From 53375103eae8dd6b717b170c69b72ac50fa01985 Mon Sep 17 00:00:00 2001 From: Roberta Dobrescu Date: Sat, 28 Mar 2015 21:43:08 +0200 Subject: [PATCH 0001/1163] tools: iio: Add iio targets in tools Makefile This patch adds targets for building and cleaning iio tools to tools/Makefile. To build iio tools from the toplevel kernel directory one should call: $ make -C tools iio and for cleaning it $ make -C tools iio_clean Signed-off-by: Roberta Dobrescu Reviewed-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- tools/Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/Makefile b/tools/Makefile index 9a617adc6675..79463b00b81e 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -8,6 +8,7 @@ help: @echo ' cpupower - a tool for all things x86 CPU power' @echo ' firewire - the userspace part of nosy, an IEEE-1394 traffic sniffer' @echo ' hv - tools used when in Hyper-V clients' + @echo ' iio - IIO tools' @echo ' lguest - a minimal 32-bit x86 hypervisor' @echo ' perf - Linux performance measurement and analysis tool' @echo ' selftests - various kernel selftests' @@ -41,7 +42,7 @@ acpi: FORCE cpupower: FORCE $(call descend,power/$@) -cgroup firewire hv guest usb virtio vm net: FORCE +cgroup firewire hv guest usb virtio vm net iio: FORCE $(call descend,$@) liblockdep: FORCE @@ -91,7 +92,7 @@ acpi_clean: cpupower_clean: $(call descend,power/cpupower,clean) -cgroup_clean hv_clean firewire_clean lguest_clean usb_clean virtio_clean vm_clean net_clean: +cgroup_clean hv_clean firewire_clean lguest_clean usb_clean virtio_clean vm_clean net_clean iio_clean: $(call descend,$(@:_clean=),clean) liblockdep_clean: @@ -114,6 +115,6 @@ tmon_clean: clean: acpi_clean cgroup_clean cpupower_clean hv_clean firewire_clean lguest_clean \ perf_clean selftests_clean turbostat_clean usb_clean virtio_clean \ - vm_clean net_clean x86_energy_perf_policy_clean tmon_clean + vm_clean net_clean iio_clean x86_energy_perf_policy_clean tmon_clean .PHONY: FORCE From a25691c1f9674090fb66586cf4c5d60d3efdf339 Mon Sep 17 00:00:00 2001 From: Vlad Dogaru Date: Fri, 3 Apr 2015 15:03:02 +0300 Subject: [PATCH 0002/1163] iio: accel: kxcjk1013: allow using an external trigger In its present state, the driver mandates that its buffer only be triggered by one of the device's own triggers (data ready or any motion). This is not always desirable, for example because the interrupt pins may not be wired in. Patch the driver to be able to accept using an external trigger, such as one based on hrtimer. When using such a trigger, we need to ensure that the device is powered on when the buffer is started. We do that by setting setup_ops for the buffer. Signed-off-by: Vlad Dogaru Reviewed-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/accel/kxcjk-1013.c | 38 ++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c index 51da3692d561..df6f5d70fa3b 100644 --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c @@ -875,15 +875,18 @@ static int kxcjk1013_write_event_config(struct iio_dev *indio_dev, return 0; } -static int kxcjk1013_validate_trigger(struct iio_dev *indio_dev, - struct iio_trigger *trig) +static int kxcjk1013_buffer_preenable(struct iio_dev *indio_dev) { struct kxcjk1013_data *data = iio_priv(indio_dev); - if (data->dready_trig != trig && data->motion_trig != trig) - return -EINVAL; + return kxcjk1013_set_power_state(data, true); +} - return 0; +static int kxcjk1013_buffer_postdisable(struct iio_dev *indio_dev) +{ + struct kxcjk1013_data *data = iio_priv(indio_dev); + + return kxcjk1013_set_power_state(data, false); } static IIO_CONST_ATTR_SAMP_FREQ_AVAIL( @@ -935,6 +938,13 @@ static const struct iio_chan_spec kxcjk1013_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(3), }; +static const struct iio_buffer_setup_ops kxcjk1013_buffer_setup_ops = { + .preenable = kxcjk1013_buffer_preenable, + .postenable = iio_triggered_buffer_postenable, + .postdisable = kxcjk1013_buffer_postdisable, + .predisable = iio_triggered_buffer_predisable, +}; + static const struct iio_info kxcjk1013_info = { .attrs = &kxcjk1013_attrs_group, .read_raw = kxcjk1013_read_raw, @@ -943,7 +953,6 @@ static const struct iio_info kxcjk1013_info = { .write_event_value = kxcjk1013_write_event, .write_event_config = kxcjk1013_write_event_config, .read_event_config = kxcjk1013_read_event_config, - .validate_trigger = kxcjk1013_validate_trigger, .driver_module = THIS_MODULE, }; @@ -1276,16 +1285,15 @@ static int kxcjk1013_probe(struct i2c_client *client, data->motion_trig = NULL; goto err_trigger_unregister; } + } - ret = iio_triggered_buffer_setup(indio_dev, - &iio_pollfunc_store_time, - kxcjk1013_trigger_handler, - NULL); - if (ret < 0) { - dev_err(&client->dev, - "iio triggered buffer setup failed\n"); - goto err_trigger_unregister; - } + ret = iio_triggered_buffer_setup(indio_dev, + &iio_pollfunc_store_time, + kxcjk1013_trigger_handler, + &kxcjk1013_buffer_setup_ops); + if (ret < 0) { + dev_err(&client->dev, "iio triggered buffer setup failed\n"); + goto err_trigger_unregister; } ret = iio_device_register(indio_dev); From c8a8585431efba0faaf41167f8f7c27c48307ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vianney=20le=20Cl=C3=A9ment=20de=20Saint-Marcq?= Date: Mon, 30 Mar 2015 10:34:58 +0200 Subject: [PATCH 0003/1163] iio: core: Introduce IIO_CHAN_INFO_CALIBEMISSIVITY MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Contact-less IR temperature sensors measure the temperature of an object by using its thermal radiation. Surfaces with different emissivity ratios emit different amounts of energy at the same temperature. IIO_CHAN_INFO_CALIBEMISSIVITY allows the user to inform the sensor of the emissivity of the object in front of it, in order to effectively measure its temperature. A device providing such setting is Melexis's MLX90614: http://melexis.com/Assets/IR-sensor-thermometer-MLX90614-Datasheet-5152.aspx. Signed-off-by: Vianney le Clément de Saint-Marcq Cc: Arnout Vandecappelle (Essensium/Mind) Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 11 +++++++++++ drivers/iio/industrialio-core.c | 1 + include/linux/iio/iio.h | 1 + 3 files changed, 13 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index 3befcb19f414..866b4ec4aab6 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -1364,3 +1364,14 @@ Description: hwfifo_watermak_min but not equal to any of the values in this list, the driver will chose an appropriate value for the hardware fifo watermark level. + +What: /sys/bus/iio/devices/iio:deviceX/in_temp_calibemissivity +What: /sys/bus/iio/devices/iio:deviceX/in_tempX_calibemissivity +What: /sys/bus/iio/devices/iio:deviceX/in_temp_object_calibemissivity +What: /sys/bus/iio/devices/iio:deviceX/in_tempX_object_calibemissivity +KernelVersion: 4.1 +Contact: linux-iio@vger.kernel.org +Description: + The emissivity ratio of the surface in the field of view of the + contactless temperature sensor. Emissivity varies from 0 to 1, + with 1 being the emissivity of a black body. diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 4df97f650e44..7c98bc1504e6 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -128,6 +128,7 @@ static const char * const iio_chan_info_postfix[] = { [IIO_CHAN_INFO_CALIBWEIGHT] = "calibweight", [IIO_CHAN_INFO_DEBOUNCE_COUNT] = "debounce_count", [IIO_CHAN_INFO_DEBOUNCE_TIME] = "debounce_time", + [IIO_CHAN_INFO_CALIBEMISSIVITY] = "calibemissivity", }; /** diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index d86b753e9b30..b1e46ae89aa7 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -43,6 +43,7 @@ enum iio_chan_info_enum { IIO_CHAN_INFO_CALIBWEIGHT, IIO_CHAN_INFO_DEBOUNCE_COUNT, IIO_CHAN_INFO_DEBOUNCE_TIME, + IIO_CHAN_INFO_CALIBEMISSIVITY, }; enum iio_shared_by { From 5147b21a61806b0ff2c29ccb3f8bc37495d5c2ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vianney=20le=20Cl=C3=A9ment=20de=20Saint-Marcq?= Date: Mon, 30 Mar 2015 10:34:59 +0200 Subject: [PATCH 0004/1163] iio: mlx90614: Add devicetree bindings documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also introduce "melexis" as a vendor prefix for device tree bindings. Signed-off-by: Vianney le Clément de Saint-Marcq Cc: Arnout Vandecappelle (Essensium/Mind) Signed-off-by: Jonathan Cameron --- .../bindings/iio/temperature/mlx90614.txt | 15 +++++++++++++++ .../devicetree/bindings/vendor-prefixes.txt | 1 + 2 files changed, 16 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/temperature/mlx90614.txt diff --git a/Documentation/devicetree/bindings/iio/temperature/mlx90614.txt b/Documentation/devicetree/bindings/iio/temperature/mlx90614.txt new file mode 100644 index 000000000000..4c959f3b8663 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/temperature/mlx90614.txt @@ -0,0 +1,15 @@ +* Melexis MLX90614 contactless IR temperature sensor + +http://melexis.com/Infrared-Thermometer-Sensors/Infrared-Thermometer-Sensors/MLX90614-615.aspx + +Required properties: + + - compatible: should be "melexis,mlx90614" + - reg: the I2C address of the sensor + +Example: + +mlx90614@5a { + compatible = "melexis,mlx90614"; + reg = <0x5a>; +}; diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index fae26d014aaf..c8db30cc59a3 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt @@ -110,6 +110,7 @@ lltc Linear Technology Corporation marvell Marvell Technology Group Ltd. maxim Maxim Integrated Products mediatek MediaTek Inc. +melexis Melexis N.V. merrii Merrii Technology Co., Ltd. micrel Micrel Inc. microchip Microchip Technology Inc. From fad65a8fe5b85b5039b316258c2790e773cc3502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vianney=20le=20Cl=C3=A9ment=20de=20Saint-Marcq?= Date: Mon, 30 Mar 2015 10:35:00 +0200 Subject: [PATCH 0005/1163] iio: mlx90614: Add emissivity setting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The mapping from the 16-bit EEPROM value to the decimal 0-1 range is approximate. A special case ensures 0xFFFF shows as 1.0 instead of 0.999998565. Writing to EEPROM requires an explicit erase by writing zero. In addition, it takes 20ms for the erase/write to complete. During this time no EEPROM register should be accessed. Therefore, two msleep()s are added to the write function and a mutex protects against concurrent access. Signed-off-by: Vianney le Clément de Saint-Marcq Cc: Arnout Vandecappelle (Essensium/Mind) Signed-off-by: Jonathan Cameron --- drivers/iio/temperature/mlx90614.c | 106 ++++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 3 deletions(-) diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c index a112fc9abf43..a307d8c9da89 100644 --- a/drivers/iio/temperature/mlx90614.c +++ b/drivers/iio/temperature/mlx90614.c @@ -12,12 +12,13 @@ * * (7-bit I2C slave address 0x5a, 100KHz bus speed only!) * - * TODO: sleep mode, configuration EEPROM + * TODO: sleep mode, filter configuration */ #include #include #include +#include #include @@ -53,8 +54,47 @@ struct mlx90614_data { struct i2c_client *client; + struct mutex lock; /* for EEPROM access only */ }; +/* + * Erase an address and write word. + * The mutex must be locked before calling. + */ +static s32 mlx90614_write_word(const struct i2c_client *client, u8 command, + u16 value) +{ + /* + * Note: The mlx90614 requires a PEC on writing but does not send us a + * valid PEC on reading. Hence, we cannot set I2C_CLIENT_PEC in + * i2c_client.flags. As a workaround, we use i2c_smbus_xfer here. + */ + union i2c_smbus_data data; + s32 ret; + + dev_dbg(&client->dev, "Writing 0x%x to address 0x%x", value, command); + + data.word = 0x0000; /* erase command */ + ret = i2c_smbus_xfer(client->adapter, client->addr, + client->flags | I2C_CLIENT_PEC, + I2C_SMBUS_WRITE, command, + I2C_SMBUS_WORD_DATA, &data); + if (ret < 0) + return ret; + + msleep(MLX90614_TIMING_EEPROM); + + data.word = value; /* actual write */ + ret = i2c_smbus_xfer(client->adapter, client->addr, + client->flags | I2C_CLIENT_PEC, + I2C_SMBUS_WRITE, command, + I2C_SMBUS_WORD_DATA, &data); + + msleep(MLX90614_TIMING_EEPROM); + + return ret; +} + static int mlx90614_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *channel, int *val, int *val2, long mask) @@ -97,6 +137,61 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_SCALE: *val = 20; return IIO_VAL_INT; + case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */ + mutex_lock(&data->lock); + ret = i2c_smbus_read_word_data(data->client, + MLX90614_EMISSIVITY); + mutex_unlock(&data->lock); + + if (ret < 0) + return ret; + + if (ret == 65535) { + *val = 1; + *val2 = 0; + } else { + *val = 0; + *val2 = ret * 15259; /* 1/65535 ~ 0.000015259 */ + } + return IIO_VAL_INT_PLUS_NANO; + default: + return -EINVAL; + } +} + +static int mlx90614_write_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_CALIBEMISSIVITY: /* 1/65535 / LSB */ + if (val < 0 || val2 < 0 || val > 1 || (val == 1 && val2 != 0)) + return -EINVAL; + val = val * 65535 + val2 / 15259; /* 1/65535 ~ 0.000015259 */ + + mutex_lock(&data->lock); + ret = mlx90614_write_word(data->client, MLX90614_EMISSIVITY, + val); + mutex_unlock(&data->lock); + + if (ret < 0) + return ret; + return 0; + default: + return -EINVAL; + } +} + +static int mlx90614_write_raw_get_fmt(struct iio_dev *indio_dev, + const struct iio_chan_spec const *channel, + long mask) +{ + switch (mask) { + case IIO_CHAN_INFO_CALIBEMISSIVITY: + return IIO_VAL_INT_PLUS_NANO; default: return -EINVAL; } @@ -115,7 +210,8 @@ static const struct iio_chan_spec mlx90614_channels[] = { .type = IIO_TEMP, .modified = 1, .channel2 = IIO_MOD_TEMP_OBJECT, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_CALIBEMISSIVITY), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE), }, @@ -125,7 +221,8 @@ static const struct iio_chan_spec mlx90614_channels[] = { .modified = 1, .channel = 1, .channel2 = IIO_MOD_TEMP_OBJECT, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_CALIBEMISSIVITY), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE), }, @@ -133,6 +230,8 @@ static const struct iio_chan_spec mlx90614_channels[] = { static const struct iio_info mlx90614_info = { .read_raw = mlx90614_read_raw, + .write_raw = mlx90614_write_raw, + .write_raw_get_fmt = mlx90614_write_raw_get_fmt, .driver_module = THIS_MODULE, }; @@ -166,6 +265,7 @@ static int mlx90614_probe(struct i2c_client *client, data = iio_priv(indio_dev); i2c_set_clientdata(client, indio_dev); data->client = client; + mutex_init(&data->lock); indio_dev->dev.parent = &client->dev; indio_dev->name = id->name; From eb4b07dae4d4b7915333f687675209f677f72fc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vianney=20le=20Cl=C3=A9ment=20de=20Saint-Marcq?= Date: Mon, 30 Mar 2015 10:35:01 +0200 Subject: [PATCH 0006/1163] iio: mlx90614: Add power management MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add support for system sleep and runtime power management. To wake up the device, the SDA line should be held low for at least 33ms while SCL is high. As this is not possible using the i2c API (and not supported by all i2c adapters), a GPIO connected to the SDA line is needed. The GPIO is named "wakeup" and can be specified in a device tree with the "wakeup-gpios" binding. If the wake-up GPIO is not given, disable power management for the device. Entering sleep requires an SMBus byte access, hence power management is also disabled if byte access is not supported by the adapter. Signed-off-by: Vianney le Clément de Saint-Marcq Cc: Arnout Vandecappelle (Essensium/Mind) Signed-off-by: Jonathan Cameron --- .../bindings/iio/temperature/mlx90614.txt | 9 + drivers/iio/temperature/mlx90614.c | 246 +++++++++++++++++- 2 files changed, 253 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/temperature/mlx90614.txt b/Documentation/devicetree/bindings/iio/temperature/mlx90614.txt index 4c959f3b8663..9be57b036092 100644 --- a/Documentation/devicetree/bindings/iio/temperature/mlx90614.txt +++ b/Documentation/devicetree/bindings/iio/temperature/mlx90614.txt @@ -7,9 +7,18 @@ Required properties: - compatible: should be "melexis,mlx90614" - reg: the I2C address of the sensor +Optional properties: + + - wakeup-gpios: device tree identifier of the GPIO connected to the SDA line + to hold low in order to wake up the device. In normal operation, the + GPIO is set as input and will not interfere in I2C communication. There + is no need for a GPIO driving the SCL line. If no GPIO is given, power + management is disabled. + Example: mlx90614@5a { compatible = "melexis,mlx90614"; reg = <0x5a>; + wakeup-gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>; }; diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c index a307d8c9da89..73ec7677496f 100644 --- a/drivers/iio/temperature/mlx90614.c +++ b/drivers/iio/temperature/mlx90614.c @@ -12,13 +12,24 @@ * * (7-bit I2C slave address 0x5a, 100KHz bus speed only!) * - * TODO: sleep mode, filter configuration + * To wake up from sleep mode, the SDA line must be held low while SCL is high + * for at least 33ms. This is achieved with an extra GPIO that can be connected + * directly to the SDA line. In normal operation, the GPIO is set as input and + * will not interfere in I2C communication. While the GPIO is driven low, the + * i2c adapter is locked since it cannot be used by other clients. The SCL line + * always has a pull-up so we do not need an extra GPIO to drive it high. If + * the "wakeup" GPIO is not given, power management will be disabled. + * + * TODO: filter configuration */ #include #include #include #include +#include +#include +#include #include @@ -52,9 +63,13 @@ #define MLX90614_TIMING_WAKEUP 34 /* time to hold SDA low for wake-up */ #define MLX90614_TIMING_STARTUP 250 /* time before first data after wake-up */ +#define MLX90614_AUTOSLEEP_DELAY 5000 /* default autosleep delay */ + struct mlx90614_data { struct i2c_client *client; struct mutex lock; /* for EEPROM access only */ + struct gpio_desc *wakeup_gpio; /* NULL to disable sleep/wake-up */ + unsigned long ready_timestamp; /* in jiffies */ }; /* @@ -95,6 +110,54 @@ static s32 mlx90614_write_word(const struct i2c_client *client, u8 command, return ret; } +#ifdef CONFIG_PM +/* + * If @startup is true, make sure MLX90614_TIMING_STARTUP ms have elapsed since + * the last wake-up. This is normally only needed to get a valid temperature + * reading. EEPROM access does not need such delay. + * Return 0 on success, <0 on error. + */ +static int mlx90614_power_get(struct mlx90614_data *data, bool startup) +{ + unsigned long now; + + if (!data->wakeup_gpio) + return 0; + + pm_runtime_get_sync(&data->client->dev); + + if (startup) { + now = jiffies; + if (time_before(now, data->ready_timestamp) && + msleep_interruptible(jiffies_to_msecs( + data->ready_timestamp - now)) != 0) { + pm_runtime_put_autosuspend(&data->client->dev); + return -EINTR; + } + } + + return 0; +} + +static void mlx90614_power_put(struct mlx90614_data *data) +{ + if (!data->wakeup_gpio) + return; + + pm_runtime_mark_last_busy(&data->client->dev); + pm_runtime_put_autosuspend(&data->client->dev); +} +#else +static inline int mlx90614_power_get(struct mlx90614_data *data, bool startup) +{ + return 0; +} + +static inline void mlx90614_power_put(struct mlx90614_data *data) +{ +} +#endif + static int mlx90614_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *channel, int *val, int *val2, long mask) @@ -125,7 +188,12 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev, return -EINVAL; } + ret = mlx90614_power_get(data, true); + if (ret < 0) + return ret; ret = i2c_smbus_read_word_data(data->client, cmd); + mlx90614_power_put(data); + if (ret < 0) return ret; *val = ret; @@ -138,10 +206,12 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev, *val = 20; return IIO_VAL_INT; case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */ + mlx90614_power_get(data, false); mutex_lock(&data->lock); ret = i2c_smbus_read_word_data(data->client, MLX90614_EMISSIVITY); mutex_unlock(&data->lock); + mlx90614_power_put(data); if (ret < 0) return ret; @@ -172,10 +242,12 @@ static int mlx90614_write_raw(struct iio_dev *indio_dev, return -EINVAL; val = val * 65535 + val2 / 15259; /* 1/65535 ~ 0.000015259 */ + mlx90614_power_get(data, false); mutex_lock(&data->lock); ret = mlx90614_write_word(data->client, MLX90614_EMISSIVITY, val); mutex_unlock(&data->lock); + mlx90614_power_put(data); if (ret < 0) return ret; @@ -235,6 +307,98 @@ static const struct iio_info mlx90614_info = { .driver_module = THIS_MODULE, }; +#ifdef CONFIG_PM +static int mlx90614_sleep(struct mlx90614_data *data) +{ + s32 ret; + + if (!data->wakeup_gpio) { + dev_dbg(&data->client->dev, "Sleep disabled"); + return -ENOSYS; + } + + dev_dbg(&data->client->dev, "Requesting sleep"); + + mutex_lock(&data->lock); + ret = i2c_smbus_xfer(data->client->adapter, data->client->addr, + data->client->flags | I2C_CLIENT_PEC, + I2C_SMBUS_WRITE, MLX90614_OP_SLEEP, + I2C_SMBUS_BYTE, NULL); + mutex_unlock(&data->lock); + + return ret; +} + +static int mlx90614_wakeup(struct mlx90614_data *data) +{ + if (!data->wakeup_gpio) { + dev_dbg(&data->client->dev, "Wake-up disabled"); + return -ENOSYS; + } + + dev_dbg(&data->client->dev, "Requesting wake-up"); + + i2c_lock_adapter(data->client->adapter); + gpiod_direction_output(data->wakeup_gpio, 0); + msleep(MLX90614_TIMING_WAKEUP); + gpiod_direction_input(data->wakeup_gpio); + i2c_unlock_adapter(data->client->adapter); + + data->ready_timestamp = jiffies + + msecs_to_jiffies(MLX90614_TIMING_STARTUP); + + /* + * Quirk: the i2c controller may get confused right after the + * wake-up signal has been sent. As a workaround, do a dummy read. + * If the read fails, the controller will probably be reset so that + * further reads will work. + */ + i2c_smbus_read_word_data(data->client, MLX90614_CONFIG); + + return 0; +} + +/* Return wake-up GPIO or NULL if sleep functionality should be disabled. */ +static struct gpio_desc *mlx90614_probe_wakeup(struct i2c_client *client) +{ + struct gpio_desc *gpio; + + if (!i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_BYTE)) { + dev_info(&client->dev, + "i2c adapter does not support SMBUS_WRITE_BYTE, sleep disabled"); + return NULL; + } + + gpio = devm_gpiod_get_optional(&client->dev, "wakeup", GPIOD_IN); + + if (IS_ERR(gpio)) { + dev_warn(&client->dev, + "gpio acquisition failed with error %ld, sleep disabled", + PTR_ERR(gpio)); + return NULL; + } else if (!gpio) { + dev_info(&client->dev, + "wakeup-gpio not found, sleep disabled"); + } + + return gpio; +} +#else +static inline int mlx90614_sleep(struct mlx90614_data *data) +{ + return -ENOSYS; +} +static inline int mlx90614_wakeup(struct mlx90614_data *data) +{ + return -ENOSYS; +} +static inline struct gpio_desc *mlx90614_probe_wakeup(struct i2c_client *client) +{ + return NULL; +} +#endif + /* Return 0 for single sensor, 1 for dual sensor, <0 on error. */ static int mlx90614_probe_num_ir_sensors(struct i2c_client *client) { @@ -266,6 +430,9 @@ static int mlx90614_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); data->client = client; mutex_init(&data->lock); + data->wakeup_gpio = mlx90614_probe_wakeup(client); + + mlx90614_wakeup(data); indio_dev->dev.parent = &client->dev; indio_dev->name = id->name; @@ -288,12 +455,30 @@ static int mlx90614_probe(struct i2c_client *client, return ret; } + if (data->wakeup_gpio) { + pm_runtime_set_autosuspend_delay(&client->dev, + MLX90614_AUTOSLEEP_DELAY); + pm_runtime_use_autosuspend(&client->dev); + pm_runtime_set_active(&client->dev); + pm_runtime_enable(&client->dev); + } + return iio_device_register(indio_dev); } static int mlx90614_remove(struct i2c_client *client) { - iio_device_unregister(i2c_get_clientdata(client)); + struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct mlx90614_data *data = iio_priv(indio_dev); + + iio_device_unregister(indio_dev); + + if (data->wakeup_gpio) { + pm_runtime_disable(&client->dev); + if (!pm_runtime_status_suspended(&client->dev)) + mlx90614_sleep(data); + pm_runtime_set_suspended(&client->dev); + } return 0; } @@ -304,10 +489,67 @@ static const struct i2c_device_id mlx90614_id[] = { }; MODULE_DEVICE_TABLE(i2c, mlx90614_id); +#ifdef CONFIG_PM_SLEEP +static int mlx90614_pm_suspend(struct device *dev) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); + struct mlx90614_data *data = iio_priv(indio_dev); + + if (data->wakeup_gpio && pm_runtime_active(dev)) + return mlx90614_sleep(data); + + return 0; +} + +static int mlx90614_pm_resume(struct device *dev) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); + struct mlx90614_data *data = iio_priv(indio_dev); + int err; + + if (data->wakeup_gpio) { + err = mlx90614_wakeup(data); + if (err < 0) + return err; + + pm_runtime_disable(dev); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + } + + return 0; +} +#endif + +#ifdef CONFIG_PM +static int mlx90614_pm_runtime_suspend(struct device *dev) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); + struct mlx90614_data *data = iio_priv(indio_dev); + + return mlx90614_sleep(data); +} + +static int mlx90614_pm_runtime_resume(struct device *dev) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); + struct mlx90614_data *data = iio_priv(indio_dev); + + return mlx90614_wakeup(data); +} +#endif + +static const struct dev_pm_ops mlx90614_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(mlx90614_pm_suspend, mlx90614_pm_resume) + SET_RUNTIME_PM_OPS(mlx90614_pm_runtime_suspend, + mlx90614_pm_runtime_resume, NULL) +}; + static struct i2c_driver mlx90614_driver = { .driver = { .name = "mlx90614", .owner = THIS_MODULE, + .pm = &mlx90614_pm_ops, }, .probe = mlx90614_probe, .remove = mlx90614_remove, From d02e0f8f62f786e9291caf4633e20724c2ab7f99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vianney=20le=20Cl=C3=A9ment=20de=20Saint-Marcq?= Date: Mon, 30 Mar 2015 10:35:02 +0200 Subject: [PATCH 0007/1163] iio: mlx90614: Check for errors in read values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The device uses the MSB of the returned temperature value as an error flag. Return a read error when this bit is set. Signed-off-by: Vianney le Clément de Saint-Marcq Cc: Arnout Vandecappelle (Essensium/Mind) Signed-off-by: Jonathan Cameron --- drivers/iio/temperature/mlx90614.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c index 73ec7677496f..06b7b9677982 100644 --- a/drivers/iio/temperature/mlx90614.c +++ b/drivers/iio/temperature/mlx90614.c @@ -196,6 +196,11 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev, if (ret < 0) return ret; + + /* MSB is an error flag */ + if (ret & 0x8000) + return -EIO; + *val = ret; return IIO_VAL_INT; case IIO_CHAN_INFO_OFFSET: From dee1f55057aeb61839f985b2cf7fff82789335d5 Mon Sep 17 00:00:00 2001 From: Vignesh R Date: Tue, 31 Mar 2015 16:42:36 +0530 Subject: [PATCH 0008/1163] iio: adc: ti_am335x_adc: refactor DT parsing into a function Refactor DT parsing into a separate function from probe() to help addition of more DT parameters later. No functional changes. Signed-off-by: Vignesh R Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ti_am335x_adc.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index a0e7161f040c..42e444044ea5 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c @@ -395,16 +395,30 @@ static const struct iio_info tiadc_info = { .driver_module = THIS_MODULE, }; +static int tiadc_parse_dt(struct platform_device *pdev, + struct tiadc_device *adc_dev) +{ + struct device_node *node = pdev->dev.of_node; + struct property *prop; + const __be32 *cur; + int channels = 0; + u32 val; + + of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) { + adc_dev->channel_line[channels] = val; + channels++; + } + + adc_dev->channels = channels; + return 0; +} + static int tiadc_probe(struct platform_device *pdev) { struct iio_dev *indio_dev; struct tiadc_device *adc_dev; struct device_node *node = pdev->dev.of_node; - struct property *prop; - const __be32 *cur; int err; - u32 val; - int channels = 0; if (!node) { dev_err(&pdev->dev, "Could not find valid DT data.\n"); @@ -420,12 +434,7 @@ static int tiadc_probe(struct platform_device *pdev) adc_dev = iio_priv(indio_dev); adc_dev->mfd_tscadc = ti_tscadc_dev_get(pdev); - - of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) { - adc_dev->channel_line[channels] = val; - channels++; - } - adc_dev->channels = channels; + tiadc_parse_dt(pdev, adc_dev); indio_dev->dev.parent = &pdev->dev; indio_dev->name = dev_name(&pdev->dev); From abda2b4f21249a079b83ed3356937fa6d9faa789 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Thu, 9 Apr 2015 17:17:47 +0300 Subject: [PATCH 0009/1163] iio: light: ltr501: Fix alignment to match open parenthesis This makes ltr501 code consistent with the coding style adopted for the new drivers added to IIO. We prepare the path for adding support for LTR559 chip. Reported by checkpatch.pl Signed-off-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/light/ltr501.c | 42 +++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c index 78b87839c4b9..f208c9871107 100644 --- a/drivers/iio/light/ltr501.c +++ b/drivers/iio/light/ltr501.c @@ -58,7 +58,7 @@ static int ltr501_drdy(struct ltr501_data *data, u8 drdy_mask) while (tries--) { ret = i2c_smbus_read_byte_data(data->client, - LTR501_ALS_PS_STATUS); + LTR501_ALS_PS_STATUS); if (ret < 0) return ret; if ((ret & drdy_mask) == drdy_mask) @@ -77,7 +77,8 @@ static int ltr501_read_als(struct ltr501_data *data, __le16 buf[2]) return ret; /* always read both ALS channels in given order */ return i2c_smbus_read_i2c_block_data(data->client, - LTR501_ALS_DATA1, 2 * sizeof(__le16), (u8 *) buf); + LTR501_ALS_DATA1, + 2 * sizeof(__le16), (u8 *)buf); } static int ltr501_read_ps(struct ltr501_data *data) @@ -107,7 +108,7 @@ static int ltr501_read_ps(struct ltr501_data *data) static const struct iio_chan_spec ltr501_channels[] = { LTR501_INTENSITY_CHANNEL(0, LTR501_ALS_DATA0, IIO_MOD_LIGHT_BOTH, 0), LTR501_INTENSITY_CHANNEL(1, LTR501_ALS_DATA1, IIO_MOD_LIGHT_IR, - BIT(IIO_CHAN_INFO_SCALE)), + BIT(IIO_CHAN_INFO_SCALE)), { .type = IIO_PROXIMITY, .address = LTR501_PS_DATA, @@ -129,8 +130,8 @@ static const int ltr501_ps_gain[4][2] = { }; static int ltr501_read_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int *val, int *val2, long mask) + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) { struct ltr501_data *data = iio_priv(indio_dev); __le16 buf[2]; @@ -149,7 +150,7 @@ static int ltr501_read_raw(struct iio_dev *indio_dev, if (ret < 0) return ret; *val = le16_to_cpu(chan->address == LTR501_ALS_DATA1 ? - buf[0] : buf[1]); + buf[0] : buf[1]); return IIO_VAL_INT; case IIO_PROXIMITY: mutex_lock(&data->lock_ps); @@ -199,8 +200,8 @@ static int ltr501_get_ps_gain_index(int val, int val2) } static int ltr501_write_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int val, int val2, long mask) + struct iio_chan_spec const *chan, + int val, int val2, long mask) { struct ltr501_data *data = iio_priv(indio_dev); int i; @@ -219,7 +220,8 @@ static int ltr501_write_raw(struct iio_dev *indio_dev, else return -EINVAL; return i2c_smbus_write_byte_data(data->client, - LTR501_ALS_CONTR, data->als_contr); + LTR501_ALS_CONTR, + data->als_contr); case IIO_PROXIMITY: i = ltr501_get_ps_gain_index(val, val2); if (i < 0) @@ -227,7 +229,8 @@ static int ltr501_write_raw(struct iio_dev *indio_dev, data->ps_contr &= ~LTR501_CONTR_PS_GAIN_MASK; data->ps_contr |= i << LTR501_CONTR_PS_GAIN_SHIFT; return i2c_smbus_write_byte_data(data->client, - LTR501_PS_CONTR, data->ps_contr); + LTR501_PS_CONTR, + data->ps_contr); default: return -EINVAL; } @@ -279,7 +282,7 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p) /* figure out which data needs to be ready */ if (test_bit(0, indio_dev->active_scan_mask) || - test_bit(1, indio_dev->active_scan_mask)) + test_bit(1, indio_dev->active_scan_mask)) mask |= LTR501_STATUS_ALS_RDY; if (test_bit(2, indio_dev->active_scan_mask)) mask |= LTR501_STATUS_PS_RDY; @@ -290,7 +293,9 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p) if (mask & LTR501_STATUS_ALS_RDY) { ret = i2c_smbus_read_i2c_block_data(data->client, - LTR501_ALS_DATA1, sizeof(als_buf), (u8 *) als_buf); + LTR501_ALS_DATA1, + sizeof(als_buf), + (u8 *)als_buf); if (ret < 0) return ret; if (test_bit(0, indio_dev->active_scan_mask)) @@ -306,8 +311,7 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p) buf[j++] = ret & LTR501_PS_DATA_MASK; } - iio_push_to_buffers_with_timestamp(indio_dev, buf, - iio_get_time_ns()); + iio_push_to_buffers_with_timestamp(indio_dev, buf, iio_get_time_ns()); done: iio_trigger_notify_done(indio_dev->trig); @@ -330,7 +334,7 @@ static int ltr501_init(struct ltr501_data *data) data->ps_contr = ret | LTR501_CONTR_ACTIVE; return ltr501_write_contr(data->client, data->als_contr, - data->ps_contr); + data->ps_contr); } static int ltr501_powerdown(struct ltr501_data *data) @@ -341,7 +345,7 @@ static int ltr501_powerdown(struct ltr501_data *data) } static int ltr501_probe(struct i2c_client *client, - const struct i2c_device_id *id) + const struct i2c_device_id *id) { struct ltr501_data *data; struct iio_dev *indio_dev; @@ -375,7 +379,7 @@ static int ltr501_probe(struct i2c_client *client, return ret; ret = iio_triggered_buffer_setup(indio_dev, NULL, - ltr501_trigger_handler, NULL); + ltr501_trigger_handler, NULL); if (ret) goto powerdown_on_error; @@ -407,14 +411,14 @@ static int ltr501_remove(struct i2c_client *client) static int ltr501_suspend(struct device *dev) { struct ltr501_data *data = iio_priv(i2c_get_clientdata( - to_i2c_client(dev))); + to_i2c_client(dev))); return ltr501_powerdown(data); } static int ltr501_resume(struct device *dev) { struct ltr501_data *data = iio_priv(i2c_get_clientdata( - to_i2c_client(dev))); + to_i2c_client(dev))); return ltr501_write_contr(data->client, data->als_contr, data->ps_contr); From 7840ffee97842132f6a7f170ca609764551f7de2 Mon Sep 17 00:00:00 2001 From: Vlad Dogaru Date: Fri, 3 Apr 2015 15:47:29 +0300 Subject: [PATCH 0010/1163] iio: sx9500: add power management Signed-off-by: Vlad Dogaru Signed-off-by: Jonathan Cameron --- drivers/iio/proximity/sx9500.c | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c index fa40f6d0ca39..d2c52f9da937 100644 --- a/drivers/iio/proximity/sx9500.c +++ b/drivers/iio/proximity/sx9500.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -89,6 +90,8 @@ struct sx9500_data { bool event_enabled[SX9500_NUM_CHANNELS]; bool trigger_enabled; u16 *buffer; + /* Remember enabled channels and sample rate during suspend. */ + unsigned int suspend_ctrl0; }; static const struct iio_event_spec sx9500_events[] = { @@ -720,6 +723,49 @@ static int sx9500_remove(struct i2c_client *client) return 0; } +#ifdef CONFIG_PM_SLEEP +static int sx9500_suspend(struct device *dev) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); + struct sx9500_data *data = iio_priv(indio_dev); + int ret; + + mutex_lock(&data->mutex); + ret = regmap_read(data->regmap, SX9500_REG_PROX_CTRL0, + &data->suspend_ctrl0); + if (ret < 0) + goto out; + + /* + * Scan period doesn't matter because when all the sensors are + * deactivated the device is in sleep mode. + */ + ret = regmap_write(data->regmap, SX9500_REG_PROX_CTRL0, 0); + +out: + mutex_unlock(&data->mutex); + return ret; +} + +static int sx9500_resume(struct device *dev) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); + struct sx9500_data *data = iio_priv(indio_dev); + int ret; + + mutex_lock(&data->mutex); + ret = regmap_write(data->regmap, SX9500_REG_PROX_CTRL0, + data->suspend_ctrl0); + mutex_unlock(&data->mutex); + + return ret; +} +#endif /* CONFIG_PM_SLEEP */ + +static const struct dev_pm_ops sx9500_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(sx9500_suspend, sx9500_resume) +}; + static const struct acpi_device_id sx9500_acpi_match[] = { {"SSX9500", 0}, { }, @@ -736,6 +782,7 @@ static struct i2c_driver sx9500_driver = { .driver = { .name = SX9500_DRIVER_NAME, .acpi_match_table = ACPI_PTR(sx9500_acpi_match), + .pm = &sx9500_pm_ops, }, .probe = sx9500_probe, .remove = sx9500_remove, From 63de9f92cc35212c4fbf0caf6cb9d8cabe488214 Mon Sep 17 00:00:00 2001 From: Vlad Dogaru Date: Fri, 3 Apr 2015 15:47:31 +0300 Subject: [PATCH 0011/1163] iio: sx9500: rename GPIO interrupt pin Signed-off-by: Vlad Dogaru Signed-off-by: Jonathan Cameron --- drivers/iio/proximity/sx9500.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c index d2c52f9da937..c3d5316e696b 100644 --- a/drivers/iio/proximity/sx9500.c +++ b/drivers/iio/proximity/sx9500.c @@ -30,7 +30,8 @@ #define SX9500_DRIVER_NAME "sx9500" #define SX9500_IRQ_NAME "sx9500_event" -#define SX9500_GPIO_NAME "sx9500_gpio" + +#define SX9500_GPIO_NAME "interrupt" /* Register definitions. */ #define SX9500_REG_IRQ_SRC 0x00 From a40c0ac108f4802a47c27c734569c1c371bded5f Mon Sep 17 00:00:00 2001 From: Vlad Dogaru Date: Fri, 3 Apr 2015 15:47:34 +0300 Subject: [PATCH 0012/1163] iio: sx9500: fix formatting Signed-off-by: Vlad Dogaru Signed-off-by: Jonathan Cameron --- drivers/iio/proximity/sx9500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c index c3d5316e696b..c6cb7f927018 100644 --- a/drivers/iio/proximity/sx9500.c +++ b/drivers/iio/proximity/sx9500.c @@ -775,7 +775,7 @@ MODULE_DEVICE_TABLE(acpi, sx9500_acpi_match); static const struct i2c_device_id sx9500_id[] = { {"sx9500", 0}, - {} + { }, }; MODULE_DEVICE_TABLE(i2c, sx9500_id); From 2f2c96338afc9f90aa5a0fca04ece1a5c389ee31 Mon Sep 17 00:00:00 2001 From: Kuppuswamy Sathyanarayanan Date: Fri, 17 Apr 2015 22:15:10 -0700 Subject: [PATCH 0013/1163] iio: ltr501: Add regmap support. Added regmap support. It will be useful to handle bitwise updates to als & ps control registers. Signed-off-by: Kuppuswamy Sathyanarayanan Signed-off-by: Jonathan Cameron --- drivers/iio/light/ltr501.c | 129 ++++++++++++++++++++++++------------- 1 file changed, 86 insertions(+), 43 deletions(-) diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c index f208c9871107..e2f73547fdc5 100644 --- a/drivers/iio/light/ltr501.c +++ b/drivers/iio/light/ltr501.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -33,6 +34,7 @@ #define LTR501_ALS_DATA0 0x8a /* 16-bit, little endian */ #define LTR501_ALS_PS_STATUS 0x8c #define LTR501_PS_DATA 0x8d /* 16-bit, little endian */ +#define LTR501_MAX_REG 0x9f #define LTR501_ALS_CONTR_SW_RESET BIT(2) #define LTR501_CONTR_PS_GAIN_MASK (BIT(3) | BIT(2)) @@ -45,23 +47,25 @@ #define LTR501_PS_DATA_MASK 0x7ff +#define LTR501_REGMAP_NAME "ltr501_regmap" + struct ltr501_data { struct i2c_client *client; struct mutex lock_als, lock_ps; u8 als_contr, ps_contr; + struct regmap *regmap; }; static int ltr501_drdy(struct ltr501_data *data, u8 drdy_mask) { int tries = 100; - int ret; + int ret, status; while (tries--) { - ret = i2c_smbus_read_byte_data(data->client, - LTR501_ALS_PS_STATUS); + ret = regmap_read(data->regmap, LTR501_ALS_PS_STATUS, &status); if (ret < 0) return ret; - if ((ret & drdy_mask) == drdy_mask) + if ((status & drdy_mask) == drdy_mask) return 0; msleep(25); } @@ -72,21 +76,30 @@ static int ltr501_drdy(struct ltr501_data *data, u8 drdy_mask) static int ltr501_read_als(struct ltr501_data *data, __le16 buf[2]) { - int ret = ltr501_drdy(data, LTR501_STATUS_ALS_RDY); + int ret; + + ret = ltr501_drdy(data, LTR501_STATUS_ALS_RDY); if (ret < 0) return ret; /* always read both ALS channels in given order */ - return i2c_smbus_read_i2c_block_data(data->client, - LTR501_ALS_DATA1, - 2 * sizeof(__le16), (u8 *)buf); + return regmap_bulk_read(data->regmap, LTR501_ALS_DATA1, + buf, 2 * sizeof(__le16)); } static int ltr501_read_ps(struct ltr501_data *data) { - int ret = ltr501_drdy(data, LTR501_STATUS_PS_RDY); + int ret, status; + + ret = ltr501_drdy(data, LTR501_STATUS_PS_RDY); if (ret < 0) return ret; - return i2c_smbus_read_word_data(data->client, LTR501_PS_DATA); + + ret = regmap_bulk_read(data->regmap, LTR501_PS_DATA, + &status, 2); + if (ret < 0) + return ret; + + return status; } #define LTR501_INTENSITY_CHANNEL(_idx, _addr, _mod, _shared) { \ @@ -170,11 +183,10 @@ static int ltr501_read_raw(struct iio_dev *indio_dev, *val = 0; *val2 = 5000; return IIO_VAL_INT_PLUS_MICRO; - } else { - *val = 1; - *val2 = 0; - return IIO_VAL_INT; } + *val = 1; + *val2 = 0; + return IIO_VAL_INT; case IIO_PROXIMITY: i = (data->ps_contr & LTR501_CONTR_PS_GAIN_MASK) >> LTR501_CONTR_PS_GAIN_SHIFT; @@ -219,18 +231,18 @@ static int ltr501_write_raw(struct iio_dev *indio_dev, data->als_contr &= ~LTR501_CONTR_ALS_GAIN_MASK; else return -EINVAL; - return i2c_smbus_write_byte_data(data->client, - LTR501_ALS_CONTR, - data->als_contr); + + return regmap_write(data->regmap, LTR501_ALS_CONTR, + data->als_contr); case IIO_PROXIMITY: i = ltr501_get_ps_gain_index(val, val2); if (i < 0) return -EINVAL; data->ps_contr &= ~LTR501_CONTR_PS_GAIN_MASK; data->ps_contr |= i << LTR501_CONTR_PS_GAIN_SHIFT; - return i2c_smbus_write_byte_data(data->client, - LTR501_PS_CONTR, - data->ps_contr); + + return regmap_write(data->regmap, LTR501_PS_CONTR, + data->ps_contr); default: return -EINVAL; } @@ -258,13 +270,15 @@ static const struct iio_info ltr501_info = { .driver_module = THIS_MODULE, }; -static int ltr501_write_contr(struct i2c_client *client, u8 als_val, u8 ps_val) +static int ltr501_write_contr(struct ltr501_data *data, u8 als_val, u8 ps_val) { - int ret = i2c_smbus_write_byte_data(client, LTR501_ALS_CONTR, als_val); + int ret; + + ret = regmap_write(data->regmap, LTR501_ALS_CONTR, als_val); if (ret < 0) return ret; - return i2c_smbus_write_byte_data(client, LTR501_PS_CONTR, ps_val); + return regmap_write(data->regmap, LTR501_PS_CONTR, ps_val); } static irqreturn_t ltr501_trigger_handler(int irq, void *p) @@ -276,7 +290,7 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p) __le16 als_buf[2]; u8 mask = 0; int j = 0; - int ret; + int ret, psdata; memset(buf, 0, sizeof(buf)); @@ -292,10 +306,8 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p) goto done; if (mask & LTR501_STATUS_ALS_RDY) { - ret = i2c_smbus_read_i2c_block_data(data->client, - LTR501_ALS_DATA1, - sizeof(als_buf), - (u8 *)als_buf); + ret = regmap_bulk_read(data->regmap, LTR501_ALS_DATA1, + (u8 *)als_buf, sizeof(als_buf)); if (ret < 0) return ret; if (test_bit(0, indio_dev->active_scan_mask)) @@ -305,10 +317,11 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p) } if (mask & LTR501_STATUS_PS_RDY) { - ret = i2c_smbus_read_word_data(data->client, LTR501_PS_DATA); + ret = regmap_bulk_read(data->regmap, LTR501_PS_DATA, + &psdata, 2); if (ret < 0) goto done; - buf[j++] = ret & LTR501_PS_DATA_MASK; + buf[j++] = psdata & LTR501_PS_DATA_MASK; } iio_push_to_buffers_with_timestamp(indio_dev, buf, iio_get_time_ns()); @@ -321,26 +334,48 @@ done: static int ltr501_init(struct ltr501_data *data) { - int ret; + int ret, status; - ret = i2c_smbus_read_byte_data(data->client, LTR501_ALS_CONTR); + ret = regmap_read(data->regmap, LTR501_ALS_CONTR, &status); if (ret < 0) return ret; - data->als_contr = ret | LTR501_CONTR_ACTIVE; - ret = i2c_smbus_read_byte_data(data->client, LTR501_PS_CONTR); + data->als_contr = status | LTR501_CONTR_ACTIVE; + + ret = regmap_read(data->regmap, LTR501_PS_CONTR, &status); if (ret < 0) return ret; - data->ps_contr = ret | LTR501_CONTR_ACTIVE; - return ltr501_write_contr(data->client, data->als_contr, - data->ps_contr); + data->ps_contr = status | LTR501_CONTR_ACTIVE; + + return ltr501_write_contr(data, data->als_contr, data->ps_contr); } +static bool ltr501_is_volatile_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case LTR501_ALS_DATA1: + case LTR501_ALS_DATA0: + case LTR501_ALS_PS_STATUS: + case LTR501_PS_DATA: + return true; + default: + return false; + } +} + +static struct regmap_config ltr501_regmap_config = { + .name = LTR501_REGMAP_NAME, + .reg_bits = 8, + .val_bits = 8, + .max_register = LTR501_MAX_REG, + .cache_type = REGCACHE_RBTREE, + .volatile_reg = ltr501_is_volatile_reg, +}; + static int ltr501_powerdown(struct ltr501_data *data) { - return ltr501_write_contr(data->client, - data->als_contr & ~LTR501_CONTR_ACTIVE, + return ltr501_write_contr(data, data->als_contr & ~LTR501_CONTR_ACTIVE, data->ps_contr & ~LTR501_CONTR_ACTIVE); } @@ -349,22 +384,30 @@ static int ltr501_probe(struct i2c_client *client, { struct ltr501_data *data; struct iio_dev *indio_dev; - int ret; + struct regmap *regmap; + int ret, partid; indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); if (!indio_dev) return -ENOMEM; + regmap = devm_regmap_init_i2c(client, <r501_regmap_config); + if (IS_ERR(regmap)) { + dev_err(&client->dev, "Regmap initialization failed.\n"); + return PTR_ERR(regmap); + } + data = iio_priv(indio_dev); i2c_set_clientdata(client, indio_dev); data->client = client; + data->regmap = regmap; mutex_init(&data->lock_als); mutex_init(&data->lock_ps); - ret = i2c_smbus_read_byte_data(data->client, LTR501_PART_ID); + ret = regmap_read(data->regmap, LTR501_PART_ID, &partid); if (ret < 0) return ret; - if ((ret >> 4) != 0x8) + if ((partid >> 4) != 0x8) return -ENODEV; indio_dev->dev.parent = &client->dev; @@ -420,7 +463,7 @@ static int ltr501_resume(struct device *dev) struct ltr501_data *data = iio_priv(i2c_get_clientdata( to_i2c_client(dev))); - return ltr501_write_contr(data->client, data->als_contr, + return ltr501_write_contr(data, data->als_contr, data->ps_contr); } #endif From 6069f47f08ea670e28ae709c645e308e98636d6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vianney=20le=20Cl=C3=A9ment=20de=20Saint-Marcq?= Date: Fri, 17 Apr 2015 16:05:35 +0200 Subject: [PATCH 0014/1163] iio: mlx90614: Fix duplicate const warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix a typo triggering a duplicate const warning on some compilers. Signed-off-by: Vianney le Clément de Saint-Marcq Cc: Arnout Vandecappelle (Essensium/Mind) Signed-off-by: Jonathan Cameron --- drivers/iio/temperature/mlx90614.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c index 06b7b9677982..b2d3b56f1260 100644 --- a/drivers/iio/temperature/mlx90614.c +++ b/drivers/iio/temperature/mlx90614.c @@ -263,7 +263,7 @@ static int mlx90614_write_raw(struct iio_dev *indio_dev, } static int mlx90614_write_raw_get_fmt(struct iio_dev *indio_dev, - const struct iio_chan_spec const *channel, + struct iio_chan_spec const *channel, long mask) { switch (mask) { From 59bd0427c01cf0172055a1b99457bee6fd75d865 Mon Sep 17 00:00:00 2001 From: Vlad Dogaru Date: Sun, 12 Apr 2015 20:09:19 +0300 Subject: [PATCH 0015/1163] iio: sx9500: optimize power usage In the interest of lowering power usage, we only activate the proximity channels and interrupts that we are currently using. For raw reads, we activate the corresponding channel and the data ready interrupt and wait for the interrupt to trigger. If no interrupt is available, we wait for the documented scan period, as specified in the datasheet. The following types of usage patterns may overlap: * raw proximity reads (need a single data ready interrupt) * trigger usage (needs data ready interrupts as long as active) * proximity events (need near/far interrupts) * triggered buffer reads (don't need any interrupts, but are usually coupled with our own trigger. To mitigate all possible patterns, we implement usage counting for all the resources used: data ready interrupts, near/far interrupts and individual channels. The device enters sleep mode as documented in the data sheet when its buffer, trigger and events are disabled, and no raw reads are currently running. Because of this new usage pattern, it is important that we give the device a chance to perform an initial compensation for all its channels at probe time. Signed-off-by: Vlad Dogaru Signed-off-by: Jonathan Cameron --- drivers/iio/proximity/sx9500.c | 360 ++++++++++++++++++++++++++++----- 1 file changed, 306 insertions(+), 54 deletions(-) diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c index c6cb7f927018..8db9d5bfecc3 100644 --- a/drivers/iio/proximity/sx9500.c +++ b/drivers/iio/proximity/sx9500.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -75,6 +76,7 @@ #define SX9500_CONVDONE_IRQ BIT(3) #define SX9500_PROXSTAT_SHIFT 4 +#define SX9500_COMPSTAT_MASK GENMASK(3, 0) #define SX9500_NUM_CHANNELS 4 @@ -93,6 +95,9 @@ struct sx9500_data { u16 *buffer; /* Remember enabled channels and sample rate during suspend. */ unsigned int suspend_ctrl0; + struct completion completion; + int data_rdy_users, close_far_users; + int channel_users[SX9500_NUM_CHANNELS]; }; static const struct iio_event_spec sx9500_events[] = { @@ -143,6 +148,10 @@ static const struct { {2, 500000}, }; +static const unsigned int sx9500_scan_period_table[] = { + 30, 60, 90, 120, 150, 200, 300, 400, +}; + static const struct regmap_range sx9500_writable_reg_ranges[] = { regmap_reg_range(SX9500_REG_IRQ_MSK, SX9500_REG_IRQ_MSK), regmap_reg_range(SX9500_REG_PROX_CTRL0, SX9500_REG_PROX_CTRL8), @@ -195,7 +204,67 @@ static const struct regmap_config sx9500_regmap_config = { .volatile_table = &sx9500_volatile_regs, }; -static int sx9500_read_proximity(struct sx9500_data *data, +static int sx9500_inc_users(struct sx9500_data *data, int *counter, + unsigned int reg, unsigned int bitmask) +{ + (*counter)++; + if (*counter != 1) + /* Bit is already active, nothing to do. */ + return 0; + + return regmap_update_bits(data->regmap, reg, bitmask, bitmask); +} + +static int sx9500_dec_users(struct sx9500_data *data, int *counter, + unsigned int reg, unsigned int bitmask) +{ + (*counter)--; + if (*counter != 0) + /* There are more users, do not deactivate. */ + return 0; + + return regmap_update_bits(data->regmap, reg, bitmask, 0); +} + +static int sx9500_inc_chan_users(struct sx9500_data *data, int chan) +{ + return sx9500_inc_users(data, &data->channel_users[chan], + SX9500_REG_PROX_CTRL0, BIT(chan)); +} + +static int sx9500_dec_chan_users(struct sx9500_data *data, int chan) +{ + return sx9500_dec_users(data, &data->channel_users[chan], + SX9500_REG_PROX_CTRL0, BIT(chan)); +} + +static int sx9500_inc_data_rdy_users(struct sx9500_data *data) +{ + return sx9500_inc_users(data, &data->data_rdy_users, + SX9500_REG_IRQ_MSK, SX9500_CONVDONE_IRQ); +} + +static int sx9500_dec_data_rdy_users(struct sx9500_data *data) +{ + return sx9500_dec_users(data, &data->data_rdy_users, + SX9500_REG_IRQ_MSK, SX9500_CONVDONE_IRQ); +} + +static int sx9500_inc_close_far_users(struct sx9500_data *data) +{ + return sx9500_inc_users(data, &data->close_far_users, + SX9500_REG_IRQ_MSK, + SX9500_CLOSE_IRQ | SX9500_FAR_IRQ); +} + +static int sx9500_dec_close_far_users(struct sx9500_data *data) +{ + return sx9500_dec_users(data, &data->close_far_users, + SX9500_REG_IRQ_MSK, + SX9500_CLOSE_IRQ | SX9500_FAR_IRQ); +} + +static int sx9500_read_prox_data(struct sx9500_data *data, const struct iio_chan_spec *chan, int *val) { @@ -215,6 +284,79 @@ static int sx9500_read_proximity(struct sx9500_data *data, return IIO_VAL_INT; } +/* + * If we have no interrupt support, we have to wait for a scan period + * after enabling a channel to get a result. + */ +static int sx9500_wait_for_sample(struct sx9500_data *data) +{ + int ret; + unsigned int val; + + ret = regmap_read(data->regmap, SX9500_REG_PROX_CTRL0, &val); + if (ret < 0) + return ret; + + val = (val & SX9500_SCAN_PERIOD_MASK) >> SX9500_SCAN_PERIOD_SHIFT; + + msleep(sx9500_scan_period_table[val]); + + return 0; +} + +static int sx9500_read_proximity(struct sx9500_data *data, + const struct iio_chan_spec *chan, + int *val) +{ + int ret; + + mutex_lock(&data->mutex); + + ret = sx9500_inc_chan_users(data, chan->channel); + if (ret < 0) + goto out; + + ret = sx9500_inc_data_rdy_users(data); + if (ret < 0) + goto out_dec_chan; + + mutex_unlock(&data->mutex); + + if (data->client->irq > 0) + ret = wait_for_completion_interruptible(&data->completion); + else + ret = sx9500_wait_for_sample(data); + + if (ret < 0) + return ret; + + mutex_lock(&data->mutex); + + ret = sx9500_read_prox_data(data, chan, val); + if (ret < 0) + goto out; + + ret = sx9500_dec_chan_users(data, chan->channel); + if (ret < 0) + goto out; + + ret = sx9500_dec_data_rdy_users(data); + if (ret < 0) + goto out; + + ret = IIO_VAL_INT; + + goto out; + +out_dec_chan: + sx9500_dec_chan_users(data, chan->channel); +out: + mutex_unlock(&data->mutex); + reinit_completion(&data->completion); + + return ret; +} + static int sx9500_read_samp_freq(struct sx9500_data *data, int *val, int *val2) { @@ -240,7 +382,6 @@ static int sx9500_read_raw(struct iio_dev *indio_dev, int *val, int *val2, long mask) { struct sx9500_data *data = iio_priv(indio_dev); - int ret; switch (chan->type) { case IIO_PROXIMITY: @@ -248,10 +389,7 @@ static int sx9500_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_RAW: if (iio_buffer_enabled(indio_dev)) return -EBUSY; - mutex_lock(&data->mutex); - ret = sx9500_read_proximity(data, chan, val); - mutex_unlock(&data->mutex); - return ret; + return sx9500_read_proximity(data, chan, val); case IIO_CHAN_INFO_SAMP_FREQ: return sx9500_read_samp_freq(data, val, val2); default: @@ -322,28 +460,16 @@ static irqreturn_t sx9500_irq_handler(int irq, void *private) return IRQ_WAKE_THREAD; } -static irqreturn_t sx9500_irq_thread_handler(int irq, void *private) +static void sx9500_push_events(struct iio_dev *indio_dev) { - struct iio_dev *indio_dev = private; - struct sx9500_data *data = iio_priv(indio_dev); int ret; unsigned int val, chan; - - mutex_lock(&data->mutex); - - ret = regmap_read(data->regmap, SX9500_REG_IRQ_SRC, &val); - if (ret < 0) { - dev_err(&data->client->dev, "i2c transfer error in irq\n"); - goto out; - } - - if (!(val & (SX9500_CLOSE_IRQ | SX9500_FAR_IRQ))) - goto out; + struct sx9500_data *data = iio_priv(indio_dev); ret = regmap_read(data->regmap, SX9500_REG_STAT, &val); if (ret < 0) { dev_err(&data->client->dev, "i2c transfer error in irq\n"); - goto out; + return; } val >>= SX9500_PROXSTAT_SHIFT; @@ -358,15 +484,34 @@ static irqreturn_t sx9500_irq_thread_handler(int irq, void *private) /* No change on this channel. */ continue; - dir = new_prox ? IIO_EV_DIR_FALLING : - IIO_EV_DIR_RISING; - ev = IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, - chan, - IIO_EV_TYPE_THRESH, - dir); + dir = new_prox ? IIO_EV_DIR_FALLING : IIO_EV_DIR_RISING; + ev = IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, chan, + IIO_EV_TYPE_THRESH, dir); iio_push_event(indio_dev, ev, iio_get_time_ns()); data->prox_stat[chan] = new_prox; } +} + +static irqreturn_t sx9500_irq_thread_handler(int irq, void *private) +{ + struct iio_dev *indio_dev = private; + struct sx9500_data *data = iio_priv(indio_dev); + int ret; + unsigned int val; + + mutex_lock(&data->mutex); + + ret = regmap_read(data->regmap, SX9500_REG_IRQ_SRC, &val); + if (ret < 0) { + dev_err(&data->client->dev, "i2c transfer error in irq\n"); + goto out; + } + + if (val & (SX9500_CLOSE_IRQ | SX9500_FAR_IRQ)) + sx9500_push_events(indio_dev); + + if (val & SX9500_CONVDONE_IRQ) + complete_all(&data->completion); out: mutex_unlock(&data->mutex); @@ -395,9 +540,7 @@ static int sx9500_write_event_config(struct iio_dev *indio_dev, int state) { struct sx9500_data *data = iio_priv(indio_dev); - int ret, i; - bool any_active = false; - unsigned int irqmask; + int ret; if (chan->type != IIO_PROXIMITY || type != IIO_EV_TYPE_THRESH || dir != IIO_EV_DIR_EITHER) @@ -405,24 +548,32 @@ static int sx9500_write_event_config(struct iio_dev *indio_dev, mutex_lock(&data->mutex); + if (state == 1) { + ret = sx9500_inc_chan_users(data, chan->channel); + if (ret < 0) + goto out_unlock; + ret = sx9500_inc_close_far_users(data); + if (ret < 0) + goto out_undo_chan; + } else { + ret = sx9500_dec_chan_users(data, chan->channel); + if (ret < 0) + goto out_unlock; + ret = sx9500_dec_close_far_users(data); + if (ret < 0) + goto out_undo_chan; + } + data->event_enabled[chan->channel] = state; + goto out_unlock; - for (i = 0; i < SX9500_NUM_CHANNELS; i++) - if (data->event_enabled[i]) { - any_active = true; - break; - } - - irqmask = SX9500_CLOSE_IRQ | SX9500_FAR_IRQ; - if (any_active) - ret = regmap_update_bits(data->regmap, SX9500_REG_IRQ_MSK, - irqmask, irqmask); +out_undo_chan: + if (state == 1) + sx9500_dec_chan_users(data, chan->channel); else - ret = regmap_update_bits(data->regmap, SX9500_REG_IRQ_MSK, - irqmask, 0); - + sx9500_inc_chan_users(data, chan->channel); +out_unlock: mutex_unlock(&data->mutex); - return ret; } @@ -473,12 +624,16 @@ static int sx9500_set_trigger_state(struct iio_trigger *trig, mutex_lock(&data->mutex); - ret = regmap_update_bits(data->regmap, SX9500_REG_IRQ_MSK, - SX9500_CONVDONE_IRQ, - state ? SX9500_CONVDONE_IRQ : 0); - if (ret == 0) - data->trigger_enabled = state; + if (state) + ret = sx9500_inc_data_rdy_users(data); + else + ret = sx9500_dec_data_rdy_users(data); + if (ret < 0) + goto out; + data->trigger_enabled = state; + +out: mutex_unlock(&data->mutex); return ret; @@ -500,7 +655,7 @@ static irqreturn_t sx9500_trigger_handler(int irq, void *private) for_each_set_bit(bit, indio_dev->active_scan_mask, indio_dev->masklength) { - ret = sx9500_read_proximity(data, &indio_dev->channels[bit], + ret = sx9500_read_prox_data(data, &indio_dev->channels[bit], &val); if (ret < 0) goto out; @@ -519,6 +674,62 @@ out: return IRQ_HANDLED; } +static int sx9500_buffer_preenable(struct iio_dev *indio_dev) +{ + struct sx9500_data *data = iio_priv(indio_dev); + int ret, i; + + mutex_lock(&data->mutex); + + for (i = 0; i < SX9500_NUM_CHANNELS; i++) + if (test_bit(i, indio_dev->active_scan_mask)) { + ret = sx9500_inc_chan_users(data, i); + if (ret) + break; + } + + if (ret) + for (i = i - 1; i >= 0; i--) + if (test_bit(i, indio_dev->active_scan_mask)) + sx9500_dec_chan_users(data, i); + + mutex_unlock(&data->mutex); + + return ret; +} + +static int sx9500_buffer_predisable(struct iio_dev *indio_dev) +{ + struct sx9500_data *data = iio_priv(indio_dev); + int ret, i; + + iio_triggered_buffer_predisable(indio_dev); + + mutex_lock(&data->mutex); + + for (i = 0; i < SX9500_NUM_CHANNELS; i++) + if (test_bit(i, indio_dev->active_scan_mask)) { + ret = sx9500_dec_chan_users(data, i); + if (ret) + break; + } + + if (ret) + for (i = i - 1; i >= 0; i--) + if (test_bit(i, indio_dev->active_scan_mask)) + sx9500_inc_chan_users(data, i); + + mutex_unlock(&data->mutex); + + return ret; +} + +static const struct iio_buffer_setup_ops sx9500_buffer_setup_ops = { + .preenable = sx9500_buffer_preenable, + .postenable = iio_triggered_buffer_postenable, + .predisable = sx9500_buffer_predisable, +}; + struct sx9500_reg_default { u8 reg; u8 def; @@ -574,11 +785,44 @@ static const struct sx9500_reg_default sx9500_default_regs[] = { }, { .reg = SX9500_REG_PROX_CTRL0, - /* Scan period: 30ms, all sensors enabled. */ - .def = 0x0f, + /* Scan period: 30ms, all sensors disabled. */ + .def = 0x00, }, }; +/* Activate all channels and perform an initial compensation. */ +static int sx9500_init_compensation(struct iio_dev *indio_dev) +{ + struct sx9500_data *data = iio_priv(indio_dev); + int i, ret; + unsigned int val; + + ret = regmap_update_bits(data->regmap, SX9500_REG_PROX_CTRL0, + GENMASK(SX9500_NUM_CHANNELS, 0), + GENMASK(SX9500_NUM_CHANNELS, 0)); + if (ret < 0) + return ret; + + for (i = 10; i >= 0; i--) { + usleep_range(10000, 20000); + ret = regmap_read(data->regmap, SX9500_REG_STAT, &val); + if (ret < 0) + goto out; + if (!(val & SX9500_COMPSTAT_MASK)) + break; + } + + if (i < 0) { + dev_err(&data->client->dev, "initial compensation timed out"); + ret = -ETIMEDOUT; + } + +out: + regmap_update_bits(data->regmap, SX9500_REG_PROX_CTRL0, + GENMASK(SX9500_NUM_CHANNELS, 0), 0); + return ret; +} + static int sx9500_init_device(struct iio_dev *indio_dev) { struct sx9500_data *data = iio_priv(indio_dev); @@ -606,6 +850,10 @@ static int sx9500_init_device(struct iio_dev *indio_dev) return ret; } + ret = sx9500_init_compensation(indio_dev); + if (ret < 0) + return ret; + return 0; } @@ -649,6 +897,7 @@ static int sx9500_probe(struct i2c_client *client, data = iio_priv(indio_dev); data->client = client; mutex_init(&data->mutex); + init_completion(&data->completion); data->trigger_enabled = false; data->regmap = devm_regmap_init_i2c(client, &sx9500_regmap_config); @@ -668,7 +917,9 @@ static int sx9500_probe(struct i2c_client *client, if (client->irq <= 0) client->irq = sx9500_gpio_probe(client, data); - if (client->irq > 0) { + if (client->irq <= 0) + dev_warn(&client->dev, "no valid irq found\n"); + else { ret = devm_request_threaded_irq(&client->dev, client->irq, sx9500_irq_handler, sx9500_irq_thread_handler, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, @@ -691,7 +942,8 @@ static int sx9500_probe(struct i2c_client *client, } ret = iio_triggered_buffer_setup(indio_dev, NULL, - sx9500_trigger_handler, NULL); + sx9500_trigger_handler, + &sx9500_buffer_setup_ops); if (ret < 0) goto out_trigger_unregister; From 821ace2929612aa1ecf49feba123e5c7130d1970 Mon Sep 17 00:00:00 2001 From: Vlad Dogaru Date: Sun, 12 Apr 2015 20:09:20 +0300 Subject: [PATCH 0016/1163] iio: sx9500: refactor GPIO interrupt code Signed-off-by: Vlad Dogaru Signed-off-by: Jonathan Cameron --- drivers/iio/proximity/sx9500.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c index 8db9d5bfecc3..1b3d894e8c69 100644 --- a/drivers/iio/proximity/sx9500.c +++ b/drivers/iio/proximity/sx9500.c @@ -32,7 +32,7 @@ #define SX9500_DRIVER_NAME "sx9500" #define SX9500_IRQ_NAME "sx9500_event" -#define SX9500_GPIO_NAME "interrupt" +#define SX9500_GPIO_INT "interrupt" /* Register definitions. */ #define SX9500_REG_IRQ_SRC 0x00 @@ -857,30 +857,24 @@ static int sx9500_init_device(struct iio_dev *indio_dev) return 0; } -static int sx9500_gpio_probe(struct i2c_client *client, - struct sx9500_data *data) +static void sx9500_gpio_probe(struct i2c_client *client, + struct sx9500_data *data) { struct device *dev; struct gpio_desc *gpio; - int ret; if (!client) - return -EINVAL; + return; dev = &client->dev; - /* data ready gpio interrupt pin */ - gpio = devm_gpiod_get_index(dev, SX9500_GPIO_NAME, 0, GPIOD_IN); - if (IS_ERR(gpio)) { - dev_err(dev, "acpi gpio get index failed\n"); - return PTR_ERR(gpio); + if (client->irq <= 0) { + gpio = devm_gpiod_get_index(dev, SX9500_GPIO_INT, 0, GPIOD_IN); + if (IS_ERR(gpio)) + dev_err(dev, "gpio get irq failed\n"); + else + client->irq = gpiod_to_irq(gpio); } - - ret = gpiod_to_irq(gpio); - - dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret); - - return ret; } static int sx9500_probe(struct i2c_client *client, @@ -914,8 +908,7 @@ static int sx9500_probe(struct i2c_client *client, indio_dev->modes = INDIO_DIRECT_MODE; i2c_set_clientdata(client, indio_dev); - if (client->irq <= 0) - client->irq = sx9500_gpio_probe(client, data); + sx9500_gpio_probe(client, data); if (client->irq <= 0) dev_warn(&client->dev, "no valid irq found\n"); From 45fd5f8e10d3b5bdff577b82db4b9dd78d4b60a3 Mon Sep 17 00:00:00 2001 From: Vlad Dogaru Date: Sun, 12 Apr 2015 20:09:21 +0300 Subject: [PATCH 0017/1163] iio: sx9500: add GPIO reset pin If a GPIO reset pin is listed in ACPI or Device Tree, use it to reset the device on initialization. Signed-off-by: Vlad Dogaru Signed-off-by: Jonathan Cameron --- drivers/iio/proximity/sx9500.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c index 1b3d894e8c69..f1e9d734b6b6 100644 --- a/drivers/iio/proximity/sx9500.c +++ b/drivers/iio/proximity/sx9500.c @@ -33,6 +33,7 @@ #define SX9500_IRQ_NAME "sx9500_event" #define SX9500_GPIO_INT "interrupt" +#define SX9500_GPIO_RESET "reset" /* Register definitions. */ #define SX9500_REG_IRQ_SRC 0x00 @@ -85,6 +86,7 @@ struct sx9500_data { struct i2c_client *client; struct iio_trigger *trig; struct regmap *regmap; + struct gpio_desc *gpiod_rst; /* * Last reading of the proximity status for each channel. We * only send an event to user space when this changes. @@ -829,6 +831,13 @@ static int sx9500_init_device(struct iio_dev *indio_dev) int ret, i; unsigned int val; + if (data->gpiod_rst) { + gpiod_set_value_cansleep(data->gpiod_rst, 0); + usleep_range(1000, 2000); + gpiod_set_value_cansleep(data->gpiod_rst, 1); + usleep_range(1000, 2000); + } + ret = regmap_write(data->regmap, SX9500_REG_IRQ_MSK, 0); if (ret < 0) return ret; @@ -875,6 +884,13 @@ static void sx9500_gpio_probe(struct i2c_client *client, else client->irq = gpiod_to_irq(gpio); } + + data->gpiod_rst = devm_gpiod_get_index(dev, SX9500_GPIO_RESET, + 0, GPIOD_OUT_HIGH); + if (IS_ERR(data->gpiod_rst)) { + dev_warn(dev, "gpio get reset pin failed\n"); + data->gpiod_rst = NULL; + } } static int sx9500_probe(struct i2c_client *client, @@ -898,8 +914,6 @@ static int sx9500_probe(struct i2c_client *client, if (IS_ERR(data->regmap)) return PTR_ERR(data->regmap); - sx9500_init_device(indio_dev); - indio_dev->dev.parent = &client->dev; indio_dev->name = SX9500_DRIVER_NAME; indio_dev->channels = sx9500_channels; @@ -910,6 +924,10 @@ static int sx9500_probe(struct i2c_client *client, sx9500_gpio_probe(client, data); + ret = sx9500_init_device(indio_dev); + if (ret < 0) + return ret; + if (client->irq <= 0) dev_warn(&client->dev, "no valid irq found\n"); else { From 6b57573bd0cd92c54a44ade46c6362b732d55a6c Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Wed, 15 Apr 2015 22:39:36 +0200 Subject: [PATCH 0018/1163] iio:tsl4531: Fix leftover TCS3472_ prefix in tsl4531 driver just cleanup, no functional change Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/light/tsl4531.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/iio/light/tsl4531.c b/drivers/iio/light/tsl4531.c index 0763b8632573..63c26e2d5d97 100644 --- a/drivers/iio/light/tsl4531.c +++ b/drivers/iio/light/tsl4531.c @@ -24,12 +24,12 @@ #define TSL4531_DRV_NAME "tsl4531" -#define TCS3472_COMMAND BIT(7) +#define TSL4531_COMMAND BIT(7) -#define TSL4531_CONTROL (TCS3472_COMMAND | 0x00) -#define TSL4531_CONFIG (TCS3472_COMMAND | 0x01) -#define TSL4531_DATA (TCS3472_COMMAND | 0x04) -#define TSL4531_ID (TCS3472_COMMAND | 0x0a) +#define TSL4531_CONTROL (TSL4531_COMMAND | 0x00) +#define TSL4531_CONFIG (TSL4531_COMMAND | 0x01) +#define TSL4531_DATA (TSL4531_COMMAND | 0x04) +#define TSL4531_ID (TSL4531_COMMAND | 0x0a) /* operating modes in control register */ #define TSL4531_MODE_POWERDOWN 0x00 From 6fa273c1aaa0ab0c22ac4b52879e6bfeea516369 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Wed, 15 Apr 2015 22:39:37 +0200 Subject: [PATCH 0019/1163] iio:tsl2563: Use tsl2563_ prefix for driver's functions just cleanup, no functional change Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/light/tsl2563.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c index 94daa9fc1247..12731d6b89ec 100644 --- a/drivers/iio/light/tsl2563.c +++ b/drivers/iio/light/tsl2563.c @@ -240,7 +240,7 @@ static int tsl2563_read_id(struct tsl2563_chip *chip, u8 *id) * convert between normalized values and HW values obtained using given * timing and gain settings. */ -static int adc_shiftbits(u8 timing) +static int tsl2563_adc_shiftbits(u8 timing) { int shift = 0; @@ -263,9 +263,9 @@ static int adc_shiftbits(u8 timing) } /* Convert a HW ADC value to normalized scale. */ -static u32 normalize_adc(u16 adc, u8 timing) +static u32 tsl2563_normalize_adc(u16 adc, u8 timing) { - return adc << adc_shiftbits(timing); + return adc << tsl2563_adc_shiftbits(timing); } static void tsl2563_wait_adc(struct tsl2563_chip *chip) @@ -350,8 +350,8 @@ static int tsl2563_get_adc(struct tsl2563_chip *chip) retry = tsl2563_adjust_gainlevel(chip, adc0); } - chip->data0 = normalize_adc(adc0, chip->gainlevel->gaintime); - chip->data1 = normalize_adc(adc1, chip->gainlevel->gaintime); + chip->data0 = tsl2563_normalize_adc(adc0, chip->gainlevel->gaintime); + chip->data1 = tsl2563_normalize_adc(adc1, chip->gainlevel->gaintime); if (!chip->int_enabled) schedule_delayed_work(&chip->poweroff_work, 5 * HZ); @@ -361,13 +361,13 @@ out: return ret; } -static inline int calib_to_sysfs(u32 calib) +static inline int tsl2563_calib_to_sysfs(u32 calib) { return (int) (((calib * CALIB_BASE_SYSFS) + CALIB_FRAC_HALF) >> CALIB_FRAC_BITS); } -static inline u32 calib_from_sysfs(int value) +static inline u32 tsl2563_calib_from_sysfs(int value) { return (((u32) value) << CALIB_FRAC_BITS) / CALIB_BASE_SYSFS; } @@ -426,7 +426,7 @@ static const struct tsl2563_lux_coeff lux_table[] = { }; /* Convert normalized, scaled ADC values to lux. */ -static unsigned int adc_to_lux(u32 adc0, u32 adc1) +static unsigned int tsl2563_adc_to_lux(u32 adc0, u32 adc1) { const struct tsl2563_lux_coeff *lp = lux_table; unsigned long ratio, lux, ch0 = adc0, ch1 = adc1; @@ -442,7 +442,7 @@ static unsigned int adc_to_lux(u32 adc0, u32 adc1) } /* Apply calibration coefficient to ADC count. */ -static u32 calib_adc(u32 adc, u32 calib) +static u32 tsl2563_calib_adc(u32 adc, u32 calib) { unsigned long scaled = adc; @@ -463,9 +463,9 @@ static int tsl2563_write_raw(struct iio_dev *indio_dev, if (mask != IIO_CHAN_INFO_CALIBSCALE) return -EINVAL; if (chan->channel2 == IIO_MOD_LIGHT_BOTH) - chip->calib0 = calib_from_sysfs(val); + chip->calib0 = tsl2563_calib_from_sysfs(val); else if (chan->channel2 == IIO_MOD_LIGHT_IR) - chip->calib1 = calib_from_sysfs(val); + chip->calib1 = tsl2563_calib_from_sysfs(val); else return -EINVAL; @@ -491,11 +491,11 @@ static int tsl2563_read_raw(struct iio_dev *indio_dev, ret = tsl2563_get_adc(chip); if (ret) goto error_ret; - calib0 = calib_adc(chip->data0, chip->calib0) * + calib0 = tsl2563_calib_adc(chip->data0, chip->calib0) * chip->cover_comp_gain; - calib1 = calib_adc(chip->data1, chip->calib1) * + calib1 = tsl2563_calib_adc(chip->data1, chip->calib1) * chip->cover_comp_gain; - *val = adc_to_lux(calib0, calib1); + *val = tsl2563_adc_to_lux(calib0, calib1); ret = IIO_VAL_INT; break; case IIO_INTENSITY: @@ -515,9 +515,9 @@ static int tsl2563_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_CALIBSCALE: if (chan->channel2 == IIO_MOD_LIGHT_BOTH) - *val = calib_to_sysfs(chip->calib0); + *val = tsl2563_calib_to_sysfs(chip->calib0); else - *val = calib_to_sysfs(chip->calib1); + *val = tsl2563_calib_to_sysfs(chip->calib1); ret = IIO_VAL_INT; break; default: @@ -750,8 +750,8 @@ static int tsl2563_probe(struct i2c_client *client, chip->high_thres = 0xffff; chip->gainlevel = tsl2563_gainlevel_table; chip->intr = TSL2563_INT_PERSIST(4); - chip->calib0 = calib_from_sysfs(CALIB_BASE_SYSFS); - chip->calib1 = calib_from_sysfs(CALIB_BASE_SYSFS); + chip->calib0 = tsl2563_calib_from_sysfs(CALIB_BASE_SYSFS); + chip->calib1 = tsl2563_calib_from_sysfs(CALIB_BASE_SYSFS); if (pdata) chip->cover_comp_gain = pdata->cover_comp_gain; From 49064b5a618df70dbe1ba58a122fd218c58d381d Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Wed, 15 Apr 2015 22:39:38 +0200 Subject: [PATCH 0020/1163] iio:tmp006: Prefix #defines with TMP006_ just cleanup, no functional change Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/temperature/tmp006.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/temperature/tmp006.c b/drivers/iio/temperature/tmp006.c index 84a0789c3d96..fcc49f89b946 100644 --- a/drivers/iio/temperature/tmp006.c +++ b/drivers/iio/temperature/tmp006.c @@ -41,8 +41,8 @@ #define TMP006_CONFIG_CR_MASK 0x0e00 #define TMP006_CONFIG_CR_SHIFT 9 -#define MANUFACTURER_MAGIC 0x5449 -#define DEVICE_MAGIC 0x0067 +#define TMP006_MANUFACTURER_MAGIC 0x5449 +#define TMP006_DEVICE_MAGIC 0x0067 struct tmp006_data { struct i2c_client *client; @@ -191,7 +191,7 @@ static bool tmp006_check_identification(struct i2c_client *client) if (did < 0) return false; - return mid == MANUFACTURER_MAGIC && did == DEVICE_MAGIC; + return mid == TMP006_MANUFACTURER_MAGIC && did == TMP006_DEVICE_MAGIC; } static int tmp006_probe(struct i2c_client *client, From 844b47027da0754e089c224c8c7d371f812320fd Mon Sep 17 00:00:00 2001 From: Kuppuswamy Sathyanarayanan Date: Sun, 19 Apr 2015 02:10:01 -0700 Subject: [PATCH 0021/1163] iio: ltr501: Add integration time support Added support to modify and read ALS integration time. Signed-off-by: Kuppuswamy Sathyanarayanan Signed-off-by: Jonathan Cameron --- drivers/iio/light/ltr501.c | 90 +++++++++++++++++++++++++++++++++++++- 1 file changed, 89 insertions(+), 1 deletion(-) diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c index e2f73547fdc5..809260402a53 100644 --- a/drivers/iio/light/ltr501.c +++ b/drivers/iio/light/ltr501.c @@ -28,6 +28,7 @@ #define LTR501_ALS_CONTR 0x80 /* ALS operation mode, SW reset */ #define LTR501_PS_CONTR 0x81 /* PS operation mode */ +#define LTR501_ALS_MEAS_RATE 0x85 /* ALS integ time, measurement rate*/ #define LTR501_PART_ID 0x86 #define LTR501_MANUFAC_ID 0x87 #define LTR501_ALS_DATA1 0x88 /* 16-bit, little endian */ @@ -49,11 +50,17 @@ #define LTR501_REGMAP_NAME "ltr501_regmap" +static const int int_time_mapping[] = {100000, 50000, 200000, 400000}; + +static const struct reg_field reg_field_it = + REG_FIELD(LTR501_ALS_MEAS_RATE, 3, 4); + struct ltr501_data { struct i2c_client *client; struct mutex lock_als, lock_ps; u8 als_contr, ps_contr; struct regmap *regmap; + struct regmap_field *reg_it; }; static int ltr501_drdy(struct ltr501_data *data, u8 drdy_mask) @@ -74,6 +81,58 @@ static int ltr501_drdy(struct ltr501_data *data, u8 drdy_mask) return -EIO; } +static int ltr501_set_it_time(struct ltr501_data *data, int it) +{ + int ret, i, index = -1, status; + + for (i = 0; i < ARRAY_SIZE(int_time_mapping); i++) { + if (int_time_mapping[i] == it) { + index = i; + break; + } + } + /* Make sure integ time index is valid */ + if (index < 0) + return -EINVAL; + + ret = regmap_read(data->regmap, LTR501_ALS_CONTR, &status); + if (ret < 0) + return ret; + + if (status & LTR501_CONTR_ALS_GAIN_MASK) { + /* + * 200 ms and 400 ms integ time can only be + * used in dynamic range 1 + */ + if (index > 1) + return -EINVAL; + } else + /* 50 ms integ time can only be used in dynamic range 2 */ + if (index == 1) + return -EINVAL; + + return regmap_field_write(data->reg_it, index); +} + +/* read int time in micro seconds */ +static int ltr501_read_it_time(struct ltr501_data *data, int *val, int *val2) +{ + int ret, index; + + ret = regmap_field_read(data->reg_it, &index); + if (ret < 0) + return ret; + + /* Make sure integ time index is valid */ + if (index < 0 || index >= ARRAY_SIZE(int_time_mapping)) + return -EINVAL; + + *val2 = int_time_mapping[index]; + *val = 0; + + return IIO_VAL_INT_PLUS_MICRO; +} + static int ltr501_read_als(struct ltr501_data *data, __le16 buf[2]) { int ret; @@ -121,7 +180,8 @@ static int ltr501_read_ps(struct ltr501_data *data) static const struct iio_chan_spec ltr501_channels[] = { LTR501_INTENSITY_CHANNEL(0, LTR501_ALS_DATA0, IIO_MOD_LIGHT_BOTH, 0), LTR501_INTENSITY_CHANNEL(1, LTR501_ALS_DATA1, IIO_MOD_LIGHT_IR, - BIT(IIO_CHAN_INFO_SCALE)), + BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_INT_TIME)), { .type = IIO_PROXIMITY, .address = LTR501_PS_DATA, @@ -196,6 +256,13 @@ static int ltr501_read_raw(struct iio_dev *indio_dev, default: return -EINVAL; } + case IIO_CHAN_INFO_INT_TIME: + switch (chan->type) { + case IIO_INTENSITY: + return ltr501_read_it_time(data, val, val2); + default: + return -EINVAL; + } } return -EINVAL; } @@ -246,16 +313,30 @@ static int ltr501_write_raw(struct iio_dev *indio_dev, default: return -EINVAL; } + case IIO_CHAN_INFO_INT_TIME: + switch (chan->type) { + case IIO_INTENSITY: + if (val != 0) + return -EINVAL; + mutex_lock(&data->lock_als); + i = ltr501_set_it_time(data, val2); + mutex_unlock(&data->lock_als); + return i; + default: + return -EINVAL; + } } return -EINVAL; } static IIO_CONST_ATTR(in_proximity_scale_available, "1 0.25 0.125 0.0625"); static IIO_CONST_ATTR(in_intensity_scale_available, "1 0.005"); +static IIO_CONST_ATTR_INT_TIME_AVAIL("0.05 0.1 0.2 0.4"); static struct attribute *ltr501_attributes[] = { &iio_const_attr_in_proximity_scale_available.dev_attr.attr, &iio_const_attr_in_intensity_scale_available.dev_attr.attr, + &iio_const_attr_integration_time_available.dev_attr.attr, NULL }; @@ -404,6 +485,13 @@ static int ltr501_probe(struct i2c_client *client, mutex_init(&data->lock_als); mutex_init(&data->lock_ps); + data->reg_it = devm_regmap_field_alloc(&client->dev, regmap, + reg_field_it); + if (IS_ERR(data->reg_it)) { + dev_err(&client->dev, "Integ time reg field init failed.\n"); + return PTR_ERR(data->reg_it); + } + ret = regmap_read(data->regmap, LTR501_PART_ID, &partid); if (ret < 0) return ret; From 7ac702b3144b635a8f7770e628d88ea1cbeda7ee Mon Sep 17 00:00:00 2001 From: Kuppuswamy Sathyanarayanan Date: Sun, 19 Apr 2015 02:10:02 -0700 Subject: [PATCH 0022/1163] iio: ltr501: Add interrupt support This patch adds interrupt support for Liteon 501 chip. Interrupt will be generated whenever ALS or proximity data exceeds values given in upper and lower threshold register settings. Signed-off-by: Kuppuswamy Sathyanarayanan Signed-off-by: Jonathan Cameron --- drivers/iio/light/ltr501.c | 319 ++++++++++++++++++++++++++++++++++++- 1 file changed, 313 insertions(+), 6 deletions(-) diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c index 809260402a53..593dbb11ec38 100644 --- a/drivers/iio/light/ltr501.c +++ b/drivers/iio/light/ltr501.c @@ -9,7 +9,7 @@ * * 7-bit I2C slave address 0x23 * - * TODO: interrupt, threshold, measurement rate, IR LED characteristics + * TODO: measurement rate, IR LED characteristics */ #include @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -35,6 +36,11 @@ #define LTR501_ALS_DATA0 0x8a /* 16-bit, little endian */ #define LTR501_ALS_PS_STATUS 0x8c #define LTR501_PS_DATA 0x8d /* 16-bit, little endian */ +#define LTR501_INTR 0x8f /* output mode, polarity, mode */ +#define LTR501_PS_THRESH_UP 0x90 /* 11 bit, ps upper threshold */ +#define LTR501_PS_THRESH_LOW 0x92 /* 11 bit, ps lower threshold */ +#define LTR501_ALS_THRESH_UP 0x97 /* 16 bit, ALS upper threshold */ +#define LTR501_ALS_THRESH_LOW 0x99 /* 16 bit, ALS lower threshold */ #define LTR501_MAX_REG 0x9f #define LTR501_ALS_CONTR_SW_RESET BIT(2) @@ -43,10 +49,14 @@ #define LTR501_CONTR_ALS_GAIN_MASK BIT(3) #define LTR501_CONTR_ACTIVE BIT(1) +#define LTR501_STATUS_ALS_INTR BIT(3) #define LTR501_STATUS_ALS_RDY BIT(2) +#define LTR501_STATUS_PS_INTR BIT(1) #define LTR501_STATUS_PS_RDY BIT(0) #define LTR501_PS_DATA_MASK 0x7ff +#define LTR501_PS_THRESH_MASK 0x7ff +#define LTR501_ALS_THRESH_MASK 0xffff #define LTR501_REGMAP_NAME "ltr501_regmap" @@ -54,6 +64,10 @@ static const int int_time_mapping[] = {100000, 50000, 200000, 400000}; static const struct reg_field reg_field_it = REG_FIELD(LTR501_ALS_MEAS_RATE, 3, 4); +static const struct reg_field reg_field_als_intr = + REG_FIELD(LTR501_INTR, 0, 0); +static const struct reg_field reg_field_ps_intr = + REG_FIELD(LTR501_INTR, 1, 1); struct ltr501_data { struct i2c_client *client; @@ -61,6 +75,8 @@ struct ltr501_data { u8 als_contr, ps_contr; struct regmap *regmap; struct regmap_field *reg_it; + struct regmap_field *reg_als_intr; + struct regmap_field *reg_ps_intr; }; static int ltr501_drdy(struct ltr501_data *data, u8 drdy_mask) @@ -161,7 +177,41 @@ static int ltr501_read_ps(struct ltr501_data *data) return status; } -#define LTR501_INTENSITY_CHANNEL(_idx, _addr, _mod, _shared) { \ +static const struct iio_event_spec ltr501_als_event_spec[] = { + { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_RISING, + .mask_separate = BIT(IIO_EV_INFO_VALUE), + }, { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_FALLING, + .mask_separate = BIT(IIO_EV_INFO_VALUE), + }, { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_EITHER, + .mask_separate = BIT(IIO_EV_INFO_ENABLE), + }, + +}; + +static const struct iio_event_spec ltr501_pxs_event_spec[] = { + { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_RISING, + .mask_separate = BIT(IIO_EV_INFO_VALUE), + }, { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_FALLING, + .mask_separate = BIT(IIO_EV_INFO_VALUE), + }, { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_EITHER, + .mask_separate = BIT(IIO_EV_INFO_ENABLE), + }, +}; + +#define LTR501_INTENSITY_CHANNEL(_idx, _addr, _mod, _shared, \ + _evspec, _evsize) { \ .type = IIO_INTENSITY, \ .modified = 1, \ .address = (_addr), \ @@ -174,14 +224,19 @@ static int ltr501_read_ps(struct ltr501_data *data) .realbits = 16, \ .storagebits = 16, \ .endianness = IIO_CPU, \ - } \ + }, \ + .event_spec = _evspec,\ + .num_event_specs = _evsize,\ } static const struct iio_chan_spec ltr501_channels[] = { - LTR501_INTENSITY_CHANNEL(0, LTR501_ALS_DATA0, IIO_MOD_LIGHT_BOTH, 0), + LTR501_INTENSITY_CHANNEL(0, LTR501_ALS_DATA0, IIO_MOD_LIGHT_BOTH, 0, + ltr501_als_event_spec, + ARRAY_SIZE(ltr501_als_event_spec)), LTR501_INTENSITY_CHANNEL(1, LTR501_ALS_DATA1, IIO_MOD_LIGHT_IR, BIT(IIO_CHAN_INFO_SCALE) | - BIT(IIO_CHAN_INFO_INT_TIME)), + BIT(IIO_CHAN_INFO_INT_TIME), + NULL, 0), { .type = IIO_PROXIMITY, .address = LTR501_PS_DATA, @@ -194,6 +249,8 @@ static const struct iio_chan_spec ltr501_channels[] = { .storagebits = 16, .endianness = IIO_CPU, }, + .event_spec = ltr501_pxs_event_spec, + .num_event_specs = ARRAY_SIZE(ltr501_pxs_event_spec), }, IIO_CHAN_SOFT_TIMESTAMP(3), }; @@ -329,6 +386,185 @@ static int ltr501_write_raw(struct iio_dev *indio_dev, return -EINVAL; } +static int ltr501_read_thresh(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) +{ + struct ltr501_data *data = iio_priv(indio_dev); + int ret, thresh_data; + + switch (chan->type) { + case IIO_INTENSITY: + switch (dir) { + case IIO_EV_DIR_RISING: + ret = regmap_bulk_read(data->regmap, + LTR501_ALS_THRESH_UP, + &thresh_data, 2); + if (ret < 0) + return ret; + *val = thresh_data & LTR501_ALS_THRESH_MASK; + return IIO_VAL_INT; + case IIO_EV_DIR_FALLING: + ret = regmap_bulk_read(data->regmap, + LTR501_ALS_THRESH_LOW, + &thresh_data, 2); + if (ret < 0) + return ret; + *val = thresh_data & LTR501_ALS_THRESH_MASK; + return IIO_VAL_INT; + default: + return -EINVAL; + } + case IIO_PROXIMITY: + switch (dir) { + case IIO_EV_DIR_RISING: + ret = regmap_bulk_read(data->regmap, + LTR501_PS_THRESH_UP, + &thresh_data, 2); + if (ret < 0) + return ret; + *val = thresh_data & LTR501_PS_THRESH_MASK; + return IIO_VAL_INT; + case IIO_EV_DIR_FALLING: + ret = regmap_bulk_read(data->regmap, + LTR501_PS_THRESH_LOW, + &thresh_data, 2); + if (ret < 0) + return ret; + *val = thresh_data & LTR501_PS_THRESH_MASK; + return IIO_VAL_INT; + default: + return -EINVAL; + } + default: + return -EINVAL; + } + + return -EINVAL; +} + +static int ltr501_write_thresh(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) +{ + struct ltr501_data *data = iio_priv(indio_dev); + int ret; + + if (val < 0) + return -EINVAL; + + switch (chan->type) { + case IIO_INTENSITY: + if (val > LTR501_ALS_THRESH_MASK) + return -EINVAL; + switch (dir) { + case IIO_EV_DIR_RISING: + mutex_lock(&data->lock_als); + ret = regmap_bulk_write(data->regmap, + LTR501_ALS_THRESH_UP, + &val, 2); + mutex_unlock(&data->lock_als); + return ret; + case IIO_EV_DIR_FALLING: + mutex_lock(&data->lock_als); + ret = regmap_bulk_write(data->regmap, + LTR501_ALS_THRESH_LOW, + &val, 2); + mutex_unlock(&data->lock_als); + return ret; + default: + return -EINVAL; + } + case IIO_PROXIMITY: + switch (dir) { + if (val > LTR501_PS_THRESH_MASK) + return -EINVAL; + case IIO_EV_DIR_RISING: + mutex_lock(&data->lock_ps); + ret = regmap_bulk_write(data->regmap, + LTR501_PS_THRESH_UP, + &val, 2); + mutex_unlock(&data->lock_ps); + return ret; + case IIO_EV_DIR_FALLING: + mutex_lock(&data->lock_ps); + ret = regmap_bulk_write(data->regmap, + LTR501_PS_THRESH_LOW, + &val, 2); + mutex_unlock(&data->lock_ps); + return ret; + default: + return -EINVAL; + } + default: + return -EINVAL; + } + + return -EINVAL; +} + +static int ltr501_read_event_config(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir) +{ + struct ltr501_data *data = iio_priv(indio_dev); + int ret, status; + + switch (chan->type) { + case IIO_INTENSITY: + ret = regmap_field_read(data->reg_als_intr, &status); + if (ret < 0) + return ret; + return status; + case IIO_PROXIMITY: + ret = regmap_field_read(data->reg_ps_intr, &status); + if (ret < 0) + return ret; + return status; + default: + return -EINVAL; + } + + return -EINVAL; +} + +static int ltr501_write_event_config(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir, int state) +{ + struct ltr501_data *data = iio_priv(indio_dev); + int ret; + + /* only 1 and 0 are valid inputs */ + if (state != 1 || state != 0) + return -EINVAL; + + switch (chan->type) { + case IIO_INTENSITY: + mutex_lock(&data->lock_als); + ret = regmap_field_write(data->reg_als_intr, state); + mutex_unlock(&data->lock_als); + return ret; + case IIO_PROXIMITY: + mutex_lock(&data->lock_ps); + ret = regmap_field_write(data->reg_ps_intr, state); + mutex_unlock(&data->lock_ps); + return ret; + default: + return -EINVAL; + } + + return -EINVAL; +} + static IIO_CONST_ATTR(in_proximity_scale_available, "1 0.25 0.125 0.0625"); static IIO_CONST_ATTR(in_intensity_scale_available, "1 0.005"); static IIO_CONST_ATTR_INT_TIME_AVAIL("0.05 0.1 0.2 0.4"); @@ -344,10 +580,21 @@ static const struct attribute_group ltr501_attribute_group = { .attrs = ltr501_attributes, }; +static const struct iio_info ltr501_info_no_irq = { + .read_raw = ltr501_read_raw, + .write_raw = ltr501_write_raw, + .attrs = <r501_attribute_group, + .driver_module = THIS_MODULE, +}; + static const struct iio_info ltr501_info = { .read_raw = ltr501_read_raw, .write_raw = ltr501_write_raw, .attrs = <r501_attribute_group, + .read_event_value = <r501_read_thresh, + .write_event_value = <r501_write_thresh, + .read_event_config = <r501_read_event_config, + .write_event_config = <r501_write_event_config, .driver_module = THIS_MODULE, }; @@ -413,6 +660,36 @@ done: return IRQ_HANDLED; } +static irqreturn_t ltr501_interrupt_handler(int irq, void *private) +{ + struct iio_dev *indio_dev = private; + struct ltr501_data *data = iio_priv(indio_dev); + int ret, status; + + ret = regmap_read(data->regmap, LTR501_ALS_PS_STATUS, &status); + if (ret < 0) { + dev_err(&data->client->dev, + "irq read int reg failed\n"); + return IRQ_HANDLED; + } + + if (status & LTR501_STATUS_ALS_INTR) + iio_push_event(indio_dev, + IIO_UNMOD_EVENT_CODE(IIO_INTENSITY, 0, + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_EITHER), + iio_get_time_ns()); + + if (status & LTR501_STATUS_PS_INTR) + iio_push_event(indio_dev, + IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, 0, + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_EITHER), + iio_get_time_ns()); + + return IRQ_HANDLED; +} + static int ltr501_init(struct ltr501_data *data) { int ret, status; @@ -492,6 +769,20 @@ static int ltr501_probe(struct i2c_client *client, return PTR_ERR(data->reg_it); } + data->reg_als_intr = devm_regmap_field_alloc(&client->dev, regmap, + reg_field_als_intr); + if (IS_ERR(data->reg_als_intr)) { + dev_err(&client->dev, "ALS intr mode reg field init failed\n"); + return PTR_ERR(data->reg_als_intr); + } + + data->reg_ps_intr = devm_regmap_field_alloc(&client->dev, regmap, + reg_field_ps_intr); + if (IS_ERR(data->reg_ps_intr)) { + dev_err(&client->dev, "PS intr mode reg field init failed.\n"); + return PTR_ERR(data->reg_ps_intr); + } + ret = regmap_read(data->regmap, LTR501_PART_ID, &partid); if (ret < 0) return ret; @@ -499,7 +790,6 @@ static int ltr501_probe(struct i2c_client *client, return -ENODEV; indio_dev->dev.parent = &client->dev; - indio_dev->info = <r501_info; indio_dev->channels = ltr501_channels; indio_dev->num_channels = ARRAY_SIZE(ltr501_channels); indio_dev->name = LTR501_DRV_NAME; @@ -509,6 +799,23 @@ static int ltr501_probe(struct i2c_client *client, if (ret < 0) return ret; + if (client->irq > 0) { + indio_dev->info = <r501_info; + ret = devm_request_threaded_irq(&client->dev, client->irq, + NULL, ltr501_interrupt_handler, + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, + "ltr501_thresh_event", + indio_dev); + if (ret) { + dev_err(&client->dev, "request irq (%d) failed\n", + client->irq); + return ret; + } + } else { + indio_dev->info = <r501_info_no_irq; + } + ret = iio_triggered_buffer_setup(indio_dev, NULL, ltr501_trigger_handler, NULL); if (ret) From eea53b4a2562e439bfc1a6d13b231f902d9b9e5f Mon Sep 17 00:00:00 2001 From: Kuppuswamy Sathyanarayanan Date: Sun, 19 Apr 2015 02:10:03 -0700 Subject: [PATCH 0023/1163] iio: ltr501: Add interrupt rate control support Added rate control support for ALS and proximity threshold interrupts.Also, Added support to modify and read ALS & proximity sensor sampling frequency. LTR-501 supports interrupt rate control using persistence register settings. Writing to persistence register would generate interrupt only if there are consecutive data values outside the threshold range. Since we don't have any existing ABI's to directly control the persistence register count, we have implemented the rate control using IIO_EV_INFO_PERIOD. _period event attribute represents the amount of time in seconds an event should be true for the device to generate the interrupt. So using _period value and device frequency, persistence count is calculated in driver using following logic. count = period / measurement_rate If the given period is not a multiple of measurement rate then we round up the value to next multiple. This patch also handles change to persistence count whenever there is change in frequency. Signed-off-by: Kuppuswamy Sathyanarayanan Signed-off-by: Jonathan Cameron --- drivers/iio/light/ltr501.c | 413 ++++++++++++++++++++++++++++++++++++- 1 file changed, 406 insertions(+), 7 deletions(-) diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c index 593dbb11ec38..d9b4536f0067 100644 --- a/drivers/iio/light/ltr501.c +++ b/drivers/iio/light/ltr501.c @@ -9,7 +9,7 @@ * * 7-bit I2C slave address 0x23 * - * TODO: measurement rate, IR LED characteristics + * TODO: IR LED characteristics */ #include @@ -29,6 +29,7 @@ #define LTR501_ALS_CONTR 0x80 /* ALS operation mode, SW reset */ #define LTR501_PS_CONTR 0x81 /* PS operation mode */ +#define LTR501_PS_MEAS_RATE 0x84 /* measurement rate*/ #define LTR501_ALS_MEAS_RATE 0x85 /* ALS integ time, measurement rate*/ #define LTR501_PART_ID 0x86 #define LTR501_MANUFAC_ID 0x87 @@ -41,6 +42,7 @@ #define LTR501_PS_THRESH_LOW 0x92 /* 11 bit, ps lower threshold */ #define LTR501_ALS_THRESH_UP 0x97 /* 16 bit, ALS upper threshold */ #define LTR501_ALS_THRESH_LOW 0x99 /* 16 bit, ALS lower threshold */ +#define LTR501_INTR_PRST 0x9e /* ps thresh, als thresh */ #define LTR501_MAX_REG 0x9f #define LTR501_ALS_CONTR_SW_RESET BIT(2) @@ -58,6 +60,9 @@ #define LTR501_PS_THRESH_MASK 0x7ff #define LTR501_ALS_THRESH_MASK 0xffff +#define LTR501_ALS_DEF_PERIOD 500000 +#define LTR501_PS_DEF_PERIOD 100000 + #define LTR501_REGMAP_NAME "ltr501_regmap" static const int int_time_mapping[] = {100000, 50000, 200000, 400000}; @@ -68,17 +73,171 @@ static const struct reg_field reg_field_als_intr = REG_FIELD(LTR501_INTR, 0, 0); static const struct reg_field reg_field_ps_intr = REG_FIELD(LTR501_INTR, 1, 1); +static const struct reg_field reg_field_als_rate = + REG_FIELD(LTR501_ALS_MEAS_RATE, 0, 2); +static const struct reg_field reg_field_ps_rate = + REG_FIELD(LTR501_PS_MEAS_RATE, 0, 3); +static const struct reg_field reg_field_als_prst = + REG_FIELD(LTR501_INTR_PRST, 0, 3); +static const struct reg_field reg_field_ps_prst = + REG_FIELD(LTR501_INTR_PRST, 4, 7); + +struct ltr501_samp_table { + int freq_val; /* repetition frequency in micro HZ*/ + int time_val; /* repetition rate in micro seconds */ +}; struct ltr501_data { struct i2c_client *client; struct mutex lock_als, lock_ps; u8 als_contr, ps_contr; + int als_period, ps_period; /* period in micro seconds */ struct regmap *regmap; struct regmap_field *reg_it; struct regmap_field *reg_als_intr; struct regmap_field *reg_ps_intr; + struct regmap_field *reg_als_rate; + struct regmap_field *reg_ps_rate; + struct regmap_field *reg_als_prst; + struct regmap_field *reg_ps_prst; }; +static const struct ltr501_samp_table ltr501_als_samp_table[] = { + {20000000, 50000}, {10000000, 100000}, + {5000000, 200000}, {2000000, 500000}, + {1000000, 1000000}, {500000, 2000000}, + {500000, 2000000}, {500000, 2000000} +}; + +static const struct ltr501_samp_table ltr501_ps_samp_table[] = { + {20000000, 50000}, {14285714, 70000}, + {10000000, 100000}, {5000000, 200000}, + {2000000, 500000}, {1000000, 1000000}, + {500000, 2000000}, {500000, 2000000}, + {500000, 2000000} +}; + +static unsigned int ltr501_match_samp_freq(const struct ltr501_samp_table *tab, + int len, int val, int val2) +{ + int i, freq; + + freq = val * 1000000 + val2; + + for (i = 0; i < len; i++) { + if (tab[i].freq_val == freq) + return i; + } + + return -EINVAL; +} + +static int ltr501_als_read_samp_freq(struct ltr501_data *data, + int *val, int *val2) +{ + int ret, i; + + ret = regmap_field_read(data->reg_als_rate, &i); + if (ret < 0) + return ret; + + if (i < 0 || i >= ARRAY_SIZE(ltr501_als_samp_table)) + return -EINVAL; + + *val = ltr501_als_samp_table[i].freq_val / 1000000; + *val2 = ltr501_als_samp_table[i].freq_val % 1000000; + + return IIO_VAL_INT_PLUS_MICRO; +} + +static int ltr501_ps_read_samp_freq(struct ltr501_data *data, + int *val, int *val2) +{ + int ret, i; + + ret = regmap_field_read(data->reg_ps_rate, &i); + if (ret < 0) + return ret; + + if (i < 0 || i >= ARRAY_SIZE(ltr501_ps_samp_table)) + return -EINVAL; + + *val = ltr501_ps_samp_table[i].freq_val / 1000000; + *val2 = ltr501_ps_samp_table[i].freq_val % 1000000; + + return IIO_VAL_INT_PLUS_MICRO; +} + +static int ltr501_als_write_samp_freq(struct ltr501_data *data, + int val, int val2) +{ + int i, ret; + + i = ltr501_match_samp_freq(ltr501_als_samp_table, + ARRAY_SIZE(ltr501_als_samp_table), + val, val2); + + if (i < 0) + return i; + + mutex_lock(&data->lock_als); + ret = regmap_field_write(data->reg_als_rate, i); + mutex_unlock(&data->lock_als); + + return ret; +} + +static int ltr501_ps_write_samp_freq(struct ltr501_data *data, + int val, int val2) +{ + int i, ret; + + i = ltr501_match_samp_freq(ltr501_ps_samp_table, + ARRAY_SIZE(ltr501_ps_samp_table), + val, val2); + + if (i < 0) + return i; + + mutex_lock(&data->lock_ps); + ret = regmap_field_write(data->reg_ps_rate, i); + mutex_unlock(&data->lock_ps); + + return ret; +} + +static int ltr501_als_read_samp_period(struct ltr501_data *data, int *val) +{ + int ret, i; + + ret = regmap_field_read(data->reg_als_rate, &i); + if (ret < 0) + return ret; + + if (i < 0 || i >= ARRAY_SIZE(ltr501_als_samp_table)) + return -EINVAL; + + *val = ltr501_als_samp_table[i].time_val; + + return IIO_VAL_INT; +} + +static int ltr501_ps_read_samp_period(struct ltr501_data *data, int *val) +{ + int ret, i; + + ret = regmap_field_read(data->reg_ps_rate, &i); + if (ret < 0) + return ret; + + if (i < 0 || i >= ARRAY_SIZE(ltr501_ps_samp_table)) + return -EINVAL; + + *val = ltr501_ps_samp_table[i].time_val; + + return IIO_VAL_INT; +} + static int ltr501_drdy(struct ltr501_data *data, u8 drdy_mask) { int tries = 100; @@ -177,6 +336,104 @@ static int ltr501_read_ps(struct ltr501_data *data) return status; } +static int ltr501_read_intr_prst(struct ltr501_data *data, + enum iio_chan_type type, + int *val2) +{ + int ret, samp_period, prst; + + switch (type) { + case IIO_INTENSITY: + ret = regmap_field_read(data->reg_als_prst, &prst); + if (ret < 0) + return ret; + + ret = ltr501_als_read_samp_period(data, &samp_period); + + if (ret < 0) + return ret; + *val2 = samp_period * prst; + return IIO_VAL_INT_PLUS_MICRO; + case IIO_PROXIMITY: + ret = regmap_field_read(data->reg_ps_prst, &prst); + if (ret < 0) + return ret; + + ret = ltr501_ps_read_samp_period(data, &samp_period); + + if (ret < 0) + return ret; + + *val2 = samp_period * prst; + return IIO_VAL_INT_PLUS_MICRO; + default: + return -EINVAL; + } + + return -EINVAL; +} + +static int ltr501_write_intr_prst(struct ltr501_data *data, + enum iio_chan_type type, + int val, int val2) +{ + int ret, samp_period, new_val; + unsigned long period; + + if (val < 0 || val2 < 0) + return -EINVAL; + + /* period in microseconds */ + period = ((val * 1000000) + val2); + + switch (type) { + case IIO_INTENSITY: + ret = ltr501_als_read_samp_period(data, &samp_period); + if (ret < 0) + return ret; + + /* period should be atleast equal to sampling period */ + if (period < samp_period) + return -EINVAL; + + new_val = DIV_ROUND_UP(period, samp_period); + if (new_val < 0 || new_val > 0x0f) + return -EINVAL; + + mutex_lock(&data->lock_als); + ret = regmap_field_write(data->reg_als_prst, new_val); + mutex_unlock(&data->lock_als); + if (ret >= 0) + data->als_period = period; + + return ret; + case IIO_PROXIMITY: + ret = ltr501_ps_read_samp_period(data, &samp_period); + if (ret < 0) + return ret; + + /* period should be atleast equal to rate */ + if (period < samp_period) + return -EINVAL; + + new_val = DIV_ROUND_UP(period, samp_period); + if (new_val < 0 || new_val > 0x0f) + return -EINVAL; + + mutex_lock(&data->lock_ps); + ret = regmap_field_write(data->reg_ps_prst, new_val); + mutex_unlock(&data->lock_ps); + if (ret >= 0) + data->ps_period = period; + + return ret; + default: + return -EINVAL; + } + + return -EINVAL; +} + static const struct iio_event_spec ltr501_als_event_spec[] = { { .type = IIO_EV_TYPE_THRESH, @@ -189,7 +446,8 @@ static const struct iio_event_spec ltr501_als_event_spec[] = { }, { .type = IIO_EV_TYPE_THRESH, .dir = IIO_EV_DIR_EITHER, - .mask_separate = BIT(IIO_EV_INFO_ENABLE), + .mask_separate = BIT(IIO_EV_INFO_ENABLE) | + BIT(IIO_EV_INFO_PERIOD), }, }; @@ -206,7 +464,8 @@ static const struct iio_event_spec ltr501_pxs_event_spec[] = { }, { .type = IIO_EV_TYPE_THRESH, .dir = IIO_EV_DIR_EITHER, - .mask_separate = BIT(IIO_EV_INFO_ENABLE), + .mask_separate = BIT(IIO_EV_INFO_ENABLE) | + BIT(IIO_EV_INFO_PERIOD), }, }; @@ -235,7 +494,8 @@ static const struct iio_chan_spec ltr501_channels[] = { ARRAY_SIZE(ltr501_als_event_spec)), LTR501_INTENSITY_CHANNEL(1, LTR501_ALS_DATA1, IIO_MOD_LIGHT_IR, BIT(IIO_CHAN_INFO_SCALE) | - BIT(IIO_CHAN_INFO_INT_TIME), + BIT(IIO_CHAN_INFO_INT_TIME) | + BIT(IIO_CHAN_INFO_SAMP_FREQ), NULL, 0), { .type = IIO_PROXIMITY, @@ -320,6 +580,15 @@ static int ltr501_read_raw(struct iio_dev *indio_dev, default: return -EINVAL; } + case IIO_CHAN_INFO_SAMP_FREQ: + switch (chan->type) { + case IIO_INTENSITY: + return ltr501_als_read_samp_freq(data, val, val2); + case IIO_PROXIMITY: + return ltr501_ps_read_samp_freq(data, val, val2); + default: + return -EINVAL; + } } return -EINVAL; } @@ -340,7 +609,7 @@ static int ltr501_write_raw(struct iio_dev *indio_dev, int val, int val2, long mask) { struct ltr501_data *data = iio_priv(indio_dev); - int i; + int i, ret, freq_val, freq_val2; if (iio_buffer_enabled(indio_dev)) return -EBUSY; @@ -382,6 +651,49 @@ static int ltr501_write_raw(struct iio_dev *indio_dev, default: return -EINVAL; } + case IIO_CHAN_INFO_SAMP_FREQ: + switch (chan->type) { + case IIO_INTENSITY: + ret = ltr501_als_read_samp_freq(data, &freq_val, + &freq_val2); + if (ret < 0) + return ret; + + ret = ltr501_als_write_samp_freq(data, val, val2); + if (ret < 0) + return ret; + + /* update persistence count when changing frequency */ + ret = ltr501_write_intr_prst(data, chan->type, + 0, data->als_period); + + if (ret < 0) + return ltr501_als_write_samp_freq(data, + freq_val, + freq_val2); + return ret; + case IIO_PROXIMITY: + ret = ltr501_ps_read_samp_freq(data, &freq_val, + &freq_val2); + if (ret < 0) + return ret; + + ret = ltr501_ps_write_samp_freq(data, val, val2); + if (ret < 0) + return ret; + + /* update persistence count when changing frequency */ + ret = ltr501_write_intr_prst(data, chan->type, + 0, data->ps_period); + + if (ret < 0) + return ltr501_ps_write_samp_freq(data, + freq_val, + freq_val2); + return ret; + default: + return -EINVAL; + } } return -EINVAL; } @@ -509,6 +821,55 @@ static int ltr501_write_thresh(struct iio_dev *indio_dev, return -EINVAL; } +static int ltr501_read_event(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; + + switch (info) { + case IIO_EV_INFO_VALUE: + return ltr501_read_thresh(indio_dev, chan, type, dir, + info, val, val2); + case IIO_EV_INFO_PERIOD: + ret = ltr501_read_intr_prst(iio_priv(indio_dev), + chan->type, val2); + *val = *val2 / 1000000; + *val2 = *val2 % 1000000; + return ret; + default: + return -EINVAL; + } + + return -EINVAL; +} + +static int ltr501_write_event(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) +{ + switch (info) { + case IIO_EV_INFO_VALUE: + if (val2 != 0) + return -EINVAL; + return ltr501_write_thresh(indio_dev, chan, type, dir, + info, val, val2); + case IIO_EV_INFO_PERIOD: + return ltr501_write_intr_prst(iio_priv(indio_dev), chan->type, + val, val2); + default: + return -EINVAL; + } + + return -EINVAL; +} + static int ltr501_read_event_config(struct iio_dev *indio_dev, const struct iio_chan_spec *chan, enum iio_event_type type, @@ -568,11 +929,13 @@ static int ltr501_write_event_config(struct iio_dev *indio_dev, static IIO_CONST_ATTR(in_proximity_scale_available, "1 0.25 0.125 0.0625"); static IIO_CONST_ATTR(in_intensity_scale_available, "1 0.005"); static IIO_CONST_ATTR_INT_TIME_AVAIL("0.05 0.1 0.2 0.4"); +static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("20 10 5 2 1 0.5"); static struct attribute *ltr501_attributes[] = { &iio_const_attr_in_proximity_scale_available.dev_attr.attr, &iio_const_attr_in_intensity_scale_available.dev_attr.attr, &iio_const_attr_integration_time_available.dev_attr.attr, + &iio_const_attr_sampling_frequency_available.dev_attr.attr, NULL }; @@ -591,8 +954,8 @@ static const struct iio_info ltr501_info = { .read_raw = ltr501_read_raw, .write_raw = ltr501_write_raw, .attrs = <r501_attribute_group, - .read_event_value = <r501_read_thresh, - .write_event_value = <r501_write_thresh, + .read_event_value = <r501_read_event, + .write_event_value = <r501_write_event, .read_event_config = <r501_read_event_config, .write_event_config = <r501_write_event_config, .driver_module = THIS_MODULE, @@ -706,6 +1069,14 @@ static int ltr501_init(struct ltr501_data *data) data->ps_contr = status | LTR501_CONTR_ACTIVE; + ret = ltr501_read_intr_prst(data, IIO_INTENSITY, &data->als_period); + if (ret < 0) + return ret; + + ret = ltr501_read_intr_prst(data, IIO_PROXIMITY, &data->ps_period); + if (ret < 0) + return ret; + return ltr501_write_contr(data, data->als_contr, data->ps_contr); } @@ -783,6 +1154,34 @@ static int ltr501_probe(struct i2c_client *client, return PTR_ERR(data->reg_ps_intr); } + data->reg_als_rate = devm_regmap_field_alloc(&client->dev, regmap, + reg_field_als_rate); + if (IS_ERR(data->reg_als_rate)) { + dev_err(&client->dev, "ALS samp rate field init failed.\n"); + return PTR_ERR(data->reg_als_rate); + } + + data->reg_ps_rate = devm_regmap_field_alloc(&client->dev, regmap, + reg_field_ps_rate); + if (IS_ERR(data->reg_ps_rate)) { + dev_err(&client->dev, "PS samp rate field init failed.\n"); + return PTR_ERR(data->reg_ps_rate); + } + + data->reg_als_prst = devm_regmap_field_alloc(&client->dev, regmap, + reg_field_als_prst); + if (IS_ERR(data->reg_als_prst)) { + dev_err(&client->dev, "ALS prst reg field init failed\n"); + return PTR_ERR(data->reg_als_prst); + } + + data->reg_ps_prst = devm_regmap_field_alloc(&client->dev, regmap, + reg_field_ps_prst); + if (IS_ERR(data->reg_ps_prst)) { + dev_err(&client->dev, "PS prst reg field init failed.\n"); + return PTR_ERR(data->reg_ps_prst); + } + ret = regmap_read(data->regmap, LTR501_PART_ID, &partid); if (ret < 0) return ret; From 772154d0ddde6b46a3866c73a16cfbfaf3053be4 Mon Sep 17 00:00:00 2001 From: Kuppuswamy Sathyanarayanan Date: Sun, 19 Apr 2015 02:10:04 -0700 Subject: [PATCH 0024/1163] iio: ltr501: Add ACPI enumeration support Added ACPI enumeration support for LTR501 chip. Signed-off-by: Kuppuswamy Sathyanarayanan Signed-off-by: Jonathan Cameron --- drivers/iio/light/ltr501.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c index d9b4536f0067..0162e8652118 100644 --- a/drivers/iio/light/ltr501.c +++ b/drivers/iio/light/ltr501.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -1264,6 +1265,12 @@ static int ltr501_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(ltr501_pm_ops, ltr501_suspend, ltr501_resume); +static const struct acpi_device_id ltr_acpi_match[] = { + {"LTER0501", 0}, + { }, +}; +MODULE_DEVICE_TABLE(acpi, ltr_acpi_match); + static const struct i2c_device_id ltr501_id[] = { { "ltr501", 0 }, { } @@ -1274,6 +1281,7 @@ static struct i2c_driver ltr501_driver = { .driver = { .name = LTR501_DRV_NAME, .pm = <r501_pm_ops, + .acpi_match_table = ACPI_PTR(ltr_acpi_match), .owner = THIS_MODULE, }, .probe = ltr501_probe, From 8592a7eefa540303dd9e60fa49340d09ca9376b4 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Tue, 21 Apr 2015 19:10:59 +0300 Subject: [PATCH 0025/1163] iio: ltr501: Add support for ltr559 chip This device is register compatible with LTR501, with a minor difference for ALS control register as showed below: ALS Control register for LTR501: 7 6 5 4 3 2 1 0 +------+------+------+------+------+------+------+------+ | | | | | | Reserved | Gain | SW | ALS Mode | | | | Reset| | +------+------+------+------+------+------+------+------+ ALS Control register for LTR559: 7 6 5 4 3 2 1 0 +------+------+------+------+------+------+------+------+ | | | | | | Reserved | Gain | SW | ALS | | | | Reset| Mode | +------+------+------+------+------+------+------+------+ We handle this difference by introducing ltr501_chip_info. Datasheet for LTR559 is at: http://optoelectronics.liteon.com/upload/download/DS86-2013-0003/S_110_LTR-559ALS-01_DS_V1.pdf Signed-off-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/light/Kconfig | 3 +- drivers/iio/light/ltr501.c | 218 +++++++++++++++++++++++++++++++------ 2 files changed, 186 insertions(+), 35 deletions(-) diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index 01a1a16ab7be..16a0ba11ab6e 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -169,7 +169,8 @@ config LTR501 select IIO_TRIGGERED_BUFFER help If you say yes here you get support for the Lite-On LTR-501ALS-01 - ambient light and proximity sensor. + ambient light and proximity sensor. This driver also supports LTR-559 + ALS/PS sensor. This driver can also be built as a module. If so, the module will be called ltr501. diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c index 0162e8652118..92da5146bc1c 100644 --- a/drivers/iio/light/ltr501.c +++ b/drivers/iio/light/ltr501.c @@ -88,9 +88,63 @@ struct ltr501_samp_table { int time_val; /* repetition rate in micro seconds */ }; +#define LTR501_RESERVED_GAIN -1 + +enum { + ltr501 = 0, + ltr559, +}; + +struct ltr501_gain { + int scale; + int uscale; +}; + +static struct ltr501_gain ltr501_als_gain_tbl[] = { + {1, 0}, + {0, 5000}, +}; + +static struct ltr501_gain ltr559_als_gain_tbl[] = { + {1, 0}, + {0, 500000}, + {0, 250000}, + {0, 125000}, + {LTR501_RESERVED_GAIN, LTR501_RESERVED_GAIN}, + {LTR501_RESERVED_GAIN, LTR501_RESERVED_GAIN}, + {0, 20000}, + {0, 10000}, +}; + +static struct ltr501_gain ltr501_ps_gain_tbl[] = { + {1, 0}, + {0, 250000}, + {0, 125000}, + {0, 62500}, +}; + +static struct ltr501_gain ltr559_ps_gain_tbl[] = { + {0, 62500}, /* x16 gain */ + {0, 31250}, /* x32 gain */ + {0, 15625}, /* bits X1 are for x64 gain */ + {0, 15624}, +}; + +struct ltr501_chip_info { + u8 partid; + struct ltr501_gain *als_gain; + int als_gain_tbl_size; + struct ltr501_gain *ps_gain; + int ps_gain_tbl_size; + u8 als_mode_active; + u8 als_gain_mask; + u8 als_gain_shift; +}; + struct ltr501_data { struct i2c_client *client; struct mutex lock_als, lock_ps; + struct ltr501_chip_info *chip_info; u8 als_contr, ps_contr; int als_period, ps_period; /* period in micro seconds */ struct regmap *regmap; @@ -516,10 +570,6 @@ static const struct iio_chan_spec ltr501_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(3), }; -static const int ltr501_ps_gain[4][2] = { - {1, 0}, {0, 250000}, {0, 125000}, {0, 62500} -}; - static int ltr501_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) @@ -557,19 +607,16 @@ static int ltr501_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_SCALE: switch (chan->type) { case IIO_INTENSITY: - if (data->als_contr & LTR501_CONTR_ALS_GAIN_MASK) { - *val = 0; - *val2 = 5000; - return IIO_VAL_INT_PLUS_MICRO; - } - *val = 1; - *val2 = 0; - return IIO_VAL_INT; + i = (data->als_contr & data->chip_info->als_gain_mask) + >> data->chip_info->als_gain_shift; + *val = data->chip_info->als_gain[i].scale; + *val2 = data->chip_info->als_gain[i].uscale; + return IIO_VAL_INT_PLUS_MICRO; case IIO_PROXIMITY: i = (data->ps_contr & LTR501_CONTR_PS_GAIN_MASK) >> LTR501_CONTR_PS_GAIN_SHIFT; - *val = ltr501_ps_gain[i][0]; - *val2 = ltr501_ps_gain[i][1]; + *val = data->chip_info->ps_gain[i].scale; + *val2 = data->chip_info->ps_gain[i].uscale; return IIO_VAL_INT_PLUS_MICRO; default: return -EINVAL; @@ -594,12 +641,13 @@ static int ltr501_read_raw(struct iio_dev *indio_dev, return -EINVAL; } -static int ltr501_get_ps_gain_index(int val, int val2) +static int ltr501_get_gain_index(struct ltr501_gain *gain, int size, + int val, int val2) { int i; - for (i = 0; i < ARRAY_SIZE(ltr501_ps_gain); i++) - if (val == ltr501_ps_gain[i][0] && val2 == ltr501_ps_gain[i][1]) + for (i = 0; i < size; i++) + if (val == gain[i].scale && val2 == gain[i].uscale) return i; return -1; @@ -611,6 +659,7 @@ static int ltr501_write_raw(struct iio_dev *indio_dev, { struct ltr501_data *data = iio_priv(indio_dev); int i, ret, freq_val, freq_val2; + struct ltr501_chip_info *info = data->chip_info; if (iio_buffer_enabled(indio_dev)) return -EBUSY; @@ -619,17 +668,21 @@ static int ltr501_write_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_SCALE: switch (chan->type) { case IIO_INTENSITY: - if (val == 0 && val2 == 5000) - data->als_contr |= LTR501_CONTR_ALS_GAIN_MASK; - else if (val == 1 && val2 == 0) - data->als_contr &= ~LTR501_CONTR_ALS_GAIN_MASK; - else + i = ltr501_get_gain_index(info->als_gain, + info->als_gain_tbl_size, + val, val2); + if (i < 0) return -EINVAL; + data->als_contr &= ~info->als_gain_mask; + data->als_contr |= i << info->als_gain_shift; + return regmap_write(data->regmap, LTR501_ALS_CONTR, data->als_contr); case IIO_PROXIMITY: - i = ltr501_get_ps_gain_index(val, val2); + i = ltr501_get_gain_index(info->ps_gain, + info->ps_gain_tbl_size, + val, val2); if (i < 0) return -EINVAL; data->ps_contr &= ~LTR501_CONTR_PS_GAIN_MASK; @@ -927,14 +980,61 @@ static int ltr501_write_event_config(struct iio_dev *indio_dev, return -EINVAL; } -static IIO_CONST_ATTR(in_proximity_scale_available, "1 0.25 0.125 0.0625"); -static IIO_CONST_ATTR(in_intensity_scale_available, "1 0.005"); +static ssize_t ltr501_show_proximity_scale_avail(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct ltr501_data *data = iio_priv(dev_to_iio_dev(dev)); + struct ltr501_chip_info *info = data->chip_info; + ssize_t len = 0; + int i; + + for (i = 0; i < info->ps_gain_tbl_size; i++) { + if (info->ps_gain[i].scale == LTR501_RESERVED_GAIN) + continue; + len += scnprintf(buf + len, PAGE_SIZE - len, "%d.%06d ", + info->ps_gain[i].scale, + info->ps_gain[i].uscale); + } + + buf[len - 1] = '\n'; + + return len; +} + +static ssize_t ltr501_show_intensity_scale_avail(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct ltr501_data *data = iio_priv(dev_to_iio_dev(dev)); + struct ltr501_chip_info *info = data->chip_info; + ssize_t len = 0; + int i; + + for (i = 0; i < info->als_gain_tbl_size; i++) { + if (info->als_gain[i].scale == LTR501_RESERVED_GAIN) + continue; + len += scnprintf(buf + len, PAGE_SIZE - len, "%d.%06d ", + info->als_gain[i].scale, + info->als_gain[i].uscale); + } + + buf[len - 1] = '\n'; + + return len; +} + static IIO_CONST_ATTR_INT_TIME_AVAIL("0.05 0.1 0.2 0.4"); static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("20 10 5 2 1 0.5"); +static IIO_DEVICE_ATTR(in_proximity_scale_available, S_IRUGO, + ltr501_show_proximity_scale_avail, NULL, 0); +static IIO_DEVICE_ATTR(in_intensity_scale_available, S_IRUGO, + ltr501_show_intensity_scale_avail, NULL, 0); + static struct attribute *ltr501_attributes[] = { - &iio_const_attr_in_proximity_scale_available.dev_attr.attr, - &iio_const_attr_in_intensity_scale_available.dev_attr.attr, + &iio_dev_attr_in_proximity_scale_available.dev_attr.attr, + &iio_dev_attr_in_intensity_scale_available.dev_attr.attr, &iio_const_attr_integration_time_available.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr, NULL @@ -962,6 +1062,29 @@ static const struct iio_info ltr501_info = { .driver_module = THIS_MODULE, }; +static struct ltr501_chip_info ltr501_chip_info_tbl[] = { + [ltr501] = { + .partid = 0x08, + .als_gain = ltr501_als_gain_tbl, + .als_gain_tbl_size = ARRAY_SIZE(ltr501_als_gain_tbl), + .ps_gain = ltr501_ps_gain_tbl, + .ps_gain_tbl_size = ARRAY_SIZE(ltr501_ps_gain_tbl), + .als_mode_active = BIT(0) | BIT(1), + .als_gain_mask = BIT(3), + .als_gain_shift = 3, + }, + [ltr559] = { + .partid = 0x09, + .als_gain = ltr559_als_gain_tbl, + .als_gain_tbl_size = ARRAY_SIZE(ltr559_als_gain_tbl), + .ps_gain = ltr559_ps_gain_tbl, + .ps_gain_tbl_size = ARRAY_SIZE(ltr559_ps_gain_tbl), + .als_mode_active = BIT(1), + .als_gain_mask = BIT(2) | BIT(3) | BIT(4), + .als_gain_shift = 2, + }, +}; + static int ltr501_write_contr(struct ltr501_data *data, u8 als_val, u8 ps_val) { int ret; @@ -1062,7 +1185,7 @@ static int ltr501_init(struct ltr501_data *data) if (ret < 0) return ret; - data->als_contr = status | LTR501_CONTR_ACTIVE; + data->als_contr = ret | data->chip_info->als_mode_active; ret = regmap_read(data->regmap, LTR501_PS_CONTR, &status); if (ret < 0) @@ -1105,17 +1228,30 @@ static struct regmap_config ltr501_regmap_config = { static int ltr501_powerdown(struct ltr501_data *data) { - return ltr501_write_contr(data, data->als_contr & ~LTR501_CONTR_ACTIVE, + return ltr501_write_contr(data, data->als_contr & + ~data->chip_info->als_mode_active, data->ps_contr & ~LTR501_CONTR_ACTIVE); } +static const char *ltr501_match_acpi_device(struct device *dev, int *chip_idx) +{ + const struct acpi_device_id *id; + + id = acpi_match_device(dev->driver->acpi_match_table, dev); + if (!id) + return NULL; + *chip_idx = id->driver_data; + return dev_name(dev); +} + static int ltr501_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct ltr501_data *data; struct iio_dev *indio_dev; struct regmap *regmap; - int ret, partid; + int ret, partid, chip_idx = 0; + const char *name = NULL; indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); if (!indio_dev) @@ -1186,13 +1322,25 @@ static int ltr501_probe(struct i2c_client *client, ret = regmap_read(data->regmap, LTR501_PART_ID, &partid); if (ret < 0) return ret; - if ((partid >> 4) != 0x8) + + if (id) { + name = id->name; + chip_idx = id->driver_data; + } else if (ACPI_HANDLE(&client->dev)) { + name = ltr501_match_acpi_device(&client->dev, &chip_idx); + } else { + return -ENODEV; + } + + data->chip_info = <r501_chip_info_tbl[chip_idx]; + + if ((partid >> 4) != data->chip_info->partid) return -ENODEV; indio_dev->dev.parent = &client->dev; indio_dev->channels = ltr501_channels; indio_dev->num_channels = ARRAY_SIZE(ltr501_channels); - indio_dev->name = LTR501_DRV_NAME; + indio_dev->name = name; indio_dev->modes = INDIO_DIRECT_MODE; ret = ltr501_init(data); @@ -1266,13 +1414,15 @@ static int ltr501_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(ltr501_pm_ops, ltr501_suspend, ltr501_resume); static const struct acpi_device_id ltr_acpi_match[] = { - {"LTER0501", 0}, + {"LTER0501", ltr501}, + {"LTER0559", ltr559}, { }, }; MODULE_DEVICE_TABLE(acpi, ltr_acpi_match); static const struct i2c_device_id ltr501_id[] = { - { "ltr501", 0 }, + { "ltr501", ltr501}, + { "ltr559", ltr559}, { } }; MODULE_DEVICE_TABLE(i2c, ltr501_id); From 035ebb15101c0f5c58d6ff8b343c6eae9ddca9c6 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Tue, 21 Apr 2015 19:11:00 +0300 Subject: [PATCH 0026/1163] iio: ltr501: Add support for ltr301 chip Added support for Liteon 301 Ambient light sensor. Since LTR-301 and LTR-501 are register compatible(and even have same part id), LTR-501 driver has been extended to support both devices. LTR-501 is similar to LTR-301 in ALS sensing, But the only difference is, LTR-501 also supports proximity sensing. LTR-501 - ALS + Proximity combo LTR-301 - ALS sensor. Signed-off-by: Kuppuswamy Sathyanarayanan Signed-off-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/light/Kconfig | 2 +- drivers/iio/light/ltr501.c | 76 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 73 insertions(+), 5 deletions(-) diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index 16a0ba11ab6e..a437bad46686 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -170,7 +170,7 @@ config LTR501 help If you say yes here you get support for the Lite-On LTR-501ALS-01 ambient light and proximity sensor. This driver also supports LTR-559 - ALS/PS sensor. + ALS/PS or LTR-301 ALS sensors. This driver can also be built as a module. If so, the module will be called ltr501. diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c index 92da5146bc1c..ca4bf470a332 100644 --- a/drivers/iio/light/ltr501.c +++ b/drivers/iio/light/ltr501.c @@ -93,6 +93,7 @@ struct ltr501_samp_table { enum { ltr501 = 0, ltr559, + ltr301, }; struct ltr501_gain { @@ -139,6 +140,10 @@ struct ltr501_chip_info { u8 als_mode_active; u8 als_gain_mask; u8 als_gain_shift; + struct iio_chan_spec const *channels; + const int no_channels; + const struct iio_info *info; + const struct iio_info *info_no_irq; }; struct ltr501_data { @@ -570,6 +575,18 @@ static const struct iio_chan_spec ltr501_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(3), }; +static const struct iio_chan_spec ltr301_channels[] = { + LTR501_INTENSITY_CHANNEL(0, LTR501_ALS_DATA0, IIO_MOD_LIGHT_BOTH, 0, + ltr501_als_event_spec, + ARRAY_SIZE(ltr501_als_event_spec)), + LTR501_INTENSITY_CHANNEL(1, LTR501_ALS_DATA1, IIO_MOD_LIGHT_IR, + BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_INT_TIME) | + BIT(IIO_CHAN_INFO_SAMP_FREQ), + NULL, 0), + IIO_CHAN_SOFT_TIMESTAMP(2), +}; + static int ltr501_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) @@ -1040,10 +1057,21 @@ static struct attribute *ltr501_attributes[] = { NULL }; +static struct attribute *ltr301_attributes[] = { + &iio_dev_attr_in_intensity_scale_available.dev_attr.attr, + &iio_const_attr_integration_time_available.dev_attr.attr, + &iio_const_attr_sampling_frequency_available.dev_attr.attr, + NULL +}; + static const struct attribute_group ltr501_attribute_group = { .attrs = ltr501_attributes, }; +static const struct attribute_group ltr301_attribute_group = { + .attrs = ltr301_attributes, +}; + static const struct iio_info ltr501_info_no_irq = { .read_raw = ltr501_read_raw, .write_raw = ltr501_write_raw, @@ -1062,6 +1090,24 @@ static const struct iio_info ltr501_info = { .driver_module = THIS_MODULE, }; +static const struct iio_info ltr301_info_no_irq = { + .read_raw = ltr501_read_raw, + .write_raw = ltr501_write_raw, + .attrs = <r301_attribute_group, + .driver_module = THIS_MODULE, +}; + +static const struct iio_info ltr301_info = { + .read_raw = ltr501_read_raw, + .write_raw = ltr501_write_raw, + .attrs = <r301_attribute_group, + .read_event_value = <r501_read_event, + .write_event_value = <r501_write_event, + .read_event_config = <r501_read_event_config, + .write_event_config = <r501_write_event_config, + .driver_module = THIS_MODULE, +}; + static struct ltr501_chip_info ltr501_chip_info_tbl[] = { [ltr501] = { .partid = 0x08, @@ -1072,6 +1118,10 @@ static struct ltr501_chip_info ltr501_chip_info_tbl[] = { .als_mode_active = BIT(0) | BIT(1), .als_gain_mask = BIT(3), .als_gain_shift = 3, + .info = <r501_info, + .info_no_irq = <r501_info_no_irq, + .channels = ltr501_channels, + .no_channels = ARRAY_SIZE(ltr501_channels), }, [ltr559] = { .partid = 0x09, @@ -1082,6 +1132,22 @@ static struct ltr501_chip_info ltr501_chip_info_tbl[] = { .als_mode_active = BIT(1), .als_gain_mask = BIT(2) | BIT(3) | BIT(4), .als_gain_shift = 2, + .info = <r501_info, + .info_no_irq = <r501_info_no_irq, + .channels = ltr501_channels, + .no_channels = ARRAY_SIZE(ltr501_channels), + }, + [ltr301] = { + .partid = 0x08, + .als_gain = ltr501_als_gain_tbl, + .als_gain_tbl_size = ARRAY_SIZE(ltr501_als_gain_tbl), + .als_mode_active = BIT(0) | BIT(1), + .als_gain_mask = BIT(3), + .als_gain_shift = 3, + .info = <r301_info, + .info_no_irq = <r301_info_no_irq, + .channels = ltr301_channels, + .no_channels = ARRAY_SIZE(ltr301_channels), }, }; @@ -1338,8 +1404,9 @@ static int ltr501_probe(struct i2c_client *client, return -ENODEV; indio_dev->dev.parent = &client->dev; - indio_dev->channels = ltr501_channels; - indio_dev->num_channels = ARRAY_SIZE(ltr501_channels); + indio_dev->info = data->chip_info->info; + indio_dev->channels = data->chip_info->channels; + indio_dev->num_channels = data->chip_info->no_channels; indio_dev->name = name; indio_dev->modes = INDIO_DIRECT_MODE; @@ -1348,7 +1415,6 @@ static int ltr501_probe(struct i2c_client *client, return ret; if (client->irq > 0) { - indio_dev->info = <r501_info; ret = devm_request_threaded_irq(&client->dev, client->irq, NULL, ltr501_interrupt_handler, IRQF_TRIGGER_FALLING | @@ -1361,7 +1427,7 @@ static int ltr501_probe(struct i2c_client *client, return ret; } } else { - indio_dev->info = <r501_info_no_irq; + indio_dev->info = data->chip_info->info_no_irq; } ret = iio_triggered_buffer_setup(indio_dev, NULL, @@ -1416,6 +1482,7 @@ static SIMPLE_DEV_PM_OPS(ltr501_pm_ops, ltr501_suspend, ltr501_resume); static const struct acpi_device_id ltr_acpi_match[] = { {"LTER0501", ltr501}, {"LTER0559", ltr559}, + {"LTER0301", ltr301}, { }, }; MODULE_DEVICE_TABLE(acpi, ltr_acpi_match); @@ -1423,6 +1490,7 @@ MODULE_DEVICE_TABLE(acpi, ltr_acpi_match); static const struct i2c_device_id ltr501_id[] = { { "ltr501", ltr501}, { "ltr559", ltr559}, + { "ltr301", ltr301}, { } }; MODULE_DEVICE_TABLE(i2c, ltr501_id); From b39f0c945c0dc39763a76e2f54fb9eea0e49e876 Mon Sep 17 00:00:00 2001 From: Irina Tirdea Date: Mon, 13 Apr 2015 18:40:52 +0300 Subject: [PATCH 0027/1163] iio: accel: mma9551_core: wrong doc fixes Fix docummentation for mma9553_read_* functions. Signed-off-by: Irina Tirdea Reported-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma9551_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/accel/mma9551_core.c b/drivers/iio/accel/mma9551_core.c index 7f55a6d7cd03..2543167c0f7c 100644 --- a/drivers/iio/accel/mma9551_core.c +++ b/drivers/iio/accel/mma9551_core.c @@ -374,7 +374,7 @@ EXPORT_SYMBOL(mma9551_read_status_word); * @app_id: Application ID * @reg: Application register * @len: Length of array to read in bytes - * @val: Array of words to read + * @buf: Array of words to read * * Read multiple configuration registers (word-sized registers). * @@ -409,7 +409,7 @@ EXPORT_SYMBOL(mma9551_read_config_words); * @app_id: Application ID * @reg: Application register * @len: Length of array to read in bytes - * @val: Array of words to read + * @buf: Array of words to read * * Read multiple status registers (word-sized registers). * @@ -444,7 +444,7 @@ EXPORT_SYMBOL(mma9551_read_status_words); * @app_id: Application ID * @reg: Application register * @len: Length of array to write in bytes - * @val: Array of words to write + * @buf: Array of words to write * * Write multiple configuration registers (word-sized registers). * From 476c41a73eee708101495d2202c82060d0fc787d Mon Sep 17 00:00:00 2001 From: Irina Tirdea Date: Mon, 13 Apr 2015 18:40:53 +0300 Subject: [PATCH 0028/1163] iio: accel: mma9551_core: typo fix in RSC APP ID Fix typo in Reset/Suspend/Clear Application ID definition. Signed-off-by: Irina Tirdea Reported-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma9551_core.c | 2 +- drivers/iio/accel/mma9551_core.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/accel/mma9551_core.c b/drivers/iio/accel/mma9551_core.c index 2543167c0f7c..54b3ae615a14 100644 --- a/drivers/iio/accel/mma9551_core.c +++ b/drivers/iio/accel/mma9551_core.c @@ -785,7 +785,7 @@ EXPORT_SYMBOL(mma9551_read_accel_scale); */ int mma9551_app_reset(struct i2c_client *client, u32 app_mask) { - return mma9551_write_config_byte(client, MMA9551_APPID_RCS, + return mma9551_write_config_byte(client, MMA9551_APPID_RSC, MMA9551_RSC_RESET + MMA9551_RSC_OFFSET(app_mask), MMA9551_RSC_VAL(app_mask)); diff --git a/drivers/iio/accel/mma9551_core.h b/drivers/iio/accel/mma9551_core.h index edaa56b1078e..79939e40805a 100644 --- a/drivers/iio/accel/mma9551_core.h +++ b/drivers/iio/accel/mma9551_core.h @@ -22,7 +22,7 @@ #define MMA9551_APPID_TILT 0x0B #define MMA9551_APPID_SLEEP_WAKE 0x12 #define MMA9551_APPID_PEDOMETER 0x15 -#define MMA9551_APPID_RCS 0x17 +#define MMA9551_APPID_RSC 0x17 #define MMA9551_APPID_NONE 0xff /* Reset/Suspend/Clear application app masks */ From 1d052931c689d14397d05ac705cf386955bcf813 Mon Sep 17 00:00:00 2001 From: Irina Tirdea Date: Mon, 13 Apr 2015 18:40:54 +0300 Subject: [PATCH 0029/1163] iio: accel: mma9553: check for error in reading initial activity and stepcnt When configuring gpio, we need to read initial values for activity and step count. This function may fail due to i2c read errors. Check the error code returned by mma9553_read_activity_stepcnt and return the appropriate error in gpio config function. Signed-off-by: Irina Tirdea Reported-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma9553.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/iio/accel/mma9553.c b/drivers/iio/accel/mma9553.c index 2df1af7d43fc..04a4bb99b269 100644 --- a/drivers/iio/accel/mma9553.c +++ b/drivers/iio/accel/mma9553.c @@ -365,9 +365,12 @@ static int mma9553_conf_gpio(struct mma9553_data *data) return 0; /* Save initial values for activity and stepcnt */ - if (activity_enabled || ev_step_detect->enabled) - mma9553_read_activity_stepcnt(data, &data->activity, - &data->stepcnt); + if (activity_enabled || ev_step_detect->enabled) { + ret = mma9553_read_activity_stepcnt(data, &data->activity, + &data->stepcnt); + if (ret < 0) + return ret; + } ret = mma9551_gpio_config(data->client, MMA9553_DEFAULT_GPIO_PIN, From 04aff96ad49d297fa530bb01aa09f1f39e65189a Mon Sep 17 00:00:00 2001 From: Irina Tirdea Date: Mon, 13 Apr 2015 18:40:55 +0300 Subject: [PATCH 0030/1163] iio: accel: mma9553: return 0 as indication of success Use return 0 instead of return ret to mark clearly the success return path. Signed-off-by: Irina Tirdea Suggested-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma9553.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/accel/mma9553.c b/drivers/iio/accel/mma9553.c index 04a4bb99b269..f2118b1a7010 100644 --- a/drivers/iio/accel/mma9553.c +++ b/drivers/iio/accel/mma9553.c @@ -794,7 +794,7 @@ static int mma9553_write_event_config(struct iio_dev *indio_dev, mutex_unlock(&data->mutex); - return ret; + return 0; err_conf_gpio: if (state) { From c105ac6a039242e847d6b770ec2f4fa2c9f20a1b Mon Sep 17 00:00:00 2001 From: Irina Tirdea Date: Mon, 13 Apr 2015 18:40:56 +0300 Subject: [PATCH 0031/1163] iio: accel: mma9553: comment and error message fixes Use "GPIO" instead of "gpio" and "ACPI" instead of "acpi". Includes a couple of small style fixes in comments (missing full stop, whitespace, paranthesis). Signed-off-by: Irina Tirdea Suggested-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma9553.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/iio/accel/mma9553.c b/drivers/iio/accel/mma9553.c index f2118b1a7010..7c87ec41b8d0 100644 --- a/drivers/iio/accel/mma9553.c +++ b/drivers/iio/accel/mma9553.c @@ -75,14 +75,14 @@ #define MMA9553_DEFAULT_GPIO_PIN mma9551_gpio6 #define MMA9553_DEFAULT_GPIO_POLARITY 0 -/* Bitnum used for gpio configuration = bit number in high status byte */ #define STATUS_TO_BITNUM(bit) (ffs(bit) - 9) +/* Bitnum used for GPIO configuration = bit number in high status byte */ #define MMA9553_DEFAULT_SAMPLE_RATE 30 /* Hz */ /* * The internal activity level must be stable for ACTTHD samples before - * ACTIVITY is updated.The ACTIVITY variable contains the current activity + * ACTIVITY is updated. The ACTIVITY variable contains the current activity * level and is updated every time a step is detected or once a second * if there are no steps. */ @@ -401,13 +401,13 @@ static int mma9553_init(struct mma9553_data *data) sizeof(data->conf), (u16 *) &data->conf); if (ret < 0) { dev_err(&data->client->dev, - "device is not MMA9553L: failed to read cfg regs\n"); + "failed to read configuration registers\n"); return ret; } - /* Reset gpio */ data->gpio_bitnum = -1; + /* Reset GPIO */ ret = mma9553_conf_gpio(data); if (ret < 0) return ret; @@ -459,7 +459,8 @@ static int mma9553_read_raw(struct iio_dev *indio_dev, * The HW only counts steps and other dependent * parameters (speed, distance, calories, activity) * if power is on (from enabling an event or the - * step counter */ + * step counter). + */ powered_on = mma9553_is_any_event_enabled(data, false, 0) || data->stepcnt_enabled; @@ -899,7 +900,7 @@ static int mma9553_get_calibgender_mode(struct iio_dev *indio_dev, gender = mma9553_get_bits(data->conf.filter, MMA9553_MASK_CONF_MALE); /* * HW expects 0 for female and 1 for male, - * while iio index is 0 for male and 1 for female + * while iio index is 0 for male and 1 for female. */ return !gender; } @@ -1111,16 +1112,16 @@ static int mma9553_gpio_probe(struct i2c_client *client) dev = &client->dev; - /* data ready gpio interrupt pin */ + /* data ready GPIO interrupt pin */ gpio = devm_gpiod_get_index(dev, MMA9553_GPIO_NAME, 0, GPIOD_IN); if (IS_ERR(gpio)) { - dev_err(dev, "acpi gpio get index failed\n"); + dev_err(dev, "ACPI GPIO get index failed\n"); return PTR_ERR(gpio); } ret = gpiod_to_irq(gpio); - dev_dbg(dev, "gpio resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret); + dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret); return ret; } From 43c30937c300bc30abb6368a71d4e17e37509a07 Mon Sep 17 00:00:00 2001 From: Irina Tirdea Date: Mon, 13 Apr 2015 18:40:57 +0300 Subject: [PATCH 0032/1163] iio: accel: mma9553: use GENMASK Use GENMASK instead of BIT or direct value to define a mask. Signed-off-by: Irina Tirdea Suggested-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma9553.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/accel/mma9553.c b/drivers/iio/accel/mma9553.c index 7c87ec41b8d0..dcbf04fa3d05 100644 --- a/drivers/iio/accel/mma9553.c +++ b/drivers/iio/accel/mma9553.c @@ -62,8 +62,8 @@ #define MMA9553_MASK_STATUS_STEPCHG BIT(13) #define MMA9553_MASK_STATUS_ACTCHG BIT(12) #define MMA9553_MASK_STATUS_SUSP BIT(11) -#define MMA9553_MASK_STATUS_ACTIVITY (BIT(10) | BIT(9) | BIT(8)) -#define MMA9553_MASK_STATUS_VERSION 0x00FF +#define MMA9553_MASK_STATUS_ACTIVITY GENMASK(10, 8) +#define MMA9553_MASK_STATUS_VERSION GENMASK(7, 0) #define MMA9553_REG_STEPCNT 0x02 #define MMA9553_REG_DISTANCE 0x04 From 996ba514591cd89c5555e143f6ad893f3f5e6824 Mon Sep 17 00:00:00 2001 From: Irina Tirdea Date: Mon, 13 Apr 2015 18:40:58 +0300 Subject: [PATCH 0033/1163] iio: accel: mma9553: prefix naming fixes Add mma9553_ prefix to all local functions/declarations. Signed-off-by: Irina Tirdea Suggested-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma9553.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/iio/accel/mma9553.c b/drivers/iio/accel/mma9553.c index dcbf04fa3d05..b17848eae9ce 100644 --- a/drivers/iio/accel/mma9553.c +++ b/drivers/iio/accel/mma9553.c @@ -75,8 +75,8 @@ #define MMA9553_DEFAULT_GPIO_PIN mma9551_gpio6 #define MMA9553_DEFAULT_GPIO_POLARITY 0 -#define STATUS_TO_BITNUM(bit) (ffs(bit) - 9) /* Bitnum used for GPIO configuration = bit number in high status byte */ +#define MMA9553_STATUS_TO_BITNUM(bit) (ffs(bit) - 9) #define MMA9553_DEFAULT_SAMPLE_RATE 30 /* Hz */ @@ -353,11 +353,11 @@ static int mma9553_conf_gpio(struct mma9553_data *data) * This bit is the logical OR of the SUSPCHG, STEPCHG, and ACTCHG flags. */ if (activity_enabled && ev_step_detect->enabled) - bitnum = STATUS_TO_BITNUM(MMA9553_MASK_STATUS_MRGFL); + bitnum = MMA9553_STATUS_TO_BITNUM(MMA9553_MASK_STATUS_MRGFL); else if (ev_step_detect->enabled) - bitnum = STATUS_TO_BITNUM(MMA9553_MASK_STATUS_STEPCHG); + bitnum = MMA9553_STATUS_TO_BITNUM(MMA9553_MASK_STATUS_STEPCHG); else if (activity_enabled) - bitnum = STATUS_TO_BITNUM(MMA9553_MASK_STATUS_ACTCHG); + bitnum = MMA9553_STATUS_TO_BITNUM(MMA9553_MASK_STATUS_ACTCHG); else /* Reset */ appid = MMA9551_APPID_NONE; @@ -947,11 +947,11 @@ static const struct iio_event_spec mma9553_activity_events[] = { }, }; -static const char * const calibgender_modes[] = { "male", "female" }; +static const char * const mma9553_calibgender_modes[] = { "male", "female" }; static const struct iio_enum mma9553_calibgender_enum = { - .items = calibgender_modes, - .num_items = ARRAY_SIZE(calibgender_modes), + .items = mma9553_calibgender_modes, + .num_items = ARRAY_SIZE(mma9553_calibgender_modes), .get = mma9553_get_calibgender_mode, .set = mma9553_set_calibgender_mode, }; From 334efd076dc5bde5c579c0cf1c2b5d3dcd8839f7 Mon Sep 17 00:00:00 2001 From: Irina Tirdea Date: Mon, 13 Apr 2015 18:41:00 +0300 Subject: [PATCH 0034/1163] iio: accel: mma9553: refactor mma9553_read_raw Refactor code for simplicity and clarity. Signed-off-by: Irina Tirdea Suggested-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma9553.c | 101 ++++++++++++------------------------ 1 file changed, 33 insertions(+), 68 deletions(-) diff --git a/drivers/iio/accel/mma9553.c b/drivers/iio/accel/mma9553.c index b17848eae9ce..032537fc2c56 100644 --- a/drivers/iio/accel/mma9553.c +++ b/drivers/iio/accel/mma9553.c @@ -441,6 +441,32 @@ static int mma9553_init(struct mma9553_data *data) return mma9551_set_device_state(data->client, true); } +static int mma9553_read_status_word(struct mma9553_data *data, u16 reg, + u16 *tmp) +{ + bool powered_on; + int ret; + + /* + * The HW only counts steps and other dependent + * parameters (speed, distance, calories, activity) + * if power is on (from enabling an event or the + * step counter). + */ + powered_on = mma9553_is_any_event_enabled(data, false, 0) || + data->stepcnt_enabled; + if (!powered_on) { + dev_err(&data->client->dev, "No channels enabled\n"); + return -EINVAL; + } + + mutex_lock(&data->mutex); + ret = mma9551_read_status_word(data->client, MMA9551_APPID_PEDOMETER, + reg, tmp); + mutex_unlock(&data->mutex); + return ret; +} + static int mma9553_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) @@ -449,70 +475,30 @@ static int mma9553_read_raw(struct iio_dev *indio_dev, int ret; u16 tmp; u8 activity; - bool powered_on; switch (mask) { case IIO_CHAN_INFO_PROCESSED: switch (chan->type) { case IIO_STEPS: - /* - * The HW only counts steps and other dependent - * parameters (speed, distance, calories, activity) - * if power is on (from enabling an event or the - * step counter). - */ - powered_on = - mma9553_is_any_event_enabled(data, false, 0) || - data->stepcnt_enabled; - if (!powered_on) { - dev_err(&data->client->dev, - "No channels enabled\n"); - return -EINVAL; - } - mutex_lock(&data->mutex); - ret = mma9551_read_status_word(data->client, - MMA9551_APPID_PEDOMETER, + ret = mma9553_read_status_word(data, MMA9553_REG_STEPCNT, &tmp); - mutex_unlock(&data->mutex); if (ret < 0) return ret; *val = tmp; return IIO_VAL_INT; case IIO_DISTANCE: - powered_on = - mma9553_is_any_event_enabled(data, false, 0) || - data->stepcnt_enabled; - if (!powered_on) { - dev_err(&data->client->dev, - "No channels enabled\n"); - return -EINVAL; - } - mutex_lock(&data->mutex); - ret = mma9551_read_status_word(data->client, - MMA9551_APPID_PEDOMETER, + ret = mma9553_read_status_word(data, MMA9553_REG_DISTANCE, &tmp); - mutex_unlock(&data->mutex); if (ret < 0) return ret; *val = tmp; return IIO_VAL_INT; case IIO_ACTIVITY: - powered_on = - mma9553_is_any_event_enabled(data, false, 0) || - data->stepcnt_enabled; - if (!powered_on) { - dev_err(&data->client->dev, - "No channels enabled\n"); - return -EINVAL; - } - mutex_lock(&data->mutex); - ret = mma9551_read_status_word(data->client, - MMA9551_APPID_PEDOMETER, + ret = mma9553_read_status_word(data, MMA9553_REG_STATUS, &tmp); - mutex_unlock(&data->mutex); if (ret < 0) return ret; @@ -537,38 +523,17 @@ static int mma9553_read_raw(struct iio_dev *indio_dev, case IIO_VELOCITY: /* m/h */ if (chan->channel2 != IIO_MOD_ROOT_SUM_SQUARED_X_Y_Z) return -EINVAL; - powered_on = - mma9553_is_any_event_enabled(data, false, 0) || - data->stepcnt_enabled; - if (!powered_on) { - dev_err(&data->client->dev, - "No channels enabled\n"); - return -EINVAL; - } - mutex_lock(&data->mutex); - ret = mma9551_read_status_word(data->client, - MMA9551_APPID_PEDOMETER, - MMA9553_REG_SPEED, &tmp); - mutex_unlock(&data->mutex); + ret = mma9553_read_status_word(data, + MMA9553_REG_SPEED, + &tmp); if (ret < 0) return ret; *val = tmp; return IIO_VAL_INT; case IIO_ENERGY: /* Cal or kcal */ - powered_on = - mma9553_is_any_event_enabled(data, false, 0) || - data->stepcnt_enabled; - if (!powered_on) { - dev_err(&data->client->dev, - "No channels enabled\n"); - return -EINVAL; - } - mutex_lock(&data->mutex); - ret = mma9551_read_status_word(data->client, - MMA9551_APPID_PEDOMETER, + ret = mma9553_read_status_word(data, MMA9553_REG_CALORIES, &tmp); - mutex_unlock(&data->mutex); if (ret < 0) return ret; *val = tmp; From ef8307a21ac79823b8a4f977eac42329328af384 Mon Sep 17 00:00:00 2001 From: Irina Tirdea Date: Mon, 13 Apr 2015 18:40:59 +0300 Subject: [PATCH 0035/1163] iio: accel: mma9553: fix gpio bitnum init value Initial value of gpio bitnum is set to -1, but the variable is declared as unsigned. Use a positive invalid value for initial gpio bitnum. Signed-off-by: Irina Tirdea Suggested-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma9553.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iio/accel/mma9553.c b/drivers/iio/accel/mma9553.c index 032537fc2c56..9d649c4a21fd 100644 --- a/drivers/iio/accel/mma9553.c +++ b/drivers/iio/accel/mma9553.c @@ -77,6 +77,7 @@ /* Bitnum used for GPIO configuration = bit number in high status byte */ #define MMA9553_STATUS_TO_BITNUM(bit) (ffs(bit) - 9) +#define MMA9553_MAX_BITNUM MMA9553_STATUS_TO_BITNUM(BIT(16)) #define MMA9553_DEFAULT_SAMPLE_RATE 30 /* Hz */ @@ -406,8 +407,8 @@ static int mma9553_init(struct mma9553_data *data) } - data->gpio_bitnum = -1; /* Reset GPIO */ + data->gpio_bitnum = MMA9553_MAX_BITNUM; ret = mma9553_conf_gpio(data); if (ret < 0) return ret; From e98ceca076bb37d42116c5395ba40d7e31ba869c Mon Sep 17 00:00:00 2001 From: Roberta Dobrescu Date: Thu, 16 Apr 2015 22:20:57 +0300 Subject: [PATCH 0036/1163] staging: iio: light: isl29018: Remove non-standard sysfs attributes This patch removes non-standard sysfs attributes range, range_available, adc_resolution and adc_resolution_available. It also removes the corresponding show and store functions. This is in preparation for using standard IIO attributes in order to move the code out of staging. Signed-off-by: Roberta Dobrescu Signed-off-by: Jonathan Cameron --- drivers/staging/iio/light/isl29018.c | 94 ---------------------------- 1 file changed, 94 deletions(-) diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c index a3489187aeb0..d3d0611d0cb4 100644 --- a/drivers/staging/iio/light/isl29018.c +++ b/drivers/staging/iio/light/isl29018.c @@ -230,87 +230,6 @@ static int isl29018_read_proximity_ir(struct isl29018_chip *chip, int scheme, } /* Sysfs interface */ -/* range */ -static ssize_t show_range(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct isl29018_chip *chip = iio_priv(indio_dev); - - return sprintf(buf, "%u\n", chip->range); -} - -static ssize_t store_range(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct isl29018_chip *chip = iio_priv(indio_dev); - int status; - unsigned long lval; - unsigned int new_range; - - if (kstrtoul(buf, 10, &lval)) - return -EINVAL; - - if (!(lval == 1000UL || lval == 4000UL || - lval == 16000UL || lval == 64000UL)) { - dev_err(dev, "The range is not supported\n"); - return -EINVAL; - } - - mutex_lock(&chip->lock); - status = isl29018_set_range(chip, lval, &new_range); - if (status < 0) { - mutex_unlock(&chip->lock); - dev_err(dev, - "Error in setting max range with err %d\n", status); - return status; - } - chip->range = new_range; - mutex_unlock(&chip->lock); - - return count; -} - -/* resolution */ -static ssize_t show_resolution(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct isl29018_chip *chip = iio_priv(indio_dev); - - return sprintf(buf, "%u\n", chip->adc_bit); -} - -static ssize_t store_resolution(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct isl29018_chip *chip = iio_priv(indio_dev); - int status; - unsigned int val; - unsigned int new_adc_bit; - - if (kstrtouint(buf, 10, &val)) - return -EINVAL; - if (!(val == 4 || val == 8 || val == 12 || val == 16)) { - dev_err(dev, "The resolution is not supported\n"); - return -EINVAL; - } - - mutex_lock(&chip->lock); - status = isl29018_set_resolution(chip, val, &new_adc_bit); - if (status < 0) { - mutex_unlock(&chip->lock); - dev_err(dev, "Error in setting resolution\n"); - return status; - } - chip->adc_bit = new_adc_bit; - mutex_unlock(&chip->lock); - - return count; -} - /* proximity scheme */ static ssize_t show_prox_infrared_suppression(struct device *dev, struct device_attribute *attr, char *buf) @@ -447,11 +366,6 @@ static const struct iio_chan_spec isl29023_channels[] = { ISL29018_IR_CHANNEL, }; -static IIO_DEVICE_ATTR(range, S_IRUGO | S_IWUSR, show_range, store_range, 0); -static IIO_CONST_ATTR(range_available, "1000 4000 16000 64000"); -static IIO_CONST_ATTR(adc_resolution_available, "4 8 12 16"); -static IIO_DEVICE_ATTR(adc_resolution, S_IRUGO | S_IWUSR, - show_resolution, store_resolution, 0); static IIO_DEVICE_ATTR(proximity_on_chip_ambient_infrared_suppression, S_IRUGO | S_IWUSR, show_prox_infrared_suppression, @@ -460,19 +374,11 @@ static IIO_DEVICE_ATTR(proximity_on_chip_ambient_infrared_suppression, #define ISL29018_DEV_ATTR(name) (&iio_dev_attr_##name.dev_attr.attr) #define ISL29018_CONST_ATTR(name) (&iio_const_attr_##name.dev_attr.attr) static struct attribute *isl29018_attributes[] = { - ISL29018_DEV_ATTR(range), - ISL29018_CONST_ATTR(range_available), - ISL29018_DEV_ATTR(adc_resolution), - ISL29018_CONST_ATTR(adc_resolution_available), ISL29018_DEV_ATTR(proximity_on_chip_ambient_infrared_suppression), NULL }; static struct attribute *isl29023_attributes[] = { - ISL29018_DEV_ATTR(range), - ISL29018_CONST_ATTR(range_available), - ISL29018_DEV_ATTR(adc_resolution), - ISL29018_CONST_ATTR(adc_resolution_available), NULL }; From 809a591b16781cc69f1f3ff2cc9a790e3ae8ec8f Mon Sep 17 00:00:00 2001 From: Roberta Dobrescu Date: Thu, 16 Apr 2015 22:20:58 +0300 Subject: [PATCH 0037/1163] staging: iio: light: isl29018: Rename lux_scale to calibscale This patch renames lux_scale to calibscale and lux_uscale to ucalibscale. This is done in order to avoid confusion since these parameters are used for hardware applied calibration. Signed-off-by: Roberta Dobrescu Signed-off-by: Jonathan Cameron --- drivers/staging/iio/light/isl29018.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c index d3d0611d0cb4..ffc3d1b2ee9a 100644 --- a/drivers/staging/iio/light/isl29018.c +++ b/drivers/staging/iio/light/isl29018.c @@ -71,8 +71,8 @@ struct isl29018_chip { struct regmap *regmap; struct mutex lock; int type; - unsigned int lux_scale; - unsigned int lux_uscale; + unsigned int calibscale; + unsigned int ucalibscale; unsigned int range; unsigned int adc_bit; int prox_scheme; @@ -165,12 +165,12 @@ static int isl29018_read_lux(struct isl29018_chip *chip, int *lux) /* To support fractional scaling, separate the unshifted lux * into two calculations: int scaling and micro-scaling. - * lux_uscale ranges from 0-999999, so about 20 bits. Split + * ucalibscale ranges from 0-999999, so about 20 bits. Split * the /1,000,000 in two to reduce the risk of over/underflow. */ data_x_range = lux_data * chip->range; - lux_unshifted = data_x_range * chip->lux_scale; - lux_unshifted += data_x_range / 1000 * chip->lux_uscale / 1000; + lux_unshifted = data_x_range * chip->calibscale; + lux_unshifted += data_x_range / 1000 * chip->ucalibscale / 1000; *lux = lux_unshifted >> chip->adc_bit; return 0; @@ -277,9 +277,9 @@ static int isl29018_write_raw(struct iio_dev *indio_dev, mutex_lock(&chip->lock); if (mask == IIO_CHAN_INFO_CALIBSCALE && chan->type == IIO_LIGHT) { - chip->lux_scale = val; + chip->calibscale = val; /* With no write_raw_get_fmt(), val2 is a MICRO fraction. */ - chip->lux_uscale = val2; + chip->ucalibscale = val2; ret = 0; } mutex_unlock(&chip->lock); @@ -323,8 +323,8 @@ static int isl29018_read_raw(struct iio_dev *indio_dev, break; case IIO_CHAN_INFO_CALIBSCALE: if (chan->type == IIO_LIGHT) { - *val = chip->lux_scale; - *val2 = chip->lux_uscale; + *val = chip->calibscale; + *val2 = chip->ucalibscale; ret = IIO_VAL_INT_PLUS_MICRO; } break; @@ -607,8 +607,8 @@ static int isl29018_probe(struct i2c_client *client, mutex_init(&chip->lock); chip->type = dev_id; - chip->lux_scale = 1; - chip->lux_uscale = 0; + chip->calibscale = 1; + chip->ucalibscale = 0; chip->range = 1000; chip->adc_bit = 16; chip->suspended = false; From b97c3c1a0b538a61fb1cab057738ccb64ae51e4d Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Thu, 23 Apr 2015 16:06:52 +0200 Subject: [PATCH 0038/1163] staging: octeon-usb: fix unaligned isochronous transfers Make sure to copy the whole transfer buffer when releasing the temporary buffer used for unaligned isochronous transfers as the data is not necessarily contiguous in that case. Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/octeon-hcd.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index 9e5476e352b4..cdb0981be2e9 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -499,15 +499,21 @@ static int octeon_alloc_temp_buffer(struct urb *urb, gfp_t mem_flags) static void octeon_free_temp_buffer(struct urb *urb) { struct octeon_temp_buffer *temp; + size_t length; if (!(urb->transfer_flags & URB_ALIGNED_TEMP_BUFFER)) return; temp = container_of(urb->transfer_buffer, struct octeon_temp_buffer, data); - if (usb_urb_dir_in(urb)) - memcpy(temp->orig_buffer, urb->transfer_buffer, - urb->actual_length); + if (usb_urb_dir_in(urb)) { + if (usb_pipeisoc(urb->pipe)) + length = urb->transfer_buffer_length; + else + length = urb->actual_length; + + memcpy(temp->orig_buffer, urb->transfer_buffer, length); + } urb->transfer_buffer = temp->orig_buffer; urb->transfer_flags &= ~URB_ALIGNED_TEMP_BUFFER; kfree(temp); From d9ca7e929d0825984873c2dd3e0bd9fda82e44be Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 29 Apr 2015 16:21:59 +0200 Subject: [PATCH 0039/1163] Staging: iop.c: move assignment out of if () block We should not be doing assignments within an if () block so fix up the code to not do this. change was created using Coccinelle. CC: Supriya Karanth CC: Somya Anand CC: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/i2o/iop.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/staging/i2o/iop.c b/drivers/staging/i2o/iop.c index 23bdbe4aa480..142aab8c7738 100644 --- a/drivers/staging/i2o/iop.c +++ b/drivers/staging/i2o/iop.c @@ -300,7 +300,8 @@ static int i2o_iop_quiesce(struct i2o_controller *c) ADAPTER_TID); /* Long timeout needed for quiesce if lots of devices */ - if ((rc = i2o_msg_post_wait(c, msg, 240))) + rc = i2o_msg_post_wait(c, msg, 240); + if (rc) osm_info("%s: Unable to quiesce (status=%#x).\n", c->name, -rc); else osm_debug("%s: Quiesced.\n", c->name); @@ -340,7 +341,8 @@ static int i2o_iop_enable(struct i2o_controller *c) ADAPTER_TID); /* How long of a timeout do we need? */ - if ((rc = i2o_msg_post_wait(c, msg, 240))) + rc = i2o_msg_post_wait(c, msg, 240); + if (rc) osm_err("%s: Could not enable (status=%#x).\n", c->name, -rc); else osm_debug("%s: Enabled.\n", c->name); @@ -406,7 +408,8 @@ static int i2o_iop_clear(struct i2o_controller *c) cpu_to_le32(I2O_CMD_ADAPTER_CLEAR << 24 | HOST_TID << 12 | ADAPTER_TID); - if ((rc = i2o_msg_post_wait(c, msg, 30))) + rc = i2o_msg_post_wait(c, msg, 30); + if (rc) osm_info("%s: Unable to clear (status=%#x).\n", c->name, -rc); else osm_debug("%s: Cleared.\n", c->name); From 3ede1b6be0718eb22531c573afc87f275147fbbe Mon Sep 17 00:00:00 2001 From: "Gujulan Elango, Hari Prasath (H.)" Date: Thu, 23 Apr 2015 13:43:01 +0000 Subject: [PATCH 0040/1163] staging: i2o: Remove unwanted semicolon This patch removes unwanted semicolon around close braces of code blocks Signed-off-by: Hari Prasath Signed-off-by: Greg Kroah-Hartman --- drivers/staging/i2o/iop.c | 44 +++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/staging/i2o/iop.c b/drivers/staging/i2o/iop.c index 142aab8c7738..c88df551bbb0 100644 --- a/drivers/staging/i2o/iop.c +++ b/drivers/staging/i2o/iop.c @@ -75,7 +75,7 @@ struct i2o_message *i2o_msg_get_wait(struct i2o_controller *c, int wait) } return msg; -}; +} #if BITS_PER_LONG == 64 /** @@ -123,7 +123,7 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr) osm_debug("%s: Add context to list %p -> %d\n", c->name, ptr, context); return entry->context; -}; +} /** * i2o_cntxt_list_remove - Remove a pointer from the context list @@ -159,7 +159,7 @@ u32 i2o_cntxt_list_remove(struct i2o_controller * c, void *ptr) context, ptr); return context; -}; +} /** * i2o_cntxt_list_get - Get a pointer from the context list and remove it @@ -192,7 +192,7 @@ void *i2o_cntxt_list_get(struct i2o_controller *c, u32 context) ptr); return ptr; -}; +} /** * i2o_cntxt_list_get_ptr - Get a context id from the context list @@ -224,7 +224,7 @@ u32 i2o_cntxt_list_get_ptr(struct i2o_controller * c, void *ptr) ptr, context); return context; -}; +} #endif /** @@ -245,7 +245,7 @@ struct i2o_controller *i2o_find_iop(int unit) } return NULL; -}; +} /** * i2o_iop_find_device - Find a I2O device on an I2O controller @@ -266,7 +266,7 @@ struct i2o_device *i2o_iop_find_device(struct i2o_controller *c, u16 tid) return dev; return NULL; -}; +} /** * i2o_quiesce_controller - quiesce controller @@ -309,7 +309,7 @@ static int i2o_iop_quiesce(struct i2o_controller *c) i2o_status_get(c); // Entered READY state return rc; -}; +} /** * i2o_iop_enable - move controller from ready to OPERATIONAL @@ -350,7 +350,7 @@ static int i2o_iop_enable(struct i2o_controller *c) i2o_status_get(c); // entered OPERATIONAL state return rc; -}; +} /** * i2o_iop_quiesce_all - Quiesce all I2O controllers on the system @@ -365,7 +365,7 @@ static inline void i2o_iop_quiesce_all(void) if (!c->no_quiesce) i2o_iop_quiesce(c); } -}; +} /** * i2o_iop_enable_all - Enables all controllers on the system @@ -378,7 +378,7 @@ static inline void i2o_iop_enable_all(void) list_for_each_entry_safe(c, tmp, &i2o_controllers, list) i2o_iop_enable(c); -}; +} /** * i2o_clear_controller - Bring I2O controller into HOLD state @@ -584,7 +584,7 @@ static int i2o_iop_reset(struct i2o_controller *c) i2o_iop_enable_all(); return rc; -}; +} /** * i2o_iop_activate - Bring controller up to HOLD @@ -653,7 +653,7 @@ static int i2o_iop_activate(struct i2o_controller *c) } return i2o_hrt_get(c); -}; +} static void i2o_res_alloc(struct i2o_controller *c, unsigned long flags) { @@ -782,7 +782,7 @@ static int i2o_iop_online(struct i2o_controller *c) return rc; return 0; -}; +} /** * i2o_iop_remove - Remove the I2O controller from the I2O core @@ -894,7 +894,7 @@ static int i2o_systab_build(void) systab->num_entries = count; return 0; -}; +} /** * i2o_parse_hrt - Parse the hardware resource table. @@ -908,7 +908,7 @@ static int i2o_parse_hrt(struct i2o_controller *c) { i2o_dump_hrt(c); return 0; -}; +} /** * i2o_status_get - Get the status block from the I2O controller @@ -1032,7 +1032,7 @@ static void i2o_iop_release(struct device *dev) struct i2o_controller *c = to_i2o_controller(dev); i2o_iop_free(c); -}; +} /** * i2o_iop_alloc - Allocate and initialize a i2o_controller struct @@ -1065,7 +1065,7 @@ struct i2o_controller *i2o_iop_alloc(void) I2O_MSG_INPOOL_MIN)) { kfree(c); return ERR_PTR(-ENOMEM); - }; + } INIT_LIST_HEAD(&c->devices); spin_lock_init(&c->lock); @@ -1084,7 +1084,7 @@ struct i2o_controller *i2o_iop_alloc(void) #endif return c; -}; +} /** * i2o_iop_add - Initialize the I2O controller and add him to the I2O core @@ -1148,7 +1148,7 @@ int i2o_iop_add(struct i2o_controller *c) i2o_iop_reset(c); return rc; -}; +} /** * i2o_event_register - Turn on/off event notification for a I2O device @@ -1184,7 +1184,7 @@ int i2o_event_register(struct i2o_device *dev, struct i2o_driver *drv, i2o_msg_post(c, msg); return 0; -}; +} /** * i2o_iop_init - I2O main initialization function @@ -1234,7 +1234,7 @@ static void __exit i2o_iop_exit(void) i2o_pci_exit(); i2o_exec_exit(); i2o_driver_exit(); -}; +} module_init(i2o_iop_init); module_exit(i2o_iop_exit); From 41d98f584f03660324f078fd812342a1e75edd6d Mon Sep 17 00:00:00 2001 From: kbuild test robot Date: Thu, 30 Apr 2015 21:03:04 +0800 Subject: [PATCH 0041/1163] i2o: fix simple_return.cocci warnings drivers/staging/i2o/iop.c:777:1-3: WARNING: end returns can be simpified Simplify a trivial if-return sequence. Possibly combine with a preceding function call. Generated by: scripts/coccinelle/misc/simple_return.cocci CC: Alan Cox Signed-off-by: Fengguang Wu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/i2o/iop.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/i2o/iop.c b/drivers/staging/i2o/iop.c index c88df551bbb0..3c2379097586 100644 --- a/drivers/staging/i2o/iop.c +++ b/drivers/staging/i2o/iop.c @@ -777,11 +777,7 @@ static int i2o_iop_online(struct i2o_controller *c) /* In READY state */ osm_debug("%s: Attempting to enable...\n", c->name); - rc = i2o_iop_enable(c); - if (rc) - return rc; - - return 0; + return i2o_iop_enable(c); } /** From 3746e6f93bbf28a25d2d69350ab6bfba02e14654 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Wed, 8 Apr 2015 17:24:02 -0600 Subject: [PATCH 0042/1163] staging: lustre: llite: remove obsolete conditional code Remove conditional flock/aops code that was only for out-of-tree vendor kernels but is not relevant for in-kernel code. Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/llite/llite_internal.h | 4 ---- .../staging/lustre/lustre/llite/llite_lib.c | 8 -------- drivers/staging/lustre/lustre/llite/rw26.c | 20 ------------------- 3 files changed, 32 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 5f918e3c4683..1253b3cf50a8 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -727,11 +727,7 @@ 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; diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index a27af7882170..f3980b3fb45b 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -227,14 +227,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, if (sbi->ll_flags & LL_SBI_USER_XATTR) data->ocd_connect_flags |= OBD_CONNECT_XATTR; -#ifdef HAVE_MS_FLOCK_LOCK - /* force vfs to use lustre handler for flock() calls - bug 10743 */ - sb->s_flags |= MS_FLOCK_LOCK; -#endif -#ifdef MS_HAS_NEW_AOPS - sb->s_flags |= MS_HAS_NEW_AOPS; -#endif - if (sbi->ll_flags & LL_SBI_FLOCK) sbi->ll_fop = &ll_file_operations_flock; else if (sbi->ll_flags & LL_SBI_LOCALFLOCK) diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index c6c824356464..7c643130499f 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -517,7 +517,6 @@ static int ll_migratepage(struct address_space *mapping, } #endif -#ifndef MS_HAS_NEW_AOPS const struct address_space_operations ll_aops = { .readpage = ll_readpage, .direct_IO = ll_direct_IO_26, @@ -532,22 +531,3 @@ const struct address_space_operations ll_aops = { .migratepage = ll_migratepage, #endif }; -#else -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, - .orig_aops.writepage = ll_writepage, - .orig_aops.writepages = ll_writepages, - .orig_aops.set_page_dirty = ll_set_page_dirty, - .orig_aops.prepare_write = ll_prepare_write, - .orig_aops.commit_write = ll_commit_write, - .orig_aops.invalidatepage = ll_invalidatepage, - .orig_aops.releasepage = ll_releasepage, -#ifdef CONFIG_MIGRATION - .orig_aops.migratepage = ll_migratepage, -#endif - .write_begin = ll_write_begin, - .write_end = ll_write_end -}; -#endif From 97903a26fcfc84b93a9cdb09d649c1b748383c24 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sun, 12 Apr 2015 22:55:02 +0200 Subject: [PATCH 0043/1163] staging: lustre: llite: drop uses of OBD free functions Replace OBD_FREE and OBD_FREE_PTR by kfree. The semantic patch that makes these changes is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr, size; @@ - OBD_FREE(ptr, size); + kfree(ptr); @@ expression ptr; @@ - OBD_FREE_PTR(ptr); + kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dcache.c | 6 ++-- drivers/staging/lustre/lustre/llite/dir.c | 34 +++++++++--------- drivers/staging/lustre/lustre/llite/file.c | 36 +++++++++---------- .../staging/lustre/lustre/llite/llite_close.c | 6 ++-- .../staging/lustre/lustre/llite/llite_lib.c | 31 ++++++++-------- .../staging/lustre/lustre/llite/llite_nfs.c | 2 +- .../lustre/lustre/llite/llite_rmtacl.c | 4 +-- drivers/staging/lustre/lustre/llite/lloop.c | 8 ++--- drivers/staging/lustre/lustre/llite/namei.c | 2 +- .../staging/lustre/lustre/llite/statahead.c | 20 +++++------ .../staging/lustre/lustre/llite/xattr_cache.c | 6 ++-- 11 files changed, 77 insertions(+), 78 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index 5af01351306d..7b008a64707d 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -52,7 +52,7 @@ static void free_dentry_data(struct rcu_head *head) struct ll_dentry_data *lld; lld = container_of(head, struct ll_dentry_data, lld_rcu_head); - OBD_FREE_PTR(lld); + kfree(lld); } /* should NOT be called with the dcache lock, see fs/dcache.c */ @@ -67,7 +67,7 @@ static void ll_release(struct dentry *de) if (lld->lld_it) { ll_intent_release(lld->lld_it); - OBD_FREE(lld->lld_it, sizeof(*lld->lld_it)); + kfree(lld->lld_it); } de->d_fsdata = NULL; @@ -194,7 +194,7 @@ int ll_d_init(struct dentry *de) de->d_fsdata = lld; __d_lustre_invalidate(de); } else { - OBD_FREE_PTR(lld); + kfree(lld); } spin_unlock(&de->d_lock); } else { diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index a5bc694dcb64..0f5d57cb149a 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -239,7 +239,7 @@ static int ll_dir_filler(void *_hash, struct page *page0) ll_pagevec_lru_add_file(&lru_pvec); if (page_pool != &page0) - OBD_FREE(page_pool, sizeof(struct page *) * max_pages); + kfree(page_pool); return rc; } @@ -650,7 +650,7 @@ static int ll_send_mgc_param(struct obd_export *mgc, char *string) sizeof(struct mgs_send_param), msp, NULL); if (rc) CERROR("Failed to set parameter: %d\n", rc); - OBD_FREE_PTR(msp); + kfree(msp); return rc; } @@ -787,7 +787,7 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, end: if (param != NULL) - OBD_FREE(param, MGS_PARAM_MAXLEN); + kfree(param); } return rc; } @@ -1072,7 +1072,7 @@ static int copy_and_ioctl(int cmd, struct obd_export *exp, rc = obd_iocontrol(cmd, exp, size, copy, NULL); out: - OBD_FREE(copy, size); + kfree(copy); return rc; } @@ -1163,7 +1163,7 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) oqctl->qc_cmd = Q_QUOTAOFF; obd_quotactl(sbi->ll_md_exp, oqctl); } - OBD_FREE_PTR(oqctl); + kfree(oqctl); return rc; } /* If QIF_SPACE is not set, client should collect the @@ -1206,11 +1206,11 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) oqctl->qc_dqblk.dqb_valid &= ~QIF_SPACE; } - OBD_FREE_PTR(oqctl_tmp); + kfree(oqctl_tmp); } out: QCTL_COPY(qctl, oqctl); - OBD_FREE_PTR(oqctl); + kfree(oqctl); } return rc; @@ -1437,7 +1437,7 @@ lmv_out_free: } free_lmv: if (tmp) - OBD_FREE(tmp, lum_size); + kfree(tmp); return rc; } case LL_IOC_REMOVE_ENTRY: { @@ -1657,7 +1657,7 @@ free_lmm: if (rc < 0) CDEBUG(D_INFO, "obd_quotacheck failed: rc %d\n", rc); - OBD_FREE_PTR(oqctl); + kfree(oqctl); return error ?: rc; } case OBD_IOC_POLL_QUOTACHECK: { @@ -1691,7 +1691,7 @@ free_lmm: goto out_poll; } out_poll: - OBD_FREE_PTR(check); + kfree(check); return rc; } case LL_IOC_QUOTACTL: { @@ -1712,7 +1712,7 @@ out_poll: rc = -EFAULT; out_quotactl: - OBD_FREE_PTR(qctl); + kfree(qctl); return rc; } case OBD_IOC_GETDTNAME: @@ -1781,13 +1781,13 @@ out_quotactl: /* We don't know the true size yet; copy the fixed-size part */ if (copy_from_user(hur, (void *)arg, sizeof(*hur))) { - OBD_FREE_PTR(hur); + kfree(hur); return -EFAULT; } /* Compute the whole struct size */ totalsize = hur_len(hur); - OBD_FREE_PTR(hur); + kfree(hur); if (totalsize < 0) return -E2BIG; @@ -1865,7 +1865,7 @@ out_quotactl: if (!copy) return -ENOMEM; if (copy_from_user(copy, (char *)arg, sizeof(*copy))) { - OBD_FREE_PTR(copy); + kfree(copy); return -EFAULT; } @@ -1873,7 +1873,7 @@ out_quotactl: if (copy_to_user((char *)arg, copy, sizeof(*copy))) rc = -EFAULT; - OBD_FREE_PTR(copy); + kfree(copy); return rc; } case LL_IOC_HSM_COPY_END: { @@ -1884,7 +1884,7 @@ out_quotactl: if (!copy) return -ENOMEM; if (copy_from_user(copy, (char *)arg, sizeof(*copy))) { - OBD_FREE_PTR(copy); + kfree(copy); return -EFAULT; } @@ -1892,7 +1892,7 @@ out_quotactl: if (copy_to_user((char *)arg, copy, sizeof(*copy))) rc = -EFAULT; - OBD_FREE_PTR(copy); + kfree(copy); return rc; } default: diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 4b44c634fcc3..6e50b3554e33 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -213,7 +213,7 @@ out: md_clear_open_replay_data(md_exp, och); /* Free @och if it is not waiting for DONE_WRITING. */ och->och_fh.cookie = DEAD_HANDLE_MAGIC; - OBD_FREE_PTR(och); + kfree(och); } if (req) /* This is close request */ ptlrpc_req_finished(req); @@ -693,7 +693,7 @@ restart: out_och_free: if (rc) { if (och_p && *och_p) { - OBD_FREE(*och_p, sizeof(struct obd_client_handle)); + kfree(*och_p); *och_p = NULL; /* OBD_FREE writes some magic there */ (*och_usecount)--; } @@ -875,7 +875,7 @@ out_close: out_release_it: ll_intent_release(&it); out: - OBD_FREE_PTR(och); + kfree(och); return ERR_PTR(rc); } @@ -1779,7 +1779,7 @@ int ll_fid2path(struct inode *inode, void __user *arg) rc = -EFAULT; gf_free: - OBD_FREE(gfout, outsize); + kfree(gfout); return rc; } @@ -1883,7 +1883,7 @@ int ll_data_version(struct inode *inode, __u64 *data_version, *data_version = obdo->o_data_version; } - OBD_FREE_PTR(obdo); + kfree(obdo); out: ccc_inode_lsm_put(inode, lsm); return rc; @@ -2110,7 +2110,7 @@ putgl: free: if (llss != NULL) - OBD_FREE_PTR(llss); + kfree(llss); return rc; } @@ -2195,10 +2195,10 @@ static int ll_hsm_import(struct inode *inode, struct file *file, out: if (hss != NULL) - OBD_FREE_PTR(hss); + kfree(hss); if (attr != NULL) - OBD_FREE_PTR(attr); + kfree(attr); return rc; } @@ -2350,7 +2350,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, hus); if (IS_ERR(op_data)) { - OBD_FREE_PTR(hus); + kfree(hus); return PTR_ERR(op_data); } @@ -2361,7 +2361,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = -EFAULT; ll_finish_md_op_data(op_data); - OBD_FREE_PTR(hus); + kfree(hus); return rc; } case LL_IOC_HSM_STATE_SET: { @@ -2373,13 +2373,13 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return -ENOMEM; if (copy_from_user(hss, (char *)arg, sizeof(*hss))) { - OBD_FREE_PTR(hss); + kfree(hss); return -EFAULT; } rc = ll_hsm_state_set(inode, hss); - OBD_FREE_PTR(hss); + kfree(hss); return rc; } case LL_IOC_HSM_ACTION: { @@ -2394,7 +2394,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, hca); if (IS_ERR(op_data)) { - OBD_FREE_PTR(hca); + kfree(hca); return PTR_ERR(op_data); } @@ -2405,7 +2405,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = -EFAULT; ll_finish_md_op_data(op_data); - OBD_FREE_PTR(hca); + kfree(hca); return rc; } case LL_IOC_SET_LEASE: { @@ -2500,13 +2500,13 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return -ENOMEM; if (copy_from_user(hui, (void *)arg, sizeof(*hui))) { - OBD_FREE_PTR(hui); + kfree(hui); return -EFAULT; } rc = ll_hsm_import(inode, file, hui); - OBD_FREE_PTR(hui); + kfree(hui); return rc; } default: { @@ -3251,7 +3251,7 @@ void ll_iocontrol_unregister(void *magic) list_del(&tmp->iocd_list); up_write(&llioc.ioc_sem); - OBD_FREE(tmp, size); + kfree(tmp); return; } } @@ -3619,6 +3619,6 @@ int ll_layout_restore(struct inode *inode) hur->hur_request.hr_itemcount = 1; rc = obd_iocontrol(LL_IOC_HSM_REQUEST, cl_i2sbi(inode)->ll_md_exp, len, hur, NULL); - OBD_FREE(hur, len); + kfree(hur); return rc; } diff --git a/drivers/staging/lustre/lustre/llite/llite_close.c b/drivers/staging/lustre/lustre/llite/llite_close.c index a94ba02ccf02..7bdae723fedd 100644 --- a/drivers/staging/lustre/lustre/llite/llite_close.c +++ b/drivers/staging/lustre/lustre/llite/llite_close.c @@ -305,7 +305,7 @@ out: ll_finish_md_op_data(op_data); if (och) { md_clear_open_replay_data(ll_i2sbi(inode)->ll_md_exp, och); - OBD_FREE_PTR(och); + kfree(och); } } @@ -374,7 +374,7 @@ int ll_close_thread_start(struct ll_close_queue **lcq_ret) task = kthread_run(ll_close_thread, lcq, "ll_close"); if (IS_ERR(task)) { - OBD_FREE(lcq, sizeof(*lcq)); + kfree(lcq); return PTR_ERR(task); } @@ -389,5 +389,5 @@ void ll_close_thread_shutdown(struct ll_close_queue *lcq) atomic_inc(&lcq->lcq_stop); wake_up(&lcq->lcq_waitq); wait_for_completion(&lcq->lcq_comp); - OBD_FREE(lcq, sizeof(*lcq)); + kfree(lcq); } diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index f3980b3fb45b..f44abb661404 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -145,7 +145,7 @@ static void ll_free_sbi(struct super_block *sb) spin_lock(&ll_sb_lock); list_del(&sbi->ll_list); spin_unlock(&ll_sb_lock); - OBD_FREE(sbi, sizeof(*sbi)); + kfree(sbi); } } @@ -177,7 +177,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, osfs = kzalloc(sizeof(*osfs), GFP_NOFS); if (!osfs) { - OBD_FREE_PTR(data); + kfree(data); return -ENOMEM; } @@ -288,7 +288,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, valid ^ CLIENT_CONNECT_MDT_REQD, ","); LCONSOLE_ERROR_MSG(0x170, "Server %s does not support feature(s) needed for correct operation of this client (%s). Please upgrade server or downgrade client.\n", sbi->ll_md_exp->exp_obd->obd_name, buf); - OBD_FREE(buf, PAGE_CACHE_SIZE); + kfree(buf); err = -EPROTO; goto out_md_fid; } @@ -493,7 +493,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, err = md_getattr(sbi->ll_md_exp, op_data, &request); if (oc) capa_put(oc); - OBD_FREE_PTR(op_data); + kfree(op_data); if (err) { CERROR("%s: md_getattr failed for root: rc = %d\n", sbi->ll_md_exp->exp_obd->obd_name, err); @@ -575,9 +575,9 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, } if (data != NULL) - OBD_FREE_PTR(data); + kfree(data); if (osfs != NULL) - OBD_FREE_PTR(osfs); + kfree(osfs); return err; out_root: @@ -596,9 +596,9 @@ out_md: sbi->ll_md_exp = NULL; out: if (data != NULL) - OBD_FREE_PTR(data); + kfree(data); if (osfs != NULL) - OBD_FREE_PTR(osfs); + kfree(osfs); lprocfs_unregister_mountpoint(sbi); return err; } @@ -924,7 +924,7 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) lsi->lsi_llsbi = sbi = ll_init_sbi(); if (!sbi) { module_put(THIS_MODULE); - OBD_FREE_PTR(cfg); + kfree(cfg); return -ENOMEM; } @@ -986,15 +986,15 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) out_free: if (md) - OBD_FREE(md, strlen(lprof->lp_md) + instlen + 2); + kfree(md); if (dt) - OBD_FREE(dt, strlen(lprof->lp_dt) + instlen + 2); + kfree(dt); if (err) ll_put_super(sb); else if (sbi->ll_flags & LL_SBI_VERBOSE) LCONSOLE_WARN("Mounted %s\n", profilenm); - OBD_FREE_PTR(cfg); + kfree(cfg); return err; } /* ll_fill_super */ @@ -1118,8 +1118,7 @@ void ll_clear_inode(struct inode *inode) ll_md_real_close(inode, FMODE_READ); if (S_ISLNK(inode->i_mode) && lli->lli_symlink_name) { - OBD_FREE(lli->lli_symlink_name, - strlen(lli->lli_symlink_name) + 1); + kfree(lli->lli_symlink_name); lli->lli_symlink_name = NULL; } @@ -1949,7 +1948,7 @@ void ll_umount_begin(struct super_block *sb) obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_dt_exp, sizeof(*ioc_data), ioc_data, NULL); - OBD_FREE_PTR(ioc_data); + kfree(ioc_data); } /* Really, we'd like to wait until there are no requests outstanding, @@ -2228,7 +2227,7 @@ void ll_finish_md_op_data(struct md_op_data *op_data) { capa_put(op_data->op_capa1); capa_put(op_data->op_capa2); - OBD_FREE_PTR(op_data); + kfree(op_data); } int ll_show_options(struct seq_file *seq, struct dentry *dentry) diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c index db43b81386f7..8d1c253d4669 100644 --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c +++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c @@ -116,7 +116,7 @@ struct inode *search_inode_for_lustre(struct super_block *sb, /* mds_fid2dentry ignores f_type */ rc = md_getattr(sbi->ll_md_exp, op_data, &req); - OBD_FREE_PTR(op_data); + kfree(op_data); if (rc) { CERROR("can't get object attrs, fid "DFID", rc %d\n", PFID(fid), rc); diff --git a/drivers/staging/lustre/lustre/llite/llite_rmtacl.c b/drivers/staging/lustre/lustre/llite/llite_rmtacl.c index f4da156f3874..c8a450b5cb18 100644 --- a/drivers/staging/lustre/lustre/llite/llite_rmtacl.c +++ b/drivers/staging/lustre/lustre/llite/llite_rmtacl.c @@ -94,7 +94,7 @@ static void rce_free(struct rmtacl_ctl_entry *rce) if (!list_empty(&rce->rce_list)) list_del(&rce->rce_list); - OBD_FREE_PTR(rce); + kfree(rce); } static struct rmtacl_ctl_entry *__rct_search(struct rmtacl_ctl_table *rct, @@ -205,7 +205,7 @@ void ee_free(struct eacl_entry *ee) if (ee->ee_acl) lustre_ext_acl_xattr_free(ee->ee_acl); - OBD_FREE_PTR(ee); + kfree(ee); } static struct eacl_entry *__et_search_del(struct eacl_table *et, pid_t key, diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c index 413a8408e3f5..cc00fd10fbcf 100644 --- a/drivers/staging/lustre/lustre/llite/lloop.c +++ b/drivers/staging/lustre/lustre/llite/lloop.c @@ -840,9 +840,9 @@ out_mem4: out_mem3: while (i--) put_disk(disks[i]); - OBD_FREE(disks, max_loop * sizeof(*disks)); + kfree(disks); out_mem2: - OBD_FREE(loop_dev, max_loop * sizeof(*loop_dev)); + kfree(loop_dev); out_mem1: unregister_blkdev(lloop_major, "lloop"); ll_iocontrol_unregister(ll_iocontrol_magic); @@ -863,8 +863,8 @@ static void lloop_exit(void) unregister_blkdev(lloop_major, "lloop"); - OBD_FREE(disks, max_loop * sizeof(*disks)); - OBD_FREE(loop_dev, max_loop * sizeof(*loop_dev)); + kfree(disks); + kfree(loop_dev); } module_init(lloop_init); diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 5a25dcd10126..72ce6e72845f 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -665,7 +665,7 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, out_release: ll_intent_release(it); - OBD_FREE(it, sizeof(*it)); + kfree(it); return rc; } diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index 7f8071242f23..fdf953f691fa 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -312,7 +312,7 @@ static void ll_sa_entry_cleanup(struct ll_statahead_info *sai, entry->se_minfo = NULL; ll_intent_release(&minfo->mi_it); iput(minfo->mi_dir); - OBD_FREE_PTR(minfo); + kfree(minfo); } if (req) { @@ -336,7 +336,7 @@ static void ll_sa_entry_put(struct ll_statahead_info *sai, ll_sa_entry_cleanup(sai, entry); iput(entry->se_inode); - OBD_FREE(entry, entry->se_size); + kfree(entry); atomic_dec(&sai->sai_cache_count); } } @@ -544,7 +544,7 @@ static void ll_sai_put(struct ll_statahead_info *sai) LASSERT(agl_list_empty(sai)); iput(inode); - OBD_FREE_PTR(sai); + kfree(sai); } } @@ -772,7 +772,7 @@ out: if (rc != 0) { ll_intent_release(it); iput(dir); - OBD_FREE_PTR(minfo); + kfree(minfo); } if (sai != NULL) ll_sai_put(sai); @@ -786,8 +786,8 @@ static void sa_args_fini(struct md_enqueue_info *minfo, iput(minfo->mi_dir); capa_put(minfo->mi_data.op_capa1); capa_put(minfo->mi_data.op_capa2); - OBD_FREE_PTR(minfo); - OBD_FREE_PTR(einfo); + kfree(minfo); + kfree(einfo); } /** @@ -816,15 +816,15 @@ static int sa_args_init(struct inode *dir, struct inode *child, minfo = kzalloc(sizeof(*minfo), GFP_NOFS); if (!minfo) { - OBD_FREE_PTR(einfo); + kfree(einfo); return -ENOMEM; } op_data = ll_prep_md_op_data(&minfo->mi_data, dir, child, qstr->name, qstr->len, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) { - OBD_FREE_PTR(einfo); - OBD_FREE_PTR(minfo); + kfree(einfo); + kfree(minfo); return PTR_ERR(op_data); } @@ -1720,7 +1720,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, out: if (sai != NULL) - OBD_FREE_PTR(sai); + kfree(sai); spin_lock(&lli->lli_sa_lock); lli->lli_opendir_key = NULL; lli->lli_opendir_pid = 0; diff --git a/drivers/staging/lustre/lustre/llite/xattr_cache.c b/drivers/staging/lustre/lustre/llite/xattr_cache.c index 69ea92adf4f1..6956dec53fcc 100644 --- a/drivers/staging/lustre/lustre/llite/xattr_cache.c +++ b/drivers/staging/lustre/lustre/llite/xattr_cache.c @@ -144,7 +144,7 @@ static int ll_xattr_cache_add(struct list_head *cache, return 0; err_value: - OBD_FREE(xattr->xe_name, xattr->xe_namelen); + kfree(xattr->xe_name); err_name: OBD_SLAB_FREE_PTR(xattr, xattr_kmem); @@ -170,8 +170,8 @@ static int ll_xattr_cache_del(struct list_head *cache, if (ll_xattr_cache_find(cache, xattr_name, &xattr) == 0) { list_del(&xattr->xe_list); - OBD_FREE(xattr->xe_name, xattr->xe_namelen); - OBD_FREE(xattr->xe_value, xattr->xe_vallen); + kfree(xattr->xe_name); + kfree(xattr->xe_value); OBD_SLAB_FREE_PTR(xattr, xattr_kmem); return 0; From 840c94d574a8bb5fb03cad0b5aa1bd0e2984b01a Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sun, 12 Apr 2015 23:34:20 +0200 Subject: [PATCH 0044/1163] staging: lustre: drop uses of some OBD alloc and free functions Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by kzalloc or calloc, as appropriate. Replace OBD_FREE and OBD_FREE_PTR by kfree. A simplified version of the semantic patch that makes these changes in the OBD_ALLOC/FREE case is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr,e1,e2; @@ - OBD_ALLOC(ptr,sizeof e1 * e2) + ptr = kcalloc(e2, sizeof e1, GFP_NOFS) @@ expression ptr,size; @@ - OBD_ALLOC(ptr,size) + ptr = kzalloc(size, GFP_NOFS) @@ expression ptr, size; @@ - OBD_FREE(ptr, size); + kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lov/lov_dev.c | 18 +++++----- drivers/staging/lustre/lustre/lov/lov_io.c | 5 +-- drivers/staging/lustre/lustre/lov/lov_obd.c | 21 ++++++------ drivers/staging/lustre/lustre/lov/lov_pool.c | 18 +++++----- .../staging/lustre/lustre/lov/lov_request.c | 34 +++++++++---------- .../staging/lustre/lustre/lov/lovsub_dev.c | 4 +-- 6 files changed, 50 insertions(+), 50 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_dev.c b/drivers/staging/lustre/lustre/lov/lov_dev.c index 711b837ddba2..63db87af7fe2 100644 --- a/drivers/staging/lustre/lustre/lov/lov_dev.c +++ b/drivers/staging/lustre/lustre/lov/lov_dev.c @@ -285,10 +285,10 @@ static void lov_emerg_free(struct lov_device_emerg **emrg, int nr) LASSERT(em->emrg_page_list.pl_nr == 0); if (em->emrg_env != NULL) cl_env_put(em->emrg_env, &em->emrg_refcheck); - OBD_FREE_PTR(em); + kfree(em); } } - OBD_FREE(emrg, nr * sizeof(emrg[0])); + kfree(emrg); } static struct lu_device *lov_device_free(const struct lu_env *env, @@ -299,10 +299,10 @@ static struct lu_device *lov_device_free(const struct lu_env *env, cl_device_fini(lu2cl_dev(d)); if (ld->ld_target != NULL) - OBD_FREE(ld->ld_target, nr * sizeof(ld->ld_target[0])); + kfree(ld->ld_target); if (ld->ld_emrg != NULL) lov_emerg_free(ld->ld_emrg, nr); - OBD_FREE_PTR(ld); + kfree(ld); return NULL; } @@ -323,13 +323,13 @@ static struct lov_device_emerg **lov_emerg_alloc(int nr) int i; int result; - OBD_ALLOC(emerg, nr * sizeof(emerg[0])); + emerg = kcalloc(nr, sizeof(emerg[0]), GFP_NOFS); if (emerg == NULL) return ERR_PTR(-ENOMEM); for (result = i = 0; i < nr && result == 0; i++) { struct lov_device_emerg *em; - OBD_ALLOC_PTR(em); + em = kzalloc(sizeof(*em), GFP_NOFS); if (em != NULL) { emerg[i] = em; cl_page_list_init(&em->emrg_page_list); @@ -369,12 +369,12 @@ static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev) if (IS_ERR(emerg)) return PTR_ERR(emerg); - OBD_ALLOC(newd, tgt_size * sz); + newd = kcalloc(tgt_size, sz, GFP_NOFS); if (newd != NULL) { mutex_lock(&dev->ld_mutex); if (sub_size > 0) { memcpy(newd, dev->ld_target, sub_size * sz); - OBD_FREE(dev->ld_target, sub_size * sz); + kfree(dev->ld_target); } dev->ld_target = newd; dev->ld_target_nr = tgt_size; @@ -478,7 +478,7 @@ static struct lu_device *lov_device_alloc(const struct lu_env *env, struct obd_device *obd; int rc; - OBD_ALLOC_PTR(ld); + ld = kzalloc(sizeof(*ld), GFP_NOFS); if (ld == NULL) return ERR_PTR(-ENOMEM); diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c index cf96e0d01e22..a043df0c519f 100644 --- a/drivers/staging/lustre/lustre/lov/lov_io.c +++ b/drivers/staging/lustre/lustre/lov/lov_io.c @@ -70,7 +70,7 @@ static void lov_io_sub_fini(const struct lu_env *env, struct lov_io *lio, if (sub->sub_stripe == lio->lis_single_subio_index) lio->lis_single_subio_index = -1; else if (!sub->sub_borrowed) - OBD_FREE_PTR(sub->sub_io); + kfree(sub->sub_io); sub->sub_io = NULL; } if (sub->sub_env != NULL && !IS_ERR(sub->sub_env)) { @@ -179,7 +179,8 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio, sub->sub_io = &lio->lis_single_subio; lio->lis_single_subio_index = stripe; } else { - OBD_ALLOC_PTR(sub->sub_io); + sub->sub_io = kzalloc(sizeof(*sub->sub_io), + GFP_NOFS); if (sub->sub_io == NULL) result = -ENOMEM; } diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 02781576637e..7e1253809708 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -554,7 +554,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, newsize = max_t(__u32, lov->lov_tgt_size, 2); while (newsize < index + 1) newsize <<= 1; - OBD_ALLOC(newtgts, sizeof(*newtgts) * newsize); + newtgts = kcalloc(newsize, sizeof(*newtgts), GFP_NOFS); if (newtgts == NULL) { mutex_unlock(&lov->lov_lock); return -ENOMEM; @@ -571,13 +571,13 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, lov->lov_tgt_size = newsize; smp_rmb(); if (old) - OBD_FREE(old, sizeof(*old) * oldsize); + kfree(old); CDEBUG(D_CONFIG, "tgts: %p size: %d\n", lov->lov_tgts, lov->lov_tgt_size); } - OBD_ALLOC_PTR(tgt); + tgt = kzalloc(sizeof(*tgt), GFP_NOFS); if (!tgt) { mutex_unlock(&lov->lov_lock); return -ENOMEM; @@ -586,7 +586,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, rc = lov_ost_pool_add(&lov->lov_packed, index, lov->lov_tgt_size); if (rc) { mutex_unlock(&lov->lov_lock); - OBD_FREE_PTR(tgt); + kfree(tgt); return rc; } @@ -712,7 +712,7 @@ static void __lov_del_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) if (tgt->ltd_exp) lov_disconnect_obd(obd, tgt); - OBD_FREE_PTR(tgt); + kfree(tgt); /* Manual cleanup - no cleanup logs to clean up the osc's. We must do it ourselves. And we can't do it from lov_cleanup, @@ -903,8 +903,7 @@ static int lov_cleanup(struct obd_device *obd) lov_del_target(obd, i, NULL, 0); } obd_putref(obd); - OBD_FREE(lov->lov_tgts, sizeof(*lov->lov_tgts) * - lov->lov_tgt_size); + kfree(lov->lov_tgts); lov->lov_tgt_size = 0; } return 0; @@ -994,7 +993,7 @@ static int lov_recreate(struct obd_export *exp, struct obdo *src_oa, LASSERT(src_oa->o_valid & OBD_MD_FLFLAGS && src_oa->o_flags & OBD_FL_RECREATE_OBJS); - OBD_ALLOC(obj_mdp, sizeof(*obj_mdp)); + obj_mdp = kzalloc(sizeof(*obj_mdp), GFP_NOFS); if (obj_mdp == NULL) return -ENOMEM; @@ -1032,7 +1031,7 @@ static int lov_recreate(struct obd_export *exp, struct obdo *src_oa, rc = obd_create(NULL, lov->lov_tgts[ost_idx]->ltd_exp, src_oa, &obj_mdp, oti); out: - OBD_FREE(obj_mdp, sizeof(*obj_mdp)); + kfree(obj_mdp); return rc; } @@ -1532,7 +1531,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, return -EAGAIN; LASSERT(tgt && tgt->ltd_exp); - OBD_ALLOC_PTR(oqctl); + oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS); if (!oqctl) return -ENOMEM; @@ -1543,7 +1542,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, qctl->qc_valid = QC_OSTIDX; qctl->obd_uuid = tgt->ltd_uuid; } - OBD_FREE_PTR(oqctl); + kfree(oqctl); break; } default: { diff --git a/drivers/staging/lustre/lustre/lov/lov_pool.c b/drivers/staging/lustre/lustre/lov/lov_pool.c index d96163de773f..75301fa066a0 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pool.c +++ b/drivers/staging/lustre/lustre/lov/lov_pool.c @@ -67,7 +67,7 @@ void lov_pool_putref(struct pool_desc *pool) LASSERT(pool->pool_proc_entry == NULL); lov_ost_pool_free(&(pool->pool_rr.lqr_pool)); lov_ost_pool_free(&(pool->pool_obds)); - OBD_FREE_PTR(pool); + kfree(pool); } } @@ -210,7 +210,7 @@ static void *pool_proc_start(struct seq_file *s, loff_t *pos) return NULL; } - OBD_ALLOC_PTR(iter); + iter = kzalloc(sizeof(*iter), GFP_NOFS); if (!iter) return ERR_PTR(-ENOMEM); iter->magic = POOL_IT_MAGIC; @@ -246,7 +246,7 @@ static void pool_proc_stop(struct seq_file *s, void *v) * will work */ s->private = iter->pool; lov_pool_putref(iter->pool); - OBD_FREE_PTR(iter); + kfree(iter); } return; } @@ -327,7 +327,7 @@ int lov_ost_pool_init(struct ost_pool *op, unsigned int count) op->op_count = 0; init_rwsem(&op->op_rw_sem); op->op_size = count; - OBD_ALLOC(op->op_array, op->op_size * sizeof(op->op_array[0])); + op->op_array = kcalloc(op->op_size, sizeof(op->op_array[0]), GFP_NOFS); if (op->op_array == NULL) { op->op_size = 0; return -ENOMEM; @@ -347,13 +347,13 @@ int lov_ost_pool_extend(struct ost_pool *op, unsigned int min_count) return 0; new_size = max(min_count, 2 * op->op_size); - OBD_ALLOC(new, new_size * sizeof(op->op_array[0])); + new = kcalloc(new_size, sizeof(op->op_array[0]), GFP_NOFS); if (new == NULL) return -ENOMEM; /* copy old array to new one */ memcpy(new, op->op_array, op->op_size * sizeof(op->op_array[0])); - OBD_FREE(op->op_array, op->op_size * sizeof(op->op_array[0])); + kfree(op->op_array); op->op_array = new; op->op_size = new_size; return 0; @@ -411,7 +411,7 @@ int lov_ost_pool_free(struct ost_pool *op) down_write(&op->op_rw_sem); - OBD_FREE(op->op_array, op->op_size * sizeof(op->op_array[0])); + kfree(op->op_array); op->op_array = NULL; op->op_count = 0; op->op_size = 0; @@ -432,7 +432,7 @@ int lov_pool_new(struct obd_device *obd, char *poolname) if (strlen(poolname) > LOV_MAXPOOLNAME) return -ENAMETOOLONG; - OBD_ALLOC_PTR(new_pool); + new_pool = kzalloc(sizeof(*new_pool), GFP_NOFS); if (new_pool == NULL) return -ENOMEM; @@ -498,7 +498,7 @@ out_err: lov_ost_pool_free(&new_pool->pool_rr.lqr_pool); out_free_pool_obds: lov_ost_pool_free(&new_pool->pool_obds); - OBD_FREE_PTR(new_pool); + kfree(new_pool); return rc; } diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index 933e2d1f8127..0a8cdbe1a537 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -71,9 +71,8 @@ void lov_finish_set(struct lov_request_set *set) if (req->rq_oi.oi_md) OBD_FREE_LARGE(req->rq_oi.oi_md, req->rq_buflen); if (req->rq_oi.oi_osfs) - OBD_FREE(req->rq_oi.oi_osfs, - sizeof(*req->rq_oi.oi_osfs)); - OBD_FREE(req, sizeof(*req)); + kfree(req->rq_oi.oi_osfs); + kfree(req); } if (set->set_pga) { @@ -83,7 +82,7 @@ void lov_finish_set(struct lov_request_set *set) if (set->set_lockh) lov_llh_put(set->set_lockh); - OBD_FREE(set, sizeof(*set)); + kfree(set); } int lov_set_finished(struct lov_request_set *set, int idempotent) @@ -286,7 +285,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_obd *lov = &exp->exp_obd->u.lov; int rc = 0, i; - OBD_ALLOC(set, sizeof(*set)); + set = kzalloc(sizeof(*set), GFP_NOFS); if (set == NULL) return -ENOMEM; lov_init_set(set); @@ -312,7 +311,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo, continue; } - OBD_ALLOC(req, sizeof(*req)); + req = kzalloc(sizeof(*req), GFP_NOFS); if (req == NULL) { rc = -ENOMEM; goto out_set; @@ -323,7 +322,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo, OBDO_ALLOC(req->rq_oi.oi_oa); if (req->rq_oi.oi_oa == NULL) { - OBD_FREE(req, sizeof(*req)); + kfree(req); rc = -ENOMEM; goto out_set; } @@ -369,7 +368,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_obd *lov = &exp->exp_obd->u.lov; int rc = 0, i; - OBD_ALLOC(set, sizeof(*set)); + set = kzalloc(sizeof(*set), GFP_NOFS); if (set == NULL) return -ENOMEM; lov_init_set(set); @@ -395,7 +394,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo, continue; } - OBD_ALLOC(req, sizeof(*req)); + req = kzalloc(sizeof(*req), GFP_NOFS); if (req == NULL) { rc = -ENOMEM; goto out_set; @@ -406,7 +405,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo, OBDO_ALLOC(req->rq_oi.oi_oa); if (req->rq_oi.oi_oa == NULL) { - OBD_FREE(req, sizeof(*req)); + kfree(req); rc = -ENOMEM; goto out_set; } @@ -488,7 +487,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_obd *lov = &exp->exp_obd->u.lov; int rc = 0, i; - OBD_ALLOC(set, sizeof(*set)); + set = kzalloc(sizeof(*set), GFP_NOFS); if (set == NULL) return -ENOMEM; lov_init_set(set); @@ -511,7 +510,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo, continue; } - OBD_ALLOC(req, sizeof(*req)); + req = kzalloc(sizeof(*req), GFP_NOFS); if (req == NULL) { rc = -ENOMEM; goto out_set; @@ -521,7 +520,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo, OBDO_ALLOC(req->rq_oi.oi_oa); if (req->rq_oi.oi_oa == NULL) { - OBD_FREE(req, sizeof(*req)); + kfree(req); rc = -ENOMEM; goto out_set; } @@ -716,7 +715,7 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo, struct lov_obd *lov = &obd->u.lov; int rc = 0, i; - OBD_ALLOC(set, sizeof(*set)); + set = kzalloc(sizeof(*set), GFP_NOFS); if (set == NULL) return -ENOMEM; lov_init_set(set); @@ -742,15 +741,16 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo, continue; } - OBD_ALLOC(req, sizeof(*req)); + req = kzalloc(sizeof(*req), GFP_NOFS); if (req == NULL) { rc = -ENOMEM; goto out_set; } - OBD_ALLOC(req->rq_oi.oi_osfs, sizeof(*req->rq_oi.oi_osfs)); + req->rq_oi.oi_osfs = kzalloc(sizeof(*req->rq_oi.oi_osfs), + GFP_NOFS); if (req->rq_oi.oi_osfs == NULL) { - OBD_FREE(req, sizeof(*req)); + kfree(req); rc = -ENOMEM; goto out_set; } diff --git a/drivers/staging/lustre/lustre/lov/lovsub_dev.c b/drivers/staging/lustre/lustre/lov/lovsub_dev.c index 42336f13a76f..90d9ec386a1a 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_dev.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_dev.c @@ -136,7 +136,7 @@ static struct lu_device *lovsub_device_free(const struct lu_env *env, lu_site_print(env, d->ld_site, &msgdata, lu_cdebug_printer); } cl_device_fini(lu2cl_dev(d)); - OBD_FREE_PTR(lsd); + kfree(lsd); return next; } @@ -172,7 +172,7 @@ static struct lu_device *lovsub_device_alloc(const struct lu_env *env, struct lu_device *d; struct lovsub_device *lsd; - OBD_ALLOC_PTR(lsd); + lsd = kzalloc(sizeof(*lsd), GFP_NOFS); if (lsd != NULL) { int result; From 3b2f5202c52a842a6528a72e85b46435c1d59116 Mon Sep 17 00:00:00 2001 From: Dzmitry Sledneu Date: Sat, 18 Apr 2015 15:20:43 +0200 Subject: [PATCH 0045/1163] staging: lustre: Make struct mdc_kuc_fops static This patch fixes the following Sparse warning: "symbol 'mdc_kuc_fops' was not declared. Should it be static?". Signed-off-by: Dzmitry Sledneu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index acfe08e459c0..b41e50ea6ed8 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -147,7 +147,7 @@ static ssize_t mdc_kuc_write(struct file *file, return count; } -struct file_operations mdc_kuc_fops = { +static struct file_operations mdc_kuc_fops = { .open = mdc_kuc_open, .write = mdc_kuc_write, .release = single_release, From 9c4e936abfadf5fc64481f06f7ba351b007af1ff Mon Sep 17 00:00:00 2001 From: Andreas Theodosiou Date: Sun, 5 Apr 2015 02:09:30 +0300 Subject: [PATCH 0046/1163] staging : unisys: Fix brace coding style issue This is a patch to visorchannel/visorchannel_funcs.c that fixes a couple of brace warnings found by checkpatch.pl. Signed-off-by: Andreas Theodosiou Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchannel/visorchannel_funcs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c index 7a9a7242f75d..9ae5f752bbf5 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c @@ -405,9 +405,8 @@ signalremove_inner(struct visorchannel *channel, u32 queue, void *msg) return FALSE; /* no signals to remove */ sig_hdr.tail = (sig_hdr.tail + 1) % sig_hdr.max_slots; - if (!sig_read_data(channel, queue, &sig_hdr, sig_hdr.tail, msg)) { + if (!sig_read_data(channel, queue, &sig_hdr, sig_hdr.tail, msg)) return FALSE; - } sig_hdr.num_received++; /* For each data field in SIGNAL_QUEUE_HEADER that was modified, @@ -470,9 +469,8 @@ signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg) mb(); /* required for channel synch */ if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, head)) return FALSE; - if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_sent)) { + if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_sent)) return FALSE; - } return TRUE; } From 1ba00980f6b9151066e8ed19e4eb37e769b3ef70 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Mon, 6 Apr 2015 10:27:40 -0400 Subject: [PATCH 0047/1163] staging: unisys: fix kdump support The s-Par drivers used to be out-of-tree, so they needed a parameter to let them know we were going into a dump. This patch removes that code and uses the built-in kernel function instead. Reviewed-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/globals.h | 1 - drivers/staging/unisys/visorchipset/visorchipset_main.c | 7 ++----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/globals.h b/drivers/staging/unisys/visorchipset/globals.h index f76e498a36b5..36b21ec3b120 100644 --- a/drivers/staging/unisys/visorchipset/globals.h +++ b/drivers/staging/unisys/visorchipset/globals.h @@ -36,7 +36,6 @@ extern int visorchipset_serverregwait; extern int visorchipset_clientregwait; extern int visorchipset_testteardown; extern int visorchipset_disable_controlvm; -extern int visorchipset_crash_kernel; extern int visorchipset_holdchipsetready; #endif diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index f2663d2c7530..899bf684cf00 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -30,6 +30,7 @@ #include #include #include +#include #define CURRENT_FILE_PC VISOR_CHIPSET_PC_visorchipset_main_c #define TEST_VNIC_PHYSITF "eth0" /* physical network itf for @@ -2207,7 +2208,7 @@ visorchipset_init(void) } if (!visorchipset_disable_controlvm) { /* if booting in a crash kernel */ - if (visorchipset_crash_kernel) + if (is_kdump_kernel()) INIT_DELAYED_WORK(&periodic_controlvm_work, setup_crash_devices_work_queue); else @@ -2315,10 +2316,6 @@ module_param_named(disable_controlvm, visorchipset_disable_controlvm, int, MODULE_PARM_DESC(visorchipset_disable_controlvm, "1 to disable polling of controlVm channel"); int visorchipset_disable_controlvm = 0; /* default is off */ -module_param_named(crash_kernel, visorchipset_crash_kernel, int, S_IRUGO); -MODULE_PARM_DESC(visorchipset_crash_kernel, - "1 means we are running in crash kernel"); -int visorchipset_crash_kernel = 0; /* default is running in non-crash kernel */ module_param_named(holdchipsetready, visorchipset_holdchipsetready, int, S_IRUGO); MODULE_PARM_DESC(visorchipset_holdchipsetready, From 0a22650b920fa9062e75ea51941a6249a0d16be7 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Mon, 13 Apr 2015 10:28:38 -0400 Subject: [PATCH 0048/1163] staging: unisys: visorchipset: Remove unused NONULLSTR() Signed-off-by: Jes Sorensen Tested-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset_main.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 899bf684cf00..6144a945629f 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -52,14 +52,6 @@ static ulong poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; static ulong most_recent_message_jiffies; /* when we got our last * controlvm message */ -static inline char * -NONULLSTR(char *s) -{ - if (s) - return s; - return ""; -} - static int serverregistered; static int clientregistered; From c1f834eb104d67a57ac745a36ace5e084328bda6 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Mon, 13 Apr 2015 10:28:39 -0400 Subject: [PATCH 0049/1163] staging: unisys: visorchipset: Avoid struct typedef abuse Signed-off-by: Jes Sorensen Tested-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/visorchipset/visorchipset_main.c | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 6144a945629f..9e142a919982 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -92,17 +92,19 @@ static LIST_HEAD(dev_info_list); static struct visorchannel *controlvm_channel; /* Manages the request payload in the controlvm channel */ -static struct controlvm_payload_info { +struct visor_controlvm_payload_info { u8 __iomem *ptr; /* pointer to base address of payload pool */ u64 offset; /* offset from beginning of controlvm * channel to beginning of payload * pool */ u32 bytes; /* number of bytes in payload pool */ -} controlvm_payload_info; +}; + +static struct visor_controlvm_payload_info controlvm_payload_info; /* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE / * CONTROLVM_DUMP_GETTEXTDUMP / CONTROLVM_DUMP_COMPLETE conversation. */ -static struct livedump_info { +struct visor_livedump_info { struct controlvm_message_header dumpcapture_header; struct controlvm_message_header gettextdump_header; struct controlvm_message_header dumpcomplete_header; @@ -111,7 +113,9 @@ static struct livedump_info { ulong length; atomic_t buffers_in_use; ulong destination; -} livedump_info; +}; + +static struct visor_livedump_info livedump_info; /* The following globals are used to handle the scenario where we are unable to * offload the payload from a controlvm message due to memory requirements. In @@ -1263,7 +1267,7 @@ my_device_destroy(struct controlvm_message *inmsg) */ static int initialize_controlvm_payload_info(HOSTADDRESS phys_addr, u64 offset, u32 bytes, - struct controlvm_payload_info *info) + struct visor_controlvm_payload_info *info) { u8 __iomem *payload = NULL; int rc = CONTROLVM_RESP_SUCCESS; @@ -1272,7 +1276,7 @@ initialize_controlvm_payload_info(HOSTADDRESS phys_addr, u64 offset, u32 bytes, rc = -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID; goto cleanup; } - memset(info, 0, sizeof(struct controlvm_payload_info)); + memset(info, 0, sizeof(struct visor_controlvm_payload_info)); if ((offset == 0) || (bytes == 0)) { rc = -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID; goto cleanup; @@ -1298,13 +1302,13 @@ cleanup: } static void -destroy_controlvm_payload_info(struct controlvm_payload_info *info) +destroy_controlvm_payload_info(struct visor_controlvm_payload_info *info) { if (info->ptr) { iounmap(info->ptr); info->ptr = NULL; } - memset(info, 0, sizeof(struct controlvm_payload_info)); + memset(info, 0, sizeof(struct visor_controlvm_payload_info)); } static void From f4c11551e7109f0d3a4708a149903e4c75e962d2 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Mon, 13 Apr 2015 10:28:40 -0400 Subject: [PATCH 0050/1163] staging: unisys: visorchipset: Get rid of ugly BOOL/TRUE/FALSE usage Signed-off-by: Jes Sorensen Tested-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/parser.c | 24 ++--- drivers/staging/unisys/visorchipset/parser.h | 8 +- .../unisys/visorchipset/visorchipset.h | 10 +- .../unisys/visorchipset/visorchipset_main.c | 98 +++++++++---------- 4 files changed, 70 insertions(+), 70 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/parser.c b/drivers/staging/unisys/visorchipset/parser.c index d8a2d6f5a75d..b30e4c158b41 100644 --- a/drivers/staging/unisys/visorchipset/parser.c +++ b/drivers/staging/unisys/visorchipset/parser.c @@ -36,13 +36,13 @@ struct parser_context { ulong param_bytes; u8 *curr; ulong bytes_remaining; - BOOL byte_stream; + bool byte_stream; char data[0]; }; static struct parser_context * -parser_init_guts(u64 addr, u32 bytes, BOOL local, - BOOL standard_payload_header, BOOL *retry) +parser_init_guts(u64 addr, u32 bytes, bool local, + bool standard_payload_header, bool *retry) { int allocbytes = sizeof(struct parser_context) + bytes; struct parser_context *rc = NULL; @@ -51,7 +51,7 @@ parser_init_guts(u64 addr, u32 bytes, BOOL local, struct spar_controlvm_parameters_header *phdr = NULL; if (retry) - *retry = FALSE; + *retry = false; if (!standard_payload_header) /* alloc and 0 extra byte to ensure payload is * '\0'-terminated @@ -60,14 +60,14 @@ parser_init_guts(u64 addr, u32 bytes, BOOL local, if ((controlvm_payload_bytes_buffered + bytes) > MAX_CONTROLVM_PAYLOAD_BYTES) { if (retry) - *retry = TRUE; + *retry = true; rc = NULL; goto cleanup; } ctx = kzalloc(allocbytes, GFP_KERNEL|__GFP_NORETRY); if (!ctx) { if (retry) - *retry = TRUE; + *retry = true; rc = NULL; goto cleanup; } @@ -76,7 +76,7 @@ parser_init_guts(u64 addr, u32 bytes, BOOL local, ctx->param_bytes = bytes; ctx->curr = NULL; ctx->bytes_remaining = 0; - ctx->byte_stream = FALSE; + ctx->byte_stream = false; if (local) { void *p; @@ -98,7 +98,7 @@ parser_init_guts(u64 addr, u32 bytes, BOOL local, } } if (!standard_payload_header) { - ctx->byte_stream = TRUE; + ctx->byte_stream = true; rc = ctx; goto cleanup; } @@ -135,9 +135,9 @@ cleanup: } struct parser_context * -parser_init(u64 addr, u32 bytes, BOOL local, BOOL *retry) +parser_init(u64 addr, u32 bytes, bool local, bool *retry) { - return parser_init_guts(addr, bytes, local, TRUE, retry); + return parser_init_guts(addr, bytes, local, true, retry); } /* Call this instead of parser_init() if the payload area consists of just @@ -146,9 +146,9 @@ parser_init(u64 addr, u32 bytes, BOOL local, BOOL *retry) * parser_byteStream_get() to obtain the data. */ struct parser_context * -parser_init_byte_stream(u64 addr, u32 bytes, BOOL local, BOOL *retry) +parser_init_byte_stream(u64 addr, u32 bytes, bool local, bool *retry) { - return parser_init_guts(addr, bytes, local, FALSE, retry); + return parser_init_guts(addr, bytes, local, false, retry); } /* Obtain '\0'-terminated copy of string in payload area. diff --git a/drivers/staging/unisys/visorchipset/parser.h b/drivers/staging/unisys/visorchipset/parser.h index 2b903f1beff2..d3b0b33348b3 100644 --- a/drivers/staging/unisys/visorchipset/parser.h +++ b/drivers/staging/unisys/visorchipset/parser.h @@ -30,10 +30,10 @@ typedef enum { PARSERSTRING_NAME, } PARSER_WHICH_STRING; -struct parser_context *parser_init(u64 addr, u32 bytes, BOOL isLocal, - BOOL *tryAgain); -struct parser_context *parser_init_byte_stream(u64 addr, u32 bytes, BOOL local, - BOOL *retry); +struct parser_context *parser_init(u64 addr, u32 bytes, bool isLocal, + bool *tryAgain); +struct parser_context *parser_init_byte_stream(u64 addr, u32 bytes, bool local, + bool *retry); void parser_param_start(struct parser_context *ctx, PARSER_WHICH_STRING which_string); void *parser_param_get(struct parser_context *ctx, char *nam, int namesize); diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index bd46df9ef45a..4c1a74f6a5b8 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -217,19 +217,19 @@ typedef void (*SPARREPORTEVENT_COMPLETE_FUNC) (struct controlvm_message *msg, void visorchipset_device_pause_response(ulong bus_no, ulong dev_no, int response); -BOOL visorchipset_get_bus_info(ulong bus_no, +bool visorchipset_get_bus_info(ulong bus_no, struct visorchipset_bus_info *bus_info); -BOOL visorchipset_get_device_info(ulong bus_no, ulong dev_no, +bool visorchipset_get_device_info(ulong bus_no, ulong dev_no, struct visorchipset_device_info *dev_info); -BOOL visorchipset_set_bus_context(ulong bus_no, void *context); -BOOL visorchipset_set_device_context(ulong bus_no, ulong dev_no, void *context); +bool visorchipset_set_bus_context(ulong bus_no, void *context); +bool visorchipset_set_device_context(ulong bus_no, ulong dev_no, void *context); int visorchipset_chipset_ready(void); int visorchipset_chipset_selftest(void); int visorchipset_chipset_notready(void); void visorchipset_save_message(struct controlvm_message *msg, enum crash_obj_type type); void *visorchipset_cache_alloc(struct kmem_cache *pool, - BOOL ok_to_block, char *fn, int ln); + bool ok_to_block, char *fn, int ln); void visorchipset_cache_free(struct kmem_cache *pool, void *p, char *fn, int ln); diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 9e142a919982..8e7885452a72 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -108,7 +108,7 @@ struct visor_livedump_info { struct controlvm_message_header dumpcapture_header; struct controlvm_message_header gettextdump_header; struct controlvm_message_header dumpcomplete_header; - BOOL gettextdump_outstanding; + bool gettextdump_outstanding; u32 crc32; ulong length; atomic_t buffers_in_use; @@ -123,7 +123,7 @@ static struct visor_livedump_info livedump_info; * process it again the next time controlvm_periodic_work() runs. */ static struct controlvm_message controlvm_pending_msg; -static BOOL controlvm_pending_msg_valid = FALSE; +static bool controlvm_pending_msg_valid = false; /* Pool of struct putfile_buffer_entry, for keeping track of pending (incoming) * TRANSMIT_FILE PutFile payloads. @@ -776,7 +776,7 @@ static void bus_responder(enum controlvm_id cmd_id, ulong bus_no, int response) { struct visorchipset_bus_info *p = NULL; - BOOL need_clear = FALSE; + bool need_clear = false; p = findbus(&bus_info_list, bus_no); if (!p) @@ -791,7 +791,7 @@ bus_responder(enum controlvm_id cmd_id, ulong bus_no, int response) if (cmd_id == CONTROLVM_BUS_CREATE) p->state.created = 1; if (cmd_id == CONTROLVM_BUS_DESTROY) - need_clear = TRUE; + need_clear = true; } if (p->pending_msg_hdr.id == CONTROLVM_INVALID) @@ -840,7 +840,7 @@ device_responder(enum controlvm_id cmd_id, ulong bus_no, ulong dev_no, int response) { struct visorchipset_device_info *p = NULL; - BOOL need_clear = FALSE; + bool need_clear = false; p = finddevice(&dev_info_list, bus_no, dev_no); if (!p) @@ -849,7 +849,7 @@ device_responder(enum controlvm_id cmd_id, ulong bus_no, ulong dev_no, if (cmd_id == CONTROLVM_DEVICE_CREATE) p->state.created = 1; if (cmd_id == CONTROLVM_DEVICE_DESTROY) - need_clear = TRUE; + need_clear = true; } if (p->pending_msg_hdr.id == CONTROLVM_INVALID) @@ -867,9 +867,9 @@ device_responder(enum controlvm_id cmd_id, ulong bus_no, ulong dev_no, static void bus_epilog(u32 bus_no, u32 cmd, struct controlvm_message_header *msg_hdr, - int response, BOOL need_response) + int response, bool need_response) { - BOOL notified = FALSE; + bool notified = false; struct visorchipset_bus_info *bus_info = findbus(&bus_info_list, bus_no); @@ -900,23 +900,23 @@ bus_epilog(u32 bus_no, * devices */ if (busdev_server_notifiers.bus_create) { (*busdev_server_notifiers.bus_create) (bus_no); - notified = TRUE; + notified = true; } if ((!bus_info->flags.server) /*client */ && busdev_client_notifiers.bus_create) { (*busdev_client_notifiers.bus_create) (bus_no); - notified = TRUE; + notified = true; } break; case CONTROLVM_BUS_DESTROY: if (busdev_server_notifiers.bus_destroy) { (*busdev_server_notifiers.bus_destroy) (bus_no); - notified = TRUE; + notified = true; } if ((!bus_info->flags.server) /*client */ && busdev_client_notifiers.bus_destroy) { (*busdev_client_notifiers.bus_destroy) (bus_no); - notified = TRUE; + notified = true; } break; } @@ -935,10 +935,10 @@ bus_epilog(u32 bus_no, static void device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd, struct controlvm_message_header *msg_hdr, int response, - BOOL need_response, BOOL for_visorbus) + bool need_response, bool for_visorbus) { struct visorchipset_busdev_notifiers *notifiers = NULL; - BOOL notified = FALSE; + bool notified = false; struct visorchipset_device_info *dev_info = finddevice(&dev_info_list, bus_no, dev_no); @@ -967,7 +967,7 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd, case CONTROLVM_DEVICE_CREATE: if (notifiers->device_create) { (*notifiers->device_create) (bus_no, dev_no); - notified = TRUE; + notified = true; } break; case CONTROLVM_DEVICE_CHANGESTATE: @@ -978,7 +978,7 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd, if (notifiers->device_resume) { (*notifiers->device_resume) (bus_no, dev_no); - notified = TRUE; + notified = true; } } /* ServerNotReady / ServerLost / SegmentStateStandby */ @@ -991,7 +991,7 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd, if (notifiers->device_pause) { (*notifiers->device_pause) (bus_no, dev_no); - notified = TRUE; + notified = true; } } else if (state.alive == segment_state_paused.alive && state.operating == @@ -1013,7 +1013,7 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd, case CONTROLVM_DEVICE_DESTROY: if (notifiers->device_destroy) { (*notifiers->device_destroy) (bus_no, dev_no); - notified = TRUE; + notified = true; } break; } @@ -1262,7 +1262,7 @@ my_device_destroy(struct controlvm_message *inmsg) /* When provided with the physical address of the controlvm channel * (phys_addr), the offset to the payload area we need to manage * (offset), and the size of this payload area (bytes), fills in the - * controlvm_payload_info struct. Returns TRUE for success or FALSE + * controlvm_payload_info struct. Returns true for success or false * for failure. */ static int @@ -1416,17 +1416,17 @@ chipset_notready(struct controlvm_message_header *msg_hdr) /* This is your "one-stop" shop for grabbing the next message from the * CONTROLVM_QUEUE_EVENT queue in the controlvm channel. */ -static BOOL +static bool read_controlvm_event(struct controlvm_message *msg) { if (visorchannel_signalremove(controlvm_channel, CONTROLVM_QUEUE_EVENT, msg)) { /* got a message */ if (msg->hdr.flags.test_message == 1) - return FALSE; - return TRUE; + return false; + return true; } - return FALSE; + return false; } /* @@ -1637,16 +1637,16 @@ parahotplug_process_message(struct controlvm_message *inmsg) /* Process a controlvm message. * Return result: - * FALSE - this function will return FALSE only in the case where the + * false - this function will return FALSE only in the case where the * controlvm message was NOT processed, but processing must be * retried before reading the next controlvm message; a * scenario where this can occur is when we need to throttle * the allocation of memory in which to copy out controlvm * payload data - * TRUE - processing of the controlvm message completed, + * true - processing of the controlvm message completed, * either successfully or with an error. */ -static BOOL +static bool handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr) { struct controlvm_message_packet *cmd = &inmsg.cmd; @@ -1659,7 +1659,7 @@ handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr) /* create parsing context if necessary */ local_addr = (inmsg.hdr.flags.test_message == 1); if (channel_addr == 0) - return TRUE; + return true; parm_addr = channel_addr + inmsg.hdr.payload_vm_offset; parm_bytes = inmsg.hdr.payload_bytes; @@ -1668,13 +1668,13 @@ handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr) * makes a difference in how we compute the virtual address. */ if (parm_addr != 0 && parm_bytes != 0) { - BOOL retry = FALSE; + bool retry = false; parser_ctx = parser_init_byte_stream(parm_addr, parm_bytes, local_addr, &retry); if (!parser_ctx && retry) - return FALSE; + return false; } if (!local_addr) { @@ -1741,7 +1741,7 @@ handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr) parser_done(parser_ctx); parser_ctx = NULL; } - return TRUE; + return true; } static HOSTADDRESS controlvm_get_channel_address(void) @@ -1759,8 +1759,8 @@ static void controlvm_periodic_work(struct work_struct *work) { struct controlvm_message inmsg; - BOOL got_command = FALSE; - BOOL handle_command_failed = FALSE; + bool got_command = false; + bool handle_command_failed = false; static u64 poll_count; /* make sure visorbus server is registered for controlvm callbacks */ @@ -1802,14 +1802,14 @@ controlvm_periodic_work(struct work_struct *work) * rather than reading a new one */ inmsg = controlvm_pending_msg; - controlvm_pending_msg_valid = FALSE; + controlvm_pending_msg_valid = false; got_command = true; } else { got_command = read_controlvm_event(&inmsg); } } - handle_command_failed = FALSE; + handle_command_failed = false; while (got_command && (!handle_command_failed)) { most_recent_message_jiffies = jiffies; if (handle_command(inmsg, @@ -1823,9 +1823,9 @@ controlvm_periodic_work(struct work_struct *work) * controlvm msg so we will attempt to * reprocess it on our next loop */ - handle_command_failed = TRUE; + handle_command_failed = true; controlvm_pending_msg = inmsg; - controlvm_pending_msg_valid = TRUE; + controlvm_pending_msg_valid = true; } } @@ -1996,60 +1996,60 @@ device_resume_response(ulong bus_no, ulong dev_no, int response) segment_state_running); } -BOOL +bool visorchipset_get_bus_info(ulong bus_no, struct visorchipset_bus_info *bus_info) { void *p = findbus(&bus_info_list, bus_no); if (!p) - return FALSE; + return false; memcpy(bus_info, p, sizeof(struct visorchipset_bus_info)); - return TRUE; + return true; } EXPORT_SYMBOL_GPL(visorchipset_get_bus_info); -BOOL +bool visorchipset_set_bus_context(ulong bus_no, void *context) { struct visorchipset_bus_info *p = findbus(&bus_info_list, bus_no); if (!p) - return FALSE; + return false; p->bus_driver_context = context; - return TRUE; + return true; } EXPORT_SYMBOL_GPL(visorchipset_set_bus_context); -BOOL +bool visorchipset_get_device_info(ulong bus_no, ulong dev_no, struct visorchipset_device_info *dev_info) { void *p = finddevice(&dev_info_list, bus_no, dev_no); if (!p) - return FALSE; + return false; memcpy(dev_info, p, sizeof(struct visorchipset_device_info)); - return TRUE; + return true; } EXPORT_SYMBOL_GPL(visorchipset_get_device_info); -BOOL +bool visorchipset_set_device_context(ulong bus_no, ulong dev_no, void *context) { struct visorchipset_device_info *p = finddevice(&dev_info_list, bus_no, dev_no); if (!p) - return FALSE; + return false; p->bus_driver_context = context; - return TRUE; + return true; } EXPORT_SYMBOL_GPL(visorchipset_set_device_context); /* Generic wrapper function for allocating memory from a kmem_cache pool. */ void * -visorchipset_cache_alloc(struct kmem_cache *pool, BOOL ok_to_block, +visorchipset_cache_alloc(struct kmem_cache *pool, bool ok_to_block, char *fn, int ln) { gfp_t gfp; From 52063eca7fd04cb4e8a5b8f0d4f99c5e8816d59e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Mon, 13 Apr 2015 10:28:41 -0400 Subject: [PATCH 0051/1163] staging: unisys: visorchipset: Do not use confuse size of long with size of u32 struct visorcipset_device_info defines bus_no and dev_no as u32, while the deprecated ulong type is 64 bits. Hence avoid promoting the values to 64 bit just to truncate them again later. Signed-off-by: Jes Sorensen Tested-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/visorchipset/visorchipset.h | 35 +++++----- .../unisys/visorchipset/visorchipset_main.c | 67 +++++++++---------- 2 files changed, 50 insertions(+), 52 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 4c1a74f6a5b8..3a8aa5614b4b 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -162,12 +162,12 @@ findbus(struct list_head *list, u32 bus_no) * visorchipset.) */ struct visorchipset_busdev_notifiers { - void (*bus_create)(ulong bus_no); - void (*bus_destroy)(ulong bus_no); - void (*device_create)(ulong bus_no, ulong dev_no); - void (*device_destroy)(ulong bus_no, ulong dev_no); - void (*device_pause)(ulong bus_no, ulong dev_no); - void (*device_resume)(ulong bus_no, ulong dev_no); + void (*bus_create)(u32 bus_no); + void (*bus_destroy)(u32 bus_no); + void (*device_create)(u32 bus_no, u32 dev_no); + void (*device_destroy)(u32 bus_no, u32 dev_no); + void (*device_pause)(u32 bus_no, u32 dev_no); + void (*device_resume)(u32 bus_no, u32 dev_no); int (*get_channel_info)(uuid_le type_uuid, ulong *min_size, ulong *max_size); }; @@ -179,12 +179,12 @@ struct visorchipset_busdev_notifiers { * -1 = it failed */ struct visorchipset_busdev_responders { - void (*bus_create)(ulong bus_no, int response); - void (*bus_destroy)(ulong bus_no, int response); - void (*device_create)(ulong bus_no, ulong dev_no, int response); - void (*device_destroy)(ulong bus_no, ulong dev_no, int response); - void (*device_pause)(ulong bus_no, ulong dev_no, int response); - void (*device_resume)(ulong bus_no, ulong dev_no, int response); + void (*bus_create)(u32 bus_no, int response); + void (*bus_destroy)(u32 bus_no, int response); + void (*device_create)(u32 bus_no, u32 dev_no, int response); + void (*device_destroy)(u32 bus_no, u32 dev_no, int response); + void (*device_pause)(u32 bus_no, u32 dev_no, int response); + void (*device_resume)(u32 bus_no, u32 dev_no, int response); }; /** Register functions (in the bus driver) to get called by visorchipset @@ -214,15 +214,14 @@ visorchipset_register_busdev_server( typedef void (*SPARREPORTEVENT_COMPLETE_FUNC) (struct controlvm_message *msg, int status); -void visorchipset_device_pause_response(ulong bus_no, ulong dev_no, - int response); +void visorchipset_device_pause_response(u32 bus_no, u32 dev_no, int response); -bool visorchipset_get_bus_info(ulong bus_no, +bool visorchipset_get_bus_info(u32 bus_no, struct visorchipset_bus_info *bus_info); -bool visorchipset_get_device_info(ulong bus_no, ulong dev_no, +bool visorchipset_get_device_info(u32 bus_no, u32 dev_no, struct visorchipset_device_info *dev_info); -bool visorchipset_set_bus_context(ulong bus_no, void *context); -bool visorchipset_set_device_context(ulong bus_no, ulong dev_no, void *context); +bool visorchipset_set_bus_context(u32 bus_no, void *context); +bool visorchipset_set_device_context(u32 bus_no, u32 dev_no, void *context); int visorchipset_chipset_ready(void); int visorchipset_chipset_selftest(void); int visorchipset_chipset_notready(void); diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 8e7885452a72..90e41cb64597 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -49,8 +49,8 @@ * message, we switch back to fast polling mode. */ #define MIN_IDLE_SECONDS 10 -static ulong poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; -static ulong most_recent_message_jiffies; /* when we got our last +static unsigned long poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; +static unsigned long most_recent_message_jiffies; /* when we got our last * controlvm message */ static int serverregistered; static int clientregistered; @@ -68,8 +68,8 @@ static struct controlvm_message_header g_del_dump_msg_hdr; static const uuid_le spar_diag_pool_channel_protocol_uuid = SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID; /* 0xffffff is an invalid Bus/Device number */ -static ulong g_diagpool_bus_no = 0xffffff; -static ulong g_diagpool_dev_no = 0xffffff; +static u32 g_diagpool_bus_no = 0xffffff; +static u32 g_diagpool_dev_no = 0xffffff; static struct controlvm_message_packet g_devicechangestate_packet; /* Only VNIC and VHBA channels are sent to visorclientbus (aka @@ -110,9 +110,9 @@ struct visor_livedump_info { struct controlvm_message_header dumpcomplete_header; bool gettextdump_outstanding; u32 crc32; - ulong length; + unsigned long length; atomic_t buffers_in_use; - ulong destination; + unsigned long destination; }; static struct visor_livedump_info livedump_info; @@ -219,11 +219,11 @@ static void parahotplug_process_list(void); static struct visorchipset_busdev_notifiers busdev_server_notifiers; static struct visorchipset_busdev_notifiers busdev_client_notifiers; -static void bus_create_response(ulong bus_no, int response); -static void bus_destroy_response(ulong bus_no, int response); -static void device_create_response(ulong bus_no, ulong dev_no, int response); -static void device_destroy_response(ulong bus_no, ulong dev_no, int response); -static void device_resume_response(ulong bus_no, ulong dev_no, int response); +static void bus_create_response(u32 bus_no, int response); +static void bus_destroy_response(u32 bus_no, int response); +static void device_create_response(u32 bus_no, u32 dev_no, int response); +static void device_destroy_response(u32 bus_no, u32 dev_no, int response); +static void device_resume_response(u32 bus_no, u32 dev_no, int response); static struct visorchipset_busdev_responders busdev_responders = { .bus_create = bus_create_response, @@ -773,7 +773,7 @@ visorchipset_save_message(struct controlvm_message *msg, EXPORT_SYMBOL_GPL(visorchipset_save_message); static void -bus_responder(enum controlvm_id cmd_id, ulong bus_no, int response) +bus_responder(enum controlvm_id cmd_id, u32 bus_no, int response) { struct visorchipset_bus_info *p = NULL; bool need_clear = false; @@ -808,7 +808,7 @@ bus_responder(enum controlvm_id cmd_id, ulong bus_no, int response) static void device_changestate_responder(enum controlvm_id cmd_id, - ulong bus_no, ulong dev_no, int response, + u32 bus_no, u32 dev_no, int response, struct spar_segment_state response_state) { struct visorchipset_device_info *p = NULL; @@ -836,8 +836,7 @@ device_changestate_responder(enum controlvm_id cmd_id, } static void -device_responder(enum controlvm_id cmd_id, ulong bus_no, ulong dev_no, - int response) +device_responder(enum controlvm_id cmd_id, u32 bus_no, u32 dev_no, int response) { struct visorchipset_device_info *p = NULL; bool need_clear = false; @@ -1033,7 +1032,7 @@ static void bus_create(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; - ulong bus_no = cmd->create_bus.bus_no; + u32 bus_no = cmd->create_bus.bus_no; int rc = CONTROLVM_RESP_SUCCESS; struct visorchipset_bus_info *bus_info = NULL; @@ -1083,7 +1082,7 @@ static void bus_destroy(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; - ulong bus_no = cmd->destroy_bus.bus_no; + u32 bus_no = cmd->destroy_bus.bus_no; struct visorchipset_bus_info *bus_info; int rc = CONTROLVM_RESP_SUCCESS; @@ -1102,7 +1101,7 @@ bus_configure(struct controlvm_message *inmsg, struct parser_context *parser_ctx) { struct controlvm_message_packet *cmd = &inmsg->cmd; - ulong bus_no = cmd->configure_bus.bus_no; + u32 bus_no = cmd->configure_bus.bus_no; struct visorchipset_bus_info *bus_info = NULL; int rc = CONTROLVM_RESP_SUCCESS; char s[99]; @@ -1142,8 +1141,8 @@ static void my_device_create(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; - ulong bus_no = cmd->create_device.bus_no; - ulong dev_no = cmd->create_device.dev_no; + u32 bus_no = cmd->create_device.bus_no; + u32 dev_no = cmd->create_device.dev_no; struct visorchipset_device_info *dev_info = NULL; struct visorchipset_bus_info *bus_info = NULL; int rc = CONTROLVM_RESP_SUCCESS; @@ -1212,8 +1211,8 @@ static void my_device_changestate(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; - ulong bus_no = cmd->device_change_state.bus_no; - ulong dev_no = cmd->device_change_state.dev_no; + u32 bus_no = cmd->device_change_state.bus_no; + u32 dev_no = cmd->device_change_state.dev_no; struct spar_segment_state state = cmd->device_change_state.state; struct visorchipset_device_info *dev_info = NULL; int rc = CONTROLVM_RESP_SUCCESS; @@ -1240,8 +1239,8 @@ static void my_device_destroy(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; - ulong bus_no = cmd->destroy_device.bus_no; - ulong dev_no = cmd->destroy_device.dev_no; + u32 bus_no = cmd->destroy_device.bus_no; + u32 dev_no = cmd->destroy_device.dev_no; struct visorchipset_device_info *dev_info = NULL; int rc = CONTROLVM_RESP_SUCCESS; @@ -1956,31 +1955,31 @@ cleanup: } static void -bus_create_response(ulong bus_no, int response) +bus_create_response(u32 bus_no, int response) { bus_responder(CONTROLVM_BUS_CREATE, bus_no, response); } static void -bus_destroy_response(ulong bus_no, int response) +bus_destroy_response(u32 bus_no, int response) { bus_responder(CONTROLVM_BUS_DESTROY, bus_no, response); } static void -device_create_response(ulong bus_no, ulong dev_no, int response) +device_create_response(u32 bus_no, u32 dev_no, int response) { device_responder(CONTROLVM_DEVICE_CREATE, bus_no, dev_no, response); } static void -device_destroy_response(ulong bus_no, ulong dev_no, int response) +device_destroy_response(u32 bus_no, u32 dev_no, int response) { device_responder(CONTROLVM_DEVICE_DESTROY, bus_no, dev_no, response); } void -visorchipset_device_pause_response(ulong bus_no, ulong dev_no, int response) +visorchipset_device_pause_response(u32 bus_no, u32 dev_no, int response) { device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE, bus_no, dev_no, response, @@ -1989,7 +1988,7 @@ visorchipset_device_pause_response(ulong bus_no, ulong dev_no, int response) EXPORT_SYMBOL_GPL(visorchipset_device_pause_response); static void -device_resume_response(ulong bus_no, ulong dev_no, int response) +device_resume_response(u32 bus_no, u32 dev_no, int response) { device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE, bus_no, dev_no, response, @@ -1997,7 +1996,7 @@ device_resume_response(ulong bus_no, ulong dev_no, int response) } bool -visorchipset_get_bus_info(ulong bus_no, struct visorchipset_bus_info *bus_info) +visorchipset_get_bus_info(u32 bus_no, struct visorchipset_bus_info *bus_info) { void *p = findbus(&bus_info_list, bus_no); @@ -2009,7 +2008,7 @@ visorchipset_get_bus_info(ulong bus_no, struct visorchipset_bus_info *bus_info) EXPORT_SYMBOL_GPL(visorchipset_get_bus_info); bool -visorchipset_set_bus_context(ulong bus_no, void *context) +visorchipset_set_bus_context(u32 bus_no, void *context) { struct visorchipset_bus_info *p = findbus(&bus_info_list, bus_no); @@ -2021,7 +2020,7 @@ visorchipset_set_bus_context(ulong bus_no, void *context) EXPORT_SYMBOL_GPL(visorchipset_set_bus_context); bool -visorchipset_get_device_info(ulong bus_no, ulong dev_no, +visorchipset_get_device_info(u32 bus_no, u32 dev_no, struct visorchipset_device_info *dev_info) { void *p = finddevice(&dev_info_list, bus_no, dev_no); @@ -2034,7 +2033,7 @@ visorchipset_get_device_info(ulong bus_no, ulong dev_no, EXPORT_SYMBOL_GPL(visorchipset_get_device_info); bool -visorchipset_set_device_context(ulong bus_no, ulong dev_no, void *context) +visorchipset_set_device_context(u32 bus_no, u32 dev_no, void *context) { struct visorchipset_device_info *p = finddevice(&dev_info_list, bus_no, dev_no); From a6e7fe5c042c171d912783a8bf0918b7f68aefe4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Mon, 13 Apr 2015 10:28:42 -0400 Subject: [PATCH 0052/1163] staging: unisys: visorchipset: Use correct type for dev_no visorchipset_bus_info.dev_no is only assigned the value of controlvm_message_packet.create_bus.dev_count, which is a u32. No point promoting it to a u64. Signed-off-by: Jes Sorensen Tested-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 3a8aa5614b4b..3848de253371 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -141,8 +141,7 @@ struct visorchipset_bus_info { struct controlvm_message_header pending_msg_hdr;/* CONTROLVM MsgHdr */ /** For private use by the bus driver */ void *bus_driver_context; - u64 dev_no; - + u32 dev_no; }; static inline struct visorchipset_bus_info * From ac48c05c678e9917b9f3e9b6e1792675a6a1d672 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Mon, 13 Apr 2015 10:28:43 -0400 Subject: [PATCH 0053/1163] staging: unisys: visorchipset: Remove unused get_channel_info notifier Signed-off-by: Jes Sorensen Tested-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 3848de253371..87b63f0dc36a 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -167,8 +167,6 @@ struct visorchipset_busdev_notifiers { void (*device_destroy)(u32 bus_no, u32 dev_no); void (*device_pause)(u32 bus_no, u32 dev_no); void (*device_resume)(u32 bus_no, u32 dev_no); - int (*get_channel_info)(uuid_le type_uuid, ulong *min_size, - ulong *max_size); }; /* These functions live inside visorchipset, and will be called to indicate From 1d4c1afac4c46723475ec8e10ff7eed3c439393c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Mon, 13 Apr 2015 10:28:44 -0400 Subject: [PATCH 0054/1163] staging: unisys: visorchipset: Get rid of ulong usage Signed-off-by: Jes Sorensen Tested-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/file.c | 6 +++--- drivers/staging/unisys/visorchipset/parser.c | 16 ++++++++-------- drivers/staging/unisys/visorchipset/parser.h | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c index 203de0b5f607..6fc56896e427 100644 --- a/drivers/staging/unisys/visorchipset/file.c +++ b/drivers/staging/unisys/visorchipset/file.c @@ -60,8 +60,8 @@ visorchipset_release(struct inode *inode, struct file *file) static int visorchipset_mmap(struct file *file, struct vm_area_struct *vma) { - ulong physaddr = 0; - ulong offset = vma->vm_pgoff << PAGE_SHIFT; + unsigned long physaddr = 0; + unsigned long offset = vma->vm_pgoff << PAGE_SHIFT; GUEST_PHYSICAL_ADDRESS addr = 0; /* sv_enable_dfp(); */ @@ -81,7 +81,7 @@ visorchipset_mmap(struct file *file, struct vm_area_struct *vma) if (addr == 0) { return -ENXIO; } - physaddr = (ulong)addr; + physaddr = (unsigned long)addr; if (remap_pfn_range(vma, vma->vm_start, physaddr >> PAGE_SHIFT, vma->vm_end - vma->vm_start, diff --git a/drivers/staging/unisys/visorchipset/parser.c b/drivers/staging/unisys/visorchipset/parser.c index b30e4c158b41..6ca6da8772a8 100644 --- a/drivers/staging/unisys/visorchipset/parser.c +++ b/drivers/staging/unisys/visorchipset/parser.c @@ -29,13 +29,13 @@ * incoming payloads. This serves as a throttling mechanism. */ #define MAX_CONTROLVM_PAYLOAD_BYTES (1024*128) -static ulong controlvm_payload_bytes_buffered; +static unsigned long controlvm_payload_bytes_buffered; struct parser_context { - ulong allocbytes; - ulong param_bytes; + unsigned long allocbytes; + unsigned long param_bytes; u8 *curr; - ulong bytes_remaining; + unsigned long bytes_remaining; bool byte_stream; char data[0]; }; @@ -84,7 +84,7 @@ parser_init_guts(u64 addr, u32 bytes, bool local, rc = NULL; goto cleanup; } - p = __va((ulong) (addr)); + p = __va((unsigned long) (addr)); memcpy(ctx->data, p, bytes); } else { rgn = visor_memregion_create(addr, bytes); @@ -165,7 +165,7 @@ parser_simpleString_get(struct parser_context *ctx) /* Obtain a copy of the buffer in the payload area. */ -void *parser_byte_stream_get(struct parser_context *ctx, ulong *nbytes) +void *parser_byte_stream_get(struct parser_context *ctx, unsigned long *nbytes) { if (!ctx->byte_stream) return NULL; @@ -265,7 +265,7 @@ void * parser_param_get(struct parser_context *ctx, char *nam, int namesize) { u8 *pscan, *pnam = nam; - ulong nscan; + unsigned long nscan; int value_length = -1, orig_value_length = -1; void *value = NULL; int i; @@ -400,7 +400,7 @@ void * parser_string_get(struct parser_context *ctx) { u8 *pscan; - ulong nscan; + unsigned long nscan; int value_length = -1; void *value = NULL; int i; diff --git a/drivers/staging/unisys/visorchipset/parser.h b/drivers/staging/unisys/visorchipset/parser.h index d3b0b33348b3..73be279bb401 100644 --- a/drivers/staging/unisys/visorchipset/parser.h +++ b/drivers/staging/unisys/visorchipset/parser.h @@ -40,7 +40,7 @@ void *parser_param_get(struct parser_context *ctx, char *nam, int namesize); void *parser_string_get(struct parser_context *ctx); uuid_le parser_id_get(struct parser_context *ctx); char *parser_simpleString_get(struct parser_context *ctx); -void *parser_byte_stream_get(struct parser_context *ctx, ulong *nbytes); +void *parser_byte_stream_get(struct parser_context *ctx, unsigned long *nbytes); void parser_done(struct parser_context *ctx); #endif From 3d3fb181309c68850762123f6f87f660a7606dfb Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Mon, 13 Apr 2015 21:16:49 -0400 Subject: [PATCH 0055/1163] staging: unisys: remove virthba driver for rewrite The virthba driver is being rewritten and will be renamed to visorhba, so delete the old driver from the source tree. Signed-off-by: Benjamin Romer Reviewed-by: Don Zickus Reviewed-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/Kconfig | 1 - drivers/staging/unisys/Makefile | 1 - drivers/staging/unisys/virthba/Kconfig | 13 - drivers/staging/unisys/virthba/Makefile | 12 - drivers/staging/unisys/virthba/virthba.c | 1572 ---------------------- drivers/staging/unisys/virthba/virthba.h | 27 - 6 files changed, 1626 deletions(-) delete mode 100644 drivers/staging/unisys/virthba/Kconfig delete mode 100644 drivers/staging/unisys/virthba/Makefile delete mode 100644 drivers/staging/unisys/virthba/virthba.c delete mode 100644 drivers/staging/unisys/virthba/virthba.h diff --git a/drivers/staging/unisys/Kconfig b/drivers/staging/unisys/Kconfig index 19fcb3465509..906cd589048d 100644 --- a/drivers/staging/unisys/Kconfig +++ b/drivers/staging/unisys/Kconfig @@ -14,6 +14,5 @@ source "drivers/staging/unisys/visorchannel/Kconfig" source "drivers/staging/unisys/visorchipset/Kconfig" source "drivers/staging/unisys/uislib/Kconfig" source "drivers/staging/unisys/virtpci/Kconfig" -source "drivers/staging/unisys/virthba/Kconfig" endif # UNISYSSPAR diff --git a/drivers/staging/unisys/Makefile b/drivers/staging/unisys/Makefile index 68b9925e7d5e..3283a013d0c6 100644 --- a/drivers/staging/unisys/Makefile +++ b/drivers/staging/unisys/Makefile @@ -6,4 +6,3 @@ obj-$(CONFIG_UNISYS_VISORCHANNEL) += visorchannel/ obj-$(CONFIG_UNISYS_VISORCHIPSET) += visorchipset/ obj-$(CONFIG_UNISYS_UISLIB) += uislib/ obj-$(CONFIG_UNISYS_VIRTPCI) += virtpci/ -obj-$(CONFIG_UNISYS_VIRTHBA) += virthba/ diff --git a/drivers/staging/unisys/virthba/Kconfig b/drivers/staging/unisys/virthba/Kconfig deleted file mode 100644 index dfadfc49114a..000000000000 --- a/drivers/staging/unisys/virthba/Kconfig +++ /dev/null @@ -1,13 +0,0 @@ -# -# Unisys virthba configuration -# - -config UNISYS_VIRTHBA - tristate "Unisys virthba driver" - depends on SCSI - select UNISYS_VISORCHIPSET - select UNISYS_UISLIB - select UNISYS_VIRTPCI - ---help--- - If you say Y here, you will enable the Unisys virthba driver. - diff --git a/drivers/staging/unisys/virthba/Makefile b/drivers/staging/unisys/virthba/Makefile deleted file mode 100644 index a4e403739183..000000000000 --- a/drivers/staging/unisys/virthba/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# -# Makefile for Unisys virthba -# - -obj-$(CONFIG_UNISYS_VIRTHBA) += virthba.o - -ccflags-y += -Idrivers/staging/unisys/include -ccflags-y += -Idrivers/staging/unisys/uislib -ccflags-y += -Idrivers/staging/unisys/visorchipset -ccflags-y += -Idrivers/staging/unisys/virtpci -ccflags-y += -Idrivers/staging/unisys/common-spar/include -ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c deleted file mode 100644 index d9001cca0f73..000000000000 --- a/drivers/staging/unisys/virthba/virthba.c +++ /dev/null @@ -1,1572 +0,0 @@ -/* virthba.c - * - * 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. - */ - -#define EXPORT_SYMTAB - -/* if you want to turn on some debugging of write device data or read - * device data, define these two undefs. You will probably want to - * customize the code which is here since it was written assuming - * reading and writing a specific data file df.64M.txt which is a - * 64Megabyte file created by Art Nilson using a scritp I wrote called - * cr_test_data.pl. The data file consists of 256 byte lines of text - * which start with an 8 digit sequence number, a colon, and then - * letters after that */ - -#include -#ifdef CONFIG_MODVERSIONS -#include -#endif - -#include "diagnostics/appos_subsystems.h" -#include "uisutils.h" -#include "uisqueue.h" -#include "uisthread.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "virthba.h" -#include "virtpci.h" -#include "visorchipset.h" -#include "version.h" -#include "guestlinuxdebug.h" -/* this is shorter than using __FILE__ (full path name) in - * debug/info/error messages - */ -#define CURRENT_FILE_PC VIRT_HBA_PC_virthba_c -#define __MYFILE__ "virthba.c" - -/* NOTE: L1_CACHE_BYTES >=128 */ -#define DEVICE_ATTRIBUTE struct device_attribute - - /* MAX_BUF = 6 lines x 10 MAXVHBA x 80 characters - * = 4800 bytes ~ 2^13 = 8192 bytes - */ -#define MAX_BUF 8192 - -/*****************************************************/ -/* Forward declarations */ -/*****************************************************/ -static int virthba_probe(struct virtpci_dev *dev, - const struct pci_device_id *id); -static void virthba_remove(struct virtpci_dev *dev); -static int virthba_abort_handler(struct scsi_cmnd *scsicmd); -static int virthba_bus_reset_handler(struct scsi_cmnd *scsicmd); -static int virthba_device_reset_handler(struct scsi_cmnd *scsicmd); -static int virthba_host_reset_handler(struct scsi_cmnd *scsicmd); -static const char *virthba_get_info(struct Scsi_Host *shp); -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 -static DEF_SCSI_QCMD(virthba_queue_command) -#else -#define virthba_queue_command virthba_queue_command_lck -#endif - -static int virthba_slave_alloc(struct scsi_device *scsidev); -static int virthba_slave_configure(struct scsi_device *scsidev); -static void virthba_slave_destroy(struct scsi_device *scsidev); -static int process_incoming_rsps(void *); -static int virthba_serverup(struct virtpci_dev *virtpcidev); -static int virthba_serverdown(struct virtpci_dev *virtpcidev, u32 state); -static void do_disk_add_remove(struct work_struct *work); -static void virthba_serverdown_complete(struct work_struct *work); -static ssize_t info_debugfs_read(struct file *file, char __user *buf, - size_t len, loff_t *offset); -static ssize_t enable_ints_write(struct file *file, - const char __user *buffer, size_t count, - loff_t *ppos); - -/*****************************************************/ -/* Globals */ -/*****************************************************/ - -static int rsltq_wait_usecs = 4000; /* Default 4ms */ -static unsigned int max_buff_len; - -/* Module options */ -static char *virthba_options = "NONE"; - -static const struct pci_device_id virthba_id_table[] = { - {PCI_DEVICE(PCI_VENDOR_ID_UNISYS, PCI_DEVICE_ID_VIRTHBA)}, - {0}, -}; - -/* export virthba_id_table */ -MODULE_DEVICE_TABLE(pci, virthba_id_table); - -static struct workqueue_struct *virthba_serverdown_workqueue; - -static struct virtpci_driver virthba_driver = { - .name = "uisvirthba", - .version = VERSION, - .vertag = NULL, - .id_table = virthba_id_table, - .probe = virthba_probe, - .remove = virthba_remove, - .resume = virthba_serverup, - .suspend = virthba_serverdown -}; - -/* The Send and Recive Buffers of the IO Queue may both be full */ -#define MAX_PENDING_REQUESTS (MIN_NUMSIGNALS*2) -#define INTERRUPT_VECTOR_MASK 0x3F - -struct scsipending { - char cmdtype; /* Type of pointer that is being stored */ - void *sent; /* The Data being tracked */ - /* struct scsi_cmnd *type for virthba_queue_command */ - /* struct uiscmdrsp *type for management commands */ -}; - -#define VIRTHBA_ERROR_COUNT 30 -#define IOS_ERROR_THRESHOLD 1000 -struct virtdisk_info { - u32 valid; - u32 channel, id, lun; /* Disk Path */ - atomic_t ios_threshold; - atomic_t error_count; - struct virtdisk_info *next; -}; - -/* Each Scsi_Host has a host_data area that contains this struct. */ -struct virthba_info { - struct Scsi_Host *scsihost; - struct virtpci_dev *virtpcidev; - struct list_head dev_info_list; - struct chaninfo chinfo; - struct irq_info intr; /* use recvInterrupt info to receive - interrupts when IOs complete */ - int interrupt_vector; - struct scsipending pending[MAX_PENDING_REQUESTS]; /* Tracks the requests - that have been */ - /* forwarded to the IOVM and haven't returned yet */ - unsigned int nextinsert; /* Start search for next pending - free slot here */ - spinlock_t privlock; - bool serverdown; - bool serverchangingstate; - unsigned long long acquire_failed_cnt; - unsigned long long interrupts_rcvd; - unsigned long long interrupts_notme; - unsigned long long interrupts_disabled; - struct work_struct serverdown_completion; - u64 __iomem *flags_addr; - atomic_t interrupt_rcvd; - wait_queue_head_t rsp_queue; - struct virtdisk_info head; -}; - -/* Work Data for dar_work_queue */ -struct diskaddremove { - u8 add; /* 0-remove, 1-add */ - struct Scsi_Host *shost; /* Scsi Host for this virthba instance */ - u32 channel, id, lun; /* Disk Path */ - struct diskaddremove *next; -}; - -#define virtpci_dev_to_virthba_virthba_get_info(d) \ - container_of(d, struct virthba_info, virtpcidev) - -static DEVICE_ATTRIBUTE *virthba_shost_attrs[]; -static struct scsi_host_template virthba_driver_template = { - .name = "Unisys Virtual HBA", - .info = virthba_get_info, - .ioctl = virthba_ioctl, - .queuecommand = virthba_queue_command, - .eh_abort_handler = virthba_abort_handler, - .eh_device_reset_handler = virthba_device_reset_handler, - .eh_bus_reset_handler = virthba_bus_reset_handler, - .eh_host_reset_handler = virthba_host_reset_handler, - .shost_attrs = virthba_shost_attrs, - -#define VIRTHBA_MAX_CMNDS 128 - .can_queue = VIRTHBA_MAX_CMNDS, - .sg_tablesize = 64, /* largest number of address/length pairs */ - .this_id = -1, - .slave_alloc = virthba_slave_alloc, - .slave_configure = virthba_slave_configure, - .slave_destroy = virthba_slave_destroy, - .use_clustering = ENABLE_CLUSTERING, -}; - -struct virthba_devices_open { - struct virthba_info *virthbainfo; -}; - -static const struct file_operations debugfs_info_fops = { - .read = info_debugfs_read, -}; - -static const struct file_operations debugfs_enable_ints_fops = { - .write = enable_ints_write, -}; - -/*****************************************************/ -/* Structs */ -/*****************************************************/ - -#define VIRTHBASOPENMAX 1 -/* array of open devices maintained by open() and close(); */ -static struct virthba_devices_open virthbas_open[VIRTHBASOPENMAX]; -static struct dentry *virthba_debugfs_dir; - -/*****************************************************/ -/* Local Functions */ -/*****************************************************/ -static int -add_scsipending_entry(struct virthba_info *vhbainfo, char cmdtype, void *new) -{ - unsigned long flags; - int insert_location; - - spin_lock_irqsave(&vhbainfo->privlock, flags); - insert_location = vhbainfo->nextinsert; - while (vhbainfo->pending[insert_location].sent) { - insert_location = (insert_location + 1) % MAX_PENDING_REQUESTS; - if (insert_location == (int)vhbainfo->nextinsert) { - spin_unlock_irqrestore(&vhbainfo->privlock, flags); - return -1; - } - } - - vhbainfo->pending[insert_location].cmdtype = cmdtype; - vhbainfo->pending[insert_location].sent = new; - vhbainfo->nextinsert = (insert_location + 1) % MAX_PENDING_REQUESTS; - spin_unlock_irqrestore(&vhbainfo->privlock, flags); - - return insert_location; -} - -static unsigned int -add_scsipending_entry_with_wait(struct virthba_info *vhbainfo, char cmdtype, - void *new) -{ - int insert_location = add_scsipending_entry(vhbainfo, cmdtype, new); - - while (insert_location == -1) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(msecs_to_jiffies(10)); - insert_location = add_scsipending_entry(vhbainfo, cmdtype, new); - } - - return (unsigned int)insert_location; -} - -static void * -del_scsipending_entry(struct virthba_info *vhbainfo, uintptr_t del) -{ - unsigned long flags; - void *sent = NULL; - - if (del < MAX_PENDING_REQUESTS) { - spin_lock_irqsave(&vhbainfo->privlock, flags); - sent = vhbainfo->pending[del].sent; - - vhbainfo->pending[del].cmdtype = 0; - vhbainfo->pending[del].sent = NULL; - spin_unlock_irqrestore(&vhbainfo->privlock, flags); - } - - return sent; -} - -/* dar_work_queue (Disk Add/Remove) */ -static struct work_struct dar_work_queue; -static struct diskaddremove *dar_work_queue_head; -static spinlock_t dar_work_queue_lock; -static unsigned short dar_work_queue_sched; -#define QUEUE_DISKADDREMOVE(dar) { \ - spin_lock_irqsave(&dar_work_queue_lock, flags); \ - if (!dar_work_queue_head) { \ - dar_work_queue_head = dar; \ - dar->next = NULL; \ - } \ - else { \ - dar->next = dar_work_queue_head; \ - dar_work_queue_head = dar; \ - } \ - if (!dar_work_queue_sched) { \ - schedule_work(&dar_work_queue); \ - dar_work_queue_sched = 1; \ - } \ - spin_unlock_irqrestore(&dar_work_queue_lock, flags); \ -} - -static inline void -send_disk_add_remove(struct diskaddremove *dar) -{ - struct scsi_device *sdev; - int error; - - sdev = scsi_device_lookup(dar->shost, dar->channel, dar->id, dar->lun); - if (sdev) { - if (!(dar->add)) - scsi_remove_device(sdev); - } else if (dar->add) { - error = - scsi_add_device(dar->shost, dar->channel, dar->id, - dar->lun); - } - kfree(dar); -} - -/*****************************************************/ -/* dar_work_queue Handler Thread */ -/*****************************************************/ -static void -do_disk_add_remove(struct work_struct *work) -{ - struct diskaddremove *dar; - struct diskaddremove *tmphead; - int i = 0; - unsigned long flags; - - spin_lock_irqsave(&dar_work_queue_lock, flags); - tmphead = dar_work_queue_head; - dar_work_queue_head = NULL; - dar_work_queue_sched = 0; - spin_unlock_irqrestore(&dar_work_queue_lock, flags); - while (tmphead) { - dar = tmphead; - tmphead = dar->next; - send_disk_add_remove(dar); - i++; - } -} - -/*****************************************************/ -/* Routine to add entry to dar_work_queue */ -/*****************************************************/ -static void -process_disk_notify(struct Scsi_Host *shost, struct uiscmdrsp *cmdrsp) -{ - struct diskaddremove *dar; - unsigned long flags; - - dar = kzalloc(sizeof(*dar), GFP_ATOMIC); - if (dar) { - dar->add = cmdrsp->disknotify.add; - dar->shost = shost; - dar->channel = cmdrsp->disknotify.channel; - dar->id = cmdrsp->disknotify.id; - dar->lun = cmdrsp->disknotify.lun; - QUEUE_DISKADDREMOVE(dar); - } -} - -/*****************************************************/ -/* Probe Remove Functions */ -/*****************************************************/ -static irqreturn_t -virthba_isr(int irq, void *dev_id) -{ - struct virthba_info *virthbainfo = (struct virthba_info *)dev_id; - struct channel_header __iomem *channel_header; - struct signal_queue_header __iomem *pqhdr; - u64 mask; - unsigned long long rc1; - - if (!virthbainfo) - return IRQ_NONE; - virthbainfo->interrupts_rcvd++; - channel_header = virthbainfo->chinfo.queueinfo->chan; - if (((readq(&channel_header->features) - & ULTRA_IO_IOVM_IS_OK_WITH_DRIVER_DISABLING_INTS) != 0) && - ((readq(&channel_header->features) & - ULTRA_IO_DRIVER_DISABLES_INTS) != - 0)) { - virthbainfo->interrupts_disabled++; - mask = ~ULTRA_CHANNEL_ENABLE_INTS; - rc1 = uisqueue_interlocked_and(virthbainfo->flags_addr, mask); - } - if (spar_signalqueue_empty(channel_header, IOCHAN_FROM_IOPART)) { - virthbainfo->interrupts_notme++; - return IRQ_NONE; - } - pqhdr = (struct signal_queue_header __iomem *) - ((char __iomem *)channel_header + - readq(&channel_header->ch_space_offset)) + IOCHAN_FROM_IOPART; - writeq(readq(&pqhdr->num_irq_received) + 1, - &pqhdr->num_irq_received); - atomic_set(&virthbainfo->interrupt_rcvd, 1); - wake_up_interruptible(&virthbainfo->rsp_queue); - return IRQ_HANDLED; -} - -static int -virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id) -{ - int error; - struct Scsi_Host *scsihost; - struct virthba_info *virthbainfo; - int rsp; - int i; - irq_handler_t handler = virthba_isr; - struct channel_header __iomem *channel_header; - struct signal_queue_header __iomem *pqhdr; - u64 mask; - - POSTCODE_LINUX_2(VHBA_PROBE_ENTRY_PC, POSTCODE_SEVERITY_INFO); - /* call scsi_host_alloc to register a scsi host adapter - * instance - this virthba that has just been created is an - * instance of a scsi host adapter. This scsi_host_alloc - * function allocates a new Scsi_Host struct & performs basic - * initialization. The host is not published to the scsi - * midlayer until scsi_add_host is called. - */ - - /* arg 2 passed in length of extra space we want allocated - * with scsi_host struct for our own use scsi_host_alloc - * assign host_no - */ - scsihost = scsi_host_alloc(&virthba_driver_template, - sizeof(struct virthba_info)); - if (!scsihost) - return -ENODEV; - - scsihost->this_id = UIS_MAGIC_VHBA; - /* linux treats max-channel differently than max-id & max-lun. - * In the latter cases, those two values result in 0 to max-1 - * (inclusive) being scanned. But in the case of channels, the - * scan is 0 to max (inclusive); so we will subtract one from - * the max-channel value. - */ - scsihost->max_channel = (unsigned)virtpcidev->scsi.max.max_channel; - scsihost->max_id = (unsigned)virtpcidev->scsi.max.max_id; - scsihost->max_lun = (unsigned)virtpcidev->scsi.max.max_lun; - scsihost->cmd_per_lun = (unsigned)virtpcidev->scsi.max.cmd_per_lun; - scsihost->max_sectors = - (unsigned short)(virtpcidev->scsi.max.max_io_size >> 9); - scsihost->sg_tablesize = - (unsigned short)(virtpcidev->scsi.max.max_io_size / PAGE_SIZE); - if (scsihost->sg_tablesize > MAX_PHYS_INFO) - scsihost->sg_tablesize = MAX_PHYS_INFO; - - /* this creates "host%d" in sysfs. If 2nd argument is NULL, - * then this generic /sys/devices/platform/host? device is - * created and /sys/scsi_host/host? -> - * /sys/devices/platform/host? If 2nd argument is not NULL, - * then this generic /sys/devices//host? is created and - * host? points to that device instead. - */ - error = scsi_add_host(scsihost, &virtpcidev->generic_dev); - if (error) { - POSTCODE_LINUX_2(VHBA_PROBE_FAILURE_PC, POSTCODE_SEVERITY_ERR); - /* decr refcount on scsihost which was incremented by - * scsi_add_host so the scsi_host gets deleted - */ - scsi_host_put(scsihost); - return -ENODEV; - } - - virthbainfo = (struct virthba_info *)scsihost->hostdata; - memset(virthbainfo, 0, sizeof(struct virthba_info)); - for (i = 0; i < VIRTHBASOPENMAX; i++) { - if (!virthbas_open[i].virthbainfo) { - virthbas_open[i].virthbainfo = virthbainfo; - break; - } - } - virthbainfo->interrupt_vector = -1; - virthbainfo->chinfo.queueinfo = &virtpcidev->queueinfo; - virthbainfo->virtpcidev = virtpcidev; - spin_lock_init(&virthbainfo->chinfo.insertlock); - - init_waitqueue_head(&virthbainfo->rsp_queue); - spin_lock_init(&virthbainfo->privlock); - memset(&virthbainfo->pending, 0, sizeof(virthbainfo->pending)); - virthbainfo->serverdown = false; - virthbainfo->serverchangingstate = false; - - virthbainfo->intr = virtpcidev->intr; - /* save of host within virthba_info */ - virthbainfo->scsihost = scsihost; - - /* save of host within virtpci_dev */ - virtpcidev->scsi.scsihost = scsihost; - - /* Setup workqueue for serverdown messages */ - INIT_WORK(&virthbainfo->serverdown_completion, - virthba_serverdown_complete); - - writeq(readq(&virthbainfo->chinfo.queueinfo->chan->features) | - ULTRA_IO_CHANNEL_IS_POLLING, - &virthbainfo->chinfo.queueinfo->chan->features); - /* start thread that will receive scsicmnd responses */ - - channel_header = virthbainfo->chinfo.queueinfo->chan; - pqhdr = (struct signal_queue_header __iomem *) - ((char __iomem *)channel_header + - readq(&channel_header->ch_space_offset)) + IOCHAN_FROM_IOPART; - virthbainfo->flags_addr = &pqhdr->features; - - if (!uisthread_start(&virthbainfo->chinfo.threadinfo, - process_incoming_rsps, - virthbainfo, "vhba_incoming")) { - /* decr refcount on scsihost which was incremented by - * scsi_add_host so the scsi_host gets deleted - */ - POSTCODE_LINUX_2(VHBA_PROBE_FAILURE_PC, POSTCODE_SEVERITY_ERR); - scsi_host_put(scsihost); - return -ENODEV; - } - virthbainfo->interrupt_vector = - virthbainfo->intr.recv_irq_handle & INTERRUPT_VECTOR_MASK; - rsp = request_irq(virthbainfo->interrupt_vector, handler, IRQF_SHARED, - scsihost->hostt->name, virthbainfo); - if (rsp != 0) { - virthbainfo->interrupt_vector = -1; - POSTCODE_LINUX_2(VHBA_PROBE_FAILURE_PC, POSTCODE_SEVERITY_ERR); - } else { - u64 __iomem *features_addr = - &virthbainfo->chinfo.queueinfo->chan->features; - mask = ~(ULTRA_IO_CHANNEL_IS_POLLING | - ULTRA_IO_DRIVER_DISABLES_INTS); - uisqueue_interlocked_and(features_addr, mask); - mask = ULTRA_IO_DRIVER_ENABLES_INTS; - uisqueue_interlocked_or(features_addr, mask); - rsltq_wait_usecs = 4000000; - } - - scsi_scan_host(scsihost); - - POSTCODE_LINUX_2(VHBA_PROBE_EXIT_PC, POSTCODE_SEVERITY_INFO); - return 0; -} - -static void -virthba_remove(struct virtpci_dev *virtpcidev) -{ - struct virthba_info *virthbainfo; - struct Scsi_Host *scsihost = - (struct Scsi_Host *)virtpcidev->scsi.scsihost; - - virthbainfo = (struct virthba_info *)scsihost->hostdata; - if (virthbainfo->interrupt_vector != -1) - free_irq(virthbainfo->interrupt_vector, virthbainfo); - - scsi_remove_host(scsihost); - - uisthread_stop(&virthbainfo->chinfo.threadinfo); - - /* decr refcount on scsihost which was incremented by - * scsi_add_host so the scsi_host gets deleted - */ - scsi_host_put(scsihost); -} - -static int -forward_vdiskmgmt_command(enum vdisk_mgmt_types vdiskcmdtype, - struct Scsi_Host *scsihost, - struct uisscsi_dest *vdest) -{ - struct uiscmdrsp *cmdrsp; - struct virthba_info *virthbainfo = - (struct virthba_info *)scsihost->hostdata; - int notifyresult = 0xffff; - wait_queue_head_t notifyevent; - - if (virthbainfo->serverdown || virthbainfo->serverchangingstate) - return FAILED; - - cmdrsp = kzalloc(SIZEOF_CMDRSP, GFP_ATOMIC); - if (!cmdrsp) - return FAILED; /* reject */ - - init_waitqueue_head(¬ifyevent); - - /* issue VDISK_MGMT_CMD - * set type to command - as opposed to task mgmt - */ - cmdrsp->cmdtype = CMD_VDISKMGMT_TYPE; - /* specify the event that has to be triggered when this cmd is - * complete - */ - cmdrsp->vdiskmgmt.notify = (void *)¬ifyevent; - cmdrsp->vdiskmgmt.notifyresult = (void *)¬ifyresult; - - /* save destination */ - cmdrsp->vdiskmgmt.vdisktype = vdiskcmdtype; - cmdrsp->vdiskmgmt.vdest.channel = vdest->channel; - cmdrsp->vdiskmgmt.vdest.id = vdest->id; - cmdrsp->vdiskmgmt.vdest.lun = vdest->lun; - cmdrsp->vdiskmgmt.scsicmd = - (void *)(uintptr_t) - add_scsipending_entry_with_wait(virthbainfo, CMD_VDISKMGMT_TYPE, - (void *)cmdrsp); - - uisqueue_put_cmdrsp_with_lock_client(virthbainfo->chinfo.queueinfo, - cmdrsp, IOCHAN_TO_IOPART, - &virthbainfo->chinfo.insertlock, - DONT_ISSUE_INTERRUPT, (u64)NULL, - OK_TO_WAIT, "vhba"); - wait_event(notifyevent, notifyresult != 0xffff); - kfree(cmdrsp); - return SUCCESS; -} - -/*****************************************************/ -/* Scsi Host support functions */ -/*****************************************************/ - -static int -forward_taskmgmt_command(enum task_mgmt_types tasktype, - struct scsi_device *scsidev) -{ - struct uiscmdrsp *cmdrsp; - struct virthba_info *virthbainfo = - (struct virthba_info *)scsidev->host->hostdata; - int notifyresult = 0xffff; - wait_queue_head_t notifyevent; - - if (virthbainfo->serverdown || virthbainfo->serverchangingstate) - return FAILED; - - cmdrsp = kzalloc(SIZEOF_CMDRSP, GFP_ATOMIC); - if (!cmdrsp) - return FAILED; /* reject */ - - init_waitqueue_head(¬ifyevent); - - /* issue TASK_MGMT_ABORT_TASK */ - /* set type to command - as opposed to task mgmt */ - cmdrsp->cmdtype = CMD_SCSITASKMGMT_TYPE; - /* specify the event that has to be triggered when this */ - /* cmd is complete */ - cmdrsp->scsitaskmgmt.notify = (void *)¬ifyevent; - cmdrsp->scsitaskmgmt.notifyresult = (void *)¬ifyresult; - - /* save destination */ - cmdrsp->scsitaskmgmt.tasktype = tasktype; - cmdrsp->scsitaskmgmt.vdest.channel = scsidev->channel; - cmdrsp->scsitaskmgmt.vdest.id = scsidev->id; - cmdrsp->scsitaskmgmt.vdest.lun = scsidev->lun; - cmdrsp->scsitaskmgmt.scsicmd = - (void *)(uintptr_t) - add_scsipending_entry_with_wait(virthbainfo, - CMD_SCSITASKMGMT_TYPE, - (void *)cmdrsp); - - uisqueue_put_cmdrsp_with_lock_client(virthbainfo->chinfo.queueinfo, - cmdrsp, IOCHAN_TO_IOPART, - &virthbainfo->chinfo.insertlock, - DONT_ISSUE_INTERRUPT, (u64)NULL, - OK_TO_WAIT, "vhba"); - wait_event(notifyevent, notifyresult != 0xffff); - kfree(cmdrsp); - return SUCCESS; -} - -/* The abort handler returns SUCCESS if it has succeeded to make LLDD - * and all related hardware forget about the scmd. - */ -static int -virthba_abort_handler(struct scsi_cmnd *scsicmd) -{ - /* issue TASK_MGMT_ABORT_TASK */ - struct scsi_device *scsidev; - struct virtdisk_info *vdisk; - - scsidev = scsicmd->device; - for (vdisk = &((struct virthba_info *)scsidev->host->hostdata)->head; - vdisk->next; vdisk = vdisk->next) { - if ((scsidev->channel == vdisk->channel) && - (scsidev->id == vdisk->id) && - (scsidev->lun == vdisk->lun)) { - if (atomic_read(&vdisk->error_count) < - VIRTHBA_ERROR_COUNT) { - atomic_inc(&vdisk->error_count); - POSTCODE_LINUX_2(VHBA_COMMAND_HANDLER_PC, - POSTCODE_SEVERITY_INFO); - } else - atomic_set(&vdisk->ios_threshold, - IOS_ERROR_THRESHOLD); - } - } - return forward_taskmgmt_command(TASK_MGMT_ABORT_TASK, scsicmd->device); -} - -static int -virthba_bus_reset_handler(struct scsi_cmnd *scsicmd) -{ - /* issue TASK_MGMT_TARGET_RESET for each target on the bus */ - struct scsi_device *scsidev; - struct virtdisk_info *vdisk; - - scsidev = scsicmd->device; - for (vdisk = &((struct virthba_info *)scsidev->host->hostdata)->head; - vdisk->next; vdisk = vdisk->next) { - if ((scsidev->channel == vdisk->channel) && - (scsidev->id == vdisk->id) && - (scsidev->lun == vdisk->lun)) { - if (atomic_read(&vdisk->error_count) < - VIRTHBA_ERROR_COUNT) { - atomic_inc(&vdisk->error_count); - POSTCODE_LINUX_2(VHBA_COMMAND_HANDLER_PC, - POSTCODE_SEVERITY_INFO); - } else - atomic_set(&vdisk->ios_threshold, - IOS_ERROR_THRESHOLD); - } - } - return forward_taskmgmt_command(TASK_MGMT_BUS_RESET, scsicmd->device); -} - -static int -virthba_device_reset_handler(struct scsi_cmnd *scsicmd) -{ - /* issue TASK_MGMT_LUN_RESET */ - struct scsi_device *scsidev; - struct virtdisk_info *vdisk; - - scsidev = scsicmd->device; - for (vdisk = &((struct virthba_info *)scsidev->host->hostdata)->head; - vdisk->next; vdisk = vdisk->next) { - if ((scsidev->channel == vdisk->channel) && - (scsidev->id == vdisk->id) && - (scsidev->lun == vdisk->lun)) { - if (atomic_read(&vdisk->error_count) < - VIRTHBA_ERROR_COUNT) { - atomic_inc(&vdisk->error_count); - POSTCODE_LINUX_2(VHBA_COMMAND_HANDLER_PC, - POSTCODE_SEVERITY_INFO); - } else - atomic_set(&vdisk->ios_threshold, - IOS_ERROR_THRESHOLD); - } - } - return forward_taskmgmt_command(TASK_MGMT_LUN_RESET, scsicmd->device); -} - -static int -virthba_host_reset_handler(struct scsi_cmnd *scsicmd) -{ - /* issue TASK_MGMT_TARGET_RESET for each target on each bus for host */ - return SUCCESS; -} - -static char virthba_get_info_str[256]; - -static const char * -virthba_get_info(struct Scsi_Host *shp) -{ - /* Return version string */ - sprintf(virthba_get_info_str, "virthba, version %s\n", VIRTHBA_VERSION); - return virthba_get_info_str; -} - -static int -virthba_ioctl(struct scsi_device *dev, int cmd, void __user *arg) -{ - return -EINVAL; -} - -/* This returns SCSI_MLQUEUE_DEVICE_BUSY if the signal queue to IOpart - * is full. - */ -static int -virthba_queue_command_lck(struct scsi_cmnd *scsicmd, - void (*virthba_cmnd_done)(struct scsi_cmnd *)) -{ - struct scsi_device *scsidev = scsicmd->device; - int insert_location; - unsigned char op; - unsigned char *cdb = scsicmd->cmnd; - struct Scsi_Host *scsihost = scsidev->host; - struct uiscmdrsp *cmdrsp; - unsigned int i; - struct virthba_info *virthbainfo = - (struct virthba_info *)scsihost->hostdata; - struct scatterlist *sg = NULL; - struct scatterlist *sgl = NULL; - int sg_failed = 0; - - if (virthbainfo->serverdown || virthbainfo->serverchangingstate) - return SCSI_MLQUEUE_DEVICE_BUSY; - cmdrsp = kzalloc(SIZEOF_CMDRSP, GFP_ATOMIC); - if (!cmdrsp) - return 1; /* reject the command */ - - /* now saving everything we need from scsi_cmd into cmdrsp - * before we queue cmdrsp set type to command - as opposed to - * task mgmt - */ - cmdrsp->cmdtype = CMD_SCSI_TYPE; - /* save the pending insertion location. Deletion from pending - * will return the scsicmd pointer for completion - */ - insert_location = - add_scsipending_entry(virthbainfo, CMD_SCSI_TYPE, (void *)scsicmd); - if (insert_location != -1) { - cmdrsp->scsi.scsicmd = (void *)(uintptr_t)insert_location; - } else { - kfree(cmdrsp); - return SCSI_MLQUEUE_DEVICE_BUSY; - } - /* save done function that we have call when cmd is complete */ - scsicmd->scsi_done = virthba_cmnd_done; - /* save destination */ - cmdrsp->scsi.vdest.channel = scsidev->channel; - cmdrsp->scsi.vdest.id = scsidev->id; - cmdrsp->scsi.vdest.lun = scsidev->lun; - /* save datadir */ - cmdrsp->scsi.data_dir = scsicmd->sc_data_direction; - memcpy(cmdrsp->scsi.cmnd, cdb, MAX_CMND_SIZE); - - cmdrsp->scsi.bufflen = scsi_bufflen(scsicmd); - - /* keep track of the max buffer length so far. */ - if (cmdrsp->scsi.bufflen > max_buff_len) - max_buff_len = cmdrsp->scsi.bufflen; - - if (scsi_sg_count(scsicmd) > MAX_PHYS_INFO) { - del_scsipending_entry(virthbainfo, (uintptr_t)insert_location); - kfree(cmdrsp); - return 1; /* reject the command */ - } - - /* This is what we USED to do when we assumed we were running */ - /* uissd & virthba on the same Linux system. */ - /* cmdrsp->scsi.buffer = scsicmd->request_buffer; */ - /* The following code does NOT make that assumption. */ - /* convert buffer to phys information */ - if (scsi_sg_count(scsicmd) == 0) { - if (scsi_bufflen(scsicmd) > 0) { - BUG_ON(scsi_sg_count(scsicmd) == 0); - } - } else { - /* buffer is scatterlist - copy it out */ - sgl = scsi_sglist(scsicmd); - - for_each_sg(sgl, sg, scsi_sg_count(scsicmd), i) { - cmdrsp->scsi.gpi_list[i].address = sg_phys(sg); - cmdrsp->scsi.gpi_list[i].length = sg->length; - } - - if (sg_failed) { - /* BUG(); ***** For now, let it fail in uissd - * if it is a problem, as it might just - * work - */ - } - - cmdrsp->scsi.guest_phys_entries = scsi_sg_count(scsicmd); - } - - op = cdb[0]; - i = uisqueue_put_cmdrsp_with_lock_client(virthbainfo->chinfo.queueinfo, - cmdrsp, IOCHAN_TO_IOPART, - &virthbainfo->chinfo. - insertlock, - DONT_ISSUE_INTERRUPT, - (u64)NULL, DONT_WAIT, "vhba"); - if (i == 0) { - /* queue must be full - and we said don't wait - return busy */ - kfree(cmdrsp); - del_scsipending_entry(virthbainfo, (uintptr_t)insert_location); - return SCSI_MLQUEUE_DEVICE_BUSY; - } - - /* we're done with cmdrsp space - data from it has been copied - * into channel - free it now. - */ - kfree(cmdrsp); - return 0; /* non-zero implies host/device is busy */ -} - -static int -virthba_slave_alloc(struct scsi_device *scsidev) -{ - /* this called by the midlayer before scan for new devices - - * LLD can alloc any struct & do init if needed. - */ - struct virtdisk_info *vdisk; - struct virtdisk_info *tmpvdisk; - struct virthba_info *virthbainfo; - struct Scsi_Host *scsihost = (struct Scsi_Host *)scsidev->host; - - virthbainfo = (struct virthba_info *)scsihost->hostdata; - if (!virthbainfo) - return 0; /* even though we errored, treat as success */ - - for (vdisk = &virthbainfo->head; vdisk->next; vdisk = vdisk->next) { - if (vdisk->next->valid && - (vdisk->next->channel == scsidev->channel) && - (vdisk->next->id == scsidev->id) && - (vdisk->next->lun == scsidev->lun)) - return 0; - } - tmpvdisk = kzalloc(sizeof(*tmpvdisk), GFP_ATOMIC); - if (!tmpvdisk) - return 0; - - tmpvdisk->channel = scsidev->channel; - tmpvdisk->id = scsidev->id; - tmpvdisk->lun = scsidev->lun; - tmpvdisk->valid = 1; - vdisk->next = tmpvdisk; - return 0; /* success */ -} - -static int -virthba_slave_configure(struct scsi_device *scsidev) -{ - return 0; /* success */ -} - -static void -virthba_slave_destroy(struct scsi_device *scsidev) -{ - /* midlevel calls this after device has been quiesced and - * before it is to be deleted. - */ - struct virtdisk_info *vdisk, *delvdisk; - struct virthba_info *virthbainfo; - struct Scsi_Host *scsihost = (struct Scsi_Host *)scsidev->host; - - virthbainfo = (struct virthba_info *)scsihost->hostdata; - for (vdisk = &virthbainfo->head; vdisk->next; vdisk = vdisk->next) { - if (vdisk->next->valid && - (vdisk->next->channel == scsidev->channel) && - (vdisk->next->id == scsidev->id) && - (vdisk->next->lun == scsidev->lun)) { - delvdisk = vdisk->next; - vdisk->next = vdisk->next->next; - kfree(delvdisk); - return; - } - } -} - -/*****************************************************/ -/* Scsi Cmnd support thread */ -/*****************************************************/ - -static void -do_scsi_linuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd) -{ - struct virtdisk_info *vdisk; - struct scsi_device *scsidev; - struct sense_data *sd; - - scsidev = scsicmd->device; - memcpy(scsicmd->sense_buffer, cmdrsp->scsi.sensebuf, MAX_SENSE_SIZE); - sd = (struct sense_data *)scsicmd->sense_buffer; - - /* Do not log errors for disk-not-present inquiries */ - if ((cmdrsp->scsi.cmnd[0] == INQUIRY) && - (host_byte(cmdrsp->scsi.linuxstat) == DID_NO_CONNECT) && - (cmdrsp->scsi.addlstat == ADDL_SEL_TIMEOUT)) - return; - - /* Okay see what our error_count is here.... */ - for (vdisk = &((struct virthba_info *)scsidev->host->hostdata)->head; - vdisk->next; vdisk = vdisk->next) { - if ((scsidev->channel != vdisk->channel) || - (scsidev->id != vdisk->id) || - (scsidev->lun != vdisk->lun)) - continue; - - if (atomic_read(&vdisk->error_count) < VIRTHBA_ERROR_COUNT) { - atomic_inc(&vdisk->error_count); - atomic_set(&vdisk->ios_threshold, IOS_ERROR_THRESHOLD); - } - } -} - -static void -do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd) -{ - struct scsi_device *scsidev; - unsigned char buf[36]; - struct scatterlist *sg; - unsigned int i; - char *thispage; - char *thispage_orig; - int bufind = 0; - struct virtdisk_info *vdisk; - - scsidev = scsicmd->device; - if ((cmdrsp->scsi.cmnd[0] == INQUIRY) && - (cmdrsp->scsi.bufflen >= MIN_INQUIRY_RESULT_LEN)) { - if (cmdrsp->scsi.no_disk_result == 0) - return; - - /* Linux scsi code is weird; it wants - * a device at Lun 0 to issue report - * luns, but we don't want a disk - * there so we'll present a processor - * there. */ - SET_NO_DISK_INQUIRY_RESULT(buf, cmdrsp->scsi.bufflen, - scsidev->lun, - DEV_DISK_CAPABLE_NOT_PRESENT, - DEV_NOT_CAPABLE); - - if (scsi_sg_count(scsicmd) == 0) { - if (scsi_bufflen(scsicmd) > 0) { - BUG_ON(scsi_sg_count(scsicmd) == - 0); - } - memcpy(scsi_sglist(scsicmd), buf, - cmdrsp->scsi.bufflen); - return; - } - - sg = scsi_sglist(scsicmd); - for (i = 0; i < scsi_sg_count(scsicmd); i++) { - thispage_orig = kmap_atomic(sg_page(sg + i)); - thispage = (void *)((unsigned long)thispage_orig | - sg[i].offset); - memcpy(thispage, buf + bufind, sg[i].length); - kunmap_atomic(thispage_orig); - bufind += sg[i].length; - } - } else { - vdisk = &((struct virthba_info *)scsidev->host->hostdata)->head; - for ( ; vdisk->next; vdisk = vdisk->next) { - if ((scsidev->channel != vdisk->channel) || - (scsidev->id != vdisk->id) || - (scsidev->lun != vdisk->lun)) - continue; - - if (atomic_read(&vdisk->ios_threshold) > 0) { - atomic_dec(&vdisk->ios_threshold); - if (atomic_read(&vdisk->ios_threshold) == 0) { - atomic_set(&vdisk->error_count, 0); - } - } - } - } -} - -static void -complete_scsi_command(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd) -{ - /* take what we need out of cmdrsp and complete the scsicmd */ - scsicmd->result = cmdrsp->scsi.linuxstat; - if (cmdrsp->scsi.linuxstat) - do_scsi_linuxstat(cmdrsp, scsicmd); - else - do_scsi_nolinuxstat(cmdrsp, scsicmd); - - if (scsicmd->scsi_done) - scsicmd->scsi_done(scsicmd); -} - -static inline void -complete_vdiskmgmt_command(struct uiscmdrsp *cmdrsp) -{ - /* copy the result of the taskmgmt and */ - /* wake up the error handler that is waiting for this */ - *(int *)cmdrsp->vdiskmgmt.notifyresult = cmdrsp->vdiskmgmt.result; - wake_up_all((wait_queue_head_t *)cmdrsp->vdiskmgmt.notify); -} - -static inline void -complete_taskmgmt_command(struct uiscmdrsp *cmdrsp) -{ - /* copy the result of the taskmgmt and */ - /* wake up the error handler that is waiting for this */ - *(int *)cmdrsp->scsitaskmgmt.notifyresult = - cmdrsp->scsitaskmgmt.result; - wake_up_all((wait_queue_head_t *)cmdrsp->scsitaskmgmt.notify); -} - -static void -drain_queue(struct virthba_info *virthbainfo, struct chaninfo *dc, - struct uiscmdrsp *cmdrsp) -{ - unsigned long flags; - int qrslt = 0; - struct scsi_cmnd *scsicmd; - struct Scsi_Host *shost = virthbainfo->scsihost; - - while (1) { - spin_lock_irqsave(&virthbainfo->chinfo.insertlock, flags); - if (!spar_channel_client_acquire_os(dc->queueinfo->chan, - "vhba")) { - spin_unlock_irqrestore(&virthbainfo->chinfo.insertlock, - flags); - virthbainfo->acquire_failed_cnt++; - break; - } - qrslt = uisqueue_get_cmdrsp(dc->queueinfo, cmdrsp, - IOCHAN_FROM_IOPART); - spar_channel_client_release_os(dc->queueinfo->chan, "vhba"); - spin_unlock_irqrestore(&virthbainfo->chinfo.insertlock, flags); - if (qrslt == 0) - break; - if (cmdrsp->cmdtype == CMD_SCSI_TYPE) { - /* scsicmd location is returned by the - * deletion - */ - scsicmd = del_scsipending_entry(virthbainfo, - (uintptr_t) - cmdrsp->scsi.scsicmd); - if (!scsicmd) - break; - /* complete the orig cmd */ - complete_scsi_command(cmdrsp, scsicmd); - } else if (cmdrsp->cmdtype == CMD_SCSITASKMGMT_TYPE) { - if (!del_scsipending_entry(virthbainfo, - (uintptr_t)cmdrsp->scsitaskmgmt.scsicmd)) - break; - complete_taskmgmt_command(cmdrsp); - } else if (cmdrsp->cmdtype == CMD_NOTIFYGUEST_TYPE) { - /* The vHba pointer has no meaning in - * a Client/Guest Partition. Let's be - * safe and set it to NULL now. Do - * not use it here! */ - cmdrsp->disknotify.v_hba = NULL; - process_disk_notify(shost, cmdrsp); - } else if (cmdrsp->cmdtype == CMD_VDISKMGMT_TYPE) { - if (!del_scsipending_entry(virthbainfo, - (uintptr_t) - cmdrsp->vdiskmgmt.scsicmd)) - break; - complete_vdiskmgmt_command(cmdrsp); - } - /* cmdrsp is now available for reuse */ - } -} - -/* main function for the thread that waits for scsi commands to arrive - * in a specified queue - */ -static int -process_incoming_rsps(void *v) -{ - struct virthba_info *virthbainfo = v; - struct chaninfo *dc = &virthbainfo->chinfo; - struct uiscmdrsp *cmdrsp = NULL; - const int SZ = sizeof(struct uiscmdrsp); - u64 mask; - unsigned long long rc1; - - UIS_DAEMONIZE("vhba_incoming"); - /* alloc once and reuse */ - cmdrsp = kmalloc(SZ, GFP_ATOMIC); - if (!cmdrsp) { - complete_and_exit(&dc->threadinfo.has_stopped, 0); - return 0; - } - mask = ULTRA_CHANNEL_ENABLE_INTS; - while (1) { - if (kthread_should_stop()) - break; - wait_event_interruptible_timeout(virthbainfo->rsp_queue, - (atomic_read(&virthbainfo->interrupt_rcvd) == 1), - usecs_to_jiffies(rsltq_wait_usecs)); - atomic_set(&virthbainfo->interrupt_rcvd, 0); - /* drain queue */ - drain_queue(virthbainfo, dc, cmdrsp); - rc1 = uisqueue_interlocked_or(virthbainfo->flags_addr, mask); - } - - kfree(cmdrsp); - - complete_and_exit(&dc->threadinfo.has_stopped, 0); -} - -/*****************************************************/ -/* Debugfs filesystem functions */ -/*****************************************************/ - -static ssize_t info_debugfs_read(struct file *file, - char __user *buf, size_t len, loff_t *offset) -{ - ssize_t bytes_read = 0; - int str_pos = 0; - u64 phys_flags_addr; - int i; - struct virthba_info *virthbainfo; - char *vbuf; - - if (len > MAX_BUF) - len = MAX_BUF; - vbuf = kzalloc(len, GFP_KERNEL); - if (!vbuf) - return -ENOMEM; - - for (i = 0; i < VIRTHBASOPENMAX; i++) { - if (!virthbas_open[i].virthbainfo) - continue; - - virthbainfo = virthbas_open[i].virthbainfo; - - str_pos += scnprintf(vbuf + str_pos, - len - str_pos, "max_buff_len:%u\n", - max_buff_len); - - str_pos += scnprintf(vbuf + str_pos, len - str_pos, - "\nvirthba result queue poll wait:%d usecs.\n", - rsltq_wait_usecs); - str_pos += scnprintf(vbuf + str_pos, len - str_pos, - "\ninterrupts_rcvd = %llu, interrupts_disabled = %llu\n", - virthbainfo->interrupts_rcvd, - virthbainfo->interrupts_disabled); - str_pos += scnprintf(vbuf + str_pos, - len - str_pos, "\ninterrupts_notme = %llu,\n", - virthbainfo->interrupts_notme); - phys_flags_addr = virt_to_phys((__force void *) - virthbainfo->flags_addr); - str_pos += scnprintf(vbuf + str_pos, len - str_pos, - "flags_addr = %p, phys_flags_addr=0x%016llx, FeatureFlags=%llu\n", - virthbainfo->flags_addr, phys_flags_addr, - (__le64)readq(virthbainfo->flags_addr)); - str_pos += scnprintf(vbuf + str_pos, - len - str_pos, "acquire_failed_cnt:%llu\n", - virthbainfo->acquire_failed_cnt); - str_pos += scnprintf(vbuf + str_pos, len - str_pos, "\n"); - } - - bytes_read = simple_read_from_buffer(buf, len, offset, vbuf, str_pos); - kfree(vbuf); - return bytes_read; -} - -static ssize_t enable_ints_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) -{ - char buf[4]; - int i, new_value; - struct virthba_info *virthbainfo; - - u64 __iomem *features_addr; - u64 mask; - - if (count >= ARRAY_SIZE(buf)) - return -EINVAL; - - buf[count] = '\0'; - if (copy_from_user(buf, buffer, count)) - return -EFAULT; - - i = kstrtoint(buf, 10, &new_value); - - if (i != 0) - return -EFAULT; - - /* set all counts to new_value usually 0 */ - for (i = 0; i < VIRTHBASOPENMAX; i++) { - if (virthbas_open[i].virthbainfo) { - virthbainfo = virthbas_open[i].virthbainfo; - features_addr = - &virthbainfo->chinfo.queueinfo->chan->features; - if (new_value == 1) { - mask = ~(ULTRA_IO_CHANNEL_IS_POLLING | - ULTRA_IO_DRIVER_DISABLES_INTS); - uisqueue_interlocked_and(features_addr, mask); - mask = ULTRA_IO_DRIVER_ENABLES_INTS; - uisqueue_interlocked_or(features_addr, mask); - rsltq_wait_usecs = 4000000; - } else { - mask = ~(ULTRA_IO_DRIVER_ENABLES_INTS | - ULTRA_IO_DRIVER_DISABLES_INTS); - uisqueue_interlocked_and(features_addr, mask); - mask = ULTRA_IO_CHANNEL_IS_POLLING; - uisqueue_interlocked_or(features_addr, mask); - rsltq_wait_usecs = 4000; - } - } - } - return count; -} - -/* As per VirtpciFunc returns 1 for success and 0 for failure */ -static int -virthba_serverup(struct virtpci_dev *virtpcidev) -{ - struct virthba_info *virthbainfo = - (struct virthba_info *)((struct Scsi_Host *)virtpcidev->scsi. - scsihost)->hostdata; - - if (!virthbainfo->serverdown) - return 1; - - if (virthbainfo->serverchangingstate) - return 0; - - virthbainfo->serverchangingstate = true; - /* Must transition channel to ATTACHED state BEFORE we - * can start using the device again - */ - SPAR_CHANNEL_CLIENT_TRANSITION(virthbainfo->chinfo.queueinfo->chan, - dev_name(&virtpcidev->generic_dev), - CHANNELCLI_ATTACHED, NULL); - - /* Start Processing the IOVM Response Queue Again */ - if (!uisthread_start(&virthbainfo->chinfo.threadinfo, - process_incoming_rsps, - virthbainfo, "vhba_incoming")) { - return 0; - } - virthbainfo->serverdown = false; - virthbainfo->serverchangingstate = false; - - return 1; -} - -static void -virthba_serverdown_complete(struct work_struct *work) -{ - struct virthba_info *virthbainfo; - struct virtpci_dev *virtpcidev; - int i; - struct scsipending *pendingdel = NULL; - struct scsi_cmnd *scsicmd = NULL; - struct uiscmdrsp *cmdrsp; - unsigned long flags; - - virthbainfo = container_of(work, struct virthba_info, - serverdown_completion); - - /* Stop Using the IOVM Response Queue (queue should be drained - * by the end) - */ - uisthread_stop(&virthbainfo->chinfo.threadinfo); - - /* Fail Commands that weren't completed */ - spin_lock_irqsave(&virthbainfo->privlock, flags); - for (i = 0; i < MAX_PENDING_REQUESTS; i++) { - pendingdel = &virthbainfo->pending[i]; - switch (pendingdel->cmdtype) { - case CMD_SCSI_TYPE: - scsicmd = (struct scsi_cmnd *)pendingdel->sent; - scsicmd->result = DID_RESET << 16; - if (scsicmd->scsi_done) - scsicmd->scsi_done(scsicmd); - break; - case CMD_SCSITASKMGMT_TYPE: - cmdrsp = (struct uiscmdrsp *)pendingdel->sent; - wake_up_all((wait_queue_head_t *) - cmdrsp->scsitaskmgmt.notify); - *(int *)cmdrsp->scsitaskmgmt.notifyresult = - TASK_MGMT_FAILED; - break; - case CMD_VDISKMGMT_TYPE: - cmdrsp = (struct uiscmdrsp *)pendingdel->sent; - *(int *)cmdrsp->vdiskmgmt.notifyresult = - VDISK_MGMT_FAILED; - wake_up_all((wait_queue_head_t *) - cmdrsp->vdiskmgmt.notify); - break; - default: - break; - } - pendingdel->cmdtype = 0; - pendingdel->sent = NULL; - } - spin_unlock_irqrestore(&virthbainfo->privlock, flags); - - virtpcidev = virthbainfo->virtpcidev; - - virthbainfo->serverdown = true; - virthbainfo->serverchangingstate = false; - /* Return the ServerDown response to Command */ - visorchipset_device_pause_response(virtpcidev->bus_no, - virtpcidev->device_no, 0); -} - -/* As per VirtpciFunc returns 1 for success and 0 for failure */ -static int -virthba_serverdown(struct virtpci_dev *virtpcidev, u32 state) -{ - int stat = 1; - - struct virthba_info *virthbainfo = - (struct virthba_info *)((struct Scsi_Host *)virtpcidev->scsi. - scsihost)->hostdata; - - if (!virthbainfo->serverdown && !virthbainfo->serverchangingstate) { - virthbainfo->serverchangingstate = true; - queue_work(virthba_serverdown_workqueue, - &virthbainfo->serverdown_completion); - } else if (virthbainfo->serverchangingstate) { - stat = 0; - } - - return stat; -} - -/*****************************************************/ -/* Module Init & Exit functions */ -/*****************************************************/ - -static int __init -virthba_parse_line(char *str) -{ - return 1; -} - -static void __init -virthba_parse_options(char *line) -{ - char *next = line; - - POSTCODE_LINUX_2(VHBA_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); - if (!line || !*line) - return; - while ((line = next)) { - next = strchr(line, ' '); - if (next) - *next++ = 0; - virthba_parse_line(line); - } - - POSTCODE_LINUX_2(VHBA_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO); -} - -static int __init -virthba_mod_init(void) -{ - int error; - int i; - - if (!unisys_spar_platform) - return -ENODEV; - - POSTCODE_LINUX_2(VHBA_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); - virthba_parse_options(virthba_options); - - error = virtpci_register_driver(&virthba_driver); - if (error < 0) { - POSTCODE_LINUX_3(VHBA_CREATE_FAILURE_PC, error, - POSTCODE_SEVERITY_ERR); - } else { - /* create the debugfs directories and entries */ - virthba_debugfs_dir = debugfs_create_dir("virthba", NULL); - debugfs_create_file("info", S_IRUSR, virthba_debugfs_dir, - NULL, &debugfs_info_fops); - debugfs_create_u32("rqwait_usecs", S_IRUSR | S_IWUSR, - virthba_debugfs_dir, &rsltq_wait_usecs); - debugfs_create_file("enable_ints", S_IWUSR, - virthba_debugfs_dir, NULL, - &debugfs_enable_ints_fops); - /* Initialize dar_work_queue */ - INIT_WORK(&dar_work_queue, do_disk_add_remove); - spin_lock_init(&dar_work_queue_lock); - - /* clear out array */ - for (i = 0; i < VIRTHBASOPENMAX; i++) - virthbas_open[i].virthbainfo = NULL; - /* Initialize the serverdown workqueue */ - virthba_serverdown_workqueue = - create_singlethread_workqueue("virthba_serverdown"); - if (!virthba_serverdown_workqueue) { - POSTCODE_LINUX_2(VHBA_CREATE_FAILURE_PC, - POSTCODE_SEVERITY_ERR); - error = -1; - } - } - - POSTCODE_LINUX_2(VHBA_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO); - return error; -} - -static ssize_t -virthba_acquire_lun(struct device *cdev, struct device_attribute *attr, - const char *buf, size_t count) -{ - struct uisscsi_dest vdest; - struct Scsi_Host *shost = class_to_shost(cdev); - int i; - - i = sscanf(buf, "%d-%d-%d", &vdest.channel, &vdest.id, &vdest.lun); - if (i != 3) - return i; - - return forward_vdiskmgmt_command(VDISK_MGMT_ACQUIRE, shost, &vdest); -} - -static ssize_t -virthba_release_lun(struct device *cdev, struct device_attribute *attr, - const char *buf, size_t count) -{ - struct uisscsi_dest vdest; - struct Scsi_Host *shost = class_to_shost(cdev); - int i; - - i = sscanf(buf, "%d-%d-%d", &vdest.channel, &vdest.id, &vdest.lun); - if (i != 3) - return i; - - return forward_vdiskmgmt_command(VDISK_MGMT_RELEASE, shost, &vdest); -} - -#define CLASS_DEVICE_ATTR(_name, _mode, _show, _store) \ - struct device_attribute class_device_attr_##_name = \ - __ATTR(_name, _mode, _show, _store) - -static CLASS_DEVICE_ATTR(acquire_lun, S_IWUSR, NULL, virthba_acquire_lun); -static CLASS_DEVICE_ATTR(release_lun, S_IWUSR, NULL, virthba_release_lun); - -static DEVICE_ATTRIBUTE *virthba_shost_attrs[] = { - &class_device_attr_acquire_lun, - &class_device_attr_release_lun, - NULL -}; - -static void __exit -virthba_mod_exit(void) -{ - virtpci_unregister_driver(&virthba_driver); - /* unregister is going to call virthba_remove */ - /* destroy serverdown completion workqueue */ - if (virthba_serverdown_workqueue) { - destroy_workqueue(virthba_serverdown_workqueue); - virthba_serverdown_workqueue = NULL; - } - - debugfs_remove_recursive(virthba_debugfs_dir); -} - -/* specify function to be run at module insertion time */ -module_init(virthba_mod_init); - -/* specify function to be run when module is removed */ -module_exit(virthba_mod_exit); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Usha Srinivasan"); -MODULE_ALIAS("uisvirthba"); - /* this is extracted during depmod and kept in modules.dep */ -/* module parameter */ -module_param(virthba_options, charp, S_IRUGO); diff --git a/drivers/staging/unisys/virthba/virthba.h b/drivers/staging/unisys/virthba/virthba.h deleted file mode 100644 index 59901668d4f4..000000000000 --- a/drivers/staging/unisys/virthba/virthba.h +++ /dev/null @@ -1,27 +0,0 @@ -/* virthba.h - * - * 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. - */ - -/* - * Unisys Virtual HBA driver header - */ - -#ifndef __VIRTHBA_H__ -#define __VIRTHBA_H__ - -#define VIRTHBA_VERSION "01.00" - -#endif /* __VIRTHBA_H__ */ From 280b5a4366dd4b813cad180e39b04e773ca0ebe0 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Mon, 13 Apr 2015 21:16:50 -0400 Subject: [PATCH 0056/1163] staging: unisys: remove virtpci driver from staging tree The virtpci driver is being rewritten, so remove the driver from the staging tree. Signed-off-by: Benjamin Romer Reviewed-by: Don Zickus Reviewed-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/Kconfig | 1 - drivers/staging/unisys/Makefile | 1 - drivers/staging/unisys/virtpci/Kconfig | 10 - drivers/staging/unisys/virtpci/Makefile | 10 - drivers/staging/unisys/virtpci/virtpci.c | 1394 ---------------------- drivers/staging/unisys/virtpci/virtpci.h | 103 -- 6 files changed, 1519 deletions(-) delete mode 100644 drivers/staging/unisys/virtpci/Kconfig delete mode 100644 drivers/staging/unisys/virtpci/Makefile delete mode 100644 drivers/staging/unisys/virtpci/virtpci.c delete mode 100644 drivers/staging/unisys/virtpci/virtpci.h diff --git a/drivers/staging/unisys/Kconfig b/drivers/staging/unisys/Kconfig index 906cd589048d..1de86d147b39 100644 --- a/drivers/staging/unisys/Kconfig +++ b/drivers/staging/unisys/Kconfig @@ -13,6 +13,5 @@ source "drivers/staging/unisys/visorutil/Kconfig" source "drivers/staging/unisys/visorchannel/Kconfig" source "drivers/staging/unisys/visorchipset/Kconfig" source "drivers/staging/unisys/uislib/Kconfig" -source "drivers/staging/unisys/virtpci/Kconfig" endif # UNISYSSPAR diff --git a/drivers/staging/unisys/Makefile b/drivers/staging/unisys/Makefile index 3283a013d0c6..899b0cbdb5dd 100644 --- a/drivers/staging/unisys/Makefile +++ b/drivers/staging/unisys/Makefile @@ -5,4 +5,3 @@ obj-$(CONFIG_UNISYS_VISORUTIL) += visorutil/ obj-$(CONFIG_UNISYS_VISORCHANNEL) += visorchannel/ obj-$(CONFIG_UNISYS_VISORCHIPSET) += visorchipset/ obj-$(CONFIG_UNISYS_UISLIB) += uislib/ -obj-$(CONFIG_UNISYS_VIRTPCI) += virtpci/ diff --git a/drivers/staging/unisys/virtpci/Kconfig b/drivers/staging/unisys/virtpci/Kconfig deleted file mode 100644 index 6d19482ce11b..000000000000 --- a/drivers/staging/unisys/virtpci/Kconfig +++ /dev/null @@ -1,10 +0,0 @@ -# -# Unisys virtpci configuration -# - -config UNISYS_VIRTPCI - tristate "Unisys virtpci driver" - select UNISYS_UISLIB - ---help--- - If you say Y here, you will enable the Unisys virtpci driver. - diff --git a/drivers/staging/unisys/virtpci/Makefile b/drivers/staging/unisys/virtpci/Makefile deleted file mode 100644 index a26c696219a5..000000000000 --- a/drivers/staging/unisys/virtpci/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# -# Makefile for Unisys virtpci -# - -obj-$(CONFIG_UNISYS_VIRTPCI) += virtpci.o - -ccflags-y += -Idrivers/staging/unisys/include -ccflags-y += -Idrivers/staging/unisys/uislib -ccflags-y += -Idrivers/staging/unisys/common-spar/include -ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c deleted file mode 100644 index d5ad01783c07..000000000000 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ /dev/null @@ -1,1394 +0,0 @@ -/* virtpci.c - * - * 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. - */ - -#define EXPORT_SYMTAB - -#include -#ifdef CONFIG_MODVERSIONS -#include -#endif -#include "diagnostics/appos_subsystems.h" -#include "uisutils.h" -#include "vbuschannel.h" -#include "vbushelper.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "version.h" -#include "guestlinuxdebug.h" -#include "timskmod.h" - -struct driver_private { - struct kobject kobj; - struct klist klist_devices; - struct klist_node knode_bus; - struct module_kobject *mkobj; - struct device_driver *driver; -}; - -#define to_driver(obj) container_of(obj, struct driver_private, kobj) - -/* bus_id went away in 2.6.30 - the size was 20 bytes, so we'll define - * it ourselves, and a macro to make getting the field a bit simpler. - */ -#ifndef BUS_ID_SIZE -#define BUS_ID_SIZE 20 -#endif - -#define BUS_ID(x) dev_name(x) - -/* MAX_BUF = 4 busses x ( 32 devices/bus + 1 busline) x 80 characters - * = 10,560 bytes ~ 2^14 = 16,384 bytes - */ -#define MAX_BUF 16384 - -#include "virtpci.h" - -/* this is shorter than using __FILE__ (full path name) in - * debug/info/error messages - */ -#define CURRENT_FILE_PC VIRT_PCI_PC_virtpci_c -#define __MYFILE__ "virtpci.c" - -#define VIRTPCI_VERSION "01.00" - -/*****************************************************/ -/* Forward declarations */ -/*****************************************************/ - -static int delete_vbus_device(struct device *vbus, void *data); -static int match_busid(struct device *dev, void *data); -static void virtpci_bus_release(struct device *dev); -static void virtpci_device_release(struct device *dev); -static int virtpci_device_add(struct device *parentbus, int devtype, - struct add_virt_guestpart *addparams, - struct scsi_adap_info *scsi, - struct net_adap_info *net); -static int virtpci_device_del(struct device *parentbus, int devtype, - struct vhba_wwnn *wwnn, unsigned char macaddr[]); -static int virtpci_device_serverdown(struct device *parentbus, int devtype, - struct vhba_wwnn *wwnn, - unsigned char macaddr[]); -static int virtpci_device_serverup(struct device *parentbus, int devtype, - struct vhba_wwnn *wwnn, - unsigned char macaddr[]); -static ssize_t virtpci_driver_attr_show(struct kobject *kobj, - struct attribute *attr, char *buf); -static ssize_t virtpci_driver_attr_store(struct kobject *kobj, - struct attribute *attr, - const char *buf, size_t count); -static int virtpci_bus_match(struct device *dev, struct device_driver *drv); -static int virtpci_uevent(struct device *dev, struct kobj_uevent_env *env); -static int virtpci_device_probe(struct device *dev); -static int virtpci_device_remove(struct device *dev); - -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 = { - .read = info_debugfs_read, -}; - -/*****************************************************/ -/* Globals */ -/*****************************************************/ - -/* methods in bus_type struct allow the bus code to serve as an - * intermediary between the device core and individual device core and - * individual drivers - */ -static struct bus_type virtpci_bus_type = { - .name = "uisvirtpci", - .match = virtpci_bus_match, - .uevent = virtpci_uevent, -}; - -static struct device virtpci_rootbus_device = { - .init_name = "vbusroot", /* root bus */ - .release = virtpci_bus_release -}; - -/* filled in with info about parent chipset driver when we register with it */ -static struct ultra_vbus_deviceinfo chipset_driver_info; - -static const struct sysfs_ops virtpci_driver_sysfs_ops = { - .show = virtpci_driver_attr_show, - .store = virtpci_driver_attr_store, -}; - -static struct kobj_type virtpci_driver_kobj_type = { - .sysfs_ops = &virtpci_driver_sysfs_ops, -}; - -static struct virtpci_dev *vpcidev_list_head; -static DEFINE_RWLOCK(vpcidev_list_lock); - -/* filled in with info about this driver, wrt it servicing client busses */ -static struct ultra_vbus_deviceinfo bus_driver_info; - -/*****************************************************/ -/* debugfs entries */ -/*****************************************************/ -/* dentry is used to create the debugfs entry directory - * for virtpci - */ -static struct dentry *virtpci_debugfs_dir; - -struct virtpci_busdev { - struct device virtpci_bus_device; -}; - -/*****************************************************/ -/* Local functions */ -/*****************************************************/ - -static inline -int WAIT_FOR_IO_CHANNEL(struct spar_io_channel_protocol __iomem *chanptr) -{ - int count = 120; - - while (count > 0) { - if (SPAR_CHANNEL_SERVER_READY(&chanptr->channel_header)) - return 1; - UIS_THREAD_WAIT_SEC(1); - count--; - } - return 0; -} - -/* Write the contents of to the ULTRA_VBUS_CHANNEL_PROTOCOL.ChpInfo. */ -static int write_vbus_chp_info(struct spar_vbus_channel_protocol *chan, - struct ultra_vbus_deviceinfo *info) -{ - int off; - - if (!chan) - return -1; - - off = sizeof(struct channel_header) + chan->hdr_info.chp_info_offset; - if (chan->hdr_info.chp_info_offset == 0) { - return -1; - } - memcpy(((u8 *)(chan)) + off, info, sizeof(*info)); - return 0; -} - -/* Write the contents of to the ULTRA_VBUS_CHANNEL_PROTOCOL.BusInfo. */ -static int write_vbus_bus_info(struct spar_vbus_channel_protocol *chan, - struct ultra_vbus_deviceinfo *info) -{ - int off; - - if (!chan) - return -1; - - off = sizeof(struct channel_header) + chan->hdr_info.bus_info_offset; - if (chan->hdr_info.bus_info_offset == 0) - return -1; - memcpy(((u8 *)(chan)) + off, info, sizeof(*info)); - return 0; -} - -/* Write the contents of to the - * ULTRA_VBUS_CHANNEL_PROTOCOL.DevInfo[]. - */ -static int -write_vbus_dev_info(struct spar_vbus_channel_protocol *chan, - struct ultra_vbus_deviceinfo *info, int devix) -{ - int off; - - if (!chan) - return -1; - - off = - (sizeof(struct channel_header) + - chan->hdr_info.dev_info_offset) + - (chan->hdr_info.device_info_struct_bytes * devix); - if (chan->hdr_info.dev_info_offset == 0) - return -1; - - memcpy(((u8 *)(chan)) + off, info, sizeof(*info)); - return 0; -} - -/* adds a vbus - * returns 0 failure, 1 success, - */ -static int add_vbus(struct add_vbus_guestpart *addparams) -{ - int ret; - struct device *vbus; - - vbus = kzalloc(sizeof(*vbus), GFP_ATOMIC); - - POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); - if (!vbus) - return 0; - - dev_set_name(vbus, "vbus%d", addparams->bus_no); - vbus->release = virtpci_bus_release; - vbus->parent = &virtpci_rootbus_device; /* root bus is parent */ - vbus->bus = &virtpci_bus_type; /* bus type */ - vbus->platform_data = (__force void *)addparams->chanptr; - - /* register a virt bus device - - * this bus shows up under /sys/devices with .name value - * "virtpci%d" any devices added to this bus then show up under - * /sys/devices/virtpci0 - */ - ret = device_register(vbus); - if (ret) { - POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR); - return 0; - } - write_vbus_chp_info(vbus->platform_data /* chanptr */, - &chipset_driver_info); - write_vbus_bus_info(vbus->platform_data /* chanptr */, - &bus_driver_info); - POSTCODE_LINUX_2(VPCI_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO); - return 1; -} - -/* for CHANSOCK wwwnn/max are AUTO-GENERATED; for normal channels, - * wwnn/max are in the channel header. - */ -#define GET_SCSIADAPINFO_FROM_CHANPTR(chanptr) { \ - memcpy_fromio(&scsi.wwnn, \ - &((struct spar_io_channel_protocol __iomem *) \ - chanptr)->vhba.wwnn, \ - sizeof(struct vhba_wwnn)); \ - memcpy_fromio(&scsi.max, \ - &((struct spar_io_channel_protocol __iomem *) \ - chanptr)->vhba.max, \ - sizeof(struct vhba_config_max)); \ - } - -/* adds a vhba - * returns 0 failure, 1 success, - */ -static int add_vhba(struct add_virt_guestpart *addparams) -{ - int i; - struct scsi_adap_info scsi; - struct device *vbus; - unsigned char busid[BUS_ID_SIZE]; - - POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); - if (!WAIT_FOR_IO_CHANNEL - ((struct spar_io_channel_protocol __iomem *)addparams->chanptr)) { - POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR); - return 0; - } - - GET_SCSIADAPINFO_FROM_CHANPTR(addparams->chanptr); - - /* find bus device with the busid that matches match_busid */ - sprintf(busid, "vbus%d", addparams->bus_no); - vbus = bus_find_device(&virtpci_bus_type, NULL, - (void *)busid, match_busid); - if (!vbus) - return 0; - - i = virtpci_device_add(vbus, VIRTHBA_TYPE, addparams, &scsi, NULL); - if (i) { - POSTCODE_LINUX_3(VPCI_CREATE_EXIT_PC, i, - POSTCODE_SEVERITY_INFO); - } - return i; -} - -/* for CHANSOCK macaddr is AUTO-GENERATED; for normal channels, - * macaddr is in the channel header. - */ -#define GET_NETADAPINFO_FROM_CHANPTR(chanptr) { \ - memcpy_fromio(net.mac_addr, \ - ((struct spar_io_channel_protocol __iomem *) \ - chanptr)->vnic.macaddr, \ - MAX_MACADDR_LEN); \ - net.num_rcv_bufs = \ - readl(&((struct spar_io_channel_protocol __iomem *)\ - chanptr)->vnic.num_rcv_bufs); \ - net.mtu = readl(&((struct spar_io_channel_protocol __iomem *) \ - chanptr)->vnic.mtu); \ - memcpy_fromio(&net.zone_uuid, \ - &((struct spar_io_channel_protocol __iomem *)\ - chanptr)->vnic.zone_uuid, \ - sizeof(uuid_le)); \ -} - -/* adds a vnic - * returns 0 failure, 1 success, - */ -static int -add_vnic(struct add_virt_guestpart *addparams) -{ - int i; - struct net_adap_info net; - struct device *vbus; - unsigned char busid[BUS_ID_SIZE]; - - POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); - if (!WAIT_FOR_IO_CHANNEL - ((struct spar_io_channel_protocol __iomem *)addparams->chanptr)) { - POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR); - return 0; - } - - GET_NETADAPINFO_FROM_CHANPTR(addparams->chanptr); - - /* find bus device with the busid that matches match_busid */ - sprintf(busid, "vbus%d", addparams->bus_no); - vbus = bus_find_device(&virtpci_bus_type, NULL, - (void *)busid, match_busid); - if (!vbus) - return 0; - - i = virtpci_device_add(vbus, VIRTNIC_TYPE, addparams, NULL, &net); - if (i) { - POSTCODE_LINUX_3(VPCI_CREATE_EXIT_PC, i, - POSTCODE_SEVERITY_INFO); - return 1; - } - return 0; -} - -/* delete vbus - * returns 0 failure, 1 success, - */ -static int -delete_vbus(struct del_vbus_guestpart *delparams) -{ - struct device *vbus; - unsigned char busid[BUS_ID_SIZE]; - - /* find bus device with the busid that matches match_busid */ - sprintf(busid, "vbus%d", delparams->bus_no); - vbus = bus_find_device(&virtpci_bus_type, NULL, - (void *)busid, match_busid); - if (!vbus) - return 0; - - /* ensure that bus has no devices? -- TBD */ - return 1; -} - -static int -delete_vbus_device(struct device *vbus, void *data) -{ - struct device *dev = &virtpci_rootbus_device; - - if ((data) && match_busid(vbus, (void *)BUS_ID(dev))) { - /* skip it - don't delete root bus */ - return 0; /* pretend no error */ - } - device_unregister(vbus); - kfree(vbus); - return 0; /* no error */ -} - -/* pause vhba -* returns 0 failure, 1 success, -*/ -static int pause_vhba(struct pause_virt_guestpart *pauseparams) -{ - int i; - struct scsi_adap_info scsi; - - GET_SCSIADAPINFO_FROM_CHANPTR(pauseparams->chanptr); - - i = virtpci_device_serverdown(NULL /*no parent bus */, VIRTHBA_TYPE, - &scsi.wwnn, NULL); - return i; -} - -/* pause vnic - * returns 0 failure, 1 success, - */ -static int pause_vnic(struct pause_virt_guestpart *pauseparams) -{ - int i; - struct net_adap_info net; - - GET_NETADAPINFO_FROM_CHANPTR(pauseparams->chanptr); - - i = virtpci_device_serverdown(NULL /*no parent bus */, VIRTNIC_TYPE, - NULL, net.mac_addr); - return i; -} - -/* resume vhba - * returns 0 failure, 1 success, - */ -static int resume_vhba(struct resume_virt_guestpart *resumeparams) -{ - int i; - struct scsi_adap_info scsi; - - GET_SCSIADAPINFO_FROM_CHANPTR(resumeparams->chanptr); - - i = virtpci_device_serverup(NULL /*no parent bus */, VIRTHBA_TYPE, - &scsi.wwnn, NULL); - return i; -} - -/* resume vnic -* returns 0 failure, 1 success, -*/ -static int -resume_vnic(struct resume_virt_guestpart *resumeparams) -{ - int i; - struct net_adap_info net; - - GET_NETADAPINFO_FROM_CHANPTR(resumeparams->chanptr); - - i = virtpci_device_serverup(NULL /*no parent bus */, VIRTNIC_TYPE, - NULL, net.mac_addr); - return i; -} - -/* delete vhba -* returns 0 failure, 1 success, -*/ -static int delete_vhba(struct del_virt_guestpart *delparams) -{ - int i; - struct scsi_adap_info scsi; - - GET_SCSIADAPINFO_FROM_CHANPTR(delparams->chanptr); - - i = virtpci_device_del(NULL /*no parent bus */, VIRTHBA_TYPE, - &scsi.wwnn, NULL); - if (i) { - return 1; - } - return 0; -} - -/* deletes a vnic - * returns 0 failure, 1 success, - */ -static int delete_vnic(struct del_virt_guestpart *delparams) -{ - int i; - struct net_adap_info net; - - GET_NETADAPINFO_FROM_CHANPTR(delparams->chanptr); - - i = virtpci_device_del(NULL /*no parent bus */, VIRTNIC_TYPE, NULL, - net.mac_addr); - return i; -} - -#define DELETE_ONE_VPCIDEV(vpcidev) { \ - device_unregister(&vpcidev->generic_dev); \ - kfree(vpcidev); \ -} - -/* deletes all vhbas and vnics - * returns 0 failure, 1 success, - */ -static void delete_all(void) -{ - int count = 0; - unsigned long flags; - struct virtpci_dev *tmpvpcidev, *nextvpcidev; - - /* delete the entire vhba/vnic list in one shot */ - write_lock_irqsave(&vpcidev_list_lock, flags); - tmpvpcidev = vpcidev_list_head; - vpcidev_list_head = NULL; - write_unlock_irqrestore(&vpcidev_list_lock, flags); - - /* delete one vhba/vnic at a time */ - while (tmpvpcidev) { - nextvpcidev = tmpvpcidev->next; - /* delete the vhba/vnic at tmpvpcidev */ - DELETE_ONE_VPCIDEV(tmpvpcidev); - tmpvpcidev = nextvpcidev; - count++; - } - - /* now delete each vbus */ - bus_for_each_dev(&virtpci_bus_type, NULL, (void *)1, - delete_vbus_device); -} - -/* deletes all vnics or vhbas - * returns 0 failure, 1 success, - */ -static int delete_all_virt(enum virtpci_dev_type devtype, - struct del_vbus_guestpart *delparams) -{ - int i; - unsigned char busid[BUS_ID_SIZE]; - struct device *vbus; - - /* find bus device with the busid that matches match_busid */ - sprintf(busid, "vbus%d", delparams->bus_no); - vbus = bus_find_device(&virtpci_bus_type, NULL, - (void *)busid, match_busid); - if (!vbus) - return 0; - - if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE)) - return 0; - - /* delete all vhbas/vnics */ - i = virtpci_device_del(vbus, devtype, NULL, NULL); - return 1; -} - -static int virtpci_ctrlchan_func(struct guest_msgs *msg) -{ - switch (msg->msgtype) { - case GUEST_ADD_VBUS: - return add_vbus(&msg->add_vbus); - case GUEST_ADD_VHBA: - return add_vhba(&msg->add_vhba); - case GUEST_ADD_VNIC: - return add_vnic(&msg->add_vnic); - case GUEST_DEL_VBUS: - return delete_vbus(&msg->del_vbus); - case GUEST_DEL_VHBA: - return delete_vhba(&msg->del_vhba); - case GUEST_DEL_VNIC: - return delete_vnic(&msg->del_vhba); - case GUEST_DEL_ALL_VHBAS: - return delete_all_virt(VIRTHBA_TYPE, &msg->del_all_vhbas); - case GUEST_DEL_ALL_VNICS: - return delete_all_virt(VIRTNIC_TYPE, &msg->del_all_vnics); - case GUEST_DEL_ALL_VBUSES: - delete_all(); - return 1; - case GUEST_PAUSE_VHBA: - return pause_vhba(&msg->pause_vhba); - case GUEST_PAUSE_VNIC: - return pause_vnic(&msg->pause_vnic); - case GUEST_RESUME_VHBA: - return resume_vhba(&msg->resume_vhba); - case GUEST_RESUME_VNIC: - return resume_vnic(&msg->resume_vnic); - default: - return 0; - } -} - -/* same as driver_helper in bus.c linux */ -static int match_busid(struct device *dev, void *data) -{ - const char *name = data; - - if (strcmp(name, BUS_ID(dev)) == 0) - return 1; - return 0; -} - -/*****************************************************/ -/* Bus functions */ -/*****************************************************/ - -static const struct pci_device_id * -virtpci_match_device(const struct pci_device_id *ids, - const struct virtpci_dev *dev) -{ - while (ids->vendor || ids->subvendor || ids->class_mask) { - if ((ids->vendor == dev->vendor) && - (ids->device == dev->device)) - return ids; - - ids++; - } - return NULL; -} - -/* NOTE: !!!!!! This function is called when a new device is added -* for this bus. Or, it is called for existing devices when a new -* driver is added for this bus. It returns nonzero if a given device -* can be handled by the given driver. -*/ -static int virtpci_bus_match(struct device *dev, struct device_driver *drv) -{ - struct virtpci_dev *virtpcidev = device_to_virtpci_dev(dev); - struct virtpci_driver *virtpcidrv = driver_to_virtpci_driver(drv); - int match = 0; - - /* check ids list for a match */ - if (virtpci_match_device(virtpcidrv->id_table, virtpcidev)) - match = 1; - - return match; /* 0 - no match; 1 - yes it matches */ -} - -static int virtpci_uevent(struct device *dev, struct kobj_uevent_env *env) -{ - /* add variables to the environment prior to the generation of - * hotplug events to user space - */ - if (add_uevent_var(env, "VIRTPCI_VERSION=%s", VIRTPCI_VERSION)) - return -ENOMEM; - return 0; -} - -/* For a child device just created on a client bus, fill in - * information about the driver that is controlling this device into - * the appropriate slot within the vbus channel of the bus - * instance. - */ -static void fix_vbus_dev_info(struct device *dev, int dev_no, int dev_type, - struct virtpci_driver *virtpcidrv) -{ - struct device *vbus; - void *chan; - struct ultra_vbus_deviceinfo dev_info; - const char *stype; - - if (!dev) - return; - if (!virtpcidrv) - return; - - vbus = dev->parent; - if (!vbus) - return; - - chan = vbus->platform_data; - if (!chan) - return; - - switch (dev_type) { - case PCI_DEVICE_ID_VIRTHBA: - stype = "vHBA"; - break; - case PCI_DEVICE_ID_VIRTNIC: - stype = "vNIC"; - break; - default: - stype = "unknown"; - break; - } - bus_device_info_init(&dev_info, stype, - virtpcidrv->name, - virtpcidrv->version, - virtpcidrv->vertag); - write_vbus_dev_info(chan, &dev_info, dev_no); - - /* Re-write bus+chipset info, because it is possible that this - * was previously written by our good counterpart, visorbus. - */ - write_vbus_chp_info(chan, &chipset_driver_info); - write_vbus_bus_info(chan, &bus_driver_info); -} - -/* This function is called to query the existence of a specific device -* and whether this driver can work with it. It should return -ENODEV -* in case of failure. -*/ -static int virtpci_device_probe(struct device *dev) -{ - struct virtpci_dev *virtpcidev = device_to_virtpci_dev(dev); - struct virtpci_driver *virtpcidrv = - driver_to_virtpci_driver(dev->driver); - const struct pci_device_id *id; - int error = 0; - - POSTCODE_LINUX_2(VPCI_PROBE_ENTRY_PC, POSTCODE_SEVERITY_INFO); - /* static match and static probe vs dynamic match & dynamic - * probe - do we care?. - */ - if (!virtpcidrv->id_table) - return -ENODEV; - - id = virtpci_match_device(virtpcidrv->id_table, virtpcidev); - if (!id) - return -ENODEV; - - /* increment reference count */ - get_device(dev); - - /* if virtpcidev is not already claimed & probe function is - * valid, probe it - */ - if (!virtpcidev->mydriver && virtpcidrv->probe) { - /* call the probe function - virthba or virtnic probe - * is what it should be - */ - error = virtpcidrv->probe(virtpcidev, id); - if (!error) { - fix_vbus_dev_info(dev, virtpcidev->device_no, - virtpcidev->device, virtpcidrv); - virtpcidev->mydriver = virtpcidrv; - POSTCODE_LINUX_2(VPCI_PROBE_EXIT_PC, - POSTCODE_SEVERITY_INFO); - } else { - put_device(dev); - } - } - POSTCODE_LINUX_2(VPCI_PROBE_FAILURE_PC, POSTCODE_SEVERITY_ERR); - return error; /* -ENODEV for probe failure */ -} - -static int virtpci_device_remove(struct device *dev_) -{ - /* dev_ passed in is the HBA device which we called - * generic_dev in our virtpcidev struct - */ - struct virtpci_dev *virtpcidev = device_to_virtpci_dev(dev_); - struct virtpci_driver *virtpcidrv = virtpcidev->mydriver; - - if (virtpcidrv) { - /* TEMP: assuming we have only one such driver for now */ - if (virtpcidrv->remove) - virtpcidrv->remove(virtpcidev); - virtpcidev->mydriver = NULL; - } - - put_device(dev_); - return 0; -} - -/*****************************************************/ -/* Bus functions */ -/*****************************************************/ - -static void virtpci_bus_release(struct device *dev) -{ -} - -/*****************************************************/ -/* Adapter functions */ -/*****************************************************/ - -/* scsi is expected to be NULL for VNIC add - * net is expected to be NULL for VHBA add - */ -static int virtpci_device_add(struct device *parentbus, int devtype, - struct add_virt_guestpart *addparams, - struct scsi_adap_info *scsi, - struct net_adap_info *net) -{ - struct virtpci_dev *virtpcidev = NULL; - struct virtpci_dev *tmpvpcidev = NULL, *prev; - unsigned long flags; - int ret; - struct spar_io_channel_protocol __iomem *io_chan = NULL; - struct device *dev; - - POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); - - if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE)) { - POSTCODE_LINUX_3(VPCI_CREATE_FAILURE_PC, devtype, - POSTCODE_SEVERITY_ERR); - return 0; - } - - /* add a Virtual Device */ - virtpcidev = kzalloc(sizeof(*virtpcidev), GFP_ATOMIC); - if (!virtpcidev) { - POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR); - return 0; - } - - /* initialize stuff unique to virtpci_dev struct */ - virtpcidev->devtype = devtype; - if (devtype == VIRTHBA_TYPE) { - virtpcidev->device = PCI_DEVICE_ID_VIRTHBA; - virtpcidev->scsi = *scsi; - } else { - virtpcidev->device = PCI_DEVICE_ID_VIRTNIC; - virtpcidev->net = *net; - } - virtpcidev->vendor = PCI_VENDOR_ID_UNISYS; - virtpcidev->bus_no = addparams->bus_no; - virtpcidev->device_no = addparams->device_no; - - virtpcidev->queueinfo.chan = addparams->chanptr; - virtpcidev->queueinfo.send_int_if_needed = NULL; - - /* Set up safe queue... */ - io_chan = (struct spar_io_channel_protocol __iomem *) - virtpcidev->queueinfo.chan; - - virtpcidev->intr = addparams->intr; - - /* initialize stuff in the device portion of the struct */ - virtpcidev->generic_dev.bus = &virtpci_bus_type; - virtpcidev->generic_dev.parent = parentbus; - virtpcidev->generic_dev.release = virtpci_device_release; - - dev_set_name(&virtpcidev->generic_dev, "%x:%x", - addparams->bus_no, addparams->device_no); - - /* add the vhba/vnic to virtpci device list - but check for - * duplicate wwnn/macaddr first - */ - write_lock_irqsave(&vpcidev_list_lock, flags); - for (tmpvpcidev = vpcidev_list_head; tmpvpcidev; - tmpvpcidev = tmpvpcidev->next) { - if (devtype == VIRTHBA_TYPE) { - if ((tmpvpcidev->scsi.wwnn.wwnn1 == scsi->wwnn.wwnn1) && - (tmpvpcidev->scsi.wwnn.wwnn2 == scsi->wwnn.wwnn2)) { - /* duplicate - already have vpcidev - with this wwnn */ - break; - } - } else - if (memcmp - (tmpvpcidev->net.mac_addr, net->mac_addr, - MAX_MACADDR_LEN) == 0) { - /* duplicate - already have vnic with this wwnn */ - break; - } - } - if (tmpvpcidev) { - /* found a vhba/vnic already in the list with same - * wwnn or macaddr - reject add - */ - write_unlock_irqrestore(&vpcidev_list_lock, flags); - kfree(virtpcidev); - POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR); - return 0; - } - - /* add it at the head */ - if (!vpcidev_list_head) { - vpcidev_list_head = virtpcidev; - } else { - /* insert virtpcidev at the head of our linked list of - * vpcidevs - */ - virtpcidev->next = vpcidev_list_head; - vpcidev_list_head = virtpcidev; - } - - write_unlock_irqrestore(&vpcidev_list_lock, flags); - - /* Must transition channel to ATTACHED state BEFORE - * registering the device, because polling of the channel - * queues can begin at any time after device_register(). - */ - dev = &virtpcidev->generic_dev; - SPAR_CHANNEL_CLIENT_TRANSITION(addparams->chanptr, - BUS_ID(dev), - CHANNELCLI_ATTACHED, NULL); - - /* don't register until device has been added to - * list. Otherwise, a device_unregister from this function can - * cause a "scheduling while atomic". - */ - ret = device_register(&virtpcidev->generic_dev); - /* NOTE: THIS IS CALLING HOTPLUG virtpci_hotplug!!! - * This call to device_register results in virtpci_bus_match - * being called !!!!! And, if match returns success, then - * virtpcidev->generic_dev.driver is setup to core_driver, - * i.e., virtpci and the probe function - * virtpcidev->generic_dev.driver->probe is called which - * results in virtpci_device_probe being called. And if - * virtpci_device_probe is successful - */ - if (ret) { - dev = &virtpcidev->generic_dev; - SPAR_CHANNEL_CLIENT_TRANSITION(addparams->chanptr, - BUS_ID(dev), - CHANNELCLI_DETACHED, NULL); - /* remove virtpcidev, the one we just added, from the list */ - write_lock_irqsave(&vpcidev_list_lock, flags); - for (tmpvpcidev = vpcidev_list_head, prev = NULL; - tmpvpcidev; - prev = tmpvpcidev, tmpvpcidev = tmpvpcidev->next) { - if (tmpvpcidev == virtpcidev) { - if (prev) - prev->next = tmpvpcidev->next; - else - vpcidev_list_head = tmpvpcidev->next; - break; - } - } - write_unlock_irqrestore(&vpcidev_list_lock, flags); - kfree(virtpcidev); - return 0; - } - - POSTCODE_LINUX_2(VPCI_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO); - return 1; -} - -static int virtpci_device_serverdown(struct device *parentbus, - int devtype, - struct vhba_wwnn *wwnn, - unsigned char macaddr[]) -{ - int pausethisone = 0; - bool found = false; - struct virtpci_dev *tmpvpcidev, *prevvpcidev; - struct virtpci_driver *vpcidriver; - unsigned long flags; - int rc = 0; - - if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE)) - return 0; - - /* find the vhba or vnic in virtpci device list */ - write_lock_irqsave(&vpcidev_list_lock, flags); - - for (tmpvpcidev = vpcidev_list_head, prevvpcidev = NULL; - (tmpvpcidev && !found); - prevvpcidev = tmpvpcidev, tmpvpcidev = tmpvpcidev->next) { - if (tmpvpcidev->devtype != devtype) - continue; - - if (devtype == VIRTHBA_TYPE) { - pausethisone = - ((tmpvpcidev->scsi.wwnn.wwnn1 == wwnn->wwnn1) && - (tmpvpcidev->scsi.wwnn.wwnn2 == wwnn->wwnn2)); - /* devtype is vhba, we're pausing vhba whose - * wwnn matches the current device's wwnn - */ - } else { /* VIRTNIC_TYPE */ - pausethisone = - memcmp(tmpvpcidev->net.mac_addr, macaddr, - MAX_MACADDR_LEN) == 0; - /* devtype is vnic, we're pausing vnic whose - * macaddr matches the current device's macaddr */ - } - - if (!pausethisone) - continue; - - found = true; - vpcidriver = tmpvpcidev->mydriver; - rc = vpcidriver->suspend(tmpvpcidev, 0); - } - write_unlock_irqrestore(&vpcidev_list_lock, flags); - - if (!found) - return 0; - - return rc; -} - -static int virtpci_device_serverup(struct device *parentbus, - int devtype, - struct vhba_wwnn *wwnn, - unsigned char macaddr[]) -{ - int resumethisone = 0; - bool found = false; - struct virtpci_dev *tmpvpcidev, *prevvpcidev; - struct virtpci_driver *vpcidriver; - unsigned long flags; - int rc = 0; - - if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE)) - return 0; - - - /* find the vhba or vnic in virtpci device list */ - write_lock_irqsave(&vpcidev_list_lock, flags); - - for (tmpvpcidev = vpcidev_list_head, prevvpcidev = NULL; - (tmpvpcidev && !found); - prevvpcidev = tmpvpcidev, tmpvpcidev = tmpvpcidev->next) { - if (tmpvpcidev->devtype != devtype) - continue; - - if (devtype == VIRTHBA_TYPE) { - resumethisone = - ((tmpvpcidev->scsi.wwnn.wwnn1 == wwnn->wwnn1) && - (tmpvpcidev->scsi.wwnn.wwnn2 == wwnn->wwnn2)); - /* devtype is vhba, we're resuming vhba whose - * wwnn matches the current device's wwnn */ - } else { /* VIRTNIC_TYPE */ - resumethisone = - memcmp(tmpvpcidev->net.mac_addr, macaddr, - MAX_MACADDR_LEN) == 0; - /* devtype is vnic, we're resuming vnic whose - * macaddr matches the current device's macaddr */ - } - - if (!resumethisone) - continue; - - found = true; - vpcidriver = tmpvpcidev->mydriver; - /* This should be done at BUS resume time, but an - * existing problem prevents us from ever getting a bus - * resume... This hack would fail to work should we - * ever have a bus that contains NO devices, since we - * would never even get here in that case. - */ - fix_vbus_dev_info(&tmpvpcidev->generic_dev, - tmpvpcidev->device_no, - tmpvpcidev->device, vpcidriver); - rc = vpcidriver->resume(tmpvpcidev); - } - - write_unlock_irqrestore(&vpcidev_list_lock, flags); - - if (!found) - return 0; - - return rc; -} - -static int virtpci_device_del(struct device *parentbus, - int devtype, struct vhba_wwnn *wwnn, - unsigned char macaddr[]) -{ - int count = 0, all = 0, delthisone; - struct virtpci_dev *tmpvpcidev, *prevvpcidev, *dellist = NULL; - unsigned long flags; - -#define DEL_CONTINUE { \ - prevvpcidev = tmpvpcidev;\ - tmpvpcidev = tmpvpcidev->next;\ - continue; \ -} - - if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE)) - return 0; - - /* see if we are to delete all - NOTE: all implies we have a - * valid parentbus - */ - all = ((devtype == VIRTHBA_TYPE) && (!wwnn)) || - ((devtype == VIRTNIC_TYPE) && (!macaddr)); - - /* find all the vhba or vnic or both in virtpci device list - * keep list of ones we are deleting so we can call - * device_unregister after we release the lock; otherwise we - * encounter "schedule while atomic" - */ - write_lock_irqsave(&vpcidev_list_lock, flags); - for (tmpvpcidev = vpcidev_list_head, prevvpcidev = NULL; tmpvpcidev;) { - if (tmpvpcidev->devtype != devtype) - DEL_CONTINUE; - - if (all) { - delthisone = - (tmpvpcidev->generic_dev.parent == parentbus); - /* we're deleting all vhbas or vnics on the - * specified parent bus - */ - } else if (devtype == VIRTHBA_TYPE) { - delthisone = - ((tmpvpcidev->scsi.wwnn.wwnn1 == wwnn->wwnn1) && - (tmpvpcidev->scsi.wwnn.wwnn2 == wwnn->wwnn2)); - /* devtype is vhba, we're deleting vhba whose - * wwnn matches the current device's wwnn - */ - } else { /* VIRTNIC_TYPE */ - delthisone = - memcmp(tmpvpcidev->net.mac_addr, macaddr, - MAX_MACADDR_LEN) == 0; - /* devtype is vnic, we're deleting vnic whose - * macaddr matches the current device's macaddr - */ - } - - if (!delthisone) - DEL_CONTINUE; - - /* take vhba/vnic out of the list */ - if (prevvpcidev) - /* not at head */ - prevvpcidev->next = tmpvpcidev->next; - else - vpcidev_list_head = tmpvpcidev->next; - - /* add it to our deletelist */ - tmpvpcidev->next = dellist; - dellist = tmpvpcidev; - - count++; - if (!all) - break; /* done */ - /* going to top of loop again - set tmpvpcidev to next - * one we're to process - */ - if (prevvpcidev) - tmpvpcidev = prevvpcidev->next; - else - tmpvpcidev = vpcidev_list_head; - } - write_unlock_irqrestore(&vpcidev_list_lock, flags); - - if (!all && (count == 0)) - return 0; - - /* now delete each one from delete list */ - while (dellist) { - /* save next */ - tmpvpcidev = dellist->next; - /* delete the vhba/vnic at dellist */ - DELETE_ONE_VPCIDEV(dellist); - /* do next */ - dellist = tmpvpcidev; - } - - return count; -} - -static void virtpci_device_release(struct device *dev_) -{ - /* this function is called when the last reference to the - * device is removed - */ -} - -/*****************************************************/ -/* Driver functions */ -/*****************************************************/ - -#define kobj_to_device_driver(obj) container_of(obj, struct device_driver, kobj) -#define attribute_to_driver_attribute(obj) \ - container_of(obj, struct driver_attribute, attr) - -static ssize_t virtpci_driver_attr_show(struct kobject *kobj, - struct attribute *attr, - char *buf) -{ - struct driver_attribute *dattr = attribute_to_driver_attribute(attr); - ssize_t ret = 0; - - struct driver_private *dprivate = to_driver(kobj); - struct device_driver *driver = dprivate->driver; - - if (dattr->show) - ret = dattr->show(driver, buf); - - return ret; -} - -static ssize_t virtpci_driver_attr_store(struct kobject *kobj, - struct attribute *attr, - const char *buf, size_t count) -{ - struct driver_attribute *dattr = attribute_to_driver_attribute(attr); - ssize_t ret = 0; - - struct driver_private *dprivate = to_driver(kobj); - struct device_driver *driver = dprivate->driver; - - if (dattr->store) - ret = dattr->store(driver, buf, count); - - return ret; -} - -/* register a new virtpci driver */ -int virtpci_register_driver(struct virtpci_driver *drv) -{ - int result = 0; - - if (!drv->id_table) - return 1; - /* initialize core driver fields needed to call driver_register */ - drv->core_driver.name = drv->name; /* name of driver in sysfs */ - drv->core_driver.bus = &virtpci_bus_type; /* type of bus this - * driver works with */ - drv->core_driver.probe = virtpci_device_probe; /* called to query the - * existence of a - * specific device and - * whether this driver - *can work with it */ - drv->core_driver.remove = virtpci_device_remove; /* called when the - * device is removed - * from the system */ - /* register with core */ - result = driver_register(&drv->core_driver); - /* calls bus_add_driver which calls driver_attach and - * module_add_driver - */ - if (result) - return result; /* failed */ - - drv->core_driver.p->kobj.ktype = &virtpci_driver_kobj_type; - - return 0; -} -EXPORT_SYMBOL_GPL(virtpci_register_driver); - -void virtpci_unregister_driver(struct virtpci_driver *drv) -{ - driver_unregister(&drv->core_driver); - /* driver_unregister calls bus_remove_driver - * bus_remove_driver calls device_detach - * device_detach calls device_release_driver for each of the - * driver's devices - * device_release driver calls drv->remove which is - * virtpci_device_remove - * virtpci_device_remove calls virthba_remove - */ -} -EXPORT_SYMBOL_GPL(virtpci_unregister_driver); - -/*****************************************************/ -/* debugfs filesystem functions */ -/*****************************************************/ -struct print_vbus_info { - int *str_pos; - char *buf; - size_t *len; -}; - -static int print_vbus(struct device *vbus, void *data) -{ - struct print_vbus_info *p = (struct print_vbus_info *)data; - - *p->str_pos += scnprintf(p->buf + *p->str_pos, *p->len - *p->str_pos, - "bus_id:%s\n", dev_name(vbus)); - return 0; -} - -static ssize_t info_debugfs_read(struct file *file, char __user *buf, - size_t len, loff_t *offset) -{ - ssize_t bytes_read = 0; - int str_pos = 0; - struct virtpci_dev *tmpvpcidev; - unsigned long flags; - struct print_vbus_info printparam; - char *vbuf; - - if (len > MAX_BUF) - len = MAX_BUF; - vbuf = kzalloc(len, GFP_KERNEL); - if (!vbuf) - return -ENOMEM; - - str_pos += scnprintf(vbuf + str_pos, len - str_pos, - " Virtual PCI Bus devices\n"); - printparam.str_pos = &str_pos; - printparam.buf = vbuf; - printparam.len = &len; - bus_for_each_dev(&virtpci_bus_type, NULL, (void *)&printparam, - print_vbus); - - str_pos += scnprintf(vbuf + str_pos, len - str_pos, - "\n Virtual PCI devices\n"); - read_lock_irqsave(&vpcidev_list_lock, flags); - tmpvpcidev = vpcidev_list_head; - while (tmpvpcidev) { - if (tmpvpcidev->devtype == VIRTHBA_TYPE) { - str_pos += scnprintf(vbuf + str_pos, len - str_pos, - "[%d:%d] VHba:%08x:%08x max-config:%d-%d-%d-%d", - tmpvpcidev->bus_no, - tmpvpcidev->device_no, - tmpvpcidev->scsi.wwnn.wwnn1, - tmpvpcidev->scsi.wwnn.wwnn2, - tmpvpcidev->scsi.max.max_channel, - tmpvpcidev->scsi.max.max_id, - tmpvpcidev->scsi.max.max_lun, - tmpvpcidev->scsi.max.cmd_per_lun); - } else { - str_pos += scnprintf(vbuf + str_pos, len - str_pos, - "[%d:%d] VNic:%pM num_rcv_bufs:%d mtu:%d", - tmpvpcidev->bus_no, - tmpvpcidev->device_no, - tmpvpcidev->net.mac_addr, - tmpvpcidev->net.num_rcv_bufs, - tmpvpcidev->net.mtu); - } - str_pos += scnprintf(vbuf + str_pos, - len - str_pos, " chanptr:%p\n", - tmpvpcidev->queueinfo.chan); - tmpvpcidev = tmpvpcidev->next; - } - read_unlock_irqrestore(&vpcidev_list_lock, flags); - - str_pos += scnprintf(vbuf + str_pos, len - str_pos, "\n"); - bytes_read = simple_read_from_buffer(buf, len, offset, vbuf, str_pos); - kfree(vbuf); - return bytes_read; -} - -/*****************************************************/ -/* Module Init & Exit functions */ -/*****************************************************/ - -static int __init virtpci_mod_init(void) -{ - int ret; - - if (!unisys_spar_platform) - return -ENODEV; - - POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); - - ret = bus_register(&virtpci_bus_type); - /* creates /sys/bus/uisvirtpci which contains devices & - * drivers directory - */ - if (ret) { - POSTCODE_LINUX_3(VPCI_CREATE_FAILURE_PC, ret, - POSTCODE_SEVERITY_ERR); - return ret; - } - bus_device_info_init(&bus_driver_info, "clientbus", "virtpci", - VERSION, NULL); - - /* create a root bus used to parent all the virtpci buses. */ - ret = device_register(&virtpci_rootbus_device); - if (ret) { - bus_unregister(&virtpci_bus_type); - POSTCODE_LINUX_3(VPCI_CREATE_FAILURE_PC, ret, - POSTCODE_SEVERITY_ERR); - return ret; - } - - if (!uisctrl_register_req_handler(2, (void *)&virtpci_ctrlchan_func, - &chipset_driver_info)) { - POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR); - device_unregister(&virtpci_rootbus_device); - bus_unregister(&virtpci_bus_type); - return -1; - } - - /* create debugfs directory and info file inside. */ - virtpci_debugfs_dir = debugfs_create_dir("virtpci", NULL); - debugfs_create_file("info", S_IRUSR, virtpci_debugfs_dir, - NULL, &debugfs_info_fops); - POSTCODE_LINUX_2(VPCI_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO); - return 0; -} - -static void __exit virtpci_mod_exit(void) -{ - /* unregister the callback function */ - device_unregister(&virtpci_rootbus_device); - bus_unregister(&virtpci_bus_type); - debugfs_remove_recursive(virtpci_debugfs_dir); -} - -module_init(virtpci_mod_init); -module_exit(virtpci_mod_exit); -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Usha Srinivasan"); -MODULE_ALIAS("uisvirtpci"); - diff --git a/drivers/staging/unisys/virtpci/virtpci.h b/drivers/staging/unisys/virtpci/virtpci.h deleted file mode 100644 index 9d85f55e8169..000000000000 --- a/drivers/staging/unisys/virtpci/virtpci.h +++ /dev/null @@ -1,103 +0,0 @@ -/* virtpci.h - * - * 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. - */ - -/* - * Unisys Virtual PCI driver header - */ - -#ifndef __VIRTPCI_H__ -#define __VIRTPCI_H__ - -#include "uisqueue.h" -#include -#include - -#define PCI_DEVICE_ID_VIRTHBA 0xAA00 -#define PCI_DEVICE_ID_VIRTNIC 0xAB00 - -struct scsi_adap_info { - void *scsihost; /* scsi host if this device is a scsi hba */ - struct vhba_wwnn wwnn; /* the world wide node name of vhba */ - struct vhba_config_max max; /* various max specifications used - * to config vhba */ -}; - -struct net_adap_info { - struct net_device *netdev; /* network device if this - * device is a NIC */ - u8 mac_addr[MAX_MACADDR_LEN]; - int num_rcv_bufs; - unsigned mtu; - uuid_le zone_uuid; -}; - -enum virtpci_dev_type { - VIRTHBA_TYPE = 0, - VIRTNIC_TYPE = 1, - VIRTBUS_TYPE = 6, -}; - -struct virtpci_dev { - enum virtpci_dev_type devtype; /* indicates type of the - * virtual pci device */ - struct virtpci_driver *mydriver; /* which driver has allocated - * this device */ - unsigned short vendor; /* vendor id for device */ - unsigned short device; /* device id for device */ - u32 bus_no; /* number of bus on which device exists */ - u32 device_no; /* device's number on the bus */ - struct irq_info intr; /* interrupt info */ - struct device generic_dev; /* generic device */ - union { - struct scsi_adap_info scsi; - struct net_adap_info net; - }; - - struct uisqueue_info queueinfo; /* holds ptr to channel where cmds & - * rsps are queued & retrieved */ - struct virtpci_dev *next; /* points to next virtpci device */ -}; - -struct virtpci_driver { - struct list_head node; - const char *name; /* the name of the driver in sysfs */ - const char *version; - const char *vertag; - const struct pci_device_id *id_table; /* must be non-NULL for probe - * to be called */ - int (*probe)(struct virtpci_dev *dev, - const struct pci_device_id *id); /* device inserted */ - void (*remove)(struct virtpci_dev *dev); /* Device removed (NULL if - * not a hot-plug capable - * driver) */ - int (*suspend)(struct virtpci_dev *dev, - u32 state); /* Device suspended */ - int (*resume)(struct virtpci_dev *dev); /* Device woken up */ - int (*enable_wake)(struct virtpci_dev *dev, - u32 state, int enable); /* Enable wake event */ - struct device_driver core_driver; /* VIRTPCI core fills this in */ -}; - -#define driver_to_virtpci_driver(in_drv) \ - container_of(in_drv, struct virtpci_driver, core_driver) -#define device_to_virtpci_dev(in_dev) \ - container_of(in_dev, struct virtpci_dev, generic_dev) - -int virtpci_register_driver(struct virtpci_driver *); -void virtpci_unregister_driver(struct virtpci_driver *); - -#endif /* __VIRTPCI_H__ */ From 6a7d8a418400f8bfaa1830759ef075bbed68cfe1 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Mon, 13 Apr 2015 21:16:51 -0400 Subject: [PATCH 0057/1163] staging: unisys: remove uislib module from staging tree This module is being removed completely, because it contained wrapper functions and utility functions that were used in virtpci and virthba. Since these two drivers are being rewritten to not use these wrappers and utilities, uislib needs to go. Signed-off-by: Benjamin Romer Reviewed-by: Don Zickus Reviewed-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/Kconfig | 1 - drivers/staging/unisys/Makefile | 1 - drivers/staging/unisys/uislib/Kconfig | 10 - drivers/staging/unisys/uislib/Makefile | 12 - drivers/staging/unisys/uislib/uislib.c | 1372 --------------------- drivers/staging/unisys/uislib/uisqueue.c | 322 ----- drivers/staging/unisys/uislib/uisthread.c | 69 -- drivers/staging/unisys/uislib/uisutils.c | 137 -- 8 files changed, 1924 deletions(-) delete mode 100644 drivers/staging/unisys/uislib/Kconfig delete mode 100644 drivers/staging/unisys/uislib/Makefile delete mode 100644 drivers/staging/unisys/uislib/uislib.c delete mode 100644 drivers/staging/unisys/uislib/uisqueue.c delete mode 100644 drivers/staging/unisys/uislib/uisthread.c delete mode 100644 drivers/staging/unisys/uislib/uisutils.c diff --git a/drivers/staging/unisys/Kconfig b/drivers/staging/unisys/Kconfig index 1de86d147b39..14e1ea6803f8 100644 --- a/drivers/staging/unisys/Kconfig +++ b/drivers/staging/unisys/Kconfig @@ -12,6 +12,5 @@ if UNISYSSPAR source "drivers/staging/unisys/visorutil/Kconfig" source "drivers/staging/unisys/visorchannel/Kconfig" source "drivers/staging/unisys/visorchipset/Kconfig" -source "drivers/staging/unisys/uislib/Kconfig" endif # UNISYSSPAR diff --git a/drivers/staging/unisys/Makefile b/drivers/staging/unisys/Makefile index 899b0cbdb5dd..97e750de4bef 100644 --- a/drivers/staging/unisys/Makefile +++ b/drivers/staging/unisys/Makefile @@ -4,4 +4,3 @@ obj-$(CONFIG_UNISYS_VISORUTIL) += visorutil/ obj-$(CONFIG_UNISYS_VISORCHANNEL) += visorchannel/ obj-$(CONFIG_UNISYS_VISORCHIPSET) += visorchipset/ -obj-$(CONFIG_UNISYS_UISLIB) += uislib/ diff --git a/drivers/staging/unisys/uislib/Kconfig b/drivers/staging/unisys/uislib/Kconfig deleted file mode 100644 index c39a0a21ae5f..000000000000 --- a/drivers/staging/unisys/uislib/Kconfig +++ /dev/null @@ -1,10 +0,0 @@ -# -# Unisys uislib configuration -# - -config UNISYS_UISLIB - tristate "Unisys uislib driver" - select UNISYS_VISORCHIPSET - ---help--- - If you say Y here, you will enable the Unisys uislib driver. - diff --git a/drivers/staging/unisys/uislib/Makefile b/drivers/staging/unisys/uislib/Makefile deleted file mode 100644 index 860f494f132f..000000000000 --- a/drivers/staging/unisys/uislib/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# -# Makefile for Unisys uislib -# - -obj-$(CONFIG_UNISYS_UISLIB) += visoruislib.o - -visoruislib-y := uislib.o uisqueue.o uisthread.o uisutils.o - -ccflags-y += -Idrivers/staging/unisys/include -ccflags-y += -Idrivers/staging/unisys/visorchipset -ccflags-y += -Idrivers/staging/unisys/common-spar/include -ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c deleted file mode 100644 index f93d0bb11b12..000000000000 --- a/drivers/staging/unisys/uislib/uislib.c +++ /dev/null @@ -1,1372 +0,0 @@ -/* uislib.c - * - * 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. - */ - -/* @ALL_INSPECTED */ -#define EXPORT_SYMTAB -#include -#include -#ifdef CONFIG_MODVERSIONS -#include -#endif -#include -#include - -#include -#include - -#include -#include "diagnostics/appos_subsystems.h" -#include "uisutils.h" -#include "vbuschannel.h" - -#include -#include /* for copy_from_user */ -#include /* for toupper */ -#include - -#include "sparstop.h" -#include "visorchipset.h" -#include "version.h" -#include "guestlinuxdebug.h" - -#define SET_PROC_OWNER(x, y) - -#define POLLJIFFIES_NORMAL 1 -/* Choose whether or not you want to wakeup the request-polling thread - * after an IO termination: - * this is shorter than using __FILE__ (full path name) in - * debug/info/error messages - */ -#define CURRENT_FILE_PC UISLIB_PC_uislib_c -#define __MYFILE__ "uislib.c" - -/* global function pointers that act as callback functions into virtpcimod */ -int (*virt_control_chan_func)(struct guest_msgs *); - -static int debug_buf_valid; -static char *debug_buf; /* Note this MUST be global, - * because the contents must */ -static unsigned int chipset_inited; - -#define WAIT_ON_CALLBACK(handle) \ - do { \ - if (handle) \ - break; \ - UIS_THREAD_WAIT; \ - } while (1) - -static struct bus_info *bus_list; -static rwlock_t bus_list_lock; -static int bus_list_count; /* number of buses in the list */ -static int max_bus_count; /* maximum number of buses expected */ -static u64 phys_data_chan; -static int platform_no; - -static struct uisthread_info incoming_ti; -static BOOL incoming_started = FALSE; -static LIST_HEAD(poll_dev_chan); -static unsigned long long tot_moved_to_tail_cnt; -static unsigned long long tot_wait_cnt; -static unsigned long long tot_wakeup_cnt; -static unsigned long long tot_schedule_cnt; -static int en_smart_wakeup = 1; -static DEFINE_SEMAPHORE(poll_dev_lock); /* unlocked */ -static DECLARE_WAIT_QUEUE_HEAD(poll_dev_wake_q); -static int poll_dev_start; - -#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; - -#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; - -#define INFO_DEBUGFS_ENTRY_FN "info" -static struct dentry *info_debugfs_entry; - -static unsigned long long cycles_before_wait, wait_cycles; - -/*****************************************************/ -/* local functions */ -/*****************************************************/ - -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 = { - .read = info_debugfs_read, -}; - -static void -init_msg_header(struct controlvm_message *msg, u32 id, uint rsp, uint svr) -{ - memset(msg, 0, sizeof(struct controlvm_message)); - msg->hdr.id = id; - msg->hdr.flags.response_expected = rsp; - msg->hdr.flags.server = svr; -} - -static __iomem void *init_vbus_channel(u64 ch_addr, u32 ch_bytes) -{ - void __iomem *ch = uislib_ioremap_cache(ch_addr, ch_bytes); - - if (!ch) - return NULL; - - if (!SPAR_VBUS_CHANNEL_OK_CLIENT(ch)) { - uislib_iounmap(ch); - return NULL; - } - return ch; -} - -static int -create_bus(struct controlvm_message *msg, char *buf) -{ - u32 bus_no, dev_count; - struct bus_info *tmp, *bus; - size_t size; - - if (max_bus_count == bus_list_count) { - POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, max_bus_count, - POSTCODE_SEVERITY_ERR); - return CONTROLVM_RESP_ERROR_MAX_BUSES; - } - - bus_no = msg->cmd.create_bus.bus_no; - dev_count = msg->cmd.create_bus.dev_count; - - POSTCODE_LINUX_4(BUS_CREATE_ENTRY_PC, bus_no, dev_count, - POSTCODE_SEVERITY_INFO); - - size = - sizeof(struct bus_info) + - (dev_count * sizeof(struct device_info *)); - bus = kzalloc(size, GFP_ATOMIC); - if (!bus) { - POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no, - POSTCODE_SEVERITY_ERR); - return CONTROLVM_RESP_ERROR_KMALLOC_FAILED; - } - - /* Currently by default, the bus Number is the GuestHandle. - * Configure Bus message can override this. - */ - if (msg->hdr.flags.test_message) { - /* This implies we're the IOVM so set guest handle to 0... */ - bus->guest_handle = 0; - bus->bus_no = bus_no; - bus->local_vnic = 1; - } else { - bus->bus_no = bus_no; - bus->guest_handle = bus_no; - } - sprintf(bus->name, "%d", (int)bus->bus_no); - bus->device_count = dev_count; - bus->device = - (struct device_info **)((char *)bus + sizeof(struct bus_info)); - bus->bus_inst_uuid = msg->cmd.create_bus.bus_inst_uuid; - bus->bus_channel_bytes = 0; - bus->bus_channel = NULL; - - /* add bus to our bus list - but check for duplicates first */ - read_lock(&bus_list_lock); - for (tmp = bus_list; tmp; tmp = tmp->next) { - if (tmp->bus_no == bus->bus_no) - break; - } - read_unlock(&bus_list_lock); - if (tmp) { - /* found a bus already in the list with same bus_no - - * reject add - */ - POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->bus_no, - POSTCODE_SEVERITY_ERR); - kfree(bus); - return CONTROLVM_RESP_ERROR_ALREADY_DONE; - } - if ((msg->cmd.create_bus.channel_addr != 0) && - (msg->cmd.create_bus.channel_bytes != 0)) { - bus->bus_channel_bytes = msg->cmd.create_bus.channel_bytes; - bus->bus_channel = - init_vbus_channel(msg->cmd.create_bus.channel_addr, - msg->cmd.create_bus.channel_bytes); - } - /* the msg is bound for virtpci; send guest_msgs struct to callback */ - if (!msg->hdr.flags.server) { - struct guest_msgs cmd; - - cmd.msgtype = GUEST_ADD_VBUS; - cmd.add_vbus.bus_no = bus_no; - cmd.add_vbus.chanptr = bus->bus_channel; - cmd.add_vbus.dev_count = dev_count; - cmd.add_vbus.bus_uuid = msg->cmd.create_bus.bus_data_type_uuid; - cmd.add_vbus.instance_uuid = msg->cmd.create_bus.bus_inst_uuid; - if (!virt_control_chan_func) { - POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->bus_no, - POSTCODE_SEVERITY_ERR); - kfree(bus); - return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; - } - if (!virt_control_chan_func(&cmd)) { - POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->bus_no, - POSTCODE_SEVERITY_ERR); - kfree(bus); - return - CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR; - } - } - - /* add bus at the head of our list */ - write_lock(&bus_list_lock); - if (!bus_list) { - bus_list = bus; - } else { - bus->next = bus_list; - bus_list = bus; - } - bus_list_count++; - write_unlock(&bus_list_lock); - - POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus->bus_no, - POSTCODE_SEVERITY_INFO); - return CONTROLVM_RESP_SUCCESS; -} - -static int -destroy_bus(struct controlvm_message *msg, char *buf) -{ - int i; - struct bus_info *bus, *prev = NULL; - struct guest_msgs cmd; - u32 bus_no; - - bus_no = msg->cmd.destroy_bus.bus_no; - - read_lock(&bus_list_lock); - - bus = bus_list; - while (bus) { - if (bus->bus_no == bus_no) - break; - prev = bus; - bus = bus->next; - } - - if (!bus) { - read_unlock(&bus_list_lock); - return CONTROLVM_RESP_ERROR_ALREADY_DONE; - } - - /* verify that this bus has no devices. */ - for (i = 0; i < bus->device_count; i++) { - if (bus->device[i]) { - read_unlock(&bus_list_lock); - return CONTROLVM_RESP_ERROR_BUS_DEVICE_ATTACHED; - } - } - read_unlock(&bus_list_lock); - - if (msg->hdr.flags.server) - goto remove; - - /* client messages require us to call the virtpci callback associated - with this bus. */ - cmd.msgtype = GUEST_DEL_VBUS; - cmd.del_vbus.bus_no = bus_no; - if (!virt_control_chan_func) - return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; - - if (!virt_control_chan_func(&cmd)) - return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR; - - /* finally, remove the bus from the list */ -remove: - write_lock(&bus_list_lock); - if (prev) /* not at head */ - prev->next = bus->next; - else - bus_list = bus->next; - bus_list_count--; - write_unlock(&bus_list_lock); - - if (bus->bus_channel) { - uislib_iounmap(bus->bus_channel); - bus->bus_channel = NULL; - } - - kfree(bus); - return CONTROLVM_RESP_SUCCESS; -} - -static int create_device(struct controlvm_message *msg, char *buf) -{ - struct device_info *dev; - struct bus_info *bus; - struct guest_msgs cmd; - u32 bus_no, dev_no; - int result = CONTROLVM_RESP_SUCCESS; - u64 min_size = MIN_IO_CHANNEL_SIZE; - struct req_handler_info *req_handler; - - bus_no = msg->cmd.create_device.bus_no; - dev_no = msg->cmd.create_device.dev_no; - - POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no, - POSTCODE_SEVERITY_INFO); - - dev = kzalloc(sizeof(*dev), GFP_ATOMIC); - if (!dev) { - POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, - POSTCODE_SEVERITY_ERR); - return CONTROLVM_RESP_ERROR_KMALLOC_FAILED; - } - - dev->channel_uuid = msg->cmd.create_device.data_type_uuid; - dev->intr = msg->cmd.create_device.intr; - dev->channel_addr = msg->cmd.create_device.channel_addr; - dev->bus_no = bus_no; - dev->dev_no = dev_no; - sema_init(&dev->interrupt_callback_lock, 1); /* unlocked */ - sprintf(dev->devid, "vbus%u:dev%u", (unsigned)bus_no, (unsigned)dev_no); - /* map the channel memory for the device. */ - if (msg->hdr.flags.test_message) { - dev->chanptr = (void __iomem *)__va(dev->channel_addr); - } else { - req_handler = req_handler_find(dev->channel_uuid); - if (req_handler) - /* generic service handler registered for this - * channel - */ - min_size = req_handler->min_channel_bytes; - if (min_size > msg->cmd.create_device.channel_bytes) { - POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, - bus_no, POSTCODE_SEVERITY_ERR); - result = CONTROLVM_RESP_ERROR_CHANNEL_SIZE_TOO_SMALL; - goto cleanup; - } - dev->chanptr = - uislib_ioremap_cache(dev->channel_addr, - msg->cmd.create_device.channel_bytes); - if (!dev->chanptr) { - result = CONTROLVM_RESP_ERROR_IOREMAP_FAILED; - POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, - bus_no, POSTCODE_SEVERITY_ERR); - goto cleanup; - } - } - dev->instance_uuid = msg->cmd.create_device.dev_inst_uuid; - dev->channel_bytes = msg->cmd.create_device.channel_bytes; - - read_lock(&bus_list_lock); - for (bus = bus_list; bus; bus = bus->next) { - if (bus->bus_no != bus_no) - continue; - /* make sure the device number is valid */ - if (dev_no >= bus->device_count) { - result = CONTROLVM_RESP_ERROR_MAX_DEVICES; - POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, - bus_no, POSTCODE_SEVERITY_ERR); - read_unlock(&bus_list_lock); - goto cleanup; - } - /* make sure this device is not already set */ - if (bus->device[dev_no]) { - POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, - dev_no, bus_no, - POSTCODE_SEVERITY_ERR); - result = CONTROLVM_RESP_ERROR_ALREADY_DONE; - read_unlock(&bus_list_lock); - goto cleanup; - } - read_unlock(&bus_list_lock); - /* the msg is bound for virtpci; send - * guest_msgs struct to callback - */ - if (msg->hdr.flags.server) { - bus->device[dev_no] = dev; - POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, dev_no, - bus_no, POSTCODE_SEVERITY_INFO); - return CONTROLVM_RESP_SUCCESS; - } - if (uuid_le_cmp(dev->channel_uuid, - spar_vhba_channel_protocol_uuid) == 0) { - wait_for_valid_guid(&((struct channel_header __iomem *) - (dev->chanptr))->chtype); - if (!SPAR_VHBA_CHANNEL_OK_CLIENT(dev->chanptr)) { - POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, - dev_no, bus_no, - POSTCODE_SEVERITY_ERR); - result = CONTROLVM_RESP_ERROR_CHANNEL_INVALID; - goto cleanup; - } - cmd.msgtype = GUEST_ADD_VHBA; - cmd.add_vhba.chanptr = dev->chanptr; - cmd.add_vhba.bus_no = bus_no; - cmd.add_vhba.device_no = dev_no; - cmd.add_vhba.instance_uuid = dev->instance_uuid; - cmd.add_vhba.intr = dev->intr; - } else if (uuid_le_cmp(dev->channel_uuid, - spar_vnic_channel_protocol_uuid) == 0) { - wait_for_valid_guid(&((struct channel_header __iomem *) - (dev->chanptr))->chtype); - if (!SPAR_VNIC_CHANNEL_OK_CLIENT(dev->chanptr)) { - POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, - dev_no, bus_no, - POSTCODE_SEVERITY_ERR); - result = CONTROLVM_RESP_ERROR_CHANNEL_INVALID; - goto cleanup; - } - cmd.msgtype = GUEST_ADD_VNIC; - cmd.add_vnic.chanptr = dev->chanptr; - cmd.add_vnic.bus_no = bus_no; - cmd.add_vnic.device_no = dev_no; - cmd.add_vnic.instance_uuid = dev->instance_uuid; - cmd.add_vhba.intr = dev->intr; - } else { - POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, - bus_no, POSTCODE_SEVERITY_ERR); - result = CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN; - goto cleanup; - } - - if (!virt_control_chan_func) { - POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, - bus_no, POSTCODE_SEVERITY_ERR); - result = CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; - goto cleanup; - } - - if (!virt_control_chan_func(&cmd)) { - POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, - bus_no, POSTCODE_SEVERITY_ERR); - result = - CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR; - goto cleanup; - } - - bus->device[dev_no] = dev; - POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, dev_no, - bus_no, POSTCODE_SEVERITY_INFO); - return CONTROLVM_RESP_SUCCESS; - } - read_unlock(&bus_list_lock); - - POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, - POSTCODE_SEVERITY_ERR); - result = CONTROLVM_RESP_ERROR_BUS_INVALID; - -cleanup: - if (!msg->hdr.flags.test_message) { - uislib_iounmap(dev->chanptr); - dev->chanptr = NULL; - } - - kfree(dev); - return result; -} - -static int pause_device(struct controlvm_message *msg) -{ - u32 bus_no, dev_no; - struct bus_info *bus; - struct device_info *dev; - struct guest_msgs cmd; - int retval = CONTROLVM_RESP_SUCCESS; - - bus_no = msg->cmd.device_change_state.bus_no; - dev_no = msg->cmd.device_change_state.dev_no; - - read_lock(&bus_list_lock); - for (bus = bus_list; bus; bus = bus->next) { - if (bus->bus_no == bus_no) { - /* make sure the device number is valid */ - if (dev_no >= bus->device_count) { - retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID; - } else { - /* make sure this device exists */ - dev = bus->device[dev_no]; - if (!dev) { - retval = - CONTROLVM_RESP_ERROR_ALREADY_DONE; - } - } - break; - } - } - if (!bus) - retval = CONTROLVM_RESP_ERROR_BUS_INVALID; - - read_unlock(&bus_list_lock); - if (retval == CONTROLVM_RESP_SUCCESS) { - /* the msg is bound for virtpci; send - * guest_msgs struct to callback - */ - if (uuid_le_cmp(dev->channel_uuid, - spar_vhba_channel_protocol_uuid) == 0) { - cmd.msgtype = GUEST_PAUSE_VHBA; - cmd.pause_vhba.chanptr = dev->chanptr; - } else if (uuid_le_cmp(dev->channel_uuid, - spar_vnic_channel_protocol_uuid) == 0) { - cmd.msgtype = GUEST_PAUSE_VNIC; - cmd.pause_vnic.chanptr = dev->chanptr; - } else { - return CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN; - } - if (!virt_control_chan_func) - return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; - if (!virt_control_chan_func(&cmd)) { - return - CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR; - } - } - return retval; -} - -static int resume_device(struct controlvm_message *msg) -{ - u32 bus_no, dev_no; - struct bus_info *bus; - struct device_info *dev; - struct guest_msgs cmd; - int retval = CONTROLVM_RESP_SUCCESS; - - bus_no = msg->cmd.device_change_state.bus_no; - dev_no = msg->cmd.device_change_state.dev_no; - - read_lock(&bus_list_lock); - for (bus = bus_list; bus; bus = bus->next) { - if (bus->bus_no == bus_no) { - /* make sure the device number is valid */ - if (dev_no >= bus->device_count) { - retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID; - } else { - /* make sure this device exists */ - dev = bus->device[dev_no]; - if (!dev) { - retval = - CONTROLVM_RESP_ERROR_ALREADY_DONE; - } - } - break; - } - } - - if (!bus) - retval = CONTROLVM_RESP_ERROR_BUS_INVALID; - - read_unlock(&bus_list_lock); - /* the msg is bound for virtpci; send - * guest_msgs struct to callback - */ - if (retval == CONTROLVM_RESP_SUCCESS) { - if (uuid_le_cmp(dev->channel_uuid, - spar_vhba_channel_protocol_uuid) == 0) { - cmd.msgtype = GUEST_RESUME_VHBA; - cmd.resume_vhba.chanptr = dev->chanptr; - } else if (uuid_le_cmp(dev->channel_uuid, - spar_vnic_channel_protocol_uuid) == 0) { - cmd.msgtype = GUEST_RESUME_VNIC; - cmd.resume_vnic.chanptr = dev->chanptr; - } else { - return CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN; - } - if (!virt_control_chan_func) - return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; - if (!virt_control_chan_func(&cmd)) { - return - CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR; - } - } - return retval; -} - -static int destroy_device(struct controlvm_message *msg, char *buf) -{ - u32 bus_no, dev_no; - struct bus_info *bus; - struct device_info *dev; - struct guest_msgs cmd; - int retval = CONTROLVM_RESP_SUCCESS; - - bus_no = msg->cmd.destroy_device.bus_no; - dev_no = msg->cmd.destroy_device.bus_no; - - read_lock(&bus_list_lock); - for (bus = bus_list; bus; bus = bus->next) { - if (bus->bus_no == bus_no) { - /* make sure the device number is valid */ - if (dev_no >= bus->device_count) { - retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID; - } else { - /* make sure this device exists */ - dev = bus->device[dev_no]; - if (!dev) { - retval = - CONTROLVM_RESP_ERROR_ALREADY_DONE; - } - } - break; - } - } - - if (!bus) - retval = CONTROLVM_RESP_ERROR_BUS_INVALID; - read_unlock(&bus_list_lock); - if (retval == CONTROLVM_RESP_SUCCESS) { - /* the msg is bound for virtpci; send - * guest_msgs struct to callback - */ - if (uuid_le_cmp(dev->channel_uuid, - spar_vhba_channel_protocol_uuid) == 0) { - cmd.msgtype = GUEST_DEL_VHBA; - cmd.del_vhba.chanptr = dev->chanptr; - } else if (uuid_le_cmp(dev->channel_uuid, - spar_vnic_channel_protocol_uuid) == 0) { - cmd.msgtype = GUEST_DEL_VNIC; - cmd.del_vnic.chanptr = dev->chanptr; - } else { - return - CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN; - } - if (!virt_control_chan_func) { - return - CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; - } - if (!virt_control_chan_func(&cmd)) { - return - CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR; - } -/* you must disable channel interrupts BEFORE you unmap the channel, - * because if you unmap first, there may still be some activity going - * on which accesses the channel and you will get a "unable to handle - * kernel paging request" - */ - if (dev->polling) - uislib_disable_channel_interrupts(bus_no, dev_no); - /* unmap the channel memory for the device. */ - if (!msg->hdr.flags.test_message) - uislib_iounmap(dev->chanptr); - kfree(dev); - bus->device[dev_no] = NULL; - } - return retval; -} - -static int -init_chipset(struct controlvm_message *msg, char *buf) -{ - POSTCODE_LINUX_2(CHIPSET_INIT_ENTRY_PC, POSTCODE_SEVERITY_INFO); - - max_bus_count = msg->cmd.init_chipset.bus_count; - platform_no = msg->cmd.init_chipset.platform_number; - phys_data_chan = 0; - - /* We need to make sure we have our functions registered - * before processing messages. If we are a test vehicle the - * test_message for init_chipset will be set. We can ignore the - * waits for the callbacks, since this will be manually entered - * from a user. If no test_message is set, we will wait for the - * functions. - */ - if (!msg->hdr.flags.test_message) - WAIT_ON_CALLBACK(virt_control_chan_func); - - chipset_inited = 1; - POSTCODE_LINUX_2(CHIPSET_INIT_EXIT_PC, POSTCODE_SEVERITY_INFO); - - return CONTROLVM_RESP_SUCCESS; -} - -static int delete_bus_glue(u32 bus_no) -{ - struct controlvm_message msg; - - init_msg_header(&msg, CONTROLVM_BUS_DESTROY, 0, 0); - msg.cmd.destroy_bus.bus_no = bus_no; - if (destroy_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS) - return 0; - return 1; -} - -static int delete_device_glue(u32 bus_no, u32 dev_no) -{ - struct controlvm_message msg; - - init_msg_header(&msg, CONTROLVM_DEVICE_DESTROY, 0, 0); - msg.cmd.destroy_device.bus_no = bus_no; - msg.cmd.destroy_device.dev_no = dev_no; - if (destroy_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) - return 0; - return 1; -} - -int -uislib_client_inject_add_bus(u32 bus_no, uuid_le inst_uuid, - u64 channel_addr, ulong n_channel_bytes) -{ - struct controlvm_message msg; - - /* step 0: init the chipset */ - POSTCODE_LINUX_3(CHIPSET_INIT_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO); - - if (!chipset_inited) { - /* step: initialize the chipset */ - init_msg_header(&msg, CONTROLVM_CHIPSET_INIT, 0, 0); - /* this change is needed so that console will come up - * OK even when the bus 0 create comes in late. If the - * bus 0 create is the first create, then the add_vnic - * will work fine, but if the bus 0 create arrives - * after number 4, then the add_vnic will fail, and the - * ultraboot will fail. - */ - msg.cmd.init_chipset.bus_count = 23; - msg.cmd.init_chipset.switch_count = 0; - if (init_chipset(&msg, NULL) != CONTROLVM_RESP_SUCCESS) - return 0; - POSTCODE_LINUX_3(CHIPSET_INIT_EXIT_PC, bus_no, - POSTCODE_SEVERITY_INFO); - } - - /* step 1: create a bus */ - POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, - POSTCODE_SEVERITY_WARNING); - init_msg_header(&msg, CONTROLVM_BUS_CREATE, 0, 0); - msg.cmd.create_bus.bus_no = bus_no; - msg.cmd.create_bus.dev_count = 23; /* devNo+1; */ - msg.cmd.create_bus.channel_addr = channel_addr; - msg.cmd.create_bus.channel_bytes = n_channel_bytes; - if (create_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { - POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no, - POSTCODE_SEVERITY_ERR); - return 0; - } - POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO); - - return 1; -} -EXPORT_SYMBOL_GPL(uislib_client_inject_add_bus); - -int -uislib_client_inject_del_bus(u32 bus_no) -{ - return delete_bus_glue(bus_no); -} -EXPORT_SYMBOL_GPL(uislib_client_inject_del_bus); - -int -uislib_client_inject_pause_vhba(u32 bus_no, u32 dev_no) -{ - struct controlvm_message msg; - int rc; - - init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0); - msg.cmd.device_change_state.bus_no = bus_no; - msg.cmd.device_change_state.dev_no = dev_no; - msg.cmd.device_change_state.state = segment_state_standby; - rc = pause_device(&msg); - if (rc != CONTROLVM_RESP_SUCCESS) - return rc; - return 0; -} -EXPORT_SYMBOL_GPL(uislib_client_inject_pause_vhba); - -int -uislib_client_inject_resume_vhba(u32 bus_no, u32 dev_no) -{ - struct controlvm_message msg; - int rc; - - init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0); - msg.cmd.device_change_state.bus_no = bus_no; - msg.cmd.device_change_state.dev_no = dev_no; - msg.cmd.device_change_state.state = segment_state_running; - rc = resume_device(&msg); - if (rc != CONTROLVM_RESP_SUCCESS) - return rc; - return 0; -} -EXPORT_SYMBOL_GPL(uislib_client_inject_resume_vhba); - -int -uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no, - u64 phys_chan_addr, u32 chan_bytes, - int is_test_addr, uuid_le inst_uuid, - struct irq_info *intr) -{ - struct controlvm_message msg; - - /* chipset init'ed with bus bus has been previously created - - * Verify it still exists step 2: create the VHBA device on the - * bus - */ - POSTCODE_LINUX_4(VHBA_CREATE_ENTRY_PC, dev_no, bus_no, - POSTCODE_SEVERITY_INFO); - - init_msg_header(&msg, CONTROLVM_DEVICE_CREATE, 0, 0); - if (is_test_addr) - /* signify that the physical channel address does NOT - * need to be ioremap()ed - */ - msg.hdr.flags.test_message = 1; - msg.cmd.create_device.bus_no = bus_no; - msg.cmd.create_device.dev_no = dev_no; - msg.cmd.create_device.dev_inst_uuid = inst_uuid; - if (intr) - msg.cmd.create_device.intr = *intr; - else - memset(&msg.cmd.create_device.intr, 0, - sizeof(struct irq_info)); - msg.cmd.create_device.channel_addr = phys_chan_addr; - if (chan_bytes < MIN_IO_CHANNEL_SIZE) { - POSTCODE_LINUX_4(VHBA_CREATE_FAILURE_PC, chan_bytes, - MIN_IO_CHANNEL_SIZE, POSTCODE_SEVERITY_ERR); - return 0; - } - msg.cmd.create_device.channel_bytes = chan_bytes; - msg.cmd.create_device.data_type_uuid = spar_vhba_channel_protocol_uuid; - if (create_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { - POSTCODE_LINUX_4(VHBA_CREATE_FAILURE_PC, dev_no, bus_no, - POSTCODE_SEVERITY_ERR); - return 0; - } - POSTCODE_LINUX_4(VHBA_CREATE_SUCCESS_PC, dev_no, bus_no, - POSTCODE_SEVERITY_INFO); - return 1; -} -EXPORT_SYMBOL_GPL(uislib_client_inject_add_vhba); - -int -uislib_client_inject_del_vhba(u32 bus_no, u32 dev_no) -{ - return delete_device_glue(bus_no, dev_no); -} -EXPORT_SYMBOL_GPL(uislib_client_inject_del_vhba); - -int -uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no, - u64 phys_chan_addr, u32 chan_bytes, - int is_test_addr, uuid_le inst_uuid, - struct irq_info *intr) -{ - struct controlvm_message msg; - - /* chipset init'ed with bus bus has been previously created - - * Verify it still exists step 2: create the VNIC device on the - * bus - */ - POSTCODE_LINUX_4(VNIC_CREATE_ENTRY_PC, dev_no, bus_no, - POSTCODE_SEVERITY_INFO); - - init_msg_header(&msg, CONTROLVM_DEVICE_CREATE, 0, 0); - if (is_test_addr) - /* signify that the physical channel address does NOT - * need to be ioremap()ed - */ - msg.hdr.flags.test_message = 1; - msg.cmd.create_device.bus_no = bus_no; - msg.cmd.create_device.dev_no = dev_no; - msg.cmd.create_device.dev_inst_uuid = inst_uuid; - if (intr) - msg.cmd.create_device.intr = *intr; - else - memset(&msg.cmd.create_device.intr, 0, - sizeof(struct irq_info)); - msg.cmd.create_device.channel_addr = phys_chan_addr; - if (chan_bytes < MIN_IO_CHANNEL_SIZE) { - POSTCODE_LINUX_4(VNIC_CREATE_FAILURE_PC, chan_bytes, - MIN_IO_CHANNEL_SIZE, POSTCODE_SEVERITY_ERR); - return 0; - } - msg.cmd.create_device.channel_bytes = chan_bytes; - msg.cmd.create_device.data_type_uuid = spar_vnic_channel_protocol_uuid; - if (create_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { - POSTCODE_LINUX_4(VNIC_CREATE_FAILURE_PC, dev_no, bus_no, - POSTCODE_SEVERITY_ERR); - return 0; - } - - POSTCODE_LINUX_4(VNIC_CREATE_SUCCESS_PC, dev_no, bus_no, - POSTCODE_SEVERITY_INFO); - return 1; -} -EXPORT_SYMBOL_GPL(uislib_client_inject_add_vnic); - -int -uislib_client_inject_pause_vnic(u32 bus_no, u32 dev_no) -{ - struct controlvm_message msg; - int rc; - - init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0); - msg.cmd.device_change_state.bus_no = bus_no; - msg.cmd.device_change_state.dev_no = dev_no; - msg.cmd.device_change_state.state = segment_state_standby; - rc = pause_device(&msg); - if (rc != CONTROLVM_RESP_SUCCESS) - return -1; - return 0; -} -EXPORT_SYMBOL_GPL(uislib_client_inject_pause_vnic); - -int -uislib_client_inject_resume_vnic(u32 bus_no, u32 dev_no) -{ - struct controlvm_message msg; - int rc; - - init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0); - msg.cmd.device_change_state.bus_no = bus_no; - msg.cmd.device_change_state.dev_no = dev_no; - msg.cmd.device_change_state.state = segment_state_running; - rc = resume_device(&msg); - if (rc != CONTROLVM_RESP_SUCCESS) - return -1; - return 0; -} -EXPORT_SYMBOL_GPL(uislib_client_inject_resume_vnic); - -int -uislib_client_inject_del_vnic(u32 bus_no, u32 dev_no) -{ - return delete_device_glue(bus_no, dev_no); -} -EXPORT_SYMBOL_GPL(uislib_client_inject_del_vnic); - -void * -uislib_cache_alloc(struct kmem_cache *cur_pool, char *fn, int ln) -{ - /* __GFP_NORETRY means "ok to fail", meaning kmalloc() can - * return NULL. If you do NOT specify __GFP_NORETRY, Linux - * will go to extreme measures to get memory for you (like, - * invoke oom killer), which will probably cripple the system. - */ - void *p = kmem_cache_alloc(cur_pool, GFP_ATOMIC | __GFP_NORETRY); - - if (!p) - return NULL; - return p; -} -EXPORT_SYMBOL_GPL(uislib_cache_alloc); - -void -uislib_cache_free(struct kmem_cache *cur_pool, void *p, char *fn, int ln) -{ - if (!p) - return; - kmem_cache_free(cur_pool, p); -} -EXPORT_SYMBOL_GPL(uislib_cache_free); - -/*****************************************************/ -/* proc filesystem callback functions */ -/*****************************************************/ - -#define PLINE(...) uisutil_add_proc_line_ex(&tot, buff, \ - buff_len, __VA_ARGS__) - -static int -info_debugfs_read_helper(char **buff, int *buff_len) -{ - int i, tot = 0; - struct bus_info *bus; - - if (PLINE("\nBuses:\n") < 0) - goto err_done; - - read_lock(&bus_list_lock); - for (bus = bus_list; bus; bus = bus->next) { - if (PLINE(" bus=0x%p, busNo=%d, deviceCount=%d\n", - bus, bus->bus_no, bus->device_count) < 0) - goto err_done_unlock; - - if (PLINE(" Devices:\n") < 0) - goto err_done_unlock; - - for (i = 0; i < bus->device_count; i++) { - if (bus->device[i]) { - if (PLINE(" busNo %d, device[%i]: 0x%p, chanptr=0x%p, swtch=0x%p\n", - bus->bus_no, i, bus->device[i], - bus->device[i]->chanptr, - bus->device[i]->swtch) < 0) - goto err_done_unlock; - - if (PLINE(" first_busy_cnt=%llu, moved_to_tail_cnt=%llu, last_on_list_cnt=%llu\n", - bus->device[i]->first_busy_cnt, - bus->device[i]->moved_to_tail_cnt, - bus->device[i]->last_on_list_cnt) < 0) - goto err_done_unlock; - } - } - } - read_unlock(&bus_list_lock); - - if (PLINE("UisUtils_Registered_Services: %d\n", - atomic_read(&uisutils_registered_services)) < 0) - goto err_done; - if (PLINE("cycles_before_wait %llu wait_cycles:%llu\n", - cycles_before_wait, wait_cycles) < 0) - goto err_done; - if (PLINE("tot_wakeup_cnt %llu:tot_wait_cnt %llu:tot_schedule_cnt %llu\n", - tot_wakeup_cnt, tot_wait_cnt, tot_schedule_cnt) < 0) - goto err_done; - if (PLINE("en_smart_wakeup %d\n", en_smart_wakeup) < 0) - goto err_done; - if (PLINE("tot_moved_to_tail_cnt %llu\n", tot_moved_to_tail_cnt) < 0) - goto err_done; - - return tot; - -err_done_unlock: - read_unlock(&bus_list_lock); -err_done: - return -1; -} - -static ssize_t info_debugfs_read(struct file *file, char __user *buf, - size_t len, loff_t *offset) -{ - char *temp; - int total_bytes = 0; - int remaining_bytes = PROC_READ_BUFFER_SIZE; - -/* *start = buf; */ - if (!debug_buf) { - debug_buf = vmalloc(PROC_READ_BUFFER_SIZE); - - if (!debug_buf) - return -ENOMEM; - } - - temp = debug_buf; - - if ((*offset == 0) || (!debug_buf_valid)) { - /* if the read fails, then -1 will be returned */ - total_bytes = info_debugfs_read_helper(&temp, &remaining_bytes); - debug_buf_valid = 1; - } else { - total_bytes = strlen(debug_buf); - } - - return simple_read_from_buffer(buf, len, offset, - debug_buf, total_bytes); -} - -static struct device_info *find_dev(u32 bus_no, u32 dev_no) -{ - struct bus_info *bus; - struct device_info *dev = NULL; - - read_lock(&bus_list_lock); - for (bus = bus_list; bus; bus = bus->next) { - if (bus->bus_no == bus_no) { - /* make sure the device number is valid */ - if (dev_no >= bus->device_count) - break; - dev = bus->device[dev_no]; - break; - } - } - read_unlock(&bus_list_lock); - return dev; -} - -/* This thread calls the "interrupt" function for each device that has - * enabled such using uislib_enable_channel_interrupts(). The "interrupt" - * function typically reads and processes the devices's channel input - * queue. This thread repeatedly does this, until the thread is told to stop - * (via uisthread_stop()). Sleeping rules: - * - If we have called the "interrupt" function for all devices, and all of - * them have reported "nothing processed" (returned 0), then we will go to - * sleep for a maximum of POLLJIFFIES_NORMAL jiffies. - * - If anyone calls uislib_force_channel_interrupt(), the above jiffy - * sleep will be interrupted, and we will resume calling the "interrupt" - * function for all devices. - * - The list of devices is dynamically re-ordered in order to - * attempt to preserve fairness. Whenever we spin thru the list of - * devices and call the dev->interrupt() function, if we find - * devices which report that there is still more work to do, the - * the first such device we find is moved to the end of the device - * list. This ensures that extremely busy devices don't starve out - * less-busy ones. - * - */ -static int process_incoming(void *v) -{ - unsigned long long cur_cycles, old_cycles, idle_cycles, delta_cycles; - struct list_head *new_tail = NULL; - int i; - - UIS_DAEMONIZE("dev_incoming"); - for (i = 0; i < 16; i++) { - old_cycles = get_cycles(); - wait_event_timeout(poll_dev_wake_q, - 0, POLLJIFFIES_NORMAL); - cur_cycles = get_cycles(); - if (wait_cycles == 0) { - wait_cycles = (cur_cycles - old_cycles); - } else { - if (wait_cycles < (cur_cycles - old_cycles)) - wait_cycles = (cur_cycles - old_cycles); - } - } - cycles_before_wait = wait_cycles; - idle_cycles = 0; - poll_dev_start = 0; - while (1) { - struct list_head *lelt, *tmp; - struct device_info *dev = NULL; - - /* poll each channel for input */ - down(&poll_dev_lock); - new_tail = NULL; - list_for_each_safe(lelt, tmp, &poll_dev_chan) { - int rc = 0; - - dev = list_entry(lelt, struct device_info, - list_polling_device_channels); - down(&dev->interrupt_callback_lock); - if (dev->interrupt) - rc = dev->interrupt(dev->interrupt_context); - else - continue; - up(&dev->interrupt_callback_lock); - if (rc) { - /* dev->interrupt returned, but there - * is still more work to do. - * Reschedule work to occur as soon as - * possible. */ - idle_cycles = 0; - if (!new_tail) { - dev->first_busy_cnt++; - if (! - (list_is_last - (lelt, - &poll_dev_chan))) { - new_tail = lelt; - dev->moved_to_tail_cnt++; - } else { - dev->last_on_list_cnt++; - } - } - } - if (kthread_should_stop()) - break; - } - if (new_tail) { - tot_moved_to_tail_cnt++; - list_move_tail(new_tail, &poll_dev_chan); - } - up(&poll_dev_lock); - cur_cycles = get_cycles(); - delta_cycles = cur_cycles - old_cycles; - old_cycles = cur_cycles; - - /* At this point, we have scanned thru all of the - * channels, and at least one of the following is true: - * - there is no input waiting on any of the channels - * - we have received a signal to stop this thread - */ - if (kthread_should_stop()) - break; - if (en_smart_wakeup == 0xFF) - break; - /* wait for POLLJIFFIES_NORMAL jiffies, or until - * someone wakes up poll_dev_wake_q, - * whichever comes first only do a wait when we have - * been idle for cycles_before_wait cycles. - */ - if (idle_cycles > cycles_before_wait) { - poll_dev_start = 0; - tot_wait_cnt++; - wait_event_timeout(poll_dev_wake_q, - poll_dev_start, - POLLJIFFIES_NORMAL); - poll_dev_start = 1; - } else { - tot_schedule_cnt++; - schedule(); - idle_cycles = idle_cycles + delta_cycles; - } - } - complete_and_exit(&incoming_ti.has_stopped, 0); -} - -static BOOL -initialize_incoming_thread(void) -{ - if (incoming_started) - return TRUE; - if (!uisthread_start(&incoming_ti, - &process_incoming, NULL, "dev_incoming")) { - return FALSE; - } - incoming_started = TRUE; - return TRUE; -} - -/* Add a new device/channel to the list being processed by - * process_incoming(). - * - indicates the function to call periodically. - * - indicates the data to pass to the - * function. - */ -void -uislib_enable_channel_interrupts(u32 bus_no, u32 dev_no, - int (*interrupt)(void *), - void *interrupt_context) -{ - struct device_info *dev; - - dev = find_dev(bus_no, dev_no); - if (!dev) - return; - - down(&poll_dev_lock); - initialize_incoming_thread(); - dev->interrupt = interrupt; - dev->interrupt_context = interrupt_context; - dev->polling = TRUE; - list_add_tail(&dev->list_polling_device_channels, - &poll_dev_chan); - up(&poll_dev_lock); -} -EXPORT_SYMBOL_GPL(uislib_enable_channel_interrupts); - -/* Remove a device/channel from the list being processed by - * process_incoming(). - */ -void -uislib_disable_channel_interrupts(u32 bus_no, u32 dev_no) -{ - struct device_info *dev; - - dev = find_dev(bus_no, dev_no); - if (!dev) - return; - down(&poll_dev_lock); - list_del(&dev->list_polling_device_channels); - dev->polling = FALSE; - dev->interrupt = NULL; - up(&poll_dev_lock); -} -EXPORT_SYMBOL_GPL(uislib_disable_channel_interrupts); - -static void -do_wakeup_polling_device_channels(struct work_struct *dummy) -{ - if (!poll_dev_start) { - poll_dev_start = 1; - wake_up(&poll_dev_wake_q); - } -} - -static DECLARE_WORK(work_wakeup_polling_device_channels, - do_wakeup_polling_device_channels); - -/* Call this function when you want to send a hint to process_incoming() that - * your device might have more requests. - */ -void -uislib_force_channel_interrupt(u32 bus_no, u32 dev_no) -{ - if (en_smart_wakeup == 0) - return; - if (poll_dev_start) - return; - /* The point of using schedule_work() instead of just doing - * the work inline is to force a slight delay before waking up - * the process_incoming() thread. - */ - tot_wakeup_cnt++; - schedule_work(&work_wakeup_polling_device_channels); -} -EXPORT_SYMBOL_GPL(uislib_force_channel_interrupt); - -/*****************************************************/ -/* Module Init & Exit functions */ -/*****************************************************/ - -static int __init -uislib_mod_init(void) -{ - if (!unisys_spar_platform) - return -ENODEV; - - /* initialize global pointers to NULL */ - bus_list = NULL; - bus_list_count = 0; - max_bus_count = 0; - rwlock_init(&bus_list_lock); - virt_control_chan_func = NULL; - - /* Issue VMCALL_GET_CONTROLVM_ADDR to get CtrlChanPhysAddr and - * then map this physical address to a virtual address. */ - POSTCODE_LINUX_2(DRIVER_ENTRY_PC, POSTCODE_SEVERITY_INFO); - - 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, - &platform_no); - - cycles_before_wait_debugfs_read = debugfs_create_u64( - CYCLES_BEFORE_WAIT_DEBUGFS_ENTRY_FN, 0666, dir_debugfs, - &cycles_before_wait); - - 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; -} - -static void __exit -uislib_mod_exit(void) -{ - if (debug_buf) { - vfree(debug_buf); - debug_buf = NULL; - } - - debugfs_remove(info_debugfs_entry); - debugfs_remove(smart_wakeup_debugfs_entry); - debugfs_remove(cycles_before_wait_debugfs_read); - debugfs_remove(platformnumber_debugfs_read); - debugfs_remove(dir_debugfs); -} - -module_init(uislib_mod_init); -module_exit(uislib_mod_exit); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Usha Srinivasan"); -MODULE_ALIAS("uislib"); - /* this is extracted during depmod and kept in modules.dep */ diff --git a/drivers/staging/unisys/uislib/uisqueue.c b/drivers/staging/unisys/uislib/uisqueue.c deleted file mode 100644 index d46dd7428a30..000000000000 --- a/drivers/staging/unisys/uislib/uisqueue.c +++ /dev/null @@ -1,322 +0,0 @@ -/* uisqueue.c - * - * 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. - */ - -/* @ALL_INSPECTED */ -#include -#include - -#include "uisutils.h" - -/* this is shorter than using __FILE__ (full path name) in - * debug/info/error messages */ -#define CURRENT_FILE_PC UISLIB_PC_uisqueue_c -#define __MYFILE__ "uisqueue.c" - -#define CHECK_CACHE_ALIGN 0 - -/*****************************************************/ -/* Exported functions */ -/*****************************************************/ - -/* - * Routine Description: - * Tries to insert the prebuilt signal pointed to by pSignal into the nth - * Queue of the Channel pointed to by pChannel - * - * Parameters: - * pChannel: (IN) points to the IO Channel - * Queue: (IN) nth Queue of the IO Channel - * pSignal: (IN) pointer to the signal - * - * Assumptions: - * - pChannel, Queue and pSignal are valid. - * - If insertion fails due to a full queue, the caller will determine the - * retry policy (e.g. wait & try again, report an error, etc.). - * - * Return value: - * 1 if the insertion succeeds, 0 if the queue was full. - */ -unsigned char spar_signal_insert(struct channel_header __iomem *ch, u32 queue, - void *sig) -{ - void __iomem *psignal; - unsigned int head, tail, nof; - - struct signal_queue_header __iomem *pqhdr = - (struct signal_queue_header __iomem *) - ((char __iomem *)ch + readq(&ch->ch_space_offset)) - + queue; - - /* capture current head and tail */ - head = readl(&pqhdr->head); - tail = readl(&pqhdr->tail); - - /* queue is full if (head + 1) % n equals tail */ - if (((head + 1) % readl(&pqhdr->max_slots)) == tail) { - nof = readq(&pqhdr->num_overflows) + 1; - writeq(nof, &pqhdr->num_overflows); - return 0; - } - - /* increment the head index */ - head = (head + 1) % readl(&pqhdr->max_slots); - - /* copy signal to the head location from the area pointed to - * by pSignal - */ - psignal = (char __iomem *)pqhdr + readq(&pqhdr->sig_base_offset) + - (head * readl(&pqhdr->signal_size)); - memcpy_toio(psignal, sig, readl(&pqhdr->signal_size)); - - mb(); /* channel synch */ - writel(head, &pqhdr->head); - - writeq(readq(&pqhdr->num_sent) + 1, &pqhdr->num_sent); - return 1; -} -EXPORT_SYMBOL_GPL(spar_signal_insert); - -/* - * Routine Description: - * Removes one signal from Channel pChannel's nth Queue at the - * time of the call and copies it into the memory pointed to by - * pSignal. - * - * Parameters: - * pChannel: (IN) points to the IO Channel - * Queue: (IN) nth Queue of the IO Channel - * pSignal: (IN) pointer to where the signals are to be copied - * - * Assumptions: - * - pChannel and Queue are valid. - * - pSignal points to a memory area large enough to hold queue's SignalSize - * - * Return value: - * 1 if the removal succeeds, 0 if the queue was empty. - */ -unsigned char -spar_signal_remove(struct channel_header __iomem *ch, u32 queue, void *sig) -{ - void __iomem *psource; - unsigned int head, tail; - struct signal_queue_header __iomem *pqhdr = - (struct signal_queue_header __iomem *)((char __iomem *)ch + - readq(&ch->ch_space_offset)) + queue; - - /* capture current head and tail */ - head = readl(&pqhdr->head); - tail = readl(&pqhdr->tail); - - /* queue is empty if the head index equals the tail index */ - if (head == tail) { - writeq(readq(&pqhdr->num_empty) + 1, &pqhdr->num_empty); - return 0; - } - - /* advance past the 'empty' front slot */ - tail = (tail + 1) % readl(&pqhdr->max_slots); - - /* copy signal from tail location to the area pointed to by pSignal */ - psource = (char __iomem *)pqhdr + readq(&pqhdr->sig_base_offset) + - (tail * readl(&pqhdr->signal_size)); - memcpy_fromio(sig, psource, readl(&pqhdr->signal_size)); - - mb(); /* channel synch */ - writel(tail, &pqhdr->tail); - - writeq(readq(&pqhdr->num_received) + 1, - &pqhdr->num_received); - return 1; -} -EXPORT_SYMBOL_GPL(spar_signal_remove); - -/* - * Routine Description: - * Removes all signals present in Channel pChannel's nth Queue at the - * time of the call and copies them into the memory pointed to by - * pSignal. Returns the # of signals copied as the value of the routine. - * - * Parameters: - * pChannel: (IN) points to the IO Channel - * Queue: (IN) nth Queue of the IO Channel - * pSignal: (IN) pointer to where the signals are to be copied - * - * Assumptions: - * - pChannel and Queue are valid. - * - pSignal points to a memory area large enough to hold Queue's MaxSignals - * # of signals, each of which is Queue's SignalSize. - * - * Return value: - * # of signals copied. - */ -unsigned int spar_signal_remove_all(struct channel_header *ch, u32 queue, - void *sig) -{ - void *psource; - unsigned int head, tail, count = 0; - struct signal_queue_header *pqhdr = - (struct signal_queue_header *)((char *)ch + - ch->ch_space_offset) + queue; - - /* capture current head and tail */ - head = pqhdr->head; - tail = pqhdr->tail; - - /* queue is empty if the head index equals the tail index */ - if (head == tail) - return 0; - - while (head != tail) { - /* advance past the 'empty' front slot */ - tail = (tail + 1) % pqhdr->max_slots; - - /* copy signal from tail location to the area pointed - * to by pSignal - */ - psource = - (char *)pqhdr + pqhdr->sig_base_offset + - (tail * pqhdr->signal_size); - memcpy((char *)sig + (pqhdr->signal_size * count), - psource, pqhdr->signal_size); - - mb(); /* channel synch */ - pqhdr->tail = tail; - - count++; - pqhdr->num_received++; - } - - return count; -} - -/* - * Routine Description: - * Determine whether a signal queue is empty. - * - * Parameters: - * pChannel: (IN) points to the IO Channel - * Queue: (IN) nth Queue of the IO Channel - * - * Return value: - * 1 if the signal queue is empty, 0 otherwise. - */ -unsigned char spar_signalqueue_empty(struct channel_header __iomem *ch, - u32 queue) -{ - struct signal_queue_header __iomem *pqhdr = - (struct signal_queue_header __iomem *)((char __iomem *)ch + - readq(&ch->ch_space_offset)) + queue; - return readl(&pqhdr->head) == readl(&pqhdr->tail); -} -EXPORT_SYMBOL_GPL(spar_signalqueue_empty); - -unsigned long long -uisqueue_interlocked_or(unsigned long long __iomem *tgt, - unsigned long long set) -{ - unsigned long long i; - unsigned long long j; - - j = readq(tgt); - do { - i = j; - j = cmpxchg((__force unsigned long long *)tgt, i, i | set); - - } while (i != j); - - return j; -} -EXPORT_SYMBOL_GPL(uisqueue_interlocked_or); - -unsigned long long -uisqueue_interlocked_and(unsigned long long __iomem *tgt, - unsigned long long set) -{ - unsigned long long i; - unsigned long long j; - - j = readq(tgt); - do { - i = j; - j = cmpxchg((__force unsigned long long *)tgt, i, i & set); - - } while (i != j); - - return j; -} -EXPORT_SYMBOL_GPL(uisqueue_interlocked_and); - -static u8 -do_locked_client_insert(struct uisqueue_info *queueinfo, - unsigned int whichqueue, - void *signal, - spinlock_t *lock, - u8 *channel_id) -{ - unsigned long flags; - u8 rc = 0; - - spin_lock_irqsave(lock, flags); - if (!spar_channel_client_acquire_os(queueinfo->chan, channel_id)) - goto unlock; - if (spar_signal_insert(queueinfo->chan, whichqueue, signal)) { - queueinfo->packets_sent++; - rc = 1; - } - spar_channel_client_release_os(queueinfo->chan, channel_id); -unlock: - spin_unlock_irqrestore((spinlock_t *)lock, flags); - return rc; -} - -int -uisqueue_put_cmdrsp_with_lock_client(struct uisqueue_info *queueinfo, - struct uiscmdrsp *cmdrsp, - unsigned int whichqueue, - void *insertlock, - unsigned char issue_irq_if_empty, - u64 irq_handle, - char oktowait, u8 *channel_id) -{ - while (!do_locked_client_insert(queueinfo, whichqueue, cmdrsp, - (spinlock_t *)insertlock, - channel_id)) { - if (oktowait != OK_TO_WAIT) - return 0; /* failed to queue */ - - /* try again */ - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(msecs_to_jiffies(10)); - } - return 1; -} -EXPORT_SYMBOL_GPL(uisqueue_put_cmdrsp_with_lock_client); - -/* uisqueue_get_cmdrsp gets the cmdrsp entry at the head of the queue - * returns NULL if queue is empty */ -int -uisqueue_get_cmdrsp(struct uisqueue_info *queueinfo, - void *cmdrsp, unsigned int whichqueue) -{ - if (!spar_signal_remove(queueinfo->chan, whichqueue, cmdrsp)) - return 0; - - queueinfo->packets_received++; - - return 1; /* Success */ -} -EXPORT_SYMBOL_GPL(uisqueue_get_cmdrsp); diff --git a/drivers/staging/unisys/uislib/uisthread.c b/drivers/staging/unisys/uislib/uisthread.c deleted file mode 100644 index d3c973b617ee..000000000000 --- a/drivers/staging/unisys/uislib/uisthread.c +++ /dev/null @@ -1,69 +0,0 @@ -/* uisthread.c - * - * 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. - */ - -/* @ALL_INSPECTED */ -#include -#include -#include -#include -#include "uisutils.h" -#include "uisthread.h" - -/* this is shorter than using __FILE__ (full path name) in - * debug/info/error messages - */ -#define CURRENT_FILE_PC UISLIB_PC_uisthread_c -#define __MYFILE__ "uisthread.c" - -/*****************************************************/ -/* Exported functions */ -/*****************************************************/ - -/* returns 0 for failure, 1 for success */ -int -uisthread_start(struct uisthread_info *thrinfo, - int (*threadfn)(void *), void *thrcontext, char *name) -{ - /* used to stop the thread */ - init_completion(&thrinfo->has_stopped); - thrinfo->task = kthread_run(threadfn, thrcontext, name); - if (IS_ERR(thrinfo->task)) { - thrinfo->id = 0; - return 0; /* failure */ - } - thrinfo->id = thrinfo->task->pid; - return 1; -} -EXPORT_SYMBOL_GPL(uisthread_start); - -void -uisthread_stop(struct uisthread_info *thrinfo) -{ - int stopped = 0; - - if (thrinfo->id == 0) - return; /* thread not running */ - - kthread_stop(thrinfo->task); - /* give up if the thread has NOT died in 1 minute */ - if (wait_for_completion_timeout(&thrinfo->has_stopped, 60 * HZ)) - stopped = 1; - - if (stopped) - thrinfo->id = 0; -} -EXPORT_SYMBOL_GPL(uisthread_stop); diff --git a/drivers/staging/unisys/uislib/uisutils.c b/drivers/staging/unisys/uislib/uisutils.c deleted file mode 100644 index 26ab76526813..000000000000 --- a/drivers/staging/unisys/uislib/uisutils.c +++ /dev/null @@ -1,137 +0,0 @@ -/* uisutils.c - * - * 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. - */ - -#include -#include -#include -#include -#include -#include -#include "uisutils.h" -#include "version.h" -#include "vbushelper.h" -#include -#ifdef CONFIG_HIGHMEM -#include -#endif - -/* this is shorter than using __FILE__ (full path name) in - * debug/info/error messages - */ -#define CURRENT_FILE_PC UISLIB_PC_uisutils_c -#define __MYFILE__ "uisutils.c" - -/* exports */ -atomic_t uisutils_registered_services = ATOMIC_INIT(0); - /* num registrations via - * uisctrl_register_req_handler() or - * uisctrl_register_req_handler_ex() */ - -/*****************************************************/ -/* Utility functions */ -/*****************************************************/ - -int -uisutil_add_proc_line_ex(int *total, char **buffer, int *buffer_remaining, - char *format, ...) -{ - va_list args; - int len; - - va_start(args, format); - len = vsnprintf(*buffer, *buffer_remaining, format, args); - va_end(args); - if (len >= *buffer_remaining) { - *buffer += *buffer_remaining; - *total += *buffer_remaining; - *buffer_remaining = 0; - return -1; - } - *buffer_remaining -= len; - *buffer += len; - *total += len; - return len; -} -EXPORT_SYMBOL_GPL(uisutil_add_proc_line_ex); - -int -uisctrl_register_req_handler(int type, void *fptr, - struct ultra_vbus_deviceinfo *chipset_driver_info) -{ - switch (type) { - case 2: - if (fptr) { - if (!virt_control_chan_func) - atomic_inc(&uisutils_registered_services); - virt_control_chan_func = fptr; - } else { - if (virt_control_chan_func) - atomic_dec(&uisutils_registered_services); - virt_control_chan_func = NULL; - } - break; - - default: - return 0; - } - if (chipset_driver_info) - bus_device_info_init(chipset_driver_info, "chipset", "uislib", - VERSION, NULL); - - return 1; -} -EXPORT_SYMBOL_GPL(uisctrl_register_req_handler); - -/* - * unsigned int uisutil_copy_fragsinfo_from_skb(unsigned char *calling_ctx, - * void *skb_in, - * unsigned int firstfraglen, - * unsigned int frags_max, - * struct phys_info frags[]) - * - * calling_ctx - input - a string that is displayed to show - * who called * this func - * void *skb_in - skb whose frag info we're copying type is hidden so we - * don't need to include skbbuff in uisutils.h which is - * included in non-networking code. - * unsigned int firstfraglen - input - length of first fragment in skb - * unsigned int frags_max - input - max len of frags array - * struct phys_info frags[] - output - frags array filled in on output - * return value indicates number of - * entries filled in frags - */ - -static LIST_HEAD(req_handler_info_list); /* list of struct req_handler_info */ -static DEFINE_SPINLOCK(req_handler_info_list_lock); - -struct req_handler_info * -req_handler_find(uuid_le switch_uuid) -{ - struct list_head *lelt, *tmp; - struct req_handler_info *entry = NULL; - - spin_lock(&req_handler_info_list_lock); - list_for_each_safe(lelt, tmp, &req_handler_info_list) { - entry = list_entry(lelt, struct req_handler_info, list_link); - if (uuid_le_cmp(entry->switch_uuid, switch_uuid) == 0) { - spin_unlock(&req_handler_info_list_lock); - return entry; - } - } - spin_unlock(&req_handler_info_list_lock); - return NULL; -} From afe11f108a6290fc03fc6028246a9759a3db104d Mon Sep 17 00:00:00 2001 From: Charlie Wong Super <1213charlie@gmail.com> Date: Sat, 4 Apr 2015 19:30:28 +0800 Subject: [PATCH 0058/1163] staging: fbtft: Replace spaces to tab Spaces at the start of the line, replace the leading space to tabs Signed-off-by: Charlie Wong Super <1213charlie@gmail.com> Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fb_st7735r.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/fbtft/fb_st7735r.c b/drivers/staging/fbtft/fb_st7735r.c index 9d874308447e..f65224318610 100644 --- a/drivers/staging/fbtft/fb_st7735r.c +++ b/drivers/staging/fbtft/fb_st7735r.c @@ -25,8 +25,8 @@ #include "fbtft.h" #define DRVNAME "fb_st7735r" -#define DEFAULT_GAMMA "0F 1A 0F 18 2F 28 20 22 1F 1B 23 37 00 07 02 10\n" \ - "0F 1B 0F 17 33 2C 29 2E 30 30 39 3F 00 07 03 10" +#define DEFAULT_GAMMA "0F 1A 0F 18 2F 28 20 22 1F 1B 23 37 00 07 02 10\n" \ + "0F 1B 0F 17 33 2C 29 2E 30 30 39 3F 00 07 03 10" static int default_init_sequence[] = { @@ -119,9 +119,9 @@ static int set_var(struct fbtft_par *par) /* MADCTL - Memory data access control RGB/BGR: 1. Mode selection pin SRGB - RGB H/W pin for color filter setting: 0=RGB, 1=BGR + RGB H/W pin for color filter setting: 0=RGB, 1=BGR 2. MADCTL RGB bit - RGB-BGR ORDER color filter panel: 0=RGB, 1=BGR */ + RGB-BGR ORDER color filter panel: 0=RGB, 1=BGR */ switch (par->info->var.rotate) { case 0: write_reg(par, 0x36, MX | MY | (par->bgr << 3)); From a94ac1590b28245225300aaca7ea2de4f3f1e296 Mon Sep 17 00:00:00 2001 From: Charlie Wong Super <1213charlie@gmail.com> Date: Sat, 4 Apr 2015 20:54:56 +0800 Subject: [PATCH 0059/1163] staging: fbtft: Add a blank line after declarations scripts/checkpatch.pl WARNING: Missing a blank line after declarations Signed-off-by: Charlie Wong Super <1213charlie@gmail.com> Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fb_tls8204.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/fbtft/fb_tls8204.c b/drivers/staging/fbtft/fb_tls8204.c index fcd38bf2ed79..5ea73b5ce45a 100644 --- a/drivers/staging/fbtft/fb_tls8204.c +++ b/drivers/staging/fbtft/fb_tls8204.c @@ -115,6 +115,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) for (x = 0; x < WIDTH; x++) { u8 ch = 0; + for (i = 0; i < 8*WIDTH; i += WIDTH) { ch >>= 1; if (vmem16[(y*8*WIDTH)+i+x]) From 8e1a4c7f718e5de5019cb5ce6ada657ce1b5ea89 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 24 Apr 2015 09:44:15 +0200 Subject: [PATCH 0060/1163] staging: fbtft: Disable DMA support if DMA is not available If NO_DMA=y: drivers/built-in.o: In function `fbtft_framebuffer_alloc': (.text+0xb53cae): undefined reference to `dmam_alloc_coherent' As DMA support is already optional, make it depend on HAS_DMA. Signed-off-by: Geert Uytterhoeven Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fbtft-core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c index 53b748be2712..ce645213a539 100644 --- a/drivers/staging/fbtft/fbtft-core.c +++ b/drivers/staging/fbtft/fbtft-core.c @@ -47,9 +47,11 @@ static unsigned long debug; module_param(debug, ulong, 0); MODULE_PARM_DESC(debug, "override device debug level"); +#ifdef CONFIG_HAS_DMA static bool dma = true; module_param(dma, bool, 0); MODULE_PARM_DESC(dma, "Use DMA buffer"); +#endif void fbtft_dbg_hex(const struct device *dev, int groupsize, @@ -856,10 +858,13 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, #endif if (txbuflen > 0) { +#ifdef CONFIG_HAS_DMA if (dma) { dev->coherent_dma_mask = ~0; txbuf = dmam_alloc_coherent(dev, txbuflen, &par->txbuf.dma, GFP_DMA); - } else { + } else +#endif + { txbuf = devm_kzalloc(par->info->device, txbuflen, GFP_KERNEL); } if (!txbuf) From 27cbc73aac0d82490e2a6fd6838d21e8c08b0166 Mon Sep 17 00:00:00 2001 From: Nicolas Iooss Date: Fri, 17 Apr 2015 17:41:43 +0800 Subject: [PATCH 0061/1163] Staging: fbtft: fix header guard typo drivers/staging/fbtft/internal.h header guard tests for __LINUX_FBTFT__INTERNAL_H but then defines __LINUX_FBTFT_INTERNAL_H (only 1 underscore) and uses the same name for the #endif comment. Use the same name everywhere. Signed-off-by: Nicolas Iooss Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/fbtft/internal.h b/drivers/staging/fbtft/internal.h index f69db8289151..eea0ec5ff4d3 100644 --- a/drivers/staging/fbtft/internal.h +++ b/drivers/staging/fbtft/internal.h @@ -13,7 +13,7 @@ * */ -#ifndef __LINUX_FBTFT__INTERNAL_H +#ifndef __LINUX_FBTFT_INTERNAL_H #define __LINUX_FBTFT_INTERNAL_H void fbtft_sysfs_init(struct fbtft_par *par); From bd7de5cea225f85b218730eddf7476dd6260bafc Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sat, 4 Apr 2015 16:59:30 +0200 Subject: [PATCH 0062/1163] staging: emxx_udc: test returned value Put NULL test on the result of the previous call instead on one of its arguments. A simplified version of the semantic match that finds this problem is as follows (http://coccinelle.lip6.fr/): // r@ expression *e1; expression *e2; identifier f; statement S1,S2; @@ e1 = f(...,e2,...); ( if (e1 == NULL || ...) S1 else S2 | *if (e2 == NULL || ...) S1 else S2 ) // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/emxx_udc/emxx_udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index fbf82bc735cf..7de1e9ec2267 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -2998,7 +2998,7 @@ static void nbu2ss_ep_fifo_flush(struct usb_ep *_ep) } ep = container_of(_ep, struct nbu2ss_ep, ep); - if (!_ep) { + if (!ep) { pr_err("udc: %s, bad ep\n", __func__); return; } From 3e2bb64d1a142e7fd81b6821483044597cfe8717 Mon Sep 17 00:00:00 2001 From: "Gujulan Elango, Hari Prasath (H.)" Date: Thu, 23 Apr 2015 19:29:51 +0000 Subject: [PATCH 0063/1163] staging: emxx_udc : remove stray semicolon This patch removes a stray semicolon around closing brace of an if code block. Signed-off-by: Hari Prasath Gujulan Elango Signed-off-by: Greg Kroah-Hartman --- drivers/staging/emxx_udc/emxx_udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index 7de1e9ec2267..d205cbe897f0 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -2347,7 +2347,7 @@ static int _nbu2ss_enable_controller(struct nbu2ss_udc *udc) dev_err(udc->dev, "*** Reset Cancel failed\n"); return -EINVAL; } - }; + } #if 0 if ((system_rev & EMXX_REV_MASK) < EMXX_REV_ES3) From 94361655442effc78904039cb051228b3228e4cb Mon Sep 17 00:00:00 2001 From: "Gujulan Elango, Hari Prasath (H.)" Date: Thu, 23 Apr 2015 19:30:53 +0000 Subject: [PATCH 0064/1163] staging: emxx_udc: Remove dead code This patch removes few lines of commented code. Signed-off-by: Hari Prasath Gujulan Elango Signed-off-by: Greg Kroah-Hartman --- drivers/staging/emxx_udc/emxx_udc.c | 33 ----------------------------- 1 file changed, 33 deletions(-) diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index d205cbe897f0..2fd04e8129e4 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -2199,18 +2199,6 @@ static void _nbu2ss_ep0_enable(struct nbu2ss_udc *udc) _nbu2ss_writel(&udc->p_regs->EP0_INT_ENA, EP0_INT_EN_BIT); } -#if 0 -/*-------------------------------------------------------------------------*/ -static void _nbu2ss_ep0_disable(struct nbu2ss_udc *udc) -{ - _nbu2ss_bitclr(&udc->p_regs->EP0_INT_ENA, EP0_INT_EN_BIT); - - _nbu2ss_bitset(&udc->p_regs->EP0_CONTROL - , (EP0_BCLR | EP0_INAK | EP0_ONAK | EP0_BCLR)); - - _nbu2ss_bitclr(&udc->p_regs->EP0_CONTROL, EP0_AUTO); -} -#endif /*-------------------------------------------------------------------------*/ static int _nbu2ss_nuke(struct nbu2ss_udc *udc, @@ -2311,12 +2299,6 @@ static int _nbu2ss_enable_controller(struct nbu2ss_udc *udc) if (udc->udc_enabled) return 0; -#if 0 - emxx_open_clockgate(EMXX_CLK_USB1); - /* emxx_clkctrl_off(EMXX_CLKCTRL_USB1); */ - /* emxx_clkctrl_on(EMXX_CLKCTRL_USB1); */ - emxx_unreset_device(EMXX_RST_USB1); -#endif /* Reset */ @@ -2330,13 +2312,6 @@ static int _nbu2ss_enable_controller(struct nbu2ss_udc *udc) _nbu2ss_writel(&udc->p_regs->AHBSCTR, WAIT_MODE); -#if 0 - /* DMA Mode Setting */ - if ((system_rev & EMXX_REV_MASK) == EMXX_REV_ES1) { - _nbu2ss_bitset(&udc->p_regs->AHBMCTR, BURST_TYPE); - _nbu2ss_bitclr(&udc->p_regs->AHBMCTR, HTRANS_MODE); - } else -#endif _nbu2ss_writel(&udc->p_regs->AHBMCTR, HBUSREQ_MODE | HTRANS_MODE | WBURST_TYPE); @@ -2349,9 +2324,6 @@ static int _nbu2ss_enable_controller(struct nbu2ss_udc *udc) } } -#if 0 - if ((system_rev & EMXX_REV_MASK) < EMXX_REV_ES3) -#endif _nbu2ss_bitset(&udc->p_regs->UTMI_CHARACTER_1, USB_SQUSET); _nbu2ss_bitset(&udc->p_regs->USB_CONTROL, (INT_SEL | SOF_RCV)); @@ -2383,11 +2355,6 @@ static void _nbu2ss_disable_controller(struct nbu2ss_udc *udc) _nbu2ss_reset_controller(udc); _nbu2ss_bitset(&udc->p_regs->EPCTR, (DIRPD | EPC_RST)); } -#if 0 - emxx_reset_device(EMXX_RST_USB1); - /* emxx_clkctrl_on(EMXX_CLKCTRL_USB1); */ - emxx_close_clockgate(EMXX_CLK_USB1); -#endif } /*-------------------------------------------------------------------------*/ From aeda3b2d4a6760bda799feeaac391a7bdcdbbdb5 Mon Sep 17 00:00:00 2001 From: Alan Date: Wed, 8 Apr 2015 20:24:43 +0100 Subject: [PATCH 0065/1163] iio: example code is buggy Shock horror, example template code that has never been used in reality is in fact a hazard. This fixes the obvious bug, probably these kind of "examples" should be deleted so real (working) examples are followed. Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/iio_simple_dummy_events.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/iio/iio_simple_dummy_events.c b/drivers/staging/iio/iio_simple_dummy_events.c index a5cd3bb219fe..c32ef78d8e5f 100644 --- a/drivers/staging/iio/iio_simple_dummy_events.c +++ b/drivers/staging/iio/iio_simple_dummy_events.c @@ -84,6 +84,7 @@ int iio_simple_dummy_write_event_config(struct iio_dev *indio_dev, default: return -EINVAL; } + break; case IIO_STEPS: switch (type) { case IIO_EV_TYPE_CHANGE: @@ -92,6 +93,7 @@ int iio_simple_dummy_write_event_config(struct iio_dev *indio_dev, default: return -EINVAL; } + break; default: return -EINVAL; } From 32b249b0f54fb304c5f90be00ebcb9c1a32d415c Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 6 Apr 2015 21:19:48 +0100 Subject: [PATCH 0066/1163] staging: vt6655: device_intr check for vif on while loop vif should never be or go null while in loop. Fixes race condition where interrupts are late and when interface is not present. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 4bb4f8ee4132..5b3de43bde99 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1090,7 +1090,7 @@ static irqreturn_t device_intr(int irq, void *dev_instance) * update ISR counter */ STAvUpdate802_11Counter(&pDevice->s802_11Counter, &pDevice->scStatistic, dwMIBCounter); - while (pDevice->dwIsr != 0) { + while (pDevice->dwIsr && pDevice->vif) { STAvUpdateIsrStatCounter(&pDevice->scStatistic, pDevice->dwIsr); MACvWriteISR(pDevice->PortOffset, pDevice->dwIsr); @@ -1102,8 +1102,7 @@ static irqreturn_t device_intr(int irq, void *dev_instance) } if (pDevice->dwIsr & ISR_TBTT) { - if (pDevice->vif && - pDevice->op_mode != NL80211_IFTYPE_ADHOC) + if (pDevice->op_mode != NL80211_IFTYPE_ADHOC) vnt_check_bb_vga(pDevice); pDevice->bBeaconSent = false; @@ -1143,19 +1142,15 @@ static irqreturn_t device_intr(int irq, void *dev_instance) max_count += device_tx_srv(pDevice, TYPE_AC0DMA); if (pDevice->dwIsr & ISR_SOFTTIMER1) { - if (pDevice->vif) { - if (pDevice->vif->bss_conf.enable_beacon) - vnt_beacon_make(pDevice, pDevice->vif); - } + if (pDevice->vif->bss_conf.enable_beacon) + vnt_beacon_make(pDevice, pDevice->vif); } /* If both buffers available wake the queue */ - if (pDevice->vif) { - if (AVAIL_TD(pDevice, TYPE_TXDMA0) && - AVAIL_TD(pDevice, TYPE_AC0DMA) && - ieee80211_queue_stopped(pDevice->hw, 0)) - ieee80211_wake_queues(pDevice->hw); - } + if (AVAIL_TD(pDevice, TYPE_TXDMA0) && + AVAIL_TD(pDevice, TYPE_AC0DMA) && + ieee80211_queue_stopped(pDevice->hw, 0)) + ieee80211_wake_queues(pDevice->hw); MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr); From 9e3ae4f9aecffcc376a714d5088a1275054f9dbf Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sat, 4 Apr 2015 22:51:02 +0300 Subject: [PATCH 0067/1163] staging: octeon-ethernet: consolidate ndo_open functions ndo_open for rgmii, sgmii and xaui are almost identical. Put the common code in a single function. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-rgmii.c | 32 +------------------ drivers/staging/octeon/ethernet-sgmii.c | 33 +------------------- drivers/staging/octeon/ethernet-xaui.c | 33 +------------------- drivers/staging/octeon/ethernet.c | 39 ++++++++++++++++++++++++ drivers/staging/octeon/octeon-ethernet.h | 2 ++ 5 files changed, 44 insertions(+), 95 deletions(-) diff --git a/drivers/staging/octeon/ethernet-rgmii.c b/drivers/staging/octeon/ethernet-rgmii.c index e36f9bc69543..88889d30cc03 100644 --- a/drivers/staging/octeon/ethernet-rgmii.c +++ b/drivers/staging/octeon/ethernet-rgmii.c @@ -298,37 +298,7 @@ static irqreturn_t cvm_oct_rgmii_rml_interrupt(int cpl, void *dev_id) int cvm_oct_rgmii_open(struct net_device *dev) { - union cvmx_gmxx_prtx_cfg gmx_cfg; - struct octeon_ethernet *priv = netdev_priv(dev); - int interface = INTERFACE(priv->port); - int index = INDEX(priv->port); - cvmx_helper_link_info_t link_info; - int rv; - - rv = cvm_oct_phy_setup_device(dev); - if (rv) - return rv; - - gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface)); - gmx_cfg.s.en = 1; - cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), gmx_cfg.u64); - - if (!octeon_is_simulation()) { - if (priv->phydev) { - int r = phy_read_status(priv->phydev); - - if (r == 0 && priv->phydev->link == 0) - netif_carrier_off(dev); - cvm_oct_adjust_link(dev); - } else { - link_info = cvmx_helper_link_get(priv->port); - if (!link_info.s.link_up) - netif_carrier_off(dev); - priv->poll = cvm_oct_rgmii_poll; - } - } - - return 0; + return cvm_oct_common_open(dev, cvm_oct_rgmii_poll, false); } int cvm_oct_rgmii_stop(struct net_device *dev) diff --git a/drivers/staging/octeon/ethernet-sgmii.c b/drivers/staging/octeon/ethernet-sgmii.c index 21a7a17acb79..a6a831510151 100644 --- a/drivers/staging/octeon/ethernet-sgmii.c +++ b/drivers/staging/octeon/ethernet-sgmii.c @@ -79,38 +79,7 @@ static void cvm_oct_sgmii_poll(struct net_device *dev) int cvm_oct_sgmii_open(struct net_device *dev) { - union cvmx_gmxx_prtx_cfg gmx_cfg; - struct octeon_ethernet *priv = netdev_priv(dev); - int interface = INTERFACE(priv->port); - int index = INDEX(priv->port); - cvmx_helper_link_info_t link_info; - int rv; - - rv = cvm_oct_phy_setup_device(dev); - if (rv) - return rv; - - gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface)); - gmx_cfg.s.en = 1; - cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), gmx_cfg.u64); - - if (octeon_is_simulation()) - return 0; - - if (priv->phydev) { - int r = phy_read_status(priv->phydev); - - if (r == 0 && priv->phydev->link == 0) - netif_carrier_off(dev); - cvm_oct_adjust_link(dev); - } else { - link_info = cvmx_helper_link_get(priv->port); - if (!link_info.s.link_up) - netif_carrier_off(dev); - priv->poll = cvm_oct_sgmii_poll; - cvm_oct_sgmii_poll(dev); - } - return 0; + return cvm_oct_common_open(dev, cvm_oct_sgmii_poll, true); } int cvm_oct_sgmii_stop(struct net_device *dev) diff --git a/drivers/staging/octeon/ethernet-xaui.c b/drivers/staging/octeon/ethernet-xaui.c index fd9d103d8e56..365b01a4df0d 100644 --- a/drivers/staging/octeon/ethernet-xaui.c +++ b/drivers/staging/octeon/ethernet-xaui.c @@ -79,38 +79,7 @@ static void cvm_oct_xaui_poll(struct net_device *dev) int cvm_oct_xaui_open(struct net_device *dev) { - union cvmx_gmxx_prtx_cfg gmx_cfg; - struct octeon_ethernet *priv = netdev_priv(dev); - int interface = INTERFACE(priv->port); - int index = INDEX(priv->port); - cvmx_helper_link_info_t link_info; - int rv; - - rv = cvm_oct_phy_setup_device(dev); - if (rv) - return rv; - - gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface)); - gmx_cfg.s.en = 1; - cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), gmx_cfg.u64); - - if (octeon_is_simulation()) - return 0; - - if (priv->phydev) { - int r = phy_read_status(priv->phydev); - - if (r == 0 && priv->phydev->link == 0) - netif_carrier_off(dev); - cvm_oct_adjust_link(dev); - } else { - link_info = cvmx_helper_link_get(priv->port); - if (!link_info.s.link_up) - netif_carrier_off(dev); - priv->poll = cvm_oct_xaui_poll; - cvm_oct_xaui_poll(dev); - } - return 0; + return cvm_oct_common_open(dev, cvm_oct_xaui_poll, true); } int cvm_oct_xaui_stop(struct net_device *dev) diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index fbbe866485c7..3ca8b7a30d32 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c @@ -499,6 +499,45 @@ void cvm_oct_common_uninit(struct net_device *dev) phy_disconnect(priv->phydev); } +int cvm_oct_common_open(struct net_device *dev, + void (*link_poll)(struct net_device *), bool poll_now) +{ + union cvmx_gmxx_prtx_cfg gmx_cfg; + struct octeon_ethernet *priv = netdev_priv(dev); + int interface = INTERFACE(priv->port); + int index = INDEX(priv->port); + cvmx_helper_link_info_t link_info; + int rv; + + rv = cvm_oct_phy_setup_device(dev); + if (rv) + return rv; + + gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface)); + gmx_cfg.s.en = 1; + cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), gmx_cfg.u64); + + if (octeon_is_simulation()) + return 0; + + if (priv->phydev) { + int r = phy_read_status(priv->phydev); + + if (r == 0 && priv->phydev->link == 0) + netif_carrier_off(dev); + cvm_oct_adjust_link(dev); + } else { + link_info = cvmx_helper_link_get(priv->port); + if (!link_info.s.link_up) + netif_carrier_off(dev); + priv->poll = link_poll; + if (poll_now) + link_poll(dev); + } + + return 0; +} + static const struct net_device_ops cvm_oct_npi_netdev_ops = { .ndo_init = cvm_oct_common_init, .ndo_uninit = cvm_oct_common_uninit, diff --git a/drivers/staging/octeon/octeon-ethernet.h b/drivers/staging/octeon/octeon-ethernet.h index f48dc766fada..7818873536d8 100644 --- a/drivers/staging/octeon/octeon-ethernet.h +++ b/drivers/staging/octeon/octeon-ethernet.h @@ -89,6 +89,8 @@ extern int cvm_oct_common_init(struct net_device *dev); extern void cvm_oct_common_uninit(struct net_device *dev); void cvm_oct_adjust_link(struct net_device *dev); int cvm_oct_common_stop(struct net_device *dev); +int cvm_oct_common_open(struct net_device *dev, + void (*link_poll)(struct net_device *), bool poll_now); extern int always_use_pow; extern int pow_send_group; From 96217ebff7f2fda012f755cdb28f34400fd5f99c Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sat, 4 Apr 2015 22:51:03 +0300 Subject: [PATCH 0068/1163] staging: octeon-ethernet: consolidate ndo_stop functions All ndo_stop functions are identical. Get rid of duplicated code. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-mdio.c | 9 ++++++++- drivers/staging/octeon/ethernet-rgmii.c | 13 ------------- drivers/staging/octeon/ethernet-sgmii.c | 13 ------------- drivers/staging/octeon/ethernet-xaui.c | 13 ------------- drivers/staging/octeon/ethernet.c | 6 +++--- drivers/staging/octeon/octeon-ethernet.h | 3 --- 6 files changed, 11 insertions(+), 46 deletions(-) diff --git a/drivers/staging/octeon/ethernet-mdio.c b/drivers/staging/octeon/ethernet-mdio.c index 40dab11e5333..ec38cb07eb7c 100644 --- a/drivers/staging/octeon/ethernet-mdio.c +++ b/drivers/staging/octeon/ethernet-mdio.c @@ -40,7 +40,7 @@ #include "ethernet-util.h" #include - +#include #include static void cvm_oct_get_drvinfo(struct net_device *dev, @@ -150,7 +150,14 @@ void cvm_oct_adjust_link(struct net_device *dev) int cvm_oct_common_stop(struct net_device *dev) { struct octeon_ethernet *priv = netdev_priv(dev); + int interface = INTERFACE(priv->port); cvmx_helper_link_info_t link_info; + union cvmx_gmxx_prtx_cfg gmx_cfg; + int index = INDEX(priv->port); + + gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface)); + gmx_cfg.s.en = 0; + cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), gmx_cfg.u64); priv->poll = NULL; diff --git a/drivers/staging/octeon/ethernet-rgmii.c b/drivers/staging/octeon/ethernet-rgmii.c index 88889d30cc03..c428a452ddbe 100644 --- a/drivers/staging/octeon/ethernet-rgmii.c +++ b/drivers/staging/octeon/ethernet-rgmii.c @@ -301,19 +301,6 @@ int cvm_oct_rgmii_open(struct net_device *dev) return cvm_oct_common_open(dev, cvm_oct_rgmii_poll, false); } -int cvm_oct_rgmii_stop(struct net_device *dev) -{ - union cvmx_gmxx_prtx_cfg gmx_cfg; - struct octeon_ethernet *priv = netdev_priv(dev); - int interface = INTERFACE(priv->port); - int index = INDEX(priv->port); - - gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface)); - gmx_cfg.s.en = 0; - cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), gmx_cfg.u64); - return cvm_oct_common_stop(dev); -} - static void cvm_oct_rgmii_immediate_poll(struct work_struct *work) { struct octeon_ethernet *priv = diff --git a/drivers/staging/octeon/ethernet-sgmii.c b/drivers/staging/octeon/ethernet-sgmii.c index a6a831510151..ece2880b9910 100644 --- a/drivers/staging/octeon/ethernet-sgmii.c +++ b/drivers/staging/octeon/ethernet-sgmii.c @@ -82,19 +82,6 @@ int cvm_oct_sgmii_open(struct net_device *dev) return cvm_oct_common_open(dev, cvm_oct_sgmii_poll, true); } -int cvm_oct_sgmii_stop(struct net_device *dev) -{ - union cvmx_gmxx_prtx_cfg gmx_cfg; - struct octeon_ethernet *priv = netdev_priv(dev); - int interface = INTERFACE(priv->port); - int index = INDEX(priv->port); - - gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface)); - gmx_cfg.s.en = 0; - cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), gmx_cfg.u64); - return cvm_oct_common_stop(dev); -} - int cvm_oct_sgmii_init(struct net_device *dev) { cvm_oct_common_init(dev); diff --git a/drivers/staging/octeon/ethernet-xaui.c b/drivers/staging/octeon/ethernet-xaui.c index 365b01a4df0d..e8e51ed779d5 100644 --- a/drivers/staging/octeon/ethernet-xaui.c +++ b/drivers/staging/octeon/ethernet-xaui.c @@ -82,19 +82,6 @@ int cvm_oct_xaui_open(struct net_device *dev) return cvm_oct_common_open(dev, cvm_oct_xaui_poll, true); } -int cvm_oct_xaui_stop(struct net_device *dev) -{ - union cvmx_gmxx_prtx_cfg gmx_cfg; - struct octeon_ethernet *priv = netdev_priv(dev); - int interface = INTERFACE(priv->port); - int index = INDEX(priv->port); - - gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface)); - gmx_cfg.s.en = 0; - cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), gmx_cfg.u64); - return cvm_oct_common_stop(dev); -} - int cvm_oct_xaui_init(struct net_device *dev) { struct octeon_ethernet *priv = netdev_priv(dev); diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index 3ca8b7a30d32..2a3f9e2acbaa 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c @@ -555,7 +555,7 @@ static const struct net_device_ops cvm_oct_xaui_netdev_ops = { .ndo_init = cvm_oct_xaui_init, .ndo_uninit = cvm_oct_xaui_uninit, .ndo_open = cvm_oct_xaui_open, - .ndo_stop = cvm_oct_xaui_stop, + .ndo_stop = cvm_oct_common_stop, .ndo_start_xmit = cvm_oct_xmit, .ndo_set_rx_mode = cvm_oct_common_set_multicast_list, .ndo_set_mac_address = cvm_oct_common_set_mac_address, @@ -570,7 +570,7 @@ static const struct net_device_ops cvm_oct_sgmii_netdev_ops = { .ndo_init = cvm_oct_sgmii_init, .ndo_uninit = cvm_oct_sgmii_uninit, .ndo_open = cvm_oct_sgmii_open, - .ndo_stop = cvm_oct_sgmii_stop, + .ndo_stop = cvm_oct_common_stop, .ndo_start_xmit = cvm_oct_xmit, .ndo_set_rx_mode = cvm_oct_common_set_multicast_list, .ndo_set_mac_address = cvm_oct_common_set_mac_address, @@ -598,7 +598,7 @@ static const struct net_device_ops cvm_oct_rgmii_netdev_ops = { .ndo_init = cvm_oct_rgmii_init, .ndo_uninit = cvm_oct_rgmii_uninit, .ndo_open = cvm_oct_rgmii_open, - .ndo_stop = cvm_oct_rgmii_stop, + .ndo_stop = cvm_oct_common_stop, .ndo_start_xmit = cvm_oct_xmit, .ndo_set_rx_mode = cvm_oct_common_set_multicast_list, .ndo_set_mac_address = cvm_oct_common_set_mac_address, diff --git a/drivers/staging/octeon/octeon-ethernet.h b/drivers/staging/octeon/octeon-ethernet.h index 7818873536d8..2581554de0b3 100644 --- a/drivers/staging/octeon/octeon-ethernet.h +++ b/drivers/staging/octeon/octeon-ethernet.h @@ -71,19 +71,16 @@ int cvm_oct_free_work(void *work_queue_entry); extern int cvm_oct_rgmii_init(struct net_device *dev); extern void cvm_oct_rgmii_uninit(struct net_device *dev); extern int cvm_oct_rgmii_open(struct net_device *dev); -extern int cvm_oct_rgmii_stop(struct net_device *dev); extern int cvm_oct_sgmii_init(struct net_device *dev); extern void cvm_oct_sgmii_uninit(struct net_device *dev); extern int cvm_oct_sgmii_open(struct net_device *dev); -extern int cvm_oct_sgmii_stop(struct net_device *dev); extern int cvm_oct_spi_init(struct net_device *dev); extern void cvm_oct_spi_uninit(struct net_device *dev); extern int cvm_oct_xaui_init(struct net_device *dev); extern void cvm_oct_xaui_uninit(struct net_device *dev); extern int cvm_oct_xaui_open(struct net_device *dev); -extern int cvm_oct_xaui_stop(struct net_device *dev); extern int cvm_oct_common_init(struct net_device *dev); extern void cvm_oct_common_uninit(struct net_device *dev); From be76400c31194d759b621bc2b70f0c61882fbaec Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sat, 4 Apr 2015 22:51:04 +0300 Subject: [PATCH 0069/1163] staging: octeon-ethernet: move ndo_stop to common init All init functions call ndo_stop if it's defined, so move it to common function. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-rgmii.c | 1 - drivers/staging/octeon/ethernet-sgmii.c | 1 - drivers/staging/octeon/ethernet-xaui.c | 1 - drivers/staging/octeon/ethernet.c | 3 +++ 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/octeon/ethernet-rgmii.c b/drivers/staging/octeon/ethernet-rgmii.c index c428a452ddbe..a6b853118bc5 100644 --- a/drivers/staging/octeon/ethernet-rgmii.c +++ b/drivers/staging/octeon/ethernet-rgmii.c @@ -314,7 +314,6 @@ int cvm_oct_rgmii_init(struct net_device *dev) int r; cvm_oct_common_init(dev); - dev->netdev_ops->ndo_stop(dev); INIT_WORK(&priv->port_work, cvm_oct_rgmii_immediate_poll); /* * Due to GMX errata in CN3XXX series chips, it is necessary diff --git a/drivers/staging/octeon/ethernet-sgmii.c b/drivers/staging/octeon/ethernet-sgmii.c index ece2880b9910..cd791c362273 100644 --- a/drivers/staging/octeon/ethernet-sgmii.c +++ b/drivers/staging/octeon/ethernet-sgmii.c @@ -85,7 +85,6 @@ int cvm_oct_sgmii_open(struct net_device *dev) int cvm_oct_sgmii_init(struct net_device *dev) { cvm_oct_common_init(dev); - dev->netdev_ops->ndo_stop(dev); /* FIXME: Need autoneg logic */ return 0; diff --git a/drivers/staging/octeon/ethernet-xaui.c b/drivers/staging/octeon/ethernet-xaui.c index e8e51ed779d5..5782c38a9c9c 100644 --- a/drivers/staging/octeon/ethernet-xaui.c +++ b/drivers/staging/octeon/ethernet-xaui.c @@ -87,7 +87,6 @@ int cvm_oct_xaui_init(struct net_device *dev) struct octeon_ethernet *priv = netdev_priv(dev); cvm_oct_common_init(dev); - dev->netdev_ops->ndo_stop(dev); if (!octeon_is_simulation() && priv->phydev == NULL) priv->poll = cvm_oct_xaui_poll; diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index 2a3f9e2acbaa..fdd23bfa62d1 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c @@ -488,6 +488,9 @@ int cvm_oct_common_init(struct net_device *dev) memset(dev->netdev_ops->ndo_get_stats(dev), 0, sizeof(struct net_device_stats)); + if (dev->netdev_ops->ndo_stop) + dev->netdev_ops->ndo_stop(dev); + return 0; } From 3c33914558cc22f9a51a7a15da1e991e49fcb1b3 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sat, 4 Apr 2015 22:51:05 +0300 Subject: [PATCH 0070/1163] staging: octeon-ethernet: delete sgmii and xaui specific uninit functions Delete redundant wrappers. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-sgmii.c | 5 ----- drivers/staging/octeon/ethernet-xaui.c | 5 ----- drivers/staging/octeon/ethernet.c | 4 ++-- drivers/staging/octeon/octeon-ethernet.h | 2 -- 4 files changed, 2 insertions(+), 14 deletions(-) diff --git a/drivers/staging/octeon/ethernet-sgmii.c b/drivers/staging/octeon/ethernet-sgmii.c index cd791c362273..1158eacc57bb 100644 --- a/drivers/staging/octeon/ethernet-sgmii.c +++ b/drivers/staging/octeon/ethernet-sgmii.c @@ -89,8 +89,3 @@ int cvm_oct_sgmii_init(struct net_device *dev) /* FIXME: Need autoneg logic */ return 0; } - -void cvm_oct_sgmii_uninit(struct net_device *dev) -{ - cvm_oct_common_uninit(dev); -} diff --git a/drivers/staging/octeon/ethernet-xaui.c b/drivers/staging/octeon/ethernet-xaui.c index 5782c38a9c9c..3714fae201d4 100644 --- a/drivers/staging/octeon/ethernet-xaui.c +++ b/drivers/staging/octeon/ethernet-xaui.c @@ -92,8 +92,3 @@ int cvm_oct_xaui_init(struct net_device *dev) return 0; } - -void cvm_oct_xaui_uninit(struct net_device *dev) -{ - cvm_oct_common_uninit(dev); -} diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index fdd23bfa62d1..a7f1fcb4762a 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c @@ -556,7 +556,7 @@ static const struct net_device_ops cvm_oct_npi_netdev_ops = { }; static const struct net_device_ops cvm_oct_xaui_netdev_ops = { .ndo_init = cvm_oct_xaui_init, - .ndo_uninit = cvm_oct_xaui_uninit, + .ndo_uninit = cvm_oct_common_uninit, .ndo_open = cvm_oct_xaui_open, .ndo_stop = cvm_oct_common_stop, .ndo_start_xmit = cvm_oct_xmit, @@ -571,7 +571,7 @@ static const struct net_device_ops cvm_oct_xaui_netdev_ops = { }; static const struct net_device_ops cvm_oct_sgmii_netdev_ops = { .ndo_init = cvm_oct_sgmii_init, - .ndo_uninit = cvm_oct_sgmii_uninit, + .ndo_uninit = cvm_oct_common_uninit, .ndo_open = cvm_oct_sgmii_open, .ndo_stop = cvm_oct_common_stop, .ndo_start_xmit = cvm_oct_xmit, diff --git a/drivers/staging/octeon/octeon-ethernet.h b/drivers/staging/octeon/octeon-ethernet.h index 2581554de0b3..3ad713fb4725 100644 --- a/drivers/staging/octeon/octeon-ethernet.h +++ b/drivers/staging/octeon/octeon-ethernet.h @@ -73,13 +73,11 @@ extern void cvm_oct_rgmii_uninit(struct net_device *dev); extern int cvm_oct_rgmii_open(struct net_device *dev); extern int cvm_oct_sgmii_init(struct net_device *dev); -extern void cvm_oct_sgmii_uninit(struct net_device *dev); extern int cvm_oct_sgmii_open(struct net_device *dev); extern int cvm_oct_spi_init(struct net_device *dev); extern void cvm_oct_spi_uninit(struct net_device *dev); extern int cvm_oct_xaui_init(struct net_device *dev); -extern void cvm_oct_xaui_uninit(struct net_device *dev); extern int cvm_oct_xaui_open(struct net_device *dev); extern int cvm_oct_common_init(struct net_device *dev); From 36a14572415459877933857f67d93d3e053180a2 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sat, 4 Apr 2015 22:51:06 +0300 Subject: [PATCH 0071/1163] staging: octeon-ethernet: add queue information to carrier note Add queue information to carrier note. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-mdio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/octeon/ethernet-mdio.c b/drivers/staging/octeon/ethernet-mdio.c index ec38cb07eb7c..604fb581f1c3 100644 --- a/drivers/staging/octeon/ethernet-mdio.c +++ b/drivers/staging/octeon/ethernet-mdio.c @@ -120,10 +120,10 @@ static void cvm_oct_note_carrier(struct octeon_ethernet *priv, cvmx_helper_link_info_t li) { if (li.s.link_up) { - pr_notice_ratelimited("%s: %u Mbps %s duplex, port %d\n", + pr_notice_ratelimited("%s: %u Mbps %s duplex, port %d, queue %d\n", netdev_name(priv->netdev), li.s.speed, (li.s.full_duplex) ? "Full" : "Half", - priv->port); + priv->port, priv->queue); } else { pr_notice_ratelimited("%s: Link down\n", netdev_name(priv->netdev)); From 2638f71307f649532f613a4bcb3b163b7b63017a Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sat, 4 Apr 2015 22:51:07 +0300 Subject: [PATCH 0072/1163] staging: octeon-ethernet: consolidate carrier notifications Always use cvm_oct_note_carrier() to avoid copy-pasted code. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-mdio.c | 5 ++--- drivers/staging/octeon/ethernet-rgmii.c | 19 +++---------------- drivers/staging/octeon/ethernet-sgmii.c | 20 +++----------------- drivers/staging/octeon/ethernet-xaui.c | 20 +++----------------- drivers/staging/octeon/octeon-ethernet.h | 4 ++++ 5 files changed, 15 insertions(+), 53 deletions(-) diff --git a/drivers/staging/octeon/ethernet-mdio.c b/drivers/staging/octeon/ethernet-mdio.c index 604fb581f1c3..6322d0dd4238 100644 --- a/drivers/staging/octeon/ethernet-mdio.c +++ b/drivers/staging/octeon/ethernet-mdio.c @@ -39,7 +39,6 @@ #include "ethernet-mdio.h" #include "ethernet-util.h" -#include #include #include @@ -116,8 +115,8 @@ int cvm_oct_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) return phy_mii_ioctl(priv->phydev, rq, cmd); } -static void cvm_oct_note_carrier(struct octeon_ethernet *priv, - cvmx_helper_link_info_t li) +void cvm_oct_note_carrier(struct octeon_ethernet *priv, + cvmx_helper_link_info_t li) { if (li.s.link_up) { pr_notice_ratelimited("%s: %u Mbps %s duplex, port %d, queue %d\n", diff --git a/drivers/staging/octeon/ethernet-rgmii.c b/drivers/staging/octeon/ethernet-rgmii.c index a6b853118bc5..65edfbf251c4 100644 --- a/drivers/staging/octeon/ethernet-rgmii.c +++ b/drivers/staging/octeon/ethernet-rgmii.c @@ -176,23 +176,10 @@ static void cvm_oct_rgmii_poll(struct net_device *dev) if (link_info.s.link_up) { if (!netif_carrier_ok(dev)) netif_carrier_on(dev); - if (priv->queue != -1) - printk_ratelimited("%s: %u Mbps %s duplex, port %2d, queue %2d\n", - dev->name, link_info.s.speed, - (link_info.s.full_duplex) ? - "Full" : "Half", - priv->port, priv->queue); - else - printk_ratelimited("%s: %u Mbps %s duplex, port %2d, POW\n", - dev->name, link_info.s.speed, - (link_info.s.full_duplex) ? - "Full" : "Half", - priv->port); - } else { - if (netif_carrier_ok(dev)) - netif_carrier_off(dev); - printk_ratelimited("%s: Link down\n", dev->name); + } else if (netif_carrier_ok(dev)) { + netif_carrier_off(dev); } + cvm_oct_note_carrier(priv, link_info); } } diff --git a/drivers/staging/octeon/ethernet-sgmii.c b/drivers/staging/octeon/ethernet-sgmii.c index 1158eacc57bb..9a747f94d48c 100644 --- a/drivers/staging/octeon/ethernet-sgmii.c +++ b/drivers/staging/octeon/ethernet-sgmii.c @@ -55,26 +55,12 @@ static void cvm_oct_sgmii_poll(struct net_device *dev) /* Tell Linux */ if (link_info.s.link_up) { - if (!netif_carrier_ok(dev)) netif_carrier_on(dev); - if (priv->queue != -1) - printk_ratelimited - ("%s: %u Mbps %s duplex, port %2d, queue %2d\n", - dev->name, link_info.s.speed, - (link_info.s.full_duplex) ? "Full" : "Half", - priv->port, priv->queue); - else - printk_ratelimited - ("%s: %u Mbps %s duplex, port %2d, POW\n", - dev->name, link_info.s.speed, - (link_info.s.full_duplex) ? "Full" : "Half", - priv->port); - } else { - if (netif_carrier_ok(dev)) - netif_carrier_off(dev); - printk_ratelimited("%s: Link down\n", dev->name); + } else if (netif_carrier_ok(dev)) { + netif_carrier_off(dev); } + cvm_oct_note_carrier(priv, link_info); } int cvm_oct_sgmii_open(struct net_device *dev) diff --git a/drivers/staging/octeon/ethernet-xaui.c b/drivers/staging/octeon/ethernet-xaui.c index 3714fae201d4..888b70b93a7b 100644 --- a/drivers/staging/octeon/ethernet-xaui.c +++ b/drivers/staging/octeon/ethernet-xaui.c @@ -55,26 +55,12 @@ static void cvm_oct_xaui_poll(struct net_device *dev) /* Tell Linux */ if (link_info.s.link_up) { - if (!netif_carrier_ok(dev)) netif_carrier_on(dev); - if (priv->queue != -1) - printk_ratelimited - ("%s: %u Mbps %s duplex, port %2d, queue %2d\n", - dev->name, link_info.s.speed, - (link_info.s.full_duplex) ? "Full" : "Half", - priv->port, priv->queue); - else - printk_ratelimited - ("%s: %u Mbps %s duplex, port %2d, POW\n", - dev->name, link_info.s.speed, - (link_info.s.full_duplex) ? "Full" : "Half", - priv->port); - } else { - if (netif_carrier_ok(dev)) - netif_carrier_off(dev); - printk_ratelimited("%s: Link down\n", dev->name); + } else if (netif_carrier_ok(dev)) { + netif_carrier_off(dev); } + cvm_oct_note_carrier(priv, link_info); } int cvm_oct_xaui_open(struct net_device *dev) diff --git a/drivers/staging/octeon/octeon-ethernet.h b/drivers/staging/octeon/octeon-ethernet.h index 3ad713fb4725..1e77f1d23c74 100644 --- a/drivers/staging/octeon/octeon-ethernet.h +++ b/drivers/staging/octeon/octeon-ethernet.h @@ -33,6 +33,8 @@ #include +#include + /** * This is the definition of the Ethernet driver's private * driver state stored in netdev_priv(dev). @@ -86,6 +88,8 @@ void cvm_oct_adjust_link(struct net_device *dev); int cvm_oct_common_stop(struct net_device *dev); int cvm_oct_common_open(struct net_device *dev, void (*link_poll)(struct net_device *), bool poll_now); +void cvm_oct_note_carrier(struct octeon_ethernet *priv, + cvmx_helper_link_info_t li); extern int always_use_pow; extern int pow_send_group; From a8d2e8171082854dadea64b808af4b54f78c0384 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sat, 4 Apr 2015 22:51:08 +0300 Subject: [PATCH 0073/1163] staging: octeon-ethernet: sgmii/xaui: make link poll generic Make link poll generic to avoid copy paste. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-sgmii.c | 24 +--------------------- drivers/staging/octeon/ethernet-xaui.c | 26 ++---------------------- drivers/staging/octeon/ethernet.c | 21 +++++++++++++++++++ drivers/staging/octeon/octeon-ethernet.h | 1 + 4 files changed, 25 insertions(+), 47 deletions(-) diff --git a/drivers/staging/octeon/ethernet-sgmii.c b/drivers/staging/octeon/ethernet-sgmii.c index 9a747f94d48c..1940f4b72a66 100644 --- a/drivers/staging/octeon/ethernet-sgmii.c +++ b/drivers/staging/octeon/ethernet-sgmii.c @@ -41,31 +41,9 @@ #include -static void cvm_oct_sgmii_poll(struct net_device *dev) -{ - struct octeon_ethernet *priv = netdev_priv(dev); - cvmx_helper_link_info_t link_info; - - link_info = cvmx_helper_link_get(priv->port); - if (link_info.u64 == priv->link_info) - return; - - link_info = cvmx_helper_link_autoconf(priv->port); - priv->link_info = link_info.u64; - - /* Tell Linux */ - if (link_info.s.link_up) { - if (!netif_carrier_ok(dev)) - netif_carrier_on(dev); - } else if (netif_carrier_ok(dev)) { - netif_carrier_off(dev); - } - cvm_oct_note_carrier(priv, link_info); -} - int cvm_oct_sgmii_open(struct net_device *dev) { - return cvm_oct_common_open(dev, cvm_oct_sgmii_poll, true); + return cvm_oct_common_open(dev, cvm_oct_link_poll, true); } int cvm_oct_sgmii_init(struct net_device *dev) diff --git a/drivers/staging/octeon/ethernet-xaui.c b/drivers/staging/octeon/ethernet-xaui.c index 888b70b93a7b..42a4d2be0cff 100644 --- a/drivers/staging/octeon/ethernet-xaui.c +++ b/drivers/staging/octeon/ethernet-xaui.c @@ -41,31 +41,9 @@ #include -static void cvm_oct_xaui_poll(struct net_device *dev) -{ - struct octeon_ethernet *priv = netdev_priv(dev); - cvmx_helper_link_info_t link_info; - - link_info = cvmx_helper_link_get(priv->port); - if (link_info.u64 == priv->link_info) - return; - - link_info = cvmx_helper_link_autoconf(priv->port); - priv->link_info = link_info.u64; - - /* Tell Linux */ - if (link_info.s.link_up) { - if (!netif_carrier_ok(dev)) - netif_carrier_on(dev); - } else if (netif_carrier_ok(dev)) { - netif_carrier_off(dev); - } - cvm_oct_note_carrier(priv, link_info); -} - int cvm_oct_xaui_open(struct net_device *dev) { - return cvm_oct_common_open(dev, cvm_oct_xaui_poll, true); + return cvm_oct_common_open(dev, cvm_oct_link_poll, true); } int cvm_oct_xaui_init(struct net_device *dev) @@ -74,7 +52,7 @@ int cvm_oct_xaui_init(struct net_device *dev) cvm_oct_common_init(dev); if (!octeon_is_simulation() && priv->phydev == NULL) - priv->poll = cvm_oct_xaui_poll; + priv->poll = cvm_oct_link_poll; return 0; } diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index a7f1fcb4762a..d395bf527d91 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c @@ -541,6 +541,27 @@ int cvm_oct_common_open(struct net_device *dev, return 0; } +void cvm_oct_link_poll(struct net_device *dev) +{ + struct octeon_ethernet *priv = netdev_priv(dev); + cvmx_helper_link_info_t link_info; + + link_info = cvmx_helper_link_get(priv->port); + if (link_info.u64 == priv->link_info) + return; + + link_info = cvmx_helper_link_autoconf(priv->port); + priv->link_info = link_info.u64; + + if (link_info.s.link_up) { + if (!netif_carrier_ok(dev)) + netif_carrier_on(dev); + } else if (netif_carrier_ok(dev)) { + netif_carrier_off(dev); + } + cvm_oct_note_carrier(priv, link_info); +} + static const struct net_device_ops cvm_oct_npi_netdev_ops = { .ndo_init = cvm_oct_common_init, .ndo_uninit = cvm_oct_common_uninit, diff --git a/drivers/staging/octeon/octeon-ethernet.h b/drivers/staging/octeon/octeon-ethernet.h index 1e77f1d23c74..22d726e0d2d0 100644 --- a/drivers/staging/octeon/octeon-ethernet.h +++ b/drivers/staging/octeon/octeon-ethernet.h @@ -90,6 +90,7 @@ int cvm_oct_common_open(struct net_device *dev, void (*link_poll)(struct net_device *), bool poll_now); void cvm_oct_note_carrier(struct octeon_ethernet *priv, cvmx_helper_link_info_t li); +void cvm_oct_link_poll(struct net_device *dev); extern int always_use_pow; extern int pow_send_group; From 67d2ee257392372e889ece8526eef9941e982512 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sat, 4 Apr 2015 22:51:09 +0300 Subject: [PATCH 0074/1163] staging: octeon-ethernet: rgmii: refactor gmx block interrupt handling Code for gmx0 and gmx1 block is identical, move it into a function. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-rgmii.c | 135 +++++++++--------------- 1 file changed, 47 insertions(+), 88 deletions(-) diff --git a/drivers/staging/octeon/ethernet-rgmii.c b/drivers/staging/octeon/ethernet-rgmii.c index 65edfbf251c4..0101fcd5d348 100644 --- a/drivers/staging/octeon/ethernet-rgmii.c +++ b/drivers/staging/octeon/ethernet-rgmii.c @@ -183,104 +183,63 @@ static void cvm_oct_rgmii_poll(struct net_device *dev) } } +static int cmv_oct_rgmii_gmx_interrupt(int interface) +{ + int index; + int count = 0; + + /* Loop through every port of this interface */ + for (index = 0; + index < cvmx_helper_ports_on_interface(interface); + index++) { + union cvmx_gmxx_rxx_int_reg gmx_rx_int_reg; + + /* Read the GMX interrupt status bits */ + gmx_rx_int_reg.u64 = cvmx_read_csr(CVMX_GMXX_RXX_INT_REG + (index, interface)); + gmx_rx_int_reg.u64 &= cvmx_read_csr(CVMX_GMXX_RXX_INT_EN + (index, interface)); + + /* Poll the port if inband status changed */ + if (gmx_rx_int_reg.s.phy_dupx || gmx_rx_int_reg.s.phy_link || + gmx_rx_int_reg.s.phy_spd) { + struct net_device *dev = + cvm_oct_device[cvmx_helper_get_ipd_port + (interface, index)]; + struct octeon_ethernet *priv = netdev_priv(dev); + + if (dev && !atomic_read(&cvm_oct_poll_queue_stopping)) + queue_work(cvm_oct_poll_queue, + &priv->port_work); + + gmx_rx_int_reg.u64 = 0; + gmx_rx_int_reg.s.phy_dupx = 1; + gmx_rx_int_reg.s.phy_link = 1; + gmx_rx_int_reg.s.phy_spd = 1; + cvmx_write_csr(CVMX_GMXX_RXX_INT_REG(index, interface), + gmx_rx_int_reg.u64); + count++; + } + } + return count; +} + static irqreturn_t cvm_oct_rgmii_rml_interrupt(int cpl, void *dev_id) { union cvmx_npi_rsl_int_blocks rsl_int_blocks; - int index; - irqreturn_t return_status = IRQ_NONE; + int count = 0; rsl_int_blocks.u64 = cvmx_read_csr(CVMX_NPI_RSL_INT_BLOCKS); /* Check and see if this interrupt was caused by the GMX0 block */ - if (rsl_int_blocks.s.gmx0) { - - int interface = 0; - /* Loop through every port of this interface */ - for (index = 0; - index < cvmx_helper_ports_on_interface(interface); - index++) { - - /* Read the GMX interrupt status bits */ - union cvmx_gmxx_rxx_int_reg gmx_rx_int_reg; - - gmx_rx_int_reg.u64 = - cvmx_read_csr(CVMX_GMXX_RXX_INT_REG - (index, interface)); - gmx_rx_int_reg.u64 &= - cvmx_read_csr(CVMX_GMXX_RXX_INT_EN - (index, interface)); - /* Poll the port if inband status changed */ - if (gmx_rx_int_reg.s.phy_dupx - || gmx_rx_int_reg.s.phy_link - || gmx_rx_int_reg.s.phy_spd) { - - struct net_device *dev = - cvm_oct_device[cvmx_helper_get_ipd_port - (interface, index)]; - struct octeon_ethernet *priv = netdev_priv(dev); - - if (dev && - !atomic_read(&cvm_oct_poll_queue_stopping)) - queue_work(cvm_oct_poll_queue, - &priv->port_work); - - gmx_rx_int_reg.u64 = 0; - gmx_rx_int_reg.s.phy_dupx = 1; - gmx_rx_int_reg.s.phy_link = 1; - gmx_rx_int_reg.s.phy_spd = 1; - cvmx_write_csr(CVMX_GMXX_RXX_INT_REG - (index, interface), - gmx_rx_int_reg.u64); - return_status = IRQ_HANDLED; - } - } - } + if (rsl_int_blocks.s.gmx0) + count += cmv_oct_rgmii_gmx_interrupt(0); /* Check and see if this interrupt was caused by the GMX1 block */ - if (rsl_int_blocks.s.gmx1) { + if (rsl_int_blocks.s.gmx1) + count += cmv_oct_rgmii_gmx_interrupt(1); - int interface = 1; - /* Loop through every port of this interface */ - for (index = 0; - index < cvmx_helper_ports_on_interface(interface); - index++) { - - /* Read the GMX interrupt status bits */ - union cvmx_gmxx_rxx_int_reg gmx_rx_int_reg; - - gmx_rx_int_reg.u64 = - cvmx_read_csr(CVMX_GMXX_RXX_INT_REG - (index, interface)); - gmx_rx_int_reg.u64 &= - cvmx_read_csr(CVMX_GMXX_RXX_INT_EN - (index, interface)); - /* Poll the port if inband status changed */ - if (gmx_rx_int_reg.s.phy_dupx - || gmx_rx_int_reg.s.phy_link - || gmx_rx_int_reg.s.phy_spd) { - - struct net_device *dev = - cvm_oct_device[cvmx_helper_get_ipd_port - (interface, index)]; - struct octeon_ethernet *priv = netdev_priv(dev); - - if (dev && - !atomic_read(&cvm_oct_poll_queue_stopping)) - queue_work(cvm_oct_poll_queue, - &priv->port_work); - - gmx_rx_int_reg.u64 = 0; - gmx_rx_int_reg.s.phy_dupx = 1; - gmx_rx_int_reg.s.phy_link = 1; - gmx_rx_int_reg.s.phy_spd = 1; - cvmx_write_csr(CVMX_GMXX_RXX_INT_REG - (index, interface), - gmx_rx_int_reg.u64); - return_status = IRQ_HANDLED; - } - } - } - return return_status; + return count ? IRQ_HANDLED : IRQ_NONE; } int cvm_oct_rgmii_open(struct net_device *dev) From 01d3007a5de1bb3f6c84dcc836dc5bffee91a7e3 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sat, 4 Apr 2015 22:51:10 +0300 Subject: [PATCH 0075/1163] staging: octeon-ethernet: rgmii: use function to configure hw preamble Use a function to enable/disable HW preamble checking to avoid copy paste. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-rgmii.c | 82 ++++++++++--------------- 1 file changed, 34 insertions(+), 48 deletions(-) diff --git a/drivers/staging/octeon/ethernet-rgmii.c b/drivers/staging/octeon/ethernet-rgmii.c index 0101fcd5d348..ba2ad2aaca3e 100644 --- a/drivers/staging/octeon/ethernet-rgmii.c +++ b/drivers/staging/octeon/ethernet-rgmii.c @@ -48,6 +48,37 @@ static DEFINE_SPINLOCK(global_register_lock); static int number_rgmii_ports; +static void cvm_oct_set_hw_preamble(struct octeon_ethernet *priv, bool enable) +{ + union cvmx_gmxx_rxx_frm_ctl gmxx_rxx_frm_ctl; + union cvmx_ipd_sub_port_fcs ipd_sub_port_fcs; + union cvmx_gmxx_rxx_int_reg gmxx_rxx_int_reg; + int interface = INTERFACE(priv->port); + int index = INDEX(priv->port); + + /* Set preamble checking. */ + gmxx_rxx_frm_ctl.u64 = cvmx_read_csr(CVMX_GMXX_RXX_FRM_CTL(index, + interface)); + gmxx_rxx_frm_ctl.s.pre_chk = enable; + cvmx_write_csr(CVMX_GMXX_RXX_FRM_CTL(index, interface), + gmxx_rxx_frm_ctl.u64); + + /* Set FCS stripping. */ + ipd_sub_port_fcs.u64 = cvmx_read_csr(CVMX_IPD_SUB_PORT_FCS); + if (enable) + ipd_sub_port_fcs.s.port_bit |= 1ull << priv->port; + else + ipd_sub_port_fcs.s.port_bit &= + 0xffffffffull ^ (1ull << priv->port); + cvmx_write_csr(CVMX_IPD_SUB_PORT_FCS, ipd_sub_port_fcs.u64); + + /* Clear any error bits. */ + gmxx_rxx_int_reg.u64 = cvmx_read_csr(CVMX_GMXX_RXX_INT_REG(index, + interface)); + cvmx_write_csr(CVMX_GMXX_RXX_INT_REG(index, interface), + gmxx_rxx_int_reg.u64); +} + static void cvm_oct_rgmii_poll(struct net_device *dev) { struct octeon_ethernet *priv = netdev_priv(dev); @@ -88,7 +119,6 @@ static void cvm_oct_rgmii_poll(struct net_device *dev) cvmx_read_csr(CVMX_GMXX_RXX_INT_REG (index, interface)); if (gmxx_rxx_int_reg.s.pcterr) { - /* * We are getting preamble errors at * 10Mbps. Most likely the PHY is @@ -97,30 +127,7 @@ static void cvm_oct_rgmii_poll(struct net_device *dev) * packets we need to disable preamble * checking and do it in software. */ - union cvmx_gmxx_rxx_frm_ctl gmxx_rxx_frm_ctl; - union cvmx_ipd_sub_port_fcs ipd_sub_port_fcs; - - /* Disable preamble checking */ - gmxx_rxx_frm_ctl.u64 = - cvmx_read_csr(CVMX_GMXX_RXX_FRM_CTL - (index, interface)); - gmxx_rxx_frm_ctl.s.pre_chk = 0; - cvmx_write_csr(CVMX_GMXX_RXX_FRM_CTL - (index, interface), - gmxx_rxx_frm_ctl.u64); - - /* Disable FCS stripping */ - ipd_sub_port_fcs.u64 = - cvmx_read_csr(CVMX_IPD_SUB_PORT_FCS); - ipd_sub_port_fcs.s.port_bit &= - 0xffffffffull ^ (1ull << priv->port); - cvmx_write_csr(CVMX_IPD_SUB_PORT_FCS, - ipd_sub_port_fcs.u64); - - /* Clear any error bits */ - cvmx_write_csr(CVMX_GMXX_RXX_INT_REG - (index, interface), - gmxx_rxx_int_reg.u64); + cvm_oct_set_hw_preamble(priv, false); printk_ratelimited("%s: Using 10Mbps with software preamble removal\n", dev->name); } @@ -137,30 +144,9 @@ static void cvm_oct_rgmii_poll(struct net_device *dev) preamble checking, FCS stripping, and clear error bits on every speed change. If errors occur during 10Mbps operation the above code will change this stuff */ - if (USE_10MBPS_PREAMBLE_WORKAROUND) { + if (USE_10MBPS_PREAMBLE_WORKAROUND) + cvm_oct_set_hw_preamble(priv, true); - union cvmx_gmxx_rxx_frm_ctl gmxx_rxx_frm_ctl; - union cvmx_ipd_sub_port_fcs ipd_sub_port_fcs; - union cvmx_gmxx_rxx_int_reg gmxx_rxx_int_reg; - int interface = INTERFACE(priv->port); - int index = INDEX(priv->port); - - /* Enable preamble checking */ - gmxx_rxx_frm_ctl.u64 = - cvmx_read_csr(CVMX_GMXX_RXX_FRM_CTL(index, interface)); - gmxx_rxx_frm_ctl.s.pre_chk = 1; - cvmx_write_csr(CVMX_GMXX_RXX_FRM_CTL(index, interface), - gmxx_rxx_frm_ctl.u64); - /* Enable FCS stripping */ - ipd_sub_port_fcs.u64 = cvmx_read_csr(CVMX_IPD_SUB_PORT_FCS); - ipd_sub_port_fcs.s.port_bit |= 1ull << priv->port; - cvmx_write_csr(CVMX_IPD_SUB_PORT_FCS, ipd_sub_port_fcs.u64); - /* Clear any error bits */ - gmxx_rxx_int_reg.u64 = - cvmx_read_csr(CVMX_GMXX_RXX_INT_REG(index, interface)); - cvmx_write_csr(CVMX_GMXX_RXX_INT_REG(index, interface), - gmxx_rxx_int_reg.u64); - } if (priv->phydev == NULL) { link_info = cvmx_helper_link_autoconf(priv->port); priv->link_info = link_info.u64; From 8884ceeb4b8ea400468683b9b4d0bf5f2b9ac7e7 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sat, 4 Apr 2015 22:51:11 +0300 Subject: [PATCH 0076/1163] staging: octeon-ethernet: spi: move spx interrupt dumps into a function Move interrupt printouts into a common function to avoid copy paste. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-spi.c | 80 ++++++++++++--------------- 1 file changed, 34 insertions(+), 46 deletions(-) diff --git a/drivers/staging/octeon/ethernet-spi.c b/drivers/staging/octeon/ethernet-spi.c index 5108bc0bb573..6ecbfb5f22dc 100644 --- a/drivers/staging/octeon/ethernet-spi.c +++ b/drivers/staging/octeon/ethernet-spi.c @@ -44,6 +44,38 @@ static int number_spi_ports; static int need_retrain[2] = { 0, 0 }; +static void cvm_oct_spxx_int_pr(union cvmx_spxx_int_reg spx_int_reg, int index) +{ + if (spx_int_reg.s.spf) + pr_err("SPI%d: SRX Spi4 interface down\n", index); + if (spx_int_reg.s.calerr) + pr_err("SPI%d: SRX Spi4 Calendar table parity error\n", index); + if (spx_int_reg.s.syncerr) + pr_err("SPI%d: SRX Consecutive Spi4 DIP4 errors have exceeded SPX_ERR_CTL[ERRCNT]\n", + index); + if (spx_int_reg.s.diperr) + pr_err("SPI%d: SRX Spi4 DIP4 error\n", index); + if (spx_int_reg.s.tpaovr) + pr_err("SPI%d: SRX Selected port has hit TPA overflow\n", + index); + if (spx_int_reg.s.rsverr) + pr_err("SPI%d: SRX Spi4 reserved control word detected\n", + index); + if (spx_int_reg.s.drwnng) + pr_err("SPI%d: SRX Spi4 receive FIFO drowning/overflow\n", + index); + if (spx_int_reg.s.clserr) + pr_err("SPI%d: SRX Spi4 packet closed on non-16B alignment without EOP\n", + index); + if (spx_int_reg.s.spiovr) + pr_err("SPI%d: SRX Spi4 async FIFO overflow\n", index); + if (spx_int_reg.s.abnorm) + pr_err("SPI%d: SRX Abnormal packet termination (ERR bit)\n", + index); + if (spx_int_reg.s.prtnxa) + pr_err("SPI%d: SRX Port out of range\n", index); +} + static irqreturn_t cvm_oct_spi_rml_interrupt(int cpl, void *dev_id) { irqreturn_t return_status = IRQ_NONE; @@ -59,30 +91,8 @@ static irqreturn_t cvm_oct_spi_rml_interrupt(int cpl, void *dev_id) spx_int_reg.u64 = cvmx_read_csr(CVMX_SPXX_INT_REG(1)); cvmx_write_csr(CVMX_SPXX_INT_REG(1), spx_int_reg.u64); if (!need_retrain[1]) { - spx_int_reg.u64 &= cvmx_read_csr(CVMX_SPXX_INT_MSK(1)); - if (spx_int_reg.s.spf) - pr_err("SPI1: SRX Spi4 interface down\n"); - if (spx_int_reg.s.calerr) - pr_err("SPI1: SRX Spi4 Calendar table parity error\n"); - if (spx_int_reg.s.syncerr) - pr_err("SPI1: SRX Consecutive Spi4 DIP4 errors have exceeded SPX_ERR_CTL[ERRCNT]\n"); - if (spx_int_reg.s.diperr) - pr_err("SPI1: SRX Spi4 DIP4 error\n"); - if (spx_int_reg.s.tpaovr) - pr_err("SPI1: SRX Selected port has hit TPA overflow\n"); - if (spx_int_reg.s.rsverr) - pr_err("SPI1: SRX Spi4 reserved control word detected\n"); - if (spx_int_reg.s.drwnng) - pr_err("SPI1: SRX Spi4 receive FIFO drowning/overflow\n"); - if (spx_int_reg.s.clserr) - pr_err("SPI1: SRX Spi4 packet closed on non-16B alignment without EOP\n"); - if (spx_int_reg.s.spiovr) - pr_err("SPI1: SRX Spi4 async FIFO overflow\n"); - if (spx_int_reg.s.abnorm) - pr_err("SPI1: SRX Abnormal packet termination (ERR bit)\n"); - if (spx_int_reg.s.prtnxa) - pr_err("SPI1: SRX Port out of range\n"); + cvm_oct_spxx_int_pr(spx_int_reg, 1); } stx_int_reg.u64 = cvmx_read_csr(CVMX_STXX_INT_REG(1)); @@ -123,30 +133,8 @@ static irqreturn_t cvm_oct_spi_rml_interrupt(int cpl, void *dev_id) spx_int_reg.u64 = cvmx_read_csr(CVMX_SPXX_INT_REG(0)); cvmx_write_csr(CVMX_SPXX_INT_REG(0), spx_int_reg.u64); if (!need_retrain[0]) { - spx_int_reg.u64 &= cvmx_read_csr(CVMX_SPXX_INT_MSK(0)); - if (spx_int_reg.s.spf) - pr_err("SPI0: SRX Spi4 interface down\n"); - if (spx_int_reg.s.calerr) - pr_err("SPI0: SRX Spi4 Calendar table parity error\n"); - if (spx_int_reg.s.syncerr) - pr_err("SPI0: SRX Consecutive Spi4 DIP4 errors have exceeded SPX_ERR_CTL[ERRCNT]\n"); - if (spx_int_reg.s.diperr) - pr_err("SPI0: SRX Spi4 DIP4 error\n"); - if (spx_int_reg.s.tpaovr) - pr_err("SPI0: SRX Selected port has hit TPA overflow\n"); - if (spx_int_reg.s.rsverr) - pr_err("SPI0: SRX Spi4 reserved control word detected\n"); - if (spx_int_reg.s.drwnng) - pr_err("SPI0: SRX Spi4 receive FIFO drowning/overflow\n"); - if (spx_int_reg.s.clserr) - pr_err("SPI0: SRX Spi4 packet closed on non-16B alignment without EOP\n"); - if (spx_int_reg.s.spiovr) - pr_err("SPI0: SRX Spi4 async FIFO overflow\n"); - if (spx_int_reg.s.abnorm) - pr_err("SPI0: SRX Abnormal packet termination (ERR bit)\n"); - if (spx_int_reg.s.prtnxa) - pr_err("SPI0: SRX Port out of range\n"); + cvm_oct_spxx_int_pr(spx_int_reg, 0); } stx_int_reg.u64 = cvmx_read_csr(CVMX_STXX_INT_REG(0)); From 124bcc5e74fe4cc761d759dac8f8c041e1d3ad96 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sat, 4 Apr 2015 22:51:12 +0300 Subject: [PATCH 0077/1163] staging: octeon-ethernet: spi: move stx interrupt dumps into a function Move interrupt printouts into a common function to avoid copy paste. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-spi.c | 68 ++++++++++++--------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/drivers/staging/octeon/ethernet-spi.c b/drivers/staging/octeon/ethernet-spi.c index 6ecbfb5f22dc..6579e1ac5542 100644 --- a/drivers/staging/octeon/ethernet-spi.c +++ b/drivers/staging/octeon/ethernet-spi.c @@ -76,6 +76,34 @@ static void cvm_oct_spxx_int_pr(union cvmx_spxx_int_reg spx_int_reg, int index) pr_err("SPI%d: SRX Port out of range\n", index); } +static void cvm_oct_stxx_int_pr(union cvmx_stxx_int_reg stx_int_reg, int index) +{ + if (stx_int_reg.s.syncerr) + pr_err("SPI%d: STX Interface encountered a fatal error\n", + index); + if (stx_int_reg.s.frmerr) + pr_err("SPI%d: STX FRMCNT has exceeded STX_DIP_CNT[MAXFRM]\n", + index); + if (stx_int_reg.s.unxfrm) + pr_err("SPI%d: STX Unexpected framing sequence\n", index); + if (stx_int_reg.s.nosync) + pr_err("SPI%d: STX ERRCNT has exceeded STX_DIP_CNT[MAXDIP]\n", + index); + if (stx_int_reg.s.diperr) + pr_err("SPI%d: STX DIP2 error on the Spi4 Status channel\n", + index); + if (stx_int_reg.s.datovr) + pr_err("SPI%d: STX Spi4 FIFO overflow error\n", index); + if (stx_int_reg.s.ovrbst) + pr_err("SPI%d: STX Transmit packet burst too big\n", index); + if (stx_int_reg.s.calpar1) + pr_err("SPI%d: STX Calendar Table Parity Error Bank%d\n", + index, 1); + if (stx_int_reg.s.calpar0) + pr_err("SPI%d: STX Calendar Table Parity Error Bank%d\n", + index, 0); +} + static irqreturn_t cvm_oct_spi_rml_interrupt(int cpl, void *dev_id) { irqreturn_t return_status = IRQ_NONE; @@ -98,26 +126,8 @@ static irqreturn_t cvm_oct_spi_rml_interrupt(int cpl, void *dev_id) stx_int_reg.u64 = cvmx_read_csr(CVMX_STXX_INT_REG(1)); cvmx_write_csr(CVMX_STXX_INT_REG(1), stx_int_reg.u64); if (!need_retrain[1]) { - stx_int_reg.u64 &= cvmx_read_csr(CVMX_STXX_INT_MSK(1)); - if (stx_int_reg.s.syncerr) - pr_err("SPI1: STX Interface encountered a fatal error\n"); - if (stx_int_reg.s.frmerr) - pr_err("SPI1: STX FRMCNT has exceeded STX_DIP_CNT[MAXFRM]\n"); - if (stx_int_reg.s.unxfrm) - pr_err("SPI1: STX Unexpected framing sequence\n"); - if (stx_int_reg.s.nosync) - pr_err("SPI1: STX ERRCNT has exceeded STX_DIP_CNT[MAXDIP]\n"); - if (stx_int_reg.s.diperr) - pr_err("SPI1: STX DIP2 error on the Spi4 Status channel\n"); - if (stx_int_reg.s.datovr) - pr_err("SPI1: STX Spi4 FIFO overflow error\n"); - if (stx_int_reg.s.ovrbst) - pr_err("SPI1: STX Transmit packet burst too big\n"); - if (stx_int_reg.s.calpar1) - pr_err("SPI1: STX Calendar Table Parity Error Bank1\n"); - if (stx_int_reg.s.calpar0) - pr_err("SPI1: STX Calendar Table Parity Error Bank0\n"); + cvm_oct_stxx_int_pr(stx_int_reg, 1); } cvmx_write_csr(CVMX_SPXX_INT_MSK(1), 0); @@ -140,26 +150,8 @@ static irqreturn_t cvm_oct_spi_rml_interrupt(int cpl, void *dev_id) stx_int_reg.u64 = cvmx_read_csr(CVMX_STXX_INT_REG(0)); cvmx_write_csr(CVMX_STXX_INT_REG(0), stx_int_reg.u64); if (!need_retrain[0]) { - stx_int_reg.u64 &= cvmx_read_csr(CVMX_STXX_INT_MSK(0)); - if (stx_int_reg.s.syncerr) - pr_err("SPI0: STX Interface encountered a fatal error\n"); - if (stx_int_reg.s.frmerr) - pr_err("SPI0: STX FRMCNT has exceeded STX_DIP_CNT[MAXFRM]\n"); - if (stx_int_reg.s.unxfrm) - pr_err("SPI0: STX Unexpected framing sequence\n"); - if (stx_int_reg.s.nosync) - pr_err("SPI0: STX ERRCNT has exceeded STX_DIP_CNT[MAXDIP]\n"); - if (stx_int_reg.s.diperr) - pr_err("SPI0: STX DIP2 error on the Spi4 Status channel\n"); - if (stx_int_reg.s.datovr) - pr_err("SPI0: STX Spi4 FIFO overflow error\n"); - if (stx_int_reg.s.ovrbst) - pr_err("SPI0: STX Transmit packet burst too big\n"); - if (stx_int_reg.s.calpar1) - pr_err("SPI0: STX Calendar Table Parity Error Bank1\n"); - if (stx_int_reg.s.calpar0) - pr_err("SPI0: STX Calendar Table Parity Error Bank0\n"); + cvm_oct_stxx_int_pr(stx_int_reg, 0); } cvmx_write_csr(CVMX_SPXX_INT_MSK(0), 0); From 81f56d332050084dccdff61bbf819d97f28abe70 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sat, 4 Apr 2015 22:51:13 +0300 Subject: [PATCH 0078/1163] staging: octeon-ethernet: spi: refactor spx block interrupt handling Code for spx1 and spx0 block are identical, move it into a function. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-spi.c | 77 +++++++++++---------------- 1 file changed, 30 insertions(+), 47 deletions(-) diff --git a/drivers/staging/octeon/ethernet-spi.c b/drivers/staging/octeon/ethernet-spi.c index 6579e1ac5542..5313ac54d863 100644 --- a/drivers/staging/octeon/ethernet-spi.c +++ b/drivers/staging/octeon/ethernet-spi.c @@ -104,6 +104,32 @@ static void cvm_oct_stxx_int_pr(union cvmx_stxx_int_reg stx_int_reg, int index) index, 0); } +static irqreturn_t cvm_oct_spi_spx_int(int index) +{ + union cvmx_spxx_int_reg spx_int_reg; + union cvmx_stxx_int_reg stx_int_reg; + + spx_int_reg.u64 = cvmx_read_csr(CVMX_SPXX_INT_REG(index)); + cvmx_write_csr(CVMX_SPXX_INT_REG(index), spx_int_reg.u64); + if (!need_retrain[index]) { + spx_int_reg.u64 &= cvmx_read_csr(CVMX_SPXX_INT_MSK(index)); + cvm_oct_spxx_int_pr(spx_int_reg, index); + } + + stx_int_reg.u64 = cvmx_read_csr(CVMX_STXX_INT_REG(index)); + cvmx_write_csr(CVMX_STXX_INT_REG(index), stx_int_reg.u64); + if (!need_retrain[index]) { + stx_int_reg.u64 &= cvmx_read_csr(CVMX_STXX_INT_MSK(index)); + cvm_oct_stxx_int_pr(stx_int_reg, index); + } + + cvmx_write_csr(CVMX_SPXX_INT_MSK(index), 0); + cvmx_write_csr(CVMX_STXX_INT_MSK(index), 0); + need_retrain[index] = 1; + + return IRQ_HANDLED; +} + static irqreturn_t cvm_oct_spi_rml_interrupt(int cpl, void *dev_id) { irqreturn_t return_status = IRQ_NONE; @@ -111,54 +137,11 @@ static irqreturn_t cvm_oct_spi_rml_interrupt(int cpl, void *dev_id) /* Check and see if this interrupt was caused by the GMX block */ rsl_int_blocks.u64 = cvmx_read_csr(CVMX_NPI_RSL_INT_BLOCKS); - if (rsl_int_blocks.s.spx1) { /* 19 - SPX1_INT_REG & STX1_INT_REG */ + if (rsl_int_blocks.s.spx1) /* 19 - SPX1_INT_REG & STX1_INT_REG */ + return_status = cvm_oct_spi_spx_int(1); - union cvmx_spxx_int_reg spx_int_reg; - union cvmx_stxx_int_reg stx_int_reg; - - spx_int_reg.u64 = cvmx_read_csr(CVMX_SPXX_INT_REG(1)); - cvmx_write_csr(CVMX_SPXX_INT_REG(1), spx_int_reg.u64); - if (!need_retrain[1]) { - spx_int_reg.u64 &= cvmx_read_csr(CVMX_SPXX_INT_MSK(1)); - cvm_oct_spxx_int_pr(spx_int_reg, 1); - } - - stx_int_reg.u64 = cvmx_read_csr(CVMX_STXX_INT_REG(1)); - cvmx_write_csr(CVMX_STXX_INT_REG(1), stx_int_reg.u64); - if (!need_retrain[1]) { - stx_int_reg.u64 &= cvmx_read_csr(CVMX_STXX_INT_MSK(1)); - cvm_oct_stxx_int_pr(stx_int_reg, 1); - } - - cvmx_write_csr(CVMX_SPXX_INT_MSK(1), 0); - cvmx_write_csr(CVMX_STXX_INT_MSK(1), 0); - need_retrain[1] = 1; - return_status = IRQ_HANDLED; - } - - if (rsl_int_blocks.s.spx0) { /* 18 - SPX0_INT_REG & STX0_INT_REG */ - union cvmx_spxx_int_reg spx_int_reg; - union cvmx_stxx_int_reg stx_int_reg; - - spx_int_reg.u64 = cvmx_read_csr(CVMX_SPXX_INT_REG(0)); - cvmx_write_csr(CVMX_SPXX_INT_REG(0), spx_int_reg.u64); - if (!need_retrain[0]) { - spx_int_reg.u64 &= cvmx_read_csr(CVMX_SPXX_INT_MSK(0)); - cvm_oct_spxx_int_pr(spx_int_reg, 0); - } - - stx_int_reg.u64 = cvmx_read_csr(CVMX_STXX_INT_REG(0)); - cvmx_write_csr(CVMX_STXX_INT_REG(0), stx_int_reg.u64); - if (!need_retrain[0]) { - stx_int_reg.u64 &= cvmx_read_csr(CVMX_STXX_INT_MSK(0)); - cvm_oct_stxx_int_pr(stx_int_reg, 0); - } - - cvmx_write_csr(CVMX_SPXX_INT_MSK(0), 0); - cvmx_write_csr(CVMX_STXX_INT_MSK(0), 0); - need_retrain[0] = 1; - return_status = IRQ_HANDLED; - } + if (rsl_int_blocks.s.spx0) /* 18 - SPX0_INT_REG & STX0_INT_REG */ + return_status = cvm_oct_spi_spx_int(0); return return_status; } From 280eb5b528fa49c141cafcc1b86bb24d1760b2d4 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sat, 4 Apr 2015 22:51:14 +0300 Subject: [PATCH 0079/1163] staging: octeon-ethernet: delete references to CONFIG_CAVIUM_RESERVE32 Delete references to CONFIG_CAVIUM_RESERVE32. Kernel does not have such option and the driver does not use it for anything. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-defines.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/octeon/ethernet-defines.h b/drivers/staging/octeon/ethernet-defines.h index 2a98a2153e16..d61955cb438c 100644 --- a/drivers/staging/octeon/ethernet-defines.h +++ b/drivers/staging/octeon/ethernet-defines.h @@ -27,12 +27,6 @@ /* * A few defines are used to control the operation of this driver: - * CONFIG_CAVIUM_RESERVE32 - * This kernel config options controls the amount of memory configured - * in a wired TLB entry for all processes to share. If this is set, the - * driver will use this memory instead of kernel memory for pools. This - * allows 32bit userspace application to access the buffers, but also - * requires all received packets to be copied. * USE_SKBUFFS_IN_HW * Tells the driver to populate the packet buffers with kernel skbuffs. * This allows the driver to receive packets without copying them. It also @@ -60,10 +54,6 @@ #define OCTEON_ETHERNET_VERSION "1.9" -#ifndef CONFIG_CAVIUM_RESERVE32 -#define CONFIG_CAVIUM_RESERVE32 0 -#endif - #define USE_SKBUFFS_IN_HW 1 #ifdef CONFIG_NETFILTER #define REUSE_SKBUFFS_WITHOUT_FREE 0 From 25efe08e849baeac40b9216bae6a5e0299872306 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sat, 4 Apr 2015 22:51:15 +0300 Subject: [PATCH 0080/1163] staging: octeon-ethernet: eliminate USE_10MBPS_PREAMBLE_WORKAROUND define We have the workaround always enabled, so eliminate a redundant #define. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-defines.h | 5 ----- drivers/staging/octeon/ethernet-rgmii.c | 14 +++----------- drivers/staging/octeon/ethernet-rx.c | 7 ++----- 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/drivers/staging/octeon/ethernet-defines.h b/drivers/staging/octeon/ethernet-defines.h index d61955cb438c..de6ae6bf918a 100644 --- a/drivers/staging/octeon/ethernet-defines.h +++ b/drivers/staging/octeon/ethernet-defines.h @@ -67,11 +67,6 @@ #define USE_RED 1 #define USE_ASYNC_IOBDMA (CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0) -/* - * Allow SW based preamble removal at 10Mbps to workaround PHYs giving - * us bad preambles. - */ -#define USE_10MBPS_PREAMBLE_WORKAROUND 1 /* * Use this to have all FPA frees also tell the L2 not to write data * to memory. diff --git a/drivers/staging/octeon/ethernet-rgmii.c b/drivers/staging/octeon/ethernet-rgmii.c index ba2ad2aaca3e..ad332c3e1546 100644 --- a/drivers/staging/octeon/ethernet-rgmii.c +++ b/drivers/staging/octeon/ethernet-rgmii.c @@ -99,14 +99,7 @@ static void cvm_oct_rgmii_poll(struct net_device *dev) link_info = cvmx_helper_link_get(priv->port); if (link_info.u64 == priv->link_info) { - - /* - * If the 10Mbps preamble workaround is supported and we're - * at 10Mbps we may need to do some special checking. - */ - if (USE_10MBPS_PREAMBLE_WORKAROUND && - (link_info.s.speed == 10)) { - + if (link_info.s.speed == 10) { /* * Read the GMXX_RXX_INT_REG[PCTERR] bit and * see if we are getting preamble errors. @@ -140,12 +133,11 @@ static void cvm_oct_rgmii_poll(struct net_device *dev) return; } - /* If the 10Mbps preamble workaround is allowed we need to on + /* Since the 10Mbps preamble workaround is allowed we need to enable preamble checking, FCS stripping, and clear error bits on every speed change. If errors occur during 10Mbps operation the above code will change this stuff */ - if (USE_10MBPS_PREAMBLE_WORKAROUND) - cvm_oct_set_hw_preamble(priv, true); + cvm_oct_set_hw_preamble(priv, true); if (priv->phydev == NULL) { link_info = cvmx_helper_link_autoconf(priv->port); diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c index 22667dbb10d8..8d40986f60ef 100644 --- a/drivers/staging/octeon/ethernet-rx.c +++ b/drivers/staging/octeon/ethernet-rx.c @@ -93,11 +93,8 @@ static inline int cvm_oct_check_rcv_error(cvmx_wqe_t *work) * instead of 60+4FCS. Note these packets still get * counted as frame errors. */ - } else - if (USE_10MBPS_PREAMBLE_WORKAROUND - && ((work->word2.snoip.err_code == 5) - || (work->word2.snoip.err_code == 7))) { - + } else if (work->word2.snoip.err_code == 5 || + work->word2.snoip.err_code == 7) { /* * We received a packet with either an alignment error * or a FCS error. This may be signalling that we are From 6646baf7041214a9d616b55de96315179f112508 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sat, 4 Apr 2015 22:51:16 +0300 Subject: [PATCH 0081/1163] staging: octeon-ethernet: eliminate USE_HW_TCPUDP_CHECKSUM define HW checksum is always enabled, so delete a redundant define. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-defines.h | 6 ------ drivers/staging/octeon/ethernet-tx.c | 2 +- drivers/staging/octeon/ethernet.c | 7 ++----- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/staging/octeon/ethernet-defines.h b/drivers/staging/octeon/ethernet-defines.h index de6ae6bf918a..a837d895c1a5 100644 --- a/drivers/staging/octeon/ethernet-defines.h +++ b/drivers/staging/octeon/ethernet-defines.h @@ -31,10 +31,6 @@ * Tells the driver to populate the packet buffers with kernel skbuffs. * This allows the driver to receive packets without copying them. It also * means that 32bit userspace can't access the packet buffers. - * USE_HW_TCPUDP_CHECKSUM - * Controls if the Octeon TCP/UDP checksum engine is used for packet - * output. If this is zero, the kernel will perform the checksum in - * software. * USE_ASYNC_IOBDMA * Use asynchronous IO access to hardware. This uses Octeon's asynchronous * IOBDMAs to issue IO accesses without stalling. Set this to zero @@ -61,8 +57,6 @@ #define REUSE_SKBUFFS_WITHOUT_FREE 1 #endif -#define USE_HW_TCPUDP_CHECKSUM 1 - /* Enable Random Early Dropping under load */ #define USE_RED 1 #define USE_ASYNC_IOBDMA (CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0) diff --git a/drivers/staging/octeon/ethernet-tx.c b/drivers/staging/octeon/ethernet-tx.c index 5b9ac1f6d6f0..94ba85ae7b50 100644 --- a/drivers/staging/octeon/ethernet-tx.c +++ b/drivers/staging/octeon/ethernet-tx.c @@ -411,7 +411,7 @@ int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev) dont_put_skbuff_in_hw: /* Check if we can use the hardware checksumming */ - if (USE_HW_TCPUDP_CHECKSUM && (skb->protocol == htons(ETH_P_IP)) && + if ((skb->protocol == htons(ETH_P_IP)) && (ip_hdr(skb)->version == 4) && (ip_hdr(skb)->ihl == 5) && ((ip_hdr(skb)->frag_off == 0) || (ip_hdr(skb)->frag_off == htons(1 << 14))) && ((ip_hdr(skb)->protocol == IPPROTO_TCP) diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index d395bf527d91..b662e2ac625f 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c @@ -468,11 +468,8 @@ int cvm_oct_common_init(struct net_device *dev) && (always_use_pow || strstr(pow_send_list, dev->name))) priv->queue = -1; - if (priv->queue != -1) { - dev->features |= NETIF_F_SG; - if (USE_HW_TCPUDP_CHECKSUM) - dev->features |= NETIF_F_IP_CSUM; - } + if (priv->queue != -1) + dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM; /* We do our own locking, Linux doesn't need to */ dev->features |= NETIF_F_LLTX; From 3a990f390ec093293c03e9542f2583c5e4c53684 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sat, 4 Apr 2015 22:51:17 +0300 Subject: [PATCH 0082/1163] staging: octeon-ethernet: eliminate USE_SKBUFFS_IN_HW define We always try to use skbuffs for packet buffers, so eliminate a redundant define. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-defines.h | 5 ----- drivers/staging/octeon/ethernet-mem.c | 4 ++-- drivers/staging/octeon/ethernet-rx.c | 4 ++-- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/staging/octeon/ethernet-defines.h b/drivers/staging/octeon/ethernet-defines.h index a837d895c1a5..b39bb3ddab1f 100644 --- a/drivers/staging/octeon/ethernet-defines.h +++ b/drivers/staging/octeon/ethernet-defines.h @@ -27,10 +27,6 @@ /* * A few defines are used to control the operation of this driver: - * USE_SKBUFFS_IN_HW - * Tells the driver to populate the packet buffers with kernel skbuffs. - * This allows the driver to receive packets without copying them. It also - * means that 32bit userspace can't access the packet buffers. * USE_ASYNC_IOBDMA * Use asynchronous IO access to hardware. This uses Octeon's asynchronous * IOBDMAs to issue IO accesses without stalling. Set this to zero @@ -50,7 +46,6 @@ #define OCTEON_ETHERNET_VERSION "1.9" -#define USE_SKBUFFS_IN_HW 1 #ifdef CONFIG_NETFILTER #define REUSE_SKBUFFS_WITHOUT_FREE 0 #else diff --git a/drivers/staging/octeon/ethernet-mem.c b/drivers/staging/octeon/ethernet-mem.c index 964da860f4c4..ea1232cd1a33 100644 --- a/drivers/staging/octeon/ethernet-mem.c +++ b/drivers/staging/octeon/ethernet-mem.c @@ -160,7 +160,7 @@ int cvm_oct_mem_fill_fpa(int pool, int size, int elements) { int freed; - if (USE_SKBUFFS_IN_HW && pool == CVMX_FPA_PACKET_POOL) + if (pool == CVMX_FPA_PACKET_POOL) freed = cvm_oct_fill_hw_skbuff(pool, size, elements); else freed = cvm_oct_fill_hw_memory(pool, size, elements); @@ -169,7 +169,7 @@ int cvm_oct_mem_fill_fpa(int pool, int size, int elements) void cvm_oct_mem_empty_fpa(int pool, int size, int elements) { - if (USE_SKBUFFS_IN_HW && pool == CVMX_FPA_PACKET_POOL) + if (pool == CVMX_FPA_PACKET_POOL) cvm_oct_free_hw_skbuff(pool, size, elements); else cvm_oct_free_hw_memory(pool, size, elements); diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c index 8d40986f60ef..91043ccc61db 100644 --- a/drivers/staging/octeon/ethernet-rx.c +++ b/drivers/staging/octeon/ethernet-rx.c @@ -230,7 +230,7 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget) } rx_count++; - skb_in_hw = USE_SKBUFFS_IN_HW && work->word2.s.bufs == 1; + skb_in_hw = work->word2.s.bufs == 1; if (likely(skb_in_hw)) { skb = *pskb; prefetch(&skb->head); @@ -391,7 +391,7 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget) * Check to see if the skbuff and work share the same * packet buffer. */ - if (USE_SKBUFFS_IN_HW && likely(packet_not_copied)) { + if (likely(packet_not_copied)) { /* * This buffer needs to be replaced, increment * the number of buffers we need to free by From cccdb27755a3ae79a5fb98257c93d4ea80efe3f8 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sat, 4 Apr 2015 22:51:18 +0300 Subject: [PATCH 0083/1163] staging: octeon-ethernet: eliminate USE_RED define We have RED always enabled, so eliminate the #define. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-defines.h | 2 -- drivers/staging/octeon/ethernet.c | 5 +---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/octeon/ethernet-defines.h b/drivers/staging/octeon/ethernet-defines.h index b39bb3ddab1f..58ff9ba80d69 100644 --- a/drivers/staging/octeon/ethernet-defines.h +++ b/drivers/staging/octeon/ethernet-defines.h @@ -52,8 +52,6 @@ #define REUSE_SKBUFFS_WITHOUT_FREE 1 #endif -/* Enable Random Early Dropping under load */ -#define USE_RED 1 #define USE_ASYNC_IOBDMA (CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0) /* diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index b662e2ac625f..afcdce4bce1c 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c @@ -180,10 +180,7 @@ static void cvm_oct_configure_common_hw(void) } #endif - if (USE_RED) - cvmx_helper_setup_red(num_packet_buffers / 4, - num_packet_buffers / 8); - + cvmx_helper_setup_red(num_packet_buffers / 4, num_packet_buffers / 8); } /** From c93b0e75a819e648e7c16a5ebd503a2a36f7c1ac Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sat, 4 Apr 2015 22:51:19 +0300 Subject: [PATCH 0084/1163] staging: octeon-ethernet: eliminate DONT_WRITEBACK This feature is not used so eliminate it. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-defines.h | 8 -------- drivers/staging/octeon/ethernet-mem.c | 2 +- drivers/staging/octeon/ethernet-rx.c | 3 +-- drivers/staging/octeon/ethernet-tx.c | 2 +- drivers/staging/octeon/ethernet.c | 5 ++--- 5 files changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/staging/octeon/ethernet-defines.h b/drivers/staging/octeon/ethernet-defines.h index 58ff9ba80d69..8a6f82fb3e2c 100644 --- a/drivers/staging/octeon/ethernet-defines.h +++ b/drivers/staging/octeon/ethernet-defines.h @@ -54,14 +54,6 @@ #define USE_ASYNC_IOBDMA (CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0) -/* - * Use this to have all FPA frees also tell the L2 not to write data - * to memory. - */ -#define DONT_WRITEBACK(x) (x) -/* Use this to not have FPA frees control L2 */ -/*#define DONT_WRITEBACK(x) 0 */ - /* Maximum number of SKBs to try to free per xmit packet. */ #define MAX_OUT_QUEUE_DEPTH 1000 diff --git a/drivers/staging/octeon/ethernet-mem.c b/drivers/staging/octeon/ethernet-mem.c index ea1232cd1a33..55d921917125 100644 --- a/drivers/staging/octeon/ethernet-mem.c +++ b/drivers/staging/octeon/ethernet-mem.c @@ -54,7 +54,7 @@ static int cvm_oct_fill_hw_skbuff(int pool, int size, int elements) break; skb_reserve(skb, 256 - (((unsigned long)skb->data) & 0x7f)); *(struct sk_buff **)(skb->data - sizeof(void *)) = skb; - cvmx_fpa_free(skb->data, pool, DONT_WRITEBACK(size / 128)); + cvmx_fpa_free(skb->data, pool, size / 128); freed--; } return elements - freed; diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c index 91043ccc61db..fbf5f946036a 100644 --- a/drivers/staging/octeon/ethernet-rx.c +++ b/drivers/staging/octeon/ethernet-rx.c @@ -400,8 +400,7 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget) cvmx_fau_atomic_add32(FAU_NUM_PACKET_BUFFERS_TO_FREE, 1); - cvmx_fpa_free(work, CVMX_FPA_WQE_POOL, - DONT_WRITEBACK(1)); + cvmx_fpa_free(work, CVMX_FPA_WQE_POOL, 1); } else { cvm_oct_free_work(work); } diff --git a/drivers/staging/octeon/ethernet-tx.c b/drivers/staging/octeon/ethernet-tx.c index 94ba85ae7b50..25f89b6229b0 100644 --- a/drivers/staging/octeon/ethernet-tx.c +++ b/drivers/staging/octeon/ethernet-tx.c @@ -576,7 +576,7 @@ int cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device *dev) if (unlikely(packet_buffer == NULL)) { printk_ratelimited("%s: Failed to allocate a packet buffer\n", dev->name); - cvmx_fpa_free(work, CVMX_FPA_WQE_POOL, DONT_WRITEBACK(1)); + cvmx_fpa_free(work, CVMX_FPA_WQE_POOL, 1); priv->stats.tx_dropped++; dev_kfree_skb_any(skb); return 0; diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index afcdce4bce1c..d05bdca37278 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c @@ -203,11 +203,10 @@ int cvm_oct_free_work(void *work_queue_entry) if (unlikely(!segment_ptr.s.i)) cvmx_fpa_free(cvm_oct_get_buffer_ptr(segment_ptr), segment_ptr.s.pool, - DONT_WRITEBACK(CVMX_FPA_PACKET_POOL_SIZE / - 128)); + CVMX_FPA_PACKET_POOL_SIZE / 128); segment_ptr = next_ptr; } - cvmx_fpa_free(work, CVMX_FPA_WQE_POOL, DONT_WRITEBACK(1)); + cvmx_fpa_free(work, CVMX_FPA_WQE_POOL, 1); return 0; } From 948c251b70e7b6bbaaf8afa1f7e6049c61af7dc6 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sat, 4 Apr 2015 22:51:20 +0300 Subject: [PATCH 0085/1163] staging: octeon-ethernet: eliminate OCTEON_ETHERNET_VERSION This driver has drifted away from out-of-tree versions years ago and the version string does not provide any useful information. Instead provide the kernel version string to ethtool, so that we get useful version information e.g. for bug reports. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-defines.h | 3 --- drivers/staging/octeon/ethernet-mdio.c | 6 +++--- drivers/staging/octeon/ethernet.c | 1 - 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/octeon/ethernet-defines.h b/drivers/staging/octeon/ethernet-defines.h index 8a6f82fb3e2c..2c986236f5a3 100644 --- a/drivers/staging/octeon/ethernet-defines.h +++ b/drivers/staging/octeon/ethernet-defines.h @@ -43,9 +43,6 @@ #include - -#define OCTEON_ETHERNET_VERSION "1.9" - #ifdef CONFIG_NETFILTER #define REUSE_SKBUFFS_WITHOUT_FREE 0 #else diff --git a/drivers/staging/octeon/ethernet-mdio.c b/drivers/staging/octeon/ethernet-mdio.c index 6322d0dd4238..2286acac4951 100644 --- a/drivers/staging/octeon/ethernet-mdio.c +++ b/drivers/staging/octeon/ethernet-mdio.c @@ -29,7 +29,7 @@ #include #include #include - +#include #include #include @@ -45,8 +45,8 @@ static void cvm_oct_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { - strlcpy(info->driver, "cavium-ethernet", sizeof(info->driver)); - strlcpy(info->version, OCTEON_ETHERNET_VERSION, sizeof(info->version)); + strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver)); + strlcpy(info->version, UTS_RELEASE, sizeof(info->version)); strlcpy(info->bus_info, "Builtin", sizeof(info->bus_info)); } diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index d05bdca37278..b8cd450465a4 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c @@ -681,7 +681,6 @@ static int cvm_oct_probe(struct platform_device *pdev) struct device_node *pip; octeon_mdiobus_force_mod_depencency(); - pr_notice("cavium-ethernet %s\n", OCTEON_ETHERNET_VERSION); pip = pdev->dev.of_node; if (!pip) { From 67620987c556ee70034bd71703d61d07b4d96e60 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sat, 4 Apr 2015 22:51:21 +0300 Subject: [PATCH 0086/1163] staging: octeon-ethernet: update boilerplate comments Update boilerplate comments to be more terse by removing redundant information. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-defines.h | 23 +++------------------- drivers/staging/octeon/ethernet-mdio.c | 24 ++++------------------- drivers/staging/octeon/ethernet-mdio.h | 24 ++++------------------- drivers/staging/octeon/ethernet-mem.c | 24 ++++------------------- drivers/staging/octeon/ethernet-mem.h | 23 +++------------------- drivers/staging/octeon/ethernet-rgmii.c | 24 ++++------------------- drivers/staging/octeon/ethernet-rx.c | 24 ++++------------------- drivers/staging/octeon/ethernet-rx.h | 24 ++++------------------- drivers/staging/octeon/ethernet-sgmii.c | 24 ++++------------------- drivers/staging/octeon/ethernet-spi.c | 24 ++++------------------- drivers/staging/octeon/ethernet-tx.c | 24 ++++------------------- drivers/staging/octeon/ethernet-tx.h | 23 +++------------------- drivers/staging/octeon/ethernet-util.h | 23 +++------------------- drivers/staging/octeon/ethernet-xaui.c | 24 ++++------------------- drivers/staging/octeon/ethernet.c | 24 ++++------------------- drivers/staging/octeon/octeon-ethernet.h | 23 +++------------------- 16 files changed, 59 insertions(+), 320 deletions(-) diff --git a/drivers/staging/octeon/ethernet-defines.h b/drivers/staging/octeon/ethernet-defines.h index 2c986236f5a3..f92e0c478e16 100644 --- a/drivers/staging/octeon/ethernet-defines.h +++ b/drivers/staging/octeon/ethernet-defines.h @@ -1,29 +1,12 @@ -/********************************************************************** - * Author: Cavium Networks - * - * Contact: support@caviumnetworks.com - * This file is part of the OCTEON SDK +/* + * This file is based on code from OCTEON SDK by Cavium Networks. * * Copyright (c) 2003-2007 Cavium Networks * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, as * published by the Free Software Foundation. - * - * This file is distributed in the hope that it will be useful, but - * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or - * NONINFRINGEMENT. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this file; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * or visit http://www.gnu.org/licenses/. - * - * This file may also be available under a different license from Cavium. - * Contact Cavium Networks for more information -**********************************************************************/ + */ /* * A few defines are used to control the operation of this driver: diff --git a/drivers/staging/octeon/ethernet-mdio.c b/drivers/staging/octeon/ethernet-mdio.c index 2286acac4951..fd9b3d899c1f 100644 --- a/drivers/staging/octeon/ethernet-mdio.c +++ b/drivers/staging/octeon/ethernet-mdio.c @@ -1,29 +1,13 @@ -/********************************************************************** - * Author: Cavium Networks - * - * Contact: support@caviumnetworks.com - * This file is part of the OCTEON SDK +/* + * This file is based on code from OCTEON SDK by Cavium Networks. * * Copyright (c) 2003-2007 Cavium Networks * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, as * published by the Free Software Foundation. - * - * This file is distributed in the hope that it will be useful, but - * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or - * NONINFRINGEMENT. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this file; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * or visit http://www.gnu.org/licenses/. - * - * This file may also be available under a different license from Cavium. - * Contact Cavium Networks for more information -**********************************************************************/ + */ + #include #include #include diff --git a/drivers/staging/octeon/ethernet-mdio.h b/drivers/staging/octeon/ethernet-mdio.h index 6191b0850646..a530b55f27d8 100644 --- a/drivers/staging/octeon/ethernet-mdio.h +++ b/drivers/staging/octeon/ethernet-mdio.h @@ -1,29 +1,13 @@ -/********************************************************************* - * Author: Cavium Networks - * - * Contact: support@caviumnetworks.com - * This file is part of the OCTEON SDK +/* + * This file is based on code from OCTEON SDK by Cavium Networks. * * Copyright (c) 2003-2007 Cavium Networks * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, as * published by the Free Software Foundation. - * - * This file is distributed in the hope that it will be useful, but - * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or - * NONINFRINGEMENT. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this file; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * or visit http://www.gnu.org/licenses/. - * - * This file may also be available under a different license from Cavium. - * Contact Cavium Networks for more information -*********************************************************************/ + */ + #include #include #include diff --git a/drivers/staging/octeon/ethernet-mem.c b/drivers/staging/octeon/ethernet-mem.c index 55d921917125..5a5cdb3cd740 100644 --- a/drivers/staging/octeon/ethernet-mem.c +++ b/drivers/staging/octeon/ethernet-mem.c @@ -1,29 +1,13 @@ -/********************************************************************** - * Author: Cavium Networks - * - * Contact: support@caviumnetworks.com - * This file is part of the OCTEON SDK +/* + * This file is based on code from OCTEON SDK by Cavium Networks. * * Copyright (c) 2003-2010 Cavium Networks * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, as * published by the Free Software Foundation. - * - * This file is distributed in the hope that it will be useful, but - * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or - * NONINFRINGEMENT. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this file; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * or visit http://www.gnu.org/licenses/. - * - * This file may also be available under a different license from Cavium. - * Contact Cavium Networks for more information -**********************************************************************/ + */ + #include #include #include diff --git a/drivers/staging/octeon/ethernet-mem.h b/drivers/staging/octeon/ethernet-mem.h index 713f2edc8b4f..62d07c426f89 100644 --- a/drivers/staging/octeon/ethernet-mem.h +++ b/drivers/staging/octeon/ethernet-mem.h @@ -1,29 +1,12 @@ -/********************************************************************* - * Author: Cavium Networks - * - * Contact: support@caviumnetworks.com - * This file is part of the OCTEON SDK +/* + * This file is based on code from OCTEON SDK by Cavium Networks. * * Copyright (c) 2003-2007 Cavium Networks * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, as * published by the Free Software Foundation. - * - * This file is distributed in the hope that it will be useful, but - * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or - * NONINFRINGEMENT. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this file; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * or visit http://www.gnu.org/licenses/. - * - * This file may also be available under a different license from Cavium. - * Contact Cavium Networks for more information -********************************************************************/ + */ int cvm_oct_mem_fill_fpa(int pool, int size, int elements); void cvm_oct_mem_empty_fpa(int pool, int size, int elements); diff --git a/drivers/staging/octeon/ethernet-rgmii.c b/drivers/staging/octeon/ethernet-rgmii.c index ad332c3e1546..beb7aac9c289 100644 --- a/drivers/staging/octeon/ethernet-rgmii.c +++ b/drivers/staging/octeon/ethernet-rgmii.c @@ -1,29 +1,13 @@ -/********************************************************************* - * Author: Cavium Networks - * - * Contact: support@caviumnetworks.com - * This file is part of the OCTEON SDK +/* + * This file is based on code from OCTEON SDK by Cavium Networks. * * Copyright (c) 2003-2007 Cavium Networks * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, as * published by the Free Software Foundation. - * - * This file is distributed in the hope that it will be useful, but - * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or - * NONINFRINGEMENT. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this file; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * or visit http://www.gnu.org/licenses/. - * - * This file may also be available under a different license from Cavium. - * Contact Cavium Networks for more information -**********************************************************************/ + */ + #include #include #include diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c index fbf5f946036a..22853d33da05 100644 --- a/drivers/staging/octeon/ethernet-rx.c +++ b/drivers/staging/octeon/ethernet-rx.c @@ -1,29 +1,13 @@ -/********************************************************************** - * Author: Cavium Networks - * - * Contact: support@caviumnetworks.com - * This file is part of the OCTEON SDK +/* + * This file is based on code from OCTEON SDK by Cavium Networks. * * Copyright (c) 2003-2010 Cavium Networks * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, as * published by the Free Software Foundation. - * - * This file is distributed in the hope that it will be useful, but - * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or - * NONINFRINGEMENT. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this file; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * or visit http://www.gnu.org/licenses/. - * - * This file may also be available under a different license from Cavium. - * Contact Cavium Networks for more information -**********************************************************************/ + */ + #include #include #include diff --git a/drivers/staging/octeon/ethernet-rx.h b/drivers/staging/octeon/ethernet-rx.h index 9240c85ce241..a5973fd015fc 100644 --- a/drivers/staging/octeon/ethernet-rx.h +++ b/drivers/staging/octeon/ethernet-rx.h @@ -1,29 +1,13 @@ -/********************************************************************* - * Author: Cavium Networks - * - * Contact: support@caviumnetworks.com - * This file is part of the OCTEON SDK +/* + * This file is based on code from OCTEON SDK by Cavium Networks. * * Copyright (c) 2003-2007 Cavium Networks * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, as * published by the Free Software Foundation. - * - * This file is distributed in the hope that it will be useful, but - * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or - * NONINFRINGEMENT. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this file; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * or visit http://www.gnu.org/licenses/. - * - * This file may also be available under a different license from Cavium. - * Contact Cavium Networks for more information -*********************************************************************/ + */ + #include void cvm_oct_poll_controller(struct net_device *dev); diff --git a/drivers/staging/octeon/ethernet-sgmii.c b/drivers/staging/octeon/ethernet-sgmii.c index 1940f4b72a66..8bceb769166c 100644 --- a/drivers/staging/octeon/ethernet-sgmii.c +++ b/drivers/staging/octeon/ethernet-sgmii.c @@ -1,29 +1,13 @@ -/********************************************************************** - * Author: Cavium Networks - * - * Contact: support@caviumnetworks.com - * This file is part of the OCTEON SDK +/* + * This file is based on code from OCTEON SDK by Cavium Networks. * * Copyright (c) 2003-2007 Cavium Networks * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, as * published by the Free Software Foundation. - * - * This file is distributed in the hope that it will be useful, but - * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or - * NONINFRINGEMENT. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this file; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * or visit http://www.gnu.org/licenses/. - * - * This file may also be available under a different license from Cavium. - * Contact Cavium Networks for more information -**********************************************************************/ + */ + #include #include #include diff --git a/drivers/staging/octeon/ethernet-spi.c b/drivers/staging/octeon/ethernet-spi.c index 5313ac54d863..2ae1944b3a1b 100644 --- a/drivers/staging/octeon/ethernet-spi.c +++ b/drivers/staging/octeon/ethernet-spi.c @@ -1,29 +1,13 @@ -/********************************************************************** - * Author: Cavium Networks - * - * Contact: support@caviumnetworks.com - * This file is part of the OCTEON SDK +/* + * This file is based on code from OCTEON SDK by Cavium Networks. * * Copyright (c) 2003-2007 Cavium Networks * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, as * published by the Free Software Foundation. - * - * This file is distributed in the hope that it will be useful, but - * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or - * NONINFRINGEMENT. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this file; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * or visit http://www.gnu.org/licenses/. - * - * This file may also be available under a different license from Cavium. - * Contact Cavium Networks for more information -**********************************************************************/ + */ + #include #include #include diff --git a/drivers/staging/octeon/ethernet-tx.c b/drivers/staging/octeon/ethernet-tx.c index 25f89b6229b0..7c1c1b052b7d 100644 --- a/drivers/staging/octeon/ethernet-tx.c +++ b/drivers/staging/octeon/ethernet-tx.c @@ -1,29 +1,13 @@ -/********************************************************************* - * Author: Cavium Networks - * - * Contact: support@caviumnetworks.com - * This file is part of the OCTEON SDK +/* + * This file is based on code from OCTEON SDK by Cavium Networks. * * Copyright (c) 2003-2010 Cavium Networks * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, as * published by the Free Software Foundation. - * - * This file is distributed in the hope that it will be useful, but - * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or - * NONINFRINGEMENT. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this file; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * or visit http://www.gnu.org/licenses/. - * - * This file may also be available under a different license from Cavium. - * Contact Cavium Networks for more information -*********************************************************************/ + */ + #include #include #include diff --git a/drivers/staging/octeon/ethernet-tx.h b/drivers/staging/octeon/ethernet-tx.h index 547680c6c371..84848e4c1664 100644 --- a/drivers/staging/octeon/ethernet-tx.h +++ b/drivers/staging/octeon/ethernet-tx.h @@ -1,29 +1,12 @@ -/********************************************************************* - * Author: Cavium Networks - * - * Contact: support@caviumnetworks.com - * This file is part of the OCTEON SDK +/* + * This file is based on code from OCTEON SDK by Cavium Networks. * * Copyright (c) 2003-2007 Cavium Networks * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, as * published by the Free Software Foundation. - * - * This file is distributed in the hope that it will be useful, but - * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or - * NONINFRINGEMENT. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this file; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * or visit http://www.gnu.org/licenses/. - * - * This file may also be available under a different license from Cavium. - * Contact Cavium Networks for more information -*********************************************************************/ + */ int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev); int cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device *dev); diff --git a/drivers/staging/octeon/ethernet-util.h b/drivers/staging/octeon/ethernet-util.h index 0f9b4a18fc27..1ba789a7741b 100644 --- a/drivers/staging/octeon/ethernet-util.h +++ b/drivers/staging/octeon/ethernet-util.h @@ -1,29 +1,12 @@ -/********************************************************************** - * Author: Cavium Networks - * - * Contact: support@caviumnetworks.com - * This file is part of the OCTEON SDK +/* + * This file is based on code from OCTEON SDK by Cavium Networks. * * Copyright (c) 2003-2007 Cavium Networks * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, as * published by the Free Software Foundation. - * - * This file is distributed in the hope that it will be useful, but - * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or - * NONINFRINGEMENT. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this file; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * or visit http://www.gnu.org/licenses/. - * - * This file may also be available under a different license from Cavium. - * Contact Cavium Networks for more information -*********************************************************************/ + */ /** * cvm_oct_get_buffer_ptr - convert packet data address to pointer diff --git a/drivers/staging/octeon/ethernet-xaui.c b/drivers/staging/octeon/ethernet-xaui.c index 42a4d2be0cff..4b47bcfaabb1 100644 --- a/drivers/staging/octeon/ethernet-xaui.c +++ b/drivers/staging/octeon/ethernet-xaui.c @@ -1,29 +1,13 @@ -/********************************************************************** - * Author: Cavium Networks - * - * Contact: support@caviumnetworks.com - * This file is part of the OCTEON SDK +/* + * This file is based on code from OCTEON SDK by Cavium Networks. * * Copyright (c) 2003-2007 Cavium Networks * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, as * published by the Free Software Foundation. - * - * This file is distributed in the hope that it will be useful, but - * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or - * NONINFRINGEMENT. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this file; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * or visit http://www.gnu.org/licenses/. - * - * This file may also be available under a different license from Cavium. - * Contact Cavium Networks for more information -**********************************************************************/ + */ + #include #include #include diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index b8cd450465a4..f9dba23a3759 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c @@ -1,29 +1,13 @@ -/********************************************************************** - * Author: Cavium Networks - * - * Contact: support@caviumnetworks.com - * This file is part of the OCTEON SDK +/* + * This file is based on code from OCTEON SDK by Cavium Networks. * * Copyright (c) 2003-2007 Cavium Networks * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, as * published by the Free Software Foundation. - * - * This file is distributed in the hope that it will be useful, but - * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or - * NONINFRINGEMENT. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this file; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * or visit http://www.gnu.org/licenses/. - * - * This file may also be available under a different license from Cavium. - * Contact Cavium Networks for more information -**********************************************************************/ + */ + #include #include #include diff --git a/drivers/staging/octeon/octeon-ethernet.h b/drivers/staging/octeon/octeon-ethernet.h index 22d726e0d2d0..e9d3e9a7e8a7 100644 --- a/drivers/staging/octeon/octeon-ethernet.h +++ b/drivers/staging/octeon/octeon-ethernet.h @@ -1,29 +1,12 @@ -/********************************************************************** - * Author: Cavium Networks - * - * Contact: support@caviumnetworks.com - * This file is part of the OCTEON SDK +/* + * This file is based on code from OCTEON SDK by Cavium Networks. * * Copyright (c) 2003-2010 Cavium Networks * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, as * published by the Free Software Foundation. - * - * This file is distributed in the hope that it will be useful, but - * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or - * NONINFRINGEMENT. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this file; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * or visit http://www.gnu.org/licenses/. - * - * This file may also be available under a different license from Cavium. - * Contact Cavium Networks for more information -**********************************************************************/ + */ /* * External interface for the Cavium Octeon ethernet driver. From 9059c615a8ba503cb5a7823d7f943a384e6063e3 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Tue, 7 Apr 2015 13:55:01 +0530 Subject: [PATCH 0087/1163] staging: panel: remove duplicate code both the misc_deregister(), parport_release() and parport_unregister_device() is there in the module_exit function also. detach is called from parport_unregister_driver() and by the time detach executes misc_deregister(), parport_release() and parport_unregister_device() has already executed marking keypad_initialized and lcd.initialized as false. so this part of the code will never execute. Signed-off-by: Sudip Mukherjee Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index ea54fb4ec837..1d8ed8b35375 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -2252,20 +2252,6 @@ static void panel_detach(struct parport *port) } unregister_reboot_notifier(&panel_notifier); - - if (keypad.enabled && keypad_initialized) { - misc_deregister(&keypad_dev); - keypad_initialized = 0; - } - - if (lcd.enabled && lcd.initialized) { - misc_deregister(&lcd_dev); - lcd.initialized = false; - } - - parport_release(pprt); - parport_unregister_device(pprt); - pprt = NULL; } static struct parport_driver panel_driver = { From 351f6689cc2941f4e1ec588b8b4673457acf2e58 Mon Sep 17 00:00:00 2001 From: Andrei Maresu Date: Thu, 9 Apr 2015 23:29:31 +0300 Subject: [PATCH 0088/1163] Staging: comedi: daqboard2000.c fixed trailing whitespace Fixed a coding style issue. Signed-off-by: Andrei Maresu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/daqboard2000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index f97d18d92255..64a87039b802 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -40,7 +40,7 @@ Configuration options: not applicable, uses PCI auto config for the card, and here are the findings so far. 1. A good document that describes the PCI interface chip is 9080db-106.pdf - available from http://www.plxtech.com/products/io/pci9080 + available from http://www.plxtech.com/products/io/pci9080 2. The initialization done so far is: a. program the FPGA (windows code sans a lot of error messages) From b3ab6fbfd8625232c54d70e29f7274118726ba45 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Apr 2015 11:49:04 -0700 Subject: [PATCH 0089/1163] staging: comedi: comedi_bond: fix 'b_mask' calc in bonding_dio_insn_bits() 'b_chans' may be a valud up to 32. 'b_mask' is an unsigned int and a left shift of more than 31 bits has undefined behavior. Fix the calc so it works correctly with a 'b_chans' of 32.. Reported-by: coverity (CID 1192244) Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_bond.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 96db0c2686a1..50b76eccb7d7 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -101,7 +101,8 @@ static int bonding_dio_insn_bits(struct comedi_device *dev, b_chans = bdev->nchans - base_chan; if (b_chans > n_left) b_chans = n_left; - b_mask = (1U << b_chans) - 1; + b_mask = (b_chans < 32) ? ((1 << b_chans) - 1) + : 0xffffffff; b_write_mask = (write_mask >> n_done) & b_mask; b_data_bits = (data_bits >> n_done) & b_mask; /* Read/Write the new digital lines. */ From accb298fb2e3d09a84bd92595b115232f14a5e60 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Apr 2015 11:49:05 -0700 Subject: [PATCH 0090/1163] staging: comedi: ni_nio_common: don't write non-existing caldac's ni_write_caldac() checks the boardinfo 'caldac' array to determine what caldac is used for a given 'addr'. It then calculates the 'bitstring' and number of 'bits' used to write a value to that caldac address. After checking the caldac array, if the number of bits is 0 there is no caldac associated with the address. If this happens we shouldn't try writing to the non-existing caldac. Reported-by: coverity (CID 1192116) Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index c66affd993aa..69d71f328006 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -4355,6 +4355,10 @@ static void ni_write_caldac(struct comedi_device *dev, int addr, int val) addr -= caldacs[type].n_chans; } + /* bits will be 0 if there is no caldac for the given addr */ + if (bits == 0) + return; + for (bit = 1 << (bits - 1); bit; bit >>= 1) { ni_writeb(dev, ((bit & bitstring) ? 0x02 : 0), Serial_Command); udelay(1); From a437dee5335e3b5fdb82199f11eebf3f41bf5b8e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Apr 2015 11:49:06 -0700 Subject: [PATCH 0091/1163] staging: comedi: serial2002: fix Coverity "Explicit null dereference" serial2002_setup_subdevices() initializes each subdevice based on the config read from the attached serial device. Part of this initialization is to setup the subdevice range_table_list for the non digital subdevices. The range_table_list is allocated only when a 'range' is passed to the functions. Each channel of the subdevice then has it's 'range' initialized and that range is added to the range_table_list. The logic of this function works but causes Coverity complain about an Explicit null dereference of the allocated 'range_table_list'. Add a check for the 'range_table_list' to quiet the Coverity issue. Reported-by: coverity (CID 1011632) Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/serial2002.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c index 304ebff119ee..83da162deb52 100644 --- a/drivers/staging/comedi/drivers/serial2002.c +++ b/drivers/staging/comedi/drivers/serial2002.c @@ -373,7 +373,7 @@ static int serial2002_setup_subdevice(struct comedi_subdevice *s, if (cfg[j].kind == kind) { if (mapping) mapping[chan] = j; - if (range) { + if (range && range_table_list) { range[j].length = 1; range[j].range.min = cfg[j].min; range[j].range.max = cfg[j].max; From 8fc369ae38ff281d38e9ea11805a5cae862989bc Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 21 Apr 2015 13:18:10 +0100 Subject: [PATCH 0092/1163] staging: comedi: wrap COMEDI_SRF_FREE_SPRIV usage The `COMEDI_SRF_FREE_SPRIV` flag in the `runflags` member of `struct comedi_subdevice` indicates that the memory pointed to by the `private` member can be automatically freed by the comedi core on subdevice clean-up (when the low-level comedi device is being "detached"). the flag doesn't really belong in `runflags`, but it was somewhere convenient to keep it without having to add a new member to the structure. Rather than access the `COMEDI_SRF_FREE_SPRIV` flag directly, use some new wrapper functions: * comedi_can_auto_free_spriv(s) - checks whether the subdevice's `s->private` points to memory that can be freed automatically. * comedi_set_spriv_auto_free(s) - marks the subdevice as having a `s->private` that points to memory that can be freed automatically. Export `comedi_set_spriv_auto_free()` for use by the low-level comedi driver modules, in particular the "amplc_dio200_common" module. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 24 +++++++++++++++++-- drivers/staging/comedi/comedi_internal.h | 1 + drivers/staging/comedi/comedidev.h | 1 + drivers/staging/comedi/drivers.c | 2 +- .../comedi/drivers/amplc_dio200_common.c | 6 ++--- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index e78ddbe5a954..fc339c5c50fc 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -679,8 +679,28 @@ static bool comedi_is_subdevice_idle(struct comedi_subdevice *s) return !(runflags & COMEDI_SRF_BUSY_MASK); } +bool comedi_can_auto_free_spriv(struct comedi_subdevice *s) +{ + unsigned runflags = __comedi_get_subdevice_runflags(s); + + return runflags & COMEDI_SRF_FREE_SPRIV; +} + /** - * comedi_alloc_spriv() - Allocate memory for the subdevice private data. + * comedi_set_spriv_auto_free - mark subdevice private data as freeable + * @s: comedi_subdevice struct + * + * Mark the subdevice as having a pointer to private data that can be + * automatically freed by the comedi core during the detach. + */ +void comedi_set_spriv_auto_free(struct comedi_subdevice *s) +{ + __comedi_set_subdevice_runflags(s, COMEDI_SRF_FREE_SPRIV); +} +EXPORT_SYMBOL_GPL(comedi_set_spriv_auto_free); + +/** + * comedi_alloc_spriv - Allocate memory for the subdevice private data. * @s: comedi_subdevice struct * @size: size of the memory to allocate * @@ -691,7 +711,7 @@ void *comedi_alloc_spriv(struct comedi_subdevice *s, size_t size) { s->private = kzalloc(size, GFP_KERNEL); if (s->private) - s->runflags |= COMEDI_SRF_FREE_SPRIV; + comedi_set_spriv_auto_free(s); return s->private; } EXPORT_SYMBOL_GPL(comedi_alloc_spriv); diff --git a/drivers/staging/comedi/comedi_internal.h b/drivers/staging/comedi/comedi_internal.h index 3b918538847e..cd9437f72c35 100644 --- a/drivers/staging/comedi/comedi_internal.h +++ b/drivers/staging/comedi/comedi_internal.h @@ -33,6 +33,7 @@ struct comedi_buf_map *comedi_buf_map_from_subdev_get( struct comedi_subdevice *s); unsigned int comedi_buf_write_n_allocated(struct comedi_subdevice *s); void comedi_device_cancel_all(struct comedi_device *dev); +bool comedi_can_auto_free_spriv(struct comedi_subdevice *s); extern unsigned int comedi_default_buf_size_kb; extern unsigned int comedi_default_buf_maxsize_kb; diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index dfab5a84b011..52071f7494c4 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -323,6 +323,7 @@ int comedi_dev_put(struct comedi_device *dev); bool comedi_is_subdevice_running(struct comedi_subdevice *s); void *comedi_alloc_spriv(struct comedi_subdevice *s, size_t size); +void comedi_set_spriv_auto_free(struct comedi_subdevice *s); int comedi_check_chanlist(struct comedi_subdevice *s, int n, diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 57dcffe00204..ed0b60c925de 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -125,7 +125,7 @@ static void comedi_device_detach_cleanup(struct comedi_device *dev) if (dev->subdevices) { for (i = 0; i < dev->n_subdevices; i++) { s = &dev->subdevices[i]; - if (s->runflags & COMEDI_SRF_FREE_SPRIV) + if (comedi_can_auto_free_spriv(s)) kfree(s->private); comedi_free_subdevice_minor(s); if (s->async) { diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index d15a3dc1216a..3a8b3f27b525 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -593,10 +593,10 @@ static int dio200_subdev_8254_init(struct comedi_device *dev, * There could be multiple timers so this driver does not * use dev->pacer to save the i8254 pointer. Instead, * comedi_8254_subdevice_init() saved the i8254 pointer in - * s->private. Set the runflag bit so that the core will - * automatically free it when the driver is detached. + * s->private. Mark the subdevice as having private data + * to be automatically freed when the device is detached. */ - s->runflags |= COMEDI_SRF_FREE_SPRIV; + comedi_set_spriv_auto_free(s); /* Initialize channels. */ if (board->has_clk_gat_sce) { From eb340acaca5eea5f87a4a1b037a32e257d8509b5 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 21 Apr 2015 13:18:11 +0100 Subject: [PATCH 0093/1163] staging: comedi: move COMEDI_SRF_... macros to "comedi_fops.c" The `COMEDI_SRF_...` macros define flag combinations in the `runflags` member of `struct comedi_subdevice`. They are only used directly in "comedi_fops.c", so move them to there. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 17 +++++++++++++++++ drivers/staging/comedi/comedidev.h | 17 ----------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index fc339c5c50fc..6f269cc35633 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -43,6 +43,23 @@ #include "comedi_internal.h" +/** + * comedi_subdevice "runflags" + * @COMEDI_SRF_RT: DEPRECATED: command is running real-time + * @COMEDI_SRF_ERROR: indicates an COMEDI_CB_ERROR event has occurred + * since the last command was started + * @COMEDI_SRF_RUNNING: command is running + * @COMEDI_SRF_FREE_SPRIV: free s->private on detach + * + * @COMEDI_SRF_BUSY_MASK: runflags that indicate the subdevice is "busy" + */ +#define COMEDI_SRF_RT BIT(1) +#define COMEDI_SRF_ERROR BIT(2) +#define COMEDI_SRF_RUNNING BIT(27) +#define COMEDI_SRF_FREE_SPRIV BIT(31) + +#define COMEDI_SRF_BUSY_MASK (COMEDI_SRF_ERROR | COMEDI_SRF_RUNNING) + /** * struct comedi_file - per-file private data for comedi device * @dev: comedi_device struct diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 52071f7494c4..28f26062a54c 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -303,23 +303,6 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s); struct comedi_device *comedi_dev_get_from_minor(unsigned minor); int comedi_dev_put(struct comedi_device *dev); -/** - * comedi_subdevice "runflags" - * @COMEDI_SRF_RT: DEPRECATED: command is running real-time - * @COMEDI_SRF_ERROR: indicates an COMEDI_CB_ERROR event has occurred - * since the last command was started - * @COMEDI_SRF_RUNNING: command is running - * @COMEDI_SRF_FREE_SPRIV: free s->private on detach - * - * @COMEDI_SRF_BUSY_MASK: runflags that indicate the subdevice is "busy" - */ -#define COMEDI_SRF_RT BIT(1) -#define COMEDI_SRF_ERROR BIT(2) -#define COMEDI_SRF_RUNNING BIT(27) -#define COMEDI_SRF_FREE_SPRIV BIT(31) - -#define COMEDI_SRF_BUSY_MASK (COMEDI_SRF_ERROR | COMEDI_SRF_RUNNING) - bool comedi_is_subdevice_running(struct comedi_subdevice *s); void *comedi_alloc_spriv(struct comedi_subdevice *s, size_t size); From e6f2804d580667515cee34812aa92e84cc142e55 Mon Sep 17 00:00:00 2001 From: "Gujulan Elango, Hari Prasath (H.)" Date: Thu, 23 Apr 2015 19:14:21 +0000 Subject: [PATCH 0094/1163] staging: comedi: Remove unwanted lines of code This patch removes a few lines of code & retains the same functionality Signed-off-by: Hari Prasath Gujulan Elango Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcimdda.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcimdda.c b/drivers/staging/comedi/drivers/cb_pcimdda.c index a4781dbbdd82..19210d89f2b2 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdda.c +++ b/drivers/staging/comedi/drivers/cb_pcimdda.c @@ -164,11 +164,7 @@ static int cb_pcimdda_auto_attach(struct comedi_device *dev, s = &dev->subdevices[1]; /* digital i/o subdevice */ - ret = subdev_8255_init(dev, s, NULL, PCIMDDA_8255_BASE_REG); - if (ret) - return ret; - - return 0; + return subdev_8255_init(dev, s, NULL, PCIMDDA_8255_BASE_REG); } static struct comedi_driver cb_pcimdda_driver = { From f17ca811835cf69e734ab189a942964c2f32006d Mon Sep 17 00:00:00 2001 From: Gbenga Adalumo Date: Wed, 22 Apr 2015 00:39:48 -0700 Subject: [PATCH 0095/1163] Staging: comedi: fix code indent coding style issues in daqboard2000.c This is a patch to daqboard2000.c file that fixes code indent errors found by the checkpatch.pl tool Signed-off-by: Gbenga Adalumo Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/daqboard2000.c | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index 64a87039b802..2ca8d3eec742 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -43,7 +43,7 @@ Configuration options: not applicable, uses PCI auto config available from http://www.plxtech.com/products/io/pci9080 2. The initialization done so far is: - a. program the FPGA (windows code sans a lot of error messages) + a. program the FPGA (windows code sans a lot of error messages) b. 3. Analog out seems to work OK with DAC's disabled, if DAC's are enabled, @@ -52,52 +52,52 @@ Configuration options: not applicable, uses PCI auto config gives me no clues. I'll keep it simple so far. 4. Analog in. - Each channel in the scanlist seems to be controlled by four + Each channel in the scanlist seems to be controlled by four control words: - Word0: - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - ! | | | ! | | | ! | | | ! | | | ! - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + Word0: + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + ! | | | ! | | | ! | | | ! | | | ! + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - Word1: - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - ! | | | ! | | | ! | | | ! | | | ! - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + Word1: + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + ! | | | ! | | | ! | | | ! | | | ! + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | | | | | - +------+------+ | | | | +-- Digital input (??) + +------+------+ | | | | +-- Digital input (??) | | | | +---- 10 us settling time | | | +------ Suspend acquisition (last to scan) | | +-------- Simultaneous sample and hold | +---------- Signed data format +------------------------- Correction offset low - Word2: - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - ! | | | ! | | | ! | | | ! | | | ! - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | | | | | | | | | | - +-----+ +--+--+ +++ +++ +--+--+ - | | | | +----- Expansion channel + Word2: + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + ! | | | ! | | | ! | | | ! | | | ! + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | | | | | | | | | + +-----+ +--+--+ +++ +++ +--+--+ + | | | | +----- Expansion channel | | | +----------- Expansion gain - | | +--------------- Channel (low) + | | +--------------- Channel (low) | +--------------------- Correction offset high +----------------------------- Correction gain low - Word3: - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - ! | | | ! | | | ! | | | ! | | | ! - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | | | | | | | | | - +------+------+ | | +-+-+ | | +-- Low bank enable - | | | | | +---- High bank enable - | | | | +------ Hi/low select + Word3: + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + ! | | | ! | | | ! | | | ! | | | ! + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | | | | | | | | + +------+------+ | | +-+-+ | | +-- Low bank enable + | | | | | +---- High bank enable + | | | | +------ Hi/low select | | | +---------- Gain (1,?,2,4,8,16,32,64) | | +-------------- differential/single ended | +---------------- Unipolar +------------------------- Correction gain high 999. The card seems to have an incredible amount of capabilities, but - trying to reverse engineer them from the Windows source is beyond my + trying to reverse engineer them from the Windows source is beyond my patience. */ From c93f5463e35a95c8cad5deb4ad5d32b0eb913abd Mon Sep 17 00:00:00 2001 From: kbuild test robot Date: Fri, 1 May 2015 00:27:35 +0800 Subject: [PATCH 0096/1163] staging: lustre: fix ifnullfree.cocci warnings drivers/staging/lustre/lustre/lov/lov_obd.c:574:3-8: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values. NULL check before some freeing functions is not needed. Based on checkpatch warning "kfree(NULL) is safe this check is probably not required" and kfreeaddr.cocci by Julia Lawall. Generated by: scripts/coccinelle/free/ifnullfree.cocci CC: Julia Lawall Signed-off-by: Fengguang Wu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lov/lov_obd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 7e1253809708..054ca32099c8 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -570,8 +570,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, lov->lov_tgts = newtgts; lov->lov_tgt_size = newsize; smp_rmb(); - if (old) - kfree(old); + kfree(old); CDEBUG(D_CONFIG, "tgts: %p size: %d\n", lov->lov_tgts, lov->lov_tgt_size); From 25e428999c0de31f966e9e4b61ec69d8dc033f70 Mon Sep 17 00:00:00 2001 From: kbuild test robot Date: Fri, 1 May 2015 00:27:35 +0800 Subject: [PATCH 0097/1163] staging: lustre: fix ifnullfree.cocci warnings drivers/staging/lustre/lustre/lov/lov_request.c:74:3-8: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values. NULL check before some freeing functions is not needed. Based on checkpatch warning "kfree(NULL) is safe this check is probably not required" and kfreeaddr.cocci by Julia Lawall. Generated by: scripts/coccinelle/free/ifnullfree.cocci CC: Julia Lawall Signed-off-by: Fengguang Wu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lov/lov_request.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index 0a8cdbe1a537..f6e13149d2ad 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -70,8 +70,7 @@ void lov_finish_set(struct lov_request_set *set) OBDO_FREE(req->rq_oi.oi_oa); if (req->rq_oi.oi_md) OBD_FREE_LARGE(req->rq_oi.oi_md, req->rq_buflen); - if (req->rq_oi.oi_osfs) - kfree(req->rq_oi.oi_osfs); + kfree(req->rq_oi.oi_osfs); kfree(req); } From 0550db925bf79707b5612c2769075f3fac713c3a Mon Sep 17 00:00:00 2001 From: kbuild test robot Date: Fri, 1 May 2015 00:21:55 +0800 Subject: [PATCH 0098/1163] staging: lustre: llite: fix ifnullfree.cocci warnings drivers/staging/lustre/lustre/llite/llite_lib.c:989:2-7: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values. drivers/staging/lustre/lustre/llite/llite_lib.c:991:2-7: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values. NULL check before some freeing functions is not needed. Based on checkpatch warning "kfree(NULL) is safe this check is probably not required" and kfreeaddr.cocci by Julia Lawall. Generated by: scripts/coccinelle/free/ifnullfree.cocci CC: Julia Lawall Signed-off-by: Fengguang Wu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_lib.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index f44abb661404..e5bac94f690b 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -985,10 +985,8 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) err = client_common_fill_super(sb, md, dt, mnt); out_free: - if (md) - kfree(md); - if (dt) - kfree(dt); + kfree(md); + kfree(dt); if (err) ll_put_super(sb); else if (sbi->ll_flags & LL_SBI_VERBOSE) From fd5e2fd053e1042b12343fb6649449081ec1bab4 Mon Sep 17 00:00:00 2001 From: kbuild test robot Date: Fri, 1 May 2015 00:21:55 +0800 Subject: [PATCH 0099/1163] staging: lustre: llite: fix ifnullfree.cocci warnings drivers/staging/lustre/lustre/llite/dir.c:1440:3-8: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values. NULL check before some freeing functions is not needed. Based on checkpatch warning "kfree(NULL) is safe this check is probably not required" and kfreeaddr.cocci by Julia Lawall. Generated by: scripts/coccinelle/free/ifnullfree.cocci CC: Julia Lawall Signed-off-by: Fengguang Wu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dir.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 0f5d57cb149a..f17154aaa329 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -1436,8 +1436,7 @@ lmv_out_free: goto free_lmv; } free_lmv: - if (tmp) - kfree(tmp); + kfree(tmp); return rc; } case LL_IOC_REMOVE_ENTRY: { From 6920ccf65d0964f7f6c6c36c551151e0fcd62327 Mon Sep 17 00:00:00 2001 From: Roberta Dobrescu Date: Thu, 16 Apr 2015 22:20:59 +0300 Subject: [PATCH 0100/1163] staging: iio: light: isl29018: Use standard sysfs attributes for scale and integration time This patch refactors the isl29018 driver code in order to use standard sysfs attributes for scale and integration time. ISL29018 light sensor uses four ranges and four ADC's resolutions which influence the calculated lux. Adc resolution is strongly connected to integration time and range should be controlled by scale. This patch introduces the usage of integration time and scale instead of adc resolution and range. Signed-off-by: Roberta Dobrescu Signed-off-by: Jonathan Cameron --- drivers/staging/iio/light/isl29018.c | 224 +++++++++++++++++++++------ 1 file changed, 176 insertions(+), 48 deletions(-) diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c index ffc3d1b2ee9a..08ca9a4172e3 100644 --- a/drivers/staging/iio/light/isl29018.c +++ b/drivers/staging/iio/light/isl29018.c @@ -66,6 +66,39 @@ #define ISL29035_BOUT_SHIFT 0x07 #define ISL29035_BOUT_MASK (0x01 << ISL29035_BOUT_SHIFT) +#define ISL29018_INT_TIME_AVAIL "0.090000 0.005630 0.000351 0.000021" +#define ISL29023_INT_TIME_AVAIL "0.090000 0.005600 0.000352 0.000022" +#define ISL29035_INT_TIME_AVAIL "0.105000 0.006500 0.000410 0.000025" + +static const char * const int_time_avail[] = { + ISL29018_INT_TIME_AVAIL, + ISL29023_INT_TIME_AVAIL, + ISL29035_INT_TIME_AVAIL, +}; + +enum isl29018_int_time { + ISL29018_INT_TIME_16, + ISL29018_INT_TIME_12, + ISL29018_INT_TIME_8, + ISL29018_INT_TIME_4, +}; + +static const unsigned int isl29018_int_utimes[3][4] = { + {90000, 5630, 351, 21}, + {90000, 5600, 352, 22}, + {105000, 6500, 410, 25}, +}; + +static const struct isl29018_scale { + unsigned int scale; + unsigned int uscale; +} isl29018_scales[4][4] = { + { {0, 15258}, {0, 61035}, {0, 244140}, {0, 976562} }, + { {0, 244140}, {0, 976562}, {3, 906250}, {15, 625000} }, + { {3, 906250}, {15, 625000}, {62, 500000}, {250, 0} }, + { {62, 500000}, {250, 0}, {1000, 0}, {4000, 0} } +}; + struct isl29018_chip { struct device *dev; struct regmap *regmap; @@ -73,51 +106,75 @@ struct isl29018_chip { int type; unsigned int calibscale; unsigned int ucalibscale; - unsigned int range; - unsigned int adc_bit; + unsigned int int_time; + struct isl29018_scale scale; int prox_scheme; bool suspended; }; -static int isl29018_set_range(struct isl29018_chip *chip, unsigned long range, - unsigned int *new_range) +static int isl29018_set_integration_time(struct isl29018_chip *chip, + unsigned int utime) { - static const unsigned long supp_ranges[] = {1000, 4000, 16000, 64000}; - int i; + int i, ret; + unsigned int int_time, new_int_time; + struct isl29018_scale new_scale; - for (i = 0; i < ARRAY_SIZE(supp_ranges); ++i) { - if (range <= supp_ranges[i]) { - *new_range = (unsigned int)supp_ranges[i]; + for (i = 0; i < ARRAY_SIZE(isl29018_int_utimes[chip->type]); ++i) { + if (utime == isl29018_int_utimes[chip->type][i]) { + new_int_time = i; + new_scale = isl29018_scales[new_int_time][0]; break; } } - if (i >= ARRAY_SIZE(supp_ranges)) + if (i >= ARRAY_SIZE(isl29018_int_utimes[chip->type])) return -EINVAL; - return regmap_update_bits(chip->regmap, ISL29018_REG_ADD_COMMANDII, - COMMANDII_RANGE_MASK, i << COMMANDII_RANGE_SHIFT); + ret = regmap_update_bits(chip->regmap, ISL29018_REG_ADD_COMMANDII, + COMMANDII_RESOLUTION_MASK, + i << COMMANDII_RESOLUTION_SHIFT); + if (ret < 0) + return ret; + + /* keep the same range when integration time changes */ + int_time = chip->int_time; + for (i = 0; i < ARRAY_SIZE(isl29018_scales[int_time]); ++i) { + if (chip->scale.scale == isl29018_scales[int_time][i].scale && + chip->scale.uscale == isl29018_scales[int_time][i].uscale) { + chip->scale = isl29018_scales[new_int_time][i]; + break; + } + } + chip->int_time = new_int_time; + + return 0; } -static int isl29018_set_resolution(struct isl29018_chip *chip, - unsigned long adcbit, unsigned int *conf_adc_bit) +static int isl29018_set_scale(struct isl29018_chip *chip, int scale, int uscale) { - static const unsigned long supp_adcbit[] = {16, 12, 8, 4}; - int i; + int i, ret; + struct isl29018_scale new_scale; - for (i = 0; i < ARRAY_SIZE(supp_adcbit); ++i) { - if (adcbit >= supp_adcbit[i]) { - *conf_adc_bit = (unsigned int)supp_adcbit[i]; + for (i = 0; i < ARRAY_SIZE(isl29018_scales[chip->int_time]); ++i) { + if (scale == isl29018_scales[chip->int_time][i].scale && + uscale == isl29018_scales[chip->int_time][i].uscale) { + new_scale = isl29018_scales[chip->int_time][i]; break; } } - if (i >= ARRAY_SIZE(supp_adcbit)) + if (i >= ARRAY_SIZE(isl29018_scales[chip->int_time])) return -EINVAL; - return regmap_update_bits(chip->regmap, ISL29018_REG_ADD_COMMANDII, - COMMANDII_RESOLUTION_MASK, - i << COMMANDII_RESOLUTION_SHIFT); + ret = regmap_update_bits(chip->regmap, ISL29018_REG_ADD_COMMANDII, + COMMANDII_RANGE_MASK, + i << COMMANDII_RANGE_SHIFT); + if (ret < 0) + return ret; + + chip->scale = new_scale; + + return 0; } static int isl29018_read_sensor_input(struct isl29018_chip *chip, int mode) @@ -156,22 +213,17 @@ static int isl29018_read_sensor_input(struct isl29018_chip *chip, int mode) static int isl29018_read_lux(struct isl29018_chip *chip, int *lux) { int lux_data; - unsigned int data_x_range, lux_unshifted; + unsigned int data_x_range; lux_data = isl29018_read_sensor_input(chip, COMMMAND1_OPMODE_ALS_ONCE); if (lux_data < 0) return lux_data; - /* To support fractional scaling, separate the unshifted lux - * into two calculations: int scaling and micro-scaling. - * ucalibscale ranges from 0-999999, so about 20 bits. Split - * the /1,000,000 in two to reduce the risk of over/underflow. - */ - data_x_range = lux_data * chip->range; - lux_unshifted = data_x_range * chip->calibscale; - lux_unshifted += data_x_range / 1000 * chip->ucalibscale / 1000; - *lux = lux_unshifted >> chip->adc_bit; + data_x_range = lux_data * chip->scale.scale + + lux_data * chip->scale.uscale / 1000000; + *lux = data_x_range * chip->calibscale + + data_x_range * chip->ucalibscale / 1000000; return 0; } @@ -229,7 +281,39 @@ static int isl29018_read_proximity_ir(struct isl29018_chip *chip, int scheme, return 0; } -/* Sysfs interface */ +static ssize_t show_scale_available(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct isl29018_chip *chip = iio_priv(indio_dev); + int i, len = 0; + + for (i = 0; i < ARRAY_SIZE(isl29018_scales[chip->int_time]); ++i) + len += sprintf(buf + len, "%d.%06d ", + isl29018_scales[chip->int_time][i].scale, + isl29018_scales[chip->int_time][i].uscale); + + buf[len - 1] = '\n'; + + return len; +} + +static ssize_t show_int_time_available(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct isl29018_chip *chip = iio_priv(indio_dev); + int i, len = 0; + + for (i = 0; i < ARRAY_SIZE(isl29018_int_utimes[chip->type]); ++i) + len += sprintf(buf + len, "0.%06d ", + isl29018_int_utimes[chip->type][i]); + + buf[len - 1] = '\n'; + + return len; +} + /* proximity scheme */ static ssize_t show_prox_infrared_suppression(struct device *dev, struct device_attribute *attr, char *buf) @@ -276,11 +360,28 @@ static int isl29018_write_raw(struct iio_dev *indio_dev, int ret = -EINVAL; mutex_lock(&chip->lock); - if (mask == IIO_CHAN_INFO_CALIBSCALE && chan->type == IIO_LIGHT) { - chip->calibscale = val; - /* With no write_raw_get_fmt(), val2 is a MICRO fraction. */ - chip->ucalibscale = val2; - ret = 0; + switch (mask) { + case IIO_CHAN_INFO_CALIBSCALE: + if (chan->type == IIO_LIGHT) { + chip->calibscale = val; + chip->ucalibscale = val2; + ret = 0; + } + break; + case IIO_CHAN_INFO_INT_TIME: + if (chan->type == IIO_LIGHT) + if (val != 0) { + mutex_unlock(&chip->lock); + return -EINVAL; + } + ret = isl29018_set_integration_time(chip, val2); + break; + case IIO_CHAN_INFO_SCALE: + if (chan->type == IIO_LIGHT) + ret = isl29018_set_scale(chip, val, val2); + break; + default: + break; } mutex_unlock(&chip->lock); @@ -321,6 +422,20 @@ static int isl29018_read_raw(struct iio_dev *indio_dev, if (!ret) ret = IIO_VAL_INT; break; + case IIO_CHAN_INFO_INT_TIME: + if (chan->type == IIO_LIGHT) { + *val = 0; + *val2 = isl29018_int_utimes[chip->type][chip->int_time]; + ret = IIO_VAL_INT_PLUS_MICRO; + } + break; + case IIO_CHAN_INFO_SCALE: + if (chan->type == IIO_LIGHT) { + *val = chip->scale.scale; + *val2 = chip->scale.uscale; + ret = IIO_VAL_INT_PLUS_MICRO; + } + break; case IIO_CHAN_INFO_CALIBSCALE: if (chan->type == IIO_LIGHT) { *val = chip->calibscale; @@ -340,7 +455,9 @@ static int isl29018_read_raw(struct iio_dev *indio_dev, .indexed = 1, \ .channel = 0, \ .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | \ - BIT(IIO_CHAN_INFO_CALIBSCALE), \ + BIT(IIO_CHAN_INFO_CALIBSCALE) | \ + BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_INT_TIME), \ } #define ISL29018_IR_CHANNEL { \ @@ -366,19 +483,27 @@ static const struct iio_chan_spec isl29023_channels[] = { ISL29018_IR_CHANNEL, }; +static IIO_DEVICE_ATTR(in_illuminance_integration_time_available, S_IRUGO, + show_int_time_available, NULL, 0); +static IIO_DEVICE_ATTR(in_illuminance_scale_available, S_IRUGO, + show_scale_available, NULL, 0); static IIO_DEVICE_ATTR(proximity_on_chip_ambient_infrared_suppression, S_IRUGO | S_IWUSR, show_prox_infrared_suppression, store_prox_infrared_suppression, 0); #define ISL29018_DEV_ATTR(name) (&iio_dev_attr_##name.dev_attr.attr) -#define ISL29018_CONST_ATTR(name) (&iio_const_attr_##name.dev_attr.attr) + static struct attribute *isl29018_attributes[] = { + ISL29018_DEV_ATTR(in_illuminance_scale_available), + ISL29018_DEV_ATTR(in_illuminance_integration_time_available), ISL29018_DEV_ATTR(proximity_on_chip_ambient_infrared_suppression), NULL }; static struct attribute *isl29023_attributes[] = { + ISL29018_DEV_ATTR(in_illuminance_scale_available), + ISL29018_DEV_ATTR(in_illuminance_integration_time_available), NULL }; @@ -422,8 +547,6 @@ enum { static int isl29018_chip_init(struct isl29018_chip *chip) { int status; - unsigned int new_adc_bit; - unsigned int new_range; if (chip->type == isl29035) { status = isl29035_detect(chip); @@ -472,14 +595,19 @@ static int isl29018_chip_init(struct isl29018_chip *chip) usleep_range(1000, 2000); /* per data sheet, page 10 */ /* set defaults */ - status = isl29018_set_range(chip, chip->range, &new_range); + status = isl29018_set_scale(chip, chip->scale.scale, + chip->scale.uscale); if (status < 0) { dev_err(chip->dev, "Init of isl29018 fails\n"); return status; } - status = isl29018_set_resolution(chip, chip->adc_bit, - &new_adc_bit); + status = isl29018_set_integration_time(chip, + isl29018_int_utimes[chip->type][chip->int_time]); + if (status < 0) { + dev_err(chip->dev, "Init of isl29018 fails\n"); + return status; + } return 0; } @@ -609,8 +737,8 @@ static int isl29018_probe(struct i2c_client *client, chip->type = dev_id; chip->calibscale = 1; chip->ucalibscale = 0; - chip->range = 1000; - chip->adc_bit = 16; + chip->int_time = ISL29018_INT_TIME_16; + chip->scale = isl29018_scales[chip->int_time][0]; chip->suspended = false; chip->regmap = devm_regmap_init_i2c(client, From 2fdaf3f4f8c718a5023db69e2d391d978e94703e Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 2 May 2015 11:25:48 +0100 Subject: [PATCH 0101/1163] iio:light:ltr501 bug in parameter sanity check. Clearly the intent was to error if the value was not 0 or 1. As implemented we have (A != 0 || A != 1) which is always true as A is never both 0 and 1 at the same time. As the autobuilder suggested, && makes more sense for this error check. Reported-by: kbuild test robot Acked-by: Kuppuswamy Sathyanarayanan Cc: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/light/ltr501.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c index ca4bf470a332..280eff19b872 100644 --- a/drivers/iio/light/ltr501.c +++ b/drivers/iio/light/ltr501.c @@ -976,7 +976,7 @@ static int ltr501_write_event_config(struct iio_dev *indio_dev, int ret; /* only 1 and 0 are valid inputs */ - if (state != 1 || state != 0) + if (state != 1 && state != 0) return -EINVAL; switch (chan->type) { From b91617ea62af5558af598ae9ad069db96f2ab00e Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 2 May 2015 12:05:05 +0100 Subject: [PATCH 0102/1163] staging:iio:light: Add some missing brackets to make sure code works as intended. Note this is not a bug due to the fact the region cannot be reached without the sanity check passing. The autobuilder reported it as missaligned code which is kind of true as well. Signed-off-by: Jonathan Cameron Cc: Roberta Dobrescu --- drivers/staging/iio/light/isl29018.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c index 08ca9a4172e3..e646c5d24004 100644 --- a/drivers/staging/iio/light/isl29018.c +++ b/drivers/staging/iio/light/isl29018.c @@ -369,12 +369,13 @@ static int isl29018_write_raw(struct iio_dev *indio_dev, } break; case IIO_CHAN_INFO_INT_TIME: - if (chan->type == IIO_LIGHT) + if (chan->type == IIO_LIGHT) { if (val != 0) { mutex_unlock(&chip->lock); return -EINVAL; } ret = isl29018_set_integration_time(chip, val2); + } break; case IIO_CHAN_INFO_SCALE: if (chan->type == IIO_LIGHT) From 1a30295a09e022c57d7ce6d94c0134af9afaf8d6 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 2 May 2015 11:29:42 +0100 Subject: [PATCH 0103/1163] iio:prox:sx9500 trivial simplification of return path in init function. Signed-off-by: Jonathan Cameron Reported-by: kbuild test robot Cc: Vlad Dogaru --- drivers/iio/proximity/sx9500.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c index f1e9d734b6b6..2042e375f835 100644 --- a/drivers/iio/proximity/sx9500.c +++ b/drivers/iio/proximity/sx9500.c @@ -859,11 +859,7 @@ static int sx9500_init_device(struct iio_dev *indio_dev) return ret; } - ret = sx9500_init_compensation(indio_dev); - if (ret < 0) - return ret; - - return 0; + return sx9500_init_compensation(indio_dev); } static void sx9500_gpio_probe(struct i2c_client *client, From 61e2c70da9cfc79e8485eafa0f98b5919b04bbe1 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Mon, 4 May 2015 11:13:03 +0200 Subject: [PATCH 0104/1163] iio: accel: kxcjk-1013: add the "KXCJ9000" ACPI id This id has been seen in the DSDT of the Teclast X98 Air 3G tablet based on Intel Bay Trail. Signed-off-by: Antonio Ospite Cc: Bastien Nocera Reviewed-by: Daniel Baluta Cc: Signed-off-by: Jonathan Cameron --- drivers/iio/accel/kxcjk-1013.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c index df6f5d70fa3b..2285bca3b739 100644 --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c @@ -1426,6 +1426,7 @@ static const struct dev_pm_ops kxcjk1013_pm_ops = { static const struct acpi_device_id kx_acpi_match[] = { {"KXCJ1013", KXCJK1013}, {"KXCJ1008", KXCJ91008}, + {"KXCJ9000", KXCJ91008}, {"KXTJ1009", KXTJ21009}, {"SMO8500", KXCJ91008}, { }, From e693e15e869fb314c86770c1f1451fdd013654c0 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Mon, 4 May 2015 11:13:04 +0200 Subject: [PATCH 0105/1163] iio: accel: kxcjk-1013: add some blank lines for readability Some extra blank lines between if checks don't hurt and improve readability. Signed-off-by: Antonio Ospite Cc: Bastien Nocera Reviewed-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/accel/kxcjk-1013.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c index 2285bca3b739..0d9bd35ff258 100644 --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c @@ -1156,8 +1156,10 @@ static const char *kxcjk1013_match_acpi_device(struct device *dev, id = acpi_match_device(dev->driver->acpi_match_table, dev); if (!id) return NULL; + if (strcmp(id->id, "SMO8500") == 0) *is_smo8500_device = true; + *chipset = (enum kx_chipset)id->driver_data; return dev_name(dev); @@ -1172,6 +1174,7 @@ static int kxcjk1013_gpio_probe(struct i2c_client *client, if (!client) return -EINVAL; + if (data->is_smo8500_device) return -ENOTSUPP; From 3337c9ff17948e1879fb06ea722baa9519533e0f Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 30 Apr 2015 15:15:46 +0200 Subject: [PATCH 0106/1163] iio: st_sensors: print error when failing to get IRQ Print a proper error message if we're missing the trigger IRQ. Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/common/st_sensors/st_sensors_trigger.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iio/common/st_sensors/st_sensors_trigger.c b/drivers/iio/common/st_sensors/st_sensors_trigger.c index 8d8ca6f1e16a..3e907040c2c7 100644 --- a/drivers/iio/common/st_sensors/st_sensors_trigger.c +++ b/drivers/iio/common/st_sensors/st_sensors_trigger.c @@ -37,8 +37,10 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev, IRQF_TRIGGER_RISING, sdata->trig->name, sdata->trig); - if (err) + if (err) { + dev_err(&indio_dev->dev, "failed to request trigger IRQ.\n"); goto request_irq_error; + } iio_trigger_set_drvdata(sdata->trig, indio_dev); sdata->trig->ops = trigger_ops; From d2bc431868a1c3172bb8fa3187a90fa806bba484 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 30 Apr 2015 15:15:47 +0200 Subject: [PATCH 0107/1163] iio: st_sensors: make interrupt optional Some sensors such as magnetometers and pressure sensors doesn't have interrupts at all, and thus no DRDY setting applies. Make the assignment of an interrupt optional, and do not call st_sensors_set_drdy_int_pin() if there is no drdy (data ready) pin specified. Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/common/st_sensors/st_sensors_core.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index edd13d2b4121..5a01093b29a2 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -245,6 +245,16 @@ static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev, { struct st_sensor_data *sdata = iio_priv(indio_dev); + /* Sensor does not support interrupts */ + if (sdata->sensor_settings->drdy_irq.addr == 0) { + if (pdata->drdy_int_pin) + dev_info(&indio_dev->dev, + "DRDY on pin INT%d specified, but sensor " + "does not support interrupts\n", + pdata->drdy_int_pin); + return 0; + } + switch (pdata->drdy_int_pin) { case 1: if (sdata->sensor_settings->drdy_irq.mask_int1 == 0) { @@ -285,7 +295,7 @@ static struct st_sensors_platform_data *st_sensors_of_probe(struct device *dev, if (!of_property_read_u32(np, "st,drdy-int-pin", &val) && (val <= 2)) pdata->drdy_int_pin = (u8) val; else - pdata->drdy_int_pin = defdata ? defdata->drdy_int_pin : 1; + pdata->drdy_int_pin = defdata ? defdata->drdy_int_pin : 0; return pdata; } From bb60646c8befe218d0bd49e71e62252cd6408ae5 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 30 Apr 2015 15:15:48 +0200 Subject: [PATCH 0108/1163] iio: st_sensors: make BDU optional Not all sensors support BDU (block data update) and in fact a bunch of the in-kernel sensor settings do not specify the BDU address field. Make this optional. Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/common/st_sensors/st_sensors_core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index 5a01093b29a2..cbeb5e01bc3a 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -344,11 +344,13 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev, return err; /* set BDU */ - err = st_sensors_write_data_with_mask(indio_dev, + if (sdata->sensor_settings->bdu.addr) { + err = st_sensors_write_data_with_mask(indio_dev, sdata->sensor_settings->bdu.addr, sdata->sensor_settings->bdu.mask, true); - if (err < 0) - return err; + if (err < 0) + return err; + } err = st_sensors_set_axis_enable(indio_dev, ST_SENSORS_ENABLE_ALL_AXIS); From 5e02bac3172fcad964eeef70ad21f583982a6eba Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 30 Apr 2015 15:15:49 +0200 Subject: [PATCH 0109/1163] iio: st_sensors: make detection more helpful The ST sensors are detected by reading a WhoAmI register and matching the number found to a sensor name string. To make it easier to figure out what happens when things go wrong, print the WhoAmI value and the device name we're trying to match. Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/common/st_sensors/st_sensors_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index cbeb5e01bc3a..1255b157c71c 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -503,7 +503,8 @@ int st_sensors_check_device_support(struct iio_dev *indio_dev, break; } if (n == ARRAY_SIZE(sensor_settings[i].sensors_supported)) { - dev_err(&indio_dev->dev, "device name and WhoAmI mismatch.\n"); + dev_err(&indio_dev->dev, "device name \"%s\" and WhoAmI (0x%02x) mismatch", + indio_dev->name, wai); goto sensor_name_mismatch; } From 1038a6872802bb4a07f627162ff989bf49e2e5cc Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 30 Apr 2015 15:15:50 +0200 Subject: [PATCH 0110/1163] iio: magnetometer: support for lsm303dlh The LSM303DLH accelerometer/magnetometer has a different device identification method than using register 0x0f, instead three registers contain a magic value. We rely on WhoAmI to be zero for this variant. Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/st-sensors.txt | 1 + drivers/iio/magnetometer/st_magn.h | 1 + drivers/iio/magnetometer/st_magn_core.c | 116 ++++++++++++++++++ drivers/iio/magnetometer/st_magn_i2c.c | 5 + 4 files changed, 123 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt index d2aaca974531..fb5e0c2d18b5 100644 --- a/Documentation/devicetree/bindings/iio/st-sensors.txt +++ b/Documentation/devicetree/bindings/iio/st-sensors.txt @@ -45,6 +45,7 @@ Gyroscopes: - st,lsm330-gyro Magnetometers: +- st,lsm303dlh-magn - st,lsm303dlhc-magn - st,lsm303dlm-magn - st,lis3mdl-magn diff --git a/drivers/iio/magnetometer/st_magn.h b/drivers/iio/magnetometer/st_magn.h index 7e81d00ef0c3..287691ca56c1 100644 --- a/drivers/iio/magnetometer/st_magn.h +++ b/drivers/iio/magnetometer/st_magn.h @@ -14,6 +14,7 @@ #include #include +#define LSM303DLH_MAGN_DEV_NAME "lsm303dlh_magn" #define LSM303DLHC_MAGN_DEV_NAME "lsm303dlhc_magn" #define LSM303DLM_MAGN_DEV_NAME "lsm303dlm_magn" #define LIS3MDL_MAGN_DEV_NAME "lis3mdl" diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c index 8ade473f99fe..73574d912e7c 100644 --- a/drivers/iio/magnetometer/st_magn_core.c +++ b/drivers/iio/magnetometer/st_magn_core.c @@ -45,6 +45,46 @@ #define ST_MAGN_FS_AVL_12000MG 12000 #define ST_MAGN_FS_AVL_16000MG 16000 +/* CUSTOM VALUES FOR SENSOR 0 */ +#define ST_MAGN_0_ODR_ADDR 0x00 +#define ST_MAGN_0_ODR_MASK 0x1c +#define ST_MAGN_0_ODR_AVL_1HZ_VAL 0x00 +#define ST_MAGN_0_ODR_AVL_2HZ_VAL 0x01 +#define ST_MAGN_0_ODR_AVL_3HZ_VAL 0x02 +#define ST_MAGN_0_ODR_AVL_8HZ_VAL 0x03 +#define ST_MAGN_0_ODR_AVL_15HZ_VAL 0x04 +#define ST_MAGN_0_ODR_AVL_30HZ_VAL 0x05 +#define ST_MAGN_0_ODR_AVL_75HZ_VAL 0x06 +#define ST_MAGN_0_ODR_AVL_220HZ_VAL 0x07 +#define ST_MAGN_0_PW_ADDR 0x02 +#define ST_MAGN_0_PW_MASK 0x03 +#define ST_MAGN_0_PW_ON 0x00 +#define ST_MAGN_0_PW_OFF 0x03 +#define ST_MAGN_0_FS_ADDR 0x01 +#define ST_MAGN_0_FS_MASK 0xe0 +#define ST_MAGN_0_FS_AVL_1300_VAL 0x01 +#define ST_MAGN_0_FS_AVL_1900_VAL 0x02 +#define ST_MAGN_0_FS_AVL_2500_VAL 0x03 +#define ST_MAGN_0_FS_AVL_4000_VAL 0x04 +#define ST_MAGN_0_FS_AVL_4700_VAL 0x05 +#define ST_MAGN_0_FS_AVL_5600_VAL 0x06 +#define ST_MAGN_0_FS_AVL_8100_VAL 0x07 +#define ST_MAGN_0_FS_AVL_1300_GAIN_XY 1100 +#define ST_MAGN_0_FS_AVL_1900_GAIN_XY 855 +#define ST_MAGN_0_FS_AVL_2500_GAIN_XY 670 +#define ST_MAGN_0_FS_AVL_4000_GAIN_XY 450 +#define ST_MAGN_0_FS_AVL_4700_GAIN_XY 400 +#define ST_MAGN_0_FS_AVL_5600_GAIN_XY 330 +#define ST_MAGN_0_FS_AVL_8100_GAIN_XY 230 +#define ST_MAGN_0_FS_AVL_1300_GAIN_Z 980 +#define ST_MAGN_0_FS_AVL_1900_GAIN_Z 760 +#define ST_MAGN_0_FS_AVL_2500_GAIN_Z 600 +#define ST_MAGN_0_FS_AVL_4000_GAIN_Z 400 +#define ST_MAGN_0_FS_AVL_4700_GAIN_Z 355 +#define ST_MAGN_0_FS_AVL_5600_GAIN_Z 295 +#define ST_MAGN_0_FS_AVL_8100_GAIN_Z 205 +#define ST_MAGN_0_MULTIREAD_BIT false + /* CUSTOM VALUES FOR SENSOR 1 */ #define ST_MAGN_1_WAI_EXP 0x3c #define ST_MAGN_1_ODR_ADDR 0x00 @@ -150,6 +190,82 @@ static const struct iio_chan_spec st_magn_2_16bit_channels[] = { }; static const struct st_sensor_settings st_magn_sensors_settings[] = { + { + .wai = 0, /* This sensor has no valid WhoAmI report 0 */ + .sensors_supported = { + [0] = LSM303DLH_MAGN_DEV_NAME, + }, + .ch = (struct iio_chan_spec *)st_magn_16bit_channels, + .odr = { + .addr = ST_MAGN_0_ODR_ADDR, + .mask = ST_MAGN_0_ODR_MASK, + .odr_avl = { + { 1, ST_MAGN_0_ODR_AVL_1HZ_VAL, }, + { 2, ST_MAGN_0_ODR_AVL_2HZ_VAL, }, + { 3, ST_MAGN_0_ODR_AVL_3HZ_VAL, }, + { 8, ST_MAGN_0_ODR_AVL_8HZ_VAL, }, + { 15, ST_MAGN_0_ODR_AVL_15HZ_VAL, }, + { 30, ST_MAGN_0_ODR_AVL_30HZ_VAL, }, + { 75, ST_MAGN_0_ODR_AVL_75HZ_VAL, }, + }, + }, + .pw = { + .addr = ST_MAGN_0_PW_ADDR, + .mask = ST_MAGN_0_PW_MASK, + .value_on = ST_MAGN_0_PW_ON, + .value_off = ST_MAGN_0_PW_OFF, + }, + .fs = { + .addr = ST_MAGN_0_FS_ADDR, + .mask = ST_MAGN_0_FS_MASK, + .fs_avl = { + [0] = { + .num = ST_MAGN_FS_AVL_1300MG, + .value = ST_MAGN_0_FS_AVL_1300_VAL, + .gain = ST_MAGN_0_FS_AVL_1300_GAIN_XY, + .gain2 = ST_MAGN_0_FS_AVL_1300_GAIN_Z, + }, + [1] = { + .num = ST_MAGN_FS_AVL_1900MG, + .value = ST_MAGN_0_FS_AVL_1900_VAL, + .gain = ST_MAGN_0_FS_AVL_1900_GAIN_XY, + .gain2 = ST_MAGN_0_FS_AVL_1900_GAIN_Z, + }, + [2] = { + .num = ST_MAGN_FS_AVL_2500MG, + .value = ST_MAGN_0_FS_AVL_2500_VAL, + .gain = ST_MAGN_0_FS_AVL_2500_GAIN_XY, + .gain2 = ST_MAGN_0_FS_AVL_2500_GAIN_Z, + }, + [3] = { + .num = ST_MAGN_FS_AVL_4000MG, + .value = ST_MAGN_0_FS_AVL_4000_VAL, + .gain = ST_MAGN_0_FS_AVL_4000_GAIN_XY, + .gain2 = ST_MAGN_0_FS_AVL_4000_GAIN_Z, + }, + [4] = { + .num = ST_MAGN_FS_AVL_4700MG, + .value = ST_MAGN_0_FS_AVL_4700_VAL, + .gain = ST_MAGN_0_FS_AVL_4700_GAIN_XY, + .gain2 = ST_MAGN_0_FS_AVL_4700_GAIN_Z, + }, + [5] = { + .num = ST_MAGN_FS_AVL_5600MG, + .value = ST_MAGN_0_FS_AVL_5600_VAL, + .gain = ST_MAGN_0_FS_AVL_5600_GAIN_XY, + .gain2 = ST_MAGN_0_FS_AVL_5600_GAIN_Z, + }, + [6] = { + .num = ST_MAGN_FS_AVL_8100MG, + .value = ST_MAGN_0_FS_AVL_8100_VAL, + .gain = ST_MAGN_0_FS_AVL_8100_GAIN_XY, + .gain2 = ST_MAGN_0_FS_AVL_8100_GAIN_Z, + }, + }, + }, + .multi_read_bit = ST_MAGN_0_MULTIREAD_BIT, + .bootime = 2, + }, { .wai = ST_MAGN_1_WAI_EXP, .sensors_supported = { diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c index 92e5c15452a3..5311d8aea8cc 100644 --- a/drivers/iio/magnetometer/st_magn_i2c.c +++ b/drivers/iio/magnetometer/st_magn_i2c.c @@ -20,6 +20,10 @@ #ifdef CONFIG_OF static const struct of_device_id st_magn_of_match[] = { + { + .compatible = "st,lsm303dlh-magn", + .data = LSM303DLH_MAGN_DEV_NAME, + }, { .compatible = "st,lsm303dlhc-magn", .data = LSM303DLHC_MAGN_DEV_NAME, @@ -71,6 +75,7 @@ static int st_magn_i2c_remove(struct i2c_client *client) } static const struct i2c_device_id st_magn_id_table[] = { + { LSM303DLH_MAGN_DEV_NAME }, { LSM303DLHC_MAGN_DEV_NAME }, { LSM303DLM_MAGN_DEV_NAME }, { LIS3MDL_MAGN_DEV_NAME }, From 5a56474a51cee4aad56f6b2225ed5828e2dc3b84 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 17:51:22 +0200 Subject: [PATCH 0111/1163] staging: lustre: fid: Use kzalloc and kfree Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree. A simplified version of the semantic patch that makes these changes is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr,size; @@ - OBD_ALLOC(ptr,size) + ptr = kzalloc(size, GFP_NOFS) @@ expression ptr, size; @@ - OBD_FREE(ptr, size); + kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/fid/fid_request.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c index 063441abfcfc..7aee3935d31c 100644 --- a/drivers/staging/lustre/lustre/fid/fid_request.c +++ b/drivers/staging/lustre/lustre/fid/fid_request.c @@ -505,11 +505,11 @@ int client_fid_init(struct obd_device *obd, char *prefix; int rc; - OBD_ALLOC_PTR(cli->cl_seq); + cli->cl_seq = kzalloc(sizeof(*cli->cl_seq), GFP_NOFS); if (cli->cl_seq == NULL) return -ENOMEM; - OBD_ALLOC(prefix, MAX_OBD_NAME + 5); + prefix = kzalloc(MAX_OBD_NAME + 5, GFP_NOFS); if (prefix == NULL) { rc = -ENOMEM; goto out_free_seq; @@ -519,13 +519,13 @@ int client_fid_init(struct obd_device *obd, /* Init client side sequence-manager */ rc = seq_client_init(cli->cl_seq, exp, type, prefix, NULL); - OBD_FREE(prefix, MAX_OBD_NAME + 5); + kfree(prefix); if (rc) goto out_free_seq; return rc; out_free_seq: - OBD_FREE_PTR(cli->cl_seq); + kfree(cli->cl_seq); cli->cl_seq = NULL; return rc; } @@ -537,7 +537,7 @@ int client_fid_fini(struct obd_device *obd) if (cli->cl_seq != NULL) { seq_client_fini(cli->cl_seq); - OBD_FREE_PTR(cli->cl_seq); + kfree(cli->cl_seq); cli->cl_seq = NULL; } From 2e65101315679fca06a673d83f3d78442800f90a Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 17:51:21 +0200 Subject: [PATCH 0112/1163] Staging: lustre: fld: Use kzalloc and kfree Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree. A simplified version of the semantic patch that makes these changes is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr,size; @@ - OBD_ALLOC(ptr,size) + ptr = kzalloc(size, GFP_NOFS) @@ expression ptr, size; @@ - OBD_FREE(ptr, size); + kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/fld/fld_cache.c | 16 ++++++++-------- drivers/staging/lustre/lustre/fld/fld_request.c | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c b/drivers/staging/lustre/lustre/fld/fld_cache.c index 0d0a73745065..ec2fc4339a2e 100644 --- a/drivers/staging/lustre/lustre/fld/fld_cache.c +++ b/drivers/staging/lustre/lustre/fld/fld_cache.c @@ -69,7 +69,7 @@ struct fld_cache *fld_cache_init(const char *name, LASSERT(name != NULL); LASSERT(cache_threshold < cache_size); - OBD_ALLOC_PTR(cache); + cache = kzalloc(sizeof(*cache), GFP_NOFS); if (cache == NULL) return ERR_PTR(-ENOMEM); @@ -116,7 +116,7 @@ void fld_cache_fini(struct fld_cache *cache) CDEBUG(D_INFO, " Cache reqs: %llu\n", cache->fci_stat.fst_cache); CDEBUG(D_INFO, " Cache hits: %llu%%\n", pct); - OBD_FREE_PTR(cache); + kfree(cache); } /** @@ -128,7 +128,7 @@ void fld_cache_entry_delete(struct fld_cache *cache, list_del(&node->fce_list); list_del(&node->fce_lru); cache->fci_cache_count--; - OBD_FREE_PTR(node); + kfree(node); } /** @@ -268,7 +268,7 @@ static void fld_cache_punch_hole(struct fld_cache *cache, OBD_ALLOC_GFP(fldt, sizeof(*fldt), GFP_ATOMIC); if (!fldt) { - OBD_FREE_PTR(f_new); + kfree(f_new); /* overlap is not allowed, so dont mess up list. */ return; } @@ -315,7 +315,7 @@ static void fld_cache_overlap_handle(struct fld_cache *cache, f_curr->fce_range.lsr_end = max(f_curr->fce_range.lsr_end, new_end); - OBD_FREE_PTR(f_new); + kfree(f_new); fld_fix_new_list(cache); } else if (new_start <= f_curr->fce_range.lsr_start && @@ -324,7 +324,7 @@ static void fld_cache_overlap_handle(struct fld_cache *cache, * e.g. whole range migrated. update fld cache entry */ f_curr->fce_range = *range; - OBD_FREE_PTR(f_new); + kfree(f_new); fld_fix_new_list(cache); } else if (f_curr->fce_range.lsr_start < new_start && @@ -364,7 +364,7 @@ struct fld_cache_entry LASSERT(range_is_sane(range)); - OBD_ALLOC_PTR(f_new); + f_new = kzalloc(sizeof(*f_new), GFP_NOFS); if (!f_new) return ERR_PTR(-ENOMEM); @@ -440,7 +440,7 @@ int fld_cache_insert(struct fld_cache *cache, rc = fld_cache_insert_nolock(cache, flde); write_unlock(&cache->fci_lock); if (rc) - OBD_FREE_PTR(flde); + kfree(flde); return rc; } diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c index 6ac225e90ee0..075eb5ceedb6 100644 --- a/drivers/staging/lustre/lustre/fld/fld_request.c +++ b/drivers/staging/lustre/lustre/fld/fld_request.c @@ -221,7 +221,7 @@ int fld_client_add_target(struct lu_client_fld *fld, CDEBUG(D_INFO, "%s: Adding target %s (idx %llu)\n", fld->lcf_name, name, tar->ft_idx); - OBD_ALLOC_PTR(target); + target = kzalloc(sizeof(*target), GFP_NOFS); if (target == NULL) return -ENOMEM; @@ -229,7 +229,7 @@ int fld_client_add_target(struct lu_client_fld *fld, list_for_each_entry(tmp, &fld->lcf_targets, ft_chain) { if (tmp->ft_idx == tar->ft_idx) { spin_unlock(&fld->lcf_lock); - OBD_FREE_PTR(target); + kfree(target); CERROR("Target %s exists in FLD and known as %s:#%llu\n", name, fld_target_name(tmp), tmp->ft_idx); return -EEXIST; @@ -268,7 +268,7 @@ int fld_client_del_target(struct lu_client_fld *fld, __u64 idx) if (target->ft_exp != NULL) class_export_put(target->ft_exp); - OBD_FREE_PTR(target); + kfree(target); return 0; } } @@ -396,7 +396,7 @@ void fld_client_fini(struct lu_client_fld *fld) list_del(&target->ft_chain); if (target->ft_exp != NULL) class_export_put(target->ft_exp); - OBD_FREE_PTR(target); + kfree(target); } spin_unlock(&fld->lcf_lock); From 00c40c169abdee57d81995588b6bc1970c1db3cb Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 17:51:20 +0200 Subject: [PATCH 0113/1163] staging: lustre: lclient: Use kzalloc and kfree Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree. A simplified version of the semantic patch that makes these changes is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr,size; @@ - OBD_ALLOC(ptr,size) + ptr = kzalloc(size, GFP_NOFS) @@ expression ptr, size; @@ - OBD_FREE(ptr, size); + kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lclient/lcommon_cl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c index ab6cb419302f..19448fe52cfd 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c +++ b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c @@ -202,7 +202,7 @@ struct lu_device *ccc_device_alloc(const struct lu_env *env, struct cl_site *site; int rc; - OBD_ALLOC_PTR(vdv); + vdv = kzalloc(sizeof(*vdv), GFP_NOFS); if (vdv == NULL) return ERR_PTR(-ENOMEM); @@ -211,7 +211,7 @@ struct lu_device *ccc_device_alloc(const struct lu_env *env, ccc2lu_dev(vdv)->ld_ops = luops; vdv->cdv_cl.cd_ops = clops; - OBD_ALLOC_PTR(site); + site = kzalloc(sizeof(*site), GFP_NOFS); if (site != NULL) { rc = cl_site_init(site, &vdv->cdv_cl); if (rc == 0) @@ -219,7 +219,7 @@ struct lu_device *ccc_device_alloc(const struct lu_env *env, else { LASSERT(lud->ld_site == NULL); CERROR("Cannot init lu_site, rc %d.\n", rc); - OBD_FREE_PTR(site); + kfree(site); } } else rc = -ENOMEM; @@ -239,10 +239,10 @@ struct lu_device *ccc_device_free(const struct lu_env *env, if (d->ld_site != NULL) { cl_site_fini(site); - OBD_FREE_PTR(site); + kfree(site); } cl_device_fini(lu2cl_dev(d)); - OBD_FREE_PTR(vdv); + kfree(vdv); return next; } From 352f7891711e6d188999b32d8c151992984616ce Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 17:51:19 +0200 Subject: [PATCH 0114/1163] staging: lustre: ldlm: Use kzalloc and kfree Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree. A simplified version of the semantic patch that makes these changes is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr,size; @@ - OBD_ALLOC(ptr,size) + ptr = kzalloc(size, GFP_NOFS) @@ expression ptr, size; @@ - OBD_FREE(ptr, size); + kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 6 +++--- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 10 +++++----- drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 14 +++++++------- drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 10 +++++----- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 8 ++++---- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index c5c86e73ca52..d0667715ebf7 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -73,7 +73,7 @@ static int import_set_conn(struct obd_import *imp, struct obd_uuid *uuid, } if (create) { - OBD_ALLOC(imp_conn, sizeof(*imp_conn)); + imp_conn = kzalloc(sizeof(*imp_conn), GFP_NOFS); if (!imp_conn) { rc = -ENOMEM; goto out_put; @@ -120,7 +120,7 @@ static int import_set_conn(struct obd_import *imp, struct obd_uuid *uuid, return 0; out_free: if (imp_conn) - OBD_FREE(imp_conn, sizeof(*imp_conn)); + kfree(imp_conn); out_put: ptlrpc_connection_put(ptlrpc_conn); return rc; @@ -179,7 +179,7 @@ int client_import_del_conn(struct obd_import *imp, struct obd_uuid *uuid) list_del(&imp_conn->oic_item); ptlrpc_connection_put(imp_conn->oic_conn); - OBD_FREE(imp_conn, sizeof(*imp_conn)); + kfree(imp_conn); CDEBUG(D_HA, "imp %p@%s: remove connection %s\n", imp, imp->imp_obd->obd_name, uuid->uuid); rc = 0; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 84b111eb48fa..2c5fe1499ce0 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -209,7 +209,7 @@ void ldlm_lock_put(struct ldlm_lock *lock) } if (lock->l_lvb_data != NULL) - OBD_FREE(lock->l_lvb_data, lock->l_lvb_len); + kfree(lock->l_lvb_data); ldlm_interval_free(ldlm_interval_detach(lock)); lu_ref_fini(&lock->l_reference); @@ -1527,7 +1527,7 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns, if (lvb_len) { lock->l_lvb_len = lvb_len; - OBD_ALLOC(lock->l_lvb_data, lvb_len); + lock->l_lvb_data = kzalloc(lvb_len, GFP_NOFS); if (lock->l_lvb_data == NULL) goto out; } @@ -1791,7 +1791,7 @@ int ldlm_work_gl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) LDLM_LOCK_RELEASE(lock); if ((gl_work->gl_flags & LDLM_GL_WORK_NOFREE) == 0) - OBD_FREE_PTR(gl_work); + kfree(gl_work); return rc; } @@ -1812,7 +1812,7 @@ int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list, if (list_empty(rpc_list)) return 0; - OBD_ALLOC_PTR(arg); + arg = kzalloc(sizeof(*arg), GFP_NOFS); if (arg == NULL) return -ENOMEM; @@ -1857,7 +1857,7 @@ int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list, rc = atomic_read(&arg->restart) ? -ERESTART : 0; goto out; out: - OBD_FREE_PTR(arg); + kfree(arg); return rc; } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 08a91f5d91b1..6d731d3eda0a 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -220,7 +220,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req, * variable length */ void *lvb_data; - OBD_ALLOC(lvb_data, lvb_len); + lvb_data = kzalloc(lvb_len, GFP_NOFS); if (lvb_data == NULL) { LDLM_ERROR(lock, "No memory: %d.\n", lvb_len); rc = -ENOMEM; @@ -448,7 +448,7 @@ static int ldlm_bl_to_thread(struct ldlm_namespace *ns, if (cancel_flags & LCF_ASYNC) { struct ldlm_bl_work_item *blwi; - OBD_ALLOC(blwi, sizeof(*blwi)); + blwi = kzalloc(sizeof(*blwi), GFP_NOFS); if (blwi == NULL) return -ENOMEM; init_blwi(blwi, ns, ld, cancels, count, lock, cancel_flags); @@ -849,7 +849,7 @@ static int ldlm_bl_thread_main(void *arg) memory_pressure_clr(); if (blwi->blwi_flags & LCF_ASYNC) - OBD_FREE(blwi, sizeof(*blwi)); + kfree(blwi); else complete(&blwi->blwi_comp); } @@ -1012,7 +1012,7 @@ static int ldlm_setup(void) if (ldlm_state != NULL) return -EALREADY; - OBD_ALLOC(ldlm_state, sizeof(*ldlm_state)); + ldlm_state = kzalloc(sizeof(*ldlm_state), GFP_NOFS); if (ldlm_state == NULL) return -ENOMEM; @@ -1059,7 +1059,7 @@ static int ldlm_setup(void) } - OBD_ALLOC(blp, sizeof(*blp)); + blp = kzalloc(sizeof(*blp), GFP_NOFS); if (blp == NULL) { rc = -ENOMEM; goto out; @@ -1129,7 +1129,7 @@ static int ldlm_cleanup(void) wait_for_completion(&blp->blp_comp); } - OBD_FREE(blp, sizeof(*blp)); + kfree(blp); } if (ldlm_state->ldlm_cb_service != NULL) @@ -1138,7 +1138,7 @@ static int ldlm_cleanup(void) ldlm_proc_cleanup(); - OBD_FREE(ldlm_state, sizeof(*ldlm_state)); + kfree(ldlm_state); ldlm_state = NULL; return 0; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index a9f4833e03e5..53e1377873cd 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -746,7 +746,7 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl) char *var_name = NULL; int rc = 0; - OBD_ALLOC(var_name, MAX_STRING_SIZE + 1); + var_name = kzalloc(MAX_STRING_SIZE + 1, GFP_NOFS); if (!var_name) return -ENOMEM; @@ -828,7 +828,7 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl) rc = lprocfs_register_stats(pl->pl_proc_dir, "stats", pl->pl_stats); out_free_name: - OBD_FREE(var_name, MAX_STRING_SIZE + 1); + kfree(var_name); return rc; } @@ -1383,7 +1383,7 @@ static int ldlm_pools_thread_start(void) if (ldlm_pools_thread != NULL) return -EALREADY; - OBD_ALLOC_PTR(ldlm_pools_thread); + ldlm_pools_thread = kzalloc(sizeof(*ldlm_pools_thread), GFP_NOFS); if (ldlm_pools_thread == NULL) return -ENOMEM; @@ -1394,7 +1394,7 @@ static int ldlm_pools_thread_start(void) "ldlm_poold"); if (IS_ERR(task)) { CERROR("Can't start pool thread, error %ld\n", PTR_ERR(task)); - OBD_FREE(ldlm_pools_thread, sizeof(*ldlm_pools_thread)); + kfree(ldlm_pools_thread); ldlm_pools_thread = NULL; return PTR_ERR(task); } @@ -1417,7 +1417,7 @@ static void ldlm_pools_thread_stop(void) * in pools thread. */ wait_for_completion(&ldlm_pools_comp); - OBD_FREE_PTR(ldlm_pools_thread); + kfree(ldlm_pools_thread); ldlm_pools_thread = NULL; } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index f750d42a7ad5..5922069873f5 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -590,7 +590,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, break; } - OBD_ALLOC_PTR(ns); + ns = kzalloc(sizeof(*ns), GFP_NOFS); if (!ns) goto out_ref; @@ -657,7 +657,7 @@ out_proc: out_hash: cfs_hash_putref(ns->ns_rs_hash); out_ns: - OBD_FREE_PTR(ns); + kfree(ns); out_ref: ldlm_put_ref(); return NULL; @@ -904,7 +904,7 @@ void ldlm_namespace_free_post(struct ldlm_namespace *ns) * this will cause issues related to using freed \a ns in poold * thread. */ LASSERT(list_empty(&ns->ns_list_chain)); - OBD_FREE_PTR(ns); + kfree(ns); ldlm_put_ref(); } @@ -1138,7 +1138,7 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, ns->ns_obd->obd_name, name->name[0], name->name[1], rc); if (res->lr_lvb_data) { - OBD_FREE(res->lr_lvb_data, res->lr_lvb_len); + kfree(res->lr_lvb_data); res->lr_lvb_data = NULL; } res->lr_lvb_len = rc; From 8bcf30c3bf4e95cd506591171d81b266d43e8d41 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 17:51:18 +0200 Subject: [PATCH 0115/1163] staging: lustre: lmv: Use kzalloc and kfree Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree. A simplified version of the semantic patch that makes these changes is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr,size; @@ - OBD_ALLOC(ptr,size) + ptr = kzalloc(size, GFP_NOFS) @@ expression ptr, size; @@ - OBD_FREE(ptr, size); + kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/lmv/lmv_intent.c | 4 +-- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 28 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/lustre/lustre/lmv/lmv_intent.c b/drivers/staging/lustre/lustre/lmv/lmv_intent.c index d22d57b4ff38..cb35f6341fb2 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_intent.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_intent.c @@ -99,7 +99,7 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm, goto out; } - OBD_ALLOC_PTR(op_data); + op_data = kzalloc(sizeof(*op_data), GFP_NOFS); if (op_data == NULL) { rc = -ENOMEM; goto out; @@ -142,7 +142,7 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm, it->d.lustre.it_lock_mode = pmode; out_free_op_data: - OBD_FREE_PTR(op_data); + kfree(op_data); out: if (rc && pmode) ldlm_lock_decref(&plock, pmode); diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index b9459faf8645..59b8fac96ed4 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -442,7 +442,7 @@ static void lmv_del_target(struct lmv_obd *lmv, int index) if (lmv->tgts[index] == NULL) return; - OBD_FREE_PTR(lmv->tgts[index]); + kfree(lmv->tgts[index]); lmv->tgts[index] = NULL; return; } @@ -488,7 +488,7 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, while (newsize < index + 1) newsize <<= 1; - OBD_ALLOC(newtgts, sizeof(*newtgts) * newsize); + newtgts = kcalloc(newsize, sizeof(*newtgts), GFP_NOFS); if (newtgts == NULL) { lmv_init_unlock(lmv); return -ENOMEM; @@ -505,13 +505,13 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, lmv->tgts_size = newsize; smp_rmb(); if (old) - OBD_FREE(old, sizeof(*old) * oldsize); + kfree(old); CDEBUG(D_CONFIG, "tgts: %p size: %d\n", lmv->tgts, lmv->tgts_size); } - OBD_ALLOC_PTR(tgt); + tgt = kzalloc(sizeof(*tgt), GFP_NOFS); if (!tgt) { lmv_init_unlock(lmv); return -ENOMEM; @@ -750,7 +750,7 @@ repeat_fid2path: /* sigh, has to go to another MDT to do path building further */ if (remote_gf == NULL) { remote_gf_size = sizeof(*remote_gf) + PATH_MAX; - OBD_ALLOC(remote_gf, remote_gf_size); + remote_gf = kzalloc(remote_gf_size, GFP_NOFS); if (remote_gf == NULL) { rc = -ENOMEM; goto out_fid2path; @@ -781,7 +781,7 @@ repeat_fid2path: out_fid2path: if (remote_gf != NULL) - OBD_FREE(remote_gf, remote_gf_size); + kfree(remote_gf); return rc; } @@ -984,7 +984,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, return -EAGAIN; LASSERT(tgt && tgt->ltd_exp); - OBD_ALLOC_PTR(oqctl); + oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS); if (!oqctl) return -ENOMEM; @@ -995,7 +995,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, qctl->qc_valid = QC_MDTIDX; qctl->obd_uuid = tgt->ltd_uuid; } - OBD_FREE_PTR(oqctl); + kfree(oqctl); break; } case OBD_IOC_CHANGELOG_SEND: @@ -1327,7 +1327,7 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) return -EINVAL; } - OBD_ALLOC(lmv->tgts, sizeof(*lmv->tgts) * 32); + lmv->tgts = kcalloc(32, sizeof(*lmv->tgts), GFP_NOFS); if (lmv->tgts == NULL) return -ENOMEM; lmv->tgts_size = 32; @@ -1380,7 +1380,7 @@ static int lmv_cleanup(struct obd_device *obd) continue; lmv_del_target(lmv, i); } - OBD_FREE(lmv->tgts, sizeof(*lmv->tgts) * lmv->tgts_size); + kfree(lmv->tgts); lmv->tgts_size = 0; } return 0; @@ -1437,7 +1437,7 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp, if (rc) return rc; - OBD_ALLOC(temp, sizeof(*temp)); + temp = kzalloc(sizeof(*temp), GFP_NOFS); if (temp == NULL) return -ENOMEM; @@ -1473,7 +1473,7 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp, } out_free_temp: - OBD_FREE(temp, sizeof(*temp)); + kfree(temp); return rc; } @@ -1769,7 +1769,7 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo, goto out; } - OBD_ALLOC_PTR(rdata); + rdata = kzalloc(sizeof(*rdata), GFP_NOFS); if (rdata == NULL) { rc = -ENOMEM; goto out; @@ -1780,7 +1780,7 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo, rc = md_enqueue(tgt->ltd_exp, einfo, it, rdata, lockh, lmm, lmmsize, NULL, extra_lock_flags); - OBD_FREE_PTR(rdata); + kfree(rdata); out: ldlm_lock_decref(&plock, pmode); return rc; From 7b81779d0dd62316d4f92fab96eeba9ddfa3aaa6 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 17:51:17 +0200 Subject: [PATCH 0116/1163] staging: lustre: mdc: Use kzalloc and kfree Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree. A simplified version of the semantic patch that makes these changes is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr,size; @@ - OBD_ALLOC(ptr,size) + ptr = kzalloc(size, GFP_NOFS) @@ expression ptr, size; @@ - OBD_FREE(ptr, size); + kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 4 +-- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 2 +- .../staging/lustre/lustre/mdc/mdc_request.c | 30 +++++++++---------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index b41e50ea6ed8..23d22a4a606e 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -106,7 +106,7 @@ static ssize_t mdc_kuc_write(struct file *file, len = sizeof(*lh) + sizeof(*hal) + MTI_NAME_MAXLEN + /* for mockup below */ 2 * cfs_size_round(sizeof(*hai)); - OBD_ALLOC(lh, len); + lh = kzalloc(len, GFP_NOFS); if (!lh) return -ENOMEM; @@ -141,7 +141,7 @@ static ssize_t mdc_kuc_write(struct file *file, rc = libcfs_kkuc_msg_put(fp, lh); fput(fp); } - OBD_FREE(lh, len); + kfree(lh); if (rc < 0) return rc; return count; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index d1c224ecd2b7..f93579739083 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -1251,7 +1251,7 @@ static int mdc_intent_getattr_async_interpret(const struct lu_env *env, rc = mdc_finish_intent_lock(exp, req, &minfo->mi_data, it, lockh); out: - OBD_FREE_PTR(einfo); + kfree(einfo); minfo->mi_cb(req, minfo, rc); return 0; } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index f8ef5fe5e771..1a4ef9df33c3 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -1201,7 +1201,7 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf) /* Key is KEY_FID2PATH + getinfo_fid2path description */ keylen = cfs_size_round(sizeof(KEY_FID2PATH)) + sizeof(*gf); - OBD_ALLOC(key, keylen); + key = kzalloc(keylen, GFP_NOFS); if (key == NULL) return -ENOMEM; memcpy(key, KEY_FID2PATH, sizeof(KEY_FID2PATH)); @@ -1234,7 +1234,7 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf) PFID(&gf->gf_fid), gf->gf_recno, gf->gf_linkno, gf->gf_path); out: - OBD_FREE(key, keylen); + kfree(key); return rc; } @@ -1604,7 +1604,7 @@ static int mdc_changelog_send_thread(void *csdata) CDEBUG(D_CHANGELOG, "changelog to fp=%p start %llu\n", cs->cs_fp, cs->cs_startrec); - OBD_ALLOC(cs->cs_buf, KUC_CHANGELOG_MSG_MAXSIZE); + cs->cs_buf = kzalloc(KUC_CHANGELOG_MSG_MAXSIZE, GFP_NOFS); if (cs->cs_buf == NULL) { rc = -ENOMEM; goto out; @@ -1645,8 +1645,8 @@ out: if (ctxt) llog_ctxt_put(ctxt); if (cs->cs_buf) - OBD_FREE(cs->cs_buf, KUC_CHANGELOG_MSG_MAXSIZE); - OBD_FREE_PTR(cs); + kfree(cs->cs_buf); + kfree(cs); return rc; } @@ -1657,7 +1657,7 @@ static int mdc_ioc_changelog_send(struct obd_device *obd, int rc; /* Freed in mdc_changelog_send_thread */ - OBD_ALLOC_PTR(cs); + cs = kzalloc(sizeof(*cs), GFP_NOFS); if (!cs) return -ENOMEM; @@ -1679,7 +1679,7 @@ static int mdc_ioc_changelog_send(struct obd_device *obd, } CERROR("Failed to start changelog thread: %d\n", rc); - OBD_FREE_PTR(cs); + kfree(cs); return rc; } @@ -1937,7 +1937,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, struct if_quotactl *qctl = karg; struct obd_quotactl *oqctl; - OBD_ALLOC_PTR(oqctl); + oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS); if (oqctl == NULL) { rc = -ENOMEM; goto out; @@ -1951,7 +1951,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, qctl->obd_uuid = obd->u.cli.cl_target_uuid; } - OBD_FREE_PTR(oqctl); + kfree(oqctl); goto out; } case LL_IOC_GET_CONNECT_FLAGS: @@ -2430,14 +2430,14 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) struct lprocfs_static_vars lvars = { NULL }; int rc; - OBD_ALLOC(cli->cl_rpc_lock, sizeof(*cli->cl_rpc_lock)); + cli->cl_rpc_lock = kzalloc(sizeof(*cli->cl_rpc_lock), GFP_NOFS); if (!cli->cl_rpc_lock) return -ENOMEM; mdc_init_rpc_lock(cli->cl_rpc_lock); ptlrpcd_addref(); - OBD_ALLOC(cli->cl_close_lock, sizeof(*cli->cl_close_lock)); + cli->cl_close_lock = kzalloc(sizeof(*cli->cl_close_lock), GFP_NOFS); if (!cli->cl_close_lock) { rc = -ENOMEM; goto err_rpc_lock; @@ -2465,9 +2465,9 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) return rc; err_close_lock: - OBD_FREE(cli->cl_close_lock, sizeof(*cli->cl_close_lock)); + kfree(cli->cl_close_lock); err_rpc_lock: - OBD_FREE(cli->cl_rpc_lock, sizeof(*cli->cl_rpc_lock)); + kfree(cli->cl_rpc_lock); ptlrpcd_decref(); return rc; } @@ -2525,8 +2525,8 @@ static int mdc_cleanup(struct obd_device *obd) { struct client_obd *cli = &obd->u.cli; - OBD_FREE(cli->cl_rpc_lock, sizeof(*cli->cl_rpc_lock)); - OBD_FREE(cli->cl_close_lock, sizeof(*cli->cl_close_lock)); + kfree(cli->cl_rpc_lock); + kfree(cli->cl_close_lock); ptlrpcd_decref(); From c9b4297faadcb972bad71aa625e1775bc2be9c46 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 17:51:16 +0200 Subject: [PATCH 0117/1163] staging: lustre: mgc: Use kzalloc and kfree Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree. A simplified version of the semantic patch that makes these changes is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr,size; @@ - OBD_ALLOC(ptr,size) + ptr = kzalloc(size, GFP_NOFS) @@ expression ptr, size; @@ - OBD_FREE(ptr, size); + kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/mgc/mgc_request.c | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 7947aec5c847..f152e5ceb941 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -149,7 +149,7 @@ static void config_log_put(struct config_llog_data *cld) sptlrpc_conf_log_stop(cld->cld_logname); class_export_put(cld->cld_mgcexp); - OBD_FREE(cld, sizeof(*cld) + strlen(cld->cld_logname) + 1); + kfree(cld); } } @@ -198,7 +198,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, CDEBUG(D_MGC, "do adding config log %s:%p\n", logname, cfg ? cfg->cfg_instance : NULL); - OBD_ALLOC(cld, sizeof(*cld) + strlen(logname) + 1); + cld = kzalloc(sizeof(*cld) + strlen(logname) + 1, GFP_NOFS); if (!cld) return ERR_PTR(-ENOMEM); @@ -1129,14 +1129,14 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, LASSERT(cfg->cfg_instance != NULL); LASSERT(cfg->cfg_sb == cfg->cfg_instance); - OBD_ALLOC(inst, PAGE_CACHE_SIZE); + inst = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS); if (inst == NULL) return -ENOMEM; if (!IS_SERVER(lsi)) { pos = snprintf(inst, PAGE_CACHE_SIZE, "%p", cfg->cfg_instance); if (pos >= PAGE_CACHE_SIZE) { - OBD_FREE(inst, PAGE_CACHE_SIZE); + kfree(inst); return -E2BIG; } } else { @@ -1144,7 +1144,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, rc = server_name2svname(lsi->lsi_svname, inst, NULL, PAGE_CACHE_SIZE); if (rc) { - OBD_FREE(inst, PAGE_CACHE_SIZE); + kfree(inst); return -EINVAL; } pos = strlen(inst); @@ -1302,7 +1302,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, /* continue, even one with error */ } - OBD_FREE(inst, PAGE_CACHE_SIZE); + kfree(inst); return rc; } @@ -1336,7 +1336,7 @@ static int mgc_process_recover_log(struct obd_device *obd, if (cfg->cfg_last_idx == 0) /* the first time */ nrpages = CONFIG_READ_NRPAGES_INIT; - OBD_ALLOC(pages, sizeof(*pages) * nrpages); + pages = kcalloc(nrpages, sizeof(*pages), GFP_NOFS); if (pages == NULL) { rc = -ENOMEM; goto out; @@ -1466,7 +1466,7 @@ out: break; __free_page(pages[i]); } - OBD_FREE(pages, sizeof(*pages) * nrpages); + kfree(pages); } return rc; } @@ -1494,7 +1494,7 @@ static int mgc_process_cfg_log(struct obd_device *mgc, if (cld->cld_cfg.cfg_sb) lsi = s2lsi(cld->cld_cfg.cfg_sb); - OBD_ALLOC_PTR(env); + env = kzalloc(sizeof(*env), GFP_NOFS); if (env == NULL) return -ENOMEM; @@ -1540,7 +1540,7 @@ out_pop: lu_env_fini(env); out_free: - OBD_FREE_PTR(env); + kfree(env); return rc; } From d7279044d819842e465c53b5e25630d67ac49bf8 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 17:51:15 +0200 Subject: [PATCH 0118/1163] staging: lustre: obdclass: Use kzalloc and kfree Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree. A simplified version of the semantic patch that makes these changes is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr,size; @@ - OBD_ALLOC(ptr,size) + ptr = kzalloc(size, GFP_NOFS) @@ expression ptr, size; @@ - OBD_FREE(ptr, size); + kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/acl.c | 29 +++---- drivers/staging/lustre/lustre/obdclass/capa.c | 4 +- .../staging/lustre/lustre/obdclass/cl_io.c | 13 +-- .../staging/lustre/lustre/obdclass/cl_page.c | 2 +- .../lustre/lustre/obdclass/class_obd.c | 4 +- .../staging/lustre/lustre/obdclass/genops.c | 40 ++++----- drivers/staging/lustre/lustre/obdclass/llog.c | 24 +++--- .../staging/lustre/lustre/obdclass/llog_obd.c | 4 +- .../lustre/lustre/obdclass/lprocfs_status.c | 14 +-- .../lustre/lustre/obdclass/lu_object.c | 6 +- .../lustre/lustre/obdclass/lustre_handles.c | 2 +- .../lustre/lustre/obdclass/lustre_peer.c | 6 +- .../lustre/lustre/obdclass/obd_config.c | 50 +++++------ .../lustre/lustre/obdclass/obd_mount.c | 86 +++++++++---------- 14 files changed, 138 insertions(+), 146 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/acl.c b/drivers/staging/lustre/lustre/obdclass/acl.c index 9a69f6b35a0e..194c48a29205 100644 --- a/drivers/staging/lustre/lustre/obdclass/acl.c +++ b/drivers/staging/lustre/lustre/obdclass/acl.c @@ -104,12 +104,12 @@ static int lustre_posix_acl_xattr_reduce_space(posix_acl_xattr_header **header, if (unlikely(old_count <= new_count)) return old_size; - OBD_ALLOC(new, new_size); + new = kzalloc(new_size, GFP_NOFS); if (unlikely(new == NULL)) return -ENOMEM; memcpy(new, *header, new_size); - OBD_FREE(*header, old_size); + kfree(*header); *header = new; return new_size; } @@ -126,12 +126,12 @@ static int lustre_ext_acl_xattr_reduce_space(ext_acl_xattr_header **header, if (unlikely(old_count <= ext_count)) return 0; - OBD_ALLOC(new, ext_size); + new = kzalloc(ext_size, GFP_NOFS); if (unlikely(new == NULL)) return -ENOMEM; memcpy(new, *header, ext_size); - OBD_FREE(*header, old_size); + kfree(*header); *header = new; return 0; } @@ -152,7 +152,7 @@ lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size) else count = CFS_ACL_XATTR_COUNT(size, posix_acl_xattr); esize = CFS_ACL_XATTR_SIZE(count, ext_acl_xattr); - OBD_ALLOC(new, esize); + new = kzalloc(esize, GFP_NOFS); if (unlikely(new == NULL)) return ERR_PTR(-ENOMEM); @@ -183,7 +183,7 @@ int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, size_t size, if (size < sizeof(*new)) return -EINVAL; - OBD_ALLOC(new, size); + new = kzalloc(size, GFP_NOFS); if (unlikely(new == NULL)) return -ENOMEM; @@ -232,7 +232,7 @@ int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, size_t size, _out: if (rc) { - OBD_FREE(new, size); + kfree(new); size = rc; } return size; @@ -244,7 +244,7 @@ EXPORT_SYMBOL(lustre_posix_acl_xattr_filter); */ void lustre_posix_acl_xattr_free(posix_acl_xattr_header *header, int size) { - OBD_FREE(header, size); + kfree(header); } EXPORT_SYMBOL(lustre_posix_acl_xattr_free); @@ -253,8 +253,7 @@ EXPORT_SYMBOL(lustre_posix_acl_xattr_free); */ void lustre_ext_acl_xattr_free(ext_acl_xattr_header *header) { - OBD_FREE(header, CFS_ACL_XATTR_SIZE(le32_to_cpu(header->a_count), \ - ext_acl_xattr)); + kfree(header); } EXPORT_SYMBOL(lustre_ext_acl_xattr_free); @@ -309,7 +308,7 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size, /* there are only base ACL entries at most. */ posix_count = 3; posix_size = CFS_ACL_XATTR_SIZE(posix_count, posix_acl_xattr); - OBD_ALLOC(new, posix_size); + new = kzalloc(posix_size, GFP_NOFS); if (unlikely(new == NULL)) return -ENOMEM; @@ -360,7 +359,7 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size, posix_count = ori_posix_count + ext_count; posix_size = CFS_ACL_XATTR_SIZE(posix_count, posix_acl_xattr); - OBD_ALLOC(new, posix_size); + new = kzalloc(posix_size, GFP_NOFS); if (unlikely(new == NULL)) return -ENOMEM; @@ -402,7 +401,7 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size, _out: if (rc) { - OBD_FREE(new, posix_size); + kfree(new); posix_size = rc; } return posix_size; @@ -432,7 +431,7 @@ lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size, ext_count = posix_count + ori_ext_count; ext_size = CFS_ACL_XATTR_SIZE(ext_count, ext_acl_xattr); - OBD_ALLOC(new, ext_size); + new = kzalloc(ext_size, GFP_NOFS); if (unlikely(new == NULL)) return ERR_PTR(-ENOMEM); @@ -538,7 +537,7 @@ lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size, out: if (rc) { - OBD_FREE(new, ext_size); + kfree(new); new = ERR_PTR(rc); } return new; diff --git a/drivers/staging/lustre/lustre/obdclass/capa.c b/drivers/staging/lustre/lustre/obdclass/capa.c index d206b1046a18..d8d1a66ad68e 100644 --- a/drivers/staging/lustre/lustre/obdclass/capa.c +++ b/drivers/staging/lustre/lustre/obdclass/capa.c @@ -87,7 +87,7 @@ struct hlist_head *init_capa_hash(void) struct hlist_head *hash; int nr_hash, i; - OBD_ALLOC(hash, PAGE_CACHE_SIZE); + hash = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS); if (!hash) return NULL; @@ -129,7 +129,7 @@ void cleanup_capa_hash(struct hlist_head *hash) } spin_unlock(&capa_lock); - OBD_FREE(hash, PAGE_CACHE_SIZE); + kfree(hash); } EXPORT_SYMBOL(cleanup_capa_hash); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index 3141b6043708..fd1a4c5421e8 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -612,7 +612,7 @@ EXPORT_SYMBOL(cl_io_lock_add); static void cl_free_io_lock_link(const struct lu_env *env, struct cl_io_lock_link *link) { - OBD_FREE_PTR(link); + kfree(link); } /** @@ -624,7 +624,7 @@ int cl_io_lock_alloc_add(const struct lu_env *env, struct cl_io *io, struct cl_io_lock_link *link; int result; - OBD_ALLOC_PTR(link); + link = kzalloc(sizeof(*link), GFP_NOFS); if (link != NULL) { link->cill_descr = *descr; link->cill_fini = cl_free_io_lock_link; @@ -1387,9 +1387,9 @@ static void cl_req_free(const struct lu_env *env, struct cl_req *req) cl_object_put(env, obj); } } - OBD_FREE(req->crq_o, req->crq_nrobjs * sizeof(req->crq_o[0])); + kfree(req->crq_o); } - OBD_FREE_PTR(req); + kfree(req); } static int cl_req_init(const struct lu_env *env, struct cl_req *req, @@ -1448,7 +1448,7 @@ struct cl_req *cl_req_alloc(const struct lu_env *env, struct cl_page *page, LINVRNT(nr_objects > 0); - OBD_ALLOC_PTR(req); + req = kzalloc(sizeof(*req), GFP_NOFS); if (req != NULL) { int result; @@ -1456,7 +1456,8 @@ struct cl_req *cl_req_alloc(const struct lu_env *env, struct cl_page *page, INIT_LIST_HEAD(&req->crq_pages); INIT_LIST_HEAD(&req->crq_layers); - OBD_ALLOC(req->crq_o, nr_objects * sizeof(req->crq_o[0])); + req->crq_o = kcalloc(nr_objects, sizeof(req->crq_o[0]), + GFP_NOFS); if (req->crq_o != NULL) { req->crq_nrobjs = nr_objects; result = cl_req_init(env, req, page); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index b7dd04808060..88735530f91b 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -270,7 +270,7 @@ static void cl_page_free(const struct lu_env *env, struct cl_page *page) lu_object_ref_del_at(&obj->co_lu, &page->cp_obj_ref, "cl_page", page); cl_object_put(env, obj); lu_ref_fini(&page->cp_reference); - OBD_FREE(page, pagesize); + kfree(page); } /** diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index d4b74b670c43..6e967af2f6b4 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -231,7 +231,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) err = -EINVAL; goto out; } - OBD_ALLOC(lcfg, data->ioc_plen1); + lcfg = kzalloc(data->ioc_plen1, GFP_NOFS); if (lcfg == NULL) { err = -ENOMEM; goto out; @@ -243,7 +243,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) if (!err) err = class_process_config(lcfg); - OBD_FREE(lcfg, data->ioc_plen1); + kfree(lcfg); goto out; } diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 66b56784f674..a107aea392e1 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -171,13 +171,13 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, } rc = -ENOMEM; - OBD_ALLOC(type, sizeof(*type)); + type = kzalloc(sizeof(*type), GFP_NOFS); if (type == NULL) return rc; - OBD_ALLOC_PTR(type->typ_dt_ops); - OBD_ALLOC_PTR(type->typ_md_ops); - OBD_ALLOC(type->typ_name, strlen(name) + 1); + type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS); + type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS); + type->typ_name = kzalloc(strlen(name) + 1, GFP_NOFS); if (type->typ_dt_ops == NULL || type->typ_md_ops == NULL || @@ -214,12 +214,12 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, failed: if (type->typ_name != NULL) - OBD_FREE(type->typ_name, strlen(name) + 1); + kfree(type->typ_name); if (type->typ_md_ops != NULL) - OBD_FREE_PTR(type->typ_md_ops); + kfree(type->typ_md_ops); if (type->typ_dt_ops != NULL) - OBD_FREE_PTR(type->typ_dt_ops); - OBD_FREE(type, sizeof(*type)); + kfree(type->typ_dt_ops); + kfree(type); return rc; } EXPORT_SYMBOL(class_register_type); @@ -237,8 +237,8 @@ int class_unregister_type(const char *name) CERROR("type %s has refcount (%d)\n", name, type->typ_refcnt); /* This is a bad situation, let's make the best of it */ /* Remove ops, but leave the name for debugging */ - OBD_FREE_PTR(type->typ_dt_ops); - OBD_FREE_PTR(type->typ_md_ops); + kfree(type->typ_dt_ops); + kfree(type->typ_md_ops); return -EBUSY; } @@ -252,12 +252,12 @@ int class_unregister_type(const char *name) spin_lock(&obd_types_lock); list_del(&type->typ_chain); spin_unlock(&obd_types_lock); - OBD_FREE(type->typ_name, strlen(name) + 1); + kfree(type->typ_name); if (type->typ_dt_ops != NULL) - OBD_FREE_PTR(type->typ_dt_ops); + kfree(type->typ_dt_ops); if (type->typ_md_ops != NULL) - OBD_FREE_PTR(type->typ_md_ops); - OBD_FREE(type, sizeof(*type)); + kfree(type->typ_md_ops); + kfree(type); return 0; } /* class_unregister_type */ EXPORT_SYMBOL(class_unregister_type); @@ -819,7 +819,7 @@ struct obd_export *class_new_export(struct obd_device *obd, struct cfs_hash *hash = NULL; int rc = 0; - OBD_ALLOC_PTR(export); + export = kzalloc(sizeof(*export), GFP_NOFS); if (!export) return ERR_PTR(-ENOMEM); @@ -904,7 +904,7 @@ exit_err: class_handle_unhash(&export->exp_handle); LASSERT(hlist_unhashed(&export->exp_uuid_hash)); obd_destroy_export(export); - OBD_FREE_PTR(export); + kfree(export); return ERR_PTR(rc); } EXPORT_SYMBOL(class_new_export); @@ -945,7 +945,7 @@ static void class_import_destroy(struct obd_import *imp) struct obd_import_conn, oic_item); list_del_init(&imp_conn->oic_item); ptlrpc_put_connection_superhack(imp_conn->oic_conn); - OBD_FREE(imp_conn, sizeof(*imp_conn)); + kfree(imp_conn); } LASSERT(imp->imp_sec == NULL); @@ -1008,7 +1008,7 @@ struct obd_import *class_new_import(struct obd_device *obd) { struct obd_import *imp; - OBD_ALLOC(imp, sizeof(*imp)); + imp = kzalloc(sizeof(*imp), GFP_NOFS); if (imp == NULL) return NULL; @@ -1811,7 +1811,7 @@ void *kuc_alloc(int payload_len, int transport, int type) struct kuc_hdr *lh; int len = kuc_len(payload_len); - OBD_ALLOC(lh, len); + lh = kzalloc(len, GFP_NOFS); if (lh == NULL) return ERR_PTR(-ENOMEM); @@ -1828,6 +1828,6 @@ EXPORT_SYMBOL(kuc_alloc); inline void kuc_free(void *p, int payload_len) { struct kuc_hdr *lh = kuc_ptr(p); - OBD_FREE(lh, kuc_len(payload_len)); + kfree(lh); } EXPORT_SYMBOL(kuc_free); diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index 114be4a78ccf..636df94775ec 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -60,7 +60,7 @@ static struct llog_handle *llog_alloc_handle(void) { struct llog_handle *loghandle; - OBD_ALLOC_PTR(loghandle); + loghandle = kzalloc(sizeof(*loghandle), GFP_NOFS); if (loghandle == NULL) return NULL; @@ -88,9 +88,9 @@ static void llog_free_handle(struct llog_handle *loghandle) else if (loghandle->lgh_hdr->llh_flags & LLOG_F_IS_CAT) LASSERT(list_empty(&loghandle->u.chd.chd_head)); LASSERT(sizeof(*(loghandle->lgh_hdr)) == LLOG_CHUNK_SIZE); - OBD_FREE(loghandle->lgh_hdr, LLOG_CHUNK_SIZE); + kfree(loghandle->lgh_hdr); out: - OBD_FREE_PTR(loghandle); + kfree(loghandle); } void llog_handle_get(struct llog_handle *loghandle) @@ -207,7 +207,7 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle, LASSERT(handle->lgh_hdr == NULL); - OBD_ALLOC_PTR(llh); + llh = kzalloc(sizeof(*llh), GFP_NOFS); if (llh == NULL) return -ENOMEM; handle->lgh_hdr = llh; @@ -261,7 +261,7 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle, } out: if (rc) { - OBD_FREE_PTR(llh); + kfree(llh); handle->lgh_hdr = NULL; } return rc; @@ -283,7 +283,7 @@ static int llog_process_thread(void *arg) LASSERT(llh); - OBD_ALLOC(buf, LLOG_CHUNK_SIZE); + buf = kzalloc(LLOG_CHUNK_SIZE, GFP_NOFS); if (!buf) { lpi->lpi_rc = -ENOMEM; return 0; @@ -400,7 +400,7 @@ out: if (cd != NULL) cd->lpcd_last_idx = last_called_index; - OBD_FREE(buf, LLOG_CHUNK_SIZE); + kfree(buf); lpi->lpi_rc = rc; return 0; } @@ -434,7 +434,7 @@ int llog_process_or_fork(const struct lu_env *env, struct llog_process_info *lpi; int rc; - OBD_ALLOC_PTR(lpi); + lpi = kzalloc(sizeof(*lpi), GFP_NOFS); if (lpi == NULL) { CERROR("cannot alloc pointer\n"); return -ENOMEM; @@ -454,7 +454,7 @@ int llog_process_or_fork(const struct lu_env *env, if (IS_ERR_VALUE(rc)) { CERROR("%s: cannot start thread: rc = %d\n", loghandle->lgh_ctxt->loc_obd->obd_name, rc); - OBD_FREE_PTR(lpi); + kfree(lpi); return rc; } wait_for_completion(&lpi->lpi_completion); @@ -463,7 +463,7 @@ int llog_process_or_fork(const struct lu_env *env, llog_process_thread(lpi); } rc = lpi->lpi_rc; - OBD_FREE_PTR(lpi); + kfree(lpi); return rc; } EXPORT_SYMBOL(llog_process_or_fork); @@ -484,7 +484,7 @@ int llog_reverse_process(const struct lu_env *env, void *buf; int rc = 0, first_index = 1, index, idx; - OBD_ALLOC(buf, LLOG_CHUNK_SIZE); + buf = kzalloc(LLOG_CHUNK_SIZE, GFP_NOFS); if (!buf) return -ENOMEM; @@ -564,7 +564,7 @@ int llog_reverse_process(const struct lu_env *env, out: if (buf) - OBD_FREE(buf, LLOG_CHUNK_SIZE); + kfree(buf); return rc; } EXPORT_SYMBOL(llog_reverse_process); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/drivers/staging/lustre/lustre/obdclass/llog_obd.c index 978d886a1103..81ab27e7376f 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_obd.c @@ -46,7 +46,7 @@ static struct llog_ctxt *llog_new_ctxt(struct obd_device *obd) { struct llog_ctxt *ctxt; - OBD_ALLOC_PTR(ctxt); + ctxt = kzalloc(sizeof(*ctxt), GFP_NOFS); if (!ctxt) return NULL; @@ -66,7 +66,7 @@ static void llog_ctxt_destroy(struct llog_ctxt *ctxt) class_import_put(ctxt->loc_imp); ctxt->loc_imp = NULL; } - OBD_FREE_PTR(ctxt); + kfree(ctxt); } int __llog_ctxt_put(const struct lu_env *env, struct llog_ctxt *ctxt) diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index c171c6c6c457..57c6ddd95f3e 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -276,7 +276,7 @@ struct proc_dir_entry *lprocfs_add_symlink(const char *name, if (parent == NULL || format == NULL) return NULL; - OBD_ALLOC_WAIT(dest, MAX_STRING_SIZE + 1); + dest = kzalloc(MAX_STRING_SIZE + 1, GFP_KERNEL); if (dest == NULL) return NULL; @@ -289,7 +289,7 @@ struct proc_dir_entry *lprocfs_add_symlink(const char *name, CERROR("LprocFS: Could not create symbolic link from %s to %s", name, dest); - OBD_FREE(dest, MAX_STRING_SIZE + 1); + kfree(dest); return entry; } EXPORT_SYMBOL(lprocfs_add_symlink); @@ -1006,7 +1006,7 @@ static void lprocfs_free_client_stats(struct nid_stat *client_stat) if (client_stat->nid_ldlm_stats) lprocfs_free_stats(&client_stat->nid_ldlm_stats); - OBD_FREE_PTR(client_stat); + kfree(client_stat); return; } @@ -1681,7 +1681,7 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) CDEBUG(D_CONFIG, "using hash %p\n", obd->obd_nid_stats_hash); - OBD_ALLOC_PTR(new_stat); + new_stat = kzalloc(sizeof(*new_stat), GFP_NOFS); if (new_stat == NULL) return -ENOMEM; @@ -1711,7 +1711,7 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) goto destroy_new; } /* not found - create */ - OBD_ALLOC(buffer, LNET_NIDSTR_SIZE); + buffer = kzalloc(LNET_NIDSTR_SIZE, GFP_NOFS); if (buffer == NULL) { rc = -ENOMEM; goto destroy_new; @@ -1721,7 +1721,7 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) new_stat->nid_proc = lprocfs_register(buffer, obd->obd_proc_exports_entry, NULL, NULL); - OBD_FREE(buffer, LNET_NIDSTR_SIZE); + kfree(buffer); if (IS_ERR(new_stat->nid_proc)) { CERROR("Error making export directory for nid %s\n", @@ -1763,7 +1763,7 @@ destroy_new_ns: destroy_new: nidstat_putref(new_stat); - OBD_FREE_PTR(new_stat); + kfree(new_stat); return rc; } EXPORT_SYMBOL(lprocfs_exp_setup); diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index 20c0779951fd..4458faad1b1a 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -1532,7 +1532,7 @@ static void keys_fini(struct lu_context *ctx) for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) key_fini(ctx, i); - OBD_FREE(ctx->lc_value, ARRAY_SIZE(lu_keys) * sizeof(ctx->lc_value[0])); + kfree(ctx->lc_value); ctx->lc_value = NULL; } @@ -1581,8 +1581,8 @@ static int keys_fill(struct lu_context *ctx) static int keys_init(struct lu_context *ctx) { - OBD_ALLOC(ctx->lc_value, - ARRAY_SIZE(lu_keys) * sizeof(ctx->lc_value[0])); + ctx->lc_value = kcalloc(ARRAY_SIZE(lu_keys), sizeof(ctx->lc_value[0]), + GFP_NOFS); if (likely(ctx->lc_value != NULL)) return keys_fill(ctx); diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index f720e3183295..1cfaabfef6e3 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c @@ -186,7 +186,7 @@ void class_handle_free_cb(struct rcu_head *rcu) if (h->h_ops->hop_free != NULL) h->h_ops->hop_free(ptr, h->h_size); else - OBD_FREE(ptr, h->h_size); + kfree(ptr); } EXPORT_SYMBOL(class_handle_free_cb); diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c index 64b2f35e224f..5cc6435cc47a 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c @@ -104,7 +104,7 @@ int class_add_uuid(const char *uuid, __u64 nid) if (strlen(uuid) > UUID_MAX - 1) return -EOVERFLOW; - OBD_ALLOC_PTR(data); + data = kzalloc(sizeof(*data), GFP_NOFS); if (data == NULL) return -ENOMEM; @@ -136,7 +136,7 @@ int class_add_uuid(const char *uuid, __u64 nid) if (found) { CDEBUG(D_INFO, "found uuid %s %s cnt=%d\n", uuid, libcfs_nid2str(nid), entry->un_nid_count); - OBD_FREE(data, sizeof(*data)); + kfree(data); } else { CDEBUG(D_INFO, "add uuid %s %s\n", uuid, libcfs_nid2str(nid)); } @@ -180,7 +180,7 @@ int class_del_uuid(const char *uuid) libcfs_nid2str(data->un_nids[0]), data->un_nid_count); - OBD_FREE(data, sizeof(*data)); + kfree(data); } return 0; diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 6ce9adc2f11c..687fbbd1eb3f 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -860,13 +860,13 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, CDEBUG(D_CONFIG, "Add profile %s\n", prof); - OBD_ALLOC(lprof, sizeof(*lprof)); + lprof = kzalloc(sizeof(*lprof), GFP_NOFS); if (lprof == NULL) return -ENOMEM; INIT_LIST_HEAD(&lprof->lp_list); LASSERT(proflen == (strlen(prof) + 1)); - OBD_ALLOC(lprof->lp_profile, proflen); + lprof->lp_profile = kzalloc(proflen, GFP_NOFS); if (lprof->lp_profile == NULL) { err = -ENOMEM; goto out; @@ -874,7 +874,7 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, memcpy(lprof->lp_profile, prof, proflen); LASSERT(osclen == (strlen(osc) + 1)); - OBD_ALLOC(lprof->lp_dt, osclen); + lprof->lp_dt = kzalloc(osclen, GFP_NOFS); if (lprof->lp_dt == NULL) { err = -ENOMEM; goto out; @@ -883,7 +883,7 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, if (mdclen > 0) { LASSERT(mdclen == (strlen(mdc) + 1)); - OBD_ALLOC(lprof->lp_md, mdclen); + lprof->lp_md = kzalloc(mdclen, GFP_NOFS); if (lprof->lp_md == NULL) { err = -ENOMEM; goto out; @@ -896,12 +896,12 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, out: if (lprof->lp_md) - OBD_FREE(lprof->lp_md, mdclen); + kfree(lprof->lp_md); if (lprof->lp_dt) - OBD_FREE(lprof->lp_dt, osclen); + kfree(lprof->lp_dt); if (lprof->lp_profile) - OBD_FREE(lprof->lp_profile, proflen); - OBD_FREE(lprof, sizeof(*lprof)); + kfree(lprof->lp_profile); + kfree(lprof); return err; } @@ -914,11 +914,11 @@ void class_del_profile(const char *prof) lprof = class_get_profile(prof); if (lprof) { list_del(&lprof->lp_list); - OBD_FREE(lprof->lp_profile, strlen(lprof->lp_profile) + 1); - OBD_FREE(lprof->lp_dt, strlen(lprof->lp_dt) + 1); + kfree(lprof->lp_profile); + kfree(lprof->lp_dt); if (lprof->lp_md) - OBD_FREE(lprof->lp_md, strlen(lprof->lp_md) + 1); - OBD_FREE(lprof, sizeof(*lprof)); + kfree(lprof->lp_md); + kfree(lprof); } } EXPORT_SYMBOL(class_del_profile); @@ -930,11 +930,11 @@ void class_del_profiles(void) list_for_each_entry_safe(lprof, n, &lustre_profile_list, lp_list) { list_del(&lprof->lp_list); - OBD_FREE(lprof->lp_profile, strlen(lprof->lp_profile) + 1); - OBD_FREE(lprof->lp_dt, strlen(lprof->lp_dt) + 1); + kfree(lprof->lp_profile); + kfree(lprof->lp_dt); if (lprof->lp_md) - OBD_FREE(lprof->lp_md, strlen(lprof->lp_md) + 1); - OBD_FREE(lprof, sizeof(*lprof)); + kfree(lprof->lp_md); + kfree(lprof); } } EXPORT_SYMBOL(class_del_profiles); @@ -1011,7 +1011,7 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, new_len = LUSTRE_CFG_BUFLEN(cfg, 1) + strlen(new_name) - name_len; - OBD_ALLOC(new_param, new_len); + new_param = kzalloc(new_len, GFP_NOFS); if (new_param == NULL) return ERR_PTR(-ENOMEM); @@ -1019,9 +1019,9 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, if (value != NULL) strcat(new_param, value); - OBD_ALLOC_PTR(bufs); + bufs = kzalloc(sizeof(*bufs), GFP_NOFS); if (bufs == NULL) { - OBD_FREE(new_param, new_len); + kfree(new_param); return ERR_PTR(-ENOMEM); } @@ -1031,8 +1031,8 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, new_cfg = lustre_cfg_new(cfg->lcfg_command, bufs); - OBD_FREE(new_param, new_len); - OBD_FREE_PTR(bufs); + kfree(new_param); + kfree(bufs); if (new_cfg == NULL) return ERR_PTR(-ENOMEM); @@ -1493,7 +1493,7 @@ int class_config_llog_handler(const struct lu_env *env, inst = 1; inst_len = LUSTRE_CFG_BUFLEN(lcfg, 0) + sizeof(clli->cfg_instance) * 2 + 4; - OBD_ALLOC(inst_name, inst_len); + inst_name = kzalloc(inst_len, GFP_NOFS); if (inst_name == NULL) { rc = -ENOMEM; goto out; @@ -1556,7 +1556,7 @@ int class_config_llog_handler(const struct lu_env *env, lustre_cfg_free(lcfg_new); if (inst) - OBD_FREE(inst_name, inst_len); + kfree(inst_name); break; } default: @@ -1671,7 +1671,7 @@ int class_config_dump_handler(const struct lu_env *env, char *outstr; int rc = 0; - OBD_ALLOC(outstr, 256); + outstr = kzalloc(256, GFP_NOFS); if (outstr == NULL) return -ENOMEM; @@ -1683,7 +1683,7 @@ int class_config_dump_handler(const struct lu_env *env, rc = -EINVAL; } - OBD_FREE(outstr, 256); + kfree(outstr); return rc; } diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 3437b2ecfc02..04a2216964dc 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -84,7 +84,7 @@ int lustre_process_log(struct super_block *sb, char *logname, LASSERT(mgc); LASSERT(cfg); - OBD_ALLOC_PTR(bufs); + bufs = kzalloc(sizeof(*bufs), GFP_NOFS); if (bufs == NULL) return -ENOMEM; @@ -97,7 +97,7 @@ int lustre_process_log(struct super_block *sb, char *logname, rc = obd_process_config(mgc, sizeof(*lcfg), lcfg); lustre_cfg_free(lcfg); - OBD_FREE_PTR(bufs); + kfree(bufs); if (rc == -EINVAL) LCONSOLE_ERROR_MSG(0x15b, "%s: The configuration from log '%s' failed from the MGS (%d). Make sure this client and the MGS are running compatible versions of Lustre.\n", @@ -247,8 +247,8 @@ int lustre_start_mgc(struct super_block *sb) mutex_lock(&mgc_start_lock); len = strlen(LUSTRE_MGC_OBDNAME) + strlen(libcfs_nid2str(nid)) + 1; - OBD_ALLOC(mgcname, len); - OBD_ALLOC(niduuid, len + 2); + mgcname = kzalloc(len, GFP_NOFS); + niduuid = kzalloc(len + 2, GFP_NOFS); if (!mgcname || !niduuid) { rc = -ENOMEM; goto out_free; @@ -257,7 +257,7 @@ int lustre_start_mgc(struct super_block *sb) mgssec = lsi->lsi_lmd->lmd_mgssec ? lsi->lsi_lmd->lmd_mgssec : ""; - OBD_ALLOC_PTR(data); + data = kzalloc(sizeof(*data), GFP_NOFS); if (data == NULL) { rc = -ENOMEM; goto out_free; @@ -375,7 +375,7 @@ int lustre_start_mgc(struct super_block *sb) lsi->lsi_lmd->lmd_mgs_failnodes = 1; /* Random uuid for MGC allows easier reconnects */ - OBD_ALLOC_PTR(uuid); + uuid = kzalloc(sizeof(*uuid), GFP_NOFS); if (!uuid) { rc = -ENOMEM; goto out_free; @@ -388,7 +388,7 @@ int lustre_start_mgc(struct super_block *sb) rc = lustre_start_simple(mgcname, LUSTRE_MGC_NAME, (char *)uuid->uuid, LUSTRE_MGS_OBDNAME, niduuid, NULL, NULL); - OBD_FREE_PTR(uuid); + kfree(uuid); if (rc) goto out_free; @@ -465,11 +465,11 @@ out_free: mutex_unlock(&mgc_start_lock); if (data) - OBD_FREE_PTR(data); + kfree(data); if (mgcname) - OBD_FREE(mgcname, len); + kfree(mgcname); if (niduuid) - OBD_FREE(niduuid, len + 2); + kfree(niduuid); return rc; } @@ -513,7 +513,7 @@ static int lustre_stop_mgc(struct super_block *sb) /* Save the obdname for cleaning the nid uuids, which are obdname_XX */ len = strlen(obd->obd_name) + 6; - OBD_ALLOC(niduuid, len); + niduuid = kzalloc(len, GFP_NOFS); if (niduuid) { strcpy(niduuid, obd->obd_name); ptr = niduuid + strlen(niduuid); @@ -539,7 +539,7 @@ static int lustre_stop_mgc(struct super_block *sb) } out: if (niduuid) - OBD_FREE(niduuid, len); + kfree(niduuid); /* class_import_put will get rid of the additional connections */ mutex_unlock(&mgc_start_lock); @@ -552,12 +552,12 @@ struct lustre_sb_info *lustre_init_lsi(struct super_block *sb) { struct lustre_sb_info *lsi; - OBD_ALLOC_PTR(lsi); + lsi = kzalloc(sizeof(*lsi), GFP_NOFS); if (!lsi) return NULL; - OBD_ALLOC_PTR(lsi->lsi_lmd); + lsi->lsi_lmd = kzalloc(sizeof(*lsi->lsi_lmd), GFP_NOFS); if (!lsi->lsi_lmd) { - OBD_FREE_PTR(lsi); + kfree(lsi); return NULL; } @@ -586,35 +586,27 @@ static int lustre_free_lsi(struct super_block *sb) if (lsi->lsi_lmd != NULL) { if (lsi->lsi_lmd->lmd_dev != NULL) - OBD_FREE(lsi->lsi_lmd->lmd_dev, - strlen(lsi->lsi_lmd->lmd_dev) + 1); + kfree(lsi->lsi_lmd->lmd_dev); if (lsi->lsi_lmd->lmd_profile != NULL) - OBD_FREE(lsi->lsi_lmd->lmd_profile, - strlen(lsi->lsi_lmd->lmd_profile) + 1); + kfree(lsi->lsi_lmd->lmd_profile); if (lsi->lsi_lmd->lmd_mgssec != NULL) - OBD_FREE(lsi->lsi_lmd->lmd_mgssec, - strlen(lsi->lsi_lmd->lmd_mgssec) + 1); + kfree(lsi->lsi_lmd->lmd_mgssec); if (lsi->lsi_lmd->lmd_opts != NULL) - OBD_FREE(lsi->lsi_lmd->lmd_opts, - strlen(lsi->lsi_lmd->lmd_opts) + 1); + kfree(lsi->lsi_lmd->lmd_opts); if (lsi->lsi_lmd->lmd_exclude_count) - OBD_FREE(lsi->lsi_lmd->lmd_exclude, - sizeof(lsi->lsi_lmd->lmd_exclude[0]) * - lsi->lsi_lmd->lmd_exclude_count); + kfree(lsi->lsi_lmd->lmd_exclude); if (lsi->lsi_lmd->lmd_mgs != NULL) - OBD_FREE(lsi->lsi_lmd->lmd_mgs, - strlen(lsi->lsi_lmd->lmd_mgs) + 1); + kfree(lsi->lsi_lmd->lmd_mgs); if (lsi->lsi_lmd->lmd_osd_type != NULL) - OBD_FREE(lsi->lsi_lmd->lmd_osd_type, - strlen(lsi->lsi_lmd->lmd_osd_type) + 1); + kfree(lsi->lsi_lmd->lmd_osd_type); if (lsi->lsi_lmd->lmd_params != NULL) - OBD_FREE(lsi->lsi_lmd->lmd_params, 4096); + kfree(lsi->lsi_lmd->lmd_params); - OBD_FREE(lsi->lsi_lmd, sizeof(*lsi->lsi_lmd)); + kfree(lsi->lsi_lmd); } LASSERT(lsi->lsi_llsbi == NULL); - OBD_FREE(lsi, sizeof(*lsi)); + kfree(lsi); s2lsi_nocast(sb) = NULL; return 0; @@ -846,7 +838,7 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr) devmax = strlen(ptr) / 8 + 1; /* temp storage until we figure out how many we have */ - OBD_ALLOC(exclude_list, sizeof(index) * devmax); + exclude_list = kcalloc(devmax, sizeof(index), GFP_NOFS); if (!exclude_list) return -ENOMEM; @@ -875,8 +867,8 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr) if (lmd->lmd_exclude_count) { /* permanent, freed in lustre_free_lsi */ - OBD_ALLOC(lmd->lmd_exclude, sizeof(index) * - lmd->lmd_exclude_count); + lmd->lmd_exclude = kcalloc(lmd->lmd_exclude_count, + sizeof(index), GFP_NOFS); if (lmd->lmd_exclude) { memcpy(lmd->lmd_exclude, exclude_list, sizeof(index) * lmd->lmd_exclude_count); @@ -885,7 +877,7 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr) lmd->lmd_exclude_count = 0; } } - OBD_FREE(exclude_list, sizeof(index) * devmax); + kfree(exclude_list); return rc; } @@ -895,7 +887,7 @@ static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr) int length; if (lmd->lmd_mgssec != NULL) { - OBD_FREE(lmd->lmd_mgssec, strlen(lmd->lmd_mgssec) + 1); + kfree(lmd->lmd_mgssec); lmd->lmd_mgssec = NULL; } @@ -905,7 +897,7 @@ static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr) else length = tail - ptr; - OBD_ALLOC(lmd->lmd_mgssec, length + 1); + lmd->lmd_mgssec = kzalloc(length + 1, GFP_NOFS); if (lmd->lmd_mgssec == NULL) return -ENOMEM; @@ -923,7 +915,7 @@ static int lmd_parse_string(char **handle, char *ptr) return -EINVAL; if (*handle != NULL) { - OBD_FREE(*handle, strlen(*handle) + 1); + kfree(*handle); *handle = NULL; } @@ -933,7 +925,7 @@ static int lmd_parse_string(char **handle, char *ptr) else length = tail - ptr; - OBD_ALLOC(*handle, length + 1); + *handle = kzalloc(length + 1, GFP_NOFS); if (*handle == NULL) return -ENOMEM; @@ -963,7 +955,7 @@ static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr) if (lmd->lmd_mgs != NULL) oldlen = strlen(lmd->lmd_mgs) + 1; - OBD_ALLOC(mgsnid, oldlen + length + 1); + mgsnid = kzalloc(oldlen + length + 1, GFP_NOFS); if (mgsnid == NULL) return -ENOMEM; @@ -971,7 +963,7 @@ static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr) /* Multiple mgsnid= are taken to mean failover locations */ memcpy(mgsnid, lmd->lmd_mgs, oldlen); mgsnid[oldlen - 1] = ':'; - OBD_FREE(lmd->lmd_mgs, oldlen); + kfree(lmd->lmd_mgs); } memcpy(mgsnid + oldlen, *ptr, length); mgsnid[oldlen + length] = '\0'; @@ -1005,7 +997,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) } lmd->lmd_magic = LMD_MAGIC; - OBD_ALLOC(lmd->lmd_params, 4096); + lmd->lmd_params = kzalloc(4096, GFP_NOFS); if (lmd->lmd_params == NULL) return -ENOMEM; lmd->lmd_params[0] = '\0'; @@ -1143,14 +1135,14 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) /* Remove leading /s from fsname */ while (*++s1 == '/') ; /* Freed in lustre_free_lsi */ - OBD_ALLOC(lmd->lmd_profile, strlen(s1) + 8); + lmd->lmd_profile = kzalloc(strlen(s1) + 8, GFP_NOFS); if (!lmd->lmd_profile) return -ENOMEM; sprintf(lmd->lmd_profile, "%s-client", s1); } /* Freed in lustre_free_lsi */ - OBD_ALLOC(lmd->lmd_dev, strlen(devname) + 1); + lmd->lmd_dev = kzalloc(strlen(devname) + 1, GFP_NOFS); if (!lmd->lmd_dev) return -ENOMEM; strcpy(lmd->lmd_dev, devname); @@ -1161,7 +1153,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) *s1-- = 0; if (*options != 0) { /* Freed in lustre_free_lsi */ - OBD_ALLOC(lmd->lmd_opts, strlen(options) + 1); + lmd->lmd_opts = kzalloc(strlen(options) + 1, GFP_NOFS); if (!lmd->lmd_opts) return -ENOMEM; strcpy(lmd->lmd_opts, options); From c5b895201c3097d8414ba520a06a545794400e0c Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 17:51:14 +0200 Subject: [PATCH 0119/1163] staging: lustre: obdecho: Use kzalloc and kfree Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree. A simplified version of the semantic patch that makes these changes is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr,size; @@ - OBD_ALLOC(ptr,size) + ptr = kzalloc(size, GFP_NOFS) @@ expression ptr, size; @@ - OBD_FREE(ptr, size); + kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/obdecho/echo_client.c | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index d542e06d6cd3..cf645388dc75 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -479,13 +479,13 @@ static int echo_alloc_memmd(struct echo_device *ed, lsm_size = lov_stripe_md_size(1); LASSERT(*lsmp == NULL); - OBD_ALLOC(*lsmp, lsm_size); + *lsmp = kzalloc(lsm_size, GFP_NOFS); if (*lsmp == NULL) return -ENOMEM; - OBD_ALLOC((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); + (*lsmp)->lsm_oinfo[0] = kzalloc(sizeof(struct lov_oinfo), GFP_NOFS); if ((*lsmp)->lsm_oinfo[0] == NULL) { - OBD_FREE(*lsmp, lsm_size); + kfree(*lsmp); return -ENOMEM; } @@ -507,8 +507,8 @@ static int echo_free_memmd(struct echo_device *ed, struct lov_stripe_md **lsmp) lsm_size = lov_stripe_md_size(1); LASSERT(*lsmp != NULL); - OBD_FREE((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); - OBD_FREE(*lsmp, lsm_size); + kfree((*lsmp)->lsm_oinfo[0]); + kfree(*lsmp); *lsmp = NULL; return 0; } @@ -700,7 +700,7 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env, int rc; int cleanup = 0; - OBD_ALLOC_PTR(ed); + ed = kzalloc(sizeof(*ed), GFP_NOFS); if (ed == NULL) { rc = -ENOMEM; goto out; @@ -798,7 +798,7 @@ out: case 2: cl_device_fini(&ed->ed_cl); case 1: - OBD_FREE_PTR(ed); + kfree(ed); case 0: default: break; @@ -895,7 +895,7 @@ static struct lu_device *echo_device_free(const struct lu_env *env, LASSERT(ed->ed_site == lu2cl_site(d->ld_site)); echo_site_fini(env, ed); cl_device_fini(&ed->ed_cl); - OBD_FREE_PTR(ed); + kfree(ed); return NULL; } @@ -1577,13 +1577,13 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, if (rw == OBD_BRW_WRITE) brw_flags = OBD_BRW_ASYNC; - OBD_ALLOC(pga, npages * sizeof(*pga)); + pga = kcalloc(npages, sizeof(*pga), GFP_NOFS); if (pga == NULL) return -ENOMEM; - OBD_ALLOC(pages, npages * sizeof(*pages)); + pages = kcalloc(npages, sizeof(*pages), GFP_NOFS); if (pages == NULL) { - OBD_FREE(pga, npages * sizeof(*pga)); + kfree(pga); return -ENOMEM; } @@ -1632,8 +1632,8 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, } OBD_PAGE_FREE(pgp->pg); } - OBD_FREE(pga, npages * sizeof(*pga)); - OBD_FREE(pages, npages * sizeof(*pages)); + kfree(pga); + kfree(pages); return rc; } @@ -1659,8 +1659,8 @@ static int echo_client_prep_commit(const struct lu_env *env, npages = batch >> PAGE_CACHE_SHIFT; tot_pages = count >> PAGE_CACHE_SHIFT; - OBD_ALLOC(lnb, npages * sizeof(struct niobuf_local)); - OBD_ALLOC(rnb, npages * sizeof(struct niobuf_remote)); + lnb = kcalloc(npages, sizeof(struct niobuf_local), GFP_NOFS); + rnb = kcalloc(npages, sizeof(struct niobuf_remote), GFP_NOFS); if (lnb == NULL || rnb == NULL) { ret = -ENOMEM; @@ -1738,9 +1738,9 @@ static int echo_client_prep_commit(const struct lu_env *env, out: if (lnb) - OBD_FREE(lnb, npages * sizeof(struct niobuf_local)); + kfree(lnb); if (rnb) - OBD_FREE(rnb, npages * sizeof(struct niobuf_remote)); + kfree(rnb); return ret; } @@ -1879,7 +1879,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, if (rc < 0) return rc; - OBD_ALLOC_PTR(env); + env = kzalloc(sizeof(*env), GFP_NOFS); if (env == NULL) return -ENOMEM; @@ -2010,7 +2010,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, out: lu_env_fini(env); - OBD_FREE_PTR(env); + kfree(env); /* XXX this should be in a helper also called by target_send_reply */ for (ack_lock = dummy_oti.oti_ack_locks, i = 0; i < 4; @@ -2050,7 +2050,7 @@ static int echo_client_setup(const struct lu_env *env, ec->ec_unique = 0; ec->ec_nstripes = 0; - OBD_ALLOC(ocd, sizeof(*ocd)); + ocd = kzalloc(sizeof(*ocd), GFP_NOFS); if (ocd == NULL) { CERROR("Can't alloc ocd connecting to %s\n", lustre_cfg_string(lcfg, 1)); @@ -2074,7 +2074,7 @@ static int echo_client_setup(const struct lu_env *env, spin_unlock(&tgt->obd_dev_lock); } - OBD_FREE(ocd, sizeof(*ocd)); + kfree(ocd); if (rc != 0) { CERROR("fail to connect to device %s\n", From 7795178d1ec256d21a48a0dcffae5f38055b7cd5 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 17:51:13 +0200 Subject: [PATCH 0120/1163] staging: lustre: osc: Use kzalloc and kfree Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree. A simplified version of the semantic patch that makes these changes is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr,size; @@ - OBD_ALLOC(ptr,size) + ptr = kzalloc(size, GFP_NOFS) @@ expression ptr, size; @@ - OBD_FREE(ptr, size); + kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/osc/osc_dev.c | 4 +-- .../staging/lustre/lustre/osc/osc_request.c | 33 ++++++++++--------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_dev.c b/drivers/staging/lustre/lustre/osc/osc_dev.c index 4935fc7c0706..ce5c3af1237b 100644 --- a/drivers/staging/lustre/lustre/osc/osc_dev.c +++ b/drivers/staging/lustre/lustre/osc/osc_dev.c @@ -204,7 +204,7 @@ static struct lu_device *osc_device_free(const struct lu_env *env, struct osc_device *od = lu2osc_dev(d); cl_device_fini(lu2cl_dev(d)); - OBD_FREE_PTR(od); + kfree(od); return NULL; } @@ -217,7 +217,7 @@ static struct lu_device *osc_device_alloc(const struct lu_env *env, struct obd_device *obd; int rc; - OBD_ALLOC_PTR(od); + od = kzalloc(sizeof(*od), GFP_NOFS); if (od == NULL) return ERR_PTR(-ENOMEM); diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index d7a9b650df09..7ddf46b7ce43 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -110,7 +110,7 @@ static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, return lmm_size; if (*lmmp != NULL && lsm == NULL) { - OBD_FREE(*lmmp, lmm_size); + kfree(*lmmp); *lmmp = NULL; return 0; } else if (unlikely(lsm != NULL && ostid_id(&lsm->lsm_oi) == 0)) { @@ -118,7 +118,7 @@ static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, } if (*lmmp == NULL) { - OBD_ALLOC(*lmmp, lmm_size); + *lmmp = kzalloc(lmm_size, GFP_NOFS); if (*lmmp == NULL) return -ENOMEM; } @@ -157,19 +157,20 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, return lsm_size; if (*lsmp != NULL && lmm == NULL) { - OBD_FREE((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); - OBD_FREE(*lsmp, lsm_size); + kfree((*lsmp)->lsm_oinfo[0]); + kfree(*lsmp); *lsmp = NULL; return 0; } if (*lsmp == NULL) { - OBD_ALLOC(*lsmp, lsm_size); + *lsmp = kzalloc(lsm_size, GFP_NOFS); if (unlikely(*lsmp == NULL)) return -ENOMEM; - OBD_ALLOC((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); + (*lsmp)->lsm_oinfo[0] = kzalloc(sizeof(struct lov_oinfo), + GFP_NOFS); if (unlikely((*lsmp)->lsm_oinfo[0] == NULL)) { - OBD_FREE(*lsmp, lsm_size); + kfree(*lsmp); return -ENOMEM; } loi_init((*lsmp)->lsm_oinfo[0]); @@ -962,7 +963,7 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes) } client_obd_list_unlock(&cli->cl_loi_list_lock); - OBD_ALLOC_PTR(body); + body = kzalloc(sizeof(*body), GFP_NOFS); if (!body) return -ENOMEM; @@ -984,7 +985,7 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes) sizeof(*body), body, NULL); if (rc != 0) __osc_update_grant(cli, body->oa.o_grant); - OBD_FREE_PTR(body); + kfree(body); return rc; } @@ -1748,7 +1749,7 @@ static void sort_brw_pages(struct brw_page **array, int num) static void osc_release_ppga(struct brw_page **ppga, u32 count) { LASSERT(ppga != NULL); - OBD_FREE(ppga, sizeof(*ppga) * count); + kfree(ppga); } static int brw_interpret(const struct lu_env *env, @@ -1908,13 +1909,13 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, if (mem_tight) mpflag = cfs_memory_pressure_get_and_set(); - OBD_ALLOC(crattr, sizeof(*crattr)); + crattr = kzalloc(sizeof(*crattr), GFP_NOFS); if (crattr == NULL) { rc = -ENOMEM; goto out; } - OBD_ALLOC(pga, sizeof(*pga) * page_count); + pga = kcalloc(page_count, sizeof(*pga), GFP_NOFS); if (pga == NULL) { rc = -ENOMEM; goto out; @@ -2055,7 +2056,7 @@ out: if (crattr != NULL) { capa_put(crattr->cra_capa); - OBD_FREE(crattr, sizeof(*crattr)); + kfree(crattr); } if (rc != 0) { @@ -2064,7 +2065,7 @@ out: if (oa) OBDO_FREE(oa); if (pga) - OBD_FREE(pga, sizeof(*pga) * page_count); + kfree(pga); /* this should happen rarely and is pretty bad, it makes the * pending list not follow the dirty order */ while (!list_empty(ext_list)) { @@ -2617,7 +2618,7 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump) * because lov_user_md_vX and lov_mds_md_vX have the same size */ if (lum.lmm_stripe_count > 0) { lum_size = lov_mds_md_size(lum.lmm_stripe_count, lum.lmm_magic); - OBD_ALLOC(lumk, lum_size); + lumk = kzalloc(lum_size, GFP_NOFS); if (!lumk) return -ENOMEM; @@ -2639,7 +2640,7 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump) rc = -EFAULT; if (lumk != &lum) - OBD_FREE(lumk, lum_size); + kfree(lumk); return rc; } From 9ae10597280cede9b2462b96cec7398cbbf1459f Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 17:51:12 +0200 Subject: [PATCH 0121/1163] staging: lustre: ptlrpc: Use kzalloc and kfree Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree. A simplified version of the semantic patch that makes these changes is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr,size; @@ - OBD_ALLOC(ptr,size) + ptr = kzalloc(size, GFP_NOFS) @@ expression ptr, size; @@ - OBD_FREE(ptr, size); + kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/client.c | 18 ++++---- .../staging/lustre/lustre/ptlrpc/connection.c | 6 +-- .../lustre/lustre/ptlrpc/lproc_ptlrpc.c | 24 +++++------ drivers/staging/lustre/lustre/ptlrpc/nrs.c | 18 ++++---- .../staging/lustre/lustre/ptlrpc/nrs_fifo.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/pinger.c | 6 +-- .../staging/lustre/lustre/ptlrpc/ptlrpcd.c | 14 +++---- drivers/staging/lustre/lustre/ptlrpc/sec.c | 2 +- .../staging/lustre/lustre/ptlrpc/sec_bulk.c | 17 ++++---- .../staging/lustre/lustre/ptlrpc/sec_config.c | 16 ++++--- .../staging/lustre/lustre/ptlrpc/sec_plain.c | 10 ++--- .../staging/lustre/lustre/ptlrpc/service.c | 42 +++++++++---------- 12 files changed, 84 insertions(+), 91 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 0357f1d4532f..45b7af77c37e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -103,7 +103,8 @@ struct ptlrpc_bulk_desc *ptlrpc_new_bulk(unsigned npages, unsigned max_brw, struct ptlrpc_bulk_desc *desc; int i; - OBD_ALLOC(desc, offsetof(struct ptlrpc_bulk_desc, bd_iov[npages])); + desc = kzalloc(offsetof(struct ptlrpc_bulk_desc, bd_iov[npages]), + GFP_NOFS); if (!desc) return NULL; @@ -205,8 +206,7 @@ void __ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc, int unpin) page_cache_release(desc->bd_iov[i].kiov_page); } - OBD_FREE(desc, offsetof(struct ptlrpc_bulk_desc, - bd_iov[desc->bd_max_iov])); + kfree(desc); } EXPORT_SYMBOL(__ptlrpc_free_bulk); @@ -439,7 +439,7 @@ void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool) ptlrpc_request_cache_free(req); } spin_unlock(&pool->prp_lock); - OBD_FREE(pool, sizeof(*pool)); + kfree(pool); } EXPORT_SYMBOL(ptlrpc_free_rq_pool); @@ -498,7 +498,7 @@ ptlrpc_init_rq_pool(int num_rq, int msgsize, { struct ptlrpc_request_pool *pool; - OBD_ALLOC(pool, sizeof(struct ptlrpc_request_pool)); + pool = kzalloc(sizeof(struct ptlrpc_request_pool), GFP_NOFS); if (!pool) return NULL; @@ -514,7 +514,7 @@ ptlrpc_init_rq_pool(int num_rq, int msgsize, if (list_empty(&pool->prp_req_list)) { /* have not allocated a single request for the pool */ - OBD_FREE(pool, sizeof(struct ptlrpc_request_pool)); + kfree(pool); pool = NULL; } return pool; @@ -856,7 +856,7 @@ struct ptlrpc_request_set *ptlrpc_prep_set(void) { struct ptlrpc_request_set *set; - OBD_ALLOC(set, sizeof(*set)); + set = kzalloc(sizeof(*set), GFP_NOFS); if (!set) return NULL; atomic_set(&set->set_refcount, 1); @@ -970,7 +970,7 @@ int ptlrpc_set_add_cb(struct ptlrpc_request_set *set, { struct ptlrpc_set_cbdata *cbdata; - OBD_ALLOC_PTR(cbdata); + cbdata = kzalloc(sizeof(*cbdata), GFP_NOFS); if (cbdata == NULL) return -ENOMEM; @@ -2214,7 +2214,7 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set) err = cbdata->psc_interpret(set, cbdata->psc_data, rc); if (err && !rc) rc = err; - OBD_FREE_PTR(cbdata); + kfree(cbdata); } } diff --git a/drivers/staging/lustre/lustre/ptlrpc/connection.c b/drivers/staging/lustre/lustre/ptlrpc/connection.c index 7e27397ce384..ffe36e22245f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/connection.c +++ b/drivers/staging/lustre/lustre/ptlrpc/connection.c @@ -54,7 +54,7 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self, if (conn) goto out; - OBD_ALLOC_PTR(conn); + conn = kzalloc(sizeof(*conn), GFP_NOFS); if (!conn) return NULL; @@ -76,7 +76,7 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self, /* coverity[overrun-buffer-val] */ conn2 = cfs_hash_findadd_unique(conn_hash, &peer, &conn->c_hash); if (conn != conn2) { - OBD_FREE_PTR(conn); + kfree(conn); conn = conn2; } out: @@ -227,7 +227,7 @@ conn_exit(struct cfs_hash *hs, struct hlist_node *hnode) LASSERTF(atomic_read(&conn->c_refcount) == 0, "Busy connection with %d refs\n", atomic_read(&conn->c_refcount)); - OBD_FREE_PTR(conn); + kfree(conn); } static cfs_hash_ops_t conn_hash_ops = { diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 9533ab976a33..139178451263 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -507,7 +507,7 @@ static int ptlrpc_lprocfs_nrs_seq_show(struct seq_file *m, void *n) num_pols = svc->srv_parts[0]->scp_nrs_reg.nrs_num_pols; spin_unlock(&nrs->nrs_lock); - OBD_ALLOC(infos, num_pols * sizeof(*infos)); + infos = kcalloc(num_pols, sizeof(*infos), GFP_NOFS); if (infos == NULL) { rc = -ENOMEM; goto out; @@ -619,7 +619,7 @@ again: out: if (infos) - OBD_FREE(infos, num_pols * sizeof(*infos)); + kfree(infos); mutex_unlock(&nrs_core.nrs_mutex); @@ -655,7 +655,7 @@ static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file, goto out; } - OBD_ALLOC(cmd, LPROCFS_NRS_WR_MAX_CMD); + cmd = kzalloc(LPROCFS_NRS_WR_MAX_CMD, GFP_NOFS); if (cmd == NULL) { rc = -ENOMEM; goto out; @@ -717,7 +717,7 @@ default_queue: mutex_unlock(&nrs_core.nrs_mutex); out: if (cmd_copy) - OBD_FREE(cmd_copy, LPROCFS_NRS_WR_MAX_CMD); + kfree(cmd_copy); return rc < 0 ? rc : count; } @@ -825,7 +825,7 @@ ptlrpc_lprocfs_svc_req_history_start(struct seq_file *s, loff_t *pos) return NULL; } - OBD_ALLOC(srhi, sizeof(*srhi)); + srhi = kzalloc(sizeof(*srhi), GFP_NOFS); if (srhi == NULL) return NULL; @@ -851,7 +851,7 @@ ptlrpc_lprocfs_svc_req_history_start(struct seq_file *s, loff_t *pos) } } - OBD_FREE(srhi, sizeof(*srhi)); + kfree(srhi); return NULL; } @@ -861,7 +861,7 @@ ptlrpc_lprocfs_svc_req_history_stop(struct seq_file *s, void *iter) struct ptlrpc_srh_iterator *srhi = iter; if (srhi != NULL) - OBD_FREE(srhi, sizeof(*srhi)); + kfree(srhi); } static void * @@ -895,7 +895,7 @@ ptlrpc_lprocfs_svc_req_history_next(struct seq_file *s, } } - OBD_FREE(srhi, sizeof(*srhi)); + kfree(srhi); return NULL; } @@ -1191,7 +1191,7 @@ int lprocfs_wr_evict_client(struct file *file, const char __user *buffer, char *kbuf; char *tmpbuf; - OBD_ALLOC(kbuf, BUFLEN); + kbuf = kzalloc(BUFLEN, GFP_NOFS); if (kbuf == NULL) return -ENOMEM; @@ -1225,7 +1225,7 @@ int lprocfs_wr_evict_client(struct file *file, const char __user *buffer, class_decref(obd, __func__, current); out: - OBD_FREE(kbuf, BUFLEN); + kfree(kbuf); return count; } EXPORT_SYMBOL(lprocfs_wr_evict_client); @@ -1275,7 +1275,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer, if (count > PAGE_CACHE_SIZE - 1 || count <= prefix_len) return -EINVAL; - OBD_ALLOC(kbuf, count + 1); + kbuf = kzalloc(count + 1, GFP_NOFS); if (kbuf == NULL) return -ENOMEM; @@ -1319,7 +1319,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer, ptlrpc_recover_import(imp, uuid, 1); out: - OBD_FREE(kbuf, count + 1); + kfree(kbuf); return count; } EXPORT_SYMBOL(lprocfs_wr_import); diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c index 81ad7473242e..68c754f67d2d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c @@ -715,7 +715,7 @@ static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name) nrs_policy_fini(policy); LASSERT(policy->pol_private == NULL); - OBD_FREE_PTR(policy); + kfree(policy); return 0; } @@ -761,7 +761,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, rc = nrs_policy_init(policy); if (rc != 0) { - OBD_FREE_PTR(policy); + kfree(policy); return rc; } @@ -776,7 +776,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, spin_unlock(&nrs->nrs_lock); nrs_policy_fini(policy); - OBD_FREE_PTR(policy); + kfree(policy); return -EEXIST; } @@ -1013,7 +1013,7 @@ again: } if (hp) - OBD_FREE_PTR(nrs); + kfree(nrs); } /** @@ -1153,7 +1153,7 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) goto fail; } - OBD_ALLOC_PTR(desc); + desc = kzalloc(sizeof(*desc), GFP_NOFS); if (desc == NULL) { rc = -ENOMEM; goto fail; @@ -1210,7 +1210,7 @@ again: */ LASSERT(rc2 == 0); mutex_unlock(&ptlrpc_all_services_mutex); - OBD_FREE_PTR(desc); + kfree(desc); goto fail; } @@ -1233,7 +1233,7 @@ again: */ LASSERT(rc2 == 0); mutex_unlock(&ptlrpc_all_services_mutex); - OBD_FREE_PTR(desc); + kfree(desc); goto fail; } } @@ -1301,7 +1301,7 @@ int ptlrpc_nrs_policy_unregister(struct ptlrpc_nrs_pol_conf *conf) conf->nc_name); list_del(&desc->pd_list); - OBD_FREE_PTR(desc); + kfree(desc); fail: mutex_unlock(&ptlrpc_all_services_mutex); @@ -1747,7 +1747,7 @@ void ptlrpc_nrs_fini(void) list_for_each_entry_safe(desc, tmp, &nrs_core.nrs_policies, pd_list) { list_del_init(&desc->pd_list); - OBD_FREE_PTR(desc); + kfree(desc); } } diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c index eb40c01db612..2eefa25f464d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c @@ -105,7 +105,7 @@ static void nrs_fifo_stop(struct ptlrpc_nrs_policy *policy) LASSERT(head != NULL); LASSERT(list_empty(&head->fh_list)); - OBD_FREE_PTR(head); + kfree(head); } /** diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index 9dbda9332dd8..5abb91cc87ff 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -427,7 +427,7 @@ struct timeout_item *ptlrpc_new_timeout(int time, enum timeout_event event, { struct timeout_item *ti; - OBD_ALLOC_PTR(ti); + ti = kzalloc(sizeof(*ti), GFP_NOFS); if (!ti) return NULL; @@ -514,7 +514,7 @@ int ptlrpc_del_timeout_client(struct list_head *obd_list, LASSERTF(ti != NULL, "ti is NULL !\n"); if (list_empty(&ti->ti_obd_list)) { list_del(&ti->ti_chain); - OBD_FREE_PTR(ti); + kfree(ti); } mutex_unlock(&pinger_mutex); return 0; @@ -529,7 +529,7 @@ int ptlrpc_pinger_remove_timeouts(void) list_for_each_entry_safe(item, tmp, &timeout_list, ti_chain) { LASSERT(list_empty(&item->ti_obd_list)); list_del(&item->ti_chain); - OBD_FREE_PTR(item); + kfree(item); } mutex_unlock(&pinger_mutex); return 0; diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index 0c178ec0e487..5ba3e6ed5289 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c @@ -528,8 +528,9 @@ static int ptlrpcd_bind(int index, int max) } if (rc == 0 && pc->pc_npartners > 0) { - OBD_ALLOC(pc->pc_partners, - sizeof(struct ptlrpcd_ctl *) * pc->pc_npartners); + pc->pc_partners = kcalloc(pc->pc_npartners, + sizeof(struct ptlrpcd_ctl *), + GFP_NOFS); if (pc->pc_partners == NULL) { pc->pc_npartners = 0; rc = -ENOMEM; @@ -699,8 +700,7 @@ out: if (pc->pc_npartners > 0) { LASSERT(pc->pc_partners != NULL); - OBD_FREE(pc->pc_partners, - sizeof(struct ptlrpcd_ctl *) * pc->pc_npartners); + kfree(pc->pc_partners); pc->pc_partners = NULL; } pc->pc_npartners = 0; @@ -717,7 +717,7 @@ static void ptlrpcd_fini(void) ptlrpcd_free(&ptlrpcds->pd_threads[i]); ptlrpcd_stop(&ptlrpcds->pd_thread_rcv, 0); ptlrpcd_free(&ptlrpcds->pd_thread_rcv); - OBD_FREE(ptlrpcds, ptlrpcds->pd_size); + kfree(ptlrpcds); ptlrpcds = NULL; } } @@ -738,7 +738,7 @@ static int ptlrpcd_init(void) nthreads &= ~1; /* make sure it is even */ size = offsetof(struct ptlrpcd, pd_threads[nthreads]); - OBD_ALLOC(ptlrpcds, size); + ptlrpcds = kzalloc(size, GFP_NOFS); if (ptlrpcds == NULL) { rc = -ENOMEM; goto out; @@ -781,7 +781,7 @@ out: ptlrpcd_free(&ptlrpcds->pd_threads[j]); ptlrpcd_stop(&ptlrpcds->pd_thread_rcv, 0); ptlrpcd_free(&ptlrpcds->pd_thread_rcv); - OBD_FREE(ptlrpcds, size); + kfree(ptlrpcds); ptlrpcds = NULL; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index 21e9dc9d5580..bcfd0b0b6f93 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -866,7 +866,7 @@ void sptlrpc_request_out_callback(struct ptlrpc_request *req) if (req->rq_pool || !req->rq_reqbuf) return; - OBD_FREE(req->rq_reqbuf, req->rq_reqbuf_len); + kfree(req->rq_reqbuf); req->rq_reqbuf = NULL; req->rq_reqbuf_len = 0; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index c05a8554d737..97edc9174da3 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -210,7 +210,7 @@ static void enc_pools_release_free_pages(long npages) /* free unused pools */ while (p_idx_max1 < p_idx_max2) { LASSERT(page_pools.epp_pools[p_idx_max2]); - OBD_FREE(page_pools.epp_pools[p_idx_max2], PAGE_CACHE_SIZE); + kfree(page_pools.epp_pools[p_idx_max2]); page_pools.epp_pools[p_idx_max2] = NULL; p_idx_max2--; } @@ -294,7 +294,7 @@ static unsigned long enc_pools_cleanup(struct page ***pools, int npools) cleaned++; } } - OBD_FREE(pools[i], PAGE_CACHE_SIZE); + kfree(pools[i]); pools[i] = NULL; } } @@ -409,12 +409,12 @@ static int enc_pools_add_pages(int npages) page_pools.epp_st_grows++; npools = npages_to_npools(npages); - OBD_ALLOC(pools, npools * sizeof(*pools)); + pools = kcalloc(npools, sizeof(*pools), GFP_NOFS); if (pools == NULL) goto out; for (i = 0; i < npools; i++) { - OBD_ALLOC(pools[i], PAGE_CACHE_SIZE); + pools[i] = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS); if (pools[i] == NULL) goto out_pools; @@ -435,7 +435,7 @@ static int enc_pools_add_pages(int npages) out_pools: enc_pools_cleanup(pools, npools); - OBD_FREE(pools, npools * sizeof(*pools)); + kfree(pools); out: if (rc) { page_pools.epp_st_grow_fails++; @@ -508,8 +508,8 @@ int sptlrpc_enc_pool_get_pages(struct ptlrpc_bulk_desc *desc) if (desc->bd_enc_iov != NULL) return 0; - OBD_ALLOC(desc->bd_enc_iov, - desc->bd_iov_count * sizeof(*desc->bd_enc_iov)); + desc->bd_enc_iov = kcalloc(desc->bd_iov_count, + sizeof(*desc->bd_enc_iov), GFP_NOFS); if (desc->bd_enc_iov == NULL) return -ENOMEM; @@ -646,8 +646,7 @@ void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc) spin_unlock(&page_pools.epp_lock); - OBD_FREE(desc->bd_enc_iov, - desc->bd_iov_count * sizeof(*desc->bd_enc_iov)); + kfree(desc->bd_enc_iov); desc->bd_enc_iov = NULL; } EXPORT_SYMBOL(sptlrpc_enc_pool_put_pages); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c index 56ba9e4e5297..16dbf3fcfc84 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c @@ -242,8 +242,7 @@ void sptlrpc_rule_set_free(struct sptlrpc_rule_set *rset) (rset->srs_nrule == 0 && rset->srs_rules == NULL)); if (rset->srs_nslot) { - OBD_FREE(rset->srs_rules, - rset->srs_nslot * sizeof(*rset->srs_rules)); + kfree(rset->srs_rules); sptlrpc_rule_set_init(rset); } } @@ -265,7 +264,7 @@ int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *rset) nslot = rset->srs_nslot + 8; /* better use realloc() if available */ - OBD_ALLOC(rules, nslot * sizeof(*rset->srs_rules)); + rules = kcalloc(nslot, sizeof(*rset->srs_rules), GFP_NOFS); if (rules == NULL) return -ENOMEM; @@ -274,8 +273,7 @@ int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *rset) memcpy(rules, rset->srs_rules, rset->srs_nrule * sizeof(*rset->srs_rules)); - OBD_FREE(rset->srs_rules, - rset->srs_nslot * sizeof(*rset->srs_rules)); + kfree(rset->srs_rules); } rset->srs_rules = rules; @@ -509,7 +507,7 @@ static void sptlrpc_conf_free_rsets(struct sptlrpc_conf *conf) &conf->sc_tgts, sct_list) { sptlrpc_rule_set_free(&conf_tgt->sct_rset); list_del(&conf_tgt->sct_list); - OBD_FREE_PTR(conf_tgt); + kfree(conf_tgt); } LASSERT(list_empty(&conf->sc_tgts)); @@ -523,7 +521,7 @@ static void sptlrpc_conf_free(struct sptlrpc_conf *conf) sptlrpc_conf_free_rsets(conf); list_del(&conf->sc_list); - OBD_FREE_PTR(conf); + kfree(conf); } static @@ -541,7 +539,7 @@ struct sptlrpc_conf_tgt *sptlrpc_conf_get_tgt(struct sptlrpc_conf *conf, if (!create) return NULL; - OBD_ALLOC_PTR(conf_tgt); + conf_tgt = kzalloc(sizeof(*conf_tgt), GFP_NOFS); if (conf_tgt) { strlcpy(conf_tgt->sct_name, name, sizeof(conf_tgt->sct_name)); sptlrpc_rule_set_init(&conf_tgt->sct_rset); @@ -565,7 +563,7 @@ struct sptlrpc_conf *sptlrpc_conf_get(const char *fsname, if (!create) return NULL; - OBD_ALLOC_PTR(conf); + conf = kzalloc(sizeof(*conf), GFP_NOFS); if (conf == NULL) return NULL; diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c index a79cd53010a4..604e51177bd3 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c @@ -376,7 +376,7 @@ struct ptlrpc_cli_ctx *plain_sec_install_ctx(struct plain_sec *plsec) { struct ptlrpc_cli_ctx *ctx, *ctx_new; - OBD_ALLOC_PTR(ctx_new); + ctx_new = kzalloc(sizeof(*ctx_new), GFP_NOFS); write_lock(&plsec->pls_lock); @@ -385,7 +385,7 @@ struct ptlrpc_cli_ctx *plain_sec_install_ctx(struct plain_sec *plsec) atomic_inc(&ctx->cc_refcount); if (ctx_new) - OBD_FREE_PTR(ctx_new); + kfree(ctx_new); } else if (ctx_new) { ctx = ctx_new; @@ -424,7 +424,7 @@ void plain_destroy_sec(struct ptlrpc_sec *sec) class_import_put(sec->ps_import); - OBD_FREE_PTR(plsec); + kfree(plsec); } static @@ -444,7 +444,7 @@ struct ptlrpc_sec *plain_create_sec(struct obd_import *imp, LASSERT(SPTLRPC_FLVR_POLICY(sf->sf_rpc) == SPTLRPC_POLICY_PLAIN); - OBD_ALLOC_PTR(plsec); + plsec = kzalloc(sizeof(*plsec), GFP_NOFS); if (plsec == NULL) return NULL; @@ -508,7 +508,7 @@ void plain_release_ctx(struct ptlrpc_sec *sec, LASSERT(atomic_read(&ctx->cc_refcount) == 0); LASSERT(ctx->cc_sec == sec); - OBD_FREE_PTR(ctx); + kfree(ctx); atomic_dec(&sec->ps_nctx); sptlrpc_sec_put(sec); diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 8e61421515cb..d0758abfec9e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -87,7 +87,7 @@ ptlrpc_alloc_rqbd(struct ptlrpc_service_part *svcpt) OBD_CPT_ALLOC_LARGE(rqbd->rqbd_buffer, svc->srv_cptable, svcpt->scp_cpt, svc->srv_buf_size); if (rqbd->rqbd_buffer == NULL) { - OBD_FREE_PTR(rqbd); + kfree(rqbd); return NULL; } @@ -113,7 +113,7 @@ ptlrpc_free_rqbd(struct ptlrpc_request_buffer_desc *rqbd) spin_unlock(&svcpt->scp_lock); OBD_FREE_LARGE(rqbd->rqbd_buffer, svcpt->scp_service->srv_buf_size); - OBD_FREE_PTR(rqbd); + kfree(rqbd); } int @@ -661,13 +661,12 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, failed: if (array->paa_reqs_count != NULL) { - OBD_FREE(array->paa_reqs_count, sizeof(__u32) * size); + kfree(array->paa_reqs_count); array->paa_reqs_count = NULL; } if (array->paa_reqs_array != NULL) { - OBD_FREE(array->paa_reqs_array, - sizeof(struct list_head) * array->paa_size); + kfree(array->paa_reqs_array); array->paa_reqs_array = NULL; } @@ -724,17 +723,18 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, CERROR("%s: failed to parse CPT array %s: %d\n", conf->psc_name, cconf->cc_pattern, rc); if (cpts != NULL) - OBD_FREE(cpts, sizeof(*cpts) * ncpts); + kfree(cpts); return ERR_PTR(rc < 0 ? rc : -EINVAL); } ncpts = rc; } } - OBD_ALLOC(service, offsetof(struct ptlrpc_service, srv_parts[ncpts])); + service = kzalloc(offsetof(struct ptlrpc_service, srv_parts[ncpts]), + GFP_NOFS); if (service == NULL) { if (cpts != NULL) - OBD_FREE(cpts, sizeof(*cpts) * ncpts); + kfree(cpts); return ERR_PTR(-ENOMEM); } @@ -2291,7 +2291,7 @@ static int ptlrpc_main(void *arg) goto out; } - OBD_ALLOC_PTR(env); + env = kzalloc(sizeof(*env), GFP_NOFS); if (env == NULL) { rc = -ENOMEM; goto out_srv_fini; @@ -2414,7 +2414,7 @@ out_srv_fini: if (env != NULL) { lu_context_fini(&env->le_ctx); - OBD_FREE_PTR(env); + kfree(env); } out: CDEBUG(D_RPCTRACE, "service thread [ %p : %u ] %d exiting: rc %d\n", @@ -2596,7 +2596,7 @@ static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt) thread = list_entry(zombie.next, struct ptlrpc_thread, t_link); list_del(&thread->t_link); - OBD_FREE_PTR(thread); + kfree(thread); } } @@ -2678,7 +2678,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) spin_lock(&svcpt->scp_lock); if (!ptlrpc_threads_increasable(svcpt)) { spin_unlock(&svcpt->scp_lock); - OBD_FREE_PTR(thread); + kfree(thread); return -EMFILE; } @@ -2687,7 +2687,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) * might require unique and contiguous t_id */ LASSERT(svcpt->scp_nthrs_starting == 1); spin_unlock(&svcpt->scp_lock); - OBD_FREE_PTR(thread); + kfree(thread); if (wait) { CDEBUG(D_INFO, "Waiting for creating thread %s #%d\n", svc->srv_thread_name, svcpt->scp_thr_nextid); @@ -2733,7 +2733,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) } else { list_del(&thread->t_link); spin_unlock(&svcpt->scp_lock); - OBD_FREE_PTR(thread); + kfree(thread); } return rc; } @@ -2817,8 +2817,7 @@ void ptlrpc_hr_fini(void) cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) { if (hrp->hrp_thrs != NULL) { - OBD_FREE(hrp->hrp_thrs, - hrp->hrp_nthrs * sizeof(hrp->hrp_thrs[0])); + kfree(hrp->hrp_thrs); } } @@ -2999,26 +2998,23 @@ ptlrpc_service_free(struct ptlrpc_service *svc) array = &svcpt->scp_at_array; if (array->paa_reqs_array != NULL) { - OBD_FREE(array->paa_reqs_array, - sizeof(struct list_head) * array->paa_size); + kfree(array->paa_reqs_array); array->paa_reqs_array = NULL; } if (array->paa_reqs_count != NULL) { - OBD_FREE(array->paa_reqs_count, - sizeof(__u32) * array->paa_size); + kfree(array->paa_reqs_count); array->paa_reqs_count = NULL; } } ptlrpc_service_for_each_part(svcpt, i, svc) - OBD_FREE_PTR(svcpt); + kfree(svcpt); if (svc->srv_cpts != NULL) cfs_expr_list_values_free(svc->srv_cpts, svc->srv_ncpts); - OBD_FREE(svc, offsetof(struct ptlrpc_service, - srv_parts[svc->srv_ncpts])); + kfree(svc); } int ptlrpc_unregister_service(struct ptlrpc_service *service) From 1134507ca420fadd465ebdbc4f6c5d5798d6ab87 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 21:38:06 +0200 Subject: [PATCH 0122/1163] staging: lustre: ldlm: ldlm_lib: remove unneeded null test before free Kfree can cope with a null argument, so drop null tests. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr; @@ - if (ptr != NULL) kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index d0667715ebf7..0a0b435f11fc 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -119,8 +119,7 @@ static int import_set_conn(struct obd_import *imp, struct obd_uuid *uuid, spin_unlock(&imp->imp_lock); return 0; out_free: - if (imp_conn) - kfree(imp_conn); + kfree(imp_conn); out_put: ptlrpc_connection_put(ptlrpc_conn); return rc; From a1ce36c0e6d8eaefef6e60baf3be9d93fafadd7e Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 21:38:05 +0200 Subject: [PATCH 0123/1163] staging: lustre: ldlm: ldlm_lock: remove unneeded null test before free Kfree can cope with a null argument, so drop null tests. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr; @@ - if (ptr != NULL) kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 2c5fe1499ce0..6a22f4183b30 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -208,8 +208,7 @@ void ldlm_lock_put(struct ldlm_lock *lock) lock->l_export = NULL; } - if (lock->l_lvb_data != NULL) - kfree(lock->l_lvb_data); + kfree(lock->l_lvb_data); ldlm_interval_free(ldlm_interval_detach(lock)); lu_ref_fini(&lock->l_reference); From 62b497d85bf3896a7caaf244966e5288fb2e3b39 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 21:38:04 +0200 Subject: [PATCH 0124/1163] staging: lustre: ldlm: ldlm_resource: remove unneeded null test before free Kfree can cope with a null argument, so drop null tests. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr; @@ - if (ptr != NULL) { kfree(ptr); ptr = NULL; - } // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 5922069873f5..7149edab44f4 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -1137,10 +1137,8 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, CERROR("%s: lvbo_init failed for resource %#llx:%#llx: rc = %d\n", ns->ns_obd->obd_name, name->name[0], name->name[1], rc); - if (res->lr_lvb_data) { - kfree(res->lr_lvb_data); - res->lr_lvb_data = NULL; - } + kfree(res->lr_lvb_data); + res->lr_lvb_data = NULL; res->lr_lvb_len = rc; mutex_unlock(&res->lr_lvb_mutex); ldlm_resource_putref(res); From acd3750e572142bb45f056f1b5ffd5230061a327 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 21:38:03 +0200 Subject: [PATCH 0125/1163] staging: lustre: libcfs: linux: remove unneeded null test before free Kfree can cope with a null argument, so drop null tests. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr; @@ - if (ptr != NULL) { kfree(ptr); ptr = NULL; - } // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/libcfs/linux/linux-tracefile.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c index c8e293002e07..483cbc82e538 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c @@ -102,11 +102,10 @@ void cfs_tracefile_fini_arch(void) int j; for (i = 0; i < num_possible_cpus(); i++) - for (j = 0; j < 3; j++) - if (cfs_trace_console_buffers[i][j] != NULL) { - kfree(cfs_trace_console_buffers[i][j]); - cfs_trace_console_buffers[i][j] = NULL; - } + for (j = 0; j < 3; j++) { + kfree(cfs_trace_console_buffers[i][j]); + cfs_trace_console_buffers[i][j] = NULL; + } for (i = 0; cfs_trace_data[i] != NULL; i++) { kfree(cfs_trace_data[i]); From 57876fd8bf6b90362ae511c4d201847a1e18bacf Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 21:38:02 +0200 Subject: [PATCH 0126/1163] Staging: lustre: llite: dir: remove unneeded null test before free Kfree can cope with a null argument, so drop null tests. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr; @@ - if (ptr != NULL) kfree(ptr); // This patch additionally simplifies one case where the free, and thus the jump to the end of the function, is not needed. Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dir.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index f17154aaa329..4b0de8d89e5c 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -754,10 +754,8 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, char *buf; param = kzalloc(MGS_PARAM_MAXLEN, GFP_NOFS); - if (!param) { - rc = -ENOMEM; - goto end; - } + if (!param) + return -ENOMEM; buf = param; /* Get fsname and assume devname to be -MDT0000. */ @@ -786,8 +784,7 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, rc = ll_send_mgc_param(mgc->u.cli.cl_mgc_mgsexp, param); end: - if (param != NULL) - kfree(param); + kfree(param); } return rc; } From e6b9a3b225b804a2683bc173c1261a9ce4a561a0 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 21:38:01 +0200 Subject: [PATCH 0127/1163] Staging: lustre: llite: file: remove unneeded null test before free Kfree can cope with a null argument, so drop null tests. The semantic patch that finds this issue is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr; @@ - if (ptr != NULL) kfree(ptr); // In the first case, llss can never be null at the point of the kfree anyway. In the second set of changes, the gotos are either eliminated, when no freeing is needed (hss failure case), or rewritten so that there is no call to free on data that has not yet been allocated (free_hss goto case). There is no goto at which attr is not null, so the out label is simply dropped. Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/file.c | 23 ++++++++-------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 6e50b3554e33..702f62d44430 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -2109,8 +2109,7 @@ putgl: } free: - if (llss != NULL) - kfree(llss); + kfree(llss); return rc; } @@ -2152,22 +2151,20 @@ static int ll_hsm_import(struct inode *inode, struct file *file, /* set HSM flags */ hss = kzalloc(sizeof(*hss), GFP_NOFS); - if (!hss) { - rc = -ENOMEM; - goto out; - } + if (!hss) + return -ENOMEM; hss->hss_valid = HSS_SETMASK | HSS_ARCHIVE_ID; hss->hss_archive_id = hui->hui_archive_id; hss->hss_setmask = HS_ARCHIVED | HS_EXISTS | HS_RELEASED; rc = ll_hsm_state_set(inode, hss); if (rc != 0) - goto out; + goto free_hss; attr = kzalloc(sizeof(*attr), GFP_NOFS); if (!attr) { rc = -ENOMEM; - goto out; + goto free_hss; } attr->ia_mode = hui->hui_mode & (S_IRWXU | S_IRWXG | S_IRWXO); @@ -2193,13 +2190,9 @@ static int ll_hsm_import(struct inode *inode, struct file *file, mutex_unlock(&inode->i_mutex); -out: - if (hss != NULL) - kfree(hss); - - if (attr != NULL) - kfree(attr); - + kfree(attr); +free_hss: + kfree(hss); return rc; } From 081825f589cc23d479a59e18ad093ef0b637b051 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 21:38:00 +0200 Subject: [PATCH 0128/1163] Staging: lustre: llite: llite_lib: remove unneeded null test before free Kfree can cope with a null argument, so drop null tests. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr; @@ - if (ptr != NULL) kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_lib.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index e5bac94f690b..c6611b11779c 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -574,10 +574,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, get_uuid2fsid(uuid->uuid, strlen(uuid->uuid), &sbi->ll_fsid); } - if (data != NULL) - kfree(data); - if (osfs != NULL) - kfree(osfs); + kfree(data); + kfree(osfs); return err; out_root: @@ -595,10 +593,8 @@ out_md: obd_disconnect(sbi->ll_md_exp); sbi->ll_md_exp = NULL; out: - if (data != NULL) - kfree(data); - if (osfs != NULL) - kfree(osfs); + kfree(data); + kfree(osfs); lprocfs_unregister_mountpoint(sbi); return err; } From 37b5022dd7b9dc0b412e2c2a7d01bd3f32e40db5 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 21:37:59 +0200 Subject: [PATCH 0129/1163] staging: lustre: llite: statahead: remove unneeded null test before free Kfree can cope with a null argument, so drop null tests. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr; @@ - if (ptr != NULL) kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/statahead.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index fdf953f691fa..f97371dd8539 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -1719,8 +1719,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, return -EAGAIN; out: - if (sai != NULL) - kfree(sai); + kfree(sai); spin_lock(&lli->lli_sa_lock); lli->lli_opendir_key = NULL; lli->lli_opendir_pid = 0; From 13879e5d17afc76b66d74324fe2b1065e301614f Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 21:37:58 +0200 Subject: [PATCH 0130/1163] staging: lustre: lmv: remove unneeded null test before free Kfree can cope with a null argument, so drop null tests. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr; @@ - if (ptr != NULL) kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 59b8fac96ed4..8e05852ea712 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -504,8 +504,7 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, lmv->tgts = newtgts; lmv->tgts_size = newsize; smp_rmb(); - if (old) - kfree(old); + kfree(old); CDEBUG(D_CONFIG, "tgts: %p size: %d\n", lmv->tgts, lmv->tgts_size); @@ -780,8 +779,7 @@ repeat_fid2path: goto repeat_fid2path; out_fid2path: - if (remote_gf != NULL) - kfree(remote_gf); + kfree(remote_gf); return rc; } From 34b8fbd6cdb1251d7f2bb3645124148365c5089a Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 21:37:57 +0200 Subject: [PATCH 0131/1163] staging: lustre: lov: lov_dev: remove unneeded null test before free Kfree can cope with a null argument, so drop null tests. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr; @@ - if (ptr != NULL) kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lov/lov_dev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_dev.c b/drivers/staging/lustre/lustre/lov/lov_dev.c index 63db87af7fe2..504b24a468fc 100644 --- a/drivers/staging/lustre/lustre/lov/lov_dev.c +++ b/drivers/staging/lustre/lustre/lov/lov_dev.c @@ -298,8 +298,7 @@ static struct lu_device *lov_device_free(const struct lu_env *env, const int nr = ld->ld_target_nr; cl_device_fini(lu2cl_dev(d)); - if (ld->ld_target != NULL) - kfree(ld->ld_target); + kfree(ld->ld_target); if (ld->ld_emrg != NULL) lov_emerg_free(ld->ld_emrg, nr); kfree(ld); From 6fa7cbab38ee64eb78376a32a57cbaa074d766e4 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 21:37:56 +0200 Subject: [PATCH 0132/1163] staging: lustre: mdc: remove unneeded null test before free Kfree can cope with a null argument, so drop null tests. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr; @@ - if (ptr != NULL) kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/mdc/mdc_request.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 1a4ef9df33c3..cbbdfceb9b2a 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -1644,8 +1644,7 @@ out: llog_cat_close(NULL, llh); if (ctxt) llog_ctxt_put(ctxt); - if (cs->cs_buf) - kfree(cs->cs_buf); + kfree(cs->cs_buf); kfree(cs); return rc; } From ba99a0aff29344797107fc7cca4adc7694c4fd98 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 21:37:55 +0200 Subject: [PATCH 0133/1163] staging: lustre: obdclass: genops: remove unneeded null test before free Kfree can cope with a null argument, so drop null tests. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr; @@ - if (ptr != NULL) kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/genops.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index a107aea392e1..37d6aefde534 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -213,12 +213,9 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, return 0; failed: - if (type->typ_name != NULL) - kfree(type->typ_name); - if (type->typ_md_ops != NULL) - kfree(type->typ_md_ops); - if (type->typ_dt_ops != NULL) - kfree(type->typ_dt_ops); + kfree(type->typ_name); + kfree(type->typ_md_ops); + kfree(type->typ_dt_ops); kfree(type); return rc; } @@ -253,10 +250,8 @@ int class_unregister_type(const char *name) list_del(&type->typ_chain); spin_unlock(&obd_types_lock); kfree(type->typ_name); - if (type->typ_dt_ops != NULL) - kfree(type->typ_dt_ops); - if (type->typ_md_ops != NULL) - kfree(type->typ_md_ops); + kfree(type->typ_dt_ops); + kfree(type->typ_md_ops); kfree(type); return 0; } /* class_unregister_type */ From 2522d76ae4061b679ebabea02e2ccf762846a4c0 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 21:37:54 +0200 Subject: [PATCH 0134/1163] staging: lustre: obdclass: llog: remove unneeded null test before free Kfree can cope with a null argument, so drop null tests. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr; @@ - if (ptr != NULL) kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/llog.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index 636df94775ec..4fa52d1b79d1 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -563,8 +563,7 @@ int llog_reverse_process(const struct lu_env *env, } out: - if (buf) - kfree(buf); + kfree(buf); return rc; } EXPORT_SYMBOL(llog_reverse_process); From 32a3fab2ed1ed7240514eb50506031e68dcd4a38 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 21:37:53 +0200 Subject: [PATCH 0135/1163] staging: lustre: obdclass: obd_config: remove unneeded null test before free Kfree can cope with a null argument, so drop null tests. The semantic patch that identifies this issue is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr; @@ - if (ptr != NULL) kfree(ptr); // The first part of the patch introduces new labels to avoid unnecessary calls to kfree. In addition, lprof->lp_md is always null in the cleanup code at the end of the function, so that kfree is just dropped. Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/obdclass/obd_config.c | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 687fbbd1eb3f..0bda9c56f148 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -869,7 +869,7 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, lprof->lp_profile = kzalloc(proflen, GFP_NOFS); if (lprof->lp_profile == NULL) { err = -ENOMEM; - goto out; + goto free_lprof; } memcpy(lprof->lp_profile, prof, proflen); @@ -877,7 +877,7 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, lprof->lp_dt = kzalloc(osclen, GFP_NOFS); if (lprof->lp_dt == NULL) { err = -ENOMEM; - goto out; + goto free_lp_profile; } memcpy(lprof->lp_dt, osc, osclen); @@ -886,7 +886,7 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, lprof->lp_md = kzalloc(mdclen, GFP_NOFS); if (lprof->lp_md == NULL) { err = -ENOMEM; - goto out; + goto free_lp_dt; } memcpy(lprof->lp_md, mdc, mdclen); } @@ -894,13 +894,11 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, list_add(&lprof->lp_list, &lustre_profile_list); return err; -out: - if (lprof->lp_md) - kfree(lprof->lp_md); - if (lprof->lp_dt) - kfree(lprof->lp_dt); - if (lprof->lp_profile) - kfree(lprof->lp_profile); +free_lp_dt: + kfree(lprof->lp_dt); +free_lp_profile: + kfree(lprof->lp_profile); +free_lprof: kfree(lprof); return err; } @@ -916,8 +914,7 @@ void class_del_profile(const char *prof) list_del(&lprof->lp_list); kfree(lprof->lp_profile); kfree(lprof->lp_dt); - if (lprof->lp_md) - kfree(lprof->lp_md); + kfree(lprof->lp_md); kfree(lprof); } } @@ -932,8 +929,7 @@ void class_del_profiles(void) list_del(&lprof->lp_list); kfree(lprof->lp_profile); kfree(lprof->lp_dt); - if (lprof->lp_md) - kfree(lprof->lp_md); + kfree(lprof->lp_md); kfree(lprof); } } From 7713e5f5e5f5949f88eed24b1a76f3af39177b8c Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 21:37:52 +0200 Subject: [PATCH 0136/1163] staging: lustre: obdclass: obd_mount: remove unneeded null test before free Kfree can cope with a null argument, so drop null tests. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr; @@ - if (ptr != NULL) kfree(ptr); @@ expression ptr; @@ - if (ptr != NULL) { kfree(ptr); ptr = NULL; - } // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/obdclass/obd_mount.c | 45 +++++++------------ 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 04a2216964dc..1f9a5f7841ae 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -464,12 +464,9 @@ out: out_free: mutex_unlock(&mgc_start_lock); - if (data) - kfree(data); - if (mgcname) - kfree(mgcname); - if (niduuid) - kfree(niduuid); + kfree(data); + kfree(mgcname); + kfree(niduuid); return rc; } @@ -538,8 +535,7 @@ static int lustre_stop_mgc(struct super_block *sb) niduuid, rc); } out: - if (niduuid) - kfree(niduuid); + kfree(niduuid); /* class_import_put will get rid of the additional connections */ mutex_unlock(&mgc_start_lock); @@ -585,22 +581,15 @@ static int lustre_free_lsi(struct super_block *sb) LASSERT(atomic_read(&lsi->lsi_mounts) == 0); if (lsi->lsi_lmd != NULL) { - if (lsi->lsi_lmd->lmd_dev != NULL) - kfree(lsi->lsi_lmd->lmd_dev); - if (lsi->lsi_lmd->lmd_profile != NULL) - kfree(lsi->lsi_lmd->lmd_profile); - if (lsi->lsi_lmd->lmd_mgssec != NULL) - kfree(lsi->lsi_lmd->lmd_mgssec); - if (lsi->lsi_lmd->lmd_opts != NULL) - kfree(lsi->lsi_lmd->lmd_opts); + kfree(lsi->lsi_lmd->lmd_dev); + kfree(lsi->lsi_lmd->lmd_profile); + kfree(lsi->lsi_lmd->lmd_mgssec); + kfree(lsi->lsi_lmd->lmd_opts); if (lsi->lsi_lmd->lmd_exclude_count) kfree(lsi->lsi_lmd->lmd_exclude); - if (lsi->lsi_lmd->lmd_mgs != NULL) - kfree(lsi->lsi_lmd->lmd_mgs); - if (lsi->lsi_lmd->lmd_osd_type != NULL) - kfree(lsi->lsi_lmd->lmd_osd_type); - if (lsi->lsi_lmd->lmd_params != NULL) - kfree(lsi->lsi_lmd->lmd_params); + kfree(lsi->lsi_lmd->lmd_mgs); + kfree(lsi->lsi_lmd->lmd_osd_type); + kfree(lsi->lsi_lmd->lmd_params); kfree(lsi->lsi_lmd); } @@ -886,10 +875,8 @@ static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr) char *tail; int length; - if (lmd->lmd_mgssec != NULL) { - kfree(lmd->lmd_mgssec); - lmd->lmd_mgssec = NULL; - } + kfree(lmd->lmd_mgssec); + lmd->lmd_mgssec = NULL; tail = strchr(ptr, ','); if (tail == NULL) @@ -914,10 +901,8 @@ static int lmd_parse_string(char **handle, char *ptr) if ((handle == NULL) || (ptr == NULL)) return -EINVAL; - if (*handle != NULL) { - kfree(*handle); - *handle = NULL; - } + kfree(*handle); + *handle = NULL; tail = strchr(ptr, ','); if (tail == NULL) From 627ef6ea9a0678b1ad74d01c6ff3f5fbefa41a42 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 21:37:51 +0200 Subject: [PATCH 0137/1163] staging: lustre: obdecho: remove unneeded null test before free Kfree can cope with a null argument, so drop null tests. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr; @@ - if (ptr != NULL) kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdecho/echo_client.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index cf645388dc75..53761787a56f 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -1737,10 +1737,8 @@ static int echo_client_prep_commit(const struct lu_env *env, } out: - if (lnb) - kfree(lnb); - if (rnb) - kfree(rnb); + kfree(lnb); + kfree(rnb); return ret; } From 59e267c07b887015d13ec65167b75b2441d04109 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 21:37:50 +0200 Subject: [PATCH 0138/1163] Staging: lustre: osc: remove unneeded null test before free Kfree can cope with a null argument, so drop null tests. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr; @@ - if (ptr != NULL) kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/osc/osc_request.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 7ddf46b7ce43..ded184edb50f 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2064,8 +2064,7 @@ out: if (oa) OBDO_FREE(oa); - if (pga) - kfree(pga); + kfree(pga); /* this should happen rarely and is pretty bad, it makes the * pending list not follow the dirty order */ while (!list_empty(ext_list)) { From 848e90c332f500344a248e3dd673e61b8ad58ce0 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 21:37:49 +0200 Subject: [PATCH 0139/1163] Staging: lustre: ptlrpc: lproc_ptlrpc: remove unneeded null test before free Kfree can cope with a null argument, so drop null tests. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr; @@ - if (ptr != NULL) kfree(ptr); // In the first case, the only cleanup needed is the unlock, so jump to that directly. Likewise, in the first two failure cases of ptlrpc_lprocfs_nrs_seq_write, no cleanup is needed, so just drop the goto and return directly. Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/ptlrpc/lproc_ptlrpc.c | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 139178451263..aeceef5152ac 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -510,7 +510,7 @@ static int ptlrpc_lprocfs_nrs_seq_show(struct seq_file *m, void *n) infos = kcalloc(num_pols, sizeof(*infos), GFP_NOFS); if (infos == NULL) { rc = -ENOMEM; - goto out; + goto unlock; } again: @@ -617,10 +617,8 @@ again: goto again; } -out: - if (infos) - kfree(infos); - + kfree(infos); +unlock: mutex_unlock(&nrs_core.nrs_mutex); return rc; @@ -650,16 +648,12 @@ static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file, char *token; int rc = 0; - if (count >= LPROCFS_NRS_WR_MAX_CMD) { - rc = -EINVAL; - goto out; - } + if (count >= LPROCFS_NRS_WR_MAX_CMD) + return -EINVAL; cmd = kzalloc(LPROCFS_NRS_WR_MAX_CMD, GFP_NOFS); - if (cmd == NULL) { - rc = -ENOMEM; - goto out; - } + if (cmd == NULL) + return -ENOMEM; /** * strsep() modifies its argument, so keep a copy */ @@ -716,8 +710,7 @@ default_queue: mutex_unlock(&nrs_core.nrs_mutex); out: - if (cmd_copy) - kfree(cmd_copy); + kfree(cmd_copy); return rc < 0 ? rc : count; } @@ -860,8 +853,7 @@ ptlrpc_lprocfs_svc_req_history_stop(struct seq_file *s, void *iter) { struct ptlrpc_srh_iterator *srhi = iter; - if (srhi != NULL) - kfree(srhi); + kfree(srhi); } static void * From 76372381dd6f5ed4b53fae0c00666e25680e21c5 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 21:37:48 +0200 Subject: [PATCH 0140/1163] staging: lustre: ptlrpc: sec_plain: remove unneeded null test before free Kfree can cope with a null argument, so drop null tests. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr; @@ - if (ptr != NULL) kfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/sec_plain.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c index 604e51177bd3..989cdcda27b5 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c @@ -384,8 +384,7 @@ struct ptlrpc_cli_ctx *plain_sec_install_ctx(struct plain_sec *plsec) if (ctx) { atomic_inc(&ctx->cc_refcount); - if (ctx_new) - kfree(ctx_new); + kfree(ctx_new); } else if (ctx_new) { ctx = ctx_new; From 207e99c20f029b8ad9784fdb3b857e0a673db949 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 1 May 2015 21:37:47 +0200 Subject: [PATCH 0141/1163] staging: lustre: ptlrpc: service: remove unneeded null test before free Kfree can cope with a null argument, so drop null tests. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr; @@ - if (ptr != NULL) kfree(ptr); @@ expression ptr; @@ - if (ptr != NULL) { kfree(ptr); ptr = NULL; - } // In the first case, specific labels are introduced to free only what is needed. Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/ptlrpc/service.c | 39 +++++++------------ 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index d0758abfec9e..d85db067fc5a 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -641,7 +641,7 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, OBD_CPT_ALLOC(array->paa_reqs_count, svc->srv_cptable, cpt, sizeof(__u32) * size); if (array->paa_reqs_count == NULL) - goto failed; + goto free_reqs_array; cfs_timer_init(&svcpt->scp_at_timer, ptlrpc_at_timer, svcpt); /* At SOW, service time should be quick; 10s seems generous. If client @@ -655,20 +655,16 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, /* We shouldn't be under memory pressure at startup, so * fail if we can't allocate all our buffers at this time. */ if (rc != 0) - goto failed; + goto free_reqs_count; return 0; - failed: - if (array->paa_reqs_count != NULL) { - kfree(array->paa_reqs_count); - array->paa_reqs_count = NULL; - } - - if (array->paa_reqs_array != NULL) { - kfree(array->paa_reqs_array); - array->paa_reqs_array = NULL; - } +free_reqs_count: + kfree(array->paa_reqs_count); + array->paa_reqs_count = NULL; +free_reqs_array: + kfree(array->paa_reqs_array); + array->paa_reqs_array = NULL; return -ENOMEM; } @@ -722,8 +718,7 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, if (rc <= 0) { CERROR("%s: failed to parse CPT array %s: %d\n", conf->psc_name, cconf->cc_pattern, rc); - if (cpts != NULL) - kfree(cpts); + kfree(cpts); return ERR_PTR(rc < 0 ? rc : -EINVAL); } ncpts = rc; @@ -733,8 +728,7 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, service = kzalloc(offsetof(struct ptlrpc_service, srv_parts[ncpts]), GFP_NOFS); if (service == NULL) { - if (cpts != NULL) - kfree(cpts); + kfree(cpts); return ERR_PTR(-ENOMEM); } @@ -2997,15 +2991,10 @@ ptlrpc_service_free(struct ptlrpc_service *svc) cfs_timer_disarm(&svcpt->scp_at_timer); array = &svcpt->scp_at_array; - if (array->paa_reqs_array != NULL) { - kfree(array->paa_reqs_array); - array->paa_reqs_array = NULL; - } - - if (array->paa_reqs_count != NULL) { - kfree(array->paa_reqs_count); - array->paa_reqs_count = NULL; - } + kfree(array->paa_reqs_array); + array->paa_reqs_array = NULL; + kfree(array->paa_reqs_count); + array->paa_reqs_count = NULL; } ptlrpc_service_for_each_part(svcpt, i, svc) From e3bf447a81d7a134581fbae11d9f937c5f39aed1 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sun, 3 May 2015 15:21:42 +0200 Subject: [PATCH 0142/1163] staging: lustre: ptlrpc: Replace OBD_CPT_ALLOC etc by kzalloc_node Replace OBD_CPT_ALLOC, OBD_CPT_ALLOC_PTR, and OBD_CPT_ALLOC_GFP by corresponding calls to kzalloc_node. The semantic patch for the OBD_CPT_ALLOC case is as follows: (http://coccinelle.lip6.fr/). // @@ expression ptr,cptab,cpt,size; @@ - OBD_CPT_ALLOC(ptr, cptab, cpt, size) + ptr = kzalloc_node(size, GFP_NOFS, cfs_cpt_spread_node(cptab, cpt)) // Note that the original OBD macros would check if the cptab argument was NULL and fall back on kzalloc in that case. Oleg Drokin argues that this test is not needed because the code containing these calls is only invoked after initialization has been completed, in which case the possible cptab arguments are not NULL. Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/nrs.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c index 68c754f67d2d..63a05f4a902d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c @@ -746,8 +746,9 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, LASSERT(desc->pd_ops->op_req_dequeue != NULL); LASSERT(desc->pd_compat != NULL); - OBD_CPT_ALLOC_GFP(policy, svcpt->scp_service->srv_cptable, - svcpt->scp_cpt, sizeof(*policy), GFP_NOFS); + policy = kzalloc_node(sizeof(*policy), GFP_NOFS, + cfs_cpt_spread_node(svcpt->scp_service->srv_cptable, + svcpt->scp_cpt)); if (policy == NULL) return -ENOMEM; @@ -961,9 +962,10 @@ static int nrs_svcpt_setup_locked(struct ptlrpc_service_part *svcpt) if (svcpt->scp_service->srv_ops.so_hpreq_handler == NULL) goto out; - OBD_CPT_ALLOC_PTR(svcpt->scp_nrs_hp, - svcpt->scp_service->srv_cptable, - svcpt->scp_cpt); + svcpt->scp_nrs_hp = + kzalloc_node(sizeof(*svcpt->scp_nrs_hp), GFP_NOFS, + cfs_cpt_spread_node(svcpt->scp_service->srv_cptable, + svcpt->scp_cpt)); if (svcpt->scp_nrs_hp == NULL) { rc = -ENOMEM; goto out; From b18d11003d8d161b251ad70375d23297beb51c4e Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sun, 3 May 2015 15:21:43 +0200 Subject: [PATCH 0143/1163] drivers: staging: lustre: lustre: Replace OBD_CPT_ALLOC etc by kzalloc_node Replace OBD_CPT_ALLOC, OBD_CPT_ALLOC_PTR, and OBD_CPT_ALLOC_GFP by corresponding calls to kzalloc_node. The semantic patch for the OBD_CPT_ALLOC case is as follows: (http://coccinelle.lip6.fr/). // @@ expression ptr,cptab,cpt,size; @@ - OBD_CPT_ALLOC(ptr, cptab, cpt, size) + ptr = kzalloc_node(size, GFP_NOFS, cfs_cpt_spread_node(cptab, cpt)) // Note that the original OBD macros would check if the cptab argument was NULL and fall back on kzalloc in that case. Oleg Drokin argues that this test is not needed because the code containing these calls is only invoked after initialization has been completed, in which case the possible cptab arguments are not NULL. Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c index 2eefa25f464d..6a61c85cfb11 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c @@ -80,7 +80,9 @@ static int nrs_fifo_start(struct ptlrpc_nrs_policy *policy) { struct nrs_fifo_head *head; - OBD_CPT_ALLOC_PTR(head, nrs_pol2cptab(policy), nrs_pol2cptid(policy)); + head = kzalloc_node(sizeof(*head), GFP_NOFS, + cfs_cpt_spread_node(nrs_pol2cptab(policy), + nrs_pol2cptid(policy))); if (head == NULL) return -ENOMEM; From bae97e81102d281c92b00c44d43304be3ae3c0a6 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sun, 3 May 2015 15:21:44 +0200 Subject: [PATCH 0144/1163] staging/lustre/ptlrpc: Replace OBD_CPT_ALLOC etc by kzalloc_node Replace OBD_CPT_ALLOC, OBD_CPT_ALLOC_PTR, and OBD_CPT_ALLOC_GFP by corresponding calls to kzalloc_node. The semantic patch for the OBD_CPT_ALLOC case is as follows: (http://coccinelle.lip6.fr/). // @@ expression ptr,cptab,cpt,size; @@ - OBD_CPT_ALLOC(ptr, cptab, cpt, size) + ptr = kzalloc_node(size, GFP_NOFS, cfs_cpt_spread_node(cptab, cpt)) // Note that the original OBD macros would check if the cptab argument was NULL and fall back on kzalloc in that case. Oleg Drokin argues that this test is not needed because the code containing these calls is only invoked after initialization has been completed, in which case the possible cptab arguments are not NULL. Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/ptlrpc/service.c | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index d85db067fc5a..3fa52f117424 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -75,7 +75,9 @@ ptlrpc_alloc_rqbd(struct ptlrpc_service_part *svcpt) struct ptlrpc_service *svc = svcpt->scp_service; struct ptlrpc_request_buffer_desc *rqbd; - OBD_CPT_ALLOC_PTR(rqbd, svc->srv_cptable, svcpt->scp_cpt); + rqbd = kzalloc_node(sizeof(*rqbd), GFP_NOFS, + cfs_cpt_spread_node(svc->srv_cptable, + svcpt->scp_cpt)); if (rqbd == NULL) return NULL; @@ -630,16 +632,18 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, array->paa_deadline = -1; /* allocate memory for scp_at_array (ptlrpc_at_array) */ - OBD_CPT_ALLOC(array->paa_reqs_array, - svc->srv_cptable, cpt, sizeof(struct list_head) * size); + array->paa_reqs_array = + kzalloc_node(sizeof(struct list_head) * size, GFP_NOFS, + cfs_cpt_spread_node(svc->srv_cptable, cpt)); if (array->paa_reqs_array == NULL) return -ENOMEM; for (index = 0; index < size; index++) INIT_LIST_HEAD(&array->paa_reqs_array[index]); - OBD_CPT_ALLOC(array->paa_reqs_count, - svc->srv_cptable, cpt, sizeof(__u32) * size); + array->paa_reqs_count = + kzalloc_node(sizeof(__u32) * size, GFP_NOFS, + cfs_cpt_spread_node(svc->srv_cptable, cpt)); if (array->paa_reqs_count == NULL) goto free_reqs_array; @@ -772,7 +776,8 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, else cpt = cpts != NULL ? cpts[i] : i; - OBD_CPT_ALLOC(svcpt, cptable, cpt, sizeof(*svcpt)); + svcpt = kzalloc_node(sizeof(*svcpt), GFP_NOFS, + cfs_cpt_spread_node(cptable, cpt)); if (svcpt == NULL) { rc = -ENOMEM; goto failed; @@ -2664,7 +2669,9 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) svcpt->scp_nthrs_running == svc->srv_nthrs_cpt_init - 1)) return -EMFILE; - OBD_CPT_ALLOC_PTR(thread, svc->srv_cptable, svcpt->scp_cpt); + thread = kzalloc_node(sizeof(*thread), GFP_NOFS, + cfs_cpt_spread_node(svc->srv_cptable, + svcpt->scp_cpt)); if (thread == NULL) return -ENOMEM; init_waitqueue_head(&thread->t_ctl_waitq); @@ -2774,8 +2781,10 @@ int ptlrpc_hr_init(void) hrp->hrp_nthrs /= weight; LASSERT(hrp->hrp_nthrs > 0); - OBD_CPT_ALLOC(hrp->hrp_thrs, ptlrpc_hr.hr_cpt_table, i, - hrp->hrp_nthrs * sizeof(*hrt)); + hrp->hrp_thrs = + kzalloc_node(hrp->hrp_nthrs * sizeof(*hrt), GFP_NOFS, + cfs_cpt_spread_node(ptlrpc_hr.hr_cpt_table, + i)); if (hrp->hrp_thrs == NULL) { rc = -ENOMEM; goto out; From 02eb884f4e26a8649724fdf236822d371998f2bb Mon Sep 17 00:00:00 2001 From: Tolga Ceylan Date: Fri, 1 May 2015 23:40:35 -0700 Subject: [PATCH 0145/1163] drivers: staging: fbtft: fbtft-bus.c: Fix different address space warning on I/O mem To fix sparse warning of incorrect type in assignment (different address space), added annotation __iomem to vmem8 and modified direct reads with ioread8(). Signed-off-by: Tolga Ceylan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fbtft-bus.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/fbtft/fbtft-bus.c b/drivers/staging/fbtft/fbtft-bus.c index 52af9cbbc2a6..912c6328fb87 100644 --- a/drivers/staging/fbtft/fbtft-bus.c +++ b/drivers/staging/fbtft/fbtft-bus.c @@ -184,7 +184,7 @@ EXPORT_SYMBOL(fbtft_write_vmem16_bus8); /* 16 bit pixel over 9-bit SPI bus: dc + high byte, dc + low byte */ int fbtft_write_vmem16_bus9(struct fbtft_par *par, size_t offset, size_t len) { - u8 *vmem8; + u8 __iomem *vmem8; u16 *txbuf16 = par->txbuf.buf; size_t remain; size_t to_copy; @@ -212,12 +212,12 @@ int fbtft_write_vmem16_bus9(struct fbtft_par *par, size_t offset, size_t len) #ifdef __LITTLE_ENDIAN for (i = 0; i < to_copy; i += 2) { - txbuf16[i] = 0x0100 | vmem8[i+1]; - txbuf16[i+1] = 0x0100 | vmem8[i]; + txbuf16[i] = 0x0100 | ioread8(vmem8 + i + 1); + txbuf16[i + 1] = 0x0100 | ioread8(vmem8 + i); } #else for (i = 0; i < to_copy; i++) - txbuf16[i] = 0x0100 | vmem8[i]; + txbuf16[i] = 0x0100 | ioread8(vmem8 + i); #endif vmem8 = vmem8 + to_copy; ret = par->fbtftops.write(par, par->txbuf.buf, to_copy*2); From 69e98df78271a71b688706dccf2ad4544d63a274 Mon Sep 17 00:00:00 2001 From: "Carlos E. Garcia" Date: Fri, 24 Apr 2015 09:40:42 -0400 Subject: [PATCH 0146/1163] Staging: fixed multiple spelling errors. Fixed multiple spelling errors. Signed-off-by: Carlos E. Garcia Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion_priv.h | 6 +++--- drivers/staging/android/uapi/ion.h | 2 +- drivers/staging/comedi/comedi_fops.c | 2 +- drivers/staging/dgnc/TODO | 6 +++--- drivers/staging/dgnc/dgnc_neo.c | 2 +- drivers/staging/emxx_udc/emxx_udc.c | 2 +- drivers/staging/fbtft/Kconfig | 2 +- drivers/staging/fwserial/dma_fifo.c | 2 +- drivers/staging/fwserial/fwserial.h | 2 +- drivers/staging/iio/Documentation/device.txt | 2 +- drivers/staging/iio/iio_simple_dummy.h | 2 +- drivers/staging/lustre/TODO | 2 +- drivers/staging/media/bcm2048/radio-bcm2048.c | 4 ++-- drivers/staging/octeon-usb/octeon-hcd.c | 4 ++-- drivers/staging/octeon-usb/octeon-hcd.h | 2 +- drivers/staging/rtl8188eu/include/rtl8188e_hal.h | 4 ++-- drivers/staging/rtl8192u/r8192U_dm.c | 2 +- drivers/staging/rtl8712/rtl8712_xmit.c | 2 +- drivers/staging/rtl8712/rtl871x_mp_phy_regdef.h | 2 +- drivers/staging/rtl8723au/hal/HalPwrSeqCmd.c | 2 +- drivers/staging/rtl8723au/hal/odm.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c | 4 ++-- drivers/staging/rtl8723au/hal/rtl8723au_xmit.c | 2 +- drivers/staging/rtl8723au/hal/usb_halinit.c | 2 +- drivers/staging/rtl8723au/include/odm_debug.h | 2 +- drivers/staging/rtl8723au/include/rtl8723a_hal.h | 2 +- drivers/staging/rtl8723au/include/rtw_cmd.h | 2 +- drivers/staging/rtl8723au/include/rtw_mlme.h | 10 +++++----- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 2 +- drivers/staging/rtl8723au/include/sta_info.h | 2 +- drivers/staging/sm750fb/ddk750_help.h | 2 +- drivers/staging/sm750fb/ddk750_mode.c | 2 +- drivers/staging/sm750fb/ddk750_reg.h | 4 ++-- drivers/staging/sm750fb/ddk750_sii164.c | 4 ++-- drivers/staging/sm750fb/readme | 8 ++++---- drivers/staging/sm750fb/sm750.c | 12 ++++++------ drivers/staging/sm750fb/sm750_accel.c | 4 ++-- drivers/staging/sm750fb/sm750_hw.h | 2 +- drivers/staging/unisys/include/guestlinuxdebug.h | 2 +- drivers/staging/vt6655/rxtx.c | 2 +- 42 files changed, 65 insertions(+), 65 deletions(-) diff --git a/drivers/staging/android/ion/ion_priv.h b/drivers/staging/android/ion/ion_priv.h index 18a5f93e13b7..52f1cd1a67ed 100644 --- a/drivers/staging/android/ion/ion_priv.h +++ b/drivers/staging/android/ion/ion_priv.h @@ -33,7 +33,7 @@ struct ion_buffer *ion_handle_buffer(struct ion_handle *handle); /** * struct ion_buffer - metadata for a particular buffer - * @ref: refernce count + * @ref: reference count * @node: node in the ion_device buffers tree * @dev: back pointer to the ion_device * @heap: back pointer to the heap the buffer came from @@ -46,7 +46,7 @@ struct ion_buffer *ion_handle_buffer(struct ion_handle *handle); * an ion_phys_addr_t (and someday a phys_addr_t) * @lock: protects the buffers cnt fields * @kmap_cnt: number of times the buffer is mapped to the kernel - * @vaddr: the kenrel mapping if kmap_cnt is not zero + * @vaddr: the kernel mapping if kmap_cnt is not zero * @dmap_cnt: number of times the buffer is mapped for dma * @sg_table: the sg table for the buffer if dmap_cnt is not zero * @pages: flat array of pages in the buffer -- used by fault @@ -266,7 +266,7 @@ void ion_heap_freelist_add(struct ion_heap *heap, struct ion_buffer *buffer); /** * ion_heap_freelist_drain - drain the deferred free list * @heap: the heap - * @size: ammount of memory to drain in bytes + * @size: amount of memory to drain in bytes * * Drains the indicated amount of memory from the deferred freelist immediately. * Returns the total amount freed. The total freed may be higher depending diff --git a/drivers/staging/android/uapi/ion.h b/drivers/staging/android/uapi/ion.h index 6aa495673370..68a14b4e21cb 100644 --- a/drivers/staging/android/uapi/ion.h +++ b/drivers/staging/android/uapi/ion.h @@ -179,7 +179,7 @@ struct ion_custom_data { * DOC: ION_IOC_SYNC - syncs a shared file descriptors to memory * * Deprecated in favor of using the dma_buf api's correctly (syncing - * will happend automatically when the buffer is mapped to a device). + * will happen automatically when the buffer is mapped to a device). * If necessary should be used after touching a cached buffer from the cpu, * this will make the buffer in memory coherent. */ diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 6f269cc35633..146ab009d5f7 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1762,7 +1762,7 @@ cleanup: /* * COMEDI_CMDTEST ioctl - * asynchronous aquisition command testing + * asynchronous acquisition command testing * * arg: * pointer to comedi_cmd structure diff --git a/drivers/staging/dgnc/TODO b/drivers/staging/dgnc/TODO index 2b2c6ea03c61..0e0825bd70ae 100644 --- a/drivers/staging/dgnc/TODO +++ b/drivers/staging/dgnc/TODO @@ -1,9 +1,9 @@ * checkpatch fixes -* remove unecessary comments -* remove unecessary error messages. Example kzalloc() has its +* remove unnecessary comments +* remove unnecessary error messages. Example kzalloc() has its own error message. Adding an extra one is useless. * use goto statements for error handling when appropriate -* there is a lot of unecessary code in the driver. It was +* there is a lot of unnecessary code in the driver. It was originally a standalone driver. Remove uneeded code. Please send patches to Greg Kroah-Hartman and diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c index f5a4d365115f..631240850bca 100644 --- a/drivers/staging/dgnc/dgnc_neo.c +++ b/drivers/staging/dgnc/dgnc_neo.c @@ -1203,7 +1203,7 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch) memcpy_fromio(ch->ch_rqueue + head, &ch->ch_neo_uart->txrxburst, n); /* - * Since RX_FIFO_DATA_ERROR was 0, we are guarenteed + * Since RX_FIFO_DATA_ERROR was 0, we are guaranteed * that all the data currently in the FIFO is free of * breaks and parity/frame/orun errors. */ diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index 2fd04e8129e4..163ca56a11ab 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -1223,7 +1223,7 @@ static int _nbu2ss_epn_in_transfer( } /*-------------------------------------------------------------*/ - /* Start tranfer */ + /* Start transfer */ iBufSize = req->req.length - req->req.actual; if (iBufSize > 0) result = _nbu2ss_epn_in_data(udc, ep, req, iBufSize); diff --git a/drivers/staging/fbtft/Kconfig b/drivers/staging/fbtft/Kconfig index 6cf0c58f538b..346f189d871a 100644 --- a/drivers/staging/fbtft/Kconfig +++ b/drivers/staging/fbtft/Kconfig @@ -12,7 +12,7 @@ config FB_TFT_AGM1264K_FL tristate "FB driver for the AGM1264K-FL LCD display" depends on FB_TFT help - Framebuffer support for the AGM1264K-FL LCD display (two Samsung KS0108 compatable chips) + Framebuffer support for the AGM1264K-FL LCD display (two Samsung KS0108 compatible chips) config FB_TFT_BD663474 tristate "FB driver for the BD663474 LCD Controller" diff --git a/drivers/staging/fwserial/dma_fifo.c b/drivers/staging/fwserial/dma_fifo.c index 027906249598..7a3347c3d02b 100644 --- a/drivers/staging/fwserial/dma_fifo.c +++ b/drivers/staging/fwserial/dma_fifo.c @@ -56,7 +56,7 @@ void dma_fifo_init(struct dma_fifo *fifo) * @size: 'apparent' size, in bytes, of fifo * @align: dma alignment to maintain (should be at least cpu cache alignment), * must be power of 2 - * @tx_limit: maximum # of bytes transmissable per dma (rounded down to + * @tx_limit: maximum # of bytes transmissible per dma (rounded down to * multiple of alignment, but at least align size) * @open_limit: maximum # of outstanding dma transactions allowed * @gfp_mask: get_free_pages mask, passed to kmalloc() diff --git a/drivers/staging/fwserial/fwserial.h b/drivers/staging/fwserial/fwserial.h index 98b853d4acbc..787aa4f3a41b 100644 --- a/drivers/staging/fwserial/fwserial.h +++ b/drivers/staging/fwserial/fwserial.h @@ -218,7 +218,7 @@ struct fwconsole_ops { * prevented with the IN_TX flag. Scheduled under lock to * limit scheduling when fifo has just been drained. * @tx_fifo: fifo used to store & block-up writes for dma to remote - * @max_payload: max bytes transmissable per dma (based on peer's max_payload) + * @max_payload: max bytes transmissible per dma (based on peer's max_payload) * @status_mask: UART_LSR_* bitmask significant to rx (based on termios) * @ignore_mask: UART_LSR_* bitmask of states to ignore (also based on termios) * @break_ctl: if set, port is 'sending break' to remote diff --git a/drivers/staging/iio/Documentation/device.txt b/drivers/staging/iio/Documentation/device.txt index 8be32e5a0af1..54ef0deed28f 100644 --- a/drivers/staging/iio/Documentation/device.txt +++ b/drivers/staging/iio/Documentation/device.txt @@ -52,7 +52,7 @@ Then fill in the following: * info->write_event_value: Write the value associated with on sensor event detectors. E.g. a threshold above which an interrupt occurs. Note that the - meaning of the value to be set is event type dependant. + meaning of the value to be set is event type dependent. - indio_dev->modes: Specify whether direct access and / or ring buffer access is supported. diff --git a/drivers/staging/iio/iio_simple_dummy.h b/drivers/staging/iio/iio_simple_dummy.h index 34989bf248a7..d86ccb76eb6d 100644 --- a/drivers/staging/iio/iio_simple_dummy.h +++ b/drivers/staging/iio/iio_simple_dummy.h @@ -25,7 +25,7 @@ struct iio_dummy_regs; * @accel_calibscale: cache for acceleration calibscale * @lock: lock to ensure state is consistent * @event_irq: irq number for event line (faked) - * @event_val: cache for event theshold value + * @event_val: cache for event threshold value * @event_en: cache of whether event is enabled */ struct iio_dummy_state { diff --git a/drivers/staging/lustre/TODO b/drivers/staging/lustre/TODO index 0512594b5199..f194417d0af7 100644 --- a/drivers/staging/lustre/TODO +++ b/drivers/staging/lustre/TODO @@ -1,6 +1,6 @@ * Possible remaining coding style fix. * Remove deadcode. -* Seperate client/server functionality. Functions only used by server can be +* Separate client/server functionality. Functions only used by server can be removed from client. * Clean up libcfs layer. Ideally we can remove include/linux/libcfs entirely. * Clean up CLIO layer. Lustre client readahead/writeback control needs to better diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c b/drivers/staging/media/bcm2048/radio-bcm2048.c index e9d0691b21d3..cf9128117a9e 100644 --- a/drivers/staging/media/bcm2048/radio-bcm2048.c +++ b/drivers/staging/media/bcm2048/radio-bcm2048.c @@ -217,7 +217,7 @@ #define BCM2048_FREQ_ERROR_FLOOR -20 #define BCM2048_FREQ_ERROR_ROOF 20 -/* -60 dB is reported as full signal strenght */ +/* -60 dB is reported as full signal strength */ #define BCM2048_RSSI_LEVEL_BASE -60 #define BCM2048_RSSI_LEVEL_ROOF -100 #define BCM2048_RSSI_LEVEL_ROOF_NEG 100 @@ -2468,7 +2468,7 @@ static int bcm2048_vidioc_g_tuner(struct file *file, void *priv, } else { /* * RSSI level -60 dB is defined to report full - * signal strenght + * signal strength */ rssi = bcm2048_get_fm_rssi(bdev); if (rssi >= BCM2048_RSSI_LEVEL_BASE) { diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index cdb0981be2e9..9bd73ea5a1fa 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -1239,7 +1239,7 @@ static int cvmx_usb_fill_tx_hw(struct cvmx_usb_state *usb, usb->index) ^ 4; int words = available; - /* Limit the amount of data to waht the SW fifo has */ + /* Limit the amount of data to what the SW fifo has */ if (fifo->entry[i].size <= available) { words = fifo->entry[i].size; fifo->tail++; @@ -1849,7 +1849,7 @@ static void cvmx_usb_start_channel(struct cvmx_usb_state *usb, int channel, transaction->xfersize = usbc_hctsiz.s.xfersize; transaction->pktcnt = usbc_hctsiz.s.pktcnt; } - /* Remeber when we start a split transaction */ + /* Remember when we start a split transaction */ if (cvmx_usb_pipe_needs_split(usb, pipe)) usb->active_split = transaction; USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), diff --git a/drivers/staging/octeon-usb/octeon-hcd.h b/drivers/staging/octeon-usb/octeon-hcd.h index 3e351ab7465a..70e7fa5e37d9 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.h +++ b/drivers/staging/octeon-usb/octeon-hcd.h @@ -1693,7 +1693,7 @@ union cvmx_usbnx_usbp_ctl_status { * struct cvmx_usbnx_usbp_ctl_status_s * @txrisetune: HS Transmitter Rise/Fall Time Adjustment * @txvreftune: HS DC Voltage Level Adjustment - * @txfslstune: FS/LS Source Impedence Adjustment + * @txfslstune: FS/LS Source Impedance Adjustment * @txhsxvtune: Transmitter High-Speed Crossover Adjustment * @sqrxtune: Squelch Threshold Adjustment * @compdistune: Disconnect Threshold Adjustment diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h index b8c42eed98c4..5015748a9f42 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h @@ -159,7 +159,7 @@ struct txpowerinfo24g { /* | 1byte|----8bytes----|1byte|--5bytes--| */ /* | | Reserved(14bytes) | */ -/* PG data exclude header, dummy 6 bytes frome CP test and reserved 1byte. */ +/* PG data exclude header, dummy 6 bytes from CP test and reserved 1byte. */ #define EFUSE_OOB_PROTECT_BYTES 15 #define HWSET_MAX_SIZE_88E 512 @@ -177,7 +177,7 @@ struct txpowerinfo24g { /* 9bytes + 1byt + 5bytes and pre 1byte. */ /* For worst case: */ /* | 2byte|----8bytes----|1byte|--7bytes--| 92D */ -/* PG data exclude header, dummy 7 bytes frome CP test and reserved 1byte. */ +/* PG data exclude header, dummy 7 bytes from CP test and reserved 1byte. */ #define EFUSE_OOB_PROTECT_BYTES_88E 18 #define EFUSE_PROTECT_BYTES_BANK_88E 16 diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index 12dd19e1159b..416a1ddb3ac5 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -120,7 +120,7 @@ static void dm_ctstoself(struct net_device *dev); * Prepare SW resource for HW dynamic mechanism. * * Assumption: - * This function is only invoked at driver intialization once. + * This function is only invoked at driver initialization once. */ void init_hal_dm(struct net_device *dev) { diff --git a/drivers/staging/rtl8712/rtl8712_xmit.c b/drivers/staging/rtl8712/rtl8712_xmit.c index a3093ac1204b..8c756df0438d 100644 --- a/drivers/staging/rtl8712/rtl8712_xmit.c +++ b/drivers/staging/rtl8712/rtl8712_xmit.c @@ -340,7 +340,7 @@ u8 r8712_append_mpdu_unit(struct xmit_buf *pxmitbuf, u8 r8712_xmitframe_aggr_1st(struct xmit_buf *pxmitbuf, struct xmit_frame *pxmitframe) { - /* linux complete context doesnt need to protect */ + /* linux complete context doesn't need to protect */ pxmitframe->pxmitbuf = pxmitbuf; pxmitbuf->priv_data = pxmitframe; pxmitframe->pxmit_urb[0] = pxmitbuf->pxmit_urb[0]; diff --git a/drivers/staging/rtl8712/rtl871x_mp_phy_regdef.h b/drivers/staging/rtl8712/rtl871x_mp_phy_regdef.h index 8e2586231ffd..2e9120a21a0b 100644 --- a/drivers/staging/rtl8712/rtl871x_mp_phy_regdef.h +++ b/drivers/staging/rtl8712/rtl871x_mp_phy_regdef.h @@ -603,7 +603,7 @@ #define bCCKRxIG 0x7f00 #define bCCKLNAPolarity 0x800000 #define bCCKRx1stGain 0x7f0000 -#define bCCKRFExtend 0x20000000 /* CCK Rx inital gain polarity */ +#define bCCKRFExtend 0x20000000 /* CCK Rx initial gain polarity */ #define bCCKRxAGCSatLevel 0x1f000000 #define bCCKRxAGCSatCount 0xe0 #define bCCKRxRFSettle 0x1f /* AGCsamp_dly */ diff --git a/drivers/staging/rtl8723au/hal/HalPwrSeqCmd.c b/drivers/staging/rtl8723au/hal/HalPwrSeqCmd.c index ae090ab11585..0a3d96e840cc 100644 --- a/drivers/staging/rtl8723au/hal/HalPwrSeqCmd.c +++ b/drivers/staging/rtl8723au/hal/HalPwrSeqCmd.c @@ -92,7 +92,7 @@ u8 HalPwrSeqCmdParsing23a(struct rtw_adapter *padapter, u8 CutVersion, value |= (GET_PWR_CFG_VALUE(PwrCfgCmd) & GET_PWR_CFG_MASK(PwrCfgCmd)); - /* Write the value back to sytem register */ + /* Write the value back to system register */ rtl8723au_write8(padapter, offset, value); break; diff --git a/drivers/staging/rtl8723au/hal/odm.c b/drivers/staging/rtl8723au/hal/odm.c index ec543cfe1b45..eb598cf8d229 100644 --- a/drivers/staging/rtl8723au/hal/odm.c +++ b/drivers/staging/rtl8723au/hal/odm.c @@ -40,7 +40,7 @@ static u32 EDCAParam[HT_IOT_PEER_MAX][3] = { /* UL DL */ {0x5ea42b, 0xa630, 0x5e431c}, /* 11:airgocap AP */ }; -/* EDCA Paramter for AP/ADSL by Mingzhi 2011-11-22 */ +/* EDCA Parameter for AP/ADSL by Mingzhi 2011-11-22 */ /* Global var */ u32 OFDMSwingTable23A[OFDM_TABLE_SIZE_92D] = { diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 04d01833dc30..efe173072ad5 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1396,7 +1396,7 @@ static void _DisableAnalog(struct rtw_adapter *padapter, bool bWithoutHWSM) /* value16 |= (APDM_HOST | FSM_HSUS |/PFM_ALDN); */ /* 2010/08/31 According to Filen description, we need to use HW to shut down 8051 automatically. */ - /* Becasue suspend operatione need the asistance of 8051 + /* Because suspend operation need the asistance of 8051 to wait for 3ms. */ value16 = APDM_HOST | AFSM_HSUS | PFM_ALDN; } else { diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c b/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c index 46a30659c96f..7fa97808b951 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c @@ -660,7 +660,7 @@ 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 */ + /* We will separate as 88C / 92C according to chip version */ /* */ ODM_ReadAndConfig_PHY_REG_1T_8723A(&pHalData->odmpriv); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c b/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c index 3e3f18634ffe..4909835cc540 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c @@ -138,7 +138,7 @@ void rtl823a_phy_rf6052setccktxpower(struct rtw_adapter *Adapter, /* Currently, we cannot fully disable driver dynamic tx power * mechanism because it is referenced by BT coexist mechanism. */ /* In the future, two mechanism shall be separated from each other - * and maintained independantly. Thanks for Lanhsin's reminder. */ + * and maintained independently. Thanks for Lanhsin's reminder. */ if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1) { TxAGC[RF_PATH_A] = 0x10101010; TxAGC[RF_PATH_B] = 0x10101010; @@ -300,7 +300,7 @@ getTxPowerWriteValByRegulatory(struct rtw_adapter *Adapter, u8 Channel, /* Currently, we cannot fully disable driver dynamic tx power mechanism because it is referenced by BT coexist mechanism. */ /* In the future, two mechanism shall be separated from each other and - maintained independantly. Thanks for Lanhsin's reminder. */ + maintained independently. Thanks for Lanhsin's reminder. */ if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1) writeVal = 0x14141414; diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c index 6bf87fe86644..14746dd8db78 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c @@ -252,7 +252,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz) } /* (1) The sequence number of each non-Qos frame / broadcast / multicast / */ - /* mgnt frame should be controled by Hw because Fw will also send null data */ + /* mgnt frame should be controlled by Hw because Fw will also send null data */ /* which we cannot control when Fw LPS enable. */ /* --> default enable non-Qos data sequense number. 2010.06.23. by tynli. */ /* (2) Enable HW SEQ control for beacon packet, because we use Hw beacon. */ diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 42ae29d26302..68156a13d00f 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -360,7 +360,7 @@ static void _InitWMACSetting(struct rtw_adapter *Adapter) /* 2010.09.08 hpfan */ /* Since ADF is removed from RCR, ps-poll will not be indicate to driver, */ - /* RxFilterMap should mask ps-poll to gurantee AP mode can + /* RxFilterMap should mask ps-poll to guarantee AP mode can rx ps-poll. */ /* value16 = 0x400; */ /* rtl8723au_write16(Adapter, REG_RXFLTMAP1, value16); */ diff --git a/drivers/staging/rtl8723au/include/odm_debug.h b/drivers/staging/rtl8723au/include/odm_debug.h index 83be5bab9e09..c4b375a6f409 100644 --- a/drivers/staging/rtl8723au/include/odm_debug.h +++ b/drivers/staging/rtl8723au/include/odm_debug.h @@ -22,7 +22,7 @@ /* Define the debug levels */ /* */ /* 1. DBG_TRACE and DBG_LOUD are used for normal cases. */ -/* So that, they can help SW engineer to develope or trace states changed */ +/* So that, they can help SW engineer to develop or trace states changed */ /* and also help HW enginner to trace every operation to and from HW, */ /* e.g IO, Tx, Rx. */ /* */ diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index ad3a442bc000..8ee301b44f0f 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -193,7 +193,7 @@ enum ChannelPlan /* | | Reserved(14bytes) | */ /* */ -/* PG data exclude header, dummy 6 bytes frome CP test and reserved 1byte. */ +/* PG data exclude header, dummy 6 bytes from CP test and reserved 1byte. */ #define EFUSE_OOB_PROTECT_BYTES 15 #define EFUSE_REAL_CONTENT_LEN_8723A 512 diff --git a/drivers/staging/rtl8723au/include/rtw_cmd.h b/drivers/staging/rtl8723au/include/rtw_cmd.h index 775dcdc1e7b9..4dcc9253be51 100644 --- a/drivers/staging/rtl8723au/include/rtw_cmd.h +++ b/drivers/staging/rtl8723au/include/rtw_cmd.h @@ -657,7 +657,7 @@ struct TDLSoption_param { Result: 0x00: success -0x01: sucess, and check Response. +0x01: success, and check Response. 0x02: cmd ignored due to duplicated sequcne number 0x03: cmd dropped due to invalid cmd code 0x04: reserved. diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index a6751f138336..dbd3a5f5c523 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -50,11 +50,11 @@ #define WIFI_SITE_MONITOR 0x00000800 #define WIFI_MP_STATE 0x00010000 -#define WIFI_MP_CTX_BACKGROUND 0x00020000 /* in continous tx background */ -#define WIFI_MP_CTX_ST 0x00040000 /* in continous tx with single-tone */ -#define WIFI_MP_CTX_BACKGROUND_PENDING 0x00080000 /* pending in continous tx background due to out of skb */ -#define WIFI_MP_CTX_CCK_HW 0x00100000 /* in continous tx */ -#define WIFI_MP_CTX_CCK_CS 0x00200000 /* in continous tx with carrier suppression */ +#define WIFI_MP_CTX_BACKGROUND 0x00020000 /* in continuous tx background */ +#define WIFI_MP_CTX_ST 0x00040000 /* in continuous tx with single-tone */ +#define WIFI_MP_CTX_BACKGROUND_PENDING 0x00080000 /* pending in continuous tx background due to out of skb */ +#define WIFI_MP_CTX_CCK_HW 0x00100000 /* in continuous tx */ +#define WIFI_MP_CTX_CCK_CS 0x00200000 /* in continuous tx with carrier suppression */ #define WIFI_MP_LPBK_STATE 0x00400000 #define _FW_UNDER_LINKING WIFI_UNDER_LINKING diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index ffb37b252fc1..ea2a6c914d38 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -103,7 +103,7 @@ extern unsigned char WMM_PARA_OUI23A[]; /* Note: */ /* We just add new channel plan when the new channel plan is different from any of the following */ /* channel plan. */ -/* If you just wnat to customize the acitions(scan period or join actions) about one of the channel plan, */ +/* If you just want to customize the actions(scan period or join actions) about one of the channel plan, */ /* customize them in struct rt_channel_info in the RT_CHANNEL_LIST. */ /* */ enum { /* _RT_CHANNEL_DOMAIN */ diff --git a/drivers/staging/rtl8723au/include/sta_info.h b/drivers/staging/rtl8723au/include/sta_info.h index c756b4f7f5d5..e7260050e533 100644 --- a/drivers/staging/rtl8723au/include/sta_info.h +++ b/drivers/staging/rtl8723au/include/sta_info.h @@ -332,7 +332,7 @@ struct sta_priv { */ struct sta_info *sta_aid[NUM_STA]; - u16 sta_dz_bitmap;/* only support 15 stations, staion aid bitmap + u16 sta_dz_bitmap;/* only support 15 stations, station aid bitmap * for sleeping sta. */ u16 tim_bitmap;/* only support 15 stations, * aid=0~15 mapping bit0~bit15 */ diff --git a/drivers/staging/sm750fb/ddk750_help.h b/drivers/staging/sm750fb/ddk750_help.h index 07c8264fac95..e7e49cebd303 100644 --- a/drivers/staging/sm750fb/ddk750_help.h +++ b/drivers/staging/sm750fb/ddk750_help.h @@ -14,7 +14,7 @@ #warning "big endian on target cpu and enable nature big endian support of 718 capability !" #define PEEK32(addr) __raw_readl(mmio750 + addr) #define POKE32(addr,data) __raw_writel(data, mmio750 + addr) -#else /* software control endianess */ +#else /* software control endianness */ #define PEEK32(addr) readl(addr + mmio750) #define POKE32(addr,data) writel(data, addr + mmio750) #endif diff --git a/drivers/staging/sm750fb/ddk750_mode.c b/drivers/staging/sm750fb/ddk750_mode.c index 2e418fb6ffde..021d4c3b2b10 100644 --- a/drivers/staging/sm750fb/ddk750_mode.c +++ b/drivers/staging/sm750fb/ddk750_mode.c @@ -162,7 +162,7 @@ static int programModeRegisters(mode_parameter_t * pModeParam,pll_value_t * pll) /* May a hardware bug or just my test chip (not confirmed). * PANEL_DISPLAY_CTRL register seems requiring few writes - * before a value can be succesfully written in. + * before a value can be successfully written in. * Added some masks to mask out the reserved bits. * Note: This problem happens by design. The hardware will wait for the * next vertical sync to turn on/off the plane. diff --git a/drivers/staging/sm750fb/ddk750_reg.h b/drivers/staging/sm750fb/ddk750_reg.h index 2016f97d2a3d..1a40dc2a2f75 100644 --- a/drivers/staging/sm750fb/ddk750_reg.h +++ b/drivers/staging/sm750fb/ddk750_reg.h @@ -1885,10 +1885,10 @@ #define DISPLAY_CONTROL_750LE 0x80288 /* Palette RAM */ -/* Panel Pallete register starts at 0x080400 ~ 0x0807FC */ +/* Panel Palette register starts at 0x080400 ~ 0x0807FC */ #define PANEL_PALETTE_RAM 0x080400 -/* Panel Pallete register starts at 0x080C00 ~ 0x080FFC */ +/* Panel Palette register starts at 0x080C00 ~ 0x080FFC */ #define CRT_PALETTE_RAM 0x080C00 /* 2D registers diff --git a/drivers/staging/sm750fb/ddk750_sii164.c b/drivers/staging/sm750fb/ddk750_sii164.c index 3d224d6a74ff..84464c1bfdd8 100644 --- a/drivers/staging/sm750fb/ddk750_sii164.c +++ b/drivers/staging/sm750fb/ddk750_sii164.c @@ -256,7 +256,7 @@ long sii164InitChip( -/* below sii164 function is not neccessary */ +/* below sii164 function is not necessary */ #ifdef SII164_FULL_FUNCTIONS @@ -388,7 +388,7 @@ unsigned char sii164IsConnected(void) /* * sii164CheckInterrupt - * Checks if interrupt has occured. + * Checks if interrupt has occurred. * * Output: * 0 - No interrupt diff --git a/drivers/staging/sm750fb/readme b/drivers/staging/sm750fb/readme index ab9af791653d..cfa45958b9d2 100644 --- a/drivers/staging/sm750fb/readme +++ b/drivers/staging/sm750fb/readme @@ -5,7 +5,7 @@ Introduction: - 2D acceleration - 16MB integrated video memory -About the kernel module paramter of driver: +About the kernel module parameter of driver: Use 1280,8bpp index color and 60 hz mode: insmod ./sm750fb.ko g_option="1280x1024-8@60" @@ -20,16 +20,16 @@ About the kernel module paramter of driver: and user can use con2fb to link fbX and ttyX Notes: - 1) if you build the driver with built-in method, the paramter + 1) if you build the driver with built-in method, the parameter you edited in the grub config file will be also the - same format as above modular method,but additionaly add + same format as above modular method,but additionally add "video=sm750fb:" ahead of parameters,so,it looks like: video=sm750fb:noaccel,1280x1024@60,otherparam,etc... it equal to modular method with below command: insmod ./sm750fb.ko g_option="noaccel:1280x1024@60:otherparm:etc..." - 2) if you put 800x600 into the paramter without bpp and + 2) if you put 800x600 into the parameter without bpp and refresh rate, kernel driver will defaulty use 16bpp and 60hz Important: diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c index 3c7ea95dd9f9..77310ff325b2 100644 --- a/drivers/staging/sm750fb/sm750.c +++ b/drivers/staging/sm750fb/sm750.c @@ -207,7 +207,7 @@ static void lynxfb_ops_fillrect(struct fb_info *info, /* * If not use spin_lock,system will die if user load driver - * and immediatly unload driver frequently (dual) + * and immediately unload driver frequently (dual) */ if (share->dual) spin_lock(&share->slock); @@ -239,7 +239,7 @@ static void lynxfb_ops_copyarea(struct fb_info *info, /* * If not use spin_lock, system will die if user load driver - * and immediatly unload driver frequently (dual) + * and immediately unload driver frequently (dual) */ if (share->dual) spin_lock(&share->slock); @@ -283,7 +283,7 @@ static void lynxfb_ops_imageblit(struct fb_info *info, _do_work: /* * If not use spin_lock, system will die if user load driver - * and immediatly unload driver frequently (dual) + * and immediately unload driver frequently (dual) */ if (share->dual) spin_lock(&share->slock); @@ -479,7 +479,7 @@ static int lynxfb_resume(struct pci_dev *pdev) ret = pci_set_power_state(pdev, PCI_D0); if (ret) { - pr_err("error:%d occured in pci_set_power_state\n", ret); + pr_err("error:%d occurred in pci_set_power_state\n", ret); return ret; } @@ -488,7 +488,7 @@ static int lynxfb_resume(struct pci_dev *pdev) pci_restore_state(pdev); ret = pci_enable_device(pdev); if (ret) { - pr_err("error:%d occured in pci_enable_device\n", ret); + pr_err("error:%d occurred in pci_enable_device\n", ret); return ret; } pci_set_master(pdev); @@ -1170,7 +1170,7 @@ static int lynxfb_pci_probe(struct pci_dev *pdev, pr_err("Unable to setup MTRR.\n"); } else { share->mtrr.vram_added = 1; - pr_info("MTRR added succesfully\n"); + pr_info("MTRR added successfully\n"); } } #endif diff --git a/drivers/staging/sm750fb/sm750_accel.c b/drivers/staging/sm750fb/sm750_accel.c index c5a372690737..6a04ef86eb13 100644 --- a/drivers/staging/sm750fb/sm750_accel.c +++ b/drivers/staging/sm750fb/sm750_accel.c @@ -246,7 +246,7 @@ unsigned int rop2) /* ROP value */ #if 0 /* Program pitch (distance between the 1st points of two adjacent lines). Note that input pitch is BYTE value, but the 2D Pitch register uses - pixel values. Need Byte to pixel convertion. + pixel values. Need Byte to pixel conversion. */ if(Bpp == 3){ sx *= 3; @@ -362,7 +362,7 @@ int hw_imageblit(struct lynx_accel *accel, #if 0 /* Program pitch (distance between the 1st points of two adjacent lines). Note that input pitch is BYTE value, but the 2D Pitch register uses - pixel values. Need Byte to pixel convertion. + pixel values. Need Byte to pixel conversion. */ if(bytePerPixel == 3 ){ dx *= 3; diff --git a/drivers/staging/sm750fb/sm750_hw.h b/drivers/staging/sm750fb/sm750_hw.h index b05be5e99f51..c607d9b81cd8 100644 --- a/drivers/staging/sm750fb/sm750_hw.h +++ b/drivers/staging/sm750fb/sm750_hw.h @@ -65,7 +65,7 @@ struct sm750_state{ }; /* sm750_share stands for a presentation of two frame buffer - that use one sm750 adaptor, it is similiar to the super class of lynx_share + that use one sm750 adaptor, it is similar to the super class of lynx_share in C++ */ diff --git a/drivers/staging/unisys/include/guestlinuxdebug.h b/drivers/staging/unisys/include/guestlinuxdebug.h index 957a627d0527..98150aa5bd01 100644 --- a/drivers/staging/unisys/include/guestlinuxdebug.h +++ b/drivers/staging/unisys/include/guestlinuxdebug.h @@ -135,7 +135,7 @@ enum event_pc { /* POSTCODE event identifier tuples */ #define POSTCODE_SEVERITY_ERR DIAG_SEVERITY_ERR #define POSTCODE_SEVERITY_WARNING DIAG_SEVERITY_WARNING #define POSTCODE_SEVERITY_INFO DIAG_SEVERITY_PRINT /* TODO-> Info currently - * doesnt show, so we + * doesn't show, so we * set info=warning */ /* example call of POSTCODE_LINUX_2(VISOR_CHIPSET_PC, POSTCODE_SEVERITY_ERR); * Please also note that the resulting postcode is in hex, so if you are diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 74687761bd2e..33c4aa49946d 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -656,7 +656,7 @@ s_vFillRTSHead( uRTSFrameLen -= 4; } - /* Note: So far RTSHead dosen't appear in ATIM & Beacom DMA, so we don't need to take them into account. + /* Note: So far RTSHead doesn't appear in ATIM & Beacom DMA, so we don't need to take them into account. Otherwise, we need to modify codes for them. */ if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { if (byFBOption == AUTO_FB_NONE) { From 86b4e7e270d9c08bfbcd0d8ed67ddded8ee35345 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giedrius=20Statkevi=C4=8Dius?= Date: Wed, 8 Apr 2015 16:37:15 +0300 Subject: [PATCH 0147/1163] staging: dgnc: remove some dead code from dgnc_tty.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove some dead code that will never be executed or which serves no purpose Signed-off-by: Giedrius Statkevičius Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index ce4187f60cb4..f954228a5064 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -428,9 +428,6 @@ void dgnc_tty_uninit(struct dgnc_board *brd) brd->PrintDriver.ttys = NULL; } - -#define TMPBUFLEN (1024) - /*======================================================================= * * dgnc_wmove - Write data to transmit queue. @@ -555,15 +552,6 @@ void dgnc_input(struct channel_t *ch) ld = tty_ldisc_ref(tp); -#ifdef TTY_DONT_FLIP - /* - * If the DONT_FLIP flag is on, don't flush our buffer, and act - * like the ld doesn't have any space to put the data right now. - */ - if (test_bit(TTY_DONT_FLIP, &tp->flags)) - len = 0; -#endif - /* * If we were unable to get a reference to the ld, * don't flush our buffer, and act like the ld doesn't @@ -897,10 +885,6 @@ void dgnc_check_queue_flow_control(struct channel_t *ch) ch->ch_stops_sent = 0; ch->ch_bd->bd_ops->send_start_character(ch); } - /* No FLOW */ - else { - /* Nothing needed. */ - } } } From 31296ba5c0f8a079f7f874e6cc0b22312539a550 Mon Sep 17 00:00:00 2001 From: Amitoj Kaur Chawla Date: Wed, 8 Apr 2015 22:25:06 +0530 Subject: [PATCH 0148/1163] Staging: sm750fb: Remove space after parenthesis Fixed error by removing space after open parenthesis '(' Problem found using checkpatch.pl ERROR: space prohibited after that open parenthesis '(' Signed-off-by: Amitoj Kaur Chawla Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/ddk750_chip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/sm750fb/ddk750_chip.c b/drivers/staging/sm750fb/ddk750_chip.c index 7b28328c92f8..3cb860ce60cc 100644 --- a/drivers/staging/sm750fb/ddk750_chip.c +++ b/drivers/staging/sm750fb/ddk750_chip.c @@ -285,7 +285,7 @@ int ddk750_initHw(initchip_param_t *pInitParam) ulReg = FIELD_SET(ulReg, VGA_CONFIGURATION, MODE, GRAPHIC); POKE32(VGA_CONFIGURATION, ulReg); } else { -#if defined(__i386__) || defined( __x86_64__) +#if defined(__i386__) || defined(__x86_64__) /* set graphic mode via IO method */ outb_p(0x88, 0x3d4); outb_p(0x06, 0x3d5); @@ -382,7 +382,7 @@ int ddk750_initHw(initchip_param_t *pInitParam) unsigned int absDiff(unsigned int a, unsigned int b) { - if ( a > b ) + if (a > b) return(a - b); else return(b - a); From 258f6a5005b2b113888e3435453ace3de552d1d1 Mon Sep 17 00:00:00 2001 From: Robin Karlsson Date: Fri, 10 Apr 2015 00:12:16 +0200 Subject: [PATCH 0149/1163] Staging: sm750fb: Fix spelling error in TODO Fixed spelling error in TODO. Signed-off-by: Robin Karlsson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/TODO | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/sm750fb/TODO b/drivers/staging/sm750fb/TODO index bc1617249395..ce23f3ccc3a4 100644 --- a/drivers/staging/sm750fb/TODO +++ b/drivers/staging/sm750fb/TODO @@ -1,5 +1,5 @@ TODO: -- lots of clechpatch cleanup +- lots of checkpatch cleanup - use kernel coding style - refine the code and remove unused code - check on hardware effects of removal of USE_HW_I2C and USE_DVICHIP (these two From fa52d96c3ea110acb77e51c856ec0b54606cc17e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giedrius=20Statkevi=C4=8Dius?= Date: Fri, 10 Apr 2015 02:42:29 +0300 Subject: [PATCH 0150/1163] staging: dgnc: clean up allocation of ->channels[i] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check if kzalloc fails in dgnc_tty_init() and if it does then free all previously allocated ->channels[i] and set them to NULL. This makes the code less error/bug prone because instead of needing programmers attention to add checks everywhere we do that in one place. Also, remove a bogus comment and check in the same loop because ->channels[i] isn't allocated anywhere else. Finally, remove a unnecessary check if ->channels[i] is NULL in the next loop because it can't be. Signed-off-by: Giedrius Statkevičius Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index f954228a5064..a8c88f829e42 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -304,19 +304,15 @@ int dgnc_tty_init(struct dgnc_board *brd) brd->nasync = brd->maxports; - /* - * Allocate channel memory that might not have been allocated - * when the driver was first loaded. - */ for (i = 0; i < brd->nasync; i++) { - if (!brd->channels[i]) { - - /* - * Okay to malloc with GFP_KERNEL, we are not at - * interrupt context, and there are no locks held. - */ - brd->channels[i] = kzalloc(sizeof(*brd->channels[i]), GFP_KERNEL); - } + /* + * Okay to malloc with GFP_KERNEL, we are not at + * interrupt context, and there are no locks held. + */ + brd->channels[i] = kzalloc(sizeof(*brd->channels[i]), + GFP_KERNEL); + if (!brd->channels[i]) + goto err_free_channels; } ch = brd->channels[0]; @@ -324,10 +320,6 @@ int dgnc_tty_init(struct dgnc_board *brd) /* Set up channel variables */ for (i = 0; i < brd->nasync; i++, ch = brd->channels[i]) { - - if (!brd->channels[i]) - continue; - spin_lock_init(&ch->ch_lock); /* Store all our magic numbers */ @@ -375,6 +367,13 @@ int dgnc_tty_init(struct dgnc_board *brd) } return 0; + +err_free_channels: + for (i = i - 1; i >= 0; --i) { + kfree(brd->channels[i]); + brd->channels[i] = NULL; + } + return -ENOMEM; } From ce2927e9a3b325b92acfeab66632f9a38d572722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giedrius=20Statkevi=C4=8Dius?= Date: Fri, 10 Apr 2015 02:42:30 +0300 Subject: [PATCH 0151/1163] staging: dgnc: don't forget to check if ->channels[i] is NULL in dgnc_tty_uninit() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a check if ->channels[i] is NULL because a NULL pointer may be dereferenced in case one of the allocations failed Reported-by: Dan Carpenter Signed-off-by: Giedrius Statkevičius Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index a8c88f829e42..6c9261cb88ec 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -403,7 +403,9 @@ void dgnc_tty_uninit(struct dgnc_board *brd) dgnc_BoardsByMajor[brd->SerialDriver.major] = NULL; brd->dgnc_Serial_Major = 0; for (i = 0; i < brd->nasync; i++) { - dgnc_remove_tty_sysfs(brd->channels[i]->ch_tun.un_sysfs); + if (brd->channels[i]) + dgnc_remove_tty_sysfs(brd->channels[i]-> + ch_tun.un_sysfs); tty_unregister_device(&brd->SerialDriver, i); } tty_unregister_driver(&brd->SerialDriver); @@ -414,7 +416,9 @@ void dgnc_tty_uninit(struct dgnc_board *brd) dgnc_BoardsByMajor[brd->PrintDriver.major] = NULL; brd->dgnc_TransparentPrint_Major = 0; for (i = 0; i < brd->nasync; i++) { - dgnc_remove_tty_sysfs(brd->channels[i]->ch_pun.un_sysfs); + if (brd->channels[i]) + dgnc_remove_tty_sysfs(brd->channels[i]-> + ch_pun.un_sysfs); tty_unregister_device(&brd->PrintDriver, i); } tty_unregister_driver(&brd->PrintDriver); From 071494d832ae2e7a318f86e8d9854ee26b8f1134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giedrius=20Statkevi=C4=8Dius?= Date: Fri, 10 Apr 2015 02:42:31 +0300 Subject: [PATCH 0152/1163] staging: dgnc: remove redundant !ch checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove checks that are redundant since we don't have boards with partially initialized ->channels[i]. Signed-off-by: Giedrius Statkevičius Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_cls.c | 4 +--- drivers/staging/dgnc/dgnc_neo.c | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c index e3564d278d91..a629a78964ce 100644 --- a/drivers/staging/dgnc/dgnc_cls.c +++ b/drivers/staging/dgnc/dgnc_cls.c @@ -379,7 +379,7 @@ static inline void cls_parse_isr(struct dgnc_board *brd, uint port) return; ch = brd->channels[port]; - if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + if (ch->magic != DGNC_CHANNEL_MAGIC) return; /* Here we try to figure out what caused the interrupt to happen */ @@ -714,8 +714,6 @@ static void cls_tasklet(unsigned long data) /* Loop on each port */ for (i = 0; i < ports; i++) { ch = bd->channels[i]; - if (!ch) - continue; /* * NOTE: Remember you CANNOT hold any channel diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c index 631240850bca..900e3ae55a38 100644 --- a/drivers/staging/dgnc/dgnc_neo.c +++ b/drivers/staging/dgnc/dgnc_neo.c @@ -395,7 +395,7 @@ static inline void neo_parse_isr(struct dgnc_board *brd, uint port) return; ch = brd->channels[port]; - if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + if (ch->magic != DGNC_CHANNEL_MAGIC) return; /* Here we try to figure out what caused the interrupt to happen */ From dc44f4e17c475230535f50011ab1f45b696b393b Mon Sep 17 00:00:00 2001 From: Mitchel Humpherys Date: Thu, 9 Apr 2015 18:10:03 -0700 Subject: [PATCH 0153/1163] staging: ion: chunk_heap: use pr_debug for heap creation print We're currently printing to the kernel log at `info' level when we successfully create the chunk heap, but success messages should be done at `debug' level. Fix this. Signed-off-by: Mitchel Humpherys Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion_chunk_heap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/android/ion/ion_chunk_heap.c b/drivers/staging/android/ion/ion_chunk_heap.c index 3e6ec2ee6802..54746157d799 100644 --- a/drivers/staging/android/ion/ion_chunk_heap.c +++ b/drivers/staging/android/ion/ion_chunk_heap.c @@ -173,7 +173,7 @@ struct ion_heap *ion_chunk_heap_create(struct ion_platform_heap *heap_data) chunk_heap->heap.ops = &chunk_heap_ops; chunk_heap->heap.type = ION_HEAP_TYPE_CHUNK; chunk_heap->heap.flags = ION_HEAP_FLAG_DEFER_FREE; - pr_info("%s: base %lu size %zu align %ld\n", __func__, chunk_heap->base, + pr_debug("%s: base %lu size %zu align %ld\n", __func__, chunk_heap->base, heap_data->size, heap_data->align); return &chunk_heap->heap; From a74d8e21679cdb2b087ff386c34e874af8bac77a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giedrius=20Statkevi=C4=8Dius?= Date: Fri, 10 Apr 2015 17:48:54 +0300 Subject: [PATCH 0154/1163] staging: dgnc: remove dead code in dgnc_tty_write() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the dead code protected by in_user in dgnc_tty_write() because it is set to 0 and never changed to 1 thus the code in ifs never gets executed. Signed-off-by: Giedrius Statkevičius Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 45 +-------------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index 6c9261cb88ec..cde55e001f8d 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -42,16 +42,11 @@ #include "dgnc_sysfs.h" #include "dgnc_utils.h" -#define init_MUTEX(sem) sema_init(sem, 1) -#define DECLARE_MUTEX(name) \ - struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) - /* * internal variables */ static struct dgnc_board *dgnc_BoardsByMajor[256]; static unsigned char *dgnc_TmpWriteBuf; -static DECLARE_MUTEX(dgnc_TmpWriteSem); /* * Default transparent print information. @@ -1692,7 +1687,6 @@ static int dgnc_tty_write(struct tty_struct *tty, ushort tail; ushort tmask; uint remain; - int from_user = 0; if (tty == NULL || dgnc_TmpWriteBuf == NULL) return 0; @@ -1772,38 +1766,6 @@ static int dgnc_tty_write(struct tty_struct *tty, if (count <= 0) goto exit_retry; - if (from_user) { - - count = min(count, WRITEBUFLEN); - - spin_unlock_irqrestore(&ch->ch_lock, flags); - - /* - * If data is coming from user space, copy it into a temporary - * buffer so we don't get swapped out while doing the copy to - * the board. - */ - /* we're allowed to block if it's from_user */ - if (down_interruptible(&dgnc_TmpWriteSem)) - return -EINTR; - - /* - * copy_from_user() returns the number - * of bytes that could *NOT* be copied. - */ - count -= copy_from_user(dgnc_TmpWriteBuf, (const unsigned char __user *) buf, count); - - if (!count) { - up(&dgnc_TmpWriteSem); - return -EFAULT; - } - - spin_lock_irqsave(&ch->ch_lock, flags); - - buf = dgnc_TmpWriteBuf; - - } - n = count; /* @@ -1840,12 +1802,7 @@ static int dgnc_tty_write(struct tty_struct *tty, ch->ch_cpstime += (HZ * count) / ch->ch_digi.digi_maxcps; } - if (from_user) { - spin_unlock_irqrestore(&ch->ch_lock, flags); - up(&dgnc_TmpWriteSem); - } else { - spin_unlock_irqrestore(&ch->ch_lock, flags); - } + spin_unlock_irqrestore(&ch->ch_lock, flags); if (count) { /* From eef94f6b7bff013d4efbc5d8ba1eefcd5a88734d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giedrius=20Statkevi=C4=8Dius?= Date: Fri, 10 Apr 2015 17:48:55 +0300 Subject: [PATCH 0155/1163] staging: dgnc: remove redundant check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit count doesn't get changed in between identical checks in dgnc_tty_write() so remove the second check Signed-off-by: Giedrius Statkevičius Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index cde55e001f8d..5c5c4b774256 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -1760,12 +1760,6 @@ static int dgnc_tty_write(struct tty_struct *tty, ch->ch_flags &= ~CH_PRON; } - /* - * If there is nothing left to copy, or I can't handle any more data, leave. - */ - if (count <= 0) - goto exit_retry; - n = count; /* From 272b1ae57828b99c932d518da6f174bcb72b87f7 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 1 May 2015 18:03:56 +0100 Subject: [PATCH 0156/1163] staging: comedi: mite: move #include The Comedi driver modules build fine if the inclusion of is removed from "mite.h", so remove it. However, since "mite.c" calls `kzalloc()`, include there. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 1 + drivers/staging/comedi/drivers/mite.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index e43a0c8323c1..e45ce003ec23 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -47,6 +47,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include "../comedi_pci.h" diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index b3ca7fc3a31e..cf45f88486e9 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -20,7 +20,6 @@ #define _MITE_H_ #include -#include #include "../comedi_pci.h" #define PCIMIO_COMPAT From 5f7c682226c3601649e59c5d3bcaf1c8e6a6ca33 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 1 May 2015 18:03:57 +0100 Subject: [PATCH 0157/1163] staging: comedi: mite.h: remove PCIMIO_COMPAT The macro `PCIMIO_COMPAT` is defined, but never used. Remove it. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index cf45f88486e9..620de2e9c2ee 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -22,8 +22,6 @@ #include #include "../comedi_pci.h" -#define PCIMIO_COMPAT - #define MAX_MITE_DMA_CHANNELS 8 struct mite_dma_descriptor { From c0cb606a3456ca956431e7b554c29f0212475e98 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 1 May 2015 18:03:58 +0100 Subject: [PATCH 0158/1163] staging: comedi: mite.c: remove commented out USE_KMALLOC The definition of the macro `USE_KMALLOC` is commented out, and nothing refers to it. Remove the commented out macro. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index e45ce003ec23..66b2becc6d73 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -42,8 +42,6 @@ */ -/* #define USE_KMALLOC */ - #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include From c95f212de8ff7f5058ab2c1eb60b8e79d341111b Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 1 May 2015 18:03:59 +0100 Subject: [PATCH 0159/1163] staging: comedi: mite.h: remove "../comedi_pci.h" and make self-reliant "mite.h" relies on a lot of things declared including "../comedi_pci.h", but doesn't need anything in "../comedi_pci.h" itself. None of the Comedi modules that include "mite.h" rely on it to include "../comedi_pci.h" on their behalf. Remove the inclusion of "../comedi_pci.h" from "mite.h", and add enough other includes and (incomplete) `struct` declarations to make it compile without warnings or errors even when included first in a .c file. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index 620de2e9c2ee..5aa4da973691 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -19,11 +19,17 @@ #ifndef _MITE_H_ #define _MITE_H_ +#include #include -#include "../comedi_pci.h" +#include #define MAX_MITE_DMA_CHANNELS 8 +struct comedi_device; +struct comedi_subdevice; +struct device; +struct pci_dev; + struct mite_dma_descriptor { __le32 count; __le32 addr; From f751a0d5039732b439e7c21866f23a9762ebd94e Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 1 May 2015 18:04:00 +0100 Subject: [PATCH 0160/1163] staging: comedi: mite.h: reformat some comments Use the usual style for block comments. Squash double spaces after comment opening sequences. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.h | 59 ++++++++++++++------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index 5aa4da973691..0d178c1745b1 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -1,20 +1,20 @@ /* - module/mite.h - Hardware driver for NI Mite PCI interface chip - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 1999 David A. Schleef - - 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. -*/ + * module/mite.h + * Hardware driver for NI Mite PCI interface chip + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 1999 David A. Schleef + * + * 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. + */ #ifndef _MITE_H_ #define _MITE_H_ @@ -115,12 +115,14 @@ int mite_buf_change(struct mite_dma_descriptor_ring *ring, struct comedi_subdevice *s); enum mite_registers { - /* The bits 0x90180700 in MITE_UNKNOWN_DMA_BURST_REG can be - written and read back. The bits 0x1f always read as 1. - The rest always read as zero. */ + /* + * The bits 0x90180700 in MITE_UNKNOWN_DMA_BURST_REG can be + * written and read back. The bits 0x1f always read as 1. + * The rest always read as zero. + */ MITE_UNKNOWN_DMA_BURST_REG = 0x28, MITE_IODWBSR = 0xc0, /* IO Device Window Base Size Register */ - MITE_IODWBSR_1 = 0xc4, /* IO Device Window Base Size Register 1 */ + MITE_IODWBSR_1 = 0xc4, /* IO Device Window Base Size Register 1 */ MITE_IODWCR_1 = 0xf4, MITE_PCI_CONFIG_OFFSET = 0x300, MITE_CSIGR = 0x460 /* chip signature */ @@ -146,7 +148,7 @@ enum mite_registers { #define MITE_FCR(x) (0x40 + MITE_CHAN(x)) /* fifo count */ enum MITE_IODWBSR_bits { - WENAB = 0x80, /* window enable */ + WENAB = 0x80, /* window enable */ }; static inline unsigned MITE_IODWBSR_1_WSIZE_bits(unsigned size) @@ -169,27 +171,27 @@ static inline int mite_csigr_version(u32 csigr_bits) }; static inline int mite_csigr_type(u32 csigr_bits) -{ /* original mite = 0, minimite = 1 */ +{ /* original mite = 0, minimite = 1 */ return (csigr_bits >> 4) & 0xf; }; static inline int mite_csigr_mmode(u32 csigr_bits) -{ /* mite mode, minimite = 1 */ +{ /* mite mode, minimite = 1 */ return (csigr_bits >> 8) & 0x3; }; static inline int mite_csigr_imode(u32 csigr_bits) -{ /* cpu port interface mode, pci = 0x3 */ +{ /* cpu port interface mode, pci = 0x3 */ return (csigr_bits >> 12) & 0x3; }; static inline int mite_csigr_dmac(u32 csigr_bits) -{ /* number of dma channels */ +{ /* number of dma channels */ return (csigr_bits >> 16) & 0xf; }; static inline int mite_csigr_wpdep(u32 csigr_bits) -{ /* write post fifo depth */ +{ /* write post fifo depth */ unsigned int wpdep_bits = (csigr_bits >> 20) & 0x7; return (wpdep_bits) ? (1 << (wpdep_bits - 1)) : 0; @@ -201,7 +203,7 @@ static inline int mite_csigr_wins(u32 csigr_bits) }; static inline int mite_csigr_iowins(u32 csigr_bits) -{ /* number of io windows */ +{ /* number of io windows */ return (csigr_bits >> 29) & 0x7; }; @@ -290,8 +292,7 @@ static inline int CR_REQS(int source) static inline int CR_REQSDRQ(unsigned drq_line) { - /* This also works on m-series when - using channels (drq_line) 4 or 5. */ + /* This also works on m-series when using channels (drq_line) 4 or 5. */ return CR_REQS((drq_line & 0x3) | 0x4); } From 65f6fac914b5710ef42ef2702ddf00b06cf9e607 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 1 May 2015 18:04:01 +0100 Subject: [PATCH 0161/1163] staging: comedi: mite.c: reformat comments Use the usual style for block comments. Squash double spaces after comment opening sequences. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 105 +++++++++++++------------- 1 file changed, 54 insertions(+), 51 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 66b2becc6d73..b514ad131100 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -1,46 +1,46 @@ /* - comedi/drivers/mite.c - Hardware driver for NI Mite PCI interface chip - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 1997-2002 David A. Schleef - - 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. -*/ + * comedi/drivers/mite.c + * Hardware driver for NI Mite PCI interface chip + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 1997-2002 David A. Schleef + * + * 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. + */ /* - The PCI-MIO E series driver was originally written by - Tomasz Motylewski <...>, and ported to comedi by ds. - - References for specifications: - - 321747b.pdf Register Level Programmer Manual (obsolete) - 321747c.pdf Register Level Programmer Manual (new) - DAQ-STC reference manual - - Other possibly relevant info: - - 320517c.pdf User manual (obsolete) - 320517f.pdf User manual (new) - 320889a.pdf delete - 320906c.pdf maximum signal ratings - 321066a.pdf about 16x - 321791a.pdf discontinuation of at-mio-16e-10 rev. c - 321808a.pdf about at-mio-16e-10 rev P - 321837a.pdf discontinuation of at-mio-16de-10 rev d - 321838a.pdf about at-mio-16de-10 rev N - - ISSUES: - -*/ + * The PCI-MIO E series driver was originally written by + * Tomasz Motylewski <...>, and ported to comedi by ds. + * + * References for specifications: + * + * 321747b.pdf Register Level Programmer Manual (obsolete) + * 321747c.pdf Register Level Programmer Manual (new) + * DAQ-STC reference manual + * + * Other possibly relevant info: + * + * 320517c.pdf User manual (obsolete) + * 320517f.pdf User manual (new) + * 320889a.pdf delete + * 320906c.pdf maximum signal ratings + * 321066a.pdf about 16x + * 321791a.pdf discontinuation of at-mio-16e-10 rev. c + * 321808a.pdf about at-mio-16e-10 rev P + * 321837a.pdf discontinuation of at-mio-16de-10 rev d + * 321838a.pdf about at-mio-16de-10 rev N + * + * ISSUES: + * + */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt @@ -131,7 +131,7 @@ int mite_setup2(struct comedi_device *dev, mite->mite_io_addr + MITE_IODWBSR); } /* - * make sure dma bursts work. I got this from running a bus analyzer + * Make sure dma bursts work. I got this from running a bus analyzer * on a pxi-6281 and a pxi-6713. 6713 powered up with register value * of 0x61f and bursts worked. 6281 powered up with register value of * 0x1f and bursts didn't work. The NI windows driver reads the @@ -223,7 +223,8 @@ struct mite_channel *mite_request_channel_in_range(struct mite_struct *mite, unsigned long flags; struct mite_channel *channel = NULL; - /* spin lock so mite_release_channel can be called safely + /* + * spin lock so mite_release_channel can be called safely * from interrupts */ spin_lock_irqsave(&mite->lock, flags); @@ -245,15 +246,15 @@ void mite_release_channel(struct mite_channel *mite_chan) struct mite_struct *mite = mite_chan->mite; unsigned long flags; - /* spin lock to prevent races with mite_request_channel */ + /* spin lock to prevent races with mite_request_channel */ spin_lock_irqsave(&mite->lock, flags); if (mite->channel_allocated[mite_chan->channel]) { mite_dma_disarm(mite_chan); mite_dma_reset(mite_chan); - /* - * disable all channel's interrupts (do it after disarm/reset so - * MITE_CHCR reg isn't changed while dma is still active!) - */ + /* + * disable all channel's interrupts (do it after disarm/reset so + * MITE_CHCR reg isn't changed while dma is still active!) + */ writel(CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE | CHCR_CLR_SAR_IE | CHCR_CLR_DONE_IE | CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE | @@ -285,7 +286,7 @@ void mite_dma_arm(struct mite_channel *mite_chan) writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel)); mmiowb(); spin_unlock_irqrestore(&mite->lock, flags); -/* mite_dma_tcr(mite, channel); */ + /* mite_dma_tcr(mite, channel); */ } EXPORT_SYMBOL_GPL(mite_dma_arm); @@ -528,8 +529,10 @@ int mite_sync_input_dma(struct mite_channel *mite_chan, } count = nbytes - async->buf_write_count; - /* it's possible count will be negative due to - * conservative value returned by mite_bytes_written_to_memory_lb */ + /* + * it's possible count will be negative due to conservative value + * returned by mite_bytes_written_to_memory_lb + */ if (count <= 0) return 0; @@ -550,7 +553,7 @@ int mite_sync_output_dma(struct mite_channel *mite_chan, u32 nbytes_ub, nbytes_lb; int count; - /* read alloc as much as we can */ + /* 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 (cmd->stop_src == TRIG_COUNT && (int)(nbytes_lb - stop_count) > 0) From f2348c736989c417fb465f569e1c9e120d04d742 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 1 May 2015 18:04:02 +0100 Subject: [PATCH 0162/1163] staging: comedi: mite.h: whitespace changes in function declarations Reformat some function declarations to avoid bunching up near column 80. Also add a blank line after a `struct` definition. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index 0d178c1745b1..c32d4e4ddccc 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -77,16 +77,13 @@ static inline int mite_setup(struct comedi_device *dev, void mite_detach(struct mite_struct *mite); struct mite_dma_descriptor_ring *mite_alloc_ring(struct mite_struct *mite); void mite_free_ring(struct mite_dma_descriptor_ring *ring); -struct mite_channel *mite_request_channel_in_range(struct mite_struct *mite, - struct - mite_dma_descriptor_ring - *ring, unsigned min_channel, - unsigned max_channel); -static inline struct mite_channel *mite_request_channel(struct mite_struct - *mite, - struct - mite_dma_descriptor_ring - *ring) +struct mite_channel * +mite_request_channel_in_range(struct mite_struct *mite, + struct mite_dma_descriptor_ring *ring, + unsigned min_channel, unsigned max_channel); +static inline struct mite_channel * +mite_request_channel(struct mite_struct *mite, + struct mite_dma_descriptor_ring *ring) { return mite_request_channel_in_range(mite, ring, 0, mite->num_channels - 1); @@ -285,6 +282,7 @@ enum ConfigRegister_bits { CR_PORTMXI = (3 << 6), CR_AMDEVICE = (1 << 0), }; + static inline int CR_REQS(int source) { return (source & 0x7) << 16; From 3ad94703419df346d1435da5c75aa4a9117753b9 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 1 May 2015 18:04:03 +0100 Subject: [PATCH 0163/1163] staging: comedi: mite: use a better MODULE_DESCRIPTION() Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index b514ad131100..fa7ae2c04556 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -624,5 +624,5 @@ module_init(mite_module_init); module_exit(mite_module_exit); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("Comedi helper for NI Mite PCI interface chip"); MODULE_LICENSE("GPL"); From bdc01d5711b33444a23dde3334cc24a0fe97d917 Mon Sep 17 00:00:00 2001 From: Nickolaus Woodruff Date: Sun, 12 Apr 2015 12:42:03 -0400 Subject: [PATCH 0164/1163] staging: rtl8192u: Make core functions static This patch fixes the following sparse warnings in r8192U_core.c: CHECK drivers/staging/rtl8192u/r8192U_core.c drivers/staging/rtl8192u/r8192U_core.c:3212:6: warning: symbol 'rtl819x_watchdog_wqcallback' was not declared. Should it be static? drivers/staging/rtl8192u/r8192U_core.c:3276:6: warning: symbol 'watch_dog_timer_callback' was not declared. Should it be static? drivers/staging/rtl8192u/r8192U_core.c:3282:5: warning: symbol '_rtl8192_up' was not declared. Should it be static? drivers/staging/rtl8192u/r8192U_core.c:3333:5: warning: symbol 'rtl8192_close' was not declared. Should it be static? drivers/staging/rtl8192u/r8192U_core.c:3406:6: warning: symbol 'rtl8192_restart' was not declared. Should it be static? drivers/staging/rtl8192u/r8192U_core.c:4618:6: warning: symbol 'rtl8192_irq_rx_tasklet' was not declared. Should it be static? drivers/staging/rtl8192u/r8192U_core.c:4736:6: warning: symbol 'rtl8192_cancel_deferred_work' was not declared. Should it be static? Signed-off-by: Nickolaus Woodruff Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index a4795afeeb9c..134332234ab9 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -3209,7 +3209,7 @@ static void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum, } -void rtl819x_watchdog_wqcallback(struct work_struct *work) +static void rtl819x_watchdog_wqcallback(struct work_struct *work) { struct delayed_work *dwork = container_of(work, struct delayed_work, work); struct r8192_priv *priv = container_of(dwork, struct r8192_priv, watch_dog_wq); @@ -3273,13 +3273,13 @@ void rtl819x_watchdog_wqcallback(struct work_struct *work) } -void watch_dog_timer_callback(unsigned long data) +static void watch_dog_timer_callback(unsigned long data) { struct r8192_priv *priv = ieee80211_priv((struct net_device *) data); queue_delayed_work(priv->priv_wq, &priv->watch_dog_wq, 0); mod_timer(&priv->watch_dog_timer, jiffies + MSECS(IEEE80211_WATCH_DOG_TIME)); } -int _rtl8192_up(struct net_device *dev) +static int _rtl8192_up(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); int init_status = 0; @@ -3330,7 +3330,7 @@ int rtl8192_up(struct net_device *dev) } -int rtl8192_close(struct net_device *dev) +static int rtl8192_close(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); int ret; @@ -3403,7 +3403,7 @@ void rtl8192_commit(struct net_device *dev) } -void rtl8192_restart(struct work_struct *work) +static void rtl8192_restart(struct work_struct *work) { struct r8192_priv *priv = container_of(work, struct r8192_priv, reset_wq); struct net_device *dev = priv->ieee80211->dev; @@ -4615,7 +4615,7 @@ static void rtl8192_rx_cmd(struct sk_buff *skb) } } -void rtl8192_irq_rx_tasklet(struct r8192_priv *priv) +static void rtl8192_irq_rx_tasklet(struct r8192_priv *priv) { struct sk_buff *skb; struct rtl8192_rx_info *info; @@ -4733,7 +4733,7 @@ fail: } //detach all the work and timer structure declared or inititialize in r8192U_init function. -void rtl8192_cancel_deferred_work(struct r8192_priv *priv) +static void rtl8192_cancel_deferred_work(struct r8192_priv *priv) { cancel_work_sync(&priv->reset_wq); From 7b7b0c9bbcc6b15e11998b6c644f31a24e3897c0 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 13 Apr 2015 23:47:24 +0200 Subject: [PATCH 0165/1163] staging: rtl8192e: Fix SPACE_BEFORE_TAB warnings Reformat r8192E_phyreg.h to make checkpatch happy. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192e/rtl8192e/r8192E_phyreg.h | 1356 ++++++++--------- 1 file changed, 678 insertions(+), 678 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h b/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h index 7899dd538dcd..d080876a1e30 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h @@ -3,7 +3,7 @@ * * 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 + * 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 @@ -20,48 +20,48 @@ #define _R819XU_PHYREG_H -#define RF_DATA 0x1d4 +#define RF_DATA 0x1d4 -#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_TxDataType 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 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_TxDataType 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 MCS_TXAGC 0x340 -#define CCK_TXAGC 0x348 +#define MCS_TXAGC 0x340 +#define CCK_TXAGC 0x348 /*---------------------0x400~0x4ff----------------------*/ -#define MacBlkCtrl 0x403 +#define MacBlkCtrl 0x403 -#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_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 @@ -94,49 +94,49 @@ #define rFPGA0_XB_LSSIReadBack 0x8a4 #define rFPGA0_XC_LSSIReadBack 0x8a8 #define rFPGA0_XD_LSSIReadBack 0x8ac -#define rFPGA0_PSDReport 0x8b4 +#define rFPGA0_PSDReport 0x8b4 #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 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_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_TxFilter1 0xa20 +#define rCCK0_TxFilter2 0xa24 +#define rCCK0_DebugPort 0xa28 #define rCCK0_FalseAlarmReport 0xa2c -#define rCCK0_TRSSIReport 0xa50 -#define rCCK0_RxReport 0xa54 +#define rCCK0_TRSSIReport 0xa50 +#define rCCK0_RxReport 0xa54 #define rCCK0_FACounterLower 0xa5c #define rCCK0_FACounterUpper 0xa58 -#define rOFDM0_LSTF 0xc00 +#define rOFDM0_LSTF 0xc00 #define rOFDM0_TRxPathEnable 0xc04 -#define rOFDM0_TRMuxPar 0xc08 -#define rOFDM0_TRSWIsolation 0xc0c -#define rOFDM0_XARxAFE 0xc10 +#define rOFDM0_TRMuxPar 0xc08 +#define rOFDM0_TRSWIsolation 0xc0c +#define rOFDM0_XARxAFE 0xc10 #define rOFDM0_XARxIQImbalance 0xc14 -#define rOFDM0_XBRxAFE 0xc18 +#define rOFDM0_XBRxAFE 0xc18 #define rOFDM0_XBRxIQImbalance 0xc1c -#define rOFDM0_XCRxAFE 0xc20 +#define rOFDM0_XCRxAFE 0xc20 #define rOFDM0_XCRxIQImbalance 0xc24 -#define rOFDM0_XDRxAFE 0xc28 +#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_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 @@ -151,702 +151,702 @@ #define rOFDM0_AGCParameter1 0xc70 #define rOFDM0_AGCParameter2 0xc74 #define rOFDM0_AGCRSSITable 0xc78 -#define rOFDM0_HTSTFAGC 0xc7c +#define rOFDM0_HTSTFAGC 0xc7c #define rOFDM0_XATxIQImbalance 0xc80 -#define rOFDM0_XATxAFE 0xc84 +#define rOFDM0_XATxAFE 0xc84 #define rOFDM0_XBTxIQImbalance 0xc88 -#define rOFDM0_XBTxAFE 0xc8c +#define rOFDM0_XBTxAFE 0xc8c #define rOFDM0_XCTxIQImbalance 0xc90 -#define rOFDM0_XCTxAFE 0xc94 +#define rOFDM0_XCTxAFE 0xc94 #define rOFDM0_XDTxIQImbalance 0xc98 -#define rOFDM0_XDTxAFE 0xc9c +#define rOFDM0_XDTxAFE 0xc9c #define rOFDM0_RxHPParameter 0xce0 #define rOFDM0_TxPseudoNoiseWgt 0xce4 -#define rOFDM0_FrameSync 0xcf0 -#define rOFDM0_DFSReport 0xcf4 -#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_FrameSync 0xcf0 +#define rOFDM0_DFSReport 0xcf4 +#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 rOFDM1_LSTF 0xd00 +#define rOFDM1_LSTF 0xd00 #define rOFDM1_TRxPathEnable 0xd04 -#define rOFDM1_CFO 0xd08 -#define rOFDM1_CSI1 0xd10 -#define rOFDM1_SBD 0xd14 -#define rOFDM1_CSI2 0xd18 -#define rOFDM1_CFOTracking 0xd2c +#define rOFDM1_CFO 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_TailCFOAB 0xdbc -#define rOFDM_TailCFOCD 0xdc0 +#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_TailCFOAB 0xdbc +#define rOFDM_TailCFOCD 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 rOFDM_BWReport 0xdcc +#define rOFDM_AGCReport 0xdd0 +#define rOFDM_RxSNR 0xdd4 +#define rOFDM_RxEVMCSI 0xdd8 +#define rOFDM_SIGReport 0xddc -#define rTxAGC_Rate18_06 0xe00 -#define rTxAGC_Rate54_24 0xe04 -#define rTxAGC_CCK_Mcs32 0xe08 -#define rTxAGC_Mcs03_Mcs00 0xe10 -#define rTxAGC_Mcs07_Mcs04 0xe14 -#define rTxAGC_Mcs11_Mcs08 0xe18 -#define rTxAGC_Mcs15_Mcs12 0xe1c +#define rTxAGC_Rate18_06 0xe00 +#define rTxAGC_Rate54_24 0xe04 +#define rTxAGC_CCK_Mcs32 0xe08 +#define rTxAGC_Mcs03_Mcs00 0xe10 +#define rTxAGC_Mcs07_Mcs04 0xe14 +#define rTxAGC_Mcs11_Mcs08 0xe18 +#define rTxAGC_Mcs15_Mcs12 0xe1c #define rZebra1_HSSIEnable 0x0 #define rZebra1_TRxEnable1 0x1 #define rZebra1_TRxEnable2 0x2 -#define rZebra1_AGC 0x4 +#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_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 rGlobalCtrl 0 +#define rRTL8256_TxLPF 19 +#define rRTL8256_RxLPF 11 -#define rRTL8258_TxLPF 0x11 -#define rRTL8258_RxLPF 0x13 +#define rRTL8258_TxLPF 0x11 +#define rRTL8258_RxLPF 0x13 #define rRTL8258_RSSILPF 0xa -#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 bCCKTxLength 0xffff0000 -#define bCCKTxCRC16 0xffff -#define bCCKTxStatus 0x1 -#define bOFDMTxStatus 0x2 +#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 bCCKTxLength 0xffff0000 +#define bCCKTxCRC16 0xffff +#define bCCKTxStatus 0x1 +#define bOFDMTxStatus 0x2 -#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 bContTxHSSI 0x400 -#define bIGFromCCK 0x200 -#define bAGCAddress 0x3f -#define bRxHPTx 0x7000 -#define bRxHPT2R 0x38000 -#define bRxHPCCKIni 0xc0000 -#define bAGCTxCode 0xc00000 -#define bAGCRxCode 0x300000 -#define b3WireDataLength 0x800 -#define b3WireAddressLength 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 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 bContTxHSSI 0x400 +#define bIGFromCCK 0x200 +#define bAGCAddress 0x3f +#define bRxHPTx 0x7000 +#define bRxHPT2R 0x38000 +#define bRxHPCCKIni 0xc0000 +#define bAGCTxCode 0xc00000 +#define bAGCRxCode 0x300000 +#define b3WireDataLength 0x800 +#define b3WireAddressLength 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 0x3f000000 -#define bLSSIReadEdge 0x80000000 -#define bLSSIReadBackData 0xfff -#define bLSSIReadOKFlag 0x1000 -#define bCCKSampleRate 0x8 +#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 0x3f000000 +#define bLSSIReadEdge 0x80000000 +#define bLSSIReadBackData 0xfff +#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 bXtalCap 0x0f000000 -#define bXtalCap01 0xc0000000 -#define bXtalCap23 0x3 -#define bXtalCap92x 0x0f000000 -#define bIntDifClkEnable 0x400 -#define bExtSigClkEnable 0x800 +#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 bXtalCap 0x0f000000 +#define bXtalCap01 0xc0000000 +#define bXtalCap23 0x3 +#define bXtalCap92x 0x0f000000 +#define bIntDifClkEnable 0x400 +#define bExtSigClkEnable 0x800 #define bBandgapMbiasPowerUp 0x10000 -#define bAD11SHGain 0xc0000 -#define bAD11InputRange 0x700000 -#define bAD11OPCurrent 0x3800000 -#define bIPathLoopback 0x4000000 -#define bQPathLoopback 0x8000000 -#define bAFELoopback 0x10000000 -#define bDA10Swing 0x7e0 -#define bDA10Reverse 0x800 -#define bDAClkSource 0x1000 -#define bAD7InputRange 0x6000 -#define bAD7Gain 0x38000 -#define bAD7OutputCMMode 0x40000 -#define bAD7InputCMMode 0x380000 -#define bAD7Current 0xc00000 -#define bRegulatorAdjust 0x7000000 -#define bAD11PowerUpAtTx 0x1 -#define bDA10PSAtTx 0x10 -#define bAD11PowerUpAtRx 0x100 -#define bDA10PSAtRx 0x1000 +#define bAD11SHGain 0xc0000 +#define bAD11InputRange 0x700000 +#define bAD11OPCurrent 0x3800000 +#define bIPathLoopback 0x4000000 +#define bQPathLoopback 0x8000000 +#define bAFELoopback 0x10000000 +#define bDA10Swing 0x7e0 +#define bDA10Reverse 0x800 +#define bDAClkSource 0x1000 +#define bAD7InputRange 0x6000 +#define bAD7Gain 0x38000 +#define bAD7OutputCMMode 0x40000 +#define bAD7InputCMMode 0x380000 +#define bAD7Current 0xc00000 +#define bRegulatorAdjust 0x7000000 +#define bAD11PowerUpAtTx 0x1 +#define bDA10PSAtTx 0x10 +#define bAD11PowerUpAtRx 0x100 +#define bDA10PSAtRx 0x1000 -#define bCCKRxAGCFormat 0x200 +#define bCCKRxAGCFormat 0x200 -#define bPSDFFTSamplepPoint 0xc000 -#define bPSDAverageNum 0x3000 -#define bIQPathControl 0xc00 -#define bPSDFreq 0x3ff -#define bPSDAntennaPath 0x30 -#define bPSDIQSwitch 0x40 -#define bPSDRxTrigger 0x400000 -#define bPSDTxTrigger 0x80000000 -#define bPSDSineToneScale 0x7f000000 -#define bPSDReport 0xffff +#define bPSDFFTSamplepPoint 0xc000 +#define bPSDAverageNum 0x3000 +#define bIQPathControl 0xc00 +#define bPSDFreq 0x3ff +#define bPSDAntennaPath 0x30 +#define bPSDIQSwitch 0x40 +#define bPSDRxTrigger 0x400000 +#define bPSDTxTrigger 0x80000000 +#define bPSDSineToneScale 0x7f000000 +#define bPSDReport 0xffff -#define bOFDMTxSC 0x30000000 -#define bCCKTxOn 0x1 -#define bOFDMTxOn 0x2 -#define bDebugPage 0xfff -#define bDebugItem 0xff -#define bAntL 0x10 -#define bAntNonHT 0x100 -#define bAntHT1 0x1000 -#define bAntHT2 0x10000 -#define bAntHT1S1 0x100000 -#define bAntNonHTS1 0x1000000 +#define bOFDMTxSC 0x30000000 +#define bCCKTxOn 0x1 +#define bOFDMTxOn 0x2 +#define bDebugPage 0xfff +#define bDebugItem 0xff +#define bAntL 0x10 +#define bAntNonHT 0x100 +#define bAntHT1 0x1000 +#define bAntHT2 0x10000 +#define bAntHT1S1 0x100000 +#define bAntNonHTS1 0x1000000 -#define bCCKBBMode 0x3 -#define bCCKTxPowerSaving 0x80 -#define bCCKRxPowerSaving 0x40 -#define bCCKSideBand 0x10 -#define bCCKScramble 0x8 -#define bCCKAntDiversity 0x8000 +#define bCCKBBMode 0x3 +#define bCCKTxPowerSaving 0x80 +#define bCCKRxPowerSaving 0x40 +#define bCCKSideBand 0x10 +#define bCCKScramble 0x8 +#define bCCKAntDiversity 0x8000 #define bCCKCarrierRecovery 0x4000 -#define bCCKTxRate 0x3000 -#define bCCKDCCancel 0x0800 -#define bCCKISICancel 0x0400 -#define bCCKMatchFilter 0x0200 -#define bCCKEqualizer 0x0100 -#define bCCKPreambleDetect 0x800000 -#define bCCKFastFalseCCA 0x400000 -#define bCCKChEstStart 0x300000 -#define bCCKCCACount 0x080000 -#define bCCKcs_lim 0x070000 -#define bCCKBistMode 0x80000000 -#define bCCKCCAMask 0x40000000 +#define bCCKTxRate 0x3000 +#define bCCKDCCancel 0x0800 +#define bCCKISICancel 0x0400 +#define bCCKMatchFilter 0x0200 +#define bCCKEqualizer 0x0100 +#define bCCKPreambleDetect 0x800000 +#define bCCKFastFalseCCA 0x400000 +#define bCCKChEstStart 0x300000 +#define bCCKCCACount 0x080000 +#define bCCKcs_lim 0x070000 +#define bCCKBistMode 0x80000000 +#define bCCKCCAMask 0x40000000 #define bCCKTxDACPhase 0x4 #define bCCKRxADCPhase 0x20000000 #define bCCKr_cp_mode0 0x0100 -#define bCCKTxDCOffset 0xf0 -#define bCCKRxDCOffset 0xf -#define bCCKCCAMode 0xc000 -#define bCCKFalseCS_lim 0x3f00 -#define bCCKCS_ratio 0xc00000 -#define bCCKCorgBit_sel 0x300000 -#define bCCKPD_lim 0x0f0000 -#define bCCKNewCCA 0x80000000 -#define bCCKRxHPofIG 0x8000 -#define bCCKRxIG 0x7f00 -#define bCCKLNAPolarity 0x800000 -#define bCCKRx1stGain 0x7f0000 -#define bCCKRFExtend 0x20000000 -#define bCCKRxAGCSatLevel 0x1f000000 -#define bCCKRxAGCSatCount 0xe0 -#define bCCKRxRFSettle 0x1f -#define bCCKFixedRxAGC 0x8000 -#define bCCKAntennaPolarity 0x2000 -#define bCCKTxFilterType 0x0c00 +#define bCCKTxDCOffset 0xf0 +#define bCCKRxDCOffset 0xf +#define bCCKCCAMode 0xc000 +#define bCCKFalseCS_lim 0x3f00 +#define bCCKCS_ratio 0xc00000 +#define bCCKCorgBit_sel 0x300000 +#define bCCKPD_lim 0x0f0000 +#define bCCKNewCCA 0x80000000 +#define bCCKRxHPofIG 0x8000 +#define bCCKRxIG 0x7f00 +#define bCCKLNAPolarity 0x800000 +#define bCCKRx1stGain 0x7f0000 +#define bCCKRFExtend 0x20000000 +#define bCCKRxAGCSatLevel 0x1f000000 +#define bCCKRxAGCSatCount 0xe0 +#define bCCKRxRFSettle 0x1f +#define bCCKFixedRxAGC 0x8000 +#define bCCKAntennaPolarity 0x2000 +#define bCCKTxFilterType 0x0c00 #define bCCKRxAGCReportType 0x0300 -#define bCCKRxDAGCEn 0x80000000 -#define bCCKRxDAGCPeriod 0x20000000 +#define bCCKRxDAGCEn 0x80000000 +#define bCCKRxDAGCPeriod 0x20000000 #define bCCKRxDAGCSatLevel 0x1f000000 -#define bCCKTimingRecovery 0x800000 -#define bCCKTxC0 0x3f0000 -#define bCCKTxC1 0x3f000000 -#define bCCKTxC2 0x3f -#define bCCKTxC3 0x3f00 -#define bCCKTxC4 0x3f0000 -#define bCCKTxC5 0x3f000000 -#define bCCKTxC6 0x3f -#define bCCKTxC7 0x3f00 -#define bCCKDebugPort 0xff0000 -#define bCCKDACDebug 0x0f000000 -#define bCCKFalseAlarmEnable 0x8000 -#define bCCKFalseAlarmRead 0x4000 -#define bCCKTRSSI 0x7f -#define bCCKRxAGCReport 0xfe -#define bCCKRxReport_AntSel 0x80000000 -#define bCCKRxReport_MFOff 0x40000000 +#define bCCKTimingRecovery 0x800000 +#define bCCKTxC0 0x3f0000 +#define bCCKTxC1 0x3f000000 +#define bCCKTxC2 0x3f +#define bCCKTxC3 0x3f00 +#define bCCKTxC4 0x3f0000 +#define bCCKTxC5 0x3f000000 +#define bCCKTxC6 0x3f +#define bCCKTxC7 0x3f00 +#define bCCKDebugPort 0xff0000 +#define bCCKDACDebug 0x0f000000 +#define bCCKFalseAlarmEnable 0x8000 +#define bCCKFalseAlarmRead 0x4000 +#define bCCKTRSSI 0x7f +#define bCCKRxAGCReport 0xfe +#define bCCKRxReport_AntSel 0x80000000 +#define bCCKRxReport_MFOff 0x40000000 #define bCCKRxRxReport_SQLoss 0x20000000 -#define bCCKRxReport_Pktloss 0x10000000 +#define bCCKRxReport_Pktloss 0x10000000 #define bCCKRxReport_Lockedbit 0x08000000 #define bCCKRxReport_RateError 0x04000000 -#define bCCKRxReport_RxRate 0x03000000 +#define bCCKRxReport_RxRate 0x03000000 #define bCCKRxFACounterLower 0xff #define bCCKRxFACounterUpper 0xff000000 -#define bCCKRxHPAGCStart 0xe000 -#define bCCKRxHPAGCFinal 0x1c00 +#define bCCKRxHPAGCStart 0xe000 +#define bCCKRxHPAGCFinal 0x1c00 #define bCCKRxFalseAlarmEnable 0x8000 -#define bCCKFACounterFreeze 0x4000 +#define bCCKFACounterFreeze 0x4000 -#define bCCKTxPathSel 0x10000000 -#define bCCKDefaultRxPath 0xc000000 -#define bCCKOptionRxPath 0x3000000 +#define bCCKTxPathSel 0x10000000 +#define bCCKDefaultRxPath 0xc000000 +#define bCCKOptionRxPath 0x3000000 -#define bNumOfSTF 0x3 -#define bShift_L 0xc0 -#define bGI_TH 0xc -#define bRxPathA 0x1 -#define bRxPathB 0x2 -#define bRxPathC 0x4 -#define bRxPathD 0x8 -#define bTxPathA 0x1 -#define bTxPathB 0x2 -#define bTxPathC 0x4 -#define bTxPathD 0x8 -#define bTRSSIFreq 0x200 -#define bADCBackoff 0x3000 -#define bDFIRBackoff 0xc000 -#define bTRSSILatchPhase 0x10000 -#define bRxIDCOffset 0xff -#define bRxQDCOffset 0xff00 -#define bRxDFIRMode 0x1800000 -#define bRxDCNFType 0xe000000 -#define bRXIQImb_A 0x3ff -#define bRXIQImb_B 0xfc00 -#define bRXIQImb_C 0x3f0000 -#define bRXIQImb_D 0xffc00000 -#define bDC_dc_Notch 0x60000 -#define bRxNBINotch 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 bRatio_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 bCFOLookBack 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 bTxQDCOffset 0xff00 -#define bTxDFIRMode 0x10000 -#define bTxPesudoNoiseOn 0x4000000 -#define bTxPesudoNoise_A 0xff -#define bTxPesudoNoise_B 0xff00 -#define bTxPesudoNoise_C 0xff0000 -#define bTxPesudoNoise_D 0xff000000 -#define bCCADropOption 0x20000 -#define bCCADropThres 0xfff00000 -#define bEDCCA_H 0xf -#define bEDCCA_L 0xf0 -#define bLambda_ED 0x300 -#define bRxInitialGain 0x7f -#define bRxAntDivEn 0x80 -#define bRxAGCAddressForLNA 0x7f00 -#define bRxHighPowerFlow 0x8000 -#define bRxAGCFreezeThres 0xc0000 -#define bRxFreezeStep_AGC1 0x300000 -#define bRxFreezeStep_AGC2 0xc00000 -#define bRxFreezeStep_AGC3 0x3000000 -#define bRxFreezeStep_AGC0 0xc000000 -#define bRxRssi_Cmp_En 0x10000000 -#define bRxQuickAGCEn 0x20000000 -#define bRxAGCFreezeThresMode 0x40000000 -#define bRxOverFlowCheckType 0x80000000 -#define bRxAGCShift 0x7f -#define bTRSW_Tri_Only 0x80 -#define bPowerThres 0x300 -#define bRxAGCEn 0x1 -#define bRxAGCTogetherEn 0x2 -#define bRxAGCMin 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 bRxProcessTime_DAGC 0x300000 -#define bRxSettle_HSSI 0x400000 -#define bRxProcessTime_BBPPW 0x800000 -#define bRxAntennaPowerShift 0x3000000 -#define bRSSITableSelect 0xc000000 -#define bRxHP_Final 0x7000000 -#define bRxHTSettle_BBP 0x7 -#define bRxHTSettle_HSSI 0x8 -#define bRxHTSettle_RxHP 0x70 -#define bRxHTSettle_BBPPW 0x80 -#define bRxHTSettle_Idle 0x300 -#define bRxHTSettle_Reserved 0x1c00 -#define bRxHTRxHPEn 0x8000 -#define bRxHTAGCFreezeThres 0x30000 -#define bRxHTAGCTogetherEn 0x40000 -#define bRxHTAGCMin 0x80000 -#define bRxHTAGCEn 0x100000 -#define bRxHTDAGCEn 0x200000 -#define bRxHTRxHP_BBP 0x1c00000 -#define bRxHTRxHP_Final 0xe0000000 -#define bRxPWRatioTH 0x3 -#define bRxPWRatioEn 0x4 -#define bRxMFHold 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_Guard_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 bNumOfSTF 0x3 +#define bShift_L 0xc0 +#define bGI_TH 0xc +#define bRxPathA 0x1 +#define bRxPathB 0x2 +#define bRxPathC 0x4 +#define bRxPathD 0x8 +#define bTxPathA 0x1 +#define bTxPathB 0x2 +#define bTxPathC 0x4 +#define bTxPathD 0x8 +#define bTRSSIFreq 0x200 +#define bADCBackoff 0x3000 +#define bDFIRBackoff 0xc000 +#define bTRSSILatchPhase 0x10000 +#define bRxIDCOffset 0xff +#define bRxQDCOffset 0xff00 +#define bRxDFIRMode 0x1800000 +#define bRxDCNFType 0xe000000 +#define bRXIQImb_A 0x3ff +#define bRXIQImb_B 0xfc00 +#define bRXIQImb_C 0x3f0000 +#define bRXIQImb_D 0xffc00000 +#define bDC_dc_Notch 0x60000 +#define bRxNBINotch 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 bRatio_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 bCFOLookBack 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 bTxQDCOffset 0xff00 +#define bTxDFIRMode 0x10000 +#define bTxPesudoNoiseOn 0x4000000 +#define bTxPesudoNoise_A 0xff +#define bTxPesudoNoise_B 0xff00 +#define bTxPesudoNoise_C 0xff0000 +#define bTxPesudoNoise_D 0xff000000 +#define bCCADropOption 0x20000 +#define bCCADropThres 0xfff00000 +#define bEDCCA_H 0xf +#define bEDCCA_L 0xf0 +#define bLambda_ED 0x300 +#define bRxInitialGain 0x7f +#define bRxAntDivEn 0x80 +#define bRxAGCAddressForLNA 0x7f00 +#define bRxHighPowerFlow 0x8000 +#define bRxAGCFreezeThres 0xc0000 +#define bRxFreezeStep_AGC1 0x300000 +#define bRxFreezeStep_AGC2 0xc00000 +#define bRxFreezeStep_AGC3 0x3000000 +#define bRxFreezeStep_AGC0 0xc000000 +#define bRxRssi_Cmp_En 0x10000000 +#define bRxQuickAGCEn 0x20000000 +#define bRxAGCFreezeThresMode 0x40000000 +#define bRxOverFlowCheckType 0x80000000 +#define bRxAGCShift 0x7f +#define bTRSW_Tri_Only 0x80 +#define bPowerThres 0x300 +#define bRxAGCEn 0x1 +#define bRxAGCTogetherEn 0x2 +#define bRxAGCMin 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 bRxProcessTime_DAGC 0x300000 +#define bRxSettle_HSSI 0x400000 +#define bRxProcessTime_BBPPW 0x800000 +#define bRxAntennaPowerShift 0x3000000 +#define bRSSITableSelect 0xc000000 +#define bRxHP_Final 0x7000000 +#define bRxHTSettle_BBP 0x7 +#define bRxHTSettle_HSSI 0x8 +#define bRxHTSettle_RxHP 0x70 +#define bRxHTSettle_BBPPW 0x80 +#define bRxHTSettle_Idle 0x300 +#define bRxHTSettle_Reserved 0x1c00 +#define bRxHTRxHPEn 0x8000 +#define bRxHTAGCFreezeThres 0x30000 +#define bRxHTAGCTogetherEn 0x40000 +#define bRxHTAGCMin 0x80000 +#define bRxHTAGCEn 0x100000 +#define bRxHTDAGCEn 0x200000 +#define bRxHTRxHP_BBP 0x1c00000 +#define bRxHTRxHP_Final 0xe0000000 +#define bRxPWRatioTH 0x3 +#define bRxPWRatioEn 0x4 +#define bRxMFHold 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_Guard_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 bMFWeightSum 0x300000 -#define bMinIdxTH 0x7f000000 +#define bMFWeightSum 0x300000 +#define bMinIdxTH 0x7f000000 -#define bDAFormat 0x40000 +#define bDAFormat 0x40000 -#define bTxChEmuEnable 0x01000000 +#define bTxChEmuEnable 0x01000000 -#define bTRSWIsolation_A 0x7f -#define bTRSWIsolation_B 0x7f00 -#define bTRSWIsolation_C 0x7f0000 -#define bTRSWIsolation_D 0x7f000000 +#define bTRSWIsolation_A 0x7f +#define bTRSWIsolation_B 0x7f00 +#define bTRSWIsolation_C 0x7f0000 +#define bTRSWIsolation_D 0x7f000000 -#define bExtLNAGain 0x7c00 +#define bExtLNAGain 0x7c00 -#define bSTBCEn 0x4 -#define bAntennaMapping 0x10 -#define bNss 0x20 -#define bCFOAntSumD 0x200 -#define bPHYCounterReset 0x8000000 -#define bCFOReportGet 0x4000000 -#define bOFDMContinueTx 0x10000000 -#define bOFDMSingleCarrier 0x20000000 -#define bOFDMSingleTone 0x40000000 -#define bHTDetect 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 bShortCFOTLength 12 -#define bShortCFOFLength 11 -#define bLongCFO 0x7ff -#define bLongCFOTLength 11 -#define bLongCFOFLength 11 -#define bTailCFO 0x1fff -#define bTailCFOTLength 13 -#define bTailCFOFLength 12 +#define bSTBCEn 0x4 +#define bAntennaMapping 0x10 +#define bNss 0x20 +#define bCFOAntSumD 0x200 +#define bPHYCounterReset 0x8000000 +#define bCFOReportGet 0x4000000 +#define bOFDMContinueTx 0x10000000 +#define bOFDMSingleCarrier 0x20000000 +#define bOFDMSingleTone 0x40000000 +#define bHTDetect 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 bShortCFOTLength 12 +#define bShortCFOFLength 11 +#define bLongCFO 0x7ff +#define bLongCFOTLength 11 +#define bLongCFOFLength 11 +#define bTailCFO 0x1fff +#define bTailCFOTLength 13 +#define bTailCFOFLength 12 -#define bmax_en_pwdB 0xffff -#define bCC_power_dB 0xffff0000 -#define bnoise_pwdB 0xffff -#define bPowerMeasTLength 10 -#define bPowerMeasFLength 3 -#define bRx_HT_BW 0x1 -#define bRxSC 0x6 -#define bRx_HT 0x8 +#define bmax_en_pwdB 0xffff +#define bCC_power_dB 0xffff0000 +#define bnoise_pwdB 0xffff +#define bPowerMeasTLength 10 +#define bPowerMeasFLength 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 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 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 bSNREVMTLength 8 -#define bSNREVMFLength 1 +#define bRxSNR_A 0xff +#define bRxSNR_B 0xff00 +#define bRxSNR_C 0xff0000 +#define bRxSNR_D 0xff000000 +#define bSNREVMTLength 8 +#define bSNREVMFLength 1 -#define bCSI1st 0xff -#define bCSI2nd 0xff00 -#define bRxEVM1st 0xff0000 -#define bRxEVM2nd 0xff000000 +#define bCSI1st 0xff +#define bCSI2nd 0xff00 +#define bRxEVM1st 0xff0000 +#define bRxEVM2nd 0xff000000 -#define bSIGEVM 0xff -#define bPWDB 0xff00 -#define bSGIEN 0x10000 +#define bSIGEVM 0xff +#define bPWDB 0xff00 +#define bSGIEN 0x10000 -#define bSFactorQAM1 0xf -#define bSFactorQAM2 0xf0 -#define bSFactorQAM3 0xf00 -#define bSFactorQAM4 0xf000 -#define bSFactorQAM5 0xf0000 -#define bSFactorQAM6 0xf0000 -#define bSFactorQAM7 0xf00000 -#define bSFactorQAM8 0xf000000 -#define bSFactorQAM9 0xf0000000 -#define bCSIScheme 0x100000 +#define bSFactorQAM1 0xf +#define bSFactorQAM2 0xf0 +#define bSFactorQAM3 0xf00 +#define bSFactorQAM4 0xf000 +#define bSFactorQAM5 0xf0000 +#define bSFactorQAM6 0xf0000 +#define bSFactorQAM7 0xf00000 +#define bSFactorQAM8 0xf000000 +#define bSFactorQAM9 0xf0000000 +#define bCSIScheme 0x100000 -#define bNoiseLvlTopSet 0x3 -#define bChSmooth 0x4 -#define bChSmoothCfg1 0x38 -#define bChSmoothCfg2 0x1c0 -#define bChSmoothCfg3 0xe00 -#define bChSmoothCfg4 0x7000 -#define bMRCMode 0x800000 -#define bTHEVMCfg 0x7000000 +#define bNoiseLvlTopSet 0x3 +#define bChSmooth 0x4 +#define bChSmoothCfg1 0x38 +#define bChSmoothCfg2 0x1c0 +#define bChSmoothCfg3 0xe00 +#define bChSmoothCfg4 0x7000 +#define bMRCMode 0x800000 +#define bTHEVMCfg 0x7000000 -#define bLoopFitType 0x1 -#define bUpdCFO 0x40 -#define bUpdCFOOffData 0x80 -#define bAdvUpdCFO 0x100 -#define bAdvTimeCtrl 0x800 -#define bUpdClko 0x1000 -#define bFC 0x6000 -#define bTrackingMode 0x8000 -#define bPhCmpEnable 0x10000 -#define bUpdClkoLTF 0x20000 -#define bComChCFO 0x40000 -#define bCSIEstiMode 0x80000 -#define bAdvUpdEqz 0x100000 -#define bUChCfg 0x7000000 -#define bUpdEqz 0x8000000 +#define bLoopFitType 0x1 +#define bUpdCFO 0x40 +#define bUpdCFOOffData 0x80 +#define bAdvUpdCFO 0x100 +#define bAdvTimeCtrl 0x800 +#define bUpdClko 0x1000 +#define bFC 0x6000 +#define bTrackingMode 0x8000 +#define bPhCmpEnable 0x10000 +#define bUpdClkoLTF 0x20000 +#define bComChCFO 0x40000 +#define bCSIEstiMode 0x80000 +#define bAdvUpdEqz 0x100000 +#define bUChCfg 0x7000000 +#define bUpdEqz 0x8000000 -#define bTxAGCRate18_06 0x7f7f7f7f -#define bTxAGCRate54_24 0x7f7f7f7f +#define bTxAGCRate18_06 0x7f7f7f7f +#define bTxAGCRate54_24 0x7f7f7f7f #define bTxAGCRateMCS32 0x7f -#define bTxAGCRateCCK 0x7f00 +#define bTxAGCRateCCK 0x7f00 #define bTxAGCRateMCS3_MCS0 0x7f7f7f7f #define bTxAGCRateMCS7_MCS4 0x7f7f7f7f #define bTxAGCRateMCS11_MCS8 0x7f7f7f7f #define bTxAGCRateMCS15_MCS12 0x7f7f7f7f -#define bRxPesudoNoiseOn 0x20000000 -#define bRxPesudoNoise_A 0xff -#define bRxPesudoNoise_B 0xff00 -#define bRxPesudoNoise_C 0xff0000 -#define bRxPesudoNoise_D 0xff000000 -#define bPesudoNoiseState_A 0xffff -#define bPesudoNoiseState_B 0xffff0000 -#define bPesudoNoiseState_C 0xffff -#define bPesudoNoiseState_D 0xffff0000 +#define bRxPesudoNoiseOn 0x20000000 +#define bRxPesudoNoise_A 0xff +#define bRxPesudoNoise_B 0xff00 +#define bRxPesudoNoise_C 0xff0000 +#define bRxPesudoNoise_D 0xff000000 +#define bPesudoNoiseState_A 0xffff +#define bPesudoNoiseState_B 0xffff0000 +#define bPesudoNoiseState_C 0xffff +#define bPesudoNoiseState_D 0xffff0000 -#define bZebra1_HSSIEnable 0x8 -#define bZebra1_TRxControl 0xc00 -#define bZebra1_TRxGainSetting 0x07f -#define bZebra1_RxCorner 0xc00 -#define bZebra1_TxChargePump 0x38 -#define bZebra1_RxChargePump 0x7 -#define bZebra1_ChannelNum 0xf80 -#define bZebra1_TxLPFBW 0x400 -#define bZebra1_RxLPFBW 0x600 +#define bZebra1_HSSIEnable 0x8 +#define bZebra1_TRxControl 0xc00 +#define bZebra1_TRxGainSetting 0x07f +#define bZebra1_RxCorner 0xc00 +#define bZebra1_TxChargePump 0x38 +#define bZebra1_RxChargePump 0x7 +#define bZebra1_ChannelNum 0xf80 +#define bZebra1_TxLPFBW 0x400 +#define bZebra1_RxLPFBW 0x600 -#define bRTL8256RegModeCtrl1 0x100 -#define bRTL8256RegModeCtrl0 0x40 -#define bRTL8256_TxLPFBW 0x18 -#define bRTL8256_RxLPFBW 0x600 +#define bRTL8256RegModeCtrl1 0x100 +#define bRTL8256RegModeCtrl0 0x40 +#define bRTL8256_TxLPFBW 0x18 +#define bRTL8256_RxLPFBW 0x600 -#define bRTL8258_TxLPFBW 0xc -#define bRTL8258_RxLPFBW 0xc00 -#define bRTL8258_RSSILPFBW 0xc0 +#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 bDWord 0xf +#define bByte0 0x1 +#define bByte1 0x2 +#define bByte2 0x4 +#define bByte3 0x8 +#define bWord0 0x3 +#define bWord1 0xc +#define bDWord 0xf -#define bMaskByte0 0xff -#define bMaskByte1 0xff00 -#define bMaskByte2 0xff0000 -#define bMaskByte3 0xff000000 -#define bMaskHWord 0xffff0000 -#define bMaskLWord 0x0000ffff -#define bMaskDWord 0xffffffff +#define bMaskByte0 0xff +#define bMaskByte1 0xff00 +#define bMaskByte2 0xff0000 +#define bMaskByte3 0xff000000 +#define bMaskHWord 0xffff0000 +#define bMaskLWord 0x0000ffff +#define bMaskDWord 0xffffffff -#define bMask12Bits 0xfff +#define bMask12Bits 0xfff -#define bEnable 0x1 -#define bDisable 0x0 +#define bEnable 0x1 +#define bDisable 0x0 -#define LeftAntenna 0x0 -#define RightAntenna 0x1 +#define LeftAntenna 0x0 +#define RightAntenna 0x1 -#define tCheckTxStatus 500 -#define tUpdateRxCounter 100 +#define tCheckTxStatus 500 +#define tUpdateRxCounter 100 -#define rateCCK 0 -#define rateOFDM 1 -#define rateHT 2 +#define rateCCK 0 +#define rateOFDM 1 +#define rateHT 2 -#define bPMAC_End 0x1ff -#define bFPGAPHY0_End 0x8ff -#define bFPGAPHY1_End 0x9ff -#define bCCKPHY0_End 0xaff -#define bOFDMPHY0_End 0xcff -#define bOFDMPHY1_End 0xdff +#define bPMAC_End 0x1ff +#define bFPGAPHY0_End 0x8ff +#define bFPGAPHY1_End 0x9ff +#define bCCKPHY0_End 0xaff +#define bOFDMPHY0_End 0xcff +#define bOFDMPHY1_End 0xdff -#define bPMACControl 0x0 -#define bWMACControl 0x1 -#define bWNICControl 0x2 +#define bPMACControl 0x0 +#define bWMACControl 0x1 +#define bWNICControl 0x2 -#define PathA 0x0 -#define PathB 0x1 -#define PathC 0x2 -#define PathD 0x3 +#define PathA 0x0 +#define PathB 0x1 +#define PathC 0x2 +#define PathD 0x3 -#define rRTL8256RxMixerPole 0xb -#define bZebraRxMixerPole 0x6 -#define rRTL8256TxBBOPBias 0x9 -#define bRTL8256TxBBOPBias 0x400 -#define rRTL8256TxBBBW 19 -#define bRTL8256TxBBBW 0x18 +#define rRTL8256RxMixerPole 0xb +#define bZebraRxMixerPole 0x6 +#define rRTL8256TxBBOPBias 0x9 +#define bRTL8256TxBBOPBias 0x400 +#define rRTL8256TxBBBW 19 +#define bRTL8256TxBBBW 0x18 #endif From 27a3071c6dc3e348fad445205e21d0b5d6b7a4e5 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 13 Apr 2015 23:47:25 +0200 Subject: [PATCH 0166/1163] staging: rtl8192e: Copy comments from r819XE_phyreg.h to r8192E_phyreg.h Both files have the same contents (with the exception of comments). One of them will not survive future commits. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192e/rtl8192e/r8192E_phyreg.h | 92 +++++++++++++------ 1 file changed, 65 insertions(+), 27 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h b/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h index d080876a1e30..8a1d91e05da9 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h @@ -53,10 +53,10 @@ #define MCS_TXAGC 0x340 #define CCK_TXAGC 0x348 -/*---------------------0x400~0x4ff----------------------*/ +/* Mac block on/off control register */ #define MacBlkCtrl 0x403 -#define rFPGA0_RFMOD 0x800 +#define rFPGA0_RFMOD 0x800 /* RF mode & CCK TxSC */ #define rFPGA0_TxInfo 0x804 #define rFPGA0_PSDFunction 0x808 #define rFPGA0_TxGainStage 0x80c @@ -98,6 +98,7 @@ #define rFPGA0_XAB_RFInterfaceRB 0x8e0 #define rFPGA0_XCD_RFInterfaceRB 0x8e4 +/* Page 9 - RF mode & OFDM TxSC */ #define rFPGA1_RFMOD 0x900 #define rFPGA1_TxBlock 0x904 #define rFPGA1_DebugSelect 0x908 @@ -106,14 +107,16 @@ #define rCCK0_System 0xa00 #define rCCK0_AFESetting 0xa04 #define rCCK0_CCA 0xa08 +/* AGC default value, saturation level */ #define rCCK0_RxAGC1 0xa0c -#define rCCK0_RxAGC2 0xa10 +#define rCCK0_RxAGC2 0xa10 /* AGC & DAGC */ #define rCCK0_RxHP 0xa14 +/* Timing recovery & channel estimation threshold */ #define rCCK0_DSPParameter1 0xa18 -#define rCCK0_DSPParameter2 0xa1c +#define rCCK0_DSPParameter2 0xa1c /* SQ threshold */ #define rCCK0_TxFilter1 0xa20 #define rCCK0_TxFilter2 0xa24 -#define rCCK0_DebugPort 0xa28 +#define rCCK0_DebugPort 0xa28 /* Debug port and TX filter 3 */ #define rCCK0_FalseAlarmReport 0xa2c #define rCCK0_TRSSIReport 0xa50 #define rCCK0_RxReport 0xa54 @@ -124,22 +127,24 @@ #define rOFDM0_TRxPathEnable 0xc04 #define rOFDM0_TRMuxPar 0xc08 #define rOFDM0_TRSWIsolation 0xc0c +/* RxIQ DC offset, Rx digital filter, DC notch filter */ #define rOFDM0_XARxAFE 0xc10 -#define rOFDM0_XARxIQImbalance 0xc14 +#define rOFDM0_XARxIQImbalance 0xc14 /* RxIQ imbalance matrix */ #define rOFDM0_XBRxAFE 0xc18 #define rOFDM0_XBRxIQImbalance 0xc1c #define rOFDM0_XCRxAFE 0xc20 #define rOFDM0_XCRxIQImbalance 0xc24 #define rOFDM0_XDRxAFE 0xc28 #define rOFDM0_XDRxIQImbalance 0xc2c -#define rOFDM0_RxDetector1 0xc30 -#define rOFDM0_RxDetector2 0xc34 -#define rOFDM0_RxDetector3 0xc38 +#define rOFDM0_RxDetector1 0xc30 /* PD, BW & SBD */ +#define rOFDM0_RxDetector2 0xc34 /* SBD */ +#define rOFDM0_RxDetector3 0xc38 /* Frame Sync */ +/* PD, SBD, Frame Sync & Short-GI */ #define rOFDM0_RxDetector4 0xc3c -#define rOFDM0_RxDSP 0xc40 -#define rOFDM0_CFOandDAGC 0xc44 +#define rOFDM0_RxDSP 0xc40 /* Rx Sync Path */ +#define rOFDM0_CFOandDAGC 0xc44 /* CFO & DAGC */ #define rOFDM0_CCADropThreshold 0xc48 -#define rOFDM0_ECCAThreshold 0xc4c +#define rOFDM0_ECCAThreshold 0xc4c /* Energy CCA */ #define rOFDM0_XAAGCCore1 0xc50 #define rOFDM0_XAAGCCore2 0xc54 #define rOFDM0_XBAGCCore1 0xc58 @@ -184,9 +189,9 @@ #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_PHYCounter1 0xda0 /* cca, parity fail */ +#define rOFDM_PHYCounter2 0xda4 /* rate illegal, crc8 fail */ +#define rOFDM_PHYCounter3 0xda8 /* MCS not supported */ #define rOFDM_ShortCFOAB 0xdac #define rOFDM_ShortCFOCD 0xdb0 #define rOFDM_LongCFOAB 0xdb4 @@ -221,14 +226,17 @@ #define rZebra1_RxLPF 0xb #define rZebra1_RxHPFCorner 0xc +/* Zebra 4 */ #define rGlobalCtrl 0 #define rRTL8256_TxLPF 19 #define rRTL8256_RxLPF 11 +/* RTL8258 */ #define rRTL8258_TxLPF 0x11 #define rRTL8258_RxLPF 0x13 #define rRTL8258_RSSILPF 0xa +/* Bit Mask - Page 1*/ #define bBBResetB 0x100 #define bGlobalResetB 0x200 #define bOFDMTxStart 0x4 @@ -273,7 +281,7 @@ #define bCCKTxCRC16 0xffff #define bCCKTxStatus 0x1 #define bOFDMTxStatus 0x2 - +/* Bit Mask - Page 8 */ #define bRFMOD 0x1 #define bJapanMode 0x2 #define bCCKTxSC 0x30 @@ -290,13 +298,16 @@ #define bRFStart 0x0000f000 #define bBBStart 0x000000f0 #define bBBCCKStart 0x0000000f +/* Bit Mask - rFPGA0_RFTiming2 */ #define bPAEnd 0xf #define bTREnd 0x0f000000 #define bRFEnd 0x000f0000 +/* T2R */ #define bCCAMask 0x000000f0 #define bR2RCCAMask 0x00000f00 #define bHSSI_R2TDelay 0xf8000000 #define bHSSI_T2RDelay 0xf80000 +/* Channel gain at continue TX. */ #define bContTxHSSI 0x400 #define bIGFromCCK 0x200 #define bAGCAddress 0x3f @@ -308,6 +319,7 @@ #define b3WireDataLength 0x800 #define b3WireAddressLength 0x400 #define b3WireRFPowerDown 0x1 +/*#define bHWSISelect 0x8 */ #define b5GPAPEPolarity 0x40000000 #define b2GPAPEPolarity 0x80000000 #define bRFSW_TxDefaultAnt 0x3 @@ -318,6 +330,7 @@ #define bRFSI_3WireClock 0x2 #define bRFSI_3WireLoad 0x4 #define bRFSI_3WireRW 0x8 +/* 3-wire total control */ #define bRFSI_3Wire 0xf #define bRFSI_RFENV 0x10 #define bRFSI_TRSW 0x20 @@ -343,11 +356,11 @@ #define bLSIG_Length 0x1fffe #define bLSIG_Parity 0x20 #define bCCKRxPhase 0x4 -#define bLSSIReadAddress 0x3f000000 -#define bLSSIReadEdge 0x80000000 +#define bLSSIReadAddress 0x3f000000 /* LSSI "read" address */ +#define bLSSIReadEdge 0x80000000 /* LSSI "read" edge signal */ #define bLSSIReadBackData 0xfff #define bLSSIReadOKFlag 0x1000 -#define bCCKSampleRate 0x8 +#define bCCKSampleRate 0x8 /* 0: 44 MHz, 1: 88MHz */ #define bRegulator0Standby 0x1 #define bRegulatorPLLStandby 0x2 @@ -404,10 +417,13 @@ #define bPSDSineToneScale 0x7f000000 #define bPSDReport 0xffff +/* Page 8 */ #define bOFDMTxSC 0x30000000 #define bCCKTxOn 0x1 #define bOFDMTxOn 0x2 +/* Reset debug page and also HWord, LWord */ #define bDebugPage 0xfff +/* Reset debug page and LWord */ #define bDebugItem 0xff #define bAntL 0x10 #define bAntNonHT 0x100 @@ -416,6 +432,7 @@ #define bAntHT1S1 0x100000 #define bAntNonHTS1 0x1000000 +/* Page a */ #define bCCKBBMode 0x3 #define bCCKTxPowerSaving 0x80 #define bCCKRxPowerSaving 0x40 @@ -436,7 +453,7 @@ #define bCCKBistMode 0x80000000 #define bCCKCCAMask 0x40000000 #define bCCKTxDACPhase 0x4 -#define bCCKRxADCPhase 0x20000000 +#define bCCKRxADCPhase 0x20000000 /* r_rx_clk */ #define bCCKr_cp_mode0 0x0100 #define bCCKTxDCOffset 0xf0 #define bCCKRxDCOffset 0xf @@ -450,11 +467,14 @@ #define bCCKRxIG 0x7f00 #define bCCKLNAPolarity 0x800000 #define bCCKRx1stGain 0x7f0000 +/* CCK Rx Initial gain polarity */ #define bCCKRFExtend 0x20000000 #define bCCKRxAGCSatLevel 0x1f000000 #define bCCKRxAGCSatCount 0xe0 +/* AGCSAmp_dly */ #define bCCKRxRFSettle 0x1f #define bCCKFixedRxAGC 0x8000 +/*#define bCCKRxAGCFormat 0x4000 remove to HSSI register 0x824 */ #define bCCKAntennaPolarity 0x2000 #define bCCKTxFilterType 0x0c00 #define bCCKRxAGCReportType 0x0300 @@ -495,6 +515,7 @@ #define bCCKDefaultRxPath 0xc000000 #define bCCKOptionRxPath 0x3000000 +/* Page c */ #define bNumOfSTF 0x3 #define bShift_L 0xc0 #define bGI_TH 0xc @@ -596,7 +617,9 @@ #define bRxHP_BBP1 0x7000 #define bRxHP_BBP2 0x70000 #define bRxHP_BBP3 0x700000 +/* The threshold for high power */ #define bRSSI_H 0x7f0000 +/* The threshold for ant diversity */ #define bRSSI_Gen 0x7f000000 #define bRxSettle_TRSW 0x7 #define bRxSettle_LNA 0x38 @@ -631,6 +654,7 @@ #define bRxPD_Delay_TH1 0x38 #define bRxPD_Delay_TH2 0x1c0 #define bRxPD_DC_COUNT_MAX 0x600 +/*#define bRxMF_Hold 0x3800*/ #define bRxPD_Delay_TH 0x8000 #define bRxProcess_Delay 0xf0000 #define bRxSearchrange_GI2_Early 0x700000 @@ -656,6 +680,7 @@ #define bExtLNAGain 0x7c00 +/* Page d */ #define bSTBCEn 0x4 #define bAntennaMapping 0x10 #define bNss 0x20 @@ -665,6 +690,13 @@ #define bOFDMContinueTx 0x10000000 #define bOFDMSingleCarrier 0x20000000 #define bOFDMSingleTone 0x40000000 +/* #define bRxPath1 0x01 + * #define bRxPath2 0x02 + * #define bRxPath3 0x04 + * #define bRxPath4 0x08 + * #define bTxPath1 0x10 + * #define bTxPath2 0x20 +*/ #define bHTDetect 0x100 #define bCFOEn 0x10000 #define bCFOValue 0xfff00000 @@ -677,8 +709,8 @@ #define bCounter_MCSNoSupport 0xffff #define bCounter_FastSync 0xffff #define bShortCFO 0xfff -#define bShortCFOTLength 12 -#define bShortCFOFLength 11 +#define bShortCFOTLength 12 /* total */ +#define bShortCFOFLength 11 /* fraction */ #define bLongCFO 0x7ff #define bLongCFOTLength 11 #define bLongCFOFLength 11 @@ -755,6 +787,7 @@ #define bUChCfg 0x7000000 #define bUpdEqz 0x8000000 +/* Page e */ #define bTxAGCRate18_06 0x7f7f7f7f #define bTxAGCRate54_24 0x7f7f7f7f #define bTxAGCRateMCS32 0x7f @@ -764,8 +797,7 @@ #define bTxAGCRateMCS11_MCS8 0x7f7f7f7f #define bTxAGCRateMCS15_MCS12 0x7f7f7f7f - -#define bRxPesudoNoiseOn 0x20000000 +#define bRxPesudoNoiseOn 0x20000000 /* Rx Pseduo noise */ #define bRxPesudoNoise_A 0xff #define bRxPesudoNoise_B 0xff00 #define bRxPesudoNoise_C 0xff0000 @@ -775,6 +807,7 @@ #define bPesudoNoiseState_C 0xffff #define bPesudoNoiseState_D 0xffff0000 +/* RF Zebra 1 */ #define bZebra1_HSSIEnable 0x8 #define bZebra1_TRxControl 0xc00 #define bZebra1_TRxGainSetting 0x07f @@ -785,15 +818,18 @@ #define bZebra1_TxLPFBW 0x400 #define bZebra1_RxLPFBW 0x600 +/* Zebra4 */ #define bRTL8256RegModeCtrl1 0x100 #define bRTL8256RegModeCtrl0 0x40 #define bRTL8256_TxLPFBW 0x18 #define bRTL8256_RxLPFBW 0x600 +/* RTL8258 */ #define bRTL8258_TxLPFBW 0xc #define bRTL8258_RxLPFBW 0xc00 #define bRTL8258_RSSILPFBW 0xc0 +/* byte enable for sb_write */ #define bByte0 0x1 #define bByte1 0x2 #define bByte2 0x4 @@ -802,6 +838,7 @@ #define bWord1 0xc #define bDWord 0xf +/* for PutRegsetting & GetRegSetting BitMask */ #define bMaskByte0 0xff #define bMaskByte1 0xff00 #define bMaskByte2 0xff0000 @@ -810,6 +847,7 @@ #define bMaskLWord 0x0000ffff #define bMaskDWord 0xffffffff +/* for PutRFRegsetting & GetRFRegSetting BitMask */ #define bMask12Bits 0xfff #define bEnable 0x1 @@ -818,14 +856,14 @@ #define LeftAntenna 0x0 #define RightAntenna 0x1 -#define tCheckTxStatus 500 -#define tUpdateRxCounter 100 +#define tCheckTxStatus 500 /* 500 ms */ +#define tUpdateRxCounter 100 /* 100 ms */ #define rateCCK 0 #define rateOFDM 1 #define rateHT 2 -#define bPMAC_End 0x1ff +#define bPMAC_End 0x1ff /* define Register-End */ #define bFPGAPHY0_End 0x8ff #define bFPGAPHY1_End 0x9ff #define bCCKPHY0_End 0xaff From aedd45dfd2385dfcaceecdb1037b3a7a20874fe5 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 13 Apr 2015 23:47:26 +0200 Subject: [PATCH 0167/1163] staging: rtl8192e: remove r819xE_phyreg.h This file is not used and its contents are duplicated in r8192E_phyreg.h. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192e/rtl8192e/r819xE_phyreg.h | 908 ------------------ 1 file changed, 908 deletions(-) delete mode 100644 drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h diff --git a/drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h b/drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h deleted file mode 100644 index 03eee3d059c6..000000000000 --- a/drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h +++ /dev/null @@ -1,908 +0,0 @@ -#ifndef _R819XU_PHYREG_H -#define _R819XU_PHYREG_H - - -#define RF_DATA 0x1d4 // FW will write RF data in the register. - -//Register //duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF -//page 1 -#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_TxDataType 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 - -//90P -#define MCS_TXAGC 0x340 // MCS AGC -#define CCK_TXAGC 0x348 // CCK AGC - -#define MacBlkCtrl 0x403 // Mac block on/off control register - -//page8 -#define rFPGA0_RFMOD 0x800 //RF mode & CCK TxSC -#define rFPGA0_TxInfo 0x804 -#define rFPGA0_PSDFunction 0x808 -#define rFPGA0_TxGainStage 0x80c -#define rFPGA0_RFTiming1 0x810 -#define rFPGA0_RFTiming2 0x814 -//#define rFPGA0_XC_RFTiming 0x818 -//#define rFPGA0_XD_RFTiming 0x81c -#define rFPGA0_XA_HSSIParameter1 0x820 -#define rFPGA0_XA_HSSIParameter2 0x824 -#define rFPGA0_XB_HSSIParameter1 0x828 -#define rFPGA0_XB_HSSIParameter2 0x82c -#define rFPGA0_XC_HSSIParameter1 0x830 -#define rFPGA0_XC_HSSIParameter2 0x834 -#define rFPGA0_XD_HSSIParameter1 0x838 -#define rFPGA0_XD_HSSIParameter2 0x83c -#define rFPGA0_XA_LSSIParameter 0x840 -#define rFPGA0_XB_LSSIParameter 0x844 -#define rFPGA0_XC_LSSIParameter 0x848 -#define rFPGA0_XD_LSSIParameter 0x84c -#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_XC_RFInterfaceOE 0x868 -#define rFPGA0_XD_RFInterfaceOE 0x86c -#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 rFPGA0_XAB_RFInterfaceRB 0x8e0 -#define rFPGA0_XCD_RFInterfaceRB 0x8e4 - -/* Page 9 - RF mode & OFDM TxSC */ -#define rFPGA1_RFMOD 0x900 -#define rFPGA1_TxBlock 0x904 -#define rFPGA1_DebugSelect 0x908 -#define rFPGA1_TxInfo 0x90c - -/* Page a */ -#define rCCK0_System 0xa00 -#define rCCK0_AFESetting 0xa04 -#define rCCK0_CCA 0xa08 -/* AGC default value, saturation level */ -#define rCCK0_RxAGC1 0xa0c -/* AGC & DAGC */ -#define rCCK0_RxAGC2 0xa10 -#define rCCK0_RxHP 0xa14 -/* Timing recovery & channel estimation threshold */ -#define rCCK0_DSPParameter1 0xa18 -/* SQ threshold */ -#define rCCK0_DSPParameter2 0xa1c -#define rCCK0_TxFilter1 0xa20 -#define rCCK0_TxFilter2 0xa24 -/* Debug port and TX filter 3 */ -#define rCCK0_DebugPort 0xa28 -#define rCCK0_FalseAlarmReport 0xa2c -#define rCCK0_TRSSIReport 0xa50 -#define rCCK0_RxReport 0xa54 -#define rCCK0_FACounterLower 0xa5c -#define rCCK0_FACounterUpper 0xa58 - -/* Page c */ -#define rOFDM0_LSTF 0xc00 -#define rOFDM0_TRxPathEnable 0xc04 -#define rOFDM0_TRMuxPar 0xc08 -#define rOFDM0_TRSWIsolation 0xc0c -/* RxIQ DC offset, Rx digital filter, DC notch filter */ -#define rOFDM0_XARxAFE 0xc10 -/* RxIQ imblance matrix */ -#define rOFDM0_XARxIQImbalance 0xc14 -#define rOFDM0_XBRxAFE 0xc18 -#define rOFDM0_XBRxIQImbalance 0xc1c -#define rOFDM0_XCRxAFE 0xc20 -#define rOFDM0_XCRxIQImbalance 0xc24 -#define rOFDM0_XDRxAFE 0xc28 -#define rOFDM0_XDRxIQImbalance 0xc2c -/* PD, BW & SBD */ -#define rOFDM0_RxDetector1 0xc30 -/* SBD */ -#define rOFDM0_RxDetector2 0xc34 -/* Frame Sync */ -#define rOFDM0_RxDetector3 0xc38 -/* PD, SBD, Frame Sync & Short-GI */ -#define rOFDM0_RxDetector4 0xc3c -/* Rx Sync Path */ -#define rOFDM0_RxDSP 0xc40 -/* CFO & DAGC */ -#define rOFDM0_CFOandDAGC 0xc44 -/* CCA Drop threshold */ -#define rOFDM0_CCADropThreshold 0xc48 -/* Energy CCA */ -#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_RxHPParameter 0xce0 -#define rOFDM0_TxPseudoNoiseWgt 0xce4 -#define rOFDM0_FrameSync 0xcf0 -#define rOFDM0_DFSReport 0xcf4 -#define rOFDM0_TxCoeff1 0xca4 -#define rOFDM0_TxCoeff2 0xca8 -#define rOFDM0_TxCoeff3 0xcac -#define rOFDM0_TxCoeff4 0xcb0 -#define rOFDM0_TxCoeff5 0xcb4 -#define rOFDM0_TxCoeff6 0xcb8 - - -/* Page d */ -#define rOFDM1_LSTF 0xd00 -#define rOFDM1_TRxPathEnable 0xd04 -#define rOFDM1_CFO 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 -/* cca, parity fail */ -#define rOFDM_PHYCounter1 0xda0 -/* rate illegal, crc8 fail */ -#define rOFDM_PHYCounter2 0xda4 -/* MCS not supported */ -#define rOFDM_PHYCounter3 0xda8 -#define rOFDM_ShortCFOAB 0xdac -#define rOFDM_ShortCFOCD 0xdb0 -#define rOFDM_LongCFOAB 0xdb4 -#define rOFDM_LongCFOCD 0xdb8 -#define rOFDM_TailCFOAB 0xdbc -#define rOFDM_TailCFOCD 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 - -/* Page e */ -#define rTxAGC_Rate18_06 0xe00 -#define rTxAGC_Rate54_24 0xe04 -#define rTxAGC_CCK_Mcs32 0xe08 -#define rTxAGC_Mcs03_Mcs00 0xe10 -#define rTxAGC_Mcs07_Mcs04 0xe14 -#define rTxAGC_Mcs11_Mcs08 0xe18 -#define rTxAGC_Mcs15_Mcs12 0xe1c - - -/* RF Zebra 1 */ -#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 - -/* Zebra 4 */ -#define rGlobalCtrl 0 -#define rRTL8256_TxLPF 19 -#define rRTL8256_RxLPF 11 - -/* RTL8258 */ -#define rRTL8258_TxLPF 0x11 -#define rRTL8258_RxLPF 0x13 -#define rRTL8258_RSSILPF 0xa - -/* Bit Mask */ -/* Page 1 */ -#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 bCCKTxLength 0xffff0000 -#define bCCKTxCRC16 0xffff -#define bCCKTxStatus 0x1 -#define bOFDMTxStatus 0x2 - -/* Page 8 */ -#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 -/* Reg x814 */ -#define bPAEnd 0xf -#define bTREnd 0x0f000000 -#define bRFEnd 0x000f0000 -/* T2R */ -#define bCCAMask 0x000000f0 -#define bR2RCCAMask 0x00000f00 -#define bHSSI_R2TDelay 0xf8000000 -#define bHSSI_T2RDelay 0xf80000 -/* Channel gain at continue TX. */ -#define bContTxHSSI 0x400 -#define bIGFromCCK 0x200 -#define bAGCAddress 0x3f -#define bRxHPTx 0x7000 -#define bRxHPT2R 0x38000 -#define bRxHPCCKIni 0xc0000 -#define bAGCTxCode 0xc00000 -#define bAGCRxCode 0x300000 -#define b3WireDataLength 0x800 -#define b3WireAddressLength 0x400 -#define b3WireRFPowerDown 0x1 -/*#define bHWSISelect 0x8 */ -#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 -/* 3-wire total control */ -#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 -/* LSSI "read" address */ -#define bLSSIReadAddress 0x3f000000 -/* LSSI "read" edge signal */ -#define bLSSIReadEdge 0x80000000 -#define bLSSIReadBackData 0xfff -#define bLSSIReadOKFlag 0x1000 -/* 0: 44 MHz, 1: 88MHz */ -#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 bXtalCap 0x0f000000 -#define bXtalCap01 0xc0000000 -#define bXtalCap23 0x3 -#define bXtalCap92x 0x0f000000 -#define bIntDifClkEnable 0x400 -#define bExtSigClkEnable 0x800 -#define bBandgapMbiasPowerUp 0x10000 -#define bAD11SHGain 0xc0000 -#define bAD11InputRange 0x700000 -#define bAD11OPCurrent 0x3800000 -#define bIPathLoopback 0x4000000 -#define bQPathLoopback 0x8000000 -#define bAFELoopback 0x10000000 -#define bDA10Swing 0x7e0 -#define bDA10Reverse 0x800 -#define bDAClkSource 0x1000 -#define bAD7InputRange 0x6000 -#define bAD7Gain 0x38000 -#define bAD7OutputCMMode 0x40000 -#define bAD7InputCMMode 0x380000 -#define bAD7Current 0xc00000 -#define bRegulatorAdjust 0x7000000 -#define bAD11PowerUpAtTx 0x1 -#define bDA10PSAtTx 0x10 -#define bAD11PowerUpAtRx 0x100 -#define bDA10PSAtRx 0x1000 - -#define bCCKRxAGCFormat 0x200 - -#define bPSDFFTSamplepPoint 0xc000 -#define bPSDAverageNum 0x3000 -#define bIQPathControl 0xc00 -#define bPSDFreq 0x3ff -#define bPSDAntennaPath 0x30 -#define bPSDIQSwitch 0x40 -#define bPSDRxTrigger 0x400000 -#define bPSDTxTrigger 0x80000000 -#define bPSDSineToneScale 0x7f000000 -#define bPSDReport 0xffff - -/* Page 8 */ -#define bOFDMTxSC 0x30000000 -#define bCCKTxOn 0x1 -#define bOFDMTxOn 0x2 -/* Reset debug page and also HWord, LWord */ -#define bDebugPage 0xfff -/* Reset debug page and LWord */ -#define bDebugItem 0xff -#define bAntL 0x10 -#define bAntNonHT 0x100 -#define bAntHT1 0x1000 -#define bAntHT2 0x10000 -#define bAntHT1S1 0x100000 -#define bAntNonHTS1 0x1000000 - -/* Page a */ -#define bCCKBBMode 0x3 -#define bCCKTxPowerSaving 0x80 -#define bCCKRxPowerSaving 0x40 -#define bCCKSideBand 0x10 -#define bCCKScramble 0x8 -#define bCCKAntDiversity 0x8000 -#define bCCKCarrierRecovery 0x4000 -#define bCCKTxRate 0x3000 -#define bCCKDCCancel 0x0800 -#define bCCKISICancel 0x0400 -#define bCCKMatchFilter 0x0200 -#define bCCKEqualizer 0x0100 -#define bCCKPreambleDetect 0x800000 -#define bCCKFastFalseCCA 0x400000 -#define bCCKChEstStart 0x300000 -#define bCCKCCACount 0x080000 -#define bCCKcs_lim 0x070000 -#define bCCKBistMode 0x80000000 -#define bCCKCCAMask 0x40000000 -#define bCCKTxDACPhase 0x4 -/* r_rx_clk */ -#define bCCKRxADCPhase 0x20000000 -#define bCCKr_cp_mode0 0x0100 -#define bCCKTxDCOffset 0xf0 -#define bCCKRxDCOffset 0xf -#define bCCKCCAMode 0xc000 -#define bCCKFalseCS_lim 0x3f00 -#define bCCKCS_ratio 0xc00000 -#define bCCKCorgBit_sel 0x300000 -#define bCCKPD_lim 0x0f0000 -#define bCCKNewCCA 0x80000000 -#define bCCKRxHPofIG 0x8000 -#define bCCKRxIG 0x7f00 -#define bCCKLNAPolarity 0x800000 -#define bCCKRx1stGain 0x7f0000 -/* CCK Rx Initial gain polarity */ -#define bCCKRFExtend 0x20000000 -#define bCCKRxAGCSatLevel 0x1f000000 -#define bCCKRxAGCSatCount 0xe0 -/* AGCSAmp_dly */ -#define bCCKRxRFSettle 0x1f -#define bCCKFixedRxAGC 0x8000 -/*#define bCCKRxAGCFormat 0x4000 remove to HSSI register 0x824 */ -#define bCCKAntennaPolarity 0x2000 -#define bCCKTxFilterType 0x0c00 -#define bCCKRxAGCReportType 0x0300 -#define bCCKRxDAGCEn 0x80000000 -#define bCCKRxDAGCPeriod 0x20000000 -#define bCCKRxDAGCSatLevel 0x1f000000 -#define bCCKTimingRecovery 0x800000 -#define bCCKTxC0 0x3f0000 -#define bCCKTxC1 0x3f000000 -#define bCCKTxC2 0x3f -#define bCCKTxC3 0x3f00 -#define bCCKTxC4 0x3f0000 -#define bCCKTxC5 0x3f000000 -#define bCCKTxC6 0x3f -#define bCCKTxC7 0x3f00 -#define bCCKDebugPort 0xff0000 -#define bCCKDACDebug 0x0f000000 -#define bCCKFalseAlarmEnable 0x8000 -#define bCCKFalseAlarmRead 0x4000 -#define bCCKTRSSI 0x7f -#define bCCKRxAGCReport 0xfe -#define bCCKRxReport_AntSel 0x80000000 -#define bCCKRxReport_MFOff 0x40000000 -#define bCCKRxRxReport_SQLoss 0x20000000 -#define bCCKRxReport_Pktloss 0x10000000 -#define bCCKRxReport_Lockedbit 0x08000000 -#define bCCKRxReport_RateError 0x04000000 -#define bCCKRxReport_RxRate 0x03000000 -#define bCCKRxFACounterLower 0xff -#define bCCKRxFACounterUpper 0xff000000 -#define bCCKRxHPAGCStart 0xe000 -#define bCCKRxHPAGCFinal 0x1c00 - -#define bCCKRxFalseAlarmEnable 0x8000 -#define bCCKFACounterFreeze 0x4000 - -#define bCCKTxPathSel 0x10000000 -#define bCCKDefaultRxPath 0xc000000 -#define bCCKOptionRxPath 0x3000000 - -/* Page c */ -#define bNumOfSTF 0x3 -#define bShift_L 0xc0 -#define bGI_TH 0xc -#define bRxPathA 0x1 -#define bRxPathB 0x2 -#define bRxPathC 0x4 -#define bRxPathD 0x8 -#define bTxPathA 0x1 -#define bTxPathB 0x2 -#define bTxPathC 0x4 -#define bTxPathD 0x8 -#define bTRSSIFreq 0x200 -#define bADCBackoff 0x3000 -#define bDFIRBackoff 0xc000 -#define bTRSSILatchPhase 0x10000 -#define bRxIDCOffset 0xff -#define bRxQDCOffset 0xff00 -#define bRxDFIRMode 0x1800000 -#define bRxDCNFType 0xe000000 -#define bRXIQImb_A 0x3ff -#define bRXIQImb_B 0xfc00 -#define bRXIQImb_C 0x3f0000 -#define bRXIQImb_D 0xffc00000 -#define bDC_dc_Notch 0x60000 -#define bRxNBINotch 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 bRatio_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 bCFOLookBack 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 bTxQDCOffset 0xff00 -#define bTxDFIRMode 0x10000 -#define bTxPesudoNoiseOn 0x4000000 -#define bTxPesudoNoise_A 0xff -#define bTxPesudoNoise_B 0xff00 -#define bTxPesudoNoise_C 0xff0000 -#define bTxPesudoNoise_D 0xff000000 -#define bCCADropOption 0x20000 -#define bCCADropThres 0xfff00000 -#define bEDCCA_H 0xf -#define bEDCCA_L 0xf0 -#define bLambda_ED 0x300 -#define bRxInitialGain 0x7f -#define bRxAntDivEn 0x80 -#define bRxAGCAddressForLNA 0x7f00 -#define bRxHighPowerFlow 0x8000 -#define bRxAGCFreezeThres 0xc0000 -#define bRxFreezeStep_AGC1 0x300000 -#define bRxFreezeStep_AGC2 0xc00000 -#define bRxFreezeStep_AGC3 0x3000000 -#define bRxFreezeStep_AGC0 0xc000000 -#define bRxRssi_Cmp_En 0x10000000 -#define bRxQuickAGCEn 0x20000000 -#define bRxAGCFreezeThresMode 0x40000000 -#define bRxOverFlowCheckType 0x80000000 -#define bRxAGCShift 0x7f -#define bTRSW_Tri_Only 0x80 -#define bPowerThres 0x300 -#define bRxAGCEn 0x1 -#define bRxAGCTogetherEn 0x2 -#define bRxAGCMin 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 -/* The threshold for high power */ -#define bRSSI_H 0x7f0000 -/* The threshold for ant diversity */ -#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 bRxProcessTime_DAGC 0x300000 -#define bRxSettle_HSSI 0x400000 -#define bRxProcessTime_BBPPW 0x800000 -#define bRxAntennaPowerShift 0x3000000 -#define bRSSITableSelect 0xc000000 -#define bRxHP_Final 0x7000000 -#define bRxHTSettle_BBP 0x7 -#define bRxHTSettle_HSSI 0x8 -#define bRxHTSettle_RxHP 0x70 -#define bRxHTSettle_BBPPW 0x80 -#define bRxHTSettle_Idle 0x300 -#define bRxHTSettle_Reserved 0x1c00 -#define bRxHTRxHPEn 0x8000 -#define bRxHTAGCFreezeThres 0x30000 -#define bRxHTAGCTogetherEn 0x40000 -#define bRxHTAGCMin 0x80000 -#define bRxHTAGCEn 0x100000 -#define bRxHTDAGCEn 0x200000 -#define bRxHTRxHP_BBP 0x1c00000 -#define bRxHTRxHP_Final 0xe0000000 -#define bRxPWRatioTH 0x3 -#define bRxPWRatioEn 0x4 -#define bRxMFHold 0x3800 -#define bRxPD_Delay_TH1 0x38 -#define bRxPD_Delay_TH2 0x1c0 -#define bRxPD_DC_COUNT_MAX 0x600 -/*#define bRxMF_Hold 0x3800*/ -#define bRxPD_Delay_TH 0x8000 -#define bRxProcess_Delay 0xf0000 -#define bRxSearchrange_GI2_Early 0x700000 -#define bRxFrame_Guard_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 bMFWeightSum 0x300000 -#define bMinIdxTH 0x7f000000 - -#define bDAFormat 0x40000 - -#define bTxChEmuEnable 0x01000000 - -#define bTRSWIsolation_A 0x7f -#define bTRSWIsolation_B 0x7f00 -#define bTRSWIsolation_C 0x7f0000 -#define bTRSWIsolation_D 0x7f000000 - -#define bExtLNAGain 0x7c00 - -/* Page d */ -#define bSTBCEn 0x4 -#define bAntennaMapping 0x10 -#define bNss 0x20 -#define bCFOAntSumD 0x200 -#define bPHYCounterReset 0x8000000 -#define bCFOReportGet 0x4000000 -#define bOFDMContinueTx 0x10000000 -#define bOFDMSingleCarrier 0x20000000 -#define bOFDMSingleTone 0x40000000 -/*#define bRxPath1 0x01 -#define bRxPath2 0x02 -#define bRxPath3 0x04 -#define bRxPath4 0x08 -#define bTxPath1 0x10 -#define bTxPath2 0x20*/ -#define bHTDetect 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 -/* total */ -#define bShortCFOTLength 12 -/* fraction */ -#define bShortCFOFLength 11 -#define bLongCFO 0x7ff -#define bLongCFOTLength 11 -#define bLongCFOFLength 11 -#define bTailCFO 0x1fff -#define bTailCFOTLength 13 -#define bTailCFOFLength 12 - -#define bmax_en_pwdB 0xffff -#define bCC_power_dB 0xffff0000 -#define bnoise_pwdB 0xffff -#define bPowerMeasTLength 10 -#define bPowerMeasFLength 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 bSNREVMTLength 8 -#define bSNREVMFLength 1 - -#define bCSI1st 0xff -#define bCSI2nd 0xff00 -#define bRxEVM1st 0xff0000 -#define bRxEVM2nd 0xff000000 - -#define bSIGEVM 0xff -#define bPWDB 0xff00 -#define bSGIEN 0x10000 - -#define bSFactorQAM1 0xf -#define bSFactorQAM2 0xf0 -#define bSFactorQAM3 0xf00 -#define bSFactorQAM4 0xf000 -#define bSFactorQAM5 0xf0000 -#define bSFactorQAM6 0xf0000 -#define bSFactorQAM7 0xf00000 -#define bSFactorQAM8 0xf000000 -#define bSFactorQAM9 0xf0000000 -#define bCSIScheme 0x100000 - -#define bNoiseLvlTopSet 0x3 -#define bChSmooth 0x4 -#define bChSmoothCfg1 0x38 -#define bChSmoothCfg2 0x1c0 -#define bChSmoothCfg3 0xe00 -#define bChSmoothCfg4 0x7000 -#define bMRCMode 0x800000 -#define bTHEVMCfg 0x7000000 - -#define bLoopFitType 0x1 -#define bUpdCFO 0x40 -#define bUpdCFOOffData 0x80 -#define bAdvUpdCFO 0x100 -#define bAdvTimeCtrl 0x800 -#define bUpdClko 0x1000 -#define bFC 0x6000 -#define bTrackingMode 0x8000 -#define bPhCmpEnable 0x10000 -#define bUpdClkoLTF 0x20000 -#define bComChCFO 0x40000 -#define bCSIEstiMode 0x80000 -#define bAdvUpdEqz 0x100000 -#define bUChCfg 0x7000000 -#define bUpdEqz 0x8000000 - -/* Page e */ -#define bTxAGCRate18_06 0x7f7f7f7f -#define bTxAGCRate54_24 0x7f7f7f7f -#define bTxAGCRateMCS32 0x7f -#define bTxAGCRateCCK 0x7f00 -#define bTxAGCRateMCS3_MCS0 0x7f7f7f7f -#define bTxAGCRateMCS7_MCS4 0x7f7f7f7f -#define bTxAGCRateMCS11_MCS8 0x7f7f7f7f -#define bTxAGCRateMCS15_MCS12 0x7f7f7f7f - - -/* Rx Pseduo noise */ -#define bRxPesudoNoiseOn 0x20000000 -#define bRxPesudoNoise_A 0xff -#define bRxPesudoNoise_B 0xff00 -#define bRxPesudoNoise_C 0xff0000 -#define bRxPesudoNoise_D 0xff000000 -#define bPesudoNoiseState_A 0xffff -#define bPesudoNoiseState_B 0xffff0000 -#define bPesudoNoiseState_C 0xffff -#define bPesudoNoiseState_D 0xffff0000 - -/* RF Zebra 1 */ -#define bZebra1_HSSIEnable 0x8 -#define bZebra1_TRxControl 0xc00 -#define bZebra1_TRxGainSetting 0x07f -#define bZebra1_RxCorner 0xc00 -#define bZebra1_TxChargePump 0x38 -#define bZebra1_RxChargePump 0x7 -#define bZebra1_ChannelNum 0xf80 -#define bZebra1_TxLPFBW 0x400 -#define bZebra1_RxLPFBW 0x600 - -/* Zebra4 */ -#define bRTL8256RegModeCtrl1 0x100 -#define bRTL8256RegModeCtrl0 0x40 -#define bRTL8256_TxLPFBW 0x18 -#define bRTL8256_RxLPFBW 0x600 - -//RTL8258 -#define bRTL8258_TxLPFBW 0xc -#define bRTL8258_RxLPFBW 0xc00 -#define bRTL8258_RSSILPFBW 0xc0 - -/* byte enable for sb_write */ -#define bByte0 0x1 -#define bByte1 0x2 -#define bByte2 0x4 -#define bByte3 0x8 -#define bWord0 0x3 -#define bWord1 0xc -#define bDWord 0xf - -/* for PutRegsetting & GetRegSetting BitMask */ -#define bMaskByte0 0xff -#define bMaskByte1 0xff00 -#define bMaskByte2 0xff0000 -#define bMaskByte3 0xff000000 -#define bMaskHWord 0xffff0000 -#define bMaskLWord 0x0000ffff -#define bMaskDWord 0xffffffff - -/* for PutRFRegsetting & GetRFRegSetting BitMask */ -#define bMask12Bits 0xfff - -#define bEnable 0x1 -#define bDisable 0x0 - -#define LeftAntenna 0x0 -#define RightAntenna 0x1 - -/* 500 ms */ -#define tCheckTxStatus 500 -/* 100 ms */ -#define tUpdateRxCounter 100 - -#define rateCCK 0 -#define rateOFDM 1 -#define rateHT 2 - -/* define Register-End */ -#define bPMAC_End 0x1ff -#define bFPGAPHY0_End 0x8ff -#define bFPGAPHY1_End 0x9ff -#define bCCKPHY0_End 0xaff -#define bOFDMPHY0_End 0xcff -#define bOFDMPHY1_End 0xdff - -#define bPMACControl 0x0 -#define bWMACControl 0x1 -#define bWNICControl 0x2 - -#define PathA 0x0 -#define PathB 0x1 -#define PathC 0x2 -#define PathD 0x3 - -#define rRTL8256RxMixerPole 0xb -#define bZebraRxMixerPole 0x6 -#define rRTL8256TxBBOPBias 0x9 -#define bRTL8256TxBBOPBias 0x400 -#define rRTL8256TxBBBW 19 -#define bRTL8256TxBBBW 0x18 - - -#endif /* __INC_HAL8190PCIPHYREG_H */ From f669228512e533468437a1058ef11303afa4e878 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 13 Apr 2015 23:47:27 +0200 Subject: [PATCH 0168/1163] staging: rtl8192e: Fix SPACING errors Fix several SPACING errors to make checkpatch happy. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 6 +++--- drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 6 +++--- drivers/staging/rtl8192e/rtllib_debug.h | 3 +-- drivers/staging/rtl8192e/rtllib_rx.c | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c index 4664a4fd1e48..eea2e39ff594 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c @@ -1002,7 +1002,7 @@ void rtl8192_SwChnl_WorkItem(struct net_device *dev) RT_TRACE(COMP_TRACE, "=====>--%s(), set chan:%d, priv:%p\n", __func__, priv->chan, priv); - rtl8192_phy_FinishSwChnlNow(dev , priv->chan); + rtl8192_phy_FinishSwChnlNow(dev, priv->chan); RT_TRACE(COMP_TRACE, "<== SwChnlCallback819xUsbWorkItem()\n"); } diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 352d381b7c4a..3ce7676445de 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -1533,7 +1533,7 @@ RESET_START: SEM_UP_IEEE_WX(&ieee->wx_sem); } else { netdev_info(dev, "ieee->state is NOT LINKED\n"); - rtllib_softmac_stop_protocol(priv->rtllib, 0 , true); + rtllib_softmac_stop_protocol(priv->rtllib, 0, true); } dm_backup_dynamic_mechanism_state(dev); @@ -2102,7 +2102,7 @@ static short rtl8192_alloc_rx_desc_ring(struct net_device *dev) entry->OWN = 1; } - if(entry) + if (entry) entry->EOR = 1; } return 0; @@ -2519,7 +2519,7 @@ void rtl8192_commit(struct net_device *dev) if (priv->up == 0) return; - rtllib_softmac_stop_protocol(priv->rtllib, 0 , true); + rtllib_softmac_stop_protocol(priv->rtllib, 0, true); rtl8192_irq_disable(dev); priv->ops->stop_adapter(dev, true); _rtl8192_up(dev, false); diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h index d365af6ebdc7..a6279e7156d0 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h @@ -84,7 +84,7 @@ #define RTL_PCI_DEVICE(vend, dev, cfg) \ .vendor = (vend), .device = (dev), \ - .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID , \ + .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \ .driver_data = (kernel_ulong_t)&(cfg) #define RTL_MAX_SCAN_SIZE 128 @@ -303,9 +303,9 @@ enum pci_bridge_vendor { PCI_BRIDGE_VENDOR_INTEL = 0x0, PCI_BRIDGE_VENDOR_ATI, PCI_BRIDGE_VENDOR_AMD, - PCI_BRIDGE_VENDOR_SIS , + PCI_BRIDGE_VENDOR_SIS, PCI_BRIDGE_VENDOR_UNKNOWN, - PCI_BRIDGE_VENDOR_MAX , + PCI_BRIDGE_VENDOR_MAX, }; struct buffer { diff --git a/drivers/staging/rtl8192e/rtllib_debug.h b/drivers/staging/rtl8192e/rtllib_debug.h index 119729d31c74..6df8df134367 100644 --- a/drivers/staging/rtl8192e/rtllib_debug.h +++ b/drivers/staging/rtl8192e/rtllib_debug.h @@ -73,8 +73,7 @@ enum RTL_DEBUG { #define RT_TRACE(component, x, args...) \ do { \ if (rt_global_debug_component & component) \ - printk(KERN_DEBUG DRV_NAME ":" x "\n" , \ - ##args);\ + printk(KERN_DEBUG DRV_NAME ":" x "\n", ##args);\ } while (0) #define assert(expr) \ diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index fe3e7e1273ff..95cd17eda768 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -469,7 +469,7 @@ static bool AddReorderEntry(struct rx_ts_record *pTS, void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb **prxbIndicateArray, u8 index) { struct net_device_stats *stats = &ieee->stats; - u8 i = 0 , j = 0; + u8 i = 0, j = 0; u16 ethertype; for (j = 0; j < index; j++) { From 20b7ec099007e31bc52b79c36673af307bd54752 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 13 Apr 2015 23:47:28 +0200 Subject: [PATCH 0169/1163] staging: rtl8192e: Remove bb tx gains from r8192_priv r8192_priv structure had 2 big arrays with tx gain register values: - cck_txbbgain_table - cck_txbbgain_ch14_table - txbbgain_table This arrays were read-only - filled in driver init code and look like firmware/chip-specific. This patch removes them from r8192_priv and puts them in (global) variables. tx_bb_gain is also flattened - register values are stored in array; Amplification value can be calculated using dm_tx_bb_gain_idx_to_amplify(). Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192e/rtl8192e/r8192E_dev.c | 5 +- drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 14 - drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 674 ++++-------------- drivers/staging/rtl8192e/rtl8192e/rtl_dm.h | 9 + 4 files changed, 151 insertions(+), 551 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c index 2869602436ef..aad5cc95c341 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c @@ -918,8 +918,7 @@ start: tmpRegC = rtl8192_QueryBBReg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord); for (i = 0; i < TxBBGainTableLength; i++) { - if (tmpRegA == - priv->txbbgain_table[i].txbbgain_value) { + if (tmpRegA == dm_tx_bb_gain[i]) { priv->rfa_txpowertrackingindex = (u8)i; priv->rfa_txpowertrackingindex_real = (u8)i; @@ -933,7 +932,7 @@ start: rCCK0_TxFilter1, bMaskByte2); for (i = 0; i < CCKTxBBGainTableLength; i++) { - if (TempCCk == priv->cck_txbbgain_table[i].ccktxbb_valuearray[0]) { + if (TempCCk == dm_cck_tx_bb_gain[i][0]) { priv->CCKPresentAttentuation_20Mdefault = (u8)i; break; } diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h index a6279e7156d0..0640e76f2a7a 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h @@ -451,15 +451,6 @@ enum two_port_status { TWO_PORT_STATUS__WITHOUT_ANY_ASSOCIATE }; -struct txbbgain_struct { - long txbb_iq_amplifygain; - u32 txbbgain_value; -}; - -struct ccktxbbgain { - u8 ccktxbb_valuearray[8]; -}; - struct init_gain { u8 xaagccore1; u8 xbagccore1; @@ -567,11 +558,6 @@ struct r8192_priv { struct bb_reg_definition PHYRegDef[4]; struct rate_adaptive rate_adaptive; - struct ccktxbbgain cck_txbbgain_table[CCKTxBBGainTableLength]; - struct ccktxbbgain cck_txbbgain_ch14_table[CCKTxBBGainTableLength]; - - struct txbbgain_struct txbbgain_table[TxBBGainTableLength]; - enum acm_method AcmMethod; struct rt_firmware *pFirmware; diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c index df4bbcf38bae..c99d584d3a7c 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c @@ -60,6 +60,99 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] = { #define RTK_UL_EDCA 0xa44f #define RTK_DL_EDCA 0x5e4322 + +const u32 dm_tx_bb_gain[TxBBGainTableLength] = { + 0x7f8001fe, /* 12 dB */ + 0x788001e2, /* 11 dB */ + 0x71c001c7, + 0x6b8001ae, + 0x65400195, + 0x5fc0017f, + 0x5a400169, + 0x55400155, + 0x50800142, + 0x4c000130, + 0x47c0011f, + 0x43c0010f, + 0x40000100, + 0x3c8000f2, + 0x390000e4, + 0x35c000d7, + 0x32c000cb, + 0x300000c0, + 0x2d4000b5, + 0x2ac000ab, + 0x288000a2, + 0x26000098, + 0x24000090, + 0x22000088, + 0x20000080, + 0x1a00006c, + 0x1c800072, + 0x18000060, + 0x19800066, + 0x15800056, + 0x26c0005b, + 0x14400051, + 0x24400051, + 0x1300004c, + 0x12000048, + 0x11000044, + 0x10000040, /* -24 dB */ +}; + +const u8 dm_cck_tx_bb_gain[CCKTxBBGainTableLength][8] = { + {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, + {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, + {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, + {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03}, + {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, + {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03}, + {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, + {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03}, + {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, + {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02}, + {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, + {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02}, + {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, + {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02}, + {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, + {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02}, + {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, + {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02}, + {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, + {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, + {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, + {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01}, + {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01} +}; + +const u8 dm_cck_tx_bb_gain_ch14[CCKTxBBGainTableLength][8] = { + {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, + {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, + {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, + {0x2d, 0x2d, 0x27, 0x17, 0x00, 0x00, 0x00, 0x00}, + {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, + {0x28, 0x28, 0x22, 0x14, 0x00, 0x00, 0x00, 0x00}, + {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, + {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00}, + {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, + {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00}, + {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, + {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00}, + {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, + {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00}, + {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, + {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00}, + {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, + {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, + {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, + {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, + {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, + {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00}, + {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00} +}; + /*---------------------------Define Local Constant---------------------------*/ @@ -590,7 +683,7 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev) rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, - priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); + dm_tx_bb_gain[priv->rfa_txpowertrackingindex_real]); } priv->rfc_txpowertrackingindex--; @@ -599,15 +692,16 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev) rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, - priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); + dm_tx_bb_gain[priv->rfc_txpowertrackingindex_real]); } } else { - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, + rtl8192_setBBreg(dev, + rOFDM0_XATxIQImbalance, bMaskDWord, - priv->txbbgain_table[4].txbbgain_value); + dm_tx_bb_gain[4]); rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, - bMaskDWord, priv->txbbgain_table[4].txbbgain_value); + bMaskDWord, dm_tx_bb_gain[4]); } } else { if (priv->rfa_txpowertrackingindex > 0) { @@ -617,11 +711,11 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev) rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, - priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); + dm_tx_bb_gain[priv->rfa_txpowertrackingindex_real]); } } else rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, - bMaskDWord, priv->txbbgain_table[4].txbbgain_value); + bMaskDWord, dm_tx_bb_gain[4]); } } else { @@ -635,22 +729,21 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev) rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, - priv->txbbgain_table - [priv->rfa_txpowertrackingindex_real].txbbgain_value); + dm_tx_bb_gain[priv->rfa_txpowertrackingindex_real]); priv->rfc_txpowertrackingindex++; priv->rfc_txpowertrackingindex_real++; rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, - priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); + dm_tx_bb_gain[priv->rfc_txpowertrackingindex_real]); } else { rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, - priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); + dm_tx_bb_gain[TxBBGainTableLength - 1]); rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, - bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); + bMaskDWord, dm_tx_bb_gain[TxBBGainTableLength - 1]); } } else { if (priv->rfa_txpowertrackingindex < (TxBBGainTableLength - 1)) { @@ -658,11 +751,11 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev) priv->rfa_txpowertrackingindex_real++; rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, - priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); + dm_tx_bb_gain[priv->rfa_txpowertrackingindex_real]); } else rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, - priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); + dm_tx_bb_gain[TxBBGainTableLength - 1]); } } if (RF_Type == RF_2T4R) { @@ -848,496 +941,6 @@ static void dm_InitializeTXPowerTracking_TSSI(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - - priv->txbbgain_table[0].txbb_iq_amplifygain = 12; - priv->txbbgain_table[0].txbbgain_value = 0x7f8001fe; - priv->txbbgain_table[1].txbb_iq_amplifygain = 11; - priv->txbbgain_table[1].txbbgain_value = 0x788001e2; - priv->txbbgain_table[2].txbb_iq_amplifygain = 10; - priv->txbbgain_table[2].txbbgain_value = 0x71c001c7; - priv->txbbgain_table[3].txbb_iq_amplifygain = 9; - priv->txbbgain_table[3].txbbgain_value = 0x6b8001ae; - priv->txbbgain_table[4].txbb_iq_amplifygain = 8; - priv->txbbgain_table[4].txbbgain_value = 0x65400195; - priv->txbbgain_table[5].txbb_iq_amplifygain = 7; - priv->txbbgain_table[5].txbbgain_value = 0x5fc0017f; - priv->txbbgain_table[6].txbb_iq_amplifygain = 6; - priv->txbbgain_table[6].txbbgain_value = 0x5a400169; - priv->txbbgain_table[7].txbb_iq_amplifygain = 5; - priv->txbbgain_table[7].txbbgain_value = 0x55400155; - priv->txbbgain_table[8].txbb_iq_amplifygain = 4; - priv->txbbgain_table[8].txbbgain_value = 0x50800142; - priv->txbbgain_table[9].txbb_iq_amplifygain = 3; - priv->txbbgain_table[9].txbbgain_value = 0x4c000130; - priv->txbbgain_table[10].txbb_iq_amplifygain = 2; - priv->txbbgain_table[10].txbbgain_value = 0x47c0011f; - priv->txbbgain_table[11].txbb_iq_amplifygain = 1; - priv->txbbgain_table[11].txbbgain_value = 0x43c0010f; - priv->txbbgain_table[12].txbb_iq_amplifygain = 0; - priv->txbbgain_table[12].txbbgain_value = 0x40000100; - priv->txbbgain_table[13].txbb_iq_amplifygain = -1; - priv->txbbgain_table[13].txbbgain_value = 0x3c8000f2; - priv->txbbgain_table[14].txbb_iq_amplifygain = -2; - priv->txbbgain_table[14].txbbgain_value = 0x390000e4; - priv->txbbgain_table[15].txbb_iq_amplifygain = -3; - priv->txbbgain_table[15].txbbgain_value = 0x35c000d7; - priv->txbbgain_table[16].txbb_iq_amplifygain = -4; - priv->txbbgain_table[16].txbbgain_value = 0x32c000cb; - priv->txbbgain_table[17].txbb_iq_amplifygain = -5; - priv->txbbgain_table[17].txbbgain_value = 0x300000c0; - priv->txbbgain_table[18].txbb_iq_amplifygain = -6; - priv->txbbgain_table[18].txbbgain_value = 0x2d4000b5; - priv->txbbgain_table[19].txbb_iq_amplifygain = -7; - priv->txbbgain_table[19].txbbgain_value = 0x2ac000ab; - priv->txbbgain_table[20].txbb_iq_amplifygain = -8; - priv->txbbgain_table[20].txbbgain_value = 0x288000a2; - priv->txbbgain_table[21].txbb_iq_amplifygain = -9; - priv->txbbgain_table[21].txbbgain_value = 0x26000098; - priv->txbbgain_table[22].txbb_iq_amplifygain = -10; - priv->txbbgain_table[22].txbbgain_value = 0x24000090; - priv->txbbgain_table[23].txbb_iq_amplifygain = -11; - priv->txbbgain_table[23].txbbgain_value = 0x22000088; - priv->txbbgain_table[24].txbb_iq_amplifygain = -12; - priv->txbbgain_table[24].txbbgain_value = 0x20000080; - priv->txbbgain_table[25].txbb_iq_amplifygain = -13; - priv->txbbgain_table[25].txbbgain_value = 0x1a00006c; - priv->txbbgain_table[26].txbb_iq_amplifygain = -14; - priv->txbbgain_table[26].txbbgain_value = 0x1c800072; - priv->txbbgain_table[27].txbb_iq_amplifygain = -15; - priv->txbbgain_table[27].txbbgain_value = 0x18000060; - priv->txbbgain_table[28].txbb_iq_amplifygain = -16; - priv->txbbgain_table[28].txbbgain_value = 0x19800066; - priv->txbbgain_table[29].txbb_iq_amplifygain = -17; - priv->txbbgain_table[29].txbbgain_value = 0x15800056; - priv->txbbgain_table[30].txbb_iq_amplifygain = -18; - priv->txbbgain_table[30].txbbgain_value = 0x26c0005b; - priv->txbbgain_table[31].txbb_iq_amplifygain = -19; - priv->txbbgain_table[31].txbbgain_value = 0x14400051; - priv->txbbgain_table[32].txbb_iq_amplifygain = -20; - priv->txbbgain_table[32].txbbgain_value = 0x24400051; - priv->txbbgain_table[33].txbb_iq_amplifygain = -21; - priv->txbbgain_table[33].txbbgain_value = 0x1300004c; - priv->txbbgain_table[34].txbb_iq_amplifygain = -22; - priv->txbbgain_table[34].txbbgain_value = 0x12000048; - priv->txbbgain_table[35].txbb_iq_amplifygain = -23; - priv->txbbgain_table[35].txbbgain_value = 0x11000044; - priv->txbbgain_table[36].txbb_iq_amplifygain = -24; - priv->txbbgain_table[36].txbbgain_value = 0x10000040; - - priv->cck_txbbgain_table[0].ccktxbb_valuearray[0] = 0x36; - priv->cck_txbbgain_table[0].ccktxbb_valuearray[1] = 0x35; - priv->cck_txbbgain_table[0].ccktxbb_valuearray[2] = 0x2e; - priv->cck_txbbgain_table[0].ccktxbb_valuearray[3] = 0x25; - priv->cck_txbbgain_table[0].ccktxbb_valuearray[4] = 0x1c; - priv->cck_txbbgain_table[0].ccktxbb_valuearray[5] = 0x12; - priv->cck_txbbgain_table[0].ccktxbb_valuearray[6] = 0x09; - priv->cck_txbbgain_table[0].ccktxbb_valuearray[7] = 0x04; - - priv->cck_txbbgain_table[1].ccktxbb_valuearray[0] = 0x33; - priv->cck_txbbgain_table[1].ccktxbb_valuearray[1] = 0x32; - priv->cck_txbbgain_table[1].ccktxbb_valuearray[2] = 0x2b; - priv->cck_txbbgain_table[1].ccktxbb_valuearray[3] = 0x23; - priv->cck_txbbgain_table[1].ccktxbb_valuearray[4] = 0x1a; - priv->cck_txbbgain_table[1].ccktxbb_valuearray[5] = 0x11; - priv->cck_txbbgain_table[1].ccktxbb_valuearray[6] = 0x08; - priv->cck_txbbgain_table[1].ccktxbb_valuearray[7] = 0x04; - - priv->cck_txbbgain_table[2].ccktxbb_valuearray[0] = 0x30; - priv->cck_txbbgain_table[2].ccktxbb_valuearray[1] = 0x2f; - priv->cck_txbbgain_table[2].ccktxbb_valuearray[2] = 0x29; - priv->cck_txbbgain_table[2].ccktxbb_valuearray[3] = 0x21; - priv->cck_txbbgain_table[2].ccktxbb_valuearray[4] = 0x19; - priv->cck_txbbgain_table[2].ccktxbb_valuearray[5] = 0x10; - priv->cck_txbbgain_table[2].ccktxbb_valuearray[6] = 0x08; - priv->cck_txbbgain_table[2].ccktxbb_valuearray[7] = 0x03; - - priv->cck_txbbgain_table[3].ccktxbb_valuearray[0] = 0x2d; - priv->cck_txbbgain_table[3].ccktxbb_valuearray[1] = 0x2d; - priv->cck_txbbgain_table[3].ccktxbb_valuearray[2] = 0x27; - priv->cck_txbbgain_table[3].ccktxbb_valuearray[3] = 0x1f; - priv->cck_txbbgain_table[3].ccktxbb_valuearray[4] = 0x18; - priv->cck_txbbgain_table[3].ccktxbb_valuearray[5] = 0x0f; - priv->cck_txbbgain_table[3].ccktxbb_valuearray[6] = 0x08; - priv->cck_txbbgain_table[3].ccktxbb_valuearray[7] = 0x03; - - priv->cck_txbbgain_table[4].ccktxbb_valuearray[0] = 0x2b; - priv->cck_txbbgain_table[4].ccktxbb_valuearray[1] = 0x2a; - priv->cck_txbbgain_table[4].ccktxbb_valuearray[2] = 0x25; - priv->cck_txbbgain_table[4].ccktxbb_valuearray[3] = 0x1e; - priv->cck_txbbgain_table[4].ccktxbb_valuearray[4] = 0x16; - priv->cck_txbbgain_table[4].ccktxbb_valuearray[5] = 0x0e; - priv->cck_txbbgain_table[4].ccktxbb_valuearray[6] = 0x07; - priv->cck_txbbgain_table[4].ccktxbb_valuearray[7] = 0x03; - - priv->cck_txbbgain_table[5].ccktxbb_valuearray[0] = 0x28; - priv->cck_txbbgain_table[5].ccktxbb_valuearray[1] = 0x28; - priv->cck_txbbgain_table[5].ccktxbb_valuearray[2] = 0x22; - priv->cck_txbbgain_table[5].ccktxbb_valuearray[3] = 0x1c; - priv->cck_txbbgain_table[5].ccktxbb_valuearray[4] = 0x15; - priv->cck_txbbgain_table[5].ccktxbb_valuearray[5] = 0x0d; - priv->cck_txbbgain_table[5].ccktxbb_valuearray[6] = 0x07; - priv->cck_txbbgain_table[5].ccktxbb_valuearray[7] = 0x03; - - priv->cck_txbbgain_table[6].ccktxbb_valuearray[0] = 0x26; - priv->cck_txbbgain_table[6].ccktxbb_valuearray[1] = 0x25; - priv->cck_txbbgain_table[6].ccktxbb_valuearray[2] = 0x21; - priv->cck_txbbgain_table[6].ccktxbb_valuearray[3] = 0x1b; - priv->cck_txbbgain_table[6].ccktxbb_valuearray[4] = 0x14; - priv->cck_txbbgain_table[6].ccktxbb_valuearray[5] = 0x0d; - priv->cck_txbbgain_table[6].ccktxbb_valuearray[6] = 0x06; - priv->cck_txbbgain_table[6].ccktxbb_valuearray[7] = 0x03; - - priv->cck_txbbgain_table[7].ccktxbb_valuearray[0] = 0x24; - priv->cck_txbbgain_table[7].ccktxbb_valuearray[1] = 0x23; - priv->cck_txbbgain_table[7].ccktxbb_valuearray[2] = 0x1f; - priv->cck_txbbgain_table[7].ccktxbb_valuearray[3] = 0x19; - priv->cck_txbbgain_table[7].ccktxbb_valuearray[4] = 0x13; - priv->cck_txbbgain_table[7].ccktxbb_valuearray[5] = 0x0c; - priv->cck_txbbgain_table[7].ccktxbb_valuearray[6] = 0x06; - priv->cck_txbbgain_table[7].ccktxbb_valuearray[7] = 0x03; - - priv->cck_txbbgain_table[8].ccktxbb_valuearray[0] = 0x22; - priv->cck_txbbgain_table[8].ccktxbb_valuearray[1] = 0x21; - priv->cck_txbbgain_table[8].ccktxbb_valuearray[2] = 0x1d; - priv->cck_txbbgain_table[8].ccktxbb_valuearray[3] = 0x18; - priv->cck_txbbgain_table[8].ccktxbb_valuearray[4] = 0x11; - priv->cck_txbbgain_table[8].ccktxbb_valuearray[5] = 0x0b; - priv->cck_txbbgain_table[8].ccktxbb_valuearray[6] = 0x06; - priv->cck_txbbgain_table[8].ccktxbb_valuearray[7] = 0x02; - - priv->cck_txbbgain_table[9].ccktxbb_valuearray[0] = 0x20; - priv->cck_txbbgain_table[9].ccktxbb_valuearray[1] = 0x20; - priv->cck_txbbgain_table[9].ccktxbb_valuearray[2] = 0x1b; - priv->cck_txbbgain_table[9].ccktxbb_valuearray[3] = 0x16; - priv->cck_txbbgain_table[9].ccktxbb_valuearray[4] = 0x11; - priv->cck_txbbgain_table[9].ccktxbb_valuearray[5] = 0x08; - priv->cck_txbbgain_table[9].ccktxbb_valuearray[6] = 0x05; - priv->cck_txbbgain_table[9].ccktxbb_valuearray[7] = 0x02; - - priv->cck_txbbgain_table[10].ccktxbb_valuearray[0] = 0x1f; - priv->cck_txbbgain_table[10].ccktxbb_valuearray[1] = 0x1e; - priv->cck_txbbgain_table[10].ccktxbb_valuearray[2] = 0x1a; - priv->cck_txbbgain_table[10].ccktxbb_valuearray[3] = 0x15; - priv->cck_txbbgain_table[10].ccktxbb_valuearray[4] = 0x10; - priv->cck_txbbgain_table[10].ccktxbb_valuearray[5] = 0x0a; - priv->cck_txbbgain_table[10].ccktxbb_valuearray[6] = 0x05; - priv->cck_txbbgain_table[10].ccktxbb_valuearray[7] = 0x02; - - priv->cck_txbbgain_table[11].ccktxbb_valuearray[0] = 0x1d; - priv->cck_txbbgain_table[11].ccktxbb_valuearray[1] = 0x1c; - priv->cck_txbbgain_table[11].ccktxbb_valuearray[2] = 0x18; - priv->cck_txbbgain_table[11].ccktxbb_valuearray[3] = 0x14; - priv->cck_txbbgain_table[11].ccktxbb_valuearray[4] = 0x0f; - priv->cck_txbbgain_table[11].ccktxbb_valuearray[5] = 0x0a; - priv->cck_txbbgain_table[11].ccktxbb_valuearray[6] = 0x05; - priv->cck_txbbgain_table[11].ccktxbb_valuearray[7] = 0x02; - - priv->cck_txbbgain_table[12].ccktxbb_valuearray[0] = 0x1b; - priv->cck_txbbgain_table[12].ccktxbb_valuearray[1] = 0x1a; - priv->cck_txbbgain_table[12].ccktxbb_valuearray[2] = 0x17; - priv->cck_txbbgain_table[12].ccktxbb_valuearray[3] = 0x13; - priv->cck_txbbgain_table[12].ccktxbb_valuearray[4] = 0x0e; - priv->cck_txbbgain_table[12].ccktxbb_valuearray[5] = 0x09; - priv->cck_txbbgain_table[12].ccktxbb_valuearray[6] = 0x04; - priv->cck_txbbgain_table[12].ccktxbb_valuearray[7] = 0x02; - - priv->cck_txbbgain_table[13].ccktxbb_valuearray[0] = 0x1a; - priv->cck_txbbgain_table[13].ccktxbb_valuearray[1] = 0x19; - priv->cck_txbbgain_table[13].ccktxbb_valuearray[2] = 0x16; - priv->cck_txbbgain_table[13].ccktxbb_valuearray[3] = 0x12; - priv->cck_txbbgain_table[13].ccktxbb_valuearray[4] = 0x0d; - priv->cck_txbbgain_table[13].ccktxbb_valuearray[5] = 0x09; - priv->cck_txbbgain_table[13].ccktxbb_valuearray[6] = 0x04; - priv->cck_txbbgain_table[13].ccktxbb_valuearray[7] = 0x02; - - priv->cck_txbbgain_table[14].ccktxbb_valuearray[0] = 0x18; - priv->cck_txbbgain_table[14].ccktxbb_valuearray[1] = 0x17; - priv->cck_txbbgain_table[14].ccktxbb_valuearray[2] = 0x15; - priv->cck_txbbgain_table[14].ccktxbb_valuearray[3] = 0x11; - priv->cck_txbbgain_table[14].ccktxbb_valuearray[4] = 0x0c; - priv->cck_txbbgain_table[14].ccktxbb_valuearray[5] = 0x08; - priv->cck_txbbgain_table[14].ccktxbb_valuearray[6] = 0x04; - priv->cck_txbbgain_table[14].ccktxbb_valuearray[7] = 0x02; - - priv->cck_txbbgain_table[15].ccktxbb_valuearray[0] = 0x17; - priv->cck_txbbgain_table[15].ccktxbb_valuearray[1] = 0x16; - priv->cck_txbbgain_table[15].ccktxbb_valuearray[2] = 0x13; - priv->cck_txbbgain_table[15].ccktxbb_valuearray[3] = 0x10; - priv->cck_txbbgain_table[15].ccktxbb_valuearray[4] = 0x0c; - priv->cck_txbbgain_table[15].ccktxbb_valuearray[5] = 0x08; - priv->cck_txbbgain_table[15].ccktxbb_valuearray[6] = 0x04; - priv->cck_txbbgain_table[15].ccktxbb_valuearray[7] = 0x02; - - priv->cck_txbbgain_table[16].ccktxbb_valuearray[0] = 0x16; - priv->cck_txbbgain_table[16].ccktxbb_valuearray[1] = 0x15; - priv->cck_txbbgain_table[16].ccktxbb_valuearray[2] = 0x12; - priv->cck_txbbgain_table[16].ccktxbb_valuearray[3] = 0x0f; - priv->cck_txbbgain_table[16].ccktxbb_valuearray[4] = 0x0b; - priv->cck_txbbgain_table[16].ccktxbb_valuearray[5] = 0x07; - priv->cck_txbbgain_table[16].ccktxbb_valuearray[6] = 0x04; - priv->cck_txbbgain_table[16].ccktxbb_valuearray[7] = 0x01; - - priv->cck_txbbgain_table[17].ccktxbb_valuearray[0] = 0x14; - priv->cck_txbbgain_table[17].ccktxbb_valuearray[1] = 0x14; - priv->cck_txbbgain_table[17].ccktxbb_valuearray[2] = 0x11; - priv->cck_txbbgain_table[17].ccktxbb_valuearray[3] = 0x0e; - priv->cck_txbbgain_table[17].ccktxbb_valuearray[4] = 0x0b; - priv->cck_txbbgain_table[17].ccktxbb_valuearray[5] = 0x07; - priv->cck_txbbgain_table[17].ccktxbb_valuearray[6] = 0x03; - priv->cck_txbbgain_table[17].ccktxbb_valuearray[7] = 0x02; - - priv->cck_txbbgain_table[18].ccktxbb_valuearray[0] = 0x13; - priv->cck_txbbgain_table[18].ccktxbb_valuearray[1] = 0x13; - priv->cck_txbbgain_table[18].ccktxbb_valuearray[2] = 0x10; - priv->cck_txbbgain_table[18].ccktxbb_valuearray[3] = 0x0d; - priv->cck_txbbgain_table[18].ccktxbb_valuearray[4] = 0x0a; - priv->cck_txbbgain_table[18].ccktxbb_valuearray[5] = 0x06; - priv->cck_txbbgain_table[18].ccktxbb_valuearray[6] = 0x03; - priv->cck_txbbgain_table[18].ccktxbb_valuearray[7] = 0x01; - - priv->cck_txbbgain_table[19].ccktxbb_valuearray[0] = 0x12; - priv->cck_txbbgain_table[19].ccktxbb_valuearray[1] = 0x12; - priv->cck_txbbgain_table[19].ccktxbb_valuearray[2] = 0x0f; - priv->cck_txbbgain_table[19].ccktxbb_valuearray[3] = 0x0c; - priv->cck_txbbgain_table[19].ccktxbb_valuearray[4] = 0x09; - priv->cck_txbbgain_table[19].ccktxbb_valuearray[5] = 0x06; - priv->cck_txbbgain_table[19].ccktxbb_valuearray[6] = 0x03; - priv->cck_txbbgain_table[19].ccktxbb_valuearray[7] = 0x01; - - priv->cck_txbbgain_table[20].ccktxbb_valuearray[0] = 0x11; - priv->cck_txbbgain_table[20].ccktxbb_valuearray[1] = 0x11; - priv->cck_txbbgain_table[20].ccktxbb_valuearray[2] = 0x0f; - priv->cck_txbbgain_table[20].ccktxbb_valuearray[3] = 0x0c; - priv->cck_txbbgain_table[20].ccktxbb_valuearray[4] = 0x09; - priv->cck_txbbgain_table[20].ccktxbb_valuearray[5] = 0x06; - priv->cck_txbbgain_table[20].ccktxbb_valuearray[6] = 0x03; - priv->cck_txbbgain_table[20].ccktxbb_valuearray[7] = 0x01; - - priv->cck_txbbgain_table[21].ccktxbb_valuearray[0] = 0x10; - priv->cck_txbbgain_table[21].ccktxbb_valuearray[1] = 0x10; - priv->cck_txbbgain_table[21].ccktxbb_valuearray[2] = 0x0e; - priv->cck_txbbgain_table[21].ccktxbb_valuearray[3] = 0x0b; - priv->cck_txbbgain_table[21].ccktxbb_valuearray[4] = 0x08; - priv->cck_txbbgain_table[21].ccktxbb_valuearray[5] = 0x05; - priv->cck_txbbgain_table[21].ccktxbb_valuearray[6] = 0x03; - priv->cck_txbbgain_table[21].ccktxbb_valuearray[7] = 0x01; - - priv->cck_txbbgain_table[22].ccktxbb_valuearray[0] = 0x0f; - priv->cck_txbbgain_table[22].ccktxbb_valuearray[1] = 0x0f; - priv->cck_txbbgain_table[22].ccktxbb_valuearray[2] = 0x0d; - priv->cck_txbbgain_table[22].ccktxbb_valuearray[3] = 0x0b; - priv->cck_txbbgain_table[22].ccktxbb_valuearray[4] = 0x08; - priv->cck_txbbgain_table[22].ccktxbb_valuearray[5] = 0x05; - priv->cck_txbbgain_table[22].ccktxbb_valuearray[6] = 0x03; - priv->cck_txbbgain_table[22].ccktxbb_valuearray[7] = 0x01; - - priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[0] = 0x36; - priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[1] = 0x35; - priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[2] = 0x2e; - priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[3] = 0x1b; - priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[7] = 0x00; - - priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[0] = 0x33; - priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[1] = 0x32; - priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[2] = 0x2b; - priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[3] = 0x19; - priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[7] = 0x00; - - priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[0] = 0x30; - priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[1] = 0x2f; - priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[2] = 0x29; - priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[3] = 0x18; - priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[7] = 0x00; - - priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[0] = 0x2d; - priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[1] = 0x2d; - priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[2] = 0x27; - priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[3] = 0x17; - priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[7] = 0x00; - - priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[0] = 0x2b; - priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[1] = 0x2a; - priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[2] = 0x25; - priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[3] = 0x15; - priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[7] = 0x00; - - priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[0] = 0x28; - priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[1] = 0x28; - priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[2] = 0x22; - priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[3] = 0x14; - priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[7] = 0x00; - - priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[0] = 0x26; - priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[1] = 0x25; - priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[2] = 0x21; - priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[3] = 0x13; - priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[7] = 0x00; - - priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[0] = 0x24; - priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[1] = 0x23; - priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[2] = 0x1f; - priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[3] = 0x12; - priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[7] = 0x00; - - priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[0] = 0x22; - priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[1] = 0x21; - priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[2] = 0x1d; - priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[3] = 0x11; - priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[7] = 0x00; - - priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[0] = 0x20; - priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[1] = 0x20; - priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[2] = 0x1b; - priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[3] = 0x10; - priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[7] = 0x00; - - priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[0] = 0x1f; - priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[1] = 0x1e; - priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[2] = 0x1a; - priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[3] = 0x0f; - priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[7] = 0x00; - - priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[0] = 0x1d; - priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[1] = 0x1c; - priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[2] = 0x18; - priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[3] = 0x0e; - priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[7] = 0x00; - - priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[0] = 0x1b; - priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[1] = 0x1a; - priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[2] = 0x17; - priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[3] = 0x0e; - priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[7] = 0x00; - - priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[0] = 0x1a; - priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[1] = 0x19; - priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[2] = 0x16; - priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[3] = 0x0d; - priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[7] = 0x00; - - priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[0] = 0x18; - priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[1] = 0x17; - priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[2] = 0x15; - priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[3] = 0x0c; - priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[7] = 0x00; - - priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[0] = 0x17; - priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[1] = 0x16; - priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[2] = 0x13; - priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[3] = 0x0b; - priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[7] = 0x00; - - priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[0] = 0x16; - priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[1] = 0x15; - priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[2] = 0x12; - priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[3] = 0x0b; - priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[7] = 0x00; - - priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[0] = 0x14; - priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[1] = 0x14; - priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[2] = 0x11; - priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[3] = 0x0a; - priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[7] = 0x00; - - priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[0] = 0x13; - priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[1] = 0x13; - priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[2] = 0x10; - priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[3] = 0x0a; - priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[7] = 0x00; - - priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[0] = 0x12; - priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[1] = 0x12; - priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[2] = 0x0f; - priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[3] = 0x09; - priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[7] = 0x00; - - priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[0] = 0x11; - priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[1] = 0x11; - priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[2] = 0x0f; - priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[3] = 0x09; - priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[7] = 0x00; - - priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[0] = 0x10; - priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[1] = 0x10; - priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[2] = 0x0e; - priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[3] = 0x08; - priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[7] = 0x00; - - priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[0] = 0x0f; - priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[1] = 0x0f; - priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[2] = 0x0d; - priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[3] = 0x08; - priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[4] = 0x00; - priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[5] = 0x00; - priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[6] = 0x00; - priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[7] = 0x00; - priv->btxpower_tracking = true; priv->txpower_count = 0; priv->btxpower_trackingInit = false; @@ -1436,39 +1039,38 @@ static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool bInCH14) { u32 TempVal; struct r8192_priv *priv = rtllib_priv(dev); + u8 attenuation = (u8)priv->CCKPresentAttentuation; TempVal = 0; if (!bInCH14) { - TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] + - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)); + TempVal = (u32)(dm_cck_tx_bb_gain[attenuation][0] + + (dm_cck_tx_bb_gain[attenuation][1] << 8)); rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); - TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] + - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) + - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16)+ - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24)); + TempVal = (u32)((dm_cck_tx_bb_gain[attenuation][2]) + + (dm_cck_tx_bb_gain[attenuation][3] << 8) + + (dm_cck_tx_bb_gain[attenuation][4] << 16)+ + (dm_cck_tx_bb_gain[attenuation][5] << 24)); rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); - TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] + - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)); + TempVal = (u32)(dm_cck_tx_bb_gain[attenuation][6] + + (dm_cck_tx_bb_gain[attenuation][7] << 8)); rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); } else { - TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] + - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)); + TempVal = (u32)((dm_cck_tx_bb_gain_ch14[attenuation][0]) + + (dm_cck_tx_bb_gain_ch14[attenuation][1] << 8)); rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); - TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] + - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) + - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16)+ - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24)); + TempVal = (u32)((dm_cck_tx_bb_gain_ch14[attenuation][2]) + + (dm_cck_tx_bb_gain_ch14[attenuation][3] << 8) + + (dm_cck_tx_bb_gain_ch14[attenuation][4] << 16)+ + (dm_cck_tx_bb_gain_ch14[attenuation][5] << 24)); rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); - TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] + - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)); + TempVal = (u32)((dm_cck_tx_bb_gain_ch14[attenuation][6]) + + (dm_cck_tx_bb_gain_ch14[attenuation][7] << 8)); rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); } - - } static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH14) @@ -1535,26 +1137,30 @@ static void dm_txpower_reset_recovery(struct net_device *dev) RT_TRACE(COMP_POWER_TRACKING, "Start Reset Recovery ==>\n"); rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, - priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value); + dm_tx_bb_gain[priv->rfa_txpowertrackingindex]); RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc80 is %08x\n", - priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFA_txPowerTrackingIndex is %x\n", + dm_tx_bb_gain[priv->rfa_txpowertrackingindex]); + RT_TRACE(COMP_POWER_TRACKING, + "Reset Recovery: Fill in RFA_txPowerTrackingIndex is %x\n", priv->rfa_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery : RF A I/Q Amplify Gain is %ld\n", - priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbb_iq_amplifygain); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: CCK Attenuation is %d dB\n", + RT_TRACE(COMP_POWER_TRACKING, + "Reset Recovery : RF A I/Q Amplify Gain is %d\n", + dm_tx_bb_gain_idx_to_amplify(priv->rfa_txpowertrackingindex)); + RT_TRACE(COMP_POWER_TRACKING, + "Reset Recovery: CCK Attenuation is %d dB\n", priv->CCKPresentAttentuation); dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, - priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value); + dm_tx_bb_gain[priv->rfc_txpowertrackingindex]); RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc90 is %08x\n", - priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFC_txPowerTrackingIndex is %x\n", + dm_tx_bb_gain[priv->rfc_txpowertrackingindex]); + RT_TRACE(COMP_POWER_TRACKING, + "Reset Recovery: Fill in RFC_txPowerTrackingIndex is %x\n", priv->rfc_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery : RF C I/Q Amplify Gain is %ld\n", - priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbb_iq_amplifygain); - + RT_TRACE(COMP_POWER_TRACKING, + "Reset Recovery : RF C I/Q Amplify Gain is %d\n", + dm_tx_bb_gain_idx_to_amplify(priv->rfc_txpowertrackingindex)); } void dm_restore_dynamic_mechanism_state(struct net_device *dev) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h index 3f02e11cfc57..6be8e8bd640a 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h @@ -252,11 +252,20 @@ extern u8 dm_shadow[16][256]; extern struct drx_path_sel DM_RxPathSelTable; extern u8 test_flag; + +/* Pre-calculated gain tables */ +extern const u32 dm_tx_bb_gain[TxBBGainTableLength]; +extern const u8 dm_cck_tx_bb_gain[CCKTxBBGainTableLength][8]; +extern const u8 dm_cck_tx_bb_gain_ch14[CCKTxBBGainTableLength][8]; +/* Maps table index to iq amplify gain (dB, 12 to -24dB) */ +#define dm_tx_bb_gain_idx_to_amplify(idx) (-idx + 12) + /*------------------------Export global variable----------------------------*/ /*--------------------------Exported Function prototype---------------------*/ /*--------------------------Exported Function prototype---------------------*/ + extern void init_hal_dm(struct net_device *dev); extern void deinit_hal_dm(struct net_device *dev); From 867ebbaebc9c670a6b590fc54d4a49a8ed4a1e19 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 13 Apr 2015 23:47:29 +0200 Subject: [PATCH 0170/1163] staging: rtl8192e: Fix LINE_SPACING warning Trivial fix - add newline in dm_InitializeTXPowerTracking_TSSI() Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c index c99d584d3a7c..9de584639c56 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c @@ -941,6 +941,7 @@ static void dm_InitializeTXPowerTracking_TSSI(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); + priv->btxpower_tracking = true; priv->txpower_count = 0; priv->btxpower_trackingInit = false; From fbb052f9fe6839ff85839d729ae1f44ff7c03760 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 13 Apr 2015 23:47:30 +0200 Subject: [PATCH 0171/1163] staging: rtl8192e: Fix DEEP_INDENTATION warnings in rtllib_parse_info_param() - Replace ?: with min_t - Remove condition that is always true Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_rx.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 95cd17eda768..bb789cc9208d 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1924,13 +1924,12 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, info_element->data[2] == 0x4c && info_element->data[3] == 0x033) { - tmp_htcap_len = min_t(u8, info_element->len, MAX_IE_LEN); - if (tmp_htcap_len != 0) { - network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; - network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf) ? - sizeof(network->bssht.bdHTCapBuf) : tmp_htcap_len; - memcpy(network->bssht.bdHTCapBuf, info_element->data, network->bssht.bdHTCapLen); - } + tmp_htcap_len = min_t(u8, info_element->len, MAX_IE_LEN); + if (tmp_htcap_len != 0) { + network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; + network->bssht.bdHTCapLen = min_t(u16, tmp_htcap_len, sizeof(network->bssht.bdHTCapBuf)); + memcpy(network->bssht.bdHTCapBuf, info_element->data, network->bssht.bdHTCapLen); + } } if (tmp_htcap_len != 0) { network->bssht.bdSupportHT = true; @@ -1951,12 +1950,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, tmp_htinfo_len = min_t(u8, info_element->len, MAX_IE_LEN); if (tmp_htinfo_len != 0) { network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; - if (tmp_htinfo_len) { - network->bssht.bdHTInfoLen = tmp_htinfo_len > sizeof(network->bssht.bdHTInfoBuf) ? - sizeof(network->bssht.bdHTInfoBuf) : tmp_htinfo_len; - memcpy(network->bssht.bdHTInfoBuf, info_element->data, network->bssht.bdHTInfoLen); - } - + network->bssht.bdHTInfoLen = min_t(u16, tmp_htinfo_len, sizeof(network->bssht.bdHTInfoBuf)); + memcpy(network->bssht.bdHTInfoBuf, info_element->data, network->bssht.bdHTInfoLen); } } From eae10b8ea5c08115d0eccd8adc89794c5a41727a Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 13 Apr 2015 23:47:31 +0200 Subject: [PATCH 0172/1163] staging: rtl8192e: Fix DEEP_INDENTATION warnings in rtl_dm.c Separate parts of dm_TXPowerTrackingCallback_TSSI() into two new functions: - dm_tx_update_tssi_weak_signal() - dm_tx_update_tssi_strong_signal() Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 180 +++++++++++---------- 1 file changed, 95 insertions(+), 85 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c index 9de584639c56..ba69157a86b4 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c @@ -542,6 +542,97 @@ static u8 CCKSwingTable_Ch14[CCK_Table_length][8] = { #define Tssi_Report_Value2 0x13e #define FW_Busy_Flag 0x13f +static void dm_tx_update_tssi_weak_signal(struct net_device *dev, u8 RF_Type) +{ + struct r8192_priv *p = rtllib_priv(dev); + + if (RF_Type == RF_2T4R) { + if ((p->rfa_txpowertrackingindex > 0) && + (p->rfc_txpowertrackingindex > 0)) { + p->rfa_txpowertrackingindex--; + if (p->rfa_txpowertrackingindex_real > 4) { + p->rfa_txpowertrackingindex_real--; + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, + bMaskDWord, + dm_tx_bb_gain[p->rfa_txpowertrackingindex_real]); + } + + p->rfc_txpowertrackingindex--; + if (p->rfc_txpowertrackingindex_real > 4) { + p->rfc_txpowertrackingindex_real--; + rtl8192_setBBreg(dev, + rOFDM0_XCTxIQImbalance, + bMaskDWord, + dm_tx_bb_gain[p->rfc_txpowertrackingindex_real]); + } + } else { + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, + bMaskDWord, + dm_tx_bb_gain[4]); + rtl8192_setBBreg(dev, + rOFDM0_XCTxIQImbalance, + bMaskDWord, dm_tx_bb_gain[4]); + } + } else { + if (p->rfa_txpowertrackingindex > 0) { + p->rfa_txpowertrackingindex--; + if (p->rfa_txpowertrackingindex_real > 4) { + p->rfa_txpowertrackingindex_real--; + rtl8192_setBBreg(dev, + rOFDM0_XATxIQImbalance, + bMaskDWord, + dm_tx_bb_gain[p->rfa_txpowertrackingindex_real]); + } + } else { + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, + bMaskDWord, dm_tx_bb_gain[4]); + } + } +} + +static void dm_tx_update_tssi_strong_signal(struct net_device *dev, u8 RF_Type) +{ + struct r8192_priv *p = rtllib_priv(dev); + + if (RF_Type == RF_2T4R) { + if ((p->rfa_txpowertrackingindex < TxBBGainTableLength - 1) && + (p->rfc_txpowertrackingindex < TxBBGainTableLength - 1)) { + p->rfa_txpowertrackingindex++; + p->rfa_txpowertrackingindex_real++; + rtl8192_setBBreg(dev, + rOFDM0_XATxIQImbalance, + bMaskDWord, + dm_tx_bb_gain[p->rfa_txpowertrackingindex_real]); + p->rfc_txpowertrackingindex++; + p->rfc_txpowertrackingindex_real++; + rtl8192_setBBreg(dev, + rOFDM0_XCTxIQImbalance, + bMaskDWord, + dm_tx_bb_gain[p->rfc_txpowertrackingindex_real]); + } else { + rtl8192_setBBreg(dev, + rOFDM0_XATxIQImbalance, + bMaskDWord, + dm_tx_bb_gain[TxBBGainTableLength - 1]); + rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, + bMaskDWord, + dm_tx_bb_gain[TxBBGainTableLength - 1]); + } + } else { + if (p->rfa_txpowertrackingindex < (TxBBGainTableLength - 1)) { + p->rfa_txpowertrackingindex++; + p->rfa_txpowertrackingindex_real++; + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, + bMaskDWord, + dm_tx_bb_gain[p->rfa_txpowertrackingindex_real]); + } else { + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, + bMaskDWord, + dm_tx_bb_gain[TxBBGainTableLength - 1]); + } + } +} + static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -672,92 +763,11 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev) priv->CCKPresentAttentuation); return; } - if (Avg_TSSI_Meas_from_driver < TSSI_13dBm - E_FOR_TX_POWER_TRACK) { - if (RF_Type == RF_2T4R) { + if (Avg_TSSI_Meas_from_driver < TSSI_13dBm - E_FOR_TX_POWER_TRACK) + dm_tx_update_tssi_weak_signal(dev, RF_Type); + else + dm_tx_update_tssi_strong_signal(dev, RF_Type); - if ((priv->rfa_txpowertrackingindex > 0) && - (priv->rfc_txpowertrackingindex > 0)) { - priv->rfa_txpowertrackingindex--; - if (priv->rfa_txpowertrackingindex_real > 4) { - priv->rfa_txpowertrackingindex_real--; - rtl8192_setBBreg(dev, - rOFDM0_XATxIQImbalance, - bMaskDWord, - dm_tx_bb_gain[priv->rfa_txpowertrackingindex_real]); - } - - priv->rfc_txpowertrackingindex--; - if (priv->rfc_txpowertrackingindex_real > 4) { - priv->rfc_txpowertrackingindex_real--; - rtl8192_setBBreg(dev, - rOFDM0_XCTxIQImbalance, - bMaskDWord, - dm_tx_bb_gain[priv->rfc_txpowertrackingindex_real]); - } - } else { - rtl8192_setBBreg(dev, - rOFDM0_XATxIQImbalance, - bMaskDWord, - dm_tx_bb_gain[4]); - rtl8192_setBBreg(dev, - rOFDM0_XCTxIQImbalance, - bMaskDWord, dm_tx_bb_gain[4]); - } - } else { - if (priv->rfa_txpowertrackingindex > 0) { - priv->rfa_txpowertrackingindex--; - if (priv->rfa_txpowertrackingindex_real > 4) { - priv->rfa_txpowertrackingindex_real--; - rtl8192_setBBreg(dev, - rOFDM0_XATxIQImbalance, - bMaskDWord, - dm_tx_bb_gain[priv->rfa_txpowertrackingindex_real]); - } - } else - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, - bMaskDWord, dm_tx_bb_gain[4]); - - } - } else { - if (RF_Type == RF_2T4R) { - if ((priv->rfa_txpowertrackingindex < - TxBBGainTableLength - 1) && - (priv->rfc_txpowertrackingindex < - TxBBGainTableLength - 1)) { - priv->rfa_txpowertrackingindex++; - priv->rfa_txpowertrackingindex_real++; - rtl8192_setBBreg(dev, - rOFDM0_XATxIQImbalance, - bMaskDWord, - dm_tx_bb_gain[priv->rfa_txpowertrackingindex_real]); - priv->rfc_txpowertrackingindex++; - priv->rfc_txpowertrackingindex_real++; - rtl8192_setBBreg(dev, - rOFDM0_XCTxIQImbalance, - bMaskDWord, - dm_tx_bb_gain[priv->rfc_txpowertrackingindex_real]); - } else { - rtl8192_setBBreg(dev, - rOFDM0_XATxIQImbalance, - bMaskDWord, - dm_tx_bb_gain[TxBBGainTableLength - 1]); - rtl8192_setBBreg(dev, - rOFDM0_XCTxIQImbalance, - bMaskDWord, dm_tx_bb_gain[TxBBGainTableLength - 1]); - } - } else { - if (priv->rfa_txpowertrackingindex < (TxBBGainTableLength - 1)) { - priv->rfa_txpowertrackingindex++; - priv->rfa_txpowertrackingindex_real++; - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, - bMaskDWord, - dm_tx_bb_gain[priv->rfa_txpowertrackingindex_real]); - } else - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, - bMaskDWord, - dm_tx_bb_gain[TxBBGainTableLength - 1]); - } - } if (RF_Type == RF_2T4R) { priv->CCKPresentAttentuation_difference = priv->rfa_txpowertrackingindex - priv->rfa_txpowertracking_default; From a569f22007f51db92304af05cda096ae1ad8844f Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 13 Apr 2015 23:47:32 +0200 Subject: [PATCH 0173/1163] staging: rtl8192e: Fix DeviceID in rtl8192_pci_findadapter() rtl8192_pci_findadapter() was looking for invalid DeviceID (0x8172), instead of proper for rtl8192e/se devices (0x8192) Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c index 51f53be2de17..e8065c0ed05f 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c @@ -62,7 +62,7 @@ bool rtl8192_pci_findadapter(struct pci_dev *pdev, struct net_device *dev) priv->card_8192 = priv->ops->nic_type; - if (DeviceID == 0x8172) { + if (DeviceID == 0x8192) { switch (RevisionID) { case HAL_HW_PCI_REVISION_ID_8192PCIE: dev_info(&pdev->dev, From 954c2d8f982fe188740f11cb4a00881d5325e89e Mon Sep 17 00:00:00 2001 From: Phong Tran Date: Fri, 3 Apr 2015 21:07:01 +0700 Subject: [PATCH 0174/1163] staging: android: ion_test: unregister the misc device Add the remove() method for deregister from misc device when it's unloaded. Signed-off-by: Phong Tran Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion_test.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/staging/android/ion/ion_test.c b/drivers/staging/android/ion/ion_test.c index 3bc461cbbfa3..052d5e2177e7 100644 --- a/drivers/staging/android/ion/ion_test.c +++ b/drivers/staging/android/ion/ion_test.c @@ -261,7 +261,19 @@ static int __init ion_test_probe(struct platform_device *pdev) return 0; } +static int ion_test_remove(struct platform_device *pdev) +{ + struct ion_test_device *testdev; + + testdev = platform_get_drvdata(pdev); + if (!testdev) + return -ENODATA; + + return misc_deregister(&testdev->misc); +} + static struct platform_driver ion_test_platform_driver = { + .remove = ion_test_remove, .driver = { .name = "ion-test", }, From 81fb0b901397588d01219764adb5e674eacc4f8b Mon Sep 17 00:00:00 2001 From: Phong Tran Date: Fri, 3 Apr 2015 21:07:02 +0700 Subject: [PATCH 0175/1163] staging: android: ion_test: unregister the platform device The driver has to unregister from platform device when it's unloaded Signed-off-by: Phong Tran Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion_test.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/staging/android/ion/ion_test.c b/drivers/staging/android/ion/ion_test.c index 052d5e2177e7..7d6e6b6bc894 100644 --- a/drivers/staging/android/ion/ion_test.c +++ b/drivers/staging/android/ion/ion_test.c @@ -272,6 +272,7 @@ static int ion_test_remove(struct platform_device *pdev) return misc_deregister(&testdev->misc); } +static struct platform_device *ion_test_pdev; static struct platform_driver ion_test_platform_driver = { .remove = ion_test_remove, .driver = { @@ -281,13 +282,18 @@ static struct platform_driver ion_test_platform_driver = { static int __init ion_test_init(void) { - platform_device_register_simple("ion-test", -1, NULL, 0); + ion_test_pdev = platform_device_register_simple("ion-test", + -1, NULL, 0); + if (!ion_test_pdev) + return -ENODEV; + return platform_driver_probe(&ion_test_platform_driver, ion_test_probe); } static void __exit ion_test_exit(void) { platform_driver_unregister(&ion_test_platform_driver); + platform_device_unregister(ion_test_pdev); } module_init(ion_test_init); From ec80e2428046d022dc6cbffd674ece81513ac96d Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Thu, 16 Apr 2015 21:08:38 +0800 Subject: [PATCH 0176/1163] staging: dt3155v4l: remove unused including Remove including that don't need it. Signed-off-by: Wei Yongjun Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/dt3155v4l/dt3155v4l.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/staging/media/dt3155v4l/dt3155v4l.c index 52a8ffe560b1..1408b651f83b 100644 --- a/drivers/staging/media/dt3155v4l/dt3155v4l.c +++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c @@ -19,7 +19,6 @@ ***************************************************************************/ #include -#include #include #include #include From 95829dcbeeba19146f7321658d311146399bef5d Mon Sep 17 00:00:00 2001 From: Edward Lipinsky Date: Sat, 18 Apr 2015 09:35:19 -0700 Subject: [PATCH 0177/1163] Staging: rtl8723au: hal: Remove trailing whitespace in odm.c This patch fixes the checkpatch.pl error: ERROR: trailing whitespace Signed-off-by: Edward Lipinsky Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/odm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/hal/odm.c b/drivers/staging/rtl8723au/hal/odm.c index eb598cf8d229..f354f5e11a30 100644 --- a/drivers/staging/rtl8723au/hal/odm.c +++ b/drivers/staging/rtl8723au/hal/odm.c @@ -388,7 +388,7 @@ void odm_CommonInfoSelfInit23a(struct dm_odm_t *pDM_Odm) pDM_Odm->bCckHighPower = true; else pDM_Odm->bCckHighPower = false; - + pDM_Odm->RFPathRxEnable = rtl8723au_read32(pDM_Odm->Adapter, rOFDM0_TRxPathEnable) & 0x0F; From 3446ef56f84a9fb97b59f463fa5c77444a86ad4f Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Thu, 16 Apr 2015 23:28:01 +0200 Subject: [PATCH 0178/1163] staging: rtl8188eu: remove duplicated comments There are identical comments near the static variable declaration, around lines 118~120. Signed-off-by: Luca Ceresoli Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index 750c87b46365..61b8572c6518 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -569,8 +569,8 @@ static uint loadparam(struct adapter *padapter, struct net_device *pnetdev) registry_par->bAcceptAddbaReq = (u8)rtw_AcceptAddbaReq; registry_par->antdiv_cfg = (u8)rtw_antdiv_cfg; registry_par->antdiv_type = (u8)rtw_antdiv_type; - registry_par->hwpdn_mode = (u8)rtw_hwpdn_mode;/* 0:disable, 1:enable, 2:by EFUSE config */ - registry_par->hwpwrp_detect = (u8)rtw_hwpwrp_detect;/* 0:disable, 1:enable */ + registry_par->hwpdn_mode = (u8)rtw_hwpdn_mode; + registry_par->hwpwrp_detect = (u8)rtw_hwpwrp_detect; registry_par->hw_wps_pbc = (u8)rtw_hw_wps_pbc; registry_par->max_roaming_times = (u8)rtw_max_roaming_times; From 22a1279b84d21701a59f2407dec9ad8c0481ec8f Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Thu, 16 Apr 2015 23:28:02 +0200 Subject: [PATCH 0179/1163] staging: rtl8188eu: fix comments over 80 characters Signed-off-by: Luca Ceresoli Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 38 ++++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index 61b8572c6518..c944b149391c 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -41,7 +41,8 @@ MODULE_VERSION(DRIVERVERSION); static int rtw_chip_version; static int rtw_rfintfs = HWPI; static int rtw_lbkmode;/* RTL8712_AIR_TRX; */ -static int rtw_network_mode = Ndis802_11IBSS;/* Ndis802_11Infrastructure; infra, ad-hoc, auto */ +/* Ndis802_11Infrastructure; infra, ad-hoc, auto */ +static int rtw_network_mode = Ndis802_11IBSS; static int rtw_channel = 1;/* ad-hoc support requirement */ static int rtw_wireless_mode = WIRELESS_11BG_24N; static int rtw_vrtl_carrier_sense = AUTO_VCS; @@ -81,21 +82,37 @@ static int rtw_uapsd_acvi_en; static int rtw_uapsd_acvo_en; static int rtw_ht_enable = 1; -static int rtw_cbw40_enable = 3; /* 0 :disable, bit(0): enable 2.4g, bit(1): enable 5g */ +/* 0 :disable, bit(0): enable 2.4g, bit(1): enable 5g */ +static int rtw_cbw40_enable = 3; 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 */ + +/* 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_rx_stbc = 1; static int rtw_ampdu_amsdu;/* 0: disabled, 1:enabled, 2:auto */ -static int rtw_lowrate_two_xmit = 1;/* Use 2 path Tx to transmit MCS0~7 and legacy mode */ +/* Use 2 path Tx to transmit MCS0~7 and legacy mode */ +static int rtw_lowrate_two_xmit = 1; static int rtw_rf_config = RF_819X_MAX_TYPE; /* auto */ static int rtw_low_power; static int rtw_wifi_spec; static int rtw_channel_plan = RT_CHANNEL_DOMAIN_MAX; -static int rtw_AcceptAddbaReq = true;/* 0:Reject AP's Add BA req, 1:Accept AP's Add BA req. */ +/* 0:Reject AP's Add BA req, 1:Accept AP's Add BA req. */ +static int rtw_AcceptAddbaReq = true; static int rtw_antdiv_cfg = 2; /* 0:OFF , 1:ON, 2:decide by Efuse config */ -static int rtw_antdiv_type; /* 0:decide by efuse 1: for 88EE, 1Tx and 1RxCG are diversity.(2 Ant with SPDT), 2: for 88EE, 1Tx and 2Rx are diversity.(2 Ant, Tx and RxCG are both on aux port, RxCS is on main port), 3: for 88EE, 1Tx and 1RxCG are fixed.(1Ant, Tx and RxCG are both on aux port) */ + +/* 0: decide by efuse + * 1: for 88EE, 1Tx and 1RxCG are diversity (2 Ant with SPDT) + * 2: for 88EE, 1Tx and 2Rx are diversity (2 Ant, Tx and RxCG are both on aux + * port, RxCS is on main port) + * 3: for 88EE, 1Tx and 1RxCG are fixed (1Ant, Tx and RxCG are both on aux port) + */ +static int rtw_antdiv_type; static int rtw_enusbss;/* 0:disable, 1:enable */ @@ -117,7 +134,8 @@ static char *if2name = "wlan%d"; module_param(if2name, charp, 0644); MODULE_PARM_DESC(if2name, "The default name to allocate for second interface"); -char *rtw_initmac; /* temp mac address if users want to use instead of the mac address in Efuse */ +/* temp mac address if users want to use instead of the mac address in Efuse */ +char *rtw_initmac; module_param(rtw_initmac, charp, 0644); module_param(rtw_channel_plan, int, 0644); @@ -741,7 +759,8 @@ u32 rtw_start_drv_threads(struct adapter *padapter) if (IS_ERR(padapter->cmdThread)) _status = _FAIL; else - _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema); /* wait for cmd_thread to run */ + /* wait for cmd_thread to run */ + _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema); return _status; } @@ -931,7 +950,8 @@ u8 rtw_free_drv_sw(struct adapter *padapter) rtw_free_mlme_priv(&padapter->mlmepriv); _rtw_free_xmit_priv(&padapter->xmitpriv); - _rtw_free_sta_priv(&padapter->stapriv); /* will free bcmc_stainfo here */ + /* will free bcmc_stainfo here */ + _rtw_free_sta_priv(&padapter->stapriv); _rtw_free_recv_priv(&padapter->recvpriv); From 2ff4e79f0ed3573515a49af8f91e64d669a41dac Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Thu, 16 Apr 2015 23:28:03 +0200 Subject: [PATCH 0180/1163] staging: rtl8188eu: document enum where it is declared The comment "/* open system */" is repeated verbatim in several places where dot11AuthAlgrthm_Open is referenced, but not where it is declared. Move it to be only at its declaration. This also fixes some "line over 80 characters" checkpatch warnings. Signed-off-by: Luca Ceresoli Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_mlme.h | 2 +- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 6 +++--- drivers/staging/rtl8188eu/os_dep/mlme_linux.c | 2 +- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme.h b/drivers/staging/rtl8188eu/include/rtw_mlme.h index 3f7d1e631ef9..8c7e8a36aa13 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme.h @@ -65,7 +65,7 @@ #define _FW_UNDER_SURVEY WIFI_SITE_MONITOR enum dot11AuthAlgrthmNum { - dot11AuthAlgrthm_Open = 0, + dot11AuthAlgrthm_Open = 0, /* open system */ dot11AuthAlgrthm_Shared, dot11AuthAlgrthm_8021X, dot11AuthAlgrthm_Auto, diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 96c1c2d4a112..796c0b0c9c5a 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -1625,7 +1625,7 @@ static int rtw_wx_set_enc(struct net_device *dev, padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; - padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; authmode = Ndis802_11AuthModeOpen; padapter->securitypriv.ndisauthtype = authmode; @@ -1664,7 +1664,7 @@ static int rtw_wx_set_enc(struct net_device *dev, DBG_88E("rtw_wx_set_enc():erq->flags = 0x%x\n", erq->flags); padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */ - padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; authmode = Ndis802_11AuthModeOpen; @@ -1855,7 +1855,7 @@ static int rtw_wx_set_auth(struct net_device *dev, padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; - padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; } diff --git a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c index baff1e2661d5..64c99f2e9077 100644 --- a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c @@ -82,7 +82,7 @@ void rtw_reset_securitypriv(struct adapter *adapter) /* reset values in securitypriv */ struct security_priv *psec_priv = &adapter->securitypriv; - psec_priv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ + psec_priv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; psec_priv->dot11PrivacyAlgrthm = _NO_PRIVACY_; psec_priv->dot11PrivacyKeyIndex = 0; psec_priv->dot118021XGrpPrivacy = _NO_PRIVACY_; diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index c944b149391c..e5e9235bc093 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -800,7 +800,7 @@ static u8 rtw_init_default_value(struct adapter *padapter) psecuritypriv->binstallGrpkey = _FAIL; psecuritypriv->sw_encrypt = pregistrypriv->software_encrypt; psecuritypriv->sw_decrypt = pregistrypriv->software_decrypt; - psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ + psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_; psecuritypriv->dot11PrivacyKeyIndex = 0; psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_; From 6c4743f7d639cdc810e6536a7d2832aab433ad08 Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Thu, 16 Apr 2015 23:28:04 +0200 Subject: [PATCH 0181/1163] staging: rtl8188eu: simplify nested ifs Signed-off-by: Luca Ceresoli Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index e5e9235bc093..9cd3a842cf1f 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -224,11 +224,9 @@ void rtw_proc_init_one(struct net_device *dev) rtw_proc); dir_dev = padapter->dir_dev; if (dir_dev == NULL) { - if (rtw_proc_cnt == 0) { - if (rtw_proc) { - remove_proc_entry(rtw_proc_name, init_net.proc_net); - rtw_proc = NULL; - } + if (rtw_proc_cnt == 0 && rtw_proc) { + remove_proc_entry(rtw_proc_name, init_net.proc_net); + rtw_proc = NULL; } pr_info("Unable to create dir_dev directory\n"); From 471450531c3942d202680f82055f96a8d74c167f Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Thu, 16 Apr 2015 23:28:05 +0200 Subject: [PATCH 0182/1163] staging: rtl8188eu: fix lines over 80 characters Signed-off-by: Luca Ceresoli Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index 9cd3a842cf1f..ba7565f57e26 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -205,13 +205,16 @@ void rtw_proc_init_one(struct net_device *dev) if (rtw_proc == NULL) { memcpy(rtw_proc_name, DRV_NAME, sizeof(DRV_NAME)); - rtw_proc = create_proc_entry(rtw_proc_name, S_IFDIR, init_net.proc_net); + rtw_proc = create_proc_entry(rtw_proc_name, S_IFDIR, + init_net.proc_net); if (rtw_proc == NULL) { DBG_88E(KERN_ERR "Unable to create rtw_proc directory\n"); return; } - entry = create_proc_read_entry("ver_info", S_IFREG | S_IRUGO, rtw_proc, proc_get_drv_version, dev); + entry = create_proc_read_entry("ver_info", S_IFREG | S_IRUGO, + rtw_proc, proc_get_drv_version, + dev); if (!entry) { pr_info("Unable to create_proc_read_entry!\n"); return; @@ -376,15 +379,17 @@ void rtw_proc_init_one(struct net_device *dev) rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); if ((RF_1T2R == rf_type) || (RF_1T1R == rf_type)) { - entry = create_proc_read_entry("rf_reg_dump3", S_IFREG | S_IRUGO, - dir_dev, proc_get_rf_reg_dump3, dev); + entry = create_proc_read_entry("rf_reg_dump3", + S_IFREG | S_IRUGO, dir_dev, + proc_get_rf_reg_dump3, dev); if (!entry) { pr_info("Unable to create_proc_read_entry!\n"); return; } - entry = create_proc_read_entry("rf_reg_dump4", S_IFREG | S_IRUGO, - dir_dev, proc_get_rf_reg_dump4, dev); + entry = create_proc_read_entry("rf_reg_dump4", + S_IFREG | S_IRUGO, dir_dev, + proc_get_rf_reg_dump4, dev); if (!entry) { pr_info("Unable to create_proc_read_entry!\n"); return; @@ -753,7 +758,8 @@ u32 rtw_start_drv_threads(struct adapter *padapter) RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_start_drv_threads\n")); - padapter->cmdThread = kthread_run(rtw_cmd_thread, padapter, "RTW_CMD_THREAD"); + padapter->cmdThread = kthread_run(rtw_cmd_thread, padapter, + "RTW_CMD_THREAD"); if (IS_ERR(padapter->cmdThread)) _status = _FAIL; else From 2f13617a35d9b13e0fe4e5ba27214de4b7fdd9eb Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Thu, 16 Apr 2015 23:28:06 +0200 Subject: [PATCH 0183/1163] staging: rtl8188eu: remove useless comment "step 2" does mean much as there is no "step 1" stated anywhere... Signed-off-by: Luca Ceresoli Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index ba7565f57e26..c193f40aadaf 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -746,7 +746,6 @@ struct net_device *rtw_init_netdev(struct adapter *old_padapter) pnetdev->watchdog_timeo = HZ*3; /* 3 second timeout */ pnetdev->wireless_handlers = (struct iw_handler_def *)&rtw_handlers_def; - /* step 2. */ loadparam(padapter, pnetdev); return pnetdev; From 4b248ab2dd818cc0cec819719cf24c838194685a Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Thu, 16 Apr 2015 23:28:07 +0200 Subject: [PATCH 0184/1163] staging: rtl8188eu: remove commented code This code is commented since the initial commit. Probably it is a remnant of old code. Signed-off-by: Luca Ceresoli Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index c193f40aadaf..78b5ad0528f0 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -622,8 +622,8 @@ static struct net_device_stats *rtw_net_get_stats(struct net_device *pnetdev) struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); struct recv_priv *precvpriv = &(padapter->recvpriv); - padapter->stats.tx_packets = pxmitpriv->tx_pkts;/* pxmitpriv->tx_pkts++; */ - padapter->stats.rx_packets = precvpriv->rx_pkts;/* precvpriv->rx_pkts++; */ + padapter->stats.tx_packets = pxmitpriv->tx_pkts; + padapter->stats.rx_packets = precvpriv->rx_pkts; padapter->stats.tx_dropped = pxmitpriv->tx_drop; padapter->stats.rx_dropped = precvpriv->rx_drop; padapter->stats.tx_bytes = pxmitpriv->tx_bytes; From 6c20d83b3d756233cc3cdf4fb2f5771ceae3d921 Mon Sep 17 00:00:00 2001 From: Binbin Zhou Date: Wed, 22 Apr 2015 11:37:26 +0800 Subject: [PATCH 0185/1163] staging: sm750: Fix the Makefile option error The sm750fb's Kconfig option is CONFIG_FB_SM750, not CONFIG_FB_SM7XX. Thus fix it to make the sm750fb can be built successfully. Signed-off-by: Binbin Zhou Reviewed-by: Huacai Chen Acked-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 2bbd1bf04c55..a12221f086c2 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -23,7 +23,7 @@ obj-$(CONFIG_VT6656) += vt6656/ obj-$(CONFIG_VME_BUS) += vme/ obj-$(CONFIG_IIO) += iio/ obj-$(CONFIG_FB_SM7XX) += sm7xxfb/ -obj-$(CONFIG_FB_SM7XX) += sm750fb/ +obj-$(CONFIG_FB_SM750) += sm750fb/ obj-$(CONFIG_FB_XGI) += xgifb/ obj-$(CONFIG_USB_EMXX) += emxx_udc/ obj-$(CONFIG_FT1000) += ft1000/ From 2b9a9d49b30d403191ac00d04678720a4f600ecd Mon Sep 17 00:00:00 2001 From: "Gujulan Elango, Hari Prasath (H.)" Date: Thu, 23 Apr 2015 13:03:07 +0000 Subject: [PATCH 0186/1163] staging: fsl-mc: Remove redundant initalization of the .owner field This patch removes the redundant static initialization of the .owner field from this driver as it is being overidden by the call from the platform driver register Signed-off-by: Hari Prasath Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-mc/bus/mc-bus.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c b/drivers/staging/fsl-mc/bus/mc-bus.c index 23512d096427..766a65959b01 100644 --- a/drivers/staging/fsl-mc/bus/mc-bus.c +++ b/drivers/staging/fsl-mc/bus/mc-bus.c @@ -713,7 +713,6 @@ MODULE_DEVICE_TABLE(of, fsl_mc_bus_match_table); static struct platform_driver fsl_mc_bus_driver = { .driver = { .name = "fsl_mc_bus", - .owner = THIS_MODULE, .pm = NULL, .of_match_table = fsl_mc_bus_match_table, }, From cf376ec0ee5c2078d99a60aadd742232f725b451 Mon Sep 17 00:00:00 2001 From: "Gujulan Elango, Hari Prasath (H.)" Date: Fri, 24 Apr 2015 06:58:11 +0000 Subject: [PATCH 0187/1163] staging: gsc_hdpi: Remove dead code This patch removes commented code from this driver. Signed-off-by: Hari Prasath Gujulan Elango Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/gsc_hpdi.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index 3cb6409c4f01..d9715ea1e2da 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -135,13 +135,6 @@ static const struct hpdi_board hpdi_boards[] = { .device_id = PCI_DEVICE_ID_PLX_9080, .subdevice_id = 0x2400, }, -#if 0 - { - .name = "pxi-hpdi32", - .device_id = 0x9656, - .subdevice_id = 0x2705, - }, -#endif }; struct hpdi_private { From cd14ad8be7c521db39f031ab99393360eac553ce Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Thu, 23 Apr 2015 19:08:16 +0530 Subject: [PATCH 0188/1163] staging: sm7xxfb: use framebuffer_alloc and release use the standard framebuffer_alloc() and framebuffer_release() instead of custom defined function. for making that change we had to change a member of the private structure from a variable to pointer and had to touch almost all places of the file. since fb was changed into a pointer so all instance of "sfb->fb." has been changed into "sfb->fb->". now we will get build warning about smtc_alloc_fb_info() and smtc_free_fb_info() to be unused which will be removed in the next patch of the series. Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm7xxfb/sm7xxfb.c | 208 ++++++++++++++++-------------- 1 file changed, 110 insertions(+), 98 deletions(-) diff --git a/drivers/staging/sm7xxfb/sm7xxfb.c b/drivers/staging/sm7xxfb/sm7xxfb.c index 77f51a075004..27f339fe483d 100644 --- a/drivers/staging/sm7xxfb/sm7xxfb.c +++ b/drivers/staging/sm7xxfb/sm7xxfb.c @@ -39,7 +39,7 @@ */ struct smtcfb_info { struct pci_dev *pdev; - struct fb_info fb; + struct fb_info *fb; u16 chip_id; u8 chip_rev_id; @@ -249,19 +249,20 @@ static int smtc_setcolreg(unsigned regno, unsigned red, unsigned green, if (regno > 255) return 1; - switch (sfb->fb.fix.visual) { + switch (sfb->fb->fix.visual) { case FB_VISUAL_DIRECTCOLOR: case FB_VISUAL_TRUECOLOR: /* * 16/32 bit true-colour, use pseudo-palette for 16 base color */ if (regno < 16) { - if (sfb->fb.var.bits_per_pixel == 16) { - u32 *pal = sfb->fb.pseudo_palette; + if (sfb->fb->var.bits_per_pixel == 16) { + u32 *pal = sfb->fb->pseudo_palette; - val = chan_to_field(red, &sfb->fb.var.red); - val |= chan_to_field(green, &sfb->fb.var.green); - val |= chan_to_field(blue, &sfb->fb.var.blue); + val = chan_to_field(red, &sfb->fb->var.red); + val |= chan_to_field(green, + &sfb->fb->var.green); + val |= chan_to_field(blue, &sfb->fb->var.blue); #ifdef __BIG_ENDIAN pal[regno] = ((red & 0xf800) >> 8) | @@ -272,11 +273,12 @@ static int smtc_setcolreg(unsigned regno, unsigned red, unsigned green, pal[regno] = val; #endif } else { - u32 *pal = sfb->fb.pseudo_palette; + u32 *pal = sfb->fb->pseudo_palette; - val = chan_to_field(red, &sfb->fb.var.red); - val |= chan_to_field(green, &sfb->fb.var.green); - val |= chan_to_field(blue, &sfb->fb.var.blue); + val = chan_to_field(red, &sfb->fb->var.red); + val |= chan_to_field(green, + &sfb->fb->var.green); + val |= chan_to_field(blue, &sfb->fb->var.blue); #ifdef __BIG_ENDIAN val = (val & 0xff00ff00 >> 8) | @@ -472,13 +474,13 @@ static void sm7xx_set_timing(struct smtcfb_info *sfb) u32 m_nscreenstride; dev_dbg(&sfb->pdev->dev, - "sfb->width=%d sfb->height=%d sfb->fb.var.bits_per_pixel=%d sfb->hz=%d\n", - sfb->width, sfb->height, sfb->fb.var.bits_per_pixel, sfb->hz); + "sfb->width=%d sfb->height=%d sfb->fb->var.bits_per_pixel=%d sfb->hz=%d\n", + sfb->width, sfb->height, sfb->fb->var.bits_per_pixel, sfb->hz); for (j = 0; j < numvgamodes; j++) { if (vgamode[j].mmsizex == sfb->width && vgamode[j].mmsizey == sfb->height && - vgamode[j].bpp == sfb->fb.var.bits_per_pixel && + vgamode[j].bpp == sfb->fb->var.bits_per_pixel && vgamode[j].hz == sfb->hz) { dev_dbg(&sfb->pdev->dev, "vgamode[j].mmsizex=%d vgamode[j].mmSizeY=%d vgamode[j].bpp=%d vgamode[j].hz=%d\n", @@ -551,8 +553,8 @@ static void sm7xx_set_timing(struct smtcfb_info *sfb) /* set data width */ m_nscreenstride = - (sfb->width * sfb->fb.var.bits_per_pixel) / 64; - switch (sfb->fb.var.bits_per_pixel) { + (sfb->width * sfb->fb->var.bits_per_pixel) / 64; + switch (sfb->fb->var.bits_per_pixel) { case 8: writel(0x0, sfb->vp_regs + 0x0); break; @@ -583,52 +585,52 @@ static void smtc_set_timing(struct smtcfb_info *sfb) static void smtcfb_setmode(struct smtcfb_info *sfb) { - switch (sfb->fb.var.bits_per_pixel) { + switch (sfb->fb->var.bits_per_pixel) { case 32: - sfb->fb.fix.visual = FB_VISUAL_TRUECOLOR; - sfb->fb.fix.line_length = sfb->fb.var.xres * 4; - sfb->fb.var.red.length = 8; - sfb->fb.var.green.length = 8; - sfb->fb.var.blue.length = 8; - sfb->fb.var.red.offset = 16; - sfb->fb.var.green.offset = 8; - sfb->fb.var.blue.offset = 0; + sfb->fb->fix.visual = FB_VISUAL_TRUECOLOR; + sfb->fb->fix.line_length = sfb->fb->var.xres * 4; + sfb->fb->var.red.length = 8; + sfb->fb->var.green.length = 8; + sfb->fb->var.blue.length = 8; + sfb->fb->var.red.offset = 16; + sfb->fb->var.green.offset = 8; + sfb->fb->var.blue.offset = 0; break; case 24: - sfb->fb.fix.visual = FB_VISUAL_TRUECOLOR; - sfb->fb.fix.line_length = sfb->fb.var.xres * 3; - sfb->fb.var.red.length = 8; - sfb->fb.var.green.length = 8; - sfb->fb.var.blue.length = 8; - sfb->fb.var.red.offset = 16; - sfb->fb.var.green.offset = 8; - sfb->fb.var.blue.offset = 0; + sfb->fb->fix.visual = FB_VISUAL_TRUECOLOR; + sfb->fb->fix.line_length = sfb->fb->var.xres * 3; + sfb->fb->var.red.length = 8; + sfb->fb->var.green.length = 8; + sfb->fb->var.blue.length = 8; + sfb->fb->var.red.offset = 16; + sfb->fb->var.green.offset = 8; + sfb->fb->var.blue.offset = 0; break; case 8: - sfb->fb.fix.visual = FB_VISUAL_PSEUDOCOLOR; - sfb->fb.fix.line_length = sfb->fb.var.xres; - sfb->fb.var.red.length = 3; - sfb->fb.var.green.length = 3; - sfb->fb.var.blue.length = 2; - sfb->fb.var.red.offset = 5; - sfb->fb.var.green.offset = 2; - sfb->fb.var.blue.offset = 0; + sfb->fb->fix.visual = FB_VISUAL_PSEUDOCOLOR; + sfb->fb->fix.line_length = sfb->fb->var.xres; + sfb->fb->var.red.length = 3; + sfb->fb->var.green.length = 3; + sfb->fb->var.blue.length = 2; + sfb->fb->var.red.offset = 5; + sfb->fb->var.green.offset = 2; + sfb->fb->var.blue.offset = 0; break; case 16: default: - sfb->fb.fix.visual = FB_VISUAL_TRUECOLOR; - sfb->fb.fix.line_length = sfb->fb.var.xres * 2; - sfb->fb.var.red.length = 5; - sfb->fb.var.green.length = 6; - sfb->fb.var.blue.length = 5; - sfb->fb.var.red.offset = 11; - sfb->fb.var.green.offset = 5; - sfb->fb.var.blue.offset = 0; + sfb->fb->fix.visual = FB_VISUAL_TRUECOLOR; + sfb->fb->fix.line_length = sfb->fb->var.xres * 2; + sfb->fb->var.red.length = 5; + sfb->fb->var.green.length = 6; + sfb->fb->var.blue.length = 5; + sfb->fb->var.red.offset = 11; + sfb->fb->var.green.offset = 5; + sfb->fb->var.blue.offset = 0; break; } - sfb->width = sfb->fb.var.xres; - sfb->height = sfb->fb.var.yres; + sfb->width = sfb->fb->var.xres; + sfb->height = sfb->fb->var.yres; sfb->hz = 60; smtc_set_timing(sfb); } @@ -686,12 +688,12 @@ static struct smtcfb_info *smtc_alloc_fb_info(struct pci_dev *pdev) sfb->pdev = pdev; - sfb->fb.flags = FBINFO_FLAG_DEFAULT; - sfb->fb.fbops = &smtcfb_ops; - sfb->fb.fix = smtcfb_fix; - sfb->fb.var = smtcfb_var; - sfb->fb.pseudo_palette = sfb->colreg; - sfb->fb.par = sfb; + sfb->fb->flags = FBINFO_FLAG_DEFAULT; + sfb->fb->fbops = &smtcfb_ops; + sfb->fb->fix = smtcfb_fix; + sfb->fb->var = smtcfb_var; + sfb->fb->pseudo_palette = sfb->colreg; + sfb->fb->par = sfb; return sfb; } @@ -721,20 +723,20 @@ static void smtc_unmap_mmio(struct smtcfb_info *sfb) static int smtc_map_smem(struct smtcfb_info *sfb, struct pci_dev *pdev, u_long smem_len) { - sfb->fb.fix.smem_start = pci_resource_start(pdev, 0); + sfb->fb->fix.smem_start = pci_resource_start(pdev, 0); #ifdef __BIG_ENDIAN - if (sfb->fb.var.bits_per_pixel == 32) - sfb->fb.fix.smem_start += 0x800000; + if (sfb->fb->var.bits_per_pixel == 32) + sfb->fb->fix.smem_start += 0x800000; #endif - sfb->fb.fix.smem_len = smem_len; + sfb->fb->fix.smem_len = smem_len; - sfb->fb.screen_base = sfb->lfb; + sfb->fb->screen_base = sfb->lfb; - if (!sfb->fb.screen_base) { + if (!sfb->fb->screen_base) { dev_err(&pdev->dev, - "%s: unable to map screen memory\n", sfb->fb.fix.id); + "%s: unable to map screen memory\n", sfb->fb->fix.id); return -ENOMEM; } @@ -747,9 +749,9 @@ static int smtc_map_smem(struct smtcfb_info *sfb, */ static void smtc_unmap_smem(struct smtcfb_info *sfb) { - if (sfb && sfb->fb.screen_base) { - iounmap(sfb->fb.screen_base); - sfb->fb.screen_base = NULL; + if (sfb && sfb->fb->screen_base) { + iounmap(sfb->fb->screen_base); + sfb->fb->screen_base = NULL; } } @@ -766,6 +768,7 @@ static int smtcfb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { struct smtcfb_info *sfb; + struct fb_info *info; u_long smem_size = 0x00800000; /* default 8MB */ int err; unsigned long mmio_base; @@ -784,14 +787,23 @@ static int smtcfb_pci_probe(struct pci_dev *pdev, sprintf(smtcfb_fix.id, "sm%Xfb", ent->device); - sfb = smtc_alloc_fb_info(pdev); - - if (!sfb) { + info = framebuffer_alloc(sizeof(*sfb), &pdev->dev); + if (!info) { + dev_err(&pdev->dev, "framebuffer_alloc failed\n"); err = -ENOMEM; goto failed_free; } + sfb = info->par; + sfb->fb = info; sfb->chip_id = ent->device; + sfb->pdev = pdev; + info->flags = FBINFO_FLAG_DEFAULT; + info->fbops = &smtcfb_ops; + info->fix = smtcfb_fix; + info->var = smtcfb_var; + info->pseudo_palette = sfb->colreg; + info->par = sfb; pci_set_drvdata(pdev, sfb); @@ -799,19 +811,19 @@ static int smtcfb_pci_probe(struct pci_dev *pdev, /* get mode parameter from smtc_scr_info */ if (smtc_scr_info.lfb_width != 0) { - sfb->fb.var.xres = smtc_scr_info.lfb_width; - sfb->fb.var.yres = smtc_scr_info.lfb_height; - sfb->fb.var.bits_per_pixel = smtc_scr_info.lfb_depth; + sfb->fb->var.xres = smtc_scr_info.lfb_width; + sfb->fb->var.yres = smtc_scr_info.lfb_height; + sfb->fb->var.bits_per_pixel = smtc_scr_info.lfb_depth; } else { /* default resolution 1024x600 16bit mode */ - sfb->fb.var.xres = SCREEN_X_RES; - sfb->fb.var.yres = SCREEN_Y_RES; - sfb->fb.var.bits_per_pixel = SCREEN_BPP; + sfb->fb->var.xres = SCREEN_X_RES; + sfb->fb->var.yres = SCREEN_Y_RES; + sfb->fb->var.bits_per_pixel = SCREEN_BPP; } #ifdef __BIG_ENDIAN - if (sfb->fb.var.bits_per_pixel == 24) - sfb->fb.var.bits_per_pixel = (smtc_scr_info.lfb_depth = 32); + if (sfb->fb->var.bits_per_pixel == 24) + sfb->fb->var.bits_per_pixel = (smtc_scr_info.lfb_depth = 32); #endif /* Map address and memory detection */ mmio_base = pci_resource_start(pdev, 0); @@ -820,8 +832,8 @@ static int smtcfb_pci_probe(struct pci_dev *pdev, switch (sfb->chip_id) { case 0x710: case 0x712: - sfb->fb.fix.mmio_start = mmio_base + 0x00400000; - sfb->fb.fix.mmio_len = 0x00400000; + sfb->fb->fix.mmio_start = mmio_base + 0x00400000; + sfb->fb->fix.mmio_len = 0x00400000; smem_size = SM712_VIDEOMEMORYSIZE; #ifdef __BIG_ENDIAN sfb->lfb = ioremap(mmio_base, 0x00c00000); @@ -833,7 +845,7 @@ static int smtcfb_pci_probe(struct pci_dev *pdev, sfb->dp_regs = sfb->lfb + 0x00408000; sfb->vp_regs = sfb->lfb + 0x0040c000; #ifdef __BIG_ENDIAN - if (sfb->fb.var.bits_per_pixel == 32) { + if (sfb->fb->var.bits_per_pixel == 32) { sfb->lfb += 0x800000; dev_info(&pdev->dev, "sfb->lfb=%p", sfb->lfb); } @@ -841,7 +853,7 @@ static int smtcfb_pci_probe(struct pci_dev *pdev, if (!smtc_regbaseaddress) { dev_err(&pdev->dev, "%s: unable to map memory mapped IO!", - sfb->fb.fix.id); + sfb->fb->fix.id); err = -ENOMEM; goto failed_fb; } @@ -854,13 +866,13 @@ static int smtcfb_pci_probe(struct pci_dev *pdev, smtc_seqw(0x17, 0x20); /* enable word swap */ #ifdef __BIG_ENDIAN - if (sfb->fb.var.bits_per_pixel == 32) + if (sfb->fb->var.bits_per_pixel == 32) smtc_seqw(0x17, 0x30); #endif break; case 0x720: - sfb->fb.fix.mmio_start = mmio_base; - sfb->fb.fix.mmio_len = 0x00200000; + sfb->fb->fix.mmio_start = mmio_base; + sfb->fb->fix.mmio_len = 0x00200000; smem_size = SM722_VIDEOMEMORYSIZE; sfb->dp_regs = ioremap(mmio_base, 0x00a00000); sfb->lfb = sfb->dp_regs + 0x00200000; @@ -880,25 +892,25 @@ static int smtcfb_pci_probe(struct pci_dev *pdev, } /* can support 32 bpp */ - if (15 == sfb->fb.var.bits_per_pixel) - sfb->fb.var.bits_per_pixel = 16; + if (15 == sfb->fb->var.bits_per_pixel) + sfb->fb->var.bits_per_pixel = 16; - sfb->fb.var.xres_virtual = sfb->fb.var.xres; - sfb->fb.var.yres_virtual = sfb->fb.var.yres; + sfb->fb->var.xres_virtual = sfb->fb->var.xres; + sfb->fb->var.yres_virtual = sfb->fb->var.yres; err = smtc_map_smem(sfb, pdev, smem_size); if (err) goto failed; smtcfb_setmode(sfb); - err = register_framebuffer(&sfb->fb); + err = register_framebuffer(info); if (err < 0) goto failed; dev_info(&pdev->dev, "Silicon Motion SM%X Rev%X primary display mode %dx%d-%d Init Complete.", - sfb->chip_id, sfb->chip_rev_id, sfb->fb.var.xres, - sfb->fb.var.yres, sfb->fb.var.bits_per_pixel); + sfb->chip_id, sfb->chip_rev_id, sfb->fb->var.xres, + sfb->fb->var.yres, sfb->fb->var.bits_per_pixel); return 0; @@ -908,7 +920,7 @@ failed: smtc_unmap_smem(sfb); smtc_unmap_mmio(sfb); failed_fb: - smtc_free_fb_info(sfb); + framebuffer_release(info); failed_free: pci_release_region(pdev, 0); @@ -940,8 +952,8 @@ static void smtcfb_pci_remove(struct pci_dev *pdev) sfb = pci_get_drvdata(pdev); smtc_unmap_smem(sfb); smtc_unmap_mmio(sfb); - unregister_framebuffer(&sfb->fb); - smtc_free_fb_info(sfb); + unregister_framebuffer(sfb->fb); + framebuffer_release(sfb->fb); pci_release_region(pdev, 0); pci_disable_device(pdev); } @@ -961,7 +973,7 @@ static int smtcfb_pci_suspend(struct device *device) smtc_seqw(0x69, (smtc_seqr(0x69) & 0xf7)); console_lock(); - fb_set_suspend(&sfb->fb, 1); + fb_set_suspend(sfb->fb, 1); console_unlock(); /* additionally turn off all function blocks including internal PLLs */ @@ -989,7 +1001,7 @@ static int smtcfb_pci_resume(struct device *device) /* enable PCI burst */ smtc_seqw(0x17, 0x20); #ifdef __BIG_ENDIAN - if (sfb->fb.var.bits_per_pixel == 32) + if (sfb->fb->var.bits_per_pixel == 32) smtc_seqw(0x17, 0x30); #endif break; @@ -1006,7 +1018,7 @@ static int smtcfb_pci_resume(struct device *device) smtcfb_setmode(sfb); console_lock(); - fb_set_suspend(&sfb->fb, 0); + fb_set_suspend(sfb->fb, 0); console_unlock(); return 0; From d8496fb4939962445a10e370a23c81185f242900 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Thu, 23 Apr 2015 19:08:17 +0530 Subject: [PATCH 0189/1163] staging: sm7xxfb: remove unused functions removed the smtc_alloc_fb_info() and smtc_free_fb_info() functions which were not used anymore. Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm7xxfb/sm7xxfb.c | 32 ------------------------------- 1 file changed, 32 deletions(-) diff --git a/drivers/staging/sm7xxfb/sm7xxfb.c b/drivers/staging/sm7xxfb/sm7xxfb.c index 27f339fe483d..5db26f16569c 100644 --- a/drivers/staging/sm7xxfb/sm7xxfb.c +++ b/drivers/staging/sm7xxfb/sm7xxfb.c @@ -674,38 +674,6 @@ static struct fb_ops smtcfb_ops = { #endif }; -/* - * alloc struct smtcfb_info and assign default values - */ -static struct smtcfb_info *smtc_alloc_fb_info(struct pci_dev *pdev) -{ - struct smtcfb_info *sfb; - - sfb = kzalloc(sizeof(*sfb), GFP_KERNEL); - - if (!sfb) - return NULL; - - sfb->pdev = pdev; - - sfb->fb->flags = FBINFO_FLAG_DEFAULT; - sfb->fb->fbops = &smtcfb_ops; - sfb->fb->fix = smtcfb_fix; - sfb->fb->var = smtcfb_var; - sfb->fb->pseudo_palette = sfb->colreg; - sfb->fb->par = sfb; - - return sfb; -} - -/* - * free struct smtcfb_info - */ -static void smtc_free_fb_info(struct smtcfb_info *sfb) -{ - kfree(sfb); -} - /* * Unmap in the memory mapped IO registers */ From d4855fe18e2d80ed87736fb8326e1bbd19c02dbb Mon Sep 17 00:00:00 2001 From: Guillaume Brogi Date: Sun, 26 Apr 2015 14:40:23 +0200 Subject: [PATCH 0190/1163] staging: vt6655: Checkpatch fix: lines longer than 80 columns This patch fixes lines longer than 80 columns in mac.c. 5 lines longer than 80 columns remain for the sake of readability. Signed-off-by: Guillaume Brogi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/mac.c | 45 ++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/drivers/staging/vt6655/mac.c b/drivers/staging/vt6655/mac.c index 8048b3263360..aed530f022b8 100644 --- a/drivers/staging/vt6655/mac.c +++ b/drivers/staging/vt6655/mac.c @@ -70,7 +70,8 @@ * Return Value: true if all test bits On; otherwise false * */ -bool MACbIsRegBitsOn(void __iomem *dwIoBase, unsigned char byRegOfs, unsigned char byTestBits) +bool MACbIsRegBitsOn(void __iomem *dwIoBase, unsigned char byRegOfs, + unsigned char byTestBits) { unsigned char byData; @@ -93,7 +94,8 @@ bool MACbIsRegBitsOn(void __iomem *dwIoBase, unsigned char byRegOfs, unsigned ch * Return Value: true if all test bits Off; otherwise false * */ -bool MACbIsRegBitsOff(void __iomem *dwIoBase, unsigned char byRegOfs, unsigned char byTestBits) +bool MACbIsRegBitsOff(void __iomem *dwIoBase, unsigned char byRegOfs, + unsigned char byTestBits) { unsigned char byData; @@ -218,7 +220,8 @@ void MACvSaveContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf) /* read page1 register */ for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE1; ii++) - VNSvInPortB((dwIoBase + ii), (pbyCxtBuf + MAC_MAX_CONTEXT_SIZE_PAGE0 + ii)); + VNSvInPortB((dwIoBase + ii), + (pbyCxtBuf + MAC_MAX_CONTEXT_SIZE_PAGE0 + ii)); MACvSelectPage0(dwIoBase); } @@ -244,7 +247,8 @@ void MACvRestoreContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf) MACvSelectPage1(dwIoBase); /* restore page1 */ for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE1; ii++) - VNSvOutPortB((dwIoBase + ii), *(pbyCxtBuf + MAC_MAX_CONTEXT_SIZE_PAGE0 + ii)); + VNSvOutPortB((dwIoBase + ii), + *(pbyCxtBuf + MAC_MAX_CONTEXT_SIZE_PAGE0 + ii)); MACvSelectPage0(dwIoBase); @@ -263,13 +267,18 @@ void MACvRestoreContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf) 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)); - VNSvOutPortD(dwIoBase + MAC_REG_AC0DMAPTR, *(unsigned long *)(pbyCxtBuf + MAC_REG_AC0DMAPTR)); - VNSvOutPortD(dwIoBase + MAC_REG_BCNDMAPTR, *(unsigned long *)(pbyCxtBuf + MAC_REG_BCNDMAPTR)); + VNSvOutPortD(dwIoBase + MAC_REG_TXDMAPTR0, + *(unsigned long *)(pbyCxtBuf + MAC_REG_TXDMAPTR0)); + VNSvOutPortD(dwIoBase + MAC_REG_AC0DMAPTR, + *(unsigned long *)(pbyCxtBuf + MAC_REG_AC0DMAPTR)); + VNSvOutPortD(dwIoBase + MAC_REG_BCNDMAPTR, + *(unsigned long *)(pbyCxtBuf + MAC_REG_BCNDMAPTR)); - VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR0, *(unsigned long *)(pbyCxtBuf + MAC_REG_RXDMAPTR0)); + VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR0, + *(unsigned long *)(pbyCxtBuf + MAC_REG_RXDMAPTR0)); - VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR1, *(unsigned long *)(pbyCxtBuf + MAC_REG_RXDMAPTR1)); + VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR1, + *(unsigned long *)(pbyCxtBuf + MAC_REG_RXDMAPTR1)); } /* @@ -641,7 +650,8 @@ void MACvSetCurrRx1DescAddr(void __iomem *dwIoBase, unsigned long dwCurrDescAddr * Return Value: none * */ -void MACvSetCurrTx0DescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAddr) +void MACvSetCurrTx0DescAddrEx(void __iomem *dwIoBase, + unsigned long dwCurrDescAddr) { unsigned short ww; unsigned char byData; @@ -679,7 +689,8 @@ void MACvSetCurrTx0DescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAd * */ /* TxDMA1 = AC0DMA */ -void MACvSetCurrAC0DescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAddr) +void MACvSetCurrAC0DescAddrEx(void __iomem *dwIoBase, + unsigned long dwCurrDescAddr) { unsigned short ww; unsigned char byData; @@ -703,7 +714,8 @@ void MACvSetCurrAC0DescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAd VNSvOutPortB(dwIoBase + MAC_REG_AC0DMACTL, DMACTL_RUN); } -void MACvSetCurrTXDescAddr(int iTxType, void __iomem *dwIoBase, unsigned long dwCurrDescAddr) +void MACvSetCurrTXDescAddr(int iTxType, void __iomem *dwIoBase, + unsigned long dwCurrDescAddr) { if (iTxType == TYPE_AC0DMA) MACvSetCurrAC0DescAddrEx(dwIoBase, dwCurrDescAddr); @@ -767,7 +779,8 @@ void MACvOneShotTimer1MicroSec(void __iomem *dwIoBase, unsigned int uDelayTime) VNSvOutPortB(dwIoBase + MAC_REG_TMCTL1, (TMCTL_TMD | TMCTL_TE)); } -void MACvSetMISCFifo(void __iomem *dwIoBase, unsigned short wOffset, unsigned long dwData) +void MACvSetMISCFifo(void __iomem *dwIoBase, unsigned short wOffset, + unsigned long dwData) { if (wOffset > 273) return; @@ -816,8 +829,10 @@ bool MACbPSWakeup(void __iomem *dwIoBase) * */ -void MACvSetKeyEntry(void __iomem *dwIoBase, unsigned short wKeyCtl, unsigned int uEntryIdx, - unsigned int uKeyIdx, unsigned char *pbyAddr, u32 *pdwKey, unsigned char byLocalID) +void MACvSetKeyEntry(void __iomem *dwIoBase, unsigned short wKeyCtl, + unsigned int uEntryIdx, unsigned int uKeyIdx, + unsigned char *pbyAddr, u32 *pdwKey, + unsigned char byLocalID) { unsigned short wOffset; u32 dwData; From 04fbf979b39b2805cb0da8a373f7f6e6b0e05bd9 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Mon, 27 Apr 2015 01:25:34 -0400 Subject: [PATCH 0191/1163] rtl8188eu: don't duplicate ieee80211 constants for status/reason These are all defined as a part of the standard and should not be duplicated on a per-driver basis. Use the global ones and delete the local ones. Note that a couple of them had slight wording differences, things like INVALID vs. NOT_VALID or similar, so they are aligned with the global naming conventions here, as dictated by compile testing. This isn't the totality of duplicated data removed, but it is a start. Signed-off-by: Paul Gortmaker Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 2 + drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 10 ++- drivers/staging/rtl8188eu/core/rtw_recv.c | 2 + drivers/staging/rtl8188eu/include/ieee80211.h | 29 +------ drivers/staging/rtl8188eu/include/wifi.h | 77 ------------------- .../staging/rtl8188eu/os_dep/ioctl_linux.c | 2 + 6 files changed, 13 insertions(+), 109 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index e65ee6e858a8..1d3f72800492 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -19,6 +19,8 @@ ******************************************************************************/ #define _RTW_AP_C_ +#include + #include #include #include diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index be9e34a0daef..2da2e97647d6 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -19,6 +19,8 @@ ******************************************************************************/ #define _RTW_MLME_EXT_C_ +#include + #include #include #include @@ -1048,10 +1050,10 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame pstat->wpa2_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa2_pairwise_cipher; if (!pstat->wpa2_group_cipher) - status = WLAN_STATUS_GROUP_CIPHER_NOT_VALID; + status = WLAN_STATUS_INVALID_GROUP_CIPHER; if (!pstat->wpa2_pairwise_cipher) - status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID; + status = WLAN_STATUS_INVALID_PAIRWISE_CIPHER; } else { status = WLAN_STATUS_INVALID_IE; } @@ -1069,10 +1071,10 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame pstat->wpa_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa_pairwise_cipher; if (!pstat->wpa_group_cipher) - status = WLAN_STATUS_GROUP_CIPHER_NOT_VALID; + status = WLAN_STATUS_INVALID_GROUP_CIPHER; if (!pstat->wpa_pairwise_cipher) - status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID; + status = WLAN_STATUS_INVALID_PAIRWISE_CIPHER; } else { status = WLAN_STATUS_INVALID_IE; } diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index cda725a8f9cd..8501eb898824 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -19,6 +19,8 @@ ******************************************************************************/ #define _RTW_RECV_C_ +#include + #include #include #include diff --git a/drivers/staging/rtl8188eu/include/ieee80211.h b/drivers/staging/rtl8188eu/include/ieee80211.h index 8fd35dcdbb94..b129ad148b47 100644 --- a/drivers/staging/rtl8188eu/include/ieee80211.h +++ b/drivers/staging/rtl8188eu/include/ieee80211.h @@ -493,34 +493,7 @@ struct ieee80211_snap_hdr { #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7) #define WLAN_CAPABILITY_SHORT_SLOT (1<<10) -/* Status codes */ -#define WLAN_STATUS_SUCCESS 0 -#define WLAN_STATUS_UNSPECIFIED_FAILURE 1 -#define WLAN_STATUS_CAPS_UNSUPPORTED 10 -#define WLAN_STATUS_REASSOC_NO_ASSOC 11 -#define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12 -#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13 -#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14 -#define WLAN_STATUS_CHALLENGE_FAIL 15 -#define WLAN_STATUS_AUTH_TIMEOUT 16 -#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17 -#define WLAN_STATUS_ASSOC_DENIED_RATES 18 -/* 802.11b */ -#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19 -#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20 -#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21 - -/* Reason codes */ -#define WLAN_REASON_UNSPECIFIED 1 -#define WLAN_REASON_PREV_AUTH_NOT_VALID 2 -#define WLAN_REASON_DEAUTH_LEAVING 3 -#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4 -#define WLAN_REASON_DISASSOC_AP_BUSY 5 -#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6 -#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7 -#define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8 -#define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9 -#define WLAN_REASON_JOIN_WRONG_CHANNEL 65534 +/* Non standard? Not in */ #define WLAN_REASON_EXPIRATION_CHK 65535 /* Information Element IDs */ diff --git a/drivers/staging/rtl8188eu/include/wifi.h b/drivers/staging/rtl8188eu/include/wifi.h index a89275e0e0e0..a08a2e045e59 100644 --- a/drivers/staging/rtl8188eu/include/wifi.h +++ b/drivers/staging/rtl8188eu/include/wifi.h @@ -130,35 +130,6 @@ enum WIFI_REASON_CODE { _RSON_TDLS_TEAR_UN_RSN_ = 26, }; -/* Reason codes (IEEE 802.11-2007, 7.3.1.7, Table 7-22) - -#define WLAN_REASON_UNSPECIFIED 1 -#define WLAN_REASON_PREV_AUTH_NOT_VALID 2 -#define WLAN_REASON_DEAUTH_LEAVING 3 -#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4 -#define WLAN_REASON_DISASSOC_AP_BUSY 5 -#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6 -#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7 -#define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8 -#define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9 */ -/* IEEE 802.11h */ -#define WLAN_REASON_PWR_CAPABILITY_NOT_VALID 10 -#define WLAN_REASON_SUPPORTED_CHANNEL_NOT_VALID 11 - -/* IEEE 802.11i -#define WLAN_REASON_INVALID_IE 13 -#define WLAN_REASON_MICHAEL_MIC_FAILURE 14 -#define WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT 15 -#define WLAN_REASON_GROUP_KEY_UPDATE_TIMEOUT 16 -#define WLAN_REASON_IE_IN_4WAY_DIFFERS 17 -#define WLAN_REASON_GROUP_CIPHER_NOT_VALID 18 -#define WLAN_REASON_PAIRWISE_CIPHER_NOT_VALID 19 -#define WLAN_REASON_AKMP_NOT_VALID 20 -#define WLAN_REASON_UNSUPPORTED_RSN_IE_VERSION 21 -#define WLAN_REASON_INVALID_RSN_IE_CAPAB 22 -#define WLAN_REASON_IEEE_802_1X_AUTH_FAILED 23 -#define WLAN_REASON_CIPHER_SUITE_REJECTED 24 */ - enum WIFI_STATUS_CODE { _STATS_SUCCESSFUL_ = 0, _STATS_FAILURE_ = 1, @@ -173,54 +144,6 @@ enum WIFI_STATUS_CODE { _STATS_RATE_FAIL_ = 18, }; -/* Status codes (IEEE 802.11-2007, 7.3.1.9, Table 7-23) -#define WLAN_STATUS_SUCCESS 0 -#define WLAN_STATUS_UNSPECIFIED_FAILURE 1 -#define WLAN_STATUS_CAPS_UNSUPPORTED 10 -#define WLAN_STATUS_REASSOC_NO_ASSOC 11 -#define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12 -#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13 -#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14 -#define WLAN_STATUS_CHALLENGE_FAIL 15 -#define WLAN_STATUS_AUTH_TIMEOUT 16 -#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17 -#define WLAN_STATUS_ASSOC_DENIED_RATES 18 */ - -/* entended */ -/* IEEE 802.11b */ -#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19 -#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20 -#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21 -/* IEEE 802.11h */ -#define WLAN_STATUS_SPEC_MGMT_REQUIRED 22 -#define WLAN_STATUS_PWR_CAPABILITY_NOT_VALID 23 -#define WLAN_STATUS_SUPPORTED_CHANNEL_NOT_VALID 24 -/* IEEE 802.11g */ -#define WLAN_STATUS_ASSOC_DENIED_NO_SHORT_SLOT_TIME 25 -#define WLAN_STATUS_ASSOC_DENIED_NO_ER_PBCC 26 -#define WLAN_STATUS_ASSOC_DENIED_NO_DSSS_OFDM 27 -/* IEEE 802.11w */ -#define WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY 30 -#define WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION 31 -/* IEEE 802.11i */ -#define WLAN_STATUS_INVALID_IE 40 -#define WLAN_STATUS_GROUP_CIPHER_NOT_VALID 41 -#define WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID 42 -#define WLAN_STATUS_AKMP_NOT_VALID 43 -#define WLAN_STATUS_UNSUPPORTED_RSN_IE_VERSION 44 -#define WLAN_STATUS_INVALID_RSN_IE_CAPAB 45 -#define WLAN_STATUS_CIPHER_REJECTED_PER_POLICY 46 -#define WLAN_STATUS_TS_NOT_CREATED 47 -#define WLAN_STATUS_DIRECT_LINK_NOT_ALLOWED 48 -#define WLAN_STATUS_DEST_STA_NOT_PRESENT 49 -#define WLAN_STATUS_DEST_STA_NOT_QOS_STA 50 -#define WLAN_STATUS_ASSOC_DENIED_LISTEN_INT_TOO_LARGE 51 -/* IEEE 802.11r */ -#define WLAN_STATUS_INVALID_FT_ACTION_FRAME_COUNT 52 -#define WLAN_STATUS_INVALID_PMKID 53 -#define WLAN_STATUS_INVALID_MDIE 54 -#define WLAN_STATUS_INVALID_FTIE 55 - enum WIFI_REG_DOMAIN { DOMAIN_FCC = 1, DOMAIN_IC = 2, diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 796c0b0c9c5a..38dba1435c1e 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -19,6 +19,8 @@ ******************************************************************************/ #define _IOCTL_LINUX_C_ +#include + #include #include #include From f9c40f143c257c2f3a7e90914e160f1a50f54f49 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Mon, 27 Apr 2015 01:25:35 -0400 Subject: [PATCH 0192/1163] rtl8712: don't duplicate ieee80211 constants for status/reason These are all defined as a part of the standard and should not be duplicated on a per-driver basis. Use the global ones and delete the local ones. It seems that ieee80211 was already included everywhere it was needed, since no explicit include <...> were needed to be added in order to preserve getting a successful compile. This isn't the totality of duplicated data removed, but it is a start. Signed-off-by: Paul Gortmaker Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/ieee80211.h | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/drivers/staging/rtl8712/ieee80211.h b/drivers/staging/rtl8712/ieee80211.h index 8269be80437a..6e813a9c1aa2 100644 --- a/drivers/staging/rtl8712/ieee80211.h +++ b/drivers/staging/rtl8712/ieee80211.h @@ -314,35 +314,6 @@ struct ieee80211_snap_hdr { #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7) #define WLAN_CAPABILITY_SHORT_SLOT (1<<10) -/* Status codes */ -#define WLAN_STATUS_SUCCESS 0 -#define WLAN_STATUS_UNSPECIFIED_FAILURE 1 -#define WLAN_STATUS_CAPS_UNSUPPORTED 10 -#define WLAN_STATUS_REASSOC_NO_ASSOC 11 -#define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12 -#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13 -#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14 -#define WLAN_STATUS_CHALLENGE_FAIL 15 -#define WLAN_STATUS_AUTH_TIMEOUT 16 -#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17 -#define WLAN_STATUS_ASSOC_DENIED_RATES 18 -/* 802.11b */ -#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19 -#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20 -#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21 - -/* Reason codes */ -#define WLAN_REASON_UNSPECIFIED 1 -#define WLAN_REASON_PREV_AUTH_NOT_VALID 2 -#define WLAN_REASON_DEAUTH_LEAVING 3 -#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4 -#define WLAN_REASON_DISASSOC_AP_BUSY 5 -#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6 -#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7 -#define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8 -#define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9 - - /* Information Element IDs */ #define WLAN_EID_SSID 0 #define WLAN_EID_SUPP_RATES 1 From 5c2918a5ba83c3805f96490de07aee36c16a27b6 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Mon, 27 Apr 2015 01:25:36 -0400 Subject: [PATCH 0193/1163] rtl8192u: don't trample on struct namespace In order to start reducing the duplicated code/constants/macros in this driver, we need to include to provide the defacto versions. However this driver has structs with the same name as the ones in the main include, so namespace collision prevents us from doing step #1. Since the structs actually differ in their respective fields, we can't simply delete the local ones without impacting the runtime; a conversion to use the global ones can be considered at a later date if desired. Rename the ones here with a vendor specific prefix so that we won't have the namespace collision, and hence can continue on with the cleanup. Automated conversion done with: for i in `find . -name '*.[ch]'` ; do \ sed -i 's/struct ieee80211_hdr/struct rtl_80211_hdr/g' $i ; \ done Signed-off-by: Paul Gortmaker Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/ieee80211.h | 44 ++++++------ .../rtl8192u/ieee80211/ieee80211_crypt_ccmp.c | 10 +-- .../rtl8192u/ieee80211/ieee80211_crypt_tkip.c | 26 +++---- .../staging/rtl8192u/ieee80211/ieee80211_rx.c | 68 +++++++++---------- .../rtl8192u/ieee80211/ieee80211_softmac.c | 32 ++++----- .../staging/rtl8192u/ieee80211/ieee80211_tx.c | 14 ++-- .../rtl8192u/ieee80211/rtl819x_BAProc.c | 48 ++++++------- drivers/staging/rtl8192u/r8192U_core.c | 12 ++-- 8 files changed, 127 insertions(+), 127 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index 0f53c6a97578..bdad6d07c574 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -1020,20 +1020,20 @@ enum ieee80211_mfie { /* Minimal header; can be used for passing 802.11 frames with sufficient * information to determine what type of underlying data type is actually * stored in the data. */ -struct ieee80211_hdr { +struct rtl_80211_hdr { __le16 frame_ctl; __le16 duration_id; u8 payload[0]; } __packed; -struct ieee80211_hdr_1addr { +struct rtl_80211_hdr_1addr { __le16 frame_ctl; __le16 duration_id; u8 addr1[ETH_ALEN]; u8 payload[0]; } __packed; -struct ieee80211_hdr_2addr { +struct rtl_80211_hdr_2addr { __le16 frame_ctl; __le16 duration_id; u8 addr1[ETH_ALEN]; @@ -1041,7 +1041,7 @@ struct ieee80211_hdr_2addr { u8 payload[0]; } __packed; -struct ieee80211_hdr_3addr { +struct rtl_80211_hdr_3addr { __le16 frame_ctl; __le16 duration_id; u8 addr1[ETH_ALEN]; @@ -1051,7 +1051,7 @@ struct ieee80211_hdr_3addr { u8 payload[0]; } __packed; -struct ieee80211_hdr_4addr { +struct rtl_80211_hdr_4addr { __le16 frame_ctl; __le16 duration_id; u8 addr1[ETH_ALEN]; @@ -1062,7 +1062,7 @@ struct ieee80211_hdr_4addr { u8 payload[0]; } __packed; -struct ieee80211_hdr_3addrqos { +struct rtl_80211_hdr_3addrqos { __le16 frame_ctl; __le16 duration_id; u8 addr1[ETH_ALEN]; @@ -1073,7 +1073,7 @@ struct ieee80211_hdr_3addrqos { __le16 qos_ctl; } __packed; -struct ieee80211_hdr_4addrqos { +struct rtl_80211_hdr_4addrqos { __le16 frame_ctl; __le16 duration_id; u8 addr1[ETH_ALEN]; @@ -1092,7 +1092,7 @@ struct ieee80211_info_element { } __packed; struct ieee80211_authentication { - struct ieee80211_hdr_3addr header; + struct rtl_80211_hdr_3addr header; __le16 algorithm; __le16 transaction; __le16 status; @@ -1101,18 +1101,18 @@ struct ieee80211_authentication { } __packed; struct ieee80211_disassoc { - struct ieee80211_hdr_3addr header; + struct rtl_80211_hdr_3addr header; __le16 reason; } __packed; struct ieee80211_probe_request { - struct ieee80211_hdr_3addr header; + struct rtl_80211_hdr_3addr header; /* SSID, supported rates */ struct ieee80211_info_element info_element[0]; } __packed; struct ieee80211_probe_response { - struct ieee80211_hdr_3addr header; + struct rtl_80211_hdr_3addr header; __le32 time_stamp[2]; __le16 beacon_interval; __le16 capability; @@ -1125,7 +1125,7 @@ struct ieee80211_probe_response { #define ieee80211_beacon ieee80211_probe_response struct ieee80211_assoc_request_frame { - struct ieee80211_hdr_3addr header; + struct rtl_80211_hdr_3addr header; __le16 capability; __le16 listen_interval; /* SSID, supported rates, RSN */ @@ -1133,7 +1133,7 @@ struct ieee80211_assoc_request_frame { } __packed; struct ieee80211_reassoc_request_frame { - struct ieee80211_hdr_3addr header; + struct rtl_80211_hdr_3addr header; __le16 capability; __le16 listen_interval; u8 current_ap[ETH_ALEN]; @@ -1142,7 +1142,7 @@ struct ieee80211_reassoc_request_frame { } __packed; struct ieee80211_assoc_response_frame { - struct ieee80211_hdr_3addr header; + struct rtl_80211_hdr_3addr header; __le16 capability; __le16 status; __le16 aid; @@ -1329,9 +1329,9 @@ static inline const char *eap_get_type(int type) //added by amy for reorder static inline u8 Frame_QoSTID(u8 *buf) { - struct ieee80211_hdr_3addr *hdr; + struct rtl_80211_hdr_3addr *hdr; u16 fc; - hdr = (struct ieee80211_hdr_3addr *)buf; + hdr = (struct rtl_80211_hdr_3addr *)buf; fc = le16_to_cpu(hdr->frame_ctl); return (u8)((frameqos *)(buf + (((fc & IEEE80211_FCTL_TODS)&&(fc & IEEE80211_FCTL_FROMDS))? 30 : 24)))->field.tid; } @@ -2262,17 +2262,17 @@ static inline int ieee80211_get_hdrlen(u16 fc) return hdrlen; } -static inline u8 *ieee80211_get_payload(struct ieee80211_hdr *hdr) +static inline u8 *ieee80211_get_payload(struct rtl_80211_hdr *hdr) { switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) { case IEEE80211_1ADDR_LEN: - return ((struct ieee80211_hdr_1addr *)hdr)->payload; + return ((struct rtl_80211_hdr_1addr *)hdr)->payload; case IEEE80211_2ADDR_LEN: - return ((struct ieee80211_hdr_2addr *)hdr)->payload; + return ((struct rtl_80211_hdr_2addr *)hdr)->payload; case IEEE80211_3ADDR_LEN: - return ((struct ieee80211_hdr_3addr *)hdr)->payload; + return ((struct rtl_80211_hdr_3addr *)hdr)->payload; case IEEE80211_4ADDR_LEN: - return ((struct ieee80211_hdr_4addr *)hdr)->payload; + return ((struct rtl_80211_hdr_4addr *)hdr)->payload; } return NULL; } @@ -2328,7 +2328,7 @@ extern void ieee80211_txb_free(struct ieee80211_txb *); extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats); extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, - struct ieee80211_hdr_4addr *header, + struct rtl_80211_hdr_4addr *header, struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c index 788704b800c4..a66141647f2d 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c @@ -112,7 +112,7 @@ static inline void xor_block(u8 *b, u8 *a, size_t len) static void ccmp_init_blocks(struct crypto_tfm *tfm, - struct ieee80211_hdr_4addr *hdr, + struct rtl_80211_hdr_4addr *hdr, u8 *pn, size_t dlen, u8 *b0, u8 *auth, u8 *s0) { @@ -196,7 +196,7 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) struct ieee80211_ccmp_data *key = priv; int data_len, i; u8 *pos; - struct ieee80211_hdr_4addr *hdr; + struct rtl_80211_hdr_4addr *hdr; cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); if (skb_headroom(skb) < CCMP_HDR_LEN || @@ -228,7 +228,7 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) *pos++ = key->tx_pn[0]; - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; if (!tcb_desc->bHwSec) { int blocks, last, len; @@ -270,7 +270,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; u8 keyidx, *pos; - struct ieee80211_hdr_4addr *hdr; + struct rtl_80211_hdr_4addr *hdr; cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); u8 pn[6]; @@ -279,7 +279,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) return -1; } - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; pos = skb->data + hdr_len; keyidx = pos[3]; if (!(keyidx & (1 << 5))) { diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c index e815c81b45dc..1f80c52a49c4 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c @@ -306,7 +306,7 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) struct ieee80211_tkip_data *tkey = priv; int len; u8 *pos; - struct ieee80211_hdr_4addr *hdr; + struct rtl_80211_hdr_4addr *hdr; cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); struct blkcipher_desc desc = {.tfm = tkey->tx_tfm_arc4}; int ret = 0; @@ -318,7 +318,7 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) skb->len < hdr_len) return -1; - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; if (!tcb_desc->bHwSec) { @@ -390,7 +390,7 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) u8 keyidx, *pos; u32 iv32; u16 iv16; - struct ieee80211_hdr_4addr *hdr; + struct rtl_80211_hdr_4addr *hdr; cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); struct blkcipher_desc desc = {.tfm = tkey->rx_tfm_arc4}; u8 rc4key[16]; @@ -401,7 +401,7 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (skb->len < hdr_len + 8 + 4) return -1; - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; pos = skb->data + hdr_len; keyidx = pos[3]; if (!(keyidx & (1 << 5))) { @@ -523,9 +523,9 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 *key, u8 *hdr, static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) { - struct ieee80211_hdr_4addr *hdr11; + struct rtl_80211_hdr_4addr *hdr11; - hdr11 = (struct ieee80211_hdr_4addr *) skb->data; + hdr11 = (struct rtl_80211_hdr_4addr *) skb->data; switch (le16_to_cpu(hdr11->frame_ctl) & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { case IEEE80211_FCTL_TODS: @@ -556,9 +556,9 @@ static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *pri { struct ieee80211_tkip_data *tkey = priv; u8 *pos; - struct ieee80211_hdr_4addr *hdr; + struct rtl_80211_hdr_4addr *hdr; - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; if (skb_tailroom(skb) < 8 || skb->len < hdr_len) { printk(KERN_DEBUG "Invalid packet for Michael MIC add " @@ -585,7 +585,7 @@ static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *pri } static void ieee80211_michael_mic_failure(struct net_device *dev, - struct ieee80211_hdr_4addr *hdr, + struct rtl_80211_hdr_4addr *hdr, int keyidx) { union iwreq_data wrqu; @@ -610,9 +610,9 @@ static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, { struct ieee80211_tkip_data *tkey = priv; u8 mic[8]; - struct ieee80211_hdr_4addr *hdr; + struct rtl_80211_hdr_4addr *hdr; - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; if (!tkey->key_set) return -1; @@ -629,8 +629,8 @@ static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) return -1; if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) { - struct ieee80211_hdr_4addr *hdr; - hdr = (struct ieee80211_hdr_4addr *) skb->data; + struct rtl_80211_hdr_4addr *hdr; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; printk(KERN_DEBUG "%s: Michael MIC verification failed for " "MSDU from %pM keyidx=%d\n", skb->dev ? skb->dev->name : "N/A", hdr->addr2, diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index 9fbb53d8c6bf..e833687c7371 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -47,7 +47,7 @@ static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { - struct ieee80211_hdr_4addr *hdr = (struct ieee80211_hdr_4addr *)skb->data; + struct rtl_80211_hdr_4addr *hdr = (struct rtl_80211_hdr_4addr *)skb->data; u16 fc = le16_to_cpu(hdr->frame_ctl); skb->dev = ieee->dev; @@ -94,7 +94,7 @@ ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, /* Called only as a tasklet (software IRQ) */ static struct sk_buff * ieee80211_frag_cache_get(struct ieee80211_device *ieee, - struct ieee80211_hdr_4addr *hdr) + struct rtl_80211_hdr_4addr *hdr) { struct sk_buff *skb = NULL; u16 fc = le16_to_cpu(hdr->frame_ctl); @@ -102,17 +102,17 @@ ieee80211_frag_cache_get(struct ieee80211_device *ieee, unsigned int frag = WLAN_GET_SEQ_FRAG(sc); unsigned int seq = WLAN_GET_SEQ_SEQ(sc); struct ieee80211_frag_entry *entry; - struct ieee80211_hdr_3addrqos *hdr_3addrqos; - struct ieee80211_hdr_4addrqos *hdr_4addrqos; + struct rtl_80211_hdr_3addrqos *hdr_3addrqos; + struct rtl_80211_hdr_4addrqos *hdr_4addrqos; u8 tid; if (((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) { - hdr_4addrqos = (struct ieee80211_hdr_4addrqos *)hdr; + hdr_4addrqos = (struct rtl_80211_hdr_4addrqos *)hdr; tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID; tid = UP2AC(tid); tid ++; } else if (IEEE80211_QOS_HAS_SEQ(fc)) { - hdr_3addrqos = (struct ieee80211_hdr_3addrqos *)hdr; + hdr_3addrqos = (struct rtl_80211_hdr_3addrqos *)hdr; tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & IEEE80211_QCTL_TID; tid = UP2AC(tid); tid ++; @@ -123,7 +123,7 @@ ieee80211_frag_cache_get(struct ieee80211_device *ieee, if (frag == 0) { /* Reserve enough space to fit maximum frame length */ skb = dev_alloc_skb(ieee->dev->mtu + - sizeof(struct ieee80211_hdr_4addr) + + sizeof(struct rtl_80211_hdr_4addr) + 8 /* LLC */ + 2 /* alignment */ + 8 /* WEP */ + @@ -163,23 +163,23 @@ ieee80211_frag_cache_get(struct ieee80211_device *ieee, /* Called only as a tasklet (software IRQ) */ static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee, - struct ieee80211_hdr_4addr *hdr) + struct rtl_80211_hdr_4addr *hdr) { u16 fc = le16_to_cpu(hdr->frame_ctl); u16 sc = le16_to_cpu(hdr->seq_ctl); unsigned int seq = WLAN_GET_SEQ_SEQ(sc); struct ieee80211_frag_entry *entry; - struct ieee80211_hdr_3addrqos *hdr_3addrqos; - struct ieee80211_hdr_4addrqos *hdr_4addrqos; + struct rtl_80211_hdr_3addrqos *hdr_3addrqos; + struct rtl_80211_hdr_4addrqos *hdr_4addrqos; u8 tid; if(((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) { - hdr_4addrqos = (struct ieee80211_hdr_4addrqos *)hdr; + hdr_4addrqos = (struct rtl_80211_hdr_4addrqos *)hdr; tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID; tid = UP2AC(tid); tid ++; } else if (IEEE80211_QOS_HAS_SEQ(fc)) { - hdr_3addrqos = (struct ieee80211_hdr_3addrqos *)hdr; + hdr_3addrqos = (struct rtl_80211_hdr_3addrqos *)hdr; tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & IEEE80211_QCTL_TID; tid = UP2AC(tid); tid ++; @@ -217,10 +217,10 @@ ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb, * this is not mandatory.... but seems that the probe * response parser uses it */ - struct ieee80211_hdr_3addr *hdr = (struct ieee80211_hdr_3addr *)skb->data; + struct rtl_80211_hdr_3addr *hdr = (struct rtl_80211_hdr_3addr *)skb->data; rx_stats->len = skb->len; - ieee80211_rx_mgt(ieee,(struct ieee80211_hdr_4addr *)skb->data,rx_stats); + ieee80211_rx_mgt(ieee,(struct rtl_80211_hdr_4addr *)skb->data,rx_stats); /* if ((ieee->state == IEEE80211_LINKED) && (memcmp(hdr->addr3, ieee->current_network.bssid, ETH_ALEN))) */ if ((memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN)))/* use ADDR1 to perform address matching for Management frames */ { @@ -298,13 +298,13 @@ static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee, { struct net_device *dev = ieee->dev; u16 fc, ethertype; - struct ieee80211_hdr_4addr *hdr; + struct rtl_80211_hdr_4addr *hdr; u8 *pos; if (skb->len < 24) return 0; - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; fc = le16_to_cpu(hdr->frame_ctl); /* check that the frame is unicast frame to us */ @@ -338,7 +338,7 @@ static inline int ieee80211_rx_frame_decrypt(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_crypt_data *crypt) { - struct ieee80211_hdr_4addr *hdr; + struct rtl_80211_hdr_4addr *hdr; int res, hdrlen; if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL) @@ -348,7 +348,7 @@ ieee80211_rx_frame_decrypt(struct ieee80211_device *ieee, struct sk_buff *skb, cb_desc *tcb_desc = (cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE); tcb_desc->bHwSec = 1; } - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); if (ieee->tkip_countermeasures && @@ -385,7 +385,7 @@ static inline int ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device *ieee, struct sk_buff *skb, int keyidx, struct ieee80211_crypt_data *crypt) { - struct ieee80211_hdr_4addr *hdr; + struct rtl_80211_hdr_4addr *hdr; int res, hdrlen; if (crypt == NULL || crypt->ops->decrypt_msdu == NULL) @@ -396,7 +396,7 @@ ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device *ieee, struct sk_buff *s tcb_desc->bHwSec = 1; } - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); atomic_inc(&crypt->refcnt); @@ -416,7 +416,7 @@ ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device *ieee, struct sk_buff *s /* this function is stolen from ipw2200 driver*/ #define IEEE_PACKET_RETRY_TIME (5*HZ) static int is_duplicate_packet(struct ieee80211_device *ieee, - struct ieee80211_hdr_4addr *header) + struct rtl_80211_hdr_4addr *header) { u16 fc = le16_to_cpu(header->frame_ctl); u16 sc = le16_to_cpu(header->seq_ctl); @@ -424,19 +424,19 @@ static int is_duplicate_packet(struct ieee80211_device *ieee, u16 frag = WLAN_GET_SEQ_FRAG(sc); u16 *last_seq, *last_frag; unsigned long *last_time; - struct ieee80211_hdr_3addrqos *hdr_3addrqos; - struct ieee80211_hdr_4addrqos *hdr_4addrqos; + struct rtl_80211_hdr_3addrqos *hdr_3addrqos; + struct rtl_80211_hdr_4addrqos *hdr_4addrqos; u8 tid; //TO2DS and QoS if(((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) { - hdr_4addrqos = (struct ieee80211_hdr_4addrqos *)header; + hdr_4addrqos = (struct rtl_80211_hdr_4addrqos *)header; tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID; tid = UP2AC(tid); tid ++; } else if(IEEE80211_QOS_HAS_SEQ(fc)) { //QoS - hdr_3addrqos = (struct ieee80211_hdr_3addrqos *)header; + hdr_3addrqos = (struct rtl_80211_hdr_3addrqos *)header; tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & IEEE80211_QCTL_TID; tid = UP2AC(tid); tid ++; @@ -768,10 +768,10 @@ static u8 parse_subframe(struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, struct ieee80211_rxb *rxb, u8 *src, u8 *dst) { - struct ieee80211_hdr_3addr *hdr = (struct ieee80211_hdr_3addr *)skb->data; + struct rtl_80211_hdr_3addr *hdr = (struct rtl_80211_hdr_3addr *)skb->data; u16 fc = le16_to_cpu(hdr->frame_ctl); - u16 LLCOffset= sizeof(struct ieee80211_hdr_3addr); + u16 LLCOffset= sizeof(struct rtl_80211_hdr_3addr); u16 ChkLength; bool bIsAggregateFrame = false; u16 nSubframe_Length; @@ -888,8 +888,8 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { struct net_device *dev = ieee->dev; - struct ieee80211_hdr_4addr *hdr; - //struct ieee80211_hdr_3addrqos *hdr; + struct rtl_80211_hdr_4addr *hdr; + //struct rtl_80211_hdr_3addrqos *hdr; size_t hdrlen; u16 fc, type, stype, sc; @@ -921,7 +921,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, int i; struct ieee80211_rxb *rxb = NULL; // cheat the the hdr type - hdr = (struct ieee80211_hdr_4addr *)skb->data; + hdr = (struct rtl_80211_hdr_4addr *)skb->data; stats = &ieee->stats; if (skb->len < 10) { @@ -1156,7 +1156,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, } - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; /* skb: hdr + (possibly fragmented) plaintext payload */ // PR: FIXME: hostap has additional conditions in the "if" below: @@ -1209,7 +1209,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, /* this was the last fragment and the frame will be * delivered, so remove skb from fragment cache */ skb = frag_skb; - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; ieee80211_frag_cache_invalidate(ieee, hdr); } @@ -1226,7 +1226,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, ieee->LinkDetectInfo.NumRecvDataInPeriod++; ieee->LinkDetectInfo.NumRxOkInPeriod++; - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) { if (/*ieee->ieee802_1x &&*/ ieee80211_is_eapol_frame(ieee, skb, hdrlen)) { @@ -2612,7 +2612,7 @@ static inline void ieee80211_process_probe_response( } void ieee80211_rx_mgt(struct ieee80211_device *ieee, - struct ieee80211_hdr_4addr *header, + struct rtl_80211_hdr_4addr *header, struct ieee80211_rx_stats *stats) { switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index c2388812d4fd..d2e8b125b989 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -222,8 +222,8 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee { unsigned long flags; short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; - struct ieee80211_hdr_3addr *header= - (struct ieee80211_hdr_3addr *) skb->data; + struct rtl_80211_hdr_3addr *header= + (struct rtl_80211_hdr_3addr *) skb->data; cb_desc *tcb_desc = (cb_desc *)(skb->cb + 8); spin_lock_irqsave(&ieee->lock, flags); @@ -289,8 +289,8 @@ inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *i { short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; - struct ieee80211_hdr_3addr *header = - (struct ieee80211_hdr_3addr *) skb->data; + struct rtl_80211_hdr_3addr *header = + (struct rtl_80211_hdr_3addr *) skb->data; if(single){ @@ -928,14 +928,14 @@ static struct sk_buff *ieee80211_null_func(struct ieee80211_device *ieee, short pwr) { struct sk_buff *skb; - struct ieee80211_hdr_3addr *hdr; + struct rtl_80211_hdr_3addr *hdr; - skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); + skb = dev_alloc_skb(sizeof(struct rtl_80211_hdr_3addr)); if (!skb) return NULL; - hdr = (struct ieee80211_hdr_3addr *)skb_put(skb,sizeof(struct ieee80211_hdr_3addr)); + hdr = (struct rtl_80211_hdr_3addr *)skb_put(skb,sizeof(struct rtl_80211_hdr_3addr)); memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN); memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN); @@ -1304,7 +1304,7 @@ static void ieee80211_auth_challenge(struct ieee80211_device *ieee, IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n"); - ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); + ieee80211_encrypt_fragment(ieee, skb, sizeof(struct rtl_80211_hdr_3addr )); softmac_mgmt_xmit(skb, ieee); mod_timer(&ieee->associate_timer, jiffies + (HZ/2)); @@ -1588,17 +1588,17 @@ static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *ssid=NULL; u8 ssidlen = 0; - struct ieee80211_hdr_3addr *header = - (struct ieee80211_hdr_3addr *) skb->data; + struct rtl_80211_hdr_3addr *header = + (struct rtl_80211_hdr_3addr *) skb->data; - if (skb->len < sizeof (struct ieee80211_hdr_3addr )) + if (skb->len < sizeof (struct rtl_80211_hdr_3addr )) return -1; /* corrupted */ memcpy(src,header->addr2, ETH_ALEN); skbend = (u8 *)skb->data + skb->len; - tag = skb->data + sizeof (struct ieee80211_hdr_3addr ); + tag = skb->data + sizeof (struct rtl_80211_hdr_3addr ); while (tag+1 < skbend){ if (*tag == 0) { @@ -1894,7 +1894,7 @@ EXPORT_SYMBOL(ieee80211_ps_tx_ack); static void ieee80211_process_action(struct ieee80211_device *ieee, struct sk_buff *skb) { - struct ieee80211_hdr *header = (struct ieee80211_hdr *)skb->data; + struct rtl_80211_hdr *header = (struct rtl_80211_hdr *)skb->data; u8 *act = ieee80211_get_payload(header); u8 tmp = 0; // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len); @@ -1985,7 +1985,7 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { - struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; + struct rtl_80211_hdr_3addr *header = (struct rtl_80211_hdr_3addr *) skb->data; u16 errcode; int aid; struct ieee80211_assoc_response_frame *assoc_resp; @@ -2243,7 +2243,7 @@ void ieee80211_wake_queue(struct ieee80211_device *ieee) unsigned long flags; struct sk_buff *skb; - struct ieee80211_hdr_3addr *header; + struct rtl_80211_hdr_3addr *header; spin_lock_irqsave(&ieee->lock, flags); if (! ieee->queue_stop) goto exit; @@ -2253,7 +2253,7 @@ void ieee80211_wake_queue(struct ieee80211_device *ieee) if (ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE) { while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ - header = (struct ieee80211_hdr_3addr *) skb->data; + header = (struct rtl_80211_hdr_3addr *) skb->data; header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c index 9f68c652fb2b..5353a45ffdff 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c @@ -194,9 +194,9 @@ int ieee80211_encrypt_fragment( if (ieee->tkip_countermeasures && crypt && crypt->ops && strcmp(crypt->ops->name, "TKIP") == 0) { if (net_ratelimit()) { - struct ieee80211_hdr_3addrqos *header; + struct rtl_80211_hdr_3addrqos *header; - header = (struct ieee80211_hdr_3addrqos *)frag->data; + header = (struct rtl_80211_hdr_3addrqos *)frag->data; printk(KERN_DEBUG "%s: TKIP countermeasures: dropped " "TX packet to %pM\n", ieee->dev->name, header->addr1); @@ -308,7 +308,7 @@ static void ieee80211_tx_query_agg_cap(struct ieee80211_device *ieee, { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; PTX_TS_RECORD pTxTs = NULL; - struct ieee80211_hdr_1addr *hdr = (struct ieee80211_hdr_1addr *)skb->data; + struct rtl_80211_hdr_1addr *hdr = (struct rtl_80211_hdr_1addr *)skb->data; if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT) return; @@ -598,14 +598,14 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); struct ieee80211_txb *txb = NULL; - struct ieee80211_hdr_3addrqos *frag_hdr; + struct rtl_80211_hdr_3addrqos *frag_hdr; int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size; unsigned long flags; struct net_device_stats *stats = &ieee->stats; int ether_type = 0, encrypt; int bytes, fc, qos_ctl = 0, hdr_len; struct sk_buff *skb_frag; - struct ieee80211_hdr_3addrqos header = { /* Ensure zero initialized */ + struct rtl_80211_hdr_3addrqos header = { /* Ensure zero initialized */ .duration_id = 0, .seq_ctl = 0, .qos_ctl = 0 @@ -787,7 +787,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) { tcb_desc->bHwSec = 0; } - frag_hdr = (struct ieee80211_hdr_3addrqos *)skb_put(skb_frag, hdr_len); + frag_hdr = (struct rtl_80211_hdr_3addrqos *)skb_put(skb_frag, hdr_len); memcpy(frag_hdr, &header, hdr_len); /* If this is not the last fragment, then add the MOREFRAGS @@ -845,7 +845,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) ieee->seq_ctrl[0]++; } }else{ - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { + if (unlikely(skb->len < sizeof(struct rtl_80211_hdr_3addr))) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index 618d2cbc049e..9ff8e056ab7f 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -110,7 +110,7 @@ void ResetBaEntry(PBA_RECORD pBA) static struct sk_buff *ieee80211_ADDBA(struct ieee80211_device *ieee, u8 *Dst, PBA_RECORD pBA, u16 StatusCode, u8 type) { struct sk_buff *skb = NULL; - struct ieee80211_hdr_3addr *BAReq = NULL; + struct rtl_80211_hdr_3addr *BAReq = NULL; u8 *tag = NULL; 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)) @@ -120,17 +120,17 @@ static struct sk_buff *ieee80211_ADDBA(struct ieee80211_device *ieee, u8 *Dst, P IEEE80211_DEBUG(IEEE80211_DL_ERR, "pBA is NULL\n"); return NULL; } - skb = dev_alloc_skb(len + sizeof( struct ieee80211_hdr_3addr)); //need to add something others? FIXME + skb = dev_alloc_skb(len + sizeof( struct rtl_80211_hdr_3addr)); //need to add something others? FIXME if (skb == NULL) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc skb for ADDBA_REQ\n"); return NULL; } - memset(skb->data, 0, sizeof( struct ieee80211_hdr_3addr)); //I wonder whether it's necessary. Apparently kernel will not do it when alloc a skb. + memset(skb->data, 0, sizeof( struct rtl_80211_hdr_3addr)); //I wonder whether it's necessary. Apparently kernel will not do it when alloc a skb. skb_reserve(skb, ieee->tx_headroom); - BAReq = ( struct ieee80211_hdr_3addr *) skb_put(skb,sizeof( struct ieee80211_hdr_3addr)); + BAReq = ( struct rtl_80211_hdr_3addr *) skb_put(skb,sizeof( struct rtl_80211_hdr_3addr)); memcpy(BAReq->addr1, Dst, ETH_ALEN); memcpy(BAReq->addr2, ieee->dev->dev_addr, ETH_ALEN); @@ -139,7 +139,7 @@ static struct sk_buff *ieee80211_ADDBA(struct ieee80211_device *ieee, u8 *Dst, P BAReq->frame_ctl = cpu_to_le16(IEEE80211_STYPE_MANAGE_ACT); //action frame - //tag += sizeof( struct ieee80211_hdr_3addr); //move to action field + //tag += sizeof( struct rtl_80211_hdr_3addr); //move to action field tag = (u8 *)skb_put(skb, 9); *tag ++= ACT_CAT_BA; *tag ++= type; @@ -195,7 +195,7 @@ static struct sk_buff *ieee80211_DELBA( { DELBA_PARAM_SET DelbaParamSet; struct sk_buff *skb = NULL; - struct ieee80211_hdr_3addr *Delba = NULL; + struct rtl_80211_hdr_3addr *Delba = NULL; u8 *tag = NULL; //len = head len + DELBA Parameter Set(2) + Reason Code(2) u16 len = 6 + ieee->tx_headroom; @@ -208,16 +208,16 @@ static struct sk_buff *ieee80211_DELBA( DelbaParamSet.field.Initiator = (TxRxSelect==TX_DIR)?1:0; DelbaParamSet.field.TID = pBA->BaParamSet.field.TID; - skb = dev_alloc_skb(len + sizeof( struct ieee80211_hdr_3addr)); //need to add something others? FIXME + skb = dev_alloc_skb(len + sizeof( struct rtl_80211_hdr_3addr)); //need to add something others? FIXME if (skb == NULL) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc skb for ADDBA_REQ\n"); return NULL; } -// memset(skb->data, 0, len+sizeof( struct ieee80211_hdr_3addr)); +// memset(skb->data, 0, len+sizeof( struct rtl_80211_hdr_3addr)); skb_reserve(skb, ieee->tx_headroom); - Delba = ( struct ieee80211_hdr_3addr *) skb_put(skb,sizeof( struct ieee80211_hdr_3addr)); + Delba = ( struct rtl_80211_hdr_3addr *) skb_put(skb,sizeof( struct rtl_80211_hdr_3addr)); memcpy(Delba->addr1, dst, ETH_ALEN); memcpy(Delba->addr2, ieee->dev->dev_addr, ETH_ALEN); @@ -333,7 +333,7 @@ static void ieee80211_send_DELBA(struct ieee80211_device *ieee, u8 *dst, ********************************************************************************************************************/ int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb) { - struct ieee80211_hdr_3addr *req = NULL; + struct rtl_80211_hdr_3addr *req = NULL; u16 rc = 0; u8 *dst = NULL, *pDialogToken = NULL, *tag = NULL; PBA_RECORD pBA = NULL; @@ -342,20 +342,20 @@ int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb) PSEQUENCE_CONTROL pBaStartSeqCtrl = NULL; PRX_TS_RECORD pTS = NULL; - if (skb->len < sizeof(struct ieee80211_hdr_3addr) + 9) { + if (skb->len < sizeof(struct rtl_80211_hdr_3addr) + 9) { IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BAREQ(%d / %zu)\n", skb->len, - (sizeof(struct ieee80211_hdr_3addr) + 9)); + (sizeof(struct rtl_80211_hdr_3addr) + 9)); return -1; } IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len); - req = (struct ieee80211_hdr_3addr *) skb->data; + req = (struct rtl_80211_hdr_3addr *) skb->data; tag = (u8 *)req; dst = (u8 *)(&req->addr2[0]); - tag += sizeof(struct ieee80211_hdr_3addr); + tag += sizeof(struct rtl_80211_hdr_3addr); pDialogToken = tag + 2; //category+action pBaParamSet = (PBA_PARAM_SET)(tag + 3); //+DialogToken pBaTimeoutVal = (u16 *)(tag + 5); @@ -435,7 +435,7 @@ OnADDBAReq_Fail: ********************************************************************************************************************/ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb) { - struct ieee80211_hdr_3addr *rsp = NULL; + struct rtl_80211_hdr_3addr *rsp = NULL; PBA_RECORD pPendingBA, pAdmittedBA; PTX_TS_RECORD pTS = NULL; u8 *dst = NULL, *pDialogToken = NULL, *tag = NULL; @@ -443,17 +443,17 @@ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb) PBA_PARAM_SET pBaParamSet = NULL; u16 ReasonCode; - if (skb->len < sizeof(struct ieee80211_hdr_3addr) + 9) { + if (skb->len < sizeof(struct rtl_80211_hdr_3addr) + 9) { IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BARSP(%d / %zu)\n", skb->len, - (sizeof(struct ieee80211_hdr_3addr) + 9)); + (sizeof(struct rtl_80211_hdr_3addr) + 9)); return -1; } - rsp = (struct ieee80211_hdr_3addr *)skb->data; + rsp = (struct rtl_80211_hdr_3addr *)skb->data; tag = (u8 *)rsp; dst = (u8 *)(&rsp->addr2[0]); - tag += sizeof(struct ieee80211_hdr_3addr); + tag += sizeof(struct rtl_80211_hdr_3addr); pDialogToken = tag + 2; pStatusCode = (u16 *)(tag + 3); pBaParamSet = (PBA_PARAM_SET)(tag + 5); @@ -569,16 +569,16 @@ OnADDBARsp_Reject: ********************************************************************************************************************/ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb) { - struct ieee80211_hdr_3addr *delba = NULL; + struct rtl_80211_hdr_3addr *delba = NULL; PDELBA_PARAM_SET pDelBaParamSet = NULL; u16 *pReasonCode = NULL; u8 *dst = NULL; - if (skb->len < sizeof(struct ieee80211_hdr_3addr) + 6) { + if (skb->len < sizeof(struct rtl_80211_hdr_3addr) + 6) { IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in DELBA(%d / %zu)\n", skb->len, - (sizeof(struct ieee80211_hdr_3addr) + 6)); + (sizeof(struct rtl_80211_hdr_3addr) + 6)); return -1; } @@ -590,9 +590,9 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb) } IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len); - delba = (struct ieee80211_hdr_3addr *)skb->data; + delba = (struct rtl_80211_hdr_3addr *)skb->data; dst = (u8 *)(&delba->addr2[0]); - delba += sizeof(struct ieee80211_hdr_3addr); + delba += sizeof(struct rtl_80211_hdr_3addr); pDelBaParamSet = (PDELBA_PARAM_SET)(delba+2); pReasonCode = (u16 *)(delba+4); diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 134332234ab9..b852396d21e6 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -3711,10 +3711,10 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, static u32 slide_beacon_adc_pwdb_index, slide_beacon_adc_pwdb_statistics; static u32 last_beacon_adc_pwdb; - struct ieee80211_hdr_3addr *hdr; + struct rtl_80211_hdr_3addr *hdr; u16 sc; unsigned int frag, seq; - hdr = (struct ieee80211_hdr_3addr *)buffer; + hdr = (struct rtl_80211_hdr_3addr *)buffer; sc = le16_to_cpu(hdr->seq_ctl); frag = WLAN_GET_SEQ_FRAG(sc); seq = WLAN_GET_SEQ_SEQ(sc); @@ -4205,7 +4205,7 @@ static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb, bool bpacket_match_bssid, bpacket_toself; bool bPacketBeacon = false, bToSelfBA = false; static struct ieee80211_rx_stats previous_stats; - struct ieee80211_hdr_3addr *hdr;//by amy + struct rtl_80211_hdr_3addr *hdr;//by amy u16 fc, type; // Get Signal Quality for only RX data queue (but not command queue) @@ -4216,7 +4216,7 @@ static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb, /* Get MAC frame start address. */ tmp_buf = (u8 *)skb->data; - hdr = (struct ieee80211_hdr_3addr *)tmp_buf; + hdr = (struct rtl_80211_hdr_3addr *)tmp_buf; fc = le16_to_cpu(hdr->frame_ctl); type = WLAN_FC_GET_TYPE(fc); praddr = hdr->addr1; @@ -4487,7 +4487,7 @@ static void rtl8192_rx_nomal(struct sk_buff *skb) .freq = IEEE80211_24GHZ_BAND, }; u32 rx_pkt_len = 0; - struct ieee80211_hdr_1addr *ieee80211_hdr = NULL; + struct rtl_80211_hdr_1addr *ieee80211_hdr = NULL; bool unicast_packet = false; /* 20 is for ps-poll */ @@ -4500,7 +4500,7 @@ static void rtl8192_rx_nomal(struct sk_buff *skb) skb_trim(skb, skb->len - 4/*sCrcLng*/); rx_pkt_len = skb->len; - ieee80211_hdr = (struct ieee80211_hdr_1addr *)skb->data; + ieee80211_hdr = (struct rtl_80211_hdr_1addr *)skb->data; unicast_packet = false; if (is_broadcast_ether_addr(ieee80211_hdr->addr1)) { //TODO From d140d6a15b9d88ac89f4a83c944ab67656fa4b50 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Mon, 27 Apr 2015 01:25:37 -0400 Subject: [PATCH 0194/1163] rtl8192u: promote auth_mode to a full 8 bits Currently LEAP is defined to two locally but the identically named global constant is 128 in . In order for us to switch over to using the global value, we need to adjust the local storage which is currently not enough to hold the larger value. This is now consistent with the similar struct used in drivers/net/wireless/ipw2x00/libipw.h and other drivers. Signed-off-by: Paul Gortmaker Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index bdad6d07c574..f6db98c7824c 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -649,7 +649,7 @@ struct ieee80211_snap_hdr { /* Authentication algorithms */ #define WLAN_AUTH_OPEN 0 #define WLAN_AUTH_SHARED_KEY 1 -#define WLAN_AUTH_LEAP 2 +#define WLAN_AUTH_LEAP 128 #define WLAN_AUTH_CHALLENGE_LEN 128 @@ -961,10 +961,10 @@ struct ieee80211_device; struct ieee80211_security { u16 active_key:2, enabled:1, - auth_mode:2, auth_algo:4, unicast_uses_group:1, encrypt:1; + u8 auth_mode; u8 key_sizes[WEP_KEYS]; u8 keys[WEP_KEYS][SCM_KEY_LEN]; u8 level; From 7c6e3f24c3e506d0e20b07ec8a2e7778b1294ca6 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Mon, 27 Apr 2015 01:25:38 -0400 Subject: [PATCH 0195/1163] rtl8192u: align local ieee80211_wmm_ac_param struct fields with global The and this local file both have a struct of the same name. They also have the same field sizes and generally the same fields, as can be seen here: ~/git/linux-head$ git grep -A4 'struct ieee80211_wmm_ac_param {' drivers/staging/rtl8192u/ieee80211/ieee80211.h:struct ieee80211_wmm_ac_param { drivers/staging/rtl8192u/ieee80211/ieee80211.h- u8 ac_aci_acm_aifsn; drivers/staging/rtl8192u/ieee80211/ieee80211.h- u8 ac_ecwmin_ecwmax; drivers/staging/rtl8192u/ieee80211/ieee80211.h- u16 ac_txop_limit; drivers/staging/rtl8192u/ieee80211/ieee80211.h-}; -- include/linux/ieee80211.h:struct ieee80211_wmm_ac_param { include/linux/ieee80211.h- u8 aci_aifsn; /* AIFSN, ACM, ACI */ include/linux/ieee80211.h- u8 cw; /* ECWmin, ECWmax (CW = 2^ECW - 1) */ include/linux/ieee80211.h- __le16 txop_limit; include/linux/ieee80211.h-} __packed; ~/git/linux-head$ Here we just align the local field names with the main system one. Then we can add an include of the system one and delete the local copy in one smooth step in a follow-on commit. Not that the replacement: for i in `find . -name '*.[ch]'` ; do sed -i 's/ac_aci_acm_aifsn/aci_aifsn/g' $i ; done for i in `find . -name '*.[ch]'` ; do sed -i 's/ac_ecwmin_ecwmax/cw/g' $i ; done for i in `find . -name '*.[ch]'` ; do sed -i 's/ac_txop_limit/txop_limit/g' $i ; done implicitly shows that only one of the three fields is currently used. Signed-off-by: Paul Gortmaker Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211.h | 6 +++--- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index f6db98c7824c..14ef5e193f2e 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -1277,9 +1277,9 @@ struct ieee80211_tim_parameters { //#else struct ieee80211_wmm_ac_param { - u8 ac_aci_acm_aifsn; - u8 ac_ecwmin_ecwmax; - u16 ac_txop_limit; + u8 aci_aifsn; + u8 cw; + u16 txop_limit; }; struct ieee80211_wmm_ts_info { diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index e833687c7371..b374088c5ff8 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -2366,10 +2366,10 @@ static inline void update_network(struct ieee80211_network *dst, /* dst->last_associate is not overwritten */ dst->wmm_info = src->wmm_info; //sure to exist in beacon or probe response frame. - if (src->wmm_param[0].ac_aci_acm_aifsn|| \ - src->wmm_param[1].ac_aci_acm_aifsn|| \ - src->wmm_param[2].ac_aci_acm_aifsn|| \ - src->wmm_param[3].ac_aci_acm_aifsn) { + if (src->wmm_param[0].aci_aifsn|| \ + src->wmm_param[1].aci_aifsn|| \ + src->wmm_param[2].aci_aifsn|| \ + src->wmm_param[3].aci_aifsn) { memcpy(dst->wmm_param, src->wmm_param, WME_AC_PRAM_LEN); } //dst->QoS_Enable = src->QoS_Enable; From db2616199e63c65373869224cc7c566b5db89a88 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Mon, 27 Apr 2015 01:25:39 -0400 Subject: [PATCH 0196/1163] rtl8192u: don't duplicate ieee80211 constants for status/auth/reason These are all defined as a part of the standard and should not be duplicated on a per-driver basis. Use the global ones and delete the local ones. In switching to we have to delete a local copy of an identical struct that we prepped earlier to have identical field names, and we add explicit include <...> where needed in order to preserve getting a successful compile. This isn't the totality of duplicated data removed, but it is a start. Signed-off-by: Paul Gortmaker Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/ieee80211.h | 77 +------------------ 1 file changed, 1 insertion(+), 76 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index 14ef5e193f2e..960769bfa15f 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -34,6 +34,7 @@ #include #include +#include #include "rtl819x_HT.h" #include "rtl819x_BA.h" @@ -646,13 +647,6 @@ struct ieee80211_snap_hdr { #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG) #define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) -/* Authentication algorithms */ -#define WLAN_AUTH_OPEN 0 -#define WLAN_AUTH_SHARED_KEY 1 -#define WLAN_AUTH_LEAP 128 - -#define WLAN_AUTH_CHALLENGE_LEN 128 - #define WLAN_CAPABILITY_BSS (1<<0) #define WLAN_CAPABILITY_IBSS (1<<1) #define WLAN_CAPABILITY_CF_POLLABLE (1<<2) @@ -671,69 +665,6 @@ struct ieee80211_snap_hdr { #define WLAN_ERP_USE_PROTECTION (1<<1) #define WLAN_ERP_BARKER_PREAMBLE (1<<2) -/* Status codes */ -enum ieee80211_statuscode { - WLAN_STATUS_SUCCESS = 0, - WLAN_STATUS_UNSPECIFIED_FAILURE = 1, - WLAN_STATUS_CAPS_UNSUPPORTED = 10, - WLAN_STATUS_REASSOC_NO_ASSOC = 11, - WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12, - WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13, - WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14, - WLAN_STATUS_CHALLENGE_FAIL = 15, - WLAN_STATUS_AUTH_TIMEOUT = 16, - WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17, - WLAN_STATUS_ASSOC_DENIED_RATES = 18, - /* 802.11b */ - WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19, - WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20, - WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21, - /* 802.11h */ - WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22, - WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23, - WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24, - /* 802.11g */ - WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25, - WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26, - /* 802.11i */ - WLAN_STATUS_INVALID_IE = 40, - WLAN_STATUS_INVALID_GROUP_CIPHER = 41, - WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42, - WLAN_STATUS_INVALID_AKMP = 43, - WLAN_STATUS_UNSUPP_RSN_VERSION = 44, - WLAN_STATUS_INVALID_RSN_IE_CAP = 45, - WLAN_STATUS_CIPHER_SUITE_REJECTED = 46, -}; - -/* Reason codes */ -enum ieee80211_reasoncode { - WLAN_REASON_UNSPECIFIED = 1, - WLAN_REASON_PREV_AUTH_NOT_VALID = 2, - WLAN_REASON_DEAUTH_LEAVING = 3, - WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4, - WLAN_REASON_DISASSOC_AP_BUSY = 5, - WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6, - WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7, - WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8, - WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9, - /* 802.11h */ - WLAN_REASON_DISASSOC_BAD_POWER = 10, - WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11, - /* 802.11i */ - WLAN_REASON_INVALID_IE = 13, - WLAN_REASON_MIC_FAILURE = 14, - WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15, - WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16, - WLAN_REASON_IE_DIFFERENT = 17, - WLAN_REASON_INVALID_GROUP_CIPHER = 18, - WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19, - WLAN_REASON_INVALID_AKMP = 20, - WLAN_REASON_UNSUPP_RSN_VERSION = 21, - WLAN_REASON_INVALID_RSN_IE_CAP = 22, - WLAN_REASON_IEEE8021X_FAILED = 23, - WLAN_REASON_CIPHER_SUITE_REJECTED = 24, -}; - #define IEEE80211_STATMASK_SIGNAL (1<<0) #define IEEE80211_STATMASK_RSSI (1<<1) #define IEEE80211_STATMASK_NOISE (1<<2) @@ -1276,12 +1207,6 @@ struct ieee80211_tim_parameters { } __packed; //#else -struct ieee80211_wmm_ac_param { - u8 aci_aifsn; - u8 cw; - u16 txop_limit; -}; - struct ieee80211_wmm_ts_info { u8 ac_dir_tid; u8 ac_up_psb; From 09e0b2ff32538a032936631ad9c110c42fab7f26 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Mon, 27 Apr 2015 01:25:40 -0400 Subject: [PATCH 0197/1163] rtl8192u: delete another embedded instance of generic reason codes We have global copies of all these reason codes. We don't need local copies. Worse is that these seem totally unused; a grep for some of the fields comes up empty, and it still compiles after its complete removal. Signed-off-by: Paul Gortmaker Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/ieee80211.h | 48 ------------------- 1 file changed, 48 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index 960769bfa15f..702bef6e2f56 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -188,54 +188,6 @@ typedef struct cb_desc { #define MGN_MCS14 0x8e #define MGN_MCS15 0x8f -//---------------------------------------------------------------------------- -// 802.11 Management frame Reason Code field -//---------------------------------------------------------------------------- -enum _ReasonCode{ - unspec_reason = 0x1, - auth_not_valid = 0x2, - deauth_lv_ss = 0x3, - inactivity = 0x4, - ap_overload = 0x5, - class2_err = 0x6, - class3_err = 0x7, - disas_lv_ss = 0x8, - asoc_not_auth = 0x9, - - //----MIC_CHECK - mic_failure = 0xe, - //----END MIC_CHECK - - // Reason code defined in 802.11i D10.0 p.28. - invalid_IE = 0x0d, - four_way_tmout = 0x0f, - two_way_tmout = 0x10, - IE_dismatch = 0x11, - invalid_Gcipher = 0x12, - invalid_Pcipher = 0x13, - invalid_AKMP = 0x14, - unsup_RSNIEver = 0x15, - invalid_RSNIE = 0x16, - auth_802_1x_fail= 0x17, - ciper_reject = 0x18, - - // Reason code defined in 7.3.1.7, 802.1e D13.0, p.42. Added by Annie, 2005-11-15. - QoS_unspec = 0x20, // 32 - QAP_bandwidth = 0x21, // 33 - poor_condition = 0x22, // 34 - no_facility = 0x23, // 35 - // Where is 36??? - req_declined = 0x25, // 37 - invalid_param = 0x26, // 38 - req_not_honored= 0x27, // 39 - TS_not_created = 0x2F, // 47 - DL_not_allowed = 0x30, // 48 - dest_not_exist = 0x31, // 49 - dest_not_QSTA = 0x32, // 50 -}; - - - #define aSifsTime ((priv->ieee80211->current_network.mode == IEEE_A || \ priv->ieee80211->current_network.mode == IEEE_N_24G || \ priv->ieee80211->current_network.mode == IEEE_N_5G) ? \ From acd442db059f63232566f72afb8f34848ff7e208 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Mon, 27 Apr 2015 01:25:41 -0400 Subject: [PATCH 0198/1163] rtl8192e: delete local copy of iee80211 reason codes. This driver has a copy of the standard reason codes from the file but with slightly different name fields. Delete the local copy and remap the only two use cases onto the names used by the global implementation with the same values. Signed-off-by: Paul Gortmaker Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 3 +- drivers/staging/rtl8192e/rtllib.h | 39 -------------------- drivers/staging/rtl8192e/rtllib_softmac.c | 3 +- 3 files changed, 4 insertions(+), 41 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 3ce7676445de..47b5aadcb2bf 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "rtl_core.h" #include "r8192E_phy.h" #include "r8192E_phyreg.h" @@ -391,7 +392,7 @@ bool MgntActSet_RF_State(struct net_device *dev, else priv->blinked_ingpio = false; rtllib_MgntDisconnect(priv->rtllib, - disas_lv_ss); + WLAN_REASON_DISASSOC_STA_HAS_LEFT); } } if ((ChangeSource == RF_CHANGE_BY_HW) && !priv->bHwRadioOff) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 3c8b708df5c3..bfec4fde01d1 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -261,45 +261,6 @@ struct sw_chnl_cmd { #define MGN_MCS14_SG 0x9e #define MGN_MCS15_SG 0x9f - -enum _ReasonCode { - unspec_reason = 0x1, - auth_not_valid = 0x2, - deauth_lv_ss = 0x3, - inactivity = 0x4, - ap_overload = 0x5, - class2_err = 0x6, - class3_err = 0x7, - disas_lv_ss = 0x8, - asoc_not_auth = 0x9, - - mic_failure = 0xe, - - invalid_IE = 0x0d, - four_way_tmout = 0x0f, - two_way_tmout = 0x10, - IE_dismatch = 0x11, - invalid_Gcipher = 0x12, - invalid_Pcipher = 0x13, - invalid_AKMP = 0x14, - unsup_RSNIEver = 0x15, - invalid_RSNIE = 0x16, - auth_802_1x_fail = 0x17, - ciper_reject = 0x18, - - QoS_unspec = 0x20, - QAP_bandwidth = 0x21, - poor_condition = 0x22, - no_facility = 0x23, - req_declined = 0x25, - invalid_param = 0x26, - req_not_honored = 0x27, - TS_not_created = 0x2F, - DL_not_allowed = 0x30, - dest_not_exist = 0x31, - dest_not_QSTA = 0x32, -}; - enum hal_def_variable { HAL_DEF_TPC_ENABLE, HAL_DEF_INIT_GAIN, diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 23b7a4c3b699..8f5e88b802c8 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "dot11d.h" short rtllib_is_54g(struct rtllib_network *net) @@ -2983,7 +2984,7 @@ void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown) if (ieee->state == RTLLIB_LINKED) { if (ieee->iw_mode == IW_MODE_INFRA) - SendDisassociation(ieee, 1, deauth_lv_ss); + SendDisassociation(ieee, 1, WLAN_REASON_DEAUTH_LEAVING); rtllib_disassociate(ieee); } From ed1c2d064a16f3cb26a00f5c523de8a073c8960c Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Thu, 30 Apr 2015 21:47:46 -0400 Subject: [PATCH 0199/1163] drivers/staging: include for modular android tegra_ion code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This file is built off of a tristate Kconfig option and also contains modular function calls so it should explicitly include module.h to avoid compile breakage during header shuffles done in the future. Cc: Greg Kroah-Hartman Cc: "Arve Hj�nnev�g" Cc: Riley Andrews Cc: Stephen Warren Cc: Thierry Reding Cc: Alexandre Courbot Cc: devel@driverdev.osuosl.org Cc: linux-tegra@vger.kernel.org Signed-off-by: Paul Gortmaker Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/tegra/tegra_ion.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/android/ion/tegra/tegra_ion.c b/drivers/staging/android/ion/tegra/tegra_ion.c index 5b8ef0e66010..4d3c516cc15e 100644 --- a/drivers/staging/android/ion/tegra/tegra_ion.c +++ b/drivers/staging/android/ion/tegra/tegra_ion.c @@ -15,6 +15,7 @@ */ #include +#include #include #include #include "../ion.h" From ae890d511ad30a1cf01e86fe213123d3dc47b7f3 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Sat, 2 May 2015 00:43:22 +0900 Subject: [PATCH 0200/1163] staging: iio: ad7606_par: Constify platform_device_id The platform_device_id is not modified by the driver and core uses it as const. Signed-off-by: Krzysztof Kozlowski Acked-by: Lars-Peter Clausen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7606_par.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/ad7606_par.c b/drivers/staging/iio/adc/ad7606_par.c index 9e24b4d4455f..1d48ae381d16 100644 --- a/drivers/staging/iio/adc/ad7606_par.c +++ b/drivers/staging/iio/adc/ad7606_par.c @@ -119,7 +119,7 @@ static const struct dev_pm_ops ad7606_pm_ops = { #define AD7606_PAR_PM_OPS NULL #endif /* CONFIG_PM */ -static struct platform_device_id ad7606_driver_ids[] = { +static const struct platform_device_id ad7606_driver_ids[] = { { .name = "ad7606-8", .driver_data = ID_AD7606_8, From ac04b3b73bbcbee48112fb516b1fdd67d0146da5 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Fri, 1 May 2015 17:10:59 -0400 Subject: [PATCH 0201/1163] staging: rtl8192u: don't redefine container_of() This file already includes . Signed-off-by: Marti Bolivar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211.h | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index 702bef6e2f56..23af2aad458e 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -24,7 +24,7 @@ #ifndef IEEE80211_H #define IEEE80211_H #include /* ETH_ALEN */ -#include /* ARRAY_SIZE */ +#include #include #include #include @@ -49,21 +49,6 @@ #define IWEVCUSTOM 0x8c02 #endif - -#ifndef container_of -/** - * container_of - cast a member of a structure out to the containing structure - * - * @ptr: the pointer to the member. - * @type: the type of the container struct this is embedded in. - * @member: the name of the member within the struct. - * - */ -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) -#endif - #define KEY_TYPE_NA 0x0 #define KEY_TYPE_WEP40 0x1 #define KEY_TYPE_TKIP 0x2 From d5a7d45fb5b667fd10a225ccf11fe395fb2417d9 Mon Sep 17 00:00:00 2001 From: Ksenija Stanojevic Date: Thu, 30 Apr 2015 19:00:23 +0200 Subject: [PATCH 0202/1163] Staging: rts5208: Replace timeval with timespec64 struct timeval tv is used to get current time. 32-bit systems using 'struct timeval' will break in the year 2038, so we have to replace that code with more appropriate types. Signed-off-by: Ksenija Stanojevic Reviewed-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx.h | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rts5208/rtsx.h b/drivers/staging/rts5208/rtsx.h index 262441bcfc41..aa1e034f7f45 100644 --- a/drivers/staging/rts5208/rtsx.h +++ b/drivers/staging/rts5208/rtsx.h @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include @@ -148,21 +148,24 @@ static inline struct rtsx_dev *host_to_rtsx(struct Scsi_Host *host) static inline void get_current_time(u8 *timeval_buf, int buf_len) { - struct timeval tv; + struct timespec64 ts64; + u32 tv_usec; if (!timeval_buf || (buf_len < 8)) return; - do_gettimeofday(&tv); + getnstimeofday64(&ts64); - 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); + tv_usec = ts64.tv_nsec/NSEC_PER_USEC; + + timeval_buf[0] = (u8)(ts64.tv_sec >> 24); + timeval_buf[1] = (u8)(ts64.tv_sec >> 16); + timeval_buf[2] = (u8)(ts64.tv_sec >> 8); + timeval_buf[3] = (u8)(ts64.tv_sec); + timeval_buf[4] = (u8)(tv_usec >> 24); + timeval_buf[5] = (u8)(tv_usec >> 16); + timeval_buf[6] = (u8)(tv_usec >> 8); + timeval_buf[7] = (u8)(tv_usec); } /* The scsi_lock() and scsi_unlock() macros protect the sm_state and the From b615d628b672c90b377c4167429c0c3b66621ba6 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:35:38 -0400 Subject: [PATCH 0203/1163] staging: unisys: Move module parameters around and mark static Move the module parameters and make sure they are static. Signed-off-by: Jes Sorensen Tested-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/globals.h | 10 ------ .../unisys/visorchipset/visorchipset_main.c | 31 ++++++++++--------- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/globals.h b/drivers/staging/unisys/visorchipset/globals.h index 36b21ec3b120..0884a68f23cd 100644 --- a/drivers/staging/unisys/visorchipset/globals.h +++ b/drivers/staging/unisys/visorchipset/globals.h @@ -28,14 +28,4 @@ /* module parameters */ -extern int visorchipset_testvnic; -extern int visorchipset_testvnicclient; -extern int visorchipset_testmsg; -extern int visorchipset_major; -extern int visorchipset_serverregwait; -extern int visorchipset_clientregwait; -extern int visorchipset_testteardown; -extern int visorchipset_disable_controlvm; -extern int visorchipset_holdchipsetready; - #endif diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 90e41cb64597..7720d2c5b0ad 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -44,6 +44,19 @@ #define POLLJIFFIES_CONTROLVMCHANNEL_FAST 1 #define POLLJIFFIES_CONTROLVMCHANNEL_SLOW 100 +/* + * Module parameters + */ +static int visorchipset_testvnic; +static int visorchipset_testvnicclient; +static int visorchipset_testmsg; +static int visorchipset_major; +static int visorchipset_serverregwait; +static int visorchipset_clientregwait = 1; /* default is on */ +static int visorchipset_testteardown; +static int visorchipset_disable_controlvm; +static int visorchipset_holdchipsetready; + /* When the controlvm channel is idle for at least MIN_IDLE_SECONDS, * we switch to slow polling mode. As soon as we get a controlvm * message, we switch back to fast polling mode. @@ -2280,43 +2293,31 @@ visorchipset_exit(void) module_param_named(testvnic, visorchipset_testvnic, int, S_IRUGO); MODULE_PARM_DESC(visorchipset_testvnic, "1 to test vnic, using dummy VNIC connected via a loopback to a physical ethernet"); -int visorchipset_testvnic = 0; - module_param_named(testvnicclient, visorchipset_testvnicclient, int, S_IRUGO); MODULE_PARM_DESC(visorchipset_testvnicclient, "1 to test vnic, using real VNIC channel attached to a separate IOVM guest"); -int visorchipset_testvnicclient = 0; - module_param_named(testmsg, visorchipset_testmsg, int, S_IRUGO); MODULE_PARM_DESC(visorchipset_testmsg, "1 to manufacture the chipset, bus, and switch messages"); -int visorchipset_testmsg = 0; - module_param_named(major, visorchipset_major, int, S_IRUGO); -MODULE_PARM_DESC(visorchipset_major, "major device number to use for the device node"); -int visorchipset_major = 0; - +MODULE_PARM_DESC(visorchipset_major, + "major device number to use for the device node"); module_param_named(serverregwait, visorchipset_serverregwait, int, S_IRUGO); MODULE_PARM_DESC(visorchipset_serverreqwait, "1 to have the module wait for the visor bus to register"); -int visorchipset_serverregwait = 0; /* default is off */ module_param_named(clientregwait, visorchipset_clientregwait, int, S_IRUGO); MODULE_PARM_DESC(visorchipset_clientregwait, "1 to have the module wait for the visorclientbus to register"); -int visorchipset_clientregwait = 1; /* default is on */ module_param_named(testteardown, visorchipset_testteardown, int, S_IRUGO); MODULE_PARM_DESC(visorchipset_testteardown, "1 to test teardown of the chipset, bus, and switch"); -int visorchipset_testteardown = 0; /* default is off */ module_param_named(disable_controlvm, visorchipset_disable_controlvm, int, S_IRUGO); MODULE_PARM_DESC(visorchipset_disable_controlvm, "1 to disable polling of controlVm channel"); -int visorchipset_disable_controlvm = 0; /* default is off */ module_param_named(holdchipsetready, visorchipset_holdchipsetready, int, S_IRUGO); MODULE_PARM_DESC(visorchipset_holdchipsetready, "1 to hold response to CHIPSET_READY"); -int visorchipset_holdchipsetready = 0; /* default is to send CHIPSET_READY - * response immediately */ + module_init(visorchipset_init); module_exit(visorchipset_exit); From 872a5032b28e5d1d420b487104adb84f9406653d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:35:39 -0400 Subject: [PATCH 0204/1163] staging: unisys: Move MYDRVNAME to visorchipset.h Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/globals.h | 2 -- drivers/staging/unisys/visorchipset/visorchipset.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/globals.h b/drivers/staging/unisys/visorchipset/globals.h index 0884a68f23cd..ee7e3b49e516 100644 --- a/drivers/staging/unisys/visorchipset/globals.h +++ b/drivers/staging/unisys/visorchipset/globals.h @@ -24,8 +24,6 @@ #include "visorchipset_umode.h" #include "version.h" -#define MYDRVNAME "visorchipset" - /* module parameters */ #endif diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 87b63f0dc36a..2c2d3fb47dc3 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -28,6 +28,8 @@ #include "vbusdeviceinfo.h" #include "vbushelper.h" +#define MYDRVNAME "visorchipset" + /** Describes the state from the perspective of which controlvm messages have * been received for a bus or device. */ From 7023638c46b6d1b819b97e397559d10c1d4fcf6f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:35:40 -0400 Subject: [PATCH 0205/1163] staging: unisys: Eliminate globals.h Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/file.c | 6 ++-- drivers/staging/unisys/visorchipset/file.h | 2 -- drivers/staging/unisys/visorchipset/globals.h | 29 ------------------- .../unisys/visorchipset/visorchipset_main.c | 2 +- 4 files changed, 5 insertions(+), 34 deletions(-) delete mode 100644 drivers/staging/unisys/visorchipset/globals.h diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c index 6fc56896e427..7d8247a46572 100644 --- a/drivers/staging/unisys/visorchipset/file.c +++ b/drivers/staging/unisys/visorchipset/file.c @@ -19,10 +19,12 @@ * communicate with the visorchipset driver using a device/file interface. */ -#include "globals.h" -#include "visorchannel.h" #include #include +#include "version.h" +#include "visorchipset.h" +#include "visorchipset_umode.h" +#include "visorchannel.h" #include "uisutils.h" #include "file.h" diff --git a/drivers/staging/unisys/visorchipset/file.h b/drivers/staging/unisys/visorchipset/file.h index 51f7699b744b..6ff28a1ae86e 100644 --- a/drivers/staging/unisys/visorchipset/file.h +++ b/drivers/staging/unisys/visorchipset/file.h @@ -18,8 +18,6 @@ #ifndef __FILE_H__ #define __FILE_H__ -#include "globals.h" - int visorchipset_file_init(dev_t majorDev, struct visorchannel **pControlVm_channel); void visorchipset_file_cleanup(dev_t major_dev); diff --git a/drivers/staging/unisys/visorchipset/globals.h b/drivers/staging/unisys/visorchipset/globals.h deleted file mode 100644 index ee7e3b49e516..000000000000 --- a/drivers/staging/unisys/visorchipset/globals.h +++ /dev/null @@ -1,29 +0,0 @@ -/* globals.h - * - * 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. - */ - -#ifndef __VISORCHIPSET_GLOBALS_H__ -#define __VISORCHIPSET_GLOBALS_H__ - -#include "diagnostics/appos_subsystems.h" -#include "timskmod.h" -#include "visorchipset.h" -#include "visorchipset_umode.h" -#include "version.h" - -/* module parameters */ - -#endif diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 7720d2c5b0ad..767c4953bfb9 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -15,7 +15,7 @@ * details. */ -#include "globals.h" +#include "version.h" #include "visorchipset.h" #include "procobjecttree.h" #include "visorchannel.h" From 5981cc995767803d19e9fe01aa82a0da51fc6c67 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:35:41 -0400 Subject: [PATCH 0206/1163] staging: unisys: Fix up a few cases of bad formatting Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/file.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c index 7d8247a46572..e63ef2a3a4a9 100644 --- a/drivers/staging/unisys/visorchipset/file.c +++ b/drivers/staging/unisys/visorchipset/file.c @@ -99,7 +99,7 @@ visorchipset_mmap(struct file *file, struct vm_area_struct *vma) } static long visorchipset_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) + unsigned long arg) { s64 adjustment; s64 vrtc_offset; @@ -108,14 +108,14 @@ static long visorchipset_ioctl(struct file *file, unsigned int cmd, case VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET: /* get the physical rtc offset */ vrtc_offset = issue_vmcall_query_guest_virtual_time_offset(); - if (copy_to_user - ((void __user *)arg, &vrtc_offset, sizeof(vrtc_offset))) { + if (copy_to_user((void __user *)arg, &vrtc_offset, + sizeof(vrtc_offset))) { return -EFAULT; } return SUCCESS; case VMCALL_UPDATE_PHYSICAL_TIME: - if (copy_from_user - (&adjustment, (void __user *)arg, sizeof(adjustment))) { + if (copy_from_user(&adjustment, (void __user *)arg, + sizeof(adjustment))) { return -EFAULT; } return issue_vmcall_update_physical_time(adjustment); From b70b9099f06d5ab68cdbe12b6d150f0d7303becf Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:35:42 -0400 Subject: [PATCH 0207/1163] staging: unisys: Remove some unnecessary parenthesis Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset_umode.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset_umode.h b/drivers/staging/unisys/visorchipset/visorchipset_umode.h index 6cf6eccb3f4a..8af5bf33883c 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_umode.h +++ b/drivers/staging/unisys/visorchipset/visorchipset_umode.h @@ -29,7 +29,7 @@ /** The user-mode program can access the control channel buffer directly * via this memory map. */ -#define VISORCHIPSET_MMAP_CONTROLCHANOFFSET (0x00000000) -#define VISORCHIPSET_MMAP_CONTROLCHANSIZE (0x00400000) /* 4MB */ +#define VISORCHIPSET_MMAP_CONTROLCHANOFFSET 0x00000000 +#define VISORCHIPSET_MMAP_CONTROLCHANSIZE 0x00400000 /* 4MB */ #endif /* __VISORCHIPSET_UMODE_H */ From bbd4be301c48adb763eda9631808e316157d6417 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:35:43 -0400 Subject: [PATCH 0208/1163] staging: unisys: Remove unncessary parenthesis Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 767c4953bfb9..b4e28d21d0c6 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -519,7 +519,7 @@ static ssize_t remaining_steps_store(struct device *dev, static void bus_info_clear(void *v) { - struct visorchipset_bus_info *p = (struct visorchipset_bus_info *) (v); + struct visorchipset_bus_info *p = (struct visorchipset_bus_info *) v; kfree(p->name); p->name = NULL; @@ -535,7 +535,7 @@ static void dev_info_clear(void *v) { struct visorchipset_device_info *p = - (struct visorchipset_device_info *)(v); + (struct visorchipset_device_info *) v; p->state.created = 0; memset(p, 0, sizeof(struct visorchipset_device_info)); From cbc2af3cb5667ff1576b9bf237082f25503a3b8b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:35:44 -0400 Subject: [PATCH 0209/1163] staging: unisys: Don't zero struct elements which will be memset away Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset_main.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index b4e28d21d0c6..90018ac3da36 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -522,12 +522,7 @@ bus_info_clear(void *v) struct visorchipset_bus_info *p = (struct visorchipset_bus_info *) v; kfree(p->name); - p->name = NULL; - kfree(p->description); - p->description = NULL; - - p->state.created = 0; memset(p, 0, sizeof(struct visorchipset_bus_info)); } @@ -537,7 +532,6 @@ dev_info_clear(void *v) struct visorchipset_device_info *p = (struct visorchipset_device_info *) v; - p->state.created = 0; memset(p, 0, sizeof(struct visorchipset_device_info)); } From e82ba62e23bc9d9e57b19fa1a5bdf18fab9a218e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:35:45 -0400 Subject: [PATCH 0210/1163] staging: unisys: Do not initialize variables unnecessarily Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/visorchipset/visorchipset_main.c | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 90018ac3da36..0d3abce9074a 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -782,7 +782,7 @@ EXPORT_SYMBOL_GPL(visorchipset_save_message); static void bus_responder(enum controlvm_id cmd_id, u32 bus_no, int response) { - struct visorchipset_bus_info *p = NULL; + struct visorchipset_bus_info *p; bool need_clear = false; p = findbus(&bus_info_list, bus_no); @@ -818,7 +818,7 @@ device_changestate_responder(enum controlvm_id cmd_id, u32 bus_no, u32 dev_no, int response, struct spar_segment_state response_state) { - struct visorchipset_device_info *p = NULL; + struct visorchipset_device_info *p; struct controlvm_message outmsg; p = finddevice(&dev_info_list, bus_no, dev_no); @@ -845,7 +845,7 @@ device_changestate_responder(enum controlvm_id cmd_id, static void device_responder(enum controlvm_id cmd_id, u32 bus_no, u32 dev_no, int response) { - struct visorchipset_device_info *p = NULL; + struct visorchipset_device_info *p; bool need_clear = false; p = finddevice(&dev_info_list, bus_no, dev_no); @@ -943,7 +943,7 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd, struct controlvm_message_header *msg_hdr, int response, bool need_response, bool for_visorbus) { - struct visorchipset_busdev_notifiers *notifiers = NULL; + struct visorchipset_busdev_notifiers *notifiers; bool notified = false; struct visorchipset_device_info *dev_info = @@ -1041,7 +1041,7 @@ bus_create(struct controlvm_message *inmsg) struct controlvm_message_packet *cmd = &inmsg->cmd; u32 bus_no = cmd->create_bus.bus_no; int rc = CONTROLVM_RESP_SUCCESS; - struct visorchipset_bus_info *bus_info = NULL; + struct visorchipset_bus_info *bus_info; bus_info = findbus(&bus_info_list, bus_no); if (bus_info && (bus_info->state.created == 1)) { @@ -1108,8 +1108,8 @@ bus_configure(struct controlvm_message *inmsg, struct parser_context *parser_ctx) { struct controlvm_message_packet *cmd = &inmsg->cmd; - u32 bus_no = cmd->configure_bus.bus_no; - struct visorchipset_bus_info *bus_info = NULL; + u32 bus_no; + struct visorchipset_bus_info *bus_info; int rc = CONTROLVM_RESP_SUCCESS; char s[99]; @@ -1150,8 +1150,8 @@ my_device_create(struct controlvm_message *inmsg) struct controlvm_message_packet *cmd = &inmsg->cmd; u32 bus_no = cmd->create_device.bus_no; u32 dev_no = cmd->create_device.dev_no; - struct visorchipset_device_info *dev_info = NULL; - struct visorchipset_bus_info *bus_info = NULL; + struct visorchipset_device_info *dev_info; + struct visorchipset_bus_info *bus_info; int rc = CONTROLVM_RESP_SUCCESS; dev_info = finddevice(&dev_info_list, bus_no, dev_no); @@ -1221,7 +1221,7 @@ my_device_changestate(struct controlvm_message *inmsg) u32 bus_no = cmd->device_change_state.bus_no; u32 dev_no = cmd->device_change_state.dev_no; struct spar_segment_state state = cmd->device_change_state.state; - struct visorchipset_device_info *dev_info = NULL; + struct visorchipset_device_info *dev_info; int rc = CONTROLVM_RESP_SUCCESS; dev_info = finddevice(&dev_info_list, bus_no, dev_no); @@ -1248,7 +1248,7 @@ my_device_destroy(struct controlvm_message *inmsg) struct controlvm_message_packet *cmd = &inmsg->cmd; u32 bus_no = cmd->destroy_device.bus_no; u32 dev_no = cmd->destroy_device.dev_no; - struct visorchipset_device_info *dev_info = NULL; + struct visorchipset_device_info *dev_info; int rc = CONTROLVM_RESP_SUCCESS; dev_info = finddevice(&dev_info_list, bus_no, dev_no); @@ -1538,8 +1538,8 @@ parahotplug_request_kickoff(struct parahotplug_request *req) static void parahotplug_process_list(void) { - struct list_head *pos = NULL; - struct list_head *tmp = NULL; + struct list_head *pos; + struct list_head *tmp; spin_lock(¶hotplug_request_list_lock); @@ -1570,8 +1570,8 @@ parahotplug_process_list(void) static int parahotplug_request_complete(int id, u16 active) { - struct list_head *pos = NULL; - struct list_head *tmp = NULL; + struct list_head *pos; + struct list_head *tmp; spin_lock(¶hotplug_request_list_lock); @@ -1656,10 +1656,10 @@ static bool handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr) { struct controlvm_message_packet *cmd = &inmsg.cmd; - u64 parm_addr = 0; - u32 parm_bytes = 0; + u64 parm_addr; + u32 parm_bytes; struct parser_context *parser_ctx = NULL; - bool local_addr = false; + bool local_addr; struct controlvm_message ackmsg; /* create parsing context if necessary */ From 9421736356cb4035a2ee10a021b8d0e82fd954a0 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:35:46 -0400 Subject: [PATCH 0211/1163] staging: unisys: Get rid of uint usage Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 0d3abce9074a..9b6c768e57ab 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -2120,7 +2120,7 @@ static ssize_t devicedisabled_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - uint id; + unsigned int id; if (kstrtouint(buf, 10, &id) != 0) return -EINVAL; @@ -2137,7 +2137,7 @@ static ssize_t deviceenabled_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - uint id; + unsigned int id; if (kstrtouint(buf, 10, &id) != 0) return -EINVAL; From be91cd3740cbaa3290ffd5a4cbb197fff7cdbeb2 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:35:47 -0400 Subject: [PATCH 0212/1163] staging: unisys: Remove unused cache object counter kmem_cache statistics are available through SLAB anyway Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset_main.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 9b6c768e57ab..e33d8866daeb 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -213,8 +213,6 @@ struct putfile_request { int completion_status; }; -static atomic_t visorchipset_cache_buffers_in_use = ATOMIC_INIT(0); - struct parahotplug_request { struct list_head list; int id; @@ -2077,7 +2075,6 @@ visorchipset_cache_alloc(struct kmem_cache *pool, bool ok_to_block, if (!p) return NULL; - atomic_inc(&visorchipset_cache_buffers_in_use); return p; } @@ -2089,7 +2086,6 @@ visorchipset_cache_free(struct kmem_cache *pool, void *p, char *fn, int ln) if (!p) return; - atomic_dec(&visorchipset_cache_buffers_in_use); kmem_cache_free(pool, p); } From 94ac450060e77f5b85bb854f6bb444ecd1d99502 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:35:48 -0400 Subject: [PATCH 0213/1163] staging: unisys: Don't include timskmod.h Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/parser.h | 1 - drivers/staging/unisys/visorchipset/visorchipset.h | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/parser.h b/drivers/staging/unisys/visorchipset/parser.h index 73be279bb401..3fe17c0c64d2 100644 --- a/drivers/staging/unisys/visorchipset/parser.h +++ b/drivers/staging/unisys/visorchipset/parser.h @@ -20,7 +20,6 @@ #include -#include "timskmod.h" #include "channel.h" typedef enum { diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 2c2d3fb47dc3..3c57782df96a 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -20,7 +20,6 @@ #include -#include "timskmod.h" #include "channel.h" #include "controlvmchannel.h" #include "parser.h" From f10c55428f9e16361d69073e2e619f38a7a1c438 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:35:49 -0400 Subject: [PATCH 0214/1163] staging: unisys: Remove a couple of unnecessary blank lines Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 3c57782df96a..53bbc4979edc 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -68,7 +68,6 @@ struct visorchipset_channel_info { u64 n_channel_bytes; uuid_le channel_type_uuid; uuid_le channel_inst_uuid; - }; /** Attributes for a particular Supervisor device. @@ -90,7 +89,6 @@ struct visorchipset_device_info { struct controlvm_message_header pending_msg_hdr;/* CONTROLVM_MESSAGE */ /** For private use by the bus driver */ void *bus_driver_context; - }; static inline struct visorchipset_device_info *finddevice( From 53dfe389c863eddf6aaeeab8afb34ffdd42a2079 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:35:50 -0400 Subject: [PATCH 0215/1163] staging: unisys: buffer_list_pool isn't used for anything Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/visorchipset/visorchipset_main.c | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index e33d8866daeb..69730d190954 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -138,13 +138,6 @@ static struct visor_livedump_info livedump_info; static struct controlvm_message controlvm_pending_msg; static bool controlvm_pending_msg_valid = false; -/* Pool of struct putfile_buffer_entry, for keeping track of pending (incoming) - * TRANSMIT_FILE PutFile payloads. - */ -static struct kmem_cache *putfile_buffer_list_pool; -static const char putfile_buffer_list_pool_name[] = - "controlvm_putfile_buffer_list_pool"; - /* This identifies a data buffer that has been received via a controlvm messages * in a remote --> local CONTROLVM_TRANSMIT_FILE conversation. */ @@ -2195,15 +2188,6 @@ visorchipset_init(void) memset(&g_del_dump_msg_hdr, 0, sizeof(struct controlvm_message_header)); - putfile_buffer_list_pool = - kmem_cache_create(putfile_buffer_list_pool_name, - sizeof(struct putfile_buffer_entry), - 0, SLAB_HWCACHE_ALIGN, NULL); - if (!putfile_buffer_list_pool) { - POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC, DIAG_SEVERITY_ERR); - rc = -1; - goto cleanup; - } if (!visorchipset_disable_controlvm) { /* if booting in a crash kernel */ if (is_kdump_kernel()) @@ -2262,10 +2246,6 @@ visorchipset_exit(void) periodic_controlvm_workqueue = NULL; destroy_controlvm_payload_info(&controlvm_payload_info); } - if (putfile_buffer_list_pool) { - kmem_cache_destroy(putfile_buffer_list_pool); - putfile_buffer_list_pool = NULL; - } cleanup_controlvm_structures(); From a5aa395da6d1688cc0d8b5239c3a66aa235580a7 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:35:51 -0400 Subject: [PATCH 0216/1163] staging: unisys: Remove write-only visorchipset_bus_info.dev_no Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 1 - drivers/staging/unisys/visorchipset/visorchipset_main.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 53bbc4979edc..d21fcb027cac 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -140,7 +140,6 @@ struct visorchipset_bus_info { struct controlvm_message_header pending_msg_hdr;/* CONTROLVM MsgHdr */ /** For private use by the bus driver */ void *bus_driver_context; - u32 dev_no; }; static inline struct visorchipset_bus_info * diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 69730d190954..e78ae7bbb72f 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -1051,7 +1051,6 @@ bus_create(struct controlvm_message *inmsg) INIT_LIST_HEAD(&bus_info->entry); bus_info->bus_no = bus_no; - bus_info->dev_no = cmd->create_bus.dev_count; POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO); From 4f66520be923db928b487a5181c6ff8a5590857f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:35:52 -0400 Subject: [PATCH 0217/1163] staging: unisys: findbus() doesn't need to be inline Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/visorchipset/visorchipset.h | 12 ------- .../unisys/visorchipset/visorchipset_main.c | 31 +++++++++++++------ 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index d21fcb027cac..70b9e6ec60d9 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -142,18 +142,6 @@ struct visorchipset_bus_info { void *bus_driver_context; }; -static inline struct visorchipset_bus_info * -findbus(struct list_head *list, u32 bus_no) -{ - struct visorchipset_bus_info *p; - - list_for_each_entry(p, list, entry) { - if (p->bus_no == bus_no) - return p; - } - return NULL; -} - /* These functions will be called from within visorchipset when certain * events happen. (The implementation of these functions is outside of * visorchipset.) diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index e78ae7bbb72f..f64756736164 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -526,6 +526,19 @@ dev_info_clear(void *v) memset(p, 0, sizeof(struct visorchipset_device_info)); } +static struct visorchipset_bus_info * +bus_find(struct list_head *list, u32 bus_no) +{ + struct visorchipset_bus_info *p; + + list_for_each_entry(p, list, entry) { + if (p->bus_no == bus_no) + return p; + } + + return NULL; +} + static u8 check_chipset_events(void) { @@ -776,7 +789,7 @@ bus_responder(enum controlvm_id cmd_id, u32 bus_no, int response) struct visorchipset_bus_info *p; bool need_clear = false; - p = findbus(&bus_info_list, bus_no); + p = bus_find(&bus_info_list, bus_no); if (!p) return; @@ -866,10 +879,10 @@ bus_epilog(u32 bus_no, u32 cmd, struct controlvm_message_header *msg_hdr, int response, bool need_response) { + struct visorchipset_bus_info *bus_info; bool notified = false; - struct visorchipset_bus_info *bus_info = findbus(&bus_info_list, - bus_no); + bus_info = bus_find(&bus_info_list, bus_no); if (!bus_info) return; @@ -1034,7 +1047,7 @@ bus_create(struct controlvm_message *inmsg) int rc = CONTROLVM_RESP_SUCCESS; struct visorchipset_bus_info *bus_info; - bus_info = findbus(&bus_info_list, bus_no); + bus_info = bus_find(&bus_info_list, bus_no); if (bus_info && (bus_info->state.created == 1)) { POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no, POSTCODE_SEVERITY_ERR); @@ -1083,7 +1096,7 @@ bus_destroy(struct controlvm_message *inmsg) struct visorchipset_bus_info *bus_info; int rc = CONTROLVM_RESP_SUCCESS; - bus_info = findbus(&bus_info_list, bus_no); + bus_info = bus_find(&bus_info_list, bus_no); if (!bus_info) rc = -CONTROLVM_RESP_ERROR_BUS_INVALID; else if (bus_info->state.created == 0) @@ -1107,7 +1120,7 @@ bus_configure(struct controlvm_message *inmsg, POSTCODE_LINUX_3(BUS_CONFIGURE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO); - bus_info = findbus(&bus_info_list, bus_no); + bus_info = bus_find(&bus_info_list, bus_no); if (!bus_info) { POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no, POSTCODE_SEVERITY_ERR); @@ -1151,7 +1164,7 @@ my_device_create(struct controlvm_message *inmsg) rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE; goto cleanup; } - bus_info = findbus(&bus_info_list, bus_no); + bus_info = bus_find(&bus_info_list, bus_no); if (!bus_info) { POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, POSTCODE_SEVERITY_ERR); @@ -1995,7 +2008,7 @@ device_resume_response(u32 bus_no, u32 dev_no, int response) bool visorchipset_get_bus_info(u32 bus_no, struct visorchipset_bus_info *bus_info) { - void *p = findbus(&bus_info_list, bus_no); + void *p = bus_find(&bus_info_list, bus_no); if (!p) return false; @@ -2007,7 +2020,7 @@ EXPORT_SYMBOL_GPL(visorchipset_get_bus_info); bool visorchipset_set_bus_context(u32 bus_no, void *context) { - struct visorchipset_bus_info *p = findbus(&bus_info_list, bus_no); + struct visorchipset_bus_info *p = bus_find(&bus_info_list, bus_no); if (!p) return false; From 92b5e8c0ac63fb74171929b98f1fa170a0ff46b2 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:35:53 -0400 Subject: [PATCH 0218/1163] staging: unisys: Remove unused typedef SPARREPORTEVENT_COMPLETE_FUNC Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 70b9e6ec60d9..59552afc663f 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -194,9 +194,6 @@ visorchipset_register_busdev_server( struct visorchipset_busdev_responders *responders, struct ultra_vbus_deviceinfo *driver_info); -typedef void (*SPARREPORTEVENT_COMPLETE_FUNC) (struct controlvm_message *msg, - int status); - void visorchipset_device_pause_response(u32 bus_no, u32 dev_no, int response); bool visorchipset_get_bus_info(u32 bus_no, From d480f6a2b9f5aaf8f34ef74ef471d0e219c45c21 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:35:54 -0400 Subject: [PATCH 0219/1163] staging: unisys: finddevice() doesn't need to be inline Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/visorchipset/visorchipset.h | 12 ------- .../unisys/visorchipset/visorchipset_main.c | 32 +++++++++++++------ 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 59552afc663f..a3fe8b7de341 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -91,18 +91,6 @@ struct visorchipset_device_info { void *bus_driver_context; }; -static inline struct visorchipset_device_info *finddevice( - struct list_head *list, u32 bus_no, u32 dev_no) -{ - struct visorchipset_device_info *p; - - list_for_each_entry(p, list, entry) { - if (p->bus_no == bus_no && p->dev_no == dev_no) - return p; - } - return NULL; -} - static inline void delbusdevices(struct list_head *list, u32 bus_no) { struct visorchipset_device_info *p, *tmp; diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index f64756736164..d1f0d18da10e 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -539,6 +539,19 @@ bus_find(struct list_head *list, u32 bus_no) return NULL; } +static struct visorchipset_device_info * +device_find(struct list_head *list, u32 bus_no, u32 dev_no) +{ + struct visorchipset_device_info *p; + + list_for_each_entry(p, list, entry) { + if (p->bus_no == bus_no && p->dev_no == dev_no) + return p; + } + + return NULL; +} + static u8 check_chipset_events(void) { @@ -825,7 +838,7 @@ device_changestate_responder(enum controlvm_id cmd_id, struct visorchipset_device_info *p; struct controlvm_message outmsg; - p = finddevice(&dev_info_list, bus_no, dev_no); + p = device_find(&dev_info_list, bus_no, dev_no); if (!p) return; if (p->pending_msg_hdr.id == CONTROLVM_INVALID) @@ -852,7 +865,7 @@ device_responder(enum controlvm_id cmd_id, u32 bus_no, u32 dev_no, int response) struct visorchipset_device_info *p; bool need_clear = false; - p = finddevice(&dev_info_list, bus_no, dev_no); + p = device_find(&dev_info_list, bus_no, dev_no); if (!p) return; if (response >= 0) { @@ -951,7 +964,7 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd, bool notified = false; struct visorchipset_device_info *dev_info = - finddevice(&dev_info_list, bus_no, dev_no); + device_find(&dev_info_list, bus_no, dev_no); char *envp[] = { "SPARSP_DIAGPOOL_PAUSED_STATE = 1", NULL @@ -1157,7 +1170,7 @@ my_device_create(struct controlvm_message *inmsg) struct visorchipset_bus_info *bus_info; int rc = CONTROLVM_RESP_SUCCESS; - dev_info = finddevice(&dev_info_list, bus_no, dev_no); + dev_info = device_find(&dev_info_list, bus_no, dev_no); if (dev_info && (dev_info->state.created == 1)) { POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, POSTCODE_SEVERITY_ERR); @@ -1227,7 +1240,7 @@ my_device_changestate(struct controlvm_message *inmsg) struct visorchipset_device_info *dev_info; int rc = CONTROLVM_RESP_SUCCESS; - dev_info = finddevice(&dev_info_list, bus_no, dev_no); + dev_info = device_find(&dev_info_list, bus_no, dev_no); if (!dev_info) { POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, dev_no, bus_no, POSTCODE_SEVERITY_ERR); @@ -1254,7 +1267,7 @@ my_device_destroy(struct controlvm_message *inmsg) struct visorchipset_device_info *dev_info; int rc = CONTROLVM_RESP_SUCCESS; - dev_info = finddevice(&dev_info_list, bus_no, dev_no); + dev_info = device_find(&dev_info_list, bus_no, dev_no); if (!dev_info) rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID; else if (dev_info->state.created == 0) @@ -2033,7 +2046,7 @@ bool visorchipset_get_device_info(u32 bus_no, u32 dev_no, struct visorchipset_device_info *dev_info) { - void *p = finddevice(&dev_info_list, bus_no, dev_no); + void *p = device_find(&dev_info_list, bus_no, dev_no); if (!p) return false; @@ -2045,8 +2058,9 @@ EXPORT_SYMBOL_GPL(visorchipset_get_device_info); bool visorchipset_set_device_context(u32 bus_no, u32 dev_no, void *context) { - struct visorchipset_device_info *p = - finddevice(&dev_info_list, bus_no, dev_no); + struct visorchipset_device_info *p; + + p = device_find(&dev_info_list, bus_no, dev_no); if (!p) return false; From 28723521a7e909d4fb19a682ad9a3647496fe62b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:35:55 -0400 Subject: [PATCH 0220/1163] staging: unisys: delbusdevices() doesn't need to be inline Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorchipset/visorchipset.h | 12 ------------ .../unisys/visorchipset/visorchipset_main.c | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index a3fe8b7de341..1d66c3766c42 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -91,18 +91,6 @@ struct visorchipset_device_info { void *bus_driver_context; }; -static inline void delbusdevices(struct list_head *list, u32 bus_no) -{ - struct visorchipset_device_info *p, *tmp; - - list_for_each_entry_safe(p, tmp, list, entry) { - if (p->bus_no == bus_no) { - list_del(&p->entry); - kfree(p); - } - } -} - /** Attributes for a particular Supervisor bus. * (For a service partition acting as the server for buses/devices, there * is a 1-to-1 relationship between busses and guest partitions.) diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index d1f0d18da10e..9f5c539d959b 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -552,6 +552,18 @@ device_find(struct list_head *list, u32 bus_no, u32 dev_no) return NULL; } +static void busdevices_del(struct list_head *list, u32 bus_no) +{ + struct visorchipset_device_info *p, *tmp; + + list_for_each_entry_safe(p, tmp, list, entry) { + if (p->bus_no == bus_no) { + list_del(&p->entry); + kfree(p); + } + } +} + static u8 check_chipset_events(void) { @@ -810,7 +822,7 @@ bus_responder(enum controlvm_id cmd_id, u32 bus_no, int response) if ((cmd_id == CONTROLVM_BUS_CREATE) && (response != (-CONTROLVM_RESP_ERROR_ALREADY_DONE))) /* undo the row we just created... */ - delbusdevices(&dev_info_list, bus_no); + busdevices_del(&dev_info_list, bus_no); } else { if (cmd_id == CONTROLVM_BUS_CREATE) p->state.created = 1; @@ -826,7 +838,7 @@ bus_responder(enum controlvm_id cmd_id, u32 bus_no, int response) p->pending_msg_hdr.id = CONTROLVM_INVALID; if (need_clear) { bus_info_clear(p); - delbusdevices(&dev_info_list, bus_no); + busdevices_del(&dev_info_list, bus_no); } } From 4eb32b4892bbf5b71f63e468af0c7d660dac6d96 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:35:56 -0400 Subject: [PATCH 0221/1163] staging: unisys: Avoid some == 0 checks Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/file.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c index e63ef2a3a4a9..a17027c211a2 100644 --- a/drivers/staging/unisys/visorchipset/file.c +++ b/drivers/staging/unisys/visorchipset/file.c @@ -36,7 +36,7 @@ static struct visorchannel **file_controlvm_channel; void visorchipset_file_cleanup(dev_t major_dev) { - if (file_cdev.ops != NULL) + if (file_cdev.ops) cdev_del(&file_cdev); file_cdev.ops = NULL; unregister_chrdev_region(major_dev, 1); @@ -47,7 +47,7 @@ visorchipset_open(struct inode *inode, struct file *file) { unsigned minor_number = iminor(inode); - if (minor_number != 0) + if (minor_number) return -ENODEV; file->private_data = NULL; return 0; @@ -73,16 +73,16 @@ visorchipset_mmap(struct file *file, struct vm_area_struct *vma) switch (offset) { case VISORCHIPSET_MMAP_CONTROLCHANOFFSET: vma->vm_flags |= VM_IO; - if (*file_controlvm_channel == NULL) { + if (!*file_controlvm_channel) return -ENXIO; - } + visorchannel_read(*file_controlvm_channel, offsetof(struct spar_controlvm_channel_protocol, gp_control_channel), &addr, sizeof(addr)); - if (addr == 0) { + if (!addr) return -ENXIO; - } + physaddr = (unsigned long)addr; if (remap_pfn_range(vma, vma->vm_start, physaddr >> PAGE_SHIFT, From ebec896762ee07c0dce9883865faa2a2d4b20751 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:35:57 -0400 Subject: [PATCH 0222/1163] staging: unisys: No point in checking != 0 Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/visorchipset/visorchipset_main.c | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 9f5c539d959b..3b5f3d6ae2ff 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -368,7 +368,7 @@ static ssize_t toolaction_store(struct device *dev, u8 tool_action; int ret; - if (kstrtou8(buf, 10, &tool_action) != 0) + if (kstrtou8(buf, 10, &tool_action)) return -EINVAL; ret = visorchannel_write(controlvm_channel, @@ -402,7 +402,7 @@ static ssize_t boottotool_store(struct device *dev, int val, ret; struct efi_spar_indication efi_spar_indication; - if (kstrtoint(buf, 10, &val) != 0) + if (kstrtoint(buf, 10, &val)) return -EINVAL; efi_spar_indication.boot_to_tool = val; @@ -434,7 +434,7 @@ static ssize_t error_store(struct device *dev, struct device_attribute *attr, u32 error; int ret; - if (kstrtou32(buf, 10, &error) != 0) + if (kstrtou32(buf, 10, &error)) return -EINVAL; ret = visorchannel_write(controlvm_channel, @@ -464,7 +464,7 @@ static ssize_t textid_store(struct device *dev, struct device_attribute *attr, u32 text_id; int ret; - if (kstrtou32(buf, 10, &text_id) != 0) + if (kstrtou32(buf, 10, &text_id)) return -EINVAL; ret = visorchannel_write(controlvm_channel, @@ -495,7 +495,7 @@ static ssize_t remaining_steps_store(struct device *dev, u16 remaining_steps; int ret; - if (kstrtou16(buf, 10, &remaining_steps) != 0) + if (kstrtou16(buf, 10, &remaining_steps)) return -EINVAL; ret = visorchannel_write(controlvm_channel, @@ -1701,7 +1701,7 @@ handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr) * within our OS-controlled memory. We need to know that, because it * makes a difference in how we compute the virtual address. */ - if (parm_addr != 0 && parm_bytes != 0) { + if (parm_addr && parm_bytes) { bool retry = false; parser_ctx = @@ -1962,7 +1962,7 @@ setup_crash_devices_work_queue(struct work_struct *work) } /* reuse IOVM create bus message */ - if (local_crash_bus_msg.cmd.create_bus.channel_addr != 0) { + if (local_crash_bus_msg.cmd.create_bus.channel_addr) { bus_create(&local_crash_bus_msg); } else { POSTCODE_LINUX_2(CRASH_DEV_BUS_NULL_FAILURE_PC, @@ -1971,7 +1971,7 @@ setup_crash_devices_work_queue(struct work_struct *work) } /* reuse create device message for storage device */ - if (local_crash_dev_msg.cmd.create_device.channel_addr != 0) { + if (local_crash_dev_msg.cmd.create_device.channel_addr) { my_device_create(&local_crash_dev_msg); } else { POSTCODE_LINUX_2(CRASH_DEV_DEV_NULL_FAILURE_PC, @@ -2129,10 +2129,10 @@ static ssize_t chipsetready_store(struct device *dev, if (sscanf(buf, "%63s", msgtype) != 1) return -EINVAL; - if (strcmp(msgtype, "CALLHOMEDISK_MOUNTED") == 0) { + if (!strcmp(msgtype, "CALLHOMEDISK_MOUNTED")) { chipset_events[0] = 1; return count; - } else if (strcmp(msgtype, "MODULES_LOADED") == 0) { + } else if (!strcmp(msgtype, "MODULES_LOADED")) { chipset_events[1] = 1; return count; } @@ -2149,7 +2149,7 @@ static ssize_t devicedisabled_store(struct device *dev, { unsigned int id; - if (kstrtouint(buf, 10, &id) != 0) + if (kstrtouint(buf, 10, &id)) return -EINVAL; parahotplug_request_complete(id, 0); @@ -2166,7 +2166,7 @@ static ssize_t deviceenabled_store(struct device *dev, { unsigned int id; - if (kstrtouint(buf, 10, &id) != 0) + if (kstrtouint(buf, 10, &id)) return -EINVAL; parahotplug_request_complete(id, 1); @@ -2195,7 +2195,7 @@ visorchipset_init(void) } addr = controlvm_get_channel_address(); - if (addr != 0) { + if (addr) { controlvm_channel = visorchannel_create_with_lock (addr, From 5157d88c9becd6a8cdb2978afaaf63b56b249c51 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:35:58 -0400 Subject: [PATCH 0223/1163] staging: unisys: Remove write-only variable g_diag_msg_hdr Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset_main.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 3b5f3d6ae2ff..b733147b4dbb 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -75,7 +75,6 @@ static struct delayed_work periodic_controlvm_work; static struct workqueue_struct *periodic_controlvm_workqueue; static DEFINE_SEMAPHORE(notifier_lock); -static struct controlvm_message_header g_diag_msg_hdr; static struct controlvm_message_header g_chipset_msg_hdr; static struct controlvm_message_header g_del_dump_msg_hdr; static const uuid_le spar_diag_pool_channel_protocol_uuid = @@ -1742,7 +1741,6 @@ handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr) /* save the hdr and cmd structures for later use */ /* when sending back the response to Command */ my_device_changestate(&inmsg); - g_diag_msg_hdr = inmsg.hdr; g_devicechangestate_packet = inmsg.cmd; break; } @@ -2220,8 +2218,6 @@ visorchipset_init(void) goto cleanup; } - memset(&g_diag_msg_hdr, 0, sizeof(struct controlvm_message_header)); - memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header)); memset(&g_del_dump_msg_hdr, 0, sizeof(struct controlvm_message_header)); @@ -2287,8 +2283,6 @@ visorchipset_exit(void) cleanup_controlvm_structures(); - memset(&g_diag_msg_hdr, 0, sizeof(struct controlvm_message_header)); - memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header)); memset(&g_del_dump_msg_hdr, 0, sizeof(struct controlvm_message_header)); From 7e61e4c9b34c51913997830682181a24febe810d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:35:59 -0400 Subject: [PATCH 0224/1163] staging: unisys: Remove write-only variable g_del_dump_msg_hdr Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset_main.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index b733147b4dbb..5ea6f9e81fba 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -76,7 +76,6 @@ static struct workqueue_struct *periodic_controlvm_workqueue; static DEFINE_SEMAPHORE(notifier_lock); static struct controlvm_message_header g_chipset_msg_hdr; -static struct controlvm_message_header g_del_dump_msg_hdr; static const uuid_le spar_diag_pool_channel_protocol_uuid = SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID; /* 0xffffff is an invalid Bus/Device number */ @@ -2220,8 +2219,6 @@ visorchipset_init(void) memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header)); - memset(&g_del_dump_msg_hdr, 0, sizeof(struct controlvm_message_header)); - if (!visorchipset_disable_controlvm) { /* if booting in a crash kernel */ if (is_kdump_kernel()) @@ -2285,8 +2282,6 @@ visorchipset_exit(void) memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header)); - memset(&g_del_dump_msg_hdr, 0, sizeof(struct controlvm_message_header)); - visorchannel_destroy(controlvm_channel); visorchipset_file_cleanup(visorchipset_platform_device.dev.devt); From 3703987cd427ca4ca1c7e98308be7f3036007a37 Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Tue, 5 May 2015 18:36:00 -0400 Subject: [PATCH 0225/1163] staging: unisys: add visorbus driver This base driver provides bus functionality to visorhid, visorhba, and visornic which will be later added to our driver base. Visorbus supports sPar bus model and manages bus specific functionality. It maintains the sysfs subtree /sys/devices/visorbus*/.It is responsible for device creation and destruction of the devices on its bus. Signed-off-by: Erik Arfvidson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/Kconfig | 1 + drivers/staging/unisys/Makefile | 1 + .../include/channels/vbuschannel.h | 2 +- drivers/staging/unisys/visorbus/Kconfig | 10 + drivers/staging/unisys/visorbus/Makefile | 14 + .../staging/unisys/visorbus/businst_attr.c | 103 ++ .../staging/unisys/visorbus/businst_attr.h | 40 + .../staging/unisys/visorbus/channel_attr.c | 227 +++ .../staging/unisys/visorbus/channel_attr.h | 27 + .../unisys/visorbus/devmajorminor_attr.c | 192 ++ .../unisys/visorbus/devmajorminor_attr.h | 31 + drivers/staging/unisys/visorbus/visorbus.h | 166 ++ .../staging/unisys/visorbus/visorbus_main.c | 1643 +++++++++++++++++ .../unisys/visorbus/visorbus_private.h | 50 + 14 files changed, 2506 insertions(+), 1 deletion(-) create mode 100644 drivers/staging/unisys/visorbus/Kconfig create mode 100644 drivers/staging/unisys/visorbus/Makefile create mode 100644 drivers/staging/unisys/visorbus/businst_attr.c create mode 100644 drivers/staging/unisys/visorbus/businst_attr.h create mode 100644 drivers/staging/unisys/visorbus/channel_attr.c create mode 100644 drivers/staging/unisys/visorbus/channel_attr.h create mode 100644 drivers/staging/unisys/visorbus/devmajorminor_attr.c create mode 100644 drivers/staging/unisys/visorbus/devmajorminor_attr.h create mode 100644 drivers/staging/unisys/visorbus/visorbus.h create mode 100644 drivers/staging/unisys/visorbus/visorbus_main.c create mode 100644 drivers/staging/unisys/visorbus/visorbus_private.h diff --git a/drivers/staging/unisys/Kconfig b/drivers/staging/unisys/Kconfig index 14e1ea6803f8..8d056b55ced7 100644 --- a/drivers/staging/unisys/Kconfig +++ b/drivers/staging/unisys/Kconfig @@ -12,5 +12,6 @@ if UNISYSSPAR source "drivers/staging/unisys/visorutil/Kconfig" source "drivers/staging/unisys/visorchannel/Kconfig" source "drivers/staging/unisys/visorchipset/Kconfig" +source "drivers/staging/unisys/visorbus/Kconfig" endif # UNISYSSPAR diff --git a/drivers/staging/unisys/Makefile b/drivers/staging/unisys/Makefile index 97e750de4bef..1ed9d39ff230 100644 --- a/drivers/staging/unisys/Makefile +++ b/drivers/staging/unisys/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_UNISYS_VISORUTIL) += visorutil/ obj-$(CONFIG_UNISYS_VISORCHANNEL) += visorchannel/ obj-$(CONFIG_UNISYS_VISORCHIPSET) += visorchipset/ +obj-$(CONFIG_UNISYS_VISORBUS) += visorbus/ diff --git a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h index 2c42ce16e0cf..5ed83a3f1428 100644 --- a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h @@ -54,7 +54,7 @@ static const uuid_le spar_vbus_channel_protocol_uuid = #define SPAR_VBUS_CHANNEL_OK_SERVER(actual_bytes) \ (spar_check_channel_server(spar_vbus_channel_protocol_uuid, \ "vbus", \ - sizeof(struct ultra_vbus_channel_protocol),\ + sizeof(struct spar_vbus_channel_protocol),\ actual_bytes)) #pragma pack(push, 1) /* both GCC and VC now allow this pragma */ diff --git a/drivers/staging/unisys/visorbus/Kconfig b/drivers/staging/unisys/visorbus/Kconfig new file mode 100644 index 000000000000..0141528657e2 --- /dev/null +++ b/drivers/staging/unisys/visorbus/Kconfig @@ -0,0 +1,10 @@ +# +# Unisys visorbus configuration +# + +config UNISYS_VISORBUS + tristate "Unisys visorbus driver" + depends on UNISYSSPAR && UNISYS_VISORUTIL && UNISYS_VISORCHANNEL && UNISYS_VISORCHIPSET + ---help--- + If you say Y here, you will enable the Unisys visorbus driver. + diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile new file mode 100644 index 000000000000..60bb96bad239 --- /dev/null +++ b/drivers/staging/unisys/visorbus/Makefile @@ -0,0 +1,14 @@ +# +# Makefile for Unisys visorbus +# + +obj-$(CONFIG_UNISYS_VISORBUS) += visorbus.o + +visorbus-y := visorbus_main.o devmajorminor_attr.o businst_attr.o channel_attr.o + +ccflags-y += -Idrivers/staging/unisys/include +ccflags-y += -Idrivers/staging/unisys/visorchannel +ccflags-y += -Idrivers/staging/unisys/visorchipset +ccflags-y += -Idrivers/staging/unisys/common-spar/include +ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels +ccflags-y += -Idrivers/staging/unisys/visorutil diff --git a/drivers/staging/unisys/visorbus/businst_attr.c b/drivers/staging/unisys/visorbus/businst_attr.c new file mode 100644 index 000000000000..b3fea9d93d5e --- /dev/null +++ b/drivers/staging/unisys/visorbus/businst_attr.c @@ -0,0 +1,103 @@ +/* businst_attr.c + * + * 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. + */ + +/* This is actually something they forgot to put in the kernel. + * struct bus_type in the kernel SHOULD have a "busses" member, which + * should be treated similarly to the "devices" and "drivers" members. + * There SHOULD be: + * - a "businst_attribute" analogous to the existing "bus_attribute" + * - a "businst_create_file" and "businst_remove_file" analogous to the + * existing "bus_create_file" and "bus_remove_file". + * That's what I created businst.c and businst.h to do. + * + * We want to add the "busses" sub-tree in sysfs, where we will house the + * names and properties of each bus instance: + * + * /sys/bus// + * version + * devices + * --> /sys/devices/ + * --> /sys/devices/ + * drivers + * + * + * + * ... + * + * + * + * ... + * >> busses + * >> + * >> + * >> + * >> ... + * >> + * >> + * >> + * >> ... + * + * I considered adding bus instance properties under + * /sys/devices/. But I thought there may be existing + * notions that ONLY device sub-trees should live under + * /sys/devices/. So I stayed out of there. + * + */ + +#include "businst_attr.h" + +#define to_businst_attr(_attr) \ + container_of(_attr, struct businst_attribute, attr) +#define to_visorbus_devdata(obj) \ + container_of(obj, struct visorbus_devdata, kobj) +#define CURRENT_FILE_PC VISOR_BUS_PC_businst_attr_c + +ssize_t businst_attr_show(struct kobject *kobj, struct attribute *attr, + char *buf) +{ + struct businst_attribute *businst_attr = to_businst_attr(attr); + struct visorbus_devdata *bus = to_visorbus_devdata(kobj); + ssize_t ret = 0; + + if (businst_attr->show) + ret = businst_attr->show(bus, buf); + return ret; +} + +ssize_t businst_attr_store(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t count) +{ + struct businst_attribute *businst_attr = to_businst_attr(attr); + struct visorbus_devdata *bus = to_visorbus_devdata(kobj); + ssize_t ret = 0; + + if (businst_attr->store) + ret = businst_attr->store(bus, buf, count); + return ret; +} + +int businst_create_file(struct visorbus_devdata *bus, + struct businst_attribute *attr) +{ + return sysfs_create_file(&bus->kobj, &attr->attr); +} + +void businst_remove_file(struct visorbus_devdata *bus, + struct businst_attribute *attr) +{ + sysfs_remove_file(&bus->kobj, &attr->attr); +} diff --git a/drivers/staging/unisys/visorbus/businst_attr.h b/drivers/staging/unisys/visorbus/businst_attr.h new file mode 100644 index 000000000000..e9fb36a692cb --- /dev/null +++ b/drivers/staging/unisys/visorbus/businst_attr.h @@ -0,0 +1,40 @@ +/* businst_attr.h + * + * 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. + */ + +#ifndef __BUSINST_H__ +#define __BUSINST_H__ + +#include "visorbus_private.h" /* just to get visorbus_devdata declaration */ +#include "timskmod.h" + +struct businst_attribute { + struct attribute attr; + ssize_t (*show)(struct visorbus_devdata*, char *buf); + ssize_t (*store)(struct visorbus_devdata*, const char *buf, + size_t count); +}; + +ssize_t businst_attr_show(struct kobject *kobj, + struct attribute *attr, char *buf); +ssize_t businst_attr_store(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t count); +int businst_create_file(struct visorbus_devdata *bus, + struct businst_attribute *attr); +void businst_remove_file(struct visorbus_devdata *bus, + struct businst_attribute *attr); + +#endif diff --git a/drivers/staging/unisys/visorbus/channel_attr.c b/drivers/staging/unisys/visorbus/channel_attr.c new file mode 100644 index 000000000000..0d7184ac1cbe --- /dev/null +++ b/drivers/staging/unisys/visorbus/channel_attr.c @@ -0,0 +1,227 @@ +/* channel_attr.c + * + * 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. + */ + +/* Implement publishing of channel attributes under: + * + * /sys/bus/visorbus/dev/channel + * + */ + +#include "channel_attr.h" +#define CURRENT_FILE_PC VISOR_BUS_PC_channel_attr_c +#define to_channel_attr(_attr) \ + container_of(_attr, struct channel_attribute, attr) +#define to_visor_device_from_kobjchannel(obj) \ + container_of(obj, struct visor_device, kobjchannel) + +struct channel_attribute { + struct attribute attr; + ssize_t (*show)(struct visor_device*, char *buf); + ssize_t (*store)(struct visor_device*, const char *buf, size_t count); +}; + +/* begin implementation of specific channel attributes to appear under +* /sys/bus/visorbus/dev/channel +*/ +static ssize_t devicechannel_attr_physaddr(struct visor_device *dev, char *buf) +{ + if (!dev->visorchannel) + return 0; + return snprintf(buf, PAGE_SIZE, "0x%Lx\n", + visorchannel_get_physaddr(dev->visorchannel)); +} + +static ssize_t devicechannel_attr_nbytes(struct visor_device *dev, char *buf) +{ + if (!dev->visorchannel) + return 0; + return snprintf(buf, PAGE_SIZE, "0x%lx\n", + visorchannel_get_nbytes(dev->visorchannel)); +} + +static ssize_t devicechannel_attr_clientpartition(struct visor_device *dev, + char *buf) { + if (!dev->visorchannel) + return 0; + return snprintf(buf, PAGE_SIZE, "0x%Lx\n", + visorchannel_get_clientpartition(dev->visorchannel)); +} + +static ssize_t devicechannel_attr_typeguid(struct visor_device *dev, char *buf) +{ + char s[99]; + + if (!dev->visorchannel) + return 0; + return snprintf(buf, PAGE_SIZE, "%s\n", + visorchannel_id(dev->visorchannel, s)); +} + +static ssize_t devicechannel_attr_zoneguid(struct visor_device *dev, char *buf) +{ + char s[99]; + + if (!dev->visorchannel) + return 0; + return snprintf(buf, PAGE_SIZE, "%s\n", + visorchannel_zoneid(dev->visorchannel, s)); +} + +static ssize_t devicechannel_attr_typename(struct visor_device *dev, char *buf) +{ + int i = 0; + struct bus_type *xbus = dev->device.bus; + struct device_driver *xdrv = dev->device.driver; + struct visor_driver *drv = NULL; + + if (!dev->visorchannel || !xbus || !xdrv) + return 0; + i = xbus->match(&dev->device, xdrv); + if (!i) + return 0; + drv = to_visor_driver(xdrv); + return snprintf(buf, PAGE_SIZE, "%s\n", drv->channel_types[i - 1].name); +} + +static ssize_t devicechannel_attr_dump(struct visor_device *dev, char *buf) +{ + int count = 0; +/* TODO: replace this with debugfs code + struct seq_file *m = NULL; + if (dev->visorchannel == NULL) + return 0; + m = visor_seq_file_new_buffer(buf, PAGE_SIZE - 1); + if (m == NULL) + return 0; + visorchannel_debug(dev->visorchannel, 1, m, 0); + count = m->count; + visor_seq_file_done_buffer(m); + m = NULL; +*/ + return count; +} + +static struct channel_attribute all_channel_attrs[] = { + __ATTR(physaddr, S_IRUGO, + devicechannel_attr_physaddr, NULL), + __ATTR(nbytes, S_IRUGO, + devicechannel_attr_nbytes, NULL), + __ATTR(clientpartition, S_IRUGO, + devicechannel_attr_clientpartition, NULL), + __ATTR(typeguid, S_IRUGO, + devicechannel_attr_typeguid, NULL), + __ATTR(zoneguid, S_IRUGO, + devicechannel_attr_zoneguid, NULL), + __ATTR(typename, S_IRUGO, + devicechannel_attr_typename, NULL), + __ATTR(dump, S_IRUGO, + devicechannel_attr_dump, NULL), +}; + +/* end implementation of specific channel attributes */ + +static ssize_t channel_attr_show(struct kobject *kobj, struct attribute *attr, + char *buf) +{ + struct channel_attribute *channel_attr = to_channel_attr(attr); + struct visor_device *dev = to_visor_device_from_kobjchannel(kobj); + ssize_t ret = 0; + + if (channel_attr->show) + ret = channel_attr->show(dev, buf); + return ret; +} + +static ssize_t channel_attr_store(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t count) +{ + struct channel_attribute *channel_attr = to_channel_attr(attr); + struct visor_device *dev = to_visor_device_from_kobjchannel(kobj); + ssize_t ret = 0; + + if (channel_attr->store) + ret = channel_attr->store(dev, buf, count); + return ret; +} + +static int channel_create_file(struct visor_device *dev, + struct channel_attribute *attr) +{ + return sysfs_create_file(&dev->kobjchannel, &attr->attr); +} + +static void channel_remove_file(struct visor_device *dev, + struct channel_attribute *attr) +{ + sysfs_remove_file(&dev->kobjchannel, &attr->attr); +} + +static const struct sysfs_ops channel_sysfs_ops = { + .show = channel_attr_show, + .store = channel_attr_store, +}; + +static struct kobj_type channel_kobj_type = { + .sysfs_ops = &channel_sysfs_ops +}; + +int register_channel_attributes(struct visor_device *dev) +{ + int rc = 0, i = 0, x = 0; + + if (dev->kobjchannel.parent) + goto away; /* already registered */ + x = kobject_init_and_add(&dev->kobjchannel, &channel_kobj_type, + &dev->device.kobj, "channel"); + if (x < 0) { + rc = x; + goto away; + } + + kobject_uevent(&dev->kobjchannel, KOBJ_ADD); + + for (i = 0; + i < sizeof(all_channel_attrs) / sizeof(struct channel_attribute); + i++) + x = channel_create_file(dev, &all_channel_attrs[i]); + if (x < 0) { + while (--i >= 0) + channel_remove_file(dev, &all_channel_attrs[i]); + kobject_del(&dev->kobjchannel); + kobject_put(&dev->kobjchannel); + rc = x; + goto away; + } +away: + return rc; +} + +void unregister_channel_attributes(struct visor_device *dev) +{ + int i = 0; + + if (!dev->kobjchannel.parent) + return; /* already unregistered */ + for (i = 0; + i < sizeof(all_channel_attrs) / sizeof(struct channel_attribute); + i++) + channel_remove_file(dev, &all_channel_attrs[i]); + + kobject_del(&dev->kobjchannel); + kobject_put(&dev->kobjchannel); + dev->kobjchannel.parent = NULL; +} diff --git a/drivers/staging/unisys/visorbus/channel_attr.h b/drivers/staging/unisys/visorbus/channel_attr.h new file mode 100644 index 000000000000..00ae37cb32ee --- /dev/null +++ b/drivers/staging/unisys/visorbus/channel_attr.h @@ -0,0 +1,27 @@ +/* channel_attr.h + * + * 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. + */ + +#ifndef __CHANNEL_ATTR_H__ +#define __CHANNEL_ATTR_H__ + +#include "visorbus.h" /* just to get visor_device declaration */ +#include "timskmod.h" + +int register_channel_attributes(struct visor_device *dev); +void unregister_channel_attributes(struct visor_device *dev); + +#endif diff --git a/drivers/staging/unisys/visorbus/devmajorminor_attr.c b/drivers/staging/unisys/visorbus/devmajorminor_attr.c new file mode 100644 index 000000000000..ceb4bb7394c6 --- /dev/null +++ b/drivers/staging/unisys/visorbus/devmajorminor_attr.c @@ -0,0 +1,192 @@ +/* devmajorminor_attr.c + * + * 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. + */ + +/* Implement publishing of device node attributes under: + * + * /sys/bus/visorbus/dev/devmajorminor + * + */ + +#include "devmajorminor_attr.h" +#define CURRENT_FILE_PC VISOR_BUS_PC_devmajorminor_attr_c + +#define to_devmajorminor_attr(_attr) \ + container_of(_attr, struct devmajorminor_attribute, attr) +#define to_visor_device_from_kobjdevmajorminor(obj) \ + container_of(obj, struct visor_device, kobjdevmajorminor) + +struct devmajorminor_attribute { + struct attribute attr; + int slot; + ssize_t (*show)(struct visor_device *, int slot, char *buf); + ssize_t (*store)(struct visor_device *, int slot, const char *buf, + size_t count); +}; + +static ssize_t DEVMAJORMINOR_ATTR(struct visor_device *dev, int slot, char *buf) +{ + int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]); + + if (slot < 0 || slot >= maxdevnodes) + return 0; + return snprintf(buf, PAGE_SIZE, "%d:%d\n", + dev->devnodes[slot].major, dev->devnodes[slot].minor); +} + +static ssize_t +devmajorminor_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) +{ + struct devmajorminor_attribute *devmajorminor_attr = + to_devmajorminor_attr(attr); + struct visor_device *dev = to_visor_device_from_kobjdevmajorminor(kobj); + ssize_t ret = 0; + + if (devmajorminor_attr->show) + ret = devmajorminor_attr->show(dev, + devmajorminor_attr->slot, buf); + return ret; +} + +static ssize_t +devmajorminor_attr_store(struct kobject *kobj, + struct attribute *attr, const char *buf, size_t count) +{ + struct devmajorminor_attribute *devmajorminor_attr = + to_devmajorminor_attr(attr); + struct visor_device *dev = to_visor_device_from_kobjdevmajorminor(kobj); + ssize_t ret = 0; + + if (devmajorminor_attr->store) + ret = devmajorminor_attr->store(dev, + devmajorminor_attr->slot, + buf, count); + return ret; +} + +int +devmajorminor_create_file(struct visor_device *dev, const char *name, + int major, int minor) +{ + int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]); + struct devmajorminor_attribute *myattr = NULL; + int x = -1, rc = 0, slot = -1; + + register_devmajorminor_attributes(dev); + for (slot = 0; slot < maxdevnodes; slot++) + if (!dev->devnodes[slot].attr) + break; + if (slot == maxdevnodes) { + rc = -ENOMEM; + goto away; + } + myattr = kmalloc(sizeof(*myattr), GFP_KERNEL); + if (!myattr) { + rc = -ENOMEM; + goto away; + } + memset(myattr, 0, sizeof(struct devmajorminor_attribute)); + myattr->show = DEVMAJORMINOR_ATTR; + myattr->store = NULL; + myattr->slot = slot; + myattr->attr.name = name; + myattr->attr.mode = S_IRUGO; + dev->devnodes[slot].attr = myattr; + dev->devnodes[slot].major = major; + dev->devnodes[slot].minor = minor; + x = sysfs_create_file(&dev->kobjdevmajorminor, &myattr->attr); + if (x < 0) { + rc = x; + goto away; + } + kobject_uevent(&dev->device.kobj, KOBJ_ONLINE); +away: + if (rc < 0) { + kfree(myattr); + myattr = NULL; + dev->devnodes[slot].attr = NULL; + } + return rc; +} + +void +devmajorminor_remove_file(struct visor_device *dev, int slot) +{ + int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]); + struct devmajorminor_attribute *myattr = NULL; + + if (slot < 0 || slot >= maxdevnodes) + return; + myattr = (struct devmajorminor_attribute *)(dev->devnodes[slot].attr); + if (myattr) + return; + sysfs_remove_file(&dev->kobjdevmajorminor, &myattr->attr); + kobject_uevent(&dev->device.kobj, KOBJ_OFFLINE); + dev->devnodes[slot].attr = NULL; + kfree(myattr); +} + +void +devmajorminor_remove_all_files(struct visor_device *dev) +{ + int i = 0; + int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]); + + for (i = 0; i < maxdevnodes; i++) + devmajorminor_remove_file(dev, i); +} + +static const struct sysfs_ops devmajorminor_sysfs_ops = { + .show = devmajorminor_attr_show, + .store = devmajorminor_attr_store, +}; + +static struct kobj_type devmajorminor_kobj_type = { + .sysfs_ops = &devmajorminor_sysfs_ops +}; + +int +register_devmajorminor_attributes(struct visor_device *dev) +{ + int rc = 0, x = 0; + + if (dev->kobjdevmajorminor.parent) + goto away; /* already registered */ + x = kobject_init_and_add(&dev->kobjdevmajorminor, + &devmajorminor_kobj_type, &dev->device.kobj, + "devmajorminor"); + if (x < 0) { + rc = x; + goto away; + } + + kobject_uevent(&dev->kobjdevmajorminor, KOBJ_ADD); + +away: + return rc; +} + +void +unregister_devmajorminor_attributes(struct visor_device *dev) +{ + if (!dev->kobjdevmajorminor.parent) + return; /* already unregistered */ + devmajorminor_remove_all_files(dev); + + kobject_del(&dev->kobjdevmajorminor); + kobject_put(&dev->kobjdevmajorminor); + dev->kobjdevmajorminor.parent = NULL; +} diff --git a/drivers/staging/unisys/visorbus/devmajorminor_attr.h b/drivers/staging/unisys/visorbus/devmajorminor_attr.h new file mode 100644 index 000000000000..0b55cb1df46a --- /dev/null +++ b/drivers/staging/unisys/visorbus/devmajorminor_attr.h @@ -0,0 +1,31 @@ +/* devmajorminor_attr.h + * + * 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. + */ + +#ifndef __DEVMAJORMINOR_ATTR_H__ +#define __DEVMAJORMINOR_ATTR_H__ + +#include "visorbus.h" /* just to get visor_device declaration */ +#include "timskmod.h" + +int register_devmajorminor_attributes(struct visor_device *dev); +void unregister_devmajorminor_attributes(struct visor_device *dev); +int devmajorminor_create_file(struct visor_device *dev, const char *nam, + int major, int minor); +void devmajorminor_remove_file(struct visor_device *dev, int slot); +void devmajorminor_remove_all_files(struct visor_device *dev); + +#endif diff --git a/drivers/staging/unisys/visorbus/visorbus.h b/drivers/staging/unisys/visorbus/visorbus.h new file mode 100644 index 000000000000..856fa3f6419c --- /dev/null +++ b/drivers/staging/unisys/visorbus/visorbus.h @@ -0,0 +1,166 @@ +/* visorbus.h + * + * 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. + */ + +/* + * This header file is to be included by other kernel mode components that + * implement a particular kind of visor_device. Each of these other kernel + * mode components is called a visor device driver. Refer to visortemplate + * for a minimal sample visor device driver. + * + * There should be nothing in this file that is private to the visorbus + * bus implementation itself. + * + */ + +#ifndef __VISORBUS_H__ +#define __VISORBUS_H__ + +#include +#include +#include +#include + +#include "periodic_work.h" +#include "visorchannel.h" +#include "channel.h" + +struct visor_driver; +struct visor_device; + +typedef void (*visorbus_state_complete_func) (struct visor_device *dev, + int status); + +/** This struct describes a specific Supervisor channel, by providing its + * GUID, name, and sizes. + */ +struct visor_channeltype_descriptor { + const uuid_le guid; + const char *name; + unsigned long min_size; + unsigned long max_size; +}; + +/** Information provided by each visor driver when it registers with the + * visorbus driver. + */ +struct visor_driver { + const char *name; + const char *version; + const char *vertag; + const char *build_date; + const char *build_time; + struct module *owner; + + /** Types of channels handled by this driver, ending with 0 GUID. + * Our specialized BUS.match() method knows about this list, and + * uses it to determine whether this driver will in fact handle a + * new device that it has detected. + */ + struct visor_channeltype_descriptor *channel_types; + + /** Called when a new device comes online, by our probe() function + * specified by driver.probe() (triggered ultimately by some call + * to driver_register() / bus_add_driver() / driver_attach()). + */ + int (*probe)(struct visor_device *dev); + + /** Called when a new device is removed, by our remove() function + * specified by driver.remove() (triggered ultimately by some call + * to device_release_driver()). + */ + void (*remove)(struct visor_device *dev); + + /** Called periodically, whenever there is a possibility that + * "something interesting" may have happened to the channel state. + */ + void (*channel_interrupt)(struct visor_device *dev); + + /** Called to initiate a change of the device's state. If the return + * valu`e is < 0, there was an error and the state transition will NOT + * occur. If the return value is >= 0, then the state transition was + * INITIATED successfully, and complete_func() will be called (or was + * just called) with the final status when either the state transition + * fails or completes successfully. + */ + int (*pause)(struct visor_device *dev, + visorbus_state_complete_func complete_func); + int (*resume)(struct visor_device *dev, + visorbus_state_complete_func complete_func); + + /** These fields are for private use by the bus driver only. */ + struct device_driver driver; + struct driver_attribute version_attr; +}; + +#define to_visor_driver(x) container_of(x, struct visor_driver, driver) + +/** A device type for things "plugged" into the visorbus bus */ + +struct visor_device { + /** visor driver can use the visorchannel member with the functions + * defined in visorchannel.h to access the channel + */ + struct visorchannel *visorchannel; + uuid_le channel_type_guid; + u64 channel_bytes; + + /** These fields are for private use by the bus driver only. + * A notable exception is that the visor driver can use + * visor_get_drvdata() and visor_set_drvdata() to retrieve or stash + * private visor driver specific data within the device member. + */ + struct device device; + struct list_head list_all; + struct periodic_work *periodic_work; + bool being_removed; + bool responded_to_device_create; + struct kobject kobjchannel; /* visorbus/dev/channel/ */ + struct kobject kobjdevmajorminor; /* visorbus/dev/devmajorminor/*/ + struct { + int major, minor; + void *attr; /* private use by devmajorminor_attr.c you can + * change this constant to whatever you + * want; */ + } devnodes[5]; + /* the code will detect and behave appropriately) */ + struct semaphore visordriver_callback_lock; + bool pausing; + bool resuming; + unsigned long chipset_bus_no; + unsigned long chipset_dev_no; +}; + +#define to_visor_device(x) container_of(x, struct visor_device, device) + +#ifndef STANDALONE_CLIENT +int visorbus_register_visor_driver(struct visor_driver *); +void visorbus_unregister_visor_driver(struct visor_driver *); +int visorbus_read_channel(struct visor_device *dev, + unsigned long offset, void *dest, + unsigned long nbytes); +int visorbus_write_channel(struct visor_device *dev, + unsigned long offset, void *src, + unsigned long nbytes); +int visorbus_clear_channel(struct visor_device *dev, + unsigned long offset, u8 ch, unsigned long nbytes); +int visorbus_registerdevnode(struct visor_device *dev, + const char *name, int major, int minor); +void visorbus_enable_channel_interrupts(struct visor_device *dev); +void visorbus_disable_channel_interrupts(struct visor_device *dev); +#endif + +#endif diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c new file mode 100644 index 000000000000..d717e35d5a1e --- /dev/null +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -0,0 +1,1643 @@ +/* visorbus_main.c + * + * Copyright � 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. + */ + +#include + +#include "visorbus_private.h" +#include "businst_attr.h" +#include "channel_attr.h" +#include "devmajorminor_attr.h" +#include "periodic_work.h" +#include "vbuschannel.h" +#include "guestlinuxdebug.h" +#include "vbusdeviceinfo.h" +/* These forward declarations are required since our drivers are out-of-tree. + * The structures referenced are kernel-private and are not in the headers, but + * it is impossible to make a functioning bus driver without them. + */ +struct subsys_private { + struct kset subsys; + struct kset *devices_kset; + + struct kset *drivers_kset; + struct klist klist_devices; + struct klist klist_drivers; + struct blocking_notifier_head bus_notifier; + unsigned int drivers_autoprobe:1; + struct bus_type *bus; + + struct list_head class_interfaces; + struct kset glue_dirs; + struct mutex class_mutex; /* ignore */ + struct class *class; +}; + +struct bus_type_private { + struct kset subsys; + struct kset *drivers_kset; + struct kset *devices_kset; + struct klist klist_devices; + struct klist klist_drivers; + struct blocking_notifier_head bus_notifier; + unsigned int drivers_autoprobe:1; + struct bus_type *bus; +}; + +#define CURRENT_FILE_PC VISOR_BUS_PC_visorbus_main_c +#define POLLJIFFIES_TESTWORK 100 +#define POLLJIFFIES_NORMALCHANNEL 10 + +static int visorbus_uevent(struct device *xdev, struct kobj_uevent_env *env); +static int visorbus_match(struct device *xdev, struct device_driver *xdrv); +static void fix_vbus_dev_info(struct visor_device *visordev); + +/** This describes the TYPE of bus. + * (Don't confuse this with an INSTANCE of the bus.) + */ +static struct bus_type visorbus_type = { + .name = "visorbus", + .match = visorbus_match, + .uevent = visorbus_uevent, +}; + +static struct delayed_work periodic_work; + +/* YES, we need 2 workqueues. + * The reason is, workitems on the test queue may need to cancel + * workitems on the other queue. You will be in for trouble if you try to + * do this with workitems queued on the same workqueue. + */ +static struct workqueue_struct *periodic_test_workqueue; +static struct workqueue_struct *periodic_dev_workqueue; +static long long bus_count; /** number of bus instances */ +static long long total_devices_created; + /** ever-increasing */ + +static void chipset_bus_create(u32 bus_no); +static void chipset_bus_destroy(u32 bus_no); +static void chipset_device_create(u32 bus_no, u32 dev_no); +static void chipset_device_destroy(u32 bus_no, u32 dev_no); +static void chipset_device_pause(u32 bus_no, u32 dev_no); +static void chipset_device_resume(u32 bus_no, u32 dev_no); + +/** These functions are implemented herein, and are called by the chipset + * driver to notify us about specific events. + */ +static struct visorchipset_busdev_notifiers chipset_notifiers = { + .bus_create = chipset_bus_create, + .bus_destroy = chipset_bus_destroy, + .device_create = chipset_device_create, + .device_destroy = chipset_device_destroy, + .device_pause = chipset_device_pause, + .device_resume = chipset_device_resume, +}; + +/** These functions are implemented in the chipset driver, and we call them + * herein when we want to acknowledge a specific event. + */ +static struct visorchipset_busdev_responders chipset_responders; + +/* filled in with info about parent chipset driver when we register with it */ +static struct ultra_vbus_deviceinfo chipset_driverinfo; +/* filled in with info about this driver, wrt it servicing client busses */ +static struct ultra_vbus_deviceinfo clientbus_driverinfo; + +/** list of visorbus_devdata structs, linked via .list_all */ +static LIST_HEAD(list_all_bus_instances); +/** list of visor_device structs, linked via .list_all */ +static LIST_HEAD(list_all_device_instances); + +static int +visorbus_uevent(struct device *xdev, struct kobj_uevent_env *env) +{ + if (add_uevent_var(env, "VERSION=%s", VERSION)) + return -ENOMEM; + return 0; +} + +/* This is called automatically upon adding a visor_device (device_add), or + * adding a visor_driver (visorbus_register_visor_driver), and returns 1 iff the + * provided driver can control the specified device. + */ +static int +visorbus_match(struct device *xdev, struct device_driver *xdrv) +{ + uuid_le channel_type; + int rc = 0; + int i; + struct visor_device *dev; + struct visor_driver *drv; + + dev = to_visor_device(xdev); + drv = to_visor_driver(xdrv); + channel_type = visorchannel_get_uuid(dev->visorchannel); + if (visorbus_forcematch) { + rc = 1; + goto away; + } + if (visorbus_forcenomatch) + goto away; + + if (!drv->channel_types) + goto away; + for (i = 0; + (uuid_le_cmp(drv->channel_types[i].guid, NULL_UUID_LE) != 0) || + (drv->channel_types[i].name); + i++) + if (uuid_le_cmp(drv->channel_types[i].guid, + channel_type) == 0) { + rc = i + 1; + goto away; + } +away: + return rc; +} + +/** This is called when device_unregister() is called for the bus device + * instance, after all other tasks involved with destroying the device + * are complete. + */ +static void +visorbus_release_busdevice(struct device *xdev) +{ + struct visorbus_devdata *devdata = dev_get_drvdata(xdev); + + dev_set_drvdata(xdev, NULL); + kfree(devdata); + kfree(xdev); +} + +/** This is called when device_unregister() is called for each child + * device instance. + */ +static void +visorbus_release_device(struct device *xdev) +{ + struct visor_device *dev = to_visor_device(xdev); + + if (dev->periodic_work) { + visor_periodic_work_destroy(dev->periodic_work); + dev->periodic_work = NULL; + } + if (dev->visorchannel) { + visorchannel_destroy(dev->visorchannel); + dev->visorchannel = NULL; + } + kfree(dev); +} + +static const struct sysfs_ops businst_sysfs_ops = { + .show = businst_attr_show, + .store = businst_attr_store, +}; + +static struct kobj_type businst_kobj_type = { + .sysfs_ops = &businst_sysfs_ops +}; + +static struct kset businstances = { /* should actually be a member of + * bus_type */ +}; + +/* BUS type attributes + * + * define & implement display of bus attributes under + * /sys/bus/visorbus. + * + */ + +static ssize_t +BUSTYPE_ATTR_version(struct bus_type *bus, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%s\n", VERSION); +} + +static struct bus_attribute bustype_attr_version = +__ATTR(version, S_IRUGO, BUSTYPE_ATTR_version, NULL); + +static int +register_bustype_attributes(void) +{ + int rc = 0; + + rc = bus_create_file(&visorbus_type, &bustype_attr_version); + if (rc < 0) + goto away; + + /* Here we make up for the fact that bus_type does not yet have a + * member to keep track of multiple bus instances for a given bus + * type. This is useful for stashing properties for each bus + * instance. + */ + kobject_set_name(&businstances.kobj, "busses"); + businstances.kobj.ktype = &businst_kobj_type; + businstances.kobj.parent = &visorbus_type.p->subsys.kobj; + rc = kset_register(&businstances); + if (rc < 0) + goto away; + + rc = 0; +away: + return rc; +} + +static void +unregister_bustype_attributes(void) +{ + bus_remove_file(&visorbus_type, &bustype_attr_version); + kset_unregister(&businstances); +} + +/* BUS instance attributes + * + * define & implement display of bus attributes under + * /sys/bus/visorbus/busses/visorbus. + * + * This is a bit hoaky because the kernel does not yet have the infrastructure + * to separate bus INSTANCE attributes from bus TYPE attributes... + * so we roll our own. See businst.c / businst.h. + * + */ + +static ssize_t businst_attr_partition_handle(struct visorbus_devdata *businst, + char *buf) { + struct visorchipset_bus_info bus_info; + int len = 0; + + if (businst && visorchipset_get_bus_info(businst->devno, &bus_info)) + len = snprintf(buf, PAGE_SIZE, + "0x%Lx\n", + (unsigned long long)bus_info.partition_handle); + return len; +} + +static ssize_t businst_attr_partition_guid(struct visorbus_devdata *businst, + char *buf) { + struct visorchipset_bus_info bus_info; + int len = 0; + + if (businst && visorchipset_get_bus_info(businst->devno, &bus_info)) + len = snprintf(buf, PAGE_SIZE, "{%pUb}\n", + &bus_info.partition_uuid); + return len; +} + +static ssize_t businst_attr_partition_name(struct visorbus_devdata *businst, + char *buf) { + struct visorchipset_bus_info bus_info; + int len = 0; + + if (businst && + visorchipset_get_bus_info(businst->devno, &bus_info) && + bus_info.name) + len = snprintf(buf, PAGE_SIZE, "%s\n", bus_info.name); + return len; +} + +static ssize_t businst_attr_channel_addr(struct visorbus_devdata *businst, + char *buf) { + struct visorchipset_bus_info bus_info; + int len = 0; + + if (businst && visorchipset_get_bus_info(businst->devno, &bus_info)) + len = snprintf(buf, PAGE_SIZE, "0x%Lx\n", (unsigned long long) + bus_info.chan_info.channel_addr); + return len; +} + +static ssize_t businst_attr_nchannel_bytes(struct visorbus_devdata *businst, + char *buf) { + struct visorchipset_bus_info bus_info; + int len = 0; + + if (businst && visorchipset_get_bus_info(businst->devno, &bus_info)) + len = snprintf(buf, PAGE_SIZE, "0x%Lx\n", (unsigned long long) + bus_info.chan_info.n_channel_bytes); + return len; +} + +static ssize_t businst_attr_channel_id(struct visorbus_devdata *businst, + char *buf) { + int len = 0; + + if (businst && businst->chan) { + visorchannel_id(businst->chan, buf); + len = strlen(buf); + buf[len++] = '\n'; + } + return len; +} + +static ssize_t businst_attr_client_bus_info(struct visorbus_devdata *businst, + char *buf) { + struct visorchipset_bus_info bus_info; + int i, x, remain = PAGE_SIZE; + unsigned long off; + char *p = buf; + u8 *partition_name; + struct ultra_vbus_deviceinfo dev_info; + + partition_name = ""; + if (businst && businst->chan) { + if (visorchipset_get_bus_info(businst->devno, &bus_info) && + bus_info.name) + partition_name = bus_info.name; + x = snprintf(p, remain, + "Client device / client driver info for %s partition (vbus #%d):\n", + partition_name, businst->devno); + p += x; + remain -= x; + x = visorchannel_read(businst->chan, + offsetof(struct + spar_vbus_channel_protocol, + chp_info), + &dev_info, sizeof(dev_info)); + if (x >= 0) { + x = vbuschannel_devinfo_to_string(&dev_info, p, + remain, -1); + p += x; + remain -= x; + } + x = visorchannel_read(businst->chan, + offsetof(struct + spar_vbus_channel_protocol, + bus_info), + &dev_info, sizeof(dev_info)); + if (x >= 0) { + x = vbuschannel_devinfo_to_string(&dev_info, p, + remain, -1); + p += x; + remain -= x; + } + off = offsetof(struct spar_vbus_channel_protocol, dev_info); + i = 0; + while (off + sizeof(dev_info) <= + visorchannel_get_nbytes(businst->chan)) { + x = visorchannel_read(businst->chan, + off, &dev_info, sizeof(dev_info)); + if (x >= 0) { + x = vbuschannel_devinfo_to_string + (&dev_info, p, remain, i); + p += x; + remain -= x; + } + off += sizeof(dev_info); + i++; + } + } + return PAGE_SIZE - remain; +} + +static struct businst_attribute ba_partition_handle = + __ATTR(partition_handle, S_IRUGO, businst_attr_partition_handle, NULL); +static struct businst_attribute ba_partition_guid = + __ATTR(partition_guid, S_IRUGO, businst_attr_partition_guid, NULL); +static struct businst_attribute ba_partition_name = + __ATTR(partition_name, S_IRUGO, businst_attr_partition_name, NULL); +static struct businst_attribute ba_channel_addr = + __ATTR(channel_addr, S_IRUGO, businst_attr_channel_addr, NULL); +static struct businst_attribute ba_nchannel_bytes = + __ATTR(nchannel_bytes, S_IRUGO, businst_attr_nchannel_bytes, NULL); +static struct businst_attribute ba_channel_id = + __ATTR(channel_id, S_IRUGO, businst_attr_channel_id, NULL); +static struct businst_attribute ba_client_bus_info = + __ATTR(client_bus_info, S_IRUGO, businst_attr_client_bus_info, NULL); + +static int +register_businst_attributes(struct visorbus_devdata *businst) +{ + int rc = 0; + + businst->kobj.kset = &businstances; /* identify parent sysfs dir */ + rc = kobject_init_and_add(&businst->kobj, &businst_kobj_type, + NULL, "visorbus%d", businst->devno); + if (rc < 0) + goto away; + + rc = businst_create_file(businst, &ba_partition_handle); + if (rc < 0) + goto away; + + rc = businst_create_file(businst, &ba_partition_guid); + if (rc < 0) + goto away; + + rc = businst_create_file(businst, &ba_partition_name); + if (rc < 0) + goto away; + + rc = businst_create_file(businst, &ba_channel_addr); + if (rc < 0) + goto away; + + rc = businst_create_file(businst, &ba_nchannel_bytes); + if (rc < 0) + goto away; + + rc = businst_create_file(businst, &ba_channel_id); + if (rc < 0) + goto away; + + rc = businst_create_file(businst, &ba_client_bus_info); + if (rc < 0) + goto away; + + kobject_uevent(&businst->kobj, KOBJ_ADD); + + rc = 0; +away: + return rc; +} + +static void +unregister_businst_attributes(struct visorbus_devdata *businst) +{ + businst_remove_file(businst, &ba_partition_handle); + businst_remove_file(businst, &ba_partition_guid); + businst_remove_file(businst, &ba_partition_name); + businst_remove_file(businst, &ba_channel_addr); + businst_remove_file(businst, &ba_nchannel_bytes); + businst_remove_file(businst, &ba_channel_id); + businst_remove_file(businst, &ba_client_bus_info); + kobject_put(&businst->kobj); +} + +/* DRIVER attributes + * + * define & implement display of driver attributes under + * /sys/bus/visorbus/drivers/. + * + */ + +static ssize_t +DRIVER_ATTR_version(struct device_driver *xdrv, char *buf) +{ + struct visor_driver *drv = to_visor_driver(xdrv); + + return snprintf(buf, PAGE_SIZE, "%s\n", drv->version); +} + +static int +register_driver_attributes(struct visor_driver *drv) +{ + int rc; + struct driver_attribute version = + __ATTR(version, S_IRUGO, DRIVER_ATTR_version, NULL); + drv->version_attr = version; + rc = driver_create_file(&drv->driver, &drv->version_attr); + return rc; +} + +static void +unregister_driver_attributes(struct visor_driver *drv) +{ + driver_remove_file(&drv->driver, &drv->version_attr); +} + +/* DEVICE attributes + * + * define & implement display of device attributes under + * /sys/bus/visorbus/devices/. + * + */ + +#define DEVATTR(nam, func) { \ + .attr = { .name = __stringify(nam), \ + .mode = 0444, \ + .owner = THIS_MODULE }, \ + .show = func, \ +} + +static struct device_attribute visor_device_attrs[] = { + /* DEVATTR(channel_nbytes, DEVICE_ATTR_channel_nbytes), */ + __ATTR_NULL +}; + +static void +dev_periodic_work(void *xdev) +{ + struct visor_device *dev = (struct visor_device *)xdev; + struct visor_driver *drv = to_visor_driver(dev->device.driver); + + down(&dev->visordriver_callback_lock); + if (drv->channel_interrupt) + drv->channel_interrupt(dev); + up(&dev->visordriver_callback_lock); + if (!visor_periodic_work_nextperiod(dev->periodic_work)) + put_device(&dev->device); +} + +static void +dev_start_periodic_work(struct visor_device *dev) +{ + if (dev->being_removed) + return; + /* now up by at least 2 */ + get_device(&dev->device); + if (!visor_periodic_work_start(dev->periodic_work)) + put_device(&dev->device); +} + +static void +dev_stop_periodic_work(struct visor_device *dev) +{ + if (visor_periodic_work_stop(dev->periodic_work)) + put_device(&dev->device); +} + +/** This is called automatically upon adding a visor_device (device_add), or + * adding a visor_driver (visorbus_register_visor_driver), but only after + * visorbus_match has returned 1 to indicate a successful match between + * driver and device. + */ +static int +visordriver_probe_device(struct device *xdev) +{ + int rc; + struct visor_driver *drv; + struct visor_device *dev; + + drv = to_visor_driver(xdev->driver); + dev = to_visor_device(xdev); + down(&dev->visordriver_callback_lock); + dev->being_removed = FALSE; + /* + * ensure that the dev->being_removed flag is cleared before + * we start the probe + */ + wmb(); + get_device(&dev->device); + if (!drv->probe) { + up(&dev->visordriver_callback_lock); + rc = -1; + goto away; + } + rc = drv->probe(dev); + if (rc < 0) + goto away; + + fix_vbus_dev_info(dev); + up(&dev->visordriver_callback_lock); + rc = 0; +away: + if (rc != 0) + put_device(&dev->device); + /* We could get here more than once if the child driver module is + * unloaded and re-loaded while devices are present. That's why we + * need a flag to be sure that we only respond to the device_create + * once. We cannot respond to the device_create prior to here, + * because until we call drv->probe() above, the channel has not been + * initialized. + */ + if (!dev->responded_to_device_create) { + dev->responded_to_device_create = TRUE; + if (chipset_responders.device_create) + (*chipset_responders.device_create)(dev->chipset_bus_no, + dev->chipset_dev_no, + rc); + } + return rc; +} + +/** This is called when device_unregister() is called for each child device + * instance, to notify the appropriate visorbus_driver that the device is + * going away, and to decrease the reference count of the device. + */ +static int +visordriver_remove_device(struct device *xdev) +{ + int rc = 0; + struct visor_device *dev; + struct visor_driver *drv; + + dev = to_visor_device(xdev); + drv = to_visor_driver(xdev->driver); + down(&dev->visordriver_callback_lock); + dev->being_removed = TRUE; + /* + * ensure that the dev->being_removed flag is set before we start the + * actual removal + */ + wmb(); + if (drv) { + if (drv->remove) + drv->remove(dev); + } + up(&dev->visordriver_callback_lock); + dev_stop_periodic_work(dev); + devmajorminor_remove_all_files(dev); + + put_device(&dev->device); + + return rc; +} + +/** A particular type of visor driver calls this function to register + * the driver. The caller MUST fill in the following fields within the + * #drv structure: + * name, version, owner, channel_types, probe, remove + * + * Here's how the whole Linux bus / driver / device model works. + * + * At system start-up, the visorbus kernel module is loaded, which registers + * visorbus_type as a bus type, using bus_register(). + * + * All kernel modules that support particular device types on a + * visorbus bus are loaded. Each of these kernel modules calls + * visorbus_register_visor_driver() in their init functions, passing a + * visor_driver struct. visorbus_register_visor_driver() in turn calls + * register_driver(&visor_driver.driver). This .driver member is + * initialized with generic methods (like probe), whose sole responsibility + * is to act as a broker for the real methods, which are within the + * visor_driver struct. (This is the way the subclass behavior is + * implemented, since visor_driver is essentially a subclass of the + * generic driver.) Whenever a driver_register() happens, core bus code in + * the kernel does (see device_attach() in drivers/base/dd.c): + * + * for each dev associated with the bus (the bus that driver is on) that + * does not yet have a driver + * if bus.match(dev,newdriver) == yes_matched ** .match specified + * ** during bus_register(). + * newdriver.probe(dev) ** for visor drivers, this will call + * ** the generic driver.probe implemented in visorbus.c, + * ** which in turn calls the probe specified within the + * ** struct visor_driver (which was specified by the + * ** actual device driver as part of + * ** visorbus_register_visor_driver()). + * + * The above dance also happens when a new device appears. + * So the question is, how are devices created within the system? + * Basically, just call device_add(dev). See pci_bus_add_devices(). + * pci_scan_device() shows an example of how to build a device struct. It + * returns the newly-created struct to pci_scan_single_device(), who adds it + * to the list of devices at PCIBUS.devices. That list of devices is what + * is traversed by pci_bus_add_devices(). + * + */ +int visorbus_register_visor_driver(struct visor_driver *drv) +{ + int rc = 0; + + drv->driver.name = drv->name; + drv->driver.bus = &visorbus_type; + drv->driver.probe = visordriver_probe_device; + drv->driver.remove = visordriver_remove_device; + drv->driver.owner = drv->owner; + + /* driver_register does this: + * bus_add_driver(drv) + * ->if (drv.bus) ** (bus_type) ** + * driver_attach(drv) + * for each dev with bus type of drv.bus + * if (!dev.drv) ** no driver assigned yet ** + * if (bus.match(dev,drv)) [visorbus_match] + * dev.drv = drv + * if (!drv.probe(dev)) [visordriver_probe_device] + * dev.drv = NULL + */ + + rc = driver_register(&drv->driver); + if (rc < 0) + return rc; + rc = register_driver_attributes(drv); + return rc; +} +EXPORT_SYMBOL_GPL(visorbus_register_visor_driver); + +/** A particular type of visor driver calls this function to unregister + * the driver, i.e., within its module_exit function. + */ +void +visorbus_unregister_visor_driver(struct visor_driver *drv) +{ + unregister_driver_attributes(drv); + driver_unregister(&drv->driver); +} +EXPORT_SYMBOL_GPL(visorbus_unregister_visor_driver); + +int +visorbus_read_channel(struct visor_device *dev, unsigned long offset, + void *dest, unsigned long nbytes) +{ + return visorchannel_read(dev->visorchannel, offset, dest, nbytes); +} +EXPORT_SYMBOL_GPL(visorbus_read_channel); + +int +visorbus_write_channel(struct visor_device *dev, unsigned long offset, + void *src, unsigned long nbytes) +{ + return visorchannel_write(dev->visorchannel, offset, src, nbytes); +} +EXPORT_SYMBOL_GPL(visorbus_write_channel); + +int +visorbus_clear_channel(struct visor_device *dev, unsigned long offset, u8 ch, + unsigned long nbytes) +{ + return visorchannel_clear(dev->visorchannel, offset, ch, nbytes); +} +EXPORT_SYMBOL_GPL(visorbus_clear_channel); + +int +visorbus_registerdevnode(struct visor_device *dev, + const char *name, int major, int minor) +{ + return devmajorminor_create_file(dev, name, major, minor); +} +EXPORT_SYMBOL_GPL(visorbus_registerdevnode); + +/** We don't really have a real interrupt, so for now we just call the + * interrupt function periodically... + */ +void +visorbus_enable_channel_interrupts(struct visor_device *dev) +{ + dev_start_periodic_work(dev); +} +EXPORT_SYMBOL_GPL(visorbus_enable_channel_interrupts); + +void +visorbus_disable_channel_interrupts(struct visor_device *dev) +{ + dev_stop_periodic_work(dev); +} +EXPORT_SYMBOL_GPL(visorbus_disable_channel_interrupts); + +/** This is how everything starts from the device end. + * This function is called when a channel first appears via a ControlVM + * message. In response, this function allocates a visor_device to + * correspond to the new channel, and attempts to connect it the appropriate + * driver. If the appropriate driver is found, the visor_driver.probe() + * function for that driver will be called, and will be passed the new + * visor_device that we just created. + * + * It's ok if the appropriate driver is not yet loaded, because in that case + * the new device struct will just stick around in the bus' list of devices. + * When the appropriate driver calls visorbus_register_visor_driver(), the + * visor_driver.probe() for the new driver will be called with the new + * device. + */ +static int +create_visor_device(struct visorbus_devdata *devdata, + unsigned long chipset_bus_no, unsigned long chipset_dev_no, + struct visorchipset_channel_info chan_info, + u64 partition_handle) +{ + int rc = -1; + struct visorchannel *visorchannel = NULL; + struct visor_device *dev = NULL; + bool gotten = FALSE, registered1 = FALSE, registered2 = FALSE; + + POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, chipset_dev_no, chipset_bus_no, + POSTCODE_SEVERITY_INFO); + /* prepare chan_hdr (abstraction to read/write channel memory) */ + visorchannel = visorchannel_create(chan_info.channel_addr, + (unsigned long) + chan_info.n_channel_bytes, + chan_info.channel_type_uuid); + if (!visorchannel) { + POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, chipset_dev_no, + DIAG_SEVERITY_ERR); + goto away; + } + dev = kmalloc(sizeof(*dev), GFP_KERNEL); + if (!dev) { + POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, chipset_dev_no, + DIAG_SEVERITY_ERR); + goto away; + } + + memset(dev, 0, sizeof(struct visor_device)); + dev->visorchannel = visorchannel; + dev->channel_type_guid = chan_info.channel_type_uuid; + dev->channel_bytes = chan_info.n_channel_bytes; + dev->chipset_bus_no = chipset_bus_no; + dev->chipset_dev_no = chipset_dev_no; + dev->device.parent = devdata->dev; + sema_init(&dev->visordriver_callback_lock, 1); /* unlocked */ + dev->device.bus = &visorbus_type; + device_initialize(&dev->device); + dev->device.release = visorbus_release_device; + /* keep a reference just for us (now 2) */ + get_device(&dev->device); + gotten = TRUE; + dev->periodic_work = + visor_periodic_work_create(POLLJIFFIES_NORMALCHANNEL, + periodic_dev_workqueue, + dev_periodic_work, + dev, dev_name(&dev->device)); + if (!dev->periodic_work) { + POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, chipset_dev_no, + DIAG_SEVERITY_ERR); + goto away; + } + + /* bus_id must be a unique name with respect to this bus TYPE + * (NOT bus instance). That's why we need to include the bus + * number within the name. + */ + dev_set_name(&dev->device, "vbus%lu:dev%lu", + chipset_bus_no, chipset_dev_no); + + /* device_add does this: + * bus_add_device(dev) + * ->device_attach(dev) + * ->for each driver drv registered on the bus that dev is on + * if (dev.drv) ** device already has a driver ** + * ** not sure we could ever get here... ** + * else + * if (bus.match(dev,drv)) [visorbus_match] + * dev.drv = drv + * if (!drv.probe(dev)) [visordriver_probe_device] + * dev.drv = NULL + * + * Note that device_add does NOT fail if no driver failed to + * claim the device. The device will be linked onto + * bus_type.klist_devices regardless (use bus_for_each_dev). + */ + rc = device_add(&dev->device); + if (rc < 0) { + POSTCODE_LINUX_3(DEVICE_ADD_PC, chipset_bus_no, + DIAG_SEVERITY_ERR); + goto away; + } + + /* note: device_register is simply device_initialize + device_add */ + rc = register_channel_attributes(dev); + if (rc < 0) { + POSTCODE_LINUX_3(DEVICE_REGISTER_FAILURE_PC, chipset_dev_no, + DIAG_SEVERITY_ERR); + goto away; + } + + registered1 = TRUE; + + rc = register_devmajorminor_attributes(dev); + if (rc < 0) { + POSTCODE_LINUX_3(DEVICE_REGISTER_FAILURE_PC, chipset_dev_no, + DIAG_SEVERITY_ERR); + goto away; + } + + registered2 = TRUE; + rc = 0; + +away: + if (rc < 0) { + if (registered2) + unregister_devmajorminor_attributes(dev); + if (registered1) + unregister_channel_attributes(dev); + if (gotten) + put_device(&dev->device); + if (visorchannel) + visorchannel_destroy(visorchannel); + kfree(dev); + } else { + total_devices_created++; + list_add_tail(&dev->list_all, &list_all_device_instances); + } + return rc; +} + +static void +remove_visor_device(struct visor_device *dev) +{ + list_del(&dev->list_all); + unregister_devmajorminor_attributes(dev); + unregister_channel_attributes(dev); + put_device(&dev->device); + device_unregister(&dev->device); +} + +static struct visor_device * +find_visor_device_by_channel(HOSTADDRESS channel_physaddr) +{ + struct list_head *listentry, *listtmp; + + list_for_each_safe(listentry, listtmp, &list_all_device_instances) { + struct visor_device *dev = list_entry(listentry, + struct visor_device, + list_all); + if (visorchannel_get_physaddr(dev->visorchannel) == + channel_physaddr) + return dev; + } + return NULL; +} + +static int +init_vbus_channel(struct visorchannel *chan) +{ + int rc = -1; + unsigned long allocated_bytes = visorchannel_get_nbytes(chan); + struct spar_vbus_channel_protocol *x = + kmalloc(sizeof(struct spar_vbus_channel_protocol), + GFP_KERNEL); + + POSTCODE_LINUX_3(VBUS_CHANNEL_ENTRY_PC, rc, POSTCODE_SEVERITY_INFO); + + if (x) { + POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR); + goto away; + } + if (visorchannel_clear(chan, 0, 0, allocated_bytes) < 0) { + POSTCODE_LINUX_2(VBUS_CHANNEL_FAILURE_PC, + POSTCODE_SEVERITY_ERR); + goto away; + } + if (visorchannel_read + (chan, 0, x, sizeof(struct spar_vbus_channel_protocol)) < 0) { + POSTCODE_LINUX_2(VBUS_CHANNEL_FAILURE_PC, + POSTCODE_SEVERITY_ERR); + goto away; + } + if (!SPAR_VBUS_CHANNEL_OK_SERVER(allocated_bytes)) { + POSTCODE_LINUX_2(VBUS_CHANNEL_FAILURE_PC, + POSTCODE_SEVERITY_ERR); + goto away; + } + + if (visorchannel_write + (chan, 0, x, sizeof(struct spar_vbus_channel_protocol)) < 0) { + POSTCODE_LINUX_3(VBUS_CHANNEL_FAILURE_PC, chan, + POSTCODE_SEVERITY_ERR); + goto away; + } + + POSTCODE_LINUX_3(VBUS_CHANNEL_EXIT_PC, chan, POSTCODE_SEVERITY_INFO); + rc = 0; + +away: + kfree(x); + x = NULL; + return rc; +} + +static int +get_vbus_header_info(struct visorchannel *chan, + struct spar_vbus_headerinfo *hdr_info) +{ + int rc = -1; + + if (!SPAR_VBUS_CHANNEL_OK_CLIENT(visorchannel_get_header(chan))) + goto away; + if (visorchannel_read(chan, sizeof(struct channel_header), hdr_info, + sizeof(*hdr_info)) < 0) { + goto away; + } + if (hdr_info->struct_bytes < sizeof(struct spar_vbus_headerinfo)) + goto away; + if (hdr_info->device_info_struct_bytes < + sizeof(struct ultra_vbus_deviceinfo)) { + goto away; + } + rc = 0; +away: + return rc; +} + +/* Write the contents of to the struct + * spar_vbus_channel_protocol.chp_info. */ + +static int +write_vbus_chp_info(struct visorchannel *chan, + struct spar_vbus_headerinfo *hdr_info, + struct ultra_vbus_deviceinfo *info) +{ + int off = sizeof(struct channel_header) + hdr_info->chp_info_offset; + + if (hdr_info->chp_info_offset == 0) + return -1; + + if (visorchannel_write(chan, off, info, sizeof(*info)) < 0) + return -1; + return 0; +} + +/* Write the contents of to the struct + * spar_vbus_channel_protocol.bus_info. */ + +static int +write_vbus_bus_info(struct visorchannel *chan, + struct spar_vbus_headerinfo *hdr_info, + struct ultra_vbus_deviceinfo *info) +{ + int off = sizeof(struct channel_header) + hdr_info->bus_info_offset; + + if (hdr_info->bus_info_offset == 0) + return -1; + + if (visorchannel_write(chan, off, info, sizeof(*info)) < 0) + return -1; + return 0; +} + +/* Write the contents of to the + * struct spar_vbus_channel_protocol.dev_info[]. + */ +static int +write_vbus_dev_info(struct visorchannel *chan, + struct spar_vbus_headerinfo *hdr_info, + struct ultra_vbus_deviceinfo *info, int devix) +{ + int off = + (sizeof(struct channel_header) + hdr_info->dev_info_offset) + + (hdr_info->device_info_struct_bytes * devix); + + if (hdr_info->dev_info_offset == 0) + return -1; + + if (visorchannel_write(chan, off, info, sizeof(*info)) < 0) + return -1; + return 0; +} + +/* For a child device just created on a client bus, fill in + * information about the driver that is controlling this device into + * the the appropriate slot within the vbus channel of the bus + * instance. + */ +static void +fix_vbus_dev_info(struct visor_device *visordev) +{ + int i; + struct visorchipset_bus_info bus_info; + struct visorbus_devdata *devdata = NULL; + struct visor_driver *visordrv; + int bus_no = visordev->chipset_bus_no; + int dev_no = visordev->chipset_dev_no; + struct ultra_vbus_deviceinfo dev_info; + const char *chan_type_name = NULL; + + if (!visordev->device.driver) + return; + + visordrv = to_visor_driver(visordev->device.driver); + if (!visorchipset_get_bus_info(bus_no, &bus_info)) + return; + + devdata = (struct visorbus_devdata *)(bus_info.bus_driver_context); + if (!devdata) + return; + + if (!devdata->vbus_valid) + return; + + /* Within the list of device types (by GUID) that the driver + * says it supports, find out which one of those types matches + * the type of this device, so that we can include the device + * type name + */ + for (i = 0; visordrv->channel_types[i].name; i++) { + if (STRUCTSEQUAL(visordrv->channel_types[i].guid, + visordev->channel_type_guid)) { + chan_type_name = visordrv->channel_types[i].name; + break; + } + } + + bus_device_info_init(&dev_info, chan_type_name, + visordrv->name, visordrv->version, + visordrv->vertag); + write_vbus_dev_info(devdata->chan, + &devdata->vbus_hdr_info, &dev_info, dev_no); + + /* Re-write bus+chipset info, because it is possible that this + * was previously written by our evil counterpart, virtpci. + */ + write_vbus_chp_info(devdata->chan, &devdata->vbus_hdr_info, + &chipset_driverinfo); + write_vbus_bus_info(devdata->chan, &devdata->vbus_hdr_info, + &clientbus_driverinfo); +} + +/** Create a device instance for the visor bus itself. + */ +static struct visorbus_devdata * +create_bus_instance(int id) +{ + struct visorbus_devdata *rc = NULL; + struct visorbus_devdata *devdata = NULL; + struct device *dev; + struct visorchipset_bus_info bus_info; + + POSTCODE_LINUX_2(BUS_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); + dev = kmalloc(sizeof(*dev), GFP_KERNEL); + if (!dev) { + POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR); + rc = NULL; + goto away; + } + memset(dev, 0, sizeof(struct device)); + dev_set_name(dev, "visorbus%d", id); + dev->release = visorbus_release_busdevice; + if (device_register(dev) < 0) { + POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, id, + POSTCODE_SEVERITY_ERR); + rc = NULL; + goto away; + } + devdata = kmalloc(sizeof(*devdata), GFP_KERNEL); + if (!devdata) { + POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR); + rc = NULL; + goto away; + } + memset(devdata, 0, sizeof(struct visorbus_devdata)); + devdata->devno = id; + devdata->dev = dev; + if ((visorchipset_get_bus_info(id, &bus_info)) && + (bus_info.chan_info.channel_addr > 0) && + (bus_info.chan_info.n_channel_bytes > 0)) { + HOSTADDRESS channel_addr = bus_info.chan_info.channel_addr; + unsigned long n_channel_bytes = + (unsigned long) + bus_info.chan_info.n_channel_bytes; + uuid_le channel_type_guid = + bus_info.chan_info.channel_type_uuid; + + devdata->chan = visorchannel_create(channel_addr, + n_channel_bytes, + channel_type_guid); + if (!devdata->chan) { + POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, channel_addr, + POSTCODE_SEVERITY_ERR); + } else { + if (bus_info.flags.server) { + init_vbus_channel(devdata->chan); + } else { + if (get_vbus_header_info(devdata->chan, + &devdata-> + vbus_hdr_info) >= 0) { + devdata->vbus_valid = TRUE; + write_vbus_chp_info(devdata->chan, + &devdata-> + vbus_hdr_info, + &chipset_driverinfo + ); + write_vbus_bus_info(devdata->chan, + &devdata-> + vbus_hdr_info, + &clientbus_driverinfo); + } + } + } + } + register_businst_attributes(devdata); + bus_count++; + list_add_tail(&devdata->list_all, &list_all_bus_instances); + if (id == 0) + devdata = devdata; /* for testing ONLY */ + dev_set_drvdata(dev, devdata); + rc = devdata; +away: + return rc; +} + +/** Remove a device instance for the visor bus itself. + */ +static void +remove_bus_instance(struct visorbus_devdata *devdata) +{ + /* Note that this will result in the release method for + * devdata->dev being called, which will call + * visorbus_release_busdevice(). This has something to do with + * the put_device() done in device_unregister(), but I have never + * successfully been able to trace thru the code to see where/how + * release() gets called. But I know it does. + */ + unregister_businst_attributes(devdata); + bus_count--; + if (devdata->chan) { + visorchannel_destroy(devdata->chan); + devdata->chan = NULL; + } + list_del(&devdata->list_all); + device_unregister(devdata->dev); +} + +/** Create and register the one-and-only one instance of + * the visor bus type (visorbus_type). + */ +static int +create_bus_type(void) +{ + int rc = 0; + + visorbus_type.dev_attrs = visor_device_attrs; + rc = bus_register(&visorbus_type); + if (rc < 0) + return rc; + + rc = register_bustype_attributes(); + return rc; +} + +/** Remove the one-and-only one instance of the visor bus type (visorbus_type). + */ +static void +remove_bus_type(void) +{ + unregister_bustype_attributes(); + bus_unregister(&visorbus_type); +} + +/** Remove all child visor bus device instances. + */ +static void +remove_all_visor_devices(void) +{ + struct list_head *listentry, *listtmp; + + list_for_each_safe(listentry, listtmp, &list_all_device_instances) { + struct visor_device *dev = list_entry(listentry, + struct visor_device, + list_all); + remove_visor_device(dev); + } +} + +static bool entered_testing_mode = FALSE; +static struct visorchipset_channel_info test_channel_infos[MAXDEVICETEST]; +static unsigned long test_bus_nos[MAXDEVICETEST]; +static unsigned long test_dev_nos[MAXDEVICETEST]; + +static void +chipset_bus_create(u32 bus_no) +{ + struct visorchipset_bus_info bus_info; + struct visorbus_devdata *devdata; + int rc = -1; + + POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO); + if (!visorchipset_get_bus_info(bus_no, &bus_info)) + goto away; + devdata = create_bus_instance(bus_no); + if (!devdata) + goto away; + if (!visorchipset_set_bus_context(bus_no, devdata)) + goto away; + POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO); + rc = 0; +away: + if (rc < 0) { + POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no, + POSTCODE_SEVERITY_ERR); + return; + } + POSTCODE_LINUX_3(CHIPSET_INIT_SUCCESS_PC, bus_no, + POSTCODE_SEVERITY_INFO); + if (chipset_responders.bus_create) + (*chipset_responders.bus_create) (bus_no, rc); +} + +static void +chipset_bus_destroy(u32 bus_no) +{ + struct visorchipset_bus_info bus_info; + struct visorbus_devdata *devdata; + int rc = -1; + + if (!visorchipset_get_bus_info(bus_no, &bus_info)) + goto away; + devdata = (struct visorbus_devdata *)(bus_info.bus_driver_context); + if (!devdata) + goto away; + remove_bus_instance(devdata); + if (!visorchipset_set_bus_context(bus_no, NULL)) + goto away; + rc = 0; +away: + if (rc < 0) + return; + if (chipset_responders.bus_destroy) + (*chipset_responders.bus_destroy)(bus_no, rc); +} + +static void +chipset_device_create(u32 bus_no, u32 dev_no) +{ + struct visorchipset_device_info dev_info; + struct visorchipset_bus_info bus_info; + struct visorbus_devdata *devdata = NULL; + int rc = -1; + + POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no, + POSTCODE_SEVERITY_INFO); + + if (entered_testing_mode) + return; + if (!visorchipset_get_device_info(bus_no, dev_no, &dev_info)) + goto away; + if (!visorchipset_get_bus_info(bus_no, &bus_info)) + goto away; + if (visorbus_devicetest) + if (total_devices_created < MAXDEVICETEST) { + test_channel_infos[total_devices_created] = + dev_info.chan_info; + test_bus_nos[total_devices_created] = bus_no; + test_dev_nos[total_devices_created] = dev_no; + } + POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no, + POSTCODE_SEVERITY_INFO); + rc = 0; +away: + if (rc < 0) { + POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, + POSTCODE_SEVERITY_ERR); + return; + } + devdata = (struct visorbus_devdata *)(bus_info.bus_driver_context); + rc = create_visor_device(devdata, bus_no, dev_no, + dev_info.chan_info, bus_info.partition_handle); + POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, dev_no, bus_no, + POSTCODE_SEVERITY_INFO); + if (rc < 0) + if (chipset_responders.device_create) + (*chipset_responders.device_create)(bus_no, dev_no, rc); +} + +static void +chipset_device_destroy(u32 bus_no, u32 dev_no) +{ + struct visorchipset_device_info dev_info; + struct visor_device *dev; + int rc = -1; + + if (entered_testing_mode) + return; + if (!visorchipset_get_device_info(bus_no, dev_no, &dev_info)) + goto away; + dev = find_visor_device_by_channel(dev_info.chan_info.channel_addr); + if (!dev) + goto away; + rc = 0; +away: + if (rc < 0) + return; + + if (chipset_responders.device_destroy) + (*chipset_responders.device_destroy) (bus_no, dev_no, rc); + remove_visor_device(dev); +} + +/* This is the callback function specified for a function driver, to + * be called when a pending "pause device" operation has been + * completed. + */ +static void +pause_state_change_complete(struct visor_device *dev, int status) +{ + if (!dev->pausing) + return; + + dev->pausing = FALSE; + if (!chipset_responders.device_pause) /* this can never happen! */ + return; + + /* Notify the chipset driver that the pause is complete, which + * will presumably want to send some sort of response to the + * initiator. */ + (*chipset_responders.device_pause) (dev->chipset_bus_no, + dev->chipset_dev_no, status); +} + +/* This is the callback function specified for a function driver, to + * be called when a pending "resume device" operation has been + * completed. + */ +static void +resume_state_change_complete(struct visor_device *dev, int status) +{ + if (!dev->resuming) + return; + + dev->resuming = FALSE; + if (!chipset_responders.device_resume) /* this can never happen! */ + return; + + /* Notify the chipset driver that the resume is complete, + * which will presumably want to send some sort of response to + * the initiator. */ + (*chipset_responders.device_resume) (dev->chipset_bus_no, + dev->chipset_dev_no, status); +} + +/* Tell the subordinate function driver for a specific device to pause + * or resume that device. Result is returned asynchronously via a + * callback function. + */ +static void +initiate_chipset_device_pause_resume(u32 bus_no, u32 dev_no, bool is_pause) +{ + struct visorchipset_device_info dev_info; + struct visor_device *dev = NULL; + int rc = -1, x; + struct visor_driver *drv = NULL; + void (*notify_func)(u32 bus_no, u32 dev_no, int response) = NULL; + + if (is_pause) + notify_func = chipset_responders.device_pause; + else + notify_func = chipset_responders.device_resume; + if (!notify_func) + goto away; + + if (!visorchipset_get_device_info(bus_no, dev_no, &dev_info)) + goto away; + + dev = find_visor_device_by_channel(dev_info.chan_info.channel_addr); + if (!dev) + goto away; + + drv = to_visor_driver(dev->device.driver); + if (!drv) + goto away; + + if (dev->pausing || dev->resuming) + goto away; + + /* Note that even though both drv->pause() and drv->resume + * specify a callback function, it is NOT necessary for us to + * increment our local module usage count. Reason is, there + * is already a linkage dependency between child function + * drivers and visorbus, so it is already IMPOSSIBLE to unload + * visorbus while child function drivers are still running. + */ + if (is_pause) { + if (!drv->pause) + goto away; + + dev->pausing = TRUE; + x = drv->pause(dev, pause_state_change_complete); + } else { + /* This should be done at BUS resume time, but an + * existing problem prevents us from ever getting a bus + * resume... This hack would fail to work should we + * ever have a bus that contains NO devices, since we + * would never even get here in that case. */ + fix_vbus_dev_info(dev); + if (!drv->resume) + goto away; + + dev->resuming = TRUE; + x = drv->resume(dev, resume_state_change_complete); + } + if (x < 0) { + if (is_pause) + dev->pausing = FALSE; + else + dev->resuming = FALSE; + goto away; + } + rc = 0; +away: + if (rc < 0) { + if (notify_func) + (*notify_func)(bus_no, dev_no, rc); + } +} + +static void +chipset_device_pause(u32 bus_no, u32 dev_no) +{ + initiate_chipset_device_pause_resume(bus_no, dev_no, TRUE); +} + +static void +chipset_device_resume(u32 bus_no, u32 dev_no) +{ + initiate_chipset_device_pause_resume(bus_no, dev_no, FALSE); +} + +struct channel_size_info { + uuid_le guid; + unsigned long min_size; + unsigned long max_size; +}; + +static int __init +visorbus_init(void) +{ + int rc = 0; + + POSTCODE_LINUX_3(DRIVER_ENTRY_PC, rc, POSTCODE_SEVERITY_INFO); + bus_device_info_init(&clientbus_driverinfo, + "clientbus", MYDRVNAME, + VERSION, NULL); + + /* process module options */ + + if (visorbus_devicetest > MAXDEVICETEST) + visorbus_devicetest = MAXDEVICETEST; + + rc = create_bus_type(); + if (rc < 0) { + POSTCODE_LINUX_2(BUS_CREATE_ENTRY_PC, DIAG_SEVERITY_ERR); + goto away; + } + + periodic_dev_workqueue = create_singlethread_workqueue("visorbus_dev"); + if (!periodic_dev_workqueue) { + POSTCODE_LINUX_2(CREATE_WORKQUEUE_PC, DIAG_SEVERITY_ERR); + rc = -ENOMEM; + goto away; + } + + /* This enables us to receive notifications when devices appear for + * which this service partition is to be a server for. + */ + visorchipset_register_busdev_server(&chipset_notifiers, + &chipset_responders, + &chipset_driverinfo); + + rc = 0; + +away: + if (rc) + POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, rc, + POSTCODE_SEVERITY_ERR); + return rc; +} + +static void +visorbus_exit(void) +{ + struct list_head *listentry, *listtmp; + + visorchipset_register_busdev_server(NULL, NULL, NULL); + remove_all_visor_devices(); + + flush_workqueue(periodic_dev_workqueue); /* better not be any work! */ + destroy_workqueue(periodic_dev_workqueue); + periodic_dev_workqueue = NULL; + + if (periodic_test_workqueue) { + cancel_delayed_work(&periodic_work); + flush_workqueue(periodic_test_workqueue); + destroy_workqueue(periodic_test_workqueue); + periodic_test_workqueue = NULL; + } + + list_for_each_safe(listentry, listtmp, &list_all_bus_instances) { + struct visorbus_devdata *devdata = list_entry(listentry, + struct + visorbus_devdata, + list_all); + remove_bus_instance(devdata); + } + remove_bus_type(); +} + +module_param_named(debug, visorbus_debug, int, S_IRUGO); +MODULE_PARM_DESC(visorbus_debug, "1 to debug"); +int visorbus_debug = 0; + +module_param_named(forcematch, visorbus_forcematch, int, S_IRUGO); +MODULE_PARM_DESC(visorbus_forcematch, + "1 to force a successful dev <--> drv match"); +int visorbus_forcematch = 0; + +module_param_named(forcenomatch, visorbus_forcenomatch, int, S_IRUGO); +MODULE_PARM_DESC(visorbus_forcenomatch, + "1 to force an UNsuccessful dev <--> drv match"); +int visorbus_forcenomatch = 0; + +module_param_named(devicetest, visorbus_devicetest, int, S_IRUGO); +MODULE_PARM_DESC(visorbus_devicetest, + "non-0 to just test device creation and destruction"); +int visorbus_devicetest = 0; + +module_param_named(debugref, visorbus_debugref, int, S_IRUGO); +MODULE_PARM_DESC(visorbus_debugref, "1 to debug reference counting"); +int visorbus_debugref = 0; + +module_param_named(serialloopbacktest, visorbus_serialloopbacktest, + int, S_IRUGO); +MODULE_PARM_DESC(visorbus_serialloopbacktest, + "non-0 to just create 2 serial devices on the same channel"); +int visorbus_serialloopbacktest = 0; + +module_init(visorbus_init); +module_exit(visorbus_exit); + +MODULE_AUTHOR("Unisys"); +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Supervisor bus driver for service partition: ver " VERSION); +MODULE_VERSION(VERSION); diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h new file mode 100644 index 000000000000..2b61312789da --- /dev/null +++ b/drivers/staging/unisys/visorbus/visorbus_private.h @@ -0,0 +1,50 @@ +/* visorbus_private.h + * + * 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. + */ + +#ifndef __VISORBUS_PRIVATE_H__ +#define __VISORBUS_PRIVATE_H__ + +#include "timskmod.h" +#include "visorbus.h" +#include "visorchipset.h" +#include "visorchannel.h" +#include "version.h" +#include "vbuschannel.h" + +/* module parameters */ +extern int visorbus_debug; +extern int visorbus_forcematch; +extern int visorbus_forcenomatch; +#define MAXDEVICETEST 4 +extern int visorbus_devicetest; +extern int visorbus_debugref; +extern int visorbus_serialloopbacktest; +#define SERIALLOOPBACKCHANADDR (100 * 1024 * 1024) + +/** This is the private data that we store for each bus device instance. + */ +struct visorbus_devdata { + int devno; /* this is the chipset busNo */ + struct list_head list_all; + struct device *dev; + struct kobject kobj; + struct visorchannel *chan; /* channel area for bus itself */ + bool vbus_valid; + struct spar_vbus_headerinfo vbus_hdr_info; +}; + +#endif From 291603cca7eb52e7c2be4c5e1451de431bd21e73 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Tue, 5 May 2015 18:36:01 -0400 Subject: [PATCH 0226/1163] staging: unisys: Move visorchannel into visorbus visorchannel seems to be a necessary component to visorbus and can never function as a standalone module. Let's treat it like a visorbus feature that is always enabled. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/Kconfig | 1 - drivers/staging/unisys/Makefile | 1 - drivers/staging/unisys/visorbus/Kconfig | 3 +-- drivers/staging/unisys/visorbus/Makefile | 2 +- drivers/staging/unisys/visorbus/globals.h | 27 +++++++++++++++++++ .../{visorchannel => visorbus}/visorchannel.h | 0 .../visorchannel_funcs.c | 0 drivers/staging/unisys/visorchipset/Kconfig | 1 + drivers/staging/unisys/visorchipset/Makefile | 2 +- 9 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 drivers/staging/unisys/visorbus/globals.h rename drivers/staging/unisys/{visorchannel => visorbus}/visorchannel.h (100%) rename drivers/staging/unisys/{visorchannel => visorbus}/visorchannel_funcs.c (100%) diff --git a/drivers/staging/unisys/Kconfig b/drivers/staging/unisys/Kconfig index 8d056b55ced7..dbdd4492cf0f 100644 --- a/drivers/staging/unisys/Kconfig +++ b/drivers/staging/unisys/Kconfig @@ -10,7 +10,6 @@ menuconfig UNISYSSPAR if UNISYSSPAR source "drivers/staging/unisys/visorutil/Kconfig" -source "drivers/staging/unisys/visorchannel/Kconfig" source "drivers/staging/unisys/visorchipset/Kconfig" source "drivers/staging/unisys/visorbus/Kconfig" diff --git a/drivers/staging/unisys/Makefile b/drivers/staging/unisys/Makefile index 1ed9d39ff230..b14a4777fd48 100644 --- a/drivers/staging/unisys/Makefile +++ b/drivers/staging/unisys/Makefile @@ -2,6 +2,5 @@ # Makefile for Unisys SPAR drivers # obj-$(CONFIG_UNISYS_VISORUTIL) += visorutil/ -obj-$(CONFIG_UNISYS_VISORCHANNEL) += visorchannel/ obj-$(CONFIG_UNISYS_VISORCHIPSET) += visorchipset/ obj-$(CONFIG_UNISYS_VISORBUS) += visorbus/ diff --git a/drivers/staging/unisys/visorbus/Kconfig b/drivers/staging/unisys/visorbus/Kconfig index 0141528657e2..12cf8f063550 100644 --- a/drivers/staging/unisys/visorbus/Kconfig +++ b/drivers/staging/unisys/visorbus/Kconfig @@ -4,7 +4,6 @@ config UNISYS_VISORBUS tristate "Unisys visorbus driver" - depends on UNISYSSPAR && UNISYS_VISORUTIL && UNISYS_VISORCHANNEL && UNISYS_VISORCHIPSET + depends on UNISYSSPAR && UNISYS_VISORUTIL && UNISYS_VISORCHIPSET ---help--- If you say Y here, you will enable the Unisys visorbus driver. - diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile index 60bb96bad239..20d87daf5b00 100644 --- a/drivers/staging/unisys/visorbus/Makefile +++ b/drivers/staging/unisys/visorbus/Makefile @@ -5,9 +5,9 @@ obj-$(CONFIG_UNISYS_VISORBUS) += visorbus.o visorbus-y := visorbus_main.o devmajorminor_attr.o businst_attr.o channel_attr.o +visorbus-y += visorchannel_funcs.o ccflags-y += -Idrivers/staging/unisys/include -ccflags-y += -Idrivers/staging/unisys/visorchannel ccflags-y += -Idrivers/staging/unisys/visorchipset ccflags-y += -Idrivers/staging/unisys/common-spar/include ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels diff --git a/drivers/staging/unisys/visorbus/globals.h b/drivers/staging/unisys/visorbus/globals.h new file mode 100644 index 000000000000..0ed8e1d8033a --- /dev/null +++ b/drivers/staging/unisys/visorbus/globals.h @@ -0,0 +1,27 @@ +/* globals.h + * + * 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. + */ + +#ifndef __VISORCHANNEL_GLOBALS_H__ +#define __VISORCHANNEL_GLOBALS_H__ + +#include "timskmod.h" +#include "memregion.h" +#include "version.h" + +#define MYDRVNAME "visorchannel" + +#endif diff --git a/drivers/staging/unisys/visorchannel/visorchannel.h b/drivers/staging/unisys/visorbus/visorchannel.h similarity index 100% rename from drivers/staging/unisys/visorchannel/visorchannel.h rename to drivers/staging/unisys/visorbus/visorchannel.h diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorbus/visorchannel_funcs.c similarity index 100% rename from drivers/staging/unisys/visorchannel/visorchannel_funcs.c rename to drivers/staging/unisys/visorbus/visorchannel_funcs.c diff --git a/drivers/staging/unisys/visorchipset/Kconfig b/drivers/staging/unisys/visorchipset/Kconfig index b03bfc5c3043..2030592d2023 100644 --- a/drivers/staging/unisys/visorchipset/Kconfig +++ b/drivers/staging/unisys/visorchipset/Kconfig @@ -6,6 +6,7 @@ config UNISYS_VISORCHIPSET tristate "Unisys visorchipset driver" select UNISYS_VISORUTIL select UNISYS_VISORCHANNEL + select UNISYS_VISORBUS ---help--- If you say Y here, you will enable the Unisys visorchipset driver. diff --git a/drivers/staging/unisys/visorchipset/Makefile b/drivers/staging/unisys/visorchipset/Makefile index 12686906bef3..1bf6699579ec 100644 --- a/drivers/staging/unisys/visorchipset/Makefile +++ b/drivers/staging/unisys/visorchipset/Makefile @@ -8,8 +8,8 @@ visorchipset-y := visorchipset_main.o file.o parser.o ccflags-y += -Idrivers/staging/unisys/include ccflags-y += -Idrivers/staging/unisys/uislib -ccflags-y += -Idrivers/staging/unisys/visorchannel ccflags-y += -Idrivers/staging/unisys/common-spar/include ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels ccflags-y += -Idrivers/staging/unisys/visorutil +ccflags-y += -Idrivers/staging/unisys/visorbus ccflags-y += -Iinclude/generated From f6439218bb0d6e40fdb90a45333b7bce5be2424d Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Tue, 5 May 2015 18:36:02 -0400 Subject: [PATCH 0227/1163] staging: unisys: Dissolve visorchannel.h This header is needed by other drivers and should be in a global namespace. In addition, functionally it is part of visorbus, so roll the contents into that header file. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorbus.h | 50 +++++++++++- .../unisys/visorbus/visorbus_private.h | 2 +- .../staging/unisys/visorbus/visorchannel.h | 76 ------------------- .../unisys/visorbus/visorchannel_funcs.c | 2 +- drivers/staging/unisys/visorchipset/file.c | 2 +- .../unisys/visorchipset/visorchipset_main.c | 2 +- 6 files changed, 53 insertions(+), 81 deletions(-) delete mode 100644 drivers/staging/unisys/visorbus/visorchannel.h diff --git a/drivers/staging/unisys/visorbus/visorbus.h b/drivers/staging/unisys/visorbus/visorbus.h index 856fa3f6419c..3956a3df80eb 100644 --- a/drivers/staging/unisys/visorbus/visorbus.h +++ b/drivers/staging/unisys/visorbus/visorbus.h @@ -35,8 +35,12 @@ #include #include "periodic_work.h" -#include "visorchannel.h" #include "channel.h" +#include "memregion.h" + +#ifndef HOSTADDRESS +#define HOSTADDRESS u64 +#endif struct visor_driver; struct visor_device; @@ -163,4 +167,48 @@ void visorbus_enable_channel_interrupts(struct visor_device *dev); void visorbus_disable_channel_interrupts(struct visor_device *dev); #endif +/* Note that for visorchannel_create() and visorchannel_create_overlapped(), + * and arguments may be 0 if we are a channel CLIENT. + * In this case, the values can simply be read from the channel header. + */ +struct visorchannel *visorchannel_create(HOSTADDRESS physaddr, + ulong channel_bytes, uuid_le guid); +struct visorchannel *visorchannel_create_overlapped(ulong channel_bytes, + struct visorchannel *parent, + ulong off, uuid_le guid); +struct visorchannel *visorchannel_create_with_lock(HOSTADDRESS physaddr, + ulong channel_bytes, + uuid_le guid); +struct visorchannel *visorchannel_create_overlapped_with_lock( + ulong channel_bytes, + struct visorchannel *parent, + ulong off, uuid_le guid); +void visorchannel_destroy(struct visorchannel *channel); +int visorchannel_read(struct visorchannel *channel, ulong offset, + void *local, ulong nbytes); +int visorchannel_write(struct visorchannel *channel, ulong offset, + void *local, ulong nbytes); +int visorchannel_clear(struct visorchannel *channel, ulong offset, + u8 ch, ulong nbytes); +BOOL visorchannel_signalremove(struct visorchannel *channel, u32 queue, + void *msg); +BOOL visorchannel_signalinsert(struct visorchannel *channel, u32 queue, + void *msg); +int visorchannel_signalqueue_slots_avail(struct visorchannel *channel, + u32 queue); +int visorchannel_signalqueue_max_slots(struct visorchannel *channel, u32 queue); +HOSTADDRESS visorchannel_get_physaddr(struct visorchannel *channel); +ulong visorchannel_get_nbytes(struct visorchannel *channel); +char *visorchannel_id(struct visorchannel *channel, char *s); +char *visorchannel_zoneid(struct visorchannel *channel, char *s); +u64 visorchannel_get_clientpartition(struct visorchannel *channel); +uuid_le visorchannel_get_uuid(struct visorchannel *channel); +struct memregion *visorchannel_get_memregion(struct visorchannel *channel); +char *visorchannel_uuid_id(uuid_le *guid, char *s); +void visorchannel_debug(struct visorchannel *channel, int num_queues, + struct seq_file *seq, u32 off); +void visorchannel_dump_section(struct visorchannel *chan, char *s, + int off, int len, struct seq_file *seq); +void __iomem *visorchannel_get_header(struct visorchannel *channel); + #endif diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h index 2b61312789da..47ab4887661d 100644 --- a/drivers/staging/unisys/visorbus/visorbus_private.h +++ b/drivers/staging/unisys/visorbus/visorbus_private.h @@ -21,7 +21,7 @@ #include "timskmod.h" #include "visorbus.h" #include "visorchipset.h" -#include "visorchannel.h" +#include "visorbus.h" #include "version.h" #include "vbuschannel.h" diff --git a/drivers/staging/unisys/visorbus/visorchannel.h b/drivers/staging/unisys/visorbus/visorchannel.h deleted file mode 100644 index 63f1b9760373..000000000000 --- a/drivers/staging/unisys/visorbus/visorchannel.h +++ /dev/null @@ -1,76 +0,0 @@ -/* visorchannel.h - * - * 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. - */ - -#ifndef __VISORCHANNEL_H__ -#define __VISORCHANNEL_H__ - -#include - -#include "memregion.h" -#include "channel.h" -#ifndef HOSTADDRESS -#define HOSTADDRESS u64 -#endif -#ifndef BOOL -#define BOOL int -#endif - -/* Note that for visorchannel_create() and visorchannel_create_overlapped(), - * and arguments may be 0 if we are a channel CLIENT. - * In this case, the values can simply be read from the channel header. - */ -struct visorchannel *visorchannel_create(HOSTADDRESS physaddr, - ulong channel_bytes, uuid_le guid); -struct visorchannel *visorchannel_create_overlapped(ulong channel_bytes, - struct visorchannel *parent, - ulong off, uuid_le guid); -struct visorchannel *visorchannel_create_with_lock(HOSTADDRESS physaddr, - ulong channel_bytes, - uuid_le guid); -struct visorchannel *visorchannel_create_overlapped_with_lock( - ulong channel_bytes, - struct visorchannel *parent, - ulong off, uuid_le guid); -void visorchannel_destroy(struct visorchannel *channel); -int visorchannel_read(struct visorchannel *channel, ulong offset, - void *local, ulong nbytes); -int visorchannel_write(struct visorchannel *channel, ulong offset, - void *local, ulong nbytes); -int visorchannel_clear(struct visorchannel *channel, ulong offset, - u8 ch, ulong nbytes); -BOOL visorchannel_signalremove(struct visorchannel *channel, u32 queue, - void *msg); -BOOL visorchannel_signalinsert(struct visorchannel *channel, u32 queue, - void *msg); -int visorchannel_signalqueue_slots_avail(struct visorchannel *channel, - u32 queue); -int visorchannel_signalqueue_max_slots(struct visorchannel *channel, u32 queue); -HOSTADDRESS visorchannel_get_physaddr(struct visorchannel *channel); -ulong visorchannel_get_nbytes(struct visorchannel *channel); -char *visorchannel_id(struct visorchannel *channel, char *s); -char *visorchannel_zoneid(struct visorchannel *channel, char *s); -u64 visorchannel_get_clientpartition(struct visorchannel *channel); -uuid_le visorchannel_get_uuid(struct visorchannel *channel); -struct memregion *visorchannel_get_memregion(struct visorchannel *channel); -char *visorchannel_uuid_id(uuid_le *guid, char *s); -void visorchannel_debug(struct visorchannel *channel, int num_queues, - struct seq_file *seq, u32 off); -void visorchannel_dump_section(struct visorchannel *chan, char *s, - int off, int len, struct seq_file *seq); -void __iomem *visorchannel_get_header(struct visorchannel *channel); - -#endif diff --git a/drivers/staging/unisys/visorbus/visorchannel_funcs.c b/drivers/staging/unisys/visorbus/visorchannel_funcs.c index 9ae5f752bbf5..b61f9549d352 100644 --- a/drivers/staging/unisys/visorbus/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorbus/visorchannel_funcs.c @@ -23,7 +23,7 @@ */ #include "globals.h" -#include "visorchannel.h" +#include "visorbus.h" #include #define MYDRVNAME "visorchannel" diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c index a17027c211a2..9822e9d1d6be 100644 --- a/drivers/staging/unisys/visorchipset/file.c +++ b/drivers/staging/unisys/visorchipset/file.c @@ -24,7 +24,7 @@ #include "version.h" #include "visorchipset.h" #include "visorchipset_umode.h" -#include "visorchannel.h" +#include "visorbus.h" #include "uisutils.h" #include "file.h" diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 5ea6f9e81fba..a8448c23a89b 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -18,7 +18,7 @@ #include "version.h" #include "visorchipset.h" #include "procobjecttree.h" -#include "visorchannel.h" +#include "visorbus.h" #include "periodic_work.h" #include "file.h" #include "parser.h" From 9bfc2c796b65b004940b6470b8e1893d31c4ae37 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Tue, 5 May 2015 18:36:03 -0400 Subject: [PATCH 0228/1163] staging: unisys: Move visorbus.h to public namespace Turn visorbus.h into a public header that all visor* drivers will include. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/{visorbus => include}/visorbus.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename drivers/staging/unisys/{visorbus => include}/visorbus.h (100%) diff --git a/drivers/staging/unisys/visorbus/visorbus.h b/drivers/staging/unisys/include/visorbus.h similarity index 100% rename from drivers/staging/unisys/visorbus/visorbus.h rename to drivers/staging/unisys/include/visorbus.h From 98e50b8a5460971aee9bb4ff9786fa158f69cd38 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Tue, 5 May 2015 18:36:04 -0400 Subject: [PATCH 0229/1163] staging: unisys: Remove unused driver The visorchannel feature is rolled into visorbus now and its headers are public under visorbus.h. Remove the unused driver, the old header file and all the ccflag includes in the Makefile. Also remove VISORCHANNEL from all Kconfigs as it is not needed. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/unisys/visorchipset/Kconfig b/drivers/staging/unisys/visorchipset/Kconfig index 2030592d2023..01d9a9a0e904 100644 --- a/drivers/staging/unisys/visorchipset/Kconfig +++ b/drivers/staging/unisys/visorchipset/Kconfig @@ -5,7 +5,6 @@ config UNISYS_VISORCHIPSET tristate "Unisys visorchipset driver" select UNISYS_VISORUTIL - select UNISYS_VISORCHANNEL select UNISYS_VISORBUS ---help--- If you say Y here, you will enable the Unisys visorchipset driver. From a9a7c767e38f3e74efb8d30397b48cc37612c4de Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Tue, 5 May 2015 18:36:05 -0400 Subject: [PATCH 0230/1163] staging: unisys: unify businst attributes into visorbus_main.c The code in businst_attr.[ch] only creates sysfs files and is called only in visorbus_main.c. This code should be unified into visorbus_main.c. There are some functions that have been made static. Signed-off-by: Prarit Bhargava Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/Makefile | 2 +- .../staging/unisys/visorbus/businst_attr.c | 103 ------------------ .../staging/unisys/visorbus/businst_attr.h | 40 ------- .../staging/unisys/visorbus/visorbus_main.c | 97 ++++++++++++++++- 4 files changed, 97 insertions(+), 145 deletions(-) delete mode 100644 drivers/staging/unisys/visorbus/businst_attr.c delete mode 100644 drivers/staging/unisys/visorbus/businst_attr.h diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile index 20d87daf5b00..e1b667db363c 100644 --- a/drivers/staging/unisys/visorbus/Makefile +++ b/drivers/staging/unisys/visorbus/Makefile @@ -4,7 +4,7 @@ obj-$(CONFIG_UNISYS_VISORBUS) += visorbus.o -visorbus-y := visorbus_main.o devmajorminor_attr.o businst_attr.o channel_attr.o +visorbus-y := visorbus_main.o devmajorminor_attr.o channel_attr.o visorbus-y += visorchannel_funcs.o ccflags-y += -Idrivers/staging/unisys/include diff --git a/drivers/staging/unisys/visorbus/businst_attr.c b/drivers/staging/unisys/visorbus/businst_attr.c deleted file mode 100644 index b3fea9d93d5e..000000000000 --- a/drivers/staging/unisys/visorbus/businst_attr.c +++ /dev/null @@ -1,103 +0,0 @@ -/* businst_attr.c - * - * 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. - */ - -/* This is actually something they forgot to put in the kernel. - * struct bus_type in the kernel SHOULD have a "busses" member, which - * should be treated similarly to the "devices" and "drivers" members. - * There SHOULD be: - * - a "businst_attribute" analogous to the existing "bus_attribute" - * - a "businst_create_file" and "businst_remove_file" analogous to the - * existing "bus_create_file" and "bus_remove_file". - * That's what I created businst.c and businst.h to do. - * - * We want to add the "busses" sub-tree in sysfs, where we will house the - * names and properties of each bus instance: - * - * /sys/bus// - * version - * devices - * --> /sys/devices/ - * --> /sys/devices/ - * drivers - * - * - * - * ... - * - * - * - * ... - * >> busses - * >> - * >> - * >> - * >> ... - * >> - * >> - * >> - * >> ... - * - * I considered adding bus instance properties under - * /sys/devices/. But I thought there may be existing - * notions that ONLY device sub-trees should live under - * /sys/devices/. So I stayed out of there. - * - */ - -#include "businst_attr.h" - -#define to_businst_attr(_attr) \ - container_of(_attr, struct businst_attribute, attr) -#define to_visorbus_devdata(obj) \ - container_of(obj, struct visorbus_devdata, kobj) -#define CURRENT_FILE_PC VISOR_BUS_PC_businst_attr_c - -ssize_t businst_attr_show(struct kobject *kobj, struct attribute *attr, - char *buf) -{ - struct businst_attribute *businst_attr = to_businst_attr(attr); - struct visorbus_devdata *bus = to_visorbus_devdata(kobj); - ssize_t ret = 0; - - if (businst_attr->show) - ret = businst_attr->show(bus, buf); - return ret; -} - -ssize_t businst_attr_store(struct kobject *kobj, struct attribute *attr, - const char *buf, size_t count) -{ - struct businst_attribute *businst_attr = to_businst_attr(attr); - struct visorbus_devdata *bus = to_visorbus_devdata(kobj); - ssize_t ret = 0; - - if (businst_attr->store) - ret = businst_attr->store(bus, buf, count); - return ret; -} - -int businst_create_file(struct visorbus_devdata *bus, - struct businst_attribute *attr) -{ - return sysfs_create_file(&bus->kobj, &attr->attr); -} - -void businst_remove_file(struct visorbus_devdata *bus, - struct businst_attribute *attr) -{ - sysfs_remove_file(&bus->kobj, &attr->attr); -} diff --git a/drivers/staging/unisys/visorbus/businst_attr.h b/drivers/staging/unisys/visorbus/businst_attr.h deleted file mode 100644 index e9fb36a692cb..000000000000 --- a/drivers/staging/unisys/visorbus/businst_attr.h +++ /dev/null @@ -1,40 +0,0 @@ -/* businst_attr.h - * - * 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. - */ - -#ifndef __BUSINST_H__ -#define __BUSINST_H__ - -#include "visorbus_private.h" /* just to get visorbus_devdata declaration */ -#include "timskmod.h" - -struct businst_attribute { - struct attribute attr; - ssize_t (*show)(struct visorbus_devdata*, char *buf); - ssize_t (*store)(struct visorbus_devdata*, const char *buf, - size_t count); -}; - -ssize_t businst_attr_show(struct kobject *kobj, - struct attribute *attr, char *buf); -ssize_t businst_attr_store(struct kobject *kobj, struct attribute *attr, - const char *buf, size_t count); -int businst_create_file(struct visorbus_devdata *bus, - struct businst_attribute *attr); -void businst_remove_file(struct visorbus_devdata *bus, - struct businst_attribute *attr); - -#endif diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index d717e35d5a1e..d178fcd76ec5 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -18,7 +18,7 @@ #include #include "visorbus_private.h" -#include "businst_attr.h" +#include "timskmod.h" #include "channel_attr.h" #include "devmajorminor_attr.h" #include "periodic_work.h" @@ -200,6 +200,101 @@ visorbus_release_device(struct device *xdev) kfree(dev); } +/* This is actually something they forgot to put in the kernel. + * struct bus_type in the kernel SHOULD have a "busses" member, which + * should be treated similarly to the "devices" and "drivers" members. + * There SHOULD be: + * - a "businst_attribute" analogous to the existing "bus_attribute" + * - a "businst_create_file" and "businst_remove_file" analogous to the + * existing "bus_create_file" and "bus_remove_file". + * That's what I created businst.c and businst.h to do. + * + * We want to add the "busses" sub-tree in sysfs, where we will house the + * names and properties of each bus instance: + * + * /sys/bus// + * version + * devices + * --> /sys/devices/ + * --> /sys/devices/ + * drivers + * + * + * + * ... + * + * + * + * ... + * >> busses + * >> + * >> + * >> + * >> ... + * >> + * >> + * >> + * >> ... + * + * I considered adding bus instance properties under + * /sys/devices/. But I thought there may be existing + * notions that ONLY device sub-trees should live under + * /sys/devices/. So I stayed out of there. + * + */ + +struct businst_attribute { + struct attribute attr; + ssize_t (*show)(struct visorbus_devdata*, char *buf); + ssize_t (*store)(struct visorbus_devdata*, const char *buf, + size_t count); +}; + +#define to_businst_attr(_attr) \ + container_of(_attr, struct businst_attribute, attr) +#define to_visorbus_devdata(obj) \ + container_of(obj, struct visorbus_devdata, kobj) + +static ssize_t +businst_attr_show(struct kobject *kobj, struct attribute *attr, + char *buf) +{ + struct businst_attribute *businst_attr = to_businst_attr(attr); + struct visorbus_devdata *bus = to_visorbus_devdata(kobj); + ssize_t ret = 0; + + if (businst_attr->show) + ret = businst_attr->show(bus, buf); + return ret; +} + +static ssize_t +businst_attr_store(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t count) +{ + struct businst_attribute *businst_attr = to_businst_attr(attr); + struct visorbus_devdata *bus = to_visorbus_devdata(kobj); + ssize_t ret = 0; + + if (businst_attr->store) + ret = businst_attr->store(bus, buf, count); + return ret; +} + +static int +businst_create_file(struct visorbus_devdata *bus, + struct businst_attribute *attr) +{ + return sysfs_create_file(&bus->kobj, &attr->attr); +} + +static void +businst_remove_file(struct visorbus_devdata *bus, + struct businst_attribute *attr) +{ + sysfs_remove_file(&bus->kobj, &attr->attr); +} + static const struct sysfs_ops businst_sysfs_ops = { .show = businst_attr_show, .store = businst_attr_store, From 826b6a0f8677995583b7b54706c8fa20e2491ac3 Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Tue, 5 May 2015 18:36:06 -0400 Subject: [PATCH 0231/1163] staging: unisys: unify channel attributes into visorbus_main.c The code in channel_attr.[ch] only creates sysfs files and is called only in visorbus_main.c. This code should be unified into visorbus_main.c. There are some functions that have been made static. Signed-off-by: Prarit Bhargava Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/Makefile | 2 +- .../staging/unisys/visorbus/channel_attr.c | 227 ------------------ .../staging/unisys/visorbus/channel_attr.h | 27 --- .../staging/unisys/visorbus/visorbus_main.c | 209 +++++++++++++++- 4 files changed, 209 insertions(+), 256 deletions(-) delete mode 100644 drivers/staging/unisys/visorbus/channel_attr.c delete mode 100644 drivers/staging/unisys/visorbus/channel_attr.h diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile index e1b667db363c..d44fbf63404e 100644 --- a/drivers/staging/unisys/visorbus/Makefile +++ b/drivers/staging/unisys/visorbus/Makefile @@ -4,7 +4,7 @@ obj-$(CONFIG_UNISYS_VISORBUS) += visorbus.o -visorbus-y := visorbus_main.o devmajorminor_attr.o channel_attr.o +visorbus-y := visorbus_main.o devmajorminor_attr.o visorbus-y += visorchannel_funcs.o ccflags-y += -Idrivers/staging/unisys/include diff --git a/drivers/staging/unisys/visorbus/channel_attr.c b/drivers/staging/unisys/visorbus/channel_attr.c deleted file mode 100644 index 0d7184ac1cbe..000000000000 --- a/drivers/staging/unisys/visorbus/channel_attr.c +++ /dev/null @@ -1,227 +0,0 @@ -/* channel_attr.c - * - * 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. - */ - -/* Implement publishing of channel attributes under: - * - * /sys/bus/visorbus/dev/channel - * - */ - -#include "channel_attr.h" -#define CURRENT_FILE_PC VISOR_BUS_PC_channel_attr_c -#define to_channel_attr(_attr) \ - container_of(_attr, struct channel_attribute, attr) -#define to_visor_device_from_kobjchannel(obj) \ - container_of(obj, struct visor_device, kobjchannel) - -struct channel_attribute { - struct attribute attr; - ssize_t (*show)(struct visor_device*, char *buf); - ssize_t (*store)(struct visor_device*, const char *buf, size_t count); -}; - -/* begin implementation of specific channel attributes to appear under -* /sys/bus/visorbus/dev/channel -*/ -static ssize_t devicechannel_attr_physaddr(struct visor_device *dev, char *buf) -{ - if (!dev->visorchannel) - return 0; - return snprintf(buf, PAGE_SIZE, "0x%Lx\n", - visorchannel_get_physaddr(dev->visorchannel)); -} - -static ssize_t devicechannel_attr_nbytes(struct visor_device *dev, char *buf) -{ - if (!dev->visorchannel) - return 0; - return snprintf(buf, PAGE_SIZE, "0x%lx\n", - visorchannel_get_nbytes(dev->visorchannel)); -} - -static ssize_t devicechannel_attr_clientpartition(struct visor_device *dev, - char *buf) { - if (!dev->visorchannel) - return 0; - return snprintf(buf, PAGE_SIZE, "0x%Lx\n", - visorchannel_get_clientpartition(dev->visorchannel)); -} - -static ssize_t devicechannel_attr_typeguid(struct visor_device *dev, char *buf) -{ - char s[99]; - - if (!dev->visorchannel) - return 0; - return snprintf(buf, PAGE_SIZE, "%s\n", - visorchannel_id(dev->visorchannel, s)); -} - -static ssize_t devicechannel_attr_zoneguid(struct visor_device *dev, char *buf) -{ - char s[99]; - - if (!dev->visorchannel) - return 0; - return snprintf(buf, PAGE_SIZE, "%s\n", - visorchannel_zoneid(dev->visorchannel, s)); -} - -static ssize_t devicechannel_attr_typename(struct visor_device *dev, char *buf) -{ - int i = 0; - struct bus_type *xbus = dev->device.bus; - struct device_driver *xdrv = dev->device.driver; - struct visor_driver *drv = NULL; - - if (!dev->visorchannel || !xbus || !xdrv) - return 0; - i = xbus->match(&dev->device, xdrv); - if (!i) - return 0; - drv = to_visor_driver(xdrv); - return snprintf(buf, PAGE_SIZE, "%s\n", drv->channel_types[i - 1].name); -} - -static ssize_t devicechannel_attr_dump(struct visor_device *dev, char *buf) -{ - int count = 0; -/* TODO: replace this with debugfs code - struct seq_file *m = NULL; - if (dev->visorchannel == NULL) - return 0; - m = visor_seq_file_new_buffer(buf, PAGE_SIZE - 1); - if (m == NULL) - return 0; - visorchannel_debug(dev->visorchannel, 1, m, 0); - count = m->count; - visor_seq_file_done_buffer(m); - m = NULL; -*/ - return count; -} - -static struct channel_attribute all_channel_attrs[] = { - __ATTR(physaddr, S_IRUGO, - devicechannel_attr_physaddr, NULL), - __ATTR(nbytes, S_IRUGO, - devicechannel_attr_nbytes, NULL), - __ATTR(clientpartition, S_IRUGO, - devicechannel_attr_clientpartition, NULL), - __ATTR(typeguid, S_IRUGO, - devicechannel_attr_typeguid, NULL), - __ATTR(zoneguid, S_IRUGO, - devicechannel_attr_zoneguid, NULL), - __ATTR(typename, S_IRUGO, - devicechannel_attr_typename, NULL), - __ATTR(dump, S_IRUGO, - devicechannel_attr_dump, NULL), -}; - -/* end implementation of specific channel attributes */ - -static ssize_t channel_attr_show(struct kobject *kobj, struct attribute *attr, - char *buf) -{ - struct channel_attribute *channel_attr = to_channel_attr(attr); - struct visor_device *dev = to_visor_device_from_kobjchannel(kobj); - ssize_t ret = 0; - - if (channel_attr->show) - ret = channel_attr->show(dev, buf); - return ret; -} - -static ssize_t channel_attr_store(struct kobject *kobj, struct attribute *attr, - const char *buf, size_t count) -{ - struct channel_attribute *channel_attr = to_channel_attr(attr); - struct visor_device *dev = to_visor_device_from_kobjchannel(kobj); - ssize_t ret = 0; - - if (channel_attr->store) - ret = channel_attr->store(dev, buf, count); - return ret; -} - -static int channel_create_file(struct visor_device *dev, - struct channel_attribute *attr) -{ - return sysfs_create_file(&dev->kobjchannel, &attr->attr); -} - -static void channel_remove_file(struct visor_device *dev, - struct channel_attribute *attr) -{ - sysfs_remove_file(&dev->kobjchannel, &attr->attr); -} - -static const struct sysfs_ops channel_sysfs_ops = { - .show = channel_attr_show, - .store = channel_attr_store, -}; - -static struct kobj_type channel_kobj_type = { - .sysfs_ops = &channel_sysfs_ops -}; - -int register_channel_attributes(struct visor_device *dev) -{ - int rc = 0, i = 0, x = 0; - - if (dev->kobjchannel.parent) - goto away; /* already registered */ - x = kobject_init_and_add(&dev->kobjchannel, &channel_kobj_type, - &dev->device.kobj, "channel"); - if (x < 0) { - rc = x; - goto away; - } - - kobject_uevent(&dev->kobjchannel, KOBJ_ADD); - - for (i = 0; - i < sizeof(all_channel_attrs) / sizeof(struct channel_attribute); - i++) - x = channel_create_file(dev, &all_channel_attrs[i]); - if (x < 0) { - while (--i >= 0) - channel_remove_file(dev, &all_channel_attrs[i]); - kobject_del(&dev->kobjchannel); - kobject_put(&dev->kobjchannel); - rc = x; - goto away; - } -away: - return rc; -} - -void unregister_channel_attributes(struct visor_device *dev) -{ - int i = 0; - - if (!dev->kobjchannel.parent) - return; /* already unregistered */ - for (i = 0; - i < sizeof(all_channel_attrs) / sizeof(struct channel_attribute); - i++) - channel_remove_file(dev, &all_channel_attrs[i]); - - kobject_del(&dev->kobjchannel); - kobject_put(&dev->kobjchannel); - dev->kobjchannel.parent = NULL; -} diff --git a/drivers/staging/unisys/visorbus/channel_attr.h b/drivers/staging/unisys/visorbus/channel_attr.h deleted file mode 100644 index 00ae37cb32ee..000000000000 --- a/drivers/staging/unisys/visorbus/channel_attr.h +++ /dev/null @@ -1,27 +0,0 @@ -/* channel_attr.h - * - * 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. - */ - -#ifndef __CHANNEL_ATTR_H__ -#define __CHANNEL_ATTR_H__ - -#include "visorbus.h" /* just to get visor_device declaration */ -#include "timskmod.h" - -int register_channel_attributes(struct visor_device *dev); -void unregister_channel_attributes(struct visor_device *dev); - -#endif diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index d178fcd76ec5..c4eec2cde1c2 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -19,7 +19,6 @@ #include "visorbus_private.h" #include "timskmod.h" -#include "channel_attr.h" #include "devmajorminor_attr.h" #include "periodic_work.h" #include "vbuschannel.h" @@ -200,6 +199,214 @@ visorbus_release_device(struct device *xdev) kfree(dev); } +/* Implement publishing of channel attributes under: + * + * /sys/bus/visorbus/dev/channel + * + */ + +#define to_channel_attr(_attr) \ + container_of(_attr, struct channel_attribute, attr) +#define to_visor_device_from_kobjchannel(obj) \ + container_of(obj, struct visor_device, kobjchannel) + +struct channel_attribute { + struct attribute attr; + ssize_t (*show)(struct visor_device*, char *buf); + ssize_t (*store)(struct visor_device*, const char *buf, size_t count); +}; + +/* begin implementation of specific channel attributes to appear under +* /sys/bus/visorbus/dev/channel +*/ +static ssize_t devicechannel_attr_physaddr(struct visor_device *dev, char *buf) +{ + if (!dev->visorchannel) + return 0; + return snprintf(buf, PAGE_SIZE, "0x%Lx\n", + visorchannel_get_physaddr(dev->visorchannel)); +} + +static ssize_t devicechannel_attr_nbytes(struct visor_device *dev, char *buf) +{ + if (!dev->visorchannel) + return 0; + return snprintf(buf, PAGE_SIZE, "0x%lx\n", + visorchannel_get_nbytes(dev->visorchannel)); +} + +static ssize_t devicechannel_attr_clientpartition(struct visor_device *dev, + char *buf) { + if (!dev->visorchannel) + return 0; + return snprintf(buf, PAGE_SIZE, "0x%Lx\n", + visorchannel_get_clientpartition(dev->visorchannel)); +} + +static ssize_t devicechannel_attr_typeguid(struct visor_device *dev, char *buf) +{ + char s[99]; + + if (!dev->visorchannel) + return 0; + return snprintf(buf, PAGE_SIZE, "%s\n", + visorchannel_id(dev->visorchannel, s)); +} + +static ssize_t devicechannel_attr_zoneguid(struct visor_device *dev, char *buf) +{ + char s[99]; + + if (!dev->visorchannel) + return 0; + return snprintf(buf, PAGE_SIZE, "%s\n", + visorchannel_zoneid(dev->visorchannel, s)); +} + +static ssize_t devicechannel_attr_typename(struct visor_device *dev, char *buf) +{ + int i = 0; + struct bus_type *xbus = dev->device.bus; + struct device_driver *xdrv = dev->device.driver; + struct visor_driver *drv = NULL; + + if (!dev->visorchannel || !xbus || !xdrv) + return 0; + i = xbus->match(&dev->device, xdrv); + if (!i) + return 0; + drv = to_visor_driver(xdrv); + return snprintf(buf, PAGE_SIZE, "%s\n", drv->channel_types[i - 1].name); +} + +static ssize_t devicechannel_attr_dump(struct visor_device *dev, char *buf) +{ + int count = 0; +/* TODO: replace this with debugfs code + struct seq_file *m = NULL; + if (dev->visorchannel == NULL) + return 0; + m = visor_seq_file_new_buffer(buf, PAGE_SIZE - 1); + if (m == NULL) + return 0; + visorchannel_debug(dev->visorchannel, 1, m, 0); + count = m->count; + visor_seq_file_done_buffer(m); + m = NULL; +*/ + return count; +} + +static struct channel_attribute all_channel_attrs[] = { + __ATTR(physaddr, S_IRUGO, + devicechannel_attr_physaddr, NULL), + __ATTR(nbytes, S_IRUGO, + devicechannel_attr_nbytes, NULL), + __ATTR(clientpartition, S_IRUGO, + devicechannel_attr_clientpartition, NULL), + __ATTR(typeguid, S_IRUGO, + devicechannel_attr_typeguid, NULL), + __ATTR(zoneguid, S_IRUGO, + devicechannel_attr_zoneguid, NULL), + __ATTR(typename, S_IRUGO, + devicechannel_attr_typename, NULL), + __ATTR(dump, S_IRUGO, + devicechannel_attr_dump, NULL), +}; + +/* end implementation of specific channel attributes */ + +static ssize_t channel_attr_show(struct kobject *kobj, struct attribute *attr, + char *buf) +{ + struct channel_attribute *channel_attr = to_channel_attr(attr); + struct visor_device *dev = to_visor_device_from_kobjchannel(kobj); + ssize_t ret = 0; + + if (channel_attr->show) + ret = channel_attr->show(dev, buf); + return ret; +} + +static ssize_t channel_attr_store(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t count) +{ + struct channel_attribute *channel_attr = to_channel_attr(attr); + struct visor_device *dev = to_visor_device_from_kobjchannel(kobj); + ssize_t ret = 0; + + if (channel_attr->store) + ret = channel_attr->store(dev, buf, count); + return ret; +} + +static int channel_create_file(struct visor_device *dev, + struct channel_attribute *attr) +{ + return sysfs_create_file(&dev->kobjchannel, &attr->attr); +} + +static void channel_remove_file(struct visor_device *dev, + struct channel_attribute *attr) +{ + sysfs_remove_file(&dev->kobjchannel, &attr->attr); +} + +static const struct sysfs_ops channel_sysfs_ops = { + .show = channel_attr_show, + .store = channel_attr_store, +}; + +static struct kobj_type channel_kobj_type = { + .sysfs_ops = &channel_sysfs_ops +}; + +int register_channel_attributes(struct visor_device *dev) +{ + int rc = 0, i = 0, x = 0; + + if (dev->kobjchannel.parent) + goto away; /* already registered */ + x = kobject_init_and_add(&dev->kobjchannel, &channel_kobj_type, + &dev->device.kobj, "channel"); + if (x < 0) { + rc = x; + goto away; + } + + kobject_uevent(&dev->kobjchannel, KOBJ_ADD); + + for (i = 0; + i < sizeof(all_channel_attrs) / sizeof(struct channel_attribute); + i++) + x = channel_create_file(dev, &all_channel_attrs[i]); + if (x < 0) { + while (--i >= 0) + channel_remove_file(dev, &all_channel_attrs[i]); + kobject_del(&dev->kobjchannel); + kobject_put(&dev->kobjchannel); + rc = x; + goto away; + } +away: + return rc; +} + +void unregister_channel_attributes(struct visor_device *dev) +{ + int i = 0; + + if (!dev->kobjchannel.parent) + return; /* already unregistered */ + for (i = 0; + i < sizeof(all_channel_attrs) / sizeof(struct channel_attribute); + i++) + channel_remove_file(dev, &all_channel_attrs[i]); + + kobject_del(&dev->kobjchannel); + kobject_put(&dev->kobjchannel); + dev->kobjchannel.parent = NULL; +} /* This is actually something they forgot to put in the kernel. * struct bus_type in the kernel SHOULD have a "busses" member, which * should be treated similarly to the "devices" and "drivers" members. From 32710457c895baefd7de6687e9e08f40ae7b2d24 Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Tue, 5 May 2015 18:36:07 -0400 Subject: [PATCH 0232/1163] staging: unisys: unify devmajorminor attributes into visorbus_main.c The code in devmajorminor_attr.[ch] only creates sysfs files and is called only in visorbus_main.c. This code should be unified into visorbus_main.c. The only changes are a forward declaration issue with register_devmajorminor_attributes() and making the functions static. Signed-off-by: Prarit Bhargava Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/Makefile | 2 +- .../unisys/visorbus/devmajorminor_attr.c | 192 ------------------ .../unisys/visorbus/devmajorminor_attr.h | 31 --- .../staging/unisys/visorbus/visorbus_main.c | 176 +++++++++++++++- 4 files changed, 176 insertions(+), 225 deletions(-) delete mode 100644 drivers/staging/unisys/visorbus/devmajorminor_attr.c delete mode 100644 drivers/staging/unisys/visorbus/devmajorminor_attr.h diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile index d44fbf63404e..0465fb909a99 100644 --- a/drivers/staging/unisys/visorbus/Makefile +++ b/drivers/staging/unisys/visorbus/Makefile @@ -4,7 +4,7 @@ obj-$(CONFIG_UNISYS_VISORBUS) += visorbus.o -visorbus-y := visorbus_main.o devmajorminor_attr.o +visorbus-y := visorbus_main.o visorbus-y += visorchannel_funcs.o ccflags-y += -Idrivers/staging/unisys/include diff --git a/drivers/staging/unisys/visorbus/devmajorminor_attr.c b/drivers/staging/unisys/visorbus/devmajorminor_attr.c deleted file mode 100644 index ceb4bb7394c6..000000000000 --- a/drivers/staging/unisys/visorbus/devmajorminor_attr.c +++ /dev/null @@ -1,192 +0,0 @@ -/* devmajorminor_attr.c - * - * 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. - */ - -/* Implement publishing of device node attributes under: - * - * /sys/bus/visorbus/dev/devmajorminor - * - */ - -#include "devmajorminor_attr.h" -#define CURRENT_FILE_PC VISOR_BUS_PC_devmajorminor_attr_c - -#define to_devmajorminor_attr(_attr) \ - container_of(_attr, struct devmajorminor_attribute, attr) -#define to_visor_device_from_kobjdevmajorminor(obj) \ - container_of(obj, struct visor_device, kobjdevmajorminor) - -struct devmajorminor_attribute { - struct attribute attr; - int slot; - ssize_t (*show)(struct visor_device *, int slot, char *buf); - ssize_t (*store)(struct visor_device *, int slot, const char *buf, - size_t count); -}; - -static ssize_t DEVMAJORMINOR_ATTR(struct visor_device *dev, int slot, char *buf) -{ - int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]); - - if (slot < 0 || slot >= maxdevnodes) - return 0; - return snprintf(buf, PAGE_SIZE, "%d:%d\n", - dev->devnodes[slot].major, dev->devnodes[slot].minor); -} - -static ssize_t -devmajorminor_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) -{ - struct devmajorminor_attribute *devmajorminor_attr = - to_devmajorminor_attr(attr); - struct visor_device *dev = to_visor_device_from_kobjdevmajorminor(kobj); - ssize_t ret = 0; - - if (devmajorminor_attr->show) - ret = devmajorminor_attr->show(dev, - devmajorminor_attr->slot, buf); - return ret; -} - -static ssize_t -devmajorminor_attr_store(struct kobject *kobj, - struct attribute *attr, const char *buf, size_t count) -{ - struct devmajorminor_attribute *devmajorminor_attr = - to_devmajorminor_attr(attr); - struct visor_device *dev = to_visor_device_from_kobjdevmajorminor(kobj); - ssize_t ret = 0; - - if (devmajorminor_attr->store) - ret = devmajorminor_attr->store(dev, - devmajorminor_attr->slot, - buf, count); - return ret; -} - -int -devmajorminor_create_file(struct visor_device *dev, const char *name, - int major, int minor) -{ - int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]); - struct devmajorminor_attribute *myattr = NULL; - int x = -1, rc = 0, slot = -1; - - register_devmajorminor_attributes(dev); - for (slot = 0; slot < maxdevnodes; slot++) - if (!dev->devnodes[slot].attr) - break; - if (slot == maxdevnodes) { - rc = -ENOMEM; - goto away; - } - myattr = kmalloc(sizeof(*myattr), GFP_KERNEL); - if (!myattr) { - rc = -ENOMEM; - goto away; - } - memset(myattr, 0, sizeof(struct devmajorminor_attribute)); - myattr->show = DEVMAJORMINOR_ATTR; - myattr->store = NULL; - myattr->slot = slot; - myattr->attr.name = name; - myattr->attr.mode = S_IRUGO; - dev->devnodes[slot].attr = myattr; - dev->devnodes[slot].major = major; - dev->devnodes[slot].minor = minor; - x = sysfs_create_file(&dev->kobjdevmajorminor, &myattr->attr); - if (x < 0) { - rc = x; - goto away; - } - kobject_uevent(&dev->device.kobj, KOBJ_ONLINE); -away: - if (rc < 0) { - kfree(myattr); - myattr = NULL; - dev->devnodes[slot].attr = NULL; - } - return rc; -} - -void -devmajorminor_remove_file(struct visor_device *dev, int slot) -{ - int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]); - struct devmajorminor_attribute *myattr = NULL; - - if (slot < 0 || slot >= maxdevnodes) - return; - myattr = (struct devmajorminor_attribute *)(dev->devnodes[slot].attr); - if (myattr) - return; - sysfs_remove_file(&dev->kobjdevmajorminor, &myattr->attr); - kobject_uevent(&dev->device.kobj, KOBJ_OFFLINE); - dev->devnodes[slot].attr = NULL; - kfree(myattr); -} - -void -devmajorminor_remove_all_files(struct visor_device *dev) -{ - int i = 0; - int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]); - - for (i = 0; i < maxdevnodes; i++) - devmajorminor_remove_file(dev, i); -} - -static const struct sysfs_ops devmajorminor_sysfs_ops = { - .show = devmajorminor_attr_show, - .store = devmajorminor_attr_store, -}; - -static struct kobj_type devmajorminor_kobj_type = { - .sysfs_ops = &devmajorminor_sysfs_ops -}; - -int -register_devmajorminor_attributes(struct visor_device *dev) -{ - int rc = 0, x = 0; - - if (dev->kobjdevmajorminor.parent) - goto away; /* already registered */ - x = kobject_init_and_add(&dev->kobjdevmajorminor, - &devmajorminor_kobj_type, &dev->device.kobj, - "devmajorminor"); - if (x < 0) { - rc = x; - goto away; - } - - kobject_uevent(&dev->kobjdevmajorminor, KOBJ_ADD); - -away: - return rc; -} - -void -unregister_devmajorminor_attributes(struct visor_device *dev) -{ - if (!dev->kobjdevmajorminor.parent) - return; /* already unregistered */ - devmajorminor_remove_all_files(dev); - - kobject_del(&dev->kobjdevmajorminor); - kobject_put(&dev->kobjdevmajorminor); - dev->kobjdevmajorminor.parent = NULL; -} diff --git a/drivers/staging/unisys/visorbus/devmajorminor_attr.h b/drivers/staging/unisys/visorbus/devmajorminor_attr.h deleted file mode 100644 index 0b55cb1df46a..000000000000 --- a/drivers/staging/unisys/visorbus/devmajorminor_attr.h +++ /dev/null @@ -1,31 +0,0 @@ -/* devmajorminor_attr.h - * - * 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. - */ - -#ifndef __DEVMAJORMINOR_ATTR_H__ -#define __DEVMAJORMINOR_ATTR_H__ - -#include "visorbus.h" /* just to get visor_device declaration */ -#include "timskmod.h" - -int register_devmajorminor_attributes(struct visor_device *dev); -void unregister_devmajorminor_attributes(struct visor_device *dev); -int devmajorminor_create_file(struct visor_device *dev, const char *nam, - int major, int minor); -void devmajorminor_remove_file(struct visor_device *dev, int slot); -void devmajorminor_remove_all_files(struct visor_device *dev); - -#endif diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index c4eec2cde1c2..d5556e2cb5ef 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -19,7 +19,6 @@ #include "visorbus_private.h" #include "timskmod.h" -#include "devmajorminor_attr.h" #include "periodic_work.h" #include "vbuschannel.h" #include "guestlinuxdebug.h" @@ -199,6 +198,181 @@ visorbus_release_device(struct device *xdev) kfree(dev); } +/* Implement publishing of device node attributes under: + * + * /sys/bus/visorbus/dev/devmajorminor + * + */ + +#define to_devmajorminor_attr(_attr) \ + container_of(_attr, struct devmajorminor_attribute, attr) +#define to_visor_device_from_kobjdevmajorminor(obj) \ + container_of(obj, struct visor_device, kobjdevmajorminor) + +struct devmajorminor_attribute { + struct attribute attr; + int slot; + ssize_t (*show)(struct visor_device *, int slot, char *buf); + ssize_t (*store)(struct visor_device *, int slot, const char *buf, + size_t count); +}; + +static ssize_t DEVMAJORMINOR_ATTR(struct visor_device *dev, int slot, char *buf) +{ + int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]); + + if (slot < 0 || slot >= maxdevnodes) + return 0; + return snprintf(buf, PAGE_SIZE, "%d:%d\n", + dev->devnodes[slot].major, dev->devnodes[slot].minor); +} + +static ssize_t +devmajorminor_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) +{ + struct devmajorminor_attribute *devmajorminor_attr = + to_devmajorminor_attr(attr); + struct visor_device *dev = to_visor_device_from_kobjdevmajorminor(kobj); + ssize_t ret = 0; + + if (devmajorminor_attr->show) + ret = devmajorminor_attr->show(dev, + devmajorminor_attr->slot, buf); + return ret; +} + +static ssize_t +devmajorminor_attr_store(struct kobject *kobj, + struct attribute *attr, const char *buf, size_t count) +{ + struct devmajorminor_attribute *devmajorminor_attr = + to_devmajorminor_attr(attr); + struct visor_device *dev = to_visor_device_from_kobjdevmajorminor(kobj); + ssize_t ret = 0; + + if (devmajorminor_attr->store) + ret = devmajorminor_attr->store(dev, + devmajorminor_attr->slot, + buf, count); + return ret; +} + +static int register_devmajorminor_attributes(struct visor_device *dev); + +int +devmajorminor_create_file(struct visor_device *dev, const char *name, + int major, int minor) +{ + int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]); + struct devmajorminor_attribute *myattr = NULL; + int x = -1, rc = 0, slot = -1; + + register_devmajorminor_attributes(dev); + for (slot = 0; slot < maxdevnodes; slot++) + if (!dev->devnodes[slot].attr) + break; + if (slot == maxdevnodes) { + rc = -ENOMEM; + goto away; + } + myattr = kmalloc(sizeof(*myattr), GFP_KERNEL); + if (!myattr) { + rc = -ENOMEM; + goto away; + } + memset(myattr, 0, sizeof(struct devmajorminor_attribute)); + myattr->show = DEVMAJORMINOR_ATTR; + myattr->store = NULL; + myattr->slot = slot; + myattr->attr.name = name; + myattr->attr.mode = S_IRUGO; + dev->devnodes[slot].attr = myattr; + dev->devnodes[slot].major = major; + dev->devnodes[slot].minor = minor; + x = sysfs_create_file(&dev->kobjdevmajorminor, &myattr->attr); + if (x < 0) { + rc = x; + goto away; + } + kobject_uevent(&dev->device.kobj, KOBJ_ONLINE); +away: + if (rc < 0) { + kfree(myattr); + myattr = NULL; + dev->devnodes[slot].attr = NULL; + } + return rc; +} + +void +devmajorminor_remove_file(struct visor_device *dev, int slot) +{ + int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]); + struct devmajorminor_attribute *myattr = NULL; + + if (slot < 0 || slot >= maxdevnodes) + return; + myattr = (struct devmajorminor_attribute *)(dev->devnodes[slot].attr); + if (myattr) + return; + sysfs_remove_file(&dev->kobjdevmajorminor, &myattr->attr); + kobject_uevent(&dev->device.kobj, KOBJ_OFFLINE); + dev->devnodes[slot].attr = NULL; + kfree(myattr); +} + +void +devmajorminor_remove_all_files(struct visor_device *dev) +{ + int i = 0; + int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]); + + for (i = 0; i < maxdevnodes; i++) + devmajorminor_remove_file(dev, i); +} + +static const struct sysfs_ops devmajorminor_sysfs_ops = { + .show = devmajorminor_attr_show, + .store = devmajorminor_attr_store, +}; + +static struct kobj_type devmajorminor_kobj_type = { + .sysfs_ops = &devmajorminor_sysfs_ops +}; + +static int +register_devmajorminor_attributes(struct visor_device *dev) +{ + int rc = 0, x = 0; + + if (dev->kobjdevmajorminor.parent) + goto away; /* already registered */ + x = kobject_init_and_add(&dev->kobjdevmajorminor, + &devmajorminor_kobj_type, &dev->device.kobj, + "devmajorminor"); + if (x < 0) { + rc = x; + goto away; + } + + kobject_uevent(&dev->kobjdevmajorminor, KOBJ_ADD); + +away: + return rc; +} + +void +unregister_devmajorminor_attributes(struct visor_device *dev) +{ + if (!dev->kobjdevmajorminor.parent) + return; /* already unregistered */ + devmajorminor_remove_all_files(dev); + + kobject_del(&dev->kobjdevmajorminor); + kobject_put(&dev->kobjdevmajorminor); + dev->kobjdevmajorminor.parent = NULL; +} + /* Implement publishing of channel attributes under: * * /sys/bus/visorbus/dev/channel From 429809db3b133ff5e1d864bfb6e09c2ce9994e9a Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Tue, 5 May 2015 18:36:08 -0400 Subject: [PATCH 0233/1163] staging: unisys: rename visorchannel_funcs.c to visorchannel.c visorchannel_funcs.c is a remnant of the separate visorchannel directory. It should be called visorchannel now. Signed-off-by: Prarit Bhargava Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/Makefile | 2 +- .../unisys/visorbus/{visorchannel_funcs.c => visorchannel.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename drivers/staging/unisys/visorbus/{visorchannel_funcs.c => visorchannel.c} (100%) diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile index 0465fb909a99..7151690695f5 100644 --- a/drivers/staging/unisys/visorbus/Makefile +++ b/drivers/staging/unisys/visorbus/Makefile @@ -5,7 +5,7 @@ obj-$(CONFIG_UNISYS_VISORBUS) += visorbus.o visorbus-y := visorbus_main.o -visorbus-y += visorchannel_funcs.o +visorbus-y += visorchannel.o ccflags-y += -Idrivers/staging/unisys/include ccflags-y += -Idrivers/staging/unisys/visorchipset diff --git a/drivers/staging/unisys/visorbus/visorchannel_funcs.c b/drivers/staging/unisys/visorbus/visorchannel.c similarity index 100% rename from drivers/staging/unisys/visorbus/visorchannel_funcs.c rename to drivers/staging/unisys/visorbus/visorchannel.c From 40699b97e2b55aa31cf486731c13ec287ad2b0d0 Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Tue, 5 May 2015 18:36:09 -0400 Subject: [PATCH 0234/1163] staging: unisys: remove globals.h globals.h is only included in visorchannel.c and only contains 2 includes. These can be included directly in visorchannel.c. Signed-off-by: Prarit Bhargava Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/globals.h | 27 ------------------- .../staging/unisys/visorbus/visorchannel.c | 3 ++- 2 files changed, 2 insertions(+), 28 deletions(-) delete mode 100644 drivers/staging/unisys/visorbus/globals.h diff --git a/drivers/staging/unisys/visorbus/globals.h b/drivers/staging/unisys/visorbus/globals.h deleted file mode 100644 index 0ed8e1d8033a..000000000000 --- a/drivers/staging/unisys/visorbus/globals.h +++ /dev/null @@ -1,27 +0,0 @@ -/* globals.h - * - * 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. - */ - -#ifndef __VISORCHANNEL_GLOBALS_H__ -#define __VISORCHANNEL_GLOBALS_H__ - -#include "timskmod.h" -#include "memregion.h" -#include "version.h" - -#define MYDRVNAME "visorchannel" - -#endif diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index b61f9549d352..33a4360cf8e6 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -22,7 +22,8 @@ * a CM2 implementation and a direct memory implementation.) */ -#include "globals.h" +#include "memregion.h" +#include "version.h" #include "visorbus.h" #include From 4b78000ecf9765519d160803e5e7077b9ea9b5be Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Tue, 5 May 2015 18:36:10 -0400 Subject: [PATCH 0235/1163] staging: unisys: remove visorbus_private.h visorbus_private.h is only included from visorbus_main.c and has no other purpose. The code can be easily moved into visorbus_main.c. Signed-off-by: Prarit Bhargava Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorbus_main.c | 27 +++++++++- .../unisys/visorbus/visorbus_private.h | 50 ------------------- 2 files changed, 26 insertions(+), 51 deletions(-) delete mode 100644 drivers/staging/unisys/visorbus/visorbus_private.h diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index d5556e2cb5ef..13a270dc9b65 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -17,12 +17,37 @@ #include -#include "visorbus_private.h" +#include "visorbus.h" +#include "visorchipset.h" +#include "version.h" #include "timskmod.h" #include "periodic_work.h" #include "vbuschannel.h" #include "guestlinuxdebug.h" #include "vbusdeviceinfo.h" + +/* module parameters */ +int visorbus_debug; +int visorbus_forcematch; +int visorbus_forcenomatch; +#define MAXDEVICETEST 4 +int visorbus_devicetest; +int visorbus_debugref; +int visorbus_serialloopbacktest; +#define SERIALLOOPBACKCHANADDR (100 * 1024 * 1024) + +/** This is the private data that we store for each bus device instance. + */ +struct visorbus_devdata { + int devno; /* this is the chipset busNo */ + struct list_head list_all; + struct device *dev; + struct kobject kobj; + struct visorchannel *chan; /* channel area for bus itself */ + bool vbus_valid; + struct spar_vbus_headerinfo vbus_hdr_info; +}; + /* These forward declarations are required since our drivers are out-of-tree. * The structures referenced are kernel-private and are not in the headers, but * it is impossible to make a functioning bus driver without them. diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h deleted file mode 100644 index 47ab4887661d..000000000000 --- a/drivers/staging/unisys/visorbus/visorbus_private.h +++ /dev/null @@ -1,50 +0,0 @@ -/* visorbus_private.h - * - * 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. - */ - -#ifndef __VISORBUS_PRIVATE_H__ -#define __VISORBUS_PRIVATE_H__ - -#include "timskmod.h" -#include "visorbus.h" -#include "visorchipset.h" -#include "visorbus.h" -#include "version.h" -#include "vbuschannel.h" - -/* module parameters */ -extern int visorbus_debug; -extern int visorbus_forcematch; -extern int visorbus_forcenomatch; -#define MAXDEVICETEST 4 -extern int visorbus_devicetest; -extern int visorbus_debugref; -extern int visorbus_serialloopbacktest; -#define SERIALLOOPBACKCHANADDR (100 * 1024 * 1024) - -/** This is the private data that we store for each bus device instance. - */ -struct visorbus_devdata { - int devno; /* this is the chipset busNo */ - struct list_head list_all; - struct device *dev; - struct kobject kobj; - struct visorchannel *chan; /* channel area for bus itself */ - bool vbus_valid; - struct spar_vbus_headerinfo vbus_hdr_info; -}; - -#endif From d777ba2e69bd2b7304adfabad6d1e495bd1b4f99 Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Tue, 5 May 2015 18:36:11 -0400 Subject: [PATCH 0236/1163] staging: unisys: remove visorchipset_umode.h removes visorchipset_umode.h and pass functionality to visorchipset.h Signed-off-by: Erik Arfvidson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/file.c | 1 - .../unisys/visorchipset/visorchipset.h | 1 + .../unisys/visorchipset/visorchipset_umode.h | 35 ------------------- 3 files changed, 1 insertion(+), 36 deletions(-) delete mode 100644 drivers/staging/unisys/visorchipset/visorchipset_umode.h diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c index 9822e9d1d6be..153f736dd76c 100644 --- a/drivers/staging/unisys/visorchipset/file.c +++ b/drivers/staging/unisys/visorchipset/file.c @@ -23,7 +23,6 @@ #include #include "version.h" #include "visorchipset.h" -#include "visorchipset_umode.h" #include "visorbus.h" #include "uisutils.h" #include "file.h" diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 1d66c3766c42..dcf8a2345a59 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -28,6 +28,7 @@ #include "vbushelper.h" #define MYDRVNAME "visorchipset" +#define VISORCHIPSET_MMAP_CONTROLCHANOFFSET 0x00000000 /** Describes the state from the perspective of which controlvm messages have * been received for a bus or device. diff --git a/drivers/staging/unisys/visorchipset/visorchipset_umode.h b/drivers/staging/unisys/visorchipset/visorchipset_umode.h deleted file mode 100644 index 8af5bf33883c..000000000000 --- a/drivers/staging/unisys/visorchipset/visorchipset_umode.h +++ /dev/null @@ -1,35 +0,0 @@ -/* visorchipset_umode.h - * - * 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. - */ - -/** @file ********************************************************************* - * - * This describes structures needed for the interface between the - * visorchipset driver and a user-mode component that opens the device. - * - ****************************************************************************** - */ - -#ifndef __VISORCHIPSET_UMODE_H -#define __VISORCHIPSET_UMODE_H - -/** The user-mode program can access the control channel buffer directly - * via this memory map. - */ -#define VISORCHIPSET_MMAP_CONTROLCHANOFFSET 0x00000000 -#define VISORCHIPSET_MMAP_CONTROLCHANSIZE 0x00400000 /* 4MB */ - -#endif /* __VISORCHIPSET_UMODE_H */ From 95e967569dfd9bbe38bb533650c8a6bfb12f9523 Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Tue, 5 May 2015 18:36:12 -0400 Subject: [PATCH 0237/1163] staging: unisys: moving file.h functionality to visorchipset.h this patch simply migrates file.h functionality to visorchipset.h Signed-off-by: Erik Arfvidson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/file.c | 5 ++-- drivers/staging/unisys/visorchipset/file.h | 25 ------------------- .../unisys/visorchipset/visorchipset.h | 4 ++- .../unisys/visorchipset/visorchipset_main.c | 1 - 4 files changed, 6 insertions(+), 29 deletions(-) delete mode 100644 drivers/staging/unisys/visorchipset/file.h diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c index 153f736dd76c..c0bd4161fb75 100644 --- a/drivers/staging/unisys/visorchipset/file.c +++ b/drivers/staging/unisys/visorchipset/file.c @@ -19,13 +19,14 @@ * communicate with the visorchipset driver using a device/file interface. */ -#include #include +#include + #include "version.h" #include "visorchipset.h" #include "visorbus.h" #include "uisutils.h" -#include "file.h" +#include "visorchipset.h" #define CURRENT_FILE_PC VISOR_CHIPSET_PC_file_c diff --git a/drivers/staging/unisys/visorchipset/file.h b/drivers/staging/unisys/visorchipset/file.h deleted file mode 100644 index 6ff28a1ae86e..000000000000 --- a/drivers/staging/unisys/visorchipset/file.h +++ /dev/null @@ -1,25 +0,0 @@ -/* file.h - * - * 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. - */ - -#ifndef __FILE_H__ -#define __FILE_H__ - -int visorchipset_file_init(dev_t majorDev, - struct visorchannel **pControlVm_channel); -void visorchipset_file_cleanup(dev_t major_dev); - -#endif diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index dcf8a2345a59..93763ee8258b 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -188,5 +188,7 @@ void *visorchipset_cache_alloc(struct kmem_cache *pool, bool ok_to_block, char *fn, int ln); void visorchipset_cache_free(struct kmem_cache *pool, void *p, char *fn, int ln); - +int visorchipset_file_init(dev_t majorDev, + struct visorchannel **pControlVm_channel); +void visorchipset_file_cleanup(dev_t major_dev); #endif diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index a8448c23a89b..34ac17b4a6f5 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -20,7 +20,6 @@ #include "procobjecttree.h" #include "visorbus.h" #include "periodic_work.h" -#include "file.h" #include "parser.h" #include "uisutils.h" #include "controlvmcompletionstatus.h" From e3420ed6629530880c6b4dcc584cdfa0736a883a Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Tue, 5 May 2015 18:36:13 -0400 Subject: [PATCH 0238/1163] staging: unisys: remove file.c and pass functionality to visorchipset This patch trasitions the include files and functions from file.c and places them into visorchipset_main.c Signed-off-by: Erik Arfvidson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/Makefile | 2 +- drivers/staging/unisys/visorchipset/file.c | 162 ------------------ .../unisys/visorchipset/visorchipset_main.c | 136 ++++++++++++++- 3 files changed, 136 insertions(+), 164 deletions(-) delete mode 100644 drivers/staging/unisys/visorchipset/file.c diff --git a/drivers/staging/unisys/visorchipset/Makefile b/drivers/staging/unisys/visorchipset/Makefile index 1bf6699579ec..6886cb7bd397 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 file.o parser.o +visorchipset-y := visorchipset_main.o parser.o ccflags-y += -Idrivers/staging/unisys/include ccflags-y += -Idrivers/staging/unisys/uislib diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c deleted file mode 100644 index c0bd4161fb75..000000000000 --- a/drivers/staging/unisys/visorchipset/file.c +++ /dev/null @@ -1,162 +0,0 @@ -/* file.c - * - * 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. - */ - -/* This contains the implementation that allows a usermode program to - * communicate with the visorchipset driver using a device/file interface. - */ - -#include -#include - -#include "version.h" -#include "visorchipset.h" -#include "visorbus.h" -#include "uisutils.h" -#include "visorchipset.h" - -#define CURRENT_FILE_PC VISOR_CHIPSET_PC_file_c - -static struct cdev file_cdev; -static struct visorchannel **file_controlvm_channel; - -void -visorchipset_file_cleanup(dev_t major_dev) -{ - if (file_cdev.ops) - cdev_del(&file_cdev); - file_cdev.ops = NULL; - unregister_chrdev_region(major_dev, 1); -} - -static int -visorchipset_open(struct inode *inode, struct file *file) -{ - unsigned minor_number = iminor(inode); - - if (minor_number) - return -ENODEV; - file->private_data = NULL; - return 0; -} - -static int -visorchipset_release(struct inode *inode, struct file *file) -{ - return 0; -} - -static int -visorchipset_mmap(struct file *file, struct vm_area_struct *vma) -{ - unsigned long physaddr = 0; - unsigned long offset = vma->vm_pgoff << PAGE_SHIFT; - GUEST_PHYSICAL_ADDRESS addr = 0; - - /* sv_enable_dfp(); */ - if (offset & (PAGE_SIZE - 1)) - return -ENXIO; /* need aligned offsets */ - - switch (offset) { - case VISORCHIPSET_MMAP_CONTROLCHANOFFSET: - vma->vm_flags |= VM_IO; - if (!*file_controlvm_channel) - return -ENXIO; - - visorchannel_read(*file_controlvm_channel, - offsetof(struct spar_controlvm_channel_protocol, - gp_control_channel), - &addr, sizeof(addr)); - if (!addr) - return -ENXIO; - - physaddr = (unsigned long)addr; - if (remap_pfn_range(vma, vma->vm_start, - physaddr >> PAGE_SHIFT, - vma->vm_end - vma->vm_start, - /*pgprot_noncached */ - (vma->vm_page_prot))) { - return -EAGAIN; - } - break; - default: - return -ENOSYS; - } - return 0; -} - -static long visorchipset_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) -{ - s64 adjustment; - s64 vrtc_offset; - - switch (cmd) { - case VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET: - /* get the physical rtc offset */ - vrtc_offset = issue_vmcall_query_guest_virtual_time_offset(); - if (copy_to_user((void __user *)arg, &vrtc_offset, - sizeof(vrtc_offset))) { - return -EFAULT; - } - return SUCCESS; - case VMCALL_UPDATE_PHYSICAL_TIME: - if (copy_from_user(&adjustment, (void __user *)arg, - sizeof(adjustment))) { - return -EFAULT; - } - return issue_vmcall_update_physical_time(adjustment); - default: - return -EFAULT; - } -} - -static const struct file_operations visorchipset_fops = { - .owner = THIS_MODULE, - .open = visorchipset_open, - .read = NULL, - .write = NULL, - .unlocked_ioctl = visorchipset_ioctl, - .release = visorchipset_release, - .mmap = visorchipset_mmap, -}; - -int -visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel) -{ - int rc = 0; - - file_controlvm_channel = controlvm_channel; - cdev_init(&file_cdev, &visorchipset_fops); - file_cdev.owner = THIS_MODULE; - if (MAJOR(major_dev) == 0) { - rc = alloc_chrdev_region(&major_dev, 0, 1, MYDRVNAME); - /* dynamic major device number registration required */ - if (rc < 0) - return rc; - } else { - /* static major device number registration required */ - rc = register_chrdev_region(major_dev, 1, MYDRVNAME); - if (rc < 0) - return rc; - } - rc = cdev_add(&file_cdev, MKDEV(MAJOR(major_dev), 0), 1); - if (rc < 0) { - unregister_chrdev_region(major_dev, 1); - return rc; - } - return 0; -} diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 34ac17b4a6f5..d5bd1a11ad88 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -16,7 +16,6 @@ */ #include "version.h" -#include "visorchipset.h" #include "procobjecttree.h" #include "visorbus.h" #include "periodic_work.h" @@ -24,7 +23,10 @@ #include "uisutils.h" #include "controlvmcompletionstatus.h" #include "guestlinuxdebug.h" +#include "visorchipset.h" +#include +#include #include #include #include @@ -56,6 +58,23 @@ static int visorchipset_testteardown; static int visorchipset_disable_controlvm; static int visorchipset_holdchipsetready; +static int +visorchipset_open(struct inode *inode, struct file *file) +{ + unsigned minor_number = iminor(inode); + + if (minor_number) + return -ENODEV; + file->private_data = NULL; + return 0; +} + +static int +visorchipset_release(struct inode *inode, struct file *file) +{ + return 0; +} + /* When the controlvm channel is idle for at least MIN_IDLE_SECONDS, * we switch to slow polling mode. As soon as we get a controlvm * message, we switch back to fast polling mode. @@ -74,6 +93,8 @@ static struct delayed_work periodic_controlvm_work; static struct workqueue_struct *periodic_controlvm_workqueue; static DEFINE_SEMAPHORE(notifier_lock); +static struct cdev file_cdev; +static struct visorchannel **file_controlvm_channel; static struct controlvm_message_header g_chipset_msg_hdr; static const uuid_le spar_diag_pool_channel_protocol_uuid = SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID; @@ -2169,6 +2190,110 @@ static ssize_t deviceenabled_store(struct device *dev, return count; } +static int +visorchipset_mmap(struct file *file, struct vm_area_struct *vma) +{ + unsigned long physaddr = 0; + unsigned long offset = vma->vm_pgoff << PAGE_SHIFT; + GUEST_PHYSICAL_ADDRESS addr = 0; + + /* sv_enable_dfp(); */ + if (offset & (PAGE_SIZE - 1)) + return -ENXIO; /* need aligned offsets */ + + switch (offset) { + case VISORCHIPSET_MMAP_CONTROLCHANOFFSET: + vma->vm_flags |= VM_IO; + if (!*file_controlvm_channel) + return -ENXIO; + + visorchannel_read(*file_controlvm_channel, + offsetof(struct spar_controlvm_channel_protocol, + gp_control_channel), + &addr, sizeof(addr)); + if (!addr) + return -ENXIO; + + physaddr = (unsigned long)addr; + if (remap_pfn_range(vma, vma->vm_start, + physaddr >> PAGE_SHIFT, + vma->vm_end - vma->vm_start, + /*pgprot_noncached */ + (vma->vm_page_prot))) { + return -EAGAIN; + } + break; + default: + return -ENXIO; + } + return 0; +} + +static long visorchipset_ioctl(struct file *file, unsigned int cmd, + unsigned long arg) +{ + s64 adjustment; + s64 vrtc_offset; + + switch (cmd) { + case VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET: + /* get the physical rtc offset */ + vrtc_offset = issue_vmcall_query_guest_virtual_time_offset(); + if (copy_to_user((void __user *)arg, &vrtc_offset, + sizeof(vrtc_offset))) { + return -EFAULT; + } + return SUCCESS; + case VMCALL_UPDATE_PHYSICAL_TIME: + if (copy_from_user(&adjustment, (void __user *)arg, + sizeof(adjustment))) { + return -EFAULT; + } + return issue_vmcall_update_physical_time(adjustment); + default: + return -EFAULT; + } +} + +static const struct file_operations visorchipset_fops = { + .owner = THIS_MODULE, + .open = visorchipset_open, + .read = NULL, + .write = NULL, + .unlocked_ioctl = visorchipset_ioctl, + .release = visorchipset_release, + .mmap = visorchipset_mmap, +}; + +int +visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel) +{ + int rc = 0; + + file_controlvm_channel = controlvm_channel; + cdev_init(&file_cdev, &visorchipset_fops); + file_cdev.owner = THIS_MODULE; + if (MAJOR(major_dev) == 0) { + rc = alloc_chrdev_region(&major_dev, 0, 1, MYDRVNAME); + /* dynamic major device number registration required */ + if (rc < 0) + return rc; + } else { + /* static major device number registration required */ + rc = register_chrdev_region(major_dev, 1, MYDRVNAME); + if (rc < 0) + return rc; + } + rc = cdev_add(&file_cdev, MKDEV(MAJOR(major_dev), 0), 1); + if (rc < 0) { + unregister_chrdev_region(major_dev, 1); + return rc; + } + return 0; +} + + + static int __init visorchipset_init(void) { @@ -2262,6 +2387,15 @@ cleanup: return rc; } +void +visorchipset_file_cleanup(dev_t major_dev) +{ + if (file_cdev.ops) + cdev_del(&file_cdev); + file_cdev.ops = NULL; + unregister_chrdev_region(major_dev, 1); +} + static void visorchipset_exit(void) { From 4616881022a1ea98738966a6cbefab0ea1c085a9 Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Tue, 5 May 2015 18:36:14 -0400 Subject: [PATCH 0239/1163] staging: unisys: move parser.[ch] functionality into visorchipset This patch moves includes files and functions from parser.[ch] into visorchipset. Signed-off-by: Erik Arfvidson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorbus_main.c | 2 +- drivers/staging/unisys/visorchipset/Makefile | 2 +- drivers/staging/unisys/visorchipset/parser.c | 430 ------------------ drivers/staging/unisys/visorchipset/parser.h | 45 -- .../unisys/visorchipset/visorchipset.h | 24 +- .../unisys/visorchipset/visorchipset_main.c | 411 ++++++++++++++++- 6 files changed, 432 insertions(+), 482 deletions(-) delete mode 100644 drivers/staging/unisys/visorchipset/parser.c delete mode 100644 drivers/staging/unisys/visorchipset/parser.h diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 13a270dc9b65..d7ca1163c1b1 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -2040,7 +2040,7 @@ visorbus_init(void) POSTCODE_LINUX_3(DRIVER_ENTRY_PC, rc, POSTCODE_SEVERITY_INFO); bus_device_info_init(&clientbus_driverinfo, - "clientbus", MYDRVNAME, + "clientbus", "visorbus", VERSION, NULL); /* process module options */ diff --git a/drivers/staging/unisys/visorchipset/Makefile b/drivers/staging/unisys/visorchipset/Makefile index 6886cb7bd397..e9168d8d69a5 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 parser.o +visorchipset-y := visorchipset_main.o ccflags-y += -Idrivers/staging/unisys/include ccflags-y += -Idrivers/staging/unisys/uislib diff --git a/drivers/staging/unisys/visorchipset/parser.c b/drivers/staging/unisys/visorchipset/parser.c deleted file mode 100644 index 6ca6da8772a8..000000000000 --- a/drivers/staging/unisys/visorchipset/parser.c +++ /dev/null @@ -1,430 +0,0 @@ -/* parser.c - * - * 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. - */ - -#include "parser.h" -#include "memregion.h" -#include "controlvmchannel.h" -#include -#include -#include - -#define MYDRVNAME "visorchipset_parser" -#define CURRENT_FILE_PC VISOR_CHIPSET_PC_parser_c - -/* We will refuse to allocate more than this many bytes to copy data from - * incoming payloads. This serves as a throttling mechanism. - */ -#define MAX_CONTROLVM_PAYLOAD_BYTES (1024*128) -static unsigned long controlvm_payload_bytes_buffered; - -struct parser_context { - unsigned long allocbytes; - unsigned long param_bytes; - u8 *curr; - unsigned long bytes_remaining; - bool byte_stream; - char data[0]; -}; - -static struct parser_context * -parser_init_guts(u64 addr, u32 bytes, bool local, - bool standard_payload_header, bool *retry) -{ - int allocbytes = sizeof(struct parser_context) + bytes; - struct parser_context *rc = NULL; - struct parser_context *ctx = NULL; - struct memregion *rgn = NULL; - struct spar_controlvm_parameters_header *phdr = NULL; - - if (retry) - *retry = false; - if (!standard_payload_header) - /* alloc and 0 extra byte to ensure payload is - * '\0'-terminated - */ - allocbytes++; - if ((controlvm_payload_bytes_buffered + bytes) - > MAX_CONTROLVM_PAYLOAD_BYTES) { - if (retry) - *retry = true; - rc = NULL; - goto cleanup; - } - ctx = kzalloc(allocbytes, GFP_KERNEL|__GFP_NORETRY); - if (!ctx) { - if (retry) - *retry = true; - rc = NULL; - goto cleanup; - } - - ctx->allocbytes = allocbytes; - ctx->param_bytes = bytes; - ctx->curr = NULL; - ctx->bytes_remaining = 0; - ctx->byte_stream = false; - if (local) { - void *p; - - if (addr > virt_to_phys(high_memory - 1)) { - rc = NULL; - goto cleanup; - } - p = __va((unsigned long) (addr)); - memcpy(ctx->data, p, bytes); - } else { - rgn = visor_memregion_create(addr, bytes); - if (!rgn) { - rc = NULL; - goto cleanup; - } - if (visor_memregion_read(rgn, 0, ctx->data, bytes) < 0) { - rc = NULL; - goto cleanup; - } - } - if (!standard_payload_header) { - ctx->byte_stream = true; - rc = ctx; - goto cleanup; - } - phdr = (struct spar_controlvm_parameters_header *)(ctx->data); - if (phdr->total_length != bytes) { - rc = NULL; - goto cleanup; - } - if (phdr->total_length < phdr->header_length) { - rc = NULL; - goto cleanup; - } - if (phdr->header_length < - sizeof(struct spar_controlvm_parameters_header)) { - rc = NULL; - goto cleanup; - } - - rc = ctx; -cleanup: - if (rgn) { - visor_memregion_destroy(rgn); - rgn = NULL; - } - if (rc) { - controlvm_payload_bytes_buffered += ctx->param_bytes; - } else { - if (ctx) { - parser_done(ctx); - ctx = NULL; - } - } - return rc; -} - -struct parser_context * -parser_init(u64 addr, u32 bytes, bool local, bool *retry) -{ - return parser_init_guts(addr, bytes, local, true, retry); -} - -/* Call this instead of parser_init() if the payload area consists of just - * a sequence of bytes, rather than a struct spar_controlvm_parameters_header - * structures. Afterwards, you can call parser_simpleString_get() or - * parser_byteStream_get() to obtain the data. - */ -struct parser_context * -parser_init_byte_stream(u64 addr, u32 bytes, bool local, bool *retry) -{ - return parser_init_guts(addr, bytes, local, false, retry); -} - -/* Obtain '\0'-terminated copy of string in payload area. - */ -char * -parser_simpleString_get(struct parser_context *ctx) -{ - if (!ctx->byte_stream) - return NULL; - return ctx->data; /* note this IS '\0'-terminated, because of - * the num of bytes we alloc+clear in - * parser_init_byteStream() */ -} - -/* Obtain a copy of the buffer in the payload area. - */ -void *parser_byte_stream_get(struct parser_context *ctx, unsigned long *nbytes) -{ - if (!ctx->byte_stream) - return NULL; - if (nbytes) - *nbytes = ctx->param_bytes; - return (void *)ctx->data; -} - -uuid_le -parser_id_get(struct parser_context *ctx) -{ - struct spar_controlvm_parameters_header *phdr = NULL; - - if (ctx == NULL) - return NULL_UUID_LE; - phdr = (struct spar_controlvm_parameters_header *)(ctx->data); - return phdr->id; -} - -void -parser_param_start(struct parser_context *ctx, PARSER_WHICH_STRING which_string) -{ - struct spar_controlvm_parameters_header *phdr = NULL; - - if (ctx == NULL) - goto Away; - phdr = (struct spar_controlvm_parameters_header *)(ctx->data); - switch (which_string) { - case PARSERSTRING_INITIATOR: - ctx->curr = ctx->data + phdr->initiator_offset; - ctx->bytes_remaining = phdr->initiator_length; - break; - case PARSERSTRING_TARGET: - ctx->curr = ctx->data + phdr->target_offset; - ctx->bytes_remaining = phdr->target_length; - break; - case PARSERSTRING_CONNECTION: - ctx->curr = ctx->data + phdr->connection_offset; - ctx->bytes_remaining = phdr->connection_length; - break; - case PARSERSTRING_NAME: - ctx->curr = ctx->data + phdr->name_offset; - ctx->bytes_remaining = phdr->name_length; - break; - default: - break; - } - -Away: - return; -} - -void -parser_done(struct parser_context *ctx) -{ - if (!ctx) - return; - controlvm_payload_bytes_buffered -= ctx->param_bytes; - kfree(ctx); -} - -/** Return length of string not counting trailing spaces. */ -static int -string_length_no_trail(char *s, int len) -{ - int i = len - 1; - - while (i >= 0) { - if (!isspace(s[i])) - return i + 1; - i--; - } - return 0; -} - -/** Grab the next name and value out of the parameter buffer. - * The entire parameter buffer looks like this: - * =\0 - * =\0 - * ... - * \0 - * If successful, the next value is returned within the supplied - * buffer (the value is always upper-cased), and the corresponding - * is returned within a kmalloc()ed buffer, whose pointer is - * provided as the return value of this function. - * (The total number of bytes allocated is strlen()+1.) - * - * NULL is returned to indicate failure, which can occur for several reasons: - * - all = pairs have already been processed - * - bad parameter - * - parameter buffer ends prematurely (couldn't find an '=' or '\0' within - * the confines of the parameter buffer) - * - the buffer is not large enough to hold the of the next - * parameter - */ -void * -parser_param_get(struct parser_context *ctx, char *nam, int namesize) -{ - u8 *pscan, *pnam = nam; - unsigned long nscan; - int value_length = -1, orig_value_length = -1; - void *value = NULL; - int i; - int closing_quote = 0; - - if (!ctx) - return NULL; - pscan = ctx->curr; - nscan = ctx->bytes_remaining; - if (nscan == 0) - return NULL; - if (*pscan == '\0') - /* This is the normal return point after you have processed - * all of the = pairs in a syntactically-valid - * parameter buffer. - */ - return NULL; - - /* skip whitespace */ - while (isspace(*pscan)) { - pscan++; - nscan--; - if (nscan == 0) - return NULL; - } - - while (*pscan != ':') { - if (namesize <= 0) - return NULL; - *pnam = toupper(*pscan); - pnam++; - namesize--; - pscan++; - nscan--; - if (nscan == 0) - return NULL; - } - if (namesize <= 0) - return NULL; - *pnam = '\0'; - nam[string_length_no_trail(nam, strlen(nam))] = '\0'; - - /* point to char immediately after ":" in ":" */ - pscan++; - nscan--; - /* skip whitespace */ - while (isspace(*pscan)) { - pscan++; - nscan--; - if (nscan == 0) - return NULL; - } - if (nscan == 0) - return NULL; - if (*pscan == '\'' || *pscan == '"') { - closing_quote = *pscan; - pscan++; - nscan--; - if (nscan == 0) - return NULL; - } - - /* look for a separator character, terminator character, or - * end of data - */ - for (i = 0, value_length = -1; i < nscan; i++) { - if (closing_quote) { - if (pscan[i] == '\0') - return NULL; - if (pscan[i] == closing_quote) { - value_length = i; - break; - } - } else - if (pscan[i] == ',' || pscan[i] == ';' - || pscan[i] == '\0') { - value_length = i; - break; - } - } - if (value_length < 0) { - if (closing_quote) - return NULL; - value_length = nscan; - } - orig_value_length = value_length; - if (closing_quote == 0) - value_length = string_length_no_trail(pscan, orig_value_length); - value = kmalloc(value_length + 1, GFP_KERNEL|__GFP_NORETRY); - if (value == NULL) - return NULL; - memcpy(value, pscan, value_length); - ((u8 *) (value))[value_length] = '\0'; - - pscan += orig_value_length; - nscan -= orig_value_length; - - /* skip past separator or closing quote */ - if (nscan > 0) { - if (*pscan != '\0') { - pscan++; - nscan--; - } - } - - if (closing_quote && (nscan > 0)) { - /* we still need to skip around the real separator if present */ - /* first, skip whitespace */ - while (isspace(*pscan)) { - pscan++; - nscan--; - if (nscan == 0) - break; - } - if (nscan > 0) { - if (*pscan == ',' || *pscan == ';') { - pscan++; - nscan--; - } else if (*pscan != '\0') { - kfree(value); - value = NULL; - return NULL; - } - } - } - ctx->curr = pscan; - ctx->bytes_remaining = nscan; - return value; -} - -void * -parser_string_get(struct parser_context *ctx) -{ - u8 *pscan; - unsigned long nscan; - int value_length = -1; - void *value = NULL; - int i; - - if (!ctx) - return NULL; - pscan = ctx->curr; - nscan = ctx->bytes_remaining; - if (nscan == 0) - return NULL; - if (!pscan) - return NULL; - for (i = 0, value_length = -1; i < nscan; i++) - if (pscan[i] == '\0') { - value_length = i; - break; - } - if (value_length < 0) /* '\0' was not included in the length */ - value_length = nscan; - value = kmalloc(value_length + 1, GFP_KERNEL|__GFP_NORETRY); - if (value == NULL) - return NULL; - if (value_length > 0) - memcpy(value, pscan, value_length); - ((u8 *) (value))[value_length] = '\0'; - return value; -} diff --git a/drivers/staging/unisys/visorchipset/parser.h b/drivers/staging/unisys/visorchipset/parser.h deleted file mode 100644 index 3fe17c0c64d2..000000000000 --- a/drivers/staging/unisys/visorchipset/parser.h +++ /dev/null @@ -1,45 +0,0 @@ -/* parser.h - * - * 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. - */ - -#ifndef __PARSER_H__ -#define __PARSER_H__ - -#include - -#include "channel.h" - -typedef enum { - PARSERSTRING_INITIATOR, - PARSERSTRING_TARGET, - PARSERSTRING_CONNECTION, - PARSERSTRING_NAME, -} PARSER_WHICH_STRING; - -struct parser_context *parser_init(u64 addr, u32 bytes, bool isLocal, - bool *tryAgain); -struct parser_context *parser_init_byte_stream(u64 addr, u32 bytes, bool local, - bool *retry); -void parser_param_start(struct parser_context *ctx, - PARSER_WHICH_STRING which_string); -void *parser_param_get(struct parser_context *ctx, char *nam, int namesize); -void *parser_string_get(struct parser_context *ctx); -uuid_le parser_id_get(struct parser_context *ctx); -char *parser_simpleString_get(struct parser_context *ctx); -void *parser_byte_stream_get(struct parser_context *ctx, unsigned long *nbytes); -void parser_done(struct parser_context *ctx); - -#endif diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 93763ee8258b..264a3e9226ea 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -22,17 +22,37 @@ #include "channel.h" #include "controlvmchannel.h" -#include "parser.h" #include "procobjecttree.h" #include "vbusdeviceinfo.h" #include "vbushelper.h" -#define MYDRVNAME "visorchipset" #define VISORCHIPSET_MMAP_CONTROLCHANOFFSET 0x00000000 /** Describes the state from the perspective of which controlvm messages have * been received for a bus or device. */ + +enum PARSER_WHICH_STRING { + PARSERSTRING_INITIATOR, + PARSERSTRING_TARGET, + PARSERSTRING_CONNECTION, + PARSERSTRING_NAME, +}; + +struct visorchannel; +struct parser_context *parser_init(u64 addr, u32 bytes, bool isLocal, + bool *tryAgain); +struct parser_context *parser_init_byte_stream(u64 addr, u32 bytes, bool local, + bool *retry); +void parser_param_start(struct parser_context *ctx, + PARSER_WHICH_STRING which_string); +void *parser_param_get(struct parser_context *ctx, char *nam, int namesize); +void *parser_string_get(struct parser_context *ctx); +uuid_le parser_id_get(struct parser_context *ctx); +char *parser_simpleString_get(struct parser_context *ctx); +void *parser_byte_stream_get(struct parser_context *ctx, unsigned long *nbytes); +void parser_done(struct parser_context *ctx); + struct visorchipset_state { u32 created:1; u32 attached:1; diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index d5bd1a11ad88..dc9f1dc18306 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -15,16 +15,19 @@ * details. */ +#include "memregion.h" +#include "controlvmchannel.h" #include "version.h" #include "procobjecttree.h" #include "visorbus.h" #include "periodic_work.h" -#include "parser.h" #include "uisutils.h" #include "controlvmcompletionstatus.h" #include "guestlinuxdebug.h" #include "visorchipset.h" + +#include #include #include #include @@ -45,6 +48,7 @@ #define POLLJIFFIES_CONTROLVMCHANNEL_FAST 1 #define POLLJIFFIES_CONTROLVMCHANNEL_SLOW 100 +#define MAX_CONTROLVM_PAYLOAD_BYTES (1024*128) /* * Module parameters */ @@ -57,6 +61,7 @@ static int visorchipset_clientregwait = 1; /* default is on */ static int visorchipset_testteardown; static int visorchipset_disable_controlvm; static int visorchipset_holdchipsetready; +static unsigned long controlvm_payload_bytes_buffered; static int visorchipset_open(struct inode *inode, struct file *file) @@ -89,6 +94,15 @@ static int clientregistered; #define MAX_CHIPSET_EVENTS 2 static u8 chipset_events[MAX_CHIPSET_EVENTS] = { 0, 0 }; +struct parser_context { + unsigned long allocbytes; + unsigned long param_bytes; + u8 *curr; + unsigned long bytes_remaining; + bool byte_stream; + char data[0]; +}; + static struct delayed_work periodic_controlvm_work; static struct workqueue_struct *periodic_controlvm_workqueue; static DEFINE_SEMAPHORE(notifier_lock); @@ -367,6 +381,397 @@ static void controlvm_respond_physdev_changestate( struct controlvm_message_header *msg_hdr, int response, struct spar_segment_state state); + +static struct parser_context * +parser_init_guts(u64 addr, u32 bytes, bool local, + bool standard_payload_header, bool *retry) +{ + int allocbytes = sizeof(struct parser_context) + bytes; + struct parser_context *rc = NULL; + struct parser_context *ctx = NULL; + struct memregion *rgn = NULL; + struct spar_controlvm_parameters_header *phdr = NULL; + + if (retry) + *retry = false; + if (!standard_payload_header) + /* alloc and 0 extra byte to ensure payload is + * '\0'-terminated + */ + allocbytes++; + if ((controlvm_payload_bytes_buffered + bytes) + > MAX_CONTROLVM_PAYLOAD_BYTES) { + if (retry) + *retry = true; + rc = NULL; + goto cleanup; + } + ctx = kzalloc(allocbytes, GFP_KERNEL|__GFP_NORETRY); + if (!ctx) { + if (retry) + *retry = true; + rc = NULL; + goto cleanup; + } + + ctx->allocbytes = allocbytes; + ctx->param_bytes = bytes; + ctx->curr = NULL; + ctx->bytes_remaining = 0; + ctx->byte_stream = false; + if (local) { + void *p; + + if (addr > virt_to_phys(high_memory - 1)) { + rc = NULL; + goto cleanup; + } + p = __va((unsigned long) (addr)); + memcpy(ctx->data, p, bytes); + } else { + rgn = visor_memregion_create(addr, bytes); + if (!rgn) { + rc = NULL; + goto cleanup; + } + if (visor_memregion_read(rgn, 0, ctx->data, bytes) < 0) { + rc = NULL; + goto cleanup; + } + } + if (!standard_payload_header) { + ctx->byte_stream = true; + rc = ctx; + goto cleanup; + } + phdr = (struct spar_controlvm_parameters_header *)(ctx->data); + if (phdr->total_length != bytes) { + rc = NULL; + goto cleanup; + } + if (phdr->total_length < phdr->header_length) { + rc = NULL; + goto cleanup; + } + if (phdr->header_length < + sizeof(struct spar_controlvm_parameters_header)) { + rc = NULL; + goto cleanup; + } + + rc = ctx; +cleanup: + if (rgn) { + visor_memregion_destroy(rgn); + rgn = NULL; + } + if (rc) { + controlvm_payload_bytes_buffered += ctx->param_bytes; + } else { + if (ctx) { + parser_done(ctx); + ctx = NULL; + } + } + return rc; +} + +struct parser_context * +parser_init(u64 addr, u32 bytes, bool local, bool *retry) +{ + return parser_init_guts(addr, bytes, local, true, retry); +} + +/* Call this instead of parser_init() if the payload area consists of just + * a sequence of bytes, rather than a struct spar_controlvm_parameters_header + * structures. Afterwards, you can call parser_simpleString_get() or + * parser_byteStream_get() to obtain the data. + */ +struct parser_context * +parser_init_byte_stream(u64 addr, u32 bytes, bool local, bool *retry) +{ + return parser_init_guts(addr, bytes, local, false, retry); +} + +/* Obtain '\0'-terminated copy of string in payload area. + */ +char * +parser_simpleString_get(struct parser_context *ctx) +{ + if (!ctx->byte_stream) + return NULL; + return ctx->data; /* note this IS '\0'-terminated, because of + * the num of bytes we alloc+clear in + * parser_init_byteStream() */ +} + +/* Obtain a copy of the buffer in the payload area. + */ +void *parser_byte_stream_get(struct parser_context *ctx, unsigned long *nbytes) +{ + if (!ctx->byte_stream) + return NULL; + if (nbytes) + *nbytes = ctx->param_bytes; + return (void *)ctx->data; +} + +uuid_le +parser_id_get(struct parser_context *ctx) +{ + struct spar_controlvm_parameters_header *phdr = NULL; + + if (ctx == NULL) + return NULL_UUID_LE; + phdr = (struct spar_controlvm_parameters_header *)(ctx->data); + return phdr->id; +} + +void +parser_param_start(struct parser_context *ctx, PARSER_WHICH_STRING which_string) +{ + struct spar_controlvm_parameters_header *phdr = NULL; + + if (ctx == NULL) + goto Away; + phdr = (struct spar_controlvm_parameters_header *)(ctx->data); + switch (which_string) { + case PARSERSTRING_INITIATOR: + ctx->curr = ctx->data + phdr->initiator_offset; + ctx->bytes_remaining = phdr->initiator_length; + break; + case PARSERSTRING_TARGET: + ctx->curr = ctx->data + phdr->target_offset; + ctx->bytes_remaining = phdr->target_length; + break; + case PARSERSTRING_CONNECTION: + ctx->curr = ctx->data + phdr->connection_offset; + ctx->bytes_remaining = phdr->connection_length; + break; + case PARSERSTRING_NAME: + ctx->curr = ctx->data + phdr->name_offset; + ctx->bytes_remaining = phdr->name_length; + break; + default: + break; + } + +Away: + return; +} + +void +parser_done(struct parser_context *ctx) +{ + if (!ctx) + return; + controlvm_payload_bytes_buffered -= ctx->param_bytes; + kfree(ctx); +} + +/** Return length of string not counting trailing spaces. */ +static int +string_length_no_trail(char *s, int len) +{ + int i = len - 1; + + while (i >= 0) { + if (!isspace(s[i])) + return i + 1; + i--; + } + return 0; +} + +/** Grab the next name and value out of the parameter buffer. + * The entire parameter buffer looks like this: + * =\0 + * =\0 + * ... + * \0 + * If successful, the next value is returned within the supplied + * buffer (the value is always upper-cased), and the corresponding + * is returned within a kmalloc()ed buffer, whose pointer is + * provided as the return value of this function. + * (The total number of bytes allocated is strlen()+1.) + * + * NULL is returned to indicate failure, which can occur for several reasons: + * - all = pairs have already been processed + * - bad parameter + * - parameter buffer ends prematurely (couldn't find an '=' or '\0' within + * the confines of the parameter buffer) + * - the buffer is not large enough to hold the of the next + * parameter + */ +void * +parser_param_get(struct parser_context *ctx, char *nam, int namesize) +{ + u8 *pscan, *pnam = nam; + unsigned long nscan; + int value_length = -1, orig_value_length = -1; + void *value = NULL; + int i; + int closing_quote = 0; + + if (!ctx) + return NULL; + pscan = ctx->curr; + nscan = ctx->bytes_remaining; + if (nscan == 0) + return NULL; + if (*pscan == '\0') + /* This is the normal return point after you have processed + * all of the = pairs in a syntactically-valid + * parameter buffer. + */ + return NULL; + + /* skip whitespace */ + while (isspace(*pscan)) { + pscan++; + nscan--; + if (nscan == 0) + return NULL; + } + + while (*pscan != ':') { + if (namesize <= 0) + return NULL; + *pnam = toupper(*pscan); + pnam++; + namesize--; + pscan++; + nscan--; + if (nscan == 0) + return NULL; + } + if (namesize <= 0) + return NULL; + *pnam = '\0'; + nam[string_length_no_trail(nam, strlen(nam))] = '\0'; + + /* point to char immediately after ":" in ":" */ + pscan++; + nscan--; + /* skip whitespace */ + while (isspace(*pscan)) { + pscan++; + nscan--; + if (nscan == 0) + return NULL; + } + if (nscan == 0) + return NULL; + if (*pscan == '\'' || *pscan == '"') { + closing_quote = *pscan; + pscan++; + nscan--; + if (nscan == 0) + return NULL; + } + + /* look for a separator character, terminator character, or + * end of data + */ + for (i = 0, value_length = -1; i < nscan; i++) { + if (closing_quote) { + if (pscan[i] == '\0') + return NULL; + if (pscan[i] == closing_quote) { + value_length = i; + break; + } + } else + if (pscan[i] == ',' || pscan[i] == ';' + || pscan[i] == '\0') { + value_length = i; + break; + } + } + if (value_length < 0) { + if (closing_quote) + return NULL; + value_length = nscan; + } + orig_value_length = value_length; + if (closing_quote == 0) + value_length = string_length_no_trail(pscan, orig_value_length); + value = kmalloc(value_length + 1, GFP_KERNEL|__GFP_NORETRY); + if (value == NULL) + return NULL; + memcpy(value, pscan, value_length); + ((u8 *) (value))[value_length] = '\0'; + + pscan += orig_value_length; + nscan -= orig_value_length; + + /* skip past separator or closing quote */ + if (nscan > 0) { + if (*pscan != '\0') { + pscan++; + nscan--; + } + } + + if (closing_quote && (nscan > 0)) { + /* we still need to skip around the real separator if present */ + /* first, skip whitespace */ + while (isspace(*pscan)) { + pscan++; + nscan--; + if (nscan == 0) + break; + } + if (nscan > 0) { + if (*pscan == ',' || *pscan == ';') { + pscan++; + nscan--; + } else if (*pscan != '\0') { + kfree(value); + value = NULL; + return NULL; + } + } + } + ctx->curr = pscan; + ctx->bytes_remaining = nscan; + return value; +} + +void * +parser_string_get(struct parser_context *ctx) +{ + u8 *pscan; + unsigned long nscan; + int value_length = -1; + void *value = NULL; + int i; + + if (!ctx) + return NULL; + pscan = ctx->curr; + nscan = ctx->bytes_remaining; + if (nscan == 0) + return NULL; + if (!pscan) + return NULL; + for (i = 0, value_length = -1; i < nscan; i++) + if (pscan[i] == '\0') { + value_length = i; + break; + } + if (value_length < 0) /* '\0' was not included in the length */ + value_length = nscan; + value = kmalloc(value_length + 1, GFP_KERNEL|__GFP_NORETRY); + if (value == NULL) + return NULL; + if (value_length > 0) + memcpy(value, pscan, value_length); + ((u8 *) (value))[value_length] = '\0'; + return value; +} + + static ssize_t toolaction_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -2274,13 +2679,13 @@ visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel) cdev_init(&file_cdev, &visorchipset_fops); file_cdev.owner = THIS_MODULE; if (MAJOR(major_dev) == 0) { - rc = alloc_chrdev_region(&major_dev, 0, 1, MYDRVNAME); + rc = alloc_chrdev_region(&major_dev, 0, 1, "visorchipset"); /* dynamic major device number registration required */ if (rc < 0) return rc; } else { /* static major device number registration required */ - rc = register_chrdev_region(major_dev, 1, MYDRVNAME); + rc = register_chrdev_region(major_dev, 1, "visorchipset"); if (rc < 0) return rc; } From c79b28f7332e54903f6c81ff1157cbd3bf761a17 Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Tue, 5 May 2015 18:36:15 -0400 Subject: [PATCH 0240/1163] staging: unisys: move visorchipset files to visorbus Move visorchipset_main.c and visorchipset.h to visorbus/visorchipset.c and visorbus/visorbus_private.h. This leaves an empty visorchipset directory which can also be destroyed. As a result of this patch the visorchipset init code now calls the visorbus_init() directly. Similarily the visorchipset exit code now cleans up by calling visorbus_exit(). No other functional changes were made. Signed-off-by: Prarit Bhargava Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/Kconfig | 1 - drivers/staging/unisys/Makefile | 1 - drivers/staging/unisys/visorbus/Kconfig | 2 +- drivers/staging/unisys/visorbus/Makefile | 2 +- drivers/staging/unisys/visorbus/visorbus_main.c | 11 +++++------ .../visorbus_private.h} | 4 ++++ .../visorchipset.c} | 9 ++++++--- drivers/staging/unisys/visorchipset/Kconfig | 11 ----------- drivers/staging/unisys/visorchipset/Makefile | 15 --------------- 9 files changed, 17 insertions(+), 39 deletions(-) rename drivers/staging/unisys/{visorchipset/visorchipset.h => visorbus/visorbus_private.h} (98%) rename drivers/staging/unisys/{visorchipset/visorchipset_main.c => visorbus/visorchipset.c} (99%) delete mode 100644 drivers/staging/unisys/visorchipset/Kconfig delete mode 100644 drivers/staging/unisys/visorchipset/Makefile diff --git a/drivers/staging/unisys/Kconfig b/drivers/staging/unisys/Kconfig index dbdd4492cf0f..50223c74eb50 100644 --- a/drivers/staging/unisys/Kconfig +++ b/drivers/staging/unisys/Kconfig @@ -10,7 +10,6 @@ menuconfig UNISYSSPAR if UNISYSSPAR source "drivers/staging/unisys/visorutil/Kconfig" -source "drivers/staging/unisys/visorchipset/Kconfig" source "drivers/staging/unisys/visorbus/Kconfig" endif # UNISYSSPAR diff --git a/drivers/staging/unisys/Makefile b/drivers/staging/unisys/Makefile index b14a4777fd48..e0c893a6e870 100644 --- a/drivers/staging/unisys/Makefile +++ b/drivers/staging/unisys/Makefile @@ -2,5 +2,4 @@ # Makefile for Unisys SPAR drivers # obj-$(CONFIG_UNISYS_VISORUTIL) += visorutil/ -obj-$(CONFIG_UNISYS_VISORCHIPSET) += visorchipset/ obj-$(CONFIG_UNISYS_VISORBUS) += visorbus/ diff --git a/drivers/staging/unisys/visorbus/Kconfig b/drivers/staging/unisys/visorbus/Kconfig index 12cf8f063550..420c9eee9075 100644 --- a/drivers/staging/unisys/visorbus/Kconfig +++ b/drivers/staging/unisys/visorbus/Kconfig @@ -4,6 +4,6 @@ config UNISYS_VISORBUS tristate "Unisys visorbus driver" - depends on UNISYSSPAR && UNISYS_VISORUTIL && UNISYS_VISORCHIPSET + depends on UNISYSSPAR && UNISYS_VISORUTIL ---help--- If you say Y here, you will enable the Unisys visorbus driver. diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile index 7151690695f5..16d3ff507a0a 100644 --- a/drivers/staging/unisys/visorbus/Makefile +++ b/drivers/staging/unisys/visorbus/Makefile @@ -6,9 +6,9 @@ obj-$(CONFIG_UNISYS_VISORBUS) += visorbus.o visorbus-y := visorbus_main.o visorbus-y += visorchannel.o +visorbus-y += visorchipset.o ccflags-y += -Idrivers/staging/unisys/include -ccflags-y += -Idrivers/staging/unisys/visorchipset ccflags-y += -Idrivers/staging/unisys/common-spar/include ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels ccflags-y += -Idrivers/staging/unisys/visorutil diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index d7ca1163c1b1..6c939ce503a1 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -18,7 +18,7 @@ #include #include "visorbus.h" -#include "visorchipset.h" +#include "visorbus_private.h" #include "version.h" #include "timskmod.h" #include "periodic_work.h" @@ -26,6 +26,8 @@ #include "guestlinuxdebug.h" #include "vbusdeviceinfo.h" +#define MYDRVNAME "visorbus" + /* module parameters */ int visorbus_debug; int visorbus_forcematch; @@ -2033,7 +2035,7 @@ struct channel_size_info { unsigned long max_size; }; -static int __init +int __init visorbus_init(void) { int rc = 0; @@ -2077,7 +2079,7 @@ away: return rc; } -static void +void visorbus_exit(void) { struct list_head *listentry, *listtmp; @@ -2135,9 +2137,6 @@ MODULE_PARM_DESC(visorbus_serialloopbacktest, "non-0 to just create 2 serial devices on the same channel"); int visorbus_serialloopbacktest = 0; -module_init(visorbus_init); -module_exit(visorbus_exit); - MODULE_AUTHOR("Unisys"); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Supervisor bus driver for service partition: ver " VERSION); diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorbus/visorbus_private.h similarity index 98% rename from drivers/staging/unisys/visorchipset/visorchipset.h rename to drivers/staging/unisys/visorbus/visorbus_private.h index 264a3e9226ea..68d770f29115 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorbus/visorbus_private.h @@ -211,4 +211,8 @@ void visorchipset_cache_free(struct kmem_cache *pool, void *p, int visorchipset_file_init(dev_t majorDev, struct visorchannel **pControlVm_channel); void visorchipset_file_cleanup(dev_t major_dev); + +/* visorbus init and exit functions */ +int __init visorbus_init(void); +void visorbus_exit(void); #endif diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorbus/visorchipset.c similarity index 99% rename from drivers/staging/unisys/visorchipset/visorchipset_main.c rename to drivers/staging/unisys/visorbus/visorchipset.c index dc9f1dc18306..f3a2145ac3ce 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -24,7 +24,7 @@ #include "uisutils.h" #include "controlvmcompletionstatus.h" #include "guestlinuxdebug.h" -#include "visorchipset.h" +#include "visorbus_private.h" #include @@ -168,7 +168,7 @@ static struct visor_livedump_info livedump_info; * process it again the next time controlvm_periodic_work() runs. */ static struct controlvm_message controlvm_pending_msg; -static bool controlvm_pending_msg_valid = false; +static bool controlvm_pending_msg_valid; /* This identifies a data buffer that has been received via a controlvm messages * in a remote --> local CONTROLVM_TRANSMIT_FILE conversation. @@ -2783,7 +2783,8 @@ visorchipset_init(void) goto cleanup; } POSTCODE_LINUX_2(CHIPSET_INIT_SUCCESS_PC, POSTCODE_SEVERITY_INFO); - rc = 0; + + rc = visorbus_init(); cleanup: if (rc) { POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, rc, @@ -2806,6 +2807,8 @@ visorchipset_exit(void) { POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO); + visorbus_exit(); + if (visorchipset_disable_controlvm) { ; } else { diff --git a/drivers/staging/unisys/visorchipset/Kconfig b/drivers/staging/unisys/visorchipset/Kconfig deleted file mode 100644 index 01d9a9a0e904..000000000000 --- a/drivers/staging/unisys/visorchipset/Kconfig +++ /dev/null @@ -1,11 +0,0 @@ -# -# Unisys visorchipset configuration -# - -config UNISYS_VISORCHIPSET - tristate "Unisys visorchipset driver" - select UNISYS_VISORUTIL - select UNISYS_VISORBUS - ---help--- - If you say Y here, you will enable the Unisys visorchipset driver. - diff --git a/drivers/staging/unisys/visorchipset/Makefile b/drivers/staging/unisys/visorchipset/Makefile deleted file mode 100644 index e9168d8d69a5..000000000000 --- a/drivers/staging/unisys/visorchipset/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -# -# Makefile for Unisys visorchipset -# - -obj-$(CONFIG_UNISYS_VISORCHIPSET) += visorchipset.o - -visorchipset-y := visorchipset_main.o - -ccflags-y += -Idrivers/staging/unisys/include -ccflags-y += -Idrivers/staging/unisys/uislib -ccflags-y += -Idrivers/staging/unisys/common-spar/include -ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels -ccflags-y += -Idrivers/staging/unisys/visorutil -ccflags-y += -Idrivers/staging/unisys/visorbus -ccflags-y += -Iinclude/generated From 2ee0deec49bd1aded66bc7b017af35f8723ff9ef Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Tue, 5 May 2015 18:36:16 -0400 Subject: [PATCH 0241/1163] staging: unisys: cleanup visorbus_private.h visorbus_private.h contains code that is called from visorbus into the visorchipset code. Now that the visorchipset code has been brought into the visorbus directory, many of the declarations are not necessary and can be cleaned up. TODO: PARSER_WHICH_STRING enum only has one member used (PARSERSTRING_NAME). TODO: crash_obj_type appears to be unnecessary in the overall scheme of code. Signed-off-by: Prarit Bhargava Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/visorbus/visorbus_private.h | 57 ------------------- .../staging/unisys/visorbus/visorchipset.c | 35 +++++++++++- 2 files changed, 33 insertions(+), 59 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h index 68d770f29115..a3d78f619d64 100644 --- a/drivers/staging/unisys/visorbus/visorbus_private.h +++ b/drivers/staging/unisys/visorbus/visorbus_private.h @@ -26,32 +26,7 @@ #include "vbusdeviceinfo.h" #include "vbushelper.h" -#define VISORCHIPSET_MMAP_CONTROLCHANOFFSET 0x00000000 - -/** Describes the state from the perspective of which controlvm messages have - * been received for a bus or device. - */ - -enum PARSER_WHICH_STRING { - PARSERSTRING_INITIATOR, - PARSERSTRING_TARGET, - PARSERSTRING_CONNECTION, - PARSERSTRING_NAME, -}; - struct visorchannel; -struct parser_context *parser_init(u64 addr, u32 bytes, bool isLocal, - bool *tryAgain); -struct parser_context *parser_init_byte_stream(u64 addr, u32 bytes, bool local, - bool *retry); -void parser_param_start(struct parser_context *ctx, - PARSER_WHICH_STRING which_string); -void *parser_param_get(struct parser_context *ctx, char *nam, int namesize); -void *parser_string_get(struct parser_context *ctx); -uuid_le parser_id_get(struct parser_context *ctx); -char *parser_simpleString_get(struct parser_context *ctx); -void *parser_byte_stream_get(struct parser_context *ctx, unsigned long *nbytes); -void parser_done(struct parser_context *ctx); struct visorchipset_state { u32 created:1; @@ -75,11 +50,6 @@ enum visorchipset_addresstype { ADDRTYPE_LOCALTEST, }; -enum crash_obj_type { - CRASH_DEV, - CRASH_BUS, -}; - /** Attributes for a particular Supervisor channel. */ struct visorchipset_channel_info { @@ -167,18 +137,6 @@ struct visorchipset_busdev_responders { void (*device_resume)(u32 bus_no, u32 dev_no, int response); }; -/** Register functions (in the bus driver) to get called by visorchipset - * whenever a bus or device appears for which this service partition is - * to be the server for. visorchipset will fill in , to - * indicate functions the bus driver should call to indicate message - * responses. - */ -void -visorchipset_register_busdev_client( - struct visorchipset_busdev_notifiers *notifiers, - struct visorchipset_busdev_responders *responders, - struct ultra_vbus_deviceinfo *driver_info); - /** Register functions (in the bus driver) to get called by visorchipset * whenever a bus or device appears for which this service partition is * to be the client for. visorchipset will fill in , to @@ -191,26 +149,11 @@ visorchipset_register_busdev_server( struct visorchipset_busdev_responders *responders, struct ultra_vbus_deviceinfo *driver_info); -void visorchipset_device_pause_response(u32 bus_no, u32 dev_no, int response); - bool visorchipset_get_bus_info(u32 bus_no, struct visorchipset_bus_info *bus_info); bool visorchipset_get_device_info(u32 bus_no, u32 dev_no, struct visorchipset_device_info *dev_info); bool visorchipset_set_bus_context(u32 bus_no, void *context); -bool visorchipset_set_device_context(u32 bus_no, u32 dev_no, void *context); -int visorchipset_chipset_ready(void); -int visorchipset_chipset_selftest(void); -int visorchipset_chipset_notready(void); -void visorchipset_save_message(struct controlvm_message *msg, - enum crash_obj_type type); -void *visorchipset_cache_alloc(struct kmem_cache *pool, - bool ok_to_block, char *fn, int ln); -void visorchipset_cache_free(struct kmem_cache *pool, void *p, - char *fn, int ln); -int visorchipset_file_init(dev_t majorDev, - struct visorchannel **pControlVm_channel); -void visorchipset_file_cleanup(dev_t major_dev); /* visorbus init and exit functions */ int __init visorbus_init(void); diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index f3a2145ac3ce..5bf8266f0663 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -49,6 +49,9 @@ #define POLLJIFFIES_CONTROLVMCHANNEL_SLOW 100 #define MAX_CONTROLVM_PAYLOAD_BYTES (1024*128) + +#define VISORCHIPSET_MMAP_CONTROLCHANOFFSET 0x00000000 + /* * Module parameters */ @@ -261,6 +264,9 @@ static void device_create_response(u32 bus_no, u32 dev_no, int response); static void device_destroy_response(u32 bus_no, u32 dev_no, int response); static void device_resume_response(u32 bus_no, u32 dev_no, int response); +static void visorchipset_device_pause_response(u32 bus_no, u32 dev_no, + int response); + static struct visorchipset_busdev_responders busdev_responders = { .bus_create = bus_create_response, .bus_destroy = bus_destroy_response, @@ -382,6 +388,8 @@ static void controlvm_respond_physdev_changestate( struct spar_segment_state state); +static void parser_done(struct parser_context *ctx); + static struct parser_context * parser_init_guts(u64 addr, u32 bytes, bool local, bool standard_payload_header, bool *retry) @@ -527,8 +535,20 @@ parser_id_get(struct parser_context *ctx) return phdr->id; } +/** Describes the state from the perspective of which controlvm messages have + * been received for a bus or device. + */ + +enum PARSER_WHICH_STRING { + PARSERSTRING_INITIATOR, + PARSERSTRING_TARGET, + PARSERSTRING_CONNECTION, + PARSERSTRING_NAME, /* TODO: only PARSERSTRING_NAME is used ? */ +}; + void -parser_param_start(struct parser_context *ctx, PARSER_WHICH_STRING which_string) +parser_param_start(struct parser_context *ctx, + enum PARSER_WHICH_STRING which_string) { struct spar_controlvm_parameters_header *phdr = NULL; @@ -1032,6 +1052,12 @@ visorchipset_register_busdev_server( } EXPORT_SYMBOL_GPL(visorchipset_register_busdev_server); +/** Register functions (in the bus driver) to get called by visorchipset + * whenever a bus or device appears for which this service partition is + * to be the server for. visorchipset will fill in , to + * indicate functions the bus driver should call to indicate message + * responses. + */ void visorchipset_register_busdev_client( struct visorchipset_busdev_notifiers *notifiers, @@ -1175,6 +1201,11 @@ static void controlvm_respond_physdev_changestate( } } +enum crash_obj_type { + CRASH_DEV, + CRASH_BUS, +}; + void visorchipset_save_message(struct controlvm_message *msg, enum crash_obj_type type) @@ -1218,7 +1249,7 @@ visorchipset_save_message(struct controlvm_message *msg, POSTCODE_SEVERITY_ERR); return; } - } else { + } else { /* CRASH_DEV */ if (visorchannel_write(controlvm_channel, crash_msg_offset + sizeof(struct controlvm_message), msg, From 10c69bb7d9c492666690f2bd359493c2e900865b Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Tue, 5 May 2015 18:36:17 -0400 Subject: [PATCH 0242/1163] staging: unisys: visorchannel cleanup visorchannel_create_guts() The error handling in this function was broken and while looking at that I noticed that the whole function was in need of cleanup. This patch fixes the error handling, specifically if (!p) { visorchannel_destroy(p); channel = NULL; } and does a lot of cleanup. I also verified that the called functions returned correct errors, and that led to a change in visor_memregion_resize(), visorchannel_destroy() and visor_memregion_destroy(). Signed-off-by: Prarit Bhargava Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorchannel.c | 79 ++++++++----------- .../unisys/visorutil/memregion_direct.c | 4 +- 2 files changed, 36 insertions(+), 47 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index 33a4360cf8e6..ff14a0d235f2 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -55,60 +55,52 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes, struct visorchannel *parent, ulong off, uuid_le guid, BOOL needs_lock) { - struct visorchannel *p = NULL; - void *rc = NULL; + struct visorchannel *channel; + int err; + size_t size = sizeof(struct channel_header); + struct memregion *memregion; - p = kmalloc(sizeof(*p), GFP_KERNEL|__GFP_NORETRY); - if (!p) { - rc = NULL; + channel = kmalloc(sizeof(*channel), GFP_KERNEL|__GFP_NORETRY); + if (!channel) goto cleanup; - } - p->memregion = NULL; - p->needs_lock = needs_lock; - spin_lock_init(&p->insert_lock); - spin_lock_init(&p->remove_lock); + + channel->memregion = NULL; + channel->needs_lock = needs_lock; + spin_lock_init(&channel->insert_lock); + spin_lock_init(&channel->remove_lock); /* prepare chan_hdr (abstraction to read/write channel memory) */ if (!parent) - p->memregion = - visor_memregion_create(physaddr, - sizeof(struct channel_header)); + memregion = visor_memregion_create(physaddr, size); else - p->memregion = - visor_memregion_create_overlapped(parent->memregion, - off, sizeof(struct channel_header)); - if (!p->memregion) { - rc = NULL; + memregion = visor_memregion_create_overlapped(parent->memregion, + off, size); + if (!memregion) goto cleanup; - } - if (visor_memregion_read(p->memregion, 0, &p->chan_hdr, - sizeof(struct channel_header)) < 0) { - rc = NULL; + channel->memregion = memregion; + + err = visor_memregion_read(channel->memregion, 0, &channel->chan_hdr, + sizeof(struct channel_header)); + if (err) goto cleanup; - } + + /* we had better be a CLIENT of this channel */ if (channel_bytes == 0) - /* we had better be a CLIENT of this channel */ - channel_bytes = (ulong)p->chan_hdr.size; + channel_bytes = (ulong)channel->chan_hdr.size; if (uuid_le_cmp(guid, NULL_UUID_LE) == 0) - /* we had better be a CLIENT of this channel */ - guid = p->chan_hdr.chtype; - if (visor_memregion_resize(p->memregion, channel_bytes) < 0) { - rc = NULL; + guid = channel->chan_hdr.chtype; + + err = visor_memregion_resize(channel->memregion, channel_bytes); + if (err) goto cleanup; - } - p->size = channel_bytes; - p->guid = guid; - rc = p; + channel->size = channel_bytes; + channel->guid = guid; + return channel; + cleanup: - - if (!rc) { - if (!p) { - visorchannel_destroy(p); - p = NULL; - } - } - return rc; + visorchannel_destroy(channel); + return NULL; } struct visorchannel * @@ -153,10 +145,7 @@ visorchannel_destroy(struct visorchannel *channel) { if (!channel) return; - if (channel->memregion) { - visor_memregion_destroy(channel->memregion); - channel->memregion = NULL; - } + visor_memregion_destroy(channel->memregion); kfree(channel); } EXPORT_SYMBOL_GPL(visorchannel_destroy); diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index eb7422fbe20f..6bb439d64511 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -156,7 +156,7 @@ visor_memregion_resize(struct memregion *memregion, ulong newsize) unmapit(memregion); memregion->nbytes = newsize; if (!mapit(memregion)) - return -1; + return -EIO; } return 0; } @@ -197,7 +197,7 @@ EXPORT_SYMBOL_GPL(visor_memregion_write); void visor_memregion_destroy(struct memregion *memregion) { - if (memregion == NULL) + if (!memregion) return; if (!memregion->overlapped) unmapit(memregion); From 69141bb8eb2edc2f41da1979fe8ae8a99d093f8d Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Tue, 5 May 2015 18:36:18 -0400 Subject: [PATCH 0243/1163] staging: unisys: visorchannel some general function cleanups Just some cleanups for visorchannel.c, and removal of safe_sig_queue_validate() which is dead code. Signed-off-by: Prarit Bhargava Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorchannel.c | 110 +++++++----------- 1 file changed, 41 insertions(+), 69 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index ff14a0d235f2..30bedcc72415 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -211,13 +211,12 @@ int visorchannel_read(struct visorchannel *channel, ulong offset, void *local, ulong nbytes) { - int rc = visor_memregion_read(channel->memregion, offset, - local, nbytes); - if ((rc >= 0) && (offset == 0) && - (nbytes >= sizeof(struct channel_header))) { - memcpy(&channel->chan_hdr, local, - sizeof(struct channel_header)); - } + int rc; + size_t size = sizeof(struct channel_header); + + rc = visor_memregion_read(channel->memregion, offset, local, nbytes); + if (rc && !offset && (nbytes >= size)) + memcpy(&channel->chan_hdr, local, size); return rc; } EXPORT_SYMBOL_GPL(visorchannel_read); @@ -226,9 +225,10 @@ int visorchannel_write(struct visorchannel *channel, ulong offset, void *local, ulong nbytes) { - if (offset == 0 && nbytes >= sizeof(struct channel_header)) - memcpy(&channel->chan_hdr, local, - sizeof(struct channel_header)); + size_t size = sizeof(struct channel_header); + + if (!offset && nbytes >= size) + memcpy(&channel->chan_hdr, local, size); return visor_memregion_write(channel->memregion, offset, local, nbytes); } EXPORT_SYMBOL_GPL(visorchannel_write); @@ -237,38 +237,34 @@ int visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch, ulong nbytes) { - int rc = -1; + int err; int bufsize = 65536; int written = 0; - u8 *buf = vmalloc(bufsize); + u8 *buf; + buf = vmalloc(bufsize); if (!buf) - goto cleanup; + return -ENOMEM; memset(buf, ch, bufsize); while (nbytes > 0) { ulong thisbytes = bufsize; - int x = -1; if (nbytes < thisbytes) thisbytes = nbytes; - x = visor_memregion_write(channel->memregion, offset + written, - buf, thisbytes); - if (x < 0) { - rc = x; + err = visor_memregion_write(channel->memregion, + offset + written, buf, thisbytes); + if (err) goto cleanup; - } + written += thisbytes; nbytes -= thisbytes; } - rc = 0; + return 0; cleanup: - if (buf) { - vfree(buf); - buf = NULL; - } - return rc; + vfree(buf); + return err; } EXPORT_SYMBOL_GPL(visorchannel_clear); @@ -307,22 +303,19 @@ static BOOL sig_read_header(struct visorchannel *channel, u32 queue, struct signal_queue_header *sig_hdr) { - BOOL rc = FALSE; + int err; if (channel->chan_hdr.ch_space_offset < sizeof(struct channel_header)) - goto cleanup; + return FALSE; /* Read the appropriate SIGNAL_QUEUE_HEADER into local memory. */ + err = visor_memregion_read(channel->memregion, + SIG_QUEUE_OFFSET(&channel->chan_hdr, queue), + sig_hdr, sizeof(struct signal_queue_header)); + if (err) + return FALSE; - if (visor_memregion_read(channel->memregion, - SIG_QUEUE_OFFSET(&channel->chan_hdr, queue), - sig_hdr, - sizeof(struct signal_queue_header)) < 0) { - goto cleanup; - } - rc = TRUE; -cleanup: - return rc; + return TRUE; } static BOOL @@ -330,24 +323,23 @@ sig_do_data(struct visorchannel *channel, u32 queue, struct signal_queue_header *sig_hdr, u32 slot, void *data, BOOL is_write) { - BOOL rc = FALSE; + int err; int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue, sig_hdr, slot); if (is_write) { - if (visor_memregion_write(channel->memregion, - signal_data_offset, - data, sig_hdr->signal_size) < 0) { - goto cleanup; - } + err = visor_memregion_write(channel->memregion, + signal_data_offset, + data, sig_hdr->signal_size); + if (err) + return FALSE; } else { - if (visor_memregion_read(channel->memregion, signal_data_offset, - data, sig_hdr->signal_size) < 0) { - goto cleanup; - } + err = visor_memregion_read(channel->memregion, + signal_data_offset, + data, sig_hdr->signal_size); + if (err) + return FALSE; } - rc = TRUE; -cleanup: - return rc; + return TRUE; } static inline BOOL @@ -364,26 +356,6 @@ sig_write_data(struct visorchannel *channel, u32 queue, return sig_do_data(channel, queue, sig_hdr, slot, data, TRUE); } -static inline unsigned char -safe_sig_queue_validate(struct signal_queue_header *psafe_sqh, - struct signal_queue_header *punsafe_sqh, - u32 *phead, u32 *ptail) -{ - if ((*phead >= psafe_sqh->max_slots) || - (*ptail >= psafe_sqh->max_slots)) { - /* Choose 0 or max, maybe based on current tail value */ - *phead = 0; - *ptail = 0; - - /* Sync with client as necessary */ - punsafe_sqh->head = *phead; - punsafe_sqh->tail = *ptail; - - return 0; - } - return 1; -} /* end safe_sig_queue_validate */ - static BOOL signalremove_inner(struct visorchannel *channel, u32 queue, void *msg) { From a4ed0ba9afd39b41066c4ead12a2e4e731daee4a Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Tue, 5 May 2015 18:36:19 -0400 Subject: [PATCH 0244/1163] staging: unisys: fix sig_read_data and sig_read_data functions The sig_read_data() and sig_write_data() functions are involved in 2 steps of calls. They really don't need to be and this makes for much simpler code. Signed-off-by: Prarit Bhargava Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorchannel.c | 48 +++++++++---------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index 30bedcc72415..d7ddc3af4638 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -318,42 +318,38 @@ sig_read_header(struct visorchannel *channel, u32 queue, return TRUE; } -static BOOL -sig_do_data(struct visorchannel *channel, u32 queue, - struct signal_queue_header *sig_hdr, u32 slot, void *data, - BOOL is_write) -{ - int err; - int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue, - sig_hdr, slot); - if (is_write) { - err = visor_memregion_write(channel->memregion, - signal_data_offset, - data, sig_hdr->signal_size); - if (err) - return FALSE; - } else { - err = visor_memregion_read(channel->memregion, - signal_data_offset, - data, sig_hdr->signal_size); - if (err) - return FALSE; - } - return TRUE; -} - static inline BOOL sig_read_data(struct visorchannel *channel, u32 queue, struct signal_queue_header *sig_hdr, u32 slot, void *data) { - return sig_do_data(channel, queue, sig_hdr, slot, data, FALSE); + int err; + int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue, + sig_hdr, slot); + + err = visor_memregion_read(channel->memregion, + signal_data_offset, + data, sig_hdr->signal_size); + if (err) + return FALSE; + + return TRUE; } static inline BOOL sig_write_data(struct visorchannel *channel, u32 queue, struct signal_queue_header *sig_hdr, u32 slot, void *data) { - return sig_do_data(channel, queue, sig_hdr, slot, data, TRUE); + int err; + int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue, + sig_hdr, slot); + + err = visor_memregion_write(channel->memregion, + signal_data_offset, + data, sig_hdr->signal_size); + if (err) + return FALSE; + + return TRUE; } static BOOL From dd5f93851cd8d507700d4051f475c2910957b024 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:20 -0400 Subject: [PATCH 0245/1163] staging: unisys: visorchannel: visorchannel_create_overlap() is never used Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/visorbus.h | 9 +-------- .../staging/unisys/visorbus/visorchannel.c | 20 ------------------- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h index 3956a3df80eb..21fd78583ba9 100644 --- a/drivers/staging/unisys/include/visorbus.h +++ b/drivers/staging/unisys/include/visorbus.h @@ -167,22 +167,15 @@ void visorbus_enable_channel_interrupts(struct visor_device *dev); void visorbus_disable_channel_interrupts(struct visor_device *dev); #endif -/* Note that for visorchannel_create() and visorchannel_create_overlapped(), +/* Note that for visorchannel_create() * and arguments may be 0 if we are a channel CLIENT. * In this case, the values can simply be read from the channel header. */ struct visorchannel *visorchannel_create(HOSTADDRESS physaddr, ulong channel_bytes, uuid_le guid); -struct visorchannel *visorchannel_create_overlapped(ulong channel_bytes, - struct visorchannel *parent, - ulong off, uuid_le guid); struct visorchannel *visorchannel_create_with_lock(HOSTADDRESS physaddr, ulong channel_bytes, uuid_le guid); -struct visorchannel *visorchannel_create_overlapped_with_lock( - ulong channel_bytes, - struct visorchannel *parent, - ulong off, uuid_le guid); void visorchannel_destroy(struct visorchannel *channel); int visorchannel_read(struct visorchannel *channel, ulong offset, void *local, ulong nbytes); diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index d7ddc3af4638..407c2b646abb 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -120,26 +120,6 @@ visorchannel_create_with_lock(HOSTADDRESS physaddr, ulong channel_bytes, } EXPORT_SYMBOL_GPL(visorchannel_create_with_lock); -struct visorchannel * -visorchannel_create_overlapped(ulong channel_bytes, - struct visorchannel *parent, ulong off, - uuid_le guid) -{ - return visorchannel_create_guts(0, channel_bytes, parent, off, guid, - FALSE); -} -EXPORT_SYMBOL_GPL(visorchannel_create_overlapped); - -struct visorchannel * -visorchannel_create_overlapped_with_lock(ulong channel_bytes, - struct visorchannel *parent, ulong off, - uuid_le guid) -{ - return visorchannel_create_guts(0, channel_bytes, parent, off, guid, - TRUE); -} -EXPORT_SYMBOL_GPL(visorchannel_create_overlapped_with_lock); - void visorchannel_destroy(struct visorchannel *channel) { From 246cff65a09399af9ca6d782d7cd176a65b063f4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:21 -0400 Subject: [PATCH 0246/1163] staging: unisys: visorbus: visorchannel_create_guts() always has parent == NULL Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchannel.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index 407c2b646abb..faafa797ee78 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -52,8 +52,7 @@ struct visorchannel { */ static struct visorchannel * visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes, - struct visorchannel *parent, ulong off, uuid_le guid, - BOOL needs_lock) + ulong off, uuid_le guid, BOOL needs_lock) { struct visorchannel *channel; int err; @@ -70,11 +69,8 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes, spin_lock_init(&channel->remove_lock); /* prepare chan_hdr (abstraction to read/write channel memory) */ - if (!parent) - memregion = visor_memregion_create(physaddr, size); - else - memregion = visor_memregion_create_overlapped(parent->memregion, - off, size); + memregion = visor_memregion_create(physaddr, size); + if (!memregion) goto cleanup; channel->memregion = memregion; @@ -106,7 +102,7 @@ cleanup: struct visorchannel * visorchannel_create(HOSTADDRESS physaddr, ulong channel_bytes, uuid_le guid) { - return visorchannel_create_guts(physaddr, channel_bytes, NULL, 0, guid, + return visorchannel_create_guts(physaddr, channel_bytes, 0, guid, FALSE); } EXPORT_SYMBOL_GPL(visorchannel_create); @@ -115,7 +111,7 @@ struct visorchannel * visorchannel_create_with_lock(HOSTADDRESS physaddr, ulong channel_bytes, uuid_le guid) { - return visorchannel_create_guts(physaddr, channel_bytes, NULL, 0, guid, + return visorchannel_create_guts(physaddr, channel_bytes, 0, guid, TRUE); } EXPORT_SYMBOL_GPL(visorchannel_create_with_lock); From 670f56ca5f96b2a78cd964d10767ad0ab0a3e767 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:22 -0400 Subject: [PATCH 0247/1163] staging: unisys: memregion: Nothing uses overlap allocations, so nuke it Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorutil/memregion.h | 2 - .../unisys/visorutil/memregion_direct.c | 52 +++---------------- 2 files changed, 7 insertions(+), 47 deletions(-) diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h index 0c3eebcf6d50..1eb3a67eef16 100644 --- a/drivers/staging/unisys/visorutil/memregion.h +++ b/drivers/staging/unisys/visorutil/memregion.h @@ -26,8 +26,6 @@ struct memregion; struct memregion *visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes); -struct memregion *visor_memregion_create_overlapped(struct memregion *parent, - ulong offset, ulong nbytes); int visor_memregion_resize(struct memregion *memregion, ulong newsize); int visor_memregion_read(struct memregion *memregion, ulong offset, void *dest, ulong nbytes); diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index 6bb439d64511..93c10b46dc86 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -30,7 +30,6 @@ struct memregion { ulong nbytes; void __iomem *mapped; BOOL requested; - BOOL overlapped; }; static BOOL mapit(struct memregion *memregion); @@ -48,7 +47,6 @@ visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes) memregion->physaddr = physaddr; memregion->nbytes = nbytes; - memregion->overlapped = FALSE; if (!mapit(memregion)) { rc = NULL; goto cleanup; @@ -63,35 +61,6 @@ cleanup: } EXPORT_SYMBOL_GPL(visor_memregion_create); -struct memregion * -visor_memregion_create_overlapped(struct memregion *parent, ulong offset, - ulong nbytes) -{ - struct memregion *memregion = NULL; - - if (parent == NULL) - return NULL; - - if (parent->mapped == NULL) - return NULL; - - if ((offset >= parent->nbytes) || - ((offset + nbytes) >= parent->nbytes)) - return NULL; - - memregion = kzalloc(sizeof(*memregion), GFP_KERNEL|__GFP_NORETRY); - if (memregion == NULL) - return NULL; - - memregion->physaddr = parent->physaddr + offset; - memregion->nbytes = nbytes; - memregion->mapped = ((u8 __iomem *)(parent->mapped)) + offset; - memregion->requested = FALSE; - memregion->overlapped = TRUE; - return memregion; -} -EXPORT_SYMBOL_GPL(visor_memregion_create_overlapped); - static BOOL mapit(struct memregion *memregion) { @@ -147,17 +116,12 @@ visor_memregion_resize(struct memregion *memregion, ulong newsize) { if (newsize == memregion->nbytes) return 0; - if (memregion->overlapped) - /* no error check here - we no longer know the - * parent's range! - */ - memregion->nbytes = newsize; - else { - unmapit(memregion); - memregion->nbytes = newsize; - if (!mapit(memregion)) - return -EIO; - } + + unmapit(memregion); + memregion->nbytes = newsize; + if (!mapit(memregion)) + return -EIO; + return 0; } EXPORT_SYMBOL_GPL(visor_memregion_resize); @@ -199,9 +163,7 @@ visor_memregion_destroy(struct memregion *memregion) { if (!memregion) return; - if (!memregion->overlapped) - unmapit(memregion); + unmapit(memregion); kfree(memregion); } EXPORT_SYMBOL_GPL(visor_memregion_destroy); - From 1bd14f37048bd77e33fd2db8950f2d41b64052f9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:23 -0400 Subject: [PATCH 0248/1163] staging: unisys: memregion: Use proper errno for mapit() Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/visorutil/memregion_direct.c | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index 93c10b46dc86..7ba68bcef371 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -32,7 +32,7 @@ struct memregion { BOOL requested; }; -static BOOL mapit(struct memregion *memregion); +static int mapit(struct memregion *memregion); static void unmapit(struct memregion *memregion); struct memregion * @@ -47,7 +47,7 @@ visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes) memregion->physaddr = physaddr; memregion->nbytes = nbytes; - if (!mapit(memregion)) { + if (mapit(memregion)) { rc = NULL; goto cleanup; } @@ -61,19 +61,24 @@ cleanup: } EXPORT_SYMBOL_GPL(visor_memregion_create); -static BOOL +static int mapit(struct memregion *memregion) { ulong physaddr = (ulong)(memregion->physaddr); ulong nbytes = memregion->nbytes; memregion->requested = FALSE; - if (request_mem_region(physaddr, nbytes, MYDRVNAME)) - memregion->requested = TRUE; + if (!request_mem_region(physaddr, nbytes, MYDRVNAME)) + return -EBUSY; + + memregion->requested = TRUE; memregion->mapped = ioremap_cache(physaddr, nbytes); - if (!memregion->mapped) - return FALSE; - return TRUE; + if (!memregion->mapped) { + memregion->requested = TRUE; + return -EFAULT; + } + + return 0; } static void @@ -114,15 +119,16 @@ EXPORT_SYMBOL_GPL(visor_memregion_get_pointer); int visor_memregion_resize(struct memregion *memregion, ulong newsize) { + int rc; + if (newsize == memregion->nbytes) return 0; unmapit(memregion); memregion->nbytes = newsize; - if (!mapit(memregion)) - return -EIO; + rc = mapit(memregion); - return 0; + return rc; } EXPORT_SYMBOL_GPL(visor_memregion_resize); From 75d1e6613c3ae4728c0ff15e23ab4226e8dfbfcf Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:24 -0400 Subject: [PATCH 0249/1163] staging: unisys: memregion: Eliminate unnecessary 'requested' flag Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorutil/memregion_direct.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index 7ba68bcef371..0ee7cb2fafd0 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -29,7 +29,6 @@ struct memregion { HOSTADDRESS physaddr; ulong nbytes; void __iomem *mapped; - BOOL requested; }; static int mapit(struct memregion *memregion); @@ -67,16 +66,12 @@ mapit(struct memregion *memregion) ulong physaddr = (ulong)(memregion->physaddr); ulong nbytes = memregion->nbytes; - memregion->requested = FALSE; if (!request_mem_region(physaddr, nbytes, MYDRVNAME)) return -EBUSY; - memregion->requested = TRUE; memregion->mapped = ioremap_cache(physaddr, nbytes); - if (!memregion->mapped) { - memregion->requested = TRUE; + if (!memregion->mapped) return -EFAULT; - } return 0; } @@ -84,14 +79,11 @@ mapit(struct memregion *memregion) static void unmapit(struct memregion *memregion) { - if (memregion->mapped != NULL) { + if (memregion->mapped) { iounmap(memregion->mapped); memregion->mapped = NULL; - } - if (memregion->requested) { - release_mem_region((ulong)(memregion->physaddr), + release_mem_region((unsigned long)memregion->physaddr, memregion->nbytes); - memregion->requested = FALSE; } } From 712c03dcab8ee2ff82b280a517ba4f0adc9a54b5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:25 -0400 Subject: [PATCH 0250/1163] staging: unisys: visorchipset: parser_init_guts(): Localize memregion usage Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchipset.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 5bf8266f0663..2be8514d7b18 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -399,6 +399,7 @@ parser_init_guts(u64 addr, u32 bytes, bool local, struct parser_context *ctx = NULL; struct memregion *rgn = NULL; struct spar_controlvm_parameters_header *phdr = NULL; + int cnt; if (retry) *retry = false; @@ -442,7 +443,10 @@ parser_init_guts(u64 addr, u32 bytes, bool local, rc = NULL; goto cleanup; } - if (visor_memregion_read(rgn, 0, ctx->data, bytes) < 0) { + cnt = visor_memregion_read(rgn, 0, ctx->data, bytes); + visor_memregion_destroy(rgn); + + if (cnt < 0) { rc = NULL; goto cleanup; } @@ -469,10 +473,6 @@ parser_init_guts(u64 addr, u32 bytes, bool local, rc = ctx; cleanup: - if (rgn) { - visor_memregion_destroy(rgn); - rgn = NULL; - } if (rc) { controlvm_payload_bytes_buffered += ctx->param_bytes; } else { From dd412751129876dbeee811843fefe3b369e487ad Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:26 -0400 Subject: [PATCH 0251/1163] staging: unisys: visorchipset: Use ioremap direction rather than heavy visor_memregion Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorchipset.c | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 2be8514d7b18..9390ed6e90d2 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -397,9 +397,7 @@ parser_init_guts(u64 addr, u32 bytes, bool local, int allocbytes = sizeof(struct parser_context) + bytes; struct parser_context *rc = NULL; struct parser_context *ctx = NULL; - struct memregion *rgn = NULL; struct spar_controlvm_parameters_header *phdr = NULL; - int cnt; if (retry) *retry = false; @@ -438,18 +436,21 @@ parser_init_guts(u64 addr, u32 bytes, bool local, p = __va((unsigned long) (addr)); memcpy(ctx->data, p, bytes); } else { - rgn = visor_memregion_create(addr, bytes); - if (!rgn) { - rc = NULL; - goto cleanup; - } - cnt = visor_memregion_read(rgn, 0, ctx->data, bytes); - visor_memregion_destroy(rgn); + void __iomem *mapping; - if (cnt < 0) { + if (!request_mem_region(addr, bytes, "visorchipset")) { rc = NULL; goto cleanup; } + + mapping = ioremap_cache(addr, bytes); + if (!mapping) { + release_mem_region(addr, bytes); + rc = NULL; + goto cleanup; + } + memcpy_fromio(ctx->data, mapping, bytes); + release_mem_region(addr, bytes); } if (!standard_payload_header) { ctx->byte_stream = true; From ff7bd1fa9f97a336a92c94b912a416de49c90b9c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:27 -0400 Subject: [PATCH 0252/1163] staging: unisys: visorchipset.c: No need to include memregion.h anymore Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchipset.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 9390ed6e90d2..e0f8d7692037 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -15,7 +15,6 @@ * details. */ -#include "memregion.h" #include "controlvmchannel.h" #include "version.h" #include "procobjecttree.h" From 1dbdf10471cec85f8ea036d609097552eb0ac441 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:28 -0400 Subject: [PATCH 0253/1163] staging: unisys: visorchannel_clear(): Avoid 64KB memory leak Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchannel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index faafa797ee78..e555476be54d 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -236,7 +236,7 @@ visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch, written += thisbytes; nbytes -= thisbytes; } - return 0; + err = 0; cleanup: vfree(buf); From c37df5f0a0e31b1609fd931f8605f4b675d504d3 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:29 -0400 Subject: [PATCH 0254/1163] staging: unisys: visorchannel_clear(): No need to use vmalloc here Using a page is sufficient, and avoids the cost of vmalloc/vfree Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchannel.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index e555476be54d..1a1e7be6369c 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -214,17 +214,18 @@ visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch, ulong nbytes) { int err; - int bufsize = 65536; + int bufsize = PAGE_SIZE; int written = 0; u8 *buf; - buf = vmalloc(bufsize); + buf = (u8 *) __get_free_page(GFP_KERNEL); if (!buf) return -ENOMEM; memset(buf, ch, bufsize); + while (nbytes > 0) { - ulong thisbytes = bufsize; + int thisbytes = bufsize; if (nbytes < thisbytes) thisbytes = nbytes; @@ -239,7 +240,7 @@ visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch, err = 0; cleanup: - vfree(buf); + free_page((unsigned long) buf); return err; } EXPORT_SYMBOL_GPL(visorchannel_clear); From 213e6a61328689f9106758487a2fefb69d074c6f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:30 -0400 Subject: [PATCH 0255/1163] staging: unisys: decouple visor_memregion_{read, write}() Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/visorutil/memregion_direct.c | 28 +++++++------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index 0ee7cb2fafd0..96460d7fdf0a 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -124,27 +124,15 @@ visor_memregion_resize(struct memregion *memregion, ulong newsize) } EXPORT_SYMBOL_GPL(visor_memregion_resize); -static int -memregion_readwrite(BOOL is_write, - struct memregion *memregion, ulong offset, - void *local, ulong nbytes) -{ - if (offset + nbytes > memregion->nbytes) - return -EIO; - - if (is_write) - memcpy_toio(memregion->mapped + offset, local, nbytes); - else - memcpy_fromio(local, memregion->mapped + offset, nbytes); - - return 0; -} - int visor_memregion_read(struct memregion *memregion, ulong offset, void *dest, ulong nbytes) { - return memregion_readwrite(FALSE, memregion, offset, dest, nbytes); + if (offset + nbytes > memregion->nbytes) + return -EIO; + + memcpy_fromio(dest, memregion->mapped + offset, nbytes); + return 0; } EXPORT_SYMBOL_GPL(visor_memregion_read); @@ -152,7 +140,11 @@ int visor_memregion_write(struct memregion *memregion, ulong offset, void *src, ulong nbytes) { - return memregion_readwrite(TRUE, memregion, offset, src, nbytes); + if (offset + nbytes > memregion->nbytes) + return -EIO; + + memcpy_toio(memregion->mapped + offset, src, nbytes); + return 0; } EXPORT_SYMBOL_GPL(visor_memregion_write); From 81c7492db05ec452599907ce69e42071e0c5ec03 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:31 -0400 Subject: [PATCH 0256/1163] staging: unisys: memregion: move struct memregion to memregion.h Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorutil/memregion.h | 6 +++++- drivers/staging/unisys/visorutil/memregion_direct.c | 6 ------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h index 1eb3a67eef16..8f006fca73b2 100644 --- a/drivers/staging/unisys/visorutil/memregion.h +++ b/drivers/staging/unisys/visorutil/memregion.h @@ -23,7 +23,11 @@ /* struct memregion is an opaque structure to users. * Fields are declared only in the implementation .c files. */ -struct memregion; +struct memregion { + HOSTADDRESS physaddr; + ulong nbytes; + void __iomem *mapped; +}; struct memregion *visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes); int visor_memregion_resize(struct memregion *memregion, ulong newsize); diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index 96460d7fdf0a..4ad25df767cd 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -25,12 +25,6 @@ #define MYDRVNAME "memregion" -struct memregion { - HOSTADDRESS physaddr; - ulong nbytes; - void __iomem *mapped; -}; - static int mapit(struct memregion *memregion); static void unmapit(struct memregion *memregion); From b3cbceb36bd413ce11ba2132418b3b35a085a1c5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:32 -0400 Subject: [PATCH 0257/1163] staging: unisys: memregion: Embed memregion in struct channel This changes the API for visor_memregion_create() to require a pre-allocated struct memregion. Embedding this in struct channel avoids a layer of additional kmalloc()'s and error checks. Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorchannel.c | 36 +++++++++---------- drivers/staging/unisys/visorutil/memregion.h | 3 +- .../unisys/visorutil/memregion_direct.c | 9 ++--- 3 files changed, 20 insertions(+), 28 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index 1a1e7be6369c..d2e4fe051ed1 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -30,7 +30,7 @@ #define MYDRVNAME "visorchannel" struct visorchannel { - struct memregion *memregion; /* from visor_memregion_create() */ + struct memregion memregion; /* from visor_memregion_create() */ struct channel_header chan_hdr; uuid_le guid; ulong size; @@ -63,19 +63,17 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes, if (!channel) goto cleanup; - channel->memregion = NULL; channel->needs_lock = needs_lock; spin_lock_init(&channel->insert_lock); spin_lock_init(&channel->remove_lock); /* prepare chan_hdr (abstraction to read/write channel memory) */ - memregion = visor_memregion_create(physaddr, size); + memregion = visor_memregion_create(&channel->memregion, physaddr, size); if (!memregion) goto cleanup; - channel->memregion = memregion; - err = visor_memregion_read(channel->memregion, 0, &channel->chan_hdr, + err = visor_memregion_read(&channel->memregion, 0, &channel->chan_hdr, sizeof(struct channel_header)); if (err) goto cleanup; @@ -86,7 +84,7 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes, if (uuid_le_cmp(guid, NULL_UUID_LE) == 0) guid = channel->chan_hdr.chtype; - err = visor_memregion_resize(channel->memregion, channel_bytes); + err = visor_memregion_resize(&channel->memregion, channel_bytes); if (err) goto cleanup; @@ -121,7 +119,7 @@ visorchannel_destroy(struct visorchannel *channel) { if (!channel) return; - visor_memregion_destroy(channel->memregion); + visor_memregion_destroy(&channel->memregion); kfree(channel); } EXPORT_SYMBOL_GPL(visorchannel_destroy); @@ -129,7 +127,7 @@ EXPORT_SYMBOL_GPL(visorchannel_destroy); HOSTADDRESS visorchannel_get_physaddr(struct visorchannel *channel) { - return visor_memregion_get_physaddr(channel->memregion); + return visor_memregion_get_physaddr(&channel->memregion); } EXPORT_SYMBOL_GPL(visorchannel_get_physaddr); @@ -179,7 +177,7 @@ EXPORT_SYMBOL_GPL(visorchannel_get_uuid); struct memregion * visorchannel_get_memregion(struct visorchannel *channel) { - return channel->memregion; + return &channel->memregion; } EXPORT_SYMBOL_GPL(visorchannel_get_memregion); @@ -190,7 +188,7 @@ visorchannel_read(struct visorchannel *channel, ulong offset, int rc; size_t size = sizeof(struct channel_header); - rc = visor_memregion_read(channel->memregion, offset, local, nbytes); + rc = visor_memregion_read(&channel->memregion, offset, local, nbytes); if (rc && !offset && (nbytes >= size)) memcpy(&channel->chan_hdr, local, size); return rc; @@ -205,7 +203,8 @@ visorchannel_write(struct visorchannel *channel, ulong offset, if (!offset && nbytes >= size) memcpy(&channel->chan_hdr, local, size); - return visor_memregion_write(channel->memregion, offset, local, nbytes); + return visor_memregion_write(&channel->memregion, + offset, local, nbytes); } EXPORT_SYMBOL_GPL(visorchannel_write); @@ -229,7 +228,7 @@ visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch, if (nbytes < thisbytes) thisbytes = nbytes; - err = visor_memregion_write(channel->memregion, + err = visor_memregion_write(&channel->memregion, offset + written, buf, thisbytes); if (err) goto cleanup; @@ -270,7 +269,7 @@ EXPORT_SYMBOL_GPL(visorchannel_get_header); * into host memory */ #define SIG_WRITE_FIELD(channel, queue, sig_hdr, FIELD) \ - (visor_memregion_write(channel->memregion, \ + (visor_memregion_write(&channel->memregion, \ SIG_QUEUE_OFFSET(&channel->chan_hdr, queue)+ \ offsetof(struct signal_queue_header, FIELD),\ &((sig_hdr)->FIELD), \ @@ -286,7 +285,7 @@ sig_read_header(struct visorchannel *channel, u32 queue, return FALSE; /* Read the appropriate SIGNAL_QUEUE_HEADER into local memory. */ - err = visor_memregion_read(channel->memregion, + err = visor_memregion_read(&channel->memregion, SIG_QUEUE_OFFSET(&channel->chan_hdr, queue), sig_hdr, sizeof(struct signal_queue_header)); if (err) @@ -303,7 +302,7 @@ sig_read_data(struct visorchannel *channel, u32 queue, int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue, sig_hdr, slot); - err = visor_memregion_read(channel->memregion, + err = visor_memregion_read(&channel->memregion, signal_data_offset, data, sig_hdr->signal_size); if (err) @@ -320,7 +319,7 @@ sig_write_data(struct visorchannel *channel, u32 queue, int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue, sig_hdr, slot); - err = visor_memregion_write(channel->memregion, + err = visor_memregion_write(&channel->memregion, signal_data_offset, data, sig_hdr->signal_size); if (err) @@ -383,7 +382,7 @@ signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg) sig_hdr.head = ((sig_hdr.head + 1) % sig_hdr.max_slots); if (sig_hdr.head == sig_hdr.tail) { sig_hdr.num_overflows++; - visor_memregion_write(channel->memregion, + visor_memregion_write(&channel->memregion, SIG_QUEUE_OFFSET(&channel->chan_hdr, queue) + offsetof(struct signal_queue_header, @@ -495,9 +494,6 @@ visorchannel_debug(struct visorchannel *channel, int num_queues, if (!channel) return; - memregion = channel->memregion; - if (!memregion) - return; addr = visor_memregion_get_physaddr(memregion); nbytes_region = visor_memregion_get_nbytes(memregion); diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h index 8f006fca73b2..3826fe6c2446 100644 --- a/drivers/staging/unisys/visorutil/memregion.h +++ b/drivers/staging/unisys/visorutil/memregion.h @@ -29,7 +29,8 @@ struct memregion { void __iomem *mapped; }; -struct memregion *visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes); +struct memregion *visor_memregion_create(struct memregion *memregion, + HOSTADDRESS physaddr, ulong nbytes); int visor_memregion_resize(struct memregion *memregion, ulong newsize); int visor_memregion_read(struct memregion *memregion, ulong offset, void *dest, ulong nbytes); diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index 4ad25df767cd..a575ecc5c3d7 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -29,14 +29,10 @@ static int mapit(struct memregion *memregion); static void unmapit(struct memregion *memregion); struct memregion * -visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes) +visor_memregion_create(struct memregion *memregion, + HOSTADDRESS physaddr, ulong nbytes) { struct memregion *rc = NULL; - struct memregion *memregion; - - memregion = kzalloc(sizeof(*memregion), GFP_KERNEL | __GFP_NORETRY); - if (memregion == NULL) - return NULL; memregion->physaddr = physaddr; memregion->nbytes = nbytes; @@ -148,6 +144,5 @@ visor_memregion_destroy(struct memregion *memregion) if (!memregion) return; unmapit(memregion); - kfree(memregion); } EXPORT_SYMBOL_GPL(visor_memregion_destroy); From 5f0dc9b1f71af2ed5ad3c248139720d56403325c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:33 -0400 Subject: [PATCH 0258/1163] staging: unisys: visorchannel_get_memregion() isn't used Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/visorbus.h | 1 - drivers/staging/unisys/visorbus/visorchannel.c | 7 ------- 2 files changed, 8 deletions(-) diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h index 21fd78583ba9..749beac488e6 100644 --- a/drivers/staging/unisys/include/visorbus.h +++ b/drivers/staging/unisys/include/visorbus.h @@ -196,7 +196,6 @@ char *visorchannel_id(struct visorchannel *channel, char *s); char *visorchannel_zoneid(struct visorchannel *channel, char *s); u64 visorchannel_get_clientpartition(struct visorchannel *channel); uuid_le visorchannel_get_uuid(struct visorchannel *channel); -struct memregion *visorchannel_get_memregion(struct visorchannel *channel); char *visorchannel_uuid_id(uuid_le *guid, char *s); void visorchannel_debug(struct visorchannel *channel, int num_queues, struct seq_file *seq, u32 off); diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index d2e4fe051ed1..5e4a591ff723 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -174,13 +174,6 @@ visorchannel_get_uuid(struct visorchannel *channel) } EXPORT_SYMBOL_GPL(visorchannel_get_uuid); -struct memregion * -visorchannel_get_memregion(struct visorchannel *channel) -{ - return &channel->memregion; -} -EXPORT_SYMBOL_GPL(visorchannel_get_memregion); - int visorchannel_read(struct visorchannel *channel, ulong offset, void *local, ulong nbytes) From 8b8fc28b6b0dc028cc62bcd8bdaba48661317e57 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:34 -0400 Subject: [PATCH 0259/1163] staging: unisys: Eliminate unused visorchannel_dump_section() Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/visorbus.h | 2 - .../staging/unisys/visorbus/visorchannel.c | 37 ------------------- 2 files changed, 39 deletions(-) diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h index 749beac488e6..e1c666234b1f 100644 --- a/drivers/staging/unisys/include/visorbus.h +++ b/drivers/staging/unisys/include/visorbus.h @@ -199,8 +199,6 @@ uuid_le visorchannel_get_uuid(struct visorchannel *channel); char *visorchannel_uuid_id(uuid_le *guid, char *s); void visorchannel_debug(struct visorchannel *channel, int num_queues, struct seq_file *seq, u32 off); -void visorchannel_dump_section(struct visorchannel *chan, char *s, - int off, int len, struct seq_file *seq); void __iomem *visorchannel_get_header(struct visorchannel *channel); #endif diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index 5e4a591ff723..150e3df89001 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -548,40 +548,3 @@ visorchannel_debug(struct visorchannel *channel, int num_queues, addr + off, nbytes); } EXPORT_SYMBOL_GPL(visorchannel_debug); - -void -visorchannel_dump_section(struct visorchannel *chan, char *s, - int off, int len, struct seq_file *seq) -{ - char *buf, *tbuf, *fmtbuf; - int fmtbufsize = 0; - int i; - int errcode = 0; - - fmtbufsize = 100 * COVQ(len, 16); - buf = kmalloc(len, GFP_KERNEL|__GFP_NORETRY); - if (!buf) - return; - fmtbuf = kmalloc(fmtbufsize, GFP_KERNEL|__GFP_NORETRY); - if (!fmtbuf) - goto fmt_failed; - - errcode = visorchannel_read(chan, off, buf, len); - if (errcode < 0) - goto read_failed; - seq_printf(seq, "channel %s:\n", s); - tbuf = buf; - while (len > 0) { - i = (len < 16) ? len : 16; - hex_dump_to_buffer(tbuf, i, 16, 1, fmtbuf, fmtbufsize, TRUE); - seq_printf(seq, "%s\n", fmtbuf); - tbuf += 16; - len -= 16; - } - -read_failed: - kfree(fmtbuf); -fmt_failed: - kfree(buf); -} -EXPORT_SYMBOL_GPL(visorchannel_dump_section); From 780fcad38a2b9061337bb59c1e6b8b76eccda825 Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Tue, 5 May 2015 18:36:35 -0400 Subject: [PATCH 0260/1163] staging: unisys: remove typedef GUEST_PHYSICAL_ADDRESS to u64 This patch removes typedef GUEST_PHYSICAL_ADDRESS to u64 Signed-off-by: Erik Arfvidson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../include/channels/controlvmchannel.h | 38 +++++++++---------- .../staging/unisys/visorbus/visorchipset.c | 2 +- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index a66db7968d6c..435ac92df237 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -20,8 +20,6 @@ #include "channel.h" #include "controlframework.h" -typedef u64 GUEST_PHYSICAL_ADDRESS; - enum { INVALID_GUEST_FIRMWARE, SAMPLE_GUEST_FIRMWARE, TIANO32_GUEST_FIRMWARE, TIANO64_GUEST_FIRMWARE }; @@ -343,7 +341,7 @@ struct controlvm_message { }; struct device_map { - GUEST_PHYSICAL_ADDRESS device_channel_address; + u64 device_channel_address; u64 device_channel_size; u32 ca_index; u32 reserved; /* natural alignment */ @@ -362,23 +360,23 @@ struct guest_devices { struct spar_controlvm_channel_protocol { struct channel_header header; - GUEST_PHYSICAL_ADDRESS gp_controlvm; /* guest physical address of + u64 gp_controlvm; /* guest physical address of * this channel */ - GUEST_PHYSICAL_ADDRESS gp_partition_tables;/* guest physical address of + u64 gp_partition_tables;/* guest physical address of * partition tables */ - GUEST_PHYSICAL_ADDRESS gp_diag_guest; /* guest physical address of + u64 gp_diag_guest; /* guest physical address of * diagnostic channel */ - GUEST_PHYSICAL_ADDRESS gp_boot_romdisk;/* guest phys addr of (read + u64 gp_boot_romdisk;/* guest phys addr of (read * only) Boot ROM disk */ - GUEST_PHYSICAL_ADDRESS gp_boot_ramdisk;/* guest phys addr of writable + u64 gp_boot_ramdisk;/* guest phys addr of writable * Boot RAM disk */ - GUEST_PHYSICAL_ADDRESS gp_acpi_table; /* guest phys addr of acpi + u64 gp_acpi_table; /* guest phys addr of acpi * table */ - GUEST_PHYSICAL_ADDRESS gp_control_channel;/* guest phys addr of control + u64 gp_control_channel;/* guest phys addr of control * channel */ - GUEST_PHYSICAL_ADDRESS gp_diag_romdisk;/* guest phys addr of diagnostic + u64 gp_diag_romdisk;/* guest phys addr of diagnostic * ROM disk */ - GUEST_PHYSICAL_ADDRESS gp_nvram; /* guest phys addr of NVRAM + u64 gp_nvram; /* guest phys addr of NVRAM * channel */ u64 request_payload_offset; /* Offset to request payload area */ u64 event_payload_offset; /* Offset to event payload area */ @@ -389,28 +387,28 @@ struct spar_controlvm_channel_protocol { u32 nvram_channel_bytes; /* Bytes in PartitionNvram segment */ u32 message_bytes; /* sizeof(CONTROLVM_MESSAGE) */ u32 message_count; /* CONTROLVM_MESSAGE_MAX */ - GUEST_PHYSICAL_ADDRESS gp_smbios_table;/* guest phys addr of SMBIOS + u64 gp_smbios_table;/* guest phys addr of SMBIOS * tables */ - GUEST_PHYSICAL_ADDRESS gp_physical_smbios_table;/* guest phys addr of + u64 gp_physical_smbios_table;/* guest phys addr of * SMBIOS table */ /* ULTRA_MAX_GUESTS_PER_SERVICE */ struct guest_devices gp_obsolete_guest_devices[16]; /* guest physical address of EFI firmware image base */ - GUEST_PHYSICAL_ADDRESS virtual_guest_firmware_image_base; + u64 virtual_guest_firmware_image_base; /* guest physical address of EFI firmware entry point */ - GUEST_PHYSICAL_ADDRESS virtual_guest_firmware_entry_point; + u64 virtual_guest_firmware_entry_point; /* guest EFI firmware image size */ u64 virtual_guest_firmware_image_size; /* GPA = 1MB where EFI firmware image is copied to */ - GUEST_PHYSICAL_ADDRESS virtual_guest_firmware_boot_base; - GUEST_PHYSICAL_ADDRESS virtual_guest_image_base; - GUEST_PHYSICAL_ADDRESS virtual_guest_image_size; + u64 virtual_guest_firmware_boot_base; + u64 virtual_guest_image_base; + u64 virtual_guest_image_size; u64 prototype_control_channel_offset; - GUEST_PHYSICAL_ADDRESS virtual_guest_partition_handle; + u64 virtual_guest_partition_handle; u16 restore_action; /* Restore Action field to restore the guest * partition */ diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index e0f8d7692037..107012f3d1ae 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -2631,7 +2631,7 @@ visorchipset_mmap(struct file *file, struct vm_area_struct *vma) { unsigned long physaddr = 0; unsigned long offset = vma->vm_pgoff << PAGE_SHIFT; - GUEST_PHYSICAL_ADDRESS addr = 0; + u64 addr = 0; /* sv_enable_dfp(); */ if (offset & (PAGE_SIZE - 1)) From e90118649019789ffe88461aba498b47e208f16e Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Tue, 5 May 2015 18:36:36 -0400 Subject: [PATCH 0261/1163] staging: unisys: remove unused enum from controlvmchannel.h This patch removes this enum since it is unused Signed-off-by: Erik Arfvidson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/controlvmchannel.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 435ac92df237..4e6dec280132 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -20,10 +20,6 @@ #include "channel.h" #include "controlframework.h" -enum { INVALID_GUEST_FIRMWARE, SAMPLE_GUEST_FIRMWARE, - TIANO32_GUEST_FIRMWARE, TIANO64_GUEST_FIRMWARE -}; - /* {2B3C2D10-7EF5-4ad8-B966-3448B7386B3D} */ #define SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID \ UUID_LE(0x2b3c2d10, 0x7ef5, 0x4ad8, \ From 35314db1869f77c2a459d72d6f4797d8068697c7 Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Tue, 5 May 2015 18:36:37 -0400 Subject: [PATCH 0262/1163] staging: unisys: remove unused #define in controlvmchannel This patch remove unused controlvmchannel.h #defines Signed-off-by: Erik Arfvidson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/controlvmchannel.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 4e6dec280132..ff15c45cf4da 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -47,13 +47,8 @@ static const uuid_le spar_controlvm_channel_protocol_uuid = ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE) -#define MY_DEVICE_INDEX 0 -#define MAX_MACDATA_LEN 8 /* number of bytes for MAC address in config packet */ #define MAX_SERIAL_NUM 32 -#define DISK_ZERO_PUN_NUMBER 1 /* Target ID on the SCSI bus for LUN 0 */ -#define DISK_ZERO_LUN_NUMBER 3 /* Logical Unit Number */ - /* Defines for various channel queues... */ #define CONTROLVM_QUEUE_REQUEST 0 #define CONTROLVM_QUEUE_RESPONSE 1 From 1452f37015dbb856572af16d37f23a552e95d494 Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Tue, 5 May 2015 18:36:38 -0400 Subject: [PATCH 0263/1163] staging: unisys: remove unused #define MAX_SERIAL_NUM This patch simply removes #define MAX_SERIAL_NUM from iochannel.h Signed-off-by: Erik Arfvidson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/common-spar/include/channels/iochannel.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 3bd7579e1daf..ff393c2c2350 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -140,10 +140,6 @@ * MAX_SKB_FRAGS size, which is 18 which is smaller than MAX_PHYS_INFO for * now. */ -#ifndef MAX_SERIAL_NUM -#define MAX_SERIAL_NUM 32 -#endif /* MAX_SERIAL_NUM */ - #define MAX_SCSI_BUSES 1 #define MAX_SCSI_TARGETS 8 #define MAX_SCSI_LUNS 16 From 4da3336c25850490a0ce478cc7621347e7e3f717 Mon Sep 17 00:00:00 2001 From: David Kershner Date: Tue, 5 May 2015 18:36:39 -0400 Subject: [PATCH 0264/1163] staging: unisys: remove server crust from visorchipset. The visorchipset driver originally serviced both servers and clients. This implementation is client only so remove some more server side implementation. Signed-off-by: David Kershner Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorbus_main.c | 8 +- .../unisys/visorbus/visorbus_private.h | 9 +- .../staging/unisys/visorbus/visorchipset.c | 226 ++++-------------- 3 files changed, 61 insertions(+), 182 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 6c939ce503a1..3fcd5fb2cb24 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -2066,9 +2066,9 @@ visorbus_init(void) /* This enables us to receive notifications when devices appear for * which this service partition is to be a server for. */ - visorchipset_register_busdev_server(&chipset_notifiers, - &chipset_responders, - &chipset_driverinfo); + visorchipset_register_busdev(&chipset_notifiers, + &chipset_responders, + &chipset_driverinfo); rc = 0; @@ -2084,7 +2084,7 @@ visorbus_exit(void) { struct list_head *listentry, *listtmp; - visorchipset_register_busdev_server(NULL, NULL, NULL); + visorchipset_register_busdev(NULL, NULL, NULL); remove_all_visor_devices(); flush_workqueue(periodic_dev_workqueue); /* better not be any work! */ diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h index a3d78f619d64..f9a5e015e21d 100644 --- a/drivers/staging/unisys/visorbus/visorbus_private.h +++ b/drivers/staging/unisys/visorbus/visorbus_private.h @@ -138,13 +138,12 @@ struct visorchipset_busdev_responders { }; /** Register functions (in the bus driver) to get called by visorchipset - * whenever a bus or device appears for which this service partition is - * to be the client for. visorchipset will fill in , to - * indicate functions the bus driver should call to indicate message - * responses. + * whenever a bus or device appears for which this guest is to be the + * client for. visorchipset will fill in , to indicate + * functions the bus driver should call to indicate message responses. */ void -visorchipset_register_busdev_server( +visorchipset_register_busdev( struct visorchipset_busdev_notifiers *notifiers, struct visorchipset_busdev_responders *responders, struct ultra_vbus_deviceinfo *driver_info); diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 107012f3d1ae..3a1ee2d21a9f 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -25,7 +25,6 @@ #include "guestlinuxdebug.h" #include "visorbus_private.h" - #include #include #include @@ -36,10 +35,6 @@ #include #define CURRENT_FILE_PC VISOR_CHIPSET_PC_visorchipset_main_c -#define TEST_VNIC_PHYSITF "eth0" /* physical network itf for - * vnic loopback test */ -#define TEST_VNIC_SWITCHNO 1 -#define TEST_VNIC_BUSNO 9 #define MAX_NAME_SIZE 128 #define MAX_IP_SIZE 50 @@ -54,14 +49,8 @@ /* * Module parameters */ -static int visorchipset_testvnic; -static int visorchipset_testvnicclient; -static int visorchipset_testmsg; static int visorchipset_major; -static int visorchipset_serverregwait; -static int visorchipset_clientregwait = 1; /* default is on */ -static int visorchipset_testteardown; -static int visorchipset_disable_controlvm; +static int visorchipset_visorbusregwait = 1; /* default is on */ static int visorchipset_holdchipsetready; static unsigned long controlvm_payload_bytes_buffered; @@ -90,8 +79,7 @@ visorchipset_release(struct inode *inode, struct file *file) static unsigned long poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; static unsigned long most_recent_message_jiffies; /* when we got our last * controlvm message */ -static int serverregistered; -static int clientregistered; +static int visorbusregistered; #define MAX_CHIPSET_EVENTS 2 static u8 chipset_events[MAX_CHIPSET_EVENTS] = { 0, 0 }; @@ -119,16 +107,6 @@ static u32 g_diagpool_bus_no = 0xffffff; static u32 g_diagpool_dev_no = 0xffffff; static struct controlvm_message_packet g_devicechangestate_packet; -/* Only VNIC and VHBA channels are sent to visorclientbus (aka - * "visorhackbus") - */ -#define FOR_VISORHACKBUS(channel_type_guid) \ - (((uuid_le_cmp(channel_type_guid,\ - spar_vnic_channel_protocol_uuid) == 0) ||\ - (uuid_le_cmp(channel_type_guid,\ - spar_vhba_channel_protocol_uuid) == 0))) -#define FOR_VISORBUS(channel_type_guid) (!(FOR_VISORHACKBUS(channel_type_guid))) - #define is_diagpool_channel(channel_type_guid) \ (uuid_le_cmp(channel_type_guid,\ spar_diag_pool_channel_protocol_uuid) == 0) @@ -254,8 +232,7 @@ static void parahotplug_process_list(void); /* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE / * CONTROLVM_REPORTEVENT. */ -static struct visorchipset_busdev_notifiers busdev_server_notifiers; -static struct visorchipset_busdev_notifiers busdev_client_notifiers; +static struct visorchipset_busdev_notifiers busdev_notifiers; static void bus_create_response(u32 bus_no, int response); static void bus_destroy_response(u32 bus_no, int response); @@ -1028,19 +1005,19 @@ clear_chipset_events(void) } void -visorchipset_register_busdev_server( +visorchipset_register_busdev( struct visorchipset_busdev_notifiers *notifiers, struct visorchipset_busdev_responders *responders, struct ultra_vbus_deviceinfo *driver_info) { down(¬ifier_lock); if (!notifiers) { - memset(&busdev_server_notifiers, 0, - sizeof(busdev_server_notifiers)); - serverregistered = 0; /* clear flag */ + memset(&busdev_notifiers, 0, + sizeof(busdev_notifiers)); + visorbusregistered = 0; /* clear flag */ } else { - busdev_server_notifiers = *notifiers; - serverregistered = 1; /* set flag */ + busdev_notifiers = *notifiers; + visorbusregistered = 1; /* set flag */ } if (responders) *responders = busdev_responders; @@ -1050,37 +1027,7 @@ visorchipset_register_busdev_server( up(¬ifier_lock); } -EXPORT_SYMBOL_GPL(visorchipset_register_busdev_server); - -/** Register functions (in the bus driver) to get called by visorchipset - * whenever a bus or device appears for which this service partition is - * to be the server for. visorchipset will fill in , to - * indicate functions the bus driver should call to indicate message - * responses. - */ -void -visorchipset_register_busdev_client( - struct visorchipset_busdev_notifiers *notifiers, - struct visorchipset_busdev_responders *responders, - struct ultra_vbus_deviceinfo *driver_info) -{ - down(¬ifier_lock); - if (!notifiers) { - memset(&busdev_client_notifiers, 0, - sizeof(busdev_client_notifiers)); - clientregistered = 0; /* clear flag */ - } else { - busdev_client_notifiers = *notifiers; - clientregistered = 1; /* set flag */ - } - if (responders) - *responders = busdev_responders; - if (driver_info) - bus_device_info_init(driver_info, "chipset(bolts)", - "visorchipset", VERSION, NULL); - up(¬ifier_lock); -} -EXPORT_SYMBOL_GPL(visorchipset_register_busdev_client); +EXPORT_SYMBOL_GPL(visorchipset_register_busdev); static void cleanup_controlvm_structures(void) @@ -1377,34 +1324,14 @@ bus_epilog(u32 bus_no, if (response == CONTROLVM_RESP_SUCCESS) { switch (cmd) { case CONTROLVM_BUS_CREATE: - /* We can't tell from the bus_create - * information which of our 2 bus flavors the - * devices on this bus will ultimately end up. - * FORTUNATELY, it turns out it is harmless to - * send the bus_create to both of them. We can - * narrow things down a little bit, though, - * because we know: - BusDev_Server can handle - * either server or client devices - * - BusDev_Client can handle ONLY client - * devices */ - if (busdev_server_notifiers.bus_create) { - (*busdev_server_notifiers.bus_create) (bus_no); - notified = true; - } - if ((!bus_info->flags.server) /*client */ && - busdev_client_notifiers.bus_create) { - (*busdev_client_notifiers.bus_create) (bus_no); + if (busdev_notifiers.bus_create) { + (*busdev_notifiers.bus_create) (bus_no); notified = true; } break; case CONTROLVM_BUS_DESTROY: - if (busdev_server_notifiers.bus_destroy) { - (*busdev_server_notifiers.bus_destroy) (bus_no); - notified = true; - } - if ((!bus_info->flags.server) /*client */ && - busdev_client_notifiers.bus_destroy) { - (*busdev_client_notifiers.bus_destroy) (bus_no); + if (busdev_notifiers.bus_destroy) { + (*busdev_notifiers.bus_destroy) (bus_no); notified = true; } break; @@ -1439,10 +1366,8 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd, if (!dev_info) return; - if (for_visorbus) - notifiers = &busdev_server_notifiers; - else - notifiers = &busdev_client_notifiers; + notifiers = &busdev_notifiers; + if (need_response) { memcpy(&dev_info->pending_msg_hdr, msg_hdr, sizeof(struct controlvm_message_header)); @@ -1692,8 +1617,7 @@ cleanup: } device_epilog(bus_no, dev_no, segment_state_running, CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc, - inmsg->hdr.flags.response_expected == 1, - FOR_VISORBUS(dev_info->chan_info.channel_type_uuid)); + inmsg->hdr.flags.response_expected == 1, 1); } static void @@ -1719,9 +1643,7 @@ my_device_changestate(struct controlvm_message *inmsg) if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info) device_epilog(bus_no, dev_no, state, CONTROLVM_DEVICE_CHANGESTATE, &inmsg->hdr, rc, - inmsg->hdr.flags.response_expected == 1, - FOR_VISORBUS( - dev_info->chan_info.channel_type_uuid)); + inmsg->hdr.flags.response_expected == 1, 1); } static void @@ -1742,9 +1664,7 @@ my_device_destroy(struct controlvm_message *inmsg) if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info) device_epilog(bus_no, dev_no, segment_state_running, CONTROLVM_DEVICE_DESTROY, &inmsg->hdr, rc, - inmsg->hdr.flags.response_expected == 1, - FOR_VISORBUS( - dev_info->chan_info.channel_type_uuid)); + inmsg->hdr.flags.response_expected == 1, 1); } /* When provided with the physical address of the controlvm channel @@ -2251,12 +2171,7 @@ controlvm_periodic_work(struct work_struct *work) static u64 poll_count; /* make sure visorbus server is registered for controlvm callbacks */ - if (visorchipset_serverregwait && !serverregistered) - goto cleanup; - /* make sure visorclientbus server is regsitered for controlvm - * callbacks - */ - if (visorchipset_clientregwait && !clientregistered) + if (visorchipset_visorbusregwait && !visorbusregistered) goto cleanup; poll_count++; @@ -2347,14 +2262,8 @@ setup_crash_devices_work_queue(struct work_struct *work) u32 local_crash_msg_offset; u16 local_crash_msg_count; - /* make sure visorbus server is registered for controlvm callbacks */ - if (visorchipset_serverregwait && !serverregistered) - goto cleanup; - - /* make sure visorclientbus server is regsitered for controlvm - * callbacks - */ - if (visorchipset_clientregwait && !clientregistered) + /* make sure visorbus is registered for controlvm callbacks */ + if (visorchipset_visorbusregwait && !visorbusregistered) goto cleanup; POSTCODE_LINUX_2(CRASH_DEV_ENTRY_PC, POSTCODE_SEVERITY_INFO); @@ -2739,18 +2648,11 @@ visorchipset_init(void) if (!unisys_spar_platform) return -ENODEV; - memset(&busdev_server_notifiers, 0, sizeof(busdev_server_notifiers)); - memset(&busdev_client_notifiers, 0, sizeof(busdev_client_notifiers)); + memset(&busdev_notifiers, 0, sizeof(busdev_notifiers)); memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info)); memset(&livedump_info, 0, sizeof(livedump_info)); atomic_set(&livedump_info.buffers_in_use, 0); - if (visorchipset_testvnic) { - POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, x, DIAG_SEVERITY_ERR); - rc = x; - goto cleanup; - } - addr = controlvm_get_channel_address(); if (addr) { controlvm_channel = @@ -2779,32 +2681,30 @@ visorchipset_init(void) memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header)); - if (!visorchipset_disable_controlvm) { - /* if booting in a crash kernel */ - if (is_kdump_kernel()) - INIT_DELAYED_WORK(&periodic_controlvm_work, - setup_crash_devices_work_queue); - else - INIT_DELAYED_WORK(&periodic_controlvm_work, - controlvm_periodic_work); - periodic_controlvm_workqueue = - create_singlethread_workqueue("visorchipset_controlvm"); + /* if booting in a crash kernel */ + if (is_kdump_kernel()) + INIT_DELAYED_WORK(&periodic_controlvm_work, + setup_crash_devices_work_queue); + else + INIT_DELAYED_WORK(&periodic_controlvm_work, + controlvm_periodic_work); + periodic_controlvm_workqueue = + create_singlethread_workqueue("visorchipset_controlvm"); - if (!periodic_controlvm_workqueue) { - POSTCODE_LINUX_2(CREATE_WORKQUEUE_FAILED_PC, - DIAG_SEVERITY_ERR); - rc = -ENOMEM; - goto cleanup; - } - most_recent_message_jiffies = jiffies; - poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; - rc = queue_delayed_work(periodic_controlvm_workqueue, - &periodic_controlvm_work, poll_jiffies); - if (rc < 0) { - POSTCODE_LINUX_2(QUEUE_DELAYED_WORK_PC, - DIAG_SEVERITY_ERR); - goto cleanup; - } + if (!periodic_controlvm_workqueue) { + POSTCODE_LINUX_2(CREATE_WORKQUEUE_FAILED_PC, + DIAG_SEVERITY_ERR); + rc = -ENOMEM; + goto cleanup; + } + most_recent_message_jiffies = jiffies; + poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; + rc = queue_delayed_work(periodic_controlvm_workqueue, + &periodic_controlvm_work, poll_jiffies); + if (rc < 0) { + POSTCODE_LINUX_2(QUEUE_DELAYED_WORK_PC, + DIAG_SEVERITY_ERR); + goto cleanup; } visorchipset_platform_device.dev.devt = major_dev; @@ -2840,15 +2740,11 @@ visorchipset_exit(void) visorbus_exit(); - if (visorchipset_disable_controlvm) { - ; - } else { - cancel_delayed_work(&periodic_controlvm_work); - flush_workqueue(periodic_controlvm_workqueue); - destroy_workqueue(periodic_controlvm_workqueue); - periodic_controlvm_workqueue = NULL; - destroy_controlvm_payload_info(&controlvm_payload_info); - } + cancel_delayed_work(&periodic_controlvm_work); + flush_workqueue(periodic_controlvm_workqueue); + destroy_workqueue(periodic_controlvm_workqueue); + periodic_controlvm_workqueue = NULL; + destroy_controlvm_payload_info(&controlvm_payload_info); cleanup_controlvm_structures(); @@ -2860,28 +2756,12 @@ visorchipset_exit(void) POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO); } -module_param_named(testvnic, visorchipset_testvnic, int, S_IRUGO); -MODULE_PARM_DESC(visorchipset_testvnic, "1 to test vnic, using dummy VNIC connected via a loopback to a physical ethernet"); -module_param_named(testvnicclient, visorchipset_testvnicclient, int, S_IRUGO); -MODULE_PARM_DESC(visorchipset_testvnicclient, "1 to test vnic, using real VNIC channel attached to a separate IOVM guest"); -module_param_named(testmsg, visorchipset_testmsg, int, S_IRUGO); -MODULE_PARM_DESC(visorchipset_testmsg, - "1 to manufacture the chipset, bus, and switch messages"); module_param_named(major, visorchipset_major, int, S_IRUGO); MODULE_PARM_DESC(visorchipset_major, "major device number to use for the device node"); -module_param_named(serverregwait, visorchipset_serverregwait, int, S_IRUGO); -MODULE_PARM_DESC(visorchipset_serverreqwait, +module_param_named(visorbusregwait, visorchipset_visorbusregwait, int, S_IRUGO); +MODULE_PARM_DESC(visorchipset_visorbusreqwait, "1 to have the module wait for the visor bus to register"); -module_param_named(clientregwait, visorchipset_clientregwait, int, S_IRUGO); -MODULE_PARM_DESC(visorchipset_clientregwait, "1 to have the module wait for the visorclientbus to register"); -module_param_named(testteardown, visorchipset_testteardown, int, S_IRUGO); -MODULE_PARM_DESC(visorchipset_testteardown, - "1 to test teardown of the chipset, bus, and switch"); -module_param_named(disable_controlvm, visorchipset_disable_controlvm, int, - S_IRUGO); -MODULE_PARM_DESC(visorchipset_disable_controlvm, - "1 to disable polling of controlVm channel"); module_param_named(holdchipsetready, visorchipset_holdchipsetready, int, S_IRUGO); MODULE_PARM_DESC(visorchipset_holdchipsetready, From a0fc428525414b2a5e5e98fa79a3026a3f9305b9 Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Tue, 5 May 2015 18:36:40 -0400 Subject: [PATCH 0265/1163] staging: unisys: remove unused CONTROL_VM messages from enum This patch removes CONTROL_VM disk messages from enum since they are completely unused. Signed-off-by: Erik Arfvidson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/controlvmchannel.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index ff15c45cf4da..cd1540913bf4 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -88,11 +88,6 @@ enum controlvm_id { CONTROLVM_DEVICE_CHANGESTATE = 0x204, /* CP --> SP, GP */ CONTROLVM_DEVICE_CHANGESTATE_EVENT = 0x205, /* SP, GP --> CP */ CONTROLVM_DEVICE_RECONFIGURE = 0x206, /* CP --> Boot */ -/* DISK commands required Parameter: BusNumber, DeviceNumber */ - CONTROLVM_DISK_CREATE = 0x221, /* CP --> SP */ - CONTROLVM_DISK_DESTROY = 0x222, /* CP --> SP */ - CONTROLVM_DISK_CONFIGURE = 0x223, /* CP --> SP */ - CONTROLVM_DISK_CHANGESTATE = 0x224, /* CP --> SP */ /* CHIPSET commands */ CONTROLVM_CHIPSET_INIT = 0x301, /* CP --> SP, GP */ CONTROLVM_CHIPSET_STOP = 0x302, /* CP --> SP, GP */ From 22a0350b5eb43fd6dedb182b736c083f801f38b8 Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Tue, 5 May 2015 18:36:41 -0400 Subject: [PATCH 0266/1163] staging: unisys: rename variable to reserverd since it is unused This patch renames send_irq_handle to reserved1 since this variable is unused in the guest side. Signed-off-by: Erik Arfvidson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/controlvmchannel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index cd1540913bf4..d3c1aab15e86 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -106,7 +106,7 @@ struct irq_info { * interrupt. Currently this is used by IOPart-SP to wake * up GP when Data Channel transitions from empty to * non-empty.*/ - u64 send_irq_handle; + u64 reserved1; /**< specifies interrupt handle. It is used to retrieve the * corresponding interrupt pin from Monitor; and the From 7e5a1a76447228bfb08804c539d84e9b27135f76 Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Tue, 5 May 2015 18:36:42 -0400 Subject: [PATCH 0267/1163] staging: unisys: controlvmchannel.h comment aligment and cleanup This patch is a comment aligment and cleanup for controlvmchannel.h. Signed-off-by: Erik Arfvidson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../include/channels/controlvmchannel.h | 219 ++++++++---------- 1 file changed, 101 insertions(+), 118 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index d3c1aab15e86..8830d70260e0 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -23,20 +23,21 @@ /* {2B3C2D10-7EF5-4ad8-B966-3448B7386B3D} */ #define SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID \ UUID_LE(0x2b3c2d10, 0x7ef5, 0x4ad8, \ - 0xb9, 0x66, 0x34, 0x48, 0xb7, 0x38, 0x6b, 0x3d) + 0xb9, 0x66, 0x34, 0x48, 0xb7, 0x38, 0x6b, 0x3d) static const uuid_le spar_controlvm_channel_protocol_uuid = SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID; #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE \ ULTRA_CHANNEL_PROTOCOL_SIGNATURE -#define CONTROLVM_MESSAGE_MAX 64 +#define CONTROLVM_MESSAGE_MAX 64 /* Must increment this whenever you insert or delete fields within -* this channel struct. Also increment whenever you change the meaning -* of fields within this channel struct so as to break pre-existing -* software. Note that you can usually add fields to the END of the -* channel struct withOUT needing to increment this. */ + * this channel struct. Also increment whenever you change the meaning + * of fields within this channel struct so as to break pre-existing + * software. Note that you can usually add fields to the END of the + * channel struct withOUT needing to increment this. + */ #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID 1 #define SPAR_CONTROLVM_CHANNEL_OK_CLIENT(ch) \ @@ -49,17 +50,16 @@ static const uuid_le spar_controlvm_channel_protocol_uuid = #define MAX_SERIAL_NUM 32 -/* Defines for various channel queues... */ +/* Defines for various channel queues */ #define CONTROLVM_QUEUE_REQUEST 0 #define CONTROLVM_QUEUE_RESPONSE 1 -#define CONTROLVM_QUEUE_EVENT 2 +#define CONTROLVM_QUEUE_EVENT 2 #define CONTROLVM_QUEUE_ACK 3 -/* Max number of messages stored during IOVM creation to be reused - * after crash */ +/* Max num of messages stored during IOVM creation to be reused after crash */ #define CONTROLVM_CRASHMSG_MAX 2 -/** Ids for commands that may appear in either queue of a ControlVm channel. +/* Ids for commands that may appear in either queue of a ControlVm channel. * * Commands that are initiated by the command partition (CP), by an IO or * console service partition (SP), or by a guest partition (GP)are: @@ -73,55 +73,50 @@ static const uuid_le spar_controlvm_channel_protocol_uuid = */ enum controlvm_id { CONTROLVM_INVALID = 0, - /* SWITCH commands required Parameter: SwitchNumber */ - /* BUS commands required Parameter: BusNumber */ - CONTROLVM_BUS_CREATE = 0x101, /* CP --> SP, GP */ - CONTROLVM_BUS_DESTROY = 0x102, /* CP --> SP, GP */ - CONTROLVM_BUS_CONFIGURE = 0x104, /* CP --> SP */ - CONTROLVM_BUS_CHANGESTATE = 0x105, /* CP --> SP, GP */ - CONTROLVM_BUS_CHANGESTATE_EVENT = 0x106, /* SP, GP --> CP */ -/* DEVICE commands required Parameter: BusNumber, DeviceNumber */ + /* SWITCH commands required Parameter: SwitchNumber */ + /* BUS commands required Parameter: BusNumber */ + CONTROLVM_BUS_CREATE = 0x101, /* CP --> SP, GP */ + CONTROLVM_BUS_DESTROY = 0x102, /* CP --> SP, GP */ + CONTROLVM_BUS_CONFIGURE = 0x104, /* CP --> SP */ + CONTROLVM_BUS_CHANGESTATE = 0x105, /* CP --> SP, GP */ + CONTROLVM_BUS_CHANGESTATE_EVENT = 0x106, /* SP, GP --> CP */ +/* DEVICE commands required Parameter: BusNumber, DeviceNumber */ - CONTROLVM_DEVICE_CREATE = 0x201, /* CP --> SP, GP */ - CONTROLVM_DEVICE_DESTROY = 0x202, /* CP --> SP, GP */ - CONTROLVM_DEVICE_CONFIGURE = 0x203, /* CP --> SP */ - CONTROLVM_DEVICE_CHANGESTATE = 0x204, /* CP --> SP, GP */ - CONTROLVM_DEVICE_CHANGESTATE_EVENT = 0x205, /* SP, GP --> CP */ - CONTROLVM_DEVICE_RECONFIGURE = 0x206, /* CP --> Boot */ + CONTROLVM_DEVICE_CREATE = 0x201, /* CP --> SP, GP */ + CONTROLVM_DEVICE_DESTROY = 0x202, /* CP --> SP, GP */ + CONTROLVM_DEVICE_CONFIGURE = 0x203, /* CP --> SP */ + CONTROLVM_DEVICE_CHANGESTATE = 0x204, /* CP --> SP, GP */ + CONTROLVM_DEVICE_CHANGESTATE_EVENT = 0x205, /* SP, GP --> CP */ + CONTROLVM_DEVICE_RECONFIGURE = 0x206, /* CP --> Boot */ /* CHIPSET commands */ - CONTROLVM_CHIPSET_INIT = 0x301, /* CP --> SP, GP */ - CONTROLVM_CHIPSET_STOP = 0x302, /* CP --> SP, GP */ - CONTROLVM_CHIPSET_SHUTDOWN = 0x303, /* CP --> SP */ - CONTROLVM_CHIPSET_READY = 0x304, /* CP --> SP */ - CONTROLVM_CHIPSET_SELFTEST = 0x305, /* CP --> SP */ + CONTROLVM_CHIPSET_INIT = 0x301, /* CP --> SP, GP */ + CONTROLVM_CHIPSET_STOP = 0x302, /* CP --> SP, GP */ + CONTROLVM_CHIPSET_SHUTDOWN = 0x303, /* CP --> SP */ + CONTROLVM_CHIPSET_READY = 0x304, /* CP --> SP */ + CONTROLVM_CHIPSET_SELFTEST = 0x305, /* CP --> SP */ }; struct irq_info { - /**< specifies interrupt info. It is used to send interrupts - * for this channel. The peer at the end of this channel - * who has registered an interrupt (using recv fields - * above) will receive the interrupt. Passed as a parameter - * to Issue_VMCALL_IO_QUEUE_TRANSITION, which generates the - * interrupt. Currently this is used by IOPart-SP to wake - * up GP when Data Channel transitions from empty to - * non-empty.*/ u64 reserved1; - /**< specifies interrupt handle. It is used to retrieve the + /* specifies interrupt handle. It is used to retrieve the * corresponding interrupt pin from Monitor; and the * interrupt pin is used to connect to the corresponding - * interrupt. Used by IOPart-GP only. */ + * interrupt. Used by IOPart-GP only. + */ u64 recv_irq_handle; - /**< specifies interrupt vector. It, interrupt pin, and shared are + /* specifies interrupt vector. It, interrupt pin, and shared are * used to connect to the corresponding interrupt. Used by - * IOPart-GP only. */ + * IOPart-GP only. + */ u32 recv_irq_vector; - /**< specifies if the recvInterrupt is shared. It, interrupt pin - * and vector are used to connect to 0 = not shared; 1 = shared. - * the corresponding interrupt. Used by IOPart-GP only. */ + /* specifies if the recvInterrupt is shared. It, interrupt pin + * and vector are used to connect to 0 = not shared; 1 = shared. + * the corresponding interrupt. Used by IOPart-GP only. + */ u8 recv_irq_shared; u8 reserved[3]; /* Natural alignment purposes */ }; @@ -135,10 +130,10 @@ struct pci_id { }; struct efi_spar_indication { - u64 boot_to_fw_ui:1; /* Bit 0: Stop in uefi ui */ - u64 clear_nvram:1; /* Bit 1: Clear NVRAM */ - u64 clear_cmos:1; /* Bit 2: Clear CMOS */ - u64 boot_to_tool:1; /* Bit 3: Run install tool */ + u64 boot_to_fw_ui:1; /* Bit 0: Stop in uefi ui */ + u64 clear_nvram:1; /* Bit 1: Clear NVRAM */ + u64 clear_cmos:1; /* Bit 2: Clear CMOS */ + u64 boot_to_tool:1; /* Bit 3: Run install tool */ /* remaining bits are available */ }; @@ -148,7 +143,7 @@ enum ultra_chipset_feature { ULTRA_CHIPSET_FEATURE_PCIVBUS = 0x00000004 }; -/** This is the common structure that is at the beginning of every +/* This is the common structure that is at the beginning of every * ControlVm message (both commands and responses) in any ControlVm * queue. Commands are easily distinguished from responses by * looking at the flags.response field. @@ -165,26 +160,26 @@ struct controlvm_message_header { u32 completion_status; /* Error status code or result of * message completion */ struct { - u32 failed:1; /**< =1 in a response to * signify + u32 failed:1; /* =1 in a response to * signify * failure */ - u32 response_expected:1; /**< =1 in all messages that expect a - * response (Control ignores this - * bit) */ - u32 server:1; /**< =1 in all bus & device-related + u32 response_expected:1; /* =1 in all messages that expect a + * response (Control ignores this + * bit) */ + u32 server:1; /* =1 in all bus & device-related * messages where the message * receiver is to act as the bus or * device server */ - u32 test_message:1; /**< =1 for testing use only + u32 test_message:1; /* =1 for testing use only * (Control and Command ignore this * bit) */ - u32 partial_completion:1; /**< =1 if there are forthcoming - * responses/acks associated - * with this message */ - u32 preserve:1; /**< =1 this is to let us know to - * preserve channel contents - * (for running guests)*/ - u32 writer_in_diag:1; /**< =1 the DiagWriter is active in the - * Diagnostic Partition*/ + u32 partial_completion:1; /* =1 if there are forthcoming + * responses/acks associated + * with this message */ + u32 preserve:1; /* =1 this is to let us know to + * preserve channel contents + * (for running guests)*/ + u32 writer_in_diag:1; /* =1 the DiagWriter is active in the + * Diagnostic Partition*/ } flags; u32 reserved; /* Natural alignment */ u64 message_handle; /* Identifies the particular message instance, @@ -200,8 +195,8 @@ struct controlvm_message_header { }; struct controlvm_packet_device_create { - u32 bus_no; /* bus # (0..n-1) from the msg receiver's end */ - u32 dev_no; /* bus-relative (0..n-1) device number */ + u32 bus_no; /* bus # (0..n-1) from the msg receiver's end */ + u32 dev_no; /* bus-relative (0..n-1) device number */ u64 channel_addr; /* Guest physical address of the channel, which * can be dereferenced by the receiver of this * ControlVm command */ @@ -212,11 +207,10 @@ struct controlvm_packet_device_create { }; /* for CONTROLVM_DEVICE_CREATE */ struct controlvm_packet_device_configure { - u32 bus_no; /**< bus # (0..n-1) from the msg + u32 bus_no; /* bus # (0..n-1) from the msg * receiver's perspective */ - - /* Control uses header SegmentIndex field to access bus number... */ - u32 dev_no; /**< bus-relative (0..n-1) device number */ + /* Control uses header SegmentIndex field to access bus number... */ + u32 dev_no; /* bus-relative (0..n-1) device number */ } ; /* for CONTROLVM_DEVICE_CONFIGURE */ struct controlvm_message_device_create { @@ -334,7 +328,7 @@ struct device_map { u64 reserved2; /* Align structure on 32-byte boundary */ }; -struct guest_devices { +struct guest_devices { struct device_map video_channel; struct device_map keyboard_channel; struct device_map network_channel; @@ -345,58 +339,47 @@ struct guest_devices { }; struct spar_controlvm_channel_protocol { - struct channel_header header; - u64 gp_controlvm; /* guest physical address of - * this channel */ - u64 gp_partition_tables;/* guest physical address of - * partition tables */ - u64 gp_diag_guest; /* guest physical address of - * diagnostic channel */ - u64 gp_boot_romdisk;/* guest phys addr of (read - * only) Boot ROM disk */ - u64 gp_boot_ramdisk;/* guest phys addr of writable - * Boot RAM disk */ - u64 gp_acpi_table; /* guest phys addr of acpi - * table */ - u64 gp_control_channel;/* guest phys addr of control - * channel */ - u64 gp_diag_romdisk;/* guest phys addr of diagnostic - * ROM disk */ - u64 gp_nvram; /* guest phys addr of NVRAM - * channel */ - u64 request_payload_offset; /* Offset to request payload area */ - u64 event_payload_offset; /* Offset to event payload area */ - u32 request_payload_bytes; /* Bytes available in request payload + struct channel_header header; + u64 gp_controlvm; /* guest phys addr of this channel */ + u64 gp_partition_tables;/* guest phys addr of partition tables */ + u64 gp_diag_guest; /* guest phys addr of diagnostic channel */ + u64 gp_boot_romdisk;/* guest phys addr of (read* only) Boot ROM disk */ + u64 gp_boot_ramdisk;/* guest phys addr of writable Boot RAM disk */ + u64 gp_acpi_table; /* guest phys addr of acpi table */ + u64 gp_control_channel;/* guest phys addr of control channel */ + u64 gp_diag_romdisk;/* guest phys addr of diagnostic ROM disk */ + u64 gp_nvram; /* guest phys addr of NVRAM channel */ + u64 request_payload_offset; /* Offset to request payload area */ + u64 event_payload_offset; /* Offset to event payload area */ + u32 request_payload_bytes; /* Bytes available in request payload * area */ - u32 event_payload_bytes;/* Bytes available in event payload area */ - u32 control_channel_bytes; - u32 nvram_channel_bytes; /* Bytes in PartitionNvram segment */ - u32 message_bytes; /* sizeof(CONTROLVM_MESSAGE) */ - u32 message_count; /* CONTROLVM_MESSAGE_MAX */ - u64 gp_smbios_table;/* guest phys addr of SMBIOS - * tables */ - u64 gp_physical_smbios_table;/* guest phys addr of - * SMBIOS table */ - /* ULTRA_MAX_GUESTS_PER_SERVICE */ - struct guest_devices gp_obsolete_guest_devices[16]; + u32 event_payload_bytes;/* Bytes available in event payload area */ + u32 control_channel_bytes; + u32 nvram_channel_bytes; /* Bytes in PartitionNvram segment */ + u32 message_bytes; /* sizeof(CONTROLVM_MESSAGE) */ + u32 message_count; /* CONTROLVM_MESSAGE_MAX */ + u64 gp_smbios_table; /* guest phys addr of SMBIOS tables */ + u64 gp_physical_smbios_table; /* guest phys addr of SMBIOS table */ + /* ULTRA_MAX_GUESTS_PER_SERVICE */ + struct guest_devices gp_obsolete_guest_devices[16]; - /* guest physical address of EFI firmware image base */ - u64 virtual_guest_firmware_image_base; + /* guest physical address of EFI firmware image base */ + u64 virtual_guest_firmware_image_base; - /* guest physical address of EFI firmware entry point */ - u64 virtual_guest_firmware_entry_point; + /* guest physical address of EFI firmware entry point */ + u64 virtual_guest_firmware_entry_point; - /* guest EFI firmware image size */ - u64 virtual_guest_firmware_image_size; + /* guest EFI firmware image size */ + u64 virtual_guest_firmware_image_size; - /* GPA = 1MB where EFI firmware image is copied to */ - u64 virtual_guest_firmware_boot_base; - u64 virtual_guest_image_base; - u64 virtual_guest_image_size; - u64 prototype_control_channel_offset; - u64 virtual_guest_partition_handle; + /* GPA = 1MB where EFI firmware image is copied to */ + u64 virtual_guest_firmware_boot_base; + u64 virtual_guest_image_base; + u64 virtual_guest_image_size; + u64 prototype_control_channel_offset; + u64 virtual_guest_partition_handle; - u16 restore_action; /* Restore Action field to restore the guest + u16 restore_action; /* Restore Action field to restore the guest * partition */ u16 dump_action; /* For Windows guests it shows if the visordisk * is running in dump mode */ @@ -446,7 +429,7 @@ struct spar_controlvm_channel_protocol { struct controlvm_message saved_crash_msg[CONTROLVM_CRASHMSG_MAX]; }; -/* Offsets for VM channel attributes... */ +/* Offsets for VM channel attributes */ #define VM_CH_REQ_QUEUE_OFFSET \ offsetof(struct spar_controlvm_channel_protocol, request_queue) #define VM_CH_RESP_QUEUE_OFFSET \ From 680385e3812b2a75dbe27395a7c49ba987698f0c Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Tue, 5 May 2015 18:36:43 -0400 Subject: [PATCH 0268/1163] staging: unisys: remove unused device_map and guest_devices struct This patch removes unused struct in the controlvm_channel message and replaces it with a char reserved inorder to mantain same message size. Signed-off-by: Erik Arfvidson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../include/channels/controlvmchannel.h | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 8830d70260e0..045c9223d0f8 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -320,24 +320,6 @@ struct controlvm_message { struct controlvm_message_packet cmd; }; -struct device_map { - u64 device_channel_address; - u64 device_channel_size; - u32 ca_index; - u32 reserved; /* natural alignment */ - u64 reserved2; /* Align structure on 32-byte boundary */ -}; - -struct guest_devices { - struct device_map video_channel; - struct device_map keyboard_channel; - struct device_map network_channel; - struct device_map storage_channel; - struct device_map console_channel; - u32 partition_index; - u32 pad; -}; - struct spar_controlvm_channel_protocol { struct channel_header header; u64 gp_controlvm; /* guest phys addr of this channel */ @@ -361,7 +343,7 @@ struct spar_controlvm_channel_protocol { u64 gp_smbios_table; /* guest phys addr of SMBIOS tables */ u64 gp_physical_smbios_table; /* guest phys addr of SMBIOS table */ /* ULTRA_MAX_GUESTS_PER_SERVICE */ - struct guest_devices gp_obsolete_guest_devices[16]; + char gp_reserved[2688]; /* guest physical address of EFI firmware image base */ u64 virtual_guest_firmware_image_base; From 91087bb384a24d73cef10c10fb0d9fd4b2cb40df Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Tue, 5 May 2015 18:36:44 -0400 Subject: [PATCH 0269/1163] staging: unisys: remove unused CONTROLVM_CHIPSET_SHUTDOWN this patch removes unused chipset command on the guest CONTROLVM_CHIPSET_SHUTDOWN Signed-off-by: Erik Arfvidson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/controlvmchannel.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 045c9223d0f8..a15095c538aa 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -91,7 +91,6 @@ enum controlvm_id { /* CHIPSET commands */ CONTROLVM_CHIPSET_INIT = 0x301, /* CP --> SP, GP */ CONTROLVM_CHIPSET_STOP = 0x302, /* CP --> SP, GP */ - CONTROLVM_CHIPSET_SHUTDOWN = 0x303, /* CP --> SP */ CONTROLVM_CHIPSET_READY = 0x304, /* CP --> SP */ CONTROLVM_CHIPSET_SELFTEST = 0x305, /* CP --> SP */ From 79245bfce8462c699581d1379029417b60eaa6cb Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Tue, 5 May 2015 18:36:45 -0400 Subject: [PATCH 0270/1163] staging: unisys: remove unused chipset feature PCIVBUS This patch removes unused chipset feature ULTRA_CHIPSET_FEATURE_PCIVBUS Signed-off-by: Erik Arfvidson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/controlvmchannel.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index a15095c538aa..d8ed52edd938 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -139,7 +139,6 @@ struct efi_spar_indication { enum ultra_chipset_feature { ULTRA_CHIPSET_FEATURE_REPLY = 0x00000001, ULTRA_CHIPSET_FEATURE_PARA_HOTPLUG = 0x00000002, - ULTRA_CHIPSET_FEATURE_PCIVBUS = 0x00000004 }; /* This is the common structure that is at the beginning of every From 67ec962a5ba2b5a901a8a78581fd3cca55a4474d Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Tue, 5 May 2015 18:36:46 -0400 Subject: [PATCH 0271/1163] staging: unisys: remove unused #define in iochannel.h This patch simply remove all unused #define's in iochannel.h Signed-off-by: Erik Arfvidson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../common-spar/include/channels/iochannel.h | 137 ------------------ 1 file changed, 137 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index ff393c2c2350..fad7fe90f560 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -86,41 +86,10 @@ * ioguestparts */ #define IOCHAN_TO_IOPART 0 /* used by ioguestpart to 'insert' signals to * iopart */ -#define IOCHAN_FROM_GUESTPART 0 /* used by iopart to 'remove' signals from - * ioguestpart - same queue as previous queue */ -#define IOCHAN_TO_GUESTPART 1 /* used by iopart to 'insert' signals to - * ioguestpart */ #define IOCHAN_FROM_IOPART 1 /* used by ioguestpart to 'remove' signals from * iopart - same queue as previous queue */ -/* these define the two queues per control channel between controlpart and "its" - * guests, which includes the iopart */ -#define CTRLCHAN_TO_CTRLGUESTPART 0 /* used by ctrlguestpart to 'insert' signals - * to ctrlpart */ -#define CTLRCHAN_FROM_CTRLPART 0 /* used by ctrlpart to 'remove' signals from - * ctrlquestpart - same queue as previous - * queue */ - -#define CTRLCHAN_TO_CTRLPART 1 /* used by ctrlpart to 'insert' signals to - * ctrlguestpart */ -#define CTRLCHAN_FROM_CTRLGUESTPART 1 /* used by ctrguestpart to 'remove' - * signals from ctrlpart - same queue as - * previous queue */ - -/* these define the Event & Ack queues per control channel Events are generated -* by CTRLGUESTPART and sent to CTRLPART; Acks are generated by CTRLPART and sent -* to CTRLGUESTPART. */ -#define CTRLCHAN_EVENT_TO_CTRLPART 2 /* used by ctrlguestpart to 'insert' Events - * to ctrlpart */ -#define CTRLCHAN_EVENT_FROM_CTRLGUESTPART 2 /* used by ctrlpart to 'remove' - * Events from ctrlguestpart */ - -#define CTRLCHAN_ACK_TO_CTRLGUESTPART 3 /* used by ctrlpart to 'insert' Acks to - * ctrlguestpart */ -#define CTRLCHAN_ACK_FROM_CTRLPART 3 /* used by ctrlguestpart to 'remove' Events - * from ctrlpart */ - /* size of cdb - i.e., scsi cmnd */ #define MAX_CMND_SIZE 16 @@ -128,24 +97,6 @@ #define MAX_PHYS_INFO 64 -/* Because GuestToGuestCopy is limited to 4KiB segments, and we have limited the -* Emulex Driver to 256 scatter list segments via the lpfc_sg_seg_cnt parameter -* to 256, the maximum I/O size is limited to 256 * 4 KiB = 1 MB */ -#define MAX_IO_SIZE (1024*1024) /* 1 MB */ - -/* NOTE 1: lpfc defines its support for segments in -* #define LPFC_SG_SEG_CNT 64 -* -* NOTE 2: In Linux, frags array in skb is currently allocated to be -* MAX_SKB_FRAGS size, which is 18 which is smaller than MAX_PHYS_INFO for -* now. */ - -#define MAX_SCSI_BUSES 1 -#define MAX_SCSI_TARGETS 8 -#define MAX_SCSI_LUNS 16 -#define MAX_SCSI_FROM_HOST 0xFFFFFFFF /* Indicator to use Physical HBA - * SCSI Host value */ - /* various types of network packets that can be sent in cmdrsp */ enum net_types { NET_RCV_POST = 0, /* submit buffer to hold receiving @@ -178,19 +129,12 @@ enum net_types { #define ETH_MIN_DATA_SIZE 46 /* minimum eth data size */ #define ETH_MIN_PACKET_SIZE (ETH_HEADER_SIZE + ETH_MIN_DATA_SIZE) -#define ETH_DEF_DATA_SIZE 1500 /* default data size */ -#define ETH_DEF_PACKET_SIZE (ETH_HEADER_SIZE + ETH_DEF_DATA_SIZE) - #define ETH_MAX_MTU 16384 /* maximum data size */ #ifndef MAX_MACADDR_LEN #define MAX_MACADDR_LEN 6 /* number of bytes in MAC address */ #endif /* MAX_MACADDR_LEN */ -#define ETH_IS_LOCALLY_ADMINISTERED(address) \ - (((u8 *)(address))[0] & ((u8)0x02)) -#define NIC_VENDOR_ID 0x0008000B - /* various types of scsi task mgmt commands */ enum task_mgmt_types { TASK_MGMT_ABORT_TASK = 1, @@ -205,20 +149,6 @@ enum vdisk_mgmt_types { VDISK_MGMT_RELEASE, }; -/* this is used in the vdest field */ -#define VDEST_ALL 0xFFFF - -#define MIN_NUMSIGNALS 64 -#define MAX_NUMSIGNALS 4096 - -/* MAX_NET_RCV_BUF specifies the number of rcv buffers that are created by each -* guest's virtnic and posted to uisnic. Uisnic, for each channel, keeps the rcv -* buffers posted and uses them to receive data on behalf of the guest's virtnic. -* NOTE: the num_rcv_bufs is configurable for each VNIC. So the following is -* simply an upperlimit on what each VNIC can provide. Setting it to half of the -* NUMSIGNALS to prevent queue full deadlocks */ -#define MAX_NET_RCV_BUFS (MIN_NUMSIGNALS / 2) - /* * structs with pragma pack */ @@ -283,13 +213,7 @@ struct uiscmdrsp_scsi { u8 scsistat; /* the scsi status */ u8 addlstat; /* non-scsi status - covers cases like timeout * needed by windows guests */ -#define ADDL_RESET 1 -#define ADDL_TIMEOUT 2 -#define ADDL_INTERNAL_ERROR 3 #define ADDL_SEL_TIMEOUT 4 -#define ADDL_CMD_TIMEOUT 5 -#define ADDL_BAD_TARGET 6 -#define ADDL_RETRY 7 /* the following fields are need to determine the result of command */ u8 sensebuf[MAX_SENSE_SIZE]; /* sense info in case cmd failed; */ @@ -320,7 +244,6 @@ struct uiscmdrsp_scsi { *connected to this logical unit. */ -#define DEV_NOT_PRESENT 0x7f /* old name - compatibility */ #define DEV_NOT_CAPABLE 0x7f /* peripheral qualifier of 0x3 */ /* peripheral type of 0x1f */ /* specifies no device but target present */ @@ -329,10 +252,6 @@ struct uiscmdrsp_scsi { /* peripheral type of 0 - disk */ /* specifies device capable, but not present */ -#define DEV_PROC_CAPABLE_NOT_PRESENT 0x23 /* peripheral qualifier of 0x1 */ - /* peripheral type of 3 - processor */ - /* specifies device capable, but not present */ - #define DEV_HISUPPORT 0x10 /* HiSup = 1; shows support for report luns */ /* must be returned for lun 0. */ @@ -423,37 +342,6 @@ struct sense_data { u8 sense_key_specific[3]; }; -/* some SCSI ADSENSE codes */ -#ifndef SCSI_ADSENSE_LUN_NOT_READY -#define SCSI_ADSENSE_LUN_NOT_READY 0x04 -#endif /* */ -#ifndef SCSI_ADSENSE_ILLEGAL_COMMAND -#define SCSI_ADSENSE_ILLEGAL_COMMAND 0x20 -#endif /* */ -#ifndef SCSI_ADSENSE_ILLEGAL_BLOCK -#endif /* */ -#ifndef SCSI_ADSENSE_ILLEGAL_BLOCK -#define SCSI_ADSENSE_ILLEGAL_BLOCK 0x21 -#endif /* */ -#ifndef SCSI_ADSENSE_INVALID_CDB -#define SCSI_ADSENSE_INVALID_CDB 0x24 -#endif /* */ -#ifndef SCSI_ADSENSE_INVALID_LUN -#define SCSI_ADSENSE_INVALID_LUN 0x25 -#endif /* */ -#ifndef SCSI_ADWRITE_PROTECT -#define SCSI_ADWRITE_PROTECT 0x27 -#endif /* */ -#ifndef SCSI_ADSENSE_MEDIUM_CHANGED -#define SCSI_ADSENSE_MEDIUM_CHANGED 0x28 -#endif /* */ -#ifndef SCSI_ADSENSE_BUS_RESET -#define SCSI_ADSENSE_BUS_RESET 0x29 -#endif /* */ -#ifndef SCSI_ADSENSE_NO_MEDIA_IN_DEVICE -#define SCSI_ADSENSE_NO_MEDIA_IN_DEVICE 0x3a -#endif /* */ - struct net_pkt_xmt { int len; /* full length of data in the packet */ int num_frags; /* number of fragments in frags containing data */ @@ -484,8 +372,6 @@ struct net_pkt_xmt { struct net_pkt_xmtdone { u32 xmt_done_result; /* result of NET_XMIT */ -#define XMIT_SUCCESS 0 -#define XMIT_FAILED 1 }; /* RCVPOST_BUF_SIZe must be at most page_size(4096) - cache_line_size (64) The @@ -582,7 +468,6 @@ struct uiscmdrsp_scsitaskmgmt { /* result of taskmgmt command - set by IOPart - values are: */ #define TASK_MGMT_FAILED 0 -#define TASK_MGMT_SUCCESS 1 }; /* The following is used by uissd to send disk add/remove notifications to @@ -629,7 +514,6 @@ struct uiscmdrsp_vdiskmgmt { /* result of taskmgmt command - set by IOPart - values are: */ #define VDISK_MGMT_FAILED 0 -#define VDISK_MGMT_SUCCESS 1 }; /* keeping cmd & rsp info in one structure for now cmd rsp packet for scsi */ @@ -684,26 +568,6 @@ struct spar_io_channel_protocol { #pragma pack(pop) /* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */ -/* define offsets to members of struct uiscmdrsp */ -#define OFFSET_CMDTYPE offsetof(struct uiscmdrsp, cmdtype) -#define OFFSET_SCSI offsetof(struct uiscmdrsp, scsi) -#define OFFSET_NET offsetof(struct uiscmdrsp, net) -#define OFFSET_SCSITASKMGMT offsetof(struct uiscmdrsp, scsitaskmgmt) -#define OFFSET_NEXT offsetof(struct uiscmdrsp, next) - -/* define offsets to members of struct uiscmdrsp_net */ -#define OFFSET_TYPE offsetof(struct uiscmdrsp_net, type) -#define OFFSET_BUF offsetof(struct uiscmdrsp_net, buf) -#define OFFSET_XMT offsetof(struct uiscmdrsp_net, xmt) -#define OFFSET_XMT_DONE_RESULT offsetof(struct uiscmdrsp_net, xmtdone) -#define OFFSET_RCVPOST offsetof(struct uiscmdrsp_net, rcvpost) -#define OFFSET_RCV_DONE_LEN offsetof(struct uiscmdrsp_net, rcv) -#define OFFSET_ENBDIS offsetof(struct uiscmdrsp_net, enbdis) - -/* define offsets to members of struct net_pkt_rcvpost */ -#define OFFSET_TOTALLEN offsetof(struct net_pkt_rcvpost, totallen) -#define OFFSET_FRAG offsetof(struct net_pkt_rcvpost, frag) - /* * INLINE functions for initializing and accessing I/O data channels */ @@ -724,7 +588,6 @@ struct spar_io_channel_protocol { /* Guest and IOPartition. */ #define PI_PAGE_SIZE 0x1000 #define PI_PAGE_MASK 0x0FFF -#define PI_PAGE_SHIFT 12 /* returns next non-zero index on success or zero on failure (i.e. out of * room) From 15dd144c3bf918797f0bf691abbca13ced861ed6 Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Tue, 5 May 2015 18:36:47 -0400 Subject: [PATCH 0272/1163] staging: unisys: cleanup and align iochannel.h comments This patch reorganizes, aligns, and corrects grammar mistakes on comments. Signed-off-by: Erik Arfvidson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../common-spar/include/channels/iochannel.h | 240 +++++++++--------- 1 file changed, 124 insertions(+), 116 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index fad7fe90f560..cbb58757e76a 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -4,29 +4,29 @@ #define __IOCHANNEL_H__ /* -* Everything needed for IOPart-GuestPart communication is define in -* this file. Note: Everything is OS-independent because this file is -* used by Windows, Linux and possible EFI drivers. */ + * Everything needed for IOPart-GuestPart communication is define in + * this file. Note: Everything is OS-independent because this file is + * used by Windows, Linux and possible EFI drivers. */ /* -* Communication flow between the IOPart and GuestPart uses the channel headers -* channel state. The following states are currently being used: -* UNINIT(All Zeroes), CHANNEL_ATTACHING, CHANNEL_ATTACHED, CHANNEL_OPENED -* -* additional states will be used later. No locking is needed to switch between -* states due to the following rules: -* -* 1. IOPart is only the only partition allowed to change from UNIT -* 2. IOPart is only the only partition allowed to change from -* CHANNEL_ATTACHING -* 3. GuestPart is only the only partition allowed to change from -* CHANNEL_ATTACHED -* -* The state changes are the following: IOPart sees the channel is in UNINIT, -* UNINIT -> CHANNEL_ATTACHING (performed only by IOPart) -* CHANNEL_ATTACHING -> CHANNEL_ATTACHED (performed only by IOPart) -* CHANNEL_ATTACHED -> CHANNEL_OPENED (performed only by GuestPart) -*/ + * Communication flow between the IOPart and GuestPart uses the channel headers + * channel state. The following states are currently being used: + * UNINIT(All Zeroes), CHANNEL_ATTACHING, CHANNEL_ATTACHED, CHANNEL_OPENED + * + * additional states will be used later. No locking is needed to switch between + * states due to the following rules: + * + * 1. IOPart is only the only partition allowed to change from UNIT + * 2. IOPart is only the only partition allowed to change from + * CHANNEL_ATTACHING + * 3. GuestPart is only the only partition allowed to change from + * CHANNEL_ATTACHED + * + * The state changes are the following: IOPart sees the channel is in UNINIT, + * UNINIT -> CHANNEL_ATTACHING (performed only by IOPart) + * CHANNEL_ATTACHING -> CHANNEL_ATTACHED (performed only by IOPart) + * CHANNEL_ATTACHED -> CHANNEL_OPENED (performed only by GuestPart) + */ #include @@ -38,11 +38,6 @@ #include "vbuschannel.h" #undef _ULTRA_CONTROLVM_CHANNEL_INLINE_ #include "channel.h" - -/* - * CHANNEL Guids - */ - #include "channel_guid.h" #define ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE ULTRA_CHANNEL_PROTOCOL_SIGNATURE @@ -51,10 +46,11 @@ ULTRA_CHANNEL_PROTOCOL_SIGNATURE /* Must increment these whenever you insert or delete fields within this channel -* struct. Also increment whenever you change the meaning of fields within this -* channel struct so as to break pre-existing software. Note that you can -* usually add fields to the END of the channel struct withOUT needing to -* increment this. */ + * struct. Also increment whenever you change the meaning of fields within this + * channel struct so as to break pre-existing software. Note that you can + * usually add fields to the END of the channel struct withOUT needing to + * increment this. + */ #define ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID 2 #define ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID 2 #define ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID 1 @@ -72,18 +68,20 @@ ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE)) /* -* Everything necessary to handle SCSI & NIC traffic between Guest Partition and -* IO Partition is defined below. */ + * Everything necessary to handle SCSI & NIC traffic between Guest Partition and + * IO Partition is defined below. + */ /* -* Defines and enums. -*/ + * Defines and enums. + */ #define MINNUM(a, b) (((a) < (b)) ? (a) : (b)) #define MAXNUM(a, b) (((a) > (b)) ? (a) : (b)) /* these define the two queues per data channel between iopart and - * ioguestparts */ + * ioguestparts + */ #define IOCHAN_TO_IOPART 0 /* used by ioguestpart to 'insert' signals to * iopart */ @@ -120,7 +118,7 @@ enum net_types { /* uisnic -> virtnic */ NET_MACADDR, /* indicates the client has requested to update * its MAC addr */ - NET_MACADDR_ACK, /* MAC address */ + NET_MACADDR_ACK, /* MAC address */ }; @@ -149,8 +147,7 @@ enum vdisk_mgmt_types { VDISK_MGMT_RELEASE, }; -/* - * structs with pragma pack */ +/* structs with pragma pack */ /* ///////////// BEGIN PRAGMA PACK PUSH 1 ///////////////////////// */ /* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */ @@ -221,17 +218,19 @@ struct uiscmdrsp_scsi { /* see that struct for details. */ void *vdisk; /* contains pointer to the vdisk so that we can clean up * when the IO completes. */ - int no_disk_result; /* used to return no disk inquiry result */ - /* when no_disk_result is set to 1, */ - /* scsi.scsistat is SAM_STAT_GOOD */ - /* scsi.addlstat is 0 */ - /* scsi.linuxstat is SAM_STAT_GOOD */ - /* That is, there is NO error. */ + int no_disk_result; + /* used to return no disk inquiry result + * when no_disk_result is set to 1, + * scsi.scsistat is SAM_STAT_GOOD + * scsi.addlstat is 0 + * scsi.linuxstat is SAM_STAT_GOOD + * That is, there is NO error. + */ }; -/* -* Defines to support sending correct inquiry result when no disk is -* configured. */ +/* Defines to support sending correct inquiry result when no disk is + * configured. + */ /* From SCSI SPC2 - * @@ -245,20 +244,21 @@ struct uiscmdrsp_scsi { */ #define DEV_NOT_CAPABLE 0x7f /* peripheral qualifier of 0x3 */ - /* peripheral type of 0x1f */ - /* specifies no device but target present */ + /* peripheral type of 0x1f */ + /* specifies no device but target present */ #define DEV_DISK_CAPABLE_NOT_PRESENT 0x20 /* peripheral qualifier of 0x1 */ /* peripheral type of 0 - disk */ /* specifies device capable, but not present */ #define DEV_HISUPPORT 0x10 /* HiSup = 1; shows support for report luns */ - /* must be returned for lun 0. */ + /* must be returned for lun 0. */ /* NOTE: Linux code assumes inquiry contains 36 bytes. Without checking length -* in buf[4] some linux code accesses bytes beyond 5 to retrieve vendor, product -* & revision. Yikes! So let us always send back 36 bytes, the minimum for -* inquiry result. */ + * in buf[4] some linux code accesses bytes beyond 5 to retrieve vendor, product + * & revision. Yikes! So let us always send back 36 bytes, the minimum for + * inquiry result. + */ #define NO_DISK_INQUIRY_RESULT_LEN 36 #define MIN_INQUIRY_RESULT_LEN 5 /* we need at least 5 bytes minimum for inquiry @@ -309,21 +309,21 @@ struct uiscmdrsp_scsi { } while (0) /* -* Struct & Defines to support sense information. -*/ + * Struct & Defines to support sense information. + */ /* The following struct is returned in sensebuf field in uiscmdrsp_scsi. It is -* initialized in exactly the manner that is recommended in Windows (hence the -* odd values). -* When set, these fields will have the following values: -* ErrorCode = 0x70 indicates current error -* Valid = 1 indicates sense info is valid -* SenseKey contains sense key as defined by SCSI specs. -* AdditionalSenseCode contains sense key as defined by SCSI specs. -* AdditionalSenseCodeQualifier contains qualifier to sense code as defined by -* scsi docs. -* AdditionalSenseLength contains will be sizeof(sense_data)-8=10. -*/ + * initialized in exactly the manner that is recommended in Windows (hence the + * odd values). + * When set, these fields will have the following values: + * ErrorCode = 0x70 indicates current error + * Valid = 1 indicates sense info is valid + * SenseKey contains sense key as defined by SCSI specs. + * AdditionalSenseCode contains sense key as defined by SCSI specs. + * AdditionalSenseCodeQualifier contains qualifier to sense code as defined by + * scsi docs. + * AdditionalSenseLength contains will be sizeof(sense_data)-8=10. + */ struct sense_data { u8 errorcode:7; u8 valid:1; @@ -375,24 +375,25 @@ struct net_pkt_xmtdone { }; /* RCVPOST_BUF_SIZe must be at most page_size(4096) - cache_line_size (64) The -* reason is because dev_skb_alloc which is used to generate RCV_POST skbs in -* virtnic requires that there is "overhead" in the buffer, and pads 16 bytes. I -* prefer to use 1 full cache line size for "overhead" so that transfers are -* better. IOVM requires that a buffer be represented by 1 phys_info structure -* which can only cover page_size. */ + * reason is because dev_skb_alloc which is used to generate RCV_POST skbs in + * virtnic requires that there is "overhead" in the buffer, and pads 16 bytes. I + * prefer to use 1 full cache line size for "overhead" so that transfers are + * better. IOVM requires that a buffer be represented by 1 phys_info structure + * which can only cover page_size. + */ #define RCVPOST_BUF_SIZE 4032 #define MAX_NET_RCV_CHAIN \ ((ETH_MAX_MTU+ETH_HEADER_SIZE + RCVPOST_BUF_SIZE-1) / RCVPOST_BUF_SIZE) struct net_pkt_rcvpost { /* rcv buf size must be large enough to include ethernet data len + - * ethernet header len - we are choosing 2K because it is guaranteed - * to be describable */ + * ethernet header len - we are choosing 2K because it is guaranteed + * to be describable */ struct phys_info frag; /* physical page information for the * single fragment 2K rcv buf */ u64 unique_num; /* This is used to make sure that * receive posts are returned to */ - /* the Adapter which sent them origonally. */ + /* the Adapter which we sent them originally. */ }; struct net_pkt_rcv { @@ -424,14 +425,14 @@ struct uiscmdrsp_net { enum net_types type; void *buf; union { - struct net_pkt_xmt xmt; /* used for NET_XMIT */ + struct net_pkt_xmt xmt; /* used for NET_XMIT */ struct net_pkt_xmtdone xmtdone; /* used for NET_XMIT_DONE */ struct net_pkt_rcvpost rcvpost; /* used for NET_RCV_POST */ - struct net_pkt_rcv rcv; /* used for NET_RCV */ + struct net_pkt_rcv rcv; /* used for NET_RCV */ struct net_pkt_enbdis enbdis; /* used for NET_RCV_ENBDIS, */ - /* NET_RCV_ENBDIS_ACK, */ - /* NET_RCV_PROMSIC, */ - /* and NET_CONNECT_STATUS */ + /* NET_RCV_ENBDIS_ACK, */ + /* NET_RCV_PROMSIC, */ + /* and NET_CONNECT_STATUS */ struct net_pkt_macaddr macaddr; }; }; @@ -446,24 +447,27 @@ struct uiscmdrsp_scsitaskmgmt { void *scsicmd; /* This is some handle that the guest has saved off for its own use. - * Its value is preserved by iopart & returned as is in the task mgmt - * rsp. */ + * Its value is preserved by iopart & returned as is in the task + * mgmt rsp. + */ void *notify; - /* For linux guests, this is a pointer to wait_queue_head that a + /* For linux guests, this is a pointer to wait_queue_head that a * thread is waiting on to see if the taskmgmt command has completed. * For windows guests, this is a pointer to a location that a waiting * thread is testing to see if the taskmgmt command has completed. * When the rsp is received by guest, the thread receiving the * response uses this to notify the thread waiting for taskmgmt * command completion. Its value is preserved by iopart & returned - * as is in the task mgmt rsp. */ + * as is in the task mgmt rsp. + */ void *notifyresult; /* this is a handle to location in guest where the result of the - * taskmgmt command (result field) is to saved off when the response - * is handled. Its value is preserved by iopart & returned as is in - * the task mgmt rsp. */ + * taskmgmt command (result field) is to saved off when the response + * is handled. Its value is preserved by iopart & returned as is in + * the task mgmt rsp. + */ char result; /* result of taskmgmt command - set by IOPart - values are: */ @@ -474,14 +478,14 @@ struct uiscmdrsp_scsitaskmgmt { * Guest */ /* Note that the vHba pointer is not used by the Client/Guest side. */ struct uiscmdrsp_disknotify { - u8 add; /* 0-remove, 1-add */ + u8 add; /* 0-remove, 1-add */ void *v_hba; /* Pointer to vhba_info for channel info to * route msg */ u32 channel, id, lun; /* SCSI Path of Disk to added or removed */ }; /* The following is used by virthba/vSCSI to send the Acquire/Release commands -* to the IOVM. */ + * to the IOVM. */ struct uiscmdrsp_vdiskmgmt { enum vdisk_mgmt_types vdisktype; @@ -492,24 +496,27 @@ struct uiscmdrsp_vdiskmgmt { void *scsicmd; /* This is some handle that the guest has saved off for its own use. - * Its value is preserved by iopart & returned as is in the task mgmt - * rsp. */ + * Its value is preserved by iopart & returned as is in the task + * mgmt rsp. + */ void *notify; /* For linux guests, this is a pointer to wait_queue_head that a - * thread is waiting on to see if the taskmgmt command has completed. - * For windows guests, this is a pointer to a location that a waiting - * thread is testing to see if the taskmgmt command has completed. - * When the rsp is received by guest, the thread receiving the - * response uses this to notify the thread waiting for taskmgmt - * command completion. Its value is preserved by iopart & returned - * as is in the task mgmt rsp. */ + * thread is waiting on to see if the tskmgmt command has completed. + * For win32 guests, this is a pointer to a location that a waiting + * thread is testing to see if the taskmgmt command has completed. + * When the rsp is received by guest, the thread receiving the + * response uses this to notify the thread waiting for taskmgmt + * command completion. Its value is preserved by iopart & returned + * as is in the task mgmt rsp. + */ void *notifyresult; /* this is a handle to location in guest where the result of the - * taskmgmt command (result field) is to saved off when the response - * is handled. Its value is preserved by iopart & returned as is in - * the task mgmt rsp. */ + * taskmgmt command (result field) is to saved off when the response + * is handled. Its value is preserved by iopart & returned as is in + * the task mgmt rsp. + */ char result; /* result of taskmgmt command - set by IOPart - values are: */ @@ -520,7 +527,7 @@ struct uiscmdrsp_vdiskmgmt { struct uiscmdrsp { char cmdtype; - /* describes what type of information is in the struct */ +/* describes what type of information is in the struct */ #define CMD_SCSI_TYPE 1 #define CMD_NET_TYPE 2 #define CMD_SCSITASKMGMT_TYPE 3 @@ -534,30 +541,31 @@ struct uiscmdrsp { struct uiscmdrsp_vdiskmgmt vdiskmgmt; }; void *private_data; /* used to send the response when the cmd is - * done (scsi & scsittaskmgmt). */ + * done (scsi & scsittaskmgmt). */ struct uiscmdrsp *next; /* General Purpose Queue Link */ struct uiscmdrsp *activeQ_next; /* Used to track active commands */ - struct uiscmdrsp *activeQ_prev; /* Used to track active commands */ + struct uiscmdrsp *activeQ_prev; /* Used to track active commands */ }; /* This is just the header of the IO channel. It is assumed that directly after -* this header there is a large region of memory which contains the command and -* response queues as specified in cmd_q and rsp_q SIGNAL_QUEUE_HEADERS. */ + * this header there is a large region of memory which contains the command and + * response queues as specified in cmd_q and rsp_q SIGNAL_QUEUE_HEADERS. + */ struct spar_io_channel_protocol { struct channel_header channel_header; struct signal_queue_header cmd_q; struct signal_queue_header rsp_q; union { struct { - struct vhba_wwnn wwnn; /* 8 bytes */ + struct vhba_wwnn wwnn; /* 8 bytes */ struct vhba_config_max max; /* 20 bytes */ - } vhba; /* 28 */ + } vhba; /* total = 28 bytes */ struct { u8 macaddr[MAX_MACADDR_LEN]; /* 6 bytes */ - u32 num_rcv_bufs; /* 4 */ - u32 mtu; /* 4 */ - uuid_le zone_uuid; /* 16 */ - } vnic; /* total 30 */ + u32 num_rcv_bufs; /* 4 bytes */ + u32 mtu; /* 4 bytes */ + uuid_le zone_uuid; /* 16 bytes */ + } vnic; /* total = 30 bytes */ }; #define MAX_CLIENTSTRING_LEN 1024 @@ -569,8 +577,8 @@ struct spar_io_channel_protocol { /* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */ /* -* INLINE functions for initializing and accessing I/O data channels -*/ + * INLINE functions for initializing and accessing I/O data channels + */ #define SIZEOF_PROTOCOL (COVER(sizeof(struct spar_io_channel_protocol), 64)) #define SIZEOF_CMDRSP (COVER(sizeof(struct uiscmdrsp), 64)) @@ -579,9 +587,9 @@ struct spar_io_channel_protocol { 2 * MIN_NUMSIGNALS * SIZEOF_CMDRSP, 4096) /* -* INLINE function for expanding a guest's pfn-off-size into multiple 4K page -* pfn-off-size entires. -*/ + * INLINE function for expanding a guest's pfn-off-size into multiple 4K page + * pfn-off-size entires. + */ /* we deal with 4K page sizes when we it comes to passing page information * between */ From 330782577e8c5c977aab1173088a59d3b19c4fce Mon Sep 17 00:00:00 2001 From: David Kershner Date: Tue, 5 May 2015 18:36:48 -0400 Subject: [PATCH 0273/1163] staging: unisys: get rid of serialloopbacktest serialloopbacktest is no longer supported. Get rid of it. Signed-off-by: David Kershner Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorbus_main.c | 7 ------- drivers/staging/unisys/visorbus/visorchipset.c | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 3fcd5fb2cb24..b00782d21b07 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -35,7 +35,6 @@ int visorbus_forcenomatch; #define MAXDEVICETEST 4 int visorbus_devicetest; int visorbus_debugref; -int visorbus_serialloopbacktest; #define SERIALLOOPBACKCHANADDR (100 * 1024 * 1024) /** This is the private data that we store for each bus device instance. @@ -2131,12 +2130,6 @@ module_param_named(debugref, visorbus_debugref, int, S_IRUGO); MODULE_PARM_DESC(visorbus_debugref, "1 to debug reference counting"); int visorbus_debugref = 0; -module_param_named(serialloopbacktest, visorbus_serialloopbacktest, - int, S_IRUGO); -MODULE_PARM_DESC(visorbus_serialloopbacktest, - "non-0 to just create 2 serial devices on the same channel"); -int visorbus_serialloopbacktest = 0; - MODULE_AUTHOR("Unisys"); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Supervisor bus driver for service partition: ver " VERSION); diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 3a1ee2d21a9f..d93ac151f3ae 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -2642,7 +2642,7 @@ visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel) static int __init visorchipset_init(void) { - int rc = 0, x = 0; + int rc = 0; HOSTADDRESS addr; if (!unisys_spar_platform) From aefebaa5bc6a22674adda07e001c5c8204ee608f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:49 -0400 Subject: [PATCH 0274/1163] staging: unisys: Eliminate visor_memregion_create() Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorchannel.c | 17 +++++++++----- drivers/staging/unisys/visorutil/memregion.h | 2 -- .../unisys/visorutil/memregion_direct.c | 22 ------------------- 3 files changed, 11 insertions(+), 30 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index 150e3df89001..f278739514f7 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -57,9 +57,8 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes, struct visorchannel *channel; int err; size_t size = sizeof(struct channel_header); - struct memregion *memregion; - channel = kmalloc(sizeof(*channel), GFP_KERNEL|__GFP_NORETRY); + channel = kzalloc(sizeof(*channel), GFP_KERNEL|__GFP_NORETRY); if (!channel) goto cleanup; @@ -67,12 +66,18 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes, spin_lock_init(&channel->insert_lock); spin_lock_init(&channel->remove_lock); - /* prepare chan_hdr (abstraction to read/write channel memory) */ - memregion = visor_memregion_create(&channel->memregion, physaddr, size); - - if (!memregion) + if (!request_mem_region(physaddr, size, MYDRVNAME)) goto cleanup; + channel->memregion.mapped = ioremap_cache(physaddr, size); + if (!channel->memregion.mapped) { + release_mem_region(physaddr, size); + goto cleanup; + } + + channel->memregion.physaddr = physaddr; + channel->memregion.nbytes = size; + err = visor_memregion_read(&channel->memregion, 0, &channel->chan_hdr, sizeof(struct channel_header)); if (err) diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h index 3826fe6c2446..cb3dbc50cd8e 100644 --- a/drivers/staging/unisys/visorutil/memregion.h +++ b/drivers/staging/unisys/visorutil/memregion.h @@ -29,8 +29,6 @@ struct memregion { void __iomem *mapped; }; -struct memregion *visor_memregion_create(struct memregion *memregion, - HOSTADDRESS physaddr, ulong nbytes); int visor_memregion_resize(struct memregion *memregion, ulong newsize); int visor_memregion_read(struct memregion *memregion, ulong offset, void *dest, ulong nbytes); diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index a575ecc5c3d7..0c7bed010c84 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -28,28 +28,6 @@ static int mapit(struct memregion *memregion); static void unmapit(struct memregion *memregion); -struct memregion * -visor_memregion_create(struct memregion *memregion, - HOSTADDRESS physaddr, ulong nbytes) -{ - struct memregion *rc = NULL; - - memregion->physaddr = physaddr; - memregion->nbytes = nbytes; - if (mapit(memregion)) { - rc = NULL; - goto cleanup; - } - rc = memregion; -cleanup: - if (rc == NULL) { - visor_memregion_destroy(memregion); - memregion = NULL; - } - return rc; -} -EXPORT_SYMBOL_GPL(visor_memregion_create); - static int mapit(struct memregion *memregion) { From 0dbb3fb66b9e9c81866e89961fa418d6ae135ea6 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:50 -0400 Subject: [PATCH 0275/1163] staging: unisys: memregion: Eliminate visor_memregion_destroy() Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchannel.c | 6 +++++- drivers/staging/unisys/visorutil/memregion.h | 1 - drivers/staging/unisys/visorutil/memregion_direct.c | 9 --------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index f278739514f7..42fabeafc01e 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -124,7 +124,11 @@ visorchannel_destroy(struct visorchannel *channel) { if (!channel) return; - visor_memregion_destroy(&channel->memregion); + if (channel->memregion.mapped) { + iounmap(channel->memregion.mapped); + release_mem_region(channel->memregion.physaddr, + channel->memregion.nbytes); + } kfree(channel); } EXPORT_SYMBOL_GPL(visorchannel_destroy); diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h index cb3dbc50cd8e..60d0dc9f07bc 100644 --- a/drivers/staging/unisys/visorutil/memregion.h +++ b/drivers/staging/unisys/visorutil/memregion.h @@ -34,7 +34,6 @@ int visor_memregion_read(struct memregion *memregion, ulong offset, void *dest, ulong nbytes); int visor_memregion_write(struct memregion *memregion, ulong offset, void *src, ulong nbytes); -void visor_memregion_destroy(struct memregion *memregion); HOSTADDRESS visor_memregion_get_physaddr(struct memregion *memregion); ulong visor_memregion_get_nbytes(struct memregion *memregion); void memregion_dump(struct memregion *memregion, char *s, diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index 0c7bed010c84..79ef4c5c686b 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -115,12 +115,3 @@ visor_memregion_write(struct memregion *memregion, ulong offset, void *src, return 0; } EXPORT_SYMBOL_GPL(visor_memregion_write); - -void -visor_memregion_destroy(struct memregion *memregion) -{ - if (!memregion) - return; - unmapit(memregion); -} -EXPORT_SYMBOL_GPL(visor_memregion_destroy); From 81b6032f46ee55af6b786065faf0f35f9c756b97 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:51 -0400 Subject: [PATCH 0276/1163] staging: unisys: memregion: Eliminate visor_memregion_resize() Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchannel.c | 17 +++++++++++++++-- drivers/staging/unisys/visorutil/memregion.h | 1 - .../staging/unisys/visorutil/memregion_direct.c | 16 ---------------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index 42fabeafc01e..cfbb19f78139 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -89,10 +89,23 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes, if (uuid_le_cmp(guid, NULL_UUID_LE) == 0) guid = channel->chan_hdr.chtype; - err = visor_memregion_resize(&channel->memregion, channel_bytes); - if (err) + iounmap(channel->memregion.mapped); + release_mem_region(channel->memregion.physaddr, + channel->memregion.nbytes); + channel->memregion.mapped = NULL; + if (!request_mem_region(channel->memregion.physaddr, channel_bytes, + MYDRVNAME)) goto cleanup; + channel->memregion.mapped = ioremap_cache(channel->memregion.physaddr, + channel_bytes); + if (!channel->memregion.mapped) { + release_mem_region(channel->memregion.physaddr, channel_bytes); + goto cleanup; + } + + channel->memregion.nbytes = channel_bytes; + channel->size = channel_bytes; channel->guid = guid; return channel; diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h index 60d0dc9f07bc..57d617f90129 100644 --- a/drivers/staging/unisys/visorutil/memregion.h +++ b/drivers/staging/unisys/visorutil/memregion.h @@ -29,7 +29,6 @@ struct memregion { void __iomem *mapped; }; -int visor_memregion_resize(struct memregion *memregion, ulong newsize); int visor_memregion_read(struct memregion *memregion, ulong offset, void *dest, ulong nbytes); int visor_memregion_write(struct memregion *memregion, diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index 79ef4c5c686b..fa7a4060c20c 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -76,22 +76,6 @@ visor_memregion_get_pointer(struct memregion *memregion) } EXPORT_SYMBOL_GPL(visor_memregion_get_pointer); -int -visor_memregion_resize(struct memregion *memregion, ulong newsize) -{ - int rc; - - if (newsize == memregion->nbytes) - return 0; - - unmapit(memregion); - memregion->nbytes = newsize; - rc = mapit(memregion); - - return rc; -} -EXPORT_SYMBOL_GPL(visor_memregion_resize); - int visor_memregion_read(struct memregion *memregion, ulong offset, void *dest, ulong nbytes) From 6fa981b4cca312cab0df77c59ed1269b3333b36a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:52 -0400 Subject: [PATCH 0277/1163] staging: unisys: memregion: Eliminate visor_memregion_get_*() functions Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorchannel.c | 7 +++---- drivers/staging/unisys/visorutil/memregion.h | 3 --- .../unisys/visorutil/memregion_direct.c | 21 ------------------- 3 files changed, 3 insertions(+), 28 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index cfbb19f78139..bf2f17ac8e97 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -149,7 +149,7 @@ EXPORT_SYMBOL_GPL(visorchannel_destroy); HOSTADDRESS visorchannel_get_physaddr(struct visorchannel *channel) { - return visor_memregion_get_physaddr(&channel->memregion); + return channel->memregion.physaddr; } EXPORT_SYMBOL_GPL(visorchannel_get_physaddr); @@ -501,7 +501,6 @@ visorchannel_debug(struct visorchannel *channel, int num_queues, { HOSTADDRESS addr = 0; ulong nbytes = 0, nbytes_region = 0; - struct memregion *memregion = NULL; struct channel_header hdr; struct channel_header *phdr = &hdr; int i = 0; @@ -510,8 +509,8 @@ visorchannel_debug(struct visorchannel *channel, int num_queues, if (!channel) return; - addr = visor_memregion_get_physaddr(memregion); - nbytes_region = visor_memregion_get_nbytes(memregion); + addr = visorchannel_get_physaddr(channel); + nbytes_region = visorchannel_get_nbytes(channel); errcode = visorchannel_read(channel, off, phdr, sizeof(struct channel_header)); if (errcode < 0) { diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h index 57d617f90129..68939371f2ba 100644 --- a/drivers/staging/unisys/visorutil/memregion.h +++ b/drivers/staging/unisys/visorutil/memregion.h @@ -33,10 +33,7 @@ int visor_memregion_read(struct memregion *memregion, ulong offset, void *dest, ulong nbytes); int visor_memregion_write(struct memregion *memregion, ulong offset, void *src, ulong nbytes); -HOSTADDRESS visor_memregion_get_physaddr(struct memregion *memregion); -ulong visor_memregion_get_nbytes(struct memregion *memregion); void memregion_dump(struct memregion *memregion, char *s, ulong off, ulong len, struct seq_file *seq); -void __iomem *visor_memregion_get_pointer(struct memregion *memregion); #endif diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index fa7a4060c20c..238e62f68204 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -55,27 +55,6 @@ unmapit(struct memregion *memregion) } } -HOSTADDRESS -visor_memregion_get_physaddr(struct memregion *memregion) -{ - return memregion->physaddr; -} -EXPORT_SYMBOL_GPL(visor_memregion_get_physaddr); - -ulong -visor_memregion_get_nbytes(struct memregion *memregion) -{ - return memregion->nbytes; -} -EXPORT_SYMBOL_GPL(visor_memregion_get_nbytes); - -void __iomem * -visor_memregion_get_pointer(struct memregion *memregion) -{ - return memregion->mapped; -} -EXPORT_SYMBOL_GPL(visor_memregion_get_pointer); - int visor_memregion_read(struct memregion *memregion, ulong offset, void *dest, ulong nbytes) From d24c3f07a6bae3b368681d25aa4eef380aa2e8f0 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:53 -0400 Subject: [PATCH 0278/1163] staging: unisys: memregion: {un, }mapit() are no longer used Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/visorutil/memregion_direct.c | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index 238e62f68204..82fb263c6747 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -25,36 +25,6 @@ #define MYDRVNAME "memregion" -static int mapit(struct memregion *memregion); -static void unmapit(struct memregion *memregion); - -static int -mapit(struct memregion *memregion) -{ - ulong physaddr = (ulong)(memregion->physaddr); - ulong nbytes = memregion->nbytes; - - if (!request_mem_region(physaddr, nbytes, MYDRVNAME)) - return -EBUSY; - - memregion->mapped = ioremap_cache(physaddr, nbytes); - if (!memregion->mapped) - return -EFAULT; - - return 0; -} - -static void -unmapit(struct memregion *memregion) -{ - if (memregion->mapped) { - iounmap(memregion->mapped); - memregion->mapped = NULL; - release_mem_region((unsigned long)memregion->physaddr, - memregion->nbytes); - } -} - int visor_memregion_read(struct memregion *memregion, ulong offset, void *dest, ulong nbytes) From ad44088f08a33894ca9fd65511d05d58434b50f4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:54 -0400 Subject: [PATCH 0279/1163] staging: unisys: visorchannel_write(): Use memcpy_toio() directly Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchannel.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index bf2f17ac8e97..bf75aa075b74 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -216,10 +216,15 @@ visorchannel_write(struct visorchannel *channel, ulong offset, { size_t size = sizeof(struct channel_header); + if (offset + nbytes > channel->memregion.nbytes) + return -EIO; + if (!offset && nbytes >= size) memcpy(&channel->chan_hdr, local, size); - return visor_memregion_write(&channel->memregion, - offset, local, nbytes); + + memcpy_toio(channel->memregion.mapped + offset, local, nbytes); + + return 0; } EXPORT_SYMBOL_GPL(visorchannel_write); From 36203e71a0604baa547a6706b5e70ee2830a2407 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:55 -0400 Subject: [PATCH 0280/1163] staging: unisys: visorchannel_read(): Use memcpy_fromio() directly Note, this changes the behavior of visorchannel_read(). The old code would return the channel header, if the offset argument was 0, and the caller tried to read beyond the size of the visorchannel. Note this only worked for offset == 0, but not for (offset > 0) && (offset < header_size), which was inconsistent. The new implementation returns an error if someone tries to read beyond the visorchannel size. Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchannel.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index bf75aa075b74..cae62fedab79 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -200,13 +200,12 @@ int visorchannel_read(struct visorchannel *channel, ulong offset, void *local, ulong nbytes) { - int rc; - size_t size = sizeof(struct channel_header); + if (offset + nbytes > channel->memregion.nbytes) + return -EIO; - rc = visor_memregion_read(&channel->memregion, offset, local, nbytes); - if (rc && !offset && (nbytes >= size)) - memcpy(&channel->chan_hdr, local, size); - return rc; + memcpy_fromio(local, channel->memregion.mapped + offset, nbytes); + + return 0; } EXPORT_SYMBOL_GPL(visorchannel_read); From 0abb60c1c5c32be56e5a67fcc437fcd18e38c2b2 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:56 -0400 Subject: [PATCH 0281/1163] staging: unisys: visorchannel_write(): Handle partial channel_header writes Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchannel.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index cae62fedab79..da7bd9c362f7 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -213,13 +213,16 @@ int visorchannel_write(struct visorchannel *channel, ulong offset, void *local, ulong nbytes) { - size_t size = sizeof(struct channel_header); + size_t chdr_size = sizeof(struct channel_header); + size_t copy_size; if (offset + nbytes > channel->memregion.nbytes) return -EIO; - if (!offset && nbytes >= size) - memcpy(&channel->chan_hdr, local, size); + if (offset < chdr_size) { + copy_size = min(chdr_size, nbytes) - offset; + memcpy(&channel->chan_hdr + offset, local, copy_size); + } memcpy_toio(channel->memregion.mapped + offset, local, nbytes); From 0d622e84f8063d4aab75a3d4e4de72efcb85dacb Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:57 -0400 Subject: [PATCH 0282/1163] staging: unisys: visorchannel_create_guts(): Use visorchannel_read() There is no benefit to calling visor_memregion_read() at this point. Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchannel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index da7bd9c362f7..6d7ea8bf435d 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -78,8 +78,8 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes, channel->memregion.physaddr = physaddr; channel->memregion.nbytes = size; - err = visor_memregion_read(&channel->memregion, 0, &channel->chan_hdr, - sizeof(struct channel_header)); + err = visorchannel_read(channel, 0, &channel->chan_hdr, + sizeof(struct channel_header)); if (err) goto cleanup; From 3b5bd6cca5b5d26cea73bfa2f078498a7f64957e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:58 -0400 Subject: [PATCH 0283/1163] staging: unisys: Eliminate visor_memregion_read() Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchannel.c | 11 +++++------ drivers/staging/unisys/visorutil/memregion.h | 2 -- drivers/staging/unisys/visorutil/memregion_direct.c | 12 ------------ 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index 6d7ea8bf435d..549128d29892 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -307,9 +307,9 @@ sig_read_header(struct visorchannel *channel, u32 queue, return FALSE; /* Read the appropriate SIGNAL_QUEUE_HEADER into local memory. */ - err = visor_memregion_read(&channel->memregion, - SIG_QUEUE_OFFSET(&channel->chan_hdr, queue), - sig_hdr, sizeof(struct signal_queue_header)); + err = visorchannel_read(channel, + SIG_QUEUE_OFFSET(&channel->chan_hdr, queue), + sig_hdr, sizeof(struct signal_queue_header)); if (err) return FALSE; @@ -324,9 +324,8 @@ sig_read_data(struct visorchannel *channel, u32 queue, int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue, sig_hdr, slot); - err = visor_memregion_read(&channel->memregion, - signal_data_offset, - data, sig_hdr->signal_size); + err = visorchannel_read(channel, signal_data_offset, + data, sig_hdr->signal_size); if (err) return FALSE; diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h index 68939371f2ba..4122b48f6707 100644 --- a/drivers/staging/unisys/visorutil/memregion.h +++ b/drivers/staging/unisys/visorutil/memregion.h @@ -29,8 +29,6 @@ struct memregion { void __iomem *mapped; }; -int visor_memregion_read(struct memregion *memregion, - ulong offset, void *dest, ulong nbytes); int visor_memregion_write(struct memregion *memregion, ulong offset, void *src, ulong nbytes); void memregion_dump(struct memregion *memregion, char *s, diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index 82fb263c6747..17b1033a8826 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -25,18 +25,6 @@ #define MYDRVNAME "memregion" -int -visor_memregion_read(struct memregion *memregion, ulong offset, void *dest, - ulong nbytes) -{ - if (offset + nbytes > memregion->nbytes) - return -EIO; - - memcpy_fromio(dest, memregion->mapped + offset, nbytes); - return 0; -} -EXPORT_SYMBOL_GPL(visor_memregion_read); - int visor_memregion_write(struct memregion *memregion, ulong offset, void *src, ulong nbytes) From 34b479ae19f318a74eae87bd8f4b96acb0d7a6ac Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:36:59 -0400 Subject: [PATCH 0284/1163] staging: unisys: Eliminate visor_memregion_write() visorchannel's signal code should call visorchannel_write() directly. This is more consistent and cleaner, and allows us to remove the last memregion call. Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorchannel.c | 34 +++++++++---------- drivers/staging/unisys/visorutil/memregion.h | 2 -- .../unisys/visorutil/memregion_direct.c | 12 ------- 3 files changed, 16 insertions(+), 32 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index 549128d29892..564d32521a4b 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -250,8 +250,8 @@ visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch, if (nbytes < thisbytes) thisbytes = nbytes; - err = visor_memregion_write(&channel->memregion, - offset + written, buf, thisbytes); + err = visorchannel_write(channel, offset + written, + buf, thisbytes); if (err) goto cleanup; @@ -290,12 +290,12 @@ EXPORT_SYMBOL_GPL(visorchannel_get_header); /** Write the contents of a specific field within a SIGNAL_QUEUE_HEADER back * into host memory */ -#define SIG_WRITE_FIELD(channel, queue, sig_hdr, FIELD) \ - (visor_memregion_write(&channel->memregion, \ - SIG_QUEUE_OFFSET(&channel->chan_hdr, queue)+ \ - offsetof(struct signal_queue_header, FIELD),\ - &((sig_hdr)->FIELD), \ - sizeof((sig_hdr)->FIELD)) >= 0) +#define SIG_WRITE_FIELD(channel, queue, sig_hdr, FIELD) \ + (visorchannel_write(channel, \ + SIG_QUEUE_OFFSET(&channel->chan_hdr, queue)+ \ + offsetof(struct signal_queue_header, FIELD), \ + &((sig_hdr)->FIELD), \ + sizeof((sig_hdr)->FIELD)) >= 0) static BOOL sig_read_header(struct visorchannel *channel, u32 queue, @@ -340,9 +340,8 @@ sig_write_data(struct visorchannel *channel, u32 queue, int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue, sig_hdr, slot); - err = visor_memregion_write(&channel->memregion, - signal_data_offset, - data, sig_hdr->signal_size); + err = visorchannel_write(channel, signal_data_offset, + data, sig_hdr->signal_size); if (err) return FALSE; @@ -403,13 +402,12 @@ signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg) sig_hdr.head = ((sig_hdr.head + 1) % sig_hdr.max_slots); if (sig_hdr.head == sig_hdr.tail) { sig_hdr.num_overflows++; - visor_memregion_write(&channel->memregion, - SIG_QUEUE_OFFSET(&channel->chan_hdr, - queue) + - offsetof(struct signal_queue_header, - num_overflows), - &(sig_hdr.num_overflows), - sizeof(sig_hdr.num_overflows)); + visorchannel_write(channel, + SIG_QUEUE_OFFSET(&channel->chan_hdr, queue) + + offsetof(struct signal_queue_header, + num_overflows), + &(sig_hdr.num_overflows), + sizeof(sig_hdr.num_overflows)); return FALSE; } diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h index 4122b48f6707..62036cd6153d 100644 --- a/drivers/staging/unisys/visorutil/memregion.h +++ b/drivers/staging/unisys/visorutil/memregion.h @@ -29,8 +29,6 @@ struct memregion { void __iomem *mapped; }; -int visor_memregion_write(struct memregion *memregion, - ulong offset, void *src, ulong nbytes); void memregion_dump(struct memregion *memregion, char *s, ulong off, ulong len, struct seq_file *seq); diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index 17b1033a8826..818f6a8b54c5 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -24,15 +24,3 @@ #include "memregion.h" #define MYDRVNAME "memregion" - -int -visor_memregion_write(struct memregion *memregion, ulong offset, void *src, - ulong nbytes) -{ - if (offset + nbytes > memregion->nbytes) - return -EIO; - - memcpy_toio(memregion->mapped + offset, src, nbytes); - return 0; -} -EXPORT_SYMBOL_GPL(visor_memregion_write); From 434cbf28b5bc1e2694e6c097dba6f111fd61cafb Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:37:00 -0400 Subject: [PATCH 0285/1163] staging: unisys: Finally remove the last remnants of memregion Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/visorbus.h | 1 - .../staging/unisys/visorbus/visorchannel.c | 53 +++++++++---------- drivers/staging/unisys/visorchannel/globals.h | 1 - drivers/staging/unisys/visorutil/Makefile | 2 +- drivers/staging/unisys/visorutil/memregion.h | 35 ------------ .../unisys/visorutil/memregion_direct.c | 26 --------- 6 files changed, 25 insertions(+), 93 deletions(-) delete mode 100644 drivers/staging/unisys/visorutil/memregion.h delete mode 100644 drivers/staging/unisys/visorutil/memregion_direct.c diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h index e1c666234b1f..87ffff4657fe 100644 --- a/drivers/staging/unisys/include/visorbus.h +++ b/drivers/staging/unisys/include/visorbus.h @@ -36,7 +36,6 @@ #include "periodic_work.h" #include "channel.h" -#include "memregion.h" #ifndef HOSTADDRESS #define HOSTADDRESS u64 diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index 564d32521a4b..ed652a08e4e1 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -17,12 +17,9 @@ /* * This provides Supervisor channel communication primitives, which are - * independent of the mechanism used to access the channel data. All channel - * data is accessed using the memregion abstraction. (memregion has both - * a CM2 implementation and a direct memory implementation.) + * independent of the mechanism used to access the channel data. */ -#include "memregion.h" #include "version.h" #include "visorbus.h" #include @@ -30,7 +27,9 @@ #define MYDRVNAME "visorchannel" struct visorchannel { - struct memregion memregion; /* from visor_memregion_create() */ + HOSTADDRESS physaddr; + ulong nbytes; + void __iomem *mapped; struct channel_header chan_hdr; uuid_le guid; ulong size; @@ -69,14 +68,14 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes, if (!request_mem_region(physaddr, size, MYDRVNAME)) goto cleanup; - channel->memregion.mapped = ioremap_cache(physaddr, size); - if (!channel->memregion.mapped) { + channel->mapped = ioremap_cache(physaddr, size); + if (!channel->mapped) { release_mem_region(physaddr, size); goto cleanup; } - channel->memregion.physaddr = physaddr; - channel->memregion.nbytes = size; + channel->physaddr = physaddr; + channel->nbytes = size; err = visorchannel_read(channel, 0, &channel->chan_hdr, sizeof(struct channel_header)); @@ -89,22 +88,19 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes, if (uuid_le_cmp(guid, NULL_UUID_LE) == 0) guid = channel->chan_hdr.chtype; - iounmap(channel->memregion.mapped); - release_mem_region(channel->memregion.physaddr, - channel->memregion.nbytes); - channel->memregion.mapped = NULL; - if (!request_mem_region(channel->memregion.physaddr, channel_bytes, - MYDRVNAME)) + iounmap(channel->mapped); + release_mem_region(channel->physaddr, channel->nbytes); + channel->mapped = NULL; + if (!request_mem_region(channel->physaddr, channel_bytes, MYDRVNAME)) goto cleanup; - channel->memregion.mapped = ioremap_cache(channel->memregion.physaddr, - channel_bytes); - if (!channel->memregion.mapped) { - release_mem_region(channel->memregion.physaddr, channel_bytes); + channel->mapped = ioremap_cache(channel->physaddr, channel_bytes); + if (!channel->mapped) { + release_mem_region(channel->physaddr, channel_bytes); goto cleanup; } - channel->memregion.nbytes = channel_bytes; + channel->nbytes = channel_bytes; channel->size = channel_bytes; channel->guid = guid; @@ -137,10 +133,9 @@ visorchannel_destroy(struct visorchannel *channel) { if (!channel) return; - if (channel->memregion.mapped) { - iounmap(channel->memregion.mapped); - release_mem_region(channel->memregion.physaddr, - channel->memregion.nbytes); + if (channel->mapped) { + iounmap(channel->mapped); + release_mem_region(channel->physaddr, channel->nbytes); } kfree(channel); } @@ -149,7 +144,7 @@ EXPORT_SYMBOL_GPL(visorchannel_destroy); HOSTADDRESS visorchannel_get_physaddr(struct visorchannel *channel) { - return channel->memregion.physaddr; + return channel->physaddr; } EXPORT_SYMBOL_GPL(visorchannel_get_physaddr); @@ -200,10 +195,10 @@ int visorchannel_read(struct visorchannel *channel, ulong offset, void *local, ulong nbytes) { - if (offset + nbytes > channel->memregion.nbytes) + if (offset + nbytes > channel->nbytes) return -EIO; - memcpy_fromio(local, channel->memregion.mapped + offset, nbytes); + memcpy_fromio(local, channel->mapped + offset, nbytes); return 0; } @@ -216,7 +211,7 @@ visorchannel_write(struct visorchannel *channel, ulong offset, size_t chdr_size = sizeof(struct channel_header); size_t copy_size; - if (offset + nbytes > channel->memregion.nbytes) + if (offset + nbytes > channel->nbytes) return -EIO; if (offset < chdr_size) { @@ -224,7 +219,7 @@ visorchannel_write(struct visorchannel *channel, ulong offset, memcpy(&channel->chan_hdr + offset, local, copy_size); } - memcpy_toio(channel->memregion.mapped + offset, local, nbytes); + memcpy_toio(channel->mapped + offset, local, nbytes); return 0; } diff --git a/drivers/staging/unisys/visorchannel/globals.h b/drivers/staging/unisys/visorchannel/globals.h index 0ed8e1d8033a..6530413958d4 100644 --- a/drivers/staging/unisys/visorchannel/globals.h +++ b/drivers/staging/unisys/visorchannel/globals.h @@ -19,7 +19,6 @@ #define __VISORCHANNEL_GLOBALS_H__ #include "timskmod.h" -#include "memregion.h" #include "version.h" #define MYDRVNAME "visorchannel" diff --git a/drivers/staging/unisys/visorutil/Makefile b/drivers/staging/unisys/visorutil/Makefile index d9ab5a36e3bf..f29978772ca3 100644 --- a/drivers/staging/unisys/visorutil/Makefile +++ b/drivers/staging/unisys/visorutil/Makefile @@ -4,6 +4,6 @@ obj-$(CONFIG_UNISYS_VISORUTIL) += visorutil.o -visorutil-y := charqueue.o periodic_work.o memregion_direct.o visorkmodutils.o +visorutil-y := charqueue.o periodic_work.o visorkmodutils.o ccflags-y += -Idrivers/staging/unisys/include diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h deleted file mode 100644 index 62036cd6153d..000000000000 --- a/drivers/staging/unisys/visorutil/memregion.h +++ /dev/null @@ -1,35 +0,0 @@ -/* memregion.h - * - * 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. - */ - -#ifndef __MEMREGION_H__ -#define __MEMREGION_H__ - -#include "timskmod.h" - -/* struct memregion is an opaque structure to users. - * Fields are declared only in the implementation .c files. - */ -struct memregion { - HOSTADDRESS physaddr; - ulong nbytes; - void __iomem *mapped; -}; - -void memregion_dump(struct memregion *memregion, char *s, - ulong off, ulong len, struct seq_file *seq); - -#endif diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c deleted file mode 100644 index 818f6a8b54c5..000000000000 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ /dev/null @@ -1,26 +0,0 @@ -/* memregion_direct.c - * - * 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. - */ - -/* - * This is an implementation of memory regions that can be used to read/write - * channel memory (in main memory of the host system) from code running in - * a virtual partition. - */ -#include "timskmod.h" -#include "memregion.h" - -#define MYDRVNAME "memregion" From 779d0752bc53aebb12a38eb2bcc696c5f12ad4d6 Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Tue, 5 May 2015 18:37:01 -0400 Subject: [PATCH 0286/1163] staging: unisys: remove BOOL,TRUE,FALSE definitions These shouldn't be defined in the code and can be replaced with the standard bool, true, and false usage that the kernel uses. Signed-off-by: Prarit Bhargava Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/include/periodic_work.h | 6 +- drivers/staging/unisys/include/timskmod.h | 5 -- drivers/staging/unisys/include/visorbus.h | 4 +- .../staging/unisys/visorbus/visorbus_main.c | 34 +++++----- .../staging/unisys/visorbus/visorchannel.c | 64 +++++++++---------- .../staging/unisys/visorbus/visorchipset.c | 2 +- drivers/staging/unisys/visorutil/charqueue.c | 4 +- drivers/staging/unisys/visorutil/charqueue.h | 2 +- .../staging/unisys/visorutil/periodic_work.c | 52 +++++++-------- .../staging/unisys/visorutil/visorkmodutils.c | 2 +- 10 files changed, 85 insertions(+), 90 deletions(-) diff --git a/drivers/staging/unisys/include/periodic_work.h b/drivers/staging/unisys/include/periodic_work.h index 26ec10bdfe65..21939db22bba 100644 --- a/drivers/staging/unisys/include/periodic_work.h +++ b/drivers/staging/unisys/include/periodic_work.h @@ -31,8 +31,8 @@ struct periodic_work *visor_periodic_work_create(ulong jiffy_interval, void *workfuncarg, const char *devnam); void visor_periodic_work_destroy(struct periodic_work *pw); -BOOL visor_periodic_work_nextperiod(struct periodic_work *pw); -BOOL visor_periodic_work_start(struct periodic_work *pw); -BOOL visor_periodic_work_stop(struct periodic_work *pw); +bool visor_periodic_work_nextperiod(struct periodic_work *pw); +bool visor_periodic_work_start(struct periodic_work *pw); +bool visor_periodic_work_stop(struct periodic_work *pw); #endif diff --git a/drivers/staging/unisys/include/timskmod.h b/drivers/staging/unisys/include/timskmod.h index cde2494ad896..2ee227559181 100644 --- a/drivers/staging/unisys/include/timskmod.h +++ b/drivers/staging/unisys/include/timskmod.h @@ -52,11 +52,6 @@ #include /* #define DEBUG */ -#ifndef BOOL -#define BOOL int -#endif -#define FALSE 0 -#define TRUE 1 #if !defined SUCCESS #define SUCCESS 0 #endif diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h index 87ffff4657fe..bce8aa255f74 100644 --- a/drivers/staging/unisys/include/visorbus.h +++ b/drivers/staging/unisys/include/visorbus.h @@ -182,9 +182,9 @@ int visorchannel_write(struct visorchannel *channel, ulong offset, void *local, ulong nbytes); int visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch, ulong nbytes); -BOOL visorchannel_signalremove(struct visorchannel *channel, u32 queue, +bool visorchannel_signalremove(struct visorchannel *channel, u32 queue, void *msg); -BOOL visorchannel_signalinsert(struct visorchannel *channel, u32 queue, +bool visorchannel_signalinsert(struct visorchannel *channel, u32 queue, void *msg); int visorchannel_signalqueue_slots_avail(struct visorchannel *channel, u32 queue); diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index b00782d21b07..f7976ca76f17 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -1076,7 +1076,7 @@ visordriver_probe_device(struct device *xdev) drv = to_visor_driver(xdev->driver); dev = to_visor_device(xdev); down(&dev->visordriver_callback_lock); - dev->being_removed = FALSE; + dev->being_removed = false; /* * ensure that the dev->being_removed flag is cleared before * we start the probe @@ -1106,7 +1106,7 @@ away: * initialized. */ if (!dev->responded_to_device_create) { - dev->responded_to_device_create = TRUE; + dev->responded_to_device_create = true; if (chipset_responders.device_create) (*chipset_responders.device_create)(dev->chipset_bus_no, dev->chipset_dev_no, @@ -1129,7 +1129,7 @@ visordriver_remove_device(struct device *xdev) dev = to_visor_device(xdev); drv = to_visor_driver(xdev->driver); down(&dev->visordriver_callback_lock); - dev->being_removed = TRUE; + dev->being_removed = true; /* * ensure that the dev->being_removed flag is set before we start the * actual removal @@ -1303,7 +1303,7 @@ create_visor_device(struct visorbus_devdata *devdata, int rc = -1; struct visorchannel *visorchannel = NULL; struct visor_device *dev = NULL; - bool gotten = FALSE, registered1 = FALSE, registered2 = FALSE; + bool gotten = false, registered1 = false, registered2 = false; POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, chipset_dev_no, chipset_bus_no, POSTCODE_SEVERITY_INFO); @@ -1337,7 +1337,7 @@ create_visor_device(struct visorbus_devdata *devdata, dev->device.release = visorbus_release_device; /* keep a reference just for us (now 2) */ get_device(&dev->device); - gotten = TRUE; + gotten = true; dev->periodic_work = visor_periodic_work_create(POLLJIFFIES_NORMALCHANNEL, periodic_dev_workqueue, @@ -1387,7 +1387,7 @@ create_visor_device(struct visorbus_devdata *devdata, goto away; } - registered1 = TRUE; + registered1 = true; rc = register_devmajorminor_attributes(dev); if (rc < 0) { @@ -1396,7 +1396,7 @@ create_visor_device(struct visorbus_devdata *devdata, goto away; } - registered2 = TRUE; + registered2 = true; rc = 0; away: @@ -1687,7 +1687,7 @@ create_bus_instance(int id) if (get_vbus_header_info(devdata->chan, &devdata-> vbus_hdr_info) >= 0) { - devdata->vbus_valid = TRUE; + devdata->vbus_valid = true; write_vbus_chp_info(devdata->chan, &devdata-> vbus_hdr_info, @@ -1775,7 +1775,7 @@ remove_all_visor_devices(void) } } -static bool entered_testing_mode = FALSE; +static bool entered_testing_mode; static struct visorchipset_channel_info test_channel_infos[MAXDEVICETEST]; static unsigned long test_bus_nos[MAXDEVICETEST]; static unsigned long test_dev_nos[MAXDEVICETEST]; @@ -1909,7 +1909,7 @@ pause_state_change_complete(struct visor_device *dev, int status) if (!dev->pausing) return; - dev->pausing = FALSE; + dev->pausing = false; if (!chipset_responders.device_pause) /* this can never happen! */ return; @@ -1930,7 +1930,7 @@ resume_state_change_complete(struct visor_device *dev, int status) if (!dev->resuming) return; - dev->resuming = FALSE; + dev->resuming = false; if (!chipset_responders.device_resume) /* this can never happen! */ return; @@ -1986,7 +1986,7 @@ initiate_chipset_device_pause_resume(u32 bus_no, u32 dev_no, bool is_pause) if (!drv->pause) goto away; - dev->pausing = TRUE; + dev->pausing = true; x = drv->pause(dev, pause_state_change_complete); } else { /* This should be done at BUS resume time, but an @@ -1998,14 +1998,14 @@ initiate_chipset_device_pause_resume(u32 bus_no, u32 dev_no, bool is_pause) if (!drv->resume) goto away; - dev->resuming = TRUE; + dev->resuming = true; x = drv->resume(dev, resume_state_change_complete); } if (x < 0) { if (is_pause) - dev->pausing = FALSE; + dev->pausing = false; else - dev->resuming = FALSE; + dev->resuming = false; goto away; } rc = 0; @@ -2019,13 +2019,13 @@ away: static void chipset_device_pause(u32 bus_no, u32 dev_no) { - initiate_chipset_device_pause_resume(bus_no, dev_no, TRUE); + initiate_chipset_device_pause_resume(bus_no, dev_no, true); } static void chipset_device_resume(u32 bus_no, u32 dev_no) { - initiate_chipset_device_pause_resume(bus_no, dev_no, FALSE); + initiate_chipset_device_pause_resume(bus_no, dev_no, false); } struct channel_size_info { diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index ed652a08e4e1..bf1e039df7af 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -33,7 +33,7 @@ struct visorchannel { struct channel_header chan_hdr; uuid_le guid; ulong size; - BOOL needs_lock; /* channel creator knows if more than one + bool needs_lock; /* channel creator knows if more than one * thread will be inserting or removing */ spinlock_t insert_lock; /* protect head writes in chan_hdr */ spinlock_t remove_lock; /* protect tail writes in chan_hdr */ @@ -51,7 +51,7 @@ struct visorchannel { */ static struct visorchannel * visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes, - ulong off, uuid_le guid, BOOL needs_lock) + ulong off, uuid_le guid, bool needs_lock) { struct visorchannel *channel; int err; @@ -115,7 +115,7 @@ struct visorchannel * visorchannel_create(HOSTADDRESS physaddr, ulong channel_bytes, uuid_le guid) { return visorchannel_create_guts(physaddr, channel_bytes, 0, guid, - FALSE); + false); } EXPORT_SYMBOL_GPL(visorchannel_create); @@ -124,7 +124,7 @@ visorchannel_create_with_lock(HOSTADDRESS physaddr, ulong channel_bytes, uuid_le guid) { return visorchannel_create_guts(physaddr, channel_bytes, 0, guid, - TRUE); + true); } EXPORT_SYMBOL_GPL(visorchannel_create_with_lock); @@ -292,26 +292,26 @@ EXPORT_SYMBOL_GPL(visorchannel_get_header); &((sig_hdr)->FIELD), \ sizeof((sig_hdr)->FIELD)) >= 0) -static BOOL +static bool sig_read_header(struct visorchannel *channel, u32 queue, struct signal_queue_header *sig_hdr) { int err; if (channel->chan_hdr.ch_space_offset < sizeof(struct channel_header)) - return FALSE; + return false; /* Read the appropriate SIGNAL_QUEUE_HEADER into local memory. */ err = visorchannel_read(channel, SIG_QUEUE_OFFSET(&channel->chan_hdr, queue), sig_hdr, sizeof(struct signal_queue_header)); if (err) - return FALSE; + return false; - return TRUE; + return true; } -static inline BOOL +static inline bool sig_read_data(struct visorchannel *channel, u32 queue, struct signal_queue_header *sig_hdr, u32 slot, void *data) { @@ -322,12 +322,12 @@ sig_read_data(struct visorchannel *channel, u32 queue, err = visorchannel_read(channel, signal_data_offset, data, sig_hdr->signal_size); if (err) - return FALSE; + return false; - return TRUE; + return true; } -static inline BOOL +static inline bool sig_write_data(struct visorchannel *channel, u32 queue, struct signal_queue_header *sig_hdr, u32 slot, void *data) { @@ -338,24 +338,24 @@ sig_write_data(struct visorchannel *channel, u32 queue, err = visorchannel_write(channel, signal_data_offset, data, sig_hdr->signal_size); if (err) - return FALSE; + return false; - return TRUE; + return true; } -static BOOL +static bool signalremove_inner(struct visorchannel *channel, u32 queue, void *msg) { struct signal_queue_header sig_hdr; if (!sig_read_header(channel, queue, &sig_hdr)) - return FALSE; + return false; if (sig_hdr.head == sig_hdr.tail) - return FALSE; /* no signals to remove */ + return false; /* no signals to remove */ sig_hdr.tail = (sig_hdr.tail + 1) % sig_hdr.max_slots; if (!sig_read_data(channel, queue, &sig_hdr, sig_hdr.tail, msg)) - return FALSE; + return false; sig_hdr.num_received++; /* For each data field in SIGNAL_QUEUE_HEADER that was modified, @@ -363,16 +363,16 @@ signalremove_inner(struct visorchannel *channel, u32 queue, void *msg) */ mb(); /* required for channel synch */ if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, tail)) - return FALSE; + return false; if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_received)) - return FALSE; - return TRUE; + return false; + return true; } -BOOL +bool visorchannel_signalremove(struct visorchannel *channel, u32 queue, void *msg) { - BOOL rc; + bool rc; if (channel->needs_lock) { spin_lock(&channel->remove_lock); @@ -386,13 +386,13 @@ visorchannel_signalremove(struct visorchannel *channel, u32 queue, void *msg) } EXPORT_SYMBOL_GPL(visorchannel_signalremove); -static BOOL +static bool signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg) { struct signal_queue_header sig_hdr; if (!sig_read_header(channel, queue, &sig_hdr)) - return FALSE; + return false; sig_hdr.head = ((sig_hdr.head + 1) % sig_hdr.max_slots); if (sig_hdr.head == sig_hdr.tail) { @@ -403,11 +403,11 @@ signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg) num_overflows), &(sig_hdr.num_overflows), sizeof(sig_hdr.num_overflows)); - return FALSE; + return false; } if (!sig_write_data(channel, queue, &sig_hdr, sig_hdr.head, msg)) - return FALSE; + return false; sig_hdr.num_sent++; @@ -416,17 +416,17 @@ signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg) */ mb(); /* required for channel synch */ if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, head)) - return FALSE; + return false; if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_sent)) - return FALSE; + return false; - return TRUE; + return true; } -BOOL +bool visorchannel_signalinsert(struct visorchannel *channel, u32 queue, void *msg) { - BOOL rc; + bool rc; if (channel->needs_lock) { spin_lock(&channel->insert_lock); diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index d93ac151f3ae..76923bf45de1 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -2045,7 +2045,7 @@ parahotplug_process_message(struct controlvm_message *inmsg) /* Process a controlvm message. * Return result: - * false - this function will return FALSE only in the case where the + * false - this function will return false only in the case where the * controlvm message was NOT processed, but processing must be * retried before reading the next controlvm message; a * scenario where this can occur is when we need to throttle diff --git a/drivers/staging/unisys/visorutil/charqueue.c b/drivers/staging/unisys/visorutil/charqueue.c index c91752a2d06b..f2227193ce0b 100644 --- a/drivers/staging/unisys/visorutil/charqueue.c +++ b/drivers/staging/unisys/visorutil/charqueue.c @@ -64,9 +64,9 @@ void visor_charqueue_enqueue(struct charqueue *charqueue, unsigned char c) } EXPORT_SYMBOL_GPL(visor_charqueue_enqueue); -BOOL visor_charqueue_is_empty(struct charqueue *charqueue) +bool visor_charqueue_is_empty(struct charqueue *charqueue) { - BOOL b; + bool b; spin_lock(&charqueue->lock); b = IS_EMPTY(charqueue); diff --git a/drivers/staging/unisys/visorutil/charqueue.h b/drivers/staging/unisys/visorutil/charqueue.h index f46a776b935b..70fe26b5ddfd 100644 --- a/drivers/staging/unisys/visorutil/charqueue.h +++ b/drivers/staging/unisys/visorutil/charqueue.h @@ -30,7 +30,7 @@ void visor_charqueue_enqueue(struct charqueue *charqueue, unsigned char c); int charqueue_dequeue(struct charqueue *charqueue); int visor_charqueue_dequeue_n(struct charqueue *charqueue, unsigned char *buf, int n); -BOOL visor_charqueue_is_empty(struct charqueue *charqueue); +bool visor_charqueue_is_empty(struct charqueue *charqueue); void visor_charqueue_destroy(struct charqueue *charqueue); #endif diff --git a/drivers/staging/unisys/visorutil/periodic_work.c b/drivers/staging/unisys/visorutil/periodic_work.c index abbfb48894f3..aa357a297f48 100644 --- a/drivers/staging/unisys/visorutil/periodic_work.c +++ b/drivers/staging/unisys/visorutil/periodic_work.c @@ -29,8 +29,8 @@ struct periodic_work { struct delayed_work work; void (*workfunc)(void *); void *workfuncarg; - BOOL is_scheduled; - BOOL want_to_stop; + bool is_scheduled; + bool want_to_stop; ulong jiffy_interval; struct workqueue_struct *workqueue; const char *devnam; @@ -74,64 +74,64 @@ EXPORT_SYMBOL_GPL(visor_periodic_work_destroy); /** Call this from your periodic work worker function to schedule the next * call. - * If this function returns FALSE, there was a failure and the + * If this function returns false, there was a failure and the * periodic work is no longer scheduled */ -BOOL visor_periodic_work_nextperiod(struct periodic_work *pw) +bool visor_periodic_work_nextperiod(struct periodic_work *pw) { - BOOL rc = FALSE; + bool rc = false; write_lock(&pw->lock); if (pw->want_to_stop) { - pw->is_scheduled = FALSE; - pw->want_to_stop = FALSE; - rc = TRUE; /* yes, TRUE; see visor_periodic_work_stop() */ + pw->is_scheduled = false; + pw->want_to_stop = false; + rc = true; /* yes, true; see visor_periodic_work_stop() */ goto unlock; } else if (queue_delayed_work(pw->workqueue, &pw->work, pw->jiffy_interval) < 0) { - pw->is_scheduled = FALSE; - rc = FALSE; + pw->is_scheduled = false; + rc = false; goto unlock; } - rc = TRUE; + rc = true; unlock: write_unlock(&pw->lock); return rc; } EXPORT_SYMBOL_GPL(visor_periodic_work_nextperiod); -/** This function returns TRUE iff new periodic work was actually started. - * If this function returns FALSE, then no work was started +/** This function returns true iff new periodic work was actually started. + * If this function returns false, then no work was started * (either because it was already started, or because of a failure). */ -BOOL visor_periodic_work_start(struct periodic_work *pw) +bool visor_periodic_work_start(struct periodic_work *pw) { - BOOL rc = FALSE; + bool rc = false; write_lock(&pw->lock); if (pw->is_scheduled) { - rc = FALSE; + rc = false; goto unlock; } if (pw->want_to_stop) { - rc = FALSE; + rc = false; goto unlock; } INIT_DELAYED_WORK(&pw->work, &periodic_work_func); if (queue_delayed_work(pw->workqueue, &pw->work, pw->jiffy_interval) < 0) { - rc = FALSE; + rc = false; goto unlock; } - pw->is_scheduled = TRUE; - rc = TRUE; + pw->is_scheduled = true; + rc = true; unlock: write_unlock(&pw->lock); return rc; } EXPORT_SYMBOL_GPL(visor_periodic_work_start); -/** This function returns TRUE iff your call actually stopped the periodic +/** This function returns true iff your call actually stopped the periodic * work. * * -- PAY ATTENTION... this is important -- @@ -165,20 +165,20 @@ EXPORT_SYMBOL_GPL(visor_periodic_work_start); * this deadlock, you will get hung up in an infinite loop saying * "waiting for delayed work...". */ -BOOL visor_periodic_work_stop(struct periodic_work *pw) +bool visor_periodic_work_stop(struct periodic_work *pw) { - BOOL stopped_something = FALSE; + bool stopped_something = false; write_lock(&pw->lock); stopped_something = pw->is_scheduled && (!pw->want_to_stop); while (pw->is_scheduled) { - pw->want_to_stop = TRUE; + pw->want_to_stop = true; if (cancel_delayed_work(&pw->work)) { /* We get here if the delayed work was pending as * delayed work, but was NOT run. */ WARN_ON(!pw->is_scheduled); - pw->is_scheduled = FALSE; + pw->is_scheduled = false; } else { /* If we get here, either the delayed work: * - was run, OR, @@ -195,7 +195,7 @@ BOOL visor_periodic_work_stop(struct periodic_work *pw) SLEEPJIFFIES(10); write_lock(&pw->lock); } else { - pw->want_to_stop = FALSE; + pw->want_to_stop = false; } } write_unlock(&pw->lock); diff --git a/drivers/staging/unisys/visorutil/visorkmodutils.c b/drivers/staging/unisys/visorutil/visorkmodutils.c index 62f0f7046e17..0b8f5c163400 100644 --- a/drivers/staging/unisys/visorutil/visorkmodutils.c +++ b/drivers/staging/unisys/visorutil/visorkmodutils.c @@ -53,7 +53,7 @@ static __init uint32_t visorutil_spar_detect(void) static __init int visorutil_mod_init(void) { if (visorutil_spar_detect()) { - unisys_spar_platform = TRUE; + unisys_spar_platform = true; return 0; } else { return -ENODEV; From 55c67dcaac7891887ad0a077c28b709be2abcb49 Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Tue, 5 May 2015 18:37:02 -0400 Subject: [PATCH 0287/1163] staging: unisys: add acpi pnp driver According to Unisys, another OS detects the PNP0A07 as the auto load device. We can also do this in the linux kernel by simply converting the driver over to the ACPI driver model. Notes: This changes the usage of __init and it had to be removed from some functions to avoid a !__init function calling an __init function. Additionally I also cleaned up the headers in visorchipset.c since I was adding a header file. Signed-off-by: Prarit Bhargava Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorbus_main.c | 2 +- .../unisys/visorbus/visorbus_private.h | 2 +- .../staging/unisys/visorbus/visorchipset.c | 77 ++++++++++++++----- 3 files changed, 58 insertions(+), 23 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index f7976ca76f17..b522ea4d2c2d 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -2034,7 +2034,7 @@ struct channel_size_info { unsigned long max_size; }; -int __init +int visorbus_init(void) { int rc = 0; diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h index f9a5e015e21d..1153c99e813f 100644 --- a/drivers/staging/unisys/visorbus/visorbus_private.h +++ b/drivers/staging/unisys/visorbus/visorbus_private.h @@ -155,6 +155,6 @@ bool visorchipset_get_device_info(u32 bus_no, u32 dev_no, bool visorchipset_set_bus_context(u32 bus_no, void *context); /* visorbus init and exit functions */ -int __init visorbus_init(void); +int visorbus_init(void); void visorbus_exit(void); #endif diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 76923bf45de1..fde89938cee5 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -15,16 +15,7 @@ * details. */ -#include "controlvmchannel.h" -#include "version.h" -#include "procobjecttree.h" -#include "visorbus.h" -#include "periodic_work.h" -#include "uisutils.h" -#include "controlvmcompletionstatus.h" -#include "guestlinuxdebug.h" -#include "visorbus_private.h" - +#include #include #include #include @@ -34,6 +25,16 @@ #include #include +#include "controlvmchannel.h" +#include "controlvmcompletionstatus.h" +#include "guestlinuxdebug.h" +#include "periodic_work.h" +#include "procobjecttree.h" +#include "uisutils.h" +#include "version.h" +#include "visorbus.h" +#include "visorbus_private.h" + #define CURRENT_FILE_PC VISOR_CHIPSET_PC_visorchipset_main_c #define MAX_NAME_SIZE 128 @@ -2637,17 +2638,12 @@ visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel) return 0; } - - -static int __init -visorchipset_init(void) +static int +visorchipset_init(struct acpi_device *acpi_device) { int rc = 0; HOSTADDRESS addr; - if (!unisys_spar_platform) - return -ENODEV; - memset(&busdev_notifiers, 0, sizeof(busdev_notifiers)); memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info)); memset(&livedump_info, 0, sizeof(livedump_info)); @@ -2733,8 +2729,8 @@ visorchipset_file_cleanup(dev_t major_dev) unregister_chrdev_region(major_dev, 1); } -static void -visorchipset_exit(void) +static int +visorchipset_exit(struct acpi_device *acpi_device) { POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO); @@ -2754,6 +2750,45 @@ visorchipset_exit(void) visorchipset_file_cleanup(visorchipset_platform_device.dev.devt); POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO); + + return 0; +} + +static const struct acpi_device_id unisys_device_ids[] = { + {"PNP0A07", 0}, + {"", 0}, +}; +MODULE_DEVICE_TABLE(acpi, unisys_device_ids); + +static struct acpi_driver unisys_acpi_driver = { + .name = "unisys_acpi", + .class = "unisys_acpi_class", + .owner = THIS_MODULE, + .ids = unisys_device_ids, + .ops = { + .add = visorchipset_init, + .remove = visorchipset_exit, + }, +}; + +static int init_unisys(void) +{ + int result; + + if (!unisys_spar_platform) + return -ENODEV; + + result = acpi_bus_register_driver(&unisys_acpi_driver); + if (result) + return -ENODEV; + + pr_info("Unisys Visorchipset Driver Loaded.\n"); + return 0; +}; + +static void exit_unisys(void) +{ + acpi_bus_unregister_driver(&unisys_acpi_driver); } module_param_named(major, visorchipset_major, int, S_IRUGO); @@ -2767,8 +2802,8 @@ module_param_named(holdchipsetready, visorchipset_holdchipsetready, MODULE_PARM_DESC(visorchipset_holdchipsetready, "1 to hold response to CHIPSET_READY"); -module_init(visorchipset_init); -module_exit(visorchipset_exit); +module_init(init_unisys); +module_exit(exit_unisys); MODULE_AUTHOR("Unisys"); MODULE_LICENSE("GPL"); From 01f125ca99f038775daae9e5963a4bf368623986 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Tue, 5 May 2015 18:37:03 -0400 Subject: [PATCH 0288/1163] staging: unisys: add ACPI and PCI requirement to Kconfig Later patches will require PCI and ACPI support in the kernel, so add these features to the Kconfig. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/Kconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/unisys/Kconfig b/drivers/staging/unisys/Kconfig index 50223c74eb50..e0562f133613 100644 --- a/drivers/staging/unisys/Kconfig +++ b/drivers/staging/unisys/Kconfig @@ -4,6 +4,8 @@ menuconfig UNISYSSPAR bool "Unisys SPAR driver support" depends on X86_64 + select PCI + select ACPI ---help--- Support for the Unisys SPAR drivers From d5b3f1dccee4dedeff8e264b58fbfe90a6033ecf Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Tue, 5 May 2015 18:37:04 -0400 Subject: [PATCH 0289/1163] staging: unisys: move timskmod.h functionality This patch removes all timksmod.h pound defines. It also removes visorkmodutils.c since it no longer has any use by itself. Since visorkmodutils.c is no longer needed the module_init for visorchipset.c is modified to call visorutil_spar_detect directly instead of the extern variable in timksmod.h. Signed-off-by: Erik Arfvidson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/include/periodic_work.h | 1 + drivers/staging/unisys/include/timskmod.h | 94 ------------------- drivers/staging/unisys/include/visorbus.h | 10 +- .../staging/unisys/visorbus/visorbus_main.c | 9 +- .../unisys/visorbus/visorbus_private.h | 2 +- .../staging/unisys/visorbus/visorchannel.c | 14 +-- .../staging/unisys/visorbus/visorchipset.c | 38 ++++++-- drivers/staging/unisys/visorutil/Makefile | 2 +- .../staging/unisys/visorutil/periodic_work.c | 4 +- .../staging/unisys/visorutil/visorkmodutils.c | 71 -------------- 10 files changed, 50 insertions(+), 195 deletions(-) delete mode 100644 drivers/staging/unisys/visorutil/visorkmodutils.c diff --git a/drivers/staging/unisys/include/periodic_work.h b/drivers/staging/unisys/include/periodic_work.h index 21939db22bba..65bad08dcb01 100644 --- a/drivers/staging/unisys/include/periodic_work.h +++ b/drivers/staging/unisys/include/periodic_work.h @@ -20,6 +20,7 @@ #include "timskmod.h" + /* PERIODIC_WORK an opaque structure to users. * Fields are declared only in the implementation .c files. */ diff --git a/drivers/staging/unisys/include/timskmod.h b/drivers/staging/unisys/include/timskmod.h index 2ee227559181..30d8e7a7e0cd 100644 --- a/drivers/staging/unisys/include/timskmod.h +++ b/drivers/staging/unisys/include/timskmod.h @@ -51,98 +51,4 @@ #include #include -/* #define DEBUG */ -#if !defined SUCCESS -#define SUCCESS 0 -#endif -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#define STRUCTSEQUAL(x, y) (memcmp(&x, &y, sizeof(x)) == 0) -#ifndef HOSTADDRESS -#define HOSTADDRESS unsigned long long -#endif - -#define sizeofmember(TYPE, MEMBER) (sizeof(((TYPE *)0)->MEMBER)) -/** "Covered quotient" function */ -#define COVQ(v, d) (((v) + (d) - 1) / (d)) -#define SWAPPOINTERS(p1, p2) \ - do { \ - void *SWAPPOINTERS_TEMP = (void *)p1; \ - (void *)(p1) = (void *)(p2); \ - (void *)(p2) = SWAPPOINTERS_TEMP; \ - } while (0) - -#define WARNDRV(fmt, args...) LOGWRN(fmt, ## args) -#define SECUREDRV(fmt, args...) LOGWRN(fmt, ## args) - -#define PRINTKDEV(devname, fmt, args...) LOGINFDEV(devname, fmt, ## args) -#define TBDDEV(devname, fmt, args...) LOGERRDEV(devname, fmt, ## args) -#define HUHDEV(devname, fmt, args...) LOGERRDEV(devname, fmt, ## args) -#define ERRDEV(devname, fmt, args...) LOGERRDEV(devname, fmt, ## args) -#define ERRDEVX(devno, fmt, args...) LOGERRDEVX(devno, fmt, ## args) -#define WARNDEV(devname, fmt, args...) LOGWRNDEV(devname, fmt, ## args) -#define SECUREDEV(devname, fmt, args...) LOGWRNDEV(devname, fmt, ## args) -#define INFODEV(devname, fmt, args...) LOGINFDEV(devname, fmt, ## args) -#define INFODEVX(devno, fmt, args...) LOGINFDEVX(devno, fmt, ## args) - -/** Verifies the consistency of your PRIVATEDEVICEDATA structure using - * conventional "signature" fields: - *

- * - sig1 should contain the size of the structure - * - sig2 should contain a pointer to the beginning of the structure - */ -#define DDLOOKSVALID(dd) \ - ((dd != NULL) && \ - ((dd)->sig1 == sizeof(PRIVATEDEVICEDATA)) && \ - ((dd)->sig2 == dd)) - -/** Verifies the consistency of your PRIVATEFILEDATA structure using - * conventional "signature" fields: - *

- * - sig1 should contain the size of the structure - * - sig2 should contain a pointer to the beginning of the structure - */ -#define FDLOOKSVALID(fd) \ - ((fd != NULL) && \ - ((fd)->sig1 == sizeof(PRIVATEFILEDATA)) && \ - ((fd)->sig2 == fd)) - -/** Sleep for an indicated number of seconds (for use in kernel mode). - * x - the number of seconds to sleep. - */ -#define SLEEP(x) \ - do { __set_current_state(TASK_INTERRUPTIBLE); \ - schedule_timeout((x)*HZ); \ - } while (0) - -/** Sleep for an indicated number of jiffies (for use in kernel mode). - * x - the number of jiffies to sleep. - */ -#define SLEEPJIFFIES(x) \ - do { __set_current_state(TASK_INTERRUPTIBLE); \ - schedule_timeout(x); \ - } while (0) - -static inline struct cdev *cdev_alloc_init(struct module *owner, - const struct file_operations *fops) -{ - struct cdev *cdev = NULL; - - cdev = cdev_alloc(); - if (!cdev) - return NULL; - cdev->ops = fops; - cdev->owner = owner; - - /* Note that the memory allocated for cdev will be deallocated - * when the usage count drops to 0, because it is controlled - * by a kobject of type ktype_cdev_dynamic. (This - * deallocation could very well happen outside of our kernel - * module, like via the cdev_put in __fput() for example.) - */ - return cdev; -} - -extern int unisys_spar_platform; - #endif diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h index bce8aa255f74..f97e203c2e7f 100644 --- a/drivers/staging/unisys/include/visorbus.h +++ b/drivers/staging/unisys/include/visorbus.h @@ -37,10 +37,6 @@ #include "periodic_work.h" #include "channel.h" -#ifndef HOSTADDRESS -#define HOSTADDRESS u64 -#endif - struct visor_driver; struct visor_device; @@ -170,9 +166,9 @@ void visorbus_disable_channel_interrupts(struct visor_device *dev); * and arguments may be 0 if we are a channel CLIENT. * In this case, the values can simply be read from the channel header. */ -struct visorchannel *visorchannel_create(HOSTADDRESS physaddr, +struct visorchannel *visorchannel_create(u64 physaddr, ulong channel_bytes, uuid_le guid); -struct visorchannel *visorchannel_create_with_lock(HOSTADDRESS physaddr, +struct visorchannel *visorchannel_create_with_lock(u64 physaddr, ulong channel_bytes, uuid_le guid); void visorchannel_destroy(struct visorchannel *channel); @@ -189,7 +185,7 @@ bool visorchannel_signalinsert(struct visorchannel *channel, u32 queue, int visorchannel_signalqueue_slots_avail(struct visorchannel *channel, u32 queue); int visorchannel_signalqueue_max_slots(struct visorchannel *channel, u32 queue); -HOSTADDRESS visorchannel_get_physaddr(struct visorchannel *channel); +u64 visorchannel_get_physaddr(struct visorchannel *channel); ulong visorchannel_get_nbytes(struct visorchannel *channel); char *visorchannel_id(struct visorchannel *channel, char *s); char *visorchannel_zoneid(struct visorchannel *channel, char *s); diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index b522ea4d2c2d..914298b73282 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -1428,7 +1428,7 @@ remove_visor_device(struct visor_device *dev) } static struct visor_device * -find_visor_device_by_channel(HOSTADDRESS channel_physaddr) +find_visor_device_by_channel(u64 channel_physaddr) { struct list_head *listentry, *listtmp; @@ -1607,8 +1607,9 @@ fix_vbus_dev_info(struct visor_device *visordev) * type name */ for (i = 0; visordrv->channel_types[i].name; i++) { - if (STRUCTSEQUAL(visordrv->channel_types[i].guid, - visordev->channel_type_guid)) { + if (memcmp(&visordrv->channel_types[i].guid, + &visordev->channel_type_guid, + sizeof(visordrv->channel_types[i].guid)) == 0) { chan_type_name = visordrv->channel_types[i].name; break; } @@ -1667,7 +1668,7 @@ create_bus_instance(int id) if ((visorchipset_get_bus_info(id, &bus_info)) && (bus_info.chan_info.channel_addr > 0) && (bus_info.chan_info.n_channel_bytes > 0)) { - HOSTADDRESS channel_addr = bus_info.chan_info.channel_addr; + u64 channel_addr = bus_info.chan_info.channel_addr; unsigned long n_channel_bytes = (unsigned long) bus_info.chan_info.n_channel_bytes; diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h index 1153c99e813f..32e26ed52085 100644 --- a/drivers/staging/unisys/visorbus/visorbus_private.h +++ b/drivers/staging/unisys/visorbus/visorbus_private.h @@ -54,7 +54,7 @@ enum visorchipset_addresstype { */ struct visorchipset_channel_info { enum visorchipset_addresstype addr_type; - HOSTADDRESS channel_addr; + u64 channel_addr; struct irq_info intr; u64 n_channel_bytes; uuid_le channel_type_uuid; diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index bf1e039df7af..44ea43462803 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -27,7 +27,7 @@ #define MYDRVNAME "visorchannel" struct visorchannel { - HOSTADDRESS physaddr; + u64 physaddr; ulong nbytes; void __iomem *mapped; struct channel_header chan_hdr; @@ -50,7 +50,7 @@ struct visorchannel { * but does NOT modify this data area. */ static struct visorchannel * -visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes, +visorchannel_create_guts(u64 physaddr, ulong channel_bytes, ulong off, uuid_le guid, bool needs_lock) { struct visorchannel *channel; @@ -112,7 +112,7 @@ cleanup: } struct visorchannel * -visorchannel_create(HOSTADDRESS physaddr, ulong channel_bytes, uuid_le guid) +visorchannel_create(u64 physaddr, ulong channel_bytes, uuid_le guid) { return visorchannel_create_guts(physaddr, channel_bytes, 0, guid, false); @@ -120,7 +120,7 @@ visorchannel_create(HOSTADDRESS physaddr, ulong channel_bytes, uuid_le guid) EXPORT_SYMBOL_GPL(visorchannel_create); struct visorchannel * -visorchannel_create_with_lock(HOSTADDRESS physaddr, ulong channel_bytes, +visorchannel_create_with_lock(u64 physaddr, ulong channel_bytes, uuid_le guid) { return visorchannel_create_guts(physaddr, channel_bytes, 0, guid, @@ -141,7 +141,7 @@ visorchannel_destroy(struct visorchannel *channel) } EXPORT_SYMBOL_GPL(visorchannel_destroy); -HOSTADDRESS +u64 visorchannel_get_physaddr(struct visorchannel *channel) { return channel->physaddr; @@ -177,7 +177,7 @@ visorchannel_zoneid(struct visorchannel *channel, char *s) } EXPORT_SYMBOL_GPL(visorchannel_zoneid); -HOSTADDRESS +u64 visorchannel_get_clientpartition(struct visorchannel *channel) { return channel->chan_hdr.partition_handle; @@ -498,7 +498,7 @@ void visorchannel_debug(struct visorchannel *channel, int num_queues, struct seq_file *seq, u32 off) { - HOSTADDRESS addr = 0; + u64 addr = 0; ulong nbytes = 0, nbytes_region = 0; struct channel_header hdr; struct channel_header *phdr = &hdr; diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index fde89938cee5..8ff79c0eeff2 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -47,6 +47,14 @@ #define VISORCHIPSET_MMAP_CONTROLCHANOFFSET 0x00000000 + +#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 + /* * Module parameters */ @@ -1675,7 +1683,7 @@ my_device_destroy(struct controlvm_message *inmsg) * for failure. */ static int -initialize_controlvm_payload_info(HOSTADDRESS phys_addr, u64 offset, u32 bytes, +initialize_controlvm_payload_info(u64 phys_addr, u64 offset, u32 bytes, struct visor_controlvm_payload_info *info) { u8 __iomem *payload = NULL; @@ -1723,7 +1731,7 @@ destroy_controlvm_payload_info(struct visor_controlvm_payload_info *info) static void initialize_controlvm_payload(void) { - HOSTADDRESS phys_addr = visorchannel_get_physaddr(controlvm_channel); + u64 phys_addr = visorchannel_get_physaddr(controlvm_channel); u64 payload_offset = 0; u32 payload_bytes = 0; @@ -2056,7 +2064,7 @@ parahotplug_process_message(struct controlvm_message *inmsg) * either successfully or with an error. */ static bool -handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr) +handle_command(struct controlvm_message inmsg, u64 channel_addr) { struct controlvm_message_packet *cmd = &inmsg.cmd; u64 parm_addr; @@ -2152,7 +2160,7 @@ handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr) return true; } -static HOSTADDRESS controlvm_get_channel_address(void) +static u64 controlvm_get_channel_address(void) { u64 addr = 0; u32 size = 0; @@ -2589,7 +2597,7 @@ static long visorchipset_ioctl(struct file *file, unsigned int cmd, sizeof(vrtc_offset))) { return -EFAULT; } - return SUCCESS; + return 0; case VMCALL_UPDATE_PHYSICAL_TIME: if (copy_from_user(&adjustment, (void __user *)arg, sizeof(adjustment))) { @@ -2642,7 +2650,7 @@ static int visorchipset_init(struct acpi_device *acpi_device) { int rc = 0; - HOSTADDRESS addr; + u64 addr; memset(&busdev_notifiers, 0, sizeof(busdev_notifiers)); memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info)); @@ -2758,7 +2766,6 @@ static const struct acpi_device_id unisys_device_ids[] = { {"PNP0A07", 0}, {"", 0}, }; -MODULE_DEVICE_TABLE(acpi, unisys_device_ids); static struct acpi_driver unisys_acpi_driver = { .name = "unisys_acpi", @@ -2770,12 +2777,25 @@ static struct acpi_driver unisys_acpi_driver = { .remove = visorchipset_exit, }, }; +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 int init_unisys(void) { int result; - - if (!unisys_spar_platform) + if (!visorutil_spar_detect()) return -ENODEV; result = acpi_bus_register_driver(&unisys_acpi_driver); diff --git a/drivers/staging/unisys/visorutil/Makefile b/drivers/staging/unisys/visorutil/Makefile index f29978772ca3..88db08517471 100644 --- a/drivers/staging/unisys/visorutil/Makefile +++ b/drivers/staging/unisys/visorutil/Makefile @@ -4,6 +4,6 @@ obj-$(CONFIG_UNISYS_VISORUTIL) += visorutil.o -visorutil-y := charqueue.o periodic_work.o visorkmodutils.o +visorutil-y := charqueue.o periodic_work.o ccflags-y += -Idrivers/staging/unisys/include diff --git a/drivers/staging/unisys/visorutil/periodic_work.c b/drivers/staging/unisys/visorutil/periodic_work.c index aa357a297f48..aa0c1f875729 100644 --- a/drivers/staging/unisys/visorutil/periodic_work.c +++ b/drivers/staging/unisys/visorutil/periodic_work.c @@ -18,6 +18,7 @@ /* * Helper functions to schedule periodic work in Linux kernel mode. */ +#include #include "timskmod.h" #include "periodic_work.h" @@ -192,7 +193,8 @@ bool visor_periodic_work_stop(struct periodic_work *pw) } if (pw->is_scheduled) { write_unlock(&pw->lock); - SLEEPJIFFIES(10); + __set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(10); write_lock(&pw->lock); } else { pw->want_to_stop = false; diff --git a/drivers/staging/unisys/visorutil/visorkmodutils.c b/drivers/staging/unisys/visorutil/visorkmodutils.c deleted file mode 100644 index 0b8f5c163400..000000000000 --- a/drivers/staging/unisys/visorutil/visorkmodutils.c +++ /dev/null @@ -1,71 +0,0 @@ -/* timskmodutils.c - * - * 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. - */ - -#include "timskmod.h" - -#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); - -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); - -MODULE_LICENSE("GPL"); From f45017babab040ab0d877abf7485484fde8d74e5 Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Tue, 5 May 2015 18:37:05 -0400 Subject: [PATCH 0290/1163] staging: unisys: remove charqueue.c This patch removes charqueue.[ch] since it no longer called Signed-off-by: Erik Arfvidson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorutil/Makefile | 2 +- drivers/staging/unisys/visorutil/charqueue.c | 127 ------------------- drivers/staging/unisys/visorutil/charqueue.h | 37 ------ 3 files changed, 1 insertion(+), 165 deletions(-) delete mode 100644 drivers/staging/unisys/visorutil/charqueue.c delete mode 100644 drivers/staging/unisys/visorutil/charqueue.h diff --git a/drivers/staging/unisys/visorutil/Makefile b/drivers/staging/unisys/visorutil/Makefile index 88db08517471..8f6a3e3afffb 100644 --- a/drivers/staging/unisys/visorutil/Makefile +++ b/drivers/staging/unisys/visorutil/Makefile @@ -4,6 +4,6 @@ obj-$(CONFIG_UNISYS_VISORUTIL) += visorutil.o -visorutil-y := charqueue.o periodic_work.o +visorutil-y := periodic_work.o ccflags-y += -Idrivers/staging/unisys/include diff --git a/drivers/staging/unisys/visorutil/charqueue.c b/drivers/staging/unisys/visorutil/charqueue.c deleted file mode 100644 index f2227193ce0b..000000000000 --- a/drivers/staging/unisys/visorutil/charqueue.c +++ /dev/null @@ -1,127 +0,0 @@ -/* charqueue.c - * - * 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. - */ - -/* - * Simple character queue implementation for Linux kernel mode. - */ - -#include "charqueue.h" - -#define MYDRVNAME "charqueue" - -#define IS_EMPTY(charqueue) (charqueue->head == charqueue->tail) - -struct charqueue { - int alloc_size; - int nslots; - spinlock_t lock; /* read/write lock for this structure */ - int head, tail; - unsigned char buf[0]; -}; - -struct charqueue *visor_charqueue_create(ulong nslots) -{ - int alloc_size = sizeof(struct charqueue) + nslots + 1; - struct charqueue *cq; - - cq = kmalloc(alloc_size, GFP_KERNEL|__GFP_NORETRY); - if (cq == NULL) - return NULL; - cq->alloc_size = alloc_size; - cq->nslots = nslots; - cq->head = 0; - cq->tail = 0; - spin_lock_init(&cq->lock); - return cq; -} -EXPORT_SYMBOL_GPL(visor_charqueue_create); - -void visor_charqueue_enqueue(struct charqueue *charqueue, unsigned char c) -{ - int alloc_slots = charqueue->nslots+1; /* 1 slot is always empty */ - - spin_lock(&charqueue->lock); - charqueue->head = (charqueue->head+1) % alloc_slots; - if (charqueue->head == charqueue->tail) - /* overflow; overwrite the oldest entry */ - charqueue->tail = (charqueue->tail+1) % alloc_slots; - charqueue->buf[charqueue->head] = c; - spin_unlock(&charqueue->lock); -} -EXPORT_SYMBOL_GPL(visor_charqueue_enqueue); - -bool visor_charqueue_is_empty(struct charqueue *charqueue) -{ - bool b; - - spin_lock(&charqueue->lock); - b = IS_EMPTY(charqueue); - spin_unlock(&charqueue->lock); - return b; -} -EXPORT_SYMBOL_GPL(visor_charqueue_is_empty); - -static int charqueue_dequeue_1(struct charqueue *charqueue) -{ - int alloc_slots = charqueue->nslots + 1; /* 1 slot is always empty */ - - if (IS_EMPTY(charqueue)) - return -1; - charqueue->tail = (charqueue->tail+1) % alloc_slots; - return charqueue->buf[charqueue->tail]; -} - -int charqueue_dequeue(struct charqueue *charqueue) -{ - int rc; - - spin_lock(&charqueue->lock); - rc = charqueue_dequeue_1(charqueue); - spin_unlock(&charqueue->lock); - return rc; -} - -int visor_charqueue_dequeue_n(struct charqueue *charqueue, unsigned char *buf, - int n) -{ - int rc, counter = 0, c; - - spin_lock(&charqueue->lock); - for (;;) { - if (n <= 0) - break; /* no more buffer space */ - c = charqueue_dequeue_1(charqueue); - if (c < 0) - break; /* no more input */ - *buf = (unsigned char)(c); - buf++; - n--; - counter++; - } - rc = counter; - spin_unlock(&charqueue->lock); - return rc; -} -EXPORT_SYMBOL_GPL(visor_charqueue_dequeue_n); - -void visor_charqueue_destroy(struct charqueue *charqueue) -{ - if (charqueue == NULL) - return; - kfree(charqueue); -} -EXPORT_SYMBOL_GPL(visor_charqueue_destroy); diff --git a/drivers/staging/unisys/visorutil/charqueue.h b/drivers/staging/unisys/visorutil/charqueue.h deleted file mode 100644 index 70fe26b5ddfd..000000000000 --- a/drivers/staging/unisys/visorutil/charqueue.h +++ /dev/null @@ -1,37 +0,0 @@ -/* charqueue.h - * - * 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. - */ - -#ifndef __CHARQUEUE_H__ -#define __CHARQUEUE_H__ - -#include "timskmod.h" - -/* struct charqueue is an opaque structure to users. - * Fields are declared only in the implementation .c files. - */ -struct charqueue; - -struct charqueue *visor_charqueue_create(ulong nslots); -void visor_charqueue_enqueue(struct charqueue *charqueue, unsigned char c); -int charqueue_dequeue(struct charqueue *charqueue); -int visor_charqueue_dequeue_n(struct charqueue *charqueue, unsigned char *buf, - int n); -bool visor_charqueue_is_empty(struct charqueue *charqueue); -void visor_charqueue_destroy(struct charqueue *charqueue); - -#endif - From c0a14641b1c6b9e85f94370ea3610ca486ca568f Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Tue, 5 May 2015 18:37:06 -0400 Subject: [PATCH 0291/1163] staging: unisys: remove timskmod.h and procobjecttree.h This patch move the needed linux include files from timskmod.h to the files that calls those include. Also procobjecttree.h is removed since it is dead code. Signed-off-by: Erik Arfvidson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/include/periodic_work.h | 3 +- .../staging/unisys/include/procobjecttree.h | 47 ---------------- drivers/staging/unisys/include/sparstop.h | 1 - drivers/staging/unisys/include/timskmod.h | 54 ------------------- drivers/staging/unisys/include/visorbus.h | 1 + .../staging/unisys/visorbus/visorbus_main.c | 1 - .../unisys/visorbus/visorbus_private.h | 1 - .../staging/unisys/visorbus/visorchipset.c | 2 +- drivers/staging/unisys/visorchannel/globals.h | 1 - .../staging/unisys/visorutil/periodic_work.c | 1 - 10 files changed, 4 insertions(+), 108 deletions(-) delete mode 100644 drivers/staging/unisys/include/procobjecttree.h delete mode 100644 drivers/staging/unisys/include/timskmod.h diff --git a/drivers/staging/unisys/include/periodic_work.h b/drivers/staging/unisys/include/periodic_work.h index 65bad08dcb01..4e19c28dc3d0 100644 --- a/drivers/staging/unisys/include/periodic_work.h +++ b/drivers/staging/unisys/include/periodic_work.h @@ -18,7 +18,8 @@ #ifndef __PERIODIC_WORK_H__ #define __PERIODIC_WORK_H__ -#include "timskmod.h" +#include +#include /* PERIODIC_WORK an opaque structure to users. diff --git a/drivers/staging/unisys/include/procobjecttree.h b/drivers/staging/unisys/include/procobjecttree.h deleted file mode 100644 index 809c6794290e..000000000000 --- a/drivers/staging/unisys/include/procobjecttree.h +++ /dev/null @@ -1,47 +0,0 @@ -/* procobjecttree.h - * - * 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. - */ - -/** @file ********************************************************************* - * - * This describes the interfaces necessary for creating a tree of types, - * objects, and properties in /proc. - * - ****************************************************************************** - */ - -#ifndef __PROCOBJECTTREE_H__ -#define __PROCOBJECTTREE_H__ - -#include "timskmod.h" - -/* These are opaque structures to users. - * Fields are declared only in the implementation .c files. - */ -typedef struct MYPROCOBJECT_Tag MYPROCOBJECT; -typedef struct MYPROCTYPE_Tag MYPROCTYPE; - -MYPROCOBJECT *visor_proc_CreateObject(MYPROCTYPE *type, const char *name, - void *context); -void visor_proc_DestroyObject(MYPROCOBJECT *obj); -MYPROCTYPE *visor_proc_CreateType(struct proc_dir_entry *procRootDir, - const char **name, - const char **propertyNames, - void (*show_property)(struct seq_file *, - void *, int)); -void visor_proc_DestroyType(MYPROCTYPE *type); - -#endif diff --git a/drivers/staging/unisys/include/sparstop.h b/drivers/staging/unisys/include/sparstop.h index 05837399a741..6150d2d58d69 100644 --- a/drivers/staging/unisys/include/sparstop.h +++ b/drivers/staging/unisys/include/sparstop.h @@ -18,7 +18,6 @@ #ifndef __SPARSTOP_H__ #define __SPARSTOP_H__ -#include "timskmod.h" #include "version.h" #include diff --git a/drivers/staging/unisys/include/timskmod.h b/drivers/staging/unisys/include/timskmod.h deleted file mode 100644 index 30d8e7a7e0cd..000000000000 --- a/drivers/staging/unisys/include/timskmod.h +++ /dev/null @@ -1,54 +0,0 @@ -/* timskmod.h - * - * 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. - */ - -#ifndef __TIMSKMOD_H__ -#define __TIMSKMOD_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -/* #define EXPORT_SYMTAB */ -#include -#include -#include -#include -#include -#include -#include - -#endif diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h index f97e203c2e7f..0f1966ceda6c 100644 --- a/drivers/staging/unisys/include/visorbus.h +++ b/drivers/staging/unisys/include/visorbus.h @@ -31,6 +31,7 @@ #include #include +#include #include #include diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 914298b73282..2e00e4249582 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -20,7 +20,6 @@ #include "visorbus.h" #include "visorbus_private.h" #include "version.h" -#include "timskmod.h" #include "periodic_work.h" #include "vbuschannel.h" #include "guestlinuxdebug.h" diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h index 32e26ed52085..8326e4da56c1 100644 --- a/drivers/staging/unisys/visorbus/visorbus_private.h +++ b/drivers/staging/unisys/visorbus/visorbus_private.h @@ -22,7 +22,6 @@ #include "channel.h" #include "controlvmchannel.h" -#include "procobjecttree.h" #include "vbusdeviceinfo.h" #include "vbushelper.h" diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 8ff79c0eeff2..776bf2e59026 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -16,6 +16,7 @@ */ #include +#include #include #include #include @@ -29,7 +30,6 @@ #include "controlvmcompletionstatus.h" #include "guestlinuxdebug.h" #include "periodic_work.h" -#include "procobjecttree.h" #include "uisutils.h" #include "version.h" #include "visorbus.h" diff --git a/drivers/staging/unisys/visorchannel/globals.h b/drivers/staging/unisys/visorchannel/globals.h index 6530413958d4..1c3c427e3e13 100644 --- a/drivers/staging/unisys/visorchannel/globals.h +++ b/drivers/staging/unisys/visorchannel/globals.h @@ -18,7 +18,6 @@ #ifndef __VISORCHANNEL_GLOBALS_H__ #define __VISORCHANNEL_GLOBALS_H__ -#include "timskmod.h" #include "version.h" #define MYDRVNAME "visorchannel" diff --git a/drivers/staging/unisys/visorutil/periodic_work.c b/drivers/staging/unisys/visorutil/periodic_work.c index aa0c1f875729..3562e8b2824b 100644 --- a/drivers/staging/unisys/visorutil/periodic_work.c +++ b/drivers/staging/unisys/visorutil/periodic_work.c @@ -20,7 +20,6 @@ */ #include -#include "timskmod.h" #include "periodic_work.h" #define MYDRVNAME "periodic_work" From 53490b545cb07c9d2e1b36aa680afaf0d435aec8 Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Tue, 5 May 2015 18:37:07 -0400 Subject: [PATCH 0292/1163] staging: unisys: move periodic_work.c into the visorbus directory This patch removes visorutil directory, move periodic_work.c into the visorbus directory. Signed-off-by: Erik Arfvidson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/Kconfig | 1 - drivers/staging/unisys/visorbus/Makefile | 1 + .../unisys/{visorutil => visorbus}/periodic_work.c | 0 drivers/staging/unisys/visorutil/Kconfig | 9 --------- drivers/staging/unisys/visorutil/Makefile | 9 --------- 5 files changed, 1 insertion(+), 19 deletions(-) rename drivers/staging/unisys/{visorutil => visorbus}/periodic_work.c (100%) delete mode 100644 drivers/staging/unisys/visorutil/Kconfig delete mode 100644 drivers/staging/unisys/visorutil/Makefile diff --git a/drivers/staging/unisys/Kconfig b/drivers/staging/unisys/Kconfig index e0562f133613..0c3e9a1368a8 100644 --- a/drivers/staging/unisys/Kconfig +++ b/drivers/staging/unisys/Kconfig @@ -11,7 +11,6 @@ menuconfig UNISYSSPAR if UNISYSSPAR -source "drivers/staging/unisys/visorutil/Kconfig" source "drivers/staging/unisys/visorbus/Kconfig" endif # UNISYSSPAR diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile index 16d3ff507a0a..72d4d4429684 100644 --- a/drivers/staging/unisys/visorbus/Makefile +++ b/drivers/staging/unisys/visorbus/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_UNISYS_VISORBUS) += visorbus.o visorbus-y := visorbus_main.o visorbus-y += visorchannel.o visorbus-y += visorchipset.o +visorbus-y += periodic_work.o ccflags-y += -Idrivers/staging/unisys/include ccflags-y += -Idrivers/staging/unisys/common-spar/include diff --git a/drivers/staging/unisys/visorutil/periodic_work.c b/drivers/staging/unisys/visorbus/periodic_work.c similarity index 100% rename from drivers/staging/unisys/visorutil/periodic_work.c rename to drivers/staging/unisys/visorbus/periodic_work.c diff --git a/drivers/staging/unisys/visorutil/Kconfig b/drivers/staging/unisys/visorutil/Kconfig deleted file mode 100644 index be9c2cf890cc..000000000000 --- a/drivers/staging/unisys/visorutil/Kconfig +++ /dev/null @@ -1,9 +0,0 @@ -# -# Unisys timskmod configuration -# - -config UNISYS_VISORUTIL - tristate "Unisys visorutil driver" - ---help--- - If you say Y here, you will enable the Unisys visorutil driver. - diff --git a/drivers/staging/unisys/visorutil/Makefile b/drivers/staging/unisys/visorutil/Makefile deleted file mode 100644 index 8f6a3e3afffb..000000000000 --- a/drivers/staging/unisys/visorutil/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# -# Makefile for Unisys timskmod -# - -obj-$(CONFIG_UNISYS_VISORUTIL) += visorutil.o - -visorutil-y := periodic_work.o - -ccflags-y += -Idrivers/staging/unisys/include From 1b27feaa9d7bfd9e68c9f5e8a0039a223916c3bf Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Tue, 5 May 2015 18:37:08 -0400 Subject: [PATCH 0293/1163] staging: unisys: fix visorbus Kconfig Removing visorutil made it impossible to build visorbus. Remove the config setting from the Kconfig so the module can be enabled in the build. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/unisys/visorbus/Kconfig b/drivers/staging/unisys/visorbus/Kconfig index 420c9eee9075..9b299ac86015 100644 --- a/drivers/staging/unisys/visorbus/Kconfig +++ b/drivers/staging/unisys/visorbus/Kconfig @@ -4,6 +4,6 @@ config UNISYS_VISORBUS tristate "Unisys visorbus driver" - depends on UNISYSSPAR && UNISYS_VISORUTIL + depends on UNISYSSPAR ---help--- If you say Y here, you will enable the Unisys visorbus driver. From 1210f8e72b06e53975c5719db2a14f8bffdd4870 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Tue, 5 May 2015 18:37:09 -0400 Subject: [PATCH 0294/1163] staging: unisys: remove visorutil from top level Makefile The visorutil directory is still mentioned in the top level makefile for the Unisys drivers, so remove it. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/unisys/Makefile b/drivers/staging/unisys/Makefile index e0c893a6e870..566af8e39aea 100644 --- a/drivers/staging/unisys/Makefile +++ b/drivers/staging/unisys/Makefile @@ -1,5 +1,4 @@ # # Makefile for Unisys SPAR drivers # -obj-$(CONFIG_UNISYS_VISORUTIL) += visorutil/ obj-$(CONFIG_UNISYS_VISORBUS) += visorbus/ From df94247a8987b1ab5be2330c7d07b51980592fe0 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:37:10 -0400 Subject: [PATCH 0295/1163] staging: unisys: visorchannel: Make visorchannel_create take a gfp_t This allows the caller to specify an appropriate GFP flag instead of hardcoding the lowest common denominator. Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../include/channels/controlvmchannel.h | 5 +---- drivers/staging/unisys/include/visorbus.h | 7 ++++--- .../staging/unisys/visorbus/visorbus_main.c | 3 ++- drivers/staging/unisys/visorbus/visorchannel.c | 18 ++++++++++-------- drivers/staging/unisys/visorbus/visorchipset.c | 8 ++++---- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index d8ed52edd938..f1c86fbc126c 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -25,9 +25,6 @@ UUID_LE(0x2b3c2d10, 0x7ef5, 0x4ad8, \ 0xb9, 0x66, 0x34, 0x48, 0xb7, 0x38, 0x6b, 0x3d) -static const uuid_le spar_controlvm_channel_protocol_uuid = - SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID; - #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE \ ULTRA_CHANNEL_PROTOCOL_SIGNATURE #define CONTROLVM_MESSAGE_MAX 64 @@ -42,7 +39,7 @@ static const uuid_le spar_controlvm_channel_protocol_uuid = #define SPAR_CONTROLVM_CHANNEL_OK_CLIENT(ch) \ spar_check_channel_client(ch, \ - spar_controlvm_channel_protocol_uuid, \ + SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID, \ "controlvm", \ sizeof(struct spar_controlvm_channel_protocol), \ ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \ diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h index 0f1966ceda6c..d54282222f65 100644 --- a/drivers/staging/unisys/include/visorbus.h +++ b/drivers/staging/unisys/include/visorbus.h @@ -168,10 +168,11 @@ void visorbus_disable_channel_interrupts(struct visor_device *dev); * In this case, the values can simply be read from the channel header. */ struct visorchannel *visorchannel_create(u64 physaddr, - ulong channel_bytes, uuid_le guid); + unsigned long channel_bytes, + gfp_t gfp, uuid_le guid); struct visorchannel *visorchannel_create_with_lock(u64 physaddr, - ulong channel_bytes, - uuid_le guid); + unsigned long channel_bytes, + gfp_t gfp, uuid_le guid); void visorchannel_destroy(struct visorchannel *channel); int visorchannel_read(struct visorchannel *channel, ulong offset, void *local, ulong nbytes); diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 2e00e4249582..77afa9dbbdc8 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -1308,8 +1308,8 @@ create_visor_device(struct visorbus_devdata *devdata, POSTCODE_SEVERITY_INFO); /* prepare chan_hdr (abstraction to read/write channel memory) */ visorchannel = visorchannel_create(chan_info.channel_addr, - (unsigned long) chan_info.n_channel_bytes, + GFP_KERNEL, chan_info.channel_type_uuid); if (!visorchannel) { POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, chipset_dev_no, @@ -1676,6 +1676,7 @@ create_bus_instance(int id) devdata->chan = visorchannel_create(channel_addr, n_channel_bytes, + GFP_KERNEL, channel_type_guid); if (!devdata->chan) { POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, channel_addr, diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index 44ea43462803..2d3e4d6defea 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -50,14 +50,15 @@ struct visorchannel { * but does NOT modify this data area. */ static struct visorchannel * -visorchannel_create_guts(u64 physaddr, ulong channel_bytes, - ulong off, uuid_le guid, bool needs_lock) +visorchannel_create_guts(u64 physaddr, unsigned long channel_bytes, + gfp_t gfp, unsigned long off, + uuid_le guid, bool needs_lock) { struct visorchannel *channel; int err; size_t size = sizeof(struct channel_header); - channel = kzalloc(sizeof(*channel), GFP_KERNEL|__GFP_NORETRY); + channel = kzalloc(sizeof(*channel), gfp); if (!channel) goto cleanup; @@ -112,18 +113,19 @@ cleanup: } struct visorchannel * -visorchannel_create(u64 physaddr, ulong channel_bytes, uuid_le guid) +visorchannel_create(u64 physaddr, unsigned long channel_bytes, + gfp_t gfp, uuid_le guid) { - return visorchannel_create_guts(physaddr, channel_bytes, 0, guid, + return visorchannel_create_guts(physaddr, channel_bytes, gfp, 0, guid, false); } EXPORT_SYMBOL_GPL(visorchannel_create); struct visorchannel * -visorchannel_create_with_lock(u64 physaddr, ulong channel_bytes, - uuid_le guid) +visorchannel_create_with_lock(u64 physaddr, unsigned long channel_bytes, + gfp_t gfp, uuid_le guid) { - return visorchannel_create_guts(physaddr, channel_bytes, 0, guid, + return visorchannel_create_guts(physaddr, channel_bytes, gfp, 0, guid, true); } EXPORT_SYMBOL_GPL(visorchannel_create_with_lock); diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 776bf2e59026..e61ec342c2ea 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -2659,11 +2659,11 @@ visorchipset_init(struct acpi_device *acpi_device) addr = controlvm_get_channel_address(); if (addr) { + int tmp_sz = sizeof(struct spar_controlvm_channel_protocol); + uuid_le uuid = SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID; controlvm_channel = - visorchannel_create_with_lock - (addr, - sizeof(struct spar_controlvm_channel_protocol), - spar_controlvm_channel_protocol_uuid); + visorchannel_create_with_lock(addr, tmp_sz, + GFP_KERNEL, uuid); if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT( visorchannel_get_header(controlvm_channel))) { initialize_controlvm_payload(); From fcc974d0d58bfcd63219b759f4c51c3313b1667d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:37:11 -0400 Subject: [PATCH 0296/1163] staging: unisys: visorchipset: Declare parser_init_byte_stream() static In addition remove unused parser_init() Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchipset.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index e61ec342c2ea..a5e1bded7890 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -470,18 +470,12 @@ cleanup: return rc; } -struct parser_context * -parser_init(u64 addr, u32 bytes, bool local, bool *retry) -{ - return parser_init_guts(addr, bytes, local, true, retry); -} - /* Call this instead of parser_init() if the payload area consists of just * a sequence of bytes, rather than a struct spar_controlvm_parameters_header * structures. Afterwards, you can call parser_simpleString_get() or * parser_byteStream_get() to obtain the data. */ -struct parser_context * +static struct parser_context * parser_init_byte_stream(u64 addr, u32 bytes, bool local, bool *retry) { return parser_init_guts(addr, bytes, local, false, retry); From 464129edbccf70d77f526943d1ca6f8163d7f82b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:37:12 -0400 Subject: [PATCH 0297/1163] staging: unisys: parser: Remove unused functions and mark others static Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorchipset.c | 201 +----------------- 1 file changed, 4 insertions(+), 197 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index a5e1bded7890..b6b332c27150 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -481,30 +481,7 @@ parser_init_byte_stream(u64 addr, u32 bytes, bool local, bool *retry) return parser_init_guts(addr, bytes, local, false, retry); } -/* Obtain '\0'-terminated copy of string in payload area. - */ -char * -parser_simpleString_get(struct parser_context *ctx) -{ - if (!ctx->byte_stream) - return NULL; - return ctx->data; /* note this IS '\0'-terminated, because of - * the num of bytes we alloc+clear in - * parser_init_byteStream() */ -} - -/* Obtain a copy of the buffer in the payload area. - */ -void *parser_byte_stream_get(struct parser_context *ctx, unsigned long *nbytes) -{ - if (!ctx->byte_stream) - return NULL; - if (nbytes) - *nbytes = ctx->param_bytes; - return (void *)ctx->data; -} - -uuid_le +static uuid_le parser_id_get(struct parser_context *ctx) { struct spar_controlvm_parameters_header *phdr = NULL; @@ -526,7 +503,7 @@ enum PARSER_WHICH_STRING { PARSERSTRING_NAME, /* TODO: only PARSERSTRING_NAME is used ? */ }; -void +static void parser_param_start(struct parser_context *ctx, enum PARSER_WHICH_STRING which_string) { @@ -560,8 +537,7 @@ Away: return; } -void -parser_done(struct parser_context *ctx) +static void parser_done(struct parser_context *ctx) { if (!ctx) return; @@ -569,176 +545,7 @@ parser_done(struct parser_context *ctx) kfree(ctx); } -/** Return length of string not counting trailing spaces. */ -static int -string_length_no_trail(char *s, int len) -{ - int i = len - 1; - - while (i >= 0) { - if (!isspace(s[i])) - return i + 1; - i--; - } - return 0; -} - -/** Grab the next name and value out of the parameter buffer. - * The entire parameter buffer looks like this: - * =\0 - * =\0 - * ... - * \0 - * If successful, the next value is returned within the supplied - * buffer (the value is always upper-cased), and the corresponding - * is returned within a kmalloc()ed buffer, whose pointer is - * provided as the return value of this function. - * (The total number of bytes allocated is strlen()+1.) - * - * NULL is returned to indicate failure, which can occur for several reasons: - * - all = pairs have already been processed - * - bad parameter - * - parameter buffer ends prematurely (couldn't find an '=' or '\0' within - * the confines of the parameter buffer) - * - the buffer is not large enough to hold the of the next - * parameter - */ -void * -parser_param_get(struct parser_context *ctx, char *nam, int namesize) -{ - u8 *pscan, *pnam = nam; - unsigned long nscan; - int value_length = -1, orig_value_length = -1; - void *value = NULL; - int i; - int closing_quote = 0; - - if (!ctx) - return NULL; - pscan = ctx->curr; - nscan = ctx->bytes_remaining; - if (nscan == 0) - return NULL; - if (*pscan == '\0') - /* This is the normal return point after you have processed - * all of the = pairs in a syntactically-valid - * parameter buffer. - */ - return NULL; - - /* skip whitespace */ - while (isspace(*pscan)) { - pscan++; - nscan--; - if (nscan == 0) - return NULL; - } - - while (*pscan != ':') { - if (namesize <= 0) - return NULL; - *pnam = toupper(*pscan); - pnam++; - namesize--; - pscan++; - nscan--; - if (nscan == 0) - return NULL; - } - if (namesize <= 0) - return NULL; - *pnam = '\0'; - nam[string_length_no_trail(nam, strlen(nam))] = '\0'; - - /* point to char immediately after ":" in ":" */ - pscan++; - nscan--; - /* skip whitespace */ - while (isspace(*pscan)) { - pscan++; - nscan--; - if (nscan == 0) - return NULL; - } - if (nscan == 0) - return NULL; - if (*pscan == '\'' || *pscan == '"') { - closing_quote = *pscan; - pscan++; - nscan--; - if (nscan == 0) - return NULL; - } - - /* look for a separator character, terminator character, or - * end of data - */ - for (i = 0, value_length = -1; i < nscan; i++) { - if (closing_quote) { - if (pscan[i] == '\0') - return NULL; - if (pscan[i] == closing_quote) { - value_length = i; - break; - } - } else - if (pscan[i] == ',' || pscan[i] == ';' - || pscan[i] == '\0') { - value_length = i; - break; - } - } - if (value_length < 0) { - if (closing_quote) - return NULL; - value_length = nscan; - } - orig_value_length = value_length; - if (closing_quote == 0) - value_length = string_length_no_trail(pscan, orig_value_length); - value = kmalloc(value_length + 1, GFP_KERNEL|__GFP_NORETRY); - if (value == NULL) - return NULL; - memcpy(value, pscan, value_length); - ((u8 *) (value))[value_length] = '\0'; - - pscan += orig_value_length; - nscan -= orig_value_length; - - /* skip past separator or closing quote */ - if (nscan > 0) { - if (*pscan != '\0') { - pscan++; - nscan--; - } - } - - if (closing_quote && (nscan > 0)) { - /* we still need to skip around the real separator if present */ - /* first, skip whitespace */ - while (isspace(*pscan)) { - pscan++; - nscan--; - if (nscan == 0) - break; - } - if (nscan > 0) { - if (*pscan == ',' || *pscan == ';') { - pscan++; - nscan--; - } else if (*pscan != '\0') { - kfree(value); - value = NULL; - return NULL; - } - } - } - ctx->curr = pscan; - ctx->bytes_remaining = nscan; - return value; -} - -void * +static void * parser_string_get(struct parser_context *ctx) { u8 *pscan; From cc55b5c5a7e3ff82e9c419554c531bc444a7f87c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:37:13 -0400 Subject: [PATCH 0298/1163] staging: unisys: parser_init_guts(): standard_payload_header is always false Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorchipset.c | 37 +++++-------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index b6b332c27150..2cf59cacc7f4 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -376,21 +376,20 @@ static void controlvm_respond_physdev_changestate( static void parser_done(struct parser_context *ctx); static struct parser_context * -parser_init_guts(u64 addr, u32 bytes, bool local, - bool standard_payload_header, bool *retry) +parser_init_guts(u64 addr, u32 bytes, bool local, bool *retry) { int allocbytes = sizeof(struct parser_context) + bytes; struct parser_context *rc = NULL; struct parser_context *ctx = NULL; - struct spar_controlvm_parameters_header *phdr = NULL; if (retry) *retry = false; - if (!standard_payload_header) - /* alloc and 0 extra byte to ensure payload is - * '\0'-terminated - */ - allocbytes++; + + /* + * alloc an 0 extra byte to ensure payload is + * '\0'-terminated + */ + allocbytes++; if ((controlvm_payload_bytes_buffered + bytes) > MAX_CONTROLVM_PAYLOAD_BYTES) { if (retry) @@ -437,26 +436,8 @@ parser_init_guts(u64 addr, u32 bytes, bool local, memcpy_fromio(ctx->data, mapping, bytes); release_mem_region(addr, bytes); } - if (!standard_payload_header) { - ctx->byte_stream = true; - rc = ctx; - goto cleanup; - } - phdr = (struct spar_controlvm_parameters_header *)(ctx->data); - if (phdr->total_length != bytes) { - rc = NULL; - goto cleanup; - } - if (phdr->total_length < phdr->header_length) { - rc = NULL; - goto cleanup; - } - if (phdr->header_length < - sizeof(struct spar_controlvm_parameters_header)) { - rc = NULL; - goto cleanup; - } + ctx->byte_stream = true; rc = ctx; cleanup: if (rc) { @@ -478,7 +459,7 @@ cleanup: static struct parser_context * parser_init_byte_stream(u64 addr, u32 bytes, bool local, bool *retry) { - return parser_init_guts(addr, bytes, local, false, retry); + return parser_init_guts(addr, bytes, local, retry); } static uuid_le From fbf355365fd652d12ed991832e582ea2ef1e8576 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:37:14 -0400 Subject: [PATCH 0299/1163] staging: unisys: Remove wrapper around parser_init_guts() Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchipset.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 2cf59cacc7f4..ac75ddfba1ba 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -376,7 +376,7 @@ static void controlvm_respond_physdev_changestate( static void parser_done(struct parser_context *ctx); static struct parser_context * -parser_init_guts(u64 addr, u32 bytes, bool local, bool *retry) +parser_init_byte_stream(u64 addr, u32 bytes, bool local, bool *retry) { int allocbytes = sizeof(struct parser_context) + bytes; struct parser_context *rc = NULL; @@ -451,17 +451,6 @@ cleanup: return rc; } -/* Call this instead of parser_init() if the payload area consists of just - * a sequence of bytes, rather than a struct spar_controlvm_parameters_header - * structures. Afterwards, you can call parser_simpleString_get() or - * parser_byteStream_get() to obtain the data. - */ -static struct parser_context * -parser_init_byte_stream(u64 addr, u32 bytes, bool local, bool *retry) -{ - return parser_init_guts(addr, bytes, local, retry); -} - static uuid_le parser_id_get(struct parser_context *ctx) { From c2ec4b23c972f49e32d408fb19c673ab44fb9540 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:37:15 -0400 Subject: [PATCH 0300/1163] staging: unisys: visorchipset: Remove unused cache allocator Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorchipset.c | 39 ------------------- 1 file changed, 39 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index ac75ddfba1ba..ca22f49f386b 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -2223,45 +2223,6 @@ visorchipset_set_device_context(u32 bus_no, u32 dev_no, void *context) } EXPORT_SYMBOL_GPL(visorchipset_set_device_context); -/* Generic wrapper function for allocating memory from a kmem_cache pool. - */ -void * -visorchipset_cache_alloc(struct kmem_cache *pool, bool ok_to_block, - char *fn, int ln) -{ - gfp_t gfp; - void *p; - - if (ok_to_block) - gfp = GFP_KERNEL; - else - gfp = GFP_ATOMIC; - /* __GFP_NORETRY means "ok to fail", meaning - * kmem_cache_alloc() can return NULL, implying the caller CAN - * cope with failure. If you do NOT specify __GFP_NORETRY, - * Linux will go to extreme measures to get memory for you - * (like, invoke oom killer), which will probably cripple the - * system. - */ - gfp |= __GFP_NORETRY; - p = kmem_cache_alloc(pool, gfp); - if (!p) - return NULL; - - return p; -} - -/* Generic wrapper function for freeing memory from a kmem_cache pool. - */ -void -visorchipset_cache_free(struct kmem_cache *pool, void *p, char *fn, int ln) -{ - if (!p) - return; - - kmem_cache_free(pool, p); -} - static ssize_t chipsetready_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) From 7192a5dd54488b6fa81f071b2ae93e00b25f0ddd Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 5 May 2015 18:37:16 -0400 Subject: [PATCH 0301/1163] staging: unisys: uislib.h: Remove unused cache allocation prototypes Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index c7d0ba8aafd8..4514772323ac 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -284,11 +284,6 @@ static inline unsigned int issue_vmcall_channel_mismatch(const char *chname, } #define UIS_DAEMONIZE(nam) -void *uislib_cache_alloc(struct kmem_cache *cur_pool, char *fn, int ln); -#define UISCACHEALLOC(cur_pool) uislib_cache_alloc(cur_pool, __FILE__, __LINE__) -void uislib_cache_free(struct kmem_cache *cur_pool, void *p, char *fn, int ln); -#define UISCACHEFREE(cur_pool, p) \ - uislib_cache_free(cur_pool, p, __FILE__, __LINE__) void uislib_enable_channel_interrupts(u32 bus_no, u32 dev_no, int (*interrupt)(void *), From 05dd0c9fcb34f8335728a2c4ea7f5bb5829900bc Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:26 -0700 Subject: [PATCH 0302/1163] staging: comedi: ni_mio_common: refactor m-series stc register handling For M-Series boards (devpriv->is_m_series), the STC registers need to be remapped. This is currently handled with some big switch statements to convert the STC register offset to the M-Series offset. Some of the registers also need special handling due to differences in the register size on the M-Series boards. Create some lookup tables to handle the remapping of the read and write registers. These are easier to maintain and can contain the register size so that a common function can be used instead of the separate helpers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 356 ++++++------------ 1 file changed, 117 insertions(+), 239 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 69d71f328006..ecfd0976a776 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -308,262 +308,140 @@ static uint8_t ni_readb(struct comedi_device *dev, int reg) * windowed STC registers to the m series register offsets. */ -static void m_series_stc_writel(struct comedi_device *dev, - uint32_t data, int reg) -{ - unsigned offset; +struct mio_regmap { + unsigned int mio_reg; + int size; +}; - switch (reg) { - case AI_SC_Load_A_Registers: - offset = M_Offset_AI_SC_Load_A; - break; - case AI_SI_Load_A_Registers: - offset = M_Offset_AI_SI_Load_A; - break; - case AO_BC_Load_A_Register: - offset = M_Offset_AO_BC_Load_A; - break; - case AO_UC_Load_A_Register: - offset = M_Offset_AO_UC_Load_A; - break; - case AO_UI_Load_A_Register: - offset = M_Offset_AO_UI_Load_A; - break; - case G_Load_A_Register(0): - offset = M_Offset_G0_Load_A; - break; - case G_Load_A_Register(1): - offset = M_Offset_G1_Load_A; - break; - case G_Load_B_Register(0): - offset = M_Offset_G0_Load_B; - break; - case G_Load_B_Register(1): - offset = M_Offset_G1_Load_B; - break; - default: - dev_warn(dev->class_dev, - "%s: bug! unhandled register=0x%x in switch\n", +static const struct mio_regmap m_series_stc_write_regmap[] = { + [Interrupt_A_Ack_Register] = { M_Offset_Interrupt_A_Ack, 2 }, + [Interrupt_B_Ack_Register] = { M_Offset_Interrupt_B_Ack, 2 }, + [AI_Command_2_Register] = { M_Offset_AI_Command_2, 2 }, + [AO_Command_2_Register] = { M_Offset_AO_Command_2, 2 }, + [G_Command_Register(0)] = { M_Offset_G0_Command, 2 }, + [G_Command_Register(1)] = { M_Offset_G1_Command, 2 }, + [AI_Command_1_Register] = { M_Offset_AI_Command_1, 2 }, + [AO_Command_1_Register] = { M_Offset_AO_Command_1, 2 }, + [DIO_Output_Register] = { 0, 0 }, /* DOES NOT MAP CLEANLY */ + /* + * DIO_Output_Register maps to: + * { M_Offset_Static_Digital_Output, 4 } + * { M_Offset_SCXI_Serial_Data_Out, 1 } + */ + [DIO_Control_Register] = { 0, 0 }, /* DOES NOT MAP CLEANLY */ + [AI_Mode_1_Register] = { M_Offset_AI_Mode_1, 2 }, + [AI_Mode_2_Register] = { M_Offset_AI_Mode_2, 2 }, + [AI_SI_Load_A_Registers] = { M_Offset_AI_SI_Load_A, 4 }, + [AI_SC_Load_A_Registers] = { M_Offset_AI_SC_Load_A, 4 }, + [AI_SI2_Load_A_Register] = { M_Offset_AI_SI2_Load_A, 4 }, + [AI_SI2_Load_B_Register] = { M_Offset_AI_SI2_Load_B, 4 }, + [G_Mode_Register(0)] = { M_Offset_G0_Mode, 2 }, + [G_Mode_Register(1)] = { M_Offset_G1_Mode, 2 }, + [G_Load_A_Register(0)] = { M_Offset_G0_Load_A, 4 }, + [G_Load_B_Register(0)] = { M_Offset_G0_Load_B, 4 }, + [G_Load_A_Register(1)] = { M_Offset_G1_Load_A, 4 }, + [G_Load_B_Register(1)] = { M_Offset_G1_Load_B, 4 }, + [G_Input_Select_Register(0)] = { M_Offset_G0_Input_Select, 2 }, + [G_Input_Select_Register(1)] = { M_Offset_G1_Input_Select, 2 }, + [AO_Mode_1_Register] = { M_Offset_AO_Mode_1, 2 }, + [AO_Mode_2_Register] = { M_Offset_AO_Mode_2, 2 }, + [AO_UI_Load_A_Register] = { M_Offset_AO_UI_Load_A, 4 }, + [AO_BC_Load_A_Register] = { M_Offset_AO_BC_Load_A, 4 }, + [AO_UC_Load_A_Register] = { M_Offset_AO_UC_Load_A, 4 }, + [Clock_and_FOUT_Register] = { M_Offset_Clock_and_FOUT, 2 }, + [IO_Bidirection_Pin_Register] = { M_Offset_IO_Bidirection_Pin, 2 }, + [RTSI_Trig_Direction_Register] = { M_Offset_RTSI_Trig_Direction, 2 }, + [Interrupt_Control_Register] = { M_Offset_Interrupt_Control, 2 }, + [AI_Output_Control_Register] = { M_Offset_AI_Output_Control, 2 }, + [Analog_Trigger_Etc_Register] = { M_Offset_Analog_Trigger_Etc, 2 }, + [AI_START_STOP_Select_Register] = { M_Offset_AI_START_STOP_Select, 2 }, + [AI_Trigger_Select_Register] = { M_Offset_AI_Trigger_Select, 2 }, + [AO_Start_Select_Register] = { M_Offset_AO_Start_Select, 2 }, + [AO_Trigger_Select_Register] = { M_Offset_AO_Trigger_Select, 2 }, + [G_Autoincrement_Register(0)] = { M_Offset_G0_Autoincrement, 2 }, + [G_Autoincrement_Register(1)] = { M_Offset_G1_Autoincrement, 2 }, + [AO_Mode_3_Register] = { M_Offset_AO_Mode_3, 2 }, + [Joint_Reset_Register] = { M_Offset_Joint_Reset, 2 }, + [Interrupt_A_Enable_Register] = { M_Offset_Interrupt_A_Enable, 2 }, + [Interrupt_B_Enable_Register] = { M_Offset_Interrupt_B_Enable, 2 }, + [AI_Personal_Register] = { M_Offset_AI_Personal, 2 }, + [AO_Personal_Register] = { M_Offset_AO_Personal, 2 }, + [RTSI_Trig_A_Output_Register] = { M_Offset_RTSI_Trig_A_Output, 2 }, + [RTSI_Trig_B_Output_Register] = { M_Offset_RTSI_Trig_B_Output, 2 }, + [Configuration_Memory_Clear] = { M_Offset_Configuration_Memory_Clear, + 2 }, + [ADC_FIFO_Clear] = { M_Offset_AI_FIFO_Clear, 2 }, + [DAC_FIFO_Clear] = { M_Offset_AO_FIFO_Clear, 2 }, + [AO_Output_Control_Register] = { M_Offset_AO_Output_Control, 2 }, + [AI_Mode_3_Register] = { M_Offset_AI_Mode_3, 2 }, +}; + +static void m_series_stc_write(struct comedi_device *dev, + unsigned int data, unsigned int reg) +{ + const struct mio_regmap *regmap; + + if (reg < ARRAY_SIZE(m_series_stc_write_regmap)) { + regmap = &m_series_stc_write_regmap[reg]; + } else { + dev_warn(dev->class_dev, "%s: unhandled register=0x%x\n", __func__, reg); return; } - ni_writel(dev, data, offset); -} -static void m_series_stc_writew(struct comedi_device *dev, - uint16_t data, int reg) -{ - unsigned offset; - - switch (reg) { - case ADC_FIFO_Clear: - offset = M_Offset_AI_FIFO_Clear; + switch (regmap->size) { + case 4: + ni_writel(dev, data, regmap->mio_reg); break; - case AI_Command_1_Register: - offset = M_Offset_AI_Command_1; + case 2: + ni_writew(dev, data, regmap->mio_reg); break; - case AI_Command_2_Register: - offset = M_Offset_AI_Command_2; - break; - case AI_Mode_1_Register: - offset = M_Offset_AI_Mode_1; - break; - case AI_Mode_2_Register: - offset = M_Offset_AI_Mode_2; - break; - case AI_Mode_3_Register: - offset = M_Offset_AI_Mode_3; - break; - case AI_Output_Control_Register: - offset = M_Offset_AI_Output_Control; - break; - case AI_Personal_Register: - offset = M_Offset_AI_Personal; - break; - case AI_SI2_Load_A_Register: - /* this is a 32 bit register on m series boards */ - ni_writel(dev, data, M_Offset_AI_SI2_Load_A); - return; - case AI_SI2_Load_B_Register: - /* this is a 32 bit register on m series boards */ - ni_writel(dev, data, M_Offset_AI_SI2_Load_B); - return; - case AI_START_STOP_Select_Register: - offset = M_Offset_AI_START_STOP_Select; - break; - case AI_Trigger_Select_Register: - offset = M_Offset_AI_Trigger_Select; - break; - case Analog_Trigger_Etc_Register: - offset = M_Offset_Analog_Trigger_Etc; - break; - case AO_Command_1_Register: - offset = M_Offset_AO_Command_1; - break; - case AO_Command_2_Register: - offset = M_Offset_AO_Command_2; - break; - case AO_Mode_1_Register: - offset = M_Offset_AO_Mode_1; - break; - case AO_Mode_2_Register: - offset = M_Offset_AO_Mode_2; - break; - case AO_Mode_3_Register: - offset = M_Offset_AO_Mode_3; - break; - case AO_Output_Control_Register: - offset = M_Offset_AO_Output_Control; - break; - case AO_Personal_Register: - offset = M_Offset_AO_Personal; - break; - case AO_Start_Select_Register: - offset = M_Offset_AO_Start_Select; - break; - case AO_Trigger_Select_Register: - offset = M_Offset_AO_Trigger_Select; - break; - case Clock_and_FOUT_Register: - offset = M_Offset_Clock_and_FOUT; - break; - case Configuration_Memory_Clear: - offset = M_Offset_Configuration_Memory_Clear; - break; - case DAC_FIFO_Clear: - offset = M_Offset_AO_FIFO_Clear; - break; - case DIO_Control_Register: - dev_dbg(dev->class_dev, - "%s: FIXME: register 0x%x does not map cleanly on to m-series boards\n", - __func__, reg); - return; - case G_Autoincrement_Register(0): - offset = M_Offset_G0_Autoincrement; - break; - case G_Autoincrement_Register(1): - offset = M_Offset_G1_Autoincrement; - break; - case G_Command_Register(0): - offset = M_Offset_G0_Command; - break; - case G_Command_Register(1): - offset = M_Offset_G1_Command; - break; - case G_Input_Select_Register(0): - offset = M_Offset_G0_Input_Select; - break; - case G_Input_Select_Register(1): - offset = M_Offset_G1_Input_Select; - break; - case G_Mode_Register(0): - offset = M_Offset_G0_Mode; - break; - case G_Mode_Register(1): - offset = M_Offset_G1_Mode; - break; - case Interrupt_A_Ack_Register: - offset = M_Offset_Interrupt_A_Ack; - break; - case Interrupt_A_Enable_Register: - offset = M_Offset_Interrupt_A_Enable; - break; - case Interrupt_B_Ack_Register: - offset = M_Offset_Interrupt_B_Ack; - break; - case Interrupt_B_Enable_Register: - offset = M_Offset_Interrupt_B_Enable; - break; - case Interrupt_Control_Register: - offset = M_Offset_Interrupt_Control; - break; - case IO_Bidirection_Pin_Register: - offset = M_Offset_IO_Bidirection_Pin; - break; - case Joint_Reset_Register: - offset = M_Offset_Joint_Reset; - break; - case RTSI_Trig_A_Output_Register: - offset = M_Offset_RTSI_Trig_A_Output; - break; - case RTSI_Trig_B_Output_Register: - offset = M_Offset_RTSI_Trig_B_Output; - break; - case RTSI_Trig_Direction_Register: - offset = M_Offset_RTSI_Trig_Direction; - break; - /* - * FIXME: DIO_Output_Register (16 bit reg) is replaced by - * M_Offset_Static_Digital_Output (32 bit) and - * M_Offset_SCXI_Serial_Data_Out (8 bit) - */ default: - dev_warn(dev->class_dev, - "%s: bug! unhandled register=0x%x in switch\n", + dev_warn(dev->class_dev, "%s: unmapped register=0x%x\n", __func__, reg); - return; + break; } - ni_writew(dev, data, offset); } -static uint32_t m_series_stc_readl(struct comedi_device *dev, int reg) -{ - unsigned offset; +static const struct mio_regmap m_series_stc_read_regmap[] = { + [AI_Status_1_Register] = { M_Offset_AI_Status_1, 2 }, + [AO_Status_1_Register] = { M_Offset_AO_Status_1, 2 }, + [G_Status_Register] = { M_Offset_G01_Status, 2 }, + [AO_Status_2_Register] = { M_Offset_AO_Status_2, 2 }, + [G_HW_Save_Register(0)] = { M_Offset_G0_HW_Save, 4 }, + [G_HW_Save_Register(1)] = { M_Offset_G1_HW_Save, 4 }, + [G_Save_Register(0)] = { M_Offset_G0_Save, 4 }, + [G_Save_Register(1)] = { M_Offset_G1_Save, 4 }, + [Joint_Status_1_Register] = { M_Offset_Joint_Status_1, 2 }, + [DIO_Serial_Input_Register] = { M_Offset_SCXI_Serial_Data_In, 1 }, + [Joint_Status_2_Register] = { M_Offset_Joint_Status_2, 2 }, +}; - switch (reg) { - case G_HW_Save_Register(0): - offset = M_Offset_G0_HW_Save; - break; - case G_HW_Save_Register(1): - offset = M_Offset_G1_HW_Save; - break; - case G_Save_Register(0): - offset = M_Offset_G0_Save; - break; - case G_Save_Register(1): - offset = M_Offset_G1_Save; - break; - default: - dev_warn(dev->class_dev, - "%s: bug! unhandled register=0x%x in switch\n", +static unsigned int m_series_stc_read(struct comedi_device *dev, + unsigned int reg) +{ + const struct mio_regmap *regmap; + + if (reg < ARRAY_SIZE(m_series_stc_read_regmap)) { + regmap = &m_series_stc_read_regmap[reg]; + } else { + dev_warn(dev->class_dev, "%s: unhandled register=0x%x\n", __func__, reg); return 0; } - return ni_readl(dev, offset); -} -static uint16_t m_series_stc_readw(struct comedi_device *dev, int reg) -{ - unsigned offset; - - switch (reg) { - case AI_Status_1_Register: - offset = M_Offset_AI_Status_1; - break; - case AO_Status_1_Register: - offset = M_Offset_AO_Status_1; - break; - case AO_Status_2_Register: - offset = M_Offset_AO_Status_2; - break; - case DIO_Serial_Input_Register: - return ni_readb(dev, M_Offset_SCXI_Serial_Data_In); - case Joint_Status_1_Register: - offset = M_Offset_Joint_Status_1; - break; - case Joint_Status_2_Register: - offset = M_Offset_Joint_Status_2; - break; - case G_Status_Register: - offset = M_Offset_G01_Status; - break; + switch (regmap->size) { + case 4: + return ni_readl(dev, regmap->mio_reg); + case 2: + return ni_readw(dev, regmap->mio_reg); + case 1: + return ni_readb(dev, regmap->mio_reg); default: - dev_warn(dev->class_dev, - "%s: bug! unhandled register=0x%x in switch\n", + dev_warn(dev->class_dev, "%s: unmapped register=0x%x\n", __func__, reg); return 0; } - return ni_readw(dev, offset); } static void ni_stc_writew(struct comedi_device *dev, uint16_t data, int reg) @@ -572,7 +450,7 @@ static void ni_stc_writew(struct comedi_device *dev, uint16_t data, int reg) unsigned long flags; if (devpriv->is_m_series) { - m_series_stc_writew(dev, data, reg); + m_series_stc_write(dev, data, reg); } else { spin_lock_irqsave(&devpriv->window_lock, flags); if (!devpriv->mite && reg < 8) { @@ -590,7 +468,7 @@ static void ni_stc_writel(struct comedi_device *dev, uint32_t data, int reg) struct ni_private *devpriv = dev->private; if (devpriv->is_m_series) { - m_series_stc_writel(dev, data, reg); + m_series_stc_write(dev, data, reg); } else { ni_stc_writew(dev, data >> 16, reg); ni_stc_writew(dev, data & 0xffff, reg + 1); @@ -604,7 +482,7 @@ static uint16_t ni_stc_readw(struct comedi_device *dev, int reg) uint16_t val; if (devpriv->is_m_series) { - val = m_series_stc_readw(dev, reg); + val = m_series_stc_read(dev, reg); } else { spin_lock_irqsave(&devpriv->window_lock, flags); if (!devpriv->mite && reg < 8) { @@ -624,7 +502,7 @@ static uint32_t ni_stc_readl(struct comedi_device *dev, int reg) uint32_t val; if (devpriv->is_m_series) { - val = m_series_stc_readl(dev, reg); + val = m_series_stc_read(dev, reg); } else { val = ni_stc_readw(dev, reg) << 16; val |= ni_stc_readw(dev, reg + 1); From 2475c548e77dda4b7815bb81f65d04242d46d6fb Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:27 -0700 Subject: [PATCH 0303/1163] staging: comedi: ni_mio_common: open code the M-Series regmap offsets Remove the enum m_series_register_offsets values that are only used in the lookup tables for the STC to M-Series register mapping and just open code the values. Having the extra level of indirection does not add any additional clarity and it gets rid of some of the CamelCase symbols. Some of the registers are not currently used by the driver so the mappings were not present in the original switch code. Add the missing register mappings to the lookup tables. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 143 ++++++++++-------- drivers/staging/comedi/drivers/ni_stc.h | 82 ---------- 2 files changed, 79 insertions(+), 146 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index ecfd0976a776..fe7a6a0d06b2 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -314,14 +314,14 @@ struct mio_regmap { }; static const struct mio_regmap m_series_stc_write_regmap[] = { - [Interrupt_A_Ack_Register] = { M_Offset_Interrupt_A_Ack, 2 }, - [Interrupt_B_Ack_Register] = { M_Offset_Interrupt_B_Ack, 2 }, - [AI_Command_2_Register] = { M_Offset_AI_Command_2, 2 }, - [AO_Command_2_Register] = { M_Offset_AO_Command_2, 2 }, - [G_Command_Register(0)] = { M_Offset_G0_Command, 2 }, - [G_Command_Register(1)] = { M_Offset_G1_Command, 2 }, - [AI_Command_1_Register] = { M_Offset_AI_Command_1, 2 }, - [AO_Command_1_Register] = { M_Offset_AO_Command_1, 2 }, + [Interrupt_A_Ack_Register] = { 0x104, 2 }, + [Interrupt_B_Ack_Register] = { 0x106, 2 }, + [AI_Command_2_Register] = { 0x108, 2 }, + [AO_Command_2_Register] = { 0x10a, 2 }, + [G_Command_Register(0)] = { 0x10c, 2 }, + [G_Command_Register(1)] = { 0x10e, 2 }, + [AI_Command_1_Register] = { 0x110, 2 }, + [AO_Command_1_Register] = { 0x112, 2 }, [DIO_Output_Register] = { 0, 0 }, /* DOES NOT MAP CLEANLY */ /* * DIO_Output_Register maps to: @@ -329,51 +329,59 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { * { M_Offset_SCXI_Serial_Data_Out, 1 } */ [DIO_Control_Register] = { 0, 0 }, /* DOES NOT MAP CLEANLY */ - [AI_Mode_1_Register] = { M_Offset_AI_Mode_1, 2 }, - [AI_Mode_2_Register] = { M_Offset_AI_Mode_2, 2 }, - [AI_SI_Load_A_Registers] = { M_Offset_AI_SI_Load_A, 4 }, - [AI_SC_Load_A_Registers] = { M_Offset_AI_SC_Load_A, 4 }, - [AI_SI2_Load_A_Register] = { M_Offset_AI_SI2_Load_A, 4 }, - [AI_SI2_Load_B_Register] = { M_Offset_AI_SI2_Load_B, 4 }, - [G_Mode_Register(0)] = { M_Offset_G0_Mode, 2 }, - [G_Mode_Register(1)] = { M_Offset_G1_Mode, 2 }, - [G_Load_A_Register(0)] = { M_Offset_G0_Load_A, 4 }, - [G_Load_B_Register(0)] = { M_Offset_G0_Load_B, 4 }, - [G_Load_A_Register(1)] = { M_Offset_G1_Load_A, 4 }, - [G_Load_B_Register(1)] = { M_Offset_G1_Load_B, 4 }, - [G_Input_Select_Register(0)] = { M_Offset_G0_Input_Select, 2 }, - [G_Input_Select_Register(1)] = { M_Offset_G1_Input_Select, 2 }, - [AO_Mode_1_Register] = { M_Offset_AO_Mode_1, 2 }, - [AO_Mode_2_Register] = { M_Offset_AO_Mode_2, 2 }, - [AO_UI_Load_A_Register] = { M_Offset_AO_UI_Load_A, 4 }, - [AO_BC_Load_A_Register] = { M_Offset_AO_BC_Load_A, 4 }, - [AO_UC_Load_A_Register] = { M_Offset_AO_UC_Load_A, 4 }, - [Clock_and_FOUT_Register] = { M_Offset_Clock_and_FOUT, 2 }, - [IO_Bidirection_Pin_Register] = { M_Offset_IO_Bidirection_Pin, 2 }, - [RTSI_Trig_Direction_Register] = { M_Offset_RTSI_Trig_Direction, 2 }, - [Interrupt_Control_Register] = { M_Offset_Interrupt_Control, 2 }, - [AI_Output_Control_Register] = { M_Offset_AI_Output_Control, 2 }, - [Analog_Trigger_Etc_Register] = { M_Offset_Analog_Trigger_Etc, 2 }, - [AI_START_STOP_Select_Register] = { M_Offset_AI_START_STOP_Select, 2 }, - [AI_Trigger_Select_Register] = { M_Offset_AI_Trigger_Select, 2 }, - [AO_Start_Select_Register] = { M_Offset_AO_Start_Select, 2 }, - [AO_Trigger_Select_Register] = { M_Offset_AO_Trigger_Select, 2 }, - [G_Autoincrement_Register(0)] = { M_Offset_G0_Autoincrement, 2 }, - [G_Autoincrement_Register(1)] = { M_Offset_G1_Autoincrement, 2 }, - [AO_Mode_3_Register] = { M_Offset_AO_Mode_3, 2 }, - [Joint_Reset_Register] = { M_Offset_Joint_Reset, 2 }, - [Interrupt_A_Enable_Register] = { M_Offset_Interrupt_A_Enable, 2 }, - [Interrupt_B_Enable_Register] = { M_Offset_Interrupt_B_Enable, 2 }, - [AI_Personal_Register] = { M_Offset_AI_Personal, 2 }, - [AO_Personal_Register] = { M_Offset_AO_Personal, 2 }, - [RTSI_Trig_A_Output_Register] = { M_Offset_RTSI_Trig_A_Output, 2 }, - [RTSI_Trig_B_Output_Register] = { M_Offset_RTSI_Trig_B_Output, 2 }, - [Configuration_Memory_Clear] = { M_Offset_Configuration_Memory_Clear, - 2 }, - [ADC_FIFO_Clear] = { M_Offset_AI_FIFO_Clear, 2 }, - [DAC_FIFO_Clear] = { M_Offset_AO_FIFO_Clear, 2 }, - [AO_Output_Control_Register] = { M_Offset_AO_Output_Control, 2 }, - [AI_Mode_3_Register] = { M_Offset_AI_Mode_3, 2 }, + [AI_Mode_1_Register] = { 0x118, 2 }, + [AI_Mode_2_Register] = { 0x11a, 2 }, + [AI_SI_Load_A_Registers] = { 0x11c, 4 }, + [AI_SI_Load_B_Registers] = { 0x120, 4 }, + [AI_SC_Load_A_Registers] = { 0x124, 4 }, + [AI_SC_Load_B_Registers] = { 0x128, 4 }, + [AI_SI2_Load_A_Register] = { 0x12c, 4 }, + [AI_SI2_Load_B_Register] = { 0x130, 4 }, + [G_Mode_Register(0)] = { 0x134, 2 }, + [G_Mode_Register(1)] = { 0x136, 2 }, + [G_Load_A_Register(0)] = { 0x138, 4 }, + [G_Load_B_Register(0)] = { 0x13c, 4 }, + [G_Load_A_Register(1)] = { 0x140, 4 }, + [G_Load_B_Register(1)] = { 0x144, 4 }, + [G_Input_Select_Register(0)] = { 0x148, 2 }, + [G_Input_Select_Register(1)] = { 0x14a, 2 }, + [AO_Mode_1_Register] = { 0x14c, 2 }, + [AO_Mode_2_Register] = { 0x14e, 2 }, + [AO_UI_Load_A_Register] = { 0x150, 4 }, + [AO_UI_Load_B_Register] = { 0x154, 4 }, + [AO_BC_Load_A_Register] = { 0x158, 4 }, + [AO_BC_Load_B_Register] = { 0x15c, 4 }, + [AO_UC_Load_A_Register] = { 0x160, 4 }, + [AO_UC_Load_B_Register] = { 0x164, 4 }, + [Clock_and_FOUT_Register] = { 0x170, 2 }, + [IO_Bidirection_Pin_Register] = { 0x172, 2 }, + [RTSI_Trig_Direction_Register] = { 0x174, 2 }, + [Interrupt_Control_Register] = { 0x176, 2 }, + [AI_Output_Control_Register] = { 0x178, 2 }, + [Analog_Trigger_Etc_Register] = { 0x17a, 2 }, + [AI_START_STOP_Select_Register] = { 0x17c, 2 }, + [AI_Trigger_Select_Register] = { 0x17e, 2 }, + [AI_DIV_Load_A_Register] = { 0x180, 4 }, + [AO_Start_Select_Register] = { 0x184, 2 }, + [AO_Trigger_Select_Register] = { 0x186, 2 }, + [G_Autoincrement_Register(0)] = { 0x188, 2 }, + [G_Autoincrement_Register(1)] = { 0x18a, 2 }, + [AO_Mode_3_Register] = { 0x18c, 2 }, + [Joint_Reset_Register] = { 0x190, 2 }, + [Interrupt_A_Enable_Register] = { 0x192, 2 }, + [Second_IRQ_A_Enable_Register] = { 0, 0 }, /* E-Series only */ + [Interrupt_B_Enable_Register] = { 0x196, 2 }, + [Second_IRQ_B_Enable_Register] = { 0, 0 }, /* E-Series only */ + [AI_Personal_Register] = { 0x19a, 2 }, + [AO_Personal_Register] = { 0x19c, 2 }, + [RTSI_Trig_A_Output_Register] = { 0x19e, 2 }, + [RTSI_Trig_B_Output_Register] = { 0x1a0, 2 }, + [RTSI_Board_Register] = { 0, 0 }, /* Unknown */ + [Configuration_Memory_Clear] = { 0x1a4, 2 }, + [ADC_FIFO_Clear] = { 0x1a6, 2 }, + [DAC_FIFO_Clear] = { 0x1a8, 2 }, + [AO_Output_Control_Register] = { 0x1ac, 2 }, + [AI_Mode_3_Register] = { 0x1ae, 2 }, }; static void m_series_stc_write(struct comedi_device *dev, @@ -404,17 +412,24 @@ static void m_series_stc_write(struct comedi_device *dev, } static const struct mio_regmap m_series_stc_read_regmap[] = { - [AI_Status_1_Register] = { M_Offset_AI_Status_1, 2 }, - [AO_Status_1_Register] = { M_Offset_AO_Status_1, 2 }, - [G_Status_Register] = { M_Offset_G01_Status, 2 }, - [AO_Status_2_Register] = { M_Offset_AO_Status_2, 2 }, - [G_HW_Save_Register(0)] = { M_Offset_G0_HW_Save, 4 }, - [G_HW_Save_Register(1)] = { M_Offset_G1_HW_Save, 4 }, - [G_Save_Register(0)] = { M_Offset_G0_Save, 4 }, - [G_Save_Register(1)] = { M_Offset_G1_Save, 4 }, - [Joint_Status_1_Register] = { M_Offset_Joint_Status_1, 2 }, - [DIO_Serial_Input_Register] = { M_Offset_SCXI_Serial_Data_In, 1 }, - [Joint_Status_2_Register] = { M_Offset_Joint_Status_2, 2 }, + [AI_Status_1_Register] = { 0x104, 2 }, + [AO_Status_1_Register] = { 0x106, 2 }, + [G_Status_Register] = { 0x108, 2 }, + [AI_Status_2_Register] = { 0, 0 }, /* Unknown */ + [AO_Status_2_Register] = { 0x10c, 2 }, + [DIO_Parallel_Input_Register] = { 0, 0 }, /* Unknown */ + [G_HW_Save_Register(0)] = { 0x110, 4 }, + [G_HW_Save_Register(1)] = { 0x114, 4 }, + [G_Save_Register(0)] = { 0x118, 4 }, + [G_Save_Register(1)] = { 0x11c, 4 }, + [AO_UI_Save_Registers] = { 0x120, 4 }, + [AO_BC_Save_Registers] = { 0x124, 4 }, + [AO_UC_Save_Registers] = { 0x128, 4 }, + [Joint_Status_1_Register] = { 0x136, 2 }, + [DIO_Serial_Input_Register] = { 0x009, 1 }, + [Joint_Status_2_Register] = { 0x13a, 2 }, + [AI_SI_Save_Registers] = { 0x180, 4 }, + [AI_SC_Save_Registers] = { 0x184, 4 }, }; static unsigned int m_series_stc_read(struct comedi_device *dev, diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index bd69c3f0acdc..9a1946e4d02a 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -924,7 +924,6 @@ enum m_series_register_offsets { M_Offset_CDIO_DMA_Select = 0x7, /* write */ M_Offset_SCXI_Status = 0x7, /* read */ M_Offset_AI_AO_Select = 0x9, /* write, same offset as e-series */ - M_Offset_SCXI_Serial_Data_In = 0x9, /* read */ M_Offset_G0_G1_Select = 0xb, /* write, same offset as e-series */ M_Offset_Misc_Command = 0xf, M_Offset_SCXI_Serial_Data_Out = 0x11, @@ -947,88 +946,7 @@ enum m_series_register_offsets { M_Offset_PFI_Filter = 0xb0, M_Offset_RTSI_Filter = 0xb4, M_Offset_SCXI_Legacy_Compatibility = 0xbc, - M_Offset_Interrupt_A_Ack = 0x104, /* write */ - M_Offset_AI_Status_1 = 0x104, /* read */ - M_Offset_Interrupt_B_Ack = 0x106, /* write */ - M_Offset_AO_Status_1 = 0x106, /* read */ - M_Offset_AI_Command_2 = 0x108, /* write */ - M_Offset_G01_Status = 0x108, /* read */ - M_Offset_AO_Command_2 = 0x10a, - M_Offset_AO_Status_2 = 0x10c, /* read */ - M_Offset_G0_Command = 0x10c, /* write */ - M_Offset_G1_Command = 0x10e, /* write */ - M_Offset_G0_HW_Save = 0x110, - M_Offset_G0_HW_Save_High = 0x110, - M_Offset_AI_Command_1 = 0x110, - M_Offset_G0_HW_Save_Low = 0x112, - M_Offset_AO_Command_1 = 0x112, - M_Offset_G1_HW_Save = 0x114, - M_Offset_G1_HW_Save_High = 0x114, - M_Offset_G1_HW_Save_Low = 0x116, - M_Offset_AI_Mode_1 = 0x118, - M_Offset_G0_Save = 0x118, - M_Offset_G0_Save_High = 0x118, - M_Offset_AI_Mode_2 = 0x11a, - M_Offset_G0_Save_Low = 0x11a, - M_Offset_AI_SI_Load_A = 0x11c, - M_Offset_G1_Save = 0x11c, - M_Offset_G1_Save_High = 0x11c, - M_Offset_G1_Save_Low = 0x11e, - M_Offset_AI_SI_Load_B = 0x120, /* write */ - M_Offset_AO_UI_Save = 0x120, /* read */ - M_Offset_AI_SC_Load_A = 0x124, /* write */ - M_Offset_AO_BC_Save = 0x124, /* read */ - M_Offset_AI_SC_Load_B = 0x128, /* write */ - M_Offset_AO_UC_Save = 0x128, /* read */ - M_Offset_AI_SI2_Load_A = 0x12c, - M_Offset_AI_SI2_Load_B = 0x130, - M_Offset_G0_Mode = 0x134, - M_Offset_G1_Mode = 0x136, /* write */ - M_Offset_Joint_Status_1 = 0x136, /* read */ - M_Offset_G0_Load_A = 0x138, - M_Offset_Joint_Status_2 = 0x13a, - M_Offset_G0_Load_B = 0x13c, - M_Offset_G1_Load_A = 0x140, - M_Offset_G1_Load_B = 0x144, - M_Offset_G0_Input_Select = 0x148, - M_Offset_G1_Input_Select = 0x14a, - M_Offset_AO_Mode_1 = 0x14c, - M_Offset_AO_Mode_2 = 0x14e, - M_Offset_AO_UI_Load_A = 0x150, - M_Offset_AO_UI_Load_B = 0x154, - M_Offset_AO_BC_Load_A = 0x158, - M_Offset_AO_BC_Load_B = 0x15c, - M_Offset_AO_UC_Load_A = 0x160, - M_Offset_AO_UC_Load_B = 0x164, - M_Offset_Clock_and_FOUT = 0x170, - M_Offset_IO_Bidirection_Pin = 0x172, - M_Offset_RTSI_Trig_Direction = 0x174, - M_Offset_Interrupt_Control = 0x176, - M_Offset_AI_Output_Control = 0x178, - M_Offset_Analog_Trigger_Etc = 0x17a, - M_Offset_AI_START_STOP_Select = 0x17c, - M_Offset_AI_Trigger_Select = 0x17e, - M_Offset_AI_SI_Save = 0x180, /* read */ - M_Offset_AI_DIV_Load_A = 0x180, /* write */ - M_Offset_AI_SC_Save = 0x184, /* read */ - M_Offset_AO_Start_Select = 0x184, /* write */ - M_Offset_AO_Trigger_Select = 0x186, - M_Offset_AO_Mode_3 = 0x18c, - M_Offset_G0_Autoincrement = 0x188, - M_Offset_G1_Autoincrement = 0x18a, - M_Offset_Joint_Reset = 0x190, - M_Offset_Interrupt_A_Enable = 0x192, - M_Offset_Interrupt_B_Enable = 0x196, - M_Offset_AI_Personal = 0x19a, - M_Offset_AO_Personal = 0x19c, - M_Offset_RTSI_Trig_A_Output = 0x19e, - M_Offset_RTSI_Trig_B_Output = 0x1a0, M_Offset_RTSI_Shared_MUX = 0x1a2, - M_Offset_AO_Output_Control = 0x1ac, - M_Offset_AI_Mode_3 = 0x1ae, - M_Offset_Configuration_Memory_Clear = 0x1a4, - M_Offset_AI_FIFO_Clear = 0x1a6, - M_Offset_AO_FIFO_Clear = 0x1a8, M_Offset_G0_Counting_Mode = 0x1b0, M_Offset_G1_Counting_Mode = 0x1b2, M_Offset_G0_Second_Gate = 0x1b4, From cfdb3429da1c481ea8774588ca9268a447108526 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:28 -0700 Subject: [PATCH 0304/1163] staging: comedi: ni_mio_common: refactor gpct to stc register handling The NI General Purpose Counter Timer (gpct) registers are mapped to the STC registers with a big switch statement. Create a lookup table to handle the mapping ot the registers. This is easier to maintain. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 177 +++++++----------- 1 file changed, 63 insertions(+), 114 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index fe7a6a0d06b2..ce7bcd2c05f9 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -3749,103 +3749,66 @@ static void init_ao_67xx(struct comedi_device *dev, struct comedi_subdevice *s) ni_ao_win_outw(dev, 0x0, AO_Later_Single_Point_Updates); } -static unsigned ni_gpct_to_stc_register(enum ni_gpct_register reg) -{ - unsigned stc_register; +static const struct mio_regmap ni_gpct_to_stc_regmap[] = { + [NITIO_G0_AUTO_INC] = { G_Autoincrement_Register(0), 2 }, + [NITIO_G1_AUTO_INC] = { G_Autoincrement_Register(1), 2 }, + [NITIO_G0_CMD] = { G_Command_Register(0), 2 }, + [NITIO_G1_CMD] = { G_Command_Register(1), 2 }, + [NITIO_G0_HW_SAVE] = { G_HW_Save_Register(0), 4 }, + [NITIO_G1_HW_SAVE] = { G_HW_Save_Register(1), 4 }, + [NITIO_G0_SW_SAVE] = { G_Save_Register(0), 4 }, + [NITIO_G1_SW_SAVE] = { G_Save_Register(1), 4 }, + [NITIO_G0_MODE] = { G_Mode_Register(0), 2 }, + [NITIO_G1_MODE] = { G_Mode_Register(1), 2 }, + [NITIO_G0_LOADA] = { G_Load_A_Register(0), 4 }, + [NITIO_G1_LOADA] = { G_Load_A_Register(1), 4 }, + [NITIO_G0_LOADB] = { G_Load_B_Register(0), 4 }, + [NITIO_G1_LOADB] = { G_Load_B_Register(1), 4 }, + [NITIO_G0_INPUT_SEL] = { G_Input_Select_Register(0), 2 }, + [NITIO_G1_INPUT_SEL] = { G_Input_Select_Register(1), 2 }, + [NITIO_G0_CNT_MODE] = { M_Offset_G0_Counting_Mode, 2 }, + [NITIO_G1_CNT_MODE] = { M_Offset_G1_Counting_Mode, 2 }, + [NITIO_G0_GATE2] = { M_Offset_G0_Second_Gate, 2 }, + [NITIO_G1_GATE2] = { M_Offset_G1_Second_Gate, 2 }, + [NITIO_G01_STATUS] = { G_Status_Register, 2 }, + [NITIO_G01_RESET] = { Joint_Reset_Register, 2 }, + [NITIO_G01_STATUS1] = { Joint_Status_1_Register, 2 }, + [NITIO_G01_STATUS2] = { Joint_Status_2_Register, 2 }, + [NITIO_G0_DMA_CFG] = { M_Offset_G0_DMA_Config, 2 }, + [NITIO_G1_DMA_CFG] = { M_Offset_G1_DMA_Config, 2 }, + [NITIO_G0_DMA_STATUS] = { M_Offset_G0_DMA_Status, 2 }, + [NITIO_G1_DMA_STATUS] = { M_Offset_G1_DMA_Status, 2 }, + [NITIO_G0_ABZ] = { M_Offset_G0_MSeries_ABZ, 2 }, + [NITIO_G1_ABZ] = { M_Offset_G1_MSeries_ABZ, 2 }, + [NITIO_G0_INT_ACK] = { Interrupt_A_Ack_Register, 2 }, + [NITIO_G1_INT_ACK] = { Interrupt_B_Ack_Register, 2 }, + [NITIO_G0_STATUS] = { AI_Status_1_Register, 2 }, + [NITIO_G1_STATUS] = { AO_Status_1_Register, 2 }, + [NITIO_G0_INT_ENA] = { Interrupt_A_Enable_Register, 2 }, + [NITIO_G1_INT_ENA] = { Interrupt_B_Enable_Register, 2 }, +}; - switch (reg) { - case NITIO_G0_AUTO_INC: - stc_register = G_Autoincrement_Register(0); - break; - case NITIO_G1_AUTO_INC: - stc_register = G_Autoincrement_Register(1); - break; - case NITIO_G0_CMD: - stc_register = G_Command_Register(0); - break; - case NITIO_G1_CMD: - stc_register = G_Command_Register(1); - break; - case NITIO_G0_HW_SAVE: - stc_register = G_HW_Save_Register(0); - break; - case NITIO_G1_HW_SAVE: - stc_register = G_HW_Save_Register(1); - break; - case NITIO_G0_SW_SAVE: - stc_register = G_Save_Register(0); - break; - case NITIO_G1_SW_SAVE: - stc_register = G_Save_Register(1); - break; - case NITIO_G0_MODE: - stc_register = G_Mode_Register(0); - break; - case NITIO_G1_MODE: - stc_register = G_Mode_Register(1); - break; - case NITIO_G0_LOADA: - stc_register = G_Load_A_Register(0); - break; - case NITIO_G1_LOADA: - stc_register = G_Load_A_Register(1); - break; - case NITIO_G0_LOADB: - stc_register = G_Load_B_Register(0); - break; - case NITIO_G1_LOADB: - stc_register = G_Load_B_Register(1); - break; - case NITIO_G0_INPUT_SEL: - stc_register = G_Input_Select_Register(0); - break; - case NITIO_G1_INPUT_SEL: - stc_register = G_Input_Select_Register(1); - break; - case NITIO_G01_STATUS: - stc_register = G_Status_Register; - break; - case NITIO_G01_RESET: - stc_register = Joint_Reset_Register; - break; - case NITIO_G01_STATUS1: - stc_register = Joint_Status_1_Register; - break; - case NITIO_G01_STATUS2: - stc_register = Joint_Status_2_Register; - break; - case NITIO_G0_INT_ACK: - stc_register = Interrupt_A_Ack_Register; - break; - case NITIO_G1_INT_ACK: - stc_register = Interrupt_B_Ack_Register; - break; - case NITIO_G0_STATUS: - stc_register = AI_Status_1_Register; - break; - case NITIO_G1_STATUS: - stc_register = AO_Status_1_Register; - break; - case NITIO_G0_INT_ENA: - stc_register = Interrupt_A_Enable_Register; - break; - case NITIO_G1_INT_ENA: - stc_register = Interrupt_B_Enable_Register; - break; - default: - pr_err("%s: unhandled register 0x%x in switch.\n", - __func__, reg); - BUG(); +static unsigned int ni_gpct_to_stc_register(struct comedi_device *dev, + enum ni_gpct_register reg) +{ + const struct mio_regmap *regmap; + + if (reg < ARRAY_SIZE(ni_gpct_to_stc_regmap)) { + regmap = &ni_gpct_to_stc_regmap[reg]; + } else { + dev_warn(dev->class_dev,"%s: unhandled register 0x%x\n", + __func__, reg); return 0; } - return stc_register; + + return regmap->mio_reg; } static void ni_gpct_write_register(struct ni_gpct *counter, unsigned bits, enum ni_gpct_register reg) { struct comedi_device *dev = counter->counter_dev->dev; - unsigned stc_register; + unsigned int stc_register = ni_gpct_to_stc_register(dev, reg); /* bits in the join reset register which are relevant to counters */ static const unsigned gpct_joint_reset_mask = G0_Reset | G1_Reset; static const unsigned gpct_interrupt_a_enable_mask = @@ -3853,31 +3816,20 @@ static void ni_gpct_write_register(struct ni_gpct *counter, unsigned bits, static const unsigned gpct_interrupt_b_enable_mask = G1_Gate_Interrupt_Enable | G1_TC_Interrupt_Enable; + if (stc_register == 0) + return; + switch (reg) { - /* m-series-only registers */ + /* m-series only registers */ case NITIO_G0_CNT_MODE: - ni_writew(dev, bits, M_Offset_G0_Counting_Mode); - break; case NITIO_G1_CNT_MODE: - ni_writew(dev, bits, M_Offset_G1_Counting_Mode); - break; case NITIO_G0_GATE2: - ni_writew(dev, bits, M_Offset_G0_Second_Gate); - break; case NITIO_G1_GATE2: - ni_writew(dev, bits, M_Offset_G1_Second_Gate); - break; case NITIO_G0_DMA_CFG: - ni_writew(dev, bits, M_Offset_G0_DMA_Config); - break; case NITIO_G1_DMA_CFG: - ni_writew(dev, bits, M_Offset_G1_DMA_Config); - break; case NITIO_G0_ABZ: - ni_writew(dev, bits, M_Offset_G0_MSeries_ABZ); - break; case NITIO_G1_ABZ: - ni_writew(dev, bits, M_Offset_G1_MSeries_ABZ); + ni_writew(dev, bits, stc_register); break; /* 32 bit registers */ @@ -3885,26 +3837,24 @@ static void ni_gpct_write_register(struct ni_gpct *counter, unsigned bits, case NITIO_G1_LOADA: case NITIO_G0_LOADB: case NITIO_G1_LOADB: - stc_register = ni_gpct_to_stc_register(reg); ni_stc_writel(dev, bits, stc_register); break; /* 16 bit registers */ case NITIO_G0_INT_ENA: BUG_ON(bits & ~gpct_interrupt_a_enable_mask); - ni_set_bitfield(dev, Interrupt_A_Enable_Register, + ni_set_bitfield(dev, stc_register, gpct_interrupt_a_enable_mask, bits); break; case NITIO_G1_INT_ENA: BUG_ON(bits & ~gpct_interrupt_b_enable_mask); - ni_set_bitfield(dev, Interrupt_B_Enable_Register, + ni_set_bitfield(dev, stc_register, gpct_interrupt_b_enable_mask, bits); break; case NITIO_G01_RESET: BUG_ON(bits & ~gpct_joint_reset_mask); /* fall-through */ default: - stc_register = ni_gpct_to_stc_register(reg); ni_stc_writew(dev, bits, stc_register); } } @@ -3913,29 +3863,28 @@ static unsigned ni_gpct_read_register(struct ni_gpct *counter, enum ni_gpct_register reg) { struct comedi_device *dev = counter->counter_dev->dev; - unsigned stc_register; + unsigned int stc_register = ni_gpct_to_stc_register(dev, reg); + + if (stc_register == 0) + return 0; switch (reg) { /* m-series only registers */ case NITIO_G0_DMA_STATUS: - return ni_readw(dev, M_Offset_G0_DMA_Status); case NITIO_G1_DMA_STATUS: - return ni_readw(dev, M_Offset_G1_DMA_Status); + return ni_readw(dev, stc_register); /* 32 bit registers */ case NITIO_G0_HW_SAVE: case NITIO_G1_HW_SAVE: case NITIO_G0_SW_SAVE: case NITIO_G1_SW_SAVE: - stc_register = ni_gpct_to_stc_register(reg); return ni_stc_readl(dev, stc_register); /* 16 bit registers */ default: - stc_register = ni_gpct_to_stc_register(reg); return ni_stc_readw(dev, stc_register); } - return 0; } static int ni_freq_out_insn_read(struct comedi_device *dev, From 0a9752d81a636ccd01f473ee8c85b8a05f06a92b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:29 -0700 Subject: [PATCH 0305/1163] staging: comedi: ni_mio_common: open code the M-Series GPCT register offsets Remove the enum m_series_register_offsets values that are only used in the lookup tables for the GPCT to STC register mapping and just open code the values. Having the extra level of indirection does not add any additional clarity and it gets rid of some of the CamelCase symbols. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 20 +++++++++---------- drivers/staging/comedi/drivers/ni_stc.h | 10 ---------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index ce7bcd2c05f9..4aa45e083604 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -3766,20 +3766,20 @@ static const struct mio_regmap ni_gpct_to_stc_regmap[] = { [NITIO_G1_LOADB] = { G_Load_B_Register(1), 4 }, [NITIO_G0_INPUT_SEL] = { G_Input_Select_Register(0), 2 }, [NITIO_G1_INPUT_SEL] = { G_Input_Select_Register(1), 2 }, - [NITIO_G0_CNT_MODE] = { M_Offset_G0_Counting_Mode, 2 }, - [NITIO_G1_CNT_MODE] = { M_Offset_G1_Counting_Mode, 2 }, - [NITIO_G0_GATE2] = { M_Offset_G0_Second_Gate, 2 }, - [NITIO_G1_GATE2] = { M_Offset_G1_Second_Gate, 2 }, + [NITIO_G0_CNT_MODE] = { 0x1b0, 2 }, /* M-Series only */ + [NITIO_G1_CNT_MODE] = { 0x1b2, 2 }, /* M-Series only */ + [NITIO_G0_GATE2] = { 0x1b4, 2 }, /* M-Series only */ + [NITIO_G1_GATE2] = { 0x1b6, 2 }, /* M-Series only */ [NITIO_G01_STATUS] = { G_Status_Register, 2 }, [NITIO_G01_RESET] = { Joint_Reset_Register, 2 }, [NITIO_G01_STATUS1] = { Joint_Status_1_Register, 2 }, [NITIO_G01_STATUS2] = { Joint_Status_2_Register, 2 }, - [NITIO_G0_DMA_CFG] = { M_Offset_G0_DMA_Config, 2 }, - [NITIO_G1_DMA_CFG] = { M_Offset_G1_DMA_Config, 2 }, - [NITIO_G0_DMA_STATUS] = { M_Offset_G0_DMA_Status, 2 }, - [NITIO_G1_DMA_STATUS] = { M_Offset_G1_DMA_Status, 2 }, - [NITIO_G0_ABZ] = { M_Offset_G0_MSeries_ABZ, 2 }, - [NITIO_G1_ABZ] = { M_Offset_G1_MSeries_ABZ, 2 }, + [NITIO_G0_DMA_CFG] = { 0x1b8, 2 }, /* M-Series only */ + [NITIO_G1_DMA_CFG] = { 0x1ba, 2 }, /* M-Series only */ + [NITIO_G0_DMA_STATUS] = { 0x1b8, 2 }, /* M-Series only */ + [NITIO_G1_DMA_STATUS] = { 0x1ba, 2 }, /* M-Series only */ + [NITIO_G0_ABZ] = { 0x1c0, 2 }, /* M-Series only */ + [NITIO_G1_ABZ] = { 0x1c2, 2 }, /* M-Series only */ [NITIO_G0_INT_ACK] = { Interrupt_A_Ack_Register, 2 }, [NITIO_G1_INT_ACK] = { Interrupt_B_Ack_Register, 2 }, [NITIO_G0_STATUS] = { AI_Status_1_Register, 2 }, diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 9a1946e4d02a..69e710f19363 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -947,16 +947,6 @@ enum m_series_register_offsets { M_Offset_RTSI_Filter = 0xb4, M_Offset_SCXI_Legacy_Compatibility = 0xbc, M_Offset_RTSI_Shared_MUX = 0x1a2, - M_Offset_G0_Counting_Mode = 0x1b0, - M_Offset_G1_Counting_Mode = 0x1b2, - M_Offset_G0_Second_Gate = 0x1b4, - M_Offset_G1_Second_Gate = 0x1b6, - M_Offset_G0_DMA_Config = 0x1b8, /* write */ - M_Offset_G0_DMA_Status = 0x1b8, /* read */ - M_Offset_G1_DMA_Config = 0x1ba, /* write */ - M_Offset_G1_DMA_Status = 0x1ba, /* read */ - M_Offset_G0_MSeries_ABZ = 0x1c0, - M_Offset_G1_MSeries_ABZ = 0x1c2, M_Offset_Clock_and_Fout2 = 0x1c4, M_Offset_PLL_Control = 0x1c6, M_Offset_PLL_Status = 0x1c8, From e0852f6ac1949f2d2612861ab608a5b1c614150c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:30 -0700 Subject: [PATCH 0306/1163] staging: comedi: ni_mio_common: simplify ni_m_series_set_pfi_routing() This function is overly complex due to the M_Offset_PFI_Output_Select() helper using a 1 based index for the registers and the private data using a 0 based index for the cached values. Modify the M_Offset_PFI_Output_Select() helper to use a 0 based index and remove the sanity check which can never happen. The 'n' value passed is calculated from the subdevice channel which will always be in range. Tidy up the function by using a local variable to mask/set the pfi output select bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 20 +++++++++---------- drivers/staging/comedi/drivers/ni_stc.h | 7 +------ 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 4aa45e083604..c1b1d7c95982 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -4391,19 +4391,17 @@ static int ni_m_series_set_pfi_routing(struct comedi_device *dev, unsigned chan, unsigned source) { struct ni_private *devpriv = dev->private; - unsigned pfi_reg_index; - unsigned array_offset; + unsigned index = chan / 3; + unsigned short val = devpriv->pfi_output_select_reg[index]; if ((source & 0x1f) != source) return -EINVAL; - pfi_reg_index = 1 + chan / 3; - array_offset = pfi_reg_index - 1; - devpriv->pfi_output_select_reg[array_offset] &= - ~MSeries_PFI_Output_Select_Mask(chan); - devpriv->pfi_output_select_reg[array_offset] |= - MSeries_PFI_Output_Select_Bits(chan, source); - ni_writew(dev, devpriv->pfi_output_select_reg[array_offset], - M_Offset_PFI_Output_Select(pfi_reg_index)); + + val &= ~MSeries_PFI_Output_Select_Mask(chan); + val |= MSeries_PFI_Output_Select_Bits(chan, source); + ni_writew(dev, val, M_Offset_PFI_Output_Select(index)); + devpriv->pfi_output_select_reg[index] = val; + return 2; } @@ -5409,7 +5407,7 @@ static int ni_E_init(struct comedi_device *dev, ni_writew(dev, s->state, M_Offset_PFI_DO); for (i = 0; i < NUM_PFI_OUTPUT_SELECT_REGS; ++i) { ni_writew(dev, devpriv->pfi_output_select_reg[i], - M_Offset_PFI_Output_Select(i + 1)); + M_Offset_PFI_Output_Select(i)); } } else { s->n_chan = 10; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 69e710f19363..e9cabbde0ca1 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -1021,12 +1021,7 @@ static inline int M_Offset_AO_Reference_Attenuation(int channel) static inline unsigned M_Offset_PFI_Output_Select(unsigned n) { - if (n < 1 || n > NUM_PFI_OUTPUT_SELECT_REGS) { - pr_err("%s: invalid pfi output select register=%i\n", - __func__, n); - return M_Offset_PFI_Output_Select_1; - } - return M_Offset_PFI_Output_Select_1 + (n - 1) * 2; + return M_Offset_PFI_Output_Select_1 + (n * 2); } enum MSeries_AI_Config_FIFO_Data_Bits { From d2dde226094cb4d6e3116da09bf2d9803785683d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:31 -0700 Subject: [PATCH 0307/1163] staging: comedi: ni_stc.h: tidy up M_Offset_* values For aesthetics, define the M_Offset_* values instead of using an enum. Convert the inline helpers used to get some of the M-Series register offsets into macros. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_stc.h | 155 ++++++++---------------- 1 file changed, 52 insertions(+), 103 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index e9cabbde0ca1..2efd1ec84cc5 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -920,109 +920,58 @@ enum ni_reg_type { static const struct comedi_lrange range_ni_E_ao_ext; -enum m_series_register_offsets { - M_Offset_CDIO_DMA_Select = 0x7, /* write */ - M_Offset_SCXI_Status = 0x7, /* read */ - M_Offset_AI_AO_Select = 0x9, /* write, same offset as e-series */ - M_Offset_G0_G1_Select = 0xb, /* write, same offset as e-series */ - M_Offset_Misc_Command = 0xf, - M_Offset_SCXI_Serial_Data_Out = 0x11, - M_Offset_SCXI_Control = 0x13, - M_Offset_SCXI_Output_Enable = 0x15, - M_Offset_AI_FIFO_Data = 0x1c, - M_Offset_Static_Digital_Output = 0x24, /* write */ - M_Offset_Static_Digital_Input = 0x24, /* read */ - M_Offset_DIO_Direction = 0x28, - M_Offset_Cal_PWM = 0x40, - M_Offset_AI_Config_FIFO_Data = 0x5e, - M_Offset_Interrupt_C_Enable = 0x88, /* write */ - M_Offset_Interrupt_C_Status = 0x88, /* read */ - M_Offset_Analog_Trigger_Control = 0x8c, - M_Offset_AO_Serial_Interrupt_Enable = 0xa0, - M_Offset_AO_Serial_Interrupt_Ack = 0xa1, /* write */ - M_Offset_AO_Serial_Interrupt_Status = 0xa1, /* read */ - M_Offset_AO_Calibration = 0xa3, - M_Offset_AO_FIFO_Data = 0xa4, - M_Offset_PFI_Filter = 0xb0, - M_Offset_RTSI_Filter = 0xb4, - M_Offset_SCXI_Legacy_Compatibility = 0xbc, - M_Offset_RTSI_Shared_MUX = 0x1a2, - M_Offset_Clock_and_Fout2 = 0x1c4, - M_Offset_PLL_Control = 0x1c6, - M_Offset_PLL_Status = 0x1c8, - M_Offset_PFI_Output_Select_1 = 0x1d0, - M_Offset_PFI_Output_Select_2 = 0x1d2, - M_Offset_PFI_Output_Select_3 = 0x1d4, - M_Offset_PFI_Output_Select_4 = 0x1d6, - M_Offset_PFI_Output_Select_5 = 0x1d8, - M_Offset_PFI_Output_Select_6 = 0x1da, - M_Offset_PFI_DI = 0x1dc, - M_Offset_PFI_DO = 0x1de, - M_Offset_AI_Config_FIFO_Bypass = 0x218, - M_Offset_SCXI_DIO_Enable = 0x21c, - M_Offset_CDI_FIFO_Data = 0x220, /* read */ - M_Offset_CDO_FIFO_Data = 0x220, /* write */ - M_Offset_CDIO_Status = 0x224, /* read */ - M_Offset_CDIO_Command = 0x224, /* write */ - M_Offset_CDI_Mode = 0x228, - M_Offset_CDO_Mode = 0x22c, - M_Offset_CDI_Mask_Enable = 0x230, - M_Offset_CDO_Mask_Enable = 0x234, -}; -static inline int M_Offset_AO_Waveform_Order(int channel) -{ - return 0xc2 + 0x4 * channel; -}; - -static inline int M_Offset_AO_Config_Bank(int channel) -{ - return 0xc3 + 0x4 * channel; -}; - -static inline int M_Offset_DAC_Direct_Data(int channel) -{ - return 0xc0 + 0x4 * channel; -} - -static inline int M_Offset_Gen_PWM(int channel) -{ - return 0x44 + 0x2 * channel; -} - -static inline int M_Offset_Static_AI_Control(int i) -{ - int offset[] = { - 0x64, - 0x261, - 0x262, - 0x263, - }; - if (((unsigned)i) >= ARRAY_SIZE(offset)) { - pr_err("%s: invalid channel=%i\n", __func__, i); - return offset[0]; - } - return offset[i]; -}; - -static inline int M_Offset_AO_Reference_Attenuation(int channel) -{ - int offset[] = { - 0x264, - 0x265, - 0x266, - 0x267 - }; - if (((unsigned)channel) >= ARRAY_SIZE(offset)) { - pr_err("%s: invalid channel=%i\n", __func__, channel); - return offset[0]; - } - return offset[channel]; -}; - -static inline unsigned M_Offset_PFI_Output_Select(unsigned n) -{ - return M_Offset_PFI_Output_Select_1 + (n * 2); -} +/* + * M-Series specific registers not handled by the DAQ-STC and GPCT register + * remapping. + */ +#define M_Offset_CDIO_DMA_Select 0x007 +#define M_Offset_SCXI_Status 0x007 +#define M_Offset_AI_AO_Select 0x009 +#define M_Offset_G0_G1_Select 0x00b +#define M_Offset_Misc_Command 0x00f +#define M_Offset_SCXI_Serial_Data_Out 0x011 +#define M_Offset_SCXI_Control 0x013 +#define M_Offset_SCXI_Output_Enable 0x015 +#define M_Offset_AI_FIFO_Data 0x01c +#define M_Offset_Static_Digital_Output 0x024 +#define M_Offset_Static_Digital_Input 0x024 +#define M_Offset_DIO_Direction 0x028 +#define M_Offset_Cal_PWM 0x040 +#define M_Offset_Gen_PWM(x) (0x044 + ((x) * 2)) +#define M_Offset_AI_Config_FIFO_Data 0x05e +#define M_Offset_Interrupt_C_Enable 0x088 +#define M_Offset_Interrupt_C_Status 0x088 +#define M_Offset_Analog_Trigger_Control 0x08c +#define M_Offset_AO_Serial_Interrupt_Enable 0x0a0 +#define M_Offset_AO_Serial_Interrupt_Ack 0x0a1 +#define M_Offset_AO_Serial_Interrupt_Status 0x0a1 +#define M_Offset_AO_Calibration 0x0a3 +#define M_Offset_AO_FIFO_Data 0x0a4 +#define M_Offset_PFI_Filter 0x0b0 +#define M_Offset_RTSI_Filter 0x0b4 +#define M_Offset_SCXI_Legacy_Compatibility 0x0bc +#define M_Offset_DAC_Direct_Data(x) (0x0c0 + ((x) * 4)) +#define M_Offset_AO_Waveform_Order(x) (0x0c2 + ((x) * 4)) +#define M_Offset_AO_Config_Bank(x) (0x0c3 + ((x) * 4)) +#define M_Offset_RTSI_Shared_MUX 0x1a2 +#define M_Offset_Clock_and_Fout2 0x1c4 +#define M_Offset_PLL_Control 0x1c6 +#define M_Offset_PLL_Status 0x1c8 +#define M_Offset_PFI_Output_Select(x) (0x1d0 + ((x) * 2)) +#define M_Offset_PFI_DI 0x1dc +#define M_Offset_PFI_DO 0x1de +#define M_Offset_AI_Config_FIFO_Bypass 0x218 +#define M_Offset_SCXI_DIO_Enable 0x21c +#define M_Offset_CDI_FIFO_Data 0x220 +#define M_Offset_CDO_FIFO_Data 0x220 +#define M_Offset_CDIO_Status 0x224 +#define M_Offset_CDIO_Command 0x224 +#define M_Offset_CDI_Mode 0x228 +#define M_Offset_CDO_Mode 0x22c +#define M_Offset_CDI_Mask_Enable 0x230 +#define M_Offset_CDO_Mask_Enable 0x234 +#define M_Offset_Static_AI_Control(x) ((x) ? (0x260 + (x)) : 0x064) +#define M_Offset_AO_Reference_Attenuation(x) (0x264 + (x)) enum MSeries_AI_Config_FIFO_Data_Bits { MSeries_AI_Config_Channel_Type_Mask = 0x7 << 6, From f496471df95ef0a218d5ad8af9d6954f88c7072f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:32 -0700 Subject: [PATCH 0308/1163] staging: comedi: ni_stc.h: reg_type is not needed by MSeries_AI_Config_Bank_Bits() This helper function sets the bits in the M_Offset_AI_Config_FIFO_Data register to select the correct bank to configure a given analog output channel. The NI M Series boards are defined by the boardinfo to have 16, 32, or 80 channels. Only 2 of the M Series boards have 80 channels, those boards happen to have a reg_type of ni_reg_622x. The bank for the 16 and 32 channel boards is selected by the 'channel & 0x30' calculation (comedi channels 0 to 15 or 31). This also selects the bank for the first 64 channels of the 80 channel boards. The additional '|= 0x400' sets the bank to access the extra channels (comedi channels >= 63). Since all the non ni_reg_622x boards have at most 32 channels, the extra check of the 'reg_type' is not required in this function. Remove it as well as the parameter. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 3 +-- drivers/staging/comedi/drivers/ni_stc.h | 10 ++++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index c1b1d7c95982..7e038a27fec0 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1808,8 +1808,7 @@ static void ni_m_series_load_channelgain_list(struct comedi_device *dev, break; } config_bits |= MSeries_AI_Config_Channel_Bits(chan); - config_bits |= - MSeries_AI_Config_Bank_Bits(board->reg_type, chan); + config_bits |= MSeries_AI_Config_Bank_Bits(chan); config_bits |= MSeries_AI_Config_Gain_Bits(range_code); if (i == n_chan - 1) config_bits |= MSeries_AI_Config_Last_Channel_Bit; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 2efd1ec84cc5..aca6e5c34080 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -990,14 +990,12 @@ static inline unsigned MSeries_AI_Config_Channel_Bits(unsigned channel) return channel & 0xf; } -static inline unsigned MSeries_AI_Config_Bank_Bits(enum ni_reg_type reg_type, - unsigned channel) +static inline unsigned MSeries_AI_Config_Bank_Bits(unsigned channel) { unsigned bits = channel & 0x30; - if (reg_type == ni_reg_622x) { - if (channel & 0x40) - bits |= 0x400; - } + + if (channel & 0x40) + bits |= 0x400; return bits; } From b6cd5c228edefaa0143faffdb1ebf85e3afc5a43 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:33 -0700 Subject: [PATCH 0309/1163] staging: comedi: ni_stc.h: simplify MSeries_AI_Config_Bank_Bits() Simplify this helper function by using a bit-shift to set the high banks select bit. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_stc.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index aca6e5c34080..3c5ba613a2d6 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -992,11 +992,7 @@ static inline unsigned MSeries_AI_Config_Channel_Bits(unsigned channel) static inline unsigned MSeries_AI_Config_Bank_Bits(unsigned channel) { - unsigned bits = channel & 0x30; - - if (channel & 0x40) - bits |= 0x400; - return bits; + return ((channel & 0x40) << 4) | (channel & 0x30); } static inline unsigned MSeries_AI_Config_Gain_Bits(unsigned range) From 975b6d25c00c5bba5dfa77d062bde7f4772d34d7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:34 -0700 Subject: [PATCH 0310/1163] staging: comedi: ni_stc.h: rename M_Offset_* symbols Renamme these CamelCase symbols. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 129 +++++++++--------- drivers/staging/comedi/drivers/ni_stc.h | 95 +++++++------ 2 files changed, 110 insertions(+), 114 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 7e038a27fec0..93c7b1325f12 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -322,12 +322,11 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [G_Command_Register(1)] = { 0x10e, 2 }, [AI_Command_1_Register] = { 0x110, 2 }, [AO_Command_1_Register] = { 0x112, 2 }, + /* + * DIO_Output_Register maps to: + * { NI_M_DIO_REG, 4 } and { NI_M_SCXI_SER_DO_REG, 1 } + */ [DIO_Output_Register] = { 0, 0 }, /* DOES NOT MAP CLEANLY */ - /* - * DIO_Output_Register maps to: - * { M_Offset_Static_Digital_Output, 4 } - * { M_Offset_SCXI_Serial_Data_Out, 1 } - */ [DIO_Control_Register] = { 0, 0 }, /* DOES NOT MAP CLEANLY */ [AI_Mode_1_Register] = { 0x118, 2 }, [AI_Mode_2_Register] = { 0x11a, 2 }, @@ -633,7 +632,7 @@ static inline void ni_set_cdo_dma_channel(struct comedi_device *dev, (ni_stc_dma_channel_select_bitfield(mite_channel) << CDO_DMA_Select_Shift) & CDO_DMA_Select_Mask; } - ni_writeb(dev, devpriv->cdio_dma_select_reg, M_Offset_CDIO_DMA_Select); + ni_writeb(dev, devpriv->cdio_dma_select_reg, NI_M_CDIO_DMA_SEL_REG); mmiowb(); spin_unlock_irqrestore(&devpriv->soft_reg_copy_lock, flags); } @@ -853,8 +852,8 @@ static void ni_clear_ai_fifo(struct comedi_device *dev) } else { ni_stc_writew(dev, 1, ADC_FIFO_Clear); if (devpriv->is_625x) { - ni_writeb(dev, 0, M_Offset_Static_AI_Control(0)); - ni_writeb(dev, 1, M_Offset_Static_AI_Control(0)); + ni_writeb(dev, 0, NI_M_STATIC_AI_CTRL_REG(0)); + ni_writeb(dev, 1, NI_M_STATIC_AI_CTRL_REG(0)); #if 0 /* the NI example code does 3 convert pulses for 625x boards, but that appears to be wrong in practice. */ @@ -1777,9 +1776,9 @@ static void ni_m_series_load_channelgain_list(struct comedi_device *dev, bypass_bits |= MSeries_AI_Bypass_Dither_Bit; /* don't use 2's complement encoding */ bypass_bits |= MSeries_AI_Bypass_Polarity_Bit; - ni_writel(dev, bypass_bits, M_Offset_AI_Config_FIFO_Bypass); + ni_writel(dev, bypass_bits, NI_M_AI_CFG_BYPASS_FIFO_REG); } else { - ni_writel(dev, 0, M_Offset_AI_Config_FIFO_Bypass); + ni_writel(dev, 0, NI_M_AI_CFG_BYPASS_FIFO_REG); } for (i = 0; i < n_chan; i++) { unsigned config_bits = 0; @@ -1816,7 +1815,7 @@ static void ni_m_series_load_channelgain_list(struct comedi_device *dev, config_bits |= MSeries_AI_Config_Dither_Bit; /* don't use 2's complement encoding */ config_bits |= MSeries_AI_Config_Polarity_Bit; - ni_writew(dev, config_bits, M_Offset_AI_Config_FIFO_Data); + ni_writew(dev, config_bits, NI_M_AI_CFG_FIFO_DATA_REG); } ni_prime_channelgain_list(dev); } @@ -2050,7 +2049,7 @@ static int ni_ai_insn_read(struct comedi_device *dev, return -ETIME; } if (devpriv->is_m_series) { - dl = ni_readl(dev, M_Offset_AI_FIFO_Data); + dl = ni_readl(dev, NI_M_AI_FIFO_DATA_REG); dl &= mask; data[n] = dl; } else { @@ -2665,8 +2664,8 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device *dev, for (i = 0; i < s->n_chan; ++i) { devpriv->ao_conf[i] &= ~MSeries_AO_Update_Timed_Bit; ni_writeb(dev, devpriv->ao_conf[i], - M_Offset_AO_Config_Bank(i)); - ni_writeb(dev, 0xf, M_Offset_AO_Waveform_Order(i)); + NI_M_AO_CFG_BANK_REG(i)); + ni_writeb(dev, 0xf, NI_M_AO_WAVEFORM_ORDER_REG(i)); } } for (i = 0; i < n_chans; i++) { @@ -2680,23 +2679,21 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device *dev, switch (krange->max - krange->min) { case 20000000: conf |= MSeries_AO_DAC_Reference_10V_Internal_Bits; - ni_writeb(dev, 0, - M_Offset_AO_Reference_Attenuation(chan)); + ni_writeb(dev, 0, NI_M_AO_REF_ATTENUATION_REG(chan)); break; case 10000000: conf |= MSeries_AO_DAC_Reference_5V_Internal_Bits; - ni_writeb(dev, 0, - M_Offset_AO_Reference_Attenuation(chan)); + ni_writeb(dev, 0, NI_M_AO_REF_ATTENUATION_REG(chan)); break; case 4000000: conf |= MSeries_AO_DAC_Reference_10V_Internal_Bits; ni_writeb(dev, MSeries_Attenuate_x5_Bit, - M_Offset_AO_Reference_Attenuation(chan)); + NI_M_AO_REF_ATTENUATION_REG(chan)); break; case 2000000: conf |= MSeries_AO_DAC_Reference_5V_Internal_Bits; ni_writeb(dev, MSeries_Attenuate_x5_Bit, - M_Offset_AO_Reference_Attenuation(chan)); + NI_M_AO_REF_ATTENUATION_REG(chan)); break; default: dev_err(dev->class_dev, @@ -2717,9 +2714,9 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device *dev, } if (timed) conf |= MSeries_AO_Update_Timed_Bit; - ni_writeb(dev, conf, M_Offset_AO_Config_Bank(chan)); + ni_writeb(dev, conf, NI_M_AO_CFG_BANK_REG(chan)); devpriv->ao_conf[chan] = conf; - ni_writeb(dev, i, M_Offset_AO_Waveform_Order(chan)); + ni_writeb(dev, i, NI_M_AO_WAVEFORM_ORDER_REG(chan)); } return invert; } @@ -2795,7 +2792,7 @@ static int ni_ao_insn_write(struct comedi_device *dev, reg = DACx_Direct_Data_671x(chan); } else if (devpriv->is_m_series) { - reg = M_Offset_DAC_Direct_Data(chan); + reg = NI_M_DAC_DIRECT_DATA_REG(chan); } else { reg = (chan) ? DAC1_Direct_Data : DAC0_Direct_Data; } @@ -3324,7 +3321,7 @@ static int ni_m_series_dio_insn_config(struct comedi_device *dev, if (ret) return ret; - ni_writel(dev, s->io_bits, M_Offset_DIO_Direction); + ni_writel(dev, s->io_bits, NI_M_DIO_DIR_REG); return insn->n; } @@ -3335,9 +3332,9 @@ static int ni_m_series_dio_insn_bits(struct comedi_device *dev, unsigned int *data) { if (comedi_dio_update_state(s, data)) - ni_writel(dev, s->state, M_Offset_Static_Digital_Output); + ni_writel(dev, s->state, NI_M_DIO_REG); - data[1] = ni_readl(dev, M_Offset_Static_Digital_Input); + data[1] = ni_readl(dev, NI_M_DIO_REG); return insn->n; } @@ -3442,13 +3439,13 @@ static int ni_cdo_inttrig(struct comedi_device *dev, if (retval < 0) return retval; #endif -/* -* XXX not sure what interrupt C group does -* ni_writeb(dev, Interrupt_Group_C_Enable_Bit, -* M_Offset_Interrupt_C_Enable); wait for dma to fill output fifo -*/ + /* + * XXX not sure what interrupt C group does + * wait for dma to fill output fifo + * ni_writeb(dev, Interrupt_Group_C_Enable_Bit, NI_M_INTC_ENA_REG); + */ for (i = 0; i < timeout; ++i) { - if (ni_readl(dev, M_Offset_CDIO_Status) & CDO_FIFO_Full_Bit) + if (ni_readl(dev, NI_M_CDIO_STATUS_REG) & CDO_FIFO_Full_Bit) break; udelay(10); } @@ -3459,7 +3456,7 @@ static int ni_cdo_inttrig(struct comedi_device *dev, } ni_writel(dev, CDO_Arm_Bit | CDO_Error_Interrupt_Enable_Set_Bit | CDO_Empty_FIFO_Interrupt_Enable_Set_Bit, - M_Offset_CDIO_Command); + NI_M_CDIO_CMD_REG); return retval; } @@ -3469,7 +3466,7 @@ static int ni_cdio_cmd(struct comedi_device *dev, struct comedi_subdevice *s) unsigned cdo_mode_bits = CDO_FIFO_Mode_Bit | CDO_Halt_On_Error_Bit; int retval; - ni_writel(dev, CDO_Reset_Bit, M_Offset_CDIO_Command); + ni_writel(dev, CDO_Reset_Bit, NI_M_CDIO_CMD_REG); switch (cmd->scan_begin_src) { case TRIG_EXT: cdo_mode_bits |= @@ -3482,11 +3479,11 @@ static int ni_cdio_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } if (cmd->scan_begin_arg & CR_INVERT) cdo_mode_bits |= CDO_Polarity_Bit; - ni_writel(dev, cdo_mode_bits, M_Offset_CDO_Mode); + ni_writel(dev, cdo_mode_bits, NI_M_CDO_MODE_REG); if (s->io_bits) { - ni_writel(dev, s->state, M_Offset_CDO_FIFO_Data); - ni_writel(dev, CDO_SW_Update_Bit, M_Offset_CDIO_Command); - ni_writel(dev, s->io_bits, M_Offset_CDO_Mask_Enable); + ni_writel(dev, s->state, NI_M_CDO_FIFO_DATA_REG); + ni_writel(dev, CDO_SW_Update_Bit, NI_M_CDIO_CMD_REG); + ni_writel(dev, s->io_bits, NI_M_CDO_MASK_ENA_REG); } else { dev_err(dev->class_dev, "attempted to run digital output command with no lines configured as outputs\n"); @@ -3506,12 +3503,12 @@ static int ni_cdio_cancel(struct comedi_device *dev, struct comedi_subdevice *s) ni_writel(dev, CDO_Disarm_Bit | CDO_Error_Interrupt_Enable_Clear_Bit | CDO_Empty_FIFO_Interrupt_Enable_Clear_Bit | CDO_FIFO_Request_Interrupt_Enable_Clear_Bit, - M_Offset_CDIO_Command); -/* -* XXX not sure what interrupt C group does ni_writeb(dev, 0, -* M_Offset_Interrupt_C_Enable); -*/ - ni_writel(dev, 0, M_Offset_CDO_Mask_Enable); + NI_M_CDIO_CMD_REG); + /* + * XXX not sure what interrupt C group does + * ni_writeb(dev, 0, NI_M_INTC_ENA_REG); + */ + ni_writel(dev, 0, NI_M_CDO_MASK_ENA_REG); ni_release_cdo_mite_channel(dev); return 0; } @@ -3542,16 +3539,16 @@ static void handle_cdio_interrupt(struct comedi_device *dev) spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); #endif - cdio_status = ni_readl(dev, M_Offset_CDIO_Status); + cdio_status = ni_readl(dev, NI_M_CDIO_STATUS_REG); if (cdio_status & (CDO_Overrun_Bit | CDO_Underflow_Bit)) { /* XXX just guessing this is needed and does something useful */ ni_writel(dev, CDO_Error_Interrupt_Confirm_Bit, - M_Offset_CDIO_Command); + NI_M_CDIO_CMD_REG); s->async->events |= COMEDI_CB_OVERFLOW; } if (cdio_status & CDO_FIFO_Empty_Bit) { ni_writel(dev, CDO_Empty_FIFO_Interrupt_Enable_Clear_Bit, - M_Offset_CDIO_Command); + NI_M_CDIO_CMD_REG); /* s->async->events |= COMEDI_CB_EOA; */ } comedi_handle_events(dev, s); @@ -4033,7 +4030,7 @@ static int ni_m_series_pwm_config(struct comedi_device *dev, } ni_writel(dev, MSeries_Cal_PWM_High_Time_Bits(up_count) | MSeries_Cal_PWM_Low_Time_Bits(down_count), - M_Offset_Cal_PWM); + NI_M_CAL_PWM_REG); devpriv->pwm_up_count = up_count; devpriv->pwm_down_count = down_count; return 5; @@ -4398,7 +4395,7 @@ static int ni_m_series_set_pfi_routing(struct comedi_device *dev, val &= ~MSeries_PFI_Output_Select_Mask(chan); val |= MSeries_PFI_Output_Select_Bits(chan, source); - ni_writew(dev, val, M_Offset_PFI_Output_Select(index)); + ni_writew(dev, val, NI_M_PFI_OUT_SEL_REG(index)); devpriv->pfi_output_select_reg[index] = val; return 2; @@ -4433,10 +4430,10 @@ static int ni_config_filter(struct comedi_device *dev, if (!devpriv->is_m_series) return -ENOTSUPP; - bits = ni_readl(dev, M_Offset_PFI_Filter); + bits = ni_readl(dev, NI_M_PFI_FILTER_REG); bits &= ~MSeries_PFI_Filter_Select_Mask(pfi_channel); bits |= MSeries_PFI_Filter_Select_Bits(pfi_channel, filter); - ni_writel(dev, bits, M_Offset_PFI_Filter); + ni_writel(dev, bits, NI_M_PFI_FILTER_REG); return 0; } @@ -4489,9 +4486,9 @@ static int ni_pfi_insn_bits(struct comedi_device *dev, return -ENOTSUPP; if (comedi_dio_update_state(s, data)) - ni_writew(dev, s->state, M_Offset_PFI_DO); + ni_writew(dev, s->state, NI_M_PFI_DO_REG); - data[1] = ni_readw(dev, M_Offset_PFI_DI); + data[1] = ni_readw(dev, NI_M_PFI_DI_REG); return insn->n; } @@ -4750,16 +4747,16 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device *dev, return retval; } - ni_writew(dev, devpriv->clock_and_fout2, M_Offset_Clock_and_Fout2); + ni_writew(dev, devpriv->clock_and_fout2, NI_M_CLK_FOUT2_REG); pll_control_bits |= MSeries_PLL_Divisor_Bits(freq_divider) | MSeries_PLL_Multiplier_Bits(freq_multiplier); - ni_writew(dev, pll_control_bits, M_Offset_PLL_Control); + ni_writew(dev, pll_control_bits, NI_M_PLL_CTRL_REG); devpriv->clock_source = source; /* it seems to typically take a few hundred microseconds for PLL to lock */ for (i = 0; i < timeout; ++i) { - if (ni_readw(dev, M_Offset_PLL_Status) & MSeries_PLL_Locked_Bit) + if (ni_readw(dev, NI_M_PLL_STATUS_REG) & MSeries_PLL_Locked_Bit) break; udelay(1); } @@ -4787,8 +4784,8 @@ static int ni_set_master_clock(struct comedi_device *dev, ~(MSeries_Timebase1_Select_Bit | MSeries_Timebase3_Select_Bit); ni_writew(dev, devpriv->clock_and_fout2, - M_Offset_Clock_and_Fout2); - ni_writew(dev, 0, M_Offset_PLL_Control); + NI_M_CLK_FOUT2_REG); + ni_writew(dev, 0, NI_M_PLL_CTRL_REG); } devpriv->clock_source = source; } else { @@ -5333,8 +5330,8 @@ static int ni_E_init(struct comedi_device *dev, /* reset DIO and set all channels to inputs */ ni_writel(dev, CDO_Reset_Bit | CDI_Reset_Bit, - M_Offset_CDIO_Command); - ni_writel(dev, s->io_bits, M_Offset_DIO_Direction); + NI_M_CDIO_CMD_REG); + ni_writel(dev, s->io_bits, NI_M_DIO_DIR_REG); } else { s->insn_bits = ni_dio_insn_bits; s->insn_config = ni_dio_insn_config; @@ -5368,7 +5365,7 @@ static int ni_E_init(struct comedi_device *dev, /* internal PWM output used for AI nonlinearity calibration */ s->insn_config = ni_m_series_pwm_config; - ni_writel(dev, 0x0, M_Offset_Cal_PWM); + ni_writel(dev, 0x0, NI_M_CAL_PWM_REG); } else if (devpriv->is_6143) { /* internal PWM output used for AI nonlinearity calibration */ s->insn_config = ni_6143_pwm_config; @@ -5403,10 +5400,10 @@ static int ni_E_init(struct comedi_device *dev, s->n_chan = 16; s->insn_bits = ni_pfi_insn_bits; - ni_writew(dev, s->state, M_Offset_PFI_DO); + ni_writew(dev, s->state, NI_M_PFI_DO_REG); for (i = 0; i < NUM_PFI_OUTPUT_SELECT_REGS; ++i) { ni_writew(dev, devpriv->pfi_output_select_reg[i], - M_Offset_PFI_Output_Select(i)); + NI_M_PFI_OUT_SEL_REG(i)); } } else { s->n_chan = 10; @@ -5525,11 +5522,11 @@ static int ni_E_init(struct comedi_device *dev, for (channel = 0; channel < board->n_aochan; ++channel) { ni_writeb(dev, 0xf, - M_Offset_AO_Waveform_Order(channel)); + NI_M_AO_WAVEFORM_ORDER_REG(channel)); ni_writeb(dev, 0x0, - M_Offset_AO_Reference_Attenuation(channel)); + NI_M_AO_REF_ATTENUATION_REG(channel)); } - ni_writeb(dev, 0x0, M_Offset_AO_Calibration); + ni_writeb(dev, 0x0, NI_M_AO_CALIB_REG); } return 0; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 3c5ba613a2d6..c86dadec932e 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -924,54 +924,53 @@ static const struct comedi_lrange range_ni_E_ao_ext; * M-Series specific registers not handled by the DAQ-STC and GPCT register * remapping. */ -#define M_Offset_CDIO_DMA_Select 0x007 -#define M_Offset_SCXI_Status 0x007 -#define M_Offset_AI_AO_Select 0x009 -#define M_Offset_G0_G1_Select 0x00b -#define M_Offset_Misc_Command 0x00f -#define M_Offset_SCXI_Serial_Data_Out 0x011 -#define M_Offset_SCXI_Control 0x013 -#define M_Offset_SCXI_Output_Enable 0x015 -#define M_Offset_AI_FIFO_Data 0x01c -#define M_Offset_Static_Digital_Output 0x024 -#define M_Offset_Static_Digital_Input 0x024 -#define M_Offset_DIO_Direction 0x028 -#define M_Offset_Cal_PWM 0x040 -#define M_Offset_Gen_PWM(x) (0x044 + ((x) * 2)) -#define M_Offset_AI_Config_FIFO_Data 0x05e -#define M_Offset_Interrupt_C_Enable 0x088 -#define M_Offset_Interrupt_C_Status 0x088 -#define M_Offset_Analog_Trigger_Control 0x08c -#define M_Offset_AO_Serial_Interrupt_Enable 0x0a0 -#define M_Offset_AO_Serial_Interrupt_Ack 0x0a1 -#define M_Offset_AO_Serial_Interrupt_Status 0x0a1 -#define M_Offset_AO_Calibration 0x0a3 -#define M_Offset_AO_FIFO_Data 0x0a4 -#define M_Offset_PFI_Filter 0x0b0 -#define M_Offset_RTSI_Filter 0x0b4 -#define M_Offset_SCXI_Legacy_Compatibility 0x0bc -#define M_Offset_DAC_Direct_Data(x) (0x0c0 + ((x) * 4)) -#define M_Offset_AO_Waveform_Order(x) (0x0c2 + ((x) * 4)) -#define M_Offset_AO_Config_Bank(x) (0x0c3 + ((x) * 4)) -#define M_Offset_RTSI_Shared_MUX 0x1a2 -#define M_Offset_Clock_and_Fout2 0x1c4 -#define M_Offset_PLL_Control 0x1c6 -#define M_Offset_PLL_Status 0x1c8 -#define M_Offset_PFI_Output_Select(x) (0x1d0 + ((x) * 2)) -#define M_Offset_PFI_DI 0x1dc -#define M_Offset_PFI_DO 0x1de -#define M_Offset_AI_Config_FIFO_Bypass 0x218 -#define M_Offset_SCXI_DIO_Enable 0x21c -#define M_Offset_CDI_FIFO_Data 0x220 -#define M_Offset_CDO_FIFO_Data 0x220 -#define M_Offset_CDIO_Status 0x224 -#define M_Offset_CDIO_Command 0x224 -#define M_Offset_CDI_Mode 0x228 -#define M_Offset_CDO_Mode 0x22c -#define M_Offset_CDI_Mask_Enable 0x230 -#define M_Offset_CDO_Mask_Enable 0x234 -#define M_Offset_Static_AI_Control(x) ((x) ? (0x260 + (x)) : 0x064) -#define M_Offset_AO_Reference_Attenuation(x) (0x264 + (x)) +#define NI_M_CDIO_DMA_SEL_REG 0x007 +#define NI_M_SCXI_STATUS_REG 0x007 +#define NI_M_AI_AO_SEL_REG 0x009 +#define NI_M_G0_G1_SEL_REG 0x00b +#define NI_M_MISC_CMD_REG 0x00f +#define NI_M_SCXI_SER_DO_REG 0x011 +#define NI_M_SCXI_CTRL_REG 0x013 +#define NI_M_SCXI_OUT_ENA_REG 0x015 +#define NI_M_AI_FIFO_DATA_REG 0x01c +#define NI_M_DIO_REG 0x024 +#define NI_M_DIO_DIR_REG 0x028 +#define NI_M_CAL_PWM_REG 0x040 +#define NI_M_GEN_PWM_REG(x) (0x044 + ((x) * 2)) +#define NI_M_AI_CFG_FIFO_DATA_REG 0x05e +#define NI_M_INTC_ENA_REG 0x088 +#define NI_M_INTC_STATUS_REG 0x088 +#define NI_M_ATRIG_CTRL_REG 0x08c +#define NI_M_AO_SER_INT_ENA_REG 0x0a0 +#define NI_M_AO_SER_INT_ACK_REG 0x0a1 +#define NI_M_AO_SER_INT_STATUS_REG 0x0a1 +#define NI_M_AO_CALIB_REG 0x0a3 +#define NI_M_AO_FIFO_DATA_REG 0x0a4 +#define NI_M_PFI_FILTER_REG 0x0b0 +#define NI_M_RTSI_FILTER_REG 0x0b4 +#define NI_M_SCXI_LEGACY_COMPAT_REG 0x0bc +#define NI_M_DAC_DIRECT_DATA_REG(x) (0x0c0 + ((x) * 4)) +#define NI_M_AO_WAVEFORM_ORDER_REG(x) (0x0c2 + ((x) * 4)) +#define NI_M_AO_CFG_BANK_REG(x) (0x0c3 + ((x) * 4)) +#define NI_M_RTSI_SHARED_MUX_REG 0x1a2 +#define NI_M_CLK_FOUT2_REG 0x1c4 +#define NI_M_PLL_CTRL_REG 0x1c6 +#define NI_M_PLL_STATUS_REG 0x1c8 +#define NI_M_PFI_OUT_SEL_REG(x) (0x1d0 + ((x) * 2)) +#define NI_M_PFI_DI_REG 0x1dc +#define NI_M_PFI_DO_REG 0x1de +#define NI_M_AI_CFG_BYPASS_FIFO_REG 0x218 +#define NI_M_SCXI_DIO_ENA_REG 0x21c +#define NI_M_CDI_FIFO_DATA_REG 0x220 +#define NI_M_CDO_FIFO_DATA_REG 0x220 +#define NI_M_CDIO_STATUS_REG 0x224 +#define NI_M_CDIO_CMD_REG 0x224 +#define NI_M_CDI_MODE_REG 0x228 +#define NI_M_CDO_MODE_REG 0x22c +#define NI_M_CDI_MASK_ENA_REG 0x230 +#define NI_M_CDO_MASK_ENA_REG 0x234 +#define NI_M_STATIC_AI_CTRL_REG(x) ((x) ? (0x260 + (x)) : 0x064) +#define NI_M_AO_REF_ATTENUATION_REG(x) (0x264 + (x)) enum MSeries_AI_Config_FIFO_Data_Bits { MSeries_AI_Config_Channel_Type_Mask = 0x7 << 6, From 67d2d05859f58a5c591e183a3a89837ee502b1cc Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:35 -0700 Subject: [PATCH 0311/1163] staging: comedi: ni_stc.h: tidy up NI_M_AI_CFG_FIFO_DATA_REG bits Rename all the CamelCase and convert the enum and helper functions into defines. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 21 ++++------ drivers/staging/comedi/drivers/ni_stc.h | 41 +++++++------------ 2 files changed, 23 insertions(+), 39 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 93c7b1325f12..0cd5fc24759b 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1792,29 +1792,26 @@ static void ni_m_series_load_channelgain_list(struct comedi_device *dev, devpriv->ai_offset[i] = 0; switch (aref) { case AREF_DIFF: - config_bits |= - MSeries_AI_Config_Channel_Type_Differential_Bits; + config_bits |= NI_M_AI_CFG_CHAN_TYPE_DIFF; break; case AREF_COMMON: - config_bits |= - MSeries_AI_Config_Channel_Type_Common_Ref_Bits; + config_bits |= NI_M_AI_CFG_CHAN_TYPE_COMMON; break; case AREF_GROUND: - config_bits |= - MSeries_AI_Config_Channel_Type_Ground_Ref_Bits; + config_bits |= NI_M_AI_CFG_CHAN_TYPE_GROUND; break; case AREF_OTHER: break; } - config_bits |= MSeries_AI_Config_Channel_Bits(chan); - config_bits |= MSeries_AI_Config_Bank_Bits(chan); - config_bits |= MSeries_AI_Config_Gain_Bits(range_code); + config_bits |= NI_M_AI_CFG_CHAN_SEL(chan); + config_bits |= NI_M_AI_CFG_BANK_SEL(chan); + config_bits |= NI_M_AI_CFG_GAIN(range_code); if (i == n_chan - 1) - config_bits |= MSeries_AI_Config_Last_Channel_Bit; + config_bits |= NI_M_AI_CFG_LAST_CHAN; if (dither) - config_bits |= MSeries_AI_Config_Dither_Bit; + config_bits |= NI_M_AI_CFG_DITHER; /* don't use 2's complement encoding */ - config_bits |= MSeries_AI_Config_Polarity_Bit; + config_bits |= NI_M_AI_CFG_POLARITY; ni_writew(dev, config_bits, NI_M_AI_CFG_FIFO_DATA_REG); } ni_prime_channelgain_list(dev); diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index c86dadec932e..fb23372d597d 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -938,6 +938,20 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_CAL_PWM_REG 0x040 #define NI_M_GEN_PWM_REG(x) (0x044 + ((x) * 2)) #define NI_M_AI_CFG_FIFO_DATA_REG 0x05e +#define NI_M_AI_CFG_LAST_CHAN BIT(14) +#define NI_M_AI_CFG_DITHER BIT(13) +#define NI_M_AI_CFG_POLARITY BIT(12) +#define NI_M_AI_CFG_GAIN(x) (((x) & 0x7) << 9) +#define NI_M_AI_CFG_CHAN_TYPE(x) (((x) & 0x7) << 6) +#define NI_M_AI_CFG_CHAN_TYPE_MASK NI_M_AI_CFG_CHAN_TYPE(7) +#define NI_M_AI_CFG_CHAN_TYPE_CALIB NI_M_AI_CFG_CHAN_TYPE(0) +#define NI_M_AI_CFG_CHAN_TYPE_DIFF NI_M_AI_CFG_CHAN_TYPE(1) +#define NI_M_AI_CFG_CHAN_TYPE_COMMON NI_M_AI_CFG_CHAN_TYPE(2) +#define NI_M_AI_CFG_CHAN_TYPE_GROUND NI_M_AI_CFG_CHAN_TYPE(3) +#define NI_M_AI_CFG_CHAN_TYPE_AUX NI_M_AI_CFG_CHAN_TYPE(5) +#define NI_M_AI_CFG_CHAN_TYPE_GHOST NI_M_AI_CFG_CHAN_TYPE(7) +#define NI_M_AI_CFG_BANK_SEL(x) ((((x) & 0x40) << 4) | ((x) & 0x30)) +#define NI_M_AI_CFG_CHAN_SEL(x) (((x) & 0xf) << 0) #define NI_M_INTC_ENA_REG 0x088 #define NI_M_INTC_STATUS_REG 0x088 #define NI_M_ATRIG_CTRL_REG 0x08c @@ -972,33 +986,6 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_STATIC_AI_CTRL_REG(x) ((x) ? (0x260 + (x)) : 0x064) #define NI_M_AO_REF_ATTENUATION_REG(x) (0x264 + (x)) -enum MSeries_AI_Config_FIFO_Data_Bits { - MSeries_AI_Config_Channel_Type_Mask = 0x7 << 6, - MSeries_AI_Config_Channel_Type_Calibration_Bits = 0x0, - MSeries_AI_Config_Channel_Type_Differential_Bits = 0x1 << 6, - MSeries_AI_Config_Channel_Type_Common_Ref_Bits = 0x2 << 6, - MSeries_AI_Config_Channel_Type_Ground_Ref_Bits = 0x3 << 6, - MSeries_AI_Config_Channel_Type_Aux_Bits = 0x5 << 6, - MSeries_AI_Config_Channel_Type_Ghost_Bits = 0x7 << 6, - MSeries_AI_Config_Polarity_Bit = 0x1000, /* 0 for 2's complement encoding */ - MSeries_AI_Config_Dither_Bit = 0x2000, - MSeries_AI_Config_Last_Channel_Bit = 0x4000, -}; -static inline unsigned MSeries_AI_Config_Channel_Bits(unsigned channel) -{ - return channel & 0xf; -} - -static inline unsigned MSeries_AI_Config_Bank_Bits(unsigned channel) -{ - return ((channel & 0x40) << 4) | (channel & 0x30); -} - -static inline unsigned MSeries_AI_Config_Gain_Bits(unsigned range) -{ - return (range & 0x7) << 9; -} - enum MSeries_Clock_and_Fout2_Bits { MSeries_PLL_In_Source_Select_RTSI0_Bits = 0xb, MSeries_PLL_In_Source_Select_Star_Trigger_Bits = 0x14, From 40aafd79a8b82ba506e28009cfa7c46bba813ce8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:36 -0700 Subject: [PATCH 0312/1163] staging: comedi: ni_stc.h: tidy up NI_M_CLK_FOUT2_REG bits Rename the CamelCase and convert the enum into defines. Use the BIT() macro to define the bits. Convert the inline function MSeries_PLL_In_Source_Select_RTSI_Bits() to a macro. The caller always passes valid values for 'RTIS_channel' so the sanity checking can safely be removed. Tidy up ni_mseries_set_pll_master_clock() to remove the unnecessary extra indent level for the code that sets a RTSI channel for the PLL source. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 46 +++++++++---------- drivers/staging/comedi/drivers/ni_stc.h | 38 +++++---------- 2 files changed, 32 insertions(+), 52 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 0cd5fc24759b..9fef0e938626 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -4684,6 +4684,7 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device *dev, unsigned pll_control_bits; unsigned freq_divider; unsigned freq_multiplier; + unsigned rtsi; unsigned i; int retval; @@ -4701,37 +4702,27 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device *dev, RTSI_Trig_Direction_Register); pll_control_bits = MSeries_PLL_Enable_Bit | MSeries_PLL_VCO_Mode_75_150MHz_Bits; - devpriv->clock_and_fout2 |= - MSeries_Timebase1_Select_Bit | MSeries_Timebase3_Select_Bit; - devpriv->clock_and_fout2 &= ~MSeries_PLL_In_Source_Select_Mask; + devpriv->clock_and_fout2 |= NI_M_CLK_FOUT2_TIMEBASE1_PLL | + NI_M_CLK_FOUT2_TIMEBASE3_PLL; + devpriv->clock_and_fout2 &= ~NI_M_CLK_FOUT2_PLL_SRC_MASK; switch (source) { case NI_MIO_PLL_PXI_STAR_TRIGGER_CLOCK: - devpriv->clock_and_fout2 |= - MSeries_PLL_In_Source_Select_Star_Trigger_Bits; + devpriv->clock_and_fout2 |= NI_M_CLK_FOUT2_PLL_SRC_STAR; break; case NI_MIO_PLL_PXI10_CLOCK: /* pxi clock is 10MHz */ - devpriv->clock_and_fout2 |= - MSeries_PLL_In_Source_Select_PXI_Clock10; + devpriv->clock_and_fout2 |= NI_M_CLK_FOUT2_PLL_SRC_PXI10; break; default: - { - unsigned rtsi_channel; - static const unsigned max_rtsi_channel = 7; - - for (rtsi_channel = 0; rtsi_channel <= max_rtsi_channel; - ++rtsi_channel) { - if (source == - NI_MIO_PLL_RTSI_CLOCK(rtsi_channel)) { - devpriv->clock_and_fout2 |= - MSeries_PLL_In_Source_Select_RTSI_Bits - (rtsi_channel); - break; - } + for (rtsi = 0; rtsi <= NI_M_MAX_RTSI_CHAN; ++rtsi) { + if (source == NI_MIO_PLL_RTSI_CLOCK(rtsi)) { + devpriv->clock_and_fout2 |= + NI_M_CLK_FOUT2_PLL_SRC_RTSI(rtsi); + break; } - if (rtsi_channel > max_rtsi_channel) - return -EINVAL; } + if (rtsi > NI_M_MAX_RTSI_CHAN) + return -EINVAL; break; } retval = ni_mseries_get_pll_parameters(period_ns, @@ -4778,8 +4769,8 @@ static int ni_set_master_clock(struct comedi_device *dev, devpriv->clock_ns = TIMEBASE_1_NS; if (devpriv->is_m_series) { devpriv->clock_and_fout2 &= - ~(MSeries_Timebase1_Select_Bit | - MSeries_Timebase3_Select_Bit); + ~(NI_M_CLK_FOUT2_TIMEBASE1_PLL | + NI_M_CLK_FOUT2_TIMEBASE3_PLL); ni_writew(dev, devpriv->clock_and_fout2, NI_M_CLK_FOUT2_REG); ni_writew(dev, 0, NI_M_PLL_CTRL_REG); @@ -4972,8 +4963,13 @@ static void ni_rtsi_init(struct comedi_device *dev) /* Initialises the RTSI bus signal switch to a default state */ + /* + * Use 10MHz instead of 20MHz for RTSI clock frequency. Appears + * to have no effect, at least on pxi-6281, which always uses + * 20MHz rtsi clock frequency + */ + devpriv->clock_and_fout2 = NI_M_CLK_FOUT2_RTSI_10MHZ; /* Set clock mode to internal */ - devpriv->clock_and_fout2 = MSeries_RTSI_10MHz_Bit; if (ni_set_master_clock(dev, NI_MIO_INTERNAL_CLOCK, 0) < 0) dev_err(dev->class_dev, "ni_set_master_clock failed, bug?\n"); /* default internal lines routing to RTSI bus lines */ diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index fb23372d597d..33adb63e1634 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -968,6 +968,17 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_AO_CFG_BANK_REG(x) (0x0c3 + ((x) * 4)) #define NI_M_RTSI_SHARED_MUX_REG 0x1a2 #define NI_M_CLK_FOUT2_REG 0x1c4 +#define NI_M_CLK_FOUT2_RTSI_10MHZ BIT(7) +#define NI_M_CLK_FOUT2_TIMEBASE3_PLL BIT(6) +#define NI_M_CLK_FOUT2_TIMEBASE1_PLL BIT(5) +#define NI_M_CLK_FOUT2_PLL_SRC(x) (((x) & 0x1f) << 0) +#define NI_M_CLK_FOUT2_PLL_SRC_MASK NI_M_CLK_FOUT2_PLL_SRC(0x1f) +#define NI_M_MAX_RTSI_CHAN 7 +#define NI_M_CLK_FOUT2_PLL_SRC_RTSI(x) (((x) == NI_M_MAX_RTSI_CHAN) \ + ? NI_M_CLK_FOUT2_PLL_SRC(0x1b) \ + : NI_M_CLK_FOUT2_PLL_SRC(0xb + (x))) +#define NI_M_CLK_FOUT2_PLL_SRC_STAR NI_M_CLK_FOUT2_PLL_SRC(0x14) +#define NI_M_CLK_FOUT2_PLL_SRC_PXI10 NI_M_CLK_FOUT2_PLL_SRC(0x1d) #define NI_M_PLL_CTRL_REG 0x1c6 #define NI_M_PLL_STATUS_REG 0x1c8 #define NI_M_PFI_OUT_SEL_REG(x) (0x1d0 + ((x) * 2)) @@ -986,33 +997,6 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_STATIC_AI_CTRL_REG(x) ((x) ? (0x260 + (x)) : 0x064) #define NI_M_AO_REF_ATTENUATION_REG(x) (0x264 + (x)) -enum MSeries_Clock_and_Fout2_Bits { - MSeries_PLL_In_Source_Select_RTSI0_Bits = 0xb, - MSeries_PLL_In_Source_Select_Star_Trigger_Bits = 0x14, - MSeries_PLL_In_Source_Select_RTSI7_Bits = 0x1b, - MSeries_PLL_In_Source_Select_PXI_Clock10 = 0x1d, - MSeries_PLL_In_Source_Select_Mask = 0x1f, - MSeries_Timebase1_Select_Bit = 0x20, /* use PLL for timebase 1 */ - MSeries_Timebase3_Select_Bit = 0x40, /* use PLL for timebase 3 */ - /* use 10MHz instead of 20MHz for RTSI clock frequency. Appears - to have no effect, at least on pxi-6281, which always uses - 20MHz rtsi clock frequency */ - MSeries_RTSI_10MHz_Bit = 0x80 -}; -static inline unsigned MSeries_PLL_In_Source_Select_RTSI_Bits(unsigned - RTSI_channel) -{ - if (RTSI_channel > 7) { - pr_err("%s: bug, invalid RTSI_channel=%i\n", __func__, - RTSI_channel); - return 0; - } - if (RTSI_channel == 7) - return MSeries_PLL_In_Source_Select_RTSI7_Bits; - else - return MSeries_PLL_In_Source_Select_RTSI0_Bits + RTSI_channel; -} - enum MSeries_PLL_Control_Bits { MSeries_PLL_Enable_Bit = 0x1000, MSeries_PLL_VCO_Mode_200_325MHz_Bits = 0x0, From b965e6a4ab970ae9bdd2517402ea51039b061326 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:37 -0700 Subject: [PATCH 0313/1163] staging: comedi: ni_stc.h: tidy up NI_M_PLL_CTRL_REG bits Rename the CamelCase and convert the enum into defines. Use the BIT() macro to define the bits. Convert the inline functions MSeries_PLL_Divisor_Bits() and MSeries_PLL_Multiplier_Bits() to macros. The helper function ni_mseries_get_pll_parameters() always returns valid values for the 'divisor' and 'multiplier' so the sanity checking can safely be removed. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 14 +++---- drivers/staging/comedi/drivers/ni_stc.h | 38 +++++-------------- 2 files changed, 15 insertions(+), 37 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 9fef0e938626..0a1f92e43b5d 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -4638,10 +4638,8 @@ static int ni_mseries_get_pll_parameters(unsigned reference_period_ns, { unsigned div; unsigned best_div = 1; - static const unsigned max_div = 0x10; unsigned mult; unsigned best_mult = 1; - static const unsigned max_mult = 0x100; static const unsigned pico_per_nano = 1000; const unsigned reference_picosec = reference_period_ns * pico_per_nano; @@ -4651,8 +4649,8 @@ static int ni_mseries_get_pll_parameters(unsigned reference_period_ns, static const unsigned fudge_factor_80_to_20Mhz = 4; int best_period_picosec = 0; - for (div = 1; div <= max_div; ++div) { - for (mult = 1; mult <= max_mult; ++mult) { + for (div = 1; div <= NI_M_PLL_MAX_DIVISOR; ++div) { + for (mult = 1; mult <= NI_M_PLL_MAX_MULTIPLIER; ++mult) { unsigned new_period_ps = (reference_picosec * div) / mult; if (abs(new_period_ps - target_picosec) < @@ -4700,8 +4698,7 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device *dev, devpriv->rtsi_trig_direction_reg &= ~Use_RTSI_Clock_Bit; ni_stc_writew(dev, devpriv->rtsi_trig_direction_reg, RTSI_Trig_Direction_Register); - pll_control_bits = - MSeries_PLL_Enable_Bit | MSeries_PLL_VCO_Mode_75_150MHz_Bits; + pll_control_bits = NI_M_PLL_CTRL_ENA | NI_M_PLL_CTRL_VCO_MODE_75_150MHZ; devpriv->clock_and_fout2 |= NI_M_CLK_FOUT2_TIMEBASE1_PLL | NI_M_CLK_FOUT2_TIMEBASE3_PLL; devpriv->clock_and_fout2 &= ~NI_M_CLK_FOUT2_PLL_SRC_MASK; @@ -4736,9 +4733,8 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device *dev, } ni_writew(dev, devpriv->clock_and_fout2, NI_M_CLK_FOUT2_REG); - pll_control_bits |= - MSeries_PLL_Divisor_Bits(freq_divider) | - MSeries_PLL_Multiplier_Bits(freq_multiplier); + pll_control_bits |= NI_M_PLL_CTRL_DIVISOR(freq_divider) | + NI_M_PLL_CTRL_MULTIPLIER(freq_multiplier); ni_writew(dev, pll_control_bits, NI_M_PLL_CTRL_REG); devpriv->clock_source = source; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 33adb63e1634..f08124e47d5b 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -980,6 +980,16 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_CLK_FOUT2_PLL_SRC_STAR NI_M_CLK_FOUT2_PLL_SRC(0x14) #define NI_M_CLK_FOUT2_PLL_SRC_PXI10 NI_M_CLK_FOUT2_PLL_SRC(0x1d) #define NI_M_PLL_CTRL_REG 0x1c6 +#define NI_M_PLL_CTRL_VCO_MODE(x) (((x) & 0x3) << 13) +#define NI_M_PLL_CTRL_VCO_MODE_200_325MHZ NI_M_PLL_CTRL_VCO_MODE(0) +#define NI_M_PLL_CTRL_VCO_MODE_175_225MHZ NI_M_PLL_CTRL_VCO_MODE(1) +#define NI_M_PLL_CTRL_VCO_MODE_100_225MHZ NI_M_PLL_CTRL_VCO_MODE(2) +#define NI_M_PLL_CTRL_VCO_MODE_75_150MHZ NI_M_PLL_CTRL_VCO_MODE(3) +#define NI_M_PLL_CTRL_ENA BIT(12) +#define NI_M_PLL_MAX_DIVISOR 0x10 +#define NI_M_PLL_CTRL_DIVISOR(x) (((x) & 0xf) << 8) +#define NI_M_PLL_MAX_MULTIPLIER 0x100 +#define NI_M_PLL_CTRL_MULTIPLIER(x) (((x) & 0xff) << 0) #define NI_M_PLL_STATUS_REG 0x1c8 #define NI_M_PFI_OUT_SEL_REG(x) (0x1d0 + ((x) * 2)) #define NI_M_PFI_DI_REG 0x1dc @@ -997,34 +1007,6 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_STATIC_AI_CTRL_REG(x) ((x) ? (0x260 + (x)) : 0x064) #define NI_M_AO_REF_ATTENUATION_REG(x) (0x264 + (x)) -enum MSeries_PLL_Control_Bits { - MSeries_PLL_Enable_Bit = 0x1000, - MSeries_PLL_VCO_Mode_200_325MHz_Bits = 0x0, - MSeries_PLL_VCO_Mode_175_225MHz_Bits = 0x2000, - MSeries_PLL_VCO_Mode_100_225MHz_Bits = 0x4000, - MSeries_PLL_VCO_Mode_75_150MHz_Bits = 0x6000, -}; -static inline unsigned MSeries_PLL_Divisor_Bits(unsigned divisor) -{ - static const unsigned max_divisor = 0x10; - if (divisor < 1 || divisor > max_divisor) { - pr_err("%s: bug, invalid divisor=%i\n", __func__, divisor); - return 0; - } - return (divisor & 0xf) << 8; -} - -static inline unsigned MSeries_PLL_Multiplier_Bits(unsigned multiplier) -{ - static const unsigned max_multiplier = 0x100; - if (multiplier < 1 || multiplier > max_multiplier) { - pr_err("%s: bug, invalid multiplier=%i\n", __func__, - multiplier); - return 0; - } - return multiplier & 0xff; -} - enum MSeries_PLL_Status { MSeries_PLL_Locked_Bit = 0x1 }; From b1c70645286c50e9fb5338b45d388e1176e881d5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:38 -0700 Subject: [PATCH 0314/1163] staging: comedi: ni_stc.h: tidy up NI_M_PLL_STATUS_REG bits Rename the CamelCase and convert the enum into defines. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 2 +- drivers/staging/comedi/drivers/ni_stc.h | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 0a1f92e43b5d..bb4fde0e777c 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -4740,7 +4740,7 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device *dev, devpriv->clock_source = source; /* it seems to typically take a few hundred microseconds for PLL to lock */ for (i = 0; i < timeout; ++i) { - if (ni_readw(dev, NI_M_PLL_STATUS_REG) & MSeries_PLL_Locked_Bit) + if (ni_readw(dev, NI_M_PLL_STATUS_REG) & NI_M_PLL_STATUS_LOCKED) break; udelay(1); } diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index f08124e47d5b..ffed5a1c6f06 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -991,6 +991,7 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_PLL_MAX_MULTIPLIER 0x100 #define NI_M_PLL_CTRL_MULTIPLIER(x) (((x) & 0xff) << 0) #define NI_M_PLL_STATUS_REG 0x1c8 +#define NI_M_PLL_STATUS_LOCKED BIT(0) #define NI_M_PFI_OUT_SEL_REG(x) (0x1d0 + ((x) * 2)) #define NI_M_PFI_DI_REG 0x1dc #define NI_M_PFI_DO_REG 0x1de @@ -1007,10 +1008,6 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_STATIC_AI_CTRL_REG(x) ((x) ? (0x260 + (x)) : 0x064) #define NI_M_AO_REF_ATTENUATION_REG(x) (0x264 + (x)) -enum MSeries_PLL_Status { - MSeries_PLL_Locked_Bit = 0x1 -}; - enum MSeries_AI_Config_FIFO_Bypass_Bits { MSeries_AI_Bypass_Channel_Mask = 0x7, MSeries_AI_Bypass_Bank_Mask = 0x78, From 41f9f0bfcf7ab2121dfeef0d8928421e214c4dee Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:39 -0700 Subject: [PATCH 0315/1163] staging: comedi: ni_stc.h: tidy up NI_M_AI_CFG_BYPASS_FIFO_REG bits Rename the CamelCase and convert the enum into defines. Use the BIT() macro to define the bits. Convert the inline helper functions into macros. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 27 ++++------ drivers/staging/comedi/drivers/ni_stc.h | 51 ++++++++----------- 2 files changed, 30 insertions(+), 48 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index bb4fde0e777c..0853f0e2cf2c 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1763,22 +1763,17 @@ static void ni_m_series_load_channelgain_list(struct comedi_device *dev, range = CR_RANGE(list[0]); range_code = ni_gainlkup[board->gainlkup][range]; dither = (list[0] & CR_ALT_FILTER) != 0; - bypass_bits = MSeries_AI_Bypass_Config_FIFO_Bit; - bypass_bits |= chan; - bypass_bits |= - (devpriv->ai_calib_source) & - (MSeries_AI_Bypass_Cal_Sel_Pos_Mask | - MSeries_AI_Bypass_Cal_Sel_Neg_Mask | - MSeries_AI_Bypass_Mode_Mux_Mask | - MSeries_AO_Bypass_AO_Cal_Sel_Mask); - bypass_bits |= MSeries_AI_Bypass_Gain_Bits(range_code); + bypass_bits = NI_M_CFG_BYPASS_FIFO | + NI_M_CFG_BYPASS_AI_CHAN(chan) | + NI_M_CFG_BYPASS_AI_GAIN(range_code) | + devpriv->ai_calib_source; if (dither) - bypass_bits |= MSeries_AI_Bypass_Dither_Bit; + bypass_bits |= NI_M_CFG_BYPASS_AI_DITHER; /* don't use 2's complement encoding */ - bypass_bits |= MSeries_AI_Bypass_Polarity_Bit; - ni_writel(dev, bypass_bits, NI_M_AI_CFG_BYPASS_FIFO_REG); + bypass_bits |= NI_M_CFG_BYPASS_AI_POLARITY; + ni_writel(dev, bypass_bits, NI_M_CFG_BYPASS_FIFO_REG); } else { - ni_writel(dev, 0, NI_M_AI_CFG_BYPASS_FIFO_REG); + ni_writel(dev, 0, NI_M_CFG_BYPASS_FIFO_REG); } for (i = 0; i < n_chan; i++) { unsigned config_bits = 0; @@ -2579,12 +2574,8 @@ static int ni_ai_insn_config(struct comedi_device *dev, switch (data[0]) { case INSN_CONFIG_ALT_SOURCE: if (devpriv->is_m_series) { - if (data[1] & ~(MSeries_AI_Bypass_Cal_Sel_Pos_Mask | - MSeries_AI_Bypass_Cal_Sel_Neg_Mask | - MSeries_AI_Bypass_Mode_Mux_Mask | - MSeries_AO_Bypass_AO_Cal_Sel_Mask)) { + if (data[1] & ~NI_M_CFG_BYPASS_AI_CAL_MASK) return -EINVAL; - } devpriv->ai_calib_source = data[1]; } else if (devpriv->is_6143) { unsigned int calib_source; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index ffed5a1c6f06..1625e1402bee 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -995,7 +995,27 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_PFI_OUT_SEL_REG(x) (0x1d0 + ((x) * 2)) #define NI_M_PFI_DI_REG 0x1dc #define NI_M_PFI_DO_REG 0x1de -#define NI_M_AI_CFG_BYPASS_FIFO_REG 0x218 +#define NI_M_CFG_BYPASS_FIFO_REG 0x218 +#define NI_M_CFG_BYPASS_FIFO BIT(31) +#define NI_M_CFG_BYPASS_AI_POLARITY BIT(22) +#define NI_M_CFG_BYPASS_AI_DITHER BIT(21) +#define NI_M_CFG_BYPASS_AI_GAIN(x) (((x) & 0x7) << 18) +#define NI_M_CFG_BYPASS_AO_CAL(x) (((x) & 0xf) << 15) +#define NI_M_CFG_BYPASS_AO_CAL_MASK NI_M_CFG_BYPASS_AO_CAL(0xf) +#define NI_M_CFG_BYPASS_AI_MODE_MUX(x) (((x) & 0x3) << 13) +#define NI_M_CFG_BYPASS_AI_MODE_MUX_MASK NI_M_CFG_BYPASS_AI_MODE_MUX(3) +#define NI_M_CFG_BYPASS_AI_CAL_NEG(x) (((x) & 0x7) << 10) +#define NI_M_CFG_BYPASS_AI_CAL_NEG_MASK NI_M_CFG_BYPASS_AI_CAL_NEG(7) +#define NI_M_CFG_BYPASS_AI_CAL_POS(x) (((x) & 0x7) << 7) +#define NI_M_CFG_BYPASS_AI_CAL_POS_MASK NI_M_CFG_BYPASS_AI_CAL_POS(7) +#define NI_M_CFG_BYPASS_AI_CAL_MASK (NI_M_CFG_BYPASS_AI_CAL_POS_MASK | \ + NI_M_CFG_BYPASS_AI_CAL_NEG_MASK | \ + NI_M_CFG_BYPASS_AI_MODE_MUX_MASK | \ + NI_M_CFG_BYPASS_AO_CAL_MASK) +#define NI_M_CFG_BYPASS_AI_BANK(x) (((x) & 0xf) << 3) +#define NI_M_CFG_BYPASS_AI_BANK_MASK NI_M_CFG_BYPASS_AI_BANK(0xf) +#define NI_M_CFG_BYPASS_AI_CHAN(x) (((x) & 0x7) << 0) +#define NI_M_CFG_BYPASS_AI_CHAN_MASK NI_M_CFG_BYPASS_AI_CHAN(7) #define NI_M_SCXI_DIO_ENA_REG 0x21c #define NI_M_CDI_FIFO_DATA_REG 0x220 #define NI_M_CDO_FIFO_DATA_REG 0x220 @@ -1008,35 +1028,6 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_STATIC_AI_CTRL_REG(x) ((x) ? (0x260 + (x)) : 0x064) #define NI_M_AO_REF_ATTENUATION_REG(x) (0x264 + (x)) -enum MSeries_AI_Config_FIFO_Bypass_Bits { - MSeries_AI_Bypass_Channel_Mask = 0x7, - MSeries_AI_Bypass_Bank_Mask = 0x78, - MSeries_AI_Bypass_Cal_Sel_Pos_Mask = 0x380, - MSeries_AI_Bypass_Cal_Sel_Neg_Mask = 0x1c00, - MSeries_AI_Bypass_Mode_Mux_Mask = 0x6000, - MSeries_AO_Bypass_AO_Cal_Sel_Mask = 0x38000, - MSeries_AI_Bypass_Gain_Mask = 0x1c0000, - MSeries_AI_Bypass_Dither_Bit = 0x200000, - MSeries_AI_Bypass_Polarity_Bit = 0x400000, /* 0 for 2's complement encoding */ - MSeries_AI_Bypass_Config_FIFO_Bit = 0x80000000 -}; -static inline unsigned MSeries_AI_Bypass_Cal_Sel_Pos_Bits(int - calibration_source) -{ - return (calibration_source << 7) & MSeries_AI_Bypass_Cal_Sel_Pos_Mask; -} - -static inline unsigned MSeries_AI_Bypass_Cal_Sel_Neg_Bits(int - calibration_source) -{ - return (calibration_source << 10) & MSeries_AI_Bypass_Cal_Sel_Pos_Mask; -} - -static inline unsigned MSeries_AI_Bypass_Gain_Bits(int gain) -{ - return (gain << 18) & MSeries_AI_Bypass_Gain_Mask; -} - enum MSeries_AO_Config_Bank_Bits { MSeries_AO_DAC_Offset_Select_Mask = 0x7, MSeries_AO_DAC_Offset_0V_Bits = 0x0, From bae453048752599aa4acedfc3b0c1244744ec2b7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:40 -0700 Subject: [PATCH 0316/1163] staging: comedi: ni_stc.h: tidy up NI_M_AO_CFG_BANK_REG bits Rename the CamelCase and convert the enum into defines. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 16 +++++++------- drivers/staging/comedi/drivers/ni_stc.h | 21 +++++++++---------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 0853f0e2cf2c..7f4e9d6df8fe 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -2650,7 +2650,7 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device *dev, if (timed) { for (i = 0; i < s->n_chan; ++i) { - devpriv->ao_conf[i] &= ~MSeries_AO_Update_Timed_Bit; + devpriv->ao_conf[i] &= ~NI_M_AO_CFG_BANK_UPDATE_TIMED; ni_writeb(dev, devpriv->ao_conf[i], NI_M_AO_CFG_BANK_REG(i)); ni_writeb(dev, 0xf, NI_M_AO_WAVEFORM_ORDER_REG(i)); @@ -2666,20 +2666,20 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device *dev, conf = 0; switch (krange->max - krange->min) { case 20000000: - conf |= MSeries_AO_DAC_Reference_10V_Internal_Bits; + conf |= NI_M_AO_CFG_BANK_REF_INT_10V; ni_writeb(dev, 0, NI_M_AO_REF_ATTENUATION_REG(chan)); break; case 10000000: - conf |= MSeries_AO_DAC_Reference_5V_Internal_Bits; + conf |= NI_M_AO_CFG_BANK_REF_INT_5V; ni_writeb(dev, 0, NI_M_AO_REF_ATTENUATION_REG(chan)); break; case 4000000: - conf |= MSeries_AO_DAC_Reference_10V_Internal_Bits; + conf |= NI_M_AO_CFG_BANK_REF_INT_10V; ni_writeb(dev, MSeries_Attenuate_x5_Bit, NI_M_AO_REF_ATTENUATION_REG(chan)); break; case 2000000: - conf |= MSeries_AO_DAC_Reference_5V_Internal_Bits; + conf |= NI_M_AO_CFG_BANK_REF_INT_5V; ni_writeb(dev, MSeries_Attenuate_x5_Bit, NI_M_AO_REF_ATTENUATION_REG(chan)); break; @@ -2690,10 +2690,10 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device *dev, } switch (krange->max + krange->min) { case 0: - conf |= MSeries_AO_DAC_Offset_0V_Bits; + conf |= NI_M_AO_CFG_BANK_OFFSET_0V; break; case 10000000: - conf |= MSeries_AO_DAC_Offset_5V_Bits; + conf |= NI_M_AO_CFG_BANK_OFFSET_5V; break; default: dev_err(dev->class_dev, @@ -2701,7 +2701,7 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device *dev, break; } if (timed) - conf |= MSeries_AO_Update_Timed_Bit; + conf |= NI_M_AO_CFG_BANK_UPDATE_TIMED; ni_writeb(dev, conf, NI_M_AO_CFG_BANK_REG(chan)); devpriv->ao_conf[chan] = conf; ni_writeb(dev, i, NI_M_AO_WAVEFORM_ORDER_REG(chan)); diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 1625e1402bee..bde58031dba3 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -966,6 +966,16 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_DAC_DIRECT_DATA_REG(x) (0x0c0 + ((x) * 4)) #define NI_M_AO_WAVEFORM_ORDER_REG(x) (0x0c2 + ((x) * 4)) #define NI_M_AO_CFG_BANK_REG(x) (0x0c3 + ((x) * 4)) +#define NI_M_AO_CFG_BANK_BIPOLAR BIT(7) +#define NI_M_AO_CFG_BANK_UPDATE_TIMED BIT(6) +#define NI_M_AO_CFG_BANK_REF(x) (((x) & 0x7) << 3) +#define NI_M_AO_CFG_BANK_REF_MASK NI_M_AO_CFG_BANK_REF(7) +#define NI_M_AO_CFG_BANK_REF_INT_10V NI_M_AO_CFG_BANK_REF(0) +#define NI_M_AO_CFG_BANK_REF_INT_5V NI_M_AO_CFG_BANK_REF(1) +#define NI_M_AO_CFG_BANK_OFFSET(x) (((x) & 0x7) << 0) +#define NI_M_AO_CFG_BANK_OFFSET_MASK NI_M_AO_CFG_BANK_OFFSET(7) +#define NI_M_AO_CFG_BANK_OFFSET_0V NI_M_AO_CFG_BANK_OFFSET(0) +#define NI_M_AO_CFG_BANK_OFFSET_5V NI_M_AO_CFG_BANK_OFFSET(1) #define NI_M_RTSI_SHARED_MUX_REG 0x1a2 #define NI_M_CLK_FOUT2_REG 0x1c4 #define NI_M_CLK_FOUT2_RTSI_10MHZ BIT(7) @@ -1028,17 +1038,6 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_STATIC_AI_CTRL_REG(x) ((x) ? (0x260 + (x)) : 0x064) #define NI_M_AO_REF_ATTENUATION_REG(x) (0x264 + (x)) -enum MSeries_AO_Config_Bank_Bits { - MSeries_AO_DAC_Offset_Select_Mask = 0x7, - MSeries_AO_DAC_Offset_0V_Bits = 0x0, - MSeries_AO_DAC_Offset_5V_Bits = 0x1, - MSeries_AO_DAC_Reference_Mask = 0x38, - MSeries_AO_DAC_Reference_10V_Internal_Bits = 0x0, - MSeries_AO_DAC_Reference_5V_Internal_Bits = 0x8, - MSeries_AO_Update_Timed_Bit = 0x40, - MSeries_AO_Bipolar_Bit = 0x80 /* turns on 2's complement encoding */ -}; - enum MSeries_AO_Reference_Attenuation_Bits { MSeries_Attenuate_x5_Bit = 0x1 }; From b06afa15400182ee5d46b97462fc179ce36b0107 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:41 -0700 Subject: [PATCH 0317/1163] staging: comedi: ni_stc.h: tidy up NI_M_AO_REF_ATTENUATION_REG bits Rename the CamelCase and convert the enum into defines. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 4 ++-- drivers/staging/comedi/drivers/ni_stc.h | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 7f4e9d6df8fe..c100c0875e75 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -2675,12 +2675,12 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device *dev, break; case 4000000: conf |= NI_M_AO_CFG_BANK_REF_INT_10V; - ni_writeb(dev, MSeries_Attenuate_x5_Bit, + ni_writeb(dev, NI_M_AO_REF_ATTENUATION_X5, NI_M_AO_REF_ATTENUATION_REG(chan)); break; case 2000000: conf |= NI_M_AO_CFG_BANK_REF_INT_5V; - ni_writeb(dev, MSeries_Attenuate_x5_Bit, + ni_writeb(dev, NI_M_AO_REF_ATTENUATION_X5, NI_M_AO_REF_ATTENUATION_REG(chan)); break; default: diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index bde58031dba3..1ad7981914bb 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -1037,10 +1037,7 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_CDO_MASK_ENA_REG 0x234 #define NI_M_STATIC_AI_CTRL_REG(x) ((x) ? (0x260 + (x)) : 0x064) #define NI_M_AO_REF_ATTENUATION_REG(x) (0x264 + (x)) - -enum MSeries_AO_Reference_Attenuation_Bits { - MSeries_Attenuate_x5_Bit = 0x1 -}; +#define NI_M_AO_REF_ATTENUATION_X5 BIT(0) static inline unsigned MSeries_Cal_PWM_High_Time_Bits(unsigned count) { From cc679f9746ea1fbdc00b53deda3c1dc6edc8d5f3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:42 -0700 Subject: [PATCH 0318/1163] staging: comedi: ni_stc.h: tidy up NI_M_CAL_PWM_REG bits Rename the CamelCase and convert the inline helper functions that set the bits in this register to macros. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 4 ++-- drivers/staging/comedi/drivers/ni_stc.h | 12 ++---------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index c100c0875e75..af095e621e9f 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -4016,8 +4016,8 @@ static int ni_m_series_pwm_config(struct comedi_device *dev, data[4] = down_count * devpriv->clock_ns; return -EAGAIN; } - ni_writel(dev, MSeries_Cal_PWM_High_Time_Bits(up_count) | - MSeries_Cal_PWM_Low_Time_Bits(down_count), + ni_writel(dev, NI_M_CAL_PWM_HIGH_TIME(up_count) | + NI_M_CAL_PWM_LOW_TIME(down_count), NI_M_CAL_PWM_REG); devpriv->pwm_up_count = up_count; devpriv->pwm_down_count = down_count; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 1ad7981914bb..33ed998890a0 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -936,6 +936,8 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_DIO_REG 0x024 #define NI_M_DIO_DIR_REG 0x028 #define NI_M_CAL_PWM_REG 0x040 +#define NI_M_CAL_PWM_HIGH_TIME(x) (((x) & 0xffff) << 16) +#define NI_M_CAL_PWM_LOW_TIME(x) (((x) & 0xffff) << 0) #define NI_M_GEN_PWM_REG(x) (0x044 + ((x) * 2)) #define NI_M_AI_CFG_FIFO_DATA_REG 0x05e #define NI_M_AI_CFG_LAST_CHAN BIT(14) @@ -1039,16 +1041,6 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_AO_REF_ATTENUATION_REG(x) (0x264 + (x)) #define NI_M_AO_REF_ATTENUATION_X5 BIT(0) -static inline unsigned MSeries_Cal_PWM_High_Time_Bits(unsigned count) -{ - return (count << 16) & 0xffff0000; -} - -static inline unsigned MSeries_Cal_PWM_Low_Time_Bits(unsigned count) -{ - return count & 0xffff; -} - static inline unsigned MSeries_PFI_Output_Select_Mask(unsigned channel) { return 0x1f << (channel % 3) * 5; From 43e9d883f02a57fe989ebd568e2508f7f4da25ef Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:43 -0700 Subject: [PATCH 0319/1163] staging: comedi: ni_stc.h: tidy up NI_M_PFI_OUT_SEL_REG bits Rename the CamelCase and convert the inline helper functions that set/get the bits in this register to macros. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 6 ++--- drivers/staging/comedi/drivers/ni_stc.h | 22 ++++--------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index af095e621e9f..740a92c4b98f 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -4367,7 +4367,7 @@ static unsigned ni_m_series_get_pfi_routing(struct comedi_device *dev, struct ni_private *devpriv = dev->private; const unsigned array_offset = chan / 3; - return MSeries_PFI_Output_Select_Source(chan, + return NI_M_PFI_OUT_SEL_TO_SRC(chan, devpriv->pfi_output_select_reg[array_offset]); } @@ -4381,8 +4381,8 @@ static int ni_m_series_set_pfi_routing(struct comedi_device *dev, if ((source & 0x1f) != source) return -EINVAL; - val &= ~MSeries_PFI_Output_Select_Mask(chan); - val |= MSeries_PFI_Output_Select_Bits(chan, source); + val &= ~NI_M_PFI_OUT_SEL_MASK(chan); + val |= NI_M_PFI_OUT_SEL(chan, source); ni_writew(dev, val, NI_M_PFI_OUT_SEL_REG(index)); devpriv->pfi_output_select_reg[index] = val; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 33ed998890a0..be9efdc18693 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -1005,6 +1005,10 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_PLL_STATUS_REG 0x1c8 #define NI_M_PLL_STATUS_LOCKED BIT(0) #define NI_M_PFI_OUT_SEL_REG(x) (0x1d0 + ((x) * 2)) +#define NI_M_PFI_CHAN(_c) (((_c) % 3) * 5) +#define NI_M_PFI_OUT_SEL(_c, _s) (((_s) & 0x1f) << NI_M_PFI_CHAN(_c)) +#define NI_M_PFI_OUT_SEL_MASK(_c) (0x1f << NI_M_PFI_CHAN(_c)) +#define NI_M_PFI_OUT_SEL_TO_SRC(_c, _b) (((_b) >> NI_M_PFI_CHAN(_c)) & 0x1f) #define NI_M_PFI_DI_REG 0x1dc #define NI_M_PFI_DO_REG 0x1de #define NI_M_CFG_BYPASS_FIFO_REG 0x218 @@ -1041,24 +1045,6 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_AO_REF_ATTENUATION_REG(x) (0x264 + (x)) #define NI_M_AO_REF_ATTENUATION_X5 BIT(0) -static inline unsigned MSeries_PFI_Output_Select_Mask(unsigned channel) -{ - return 0x1f << (channel % 3) * 5; -}; - -static inline unsigned MSeries_PFI_Output_Select_Bits(unsigned channel, - unsigned source) -{ - return (source & 0x1f) << ((channel % 3) * 5); -}; - -/* inverse to MSeries_PFI_Output_Select_Bits */ -static inline unsigned MSeries_PFI_Output_Select_Source(unsigned channel, - unsigned bits) -{ - return (bits >> ((channel % 3) * 5)) & 0x1f; -}; - static inline unsigned MSeries_PFI_Filter_Select_Mask(unsigned channel) { return 0x3 << (channel * 2); From 0dee7ecc4dac113469b42d75f314d94e62c834a5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:44 -0700 Subject: [PATCH 0320/1163] staging: comedi: ni_stc.h: tidy up NI_M_PFI_FILTER_REG bits Rename the CamelCase and convert the inline helper functions that set the bits in this register to macros. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 4 ++-- drivers/staging/comedi/drivers/ni_stc.h | 14 ++------------ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 740a92c4b98f..f1299aed2850 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -4419,8 +4419,8 @@ static int ni_config_filter(struct comedi_device *dev, return -ENOTSUPP; bits = ni_readl(dev, NI_M_PFI_FILTER_REG); - bits &= ~MSeries_PFI_Filter_Select_Mask(pfi_channel); - bits |= MSeries_PFI_Filter_Select_Bits(pfi_channel, filter); + bits &= ~NI_M_PFI_FILTER_SEL_MASK(pfi_channel); + bits |= NI_M_PFI_FILTER_SEL(pfi_channel, filter); ni_writel(dev, bits, NI_M_PFI_FILTER_REG); return 0; } diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index be9efdc18693..983aeee79bdf 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -963,6 +963,8 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_AO_CALIB_REG 0x0a3 #define NI_M_AO_FIFO_DATA_REG 0x0a4 #define NI_M_PFI_FILTER_REG 0x0b0 +#define NI_M_PFI_FILTER_SEL(_c, _f) (((_f) & 0x3) << ((_c) * 2)) +#define NI_M_PFI_FILTER_SEL_MASK(_c) NI_M_PFI_FILTER_SEL((_c), 0x3) #define NI_M_RTSI_FILTER_REG 0x0b4 #define NI_M_SCXI_LEGACY_COMPAT_REG 0x0bc #define NI_M_DAC_DIRECT_DATA_REG(x) (0x0c0 + ((x) * 4)) @@ -1045,18 +1047,6 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_AO_REF_ATTENUATION_REG(x) (0x264 + (x)) #define NI_M_AO_REF_ATTENUATION_X5 BIT(0) -static inline unsigned MSeries_PFI_Filter_Select_Mask(unsigned channel) -{ - return 0x3 << (channel * 2); -} - -static inline unsigned MSeries_PFI_Filter_Select_Bits(unsigned channel, - unsigned filter) -{ - return (filter << (channel * - 2)) & MSeries_PFI_Filter_Select_Mask(channel); -} - enum CDIO_DMA_Select_Bits { CDI_DMA_Select_Shift = 0, CDI_DMA_Select_Mask = 0xf, From 2dd0825fb4e53ee23f2391cc7c5b4afee8b1c8e1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:45 -0700 Subject: [PATCH 0321/1163] staging: comedi: ni_stc.h: tidy up NI_M_CDIO_DMA_SEL_REG bits Rename the CamelCase and convert enums into macros to set the bits in this register. 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 ++++++++++------- drivers/staging/comedi/drivers/ni_stc.h | 11 ++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index f1299aed2850..2b9790ed6945 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -621,16 +621,19 @@ static inline void ni_set_cdo_dma_channel(struct comedi_device *dev, { struct ni_private *devpriv = dev->private; unsigned long flags; + unsigned bits; spin_lock_irqsave(&devpriv->soft_reg_copy_lock, flags); - devpriv->cdio_dma_select_reg &= ~CDO_DMA_Select_Mask; + devpriv->cdio_dma_select_reg &= ~NI_M_CDIO_DMA_SEL_CDO_MASK; if (mite_channel >= 0) { - /*XXX just guessing ni_stc_dma_channel_select_bitfield() returns the right bits, - under the assumption the cdio dma selection works just like ai/ao/gpct. - Definitely works for dma channels 0 and 1. */ - devpriv->cdio_dma_select_reg |= - (ni_stc_dma_channel_select_bitfield(mite_channel) << - CDO_DMA_Select_Shift) & CDO_DMA_Select_Mask; + /* + * XXX just guessing ni_stc_dma_channel_select_bitfield() + * returns the right bits, under the assumption the cdio dma + * selection works just like ai/ao/gpct. + * Definitely works for dma channels 0 and 1. + */ + bits = ni_stc_dma_channel_select_bitfield(mite_channel); + devpriv->cdio_dma_select_reg |= NI_M_CDIO_DMA_SEL_CDO(bits); } ni_writeb(dev, devpriv->cdio_dma_select_reg, NI_M_CDIO_DMA_SEL_REG); mmiowb(); diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 983aeee79bdf..a26e5c21aed1 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -925,6 +925,10 @@ static const struct comedi_lrange range_ni_E_ao_ext; * remapping. */ #define NI_M_CDIO_DMA_SEL_REG 0x007 +#define NI_M_CDIO_DMA_SEL_CDO(x) (((x) & 0xf) << 4) +#define NI_M_CDIO_DMA_SEL_CDO_MASK NI_M_CDIO_DMA_SEL_CDO(0xf) +#define NI_M_CDIO_DMA_SEL_CDI(x) (((x) & 0xf) << 0) +#define NI_M_CDIO_DMA_SEL_CDI_MASK NI_M_CDIO_DMA_SEL_CDI(0xf) #define NI_M_SCXI_STATUS_REG 0x007 #define NI_M_AI_AO_SEL_REG 0x009 #define NI_M_G0_G1_SEL_REG 0x00b @@ -1047,13 +1051,6 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_AO_REF_ATTENUATION_REG(x) (0x264 + (x)) #define NI_M_AO_REF_ATTENUATION_X5 BIT(0) -enum CDIO_DMA_Select_Bits { - CDI_DMA_Select_Shift = 0, - CDI_DMA_Select_Mask = 0xf, - CDO_DMA_Select_Shift = 4, - CDO_DMA_Select_Mask = 0xf << CDO_DMA_Select_Shift -}; - enum CDIO_Status_Bits { CDO_FIFO_Empty_Bit = 0x1, CDO_FIFO_Full_Bit = 0x2, From d53be924c8260266b72244c92399ec68d2eb8871 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:46 -0700 Subject: [PATCH 0322/1163] staging: comedi: ni_stc.h: tidy up NI_M_CDIO_STATUS_REG bits Rename the CamelCase and convert enums into defines. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 7 ++--- drivers/staging/comedi/drivers/ni_stc.h | 27 ++++++++++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 2b9790ed6945..8cdcc1b600f6 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -3436,7 +3436,8 @@ static int ni_cdo_inttrig(struct comedi_device *dev, * ni_writeb(dev, Interrupt_Group_C_Enable_Bit, NI_M_INTC_ENA_REG); */ for (i = 0; i < timeout; ++i) { - if (ni_readl(dev, NI_M_CDIO_STATUS_REG) & CDO_FIFO_Full_Bit) + if (ni_readl(dev, NI_M_CDIO_STATUS_REG) & + NI_M_CDIO_STATUS_CDO_FIFO_FULL) break; udelay(10); } @@ -3531,13 +3532,13 @@ static void handle_cdio_interrupt(struct comedi_device *dev) #endif cdio_status = ni_readl(dev, NI_M_CDIO_STATUS_REG); - if (cdio_status & (CDO_Overrun_Bit | CDO_Underflow_Bit)) { + if (cdio_status & NI_M_CDIO_STATUS_CDO_ERROR) { /* XXX just guessing this is needed and does something useful */ ni_writel(dev, CDO_Error_Interrupt_Confirm_Bit, NI_M_CDIO_CMD_REG); s->async->events |= COMEDI_CB_OVERFLOW; } - if (cdio_status & CDO_FIFO_Empty_Bit) { + if (cdio_status & NI_M_CDIO_STATUS_CDO_FIFO_EMPTY) { ni_writel(dev, CDO_Empty_FIFO_Interrupt_Enable_Clear_Bit, NI_M_CDIO_CMD_REG); /* s->async->events |= COMEDI_CB_EOA; */ diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index a26e5c21aed1..2f0f94d1e101 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -1042,6 +1042,20 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_CDI_FIFO_DATA_REG 0x220 #define NI_M_CDO_FIFO_DATA_REG 0x220 #define NI_M_CDIO_STATUS_REG 0x224 +#define NI_M_CDIO_STATUS_CDI_OVERFLOW BIT(20) +#define NI_M_CDIO_STATUS_CDI_OVERRUN BIT(19) +#define NI_M_CDIO_STATUS_CDI_ERROR (NI_M_CDIO_STATUS_CDI_OVERFLOW | \ + NI_M_CDIO_STATUS_CDI_OVERRUN) +#define NI_M_CDIO_STATUS_CDI_FIFO_REQ BIT(18) +#define NI_M_CDIO_STATUS_CDI_FIFO_FULL BIT(17) +#define NI_M_CDIO_STATUS_CDI_FIFO_EMPTY BIT(16) +#define NI_M_CDIO_STATUS_CDO_UNDERFLOW BIT(4) +#define NI_M_CDIO_STATUS_CDO_OVERRUN BIT(3) +#define NI_M_CDIO_STATUS_CDO_ERROR (NI_M_CDIO_STATUS_CDO_UNDERFLOW | \ + NI_M_CDIO_STATUS_CDO_OVERRUN) +#define NI_M_CDIO_STATUS_CDO_FIFO_REQ BIT(2) +#define NI_M_CDIO_STATUS_CDO_FIFO_FULL BIT(1) +#define NI_M_CDIO_STATUS_CDO_FIFO_EMPTY BIT(0) #define NI_M_CDIO_CMD_REG 0x224 #define NI_M_CDI_MODE_REG 0x228 #define NI_M_CDO_MODE_REG 0x22c @@ -1051,19 +1065,6 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_AO_REF_ATTENUATION_REG(x) (0x264 + (x)) #define NI_M_AO_REF_ATTENUATION_X5 BIT(0) -enum CDIO_Status_Bits { - CDO_FIFO_Empty_Bit = 0x1, - CDO_FIFO_Full_Bit = 0x2, - CDO_FIFO_Request_Bit = 0x4, - CDO_Overrun_Bit = 0x8, - CDO_Underflow_Bit = 0x10, - CDI_FIFO_Empty_Bit = 0x10000, - CDI_FIFO_Full_Bit = 0x20000, - CDI_FIFO_Request_Bit = 0x40000, - CDI_Overrun_Bit = 0x80000, - CDI_Overflow_Bit = 0x100000 -}; - enum CDIO_Command_Bits { CDO_Disarm_Bit = 0x1, CDO_Arm_Bit = 0x2, From 3c3eb8eaa75fc698f4edb7517830b112f51c11d0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:47 -0700 Subject: [PATCH 0323/1163] staging: comedi: ni_stc.h: tidy up NI_M_CDIO_CMD_REG bits Rename the CamelCase and convert enums into defines. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 23 +++++----- drivers/staging/comedi/drivers/ni_stc.h | 43 +++++++++---------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 8cdcc1b600f6..acba13847c29 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -3446,8 +3446,9 @@ static int ni_cdo_inttrig(struct comedi_device *dev, s->cancel(dev, s); return -EIO; } - ni_writel(dev, CDO_Arm_Bit | CDO_Error_Interrupt_Enable_Set_Bit | - CDO_Empty_FIFO_Interrupt_Enable_Set_Bit, + ni_writel(dev, NI_M_CDO_CMD_ARM | + NI_M_CDO_CMD_ERR_INT_ENA_SET | + NI_M_CDO_CMD_F_E_INT_ENA_SET, NI_M_CDIO_CMD_REG); return retval; } @@ -3458,7 +3459,7 @@ static int ni_cdio_cmd(struct comedi_device *dev, struct comedi_subdevice *s) unsigned cdo_mode_bits = CDO_FIFO_Mode_Bit | CDO_Halt_On_Error_Bit; int retval; - ni_writel(dev, CDO_Reset_Bit, NI_M_CDIO_CMD_REG); + ni_writel(dev, NI_M_CDO_CMD_RESET, NI_M_CDIO_CMD_REG); switch (cmd->scan_begin_src) { case TRIG_EXT: cdo_mode_bits |= @@ -3474,7 +3475,7 @@ static int ni_cdio_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ni_writel(dev, cdo_mode_bits, NI_M_CDO_MODE_REG); if (s->io_bits) { ni_writel(dev, s->state, NI_M_CDO_FIFO_DATA_REG); - ni_writel(dev, CDO_SW_Update_Bit, NI_M_CDIO_CMD_REG); + ni_writel(dev, NI_M_CDO_CMD_SW_UPDATE, NI_M_CDIO_CMD_REG); ni_writel(dev, s->io_bits, NI_M_CDO_MASK_ENA_REG); } else { dev_err(dev->class_dev, @@ -3492,9 +3493,10 @@ static int ni_cdio_cmd(struct comedi_device *dev, struct comedi_subdevice *s) static int ni_cdio_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { - ni_writel(dev, CDO_Disarm_Bit | CDO_Error_Interrupt_Enable_Clear_Bit | - CDO_Empty_FIFO_Interrupt_Enable_Clear_Bit | - CDO_FIFO_Request_Interrupt_Enable_Clear_Bit, + ni_writel(dev, NI_M_CDO_CMD_DISARM | + NI_M_CDO_CMD_ERR_INT_ENA_CLR | + NI_M_CDO_CMD_F_E_INT_ENA_CLR | + NI_M_CDO_CMD_F_REQ_INT_ENA_CLR, NI_M_CDIO_CMD_REG); /* * XXX not sure what interrupt C group does @@ -3534,12 +3536,12 @@ static void handle_cdio_interrupt(struct comedi_device *dev) cdio_status = ni_readl(dev, NI_M_CDIO_STATUS_REG); if (cdio_status & NI_M_CDIO_STATUS_CDO_ERROR) { /* XXX just guessing this is needed and does something useful */ - ni_writel(dev, CDO_Error_Interrupt_Confirm_Bit, + ni_writel(dev, NI_M_CDO_CMD_ERR_INT_CONFIRM, NI_M_CDIO_CMD_REG); s->async->events |= COMEDI_CB_OVERFLOW; } if (cdio_status & NI_M_CDIO_STATUS_CDO_FIFO_EMPTY) { - ni_writel(dev, CDO_Empty_FIFO_Interrupt_Enable_Clear_Bit, + ni_writel(dev, NI_M_CDO_CMD_F_E_INT_ENA_CLR, NI_M_CDIO_CMD_REG); /* s->async->events |= COMEDI_CB_EOA; */ } @@ -5313,7 +5315,8 @@ static int ni_E_init(struct comedi_device *dev, } /* reset DIO and set all channels to inputs */ - ni_writel(dev, CDO_Reset_Bit | CDI_Reset_Bit, + ni_writel(dev, NI_M_CDO_CMD_RESET | + NI_M_CDI_CMD_RESET, NI_M_CDIO_CMD_REG); ni_writel(dev, s->io_bits, NI_M_DIO_DIR_REG); } else { diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 2f0f94d1e101..35caf8e1d4b1 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -1057,6 +1057,26 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_CDIO_STATUS_CDO_FIFO_FULL BIT(1) #define NI_M_CDIO_STATUS_CDO_FIFO_EMPTY BIT(0) #define NI_M_CDIO_CMD_REG 0x224 +#define NI_M_CDI_CMD_SW_UPDATE BIT(20) +#define NI_M_CDO_CMD_SW_UPDATE BIT(19) +#define NI_M_CDO_CMD_F_E_INT_ENA_CLR BIT(17) +#define NI_M_CDO_CMD_F_E_INT_ENA_SET BIT(16) +#define NI_M_CDI_CMD_ERR_INT_CONFIRM BIT(15) +#define NI_M_CDO_CMD_ERR_INT_CONFIRM BIT(14) +#define NI_M_CDI_CMD_F_REQ_INT_ENA_CLR BIT(13) +#define NI_M_CDI_CMD_F_REQ_INT_ENA_SET BIT(12) +#define NI_M_CDO_CMD_F_REQ_INT_ENA_CLR BIT(11) +#define NI_M_CDO_CMD_F_REQ_INT_ENA_SET BIT(10) +#define NI_M_CDI_CMD_ERR_INT_ENA_CLR BIT(9) +#define NI_M_CDI_CMD_ERR_INT_ENA_SET BIT(8) +#define NI_M_CDO_CMD_ERR_INT_ENA_CLR BIT(7) +#define NI_M_CDO_CMD_ERR_INT_ENA_SET BIT(6) +#define NI_M_CDI_CMD_RESET BIT(5) +#define NI_M_CDO_CMD_RESET BIT(4) +#define NI_M_CDI_CMD_ARM BIT(3) +#define NI_M_CDI_CMD_DISARM BIT(2) +#define NI_M_CDO_CMD_ARM BIT(1) +#define NI_M_CDO_CMD_DISARM BIT(0) #define NI_M_CDI_MODE_REG 0x228 #define NI_M_CDO_MODE_REG 0x22c #define NI_M_CDI_MASK_ENA_REG 0x230 @@ -1065,29 +1085,6 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_AO_REF_ATTENUATION_REG(x) (0x264 + (x)) #define NI_M_AO_REF_ATTENUATION_X5 BIT(0) -enum CDIO_Command_Bits { - CDO_Disarm_Bit = 0x1, - CDO_Arm_Bit = 0x2, - CDI_Disarm_Bit = 0x4, - CDI_Arm_Bit = 0x8, - CDO_Reset_Bit = 0x10, - CDI_Reset_Bit = 0x20, - CDO_Error_Interrupt_Enable_Set_Bit = 0x40, - CDO_Error_Interrupt_Enable_Clear_Bit = 0x80, - CDI_Error_Interrupt_Enable_Set_Bit = 0x100, - CDI_Error_Interrupt_Enable_Clear_Bit = 0x200, - CDO_FIFO_Request_Interrupt_Enable_Set_Bit = 0x400, - CDO_FIFO_Request_Interrupt_Enable_Clear_Bit = 0x800, - CDI_FIFO_Request_Interrupt_Enable_Set_Bit = 0x1000, - CDI_FIFO_Request_Interrupt_Enable_Clear_Bit = 0x2000, - CDO_Error_Interrupt_Confirm_Bit = 0x4000, - CDI_Error_Interrupt_Confirm_Bit = 0x8000, - CDO_Empty_FIFO_Interrupt_Enable_Set_Bit = 0x10000, - CDO_Empty_FIFO_Interrupt_Enable_Clear_Bit = 0x20000, - CDO_SW_Update_Bit = 0x80000, - CDI_SW_Update_Bit = 0x100000 -}; - enum CDI_Mode_Bits { CDI_Sample_Source_Select_Mask = 0x3f, CDI_Halt_On_Error_Bit = 0x200, From f9a8f6067da172c58390dd5d1b786b4e4e790f61 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:48 -0700 Subject: [PATCH 0324/1163] staging: comedi: ni_stc.h: tidy up NI_M_CDI_MODE_REG bits Rename the CamelCase and convert enums into defines. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_stc.h | 27 ++++++++++++------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 35caf8e1d4b1..1c13c99a33d8 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -1078,6 +1078,19 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_CDO_CMD_ARM BIT(1) #define NI_M_CDO_CMD_DISARM BIT(0) #define NI_M_CDI_MODE_REG 0x228 +#define NI_M_CDI_MODE_DATA_LANE(x) (((x) & 0x3) << 12) +#define NI_M_CDI_MODE_DATA_LANE_MASK NI_M_CDI_MODE_DATA_LANE(3) +#define NI_M_CDI_MODE_DATA_LANE_0_15 NI_M_CDI_MODE_DATA_LANE(0) +#define NI_M_CDI_MODE_DATA_LANE_16_31 NI_M_CDI_MODE_DATA_LANE(1) +#define NI_M_CDI_MODE_DATA_LANE_0_7 NI_M_CDI_MODE_DATA_LANE(0) +#define NI_M_CDI_MODE_DATA_LANE_8_15 NI_M_CDI_MODE_DATA_LANE(1) +#define NI_M_CDI_MODE_DATA_LANE_16_23 NI_M_CDI_MODE_DATA_LANE(2) +#define NI_M_CDI_MODE_DATA_LANE_24_31 NI_M_CDI_MODE_DATA_LANE(3) +#define NI_M_CDI_MODE_FIFO_MODE BIT(11) +#define NI_M_CDI_MODE_POLARITY BIT(10) +#define NI_M_CDI_MODE_HALT_ON_ERROR BIT(9) +#define NI_M_CDI_MODE_SAMPLE_SRC(x) (((x) & 0x3f) << 0) +#define NI_M_CDI_MODE_SAMPLE_SRC_MASK NI_M_CDI_MODE_SAMPLE_SRC(0x3f) #define NI_M_CDO_MODE_REG 0x22c #define NI_M_CDI_MASK_ENA_REG 0x230 #define NI_M_CDO_MASK_ENA_REG 0x234 @@ -1085,20 +1098,6 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_AO_REF_ATTENUATION_REG(x) (0x264 + (x)) #define NI_M_AO_REF_ATTENUATION_X5 BIT(0) -enum CDI_Mode_Bits { - CDI_Sample_Source_Select_Mask = 0x3f, - CDI_Halt_On_Error_Bit = 0x200, - CDI_Polarity_Bit = 0x400, /* sample clock on falling edge */ - CDI_FIFO_Mode_Bit = 0x800, /* set for half full mode, clear for not empty mode */ - CDI_Data_Lane_Mask = 0x3000, /* data lanes specify which dio channels map to byte or word accesses to the dio fifos */ - CDI_Data_Lane_0_15_Bits = 0x0, - CDI_Data_Lane_16_31_Bits = 0x1000, - CDI_Data_Lane_0_7_Bits = 0x0, - CDI_Data_Lane_8_15_Bits = 0x1000, - CDI_Data_Lane_16_23_Bits = 0x2000, - CDI_Data_Lane_24_31_Bits = 0x3000 -}; - enum CDO_Mode_Bits { CDO_Sample_Source_Select_Mask = 0x3f, CDO_Retransmit_Bit = 0x100, From b9abc4aa75197f48d54092f36576249312dff55a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:49 -0700 Subject: [PATCH 0325/1163] staging: comedi: ni_mio_common: remove BUG() check in ni_cdio_cmd() The cmd->scan_begin_src was validated in ni_cdio_cmdtest() and can only be TRIG_EXT. Remove the switch statement and unnecessary BUG() check. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index acba13847c29..cbfbfa5ab752 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -3460,16 +3460,8 @@ static int ni_cdio_cmd(struct comedi_device *dev, struct comedi_subdevice *s) int retval; ni_writel(dev, NI_M_CDO_CMD_RESET, NI_M_CDIO_CMD_REG); - switch (cmd->scan_begin_src) { - case TRIG_EXT: - cdo_mode_bits |= - CR_CHAN(cmd->scan_begin_arg) & - CDO_Sample_Source_Select_Mask; - break; - default: - BUG(); - break; - } + cdo_mode_bits |= CR_CHAN(cmd->scan_begin_arg) & + CDO_Sample_Source_Select_Mask; if (cmd->scan_begin_arg & CR_INVERT) cdo_mode_bits |= CDO_Polarity_Bit; ni_writel(dev, cdo_mode_bits, NI_M_CDO_MODE_REG); From 258f004754c436c31447123b9f2f8337e35b8037 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:50 -0700 Subject: [PATCH 0326/1163] staging: comedi: ni_stc.h: tidy up NI_M_CDO_MODE_REG bits Rename the CamelCase and convert enums into defines. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 11 +++---- drivers/staging/comedi/drivers/ni_stc.h | 29 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index cbfbfa5ab752..e8c6fff81c40 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -3371,7 +3371,7 @@ static int ni_cdio_cmdtest(struct comedi_device *dev, err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0); tmp = cmd->scan_begin_arg; - tmp &= CR_PACK_FLAGS(CDO_Sample_Source_Select_Mask, 0, 0, CR_INVERT); + tmp &= CR_PACK_FLAGS(NI_M_CDO_MODE_SAMPLE_SRC_MASK, 0, 0, CR_INVERT); if (tmp != cmd->scan_begin_arg) err |= -EINVAL; @@ -3456,14 +3456,15 @@ static int ni_cdo_inttrig(struct comedi_device *dev, static int ni_cdio_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { const struct comedi_cmd *cmd = &s->async->cmd; - unsigned cdo_mode_bits = CDO_FIFO_Mode_Bit | CDO_Halt_On_Error_Bit; + unsigned cdo_mode_bits; int retval; ni_writel(dev, NI_M_CDO_CMD_RESET, NI_M_CDIO_CMD_REG); - cdo_mode_bits |= CR_CHAN(cmd->scan_begin_arg) & - CDO_Sample_Source_Select_Mask; + cdo_mode_bits = NI_M_CDO_MODE_FIFO_MODE | + NI_M_CDO_MODE_HALT_ON_ERROR | + NI_M_CDO_MODE_SAMPLE_SRC(CR_CHAN(cmd->scan_begin_arg)); if (cmd->scan_begin_arg & CR_INVERT) - cdo_mode_bits |= CDO_Polarity_Bit; + cdo_mode_bits |= NI_M_CDO_MODE_POLARITY; ni_writel(dev, cdo_mode_bits, NI_M_CDO_MODE_REG); if (s->io_bits) { ni_writel(dev, s->state, NI_M_CDO_FIFO_DATA_REG); diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 1c13c99a33d8..a05c6ef66ff8 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -1092,27 +1092,26 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_CDI_MODE_SAMPLE_SRC(x) (((x) & 0x3f) << 0) #define NI_M_CDI_MODE_SAMPLE_SRC_MASK NI_M_CDI_MODE_SAMPLE_SRC(0x3f) #define NI_M_CDO_MODE_REG 0x22c +#define NI_M_CDO_MODE_DATA_LANE(x) (((x) & 0x3) << 12) +#define NI_M_CDO_MODE_DATA_LANE_MASK NI_M_CDO_MODE_DATA_LANE(3) +#define NI_M_CDO_MODE_DATA_LANE_0_15 NI_M_CDO_MODE_DATA_LANE(0) +#define NI_M_CDO_MODE_DATA_LANE_16_31 NI_M_CDO_MODE_DATA_LANE(1) +#define NI_M_CDO_MODE_DATA_LANE_0_7 NI_M_CDO_MODE_DATA_LANE(0) +#define NI_M_CDO_MODE_DATA_LANE_8_15 NI_M_CDO_MODE_DATA_LANE(1) +#define NI_M_CDO_MODE_DATA_LANE_16_23 NI_M_CDO_MODE_DATA_LANE(2) +#define NI_M_CDO_MODE_DATA_LANE_24_31 NI_M_CDO_MODE_DATA_LANE(3) +#define NI_M_CDO_MODE_FIFO_MODE BIT(11) +#define NI_M_CDO_MODE_POLARITY BIT(10) +#define NI_M_CDO_MODE_HALT_ON_ERROR BIT(9) +#define NI_M_CDO_MODE_RETRANSMIT BIT(8) +#define NI_M_CDO_MODE_SAMPLE_SRC(x) (((x) & 0x3f) << 0) +#define NI_M_CDO_MODE_SAMPLE_SRC_MASK NI_M_CDO_MODE_SAMPLE_SRC(0x3f) #define NI_M_CDI_MASK_ENA_REG 0x230 #define NI_M_CDO_MASK_ENA_REG 0x234 #define NI_M_STATIC_AI_CTRL_REG(x) ((x) ? (0x260 + (x)) : 0x064) #define NI_M_AO_REF_ATTENUATION_REG(x) (0x264 + (x)) #define NI_M_AO_REF_ATTENUATION_X5 BIT(0) -enum CDO_Mode_Bits { - CDO_Sample_Source_Select_Mask = 0x3f, - CDO_Retransmit_Bit = 0x100, - CDO_Halt_On_Error_Bit = 0x200, - CDO_Polarity_Bit = 0x400, /* sample clock on falling edge */ - CDO_FIFO_Mode_Bit = 0x800, /* set for half full mode, clear for not full mode */ - CDO_Data_Lane_Mask = 0x3000, /* data lanes specify which dio channels map to byte or word accesses to the dio fifos */ - CDO_Data_Lane_0_15_Bits = 0x0, - CDO_Data_Lane_16_31_Bits = 0x1000, - CDO_Data_Lane_0_7_Bits = 0x0, - CDO_Data_Lane_8_15_Bits = 0x1000, - CDO_Data_Lane_16_23_Bits = 0x2000, - CDO_Data_Lane_24_31_Bits = 0x3000 -}; - enum Interrupt_C_Enable_Bits { Interrupt_Group_C_Enable_Bit = 0x1 }; From 60f078f974b24c10414b10f518996108a80fd1b1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:51 -0700 Subject: [PATCH 0327/1163] staging: comedi: ni_stc.h: tidy up NI_M_INTC_ENA_REG bits Rename the CamelCase and convert enums into defines. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 2 +- drivers/staging/comedi/drivers/ni_stc.h | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index e8c6fff81c40..1ecbb3cf7fea 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -3433,7 +3433,7 @@ static int ni_cdo_inttrig(struct comedi_device *dev, /* * XXX not sure what interrupt C group does * wait for dma to fill output fifo - * ni_writeb(dev, Interrupt_Group_C_Enable_Bit, NI_M_INTC_ENA_REG); + * ni_writeb(dev, NI_M_INTC_ENA, NI_M_INTC_ENA_REG); */ for (i = 0; i < timeout; ++i) { if (ni_readl(dev, NI_M_CDIO_STATUS_REG) & diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index a05c6ef66ff8..a29e65af6261 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -959,6 +959,7 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_AI_CFG_BANK_SEL(x) ((((x) & 0x40) << 4) | ((x) & 0x30)) #define NI_M_AI_CFG_CHAN_SEL(x) (((x) & 0xf) << 0) #define NI_M_INTC_ENA_REG 0x088 +#define NI_M_INTC_ENA BIT(0) #define NI_M_INTC_STATUS_REG 0x088 #define NI_M_ATRIG_CTRL_REG 0x08c #define NI_M_AO_SER_INT_ENA_REG 0x0a0 @@ -1112,10 +1113,6 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_AO_REF_ATTENUATION_REG(x) (0x264 + (x)) #define NI_M_AO_REF_ATTENUATION_X5 BIT(0) -enum Interrupt_C_Enable_Bits { - Interrupt_Group_C_Enable_Bit = 0x1 -}; - enum Interrupt_C_Status_Bits { Interrupt_Group_C_Status_Bit = 0x1 }; From 793b1936067c8bb6abd7272e06348e4d70abc69a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:52 -0700 Subject: [PATCH 0328/1163] staging: comedi: ni_stc.h: tidy up NI_M_INTC_STATUS_REG bits Rename the CamelCase and convert enums into defines. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_stc.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index a29e65af6261..cc095bf24911 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -961,6 +961,7 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_INTC_ENA_REG 0x088 #define NI_M_INTC_ENA BIT(0) #define NI_M_INTC_STATUS_REG 0x088 +#define NI_M_INTC_STATUS BIT(0) #define NI_M_ATRIG_CTRL_REG 0x08c #define NI_M_AO_SER_INT_ENA_REG 0x0a0 #define NI_M_AO_SER_INT_ACK_REG 0x0a1 @@ -1113,10 +1114,6 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_AO_REF_ATTENUATION_REG(x) (0x264 + (x)) #define NI_M_AO_REF_ATTENUATION_X5 BIT(0) -enum Interrupt_C_Status_Bits { - Interrupt_Group_C_Status_Bit = 0x1 -}; - #define M_SERIES_EEPROM_SIZE 1024 struct ni_board_struct { From b81ddcc3c9e09ba73af2b18dfaf910d40125b6cd Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:53 -0700 Subject: [PATCH 0329/1163] staging: comedi: ni_mio_common: remove disabled GPCT functions The GPCT (general purpose counter timer) is handled by the ni_tio and ni_tiocmd modules. Remove the old disabled code in this file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 82 ------------------- 1 file changed, 82 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 1ecbb3cf7fea..8a646b816cbb 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -5018,88 +5018,6 @@ static int ni_gpct_cancel(struct comedi_device *dev, struct comedi_subdevice *s) } #endif -#if 0 -/* - * Read the GPCTs current value. - */ -static int GPCT_G_Watch(struct comedi_device *dev, int chan) -{ - unsigned int hi1, hi2, lo; - - devpriv->gpct_command[chan] &= ~G_Save_Trace; - ni_stc_writew(dev, devpriv->gpct_command[chan], - G_Command_Register(chan)); - - devpriv->gpct_command[chan] |= G_Save_Trace; - ni_stc_writew(dev, devpriv->gpct_command[chan], - G_Command_Register(chan)); - - /* This procedure is used because the two registers cannot - * be read atomically. */ - do { - hi1 = ni_stc_readw(dev, G_Save_Register_High(chan)); - lo = ni_stc_readw(dev, G_Save_Register_Low(chan)); - hi2 = ni_stc_readw(dev, G_Save_Register_High(chan)); - } while (hi1 != hi2); - - return (hi1 << 16) | lo; -} - -static void GPCT_Reset(struct comedi_device *dev, int chan) -{ - int temp_ack_reg = 0; - - devpriv->gpct_cur_operation[chan] = GPCT_RESET; - - switch (chan) { - case 0: - ni_stc_writew(dev, G0_Reset, Joint_Reset_Register); - ni_set_bits(dev, Interrupt_A_Enable_Register, - G0_TC_Interrupt_Enable, 0); - ni_set_bits(dev, Interrupt_A_Enable_Register, - G0_Gate_Interrupt_Enable, 0); - temp_ack_reg |= G0_Gate_Error_Confirm; - temp_ack_reg |= G0_TC_Error_Confirm; - temp_ack_reg |= G0_TC_Interrupt_Ack; - temp_ack_reg |= G0_Gate_Interrupt_Ack; - ni_stc_writew(dev, temp_ack_reg, Interrupt_A_Ack_Register); - - /* problem...this interferes with the other ctr... */ - devpriv->an_trig_etc_reg |= GPFO_0_Output_Enable; - ni_stc_writew(dev, devpriv->an_trig_etc_reg, - Analog_Trigger_Etc_Register); - break; - case 1: - ni_stc_writew(dev, G1_Reset, Joint_Reset_Register); - ni_set_bits(dev, Interrupt_B_Enable_Register, - G1_TC_Interrupt_Enable, 0); - ni_set_bits(dev, Interrupt_B_Enable_Register, - G0_Gate_Interrupt_Enable, 0); - temp_ack_reg |= G1_Gate_Error_Confirm; - temp_ack_reg |= G1_TC_Error_Confirm; - temp_ack_reg |= G1_TC_Interrupt_Ack; - temp_ack_reg |= G1_Gate_Interrupt_Ack; - ni_stc_writew(dev, temp_ack_reg, Interrupt_B_Ack_Register); - - devpriv->an_trig_etc_reg |= GPFO_1_Output_Enable; - ni_stc_writew(dev, devpriv->an_trig_etc_reg, - Analog_Trigger_Etc_Register); - break; - } - - devpriv->gpct_mode[chan] = 0; - devpriv->gpct_input_select[chan] = 0; - devpriv->gpct_command[chan] = 0; - - devpriv->gpct_command[chan] |= G_Synchronized_Gate; - - ni_stc_writew(dev, devpriv->gpct_mode[chan], G_Mode_Register(chan)); - ni_stc_writew(dev, devpriv->gpct_input_select[chan], - G_Input_Select_Register(chan)); - ni_stc_writew(dev, 0, G_Autoincrement_Register(chan)); -} -#endif - static irqreturn_t ni_E_interrupt(int irq, void *d) { struct comedi_device *dev = d; From 480456d3d6f51e09c4a631afa983434ed7e35d15 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:54 -0700 Subject: [PATCH 0330/1163] staging: comedi: ni_stc.h: tidy up Interrupt_A_Ack_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 37 ++++++------------- drivers/staging/comedi/drivers/ni_stc.h | 35 +++++++++++------- 2 files changed, 33 insertions(+), 39 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 8a646b816cbb..f0be47ef5347 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -314,7 +314,7 @@ struct mio_regmap { }; static const struct mio_regmap m_series_stc_write_regmap[] = { - [Interrupt_A_Ack_Register] = { 0x104, 2 }, + [NISTC_INTA_ACK_REG] = { 0x104, 2 }, [Interrupt_B_Ack_Register] = { 0x106, 2 }, [AI_Command_2_Register] = { 0x108, 2 }, [AO_Command_2_Register] = { 0x10a, 2 }, @@ -1340,16 +1340,15 @@ static void ack_a_interrupt(struct comedi_device *dev, unsigned short a_status) unsigned short ack = 0; if (a_status & AI_SC_TC_St) - ack |= AI_SC_TC_Interrupt_Ack; + ack |= NISTC_INTA_ACK_AI_SC_TC; if (a_status & AI_START1_St) - ack |= AI_START1_Interrupt_Ack; + ack |= NISTC_INTA_ACK_AI_START1; if (a_status & AI_START_St) - ack |= AI_START_Interrupt_Ack; + ack |= NISTC_INTA_ACK_AI_START; if (a_status & AI_STOP_St) - /* not sure why we used to ack the START here also, instead of doing it independently. Frank Hess 2007-07-06 */ - ack |= AI_STOP_Interrupt_Ack /*| AI_START_Interrupt_Ack */; + ack |= NISTC_INTA_ACK_AI_STOP; if (ack) - ni_stc_writew(dev, ack, Interrupt_A_Ack_Register); + ni_stc_writew(dev, ack, NISTC_INTA_ACK_REG); } static void handle_a_interrupt(struct comedi_device *dev, unsigned short status, @@ -1697,15 +1696,9 @@ static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s) * AI_Personal_Register * AI_Output_Control_Register */ - ni_stc_writew(dev, - AI_SC_TC_Error_Confirm | - AI_START_Interrupt_Ack | - AI_START2_Interrupt_Ack | - AI_START1_Interrupt_Ack | - AI_SC_TC_Interrupt_Ack | - AI_Error_Interrupt_Ack | - AI_STOP_Interrupt_Ack, - Interrupt_A_Ack_Register); /* clear interrupts */ + + /* clear interrupts */ + ni_stc_writew(dev, NISTC_INTA_ACK_AI_ALL, NISTC_INTA_ACK_REG); ni_stc_writew(dev, AI_Configuration_End, Joint_Reset_Register); @@ -2506,15 +2499,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } /* clear interrupts */ - ni_stc_writew(dev, - AI_Error_Interrupt_Ack | - AI_STOP_Interrupt_Ack | - AI_START_Interrupt_Ack | - AI_START2_Interrupt_Ack | - AI_START1_Interrupt_Ack | - AI_SC_TC_Interrupt_Ack | - AI_SC_TC_Error_Confirm, - Interrupt_A_Ack_Register); + ni_stc_writew(dev, NISTC_INTA_ACK_AI_ALL, NISTC_INTA_ACK_REG); ni_set_bits(dev, Interrupt_A_Enable_Register, interrupt_a_enable, 1); @@ -3763,7 +3748,7 @@ static const struct mio_regmap ni_gpct_to_stc_regmap[] = { [NITIO_G1_DMA_STATUS] = { 0x1ba, 2 }, /* M-Series only */ [NITIO_G0_ABZ] = { 0x1c0, 2 }, /* M-Series only */ [NITIO_G1_ABZ] = { 0x1c2, 2 }, /* M-Series only */ - [NITIO_G0_INT_ACK] = { Interrupt_A_Ack_Register, 2 }, + [NITIO_G0_INT_ACK] = { NISTC_INTA_ACK_REG, 2 }, [NITIO_G1_INT_ACK] = { Interrupt_B_Ack_Register, 2 }, [NITIO_G0_STATUS] = { AI_Status_1_Register, 2 }, [NITIO_G1_STATUS] = { AO_Status_1_Register, 2 }, diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index cc095bf24911..098d8183f417 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -45,20 +45,29 @@ #define NUM_PFI_OUTPUT_SELECT_REGS 6 -/* Registers in the National Instruments DAQ-STC chip */ +/* + * Registers in the National Instruments DAQ-STC chip + */ -#define Interrupt_A_Ack_Register 2 -#define G0_Gate_Interrupt_Ack _bit15 -#define G0_TC_Interrupt_Ack _bit14 -#define AI_Error_Interrupt_Ack _bit13 -#define AI_STOP_Interrupt_Ack _bit12 -#define AI_START_Interrupt_Ack _bit11 -#define AI_START2_Interrupt_Ack _bit10 -#define AI_START1_Interrupt_Ack _bit9 -#define AI_SC_TC_Interrupt_Ack _bit8 -#define AI_SC_TC_Error_Confirm _bit7 -#define G0_TC_Error_Confirm _bit6 -#define G0_Gate_Error_Confirm _bit5 +#define NISTC_INTA_ACK_REG 2 +#define NISTC_INTA_ACK_G0_GATE BIT(15) +#define NISTC_INTA_ACK_G0_TC BIT(14) +#define NISTC_INTA_ACK_AI_ERR BIT(13) +#define NISTC_INTA_ACK_AI_STOP BIT(12) +#define NISTC_INTA_ACK_AI_START BIT(11) +#define NISTC_INTA_ACK_AI_START2 BIT(10) +#define NISTC_INTA_ACK_AI_START1 BIT(9) +#define NISTC_INTA_ACK_AI_SC_TC BIT(8) +#define NISTC_INTA_ACK_AI_SC_TC_ERR BIT(7) +#define NISTC_INTA_ACK_G0_TC_ERR BIT(6) +#define NISTC_INTA_ACK_G0_GATE_ERR BIT(5) +#define NISTC_INTA_ACK_AI_ALL (NISTC_INTA_ACK_AI_ERR | \ + NISTC_INTA_ACK_AI_STOP | \ + NISTC_INTA_ACK_AI_START | \ + NISTC_INTA_ACK_AI_START2 | \ + NISTC_INTA_ACK_AI_START1 | \ + NISTC_INTA_ACK_AI_SC_TC | \ + NISTC_INTA_ACK_AI_SC_TC_ERR) #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 From 4a6de8327d125158827ad72d6d07d674c98e0387 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:55 -0700 Subject: [PATCH 0331/1163] staging: comedi: ni_stc.h: tidy up Interrupt_B_Ack_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 28 ++++++------ drivers/staging/comedi/drivers/ni_stc.h | 45 +++++++++++-------- 2 files changed, 40 insertions(+), 33 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index f0be47ef5347..db6c6e4cddf4 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -315,7 +315,7 @@ struct mio_regmap { static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_INTA_ACK_REG] = { 0x104, 2 }, - [Interrupt_B_Ack_Register] = { 0x106, 2 }, + [NISTC_INTB_ACK_REG] = { 0x106, 2 }, [AI_Command_2_Register] = { 0x108, 2 }, [AO_Command_2_Register] = { 0x10a, 2 }, [G_Command_Register(0)] = { 0x10c, 2 }, @@ -1434,21 +1434,21 @@ static void ack_b_interrupt(struct comedi_device *dev, unsigned short b_status) unsigned short ack = 0; if (b_status & AO_BC_TC_St) - ack |= AO_BC_TC_Interrupt_Ack; + ack |= NISTC_INTB_ACK_AO_BC_TC; if (b_status & AO_Overrun_St) - ack |= AO_Error_Interrupt_Ack; + ack |= NISTC_INTB_ACK_AO_ERR; if (b_status & AO_START_St) - ack |= AO_START_Interrupt_Ack; + ack |= NISTC_INTB_ACK_AO_START; if (b_status & AO_START1_St) - ack |= AO_START1_Interrupt_Ack; + ack |= NISTC_INTB_ACK_AO_START1; if (b_status & AO_UC_TC_St) - ack |= AO_UC_TC_Interrupt_Ack; + ack |= NISTC_INTB_ACK_AO_UC_TC; if (b_status & AO_UI2_TC_St) - ack |= AO_UI2_TC_Interrupt_Ack; + ack |= NISTC_INTB_ACK_AO_UI2_TC; if (b_status & AO_UPDATE_St) - ack |= AO_UPDATE_Interrupt_Ack; + ack |= NISTC_INTB_ACK_AO_UPDATE; if (ack) - ni_stc_writew(dev, ack, Interrupt_B_Ack_Register); + ni_stc_writew(dev, ack, NISTC_INTB_ACK_REG); } static void handle_b_interrupt(struct comedi_device *dev, @@ -2900,7 +2900,7 @@ static int ni_ao_inttrig(struct comedi_device *dev, * stc manual says we are need to clear error interrupt after * AO_TMRDACWRs_In_Progress_St clears */ - ni_stc_writew(dev, AO_Error_Interrupt_Ack, Interrupt_B_Ack_Register); + ni_stc_writew(dev, NISTC_INTB_ACK_AO_ERR, NISTC_INTB_ACK_REG); ni_set_bits(dev, Interrupt_B_Enable_Register, interrupt_b_bits, 1); @@ -3104,8 +3104,8 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ni_stc_writew(dev, AO_Configuration_End, Joint_Reset_Register); if (cmd->stop_src == TRIG_COUNT) { - ni_stc_writew(dev, AO_BC_TC_Interrupt_Ack, - Interrupt_B_Ack_Register); + ni_stc_writew(dev, NISTC_INTB_ACK_AO_BC_TC, + NISTC_INTB_ACK_REG); ni_set_bits(dev, Interrupt_B_Enable_Register, AO_BC_TC_Interrupt_Enable, 1); } @@ -3208,7 +3208,7 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s) ni_stc_writew(dev, AO_Disarm, AO_Command_1_Register); ni_set_bits(dev, Interrupt_B_Enable_Register, ~0, 0); ni_stc_writew(dev, AO_BC_Source_Select, AO_Personal_Register); - ni_stc_writew(dev, 0x3f98, Interrupt_B_Ack_Register); + ni_stc_writew(dev, NISTC_INTB_ACK_AO_ALL, NISTC_INTB_ACK_REG); ni_stc_writew(dev, AO_BC_Source_Select | AO_UPDATE_Pulse_Width | AO_TMRDACWR_Pulse_Width, AO_Personal_Register); ni_stc_writew(dev, 0, AO_Output_Control_Register); @@ -3749,7 +3749,7 @@ static const struct mio_regmap ni_gpct_to_stc_regmap[] = { [NITIO_G0_ABZ] = { 0x1c0, 2 }, /* M-Series only */ [NITIO_G1_ABZ] = { 0x1c2, 2 }, /* M-Series only */ [NITIO_G0_INT_ACK] = { NISTC_INTA_ACK_REG, 2 }, - [NITIO_G1_INT_ACK] = { Interrupt_B_Ack_Register, 2 }, + [NITIO_G1_INT_ACK] = { NISTC_INTB_ACK_REG, 2 }, [NITIO_G0_STATUS] = { AI_Status_1_Register, 2 }, [NITIO_G1_STATUS] = { AO_Status_1_Register, 2 }, [NITIO_G0_INT_ENA] = { Interrupt_A_Enable_Register, 2 }, diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 098d8183f417..07df8a5e40ea 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -69,6 +69,32 @@ NISTC_INTA_ACK_AI_SC_TC | \ NISTC_INTA_ACK_AI_SC_TC_ERR) +#define NISTC_INTB_ACK_REG 3 +#define NISTC_INTB_ACK_G1_GATE BIT(15) +#define NISTC_INTB_ACK_G1_TC BIT(14) +#define NISTC_INTB_ACK_AO_ERR BIT(13) +#define NISTC_INTB_ACK_AO_STOP BIT(12) +#define NISTC_INTB_ACK_AO_START BIT(11) +#define NISTC_INTB_ACK_AO_UPDATE BIT(10) +#define NISTC_INTB_ACK_AO_START1 BIT(9) +#define NISTC_INTB_ACK_AO_BC_TC BIT(8) +#define NISTC_INTB_ACK_AO_UC_TC BIT(7) +#define NISTC_INTB_ACK_AO_UI2_TC BIT(6) +#define NISTC_INTB_ACK_AO_UI2_TC_ERR BIT(5) +#define NISTC_INTB_ACK_AO_BC_TC_ERR BIT(4) +#define NISTC_INTB_ACK_AO_BC_TC_TRIG_ERR BIT(3) +#define NISTC_INTB_ACK_G1_TC_ERR BIT(2) +#define NISTC_INTB_ACK_G1_GATE_ERR BIT(1) +#define NISTC_INTB_ACK_AO_ALL (NISTC_INTB_ACK_AO_ERR | \ + NISTC_INTB_ACK_AO_STOP | \ + NISTC_INTB_ACK_AO_START | \ + NISTC_INTB_ACK_AO_UPDATE | \ + NISTC_INTB_ACK_AO_START1 | \ + NISTC_INTB_ACK_AO_BC_TC | \ + NISTC_INTB_ACK_AO_UC_TC | \ + NISTC_INTB_ACK_AO_BC_TC_ERR | \ + NISTC_INTB_ACK_AO_BC_TC_TRIG_ERR) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -89,25 +115,6 @@ #define AI_Status_2_Register 5 -#define Interrupt_B_Ack_Register 3 -enum Interrupt_B_Ack_Bits { - G1_Gate_Error_Confirm = _bit1, - G1_TC_Error_Confirm = _bit2, - AO_BC_TC_Trigger_Error_Confirm = _bit3, - AO_BC_TC_Error_Confirm = _bit4, - AO_UI2_TC_Error_Confrim = _bit5, - AO_UI2_TC_Interrupt_Ack = _bit6, - AO_UC_TC_Interrupt_Ack = _bit7, - AO_BC_TC_Interrupt_Ack = _bit8, - AO_START1_Interrupt_Ack = _bit9, - AO_UPDATE_Interrupt_Ack = _bit10, - AO_START_Interrupt_Ack = _bit11, - AO_STOP_Interrupt_Ack = _bit12, - AO_Error_Interrupt_Ack = _bit13, - G1_TC_Interrupt_Ack = _bit14, - G1_Gate_Interrupt_Ack = _bit15 -}; - #define AO_Status_1_Register 3 #define Interrupt_B_St _bit15 #define AO_FIFO_Full_St _bit14 From a1da35a5c549b5a75c77dfee289d0a38823e78cf Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:56 -0700 Subject: [PATCH 0332/1163] staging: comedi: ni_stc.h: tidy up AI_Command_2_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 22 +++++++-------- drivers/staging/comedi/drivers/ni_stc.h | 28 +++++++++---------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index db6c6e4cddf4..6c545a9de903 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -316,7 +316,7 @@ struct mio_regmap { static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_INTA_ACK_REG] = { 0x104, 2 }, [NISTC_INTB_ACK_REG] = { 0x106, 2 }, - [AI_Command_2_Register] = { 0x108, 2 }, + [NISTC_AI_CMD2_REG] = { 0x108, 2 }, [AO_Command_2_Register] = { 0x10a, 2 }, [G_Command_Register(0)] = { 0x10c, 2 }, [G_Command_Register(1)] = { 0x10e, 2 }, @@ -1315,8 +1315,8 @@ static void ni_handle_eos(struct comedi_device *dev, struct comedi_subdevice *s) s->async->events |= COMEDI_CB_EOS; #endif } - /* handle special case of single scan using AI_End_On_End_Of_Scan */ - if ((devpriv->ai_cmd2 & AI_End_On_End_Of_Scan)) + /* handle special case of single scan */ + if (devpriv->ai_cmd2 & NISTC_AI_CMD2_END_ON_EOS) shutdown_ai_command(dev); } @@ -2253,8 +2253,8 @@ static int ni_ai_inttrig(struct comedi_device *dev, if (trig_num != cmd->start_arg) return -EINVAL; - ni_stc_writew(dev, AI_START1_Pulse | devpriv->ai_cmd2, - AI_Command_2_Register); + ni_stc_writew(dev, NISTC_AI_CMD2_START1_PULSE | devpriv->ai_cmd2, + NISTC_AI_CMD2_REG); s->async->inttrig = NULL; return 1; @@ -2344,7 +2344,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ni_stc_writew(dev, AI_SC_Load, AI_Command_1_Register); if (stop_count == 0) { - devpriv->ai_cmd2 |= AI_End_On_End_Of_Scan; + devpriv->ai_cmd2 |= NISTC_AI_CMD2_END_ON_EOS; interrupt_a_enable |= AI_STOP_Interrupt_Enable; /* this is required to get the last sample for chanlist_len > 1, not sure why */ if (cmd->chanlist_len > 1) @@ -2460,8 +2460,8 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) interrupt_a_enable |= AI_FIFO_Interrupt_Enable; #endif - if (cmd->flags & CMDF_WAKE_EOS - || (devpriv->ai_cmd2 & AI_End_On_End_Of_Scan)) { + if ((cmd->flags & CMDF_WAKE_EOS) || + (devpriv->ai_cmd2 & NISTC_AI_CMD2_END_ON_EOS)) { /* wake on end-of-scan */ devpriv->aimode = AIMODE_SCAN; } else { @@ -2537,9 +2537,9 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) #endif if (cmd->start_src == TRIG_NOW) { - /* AI_START1_Pulse */ - ni_stc_writew(dev, AI_START1_Pulse | devpriv->ai_cmd2, - AI_Command_2_Register); + ni_stc_writew(dev, NISTC_AI_CMD2_START1_PULSE | + devpriv->ai_cmd2, + NISTC_AI_CMD2_REG); s->async->inttrig = NULL; } else if (cmd->start_src == TRIG_EXT) { s->async->inttrig = NULL; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 07df8a5e40ea..79a5dc066745 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -95,6 +95,20 @@ NISTC_INTB_ACK_AO_BC_TC_ERR | \ NISTC_INTB_ACK_AO_BC_TC_TRIG_ERR) +#define NISTC_AI_CMD2_REG 4 +#define NISTC_AI_CMD2_END_ON_SC_TC BIT(15) +#define NISTC_AI_CMD2_END_ON_EOS BIT(14) +#define NISTC_AI_CMD2_START1_DISABLE BIT(11) +#define NISTC_AI_CMD2_SC_SAVE_TRACE BIT(10) +#define NISTC_AI_CMD2_SI_SW_ON_SC_TC BIT(9) +#define NISTC_AI_CMD2_SI_SW_ON_STOP BIT(8) +#define NISTC_AI_CMD2_SI_SW_ON_TC BIT(7) +#define NISTC_AI_CMD2_SC_SW_ON_TC BIT(4) +#define NISTC_AI_CMD2_STOP_PULSE BIT(3) +#define NISTC_AI_CMD2_START_PULSE BIT(2) +#define NISTC_AI_CMD2_START2_PULSE BIT(1) +#define NISTC_AI_CMD2_START1_PULSE BIT(0) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -133,20 +147,6 @@ #define AO_FIFO_Request_St _bit1 #define Pass_Thru_1_Interrupt_St _bit0 -#define AI_Command_2_Register 4 -#define AI_End_On_SC_TC _bit15 -#define AI_End_On_End_Of_Scan _bit14 -#define AI_START1_Disable _bit11 -#define AI_SC_Save_Trace _bit10 -#define AI_SI_Switch_Load_On_SC_TC _bit9 -#define AI_SI_Switch_Load_On_STOP _bit8 -#define AI_SI_Switch_Load_On_TC _bit7 -#define AI_SC_Switch_Load_On_TC _bit4 -#define AI_STOP_Pulse _bit3 -#define AI_START_Pulse _bit2 -#define AI_START2_Pulse _bit1 -#define AI_START1_Pulse _bit0 - #define AO_Command_2_Register 5 #define AO_End_On_BC_TC(x) (((x) & 0x3) << 14) #define AO_Start_Stop_Gate_Enable _bit13 From 382b3c4f9a9ed7ce8b019b41cd3ba505426665c8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:57 -0700 Subject: [PATCH 0333/1163] staging: comedi: ni_stc.h: tidy up AO_Command_2_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 14 ++++---- drivers/staging/comedi/drivers/ni_stc.h | 34 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 6c545a9de903..45d16d7bd58f 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -317,7 +317,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_INTA_ACK_REG] = { 0x104, 2 }, [NISTC_INTB_ACK_REG] = { 0x106, 2 }, [NISTC_AI_CMD2_REG] = { 0x108, 2 }, - [AO_Command_2_Register] = { 0x10a, 2 }, + [NISTC_AO_CMD2_REG] = { 0x10a, 2 }, [G_Command_Register(0)] = { 0x10c, 2 }, [G_Command_Register(1)] = { 0x10e, 2 }, [AI_Command_1_Register] = { 0x110, 2 }, @@ -2909,8 +2909,8 @@ static int ni_ao_inttrig(struct comedi_device *dev, AO_DAC1_Update_Mode | AO_DAC0_Update_Mode, AO_Command_1_Register); - ni_stc_writew(dev, devpriv->ao_cmd2 | AO_START1_Pulse, - AO_Command_2_Register); + ni_stc_writew(dev, NISTC_AO_CMD2_START1_PULSE | devpriv->ao_cmd2, + NISTC_AO_CMD2_REG); return 0; } @@ -3024,7 +3024,7 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) AO_UPDATE_Source_Select(0x1f) | AO_UPDATE_Source_Polarity); switch (cmd->scan_begin_src) { case TRIG_TIMER: - devpriv->ao_cmd2 &= ~AO_BC_Gate_Enable; + devpriv->ao_cmd2 &= ~NISTC_AO_CMD2_BC_GATE_ENA; trigvar = ni_ns_to_timer(dev, cmd->scan_begin_arg, CMDF_ROUND_NEAREST); @@ -3037,13 +3037,13 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) AO_UPDATE_Source_Select(cmd->scan_begin_arg); if (cmd->scan_begin_arg & CR_INVERT) devpriv->ao_mode1 |= AO_UPDATE_Source_Polarity; - devpriv->ao_cmd2 |= AO_BC_Gate_Enable; + devpriv->ao_cmd2 |= NISTC_AO_CMD2_BC_GATE_ENA; break; default: BUG(); break; } - ni_stc_writew(dev, devpriv->ao_cmd2, AO_Command_2_Register); + ni_stc_writew(dev, devpriv->ao_cmd2, NISTC_AO_CMD2_REG); ni_stc_writew(dev, devpriv->ao_mode1, AO_Mode_1_Register); devpriv->ao_mode2 &= ~(AO_UI_Reload_Mode(3) | AO_UI_Initial_Load_Source); @@ -3216,7 +3216,7 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ao_cmd1 = 0; ni_stc_writew(dev, devpriv->ao_cmd1, AO_Command_1_Register); devpriv->ao_cmd2 = 0; - ni_stc_writew(dev, devpriv->ao_cmd2, AO_Command_2_Register); + ni_stc_writew(dev, devpriv->ao_cmd2, NISTC_AO_CMD2_REG); devpriv->ao_mode1 = 0; ni_stc_writew(dev, devpriv->ao_mode1, AO_Mode_1_Register); devpriv->ao_mode2 = 0; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 79a5dc066745..2a54864ffa21 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -109,6 +109,23 @@ #define NISTC_AI_CMD2_START2_PULSE BIT(1) #define NISTC_AI_CMD2_START1_PULSE BIT(0) +#define NISTC_AO_CMD2_REG 5 +#define NISTC_AO_CMD2_END_ON_BC_TC(x) (((x) & 0x3) << 14) +#define NISTC_AO_CMD2_START_STOP_GATE_ENA BIT(13) +#define NISTC_AO_CMD2_UC_SAVE_TRACE BIT(12) +#define NISTC_AO_CMD2_BC_GATE_ENA BIT(11) +#define NISTC_AO_CMD2_BC_SAVE_TRACE BIT(10) +#define NISTC_AO_CMD2_UI_SW_ON_BC_TC BIT(9) +#define NISTC_AO_CMD2_UI_SW_ON_STOP BIT(8) +#define NISTC_AO_CMD2_UI_SW_ON_TC BIT(7) +#define NISTC_AO_CMD2_UC_SW_ON_BC_TC BIT(6) +#define NISTC_AO_CMD2_UC_SW_ON_TC BIT(5) +#define NISTC_AO_CMD2_BC_SW_ON_TC BIT(4) +#define NISTC_AO_CMD2_MUTE_B BIT(3) +#define NISTC_AO_CMD2_MUTE_A BIT(2) +#define NISTC_AO_CMD2_UPDATE2_PULSE BIT(1) +#define NISTC_AO_CMD2_START1_PULSE BIT(0) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -147,23 +164,6 @@ #define AO_FIFO_Request_St _bit1 #define Pass_Thru_1_Interrupt_St _bit0 -#define AO_Command_2_Register 5 -#define AO_End_On_BC_TC(x) (((x) & 0x3) << 14) -#define AO_Start_Stop_Gate_Enable _bit13 -#define AO_UC_Save_Trace _bit12 -#define AO_BC_Gate_Enable _bit11 -#define AO_BC_Save_Trace _bit10 -#define AO_UI_Switch_Load_On_BC_TC _bit9 -#define AO_UI_Switch_Load_On_Stop _bit8 -#define AO_UI_Switch_Load_On_TC _bit7 -#define AO_UC_Switch_Load_On_BC_TC _bit6 -#define AO_UC_Switch_Load_On_TC _bit5 -#define AO_BC_Switch_Load_On_TC _bit4 -#define AO_Mute_B _bit3 -#define AO_Mute_A _bit2 -#define AO_UPDATE2_Pulse _bit1 -#define AO_START1_Pulse _bit0 - #define AO_Status_2_Register 6 #define DIO_Parallel_Input_Register 7 From 5fa2fa44af1930f1d3f84f8cfbca95a0a80547e7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:58 -0700 Subject: [PATCH 0334/1163] staging: comedi: ni_stc.h: tidy up G_Command_Register Rename the CamelCase and define the G0 and G1 registers to add clarity to the mio_regmap tables. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 8 ++++---- drivers/staging/comedi/drivers/ni_stc.h | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 45d16d7bd58f..0ac17c88b54a 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -318,8 +318,8 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_INTB_ACK_REG] = { 0x106, 2 }, [NISTC_AI_CMD2_REG] = { 0x108, 2 }, [NISTC_AO_CMD2_REG] = { 0x10a, 2 }, - [G_Command_Register(0)] = { 0x10c, 2 }, - [G_Command_Register(1)] = { 0x10e, 2 }, + [NISTC_G0_CMD_REG] = { 0x10c, 2 }, + [NISTC_G1_CMD_REG] = { 0x10e, 2 }, [AI_Command_1_Register] = { 0x110, 2 }, [AO_Command_1_Register] = { 0x112, 2 }, /* @@ -3720,8 +3720,8 @@ static void init_ao_67xx(struct comedi_device *dev, struct comedi_subdevice *s) static const struct mio_regmap ni_gpct_to_stc_regmap[] = { [NITIO_G0_AUTO_INC] = { G_Autoincrement_Register(0), 2 }, [NITIO_G1_AUTO_INC] = { G_Autoincrement_Register(1), 2 }, - [NITIO_G0_CMD] = { G_Command_Register(0), 2 }, - [NITIO_G1_CMD] = { G_Command_Register(1), 2 }, + [NITIO_G0_CMD] = { NISTC_G0_CMD_REG, 2 }, + [NITIO_G1_CMD] = { NISTC_G1_CMD_REG, 2 }, [NITIO_G0_HW_SAVE] = { G_HW_Save_Register(0), 4 }, [NITIO_G1_HW_SAVE] = { G_HW_Save_Register(1), 4 }, [NITIO_G0_SW_SAVE] = { G_Save_Register(0), 4 }, diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 2a54864ffa21..7f88dd40affe 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -126,6 +126,9 @@ #define NISTC_AO_CMD2_UPDATE2_PULSE BIT(1) #define NISTC_AO_CMD2_START1_PULSE BIT(0) +#define NISTC_G0_CMD_REG 6 +#define NISTC_G1_CMD_REG 7 + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -599,7 +602,6 @@ static unsigned AO_UPDATE_Output_Select(enum ao_update_output_selection #define AI_External_Gate_Select(a) ((a) & 0x1f) #define G_Autoincrement_Register(a) (68+(a)) -#define G_Command_Register(a) (6+(a)) #define G_HW_Save_Register(a) (8+(a)*2) #define G_HW_Save_Register_High(a) (8+(a)*2) #define G_HW_Save_Register_Low(a) (9+(a)*2) From 4c4d715a7d482a8547abf1b1ab6a0fc24846c935 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:58:59 -0700 Subject: [PATCH 0335/1163] staging: comedi: ni_stc.h: tidy up AI_Command_1_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 60 ++++++++++--------- drivers/staging/comedi/drivers/ni_stc.h | 34 +++++------ 2 files changed, 48 insertions(+), 46 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 0ac17c88b54a..2e017dc62af6 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -320,7 +320,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_AO_CMD2_REG] = { 0x10a, 2 }, [NISTC_G0_CMD_REG] = { 0x10c, 2 }, [NISTC_G1_CMD_REG] = { 0x10e, 2 }, - [AI_Command_1_Register] = { 0x110, 2 }, + [NISTC_AI_CMD1_REG] = { 0x110, 2 }, [AO_Command_1_Register] = { 0x112, 2 }, /* * DIO_Output_Register maps to: @@ -860,12 +860,12 @@ static void ni_clear_ai_fifo(struct comedi_device *dev) #if 0 /* the NI example code does 3 convert pulses for 625x boards, but that appears to be wrong in practice. */ - ni_stc_writew(dev, AI_CONVERT_Pulse, - AI_Command_1_Register); - ni_stc_writew(dev, AI_CONVERT_Pulse, - AI_Command_1_Register); - ni_stc_writew(dev, AI_CONVERT_Pulse, - AI_Command_1_Register); + ni_stc_writew(dev, NISTC_AI_CMD1_CONVERT_PULSE, + NISTC_AI_CMD1_REG); + ni_stc_writew(dev, NISTC_AI_CMD1_CONVERT_PULSE, + NISTC_AI_CMD1_REG); + ni_stc_writew(dev, NISTC_AI_CMD1_CONVERT_PULSE, + NISTC_AI_CMD1_REG); #endif } } @@ -1629,7 +1629,7 @@ static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s) if (!devpriv->is_6143) ni_writeb(dev, 0, Misc_Command); - ni_stc_writew(dev, AI_Disarm, AI_Command_1_Register); /* reset pulses */ + ni_stc_writew(dev, NISTC_AI_CMD1_DISARM, NISTC_AI_CMD1_REG); ni_stc_writew(dev, AI_Start_Stop | AI_Mode_1_Reserved /*| AI_Trigger_Once */, AI_Mode_1_Register); @@ -1727,7 +1727,7 @@ static void ni_prime_channelgain_list(struct comedi_device *dev) { int i; - ni_stc_writew(dev, AI_CONVERT_Pulse, AI_Command_1_Register); + ni_stc_writew(dev, NISTC_AI_CMD1_CONVERT_PULSE, NISTC_AI_CMD1_REG); for (i = 0; i < NI_TIMEOUT; ++i) { if (!(ni_stc_readw(dev, AI_Status_1_Register) & AI_FIFO_Empty_St)) { @@ -1971,13 +1971,13 @@ static int ni_ai_insn_read(struct comedi_device *dev, signbits = devpriv->ai_offset[0]; if (devpriv->is_611x) { for (n = 0; n < num_adc_stages_611x; n++) { - ni_stc_writew(dev, AI_CONVERT_Pulse, - AI_Command_1_Register); + ni_stc_writew(dev, NISTC_AI_CMD1_CONVERT_PULSE, + NISTC_AI_CMD1_REG); udelay(1); } for (n = 0; n < insn->n; n++) { - ni_stc_writew(dev, AI_CONVERT_Pulse, - AI_Command_1_Register); + ni_stc_writew(dev, NISTC_AI_CMD1_CONVERT_PULSE, + NISTC_AI_CMD1_REG); /* The 611x has screwy 32-bit FIFOs. */ d = 0; for (i = 0; i < NI_TIMEOUT; i++) { @@ -2003,8 +2003,8 @@ static int ni_ai_insn_read(struct comedi_device *dev, } } else if (devpriv->is_6143) { for (n = 0; n < insn->n; n++) { - ni_stc_writew(dev, AI_CONVERT_Pulse, - AI_Command_1_Register); + ni_stc_writew(dev, NISTC_AI_CMD1_CONVERT_PULSE, + NISTC_AI_CMD1_REG); /* The 6143 has 32-bit FIFOs. You need to strobe a bit to move a single 16bit stranded sample into the FIFO */ dl = 0; @@ -2025,8 +2025,8 @@ static int ni_ai_insn_read(struct comedi_device *dev, } } else { for (n = 0; n < insn->n; n++) { - ni_stc_writew(dev, AI_CONVERT_Pulse, - AI_Command_1_Register); + ni_stc_writew(dev, NISTC_AI_CMD1_CONVERT_PULSE, + NISTC_AI_CMD1_REG); for (i = 0; i < NI_TIMEOUT; i++) { if (!(ni_stc_readw(dev, AI_Status_1_Register) & AI_FIFO_Empty_St)) @@ -2341,7 +2341,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) mode1 |= AI_Start_Stop | AI_Mode_1_Reserved | AI_Trigger_Once; ni_stc_writew(dev, mode1, AI_Mode_1_Register); /* load SC (Scan Count) */ - ni_stc_writew(dev, AI_SC_Load, AI_Command_1_Register); + ni_stc_writew(dev, NISTC_AI_CMD1_SC_LOAD, NISTC_AI_CMD1_REG); if (stop_count == 0) { devpriv->ai_cmd2 |= NISTC_AI_CMD2_END_ON_EOS; @@ -2360,7 +2360,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ni_stc_writew(dev, mode1, AI_Mode_1_Register); /* load SC (Scan Count) */ - ni_stc_writew(dev, AI_SC_Load, AI_Command_1_Register); + ni_stc_writew(dev, NISTC_AI_CMD1_SC_LOAD, NISTC_AI_CMD1_REG); break; } @@ -2394,7 +2394,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) timer = ni_ns_to_timer(dev, cmd->scan_begin_arg, CMDF_ROUND_NEAREST); ni_stc_writel(dev, timer, AI_SI_Load_A_Registers); - ni_stc_writew(dev, AI_SI_Load, AI_Command_1_Register); + ni_stc_writew(dev, NISTC_AI_CMD1_SI_LOAD, NISTC_AI_CMD1_REG); break; case TRIG_EXT: if (cmd->scan_begin_arg & CR_EDGE) @@ -2431,8 +2431,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) mode2 |= AI_SI2_Reload_Mode; ni_stc_writew(dev, mode2, AI_Mode_2_Register); - /* AI_SI2_Load */ - ni_stc_writew(dev, AI_SI2_Load, AI_Command_1_Register); + ni_stc_writew(dev, NISTC_AI_CMD1_SI2_LOAD, NISTC_AI_CMD1_REG); mode2 |= AI_SI2_Reload_Mode; /* alternate */ mode2 |= AI_SI2_Initial_Load_Source; /* B */ @@ -2515,15 +2514,18 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) switch (cmd->scan_begin_src) { case TRIG_TIMER: - ni_stc_writew(dev, - AI_SI2_Arm | AI_SI_Arm | AI_DIV_Arm | AI_SC_Arm, - AI_Command_1_Register); + ni_stc_writew(dev, NISTC_AI_CMD1_SI2_ARM | + NISTC_AI_CMD1_SI_ARM | + NISTC_AI_CMD1_DIV_ARM | + NISTC_AI_CMD1_SC_ARM, + NISTC_AI_CMD1_REG); break; case TRIG_EXT: - /* XXX AI_SI_Arm? */ - ni_stc_writew(dev, - AI_SI2_Arm | AI_SI_Arm | AI_DIV_Arm | AI_SC_Arm, - AI_Command_1_Register); + ni_stc_writew(dev, NISTC_AI_CMD1_SI2_ARM | + NISTC_AI_CMD1_SI_ARM | /* XXX ? */ + NISTC_AI_CMD1_DIV_ARM | + NISTC_AI_CMD1_SC_ARM, + NISTC_AI_CMD1_REG); break; } diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 7f88dd40affe..ecd80bc59061 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -129,6 +129,23 @@ #define NISTC_G0_CMD_REG 6 #define NISTC_G1_CMD_REG 7 +#define NISTC_AI_CMD1_REG 8 +#define NISTC_AI_CMD1_ATRIG_RESET BIT(14) +#define NISTC_AI_CMD1_DISARM BIT(13) +#define NISTC_AI_CMD1_SI2_ARM BIT(12) +#define NISTC_AI_CMD1_SI2_LOAD BIT(11) +#define NISTC_AI_CMD1_SI_ARM BIT(10) +#define NISTC_AI_CMD1_SI_LOAD BIT(9) +#define NISTC_AI_CMD1_DIV_ARM BIT(8) +#define NISTC_AI_CMD1_DIV_LOAD BIT(7) +#define NISTC_AI_CMD1_SC_ARM BIT(6) +#define NISTC_AI_CMD1_SC_LOAD BIT(5) +#define NISTC_AI_CMD1_SCAN_IN_PROG_PULSE BIT(4) +#define NISTC_AI_CMD1_EXTMUX_CLK_PULSE BIT(3) +#define NISTC_AI_CMD1_LOCALMUX_CLK_PULSE BIT(2) +#define NISTC_AI_CMD1_SC_TC_PULSE BIT(1) +#define NISTC_AI_CMD1_CONVERT_PULSE BIT(0) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -171,23 +188,6 @@ #define DIO_Parallel_Input_Register 7 -#define AI_Command_1_Register 8 -#define AI_Analog_Trigger_Reset _bit14 -#define AI_Disarm _bit13 -#define AI_SI2_Arm _bit12 -#define AI_SI2_Load _bit11 -#define AI_SI_Arm _bit10 -#define AI_SI_Load _bit9 -#define AI_DIV_Arm _bit8 -#define AI_DIV_Load _bit7 -#define AI_SC_Arm _bit6 -#define AI_SC_Load _bit5 -#define AI_SCAN_IN_PROG_Pulse _bit4 -#define AI_EXTMUX_CLK_Pulse _bit3 -#define AI_LOCALMUX_CLK_Pulse _bit2 -#define AI_SC_TC_Pulse _bit1 -#define AI_CONVERT_Pulse _bit0 - #define AO_Command_1_Register 9 #define AO_Analog_Trigger_Reset _bit15 #define AO_START_Pulse _bit14 From 7bfcc2d4cd676ec5b29799a1865c25f48489c869 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:00 -0700 Subject: [PATCH 0336/1163] staging: comedi: ni_stc.h: tidy up AO_Command_1_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 38 +++++++++++-------- drivers/staging/comedi/drivers/ni_stc.h | 36 +++++++++--------- 2 files changed, 40 insertions(+), 34 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 2e017dc62af6..88fd44aa4c70 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -321,7 +321,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_G0_CMD_REG] = { 0x10c, 2 }, [NISTC_G1_CMD_REG] = { 0x10e, 2 }, [NISTC_AI_CMD1_REG] = { 0x110, 2 }, - [AO_Command_1_Register] = { 0x112, 2 }, + [NISTC_AO_CMD1_REG] = { 0x112, 2 }, /* * DIO_Output_Register maps to: * { NI_M_DIO_REG, 4 } and { NI_M_SCXI_SER_DO_REG, 1 } @@ -2906,10 +2906,13 @@ static int ni_ao_inttrig(struct comedi_device *dev, ni_set_bits(dev, Interrupt_B_Enable_Register, interrupt_b_bits, 1); - ni_stc_writew(dev, devpriv->ao_cmd1 | - AO_UI_Arm | AO_UC_Arm | AO_BC_Arm | - AO_DAC1_Update_Mode | AO_DAC0_Update_Mode, - AO_Command_1_Register); + ni_stc_writew(dev, NISTC_AO_CMD1_UI_ARM | + NISTC_AO_CMD1_UC_ARM | + NISTC_AO_CMD1_BC_ARM | + NISTC_AO_CMD1_DAC1_UPDATE_MODE | + NISTC_AO_CMD1_DAC0_UPDATE_MODE | + devpriv->ao_cmd1, + NISTC_AO_CMD1_REG); ni_stc_writew(dev, NISTC_AO_CMD2_START1_PULSE | devpriv->ao_cmd2, NISTC_AO_CMD2_REG); @@ -2933,7 +2936,7 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ni_stc_writew(dev, AO_Configuration_Start, Joint_Reset_Register); - ni_stc_writew(dev, AO_Disarm, AO_Command_1_Register); + ni_stc_writew(dev, NISTC_AO_CMD1_DISARM, NISTC_AO_CMD1_REG); if (devpriv->is_6xxx) { ni_ao_win_outw(dev, CLEAR_WG, AO_Misc_611x); @@ -2992,7 +2995,7 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ni_stc_writel(dev, 0xffffff, AO_BC_Load_A_Register); else ni_stc_writel(dev, 0, AO_BC_Load_A_Register); - ni_stc_writew(dev, AO_BC_Load, AO_Command_1_Register); + ni_stc_writew(dev, NISTC_AO_CMD1_BC_LOAD, NISTC_AO_CMD1_REG); devpriv->ao_mode2 &= ~AO_UC_Initial_Load_Source; ni_stc_writew(dev, devpriv->ao_mode2, AO_Mode_2_Register); switch (cmd->stop_src) { @@ -3001,23 +3004,25 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* this is how the NI example code does it for m-series boards, verified correct with 6259 */ ni_stc_writel(dev, cmd->stop_arg - 1, AO_UC_Load_A_Register); - ni_stc_writew(dev, AO_UC_Load, AO_Command_1_Register); + ni_stc_writew(dev, NISTC_AO_CMD1_UC_LOAD, + NISTC_AO_CMD1_REG); } else { ni_stc_writel(dev, cmd->stop_arg, AO_UC_Load_A_Register); - ni_stc_writew(dev, AO_UC_Load, AO_Command_1_Register); + ni_stc_writew(dev, NISTC_AO_CMD1_UC_LOAD, + NISTC_AO_CMD1_REG); ni_stc_writel(dev, cmd->stop_arg - 1, AO_UC_Load_A_Register); } break; case TRIG_NONE: ni_stc_writel(dev, 0xffffff, AO_UC_Load_A_Register); - ni_stc_writew(dev, AO_UC_Load, AO_Command_1_Register); + ni_stc_writew(dev, NISTC_AO_CMD1_UC_LOAD, NISTC_AO_CMD1_REG); ni_stc_writel(dev, 0xffffff, AO_UC_Load_A_Register); break; default: ni_stc_writel(dev, 0, AO_UC_Load_A_Register); - ni_stc_writew(dev, AO_UC_Load, AO_Command_1_Register); + ni_stc_writew(dev, NISTC_AO_CMD1_UC_LOAD, NISTC_AO_CMD1_REG); ni_stc_writel(dev, cmd->stop_arg, AO_UC_Load_A_Register); } @@ -3031,7 +3036,7 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ni_ns_to_timer(dev, cmd->scan_begin_arg, CMDF_ROUND_NEAREST); ni_stc_writel(dev, 1, AO_UI_Load_A_Register); - ni_stc_writew(dev, AO_UI_Load, AO_Command_1_Register); + ni_stc_writew(dev, NISTC_AO_CMD1_UI_LOAD, NISTC_AO_CMD1_REG); ni_stc_writel(dev, trigvar, AO_UI_Load_A_Register); break; case TRIG_EXT: @@ -3072,8 +3077,9 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } ni_stc_writew(dev, devpriv->ao_mode1, AO_Mode_1_Register); - ni_stc_writew(dev, AO_DAC0_Update_Mode | AO_DAC1_Update_Mode, - AO_Command_1_Register); + ni_stc_writew(dev, NISTC_AO_CMD1_DAC1_UPDATE_MODE | + NISTC_AO_CMD1_DAC0_UPDATE_MODE, + NISTC_AO_CMD1_REG); devpriv->ao_mode3 |= AO_Stop_On_Overrun_Error; ni_stc_writew(dev, devpriv->ao_mode3, AO_Mode_3_Register); @@ -3207,7 +3213,7 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s) ni_release_ao_mite_channel(dev); ni_stc_writew(dev, AO_Configuration_Start, Joint_Reset_Register); - ni_stc_writew(dev, AO_Disarm, AO_Command_1_Register); + ni_stc_writew(dev, NISTC_AO_CMD1_DISARM, NISTC_AO_CMD1_REG); ni_set_bits(dev, Interrupt_B_Enable_Register, ~0, 0); ni_stc_writew(dev, AO_BC_Source_Select, AO_Personal_Register); ni_stc_writew(dev, NISTC_INTB_ACK_AO_ALL, NISTC_INTB_ACK_REG); @@ -3216,7 +3222,7 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s) ni_stc_writew(dev, 0, AO_Output_Control_Register); ni_stc_writew(dev, 0, AO_Start_Select_Register); devpriv->ao_cmd1 = 0; - ni_stc_writew(dev, devpriv->ao_cmd1, AO_Command_1_Register); + ni_stc_writew(dev, devpriv->ao_cmd1, NISTC_AO_CMD1_REG); devpriv->ao_cmd2 = 0; ni_stc_writew(dev, devpriv->ao_cmd2, NISTC_AO_CMD2_REG); devpriv->ao_mode1 = 0; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index ecd80bc59061..fcc36d93b2fa 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -146,6 +146,24 @@ #define NISTC_AI_CMD1_SC_TC_PULSE BIT(1) #define NISTC_AI_CMD1_CONVERT_PULSE BIT(0) +#define NISTC_AO_CMD1_REG 9 +#define NISTC_AO_CMD1_ATRIG_RESET BIT(15) +#define NISTC_AO_CMD1_START_PULSE BIT(14) +#define NISTC_AO_CMD1_DISARM BIT(13) +#define NISTC_AO_CMD1_UI2_ARM_DISARM BIT(12) +#define NISTC_AO_CMD1_UI2_LOAD BIT(11) +#define NISTC_AO_CMD1_UI_ARM BIT(10) +#define NISTC_AO_CMD1_UI_LOAD BIT(9) +#define NISTC_AO_CMD1_UC_ARM BIT(8) +#define NISTC_AO_CMD1_UC_LOAD BIT(7) +#define NISTC_AO_CMD1_BC_ARM BIT(6) +#define NISTC_AO_CMD1_BC_LOAD BIT(5) +#define NISTC_AO_CMD1_DAC1_UPDATE_MODE BIT(4) +#define NISTC_AO_CMD1_LDAC1_SRC_SEL BIT(3) +#define NISTC_AO_CMD1_DAC0_UPDATE_MODE BIT(2) +#define NISTC_AO_CMD1_LDAC0_SRC_SEL BIT(1) +#define NISTC_AO_CMD1_UPDATE_PULSE BIT(0) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -188,24 +206,6 @@ #define DIO_Parallel_Input_Register 7 -#define AO_Command_1_Register 9 -#define AO_Analog_Trigger_Reset _bit15 -#define AO_START_Pulse _bit14 -#define AO_Disarm _bit13 -#define AO_UI2_Arm_Disarm _bit12 -#define AO_UI2_Load _bit11 -#define AO_UI_Arm _bit10 -#define AO_UI_Load _bit9 -#define AO_UC_Arm _bit8 -#define AO_UC_Load _bit7 -#define AO_BC_Arm _bit6 -#define AO_BC_Load _bit5 -#define AO_DAC1_Update_Mode _bit4 -#define AO_LDAC1_Source_Select _bit3 -#define AO_DAC0_Update_Mode _bit2 -#define AO_LDAC0_Source_Select _bit1 -#define AO_UPDATE_Pulse _bit0 - #define DIO_Output_Register 10 #define DIO_Parallel_Data_Out(a) ((a)&0xff) #define DIO_Parallel_Data_Mask 0xff From 05aafeea0c771895c49fb43c00f05a31ff9f2ba2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:01 -0700 Subject: [PATCH 0337/1163] staging: comedi: ni_stc.h: tidy up DIO_Output_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 28 ++++++++++--------- drivers/staging/comedi/drivers/ni_stc.h | 16 +++++------ 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 88fd44aa4c70..d8c4d60670b7 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -323,10 +323,10 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_AI_CMD1_REG] = { 0x110, 2 }, [NISTC_AO_CMD1_REG] = { 0x112, 2 }, /* - * DIO_Output_Register maps to: + * NISTC_DIO_OUT_REG maps to: * { NI_M_DIO_REG, 4 } and { NI_M_SCXI_SER_DO_REG, 1 } */ - [DIO_Output_Register] = { 0, 0 }, /* DOES NOT MAP CLEANLY */ + [NISTC_DIO_OUT_REG] = { 0, 0 }, /* DOES NOT MAP CLEANLY */ [DIO_Control_Register] = { 0, 0 }, /* DOES NOT MAP CLEANLY */ [AI_Mode_1_Register] = { 0x118, 2 }, [AI_Mode_2_Register] = { 0x11a, 2 }, @@ -3280,13 +3280,14 @@ static int ni_dio_insn_bits(struct comedi_device *dev, struct ni_private *devpriv = dev->private; /* Make sure we're not using the serial part of the dio */ - if ((data[0] & (DIO_SDIN | DIO_SDOUT)) && devpriv->serial_interval_ns) + if ((data[0] & (NISTC_DIO_SDIN | NISTC_DIO_SDOUT)) && + devpriv->serial_interval_ns) return -EBUSY; if (comedi_dio_update_state(s, data)) { - devpriv->dio_output &= ~DIO_Parallel_Data_Mask; - devpriv->dio_output |= DIO_Parallel_Data_Out(s->state); - ni_stc_writew(dev, devpriv->dio_output, DIO_Output_Register); + devpriv->dio_output &= ~NISTC_DIO_OUT_PARALLEL_MASK; + devpriv->dio_output |= NISTC_DIO_OUT_PARALLEL(s->state); + ni_stc_writew(dev, devpriv->dio_output, NISTC_DIO_OUT_REG); } data[1] = ni_stc_readw(dev, DIO_Parallel_Input_Register); @@ -3543,9 +3544,9 @@ static int ni_serial_hw_readwrite8(struct comedi_device *dev, unsigned int status1; int err = 0, count = 20; - devpriv->dio_output &= ~DIO_Serial_Data_Mask; - devpriv->dio_output |= DIO_Serial_Data_Out(data_out); - ni_stc_writew(dev, devpriv->dio_output, DIO_Output_Register); + devpriv->dio_output &= ~NISTC_DIO_OUT_SERIAL_MASK; + devpriv->dio_output |= NISTC_DIO_OUT_SERIAL(data_out); + ni_stc_writew(dev, devpriv->dio_output, NISTC_DIO_OUT_REG); status1 = ni_stc_readw(dev, Joint_Status_1_Register); if (status1 & DIO_Serial_IO_In_Progress_St) { @@ -3598,10 +3599,10 @@ static int ni_serial_sw_readwrite8(struct comedi_device *dev, /* Output current bit; note that we cannot touch s->state because it is a per-subdevice field, and serial is a separate subdevice from DIO. */ - devpriv->dio_output &= ~DIO_SDOUT; + devpriv->dio_output &= ~NISTC_DIO_SDOUT; if (data_out & mask) - devpriv->dio_output |= DIO_SDOUT; - ni_stc_writew(dev, devpriv->dio_output, DIO_Output_Register); + devpriv->dio_output |= NISTC_DIO_SDOUT; + ni_stc_writew(dev, devpriv->dio_output, NISTC_DIO_OUT_REG); /* Assert SDCLK (active low, inverted), wait for half of the delay, deassert SDCLK, and wait for the other half. */ @@ -3616,7 +3617,8 @@ static int ni_serial_sw_readwrite8(struct comedi_device *dev, udelay((devpriv->serial_interval_ns + 999) / 2000); /* Input current bit */ - if (ni_stc_readw(dev, DIO_Parallel_Input_Register) & DIO_SDIN) + if (ni_stc_readw(dev, DIO_Parallel_Input_Register) & + NISTC_DIO_SDIN) input |= mask; } diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index fcc36d93b2fa..33823ff3a683 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -164,6 +164,14 @@ #define NISTC_AO_CMD1_LDAC0_SRC_SEL BIT(1) #define NISTC_AO_CMD1_UPDATE_PULSE BIT(0) +#define NISTC_DIO_OUT_REG 10 +#define NISTC_DIO_OUT_SERIAL(x) (((x) & 0xff) << 8) +#define NISTC_DIO_OUT_SERIAL_MASK NISTC_DIO_OUT_SERIAL(0xff) +#define NISTC_DIO_OUT_PARALLEL(x) ((x) & 0xff) +#define NISTC_DIO_OUT_PARALLEL_MASK NISTC_DIO_OUT_PARALLEL(0xff) +#define NISTC_DIO_SDIN BIT(4) +#define NISTC_DIO_SDOUT BIT(0) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -206,14 +214,6 @@ #define DIO_Parallel_Input_Register 7 -#define DIO_Output_Register 10 -#define DIO_Parallel_Data_Out(a) ((a)&0xff) -#define DIO_Parallel_Data_Mask 0xff -#define DIO_SDOUT _bit0 -#define DIO_SDIN _bit4 -#define DIO_Serial_Data_Out(a) (((a)&0xff)<<8) -#define DIO_Serial_Data_Mask 0xff00 - #define DIO_Control_Register 11 #define DIO_Software_Serial_Control _bit11 #define DIO_HW_Serial_Timebase _bit10 From 59a97c3c867797c68bf14ce1620ac8a8f695eef0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:02 -0700 Subject: [PATCH 0338/1163] staging: comedi: ni_stc.h: tidy up DIO_Control_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 46 +++++++++---------- drivers/staging/comedi/drivers/ni_stc.h | 16 +++---- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index d8c4d60670b7..284ce94f9b2a 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -327,7 +327,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { * { NI_M_DIO_REG, 4 } and { NI_M_SCXI_SER_DO_REG, 1 } */ [NISTC_DIO_OUT_REG] = { 0, 0 }, /* DOES NOT MAP CLEANLY */ - [DIO_Control_Register] = { 0, 0 }, /* DOES NOT MAP CLEANLY */ + [NISTC_DIO_CTRL_REG] = { 0, 0 }, /* DOES NOT MAP CLEANLY */ [AI_Mode_1_Register] = { 0x118, 2 }, [AI_Mode_2_Register] = { 0x11a, 2 }, [AI_SI_Load_A_Registers] = { 0x11c, 4 }, @@ -3265,9 +3265,9 @@ static int ni_dio_insn_config(struct comedi_device *dev, if (ret) return ret; - devpriv->dio_control &= ~DIO_Pins_Dir_Mask; - devpriv->dio_control |= DIO_Pins_Dir(s->io_bits); - ni_stc_writew(dev, devpriv->dio_control, DIO_Control_Register); + devpriv->dio_control &= ~NISTC_DIO_CTRL_DIR_MASK; + devpriv->dio_control |= NISTC_DIO_CTRL_DIR(s->io_bits); + ni_stc_writew(dev, devpriv->dio_control, NISTC_DIO_CTRL_REG); return insn->n; } @@ -3554,9 +3554,9 @@ static int ni_serial_hw_readwrite8(struct comedi_device *dev, goto Error; } - devpriv->dio_control |= DIO_HW_Serial_Start; - ni_stc_writew(dev, devpriv->dio_control, DIO_Control_Register); - devpriv->dio_control &= ~DIO_HW_Serial_Start; + devpriv->dio_control |= NISTC_DIO_CTRL_HW_SER_START; + ni_stc_writew(dev, devpriv->dio_control, NISTC_DIO_CTRL_REG); + devpriv->dio_control &= ~NISTC_DIO_CTRL_HW_SER_START; /* Wait until STC says we're done, but don't loop infinitely. */ while ((status1 = ni_stc_readw(dev, Joint_Status_1_Register)) & @@ -3579,7 +3579,7 @@ static int ni_serial_hw_readwrite8(struct comedi_device *dev, *data_in = ni_stc_readw(dev, DIO_Serial_Input_Register); Error: - ni_stc_writew(dev, devpriv->dio_control, DIO_Control_Register); + ni_stc_writew(dev, devpriv->dio_control, NISTC_DIO_CTRL_REG); return err; } @@ -3606,13 +3606,13 @@ static int ni_serial_sw_readwrite8(struct comedi_device *dev, /* Assert SDCLK (active low, inverted), wait for half of the delay, deassert SDCLK, and wait for the other half. */ - devpriv->dio_control |= DIO_Software_Serial_Control; - ni_stc_writew(dev, devpriv->dio_control, DIO_Control_Register); + devpriv->dio_control |= NISTC_DIO_SDCLK; + ni_stc_writew(dev, devpriv->dio_control, NISTC_DIO_CTRL_REG); udelay((devpriv->serial_interval_ns + 999) / 2000); - devpriv->dio_control &= ~DIO_Software_Serial_Control; - ni_stc_writew(dev, devpriv->dio_control, DIO_Control_Register); + devpriv->dio_control &= ~NISTC_DIO_SDCLK; + ni_stc_writew(dev, devpriv->dio_control, NISTC_DIO_CTRL_REG); udelay((devpriv->serial_interval_ns + 999) / 2000); @@ -3643,30 +3643,30 @@ static int ni_serial_insn_config(struct comedi_device *dev, switch (data[0]) { case INSN_CONFIG_SERIAL_CLOCK: devpriv->serial_hw_mode = 1; - devpriv->dio_control |= DIO_HW_Serial_Enable; + devpriv->dio_control |= NISTC_DIO_CTRL_HW_SER_ENA; if (data[1] == SERIAL_DISABLED) { devpriv->serial_hw_mode = 0; - devpriv->dio_control &= ~(DIO_HW_Serial_Enable | - DIO_Software_Serial_Control); + devpriv->dio_control &= ~(NISTC_DIO_CTRL_HW_SER_ENA | + NISTC_DIO_SDCLK); data[1] = SERIAL_DISABLED; devpriv->serial_interval_ns = data[1]; } else if (data[1] <= SERIAL_600NS) { /* Warning: this clock speed is too fast to reliably control SCXI. */ - devpriv->dio_control &= ~DIO_HW_Serial_Timebase; + devpriv->dio_control &= ~NISTC_DIO_CTRL_HW_SER_TIMEBASE; devpriv->clock_and_fout |= Slow_Internal_Timebase; devpriv->clock_and_fout &= ~DIO_Serial_Out_Divide_By_2; data[1] = SERIAL_600NS; devpriv->serial_interval_ns = data[1]; } else if (data[1] <= SERIAL_1_2US) { - devpriv->dio_control &= ~DIO_HW_Serial_Timebase; + devpriv->dio_control &= ~NISTC_DIO_CTRL_HW_SER_TIMEBASE; devpriv->clock_and_fout |= Slow_Internal_Timebase | DIO_Serial_Out_Divide_By_2; data[1] = SERIAL_1_2US; devpriv->serial_interval_ns = data[1]; } else if (data[1] <= SERIAL_10US) { - devpriv->dio_control |= DIO_HW_Serial_Timebase; + devpriv->dio_control |= NISTC_DIO_CTRL_HW_SER_TIMEBASE; devpriv->clock_and_fout |= Slow_Internal_Timebase | DIO_Serial_Out_Divide_By_2; /* Note: DIO_Serial_Out_Divide_By_2 only affects @@ -3676,14 +3676,14 @@ static int ni_serial_insn_config(struct comedi_device *dev, data[1] = SERIAL_10US; devpriv->serial_interval_ns = data[1]; } else { - devpriv->dio_control &= ~(DIO_HW_Serial_Enable | - DIO_Software_Serial_Control); + devpriv->dio_control &= ~(NISTC_DIO_CTRL_HW_SER_ENA | + NISTC_DIO_SDCLK); devpriv->serial_hw_mode = 0; data[1] = (data[1] / 1000) * 1000; devpriv->serial_interval_ns = data[1]; } - ni_stc_writew(dev, devpriv->dio_control, DIO_Control_Register); + ni_stc_writew(dev, devpriv->dio_control, NISTC_DIO_CTRL_REG); ni_stc_writew(dev, devpriv->clock_and_fout, Clock_and_FOUT_Register); return 1; @@ -5230,8 +5230,8 @@ static int ni_E_init(struct comedi_device *dev, s->insn_config = ni_dio_insn_config; /* set all channels to inputs */ - devpriv->dio_control = DIO_Pins_Dir(s->io_bits); - ni_writew(dev, devpriv->dio_control, DIO_Control_Register); + devpriv->dio_control = NISTC_DIO_CTRL_DIR(s->io_bits); + ni_writew(dev, devpriv->dio_control, NISTC_DIO_CTRL_REG); } /* 8255 device */ diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 33823ff3a683..cf0b5e5dbba2 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -172,6 +172,14 @@ #define NISTC_DIO_SDIN BIT(4) #define NISTC_DIO_SDOUT BIT(0) +#define NISTC_DIO_CTRL_REG 11 +#define NISTC_DIO_SDCLK BIT(11) +#define NISTC_DIO_CTRL_HW_SER_TIMEBASE BIT(10) +#define NISTC_DIO_CTRL_HW_SER_ENA BIT(9) +#define NISTC_DIO_CTRL_HW_SER_START BIT(8) +#define NISTC_DIO_CTRL_DIR(x) ((x) & 0xff) +#define NISTC_DIO_CTRL_DIR_MASK NISTC_DIO_CTRL_DIR(0xff) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -214,14 +222,6 @@ #define DIO_Parallel_Input_Register 7 -#define DIO_Control_Register 11 -#define DIO_Software_Serial_Control _bit11 -#define DIO_HW_Serial_Timebase _bit10 -#define DIO_HW_Serial_Enable _bit9 -#define DIO_HW_Serial_Start _bit8 -#define DIO_Pins_Dir(a) ((a)&0xff) -#define DIO_Pins_Dir_Mask 0xff - #define AI_Mode_1_Register 12 #define AI_CONVERT_Source_Select(a) (((a) & 0x1f) << 11) #define AI_SI_Source_select(a) (((a) & 0x1f) << 6) From bd358f5e2920db00f9c5f6c4267a22b0e6c17960 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:03 -0700 Subject: [PATCH 0339/1163] staging: comedi: ni_stc.h: tidy up AI_Mode_1_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 29 +++++++++++-------- drivers/staging/comedi/drivers/ni_stc.h | 20 ++++++------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 284ce94f9b2a..01015d76af53 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -328,7 +328,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { */ [NISTC_DIO_OUT_REG] = { 0, 0 }, /* DOES NOT MAP CLEANLY */ [NISTC_DIO_CTRL_REG] = { 0, 0 }, /* DOES NOT MAP CLEANLY */ - [AI_Mode_1_Register] = { 0x118, 2 }, + [NISTC_AI_MODE1_REG] = { 0x118, 2 }, [AI_Mode_2_Register] = { 0x11a, 2 }, [AI_SI_Load_A_Registers] = { 0x11c, 4 }, [AI_SI_Load_B_Registers] = { 0x120, 4 }, @@ -1630,9 +1630,10 @@ static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s) ni_writeb(dev, 0, Misc_Command); ni_stc_writew(dev, NISTC_AI_CMD1_DISARM, NISTC_AI_CMD1_REG); - ni_stc_writew(dev, AI_Start_Stop | AI_Mode_1_Reserved - /*| AI_Trigger_Once */, - AI_Mode_1_Register); + ni_stc_writew(dev, NISTC_AI_MODE1_START_STOP | + NISTC_AI_MODE1_RSVD + /*| NISTC_AI_MODE1_TRIGGER_ONCE */, + NISTC_AI_MODE1_REG); ni_stc_writew(dev, 0x0000, AI_Mode_2_Register); /* generate FIFO interrupts on non-empty */ ni_stc_writew(dev, (0 << 6) | 0x0000, AI_Mode_3_Register); @@ -1691,7 +1692,7 @@ static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s) /* the following registers should not be changed, because there * are no backup registers in devpriv. If you want to change * any of these, add a backup register and other appropriate code: - * AI_Mode_1_Register + * NISTC_AI_MODE1_REG * AI_Mode_3_Register * AI_Personal_Register * AI_Output_Control_Register @@ -2338,8 +2339,10 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* stage number of scans */ ni_stc_writel(dev, stop_count, AI_SC_Load_A_Registers); - mode1 |= AI_Start_Stop | AI_Mode_1_Reserved | AI_Trigger_Once; - ni_stc_writew(dev, mode1, AI_Mode_1_Register); + mode1 |= NISTC_AI_MODE1_START_STOP | + NISTC_AI_MODE1_RSVD | + NISTC_AI_MODE1_TRIGGER_ONCE; + ni_stc_writew(dev, mode1, NISTC_AI_MODE1_REG); /* load SC (Scan Count) */ ni_stc_writew(dev, NISTC_AI_CMD1_SC_LOAD, NISTC_AI_CMD1_REG); @@ -2356,8 +2359,10 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* stage number of scans */ ni_stc_writel(dev, 0, AI_SC_Load_A_Registers); - mode1 |= AI_Start_Stop | AI_Mode_1_Reserved | AI_Continuous; - ni_stc_writew(dev, mode1, AI_Mode_1_Register); + mode1 |= NISTC_AI_MODE1_START_STOP | + NISTC_AI_MODE1_RSVD | + NISTC_AI_MODE1_CONTINUOUS; + ni_stc_writew(dev, mode1, NISTC_AI_MODE1_REG); /* load SC (Scan Count) */ ni_stc_writew(dev, NISTC_AI_CMD1_SC_LOAD, NISTC_AI_CMD1_REG); @@ -2439,10 +2444,10 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ni_stc_writew(dev, mode2, AI_Mode_2_Register); break; case TRIG_EXT: - mode1 |= AI_CONVERT_Source_Select(1 + cmd->convert_arg); + mode1 |= NISTC_AI_MODE1_CONVERT_SRC(1 + cmd->convert_arg); if ((cmd->convert_arg & CR_INVERT) == 0) - mode1 |= AI_CONVERT_Source_Polarity; - ni_stc_writew(dev, mode1, AI_Mode_1_Register); + mode1 |= NISTC_AI_MODE1_CONVERT_POLARITY; + ni_stc_writew(dev, mode1, NISTC_AI_MODE1_REG); mode2 |= AI_Start_Stop_Gate_Enable | AI_SC_Gate_Enable; ni_stc_writew(dev, mode2, AI_Mode_2_Register); diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index cf0b5e5dbba2..315579e60216 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -180,6 +180,16 @@ #define NISTC_DIO_CTRL_DIR(x) ((x) & 0xff) #define NISTC_DIO_CTRL_DIR_MASK NISTC_DIO_CTRL_DIR(0xff) +#define NISTC_AI_MODE1_REG 12 +#define NISTC_AI_MODE1_CONVERT_SRC(x) (((x) & 0x1f) << 11) +#define NISTC_AI_MODE1_SI_SRC(x) (((x) & 0x1f) << 6) +#define NISTC_AI_MODE1_CONVERT_POLARITY BIT(5) +#define NISTC_AI_MODE1_SI_POLARITY BIT(4) +#define NISTC_AI_MODE1_START_STOP BIT(3) +#define NISTC_AI_MODE1_RSVD BIT(2) +#define NISTC_AI_MODE1_CONTINUOUS BIT(1) +#define NISTC_AI_MODE1_TRIGGER_ONCE BIT(0) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -222,16 +232,6 @@ #define DIO_Parallel_Input_Register 7 -#define AI_Mode_1_Register 12 -#define AI_CONVERT_Source_Select(a) (((a) & 0x1f) << 11) -#define AI_SI_Source_select(a) (((a) & 0x1f) << 6) -#define AI_CONVERT_Source_Polarity _bit5 -#define AI_SI_Source_Polarity _bit4 -#define AI_Start_Stop _bit3 -#define AI_Mode_1_Reserved _bit2 -#define AI_Continuous _bit1 -#define AI_Trigger_Once _bit0 - #define AI_Mode_2_Register 13 #define AI_SC_Gate_Enable _bit15 #define AI_Start_Stop_Gate_Enable _bit14 From b134cc58b81069ea6e1322a883e4bd66726a9f2d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:04 -0700 Subject: [PATCH 0340/1163] staging: comedi: ni_stc.h: tidy up AI_Mode_2_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 43 +++++++++---------- drivers/staging/comedi/drivers/ni_stc.h | 28 ++++++------ 2 files changed, 34 insertions(+), 37 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 01015d76af53..7cbe9d9e0bd8 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -329,7 +329,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_DIO_OUT_REG] = { 0, 0 }, /* DOES NOT MAP CLEANLY */ [NISTC_DIO_CTRL_REG] = { 0, 0 }, /* DOES NOT MAP CLEANLY */ [NISTC_AI_MODE1_REG] = { 0x118, 2 }, - [AI_Mode_2_Register] = { 0x11a, 2 }, + [NISTC_AI_MODE2_REG] = { 0x11a, 2 }, [AI_SI_Load_A_Registers] = { 0x11c, 4 }, [AI_SI_Load_B_Registers] = { 0x120, 4 }, [AI_SC_Load_A_Registers] = { 0x124, 4 }, @@ -1634,7 +1634,7 @@ static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s) NISTC_AI_MODE1_RSVD /*| NISTC_AI_MODE1_TRIGGER_ONCE */, NISTC_AI_MODE1_REG); - ni_stc_writew(dev, 0x0000, AI_Mode_2_Register); + ni_stc_writew(dev, 0, NISTC_AI_MODE2_REG); /* generate FIFO interrupts on non-empty */ ni_stc_writew(dev, (0 << 6) | 0x0000, AI_Mode_3_Register); if (devpriv->is_611x) { @@ -2313,10 +2313,10 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } } - mode2 &= ~AI_Pre_Trigger; - mode2 &= ~AI_SC_Initial_Load_Source; - mode2 &= ~AI_SC_Reload_Mode; - ni_stc_writew(dev, mode2, AI_Mode_2_Register); + mode2 &= ~NISTC_AI_MODE2_PRE_TRIGGER; + mode2 &= ~NISTC_AI_MODE2_SC_INIT_LOAD_SRC; + mode2 &= ~NISTC_AI_MODE2_SC_RELOAD_MODE; + ni_stc_writew(dev, mode2, NISTC_AI_MODE2_REG); if (cmd->chanlist_len == 1 || devpriv->is_611x || devpriv->is_6143) { start_stop_select |= AI_STOP_Polarity; @@ -2374,7 +2374,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* stop bits for non 611x boards AI_SI_Special_Trigger_Delay=0 - AI_Pre_Trigger=0 + NISTC_AI_MODE2_PRE_TRIGGER=0 AI_START_STOP_Select_Register: AI_START_Polarity=0 (?) rising edge AI_START_Edge=1 edge triggered @@ -2389,11 +2389,10 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ni_stc_writew(dev, start_stop_select, AI_START_STOP_Select_Register); - mode2 |= AI_SI_Reload_Mode(0); - /* AI_SI_Initial_Load_Source=A */ - mode2 &= ~AI_SI_Initial_Load_Source; - /* mode2 |= AI_SC_Reload_Mode; */ - ni_stc_writew(dev, mode2, AI_Mode_2_Register); + mode2 &= ~NISTC_AI_MODE2_SI_INIT_LOAD_SRC; /* A */ + mode2 |= NISTC_AI_MODE2_SI_RELOAD_MODE(0); + /* mode2 |= NISTC_AI_MODE2_SC_RELOAD_MODE; */ + ni_stc_writew(dev, mode2, NISTC_AI_MODE2_REG); /* load SI */ timer = ni_ns_to_timer(dev, cmd->scan_begin_arg, @@ -2430,18 +2429,15 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ni_stc_writew(dev, 1, AI_SI2_Load_A_Register); ni_stc_writew(dev, timer, AI_SI2_Load_B_Register); - /* AI_SI2_Reload_Mode = alternate */ - /* AI_SI2_Initial_Load_Source = A */ - mode2 &= ~AI_SI2_Initial_Load_Source; - mode2 |= AI_SI2_Reload_Mode; - ni_stc_writew(dev, mode2, AI_Mode_2_Register); + mode2 &= ~NISTC_AI_MODE2_SI2_INIT_LOAD_SRC; /* A */ + mode2 |= NISTC_AI_MODE2_SI2_RELOAD_MODE; /* alternate */ + ni_stc_writew(dev, mode2, NISTC_AI_MODE2_REG); ni_stc_writew(dev, NISTC_AI_CMD1_SI2_LOAD, NISTC_AI_CMD1_REG); - mode2 |= AI_SI2_Reload_Mode; /* alternate */ - mode2 |= AI_SI2_Initial_Load_Source; /* B */ - - ni_stc_writew(dev, mode2, AI_Mode_2_Register); + mode2 |= NISTC_AI_MODE2_SI2_INIT_LOAD_SRC; /* B */ + mode2 |= NISTC_AI_MODE2_SI2_RELOAD_MODE; /* alternate */ + ni_stc_writew(dev, mode2, NISTC_AI_MODE2_REG); break; case TRIG_EXT: mode1 |= NISTC_AI_MODE1_CONVERT_SRC(1 + cmd->convert_arg); @@ -2449,8 +2445,9 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) mode1 |= NISTC_AI_MODE1_CONVERT_POLARITY; ni_stc_writew(dev, mode1, NISTC_AI_MODE1_REG); - mode2 |= AI_Start_Stop_Gate_Enable | AI_SC_Gate_Enable; - ni_stc_writew(dev, mode2, AI_Mode_2_Register); + mode2 |= NISTC_AI_MODE2_SC_GATE_ENA | + NISTC_AI_MODE2_START_STOP_GATE_ENA; + ni_stc_writew(dev, mode2, NISTC_AI_MODE2_REG); break; } diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 315579e60216..739061a1be9b 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -190,6 +190,20 @@ #define NISTC_AI_MODE1_CONTINUOUS BIT(1) #define NISTC_AI_MODE1_TRIGGER_ONCE BIT(0) +#define NISTC_AI_MODE2_REG 13 +#define NISTC_AI_MODE2_SC_GATE_ENA BIT(15) +#define NISTC_AI_MODE2_START_STOP_GATE_ENA BIT(14) +#define NISTC_AI_MODE2_PRE_TRIGGER BIT(13) +#define NISTC_AI_MODE2_EXTMUX_PRESENT BIT(12) +#define NISTC_AI_MODE2_SI2_INIT_LOAD_SRC BIT(9) +#define NISTC_AI_MODE2_SI2_RELOAD_MODE BIT(8) +#define NISTC_AI_MODE2_SI_INIT_LOAD_SRC BIT(7) +#define NISTC_AI_MODE2_SI_RELOAD_MODE(x) (((x) & 0x7) << 4) +#define NISTC_AI_MODE2_SI_WR_SWITCH BIT(3) +#define NISTC_AI_MODE2_SC_INIT_LOAD_SRC BIT(2) +#define NISTC_AI_MODE2_SC_RELOAD_MODE BIT(1) +#define NISTC_AI_MODE2_SC_WR_SWITCH BIT(0) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -232,20 +246,6 @@ #define DIO_Parallel_Input_Register 7 -#define AI_Mode_2_Register 13 -#define AI_SC_Gate_Enable _bit15 -#define AI_Start_Stop_Gate_Enable _bit14 -#define AI_Pre_Trigger _bit13 -#define AI_External_MUX_Present _bit12 -#define AI_SI2_Initial_Load_Source _bit9 -#define AI_SI2_Reload_Mode _bit8 -#define AI_SI_Initial_Load_Source _bit7 -#define AI_SI_Reload_Mode(a) (((a) & 0x7)<<4) -#define AI_SI_Write_Switch _bit3 -#define AI_SC_Initial_Load_Source _bit2 -#define AI_SC_Reload_Mode _bit1 -#define AI_SC_Write_Switch _bit0 - #define AI_SI_Load_A_Registers 14 #define AI_SI_Load_B_Registers 16 #define AI_SC_Load_A_Registers 18 From a2c537362a7975a7bab1e325872510dbf68b83c6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:05 -0700 Subject: [PATCH 0341/1163] staging: comedi: ni_stc.h: tidy up AI_*_Load_[AB]_Registers Rename the CamelCase. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 22 +++++++++---------- drivers/staging/comedi/drivers/ni_stc.h | 14 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 7cbe9d9e0bd8..6b63bad12d17 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -330,12 +330,12 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_DIO_CTRL_REG] = { 0, 0 }, /* DOES NOT MAP CLEANLY */ [NISTC_AI_MODE1_REG] = { 0x118, 2 }, [NISTC_AI_MODE2_REG] = { 0x11a, 2 }, - [AI_SI_Load_A_Registers] = { 0x11c, 4 }, - [AI_SI_Load_B_Registers] = { 0x120, 4 }, - [AI_SC_Load_A_Registers] = { 0x124, 4 }, - [AI_SC_Load_B_Registers] = { 0x128, 4 }, - [AI_SI2_Load_A_Register] = { 0x12c, 4 }, - [AI_SI2_Load_B_Register] = { 0x130, 4 }, + [NISTC_AI_SI_LOADA_REG] = { 0x11c, 4 }, + [NISTC_AI_SI_LOADB_REG] = { 0x120, 4 }, + [NISTC_AI_SC_LOADA_REG] = { 0x124, 4 }, + [NISTC_AI_SC_LOADB_REG] = { 0x128, 4 }, + [NISTC_AI_SI2_LOADA_REG] = { 0x12c, 4 }, + [NISTC_AI_SI2_LOADB_REG] = { 0x130, 4 }, [G_Mode_Register(0)] = { 0x134, 2 }, [G_Mode_Register(1)] = { 0x136, 2 }, [G_Load_A_Register(0)] = { 0x138, 4 }, @@ -2337,7 +2337,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) stop_count += num_adc_stages_611x; } /* stage number of scans */ - ni_stc_writel(dev, stop_count, AI_SC_Load_A_Registers); + ni_stc_writel(dev, stop_count, NISTC_AI_SC_LOADA_REG); mode1 |= NISTC_AI_MODE1_START_STOP | NISTC_AI_MODE1_RSVD | @@ -2357,7 +2357,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) break; case TRIG_NONE: /* stage number of scans */ - ni_stc_writel(dev, 0, AI_SC_Load_A_Registers); + ni_stc_writel(dev, 0, NISTC_AI_SC_LOADA_REG); mode1 |= NISTC_AI_MODE1_START_STOP | NISTC_AI_MODE1_RSVD | @@ -2397,7 +2397,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* load SI */ timer = ni_ns_to_timer(dev, cmd->scan_begin_arg, CMDF_ROUND_NEAREST); - ni_stc_writel(dev, timer, AI_SI_Load_A_Registers); + ni_stc_writel(dev, timer, NISTC_AI_SI_LOADA_REG); ni_stc_writew(dev, NISTC_AI_CMD1_SI_LOAD, NISTC_AI_CMD1_REG); break; case TRIG_EXT: @@ -2426,8 +2426,8 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) timer = ni_ns_to_timer(dev, cmd->convert_arg, CMDF_ROUND_NEAREST); /* 0,0 does not work */ - ni_stc_writew(dev, 1, AI_SI2_Load_A_Register); - ni_stc_writew(dev, timer, AI_SI2_Load_B_Register); + ni_stc_writew(dev, 1, NISTC_AI_SI2_LOADA_REG); + ni_stc_writew(dev, timer, NISTC_AI_SI2_LOADB_REG); mode2 &= ~NISTC_AI_MODE2_SI2_INIT_LOAD_SRC; /* A */ mode2 |= NISTC_AI_MODE2_SI2_RELOAD_MODE; /* alternate */ diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 739061a1be9b..92bb724065e3 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -204,6 +204,13 @@ #define NISTC_AI_MODE2_SC_RELOAD_MODE BIT(1) #define NISTC_AI_MODE2_SC_WR_SWITCH BIT(0) +#define NISTC_AI_SI_LOADA_REG 14 +#define NISTC_AI_SI_LOADB_REG 16 +#define NISTC_AI_SC_LOADA_REG 18 +#define NISTC_AI_SC_LOADB_REG 20 +#define NISTC_AI_SI2_LOADA_REG 23 +#define NISTC_AI_SI2_LOADB_REG 25 + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -246,16 +253,9 @@ #define DIO_Parallel_Input_Register 7 -#define AI_SI_Load_A_Registers 14 -#define AI_SI_Load_B_Registers 16 -#define AI_SC_Load_A_Registers 18 -#define AI_SC_Load_B_Registers 20 #define AI_SI_Save_Registers 64 #define AI_SC_Save_Registers 66 -#define AI_SI2_Load_A_Register 23 -#define AI_SI2_Load_B_Register 25 - #define Joint_Status_1_Register 27 #define DIO_Serial_IO_In_Progress_St _bit12 From aff27008376a83ee1603e688b68ceed24356c81e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:06 -0700 Subject: [PATCH 0342/1163] staging: comedi: ni_stc.h: tidy up G_{Mode,Load,Input}*_Register Rename the CamelCase and define he G0 and G1 registers to add clarity to the mio_regmap tables. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 32 +++++++++---------- drivers/staging/comedi/drivers/ni_stc.h | 17 +++++----- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 6b63bad12d17..a2049a3d3341 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -336,14 +336,14 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_AI_SC_LOADB_REG] = { 0x128, 4 }, [NISTC_AI_SI2_LOADA_REG] = { 0x12c, 4 }, [NISTC_AI_SI2_LOADB_REG] = { 0x130, 4 }, - [G_Mode_Register(0)] = { 0x134, 2 }, - [G_Mode_Register(1)] = { 0x136, 2 }, - [G_Load_A_Register(0)] = { 0x138, 4 }, - [G_Load_B_Register(0)] = { 0x13c, 4 }, - [G_Load_A_Register(1)] = { 0x140, 4 }, - [G_Load_B_Register(1)] = { 0x144, 4 }, - [G_Input_Select_Register(0)] = { 0x148, 2 }, - [G_Input_Select_Register(1)] = { 0x14a, 2 }, + [NISTC_G0_MODE_REG] = { 0x134, 2 }, + [NISTC_G1_MODE_REG] = { 0x136, 2 }, + [NISTC_G0_LOADA_REG] = { 0x138, 4 }, + [NISTC_G0_LOADB_REG] = { 0x13c, 4 }, + [NISTC_G1_LOADA_REG] = { 0x140, 4 }, + [NISTC_G1_LOADB_REG] = { 0x144, 4 }, + [NISTC_G0_INPUT_SEL_REG] = { 0x148, 2 }, + [NISTC_G1_INPUT_SEL_REG] = { 0x14a, 2 }, [AO_Mode_1_Register] = { 0x14c, 2 }, [AO_Mode_2_Register] = { 0x14e, 2 }, [AO_UI_Load_A_Register] = { 0x150, 4 }, @@ -3738,14 +3738,14 @@ static const struct mio_regmap ni_gpct_to_stc_regmap[] = { [NITIO_G1_HW_SAVE] = { G_HW_Save_Register(1), 4 }, [NITIO_G0_SW_SAVE] = { G_Save_Register(0), 4 }, [NITIO_G1_SW_SAVE] = { G_Save_Register(1), 4 }, - [NITIO_G0_MODE] = { G_Mode_Register(0), 2 }, - [NITIO_G1_MODE] = { G_Mode_Register(1), 2 }, - [NITIO_G0_LOADA] = { G_Load_A_Register(0), 4 }, - [NITIO_G1_LOADA] = { G_Load_A_Register(1), 4 }, - [NITIO_G0_LOADB] = { G_Load_B_Register(0), 4 }, - [NITIO_G1_LOADB] = { G_Load_B_Register(1), 4 }, - [NITIO_G0_INPUT_SEL] = { G_Input_Select_Register(0), 2 }, - [NITIO_G1_INPUT_SEL] = { G_Input_Select_Register(1), 2 }, + [NITIO_G0_MODE] = { NISTC_G0_MODE_REG, 2 }, + [NITIO_G1_MODE] = { NISTC_G1_MODE_REG, 2 }, + [NITIO_G0_LOADA] = { NISTC_G0_LOADA_REG, 4 }, + [NITIO_G1_LOADA] = { NISTC_G1_LOADA_REG, 4 }, + [NITIO_G0_LOADB] = { NISTC_G0_LOADB_REG, 4 }, + [NITIO_G1_LOADB] = { NISTC_G1_LOADB_REG, 4 }, + [NITIO_G0_INPUT_SEL] = { NISTC_G0_INPUT_SEL_REG, 2 }, + [NITIO_G1_INPUT_SEL] = { NISTC_G1_INPUT_SEL_REG, 2 }, [NITIO_G0_CNT_MODE] = { 0x1b0, 2 }, /* M-Series only */ [NITIO_G1_CNT_MODE] = { 0x1b2, 2 }, /* M-Series only */ [NITIO_G0_GATE2] = { 0x1b4, 2 }, /* M-Series only */ diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 92bb724065e3..37905858e768 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -211,6 +211,15 @@ #define NISTC_AI_SI2_LOADA_REG 23 #define NISTC_AI_SI2_LOADB_REG 25 +#define NISTC_G0_MODE_REG 26 +#define NISTC_G1_MODE_REG 27 +#define NISTC_G0_LOADA_REG 28 +#define NISTC_G0_LOADB_REG 30 +#define NISTC_G1_LOADA_REG 32 +#define NISTC_G1_LOADB_REG 34 +#define NISTC_G0_INPUT_SEL_REG 36 +#define NISTC_G1_INPUT_SEL_REG 37 + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -605,14 +614,6 @@ static unsigned AO_UPDATE_Output_Select(enum ao_update_output_selection #define G_HW_Save_Register(a) (8+(a)*2) #define G_HW_Save_Register_High(a) (8+(a)*2) #define G_HW_Save_Register_Low(a) (9+(a)*2) -#define G_Input_Select_Register(a) (36+(a)) -#define G_Load_A_Register(a) (28+(a)*4) -#define G_Load_A_Register_High(a) (28+(a)*4) -#define G_Load_A_Register_Low(a) (29+(a)*4) -#define G_Load_B_Register(a) (30+(a)*4) -#define G_Load_B_Register_High(a) (30+(a)*4) -#define G_Load_B_Register_Low(a) (31+(a)*4) -#define G_Mode_Register(a) (26+(a)) #define G_Save_Register(a) (12+(a)*2) #define G_Save_Register_High(a) (12+(a)*2) #define G_Save_Register_Low(a) (13+(a)*2) From 4e5ce0a8f3a2e59e17b997601947f6863ce69256 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:07 -0700 Subject: [PATCH 0343/1163] staging: comedi: ni_stc.h: tidy up AO_Mode_1_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 35 ++++++++++--------- drivers/staging/comedi/drivers/ni_stc.h | 22 ++++++------ 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index a2049a3d3341..e4ae9a1445b5 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -344,7 +344,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_G1_LOADB_REG] = { 0x144, 4 }, [NISTC_G0_INPUT_SEL_REG] = { 0x148, 2 }, [NISTC_G1_INPUT_SEL_REG] = { 0x14a, 2 }, - [AO_Mode_1_Register] = { 0x14c, 2 }, + [NISTC_AO_MODE1_REG] = { 0x14c, 2 }, [AO_Mode_2_Register] = { 0x14e, 2 }, [AO_UI_Load_A_Register] = { 0x150, 4 }, [AO_UI_Load_B_Register] = { 0x154, 4 }, @@ -2957,13 +2957,13 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ni_ao_config_chanlist(dev, s, cmd->chanlist, cmd->chanlist_len, 1); if (cmd->stop_src == TRIG_NONE) { - devpriv->ao_mode1 |= AO_Continuous; - devpriv->ao_mode1 &= ~AO_Trigger_Once; + devpriv->ao_mode1 |= NISTC_AO_MODE1_CONTINUOUS; + devpriv->ao_mode1 &= ~NISTC_AO_MODE1_TRIGGER_ONCE; } else { - devpriv->ao_mode1 &= ~AO_Continuous; - devpriv->ao_mode1 |= AO_Trigger_Once; + devpriv->ao_mode1 &= ~NISTC_AO_MODE1_CONTINUOUS; + devpriv->ao_mode1 |= NISTC_AO_MODE1_TRIGGER_ONCE; } - ni_stc_writew(dev, devpriv->ao_mode1, AO_Mode_1_Register); + ni_stc_writew(dev, devpriv->ao_mode1, NISTC_AO_MODE1_REG); switch (cmd->start_src) { case TRIG_INT: case TRIG_NOW: @@ -2990,7 +2990,7 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ao_mode3 &= ~AO_Trigger_Length; ni_stc_writew(dev, devpriv->ao_mode3, AO_Mode_3_Register); - ni_stc_writew(dev, devpriv->ao_mode1, AO_Mode_1_Register); + ni_stc_writew(dev, devpriv->ao_mode1, NISTC_AO_MODE1_REG); devpriv->ao_mode2 &= ~AO_BC_Initial_Load_Source; ni_stc_writew(dev, devpriv->ao_mode2, AO_Mode_2_Register); if (cmd->stop_src == TRIG_NONE) @@ -3028,9 +3028,10 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ni_stc_writel(dev, cmd->stop_arg, AO_UC_Load_A_Register); } - devpriv->ao_mode1 &= - ~(AO_UI_Source_Select(0x1f) | AO_UI_Source_Polarity | - AO_UPDATE_Source_Select(0x1f) | AO_UPDATE_Source_Polarity); + devpriv->ao_mode1 &= ~(NISTC_AO_MODE1_UPDATE_SRC_MASK | + NISTC_AO_MODE1_UI_SRC_MASK | + NISTC_AO_MODE1_UPDATE_SRC_POLARITY | + NISTC_AO_MODE1_UI_SRC_POLARITY); switch (cmd->scan_begin_src) { case TRIG_TIMER: devpriv->ao_cmd2 &= ~NISTC_AO_CMD2_BC_GATE_ENA; @@ -3043,9 +3044,9 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) break; case TRIG_EXT: devpriv->ao_mode1 |= - AO_UPDATE_Source_Select(cmd->scan_begin_arg); + NISTC_AO_MODE1_UPDATE_SRC(cmd->scan_begin_arg); if (cmd->scan_begin_arg & CR_INVERT) - devpriv->ao_mode1 |= AO_UPDATE_Source_Polarity; + devpriv->ao_mode1 |= NISTC_AO_MODE1_UPDATE_SRC_POLARITY; devpriv->ao_cmd2 |= NISTC_AO_CMD2_BC_GATE_ENA; break; default: @@ -3053,13 +3054,13 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) break; } ni_stc_writew(dev, devpriv->ao_cmd2, NISTC_AO_CMD2_REG); - ni_stc_writew(dev, devpriv->ao_mode1, AO_Mode_1_Register); + ni_stc_writew(dev, devpriv->ao_mode1, NISTC_AO_MODE1_REG); devpriv->ao_mode2 &= ~(AO_UI_Reload_Mode(3) | AO_UI_Initial_Load_Source); ni_stc_writew(dev, devpriv->ao_mode2, AO_Mode_2_Register); if (cmd->scan_end_arg > 1) { - devpriv->ao_mode1 |= AO_Multiple_Channels; + devpriv->ao_mode1 |= NISTC_AO_MODE1_MULTI_CHAN; ni_stc_writew(dev, AO_Number_Of_Channels(cmd->scan_end_arg - 1) | AO_UPDATE_Output_Select(AO_Update_Output_High_Z), @@ -3067,7 +3068,7 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } else { unsigned bits; - devpriv->ao_mode1 &= ~AO_Multiple_Channels; + devpriv->ao_mode1 &= ~NISTC_AO_MODE1_MULTI_CHAN; bits = AO_UPDATE_Output_Select(AO_Update_Output_High_Z); if (devpriv->is_m_series || devpriv->is_6xxx) { bits |= AO_Number_Of_Channels(0); @@ -3077,7 +3078,7 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } ni_stc_writew(dev, bits, AO_Output_Control_Register); } - ni_stc_writew(dev, devpriv->ao_mode1, AO_Mode_1_Register); + ni_stc_writew(dev, devpriv->ao_mode1, NISTC_AO_MODE1_REG); ni_stc_writew(dev, NISTC_AO_CMD1_DAC1_UPDATE_MODE | NISTC_AO_CMD1_DAC0_UPDATE_MODE, @@ -3228,7 +3229,7 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ao_cmd2 = 0; ni_stc_writew(dev, devpriv->ao_cmd2, NISTC_AO_CMD2_REG); devpriv->ao_mode1 = 0; - ni_stc_writew(dev, devpriv->ao_mode1, AO_Mode_1_Register); + ni_stc_writew(dev, devpriv->ao_mode1, NISTC_AO_MODE1_REG); devpriv->ao_mode2 = 0; ni_stc_writew(dev, devpriv->ao_mode2, AO_Mode_2_Register); if (devpriv->is_m_series) diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 37905858e768..9919e7d2f5e5 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -220,6 +220,18 @@ #define NISTC_G0_INPUT_SEL_REG 36 #define NISTC_G1_INPUT_SEL_REG 37 +#define NISTC_AO_MODE1_REG 38 +#define NISTC_AO_MODE1_UPDATE_SRC(x) (((x) & 0x1f) << 11) +#define NISTC_AO_MODE1_UPDATE_SRC_MASK NISTC_AO_MODE1_UPDATE_SRC(0x1f) +#define NISTC_AO_MODE1_UI_SRC(x) (((x) & 0x1f) << 6) +#define NISTC_AO_MODE1_UI_SRC_MASK NISTC_AO_MODE1_UI_SRC(0x1f) +#define NISTC_AO_MODE1_MULTI_CHAN BIT(5) +#define NISTC_AO_MODE1_UPDATE_SRC_POLARITY BIT(4) +#define NISTC_AO_MODE1_UI_SRC_POLARITY BIT(3) +#define NISTC_AO_MODE1_UC_SW_EVERY_TC BIT(2) +#define NISTC_AO_MODE1_CONTINUOUS BIT(1) +#define NISTC_AO_MODE1_TRIGGER_ONCE BIT(0) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -274,16 +286,6 @@ enum Joint_Status_2_Bits { AO_TMRDACWRs_In_Progress_St = 0x20, }; -#define AO_Mode_1_Register 38 -#define AO_UPDATE_Source_Select(x) (((x)&0x1f)<<11) -#define AO_UI_Source_Select(x) (((x)&0x1f)<<6) -#define AO_Multiple_Channels _bit5 -#define AO_UPDATE_Source_Polarity _bit4 -#define AO_UI_Source_Polarity _bit3 -#define AO_UC_Switch_Load_Every_TC _bit2 -#define AO_Continuous _bit1 -#define AO_Trigger_Once _bit0 - #define AO_Mode_2_Register 39 #define AO_FIFO_Mode_Mask (0x3 << 14) enum AO_FIFO_Mode_Bits { From ec8bf7250f8156a8ba0d2381046224e66042d83c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:08 -0700 Subject: [PATCH 0344/1163] staging: comedi: ni_stc.h: tidy up AO_Mode_2_Register and bits Rename the CamelCase and convert the enum into defines. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 28 ++++++------- drivers/staging/comedi/drivers/ni_stc.h | 41 +++++++++---------- 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index e4ae9a1445b5..ddc7e7612ce5 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -345,7 +345,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_G0_INPUT_SEL_REG] = { 0x148, 2 }, [NISTC_G1_INPUT_SEL_REG] = { 0x14a, 2 }, [NISTC_AO_MODE1_REG] = { 0x14c, 2 }, - [AO_Mode_2_Register] = { 0x14e, 2 }, + [NISTC_AO_MODE2_REG] = { 0x14e, 2 }, [AO_UI_Load_A_Register] = { 0x150, 4 }, [AO_UI_Load_B_Register] = { 0x154, 4 }, [AO_BC_Load_A_Register] = { 0x158, 4 }, @@ -2991,15 +2991,15 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ni_stc_writew(dev, devpriv->ao_mode3, AO_Mode_3_Register); ni_stc_writew(dev, devpriv->ao_mode1, NISTC_AO_MODE1_REG); - devpriv->ao_mode2 &= ~AO_BC_Initial_Load_Source; - ni_stc_writew(dev, devpriv->ao_mode2, AO_Mode_2_Register); + devpriv->ao_mode2 &= ~NISTC_AO_MODE2_BC_INIT_LOAD_SRC; + ni_stc_writew(dev, devpriv->ao_mode2, NISTC_AO_MODE2_REG); if (cmd->stop_src == TRIG_NONE) ni_stc_writel(dev, 0xffffff, AO_BC_Load_A_Register); else ni_stc_writel(dev, 0, AO_BC_Load_A_Register); ni_stc_writew(dev, NISTC_AO_CMD1_BC_LOAD, NISTC_AO_CMD1_REG); - devpriv->ao_mode2 &= ~AO_UC_Initial_Load_Source; - ni_stc_writew(dev, devpriv->ao_mode2, AO_Mode_2_Register); + devpriv->ao_mode2 &= ~NISTC_AO_MODE2_UC_INIT_LOAD_SRC; + ni_stc_writew(dev, devpriv->ao_mode2, NISTC_AO_MODE2_REG); switch (cmd->stop_src) { case TRIG_COUNT: if (devpriv->is_m_series) { @@ -3055,9 +3055,9 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } ni_stc_writew(dev, devpriv->ao_cmd2, NISTC_AO_CMD2_REG); ni_stc_writew(dev, devpriv->ao_mode1, NISTC_AO_MODE1_REG); - devpriv->ao_mode2 &= - ~(AO_UI_Reload_Mode(3) | AO_UI_Initial_Load_Source); - ni_stc_writew(dev, devpriv->ao_mode2, AO_Mode_2_Register); + devpriv->ao_mode2 &= ~(NISTC_AO_MODE2_UI_RELOAD_MODE(3) | + NISTC_AO_MODE2_UI_INIT_LOAD_SRC); + ni_stc_writew(dev, devpriv->ao_mode2, NISTC_AO_MODE2_REG); if (cmd->scan_end_arg > 1) { devpriv->ao_mode1 |= NISTC_AO_MODE1_MULTI_CHAN; @@ -3087,14 +3087,14 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ao_mode3 |= AO_Stop_On_Overrun_Error; ni_stc_writew(dev, devpriv->ao_mode3, AO_Mode_3_Register); - devpriv->ao_mode2 &= ~AO_FIFO_Mode_Mask; + devpriv->ao_mode2 &= ~NISTC_AO_MODE2_FIFO_MODE_MASK; #ifdef PCIDMA - devpriv->ao_mode2 |= AO_FIFO_Mode_HF_to_F; + devpriv->ao_mode2 |= NISTC_AO_MODE2_FIFO_MODE_HF_F; #else - devpriv->ao_mode2 |= AO_FIFO_Mode_HF; + devpriv->ao_mode2 |= NISTC_AO_MODE2_FIFO_MODE_HF; #endif - devpriv->ao_mode2 &= ~AO_FIFO_Retransmit_Enable; - ni_stc_writew(dev, devpriv->ao_mode2, AO_Mode_2_Register); + devpriv->ao_mode2 &= ~NISTC_AO_MODE2_FIFO_REXMIT_ENA; + ni_stc_writew(dev, devpriv->ao_mode2, NISTC_AO_MODE2_REG); bits = AO_BC_Source_Select | AO_UPDATE_Pulse_Width | AO_TMRDACWR_Pulse_Width; @@ -3231,7 +3231,7 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ao_mode1 = 0; ni_stc_writew(dev, devpriv->ao_mode1, NISTC_AO_MODE1_REG); devpriv->ao_mode2 = 0; - ni_stc_writew(dev, devpriv->ao_mode2, AO_Mode_2_Register); + ni_stc_writew(dev, devpriv->ao_mode2, NISTC_AO_MODE2_REG); if (devpriv->is_m_series) devpriv->ao_mode3 = AO_Last_Gate_Disable; else diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 9919e7d2f5e5..4100bad9e1e5 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -232,6 +232,26 @@ #define NISTC_AO_MODE1_CONTINUOUS BIT(1) #define NISTC_AO_MODE1_TRIGGER_ONCE BIT(0) +#define NISTC_AO_MODE2_REG 39 +#define NISTC_AO_MODE2_FIFO_MODE(x) (((x) & 0x3) << 14) +#define NISTC_AO_MODE2_FIFO_MODE_MASK NISTC_AO_MODE2_FIFO_MODE(3) +#define NISTC_AO_MODE2_FIFO_MODE_E NISTC_AO_MODE2_FIFO_MODE(0) +#define NISTC_AO_MODE2_FIFO_MODE_HF NISTC_AO_MODE2_FIFO_MODE(1) +#define NISTC_AO_MODE2_FIFO_MODE_F NISTC_AO_MODE2_FIFO_MODE(2) +#define NISTC_AO_MODE2_FIFO_MODE_HF_F NISTC_AO_MODE2_FIFO_MODE(3) +#define NISTC_AO_MODE2_FIFO_REXMIT_ENA BIT(13) +#define NISTC_AO_MODE2_START1_DISABLE BIT(12) +#define NISTC_AO_MODE2_UC_INIT_LOAD_SRC BIT(11) +#define NISTC_AO_MODE2_UC_WR_SWITCH BIT(10) +#define NISTC_AO_MODE2_UI2_INIT_LOAD_SRC BIT(9) +#define NISTC_AO_MODE2_UI2_RELOAD_MODE BIT(8) +#define NISTC_AO_MODE2_UI_INIT_LOAD_SRC BIT(7) +#define NISTC_AO_MODE2_UI_RELOAD_MODE(x) (((x) & 0x7) << 4) +#define NISTC_AO_MODE2_UI_WR_SWITCH BIT(3) +#define NISTC_AO_MODE2_BC_INIT_LOAD_SRC BIT(2) +#define NISTC_AO_MODE2_BC_RELOAD_MODE BIT(1) +#define NISTC_AO_MODE2_BC_WR_SWITCH BIT(0) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -286,27 +306,6 @@ enum Joint_Status_2_Bits { AO_TMRDACWRs_In_Progress_St = 0x20, }; -#define AO_Mode_2_Register 39 -#define AO_FIFO_Mode_Mask (0x3 << 14) -enum AO_FIFO_Mode_Bits { - AO_FIFO_Mode_HF_to_F = (3 << 14), - AO_FIFO_Mode_F = (2 << 14), - AO_FIFO_Mode_HF = (1 << 14), - AO_FIFO_Mode_E = (0 << 14), -}; -#define AO_FIFO_Retransmit_Enable _bit13 -#define AO_START1_Disable _bit12 -#define AO_UC_Initial_Load_Source _bit11 -#define AO_UC_Write_Switch _bit10 -#define AO_UI2_Initial_Load_Source _bit9 -#define AO_UI2_Reload_Mode _bit8 -#define AO_UI_Initial_Load_Source _bit7 -#define AO_UI_Reload_Mode(x) (((x) & 0x7) << 4) -#define AO_UI_Write_Switch _bit3 -#define AO_BC_Initial_Load_Source _bit2 -#define AO_BC_Reload_Mode _bit1 -#define AO_BC_Write_Switch _bit0 - #define AO_UI_Load_A_Register 40 #define AO_UI_Load_A_Register_High 40 #define AO_UI_Load_A_Register_Low 41 From 37e0ecee83a41b08361c33ea627e0d2e0a9ea88d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:09 -0700 Subject: [PATCH 0345/1163] staging: comedi: ni_stc.h: tidy up AO_*_Load_[AB]_Register Rename the CamelCase. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 34 +++++++++---------- drivers/staging/comedi/drivers/ni_stc.h | 21 ++++-------- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index ddc7e7612ce5..3035f16c9de5 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -346,12 +346,12 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_G1_INPUT_SEL_REG] = { 0x14a, 2 }, [NISTC_AO_MODE1_REG] = { 0x14c, 2 }, [NISTC_AO_MODE2_REG] = { 0x14e, 2 }, - [AO_UI_Load_A_Register] = { 0x150, 4 }, - [AO_UI_Load_B_Register] = { 0x154, 4 }, - [AO_BC_Load_A_Register] = { 0x158, 4 }, - [AO_BC_Load_B_Register] = { 0x15c, 4 }, - [AO_UC_Load_A_Register] = { 0x160, 4 }, - [AO_UC_Load_B_Register] = { 0x164, 4 }, + [NISTC_AO_UI_LOADA_REG] = { 0x150, 4 }, + [NISTC_AO_UI_LOADB_REG] = { 0x154, 4 }, + [NISTC_AO_BC_LOADA_REG] = { 0x158, 4 }, + [NISTC_AO_BC_LOADB_REG] = { 0x15c, 4 }, + [NISTC_AO_UC_LOADA_REG] = { 0x160, 4 }, + [NISTC_AO_UC_LOADB_REG] = { 0x164, 4 }, [Clock_and_FOUT_Register] = { 0x170, 2 }, [IO_Bidirection_Pin_Register] = { 0x172, 2 }, [RTSI_Trig_Direction_Register] = { 0x174, 2 }, @@ -2994,9 +2994,9 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ao_mode2 &= ~NISTC_AO_MODE2_BC_INIT_LOAD_SRC; ni_stc_writew(dev, devpriv->ao_mode2, NISTC_AO_MODE2_REG); if (cmd->stop_src == TRIG_NONE) - ni_stc_writel(dev, 0xffffff, AO_BC_Load_A_Register); + ni_stc_writel(dev, 0xffffff, NISTC_AO_BC_LOADA_REG); else - ni_stc_writel(dev, 0, AO_BC_Load_A_Register); + ni_stc_writel(dev, 0, NISTC_AO_BC_LOADA_REG); ni_stc_writew(dev, NISTC_AO_CMD1_BC_LOAD, NISTC_AO_CMD1_REG); devpriv->ao_mode2 &= ~NISTC_AO_MODE2_UC_INIT_LOAD_SRC; ni_stc_writew(dev, devpriv->ao_mode2, NISTC_AO_MODE2_REG); @@ -3005,27 +3005,27 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (devpriv->is_m_series) { /* this is how the NI example code does it for m-series boards, verified correct with 6259 */ ni_stc_writel(dev, cmd->stop_arg - 1, - AO_UC_Load_A_Register); + NISTC_AO_UC_LOADA_REG); ni_stc_writew(dev, NISTC_AO_CMD1_UC_LOAD, NISTC_AO_CMD1_REG); } else { ni_stc_writel(dev, cmd->stop_arg, - AO_UC_Load_A_Register); + NISTC_AO_UC_LOADA_REG); ni_stc_writew(dev, NISTC_AO_CMD1_UC_LOAD, NISTC_AO_CMD1_REG); ni_stc_writel(dev, cmd->stop_arg - 1, - AO_UC_Load_A_Register); + NISTC_AO_UC_LOADA_REG); } break; case TRIG_NONE: - ni_stc_writel(dev, 0xffffff, AO_UC_Load_A_Register); + ni_stc_writel(dev, 0xffffff, NISTC_AO_UC_LOADA_REG); ni_stc_writew(dev, NISTC_AO_CMD1_UC_LOAD, NISTC_AO_CMD1_REG); - ni_stc_writel(dev, 0xffffff, AO_UC_Load_A_Register); + ni_stc_writel(dev, 0xffffff, NISTC_AO_UC_LOADA_REG); break; default: - ni_stc_writel(dev, 0, AO_UC_Load_A_Register); + ni_stc_writel(dev, 0, NISTC_AO_UC_LOADA_REG); ni_stc_writew(dev, NISTC_AO_CMD1_UC_LOAD, NISTC_AO_CMD1_REG); - ni_stc_writel(dev, cmd->stop_arg, AO_UC_Load_A_Register); + ni_stc_writel(dev, cmd->stop_arg, NISTC_AO_UC_LOADA_REG); } devpriv->ao_mode1 &= ~(NISTC_AO_MODE1_UPDATE_SRC_MASK | @@ -3038,9 +3038,9 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) trigvar = ni_ns_to_timer(dev, cmd->scan_begin_arg, CMDF_ROUND_NEAREST); - ni_stc_writel(dev, 1, AO_UI_Load_A_Register); + ni_stc_writel(dev, 1, NISTC_AO_UI_LOADA_REG); ni_stc_writew(dev, NISTC_AO_CMD1_UI_LOAD, NISTC_AO_CMD1_REG); - ni_stc_writel(dev, trigvar, AO_UI_Load_A_Register); + ni_stc_writel(dev, trigvar, NISTC_AO_UI_LOADA_REG); break; case TRIG_EXT: devpriv->ao_mode1 |= diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 4100bad9e1e5..6a19016f7a29 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -252,6 +252,13 @@ #define NISTC_AO_MODE2_BC_RELOAD_MODE BIT(1) #define NISTC_AO_MODE2_BC_WR_SWITCH BIT(0) +#define NISTC_AO_UI_LOADA_REG 40 +#define NISTC_AO_UI_LOADB_REG 42 +#define NISTC_AO_BC_LOADA_REG 44 +#define NISTC_AO_BC_LOADB_REG 46 +#define NISTC_AO_UC_LOADA_REG 48 +#define NISTC_AO_UC_LOADB_REG 50 + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -306,22 +313,8 @@ enum Joint_Status_2_Bits { AO_TMRDACWRs_In_Progress_St = 0x20, }; -#define AO_UI_Load_A_Register 40 -#define AO_UI_Load_A_Register_High 40 -#define AO_UI_Load_A_Register_Low 41 -#define AO_UI_Load_B_Register 42 #define AO_UI_Save_Registers 16 -#define AO_BC_Load_A_Register 44 -#define AO_BC_Load_A_Register_High 44 -#define AO_BC_Load_A_Register_Low 45 -#define AO_BC_Load_B_Register 46 -#define AO_BC_Load_B_Register_High 46 -#define AO_BC_Load_B_Register_Low 47 #define AO_BC_Save_Registers 18 -#define AO_UC_Load_A_Register 48 -#define AO_UC_Load_A_Register_High 48 -#define AO_UC_Load_A_Register_Low 49 -#define AO_UC_Load_B_Register 50 #define AO_UC_Save_Registers 20 #define Clock_and_FOUT_Register 56 From a47fc02b497ec7ed9e1409f5a24fa5c0ea1ee1a7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:10 -0700 Subject: [PATCH 0346/1163] staging: comedi: ni_stc.h: tidy up Clock_and_FOUT_Register and bits Rename the CamelCase and convert the enum and inline function into defines. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 62 +++++++++---------- drivers/staging/comedi/drivers/ni_stc.h | 38 +++++------- 2 files changed, 48 insertions(+), 52 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 3035f16c9de5..58663a2012f0 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -352,7 +352,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_AO_BC_LOADB_REG] = { 0x15c, 4 }, [NISTC_AO_UC_LOADA_REG] = { 0x160, 4 }, [NISTC_AO_UC_LOADB_REG] = { 0x164, 4 }, - [Clock_and_FOUT_Register] = { 0x170, 2 }, + [NISTC_CLK_FOUT_REG] = { 0x170, 2 }, [IO_Bidirection_Pin_Register] = { 0x172, 2 }, [RTSI_Trig_Direction_Register] = { 0x174, 2 }, [Interrupt_Control_Register] = { 0x176, 2 }, @@ -3637,6 +3637,7 @@ static int ni_serial_insn_config(struct comedi_device *dev, unsigned int *data) { struct ni_private *devpriv = dev->private; + unsigned clk_fout = devpriv->clock_and_fout; int err = insn->n; unsigned char byte_out, byte_in = 0; @@ -3658,21 +3659,21 @@ static int ni_serial_insn_config(struct comedi_device *dev, /* Warning: this clock speed is too fast to reliably control SCXI. */ devpriv->dio_control &= ~NISTC_DIO_CTRL_HW_SER_TIMEBASE; - devpriv->clock_and_fout |= Slow_Internal_Timebase; - devpriv->clock_and_fout &= ~DIO_Serial_Out_Divide_By_2; + clk_fout |= NISTC_CLK_FOUT_SLOW_TIMEBASE; + clk_fout &= ~NISTC_CLK_FOUT_DIO_SER_OUT_DIV2; data[1] = SERIAL_600NS; devpriv->serial_interval_ns = data[1]; } else if (data[1] <= SERIAL_1_2US) { devpriv->dio_control &= ~NISTC_DIO_CTRL_HW_SER_TIMEBASE; - devpriv->clock_and_fout |= Slow_Internal_Timebase | - DIO_Serial_Out_Divide_By_2; + clk_fout |= NISTC_CLK_FOUT_SLOW_TIMEBASE | + NISTC_CLK_FOUT_DIO_SER_OUT_DIV2; data[1] = SERIAL_1_2US; devpriv->serial_interval_ns = data[1]; } else if (data[1] <= SERIAL_10US) { devpriv->dio_control |= NISTC_DIO_CTRL_HW_SER_TIMEBASE; - devpriv->clock_and_fout |= Slow_Internal_Timebase | - DIO_Serial_Out_Divide_By_2; - /* Note: DIO_Serial_Out_Divide_By_2 only affects + clk_fout |= NISTC_CLK_FOUT_SLOW_TIMEBASE | + NISTC_CLK_FOUT_DIO_SER_OUT_DIV2; + /* Note: NISTC_CLK_FOUT_DIO_SER_OUT_DIV2 only affects 600ns/1.2us. If you turn divide_by_2 off with the slow clock, you will still get 10us, except then all your delays are wrong. */ @@ -3685,10 +3686,10 @@ static int ni_serial_insn_config(struct comedi_device *dev, data[1] = (data[1] / 1000) * 1000; devpriv->serial_interval_ns = data[1]; } + devpriv->clock_and_fout = clk_fout; ni_stc_writew(dev, devpriv->dio_control, NISTC_DIO_CTRL_REG); - ni_stc_writew(dev, devpriv->clock_and_fout, - Clock_and_FOUT_Register); + ni_stc_writew(dev, devpriv->clock_and_fout, NISTC_CLK_FOUT_REG); return 1; case INSN_CONFIG_BIDIRECTIONAL_DATA: @@ -3874,7 +3875,7 @@ static int ni_freq_out_insn_read(struct comedi_device *dev, unsigned int *data) { struct ni_private *devpriv = dev->private; - unsigned int val = devpriv->clock_and_fout & FOUT_Divider_mask; + unsigned int val = NISTC_CLK_FOUT_TO_DIVIDER(devpriv->clock_and_fout); int i; for (i = 0; i < insn->n; i++) @@ -3891,17 +3892,17 @@ static int ni_freq_out_insn_write(struct comedi_device *dev, struct ni_private *devpriv = dev->private; if (insn->n) { - devpriv->clock_and_fout &= ~FOUT_Enable; - ni_stc_writew(dev, devpriv->clock_and_fout, - Clock_and_FOUT_Register); - devpriv->clock_and_fout &= ~FOUT_Divider_mask; + unsigned int val = data[insn->n - 1]; + + devpriv->clock_and_fout &= ~NISTC_CLK_FOUT_ENA; + ni_stc_writew(dev, devpriv->clock_and_fout, NISTC_CLK_FOUT_REG); + devpriv->clock_and_fout &= ~NISTC_CLK_FOUT_DIVIDER_MASK; /* use the last data value to set the fout divider */ - devpriv->clock_and_fout |= FOUT_Divider(data[insn->n - 1]); + devpriv->clock_and_fout |= NISTC_CLK_FOUT_DIVIDER(val); - devpriv->clock_and_fout |= FOUT_Enable; - ni_stc_writew(dev, devpriv->clock_and_fout, - Clock_and_FOUT_Register); + devpriv->clock_and_fout |= NISTC_CLK_FOUT_ENA; + ni_stc_writew(dev, devpriv->clock_and_fout, NISTC_CLK_FOUT_REG); } return insn->n; } @@ -3917,19 +3918,18 @@ static int ni_freq_out_insn_config(struct comedi_device *dev, case INSN_CONFIG_SET_CLOCK_SRC: switch (data[1]) { case NI_FREQ_OUT_TIMEBASE_1_DIV_2_CLOCK_SRC: - devpriv->clock_and_fout &= ~FOUT_Timebase_Select; + devpriv->clock_and_fout &= ~NISTC_CLK_FOUT_TIMEBASE_SEL; break; case NI_FREQ_OUT_TIMEBASE_2_CLOCK_SRC: - devpriv->clock_and_fout |= FOUT_Timebase_Select; + devpriv->clock_and_fout |= NISTC_CLK_FOUT_TIMEBASE_SEL; break; default: return -EINVAL; } - ni_stc_writew(dev, devpriv->clock_and_fout, - Clock_and_FOUT_Register); + ni_stc_writew(dev, devpriv->clock_and_fout, NISTC_CLK_FOUT_REG); break; case INSN_CONFIG_GET_CLOCK_SRC: - if (devpriv->clock_and_fout & FOUT_Timebase_Select) { + if (devpriv->clock_and_fout & NISTC_CLK_FOUT_TIMEBASE_SEL) { data[1] = NI_FREQ_OUT_TIMEBASE_2_CLOCK_SRC; data[2] = TIMEBASE_2_NS; } else { @@ -5106,16 +5106,16 @@ static int ni_E_init(struct comedi_device *dev, } /* initialize clock dividers */ - devpriv->clock_and_fout = Slow_Internal_Time_Divide_By_2 | - Slow_Internal_Timebase | - Clock_To_Board_Divide_By_2 | - Clock_To_Board; + devpriv->clock_and_fout = NISTC_CLK_FOUT_SLOW_DIV2 | + NISTC_CLK_FOUT_SLOW_TIMEBASE | + NISTC_CLK_FOUT_TO_BOARD_DIV2 | + NISTC_CLK_FOUT_TO_BOARD; if (!devpriv->is_6xxx) { /* BEAM is this needed for PCI-6143 ?? */ - devpriv->clock_and_fout |= (AI_Output_Divide_By_2 | - AO_Output_Divide_By_2); + devpriv->clock_and_fout |= (NISTC_CLK_FOUT_AI_OUT_DIV2 | + NISTC_CLK_FOUT_AO_OUT_DIV2); } - ni_stc_writew(dev, devpriv->clock_and_fout, Clock_and_FOUT_Register); + ni_stc_writew(dev, devpriv->clock_and_fout, NISTC_CLK_FOUT_REG); ret = comedi_alloc_subdevices(dev, NI_NUM_SUBDEVICES); if (ret) diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 6a19016f7a29..907bf2a196d3 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -259,6 +259,23 @@ #define NISTC_AO_UC_LOADA_REG 48 #define NISTC_AO_UC_LOADB_REG 50 +#define NISTC_CLK_FOUT_REG 56 +#define NISTC_CLK_FOUT_ENA BIT(15) +#define NISTC_CLK_FOUT_TIMEBASE_SEL BIT(14) +#define NISTC_CLK_FOUT_DIO_SER_OUT_DIV2 BIT(13) +#define NISTC_CLK_FOUT_SLOW_DIV2 BIT(12) +#define NISTC_CLK_FOUT_SLOW_TIMEBASE BIT(11) +#define NISTC_CLK_FOUT_G_SRC_DIV2 BIT(10) +#define NISTC_CLK_FOUT_TO_BOARD_DIV2 BIT(9) +#define NISTC_CLK_FOUT_TO_BOARD BIT(8) +#define NISTC_CLK_FOUT_AI_OUT_DIV2 BIT(7) +#define NISTC_CLK_FOUT_AI_SRC_DIV2 BIT(6) +#define NISTC_CLK_FOUT_AO_OUT_DIV2 BIT(5) +#define NISTC_CLK_FOUT_AO_SRC_DIV2 BIT(4) +#define NISTC_CLK_FOUT_DIVIDER(x) (((x) & 0xf) << 0) +#define NISTC_CLK_FOUT_TO_DIVIDER(x) (((x) >> 0) & 0xf) +#define NISTC_CLK_FOUT_DIVIDER_MASK NISTC_CLK_FOUT_DIVIDER(0xf) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -317,27 +334,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define Clock_and_FOUT_Register 56 -enum Clock_and_FOUT_bits { - FOUT_Enable = _bit15, - FOUT_Timebase_Select = _bit14, - DIO_Serial_Out_Divide_By_2 = _bit13, - Slow_Internal_Time_Divide_By_2 = _bit12, - Slow_Internal_Timebase = _bit11, - G_Source_Divide_By_2 = _bit10, - Clock_To_Board_Divide_By_2 = _bit9, - Clock_To_Board = _bit8, - AI_Output_Divide_By_2 = _bit7, - AI_Source_Divide_By_2 = _bit6, - AO_Output_Divide_By_2 = _bit5, - AO_Source_Divide_By_2 = _bit4, - FOUT_Divider_mask = 0xf -}; -static inline unsigned FOUT_Divider(unsigned divider) -{ - return divider & FOUT_Divider_mask; -} - #define IO_Bidirection_Pin_Register 57 #define RTSI_Trig_Direction_Register 58 enum RTSI_Trig_Direction_Bits { From f1618db1d9679bba2864cbc5fdc44623817e7016 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:11 -0700 Subject: [PATCH 0347/1163] staging: comedi: ni_mio_common: use 'reg' in ni_set_bitfield() Use the passed 'reg' parameter to write to the STC registers instead of duplicating the case symbol. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 58663a2012f0..41eae5c99fee 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -535,30 +535,27 @@ static inline void ni_set_bitfield(struct comedi_device *dev, int reg, case Interrupt_A_Enable_Register: devpriv->int_a_enable_reg &= ~bit_mask; devpriv->int_a_enable_reg |= bit_values & bit_mask; - ni_stc_writew(dev, devpriv->int_a_enable_reg, - Interrupt_A_Enable_Register); + ni_stc_writew(dev, devpriv->int_a_enable_reg, reg); break; case Interrupt_B_Enable_Register: devpriv->int_b_enable_reg &= ~bit_mask; devpriv->int_b_enable_reg |= bit_values & bit_mask; - ni_stc_writew(dev, devpriv->int_b_enable_reg, - Interrupt_B_Enable_Register); + ni_stc_writew(dev, devpriv->int_b_enable_reg, reg); break; case IO_Bidirection_Pin_Register: devpriv->io_bidirection_pin_reg &= ~bit_mask; devpriv->io_bidirection_pin_reg |= bit_values & bit_mask; - ni_stc_writew(dev, devpriv->io_bidirection_pin_reg, - IO_Bidirection_Pin_Register); + ni_stc_writew(dev, devpriv->io_bidirection_pin_reg, reg); break; case AI_AO_Select: devpriv->ai_ao_select_reg &= ~bit_mask; devpriv->ai_ao_select_reg |= bit_values & bit_mask; - ni_writeb(dev, devpriv->ai_ao_select_reg, AI_AO_Select); + ni_writeb(dev, devpriv->ai_ao_select_reg, reg); break; case G0_G1_Select: devpriv->g0_g1_select_reg &= ~bit_mask; devpriv->g0_g1_select_reg |= bit_values & bit_mask; - ni_writeb(dev, devpriv->g0_g1_select_reg, G0_G1_Select); + ni_writeb(dev, devpriv->g0_g1_select_reg, reg); break; default: dev_err(dev->class_dev, "called with invalid register %d\n", From 5ecadf8c4fb9a634dd20af2d14b588254f336a88 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:12 -0700 Subject: [PATCH 0348/1163] staging: comedi: ni_stc.h: tidy up IO_Bidirection_Pin_Register Rename the CamelCase. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 10 +++++----- drivers/staging/comedi/drivers/ni_stc.h | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 41eae5c99fee..fb1df9fc9d38 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -353,7 +353,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_AO_UC_LOADA_REG] = { 0x160, 4 }, [NISTC_AO_UC_LOADB_REG] = { 0x164, 4 }, [NISTC_CLK_FOUT_REG] = { 0x170, 2 }, - [IO_Bidirection_Pin_Register] = { 0x172, 2 }, + [NISTC_IO_BIDIR_PIN_REG] = { 0x172, 2 }, [RTSI_Trig_Direction_Register] = { 0x174, 2 }, [Interrupt_Control_Register] = { 0x176, 2 }, [AI_Output_Control_Register] = { 0x178, 2 }, @@ -542,7 +542,7 @@ static inline void ni_set_bitfield(struct comedi_device *dev, int reg, devpriv->int_b_enable_reg |= bit_values & bit_mask; ni_stc_writew(dev, devpriv->int_b_enable_reg, reg); break; - case IO_Bidirection_Pin_Register: + case NISTC_IO_BIDIR_PIN_REG: devpriv->io_bidirection_pin_reg &= ~bit_mask; devpriv->io_bidirection_pin_reg |= bit_values & bit_mask; ni_stc_writew(dev, devpriv->io_bidirection_pin_reg, reg); @@ -4434,10 +4434,10 @@ static int ni_pfi_insn_config(struct comedi_device *dev, switch (data[0]) { case COMEDI_OUTPUT: - ni_set_bits(dev, IO_Bidirection_Pin_Register, 1 << chan, 1); + ni_set_bits(dev, NISTC_IO_BIDIR_PIN_REG, 1 << chan, 1); break; case COMEDI_INPUT: - ni_set_bits(dev, IO_Bidirection_Pin_Register, 1 << chan, 0); + ni_set_bits(dev, NISTC_IO_BIDIR_PIN_REG, 1 << chan, 0); break; case INSN_CONFIG_DIO_QUERY: data[1] = @@ -5303,7 +5303,7 @@ static int ni_E_init(struct comedi_device *dev, } s->insn_config = ni_pfi_insn_config; - ni_set_bits(dev, IO_Bidirection_Pin_Register, ~0, 0); + ni_set_bits(dev, NISTC_IO_BIDIR_PIN_REG, ~0, 0); /* cs5529 calibration adc */ s = &dev->subdevices[NI_CS5529_CALIBRATION_SUBDEV]; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 907bf2a196d3..e6be68cf47a0 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -276,6 +276,8 @@ #define NISTC_CLK_FOUT_TO_DIVIDER(x) (((x) >> 0) & 0xf) #define NISTC_CLK_FOUT_DIVIDER_MASK NISTC_CLK_FOUT_DIVIDER(0xf) +#define NISTC_IO_BIDIR_PIN_REG 57 + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -334,7 +336,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define IO_Bidirection_Pin_Register 57 #define RTSI_Trig_Direction_Register 58 enum RTSI_Trig_Direction_Bits { Drive_RTSI_Clock_Bit = 0x1, From e2bdb0d833655b09d7ae75b7ca4eafde22fda9a4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:13 -0700 Subject: [PATCH 0349/1163] staging: comedi: ni_stc.h: remove unreachable code in RTSI_Output_Bit() All the callers of this function check the 'channel' number with num_configurable_rtsi_channels(). This check can never occure. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_stc.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index e6be68cf47a0..e81caa88f5cf 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -352,10 +352,6 @@ static inline unsigned RTSI_Output_Bit(unsigned channel, int is_mseries) base_bit_shift = 9; max_channel = 6; } - if (channel > max_channel) { - pr_err("%s: bug, invalid RTSI_channel=%i\n", __func__, channel); - return 0; - } return 1 << (base_bit_shift + channel); } From a4f18b1c40875d199a1f7a77f08642d38c4e6b21 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:14 -0700 Subject: [PATCH 0350/1163] staging: comedi: ni_stc.h: tidy up RTSI_Trig_Direction_Register and bits Rename the CamelCase and convert the enum and inline function into defines. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 67 +++++++++---------- drivers/staging/comedi/drivers/ni_stc.h | 26 ++----- 2 files changed, 37 insertions(+), 56 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index fb1df9fc9d38..5bdfb5f060c6 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -60,7 +60,6 @@ /* A timeout count */ #define NI_TIMEOUT 1000 -static const unsigned old_RTSI_clock_channel = 7; /* Note: this table must match the ai_gain_* definitions */ static const short ni_gainlkup[][16] = { @@ -354,7 +353,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_AO_UC_LOADB_REG] = { 0x164, 4 }, [NISTC_CLK_FOUT_REG] = { 0x170, 2 }, [NISTC_IO_BIDIR_PIN_REG] = { 0x172, 2 }, - [RTSI_Trig_Direction_Register] = { 0x174, 2 }, + [NISTC_RTSI_TRIG_DIR_REG] = { 0x174, 2 }, [Interrupt_Control_Register] = { 0x176, 2 }, [AI_Output_Control_Register] = { 0x178, 2 }, [Analog_Trigger_Etc_Register] = { 0x17a, 2 }, @@ -4680,9 +4679,9 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device *dev, __func__, min_period_ns, max_period_ns); return -EINVAL; } - devpriv->rtsi_trig_direction_reg &= ~Use_RTSI_Clock_Bit; + devpriv->rtsi_trig_direction_reg &= ~NISTC_RTSI_TRIG_USE_CLK; ni_stc_writew(dev, devpriv->rtsi_trig_direction_reg, - RTSI_Trig_Direction_Register); + NISTC_RTSI_TRIG_DIR_REG); pll_control_bits = NI_M_PLL_CTRL_ENA | NI_M_PLL_CTRL_VCO_MODE_75_150MHZ; devpriv->clock_and_fout2 |= NI_M_CLK_FOUT2_TIMEBASE1_PLL | NI_M_CLK_FOUT2_TIMEBASE3_PLL; @@ -4744,9 +4743,9 @@ static int ni_set_master_clock(struct comedi_device *dev, struct ni_private *devpriv = dev->private; if (source == NI_MIO_INTERNAL_CLOCK) { - devpriv->rtsi_trig_direction_reg &= ~Use_RTSI_Clock_Bit; + devpriv->rtsi_trig_direction_reg &= ~NISTC_RTSI_TRIG_USE_CLK; ni_stc_writew(dev, devpriv->rtsi_trig_direction_reg, - RTSI_Trig_Direction_Register); + NISTC_RTSI_TRIG_DIR_REG); devpriv->clock_ns = TIMEBASE_1_NS; if (devpriv->is_m_series) { devpriv->clock_and_fout2 &= @@ -4764,10 +4763,10 @@ static int ni_set_master_clock(struct comedi_device *dev, } else { if (source == NI_MIO_RTSI_CLOCK) { devpriv->rtsi_trig_direction_reg |= - Use_RTSI_Clock_Bit; + NISTC_RTSI_TRIG_USE_CLK; ni_stc_writew(dev, devpriv->rtsi_trig_direction_reg, - RTSI_Trig_Direction_Register); + NISTC_RTSI_TRIG_DIR_REG); if (period_ns == 0) { dev_err(dev->class_dev, "we don't handle an unspecified clock period correctly yet, returning error\n"); @@ -4783,26 +4782,19 @@ static int ni_set_master_clock(struct comedi_device *dev, return 3; } -static unsigned num_configurable_rtsi_channels(struct comedi_device *dev) -{ - struct ni_private *devpriv = dev->private; - - return (devpriv->is_m_series) ? 8 : 7; -} - static int ni_valid_rtsi_output_source(struct comedi_device *dev, unsigned chan, unsigned source) { struct ni_private *devpriv = dev->private; - if (chan >= num_configurable_rtsi_channels(dev)) { - if (chan == old_RTSI_clock_channel) { + if (chan >= NISTC_RTSI_TRIG_NUM_CHAN(devpriv->is_m_series)) { + if (chan == NISTC_RTSI_TRIG_OLD_CLK_CHAN) { if (source == NI_RTSI_OUTPUT_RTSI_OSC) return 1; dev_err(dev->class_dev, "%s: invalid source for channel=%i, channel %i is always the RTSI clock for pre-m-series boards\n", - __func__, chan, old_RTSI_clock_channel); + __func__, chan, NISTC_RTSI_TRIG_OLD_CLK_CHAN); return 0; } return 0; @@ -4855,11 +4847,11 @@ static unsigned ni_get_rtsi_routing(struct comedi_device *dev, unsigned chan) if (chan < 4) { return RTSI_Trig_Output_Source(chan, devpriv->rtsi_trig_a_output_reg); - } else if (chan < num_configurable_rtsi_channels(dev)) { + } else if (chan < NISTC_RTSI_TRIG_NUM_CHAN(devpriv->is_m_series)) { return RTSI_Trig_Output_Source(chan, devpriv->rtsi_trig_b_output_reg); } else { - if (chan == old_RTSI_clock_channel) + if (chan == NISTC_RTSI_TRIG_OLD_CLK_CHAN) return NI_RTSI_OUTPUT_RTSI_OSC; dev_err(dev->class_dev, "bug! should never get here?\n"); return 0; @@ -4873,42 +4865,43 @@ static int ni_rtsi_insn_config(struct comedi_device *dev, { struct ni_private *devpriv = dev->private; unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int max_chan = NISTC_RTSI_TRIG_NUM_CHAN(devpriv->is_m_series); switch (data[0]) { case INSN_CONFIG_DIO_OUTPUT: - if (chan < num_configurable_rtsi_channels(dev)) { + if (chan < max_chan) { devpriv->rtsi_trig_direction_reg |= - RTSI_Output_Bit(chan, devpriv->is_m_series); - } else if (chan == old_RTSI_clock_channel) { + NISTC_RTSI_TRIG_DIR(chan, devpriv->is_m_series); + } else if (chan == NISTC_RTSI_TRIG_OLD_CLK_CHAN) { devpriv->rtsi_trig_direction_reg |= - Drive_RTSI_Clock_Bit; + NISTC_RTSI_TRIG_DRV_CLK; } ni_stc_writew(dev, devpriv->rtsi_trig_direction_reg, - RTSI_Trig_Direction_Register); + NISTC_RTSI_TRIG_DIR_REG); break; case INSN_CONFIG_DIO_INPUT: - if (chan < num_configurable_rtsi_channels(dev)) { + if (chan < max_chan) { devpriv->rtsi_trig_direction_reg &= - ~RTSI_Output_Bit(chan, devpriv->is_m_series); - } else if (chan == old_RTSI_clock_channel) { + ~NISTC_RTSI_TRIG_DIR(chan, devpriv->is_m_series); + } else if (chan == NISTC_RTSI_TRIG_OLD_CLK_CHAN) { devpriv->rtsi_trig_direction_reg &= - ~Drive_RTSI_Clock_Bit; + ~NISTC_RTSI_TRIG_DRV_CLK; } ni_stc_writew(dev, devpriv->rtsi_trig_direction_reg, - RTSI_Trig_Direction_Register); + NISTC_RTSI_TRIG_DIR_REG); break; case INSN_CONFIG_DIO_QUERY: - if (chan < num_configurable_rtsi_channels(dev)) { + if (chan < max_chan) { data[1] = (devpriv->rtsi_trig_direction_reg & - RTSI_Output_Bit(chan, devpriv->is_m_series)) + NISTC_RTSI_TRIG_DIR(chan, devpriv->is_m_series)) ? INSN_CONFIG_DIO_OUTPUT : INSN_CONFIG_DIO_INPUT; - } else if (chan == old_RTSI_clock_channel) { - data[1] = - (devpriv->rtsi_trig_direction_reg & - Drive_RTSI_Clock_Bit) - ? INSN_CONFIG_DIO_OUTPUT : INSN_CONFIG_DIO_INPUT; + } else if (chan == NISTC_RTSI_TRIG_OLD_CLK_CHAN) { + data[1] = (devpriv->rtsi_trig_direction_reg & + NISTC_RTSI_TRIG_DRV_CLK) + ? INSN_CONFIG_DIO_OUTPUT + : INSN_CONFIG_DIO_INPUT; } return 2; case INSN_CONFIG_SET_CLOCK_SRC: diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index e81caa88f5cf..8a3052e2aca3 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -278,6 +278,13 @@ #define NISTC_IO_BIDIR_PIN_REG 57 +#define NISTC_RTSI_TRIG_DIR_REG 58 +#define NISTC_RTSI_TRIG_OLD_CLK_CHAN 7 +#define NISTC_RTSI_TRIG_NUM_CHAN(_m) ((_m) ? 8 : 7) +#define NISTC_RTSI_TRIG_DIR(_c, _m) ((_m) ? BIT(8 + (_c)) : BIT(7 + (_c))) +#define NISTC_RTSI_TRIG_USE_CLK BIT(1) +#define NISTC_RTSI_TRIG_DRV_CLK BIT(0) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -336,25 +343,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define RTSI_Trig_Direction_Register 58 -enum RTSI_Trig_Direction_Bits { - Drive_RTSI_Clock_Bit = 0x1, - Use_RTSI_Clock_Bit = 0x2, -}; -static inline unsigned RTSI_Output_Bit(unsigned channel, int is_mseries) -{ - unsigned max_channel; - unsigned base_bit_shift; - if (is_mseries) { - base_bit_shift = 8; - max_channel = 7; - } else { - base_bit_shift = 9; - max_channel = 6; - } - return 1 << (base_bit_shift + channel); -} - #define Interrupt_Control_Register 59 #define Interrupt_B_Enable _bit15 #define Interrupt_B_Output_Select(x) ((x)<<12) From d8f62c463867293ed37fd9ac25dfc2338dc01594 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:15 -0700 Subject: [PATCH 0351/1163] staging: comedi: ni_stc.h: tidy up Interrupt_Control_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 15 +++++++------- drivers/staging/comedi/drivers/ni_pcimio.c | 2 +- drivers/staging/comedi/drivers/ni_stc.h | 20 +++++++++---------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 5bdfb5f060c6..fcb8362fda80 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -354,7 +354,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_CLK_FOUT_REG] = { 0x170, 2 }, [NISTC_IO_BIDIR_PIN_REG] = { 0x172, 2 }, [NISTC_RTSI_TRIG_DIR_REG] = { 0x174, 2 }, - [Interrupt_Control_Register] = { 0x176, 2 }, + [NISTC_INT_CTRL_REG] = { 0x176, 2 }, [AI_Output_Control_Register] = { 0x178, 2 }, [Analog_Trigger_Etc_Register] = { 0x17a, 2 }, [AI_START_STOP_Select_Register] = { 0x17c, 2 }, @@ -5389,12 +5389,13 @@ static int ni_E_init(struct comedi_device *dev, if (dev->irq) { ni_stc_writew(dev, - (irq_polarity ? Interrupt_Output_Polarity : 0) | - (Interrupt_Output_On_3_Pins & 0) | - Interrupt_A_Enable | Interrupt_B_Enable | - Interrupt_A_Output_Select(interrupt_pin) | - Interrupt_B_Output_Select(interrupt_pin), - Interrupt_Control_Register); + (irq_polarity ? NISTC_INT_CTRL_INT_POL : 0) | + (NISTC_INT_CTRL_3PIN_INT & 0) | + NISTC_INT_CTRL_INTA_ENA | + NISTC_INT_CTRL_INTB_ENA | + NISTC_INT_CTRL_INTA_SEL(interrupt_pin) | + NISTC_INT_CTRL_INTB_SEL(interrupt_pin), + NISTC_INT_CTRL_REG); } /* DMA setup */ diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c b/drivers/staging/comedi/drivers/ni_pcimio.c index 1481f71a31b1..9f4d4b1f9962 100644 --- a/drivers/staging/comedi/drivers/ni_pcimio.c +++ b/drivers/staging/comedi/drivers/ni_pcimio.c @@ -1085,7 +1085,7 @@ static void init_6143(struct comedi_device *dev) struct ni_private *devpriv = dev->private; /* Disable interrupts */ - ni_stc_writew(dev, 0, Interrupt_Control_Register); + ni_stc_writew(dev, 0, NISTC_INT_CTRL_REG); /* Initialise 6143 AI specific bits */ diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 8a3052e2aca3..5004691e7e88 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -285,6 +285,16 @@ #define NISTC_RTSI_TRIG_USE_CLK BIT(1) #define NISTC_RTSI_TRIG_DRV_CLK BIT(0) +#define NISTC_INT_CTRL_REG 59 +#define NISTC_INT_CTRL_INTB_ENA BIT(15) +#define NISTC_INT_CTRL_INTB_SEL(x) (((x) & 0x7) << 12) +#define NISTC_INT_CTRL_INTA_ENA BIT(11) +#define NISTC_INT_CTRL_INTA_SEL(x) (((x) & 0x7) << 8) +#define NISTC_INT_CTRL_PASSTHRU0_POL BIT(3) +#define NISTC_INT_CTRL_PASSTHRU1_POL BIT(2) +#define NISTC_INT_CTRL_3PIN_INT BIT(1) +#define NISTC_INT_CTRL_INT_POL BIT(0) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -343,16 +353,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define Interrupt_Control_Register 59 -#define Interrupt_B_Enable _bit15 -#define Interrupt_B_Output_Select(x) ((x)<<12) -#define Interrupt_A_Enable _bit11 -#define Interrupt_A_Output_Select(x) ((x)<<8) -#define Pass_Thru_0_Interrupt_Polarity _bit3 -#define Pass_Thru_1_Interrupt_Polarity _bit2 -#define Interrupt_Output_On_3_Pins _bit1 -#define Interrupt_Output_Polarity _bit0 - #define AI_Output_Control_Register 60 #define AI_START_Output_Select _bit10 #define AI_SCAN_IN_PROG_Output_Select(x) (((x) & 0x3) << 8) From aa9d73ba831eef18624cb7b8288987b3bfd4dac8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:16 -0700 Subject: [PATCH 0352/1163] staging: comedi: ni_stc.h: tidy up AI_Output_Control_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Tidy up the programming of this register un ni_ai_reset() by using a local variable to set the common bits then writing the register in the common code path. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 47 ++++++------------- drivers/staging/comedi/drivers/ni_stc.h | 30 +++++------- 2 files changed, 26 insertions(+), 51 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index fcb8362fda80..20557b5be996 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -355,7 +355,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_IO_BIDIR_PIN_REG] = { 0x172, 2 }, [NISTC_RTSI_TRIG_DIR_REG] = { 0x174, 2 }, [NISTC_INT_CTRL_REG] = { 0x176, 2 }, - [AI_Output_Control_Register] = { 0x178, 2 }, + [NISTC_AI_OUT_CTRL_REG] = { 0x178, 2 }, [Analog_Trigger_Etc_Register] = { 0x17a, 2 }, [AI_START_STOP_Select_Register] = { 0x17c, 2 }, [AI_Trigger_Select_Register] = { 0x17e, 2 }, @@ -1608,6 +1608,7 @@ static int ni_ao_setup_MITE_dma(struct comedi_device *dev) static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s) { struct ni_private *devpriv = dev->private; + unsigned ai_out_ctrl; ni_release_ai_mite_channel(dev); /* ai configuration */ @@ -1633,65 +1634,45 @@ static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s) ni_stc_writew(dev, 0, NISTC_AI_MODE2_REG); /* generate FIFO interrupts on non-empty */ ni_stc_writew(dev, (0 << 6) | 0x0000, AI_Mode_3_Register); + + ai_out_ctrl = NISTC_AI_OUT_CTRL_SCAN_IN_PROG_SEL(3) | + NISTC_AI_OUT_CTRL_EXTMUX_CLK_SEL(0) | + NISTC_AI_OUT_CTRL_LOCALMUX_CLK_SEL(2) | + NISTC_AI_OUT_CTRL_SC_TC_SEL(3); if (devpriv->is_611x) { ni_stc_writew(dev, AI_SHIFTIN_Pulse_Width | AI_SOC_Polarity | AI_LOCALMUX_CLK_Pulse_Width, AI_Personal_Register); - ni_stc_writew(dev, - AI_SCAN_IN_PROG_Output_Select(3) | - AI_EXTMUX_CLK_Output_Select(0) | - AI_LOCALMUX_CLK_Output_Select(2) | - AI_SC_TC_Output_Select(3) | - AI_CONVERT_Output_Select - (AI_CONVERT_Output_Enable_High), - AI_Output_Control_Register); + ai_out_ctrl |= NISTC_AI_OUT_CTRL_CONVERT_HIGH; } else if (devpriv->is_6143) { ni_stc_writew(dev, AI_SHIFTIN_Pulse_Width | AI_SOC_Polarity | AI_LOCALMUX_CLK_Pulse_Width, AI_Personal_Register); - ni_stc_writew(dev, - AI_SCAN_IN_PROG_Output_Select(3) | - AI_EXTMUX_CLK_Output_Select(0) | - AI_LOCALMUX_CLK_Output_Select(2) | - AI_SC_TC_Output_Select(3) | - AI_CONVERT_Output_Select - (AI_CONVERT_Output_Enable_Low), - AI_Output_Control_Register); + ai_out_ctrl |= NISTC_AI_OUT_CTRL_CONVERT_LOW; } else { - unsigned ai_output_control_bits; - ni_stc_writew(dev, AI_SHIFTIN_Pulse_Width | AI_SOC_Polarity | AI_CONVERT_Pulse_Width | AI_LOCALMUX_CLK_Pulse_Width, AI_Personal_Register); - ai_output_control_bits = - AI_SCAN_IN_PROG_Output_Select(3) | - AI_EXTMUX_CLK_Output_Select(0) | - AI_LOCALMUX_CLK_Output_Select(2) | - AI_SC_TC_Output_Select(3); if (devpriv->is_622x) - ai_output_control_bits |= - AI_CONVERT_Output_Select - (AI_CONVERT_Output_Enable_High); + ai_out_ctrl |= NISTC_AI_OUT_CTRL_CONVERT_HIGH; else - ai_output_control_bits |= - AI_CONVERT_Output_Select - (AI_CONVERT_Output_Enable_Low); - ni_stc_writew(dev, ai_output_control_bits, - AI_Output_Control_Register); + ai_out_ctrl |= NISTC_AI_OUT_CTRL_CONVERT_LOW; } + ni_stc_writew(dev, ai_out_ctrl, NISTC_AI_OUT_CTRL_REG); + /* the following registers should not be changed, because there * are no backup registers in devpriv. If you want to change * any of these, add a backup register and other appropriate code: * NISTC_AI_MODE1_REG * AI_Mode_3_Register * AI_Personal_Register - * AI_Output_Control_Register + * NISTC_AI_OUT_CTRL_REG */ /* clear interrupts */ diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 5004691e7e88..69156afa3098 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -295,6 +295,18 @@ #define NISTC_INT_CTRL_3PIN_INT BIT(1) #define NISTC_INT_CTRL_INT_POL BIT(0) +#define NISTC_AI_OUT_CTRL_REG 60 +#define NISTC_AI_OUT_CTRL_START_SEL BIT(10) +#define NISTC_AI_OUT_CTRL_SCAN_IN_PROG_SEL(x) (((x) & 0x3) << 8) +#define NISTC_AI_OUT_CTRL_EXTMUX_CLK_SEL(x) (((x) & 0x3) << 6) +#define NISTC_AI_OUT_CTRL_LOCALMUX_CLK_SEL(x) (((x) & 0x3) << 4) +#define NISTC_AI_OUT_CTRL_SC_TC_SEL(x) (((x) & 0x3) << 2) +#define NISTC_AI_OUT_CTRL_CONVERT_SEL(x) (((x) & 0x3) << 0) +#define NISTC_AI_OUT_CTRL_CONVERT_HIGH_Z NISTC_AI_OUT_CTRL_CONVERT_SEL(0) +#define NISTC_AI_OUT_CTRL_CONVERT_GND NISTC_AI_OUT_CTRL_CONVERT_SEL(1) +#define NISTC_AI_OUT_CTRL_CONVERT_LOW NISTC_AI_OUT_CTRL_CONVERT_SEL(2) +#define NISTC_AI_OUT_CTRL_CONVERT_HIGH NISTC_AI_OUT_CTRL_CONVERT_SEL(3) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -353,24 +365,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define AI_Output_Control_Register 60 -#define AI_START_Output_Select _bit10 -#define AI_SCAN_IN_PROG_Output_Select(x) (((x) & 0x3) << 8) -#define AI_EXTMUX_CLK_Output_Select(x) (((x) & 0x3) << 6) -#define AI_LOCALMUX_CLK_Output_Select(x) ((x)<<4) -#define AI_SC_TC_Output_Select(x) ((x)<<2) -enum ai_convert_output_selection { - AI_CONVERT_Output_High_Z = 0, - AI_CONVERT_Output_Ground = 1, - AI_CONVERT_Output_Enable_Low = 2, - AI_CONVERT_Output_Enable_High = 3 -}; -static unsigned AI_CONVERT_Output_Select(enum ai_convert_output_selection - selection) -{ - return selection & 0x3; -} - #define AI_START_STOP_Select_Register 62 #define AI_START_Polarity _bit15 #define AI_STOP_Polarity _bit14 From 27cf6c02abc6788a71c1e939fdab1418eb6c3bcc Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:17 -0700 Subject: [PATCH 0353/1163] staging: comedi: ni_stc.h: tidy up Analog_Trigger_Etc_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 7 +++---- drivers/staging/comedi/drivers/ni_stc.h | 19 +++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 20557b5be996..265f9baffe18 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -356,7 +356,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_RTSI_TRIG_DIR_REG] = { 0x174, 2 }, [NISTC_INT_CTRL_REG] = { 0x176, 2 }, [NISTC_AI_OUT_CTRL_REG] = { 0x178, 2 }, - [Analog_Trigger_Etc_Register] = { 0x17a, 2 }, + [NISTC_ATRIG_ETC_REG] = { 0x17a, 2 }, [AI_START_STOP_Select_Register] = { 0x17c, 2 }, [AI_Trigger_Select_Register] = { 0x17e, 2 }, [AI_DIV_Load_A_Register] = { 0x180, 4 }, @@ -2262,9 +2262,8 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* disable analog triggering for now, since it * interferes with the use of pfi0 */ - devpriv->an_trig_etc_reg &= ~Analog_Trigger_Enable; - ni_stc_writew(dev, devpriv->an_trig_etc_reg, - Analog_Trigger_Etc_Register); + devpriv->an_trig_etc_reg &= ~NISTC_ATRIG_ETC_ENA; + ni_stc_writew(dev, devpriv->an_trig_etc_reg, NISTC_ATRIG_ETC_REG); switch (cmd->start_src) { case TRIG_INT: diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 69156afa3098..2b290063bce4 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -307,6 +307,15 @@ #define NISTC_AI_OUT_CTRL_CONVERT_LOW NISTC_AI_OUT_CTRL_CONVERT_SEL(2) #define NISTC_AI_OUT_CTRL_CONVERT_HIGH NISTC_AI_OUT_CTRL_CONVERT_SEL(3) +#define NISTC_ATRIG_ETC_REG 61 +#define NISTC_ATRIG_ETC_GPFO_1_ENA BIT(15) +#define NISTC_ATRIG_ETC_GPFO_0_ENA BIT(14) +#define NISTC_ATRIG_ETC_GPFO_0_SEL(x) (((x) & 0x3) << 11) +#define NISTC_ATRIG_ETC_GPFO_1_SEL BIT(7) +#define NISTC_ATRIG_ETC_DRV BIT(4) +#define NISTC_ATRIG_ETC_ENA BIT(3) +#define NISTC_ATRIG_ETC_MODE(x) (((x) & 0x7) << 0) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -587,7 +596,6 @@ static unsigned AO_UPDATE_Output_Select(enum ao_update_output_selection #define G_Save_Register_High(a) (12+(a)*2) #define G_Save_Register_Low(a) (13+(a)*2) #define G_Status_Register 4 -#define Analog_Trigger_Etc_Register 61 /* command register */ #define G_Disarm_Copy _bit15 /* strobe */ @@ -657,15 +665,6 @@ static unsigned AO_UPDATE_Output_Select(enum ao_update_output_selection /* general purpose counter timer */ #define G_Autoincrement(a) ((a)<<0) -/*Analog_Trigger_Etc_Register*/ -#define Analog_Trigger_Mode(x) ((x) & 0x7) -#define Analog_Trigger_Enable _bit3 -#define Analog_Trigger_Drive _bit4 -#define GPFO_1_Output_Select _bit7 -#define GPFO_0_Output_Select(a) ((a)<<11) -#define GPFO_0_Output_Enable _bit14 -#define GPFO_1_Output_Enable _bit15 - /* Additional windowed registers unique to E series */ /* 16 bit registers shadowed from DAQ-STC */ From 3e9088929f06a42f2ab4085562caefbd36a8324f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:18 -0700 Subject: [PATCH 0354/1163] staging: comedi: ni_stc.h: tidy up AI_START_STOP_Select_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 61 +++++++++---------- drivers/staging/comedi/drivers/ni_stc.h | 20 +++--- 2 files changed, 40 insertions(+), 41 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 265f9baffe18..e2e3535aa77a 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -357,7 +357,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_INT_CTRL_REG] = { 0x176, 2 }, [NISTC_AI_OUT_CTRL_REG] = { 0x178, 2 }, [NISTC_ATRIG_ETC_REG] = { 0x17a, 2 }, - [AI_START_STOP_Select_Register] = { 0x17c, 2 }, + [NISTC_AI_START_STOP_REG] = { 0x17c, 2 }, [AI_Trigger_Select_Register] = { 0x17e, 2 }, [AI_DIV_Load_A_Register] = { 0x180, 4 }, [AO_Start_Select_Register] = { 0x184, 2 }, @@ -2295,13 +2295,15 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ni_stc_writew(dev, mode2, NISTC_AI_MODE2_REG); if (cmd->chanlist_len == 1 || devpriv->is_611x || devpriv->is_6143) { - start_stop_select |= AI_STOP_Polarity; - start_stop_select |= AI_STOP_Select(31); /* logic low */ - start_stop_select |= AI_STOP_Sync; + /* logic low */ + start_stop_select |= NISTC_AI_STOP_POLARITY | + NISTC_AI_STOP_SEL(31) | + NISTC_AI_STOP_SYNC; } else { - start_stop_select |= AI_STOP_Select(19); /* ai configuration memory */ + /* ai configuration memory */ + start_stop_select |= NISTC_AI_STOP_SEL(19); } - ni_stc_writew(dev, start_stop_select, AI_START_STOP_Select_Register); + ni_stc_writew(dev, start_stop_select, NISTC_AI_START_STOP_REG); devpriv->ai_cmd2 = 0; switch (cmd->stop_src) { @@ -2327,8 +2329,8 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) interrupt_a_enable |= AI_STOP_Interrupt_Enable; /* this is required to get the last sample for chanlist_len > 1, not sure why */ if (cmd->chanlist_len > 1) - start_stop_select |= - AI_STOP_Polarity | AI_STOP_Edge; + start_stop_select |= NISTC_AI_STOP_POLARITY | + NISTC_AI_STOP_EDGE; } break; case TRIG_NONE: @@ -2348,22 +2350,21 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) switch (cmd->scan_begin_src) { case TRIG_TIMER: /* - stop bits for non 611x boards - AI_SI_Special_Trigger_Delay=0 - NISTC_AI_MODE2_PRE_TRIGGER=0 - AI_START_STOP_Select_Register: - AI_START_Polarity=0 (?) rising edge - AI_START_Edge=1 edge triggered - AI_START_Sync=1 (?) - AI_START_Select=0 SI_TC - AI_STOP_Polarity=0 rising edge - AI_STOP_Edge=0 level - AI_STOP_Sync=1 - AI_STOP_Select=19 external pin (configuration mem) + * stop bits for non 611x boards + * AI_SI_Special_Trigger_Delay=0 + * NISTC_AI_MODE2_PRE_TRIGGER=0 + * NISTC_AI_START_STOP_REG: + * NISTC_AI_START_POLARITY=0 (?) rising edge + * NISTC_AI_START_EDGE=1 edge triggered + * NISTC_AI_START_SYNC=1 (?) + * NISTC_AI_START_SEL=0 SI_TC + * NISTC_AI_STOP_POLARITY=0 rising edge + * NISTC_AI_STOP_EDGE=0 level + * NISTC_AI_STOP_SYNC=1 + * NISTC_AI_STOP_SEL=19 external pin (configuration mem) */ - start_stop_select |= AI_START_Edge | AI_START_Sync; - ni_stc_writew(dev, start_stop_select, - AI_START_STOP_Select_Register); + start_stop_select |= NISTC_AI_START_EDGE | NISTC_AI_START_SYNC; + ni_stc_writew(dev, start_stop_select, NISTC_AI_START_STOP_REG); mode2 &= ~NISTC_AI_MODE2_SI_INIT_LOAD_SRC; /* A */ mode2 |= NISTC_AI_MODE2_SI_RELOAD_MODE(0); @@ -2378,18 +2379,16 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) break; case TRIG_EXT: if (cmd->scan_begin_arg & CR_EDGE) - start_stop_select |= AI_START_Edge; - /* AI_START_Polarity==1 is falling edge */ - if (cmd->scan_begin_arg & CR_INVERT) - start_stop_select |= AI_START_Polarity; + start_stop_select |= NISTC_AI_START_EDGE; + if (cmd->scan_begin_arg & CR_INVERT) /* falling edge */ + start_stop_select |= NISTC_AI_START_POLARITY; if (cmd->scan_begin_src != cmd->convert_src || (cmd->scan_begin_arg & ~CR_EDGE) != (cmd->convert_arg & ~CR_EDGE)) - start_stop_select |= AI_START_Sync; + start_stop_select |= NISTC_AI_START_SYNC; start_stop_select |= - AI_START_Select(1 + CR_CHAN(cmd->scan_begin_arg)); - ni_stc_writew(dev, start_stop_select, - AI_START_STOP_Select_Register); + NISTC_AI_START_SEL(1 + CR_CHAN(cmd->scan_begin_arg)); + ni_stc_writew(dev, start_stop_select, NISTC_AI_START_STOP_REG); break; } diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 2b290063bce4..8710dafb95c0 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -316,6 +316,16 @@ #define NISTC_ATRIG_ETC_ENA BIT(3) #define NISTC_ATRIG_ETC_MODE(x) (((x) & 0x7) << 0) +#define NISTC_AI_START_STOP_REG 62 +#define NISTC_AI_START_POLARITY BIT(15) +#define NISTC_AI_STOP_POLARITY BIT(14) +#define NISTC_AI_STOP_SYNC BIT(13) +#define NISTC_AI_STOP_EDGE BIT(12) +#define NISTC_AI_STOP_SEL(x) (((x) & 0x1f) << 7) +#define NISTC_AI_START_SYNC BIT(6) +#define NISTC_AI_START_EDGE BIT(5) +#define NISTC_AI_START_SEL(x) (((x) & 0x1f) << 0) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -374,16 +384,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define AI_START_STOP_Select_Register 62 -#define AI_START_Polarity _bit15 -#define AI_STOP_Polarity _bit14 -#define AI_STOP_Sync _bit13 -#define AI_STOP_Edge _bit12 -#define AI_STOP_Select(a) (((a) & 0x1f)<<7) -#define AI_START_Sync _bit6 -#define AI_START_Edge _bit5 -#define AI_START_Select(a) ((a) & 0x1f) - #define AI_Trigger_Select_Register 63 #define AI_START1_Polarity _bit15 #define AI_START2_Polarity _bit14 From f878071a44d61ac52765c7b0c23ddb1170044174 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:19 -0700 Subject: [PATCH 0355/1163] staging: comedi: ni_stc.h: tidy up AI_Trigger_Select_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Tidy up ni_ai_cmd() by using a local var to set the common bits and programming the register in the common code path. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 31 +++++++++---------- drivers/staging/comedi/drivers/ni_stc.h | 20 ++++++------ 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index e2e3535aa77a..880c50f8ec92 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -358,7 +358,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_AI_OUT_CTRL_REG] = { 0x178, 2 }, [NISTC_ATRIG_ETC_REG] = { 0x17a, 2 }, [NISTC_AI_START_STOP_REG] = { 0x17c, 2 }, - [AI_Trigger_Select_Register] = { 0x17e, 2 }, + [NISTC_AI_TRIG_SEL_REG] = { 0x17e, 2 }, [AI_DIV_Load_A_Register] = { 0x180, 4 }, [AO_Start_Select_Register] = { 0x184, 2 }, [AO_Trigger_Select_Register] = { 0x186, 2 }, @@ -2248,6 +2248,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) int start_stop_select = 0; unsigned int stop_count; int interrupt_a_enable = 0; + unsigned ai_trig; if (dev->irq == 0) { dev_err(dev->class_dev, "cannot run command without an irq\n"); @@ -2265,29 +2266,25 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->an_trig_etc_reg &= ~NISTC_ATRIG_ETC_ENA; ni_stc_writew(dev, devpriv->an_trig_etc_reg, NISTC_ATRIG_ETC_REG); + ai_trig = NISTC_AI_TRIG_START2_SEL(0) | NISTC_AI_TRIG_START1_SYNC; switch (cmd->start_src) { case TRIG_INT: case TRIG_NOW: - ni_stc_writew(dev, - AI_START2_Select(0) | - AI_START1_Sync | AI_START1_Edge | - AI_START1_Select(0), - AI_Trigger_Select_Register); + ai_trig |= NISTC_AI_TRIG_START1_EDGE | + NISTC_AI_TRIG_START1_SEL(0), + NISTC_AI_TRIG_SEL_REG; break; case TRIG_EXT: - { - int chan = CR_CHAN(cmd->start_arg); - unsigned int bits = AI_START2_Select(0) | - AI_START1_Sync | AI_START1_Select(chan + 1); + ai_trig |= NISTC_AI_TRIG_START1_SEL(CR_CHAN(cmd->start_arg) + + 1); - if (cmd->start_arg & CR_INVERT) - bits |= AI_START1_Polarity; - if (cmd->start_arg & CR_EDGE) - bits |= AI_START1_Edge; - ni_stc_writew(dev, bits, AI_Trigger_Select_Register); - break; - } + if (cmd->start_arg & CR_INVERT) + ai_trig |= NISTC_AI_TRIG_START1_POLARITY; + if (cmd->start_arg & CR_EDGE) + ai_trig |= NISTC_AI_TRIG_START1_EDGE; + break; } + ni_stc_writew(dev, ai_trig, NISTC_AI_TRIG_SEL_REG); mode2 &= ~NISTC_AI_MODE2_PRE_TRIGGER; mode2 &= ~NISTC_AI_MODE2_SC_INIT_LOAD_SRC; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 8710dafb95c0..709c8bd5c9f6 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -326,6 +326,16 @@ #define NISTC_AI_START_EDGE BIT(5) #define NISTC_AI_START_SEL(x) (((x) & 0x1f) << 0) +#define NISTC_AI_TRIG_SEL_REG 63 +#define NISTC_AI_TRIG_START1_POLARITY BIT(15) +#define NISTC_AI_TRIG_START2_POLARITY BIT(14) +#define NISTC_AI_TRIG_START2_SYNC BIT(13) +#define NISTC_AI_TRIG_START2_EDGE BIT(12) +#define NISTC_AI_TRIG_START2_SEL(x) (((x) & 0x1f) << 7) +#define NISTC_AI_TRIG_START1_SYNC BIT(6) +#define NISTC_AI_TRIG_START1_EDGE BIT(5) +#define NISTC_AI_TRIG_START1_SEL(x) (((x) & 0x1f) << 0) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -384,16 +394,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define AI_Trigger_Select_Register 63 -#define AI_START1_Polarity _bit15 -#define AI_START2_Polarity _bit14 -#define AI_START2_Sync _bit13 -#define AI_START2_Edge _bit12 -#define AI_START2_Select(a) (((a) & 0x1f) << 7) -#define AI_START1_Sync _bit6 -#define AI_START1_Edge _bit5 -#define AI_START1_Select(a) ((a) & 0x1f) - #define AI_DIV_Load_A_Register 64 #define AO_Start_Select_Register 66 From af5102a77e6ef0d40611f5255faf3cd860180c29 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:20 -0700 Subject: [PATCH 0356/1163] staging: comedi: ni_stc.h: tidy up AI_DIV_Load_A_Register Rename the CamelCase. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 2 +- drivers/staging/comedi/drivers/ni_stc.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 880c50f8ec92..ba1c991408d3 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -359,7 +359,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_ATRIG_ETC_REG] = { 0x17a, 2 }, [NISTC_AI_START_STOP_REG] = { 0x17c, 2 }, [NISTC_AI_TRIG_SEL_REG] = { 0x17e, 2 }, - [AI_DIV_Load_A_Register] = { 0x180, 4 }, + [NISTC_AI_DIV_LOADA_REG] = { 0x180, 4 }, [AO_Start_Select_Register] = { 0x184, 2 }, [AO_Trigger_Select_Register] = { 0x186, 2 }, [G_Autoincrement_Register(0)] = { 0x188, 2 }, diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 709c8bd5c9f6..4b4cc9fd88f4 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -336,6 +336,8 @@ #define NISTC_AI_TRIG_START1_EDGE BIT(5) #define NISTC_AI_TRIG_START1_SEL(x) (((x) & 0x1f) << 0) +#define NISTC_AI_DIV_LOADA_REG 64 + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -394,8 +396,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define AI_DIV_Load_A_Register 64 - #define AO_Start_Select_Register 66 #define AO_UI2_Software_Gate _bit15 #define AO_UI2_External_Gate_Polarity _bit14 From 2b6285dab7ca8ac069f4087172ebb0c1aa908777 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:21 -0700 Subject: [PATCH 0357/1163] staging: comedi: ni_stc.h: tidy up AO_Start_Select_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 6 +++--- drivers/staging/comedi/drivers/ni_stc.h | 20 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index ba1c991408d3..2522bab8ca13 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -360,7 +360,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_AI_START_STOP_REG] = { 0x17c, 2 }, [NISTC_AI_TRIG_SEL_REG] = { 0x17e, 2 }, [NISTC_AI_DIV_LOADA_REG] = { 0x180, 4 }, - [AO_Start_Select_Register] = { 0x184, 2 }, + [NISTC_AO_START_SEL_REG] = { 0x184, 2 }, [AO_Trigger_Select_Register] = { 0x186, 2 }, [G_Autoincrement_Register(0)] = { 0x188, 2 }, [G_Autoincrement_Register(1)] = { 0x18a, 2 }, @@ -3082,7 +3082,7 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) #endif ni_stc_writew(dev, bits, AO_Personal_Register); /* enable sending of ao dma requests */ - ni_stc_writew(dev, AO_AOFREQ_Enable, AO_Start_Select_Register); + ni_stc_writew(dev, NISTC_AO_START_AOFREQ_ENA, NISTC_AO_START_SEL_REG); ni_stc_writew(dev, AO_Configuration_End, Joint_Reset_Register); @@ -3195,7 +3195,7 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s) ni_stc_writew(dev, AO_BC_Source_Select | AO_UPDATE_Pulse_Width | AO_TMRDACWR_Pulse_Width, AO_Personal_Register); ni_stc_writew(dev, 0, AO_Output_Control_Register); - ni_stc_writew(dev, 0, AO_Start_Select_Register); + ni_stc_writew(dev, 0, NISTC_AO_START_SEL_REG); devpriv->ao_cmd1 = 0; ni_stc_writew(dev, devpriv->ao_cmd1, NISTC_AO_CMD1_REG); devpriv->ao_cmd2 = 0; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 4b4cc9fd88f4..fc80b17430bf 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -338,6 +338,16 @@ #define NISTC_AI_DIV_LOADA_REG 64 +#define NISTC_AO_START_SEL_REG 66 +#define NISTC_AO_START_UI2_SW_GATE BIT(15) +#define NISTC_AO_START_UI2_EXT_GATE_POL BIT(14) +#define NISTC_AO_START_POLARITY BIT(13) +#define NISTC_AO_START_AOFREQ_ENA BIT(12) +#define NISTC_AO_START_UI2_EXT_GATE_SEL(x) (((x) & 0x1f) << 7) +#define NISTC_AO_START_SYNC BIT(6) +#define NISTC_AO_START_EDGE BIT(5) +#define NISTC_AO_START_SEL(x) (((x) & 0x1f) << 0) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -396,16 +406,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define AO_Start_Select_Register 66 -#define AO_UI2_Software_Gate _bit15 -#define AO_UI2_External_Gate_Polarity _bit14 -#define AO_START_Polarity _bit13 -#define AO_AOFREQ_Enable _bit12 -#define AO_UI2_External_Gate_Select(a) (((a) & 0x1f) << 7) -#define AO_START_Sync _bit6 -#define AO_START_Edge _bit5 -#define AO_START_Select(a) ((a) & 0x1f) - #define AO_Trigger_Select_Register 67 #define AO_UI2_External_Gate_Enable _bit15 #define AO_Delayed_START1 _bit14 From f21844d33b6de37aa105de3e2e50dd944dd3d2b0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:22 -0700 Subject: [PATCH 0358/1163] staging: comedi: ni_stc.h: tidy up AO_Trigger_Select_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Tidy up the ni_ao_cmd() by using a local var to mask/set the bits then programming the register in the common code path. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 36 +++++++++++-------- drivers/staging/comedi/drivers/ni_stc.h | 21 +++++------ 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 2522bab8ca13..0634babd2cf2 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -361,7 +361,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_AI_TRIG_SEL_REG] = { 0x17e, 2 }, [NISTC_AI_DIV_LOADA_REG] = { 0x180, 4 }, [NISTC_AO_START_SEL_REG] = { 0x184, 2 }, - [AO_Trigger_Select_Register] = { 0x186, 2 }, + [NISTC_AO_TRIG_SEL_REG] = { 0x186, 2 }, [G_Autoincrement_Register(0)] = { 0x188, 2 }, [G_Autoincrement_Register(1)] = { 0x18a, 2 }, [AO_Mode_3_Register] = { 0x18c, 2 }, @@ -2902,6 +2902,7 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) int bits; int i; unsigned trigvar; + unsigned val; if (dev->irq == 0) { dev_err(dev->class_dev, "cannot run command without an irq\n"); @@ -2936,29 +2937,36 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ao_mode1 |= NISTC_AO_MODE1_TRIGGER_ONCE; } ni_stc_writew(dev, devpriv->ao_mode1, NISTC_AO_MODE1_REG); + + val = devpriv->ao_trigger_select; switch (cmd->start_src) { case TRIG_INT: case TRIG_NOW: - devpriv->ao_trigger_select &= - ~(AO_START1_Polarity | AO_START1_Select(-1)); - devpriv->ao_trigger_select |= AO_START1_Edge | AO_START1_Sync; - ni_stc_writew(dev, devpriv->ao_trigger_select, - AO_Trigger_Select_Register); + val &= ~(NISTC_AO_TRIG_START1_POLARITY | + NISTC_AO_TRIG_START1_SEL_MASK); + val |= NISTC_AO_TRIG_START1_EDGE | + NISTC_AO_TRIG_START1_SYNC; break; case TRIG_EXT: - devpriv->ao_trigger_select = - AO_START1_Select(CR_CHAN(cmd->start_arg) + 1); - if (cmd->start_arg & CR_INVERT) - devpriv->ao_trigger_select |= AO_START1_Polarity; /* 0=active high, 1=active low. see daq-stc 3-24 (p186) */ - if (cmd->start_arg & CR_EDGE) - devpriv->ao_trigger_select |= AO_START1_Edge; /* 0=edge detection disabled, 1=enabled */ + val = NISTC_AO_TRIG_START1_SEL(CR_CHAN(cmd->start_arg) + 1); + if (cmd->start_arg & CR_INVERT) { + /* 0=active high, 1=active low. see daq-stc 3-24 (p186) */ + val |= NISTC_AO_TRIG_START1_POLARITY; + } + if (cmd->start_arg & CR_EDGE) { + /* 0=edge detection disabled, 1=enabled */ + val |= NISTC_AO_TRIG_START1_EDGE; + } ni_stc_writew(dev, devpriv->ao_trigger_select, - AO_Trigger_Select_Register); + NISTC_AO_TRIG_SEL_REG); break; default: BUG(); break; } + devpriv->ao_trigger_select = val; + ni_stc_writew(dev, devpriv->ao_trigger_select, NISTC_AO_TRIG_SEL_REG); + devpriv->ao_mode3 &= ~AO_Trigger_Length; ni_stc_writew(dev, devpriv->ao_mode3, AO_Mode_3_Register); @@ -3211,7 +3219,7 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s) ni_stc_writew(dev, devpriv->ao_mode3, AO_Mode_3_Register); devpriv->ao_trigger_select = 0; ni_stc_writew(dev, devpriv->ao_trigger_select, - AO_Trigger_Select_Register); + NISTC_AO_TRIG_SEL_REG); if (devpriv->is_6xxx) { unsigned immediate_bits = 0; unsigned i; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index fc80b17430bf..385950430627 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -348,6 +348,17 @@ #define NISTC_AO_START_EDGE BIT(5) #define NISTC_AO_START_SEL(x) (((x) & 0x1f) << 0) +#define NISTC_AO_TRIG_SEL_REG 67 +#define NISTC_AO_TRIG_UI2_EXT_GATE_ENA BIT(15) +#define NISTC_AO_TRIG_DELAYED_START1 BIT(14) +#define NISTC_AO_TRIG_START1_POLARITY BIT(13) +#define NISTC_AO_TRIG_UI2_SRC_POLARITY BIT(12) +#define NISTC_AO_TRIG_UI2_SRC_SEL(x) (((x) & 0x1f) << 7) +#define NISTC_AO_TRIG_START1_SYNC BIT(6) +#define NISTC_AO_TRIG_START1_EDGE BIT(5) +#define NISTC_AO_TRIG_START1_SEL(x) (((x) & 0x1f) << 0) +#define NISTC_AO_TRIG_START1_SEL_MASK NISTC_AO_TRIG_START1_SEL(0x1f) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -406,16 +417,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define AO_Trigger_Select_Register 67 -#define AO_UI2_External_Gate_Enable _bit15 -#define AO_Delayed_START1 _bit14 -#define AO_START1_Polarity _bit13 -#define AO_UI2_Source_Polarity _bit12 -#define AO_UI2_Source_Select(x) (((x)&0x1f)<<7) -#define AO_START1_Sync _bit6 -#define AO_START1_Edge _bit5 -#define AO_START1_Select(x) (((x)&0x1f)<<0) - #define AO_Mode_3_Register 70 #define AO_UI2_Switch_Load_Next_TC _bit13 #define AO_UC_Switch_Load_Every_BC_TC _bit12 From 38aba4c99498feec862f4b1b588fb6719184b94c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:23 -0700 Subject: [PATCH 0359/1163] staging: comedi: ni_stc.h: tidy up G_Autoincrement_Register Rename the CamelCase and define the G0 and G1 registers to add clarity to the mio_regmap tables. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 8 ++++---- drivers/staging/comedi/drivers/ni_stc.h | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 0634babd2cf2..2c85b5715b05 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -362,8 +362,8 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_AI_DIV_LOADA_REG] = { 0x180, 4 }, [NISTC_AO_START_SEL_REG] = { 0x184, 2 }, [NISTC_AO_TRIG_SEL_REG] = { 0x186, 2 }, - [G_Autoincrement_Register(0)] = { 0x188, 2 }, - [G_Autoincrement_Register(1)] = { 0x18a, 2 }, + [NISTC_G0_AUTOINC_REG] = { 0x188, 2 }, + [NISTC_G1_AUTOINC_REG] = { 0x18a, 2 }, [AO_Mode_3_Register] = { 0x18c, 2 }, [Joint_Reset_Register] = { 0x190, 2 }, [Interrupt_A_Enable_Register] = { 0x192, 2 }, @@ -3712,8 +3712,8 @@ static void init_ao_67xx(struct comedi_device *dev, struct comedi_subdevice *s) } static const struct mio_regmap ni_gpct_to_stc_regmap[] = { - [NITIO_G0_AUTO_INC] = { G_Autoincrement_Register(0), 2 }, - [NITIO_G1_AUTO_INC] = { G_Autoincrement_Register(1), 2 }, + [NITIO_G0_AUTO_INC] = { NISTC_G0_AUTOINC_REG, 2 }, + [NITIO_G1_AUTO_INC] = { NISTC_G1_AUTOINC_REG, 2 }, [NITIO_G0_CMD] = { NISTC_G0_CMD_REG, 2 }, [NITIO_G1_CMD] = { NISTC_G1_CMD_REG, 2 }, [NITIO_G0_HW_SAVE] = { G_HW_Save_Register(0), 4 }, diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 385950430627..f63f290c4cb1 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -359,6 +359,9 @@ #define NISTC_AO_TRIG_START1_SEL(x) (((x) & 0x1f) << 0) #define NISTC_AO_TRIG_START1_SEL_MASK NISTC_AO_TRIG_START1_SEL(0x1f) +#define NISTC_G0_AUTOINC_REG 68 +#define NISTC_G1_AUTOINC_REG 69 + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -589,7 +592,6 @@ static unsigned AO_UPDATE_Output_Select(enum ao_update_output_selection #define AI_External_Gate_Polarity _bit5 #define AI_External_Gate_Select(a) ((a) & 0x1f) -#define G_Autoincrement_Register(a) (68+(a)) #define G_HW_Save_Register(a) (8+(a)*2) #define G_HW_Save_Register_High(a) (8+(a)*2) #define G_HW_Save_Register_Low(a) (9+(a)*2) From 72bca4f5e2c724120c1aa319f1b3042e3691d6ac Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:24 -0700 Subject: [PATCH 0360/1163] staging: comedi: ni_stc.h: tidy up AO_Mode_3_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 20 ++++++++--------- drivers/staging/comedi/drivers/ni_stc.h | 22 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 2c85b5715b05..a417ab405a3d 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -364,7 +364,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_AO_TRIG_SEL_REG] = { 0x186, 2 }, [NISTC_G0_AUTOINC_REG] = { 0x188, 2 }, [NISTC_G1_AUTOINC_REG] = { 0x18a, 2 }, - [AO_Mode_3_Register] = { 0x18c, 2 }, + [NISTC_AO_MODE3_REG] = { 0x18c, 2 }, [Joint_Reset_Register] = { 0x190, 2 }, [Interrupt_A_Enable_Register] = { 0x192, 2 }, [Second_IRQ_A_Enable_Register] = { 0, 0 }, /* E-Series only */ @@ -2857,9 +2857,9 @@ static int ni_ao_inttrig(struct comedi_device *dev, interrupt_b_bits |= AO_FIFO_Interrupt_Enable; #endif - ni_stc_writew(dev, devpriv->ao_mode3 | AO_Not_An_UPDATE, - AO_Mode_3_Register); - ni_stc_writew(dev, devpriv->ao_mode3, AO_Mode_3_Register); + ni_stc_writew(dev, devpriv->ao_mode3 | NISTC_AO_MODE3_NOT_AN_UPDATE, + NISTC_AO_MODE3_REG); + ni_stc_writew(dev, devpriv->ao_mode3, NISTC_AO_MODE3_REG); /* wait for DACs to be loaded */ for (i = 0; i < timeout; i++) { udelay(1); @@ -2967,8 +2967,8 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ao_trigger_select = val; ni_stc_writew(dev, devpriv->ao_trigger_select, NISTC_AO_TRIG_SEL_REG); - devpriv->ao_mode3 &= ~AO_Trigger_Length; - ni_stc_writew(dev, devpriv->ao_mode3, AO_Mode_3_Register); + devpriv->ao_mode3 &= ~NISTC_AO_MODE3_TRIG_LEN; + ni_stc_writew(dev, devpriv->ao_mode3, NISTC_AO_MODE3_REG); ni_stc_writew(dev, devpriv->ao_mode1, NISTC_AO_MODE1_REG); devpriv->ao_mode2 &= ~NISTC_AO_MODE2_BC_INIT_LOAD_SRC; @@ -3064,8 +3064,8 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) NISTC_AO_CMD1_DAC0_UPDATE_MODE, NISTC_AO_CMD1_REG); - devpriv->ao_mode3 |= AO_Stop_On_Overrun_Error; - ni_stc_writew(dev, devpriv->ao_mode3, AO_Mode_3_Register); + devpriv->ao_mode3 |= NISTC_AO_MODE3_STOP_ON_OVERRUN_ERR; + ni_stc_writew(dev, devpriv->ao_mode3, NISTC_AO_MODE3_REG); devpriv->ao_mode2 &= ~NISTC_AO_MODE2_FIFO_MODE_MASK; #ifdef PCIDMA @@ -3213,10 +3213,10 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ao_mode2 = 0; ni_stc_writew(dev, devpriv->ao_mode2, NISTC_AO_MODE2_REG); if (devpriv->is_m_series) - devpriv->ao_mode3 = AO_Last_Gate_Disable; + devpriv->ao_mode3 = NISTC_AO_MODE3_LAST_GATE_DISABLE; else devpriv->ao_mode3 = 0; - ni_stc_writew(dev, devpriv->ao_mode3, AO_Mode_3_Register); + ni_stc_writew(dev, devpriv->ao_mode3, NISTC_AO_MODE3_REG); devpriv->ao_trigger_select = 0; ni_stc_writew(dev, devpriv->ao_trigger_select, NISTC_AO_TRIG_SEL_REG); diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index f63f290c4cb1..69bfdc006944 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -362,6 +362,17 @@ #define NISTC_G0_AUTOINC_REG 68 #define NISTC_G1_AUTOINC_REG 69 +#define NISTC_AO_MODE3_REG 70 +#define NISTC_AO_MODE3_UI2_SW_NEXT_TC BIT(13) +#define NISTC_AO_MODE3_UC_SW_EVERY_BC_TC BIT(12) +#define NISTC_AO_MODE3_TRIG_LEN BIT(11) +#define NISTC_AO_MODE3_STOP_ON_OVERRUN_ERR BIT(5) +#define NISTC_AO_MODE3_STOP_ON_BC_TC_TRIG_ERR BIT(4) +#define NISTC_AO_MODE3_STOP_ON_BC_TC_ERR BIT(3) +#define NISTC_AO_MODE3_NOT_AN_UPDATE BIT(2) +#define NISTC_AO_MODE3_SW_GATE BIT(1) +#define NISTC_AO_MODE3_LAST_GATE_DISABLE BIT(0) /* M-Series only */ + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -420,17 +431,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define AO_Mode_3_Register 70 -#define AO_UI2_Switch_Load_Next_TC _bit13 -#define AO_UC_Switch_Load_Every_BC_TC _bit12 -#define AO_Trigger_Length _bit11 -#define AO_Stop_On_Overrun_Error _bit5 -#define AO_Stop_On_BC_TC_Trigger_Error _bit4 -#define AO_Stop_On_BC_TC_Error _bit3 -#define AO_Not_An_UPDATE _bit2 -#define AO_Software_Gate _bit1 -#define AO_Last_Gate_Disable _bit0 /* M Series only */ - #define Joint_Reset_Register 72 #define Software_Reset _bit11 #define AO_Configuration_End _bit9 From 707502f3d0f1b07938fb9115971ecce1c9db1a97 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:25 -0700 Subject: [PATCH 0361/1163] staging: comedi: ni_stc.h: tidy up Joint_Reset_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 26 +++++++++---------- drivers/staging/comedi/drivers/ni_stc.h | 22 ++++++++-------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index a417ab405a3d..ea6eabdc6481 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -365,7 +365,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_G0_AUTOINC_REG] = { 0x188, 2 }, [NISTC_G1_AUTOINC_REG] = { 0x18a, 2 }, [NISTC_AO_MODE3_REG] = { 0x18c, 2 }, - [Joint_Reset_Register] = { 0x190, 2 }, + [NISTC_RESET_REG] = { 0x190, 2 }, [Interrupt_A_Enable_Register] = { 0x192, 2 }, [Second_IRQ_A_Enable_Register] = { 0, 0 }, /* E-Series only */ [Interrupt_B_Enable_Register] = { 0x196, 2 }, @@ -1612,8 +1612,8 @@ static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s) ni_release_ai_mite_channel(dev); /* ai configuration */ - ni_stc_writew(dev, AI_Configuration_Start | AI_Reset, - Joint_Reset_Register); + ni_stc_writew(dev, NISTC_RESET_AI_CFG_START | NISTC_RESET_AI, + NISTC_RESET_REG); ni_set_bits(dev, Interrupt_A_Enable_Register, AI_SC_TC_Interrupt_Enable | AI_START1_Interrupt_Enable | @@ -1678,7 +1678,7 @@ static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s) /* clear interrupts */ ni_stc_writew(dev, NISTC_INTA_ACK_AI_ALL, NISTC_INTA_ACK_REG); - ni_stc_writew(dev, AI_Configuration_End, Joint_Reset_Register); + ni_stc_writew(dev, NISTC_RESET_AI_CFG_END, NISTC_RESET_REG); return 0; } @@ -2259,7 +2259,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ni_load_channelgain_list(dev, s, cmd->chanlist_len, cmd->chanlist); /* start configuration */ - ni_stc_writew(dev, AI_Configuration_Start, Joint_Reset_Register); + ni_stc_writew(dev, NISTC_RESET_AI_CFG_START, NISTC_RESET_REG); /* disable analog triggering for now, since it * interferes with the use of pfi0 */ @@ -2484,7 +2484,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } /* end configuration */ - ni_stc_writew(dev, AI_Configuration_End, Joint_Reset_Register); + ni_stc_writew(dev, NISTC_RESET_AI_CFG_END, NISTC_RESET_REG); switch (cmd->scan_begin_src) { case TRIG_TIMER: @@ -2909,7 +2909,7 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) return -EIO; } - ni_stc_writew(dev, AO_Configuration_Start, Joint_Reset_Register); + ni_stc_writew(dev, NISTC_RESET_AO_CFG_START, NISTC_RESET_REG); ni_stc_writew(dev, NISTC_AO_CMD1_DISARM, NISTC_AO_CMD1_REG); @@ -3092,7 +3092,7 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* enable sending of ao dma requests */ ni_stc_writew(dev, NISTC_AO_START_AOFREQ_ENA, NISTC_AO_START_SEL_REG); - ni_stc_writew(dev, AO_Configuration_End, Joint_Reset_Register); + ni_stc_writew(dev, NISTC_RESET_AO_CFG_END, NISTC_RESET_REG); if (cmd->stop_src == TRIG_COUNT) { ni_stc_writew(dev, NISTC_INTB_ACK_AO_BC_TC, @@ -3195,7 +3195,7 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s) ni_release_ao_mite_channel(dev); - ni_stc_writew(dev, AO_Configuration_Start, Joint_Reset_Register); + ni_stc_writew(dev, NISTC_RESET_AO_CFG_START, NISTC_RESET_REG); ni_stc_writew(dev, NISTC_AO_CMD1_DISARM, NISTC_AO_CMD1_REG); ni_set_bits(dev, Interrupt_B_Enable_Register, ~0, 0); ni_stc_writew(dev, AO_BC_Source_Select, AO_Personal_Register); @@ -3229,7 +3229,7 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s) ni_ao_win_outw(dev, immediate_bits, AO_Immediate_671x); ni_ao_win_outw(dev, CLEAR_WG, AO_Misc_611x); } - ni_stc_writew(dev, AO_Configuration_End, Joint_Reset_Register); + ni_stc_writew(dev, NISTC_RESET_AO_CFG_END, NISTC_RESET_REG); return 0; } @@ -3733,7 +3733,7 @@ static const struct mio_regmap ni_gpct_to_stc_regmap[] = { [NITIO_G0_GATE2] = { 0x1b4, 2 }, /* M-Series only */ [NITIO_G1_GATE2] = { 0x1b6, 2 }, /* M-Series only */ [NITIO_G01_STATUS] = { G_Status_Register, 2 }, - [NITIO_G01_RESET] = { Joint_Reset_Register, 2 }, + [NITIO_G01_RESET] = { NISTC_RESET_REG, 2 }, [NITIO_G01_STATUS1] = { Joint_Status_1_Register, 2 }, [NITIO_G01_STATUS2] = { Joint_Status_2_Register, 2 }, [NITIO_G0_DMA_CFG] = { 0x1b8, 2 }, /* M-Series only */ @@ -3771,8 +3771,6 @@ static void ni_gpct_write_register(struct ni_gpct *counter, unsigned bits, { struct comedi_device *dev = counter->counter_dev->dev; unsigned int stc_register = ni_gpct_to_stc_register(dev, reg); - /* bits in the join reset register which are relevant to counters */ - static const unsigned gpct_joint_reset_mask = G0_Reset | G1_Reset; static const unsigned gpct_interrupt_a_enable_mask = G0_Gate_Interrupt_Enable | G0_TC_Interrupt_Enable; static const unsigned gpct_interrupt_b_enable_mask = @@ -3814,7 +3812,7 @@ static void ni_gpct_write_register(struct ni_gpct *counter, unsigned bits, gpct_interrupt_b_enable_mask, bits); break; case NITIO_G01_RESET: - BUG_ON(bits & ~gpct_joint_reset_mask); + BUG_ON(bits & ~(NISTC_RESET_G0 | NISTC_RESET_G1)); /* fall-through */ default: ni_stc_writew(dev, bits, stc_register); diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 69bfdc006944..c9cec4c3070b 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -373,6 +373,17 @@ #define NISTC_AO_MODE3_SW_GATE BIT(1) #define NISTC_AO_MODE3_LAST_GATE_DISABLE BIT(0) /* M-Series only */ +#define NISTC_RESET_REG 72 +#define NISTC_RESET_SOFTWARE BIT(11) +#define NISTC_RESET_AO_CFG_END BIT(9) +#define NISTC_RESET_AI_CFG_END BIT(8) +#define NISTC_RESET_AO_CFG_START BIT(5) +#define NISTC_RESET_AI_CFG_START BIT(4) +#define NISTC_RESET_G1 BIT(3) +#define NISTC_RESET_G0 BIT(2) +#define NISTC_RESET_AO BIT(1) +#define NISTC_RESET_AI BIT(0) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -431,17 +442,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define Joint_Reset_Register 72 -#define Software_Reset _bit11 -#define AO_Configuration_End _bit9 -#define AI_Configuration_End _bit8 -#define AO_Configuration_Start _bit5 -#define AI_Configuration_Start _bit4 -#define G1_Reset _bit3 -#define G0_Reset _bit2 -#define AO_Reset _bit1 -#define AI_Reset _bit0 - #define Interrupt_A_Enable_Register 73 #define Pass_Thru_0_Interrupt_Enable _bit9 #define G0_Gate_Interrupt_Enable _bit8 From 5cca26aaf2305db6bdaae26b2bb814ae93ca1652 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:26 -0700 Subject: [PATCH 0362/1163] staging: comedi: ni_stc.h: tidy up Interrupt_A_Enable_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 29 +++++++---------- drivers/staging/comedi/drivers/ni_stc.h | 31 ++++++++++++------- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index ea6eabdc6481..0651aed7f4db 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -366,7 +366,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_G1_AUTOINC_REG] = { 0x18a, 2 }, [NISTC_AO_MODE3_REG] = { 0x18c, 2 }, [NISTC_RESET_REG] = { 0x190, 2 }, - [Interrupt_A_Enable_Register] = { 0x192, 2 }, + [NISTC_INTA_ENA_REG] = { 0x192, 2 }, [Second_IRQ_A_Enable_Register] = { 0, 0 }, /* E-Series only */ [Interrupt_B_Enable_Register] = { 0x196, 2 }, [Second_IRQ_B_Enable_Register] = { 0, 0 }, /* E-Series only */ @@ -531,7 +531,7 @@ static inline void ni_set_bitfield(struct comedi_device *dev, int reg, spin_lock_irqsave(&devpriv->soft_reg_copy_lock, flags); switch (reg) { - case Interrupt_A_Enable_Register: + case NISTC_INTA_ENA_REG: devpriv->int_a_enable_reg &= ~bit_mask; devpriv->int_a_enable_reg |= bit_values & bit_mask; ni_stc_writew(dev, devpriv->int_a_enable_reg, reg); @@ -1615,11 +1615,7 @@ static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s) ni_stc_writew(dev, NISTC_RESET_AI_CFG_START | NISTC_RESET_AI, NISTC_RESET_REG); - ni_set_bits(dev, Interrupt_A_Enable_Register, - AI_SC_TC_Interrupt_Enable | AI_START1_Interrupt_Enable | - AI_START2_Interrupt_Enable | AI_START_Interrupt_Enable | - AI_STOP_Interrupt_Enable | AI_Error_Interrupt_Enable | - AI_FIFO_Interrupt_Enable, 0); + ni_set_bits(dev, NISTC_INTA_ENA_REG, NISTC_INTA_ENA_AI_MASK, 0); ni_clear_ai_fifo(dev); @@ -2323,7 +2319,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (stop_count == 0) { devpriv->ai_cmd2 |= NISTC_AI_CMD2_END_ON_EOS; - interrupt_a_enable |= AI_STOP_Interrupt_Enable; + interrupt_a_enable |= NISTC_INTA_ENA_AI_STOP; /* this is required to get the last sample for chanlist_len > 1, not sure why */ if (cmd->chanlist_len > 1) start_stop_select |= NISTC_AI_STOP_POLARITY | @@ -2426,11 +2422,11 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (dev->irq) { /* interrupt on FIFO, errors, SC_TC */ - interrupt_a_enable |= AI_Error_Interrupt_Enable | - AI_SC_TC_Interrupt_Enable; + interrupt_a_enable |= NISTC_INTA_ENA_AI_ERR | + NISTC_INTA_ENA_AI_SC_TC; #ifndef PCIDMA - interrupt_a_enable |= AI_FIFO_Interrupt_Enable; + interrupt_a_enable |= NISTC_INTA_ENA_AI_FIFO; #endif if ((cmd->flags & CMDF_WAKE_EOS) || @@ -2465,7 +2461,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ni_stc_writew(dev, AI_FIFO_Mode_HF, AI_Mode_3_Register); #endif - interrupt_a_enable |= AI_STOP_Interrupt_Enable; + interrupt_a_enable |= NISTC_INTA_ENA_AI_STOP; break; default: break; @@ -2474,11 +2470,10 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* clear interrupts */ ni_stc_writew(dev, NISTC_INTA_ACK_AI_ALL, NISTC_INTA_ACK_REG); - ni_set_bits(dev, Interrupt_A_Enable_Register, - interrupt_a_enable, 1); + ni_set_bits(dev, NISTC_INTA_ENA_REG, interrupt_a_enable, 1); } else { /* interrupt on nothing */ - ni_set_bits(dev, Interrupt_A_Enable_Register, ~0, 0); + ni_set_bits(dev, NISTC_INTA_ENA_REG, ~0, 0); /* XXX start polling if necessary */ } @@ -3746,7 +3741,7 @@ static const struct mio_regmap ni_gpct_to_stc_regmap[] = { [NITIO_G1_INT_ACK] = { NISTC_INTB_ACK_REG, 2 }, [NITIO_G0_STATUS] = { AI_Status_1_Register, 2 }, [NITIO_G1_STATUS] = { AO_Status_1_Register, 2 }, - [NITIO_G0_INT_ENA] = { Interrupt_A_Enable_Register, 2 }, + [NITIO_G0_INT_ENA] = { NISTC_INTA_ENA_REG, 2 }, [NITIO_G1_INT_ENA] = { Interrupt_B_Enable_Register, 2 }, }; @@ -3772,7 +3767,7 @@ static void ni_gpct_write_register(struct ni_gpct *counter, unsigned bits, struct comedi_device *dev = counter->counter_dev->dev; unsigned int stc_register = ni_gpct_to_stc_register(dev, reg); static const unsigned gpct_interrupt_a_enable_mask = - G0_Gate_Interrupt_Enable | G0_TC_Interrupt_Enable; + NISTC_INTA_ENA_G0_GATE | NISTC_INTA_ENA_G0_TC; static const unsigned gpct_interrupt_b_enable_mask = G1_Gate_Interrupt_Enable | G1_TC_Interrupt_Enable; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index c9cec4c3070b..81a918e33026 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -384,6 +384,25 @@ #define NISTC_RESET_AO BIT(1) #define NISTC_RESET_AI BIT(0) +#define NISTC_INTA_ENA_REG 73 +#define NISTC_INTA_ENA_PASSTHRU0 BIT(9) +#define NISTC_INTA_ENA_G0_GATE BIT(8) +#define NISTC_INTA_ENA_AI_FIFO BIT(7) +#define NISTC_INTA_ENA_G0_TC BIT(6) +#define NISTC_INTA_ENA_AI_ERR BIT(5) +#define NISTC_INTA_ENA_AI_STOP BIT(4) +#define NISTC_INTA_ENA_AI_START BIT(3) +#define NISTC_INTA_ENA_AI_START2 BIT(2) +#define NISTC_INTA_ENA_AI_START1 BIT(1) +#define NISTC_INTA_ENA_AI_SC_TC BIT(0) +#define NISTC_INTA_ENA_AI_MASK (NISTC_INTA_ENA_AI_FIFO | \ + NISTC_INTA_ENA_AI_ERR | \ + NISTC_INTA_ENA_AI_STOP | \ + NISTC_INTA_ENA_AI_START | \ + NISTC_INTA_ENA_AI_START2 | \ + NISTC_INTA_ENA_AI_START1 | \ + NISTC_INTA_ENA_AI_SC_TC) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -442,18 +461,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define Interrupt_A_Enable_Register 73 -#define Pass_Thru_0_Interrupt_Enable _bit9 -#define G0_Gate_Interrupt_Enable _bit8 -#define AI_FIFO_Interrupt_Enable _bit7 -#define G0_TC_Interrupt_Enable _bit6 -#define AI_Error_Interrupt_Enable _bit5 -#define AI_STOP_Interrupt_Enable _bit4 -#define AI_START_Interrupt_Enable _bit3 -#define AI_START2_Interrupt_Enable _bit2 -#define AI_START1_Interrupt_Enable _bit1 -#define AI_SC_TC_Interrupt_Enable _bit0 - #define Interrupt_B_Enable_Register 75 #define Pass_Thru_1_Interrupt_Enable _bit11 #define G1_Gate_Interrupt_Enable _bit10 From d84e9c348901ee0be9b71e1f9fb7ab32d48a2a82 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:27 -0700 Subject: [PATCH 0363/1163] staging: comedi: ni_stc.h: tidy up Second_IRQ_A_Enable_Register and bits Rename the CamelCase. The bit defines are identical to NISTC_INTA_ENA_REG. Reuse them. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 6 +++--- drivers/staging/comedi/drivers/ni_stc.h | 15 +-------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 0651aed7f4db..0e7075dd5109 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -367,7 +367,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_AO_MODE3_REG] = { 0x18c, 2 }, [NISTC_RESET_REG] = { 0x190, 2 }, [NISTC_INTA_ENA_REG] = { 0x192, 2 }, - [Second_IRQ_A_Enable_Register] = { 0, 0 }, /* E-Series only */ + [NISTC_INTA2_ENA_REG] = { 0, 0 }, /* E-Series only */ [Interrupt_B_Enable_Register] = { 0x196, 2 }, [Second_IRQ_B_Enable_Register] = { 0, 0 }, /* E-Series only */ [AI_Personal_Register] = { 0x19a, 2 }, @@ -818,9 +818,9 @@ static void ni_e_series_enable_second_irq(struct comedi_device *dev, * dma requests for their counters */ if (gpct_index == 0) { - reg = Second_IRQ_A_Enable_Register; + reg = NISTC_INTA2_ENA_REG; if (enable) - val = G0_Gate_Second_Irq_Enable; + val = NISTC_INTA_ENA_G0_GATE; } else { reg = Second_IRQ_B_Enable_Register; if (enable) diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 81a918e33026..6f6c821c1816 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -385,6 +385,7 @@ #define NISTC_RESET_AI BIT(0) #define NISTC_INTA_ENA_REG 73 +#define NISTC_INTA2_ENA_REG 74 #define NISTC_INTA_ENA_PASSTHRU0 BIT(9) #define NISTC_INTA_ENA_G0_GATE BIT(8) #define NISTC_INTA_ENA_AI_FIFO BIT(7) @@ -475,20 +476,6 @@ enum Joint_Status_2_Bits { #define AO_START1_Interrupt_Enable _bit1 #define AO_BC_TC_Interrupt_Enable _bit0 -#define Second_IRQ_A_Enable_Register 74 -enum Second_IRQ_A_Enable_Bits { - AI_SC_TC_Second_Irq_Enable = _bit0, - AI_START1_Second_Irq_Enable = _bit1, - AI_START2_Second_Irq_Enable = _bit2, - AI_START_Second_Irq_Enable = _bit3, - AI_STOP_Second_Irq_Enable = _bit4, - AI_Error_Second_Irq_Enable = _bit5, - G0_TC_Second_Irq_Enable = _bit6, - AI_FIFO_Second_Irq_Enable = _bit7, - G0_Gate_Second_Irq_Enable = _bit8, - Pass_Thru_0_Second_Irq_Enable = _bit9 -}; - #define Second_IRQ_B_Enable_Register 76 enum Second_IRQ_B_Enable_Bits { AO_BC_TC_Second_Irq_Enable = _bit0, From 4c9c1d2c52992995b319de5edfe13887b86f8542 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:28 -0700 Subject: [PATCH 0364/1163] staging: comedi: ni_stc.h: tidy up Interrupt_B_Enable_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 30 +++++++++---------- drivers/staging/comedi/drivers/ni_stc.h | 28 ++++++++--------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 0e7075dd5109..24d27044f147 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -368,7 +368,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_RESET_REG] = { 0x190, 2 }, [NISTC_INTA_ENA_REG] = { 0x192, 2 }, [NISTC_INTA2_ENA_REG] = { 0, 0 }, /* E-Series only */ - [Interrupt_B_Enable_Register] = { 0x196, 2 }, + [NISTC_INTB_ENA_REG] = { 0x196, 2 }, [Second_IRQ_B_Enable_Register] = { 0, 0 }, /* E-Series only */ [AI_Personal_Register] = { 0x19a, 2 }, [AO_Personal_Register] = { 0x19c, 2 }, @@ -536,7 +536,7 @@ static inline void ni_set_bitfield(struct comedi_device *dev, int reg, devpriv->int_a_enable_reg |= bit_values & bit_mask; ni_stc_writew(dev, devpriv->int_a_enable_reg, reg); break; - case Interrupt_B_Enable_Register: + case NISTC_INTB_ENA_REG: devpriv->int_b_enable_reg &= ~bit_mask; devpriv->int_b_enable_reg |= bit_values & bit_mask; ni_stc_writew(dev, devpriv->int_b_enable_reg, reg); @@ -1490,9 +1490,9 @@ static void handle_b_interrupt(struct comedi_device *dev, ret = ni_ao_fifo_half_empty(dev, s); if (!ret) { dev_err(dev->class_dev, "AO buffer underrun\n"); - ni_set_bits(dev, Interrupt_B_Enable_Register, - AO_FIFO_Interrupt_Enable | - AO_Error_Interrupt_Enable, 0); + ni_set_bits(dev, NISTC_INTB_ENA_REG, + NISTC_INTB_ENA_AO_FIFO | + NISTC_INTB_ENA_AO_ERR, 0); s->async->events |= COMEDI_CB_OVERFLOW; } } @@ -2831,9 +2831,9 @@ static int ni_ao_inttrig(struct comedi_device *dev, multiple times) */ s->async->inttrig = NULL; - ni_set_bits(dev, Interrupt_B_Enable_Register, - AO_FIFO_Interrupt_Enable | AO_Error_Interrupt_Enable, 0); - interrupt_b_bits = AO_Error_Interrupt_Enable; + ni_set_bits(dev, NISTC_INTB_ENA_REG, + NISTC_INTB_ENA_AO_FIFO | NISTC_INTB_ENA_AO_ERR, 0); + interrupt_b_bits = NISTC_INTB_ENA_AO_ERR; #ifdef PCIDMA ni_stc_writew(dev, 1, DAC_FIFO_Clear); if (devpriv->is_6xxx) @@ -2849,7 +2849,7 @@ static int ni_ao_inttrig(struct comedi_device *dev, if (ret == 0) return -EPIPE; - interrupt_b_bits |= AO_FIFO_Interrupt_Enable; + interrupt_b_bits |= NISTC_INTB_ENA_AO_FIFO; #endif ni_stc_writew(dev, devpriv->ao_mode3 | NISTC_AO_MODE3_NOT_AN_UPDATE, @@ -2873,7 +2873,7 @@ static int ni_ao_inttrig(struct comedi_device *dev, */ ni_stc_writew(dev, NISTC_INTB_ACK_AO_ERR, NISTC_INTB_ACK_REG); - ni_set_bits(dev, Interrupt_B_Enable_Register, interrupt_b_bits, 1); + ni_set_bits(dev, NISTC_INTB_ENA_REG, interrupt_b_bits, 1); ni_stc_writew(dev, NISTC_AO_CMD1_UI_ARM | NISTC_AO_CMD1_UC_ARM | @@ -3092,8 +3092,8 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (cmd->stop_src == TRIG_COUNT) { ni_stc_writew(dev, NISTC_INTB_ACK_AO_BC_TC, NISTC_INTB_ACK_REG); - ni_set_bits(dev, Interrupt_B_Enable_Register, - AO_BC_TC_Interrupt_Enable, 1); + ni_set_bits(dev, NISTC_INTB_ENA_REG, + NISTC_INTB_ENA_AO_BC_TC, 1); } s->async->inttrig = ni_ao_inttrig; @@ -3192,7 +3192,7 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s) ni_stc_writew(dev, NISTC_RESET_AO_CFG_START, NISTC_RESET_REG); ni_stc_writew(dev, NISTC_AO_CMD1_DISARM, NISTC_AO_CMD1_REG); - ni_set_bits(dev, Interrupt_B_Enable_Register, ~0, 0); + ni_set_bits(dev, NISTC_INTB_ENA_REG, ~0, 0); ni_stc_writew(dev, AO_BC_Source_Select, AO_Personal_Register); ni_stc_writew(dev, NISTC_INTB_ACK_AO_ALL, NISTC_INTB_ACK_REG); ni_stc_writew(dev, AO_BC_Source_Select | AO_UPDATE_Pulse_Width | @@ -3742,7 +3742,7 @@ static const struct mio_regmap ni_gpct_to_stc_regmap[] = { [NITIO_G0_STATUS] = { AI_Status_1_Register, 2 }, [NITIO_G1_STATUS] = { AO_Status_1_Register, 2 }, [NITIO_G0_INT_ENA] = { NISTC_INTA_ENA_REG, 2 }, - [NITIO_G1_INT_ENA] = { Interrupt_B_Enable_Register, 2 }, + [NITIO_G1_INT_ENA] = { NISTC_INTB_ENA_REG, 2 }, }; static unsigned int ni_gpct_to_stc_register(struct comedi_device *dev, @@ -3769,7 +3769,7 @@ static void ni_gpct_write_register(struct ni_gpct *counter, unsigned bits, static const unsigned gpct_interrupt_a_enable_mask = NISTC_INTA_ENA_G0_GATE | NISTC_INTA_ENA_G0_TC; static const unsigned gpct_interrupt_b_enable_mask = - G1_Gate_Interrupt_Enable | G1_TC_Interrupt_Enable; + NISTC_INTB_ENA_G1_GATE | NISTC_INTB_ENA_G1_TC; if (stc_register == 0) return; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 6f6c821c1816..f6782b951899 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -404,6 +404,20 @@ NISTC_INTA_ENA_AI_START1 | \ NISTC_INTA_ENA_AI_SC_TC) +#define NISTC_INTB_ENA_REG 75 +#define NISTC_INTB_ENA_PASSTHRU1 BIT(11) +#define NISTC_INTB_ENA_G1_GATE BIT(10) +#define NISTC_INTB_ENA_G1_TC BIT(9) +#define NISTC_INTB_ENA_AO_FIFO BIT(8) +#define NISTC_INTB_ENA_AO_UI2_TC BIT(7) +#define NISTC_INTB_ENA_AO_UC_TC BIT(6) +#define NISTC_INTB_ENA_AO_ERR BIT(5) +#define NISTC_INTB_ENA_AO_STOP BIT(4) +#define NISTC_INTB_ENA_AO_START BIT(3) +#define NISTC_INTB_ENA_AO_UPDATE BIT(2) +#define NISTC_INTB_ENA_AO_START1 BIT(1) +#define NISTC_INTB_ENA_AO_BC_TC BIT(0) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -462,20 +476,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define Interrupt_B_Enable_Register 75 -#define Pass_Thru_1_Interrupt_Enable _bit11 -#define G1_Gate_Interrupt_Enable _bit10 -#define G1_TC_Interrupt_Enable _bit9 -#define AO_FIFO_Interrupt_Enable _bit8 -#define AO_UI2_TC_Interrupt_Enable _bit7 -#define AO_UC_TC_Interrupt_Enable _bit6 -#define AO_Error_Interrupt_Enable _bit5 -#define AO_STOP_Interrupt_Enable _bit4 -#define AO_START_Interrupt_Enable _bit3 -#define AO_UPDATE_Interrupt_Enable _bit2 -#define AO_START1_Interrupt_Enable _bit1 -#define AO_BC_TC_Interrupt_Enable _bit0 - #define Second_IRQ_B_Enable_Register 76 enum Second_IRQ_B_Enable_Bits { AO_BC_TC_Second_Irq_Enable = _bit0, From 04b6846731508684366b1b91a893021c4272da6d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:29 -0700 Subject: [PATCH 0365/1163] staging: comedi: ni_stc.h: tidy up Second_IRQ_B_Enable_Register and bits Rename the CamelCase. The bit defines are identical to NISTC_INTB_ENA_REG. Reuse them. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 6 +++--- drivers/staging/comedi/drivers/ni_stc.h | 17 +---------------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 24d27044f147..3123fb952dac 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -369,7 +369,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_INTA_ENA_REG] = { 0x192, 2 }, [NISTC_INTA2_ENA_REG] = { 0, 0 }, /* E-Series only */ [NISTC_INTB_ENA_REG] = { 0x196, 2 }, - [Second_IRQ_B_Enable_Register] = { 0, 0 }, /* E-Series only */ + [NISTC_INTB2_ENA_REG] = { 0, 0 }, /* E-Series only */ [AI_Personal_Register] = { 0x19a, 2 }, [AO_Personal_Register] = { 0x19c, 2 }, [RTSI_Trig_A_Output_Register] = { 0x19e, 2 }, @@ -822,9 +822,9 @@ static void ni_e_series_enable_second_irq(struct comedi_device *dev, if (enable) val = NISTC_INTA_ENA_G0_GATE; } else { - reg = Second_IRQ_B_Enable_Register; + reg = NISTC_INTB2_ENA_REG; if (enable) - val = G1_Gate_Second_Irq_Enable; + val = NISTC_INTB_ENA_G1_GATE; } ni_stc_writew(dev, val, reg); } diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index f6782b951899..a890243033cb 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -405,6 +405,7 @@ NISTC_INTA_ENA_AI_SC_TC) #define NISTC_INTB_ENA_REG 75 +#define NISTC_INTB2_ENA_REG 76 #define NISTC_INTB_ENA_PASSTHRU1 BIT(11) #define NISTC_INTB_ENA_G1_GATE BIT(10) #define NISTC_INTB_ENA_G1_TC BIT(9) @@ -476,22 +477,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define Second_IRQ_B_Enable_Register 76 -enum Second_IRQ_B_Enable_Bits { - AO_BC_TC_Second_Irq_Enable = _bit0, - AO_START1_Second_Irq_Enable = _bit1, - AO_UPDATE_Second_Irq_Enable = _bit2, - AO_START_Second_Irq_Enable = _bit3, - AO_STOP_Second_Irq_Enable = _bit4, - AO_Error_Second_Irq_Enable = _bit5, - AO_UC_TC_Second_Irq_Enable = _bit6, - AO_UI2_TC_Second_Irq_Enable = _bit7, - AO_FIFO_Second_Irq_Enable = _bit8, - G1_TC_Second_Irq_Enable = _bit9, - G1_Gate_Second_Irq_Enable = _bit10, - Pass_Thru_1_Second_Irq_Enable = _bit11 -}; - #define AI_Personal_Register 77 #define AI_SHIFTIN_Pulse_Width _bit15 #define AI_EOC_Polarity _bit14 From c1b74035e1d5da58292448df2351d9334ff36a24 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:30 -0700 Subject: [PATCH 0366/1163] staging: comedi: ni_stc.h: tidy up AI_Personal_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Tidy up ni_ai_reset() by using a local var to set the common bits and programming the register in the common code path. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 25 ++++++----------- drivers/staging/comedi/drivers/ni_stc.h | 28 +++++++++---------- 2 files changed, 22 insertions(+), 31 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 3123fb952dac..5e0c527ac557 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -370,7 +370,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_INTA2_ENA_REG] = { 0, 0 }, /* E-Series only */ [NISTC_INTB_ENA_REG] = { 0x196, 2 }, [NISTC_INTB2_ENA_REG] = { 0, 0 }, /* E-Series only */ - [AI_Personal_Register] = { 0x19a, 2 }, + [NISTC_AI_PERSONAL_REG] = { 0x19a, 2 }, [AO_Personal_Register] = { 0x19c, 2 }, [RTSI_Trig_A_Output_Register] = { 0x19e, 2 }, [RTSI_Trig_B_Output_Register] = { 0x1a0, 2 }, @@ -1608,6 +1608,7 @@ static int ni_ao_setup_MITE_dma(struct comedi_device *dev) static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s) { struct ni_private *devpriv = dev->private; + unsigned ai_personal; unsigned ai_out_ctrl; ni_release_ai_mite_channel(dev); @@ -1631,35 +1632,25 @@ static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s) /* generate FIFO interrupts on non-empty */ ni_stc_writew(dev, (0 << 6) | 0x0000, AI_Mode_3_Register); + ai_personal = NISTC_AI_PERSONAL_SHIFTIN_PW | + NISTC_AI_PERSONAL_SOC_POLARITY | + NISTC_AI_PERSONAL_LOCALMUX_CLK_PW; ai_out_ctrl = NISTC_AI_OUT_CTRL_SCAN_IN_PROG_SEL(3) | NISTC_AI_OUT_CTRL_EXTMUX_CLK_SEL(0) | NISTC_AI_OUT_CTRL_LOCALMUX_CLK_SEL(2) | NISTC_AI_OUT_CTRL_SC_TC_SEL(3); if (devpriv->is_611x) { - ni_stc_writew(dev, - AI_SHIFTIN_Pulse_Width | - AI_SOC_Polarity | - AI_LOCALMUX_CLK_Pulse_Width, - AI_Personal_Register); ai_out_ctrl |= NISTC_AI_OUT_CTRL_CONVERT_HIGH; } else if (devpriv->is_6143) { - ni_stc_writew(dev, AI_SHIFTIN_Pulse_Width | - AI_SOC_Polarity | - AI_LOCALMUX_CLK_Pulse_Width, - AI_Personal_Register); ai_out_ctrl |= NISTC_AI_OUT_CTRL_CONVERT_LOW; } else { - ni_stc_writew(dev, - AI_SHIFTIN_Pulse_Width | - AI_SOC_Polarity | - AI_CONVERT_Pulse_Width | - AI_LOCALMUX_CLK_Pulse_Width, - AI_Personal_Register); + ai_personal |= NISTC_AI_PERSONAL_CONVERT_PW; if (devpriv->is_622x) ai_out_ctrl |= NISTC_AI_OUT_CTRL_CONVERT_HIGH; else ai_out_ctrl |= NISTC_AI_OUT_CTRL_CONVERT_LOW; } + ni_stc_writew(dev, ai_personal, NISTC_AI_PERSONAL_REG); ni_stc_writew(dev, ai_out_ctrl, NISTC_AI_OUT_CTRL_REG); /* the following registers should not be changed, because there @@ -1667,7 +1658,7 @@ static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s) * any of these, add a backup register and other appropriate code: * NISTC_AI_MODE1_REG * AI_Mode_3_Register - * AI_Personal_Register + * NISTC_AI_PERSONAL_REG * NISTC_AI_OUT_CTRL_REG */ diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index a890243033cb..27f21fad1d83 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -419,6 +419,20 @@ #define NISTC_INTB_ENA_AO_START1 BIT(1) #define NISTC_INTB_ENA_AO_BC_TC BIT(0) +#define NISTC_AI_PERSONAL_REG 77 +#define NISTC_AI_PERSONAL_SHIFTIN_PW BIT(15) +#define NISTC_AI_PERSONAL_EOC_POLARITY BIT(14) +#define NISTC_AI_PERSONAL_SOC_POLARITY BIT(13) +#define NISTC_AI_PERSONAL_SHIFTIN_POL BIT(12) +#define NISTC_AI_PERSONAL_CONVERT_TIMEBASE BIT(11) +#define NISTC_AI_PERSONAL_CONVERT_PW BIT(10) +#define NISTC_AI_PERSONAL_CONVERT_ORIG_PULSE BIT(9) +#define NISTC_AI_PERSONAL_FIFO_FLAGS_POL BIT(8) +#define NISTC_AI_PERSONAL_OVERRUN_MODE BIT(7) +#define NISTC_AI_PERSONAL_EXTMUX_CLK_PW BIT(6) +#define NISTC_AI_PERSONAL_LOCALMUX_CLK_PW BIT(5) +#define NISTC_AI_PERSONAL_AIFREQ_POL BIT(4) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -477,20 +491,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define AI_Personal_Register 77 -#define AI_SHIFTIN_Pulse_Width _bit15 -#define AI_EOC_Polarity _bit14 -#define AI_SOC_Polarity _bit13 -#define AI_SHIFTIN_Polarity _bit12 -#define AI_CONVERT_Pulse_Timebase _bit11 -#define AI_CONVERT_Pulse_Width _bit10 -#define AI_CONVERT_Original_Pulse _bit9 -#define AI_FIFO_Flags_Polarity _bit8 -#define AI_Overrun_Mode _bit7 -#define AI_EXTMUX_CLK_Pulse_Width _bit6 -#define AI_LOCALMUX_CLK_Pulse_Width _bit5 -#define AI_AIFREQ_Polarity _bit4 - #define AO_Personal_Register 78 enum AO_Personal_Bits { AO_Interval_Buffer_Mode = 1 << 3, From 63ff3f2c2945adecf6b843c8213ab050ef1326f8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:31 -0700 Subject: [PATCH 0367/1163] staging: comedi: ni_stc.h: tidy up AO_Personal_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 29 ++++++++++------- drivers/staging/comedi/drivers/ni_stc.h | 31 +++++++++---------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 5e0c527ac557..3d4f876d2f87 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -371,7 +371,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_INTB_ENA_REG] = { 0x196, 2 }, [NISTC_INTB2_ENA_REG] = { 0, 0 }, /* E-Series only */ [NISTC_AI_PERSONAL_REG] = { 0x19a, 2 }, - [AO_Personal_Register] = { 0x19c, 2 }, + [NISTC_AO_PERSONAL_REG] = { 0x19c, 2 }, [RTSI_Trig_A_Output_Register] = { 0x19e, 2 }, [RTSI_Trig_B_Output_Register] = { 0x1a0, 2 }, [RTSI_Board_Register] = { 0, 0 }, /* Unknown */ @@ -3062,19 +3062,22 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ao_mode2 &= ~NISTC_AO_MODE2_FIFO_REXMIT_ENA; ni_stc_writew(dev, devpriv->ao_mode2, NISTC_AO_MODE2_REG); - bits = AO_BC_Source_Select | AO_UPDATE_Pulse_Width | - AO_TMRDACWR_Pulse_Width; + bits = NISTC_AO_PERSONAL_BC_SRC_SEL | + NISTC_AO_PERSONAL_UPDATE_PW | + NISTC_AO_PERSONAL_TMRDACWR_PW; if (board->ao_fifo_depth) - bits |= AO_FIFO_Enable; + bits |= NISTC_AO_PERSONAL_FIFO_ENA; else - bits |= AO_DMA_PIO_Control; + bits |= NISTC_AO_PERSONAL_DMA_PIO_CTRL; #if 0 - /* F Hess: windows driver does not set AO_Number_Of_DAC_Packages bit for 6281, - verified with bus analyzer. */ + /* + * F Hess: windows driver does not set NISTC_AO_PERSONAL_NUM_DAC bit + * for 6281, verified with bus analyzer. + */ if (devpriv->is_m_series) - bits |= AO_Number_Of_DAC_Packages; + bits |= NISTC_AO_PERSONAL_NUM_DAC; #endif - ni_stc_writew(dev, bits, AO_Personal_Register); + ni_stc_writew(dev, bits, NISTC_AO_PERSONAL_REG); /* enable sending of ao dma requests */ ni_stc_writew(dev, NISTC_AO_START_AOFREQ_ENA, NISTC_AO_START_SEL_REG); @@ -3184,10 +3187,12 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s) ni_stc_writew(dev, NISTC_RESET_AO_CFG_START, NISTC_RESET_REG); ni_stc_writew(dev, NISTC_AO_CMD1_DISARM, NISTC_AO_CMD1_REG); ni_set_bits(dev, NISTC_INTB_ENA_REG, ~0, 0); - ni_stc_writew(dev, AO_BC_Source_Select, AO_Personal_Register); + ni_stc_writew(dev, NISTC_AO_PERSONAL_BC_SRC_SEL, NISTC_AO_PERSONAL_REG); ni_stc_writew(dev, NISTC_INTB_ACK_AO_ALL, NISTC_INTB_ACK_REG); - ni_stc_writew(dev, AO_BC_Source_Select | AO_UPDATE_Pulse_Width | - AO_TMRDACWR_Pulse_Width, AO_Personal_Register); + ni_stc_writew(dev, NISTC_AO_PERSONAL_BC_SRC_SEL | + NISTC_AO_PERSONAL_UPDATE_PW | + NISTC_AO_PERSONAL_TMRDACWR_PW, + NISTC_AO_PERSONAL_REG); ni_stc_writew(dev, 0, AO_Output_Control_Register); ni_stc_writew(dev, 0, NISTC_AO_START_SEL_REG); devpriv->ao_cmd1 = 0; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 27f21fad1d83..333114f22ba0 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -433,6 +433,21 @@ #define NISTC_AI_PERSONAL_LOCALMUX_CLK_PW BIT(5) #define NISTC_AI_PERSONAL_AIFREQ_POL BIT(4) +#define NISTC_AO_PERSONAL_REG 78 +#define NISTC_AO_PERSONAL_MULTI_DACS BIT(15) /* M-Series only */ +#define NISTC_AO_PERSONAL_NUM_DAC BIT(14) /* 1:single; 0:dual */ +#define NISTC_AO_PERSONAL_FAST_CPU BIT(13) /* M-Series reserved */ +#define NISTC_AO_PERSONAL_TMRDACWR_PW BIT(12) +#define NISTC_AO_PERSONAL_FIFO_FLAGS_POL BIT(11) /* M-Series reserved */ +#define NISTC_AO_PERSONAL_FIFO_ENA BIT(10) +#define NISTC_AO_PERSONAL_AOFREQ_POL BIT(9) /* M-Series reserved */ +#define NISTC_AO_PERSONAL_DMA_PIO_CTRL BIT(8) /* M-Series reserved */ +#define NISTC_AO_PERSONAL_UPDATE_ORIG_PULSE BIT(7) +#define NISTC_AO_PERSONAL_UPDATE_TIMEBASE BIT(6) +#define NISTC_AO_PERSONAL_UPDATE_PW BIT(5) +#define NISTC_AO_PERSONAL_BC_SRC_SEL BIT(4) +#define NISTC_AO_PERSONAL_INTERVAL_BUFFER_MODE BIT(3) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -491,22 +506,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define AO_Personal_Register 78 -enum AO_Personal_Bits { - AO_Interval_Buffer_Mode = 1 << 3, - AO_BC_Source_Select = 1 << 4, - AO_UPDATE_Pulse_Width = 1 << 5, - AO_UPDATE_Pulse_Timebase = 1 << 6, - AO_UPDATE_Original_Pulse = 1 << 7, - AO_DMA_PIO_Control = 1 << 8, /* M Series: reserved */ - AO_AOFREQ_Polarity = 1 << 9, /* M Series: reserved */ - AO_FIFO_Enable = 1 << 10, - AO_FIFO_Flags_Polarity = 1 << 11, /* M Series: reserved */ - AO_TMRDACWR_Pulse_Width = 1 << 12, - AO_Fast_CPU = 1 << 13, /* M Series: reserved */ - AO_Number_Of_DAC_Packages = 1 << 14, /* 1 for "single" mode, 0 for "dual" */ - AO_Multiple_DACS_Per_Package = 1 << 15 /* m-series only */ -}; #define RTSI_Trig_A_Output_Register 79 #define RTSI_Trig_B_Output_Register 80 enum RTSI_Trig_B_Output_Bits { From 390bc6ffe797b6b071eeab4628054adc4b9b4751 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:32 -0700 Subject: [PATCH 0368/1163] staging: comedi: ni_stc.h: tidy up RTSI_Trig_[AB]_Output_Register and bits Rename the CamelCase. Convert the inline helper functions to macros and use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 55 ++++++++----------- drivers/staging/comedi/drivers/ni_stc.h | 30 +++------- 2 files changed, 31 insertions(+), 54 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 3d4f876d2f87..a29ee9ec8236 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -372,8 +372,8 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_INTB2_ENA_REG] = { 0, 0 }, /* E-Series only */ [NISTC_AI_PERSONAL_REG] = { 0x19a, 2 }, [NISTC_AO_PERSONAL_REG] = { 0x19c, 2 }, - [RTSI_Trig_A_Output_Register] = { 0x19e, 2 }, - [RTSI_Trig_B_Output_Register] = { 0x1a0, 2 }, + [NISTC_RTSI_TRIGA_OUT_REG] = { 0x19e, 2 }, + [NISTC_RTSI_TRIGB_OUT_REG] = { 0x1a0, 2 }, [RTSI_Board_Register] = { 0, 0 }, /* Unknown */ [Configuration_Memory_Clear] = { 0x1a4, 2 }, [ADC_FIFO_Clear] = { 0x1a6, 2 }, @@ -4791,24 +4791,22 @@ static int ni_valid_rtsi_output_source(struct comedi_device *dev, } static int ni_set_rtsi_routing(struct comedi_device *dev, - unsigned chan, unsigned source) + unsigned chan, unsigned src) { struct ni_private *devpriv = dev->private; - if (ni_valid_rtsi_output_source(dev, chan, source) == 0) + if (ni_valid_rtsi_output_source(dev, chan, src) == 0) return -EINVAL; if (chan < 4) { - devpriv->rtsi_trig_a_output_reg &= ~RTSI_Trig_Output_Mask(chan); - devpriv->rtsi_trig_a_output_reg |= - RTSI_Trig_Output_Bits(chan, source); + devpriv->rtsi_trig_a_output_reg &= ~NISTC_RTSI_TRIG_MASK(chan); + devpriv->rtsi_trig_a_output_reg |= NISTC_RTSI_TRIG(chan, src); ni_stc_writew(dev, devpriv->rtsi_trig_a_output_reg, - RTSI_Trig_A_Output_Register); + NISTC_RTSI_TRIGA_OUT_REG); } else if (chan < 8) { - devpriv->rtsi_trig_b_output_reg &= ~RTSI_Trig_Output_Mask(chan); - devpriv->rtsi_trig_b_output_reg |= - RTSI_Trig_Output_Bits(chan, source); + devpriv->rtsi_trig_b_output_reg &= ~NISTC_RTSI_TRIG_MASK(chan); + devpriv->rtsi_trig_b_output_reg |= NISTC_RTSI_TRIG(chan, src); ni_stc_writew(dev, devpriv->rtsi_trig_b_output_reg, - RTSI_Trig_B_Output_Register); + NISTC_RTSI_TRIGB_OUT_REG); } return 2; } @@ -4818,11 +4816,11 @@ static unsigned ni_get_rtsi_routing(struct comedi_device *dev, unsigned chan) struct ni_private *devpriv = dev->private; if (chan < 4) { - return RTSI_Trig_Output_Source(chan, - devpriv->rtsi_trig_a_output_reg); + return NISTC_RTSI_TRIG_TO_SRC(chan, + devpriv->rtsi_trig_a_output_reg); } else if (chan < NISTC_RTSI_TRIG_NUM_CHAN(devpriv->is_m_series)) { - return RTSI_Trig_Output_Source(chan, - devpriv->rtsi_trig_b_output_reg); + return NISTC_RTSI_TRIG_TO_SRC(chan, + devpriv->rtsi_trig_b_output_reg); } else { if (chan == NISTC_RTSI_TRIG_OLD_CLK_CHAN) return NI_RTSI_OUTPUT_RTSI_OSC; @@ -4921,26 +4919,21 @@ static void ni_rtsi_init(struct comedi_device *dev) dev_err(dev->class_dev, "ni_set_master_clock failed, bug?\n"); /* default internal lines routing to RTSI bus lines */ devpriv->rtsi_trig_a_output_reg = - RTSI_Trig_Output_Bits(0, - NI_RTSI_OUTPUT_ADR_START1) | - RTSI_Trig_Output_Bits(1, - NI_RTSI_OUTPUT_ADR_START2) | - RTSI_Trig_Output_Bits(2, - NI_RTSI_OUTPUT_SCLKG) | - RTSI_Trig_Output_Bits(3, NI_RTSI_OUTPUT_DACUPDN); + NISTC_RTSI_TRIG(0, NI_RTSI_OUTPUT_ADR_START1) | + NISTC_RTSI_TRIG(1, NI_RTSI_OUTPUT_ADR_START2) | + NISTC_RTSI_TRIG(2, NI_RTSI_OUTPUT_SCLKG) | + NISTC_RTSI_TRIG(3, NI_RTSI_OUTPUT_DACUPDN); ni_stc_writew(dev, devpriv->rtsi_trig_a_output_reg, - RTSI_Trig_A_Output_Register); + NISTC_RTSI_TRIGA_OUT_REG); devpriv->rtsi_trig_b_output_reg = - RTSI_Trig_Output_Bits(4, - NI_RTSI_OUTPUT_DA_START1) | - RTSI_Trig_Output_Bits(5, - NI_RTSI_OUTPUT_G_SRC0) | - RTSI_Trig_Output_Bits(6, NI_RTSI_OUTPUT_G_GATE0); + NISTC_RTSI_TRIG(4, NI_RTSI_OUTPUT_DA_START1) | + NISTC_RTSI_TRIG(5, NI_RTSI_OUTPUT_G_SRC0) | + NISTC_RTSI_TRIG(6, NI_RTSI_OUTPUT_G_GATE0); if (devpriv->is_m_series) devpriv->rtsi_trig_b_output_reg |= - RTSI_Trig_Output_Bits(7, NI_RTSI_OUTPUT_RTSI_OSC); + NISTC_RTSI_TRIG(7, NI_RTSI_OUTPUT_RTSI_OSC); ni_stc_writew(dev, devpriv->rtsi_trig_b_output_reg, - RTSI_Trig_B_Output_Register); + NISTC_RTSI_TRIGB_OUT_REG); /* * Sets the source and direction of the 4 on board lines diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 333114f22ba0..88ffdf0c1bfa 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -448,6 +448,13 @@ #define NISTC_AO_PERSONAL_BC_SRC_SEL BIT(4) #define NISTC_AO_PERSONAL_INTERVAL_BUFFER_MODE BIT(3) +#define NISTC_RTSI_TRIGA_OUT_REG 79 +#define NISTC_RTSI_TRIGB_OUT_REG 80 +#define NISTC_RTSI_TRIGB_SUB_SEL1 BIT(15) /* not for M-Series */ +#define NISTC_RTSI_TRIG(_c, _s) (((_s) & 0xf) << (((_c) % 4) * 4)) +#define NISTC_RTSI_TRIG_MASK(_c) NISTC_RTSI_TRIG((_c), 0xf) +#define NISTC_RTSI_TRIG_TO_SRC(_c, _b) (((_b) >> (((_c) % 4) * 4)) & 0xf) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -506,29 +513,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define RTSI_Trig_A_Output_Register 79 -#define RTSI_Trig_B_Output_Register 80 -enum RTSI_Trig_B_Output_Bits { - RTSI_Sub_Selection_1_Bit = 0x8000 /* not for m-series */ -}; -static inline unsigned RTSI_Trig_Output_Bits(unsigned rtsi_channel, - unsigned source) -{ - return (source & 0xf) << ((rtsi_channel % 4) * 4); -}; - -static inline unsigned RTSI_Trig_Output_Mask(unsigned rtsi_channel) -{ - return 0xf << ((rtsi_channel % 4) * 4); -}; - -/* inverse to RTSI_Trig_Output_Bits() */ -static inline unsigned RTSI_Trig_Output_Source(unsigned rtsi_channel, - unsigned bits) -{ - return (bits >> ((rtsi_channel % 4) * 4)) & 0xf; -}; - #define RTSI_Board_Register 81 #define Write_Strobe_0_Register 82 #define Write_Strobe_1_Register 83 From 24a11ba670f79a81ebd99931b9ba863f6db04812 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:33 -0700 Subject: [PATCH 0369/1163] staging: comedi: ni_stc.h: tidy up RTSI_Board_Register Rename the CamelCase. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 10 +++++----- drivers/staging/comedi/drivers/ni_stc.h | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index a29ee9ec8236..3334c54db03c 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -374,7 +374,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_AO_PERSONAL_REG] = { 0x19c, 2 }, [NISTC_RTSI_TRIGA_OUT_REG] = { 0x19e, 2 }, [NISTC_RTSI_TRIGB_OUT_REG] = { 0x1a0, 2 }, - [RTSI_Board_Register] = { 0, 0 }, /* Unknown */ + [NISTC_RTSI_BOARD_REG] = { 0, 0 }, /* Unknown */ [Configuration_Memory_Clear] = { 0x1a4, 2 }, [ADC_FIFO_Clear] = { 0x1a6, 2 }, [DAC_FIFO_Clear] = { 0x1a8, 2 }, @@ -4935,10 +4935,10 @@ static void ni_rtsi_init(struct comedi_device *dev) ni_stc_writew(dev, devpriv->rtsi_trig_b_output_reg, NISTC_RTSI_TRIGB_OUT_REG); -/* -* Sets the source and direction of the 4 on board lines -* ni_stc_writew(dev, 0x0000, RTSI_Board_Register); -*/ + /* + * Sets the source and direction of the 4 on board lines + * ni_stc_writew(dev, 0, NISTC_RTSI_BOARD_REG); + */ } #ifdef PCIDMA diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 88ffdf0c1bfa..123cde66ac4a 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -455,6 +455,8 @@ #define NISTC_RTSI_TRIG_MASK(_c) NISTC_RTSI_TRIG((_c), 0xf) #define NISTC_RTSI_TRIG_TO_SRC(_c, _b) (((_b) >> (((_c) % 4) * 4)) & 0xf) +#define NISTC_RTSI_BOARD_REG 81 + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -513,7 +515,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define RTSI_Board_Register 81 #define Write_Strobe_0_Register 82 #define Write_Strobe_1_Register 83 #define Write_Strobe_2_Register 84 From 8102f3d0c17b11e01e31a01c762867ae44a96d23 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:34 -0700 Subject: [PATCH 0370/1163] staging: comedi: ni_stc.h: tidy up Write_Strobe_*_Register The Write_Strobe_*_Register defines are noy used. Instead the more descriptive Configuration_Memory_Clear, ADC_FIFO_Clear and DAC_FIFO_Clear defines are used. Remove the unused defines and rename the CamelCase. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 18 +++++++++--------- drivers/staging/comedi/drivers/ni_stc.h | 14 +++++--------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 3334c54db03c..2229006e71c9 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -375,9 +375,9 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_RTSI_TRIGA_OUT_REG] = { 0x19e, 2 }, [NISTC_RTSI_TRIGB_OUT_REG] = { 0x1a0, 2 }, [NISTC_RTSI_BOARD_REG] = { 0, 0 }, /* Unknown */ - [Configuration_Memory_Clear] = { 0x1a4, 2 }, - [ADC_FIFO_Clear] = { 0x1a6, 2 }, - [DAC_FIFO_Clear] = { 0x1a8, 2 }, + [NISTC_CFG_MEM_CLR_REG] = { 0x1a4, 2 }, + [NISTC_ADC_FIFO_CLR_REG] = { 0x1a6, 2 }, + [NISTC_DAC_FIFO_CLR_REG] = { 0x1a8, 2 }, [AO_Output_Control_Register] = { 0x1ac, 2 }, [AI_Mode_3_Register] = { 0x1ae, 2 }, }; @@ -849,7 +849,7 @@ static void ni_clear_ai_fifo(struct comedi_device *dev) if (i == timeout) dev_err(dev->class_dev, "FIFO flush timeout\n"); } else { - ni_stc_writew(dev, 1, ADC_FIFO_Clear); + ni_stc_writew(dev, 1, NISTC_ADC_FIFO_CLR_REG); if (devpriv->is_625x) { ni_writeb(dev, 0, NI_M_STATIC_AI_CTRL_REG(0)); ni_writeb(dev, 1, NI_M_STATIC_AI_CTRL_REG(0)); @@ -1084,7 +1084,7 @@ static int ni_ao_prep_fifo(struct comedi_device *dev, unsigned int nsamples; /* reset fifo */ - ni_stc_writew(dev, 1, DAC_FIFO_Clear); + ni_stc_writew(dev, 1, NISTC_DAC_FIFO_CLR_REG); if (devpriv->is_6xxx) ni_ao_win_outl(dev, 0x6, AO_FIFO_Offset_Load_611x); @@ -1696,7 +1696,7 @@ static void ni_prime_channelgain_list(struct comedi_device *dev) for (i = 0; i < NI_TIMEOUT; ++i) { if (!(ni_stc_readw(dev, AI_Status_1_Register) & AI_FIFO_Empty_St)) { - ni_stc_writew(dev, 1, ADC_FIFO_Clear); + ni_stc_writew(dev, 1, NISTC_ADC_FIFO_CLR_REG); return; } udelay(1); @@ -1715,7 +1715,7 @@ static void ni_m_series_load_channelgain_list(struct comedi_device *dev, unsigned int dither; unsigned range_code; - ni_stc_writew(dev, 1, Configuration_Memory_Clear); + ni_stc_writew(dev, 1, NISTC_CFG_MEM_CLR_REG); if ((list[0] & CR_ALT_SOURCE)) { unsigned bypass_bits; @@ -1830,7 +1830,7 @@ static void ni_load_channelgain_list(struct comedi_device *dev, devpriv->changain_state = 0; } - ni_stc_writew(dev, 1, Configuration_Memory_Clear); + ni_stc_writew(dev, 1, NISTC_CFG_MEM_CLR_REG); /* Set up Calibration mode if required */ if (devpriv->is_6143) { @@ -2826,7 +2826,7 @@ static int ni_ao_inttrig(struct comedi_device *dev, NISTC_INTB_ENA_AO_FIFO | NISTC_INTB_ENA_AO_ERR, 0); interrupt_b_bits = NISTC_INTB_ENA_AO_ERR; #ifdef PCIDMA - ni_stc_writew(dev, 1, DAC_FIFO_Clear); + ni_stc_writew(dev, 1, NISTC_DAC_FIFO_CLR_REG); if (devpriv->is_6xxx) ni_ao_win_outl(dev, 0x6, AO_FIFO_Offset_Load_611x); ret = ni_ao_setup_MITE_dma(dev); diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 123cde66ac4a..2501df83c5d5 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -457,6 +457,11 @@ #define NISTC_RTSI_BOARD_REG 81 +#define NISTC_CFG_MEM_CLR_REG 82 +#define NISTC_ADC_FIFO_CLR_REG 83 +#define NISTC_DAC_FIFO_CLR_REG 84 +#define NISTC_WR_STROBE3_REG 85 + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -515,11 +520,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define Write_Strobe_0_Register 82 -#define Write_Strobe_1_Register 83 -#define Write_Strobe_2_Register 84 -#define Write_Strobe_3_Register 85 - #define AO_Output_Control_Register 86 #define AO_External_Gate_Enable _bit15 #define AO_External_Gate_Select(x) (((x)&0x1f)<<10) @@ -637,10 +637,6 @@ static unsigned AO_UPDATE_Output_Select(enum ao_update_output_selection #define Window_Address 0x00 #define Window_Data 0x02 -#define Configuration_Memory_Clear 82 -#define ADC_FIFO_Clear 83 -#define DAC_FIFO_Clear 84 - /* i/o port offsets */ /* 8 bit registers */ From 5bd1c7283794112234aace1ef679c947d26a841e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:35 -0700 Subject: [PATCH 0371/1163] staging: comedi: ni_stc.h: tidy up AO_Output_Control_Register and bits Rename the CamelCase. Convert the inline helper function into a macro and use the BIT() marco to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 18 +++++------ drivers/staging/comedi/drivers/ni_stc.h | 32 ++++++++----------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 2229006e71c9..187a26153bd0 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -378,7 +378,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_CFG_MEM_CLR_REG] = { 0x1a4, 2 }, [NISTC_ADC_FIFO_CLR_REG] = { 0x1a6, 2 }, [NISTC_DAC_FIFO_CLR_REG] = { 0x1a8, 2 }, - [AO_Output_Control_Register] = { 0x1ac, 2 }, + [NISTC_AO_OUT_CTRL_REG] = { 0x1ac, 2 }, [AI_Mode_3_Register] = { 0x1ae, 2 }, }; @@ -3028,21 +3028,21 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (cmd->scan_end_arg > 1) { devpriv->ao_mode1 |= NISTC_AO_MODE1_MULTI_CHAN; ni_stc_writew(dev, - AO_Number_Of_Channels(cmd->scan_end_arg - 1) | - AO_UPDATE_Output_Select(AO_Update_Output_High_Z), - AO_Output_Control_Register); + NISTC_AO_OUT_CTRL_CHANS(cmd->scan_end_arg - 1) | + NISTC_AO_OUT_CTRL_UPDATE_SEL_HIGHZ, + NISTC_AO_OUT_CTRL_REG); } else { unsigned bits; devpriv->ao_mode1 &= ~NISTC_AO_MODE1_MULTI_CHAN; - bits = AO_UPDATE_Output_Select(AO_Update_Output_High_Z); + bits = NISTC_AO_OUT_CTRL_UPDATE_SEL_HIGHZ; if (devpriv->is_m_series || devpriv->is_6xxx) { - bits |= AO_Number_Of_Channels(0); + bits |= NISTC_AO_OUT_CTRL_CHANS(0); } else { bits |= - AO_Number_Of_Channels(CR_CHAN(cmd->chanlist[0])); + NISTC_AO_OUT_CTRL_CHANS(CR_CHAN(cmd->chanlist[0])); } - ni_stc_writew(dev, bits, AO_Output_Control_Register); + ni_stc_writew(dev, bits, NISTC_AO_OUT_CTRL_REG); } ni_stc_writew(dev, devpriv->ao_mode1, NISTC_AO_MODE1_REG); @@ -3193,7 +3193,7 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s) NISTC_AO_PERSONAL_UPDATE_PW | NISTC_AO_PERSONAL_TMRDACWR_PW, NISTC_AO_PERSONAL_REG); - ni_stc_writew(dev, 0, AO_Output_Control_Register); + ni_stc_writew(dev, 0, NISTC_AO_OUT_CTRL_REG); ni_stc_writew(dev, 0, NISTC_AO_START_SEL_REG); devpriv->ao_cmd1 = 0; ni_stc_writew(dev, devpriv->ao_cmd1, NISTC_AO_CMD1_REG); diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 2501df83c5d5..230744fed114 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -462,6 +462,19 @@ #define NISTC_DAC_FIFO_CLR_REG 84 #define NISTC_WR_STROBE3_REG 85 +#define NISTC_AO_OUT_CTRL_REG 86 +#define NISTC_AO_OUT_CTRL_EXT_GATE_ENA BIT(15) +#define NISTC_AO_OUT_CTRL_EXT_GATE_SEL(x) (((x) & 0x1f) << 10) +#define NISTC_AO_OUT_CTRL_CHANS(x) (((x) & 0xf) << 6) +#define NISTC_AO_OUT_CTRL_UPDATE2_SEL(x) (((x) & 0x3) << 4) +#define NISTC_AO_OUT_CTRL_EXT_GATE_POL BIT(3) +#define NISTC_AO_OUT_CTRL_UPDATE2_TOGGLE BIT(2) +#define NISTC_AO_OUT_CTRL_UPDATE_SEL(x) (((x) & 0x3) << 0) +#define NISTC_AO_OUT_CTRL_UPDATE_SEL_HIGHZ NISTC_AO_OUT_CTRL_UPDATE_SEL(0) +#define NISTC_AO_OUT_CTRL_UPDATE_SEL_GND NISTC_AO_OUT_CTRL_UPDATE_SEL(1) +#define NISTC_AO_OUT_CTRL_UPDATE_SEL_LOW NISTC_AO_OUT_CTRL_UPDATE_SEL(2) +#define NISTC_AO_OUT_CTRL_UPDATE_SEL_HIGH NISTC_AO_OUT_CTRL_UPDATE_SEL(3) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -520,25 +533,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define AO_Output_Control_Register 86 -#define AO_External_Gate_Enable _bit15 -#define AO_External_Gate_Select(x) (((x)&0x1f)<<10) -#define AO_Number_Of_Channels(x) (((x)&0xf)<<6) -#define AO_UPDATE2_Output_Select(x) (((x)&0x3)<<4) -#define AO_External_Gate_Polarity _bit3 -#define AO_UPDATE2_Output_Toggle _bit2 -enum ao_update_output_selection { - AO_Update_Output_High_Z = 0, - AO_Update_Output_Ground = 1, - AO_Update_Output_Enable_Low = 2, - AO_Update_Output_Enable_High = 3 -}; -static unsigned AO_UPDATE_Output_Select(enum ao_update_output_selection - selection) -{ - return selection & 0x3; -} - #define AI_Mode_3_Register 87 #define AI_Trigger_Length _bit15 #define AI_Delay_START _bit14 From c7edadc10326ec710b01cc1b727a701fcc06bed9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:36 -0700 Subject: [PATCH 0372/1163] staging: comedi: ni_stc.h: tidy up AI_Mode_3_Register and bits Rename the CamelCase. Use the BIT() marco to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 29 ++++++++-------- drivers/staging/comedi/drivers/ni_stc.h | 33 ++++++++++--------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 187a26153bd0..c0bd097ac13f 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -379,7 +379,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] = { [NISTC_ADC_FIFO_CLR_REG] = { 0x1a6, 2 }, [NISTC_DAC_FIFO_CLR_REG] = { 0x1a8, 2 }, [NISTC_AO_OUT_CTRL_REG] = { 0x1ac, 2 }, - [AI_Mode_3_Register] = { 0x1ae, 2 }, + [NISTC_AI_MODE3_REG] = { 0x1ae, 2 }, }; static void m_series_stc_write(struct comedi_device *dev, @@ -1630,7 +1630,8 @@ static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s) NISTC_AI_MODE1_REG); ni_stc_writew(dev, 0, NISTC_AI_MODE2_REG); /* generate FIFO interrupts on non-empty */ - ni_stc_writew(dev, (0 << 6) | 0x0000, AI_Mode_3_Register); + ni_stc_writew(dev, NISTC_AI_MODE3_FIFO_MODE_NE, + NISTC_AI_MODE3_REG); ai_personal = NISTC_AI_PERSONAL_SHIFTIN_PW | NISTC_AI_PERSONAL_SOC_POLARITY | @@ -1657,7 +1658,7 @@ static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s) * are no backup registers in devpriv. If you want to change * any of these, add a backup register and other appropriate code: * NISTC_AI_MODE1_REG - * AI_Mode_3_Register + * NISTC_AI_MODE3_REG * NISTC_AI_PERSONAL_REG * NISTC_AI_OUT_CTRL_REG */ @@ -2335,7 +2336,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) case TRIG_TIMER: /* * stop bits for non 611x boards - * AI_SI_Special_Trigger_Delay=0 + * NISTC_AI_MODE3_SI_TRIG_DELAY=0 * NISTC_AI_MODE2_PRE_TRIGGER=0 * NISTC_AI_START_STOP_REG: * NISTC_AI_START_POLARITY=0 (?) rising edge @@ -2432,25 +2433,25 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) case AIMODE_HALF_FULL: /*generate FIFO interrupts and DMA requests on half-full */ #ifdef PCIDMA - ni_stc_writew(dev, AI_FIFO_Mode_HF_to_E, - AI_Mode_3_Register); + ni_stc_writew(dev, NISTC_AI_MODE3_FIFO_MODE_HF_E, + NISTC_AI_MODE3_REG); #else - ni_stc_writew(dev, AI_FIFO_Mode_HF, - AI_Mode_3_Register); + ni_stc_writew(dev, NISTC_AI_MODE3_FIFO_MODE_HF, + NISTC_AI_MODE3_REG); #endif break; case AIMODE_SAMPLE: /*generate FIFO interrupts on non-empty */ - ni_stc_writew(dev, AI_FIFO_Mode_NE, - AI_Mode_3_Register); + ni_stc_writew(dev, NISTC_AI_MODE3_FIFO_MODE_NE, + NISTC_AI_MODE3_REG); break; case AIMODE_SCAN: #ifdef PCIDMA - ni_stc_writew(dev, AI_FIFO_Mode_NE, - AI_Mode_3_Register); + ni_stc_writew(dev, NISTC_AI_MODE3_FIFO_MODE_NE, + NISTC_AI_MODE3_REG); #else - ni_stc_writew(dev, AI_FIFO_Mode_HF, - AI_Mode_3_Register); + ni_stc_writew(dev, NISTC_AI_MODE3_FIFO_MODE_HF, + NISTC_AI_MODE3_REG); #endif interrupt_a_enable |= NISTC_INTA_ENA_AI_STOP; break; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 230744fed114..6c9bb6c4d2f0 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -475,6 +475,23 @@ #define NISTC_AO_OUT_CTRL_UPDATE_SEL_LOW NISTC_AO_OUT_CTRL_UPDATE_SEL(2) #define NISTC_AO_OUT_CTRL_UPDATE_SEL_HIGH NISTC_AO_OUT_CTRL_UPDATE_SEL(3) +#define NISTC_AI_MODE3_REG 87 +#define NISTC_AI_MODE3_TRIG_LEN BIT(15) +#define NISTC_AI_MODE3_DELAY_START BIT(14) +#define NISTC_AI_MODE3_SOFTWARE_GATE BIT(13) +#define NISTC_AI_MODE3_SI_TRIG_DELAY BIT(12) +#define NISTC_AI_MODE3_SI2_SRC_SEL BIT(11) +#define NISTC_AI_MODE3_DELAYED_START2 BIT(10) +#define NISTC_AI_MODE3_DELAYED_START1 BIT(9) +#define NISTC_AI_MODE3_EXT_GATE_MODE BIT(8) +#define NISTC_AI_MODE3_FIFO_MODE(x) (((x) & 0x3) << 6) +#define NISTC_AI_MODE3_FIFO_MODE_NE NISTC_AI_MODE3_FIFO_MODE(0) +#define NISTC_AI_MODE3_FIFO_MODE_HF NISTC_AI_MODE3_FIFO_MODE(1) +#define NISTC_AI_MODE3_FIFO_MODE_F NISTC_AI_MODE3_FIFO_MODE(2) +#define NISTC_AI_MODE3_FIFO_MODE_HF_E NISTC_AI_MODE3_FIFO_MODE(3) +#define NISTC_AI_MODE3_EXT_GATE_POL BIT(5) +#define NISTC_AI_MODE3_EXT_GATE_SEL(x) (((x) & 0x1f) << 0) + #define AI_Status_1_Register 2 #define Interrupt_A_St 0x8000 #define AI_FIFO_Full_St 0x4000 @@ -533,22 +550,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define AI_Mode_3_Register 87 -#define AI_Trigger_Length _bit15 -#define AI_Delay_START _bit14 -#define AI_Software_Gate _bit13 -#define AI_SI_Special_Trigger_Delay _bit12 -#define AI_SI2_Source_Select _bit11 -#define AI_Delayed_START2 _bit10 -#define AI_Delayed_START1 _bit9 -#define AI_External_Gate_Mode _bit8 -#define AI_FIFO_Mode_HF_to_E (3<<6) -#define AI_FIFO_Mode_F (2<<6) -#define AI_FIFO_Mode_HF (1<<6) -#define AI_FIFO_Mode_NE (0<<6) -#define AI_External_Gate_Polarity _bit5 -#define AI_External_Gate_Select(a) ((a) & 0x1f) - #define G_HW_Save_Register(a) (8+(a)*2) #define G_HW_Save_Register_High(a) (8+(a)*2) #define G_HW_Save_Register_Low(a) (9+(a)*2) From 7b14fffd7832dd571a82c18bd0b58319b40d7378 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:37 -0700 Subject: [PATCH 0373/1163] staging: comedi: ni_stc.h: tidy up AI_Status_1_Register and bits Rename the CamelCase. Use the BIT() marco to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 65 +++++++++---------- drivers/staging/comedi/drivers/ni_stc.h | 38 ++++++----- 2 files changed, 53 insertions(+), 50 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index c0bd097ac13f..50a14d287613 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -410,7 +410,7 @@ static void m_series_stc_write(struct comedi_device *dev, } static const struct mio_regmap m_series_stc_read_regmap[] = { - [AI_Status_1_Register] = { 0x104, 2 }, + [NISTC_AI_STATUS1_REG] = { 0x104, 2 }, [AO_Status_1_Register] = { 0x106, 2 }, [G_Status_Register] = { 0x108, 2 }, [AI_Status_2_Register] = { 0, 0 }, /* Unknown */ @@ -950,8 +950,8 @@ static int ni_ai_drain_dma(struct comedi_device *dev) spin_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->ai_mite_chan) { for (i = 0; i < timeout; i++) { - if ((ni_stc_readw(dev, AI_Status_1_Register) & - AI_FIFO_Empty_St) + if ((ni_stc_readw(dev, NISTC_AI_STATUS1_REG) & + NISTC_AI_STATUS1_FIFO_E) && mite_bytes_in_transit(devpriv->ai_mite_chan) == 0) break; @@ -962,7 +962,7 @@ static int ni_ai_drain_dma(struct comedi_device *dev) dev_err(dev->class_dev, "mite_bytes_in_transit=%i, AI_Status1_Register=0x%x\n", mite_bytes_in_transit(devpriv->ai_mite_chan), - ni_stc_readw(dev, AI_Status_1_Register)); + ni_stc_readw(dev, NISTC_AI_STATUS1_REG)); retval = -1; } } @@ -1185,8 +1185,8 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev) int i; if (devpriv->is_611x) { - while ((ni_stc_readw(dev, AI_Status_1_Register) & - AI_FIFO_Empty_St) == 0) { + while ((ni_stc_readw(dev, NISTC_AI_STATUS1_REG) & + NISTC_AI_STATUS1_FIFO_E) == 0) { dl = ni_readl(dev, ADC_FIFO_Data_611x); /* This may get the hi/lo data in the wrong order */ @@ -1217,16 +1217,16 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev) } } else { - fifo_empty = ni_stc_readw(dev, AI_Status_1_Register) & - AI_FIFO_Empty_St; + fifo_empty = ni_stc_readw(dev, NISTC_AI_STATUS1_REG) & + NISTC_AI_STATUS1_FIFO_E; while (fifo_empty == 0) { for (i = 0; i < sizeof(devpriv->ai_fifo_buffer) / sizeof(devpriv->ai_fifo_buffer[0]); i++) { fifo_empty = ni_stc_readw(dev, - AI_Status_1_Register) & - AI_FIFO_Empty_St; + NISTC_AI_STATUS1_REG) & + NISTC_AI_STATUS1_FIFO_E; if (fifo_empty) break; devpriv->ai_fifo_buffer[i] = @@ -1335,13 +1335,13 @@ static void ack_a_interrupt(struct comedi_device *dev, unsigned short a_status) { unsigned short ack = 0; - if (a_status & AI_SC_TC_St) + if (a_status & NISTC_AI_STATUS1_SC_TC) ack |= NISTC_INTA_ACK_AI_SC_TC; - if (a_status & AI_START1_St) + if (a_status & NISTC_AI_STATUS1_START1) ack |= NISTC_INTA_ACK_AI_START1; - if (a_status & AI_START_St) + if (a_status & NISTC_AI_STATUS1_START) ack |= NISTC_INTA_ACK_AI_START; - if (a_status & AI_STOP_St) + if (a_status & NISTC_AI_STATUS1_STOP) ack |= NISTC_INTA_ACK_AI_STOP; if (ack) ni_stc_writew(dev, ack, NISTC_INTA_ACK_REG); @@ -1373,8 +1373,8 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status, #endif /* test for all uncommon interrupt events at the same time */ - if (status & (AI_Overrun_St | AI_Overflow_St | AI_SC_TC_Error_St | - AI_SC_TC_St | AI_START1_St)) { + if (status & (NISTC_AI_STATUS1_ERR | + NISTC_AI_STATUS1_SC_TC | NISTC_AI_STATUS1_START1)) { if (status == 0xffff) { dev_err(dev->class_dev, "Card removed?\n"); /* we probably aren't even running a command now, @@ -1385,41 +1385,40 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status, } return; } - if (status & (AI_Overrun_St | AI_Overflow_St | - AI_SC_TC_Error_St)) { + if (status & NISTC_AI_STATUS1_ERR) { dev_err(dev->class_dev, "ai error a_status=%04x\n", status); shutdown_ai_command(dev); s->async->events |= COMEDI_CB_ERROR; - if (status & (AI_Overrun_St | AI_Overflow_St)) + if (status & NISTC_AI_STATUS1_OVER) s->async->events |= COMEDI_CB_OVERFLOW; comedi_handle_events(dev, s); return; } - if (status & AI_SC_TC_St) { + if (status & NISTC_AI_STATUS1_SC_TC) { if (cmd->stop_src == TRIG_COUNT) shutdown_ai_command(dev); } } #ifndef PCIDMA - if (status & AI_FIFO_Half_Full_St) { + if (status & NISTC_AI_STATUS1_FIFO_HF) { int i; static const int timeout = 10; /* pcmcia cards (at least 6036) seem to stop producing interrupts if we *fail to get the fifo less than half full, so loop to be sure.*/ for (i = 0; i < timeout; ++i) { ni_handle_fifo_half_full(dev); - if ((ni_stc_readw(dev, AI_Status_1_Register) & - AI_FIFO_Half_Full_St) == 0) + if ((ni_stc_readw(dev, NISTC_AI_STATUS1_REG) & + NISTC_AI_STATUS1_FIFO_HF) == 0) break; } } #endif /* !PCIDMA */ - if ((status & AI_STOP_St)) + if (status & NISTC_AI_STATUS1_STOP) ni_handle_eos(dev, s); comedi_handle_events(dev, s); @@ -1695,8 +1694,8 @@ static void ni_prime_channelgain_list(struct comedi_device *dev) ni_stc_writew(dev, NISTC_AI_CMD1_CONVERT_PULSE, NISTC_AI_CMD1_REG); for (i = 0; i < NI_TIMEOUT; ++i) { - if (!(ni_stc_readw(dev, AI_Status_1_Register) & - AI_FIFO_Empty_St)) { + if (!(ni_stc_readw(dev, NISTC_AI_STATUS1_REG) & + NISTC_AI_STATUS1_FIFO_E)) { ni_stc_writew(dev, 1, NISTC_ADC_FIFO_CLR_REG); return; } @@ -1953,8 +1952,8 @@ static int ni_ai_insn_read(struct comedi_device *dev, d &= 0xffff; break; } - if (!(ni_stc_readw(dev, AI_Status_1_Register) & - AI_FIFO_Empty_St)) { + if (!(ni_stc_readw(dev, NISTC_AI_STATUS1_REG) & + NISTC_AI_STATUS1_FIFO_E)) { d = ni_readl(dev, ADC_FIFO_Data_611x); d &= 0xffff; break; @@ -1994,8 +1993,8 @@ static int ni_ai_insn_read(struct comedi_device *dev, ni_stc_writew(dev, NISTC_AI_CMD1_CONVERT_PULSE, NISTC_AI_CMD1_REG); for (i = 0; i < NI_TIMEOUT; i++) { - if (!(ni_stc_readw(dev, AI_Status_1_Register) & - AI_FIFO_Empty_St)) + if (!(ni_stc_readw(dev, NISTC_AI_STATUS1_REG) & + NISTC_AI_STATUS1_FIFO_E)) break; } if (i == NI_TIMEOUT) { @@ -3736,7 +3735,7 @@ static const struct mio_regmap ni_gpct_to_stc_regmap[] = { [NITIO_G1_ABZ] = { 0x1c2, 2 }, /* M-Series only */ [NITIO_G0_INT_ACK] = { NISTC_INTA_ACK_REG, 2 }, [NITIO_G1_INT_ACK] = { NISTC_INTB_ACK_REG, 2 }, - [NITIO_G0_STATUS] = { AI_Status_1_Register, 2 }, + [NITIO_G0_STATUS] = { NISTC_AI_STATUS1_REG, 2 }, [NITIO_G1_STATUS] = { AO_Status_1_Register, 2 }, [NITIO_G0_INT_ENA] = { NISTC_INTA_ENA_REG, 2 }, [NITIO_G1_INT_ENA] = { NISTC_INTB_ENA_REG, 2 }, @@ -4992,7 +4991,7 @@ static irqreturn_t ni_E_interrupt(int irq, void *d) /* lock to avoid race with comedi_poll */ spin_lock_irqsave(&dev->spinlock, flags); - a_status = ni_stc_readw(dev, AI_Status_1_Register); + a_status = ni_stc_readw(dev, NISTC_AI_STATUS1_REG); b_status = ni_stc_readw(dev, AO_Status_1_Register); #ifdef PCIDMA if (mite) { @@ -5021,7 +5020,7 @@ static irqreturn_t ni_E_interrupt(int irq, void *d) #endif ack_a_interrupt(dev, a_status); ack_b_interrupt(dev, b_status); - if ((a_status & Interrupt_A_St) || (ai_mite_status & CHSR_INT)) + if ((a_status & NISTC_AI_STATUS1_INTA) || (ai_mite_status & CHSR_INT)) handle_a_interrupt(dev, a_status, ai_mite_status); if ((b_status & Interrupt_B_St) || (ao_mite_status & CHSR_INT)) handle_b_interrupt(dev, b_status, ao_mite_status); diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 6c9bb6c4d2f0..1681376af182 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -492,23 +492,27 @@ #define NISTC_AI_MODE3_EXT_GATE_POL BIT(5) #define NISTC_AI_MODE3_EXT_GATE_SEL(x) (((x) & 0x1f) << 0) -#define AI_Status_1_Register 2 -#define Interrupt_A_St 0x8000 -#define AI_FIFO_Full_St 0x4000 -#define AI_FIFO_Half_Full_St 0x2000 -#define AI_FIFO_Empty_St 0x1000 -#define AI_Overrun_St 0x0800 -#define AI_Overflow_St 0x0400 -#define AI_SC_TC_Error_St 0x0200 -#define AI_START2_St 0x0100 -#define AI_START1_St 0x0080 -#define AI_SC_TC_St 0x0040 -#define AI_START_St 0x0020 -#define AI_STOP_St 0x0010 -#define G0_TC_St 0x0008 -#define G0_Gate_Interrupt_St 0x0004 -#define AI_FIFO_Request_St 0x0002 -#define Pass_Thru_0_Interrupt_St 0x0001 +#define NISTC_AI_STATUS1_REG 2 +#define NISTC_AI_STATUS1_INTA BIT(15) +#define NISTC_AI_STATUS1_FIFO_F BIT(14) +#define NISTC_AI_STATUS1_FIFO_HF BIT(13) +#define NISTC_AI_STATUS1_FIFO_E BIT(12) +#define NISTC_AI_STATUS1_OVERRUN BIT(11) +#define NISTC_AI_STATUS1_OVERFLOW BIT(10) +#define NISTC_AI_STATUS1_SC_TC_ERR BIT(9) +#define NISTC_AI_STATUS1_OVER (NISTC_AI_STATUS1_OVERRUN | \ + NISTC_AI_STATUS1_OVERFLOW) +#define NISTC_AI_STATUS1_ERR (NISTC_AI_STATUS1_OVER | \ + NISTC_AI_STATUS1_SC_TC_ERR) +#define NISTC_AI_STATUS1_START2 BIT(8) +#define NISTC_AI_STATUS1_START1 BIT(7) +#define NISTC_AI_STATUS1_SC_TC BIT(6) +#define NISTC_AI_STATUS1_START BIT(5) +#define NISTC_AI_STATUS1_STOP BIT(4) +#define NISTC_AI_STATUS1_G0_TC BIT(3) +#define NISTC_AI_STATUS1_G0_GATE BIT(2) +#define NISTC_AI_STATUS1_FIFO_REQ BIT(1) +#define NISTC_AI_STATUS1_PASSTHRU0 BIT(0) #define AI_Status_2_Register 5 From d123ee3ce0803e47a477f8efe680d549967e10f0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:38 -0700 Subject: [PATCH 0374/1163] staging: comedi: ni_stc.h: tidy up AO_Status_1_Register and bits Rename the CamelCase. Use the BIT() marco to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 32 ++++++++--------- drivers/staging/comedi/drivers/ni_stc.h | 36 +++++++++---------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 50a14d287613..d7a723256e1a 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -411,7 +411,7 @@ static void m_series_stc_write(struct comedi_device *dev, static const struct mio_regmap m_series_stc_read_regmap[] = { [NISTC_AI_STATUS1_REG] = { 0x104, 2 }, - [AO_Status_1_Register] = { 0x106, 2 }, + [NISTC_AO_STATUS1_REG] = { 0x106, 2 }, [G_Status_Register] = { 0x108, 2 }, [AI_Status_2_Register] = { 0, 0 }, /* Unknown */ [AO_Status_2_Register] = { 0x10c, 2 }, @@ -994,8 +994,8 @@ static int ni_ao_wait_for_dma_load(struct comedi_device *dev) for (i = 0; i < timeout; i++) { unsigned short b_status; - b_status = ni_stc_readw(dev, AO_Status_1_Register); - if (b_status & AO_FIFO_Half_Full_St) + b_status = ni_stc_readw(dev, NISTC_AO_STATUS1_REG); + if (b_status & NISTC_AO_STATUS1_FIFO_HF) break; /* if we poll too often, the pci bus activity seems to slow the dma transfer down */ @@ -1428,19 +1428,19 @@ static void ack_b_interrupt(struct comedi_device *dev, unsigned short b_status) { unsigned short ack = 0; - if (b_status & AO_BC_TC_St) + if (b_status & NISTC_AO_STATUS1_BC_TC) ack |= NISTC_INTB_ACK_AO_BC_TC; - if (b_status & AO_Overrun_St) + if (b_status & NISTC_AO_STATUS1_OVERRUN) ack |= NISTC_INTB_ACK_AO_ERR; - if (b_status & AO_START_St) + if (b_status & NISTC_AO_STATUS1_START) ack |= NISTC_INTB_ACK_AO_START; - if (b_status & AO_START1_St) + if (b_status & NISTC_AO_STATUS1_START1) ack |= NISTC_INTB_ACK_AO_START1; - if (b_status & AO_UC_TC_St) + if (b_status & NISTC_AO_STATUS1_UC_TC) ack |= NISTC_INTB_ACK_AO_UC_TC; - if (b_status & AO_UI2_TC_St) + if (b_status & NISTC_AO_STATUS1_UI2_TC) ack |= NISTC_INTB_ACK_AO_UI2_TC; - if (b_status & AO_UPDATE_St) + if (b_status & NISTC_AO_STATUS1_UPDATE) ack |= NISTC_INTB_ACK_AO_UPDATE; if (ack) ni_stc_writew(dev, ack, NISTC_INTB_ACK_REG); @@ -1472,18 +1472,18 @@ static void handle_b_interrupt(struct comedi_device *dev, if (b_status == 0xffff) return; - if (b_status & AO_Overrun_St) { + if (b_status & NISTC_AO_STATUS1_OVERRUN) { dev_err(dev->class_dev, "AO FIFO underrun status=0x%04x status2=0x%04x\n", b_status, ni_stc_readw(dev, AO_Status_2_Register)); s->async->events |= COMEDI_CB_OVERFLOW; } - if (b_status & AO_BC_TC_St) + if (b_status & NISTC_AO_STATUS1_BC_TC) s->async->events |= COMEDI_CB_EOA; #ifndef PCIDMA - if (b_status & AO_FIFO_Request_St) { + if (b_status & NISTC_AO_STATUS1_FIFO_REQ) { int ret; ret = ni_ao_fifo_half_empty(dev, s); @@ -3736,7 +3736,7 @@ static const struct mio_regmap ni_gpct_to_stc_regmap[] = { [NITIO_G0_INT_ACK] = { NISTC_INTA_ACK_REG, 2 }, [NITIO_G1_INT_ACK] = { NISTC_INTB_ACK_REG, 2 }, [NITIO_G0_STATUS] = { NISTC_AI_STATUS1_REG, 2 }, - [NITIO_G1_STATUS] = { AO_Status_1_Register, 2 }, + [NITIO_G1_STATUS] = { NISTC_AO_STATUS1_REG, 2 }, [NITIO_G0_INT_ENA] = { NISTC_INTA_ENA_REG, 2 }, [NITIO_G1_INT_ENA] = { NISTC_INTB_ENA_REG, 2 }, }; @@ -4992,7 +4992,7 @@ static irqreturn_t ni_E_interrupt(int irq, void *d) /* lock to avoid race with comedi_poll */ spin_lock_irqsave(&dev->spinlock, flags); a_status = ni_stc_readw(dev, NISTC_AI_STATUS1_REG); - b_status = ni_stc_readw(dev, AO_Status_1_Register); + b_status = ni_stc_readw(dev, NISTC_AO_STATUS1_REG); #ifdef PCIDMA if (mite) { struct ni_private *devpriv = dev->private; @@ -5022,7 +5022,7 @@ static irqreturn_t ni_E_interrupt(int irq, void *d) ack_b_interrupt(dev, b_status); if ((a_status & NISTC_AI_STATUS1_INTA) || (ai_mite_status & CHSR_INT)) handle_a_interrupt(dev, a_status, ai_mite_status); - if ((b_status & Interrupt_B_St) || (ao_mite_status & CHSR_INT)) + if ((b_status & NISTC_AO_STATUS1_INTB) || (ao_mite_status & CHSR_INT)) handle_b_interrupt(dev, b_status, ao_mite_status); handle_gpct_interrupt(dev, 0); handle_gpct_interrupt(dev, 1); diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 1681376af182..e1f4b66144ba 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -514,25 +514,25 @@ #define NISTC_AI_STATUS1_FIFO_REQ BIT(1) #define NISTC_AI_STATUS1_PASSTHRU0 BIT(0) -#define AI_Status_2_Register 5 +#define NISTC_AO_STATUS1_REG 3 +#define NISTC_AO_STATUS1_INTB BIT(15) +#define NISTC_AO_STATUS1_FIFO_F BIT(14) +#define NISTC_AO_STATUS1_FIFO_HF BIT(13) +#define NISTC_AO_STATUS1_FIFO_E BIT(12) +#define NISTC_AO_STATUS1_BC_TC_ERR BIT(11) +#define NISTC_AO_STATUS1_START BIT(10) +#define NISTC_AO_STATUS1_OVERRUN BIT(9) +#define NISTC_AO_STATUS1_START1 BIT(8) +#define NISTC_AO_STATUS1_BC_TC BIT(7) +#define NISTC_AO_STATUS1_UC_TC BIT(6) +#define NISTC_AO_STATUS1_UPDATE BIT(5) +#define NISTC_AO_STATUS1_UI2_TC BIT(4) +#define NISTC_AO_STATUS1_G1_TC BIT(3) +#define NISTC_AO_STATUS1_G1_GATE BIT(2) +#define NISTC_AO_STATUS1_FIFO_REQ BIT(1) +#define NISTC_AO_STATUS1_PASSTHRU1 BIT(0) -#define AO_Status_1_Register 3 -#define Interrupt_B_St _bit15 -#define AO_FIFO_Full_St _bit14 -#define AO_FIFO_Half_Full_St _bit13 -#define AO_FIFO_Empty_St _bit12 -#define AO_BC_TC_Error_St _bit11 -#define AO_START_St _bit10 -#define AO_Overrun_St _bit9 -#define AO_START1_St _bit8 -#define AO_BC_TC_St _bit7 -#define AO_UC_TC_St _bit6 -#define AO_UPDATE_St _bit5 -#define AO_UI2_TC_St _bit4 -#define G1_TC_St _bit3 -#define G1_Gate_Interrupt_St _bit2 -#define AO_FIFO_Request_St _bit1 -#define Pass_Thru_1_Interrupt_St _bit0 +#define AI_Status_2_Register 5 #define AO_Status_2_Register 6 From 7f0e1bac320430cb94316057e91c1f15cc6e19cf Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:39 -0700 Subject: [PATCH 0375/1163] staging: comedi: ni_stc.h: tidy up G_Status_Register Rename the CamelCase. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 4 ++-- drivers/staging/comedi/drivers/ni_stc.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index d7a723256e1a..a71a697f2b9b 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -412,7 +412,7 @@ static void m_series_stc_write(struct comedi_device *dev, static const struct mio_regmap m_series_stc_read_regmap[] = { [NISTC_AI_STATUS1_REG] = { 0x104, 2 }, [NISTC_AO_STATUS1_REG] = { 0x106, 2 }, - [G_Status_Register] = { 0x108, 2 }, + [NISTC_G01_STATUS_REG] = { 0x108, 2 }, [AI_Status_2_Register] = { 0, 0 }, /* Unknown */ [AO_Status_2_Register] = { 0x10c, 2 }, [DIO_Parallel_Input_Register] = { 0, 0 }, /* Unknown */ @@ -3723,7 +3723,7 @@ static const struct mio_regmap ni_gpct_to_stc_regmap[] = { [NITIO_G1_CNT_MODE] = { 0x1b2, 2 }, /* M-Series only */ [NITIO_G0_GATE2] = { 0x1b4, 2 }, /* M-Series only */ [NITIO_G1_GATE2] = { 0x1b6, 2 }, /* M-Series only */ - [NITIO_G01_STATUS] = { G_Status_Register, 2 }, + [NITIO_G01_STATUS] = { NISTC_G01_STATUS_REG, 2 }, [NITIO_G01_RESET] = { NISTC_RESET_REG, 2 }, [NITIO_G01_STATUS1] = { Joint_Status_1_Register, 2 }, [NITIO_G01_STATUS2] = { Joint_Status_2_Register, 2 }, diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index e1f4b66144ba..5950bab41c77 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -532,6 +532,8 @@ #define NISTC_AO_STATUS1_FIFO_REQ BIT(1) #define NISTC_AO_STATUS1_PASSTHRU1 BIT(0) +#define NISTC_G01_STATUS_REG 4 + #define AI_Status_2_Register 5 #define AO_Status_2_Register 6 @@ -560,7 +562,6 @@ enum Joint_Status_2_Bits { #define G_Save_Register(a) (12+(a)*2) #define G_Save_Register_High(a) (12+(a)*2) #define G_Save_Register_Low(a) (13+(a)*2) -#define G_Status_Register 4 /* command register */ #define G_Disarm_Copy _bit15 /* strobe */ From 3ca18feff7c4259f3f809575fdb26bdc7828a9bd Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:40 -0700 Subject: [PATCH 0376/1163] staging: comedi: ni_stc.h: tidy up AI_Status_2_Register Rename the CamelCase. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 2 +- drivers/staging/comedi/drivers/ni_stc.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index a71a697f2b9b..7b579376f3ba 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -413,7 +413,7 @@ static const struct mio_regmap m_series_stc_read_regmap[] = { [NISTC_AI_STATUS1_REG] = { 0x104, 2 }, [NISTC_AO_STATUS1_REG] = { 0x106, 2 }, [NISTC_G01_STATUS_REG] = { 0x108, 2 }, - [AI_Status_2_Register] = { 0, 0 }, /* Unknown */ + [NISTC_AI_STATUS2_REG] = { 0, 0 }, /* Unknown */ [AO_Status_2_Register] = { 0x10c, 2 }, [DIO_Parallel_Input_Register] = { 0, 0 }, /* Unknown */ [G_HW_Save_Register(0)] = { 0x110, 4 }, diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 5950bab41c77..2f72c47ef2f6 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -534,7 +534,7 @@ #define NISTC_G01_STATUS_REG 4 -#define AI_Status_2_Register 5 +#define NISTC_AI_STATUS2_REG 5 #define AO_Status_2_Register 6 From 63b2bb05e1ac74c309d61d6c0763c5fb75cc8791 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:41 -0700 Subject: [PATCH 0377/1163] staging: comedi: ni_stc.h: tidy up AO_Status_2_Register Rename the CamelCase. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 4 ++-- drivers/staging/comedi/drivers/ni_stc.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 7b579376f3ba..6b7013831ef7 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -414,7 +414,7 @@ static const struct mio_regmap m_series_stc_read_regmap[] = { [NISTC_AO_STATUS1_REG] = { 0x106, 2 }, [NISTC_G01_STATUS_REG] = { 0x108, 2 }, [NISTC_AI_STATUS2_REG] = { 0, 0 }, /* Unknown */ - [AO_Status_2_Register] = { 0x10c, 2 }, + [NISTC_AO_STATUS2_REG] = { 0x10c, 2 }, [DIO_Parallel_Input_Register] = { 0, 0 }, /* Unknown */ [G_HW_Save_Register(0)] = { 0x110, 4 }, [G_HW_Save_Register(1)] = { 0x114, 4 }, @@ -1475,7 +1475,7 @@ static void handle_b_interrupt(struct comedi_device *dev, if (b_status & NISTC_AO_STATUS1_OVERRUN) { dev_err(dev->class_dev, "AO FIFO underrun status=0x%04x status2=0x%04x\n", - b_status, ni_stc_readw(dev, AO_Status_2_Register)); + b_status, ni_stc_readw(dev, NISTC_AO_STATUS2_REG)); s->async->events |= COMEDI_CB_OVERFLOW; } diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 2f72c47ef2f6..4411f7baeeee 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -536,7 +536,7 @@ #define NISTC_AI_STATUS2_REG 5 -#define AO_Status_2_Register 6 +#define NISTC_AO_STATUS2_REG 6 #define DIO_Parallel_Input_Register 7 From 6f764a47f3311c6f283d050e6630683569e07f33 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:42 -0700 Subject: [PATCH 0378/1163] staging: comedi: ni_stc.h: tidy up DIO_Parallel_Input_Register Rename the CamelCase. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 7 +++---- drivers/staging/comedi/drivers/ni_stc.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 6b7013831ef7..ea30689818d5 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -415,7 +415,7 @@ static const struct mio_regmap m_series_stc_read_regmap[] = { [NISTC_G01_STATUS_REG] = { 0x108, 2 }, [NISTC_AI_STATUS2_REG] = { 0, 0 }, /* Unknown */ [NISTC_AO_STATUS2_REG] = { 0x10c, 2 }, - [DIO_Parallel_Input_Register] = { 0, 0 }, /* Unknown */ + [NISTC_DIO_IN_REG] = { 0, 0 }, /* Unknown */ [G_HW_Save_Register(0)] = { 0x110, 4 }, [G_HW_Save_Register(1)] = { 0x114, 4 }, [G_Save_Register(0)] = { 0x118, 4 }, @@ -3264,7 +3264,7 @@ static int ni_dio_insn_bits(struct comedi_device *dev, ni_stc_writew(dev, devpriv->dio_output, NISTC_DIO_OUT_REG); } - data[1] = ni_stc_readw(dev, DIO_Parallel_Input_Register); + data[1] = ni_stc_readw(dev, NISTC_DIO_IN_REG); return insn->n; } @@ -3591,8 +3591,7 @@ static int ni_serial_sw_readwrite8(struct comedi_device *dev, udelay((devpriv->serial_interval_ns + 999) / 2000); /* Input current bit */ - if (ni_stc_readw(dev, DIO_Parallel_Input_Register) & - NISTC_DIO_SDIN) + if (ni_stc_readw(dev, NISTC_DIO_IN_REG) & NISTC_DIO_SDIN) input |= mask; } diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 4411f7baeeee..5be6a9505ab4 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -538,7 +538,7 @@ #define NISTC_AO_STATUS2_REG 6 -#define DIO_Parallel_Input_Register 7 +#define NISTC_DIO_IN_REG 7 #define AI_SI_Save_Registers 64 #define AI_SC_Save_Registers 66 From 27650d99004d8fc962c56c9c2260af0cb5f2ff7d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:43 -0700 Subject: [PATCH 0379/1163] staging: comedi: ni_stc.h: tidy up G_HW_Save_Register Rename the CamelCase and define the G0 and G1 registers to add clarity to the mio_regmap tables. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 8 ++++---- drivers/staging/comedi/drivers/ni_stc.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index ea30689818d5..f0f449c5dce5 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -416,8 +416,8 @@ static const struct mio_regmap m_series_stc_read_regmap[] = { [NISTC_AI_STATUS2_REG] = { 0, 0 }, /* Unknown */ [NISTC_AO_STATUS2_REG] = { 0x10c, 2 }, [NISTC_DIO_IN_REG] = { 0, 0 }, /* Unknown */ - [G_HW_Save_Register(0)] = { 0x110, 4 }, - [G_HW_Save_Register(1)] = { 0x114, 4 }, + [NISTC_G0_HW_SAVE_REG] = { 0x110, 4 }, + [NISTC_G1_HW_SAVE_REG] = { 0x114, 4 }, [G_Save_Register(0)] = { 0x118, 4 }, [G_Save_Register(1)] = { 0x11c, 4 }, [AO_UI_Save_Registers] = { 0x120, 4 }, @@ -3706,8 +3706,8 @@ static const struct mio_regmap ni_gpct_to_stc_regmap[] = { [NITIO_G1_AUTO_INC] = { NISTC_G1_AUTOINC_REG, 2 }, [NITIO_G0_CMD] = { NISTC_G0_CMD_REG, 2 }, [NITIO_G1_CMD] = { NISTC_G1_CMD_REG, 2 }, - [NITIO_G0_HW_SAVE] = { G_HW_Save_Register(0), 4 }, - [NITIO_G1_HW_SAVE] = { G_HW_Save_Register(1), 4 }, + [NITIO_G0_HW_SAVE] = { NISTC_G0_HW_SAVE_REG, 4 }, + [NITIO_G1_HW_SAVE] = { NISTC_G1_HW_SAVE_REG, 4 }, [NITIO_G0_SW_SAVE] = { G_Save_Register(0), 4 }, [NITIO_G1_SW_SAVE] = { G_Save_Register(1), 4 }, [NITIO_G0_MODE] = { NISTC_G0_MODE_REG, 2 }, diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 5be6a9505ab4..0b4dcc475012 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -540,6 +540,9 @@ #define NISTC_DIO_IN_REG 7 +#define NISTC_G0_HW_SAVE_REG 8 +#define NISTC_G1_HW_SAVE_REG 10 + #define AI_SI_Save_Registers 64 #define AI_SC_Save_Registers 66 @@ -556,9 +559,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define G_HW_Save_Register(a) (8+(a)*2) -#define G_HW_Save_Register_High(a) (8+(a)*2) -#define G_HW_Save_Register_Low(a) (9+(a)*2) #define G_Save_Register(a) (12+(a)*2) #define G_Save_Register_High(a) (12+(a)*2) #define G_Save_Register_Low(a) (13+(a)*2) From d9c4115fcdea6737b72b715736b59bdc5b560835 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:44 -0700 Subject: [PATCH 0380/1163] staging: comedi: ni_stc.h: tidy up G_Save_Register Rename the CamelCase and define the G0 and G1 registers to add clarity to the mio_regmap tables. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 8 ++++---- drivers/staging/comedi/drivers/ni_stc.h | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index f0f449c5dce5..9cd796ce1832 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -418,8 +418,8 @@ static const struct mio_regmap m_series_stc_read_regmap[] = { [NISTC_DIO_IN_REG] = { 0, 0 }, /* Unknown */ [NISTC_G0_HW_SAVE_REG] = { 0x110, 4 }, [NISTC_G1_HW_SAVE_REG] = { 0x114, 4 }, - [G_Save_Register(0)] = { 0x118, 4 }, - [G_Save_Register(1)] = { 0x11c, 4 }, + [NISTC_G0_SAVE_REG] = { 0x118, 4 }, + [NISTC_G1_SAVE_REG] = { 0x11c, 4 }, [AO_UI_Save_Registers] = { 0x120, 4 }, [AO_BC_Save_Registers] = { 0x124, 4 }, [AO_UC_Save_Registers] = { 0x128, 4 }, @@ -3708,8 +3708,8 @@ static const struct mio_regmap ni_gpct_to_stc_regmap[] = { [NITIO_G1_CMD] = { NISTC_G1_CMD_REG, 2 }, [NITIO_G0_HW_SAVE] = { NISTC_G0_HW_SAVE_REG, 4 }, [NITIO_G1_HW_SAVE] = { NISTC_G1_HW_SAVE_REG, 4 }, - [NITIO_G0_SW_SAVE] = { G_Save_Register(0), 4 }, - [NITIO_G1_SW_SAVE] = { G_Save_Register(1), 4 }, + [NITIO_G0_SW_SAVE] = { NISTC_G0_SAVE_REG, 4 }, + [NITIO_G1_SW_SAVE] = { NISTC_G1_SAVE_REG, 4 }, [NITIO_G0_MODE] = { NISTC_G0_MODE_REG, 2 }, [NITIO_G1_MODE] = { NISTC_G1_MODE_REG, 2 }, [NITIO_G0_LOADA] = { NISTC_G0_LOADA_REG, 4 }, diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 0b4dcc475012..ff577210c23c 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -543,6 +543,9 @@ #define NISTC_G0_HW_SAVE_REG 8 #define NISTC_G1_HW_SAVE_REG 10 +#define NISTC_G0_SAVE_REG 12 +#define NISTC_G1_SAVE_REG 14 + #define AI_SI_Save_Registers 64 #define AI_SC_Save_Registers 66 @@ -559,10 +562,6 @@ enum Joint_Status_2_Bits { #define AO_BC_Save_Registers 18 #define AO_UC_Save_Registers 20 -#define G_Save_Register(a) (12+(a)*2) -#define G_Save_Register_High(a) (12+(a)*2) -#define G_Save_Register_Low(a) (13+(a)*2) - /* command register */ #define G_Disarm_Copy _bit15 /* strobe */ #define G_Save_Trace_Copy _bit14 From 2c090acdc981421765becba929d9581511bdbbd0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:45 -0700 Subject: [PATCH 0381/1163] staging: comedi: ni_stc.h: tidy up AO_*_Save_Registers Rename the CamelCase. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 6 +++--- drivers/staging/comedi/drivers/ni_stc.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 9cd796ce1832..b194d1558463 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -420,9 +420,9 @@ static const struct mio_regmap m_series_stc_read_regmap[] = { [NISTC_G1_HW_SAVE_REG] = { 0x114, 4 }, [NISTC_G0_SAVE_REG] = { 0x118, 4 }, [NISTC_G1_SAVE_REG] = { 0x11c, 4 }, - [AO_UI_Save_Registers] = { 0x120, 4 }, - [AO_BC_Save_Registers] = { 0x124, 4 }, - [AO_UC_Save_Registers] = { 0x128, 4 }, + [NISTC_AO_UI_SAVE_REG] = { 0x120, 4 }, + [NISTC_AO_BC_SAVE_REG] = { 0x124, 4 }, + [NISTC_AO_UC_SAVE_REG] = { 0x128, 4 }, [Joint_Status_1_Register] = { 0x136, 2 }, [DIO_Serial_Input_Register] = { 0x009, 1 }, [Joint_Status_2_Register] = { 0x13a, 2 }, diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index ff577210c23c..af07e4c7f698 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -546,6 +546,10 @@ #define NISTC_G0_SAVE_REG 12 #define NISTC_G1_SAVE_REG 14 +#define NISTC_AO_UI_SAVE_REG 16 +#define NISTC_AO_BC_SAVE_REG 18 +#define NISTC_AO_UC_SAVE_REG 20 + #define AI_SI_Save_Registers 64 #define AI_SC_Save_Registers 66 @@ -558,10 +562,6 @@ enum Joint_Status_2_Bits { AO_TMRDACWRs_In_Progress_St = 0x20, }; -#define AO_UI_Save_Registers 16 -#define AO_BC_Save_Registers 18 -#define AO_UC_Save_Registers 20 - /* command register */ #define G_Disarm_Copy _bit15 /* strobe */ #define G_Save_Trace_Copy _bit14 From d3fed0813242a2fa6604e627326724d7cae9a068 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:46 -0700 Subject: [PATCH 0382/1163] staging: comedi: ni_stc.h: tidy up Joint_Status_1_Register Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 18 ++++++++++-------- drivers/staging/comedi/drivers/ni_stc.h | 6 +++--- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index b194d1558463..9051477f7ac6 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -423,7 +423,7 @@ static const struct mio_regmap m_series_stc_read_regmap[] = { [NISTC_AO_UI_SAVE_REG] = { 0x120, 4 }, [NISTC_AO_BC_SAVE_REG] = { 0x124, 4 }, [NISTC_AO_UC_SAVE_REG] = { 0x128, 4 }, - [Joint_Status_1_Register] = { 0x136, 2 }, + [NISTC_STATUS1_REG] = { 0x136, 2 }, [DIO_Serial_Input_Register] = { 0x009, 1 }, [Joint_Status_2_Register] = { 0x13a, 2 }, [AI_SI_Save_Registers] = { 0x180, 4 }, @@ -3522,8 +3522,8 @@ static int ni_serial_hw_readwrite8(struct comedi_device *dev, devpriv->dio_output |= NISTC_DIO_OUT_SERIAL(data_out); ni_stc_writew(dev, devpriv->dio_output, NISTC_DIO_OUT_REG); - status1 = ni_stc_readw(dev, Joint_Status_1_Register); - if (status1 & DIO_Serial_IO_In_Progress_St) { + status1 = ni_stc_readw(dev, NISTC_STATUS1_REG); + if (status1 & NISTC_STATUS1_SERIO_IN_PROG) { err = -EBUSY; goto Error; } @@ -3533,8 +3533,8 @@ static int ni_serial_hw_readwrite8(struct comedi_device *dev, devpriv->dio_control &= ~NISTC_DIO_CTRL_HW_SER_START; /* Wait until STC says we're done, but don't loop infinitely. */ - while ((status1 = ni_stc_readw(dev, Joint_Status_1_Register)) & - DIO_Serial_IO_In_Progress_St) { + while ((status1 = ni_stc_readw(dev, NISTC_STATUS1_REG)) & + NISTC_STATUS1_SERIO_IN_PROG) { /* Delay one bit per loop */ udelay((devpriv->serial_interval_ns + 999) / 1000); if (--count < 0) { @@ -3545,8 +3545,10 @@ static int ni_serial_hw_readwrite8(struct comedi_device *dev, } } - /* Delay for last bit. This delay is absolutely necessary, because - DIO_Serial_IO_In_Progress_St goes high one bit too early. */ + /* + * Delay for last bit. This delay is absolutely necessary, because + * NISTC_STATUS1_SERIO_IN_PROG goes high one bit too early. + */ udelay((devpriv->serial_interval_ns + 999) / 1000); if (data_in) @@ -3724,7 +3726,7 @@ static const struct mio_regmap ni_gpct_to_stc_regmap[] = { [NITIO_G1_GATE2] = { 0x1b6, 2 }, /* M-Series only */ [NITIO_G01_STATUS] = { NISTC_G01_STATUS_REG, 2 }, [NITIO_G01_RESET] = { NISTC_RESET_REG, 2 }, - [NITIO_G01_STATUS1] = { Joint_Status_1_Register, 2 }, + [NITIO_G01_STATUS1] = { NISTC_STATUS1_REG, 2 }, [NITIO_G01_STATUS2] = { Joint_Status_2_Register, 2 }, [NITIO_G0_DMA_CFG] = { 0x1b8, 2 }, /* M-Series only */ [NITIO_G1_DMA_CFG] = { 0x1ba, 2 }, /* M-Series only */ diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index af07e4c7f698..2d7f342790fa 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -550,12 +550,12 @@ #define NISTC_AO_BC_SAVE_REG 18 #define NISTC_AO_UC_SAVE_REG 20 +#define NISTC_STATUS1_REG 27 +#define NISTC_STATUS1_SERIO_IN_PROG BIT(12) + #define AI_SI_Save_Registers 64 #define AI_SC_Save_Registers 66 -#define Joint_Status_1_Register 27 -#define DIO_Serial_IO_In_Progress_St _bit12 - #define DIO_Serial_Input_Register 28 #define Joint_Status_2_Register 29 enum Joint_Status_2_Bits { From 8fbb015484a5d8038ced1d0bb81041e6b7437ccc Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:47 -0700 Subject: [PATCH 0383/1163] staging: comedi: ni_stc.h: tidy up DIO_Serial_Input_Register Rename the CamelCase. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 4 ++-- drivers/staging/comedi/drivers/ni_stc.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 9051477f7ac6..cb4aed174648 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -424,7 +424,7 @@ static const struct mio_regmap m_series_stc_read_regmap[] = { [NISTC_AO_BC_SAVE_REG] = { 0x124, 4 }, [NISTC_AO_UC_SAVE_REG] = { 0x128, 4 }, [NISTC_STATUS1_REG] = { 0x136, 2 }, - [DIO_Serial_Input_Register] = { 0x009, 1 }, + [NISTC_DIO_SERIAL_IN_REG] = { 0x009, 1 }, [Joint_Status_2_Register] = { 0x13a, 2 }, [AI_SI_Save_Registers] = { 0x180, 4 }, [AI_SC_Save_Registers] = { 0x184, 4 }, @@ -3552,7 +3552,7 @@ static int ni_serial_hw_readwrite8(struct comedi_device *dev, udelay((devpriv->serial_interval_ns + 999) / 1000); if (data_in) - *data_in = ni_stc_readw(dev, DIO_Serial_Input_Register); + *data_in = ni_stc_readw(dev, NISTC_DIO_SERIAL_IN_REG); Error: ni_stc_writew(dev, devpriv->dio_control, NISTC_DIO_CTRL_REG); diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 2d7f342790fa..509578c46a64 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -553,10 +553,11 @@ #define NISTC_STATUS1_REG 27 #define NISTC_STATUS1_SERIO_IN_PROG BIT(12) +#define NISTC_DIO_SERIAL_IN_REG 28 + #define AI_SI_Save_Registers 64 #define AI_SC_Save_Registers 66 -#define DIO_Serial_Input_Register 28 #define Joint_Status_2_Register 29 enum Joint_Status_2_Bits { AO_TMRDACWRs_In_Progress_St = 0x20, From bab382efa82265d8a13ba111028158adb8f48510 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:48 -0700 Subject: [PATCH 0384/1163] staging: comedi: ni_stc.h: tidy up Joint_Status_2_Register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 8 ++++---- drivers/staging/comedi/drivers/ni_stc.h | 8 +++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index cb4aed174648..17646a2f55b2 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -425,7 +425,7 @@ static const struct mio_regmap m_series_stc_read_regmap[] = { [NISTC_AO_UC_SAVE_REG] = { 0x128, 4 }, [NISTC_STATUS1_REG] = { 0x136, 2 }, [NISTC_DIO_SERIAL_IN_REG] = { 0x009, 1 }, - [Joint_Status_2_Register] = { 0x13a, 2 }, + [NISTC_STATUS2_REG] = { 0x13a, 2 }, [AI_SI_Save_Registers] = { 0x180, 4 }, [AI_SC_Save_Registers] = { 0x184, 4 }, }; @@ -2849,8 +2849,8 @@ static int ni_ao_inttrig(struct comedi_device *dev, /* wait for DACs to be loaded */ for (i = 0; i < timeout; i++) { udelay(1); - if ((ni_stc_readw(dev, Joint_Status_2_Register) & - AO_TMRDACWRs_In_Progress_St) == 0) + if ((ni_stc_readw(dev, NISTC_STATUS2_REG) & + NISTC_STATUS2_AO_TMRDACWRS_IN_PROGRESS) == 0) break; } if (i == timeout) { @@ -3727,7 +3727,7 @@ static const struct mio_regmap ni_gpct_to_stc_regmap[] = { [NITIO_G01_STATUS] = { NISTC_G01_STATUS_REG, 2 }, [NITIO_G01_RESET] = { NISTC_RESET_REG, 2 }, [NITIO_G01_STATUS1] = { NISTC_STATUS1_REG, 2 }, - [NITIO_G01_STATUS2] = { Joint_Status_2_Register, 2 }, + [NITIO_G01_STATUS2] = { NISTC_STATUS2_REG, 2 }, [NITIO_G0_DMA_CFG] = { 0x1b8, 2 }, /* M-Series only */ [NITIO_G1_DMA_CFG] = { 0x1ba, 2 }, /* M-Series only */ [NITIO_G0_DMA_STATUS] = { 0x1b8, 2 }, /* M-Series only */ diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 509578c46a64..cd4cf98fbd04 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -555,14 +555,12 @@ #define NISTC_DIO_SERIAL_IN_REG 28 +#define NISTC_STATUS2_REG 29 +#define NISTC_STATUS2_AO_TMRDACWRS_IN_PROGRESS BIT(5) + #define AI_SI_Save_Registers 64 #define AI_SC_Save_Registers 66 -#define Joint_Status_2_Register 29 -enum Joint_Status_2_Bits { - AO_TMRDACWRs_In_Progress_St = 0x20, -}; - /* command register */ #define G_Disarm_Copy _bit15 /* strobe */ #define G_Save_Trace_Copy _bit14 From 549835c76a3ab053c4450d23d9c11ae43290196d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:49 -0700 Subject: [PATCH 0385/1163] staging: comedi: ni_stc.h: tidy up AI_*_Save_Registers Rename the CamelCase. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 4 ++-- drivers/staging/comedi/drivers/ni_stc.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 17646a2f55b2..8dda682fca10 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -426,8 +426,8 @@ static const struct mio_regmap m_series_stc_read_regmap[] = { [NISTC_STATUS1_REG] = { 0x136, 2 }, [NISTC_DIO_SERIAL_IN_REG] = { 0x009, 1 }, [NISTC_STATUS2_REG] = { 0x13a, 2 }, - [AI_SI_Save_Registers] = { 0x180, 4 }, - [AI_SC_Save_Registers] = { 0x184, 4 }, + [NISTC_AI_SI_SAVE_REG] = { 0x180, 4 }, + [NISTC_AI_SC_SAVE_REG] = { 0x184, 4 }, }; static unsigned int m_series_stc_read(struct comedi_device *dev, diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index cd4cf98fbd04..da4495112e16 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -558,8 +558,8 @@ #define NISTC_STATUS2_REG 29 #define NISTC_STATUS2_AO_TMRDACWRS_IN_PROGRESS BIT(5) -#define AI_SI_Save_Registers 64 -#define AI_SC_Save_Registers 66 +#define NISTC_AI_SI_SAVE_REG 64 +#define NISTC_AI_SC_SAVE_REG 66 /* command register */ #define G_Disarm_Copy _bit15 /* strobe */ From 81bee07f955a5704c3c45b17a4771a7e802d4a86 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:50 -0700 Subject: [PATCH 0386/1163] staging: comedi: ni_stc.h: remove unused GPCT register bit defines The bit defines in this header for the GPCT registers are not used. The ones in ni_tio_internal.h are used instead. Remove them from this header. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_stc.h | 68 ------------------------- 1 file changed, 68 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index da4495112e16..45d841420aef 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -561,74 +561,6 @@ #define NISTC_AI_SI_SAVE_REG 64 #define NISTC_AI_SC_SAVE_REG 66 -/* command register */ -#define G_Disarm_Copy _bit15 /* strobe */ -#define G_Save_Trace_Copy _bit14 -#define G_Arm_Copy _bit13 /* strobe */ -#define G_Bank_Switch_Start _bit10 /* strobe */ -#define G_Little_Big_Endian _bit9 -#define G_Synchronized_Gate _bit8 -#define G_Write_Switch _bit7 -#define G_Up_Down(a) (((a)&0x03)<<5) -#define G_Disarm _bit4 /* strobe */ -#define G_Analog_Trigger_Reset _bit3 /* strobe */ -#define G_Save_Trace _bit1 -#define G_Arm _bit0 /* strobe */ - -/*channel agnostic names for the command register #defines */ -#define G_Bank_Switch_Enable _bit12 -#define G_Bank_Switch_Mode _bit11 -#define G_Load _bit2 /* strobe */ - -/* input select register */ -#define G_Gate_Select(a) (((a)&0x1f)<<7) -#define G_Source_Select(a) (((a)&0x1f)<<2) -#define G_Write_Acknowledges_Irq _bit1 -#define G_Read_Acknowledges_Irq _bit0 - -/* same input select register, but with channel agnostic names */ -#define G_Source_Polarity _bit15 -#define G_Output_Polarity _bit14 -#define G_OR_Gate _bit13 -#define G_Gate_Select_Load_Source _bit12 - -/* mode register */ -#define G_Loading_On_TC _bit12 -#define G_Output_Mode(a) (((a)&0x03)<<8) -#define G_Trigger_Mode_For_Edge_Gate(a) (((a)&0x03)<<3) -#define G_Gating_Mode(a) (((a)&0x03)<<0) - -/* same input mode register, but with channel agnostic names */ -#define G_Load_Source_Select _bit7 -#define G_Reload_Source_Switching _bit15 -#define G_Loading_On_Gate _bit14 -#define G_Gate_Polarity _bit13 - -#define G_Counting_Once(a) (((a)&0x03)<<10) -#define G_Stop_Mode(a) (((a)&0x03)<<5) -#define G_Gate_On_Both_Edges _bit2 - -/* G_Status_Register */ -#define G1_Gate_Error_St _bit15 -#define G0_Gate_Error_St _bit14 -#define G1_TC_Error_St _bit13 -#define G0_TC_Error_St _bit12 -#define G1_No_Load_Between_Gates_St _bit11 -#define G0_No_Load_Between_Gates_St _bit10 -#define G1_Armed_St _bit9 -#define G0_Armed_St _bit8 -#define G1_Stale_Data_St _bit7 -#define G0_Stale_Data_St _bit6 -#define G1_Next_Load_Source_St _bit5 -#define G0_Next_Load_Source_St _bit4 -#define G1_Counting_St _bit3 -#define G0_Counting_St _bit2 -#define G1_Save_St _bit1 -#define G0_Save_St _bit0 - -/* general purpose counter timer */ -#define G_Autoincrement(a) ((a)<<0) - /* Additional windowed registers unique to E series */ /* 16 bit registers shadowed from DAQ-STC */ From 4f809ff5e87fe7f2bb6bb6150d1b3bef4621c2d7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:51 -0700 Subject: [PATCH 0387/1163] staging: comedi: ni_stc.h: tidy up Window_{Address,Data} defines Rename the CamelCase. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 8 ++++---- drivers/staging/comedi/drivers/ni_stc.h | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 8dda682fca10..518c03303c74 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -469,8 +469,8 @@ static void ni_stc_writew(struct comedi_device *dev, uint16_t data, int reg) if (!devpriv->mite && reg < 8) { ni_writew(dev, data, reg * 2); } else { - ni_writew(dev, reg, Window_Address); - ni_writew(dev, data, Window_Data); + ni_writew(dev, reg, NI_E_STC_WINDOW_ADDR_REG); + ni_writew(dev, data, NI_E_STC_WINDOW_DATA_REG); } spin_unlock_irqrestore(&devpriv->window_lock, flags); } @@ -501,8 +501,8 @@ static uint16_t ni_stc_readw(struct comedi_device *dev, int reg) if (!devpriv->mite && reg < 8) { val = ni_readw(dev, reg * 2); } else { - ni_writew(dev, reg, Window_Address); - val = ni_readw(dev, Window_Data); + ni_writew(dev, reg, NI_E_STC_WINDOW_ADDR_REG); + val = ni_readw(dev, NI_E_STC_WINDOW_DATA_REG); } spin_unlock_irqrestore(&devpriv->window_lock, flags); } diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 45d841420aef..ac9261a70904 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -561,11 +561,11 @@ #define NISTC_AI_SI_SAVE_REG 64 #define NISTC_AI_SC_SAVE_REG 66 -/* Additional windowed registers unique to E series */ - -/* 16 bit registers shadowed from DAQ-STC */ -#define Window_Address 0x00 -#define Window_Data 0x02 +/* + * PCI E Series Registers + */ +#define NI_E_STC_WINDOW_ADDR_REG 0x00 /* rw16 */ +#define NI_E_STC_WINDOW_DATA_REG 0x02 /* rw16 */ /* i/o port offsets */ From 906170b882b609144d982a732ea9ad9faf1697fc Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:52 -0700 Subject: [PATCH 0388/1163] staging: comedi: ni_stc.h: tidy up XXX_Status register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 7 ++++--- drivers/staging/comedi/drivers/ni_stc.h | 10 +++------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 518c03303c74..b4a8a4c835e2 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1248,7 +1248,7 @@ static void get_last_sample_611x(struct comedi_device *dev) return; /* Check if there's a single sample stuck in the FIFO */ - if (ni_readb(dev, XXX_Status) & 0x80) { + if (ni_readb(dev, NI_E_STATUS_REG) & 0x80) { dl = ni_readl(dev, ADC_FIFO_Data_611x); data = dl & 0xffff; comedi_buf_write_samples(s, &data, 1); @@ -1946,7 +1946,7 @@ static int ni_ai_insn_read(struct comedi_device *dev, /* The 611x has screwy 32-bit FIFOs. */ d = 0; for (i = 0; i < NI_TIMEOUT; i++) { - if (ni_readb(dev, XXX_Status) & 0x80) { + if (ni_readb(dev, NI_E_STATUS_REG) & 0x80) { d = ni_readl(dev, ADC_FIFO_Data_611x); d >>= 16; d &= 0xffff; @@ -4258,7 +4258,8 @@ static int ni_read_eeprom(struct comedi_device *dev, int addr) for (bit = 0x80; bit; bit >>= 1) { ni_writeb(dev, 0x04, Serial_Command); ni_writeb(dev, 0x05, Serial_Command); - bitstring |= ((ni_readb(dev, XXX_Status) & PROMOUT) ? bit : 0); + if (ni_readb(dev, NI_E_STATUS_REG) & NI_E_STATUS_PROMOUT) + bitstring |= bit; } ni_writeb(dev, 0x00, Serial_Command); diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index ac9261a70904..643f3c2d98b9 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -567,14 +567,10 @@ #define NI_E_STC_WINDOW_ADDR_REG 0x00 /* rw16 */ #define NI_E_STC_WINDOW_DATA_REG 0x02 /* rw16 */ -/* i/o port offsets */ +#define NI_E_STATUS_REG 0x01 /* r8 */ +#define NI_E_STATUS_AI_FIFO_LOWER_NE BIT(3) +#define NI_E_STATUS_PROMOUT BIT(0) -/* 8 bit registers */ -#define XXX_Status 0x01 -enum XXX_Status_Bits { - PROMOUT = 0x1, - AI_FIFO_LOWER_NOT_EMPTY = 0x8, -}; #define Serial_Command 0x0d #define Misc_Command 0x0f #define Port_A 0x19 From 2ed183fff4ce1de272fb1f4e1c1a3fd49a8a969a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:53 -0700 Subject: [PATCH 0389/1163] staging: comedi: ni_stc.h: tidy up Serial_Command register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 34 +++++++++++-------- drivers/staging/comedi/drivers/ni_stc.h | 8 +++-- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index b4a8a4c835e2..2f7d64dc9b43 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -4129,6 +4129,7 @@ static void ni_write_caldac(struct comedi_device *dev, int addr, int val) const struct ni_board_struct *board = dev->board_ptr; struct ni_private *devpriv = dev->private; unsigned int loadbit = 0, bits = 0, bit, bitstring = 0; + unsigned int cmd; int i; int type; @@ -4142,7 +4143,7 @@ static void ni_write_caldac(struct comedi_device *dev, int addr, int val) break; if (addr < caldacs[type].n_chans) { bits = caldacs[type].packbits(addr, val, &bitstring); - loadbit = SerDacLd(i); + loadbit = NI_E_SERIAL_CMD_DAC_LD(i); break; } addr -= caldacs[type].n_chans; @@ -4153,15 +4154,15 @@ static void ni_write_caldac(struct comedi_device *dev, int addr, int val) return; for (bit = 1 << (bits - 1); bit; bit >>= 1) { - ni_writeb(dev, ((bit & bitstring) ? 0x02 : 0), Serial_Command); + cmd = (bit & bitstring) ? NI_E_SERIAL_CMD_SDATA : 0; + ni_writeb(dev, cmd, NI_E_SERIAL_CMD_REG); udelay(1); - ni_writeb(dev, 1 | ((bit & bitstring) ? 0x02 : 0), - Serial_Command); + ni_writeb(dev, NI_E_SERIAL_CMD_SCLK | cmd, NI_E_SERIAL_CMD_REG); udelay(1); } - ni_writeb(dev, loadbit, Serial_Command); + ni_writeb(dev, loadbit, NI_E_SERIAL_CMD_REG); udelay(1); - ni_writeb(dev, 0, Serial_Command); + ni_writeb(dev, 0, NI_E_SERIAL_CMD_REG); } static int ni_calib_insn_write(struct comedi_device *dev, @@ -4243,25 +4244,30 @@ static void caldac_setup(struct comedi_device *dev, struct comedi_subdevice *s) static int ni_read_eeprom(struct comedi_device *dev, int addr) { + unsigned int cmd = NI_E_SERIAL_CMD_EEPROM_CS; int bit; int bitstring; bitstring = 0x0300 | ((addr & 0x100) << 3) | (addr & 0xff); - ni_writeb(dev, 0x04, Serial_Command); + ni_writeb(dev, cmd, NI_E_SERIAL_CMD_REG); for (bit = 0x8000; bit; bit >>= 1) { - ni_writeb(dev, 0x04 | ((bit & bitstring) ? 0x02 : 0), - Serial_Command); - ni_writeb(dev, 0x05 | ((bit & bitstring) ? 0x02 : 0), - Serial_Command); + if (bit & bitstring) + cmd |= NI_E_SERIAL_CMD_SDATA; + else + cmd &= ~NI_E_SERIAL_CMD_SDATA; + + ni_writeb(dev, cmd, NI_E_SERIAL_CMD_REG); + ni_writeb(dev, NI_E_SERIAL_CMD_SCLK | cmd, NI_E_SERIAL_CMD_REG); } + cmd = NI_E_SERIAL_CMD_EEPROM_CS; bitstring = 0; for (bit = 0x80; bit; bit >>= 1) { - ni_writeb(dev, 0x04, Serial_Command); - ni_writeb(dev, 0x05, Serial_Command); + ni_writeb(dev, cmd, NI_E_SERIAL_CMD_REG); + ni_writeb(dev, NI_E_SERIAL_CMD_SCLK | cmd, NI_E_SERIAL_CMD_REG); if (ni_readb(dev, NI_E_STATUS_REG) & NI_E_STATUS_PROMOUT) bitstring |= bit; } - ni_writeb(dev, 0x00, Serial_Command); + ni_writeb(dev, 0, NI_E_SERIAL_CMD_REG); return bitstring; } diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 643f3c2d98b9..ffd435c468d6 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -571,7 +571,12 @@ #define NI_E_STATUS_AI_FIFO_LOWER_NE BIT(3) #define NI_E_STATUS_PROMOUT BIT(0) -#define Serial_Command 0x0d +#define NI_E_SERIAL_CMD_REG 0x0d /* w8 */ +#define NI_E_SERIAL_CMD_DAC_LD(x) BIT(3 + (x)) +#define NI_E_SERIAL_CMD_EEPROM_CS BIT(2) +#define NI_E_SERIAL_CMD_SDATA BIT(1) +#define NI_E_SERIAL_CMD_SCLK BIT(0) + #define Misc_Command 0x0f #define Port_A 0x19 #define Port_B 0x1b @@ -765,7 +770,6 @@ enum cs5529_status_bits { CSS_OSC_DETECT = 0x2, /* indicates adc error */ CSS_OVERRANGE = 0x4, }; -#define SerDacLd(x) (0x08<<(x)) /* This is stuff unique to the NI E series drivers, From 68885d9e00c81c685ebfa3cbb850d065e0eaecf9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:54 -0700 Subject: [PATCH 0390/1163] staging: comedi: ni_stc.h: tidy up Misc_Command register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 2 +- drivers/staging/comedi/drivers/ni_stc.h | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 2f7d64dc9b43..06c491d4dac3 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1620,7 +1620,7 @@ static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s) ni_clear_ai_fifo(dev); if (!devpriv->is_6143) - ni_writeb(dev, 0, Misc_Command); + ni_writeb(dev, NI_E_MISC_CMD_EXT_ATRIG, NI_E_MISC_CMD_REG); ni_stc_writew(dev, NISTC_AI_CMD1_DISARM, NISTC_AI_CMD1_REG); ni_stc_writew(dev, NISTC_AI_MODE1_START_STOP | diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index ffd435c468d6..9cea34473b52 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -577,7 +577,11 @@ #define NI_E_SERIAL_CMD_SDATA BIT(1) #define NI_E_SERIAL_CMD_SCLK BIT(0) -#define Misc_Command 0x0f +#define NI_E_MISC_CMD_REG 0x0f /* w8 */ +#define NI_E_MISC_CMD_INTEXT_ATRIG(x) (((x) & 0x1) << 7) +#define NI_E_MISC_CMD_EXT_ATRIG NI_E_MISC_CMD_INTEXT_ATRIG(0) +#define NI_E_MISC_CMD_INT_ATRIG NI_E_MISC_CMD_INTEXT_ATRIG(1) + #define Port_A 0x19 #define Port_B 0x1b #define Port_C 0x1d From 61260f58496af82593f48f17071da950af500e60 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:55 -0700 Subject: [PATCH 0391/1163] staging: comedi: ni_stc.h: tidy up 8255 register defines Only the 'Port_A' define is used. Rename the CamelCase and remove the unused defines. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 3 ++- drivers/staging/comedi/drivers/ni_stc.h | 10 ++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 06c491d4dac3..202957c0c3a7 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -5204,7 +5204,8 @@ static int ni_E_init(struct comedi_device *dev, /* 8255 device */ s = &dev->subdevices[NI_8255_DIO_SUBDEV]; if (board->has_8255) { - ret = subdev_8255_init(dev, s, ni_8255_callback, Port_A); + ret = subdev_8255_init(dev, s, ni_8255_callback, + NI_E_8255_BASE); if (ret) return ret; } else { diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 9cea34473b52..3bf73a7a9921 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -582,14 +582,6 @@ #define NI_E_MISC_CMD_EXT_ATRIG NI_E_MISC_CMD_INTEXT_ATRIG(0) #define NI_E_MISC_CMD_INT_ATRIG NI_E_MISC_CMD_INTEXT_ATRIG(1) -#define Port_A 0x19 -#define Port_B 0x1b -#define Port_C 0x1d -#define Configuration 0x1f -#define Strobes 0x01 -#define Channel_A_Mode 0x03 -#define Channel_B_Mode 0x05 -#define Channel_C_Mode 0x07 #define AI_AO_Select 0x09 enum AI_AO_Select_Bits { AI_DMA_Select_Shift = 0, @@ -643,6 +635,8 @@ static inline unsigned int AI_CONFIG_CHANNEL(unsigned int channel) return channel & 0x3f; } +#define NI_E_8255_BASE 0x19 /* rw8 */ + #define ADC_FIFO_Data_Register 0x1c #define AO_Configuration 0x16 From 363f570ef0e4a5361e97a1c0632e17c5d4148ec8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:56 -0700 Subject: [PATCH 0392/1163] staging: comedi: ni_stc.h: tidy up ADC_FIFO_Data_Register Rename the CamelCase. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 6 +++--- drivers/staging/comedi/drivers/ni_stc.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 202957c0c3a7..74817f8a2728 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1154,7 +1154,7 @@ static void ni_ai_fifo_read(struct comedi_device *dev, } for (i = 0; i < n; i++) { devpriv->ai_fifo_buffer[i] = - ni_readw(dev, ADC_FIFO_Data_Register); + ni_readw(dev, NI_E_AI_FIFO_DATA_REG); } comedi_buf_write_samples(s, devpriv->ai_fifo_buffer, n); } @@ -1230,7 +1230,7 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev) if (fifo_empty) break; devpriv->ai_fifo_buffer[i] = - ni_readw(dev, ADC_FIFO_Data_Register); + ni_readw(dev, NI_E_AI_FIFO_DATA_REG); } comedi_buf_write_samples(s, devpriv->ai_fifo_buffer, i); } @@ -2006,7 +2006,7 @@ static int ni_ai_insn_read(struct comedi_device *dev, dl &= mask; data[n] = dl; } else { - d = ni_readw(dev, ADC_FIFO_Data_Register); + d = ni_readw(dev, NI_E_AI_FIFO_DATA_REG); d += signbits; /* subtle: needs to be short addition */ data[n] = d; } diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 3bf73a7a9921..ea5999c8a907 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -637,7 +637,7 @@ static inline unsigned int AI_CONFIG_CHANNEL(unsigned int channel) #define NI_E_8255_BASE 0x19 /* rw8 */ -#define ADC_FIFO_Data_Register 0x1c +#define NI_E_AI_FIFO_DATA_REG 0x1c /* r16 */ #define AO_Configuration 0x16 #define AO_Bipolar _bit0 From 76efac7f525f2e9fffe9e751c29cd93aae96c710 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:57 -0700 Subject: [PATCH 0393/1163] staging: comedi: ni_stc.h: tidy up Configuration_Memory_Low register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 13 +++++++------ drivers/staging/comedi/drivers/ni_stc.h | 12 ++++++------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 74817f8a2728..0fba36dabd5b 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1902,13 +1902,14 @@ static void ni_load_channelgain_list(struct comedi_device *dev, ni_writew(dev, hi, Configuration_Memory_High); if (!devpriv->is_6143) { - lo = range; - if (i == n_chan - 1) - lo |= AI_LAST_CHANNEL; - if (dither) - lo |= AI_DITHER; + lo = NI_E_AI_CFG_LO_GAIN(range); - ni_writew(dev, lo, Configuration_Memory_Low); + if (i == n_chan - 1) + lo |= NI_E_AI_CFG_LO_LAST_CHAN; + if (dither) + lo |= NI_E_AI_CFG_LO_DITHER; + + ni_writew(dev, lo, NI_E_AI_CFG_LO_REG); } } diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index ea5999c8a907..8abf78db47bc 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -616,13 +616,13 @@ static inline unsigned GPCT_DMA_Select_Mask(unsigned gpct_index) return 0xf << (4 * gpct_index); } -/* 16 bit registers */ +#define NI_E_AI_CFG_LO_REG 0x10 /* w16 */ +#define NI_E_AI_CFG_LO_LAST_CHAN BIT(15) +#define NI_E_AI_CFG_LO_GEN_TRIG BIT(12) +#define NI_E_AI_CFG_LO_DITHER BIT(9) +#define NI_E_AI_CFG_LO_UNI BIT(8) +#define NI_E_AI_CFG_LO_GAIN(x) ((x) << 0) -#define Configuration_Memory_Low 0x10 -enum Configuration_Memory_Low_Bits { - AI_DITHER = 0x200, - AI_LAST_CHANNEL = 0x8000, -}; #define Configuration_Memory_High 0x12 enum Configuration_Memory_High_Bits { AI_AC_COUPLE = 0x800, From d504a6ee3db248e2ec3dc5e4304a381d5ba9bb6f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:58 -0700 Subject: [PATCH 0394/1163] staging: comedi: ni_stc.h: tidy up Configuration_Memory_High register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 10 +++++----- drivers/staging/comedi/drivers/ni_stc.h | 18 +++++++----------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 0fba36dabd5b..64c44a1a1065 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1885,21 +1885,21 @@ static void ni_load_channelgain_list(struct comedi_device *dev, aref = AREF_OTHER; switch (aref) { case AREF_DIFF: - hi |= AI_DIFFERENTIAL; + hi |= NI_E_AI_CFG_HI_TYPE_DIFF; break; case AREF_COMMON: - hi |= AI_COMMON; + hi |= NI_E_AI_CFG_HI_TYPE_COMMON; break; case AREF_GROUND: - hi |= AI_GROUND; + hi |= NI_E_AI_CFG_HI_TYPE_GROUND; break; case AREF_OTHER: break; } } - hi |= AI_CONFIG_CHANNEL(chan); + hi |= NI_E_AI_CFG_HI_CHAN(chan); - ni_writew(dev, hi, Configuration_Memory_High); + ni_writew(dev, hi, NI_E_AI_CFG_HI_REG); if (!devpriv->is_6143) { lo = NI_E_AI_CFG_LO_GAIN(range); diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 8abf78db47bc..14e4351b0aa8 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -623,17 +623,13 @@ static inline unsigned GPCT_DMA_Select_Mask(unsigned gpct_index) #define NI_E_AI_CFG_LO_UNI BIT(8) #define NI_E_AI_CFG_LO_GAIN(x) ((x) << 0) -#define Configuration_Memory_High 0x12 -enum Configuration_Memory_High_Bits { - AI_AC_COUPLE = 0x800, - AI_DIFFERENTIAL = 0x1000, - AI_COMMON = 0x2000, - AI_GROUND = 0x3000, -}; -static inline unsigned int AI_CONFIG_CHANNEL(unsigned int channel) -{ - return channel & 0x3f; -} +#define NI_E_AI_CFG_HI_REG 0x12 /* w16 */ +#define NI_E_AI_CFG_HI_TYPE(x) (((x) & 0x7) << 12) +#define NI_E_AI_CFG_HI_TYPE_DIFF NI_E_AI_CFG_HI_TYPE(1) +#define NI_E_AI_CFG_HI_TYPE_COMMON NI_E_AI_CFG_HI_TYPE(2) +#define NI_E_AI_CFG_HI_TYPE_GROUND NI_E_AI_CFG_HI_TYPE(3) +#define NI_E_AI_CFG_HI_AC_COUPLE BIT(11) +#define NI_E_AI_CFG_HI_CHAN(x) (((x) & 0x3f) << 0) #define NI_E_8255_BASE 0x19 /* rw8 */ From b497b8da801088f380a98851a5c50ffcd7b40c86 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 14:59:59 -0700 Subject: [PATCH 0395/1163] staging: comedi: ni_stc.h: tidy up AO_Configuration register and bits Rename the CamelCase. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 16 ++++++++-------- drivers/staging/comedi/drivers/ni_stc.h | 14 +++++++------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 64c44a1a1065..39e680e12882 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -2675,27 +2675,27 @@ static int ni_old_ao_config_chanlist(struct comedi_device *dev, for (i = 0; i < n_chans; i++) { chan = CR_CHAN(chanspec[i]); range = CR_RANGE(chanspec[i]); - conf = AO_Channel(chan); + conf = NI_E_AO_DACSEL(chan); if (comedi_range_is_bipolar(s, range)) { - conf |= AO_Bipolar; + conf |= NI_E_AO_CFG_BIP; invert = (s->maxdata + 1) >> 1; } else { invert = 0; } if (comedi_range_is_external(s, range)) - conf |= AO_Ext_Ref; + conf |= NI_E_AO_EXT_REF; /* not all boards can deglitch, but this shouldn't hurt */ if (chanspec[i] & CR_DEGLITCH) - conf |= AO_Deglitch; + conf |= NI_E_AO_DEGLITCH; /* analog reference */ /* AREF_OTHER connects AO ground to AI ground, i think */ - conf |= (CR_AREF(chanspec[i]) == - AREF_OTHER) ? AO_Ground_Ref : 0; + if (CR_AREF(chanspec[i]) == AREF_OTHER) + conf |= NI_E_AO_GROUND_REF; - ni_writew(dev, conf, AO_Configuration); + ni_writew(dev, conf, NI_E_AO_CFG_REG); devpriv->ao_conf[chan] = conf; } return invert; @@ -3698,7 +3698,7 @@ static void init_ao_67xx(struct comedi_device *dev, struct comedi_subdevice *s) int i; for (i = 0; i < s->n_chan; i++) { - ni_ao_win_outw(dev, AO_Channel(i) | 0x0, + ni_ao_win_outw(dev, NI_E_AO_DACSEL(i) | 0x0, AO_Configuration_2_67xx); } ni_ao_win_outw(dev, 0x0, AO_Later_Single_Point_Updates); diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 14e4351b0aa8..486e6a08b8dc 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -631,17 +631,17 @@ static inline unsigned GPCT_DMA_Select_Mask(unsigned gpct_index) #define NI_E_AI_CFG_HI_AC_COUPLE BIT(11) #define NI_E_AI_CFG_HI_CHAN(x) (((x) & 0x3f) << 0) +#define NI_E_AO_CFG_REG 0x16 /* w16 */ +#define NI_E_AO_DACSEL(x) ((x) << 8) +#define NI_E_AO_GROUND_REF BIT(3) +#define NI_E_AO_EXT_REF BIT(2) +#define NI_E_AO_DEGLITCH BIT(1) +#define NI_E_AO_CFG_BIP BIT(0) + #define NI_E_8255_BASE 0x19 /* rw8 */ #define NI_E_AI_FIFO_DATA_REG 0x1c /* r16 */ -#define AO_Configuration 0x16 -#define AO_Bipolar _bit0 -#define AO_Deglitch _bit1 -#define AO_Ext_Ref _bit2 -#define AO_Ground_Ref _bit3 -#define AO_Channel(x) ((x) << 8) - #define DAC_FIFO_Data 0x1e #define DAC0_Direct_Data 0x18 #define DAC1_Direct_Data 0x1a From 9e0ad6f4d1fe3ff97ca66bde6484c320ce9d80da Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 15:00:00 -0700 Subject: [PATCH 0396/1163] staging: comedi: ni_stc.h: tidy up DAC_FIFO_Data register Rename the CamelCase. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 2 +- drivers/staging/comedi/drivers/ni_stc.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 39e680e12882..b9e35ead643c 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1032,7 +1032,7 @@ static void ni_ao_fifo_load(struct comedi_device *dev, } ni_writel(dev, packed_data, DAC_FIFO_Data_611x); } else { - ni_writew(dev, d, DAC_FIFO_Data); + ni_writew(dev, d, NI_E_AO_FIFO_DATA_REG); } } } diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 486e6a08b8dc..2afa701eb4d0 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -642,7 +642,7 @@ static inline unsigned GPCT_DMA_Select_Mask(unsigned gpct_index) #define NI_E_AI_FIFO_DATA_REG 0x1c /* r16 */ -#define DAC_FIFO_Data 0x1e +#define NI_E_AO_FIFO_DATA_REG 0x1e /* w16 */ #define DAC0_Direct_Data 0x18 #define DAC1_Direct_Data 0x1a From 25e941affe11e258a213bb12e765dfaabd327c57 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 15:00:01 -0700 Subject: [PATCH 0397/1163] staging: comedi: ni_stc.h: tidy up DAC[01]_Direct_Data registers Rename the CamelCase and convert the defines into a macro. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 2 +- drivers/staging/comedi/drivers/ni_stc.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index b9e35ead643c..4a94bc3986ef 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -2733,7 +2733,7 @@ static int ni_ao_insn_write(struct comedi_device *dev, } else if (devpriv->is_m_series) { reg = NI_M_DAC_DIRECT_DATA_REG(chan); } else { - reg = (chan) ? DAC1_Direct_Data : DAC0_Direct_Data; + reg = NI_E_DAC_DIRECT_DATA_REG(chan); } ni_ao_config_chanlist(dev, s, &insn->chanspec, 1, 0); diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 2afa701eb4d0..23cc4902b905 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -638,13 +638,13 @@ static inline unsigned GPCT_DMA_Select_Mask(unsigned gpct_index) #define NI_E_AO_DEGLITCH BIT(1) #define NI_E_AO_CFG_BIP BIT(0) +#define NI_E_DAC_DIRECT_DATA_REG(x) (0x18 + ((x) * 2)) /* w16 */ + #define NI_E_8255_BASE 0x19 /* rw8 */ #define NI_E_AI_FIFO_DATA_REG 0x1c /* r16 */ #define NI_E_AO_FIFO_DATA_REG 0x1e /* w16 */ -#define DAC0_Direct_Data 0x18 -#define DAC1_Direct_Data 0x1a /* 611x registers (these boards differ from the e-series) */ From 3446b08e83eb152fe97c791d16cbc68523a62bce Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 15:00:02 -0700 Subject: [PATCH 0398/1163] staging: comedi: ni_mio_common: remove BUG_ON(gpct_index ...) checks The gpct_index will always be 0 or 1. Remove the unnecessary BUG_ON() checks. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 2 -- drivers/staging/comedi/drivers/ni_stc.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 4a94bc3986ef..2e1fde3d843d 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -686,7 +686,6 @@ static int ni_request_gpct_mite_channel(struct comedi_device *dev, unsigned long flags; struct mite_channel *mite_chan; - BUG_ON(gpct_index >= NUM_GPCT); spin_lock_irqsave(&devpriv->mite_channel_lock, flags); BUG_ON(devpriv->counter_dev->counters[gpct_index].mite_chan); mite_chan = @@ -770,7 +769,6 @@ static void ni_release_gpct_mite_channel(struct comedi_device *dev, struct ni_private *devpriv = dev->private; unsigned long flags; - BUG_ON(gpct_index >= NUM_GPCT); spin_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->counter_dev->counters[gpct_index].mite_chan) { struct mite_channel *mite_chan = diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 23cc4902b905..9ce4c5639923 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -605,14 +605,12 @@ static inline unsigned ni_stc_dma_channel_select_bitfield(unsigned channel) static inline unsigned GPCT_DMA_Select_Bits(unsigned gpct_index, unsigned mite_channel) { - BUG_ON(gpct_index > 1); return ni_stc_dma_channel_select_bitfield(mite_channel) << (4 * gpct_index); } static inline unsigned GPCT_DMA_Select_Mask(unsigned gpct_index) { - BUG_ON(gpct_index > 1); return 0xf << (4 * gpct_index); } From a4b7ef9d8eae56f0355d0ee2a762639901d7bef4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 15:00:03 -0700 Subject: [PATCH 0399/1163] staging: comedi: ni_stc.h: tidy up AI_AO_Select register and bits Rename the CamelCase and convert the enum into macros. Tidy up the driver code to use the new macros. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 28 ++++++++----------- drivers/staging/comedi/drivers/ni_stc.h | 13 ++++----- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 2e1fde3d843d..7dfa38268bdc 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -546,7 +546,7 @@ static inline void ni_set_bitfield(struct comedi_device *dev, int reg, devpriv->io_bidirection_pin_reg |= bit_values & bit_mask; ni_stc_writew(dev, devpriv->io_bidirection_pin_reg, reg); break; - case AI_AO_Select: + case NI_E_DMA_AI_AO_SEL_REG: devpriv->ai_ao_select_reg &= ~bit_mask; devpriv->ai_ao_select_reg |= bit_values & bit_mask; ni_writeb(dev, devpriv->ai_ao_select_reg, reg); @@ -571,29 +571,25 @@ static inline void ni_set_bitfield(struct comedi_device *dev, int reg, /* negative channel means no channel */ static inline void ni_set_ai_dma_channel(struct comedi_device *dev, int channel) { - unsigned bitfield; + unsigned bits = 0; if (channel >= 0) - bitfield = - (ni_stc_dma_channel_select_bitfield(channel) << - AI_DMA_Select_Shift) & AI_DMA_Select_Mask; - else - bitfield = 0; - ni_set_bitfield(dev, AI_AO_Select, AI_DMA_Select_Mask, bitfield); + bits = ni_stc_dma_channel_select_bitfield(channel); + + ni_set_bitfield(dev, NI_E_DMA_AI_AO_SEL_REG, + NI_E_DMA_AI_SEL_MASK, NI_E_DMA_AI_SEL(bits)); } /* negative channel means no channel */ static inline void ni_set_ao_dma_channel(struct comedi_device *dev, int channel) { - unsigned bitfield; + unsigned bits = 0; if (channel >= 0) - bitfield = - (ni_stc_dma_channel_select_bitfield(channel) << - AO_DMA_Select_Shift) & AO_DMA_Select_Mask; - else - bitfield = 0; - ni_set_bitfield(dev, AI_AO_Select, AO_DMA_Select_Mask, bitfield); + bits = ni_stc_dma_channel_select_bitfield(channel); + + ni_set_bitfield(dev, NI_E_DMA_AI_AO_SEL_REG, + NI_E_DMA_AO_SEL_MASK, NI_E_DMA_AO_SEL(bits)); } /* negative mite_channel means no channel */ @@ -5373,7 +5369,7 @@ static int ni_E_init(struct comedi_device *dev, } /* DMA setup */ - ni_writeb(dev, devpriv->ai_ao_select_reg, AI_AO_Select); + ni_writeb(dev, devpriv->ai_ao_select_reg, NI_E_DMA_AI_AO_SEL_REG); ni_writeb(dev, devpriv->g0_g1_select_reg, G0_G1_Select); if (devpriv->is_6xxx) { diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 9ce4c5639923..2db29a14b2ec 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -571,6 +571,12 @@ #define NI_E_STATUS_AI_FIFO_LOWER_NE BIT(3) #define NI_E_STATUS_PROMOUT BIT(0) +#define NI_E_DMA_AI_AO_SEL_REG 0x09 /* w8 */ +#define NI_E_DMA_AI_SEL(x) (((x) & 0xf) << 0) +#define NI_E_DMA_AI_SEL_MASK NI_E_DMA_AI_SEL(0xf) +#define NI_E_DMA_AO_SEL(x) (((x) & 0xf) << 4) +#define NI_E_DMA_AO_SEL_MASK NI_E_DMA_AO_SEL(0xf) + #define NI_E_SERIAL_CMD_REG 0x0d /* w8 */ #define NI_E_SERIAL_CMD_DAC_LD(x) BIT(3 + (x)) #define NI_E_SERIAL_CMD_EEPROM_CS BIT(2) @@ -582,13 +588,6 @@ #define NI_E_MISC_CMD_EXT_ATRIG NI_E_MISC_CMD_INTEXT_ATRIG(0) #define NI_E_MISC_CMD_INT_ATRIG NI_E_MISC_CMD_INTEXT_ATRIG(1) -#define AI_AO_Select 0x09 -enum AI_AO_Select_Bits { - AI_DMA_Select_Shift = 0, - AI_DMA_Select_Mask = 0xf, - AO_DMA_Select_Shift = 4, - AO_DMA_Select_Mask = 0xf << AO_DMA_Select_Shift -}; #define G0_G1_Select 0x0b static inline unsigned ni_stc_dma_channel_select_bitfield(unsigned channel) { From 7d6f3aaead3a76e7e12aa2bbfe18d8ed423d1d19 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 15:00:04 -0700 Subject: [PATCH 0400/1163] staging: comedi: ni_stc.h: tidy up G0_G1_Select register and bits Rename the CamelCase. Convert the inline helper functions into macros. Tidy up the driver code to use the new macros. For consistency, make the ni_set_gpct_dma_channel() helper follow the same style as the ni_set_ai_dma_channel() and ni_set_ao_dma_channel() helpers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 22 +++++++++---------- drivers/staging/comedi/drivers/ni_stc.h | 17 ++++---------- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 7dfa38268bdc..cfb5f34b4937 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -551,7 +551,7 @@ static inline void ni_set_bitfield(struct comedi_device *dev, int reg, devpriv->ai_ao_select_reg |= bit_values & bit_mask; ni_writeb(dev, devpriv->ai_ao_select_reg, reg); break; - case G0_G1_Select: + case NI_E_DMA_G0_G1_SEL_REG: devpriv->g0_g1_select_reg &= ~bit_mask; devpriv->g0_g1_select_reg |= bit_values & bit_mask; ni_writeb(dev, devpriv->g0_g1_select_reg, reg); @@ -592,19 +592,19 @@ static inline void ni_set_ao_dma_channel(struct comedi_device *dev, int channel) NI_E_DMA_AO_SEL_MASK, NI_E_DMA_AO_SEL(bits)); } -/* negative mite_channel means no channel */ +/* negative channel means no channel */ static inline void ni_set_gpct_dma_channel(struct comedi_device *dev, unsigned gpct_index, - int mite_channel) + int channel) { - unsigned bitfield; + unsigned bits = 0; - if (mite_channel >= 0) - bitfield = GPCT_DMA_Select_Bits(gpct_index, mite_channel); - else - bitfield = 0; - ni_set_bitfield(dev, G0_G1_Select, GPCT_DMA_Select_Mask(gpct_index), - bitfield); + if (channel >= 0) + bits = ni_stc_dma_channel_select_bitfield(channel); + + ni_set_bitfield(dev, NI_E_DMA_G0_G1_SEL_REG, + NI_E_DMA_G0_G1_SEL_MASK(gpct_index), + NI_E_DMA_G0_G1_SEL(gpct_index, bits)); } /* negative mite_channel means no channel */ @@ -5370,7 +5370,7 @@ static int ni_E_init(struct comedi_device *dev, /* DMA setup */ ni_writeb(dev, devpriv->ai_ao_select_reg, NI_E_DMA_AI_AO_SEL_REG); - ni_writeb(dev, devpriv->g0_g1_select_reg, G0_G1_Select); + ni_writeb(dev, devpriv->g0_g1_select_reg, NI_E_DMA_G0_G1_SEL_REG); if (devpriv->is_6xxx) { ni_writeb(dev, 0, Magic_611x); diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 2db29a14b2ec..e181d914d3e7 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -577,6 +577,10 @@ #define NI_E_DMA_AO_SEL(x) (((x) & 0xf) << 4) #define NI_E_DMA_AO_SEL_MASK NI_E_DMA_AO_SEL(0xf) +#define NI_E_DMA_G0_G1_SEL_REG 0x0b /* w8 */ +#define NI_E_DMA_G0_G1_SEL(_g, _c) (((_c) & 0xf) << ((_g) * 4)) +#define NI_E_DMA_G0_G1_SEL_MASK(_g) NI_E_DMA_G0_G1_SEL((_g), 0xf) + #define NI_E_SERIAL_CMD_REG 0x0d /* w8 */ #define NI_E_SERIAL_CMD_DAC_LD(x) BIT(3 + (x)) #define NI_E_SERIAL_CMD_EEPROM_CS BIT(2) @@ -588,7 +592,6 @@ #define NI_E_MISC_CMD_EXT_ATRIG NI_E_MISC_CMD_INTEXT_ATRIG(0) #define NI_E_MISC_CMD_INT_ATRIG NI_E_MISC_CMD_INTEXT_ATRIG(1) -#define G0_G1_Select 0x0b static inline unsigned ni_stc_dma_channel_select_bitfield(unsigned channel) { if (channel < 4) @@ -601,18 +604,6 @@ static inline unsigned ni_stc_dma_channel_select_bitfield(unsigned channel) return 0; } -static inline unsigned GPCT_DMA_Select_Bits(unsigned gpct_index, - unsigned mite_channel) -{ - return ni_stc_dma_channel_select_bitfield(mite_channel) << (4 * - gpct_index); -} - -static inline unsigned GPCT_DMA_Select_Mask(unsigned gpct_index) -{ - return 0xf << (4 * gpct_index); -} - #define NI_E_AI_CFG_LO_REG 0x10 /* w16 */ #define NI_E_AI_CFG_LO_LAST_CHAN BIT(15) #define NI_E_AI_CFG_LO_GEN_TRIG BIT(12) From f78476b4d3939d9aa7299889f9a5066b96b2195f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 15:00:05 -0700 Subject: [PATCH 0401/1163] staging: comedi: ni_mio_common: move ni_stc_dma_channel_select_bitfield() Move this inline helper function from ni_stc.h. It does not need to be exposed outside of this file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 11 +++++++++++ drivers/staging/comedi/drivers/ni_stc.h | 12 ------------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index cfb5f34b4937..e2081ea314bf 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -567,6 +567,17 @@ static inline void ni_set_bitfield(struct comedi_device *dev, int reg, #ifdef PCIDMA /* DMA channel setup */ +static inline unsigned ni_stc_dma_channel_select_bitfield(unsigned channel) +{ + if (channel < 4) + return 1 << channel; + if (channel == 4) + return 0x3; + if (channel == 5) + return 0x5; + BUG(); + return 0; +} /* negative channel means no channel */ static inline void ni_set_ai_dma_channel(struct comedi_device *dev, int channel) diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index e181d914d3e7..dc95e6aef5a0 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -592,18 +592,6 @@ #define NI_E_MISC_CMD_EXT_ATRIG NI_E_MISC_CMD_INTEXT_ATRIG(0) #define NI_E_MISC_CMD_INT_ATRIG NI_E_MISC_CMD_INTEXT_ATRIG(1) -static inline unsigned ni_stc_dma_channel_select_bitfield(unsigned channel) -{ - if (channel < 4) - return 1 << channel; - if (channel == 4) - return 0x3; - if (channel == 5) - return 0x5; - BUG(); - return 0; -} - #define NI_E_AI_CFG_LO_REG 0x10 /* w16 */ #define NI_E_AI_CFG_LO_LAST_CHAN BIT(15) #define NI_E_AI_CFG_LO_GEN_TRIG BIT(12) From 62e0e09469690ea2a6748f63fa041397d8be2a19 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 15:00:06 -0700 Subject: [PATCH 0402/1163] staging: comedi: ni_stc.h: remove unused _bit* defines Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_stc.h | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index dc95e6aef5a0..4f4a902baf01 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -26,23 +26,6 @@ #include "ni_tio.h" -#define _bit15 0x8000 -#define _bit14 0x4000 -#define _bit13 0x2000 -#define _bit12 0x1000 -#define _bit11 0x0800 -#define _bit10 0x0400 -#define _bit9 0x0200 -#define _bit8 0x0100 -#define _bit7 0x0080 -#define _bit6 0x0040 -#define _bit5 0x0020 -#define _bit4 0x0010 -#define _bit3 0x0008 -#define _bit2 0x0004 -#define _bit1 0x0002 -#define _bit0 0x0001 - #define NUM_PFI_OUTPUT_SELECT_REGS 6 /* From 0418da51378e83cde58043cf7a272760a5214a2d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 15:00:07 -0700 Subject: [PATCH 0403/1163] staging: comedi: ni_stc.h: rename the NI-611x register defines Rename the CamelCase. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 34 ++++++++++--------- drivers/staging/comedi/drivers/ni_stc.h | 21 ++++++------ 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index e2081ea314bf..e50eb9ac34bc 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -879,8 +879,8 @@ static inline void ni_ao_win_outw(struct comedi_device *dev, uint16_t data, unsigned long flags; spin_lock_irqsave(&devpriv->window_lock, flags); - ni_writew(dev, addr, AO_Window_Address_611x); - ni_writew(dev, data, AO_Window_Data_611x); + ni_writew(dev, addr, NI611X_AO_WINDOW_ADDR_REG); + ni_writew(dev, data, NI611X_AO_WINDOW_DATA_REG); spin_unlock_irqrestore(&devpriv->window_lock, flags); } @@ -891,8 +891,8 @@ static inline void ni_ao_win_outl(struct comedi_device *dev, uint32_t data, unsigned long flags; spin_lock_irqsave(&devpriv->window_lock, flags); - ni_writew(dev, addr, AO_Window_Address_611x); - ni_writel(dev, data, AO_Window_Data_611x); + ni_writew(dev, addr, NI611X_AO_WINDOW_ADDR_REG); + ni_writel(dev, data, NI611X_AO_WINDOW_DATA_REG); spin_unlock_irqrestore(&devpriv->window_lock, flags); } @@ -903,8 +903,8 @@ static inline unsigned short ni_ao_win_inw(struct comedi_device *dev, int addr) unsigned short data; spin_lock_irqsave(&devpriv->window_lock, flags); - ni_writew(dev, addr, AO_Window_Address_611x); - data = ni_readw(dev, AO_Window_Data_611x); + ni_writew(dev, addr, NI611X_AO_WINDOW_ADDR_REG); + data = ni_readw(dev, NI611X_AO_WINDOW_DATA_REG); spin_unlock_irqrestore(&devpriv->window_lock, flags); return data; } @@ -1035,7 +1035,7 @@ static void ni_ao_fifo_load(struct comedi_device *dev, i++; packed_data |= (d << 16) & 0xffff0000; } - ni_writel(dev, packed_data, DAC_FIFO_Data_611x); + ni_writel(dev, packed_data, NI611X_AO_FIFO_DATA_REG); } else { ni_writew(dev, d, NI_E_AO_FIFO_DATA_REG); } @@ -1118,7 +1118,7 @@ static void ni_ai_fifo_read(struct comedi_device *dev, if (devpriv->is_611x) { for (i = 0; i < n / 2; i++) { - dl = ni_readl(dev, ADC_FIFO_Data_611x); + dl = ni_readl(dev, NI611X_AI_FIFO_DATA_REG); /* This may get the hi/lo data in the wrong order */ data = (dl >> 16) & 0xffff; comedi_buf_write_samples(s, &data, 1); @@ -1127,7 +1127,7 @@ static void ni_ai_fifo_read(struct comedi_device *dev, } /* Check if there's a single sample stuck in the FIFO */ if (n % 2) { - dl = ni_readl(dev, ADC_FIFO_Data_611x); + dl = ni_readl(dev, NI611X_AI_FIFO_DATA_REG); data = dl & 0xffff; comedi_buf_write_samples(s, &data, 1); } @@ -1192,7 +1192,7 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev) if (devpriv->is_611x) { while ((ni_stc_readw(dev, NISTC_AI_STATUS1_REG) & NISTC_AI_STATUS1_FIFO_E) == 0) { - dl = ni_readl(dev, ADC_FIFO_Data_611x); + dl = ni_readl(dev, NI611X_AI_FIFO_DATA_REG); /* This may get the hi/lo data in the wrong order */ data = dl >> 16; @@ -1254,7 +1254,7 @@ static void get_last_sample_611x(struct comedi_device *dev) /* Check if there's a single sample stuck in the FIFO */ if (ni_readb(dev, NI_E_STATUS_REG) & 0x80) { - dl = ni_readl(dev, ADC_FIFO_Data_611x); + dl = ni_readl(dev, NI611X_AI_FIFO_DATA_REG); data = dl & 0xffff; comedi_buf_write_samples(s, &data, 1); } @@ -1882,7 +1882,7 @@ static void ni_load_channelgain_list(struct comedi_device *dev, if ((list[i] & CR_ALT_SOURCE)) { if (devpriv->is_611x) ni_writew(dev, CR_CHAN(list[i]) & 0x0003, - Calibration_Channel_Select_611x); + NI611X_CALIB_CHAN_SEL_REG); } else { if (devpriv->is_611x) aref = AREF_DIFF; @@ -1953,14 +1953,16 @@ static int ni_ai_insn_read(struct comedi_device *dev, d = 0; for (i = 0; i < NI_TIMEOUT; i++) { if (ni_readb(dev, NI_E_STATUS_REG) & 0x80) { - d = ni_readl(dev, ADC_FIFO_Data_611x); + d = ni_readl(dev, + NI611X_AI_FIFO_DATA_REG); d >>= 16; d &= 0xffff; break; } if (!(ni_stc_readw(dev, NISTC_AI_STATUS1_REG) & NISTC_AI_STATUS1_FIFO_E)) { - d = ni_readl(dev, ADC_FIFO_Data_611x); + d = ni_readl(dev, + NI611X_AI_FIFO_DATA_REG); d &= 0xffff; break; } @@ -2552,7 +2554,7 @@ static int ni_ai_insn_config(struct comedi_device *dev, devpriv->ai_calib_source = calib_source; if (devpriv->is_611x) { ni_writeb(dev, calib_source_adjust, - Cal_Gain_Select_611x); + NI611X_CAL_GAIN_SEL_REG); } } return 2; @@ -5384,7 +5386,7 @@ static int ni_E_init(struct comedi_device *dev, ni_writeb(dev, devpriv->g0_g1_select_reg, NI_E_DMA_G0_G1_SEL_REG); if (devpriv->is_6xxx) { - ni_writeb(dev, 0, Magic_611x); + ni_writeb(dev, 0, NI611X_MAGIC_REG); } else if (devpriv->is_m_series) { int channel; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 4f4a902baf01..578c839f2bf8 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -605,17 +605,18 @@ #define NI_E_AO_FIFO_DATA_REG 0x1e /* w16 */ -/* 611x registers (these boards differ from the e-series) */ +/* + * 611x registers (these boards differ from the e-series) + */ +#define NI611X_MAGIC_REG 0x19 /* w8 (new) */ +#define NI611X_CALIB_CHAN_SEL_REG 0x1a /* w16 (new) */ +#define NI611X_AI_FIFO_DATA_REG 0x1c /* r32 (incompatible) */ +#define NI611X_AI_FIFO_OFFSET_LOAD_REG 0x05 /* r8 (new) */ +#define NI611X_AO_FIFO_DATA_REG 0x14 /* w32 (incompatible) */ +#define NI611X_CAL_GAIN_SEL_REG 0x05 /* w8 (new) */ -#define Magic_611x 0x19 /* w8 (new) */ -#define Calibration_Channel_Select_611x 0x1a /* w16 (new) */ -#define ADC_FIFO_Data_611x 0x1c /* r32 (incompatible) */ -#define AI_FIFO_Offset_Load_611x 0x05 /* r8 (new) */ -#define DAC_FIFO_Data_611x 0x14 /* w32 (incompatible) */ -#define Cal_Gain_Select_611x 0x05 /* w8 (new) */ - -#define AO_Window_Address_611x 0x18 -#define AO_Window_Data_611x 0x1e +#define NI611X_AO_WINDOW_ADDR_REG 0x18 +#define NI611X_AO_WINDOW_DATA_REG 0x1e /* 6143 registers */ #define Magic_6143 0x19 /* w8 */ From ee3e21ac4be697350369bbd1c0b70f4acb909fa0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 15:00:08 -0700 Subject: [PATCH 0404/1163] staging: comedi: ni_stc.h: rename the NI-6143 register defines Rename the CamelCase. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 54 ++++++++--------- drivers/staging/comedi/drivers/ni_pcimio.c | 15 +++-- drivers/staging/comedi/drivers/ni_stc.h | 58 ++++++++++--------- 3 files changed, 65 insertions(+), 62 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index e50eb9ac34bc..802aabf0deee 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -843,11 +843,11 @@ static void ni_clear_ai_fifo(struct comedi_device *dev) if (devpriv->is_6143) { /* Flush the 6143 data FIFO */ - ni_writel(dev, 0x10, AIFIFO_Control_6143); - ni_writel(dev, 0x00, AIFIFO_Control_6143); + ni_writel(dev, 0x10, NI6143_AI_FIFO_CTRL_REG); + ni_writel(dev, 0x00, NI6143_AI_FIFO_CTRL_REG); /* Wait for complete */ for (i = 0; i < timeout; i++) { - if (!(ni_readl(dev, AIFIFO_Status_6143) & 0x10)) + if (!(ni_readl(dev, NI6143_AI_FIFO_STATUS_REG) & 0x10)) break; udelay(1); } @@ -1134,7 +1134,7 @@ static void ni_ai_fifo_read(struct comedi_device *dev, } else if (devpriv->is_6143) { /* This just reads the FIFO assuming the data is present, no checks on the FIFO status are performed */ for (i = 0; i < n / 2; i++) { - dl = ni_readl(dev, AIFIFO_Data_6143); + dl = ni_readl(dev, NI6143_AI_FIFO_DATA_REG); data = (dl >> 16) & 0xffff; comedi_buf_write_samples(s, &data, 1); @@ -1144,8 +1144,8 @@ static void ni_ai_fifo_read(struct comedi_device *dev, if (n % 2) { /* Assume there is a single sample stuck in the FIFO */ /* Get stranded sample into FIFO */ - ni_writel(dev, 0x01, AIFIFO_Control_6143); - dl = ni_readl(dev, AIFIFO_Data_6143); + ni_writel(dev, 0x01, NI6143_AI_FIFO_CTRL_REG); + dl = ni_readl(dev, NI6143_AI_FIFO_DATA_REG); data = (dl >> 16) & 0xffff; comedi_buf_write_samples(s, &data, 1); } @@ -1202,8 +1202,8 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev) } } else if (devpriv->is_6143) { i = 0; - while (ni_readl(dev, AIFIFO_Status_6143) & 0x04) { - dl = ni_readl(dev, AIFIFO_Data_6143); + while (ni_readl(dev, NI6143_AI_FIFO_STATUS_REG) & 0x04) { + dl = ni_readl(dev, NI6143_AI_FIFO_DATA_REG); /* This may get the hi/lo data in the wrong order */ data = dl >> 16; @@ -1213,10 +1213,10 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev) i += 2; } /* Check if stranded sample is present */ - if (ni_readl(dev, AIFIFO_Status_6143) & 0x01) { + if (ni_readl(dev, NI6143_AI_FIFO_STATUS_REG) & 0x01) { /* Get stranded sample into FIFO */ - ni_writel(dev, 0x01, AIFIFO_Control_6143); - dl = ni_readl(dev, AIFIFO_Data_6143); + ni_writel(dev, 0x01, NI6143_AI_FIFO_CTRL_REG); + dl = ni_readl(dev, NI6143_AI_FIFO_DATA_REG); data = (dl >> 16) & 0xffff; comedi_buf_write_samples(s, &data, 1); } @@ -1271,10 +1271,10 @@ static void get_last_sample_6143(struct comedi_device *dev) return; /* Check if there's a single sample stuck in the FIFO */ - if (ni_readl(dev, AIFIFO_Status_6143) & 0x01) { + if (ni_readl(dev, NI6143_AI_FIFO_STATUS_REG) & 0x01) { /* Get stranded sample into FIFO */ - ni_writel(dev, 0x01, AIFIFO_Control_6143); - dl = ni_readl(dev, AIFIFO_Data_6143); + ni_writel(dev, 0x01, NI6143_AI_FIFO_CTRL_REG); + dl = ni_readl(dev, NI6143_AI_FIFO_DATA_REG); /* This may get the hi/lo data in the wrong order */ data = (dl >> 16) & 0xffff; @@ -1843,20 +1843,20 @@ static void ni_load_channelgain_list(struct comedi_device *dev, && !devpriv->ai_calib_source_enabled) { /* Strobe Relay enable bit */ ni_writew(dev, devpriv->ai_calib_source | - Calibration_Channel_6143_RelayOn, - Calibration_Channel_6143); + NI6143_CALIB_CHAN_RELAY_ON, + NI6143_CALIB_CHAN_REG); ni_writew(dev, devpriv->ai_calib_source, - Calibration_Channel_6143); + NI6143_CALIB_CHAN_REG); devpriv->ai_calib_source_enabled = 1; msleep_interruptible(100); /* Allow relays to change */ } else if (!(list[0] & CR_ALT_SOURCE) && devpriv->ai_calib_source_enabled) { /* Strobe Relay disable bit */ ni_writew(dev, devpriv->ai_calib_source | - Calibration_Channel_6143_RelayOff, - Calibration_Channel_6143); + NI6143_CALIB_CHAN_RELAY_OFF, + NI6143_CALIB_CHAN_REG); ni_writew(dev, devpriv->ai_calib_source, - Calibration_Channel_6143); + NI6143_CALIB_CHAN_REG); devpriv->ai_calib_source_enabled = 0; msleep_interruptible(100); /* Allow relays to change */ } @@ -1982,11 +1982,13 @@ static int ni_ai_insn_read(struct comedi_device *dev, /* The 6143 has 32-bit FIFOs. You need to strobe a bit to move a single 16bit stranded sample into the FIFO */ dl = 0; for (i = 0; i < NI_TIMEOUT; i++) { - if (ni_readl(dev, AIFIFO_Status_6143) & 0x01) { + if (ni_readl(dev, NI6143_AI_FIFO_STATUS_REG) & + 0x01) { /* Get stranded sample into FIFO */ ni_writel(dev, 0x01, - AIFIFO_Control_6143); - dl = ni_readl(dev, AIFIFO_Data_6143); + NI6143_AI_FIFO_CTRL_REG); + dl = ni_readl(dev, + NI6143_AI_FIFO_DATA_REG); break; } } @@ -2541,7 +2543,7 @@ static int ni_ai_insn_config(struct comedi_device *dev, calib_source = data[1] & 0xf; devpriv->ai_calib_source = calib_source; - ni_writew(dev, calib_source, Calibration_Channel_6143); + ni_writew(dev, calib_source, NI6143_CALIB_CHAN_REG); } else { unsigned int calib_source; unsigned int calib_source_adjust; @@ -4055,9 +4057,9 @@ static int ni_6143_pwm_config(struct comedi_device *dev, data[4] = down_count * devpriv->clock_ns; return -EAGAIN; } - ni_writel(dev, up_count, Calibration_HighTime_6143); + ni_writel(dev, up_count, NI6143_CALIB_HI_TIME_REG); devpriv->pwm_up_count = up_count; - ni_writel(dev, down_count, Calibration_LowTime_6143); + ni_writel(dev, down_count, NI6143_CALIB_LO_TIME_REG); devpriv->pwm_down_count = down_count; return 5; case INSN_CONFIG_GET_PWM_OUTPUT: diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c b/drivers/staging/comedi/drivers/ni_pcimio.c index 9f4d4b1f9962..30a5a75d1fe7 100644 --- a/drivers/staging/comedi/drivers/ni_pcimio.c +++ b/drivers/staging/comedi/drivers/ni_pcimio.c @@ -1090,21 +1090,20 @@ static void init_6143(struct comedi_device *dev) /* Initialise 6143 AI specific bits */ /* Set G0,G1 DMA mode to E series version */ - ni_writeb(dev, 0x00, Magic_6143); + ni_writeb(dev, 0x00, NI6143_MAGIC_REG); /* Set EOCMode, ADCMode and pipelinedelay */ - ni_writeb(dev, 0x80, PipelineDelay_6143); + ni_writeb(dev, 0x80, NI6143_PIPELINE_DELAY_REG); /* Set EOC Delay */ - ni_writeb(dev, 0x00, EOC_Set_6143); + ni_writeb(dev, 0x00, NI6143_EOC_SET_REG); /* Set the FIFO half full level */ - ni_writel(dev, board->ai_fifo_depth / 2, AIFIFO_Flag_6143); + ni_writel(dev, board->ai_fifo_depth / 2, NI6143_AI_FIFO_FLAG_REG); /* Strobe Relay disable bit */ devpriv->ai_calib_source_enabled = 0; - ni_writew(dev, devpriv->ai_calib_source | - Calibration_Channel_6143_RelayOff, - Calibration_Channel_6143); - ni_writew(dev, devpriv->ai_calib_source, Calibration_Channel_6143); + ni_writew(dev, devpriv->ai_calib_source | NI6143_CALIB_CHAN_RELAY_OFF, + NI6143_CALIB_CHAN_REG); + ni_writew(dev, devpriv->ai_calib_source, NI6143_CALIB_CHAN_REG); } static void pcimio_detach(struct comedi_device *dev) diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 578c839f2bf8..ddb0e6ccbbc0 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -618,35 +618,37 @@ #define NI611X_AO_WINDOW_ADDR_REG 0x18 #define NI611X_AO_WINDOW_DATA_REG 0x1e -/* 6143 registers */ -#define Magic_6143 0x19 /* w8 */ -#define G0G1_DMA_Select_6143 0x0B /* w8 */ -#define PipelineDelay_6143 0x1f /* w8 */ -#define EOC_Set_6143 0x1D /* w8 */ -#define AIDMA_Select_6143 0x09 /* w8 */ -#define AIFIFO_Data_6143 0x8C /* w32 */ -#define AIFIFO_Flag_6143 0x84 /* w32 */ -#define AIFIFO_Control_6143 0x88 /* w32 */ -#define AIFIFO_Status_6143 0x88 /* w32 */ -#define AIFIFO_DMAThreshold_6143 0x90 /* w32 */ -#define AIFIFO_Words_Available_6143 0x94 /* w32 */ +/* + * 6143 registers + */ +#define NI6143_MAGIC_REG 0x19 /* w8 */ +#define NI6143_DMA_G0_G1_SEL_REG 0x0b /* w8 */ +#define NI6143_PIPELINE_DELAY_REG 0x1f /* w8 */ +#define NI6143_EOC_SET_REG 0x1d /* w8 */ +#define NI6143_DMA_AI_SEL_REG 0x09 /* w8 */ +#define NI6143_AI_FIFO_DATA_REG 0x8c /* r32 */ +#define NI6143_AI_FIFO_FLAG_REG 0x84 /* w32 */ +#define NI6143_AI_FIFO_CTRL_REG 0x88 /* w32 */ +#define NI6143_AI_FIFO_STATUS_REG 0x88 /* r32 */ +#define NI6143_AI_FIFO_DMA_THRESH_REG 0x90 /* w32 */ +#define NI6143_AI_FIFO_WORDS_AVAIL_REG 0x94 /* w32 */ -#define Calibration_Channel_6143 0x42 /* w16 */ -#define Calibration_LowTime_6143 0x20 /* w16 */ -#define Calibration_HighTime_6143 0x22 /* w16 */ -#define Relay_Counter_Load_Val__6143 0x4C /* w32 */ -#define Signature_6143 0x50 /* w32 */ -#define Release_Date_6143 0x54 /* w32 */ -#define Release_Oldest_Date_6143 0x58 /* w32 */ - -#define Calibration_Channel_6143_RelayOn 0x8000 /* Calibration relay switch On */ -#define Calibration_Channel_6143_RelayOff 0x4000 /* Calibration relay switch Off */ -#define Calibration_Channel_Gnd_Gnd 0x00 /* Offset Calibration */ -#define Calibration_Channel_2v5_Gnd 0x02 /* 2.5V Reference */ -#define Calibration_Channel_Pwm_Gnd 0x05 /* +/- 5V Self Cal */ -#define Calibration_Channel_2v5_Pwm 0x0a /* PWM Calibration */ -#define Calibration_Channel_Pwm_Pwm 0x0d /* CMRR */ -#define Calibration_Channel_Gnd_Pwm 0x0e /* PWM Calibration */ +#define NI6143_CALIB_CHAN_REG 0x42 /* w16 */ +#define NI6143_CALIB_CHAN_RELAY_ON BIT(15) +#define NI6143_CALIB_CHAN_RELAY_OFF BIT(14) +#define NI6143_CALIB_CHAN(x) (((x) & 0xf) << 0) +#define NI6143_CALIB_CHAN_GND_GND NI6143_CALIB_CHAN(0) /* Offset Cal */ +#define NI6143_CALIB_CHAN_2V5_GND NI6143_CALIB_CHAN(2) /* 2.5V ref */ +#define NI6143_CALIB_CHAN_PWM_GND NI6143_CALIB_CHAN(5) /* +-5V Self Cal */ +#define NI6143_CALIB_CHAN_2V5_PWM NI6143_CALIB_CHAN(10) /* PWM Cal */ +#define NI6143_CALIB_CHAN_PWM_PWM NI6143_CALIB_CHAN(13) /* CMRR */ +#define NI6143_CALIB_CHAN_GND_PWM NI6143_CALIB_CHAN(14) /* PWM Cal */ +#define NI6143_CALIB_LO_TIME_REG 0x20 /* w16 */ +#define NI6143_CALIB_HI_TIME_REG 0x22 /* w16 */ +#define NI6143_RELAY_COUNTER_LOAD_REG 0x4c /* w32 */ +#define NI6143_SIGNATURE_REG 0x50 /* w32 */ +#define NI6143_RELEASE_DATE_REG 0x54 /* w32 */ +#define NI6143_RELEASE_OLDEST_DATE_REG 0x58 /* w32 */ /* 671x, 611x registers */ From b738aa3a131bdc670191318bebc558629b3f1ed4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 15:00:09 -0700 Subject: [PATCH 0405/1163] staging: comedi: ni_stc.h: tidy up the cs5529_configuration_bits For aesthetics, convert the enum into defines and the inline functions into macros. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 8 +-- drivers/staging/comedi/drivers/ni_stc.h | 58 +++++++++---------- 2 files changed, 30 insertions(+), 36 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 802aabf0deee..8a484fb5ea8e 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -4581,19 +4581,19 @@ static void cs5529_config_write(struct comedi_device *dev, unsigned int value, static int init_cs5529(struct comedi_device *dev) { - unsigned int config_bits = - CSCFG_PORT_MODE | CSCFG_WORD_RATE_2180_CYCLES; + unsigned int config_bits = CS5529_CFG_PORT_FLAG | + CS5529_CFG_WORD_RATE_2180; #if 1 /* do self-calibration */ - cs5529_config_write(dev, config_bits | CSCFG_SELF_CAL_OFFSET_GAIN, + cs5529_config_write(dev, config_bits | CS5529_CFG_CALIB_BOTH_SELF, CSCMD_CONFIG_REGISTER); /* need to force a conversion for calibration to run */ cs5529_do_conversion(dev, NULL); #else /* force gain calibration to 1 */ cs5529_config_write(dev, 0x400000, CSCMD_GAIN_REGISTER); - cs5529_config_write(dev, config_bits | CSCFG_SELF_CAL_OFFSET, + cs5529_config_write(dev, config_bits | CS5529_CFG_CALIB_OFFSET_SELF, CSCMD_CONFIG_REGISTER); if (cs5529_wait_for_idle(dev)) dev_err(dev->class_dev, diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index ddb0e6ccbbc0..3d1fd9b08684 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -676,39 +676,33 @@ static inline unsigned int DACx_Direct_Data_671x(int channel) enum AO_Misc_611x_Bits { CLEAR_WG = 1, }; -enum cs5529_configuration_bits { - CSCFG_CAL_CONTROL_MASK = 0x7, - CSCFG_SELF_CAL_OFFSET = 0x1, - CSCFG_SELF_CAL_GAIN = 0x2, - CSCFG_SELF_CAL_OFFSET_GAIN = 0x3, - CSCFG_SYSTEM_CAL_OFFSET = 0x5, - CSCFG_SYSTEM_CAL_GAIN = 0x6, - CSCFG_DONE = 1 << 3, - CSCFG_POWER_SAVE_SELECT = 1 << 4, - CSCFG_PORT_MODE = 1 << 5, - CSCFG_RESET_VALID = 1 << 6, - CSCFG_RESET = 1 << 7, - CSCFG_UNIPOLAR = 1 << 12, - CSCFG_WORD_RATE_2180_CYCLES = 0x0 << 13, - CSCFG_WORD_RATE_1092_CYCLES = 0x1 << 13, - CSCFG_WORD_RATE_532_CYCLES = 0x2 << 13, - CSCFG_WORD_RATE_388_CYCLES = 0x3 << 13, - CSCFG_WORD_RATE_324_CYCLES = 0x4 << 13, - CSCFG_WORD_RATE_17444_CYCLES = 0x5 << 13, - CSCFG_WORD_RATE_8724_CYCLES = 0x6 << 13, - CSCFG_WORD_RATE_4364_CYCLES = 0x7 << 13, - CSCFG_WORD_RATE_MASK = 0x7 << 13, - CSCFG_LOW_POWER = 1 << 16, -}; -static inline unsigned int CS5529_CONFIG_DOUT(int output) -{ - return 1 << (18 + output); -} -static inline unsigned int CS5529_CONFIG_AOUT(int output) -{ - return 1 << (22 + output); -} +#define CS5529_CFG_AOUT(x) BIT(22 + (x)) +#define CS5529_CFG_DOUT(x) BIT(18 + (x)) +#define CS5529_CFG_LOW_PWR_MODE BIT(16) +#define CS5529_CFG_WORD_RATE(x) (((x) & 0x7) << 13) +#define CS5529_CFG_WORD_RATE_MASK CS5529_CFG_WORD_RATE(0x7) +#define CS5529_CFG_WORD_RATE_2180 CS5529_CFG_WORD_RATE(0) +#define CS5529_CFG_WORD_RATE_1092 CS5529_CFG_WORD_RATE(1) +#define CS5529_CFG_WORD_RATE_532 CS5529_CFG_WORD_RATE(2) +#define CS5529_CFG_WORD_RATE_388 CS5529_CFG_WORD_RATE(3) +#define CS5529_CFG_WORD_RATE_324 CS5529_CFG_WORD_RATE(4) +#define CS5529_CFG_WORD_RATE_17444 CS5529_CFG_WORD_RATE(5) +#define CS5529_CFG_WORD_RATE_8724 CS5529_CFG_WORD_RATE(6) +#define CS5529_CFG_WORD_RATE_4364 CS5529_CFG_WORD_RATE(7) +#define CS5529_CFG_UNIPOLAR BIT(12) +#define CS5529_CFG_RESET BIT(7) +#define CS5529_CFG_RESET_VALID BIT(6) +#define CS5529_CFG_PORT_FLAG BIT(5) +#define CS5529_CFG_PWR_SAVE_SEL BIT(4) +#define CS5529_CFG_DONE_FLAG BIT(3) +#define CS5529_CFG_CALIB(x) (((x) & 0x7) << 0) +#define CS5529_CFG_CALIB_NONE CS5529_CFG_CALIB(0) +#define CS5529_CFG_CALIB_OFFSET_SELF CS5529_CFG_CALIB(1) +#define CS5529_CFG_CALIB_GAIN_SELF CS5529_CFG_CALIB(2) +#define CS5529_CFG_CALIB_BOTH_SELF CS5529_CFG_CALIB(3) +#define CS5529_CFG_CALIB_OFFSET_SYS CS5529_CFG_CALIB(5) +#define CS5529_CFG_CALIB_GAIN_SYS CS5529_CFG_CALIB(6) enum cs5529_command_bits { CSCMD_POWER_SAVE = 0x1, From 94f0cbb99a040a8aceddb490e4ed08cd4d4a4fde Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 15:00:10 -0700 Subject: [PATCH 0406/1163] staging: comedi: ni_stc.h: tidy up the cs5529_command_bits For aesthetics, convert the enum into defines. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 12 ++++----- drivers/staging/comedi/drivers/ni_stc.h | 25 +++++++++++-------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 8a484fb5ea8e..33f01e1efb29 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -4512,7 +4512,7 @@ static int cs5529_do_conversion(struct comedi_device *dev, int retval; unsigned short status; - cs5529_command(dev, CSCMD_COMMAND | CSCMD_SINGLE_CONVERSION); + cs5529_command(dev, CS5529_CMD_CB | CS5529_CMD_SINGLE_CONV); retval = cs5529_wait_for_idle(dev); if (retval) { dev_err(dev->class_dev, @@ -4572,8 +4572,8 @@ static void cs5529_config_write(struct comedi_device *dev, unsigned int value, CAL_ADC_Config_Data_High_Word_67xx); ni_ao_win_outw(dev, (value & 0xffff), CAL_ADC_Config_Data_Low_Word_67xx); - reg_select_bits &= CSCMD_REGISTER_SELECT_MASK; - cs5529_command(dev, CSCMD_COMMAND | reg_select_bits); + reg_select_bits &= CS5529_CMD_REG_MASK; + cs5529_command(dev, CS5529_CMD_CB | reg_select_bits); if (cs5529_wait_for_idle(dev)) dev_err(dev->class_dev, "timeout or signal in %s\n", __func__); @@ -4587,14 +4587,14 @@ static int init_cs5529(struct comedi_device *dev) #if 1 /* do self-calibration */ cs5529_config_write(dev, config_bits | CS5529_CFG_CALIB_BOTH_SELF, - CSCMD_CONFIG_REGISTER); + CS5529_CFG_REG); /* need to force a conversion for calibration to run */ cs5529_do_conversion(dev, NULL); #else /* force gain calibration to 1 */ - cs5529_config_write(dev, 0x400000, CSCMD_GAIN_REGISTER); + cs5529_config_write(dev, 0x400000, CS5529_GAIN_REG); cs5529_config_write(dev, config_bits | CS5529_CFG_CALIB_OFFSET_SELF, - CSCMD_CONFIG_REGISTER); + CS5529_CFG_REG); if (cs5529_wait_for_idle(dev)) dev_err(dev->class_dev, "timeout or signal in %s\n", __func__); diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 3d1fd9b08684..0013e304ed56 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -677,6 +677,20 @@ enum AO_Misc_611x_Bits { CLEAR_WG = 1, }; +#define CS5529_CMD_CB BIT(7) +#define CS5529_CMD_SINGLE_CONV BIT(6) +#define CS5529_CMD_CONT_CONV BIT(5) +#define CS5529_CMD_READ BIT(4) +#define CS5529_CMD_REG(x) (((x) & 0x7) << 1) +#define CS5529_CMD_REG_MASK CS5529_CMD_REG(7) +#define CS5529_CMD_PWR_SAVE BIT(0) + +#define CS5529_OFFSET_REG CS5529_CMD_REG(0) +#define CS5529_GAIN_REG CS5529_CMD_REG(1) +#define CS5529_CONV_DATA_REG CS5529_CMD_REG(3) +#define CS5529_SETUP_REG CS5529_CMD_REG(4) + +#define CS5529_CFG_REG CS5529_CMD_REG(2) #define CS5529_CFG_AOUT(x) BIT(22 + (x)) #define CS5529_CFG_DOUT(x) BIT(18 + (x)) #define CS5529_CFG_LOW_PWR_MODE BIT(16) @@ -704,17 +718,6 @@ enum AO_Misc_611x_Bits { #define CS5529_CFG_CALIB_OFFSET_SYS CS5529_CFG_CALIB(5) #define CS5529_CFG_CALIB_GAIN_SYS CS5529_CFG_CALIB(6) -enum cs5529_command_bits { - CSCMD_POWER_SAVE = 0x1, - CSCMD_REGISTER_SELECT_MASK = 0xe, - CSCMD_OFFSET_REGISTER = 0x0, - CSCMD_GAIN_REGISTER = 0x2, - CSCMD_CONFIG_REGISTER = 0x4, - CSCMD_READ = 0x10, - CSCMD_CONTINUOUS_CONVERSIONS = 0x20, - CSCMD_SINGLE_CONVERSION = 0x40, - CSCMD_COMMAND = 0x80, -}; enum cs5529_status_bits { CSS_ADC_BUSY = 0x1, CSS_OSC_DETECT = 0x2, /* indicates adc error */ From ef3915435c587caa24b8840f29102aa49d921216 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 15:00:11 -0700 Subject: [PATCH 0407/1163] staging: comedi: ni_stc.h: tidy up the windowed_regs_67xx_61xx Rename the CamelCase. For aesthetics, convert the enum into defines. Use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 51 +++++++++--------- drivers/staging/comedi/drivers/ni_stc.h | 53 ++++++++----------- 2 files changed, 47 insertions(+), 57 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 33f01e1efb29..c741dde9c0bb 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1091,7 +1091,7 @@ static int ni_ao_prep_fifo(struct comedi_device *dev, /* reset fifo */ ni_stc_writew(dev, 1, NISTC_DAC_FIFO_CLR_REG); if (devpriv->is_6xxx) - ni_ao_win_outl(dev, 0x6, AO_FIFO_Offset_Load_611x); + ni_ao_win_outl(dev, 0x6, NI611X_AO_FIFO_OFFSET_LOAD_REG); /* load some data */ nbytes = comedi_buf_read_n_available(s); @@ -2736,9 +2736,9 @@ static int ni_ao_insn_write(struct comedi_device *dev, int i; if (devpriv->is_6xxx) { - ni_ao_win_outw(dev, 1 << chan, AO_Immediate_671x); + ni_ao_win_outw(dev, 1 << chan, NI671X_AO_IMMEDIATE_REG); - reg = DACx_Direct_Data_671x(chan); + reg = NI671X_DAC_DIRECT_DATA_REG(chan); } else if (devpriv->is_m_series) { reg = NI_M_DAC_DIRECT_DATA_REG(chan); } else { @@ -2838,7 +2838,7 @@ static int ni_ao_inttrig(struct comedi_device *dev, #ifdef PCIDMA ni_stc_writew(dev, 1, NISTC_DAC_FIFO_CLR_REG); if (devpriv->is_6xxx) - ni_ao_win_outl(dev, 0x6, AO_FIFO_Offset_Load_611x); + ni_ao_win_outl(dev, 0x6, NI611X_AO_FIFO_OFFSET_LOAD_REG); ret = ni_ao_setup_MITE_dma(dev); if (ret) return ret; @@ -2910,7 +2910,8 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ni_stc_writew(dev, NISTC_AO_CMD1_DISARM, NISTC_AO_CMD1_REG); if (devpriv->is_6xxx) { - ni_ao_win_outw(dev, CLEAR_WG, AO_Misc_611x); + ni_ao_win_outw(dev, NI611X_AO_MISC_CLEAR_WG, + NI611X_AO_MISC_REG); bits = 0; for (i = 0; i < cmd->chanlist_len; i++) { @@ -2918,9 +2919,9 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) chan = CR_CHAN(cmd->chanlist[i]); bits |= 1 << chan; - ni_ao_win_outw(dev, chan, AO_Waveform_Generation_611x); + ni_ao_win_outw(dev, chan, NI611X_AO_WAVEFORM_GEN_REG); } - ni_ao_win_outw(dev, bits, AO_Timed_611x); + ni_ao_win_outw(dev, bits, NI611X_AO_TIMED_REG); } ni_ao_config_chanlist(dev, s, cmd->chanlist, cmd->chanlist_len, 1); @@ -3227,8 +3228,9 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s) for (i = 0; i < s->n_chan; ++i) immediate_bits |= 1 << i; - ni_ao_win_outw(dev, immediate_bits, AO_Immediate_671x); - ni_ao_win_outw(dev, CLEAR_WG, AO_Misc_611x); + ni_ao_win_outw(dev, immediate_bits, NI671X_AO_IMMEDIATE_REG); + ni_ao_win_outw(dev, NI611X_AO_MISC_CLEAR_WG, + NI611X_AO_MISC_REG); } ni_stc_writew(dev, NISTC_RESET_AO_CFG_END, NISTC_RESET_REG); @@ -3708,9 +3710,9 @@ static void init_ao_67xx(struct comedi_device *dev, struct comedi_subdevice *s) for (i = 0; i < s->n_chan; i++) { ni_ao_win_outw(dev, NI_E_AO_DACSEL(i) | 0x0, - AO_Configuration_2_67xx); + NI67XX_AO_CFG2_REG); } - ni_ao_win_outw(dev, 0x0, AO_Later_Single_Point_Updates); + ni_ao_win_outw(dev, 0x0, NI67XX_AO_SP_UPDATES_REG); } static const struct mio_regmap ni_gpct_to_stc_regmap[] = { @@ -4472,8 +4474,8 @@ static int cs5529_wait_for_idle(struct comedi_device *dev) int i; for (i = 0; i < timeout; i++) { - status = ni_ao_win_inw(dev, CAL_ADC_Status_67xx); - if ((status & CSS_ADC_BUSY) == 0) + status = ni_ao_win_inw(dev, NI67XX_CAL_STATUS_REG); + if ((status & NI67XX_CAL_STATUS_BUSY) == 0) break; set_current_state(TASK_INTERRUPTIBLE); if (schedule_timeout(1)) @@ -4491,13 +4493,14 @@ static void cs5529_command(struct comedi_device *dev, unsigned short value) static const int timeout = 100; int i; - ni_ao_win_outw(dev, value, CAL_ADC_Command_67xx); + ni_ao_win_outw(dev, value, NI67XX_CAL_CMD_REG); /* give time for command to start being serially clocked into cs5529. - * this insures that the CSS_ADC_BUSY bit will get properly + * this insures that the NI67XX_CAL_STATUS_BUSY bit will get properly * set before we exit this function. */ for (i = 0; i < timeout; i++) { - if ((ni_ao_win_inw(dev, CAL_ADC_Status_67xx) & CSS_ADC_BUSY)) + if (ni_ao_win_inw(dev, NI67XX_CAL_STATUS_REG) & + NI67XX_CAL_STATUS_BUSY) break; udelay(1); } @@ -4519,18 +4522,18 @@ static int cs5529_do_conversion(struct comedi_device *dev, "timeout or signal in cs5529_do_conversion()\n"); return -ETIME; } - status = ni_ao_win_inw(dev, CAL_ADC_Status_67xx); - if (status & CSS_OSC_DETECT) { + status = ni_ao_win_inw(dev, NI67XX_CAL_STATUS_REG); + if (status & NI67XX_CAL_STATUS_OSC_DETECT) { dev_err(dev->class_dev, "cs5529 conversion error, status CSS_OSC_DETECT\n"); return -EIO; } - if (status & CSS_OVERRANGE) { + if (status & NI67XX_CAL_STATUS_OVERRANGE) { dev_err(dev->class_dev, "cs5529 conversion error, overrange (ignoring)\n"); } if (data) { - *data = ni_ao_win_inw(dev, CAL_ADC_Data_67xx); + *data = ni_ao_win_inw(dev, NI67XX_CAL_DATA_REG); /* cs5529 returns 16 bit signed data in bipolar mode */ *data ^= (1 << 15); } @@ -4554,7 +4557,7 @@ static int cs5529_ai_insn_read(struct comedi_device *dev, channel_select = INTERNAL_REF; else channel_select = CR_CHAN(insn->chanspec); - ni_ao_win_outw(dev, channel_select, AO_Calibration_Channel_Select_67xx); + ni_ao_win_outw(dev, channel_select, NI67XX_AO_CAL_CHAN_SEL_REG); for (n = 0; n < insn->n; n++) { retval = cs5529_do_conversion(dev, &sample); @@ -4568,10 +4571,8 @@ static int cs5529_ai_insn_read(struct comedi_device *dev, static void cs5529_config_write(struct comedi_device *dev, unsigned int value, unsigned int reg_select_bits) { - ni_ao_win_outw(dev, ((value >> 16) & 0xff), - CAL_ADC_Config_Data_High_Word_67xx); - ni_ao_win_outw(dev, (value & 0xffff), - CAL_ADC_Config_Data_Low_Word_67xx); + ni_ao_win_outw(dev, (value >> 16) & 0xff, NI67XX_CAL_CFG_HI_REG); + ni_ao_win_outw(dev, value & 0xffff, NI67XX_CAL_CFG_LO_REG); reg_select_bits &= CS5529_CMD_REG_MASK; cs5529_command(dev, CS5529_CMD_CB | reg_select_bits); if (cs5529_wait_for_idle(dev)) diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 0013e304ed56..79887818009e 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -650,32 +650,27 @@ #define NI6143_RELEASE_DATE_REG 0x54 /* w32 */ #define NI6143_RELEASE_OLDEST_DATE_REG 0x58 /* w32 */ -/* 671x, 611x registers */ - -/* 671xi, 611x windowed ao registers */ -enum windowed_regs_67xx_61xx { - AO_Immediate_671x = 0x11, /* W 16 */ - AO_Timed_611x = 0x10, /* W 16 */ - AO_FIFO_Offset_Load_611x = 0x13, /* W32 */ - AO_Later_Single_Point_Updates = 0x14, /* W 16 */ - AO_Waveform_Generation_611x = 0x15, /* W 16 */ - AO_Misc_611x = 0x16, /* W 16 */ - AO_Calibration_Channel_Select_67xx = 0x17, /* W 16 */ - AO_Configuration_2_67xx = 0x18, /* W 16 */ - CAL_ADC_Command_67xx = 0x19, /* W 8 */ - CAL_ADC_Status_67xx = 0x1a, /* R 8 */ - CAL_ADC_Data_67xx = 0x1b, /* R 16 */ - CAL_ADC_Config_Data_High_Word_67xx = 0x1c, /* RW 16 */ - CAL_ADC_Config_Data_Low_Word_67xx = 0x1d, /* RW 16 */ -}; -static inline unsigned int DACx_Direct_Data_671x(int channel) -{ - return channel; -} - -enum AO_Misc_611x_Bits { - CLEAR_WG = 1, -}; +/* + * 671x, 611x windowed ao registers + */ +#define NI671X_DAC_DIRECT_DATA_REG(x) (0x00 + (x)) /* w16 */ +#define NI611X_AO_TIMED_REG 0x10 /* w16 */ +#define NI671X_AO_IMMEDIATE_REG 0x11 /* w16 */ +#define NI611X_AO_FIFO_OFFSET_LOAD_REG 0x13 /* w32 */ +#define NI67XX_AO_SP_UPDATES_REG 0x14 /* w16 */ +#define NI611X_AO_WAVEFORM_GEN_REG 0x15 /* w16 */ +#define NI611X_AO_MISC_REG 0x16 /* w16 */ +#define NI611X_AO_MISC_CLEAR_WG BIT(0) +#define NI67XX_AO_CAL_CHAN_SEL_REG 0x17 /* w16 */ +#define NI67XX_AO_CFG2_REG 0x18 /* w16 */ +#define NI67XX_CAL_CMD_REG 0x19 /* w16 */ +#define NI67XX_CAL_STATUS_REG 0x1a /* r8 */ +#define NI67XX_CAL_STATUS_BUSY BIT(0) +#define NI67XX_CAL_STATUS_OSC_DETECT BIT(1) +#define NI67XX_CAL_STATUS_OVERRANGE BIT(2) +#define NI67XX_CAL_DATA_REG 0x1b /* r16 */ +#define NI67XX_CAL_CFG_HI_REG 0x1c /* rw16 */ +#define NI67XX_CAL_CFG_LO_REG 0x1d /* rw16 */ #define CS5529_CMD_CB BIT(7) #define CS5529_CMD_SINGLE_CONV BIT(6) @@ -718,12 +713,6 @@ enum AO_Misc_611x_Bits { #define CS5529_CFG_CALIB_OFFSET_SYS CS5529_CFG_CALIB(5) #define CS5529_CFG_CALIB_GAIN_SYS CS5529_CFG_CALIB(6) -enum cs5529_status_bits { - CSS_ADC_BUSY = 0x1, - CSS_OSC_DETECT = 0x2, /* indicates adc error */ - CSS_OVERRANGE = 0x4, -}; - /* This is stuff unique to the NI E series drivers, but I thought I'd put it here anyway. From 35bb871663ddb06df9d601b32deac5f4f06b65b4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 15:00:12 -0700 Subject: [PATCH 0408/1163] staging: comedi: ni_stc.h: final cleanup 1) Move the enum's to a better location and tidy up the whitespace. 2) Tidy up the defines used for some array sizes in the private data. 3) Add comments for the spinlock_t variables in the private data. 4) Move the forward declaration to the end of the file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_stc.h | 81 ++++++++++++++----------- 1 file changed, 47 insertions(+), 34 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 79887818009e..1d5af25b92a8 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -26,8 +26,6 @@ #include "ni_tio.h" -#define NUM_PFI_OUTPUT_SELECT_REGS 6 - /* * Registers in the National Instruments DAQ-STC chip */ @@ -713,34 +711,6 @@ #define CS5529_CFG_CALIB_OFFSET_SYS CS5529_CFG_CALIB(5) #define CS5529_CFG_CALIB_GAIN_SYS CS5529_CFG_CALIB(6) -/* - This is stuff unique to the NI E series drivers, - but I thought I'd put it here anyway. -*/ - -enum { ai_gain_16 = - 0, ai_gain_8, ai_gain_14, ai_gain_4, ai_gain_611x, ai_gain_622x, - ai_gain_628x, ai_gain_6143 -}; -enum caldac_enum { caldac_none = 0, mb88341, dac8800, dac8043, ad8522, - ad8804, ad8842, ad8804_debug -}; -enum ni_reg_type { - ni_reg_normal = 0x0, - ni_reg_611x = 0x1, - ni_reg_6711 = 0x2, - ni_reg_6713 = 0x4, - ni_reg_67xx_mask = 0x6, - ni_reg_6xxx_mask = 0x7, - ni_reg_622x = 0x8, - ni_reg_625x = 0x10, - ni_reg_628x = 0x18, - ni_reg_m_series_mask = 0x18, - ni_reg_6143 = 0x20 -}; - -static const struct comedi_lrange range_ni_E_ao_ext; - /* * M-Series specific registers not handled by the DAQ-STC and GPCT register * remapping. @@ -935,7 +905,41 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_AO_REF_ATTENUATION_REG(x) (0x264 + (x)) #define NI_M_AO_REF_ATTENUATION_X5 BIT(0) -#define M_SERIES_EEPROM_SIZE 1024 +enum { + ai_gain_16 = 0, + ai_gain_8, + ai_gain_14, + ai_gain_4, + ai_gain_611x, + ai_gain_622x, + ai_gain_628x, + ai_gain_6143 +}; + +enum caldac_enum { + caldac_none = 0, + mb88341, + dac8800, + dac8043, + ad8522, + ad8804, + ad8842, + ad8804_debug +}; + +enum ni_reg_type { + ni_reg_normal = 0x0, + ni_reg_611x = 0x1, + ni_reg_6711 = 0x2, + ni_reg_6713 = 0x4, + ni_reg_67xx_mask = 0x6, + ni_reg_6xxx_mask = 0x7, + ni_reg_622x = 0x8, + ni_reg_625x = 0x10, + ni_reg_628x = 0x18, + ni_reg_m_series_mask = 0x18, + ni_reg_6143 = 0x20 +}; struct ni_board_struct { const char *name; @@ -963,9 +967,13 @@ struct ni_board_struct { enum caldac_enum caldac[3]; }; -#define MAX_N_CALDACS 34 -#define MAX_N_AO_CHAN 8 -#define NUM_GPCT 2 +#define MAX_N_CALDACS 34 +#define MAX_N_AO_CHAN 8 +#define NUM_GPCT 2 + +#define NUM_PFI_OUTPUT_SELECT_REGS 6 + +#define M_SERIES_EEPROM_SIZE 1024 struct ni_private { unsigned short dio_output; @@ -973,8 +981,11 @@ struct ni_private { int aimode; unsigned int ai_calib_source; unsigned int ai_calib_source_enabled; + /* protects access to windowed registers */ spinlock_t window_lock; + /* protects interrupt/dma register access */ spinlock_t soft_reg_copy_lock; + /* protects mite DMA channel request/release */ spinlock_t mite_channel_lock; int changain_state; @@ -1046,4 +1057,6 @@ struct ni_private { unsigned int is_6713:1; }; +static const struct comedi_lrange range_ni_E_ao_ext; + #endif /* _COMEDI_NI_STC_H */ From 4a72a7af462de09a2f6ef2bafd08878062b3cb5d Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 10 May 2015 14:54:38 +0200 Subject: [PATCH 0409/1163] staging: remove i2o subsystem This subsystem isn't used anymore, and the hardware isn't around. It's been in staging for a while, and it's time for it to now be removed. Cc: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - drivers/staging/i2o/Kconfig | 120 -- drivers/staging/i2o/Makefile | 16 - drivers/staging/i2o/README | 98 -- drivers/staging/i2o/README.ioctl | 394 ------ drivers/staging/i2o/bus-osm.c | 177 --- drivers/staging/i2o/config-osm.c | 90 -- drivers/staging/i2o/core.h | 69 - drivers/staging/i2o/debug.c | 473 ------- drivers/staging/i2o/device.c | 592 --------- drivers/staging/i2o/driver.c | 381 ------ drivers/staging/i2o/exec-osm.c | 612 --------- drivers/staging/i2o/i2o.h | 988 -------------- drivers/staging/i2o/i2o_block.c | 1228 ------------------ drivers/staging/i2o/i2o_block.h | 103 -- drivers/staging/i2o/i2o_config.c | 1162 ----------------- drivers/staging/i2o/i2o_proc.c | 2049 ------------------------------ drivers/staging/i2o/i2o_scsi.c | 814 ------------ drivers/staging/i2o/iop.c | 1254 ------------------ drivers/staging/i2o/memory.c | 312 ----- drivers/staging/i2o/pci.c | 500 -------- 22 files changed, 11435 deletions(-) delete mode 100644 drivers/staging/i2o/Kconfig delete mode 100644 drivers/staging/i2o/Makefile delete mode 100644 drivers/staging/i2o/README delete mode 100644 drivers/staging/i2o/README.ioctl delete mode 100644 drivers/staging/i2o/bus-osm.c delete mode 100644 drivers/staging/i2o/config-osm.c delete mode 100644 drivers/staging/i2o/core.h delete mode 100644 drivers/staging/i2o/debug.c delete mode 100644 drivers/staging/i2o/device.c delete mode 100644 drivers/staging/i2o/driver.c delete mode 100644 drivers/staging/i2o/exec-osm.c delete mode 100644 drivers/staging/i2o/i2o.h delete mode 100644 drivers/staging/i2o/i2o_block.c delete mode 100644 drivers/staging/i2o/i2o_block.h delete mode 100644 drivers/staging/i2o/i2o_config.c delete mode 100644 drivers/staging/i2o/i2o_proc.c delete mode 100644 drivers/staging/i2o/i2o_scsi.c delete mode 100644 drivers/staging/i2o/iop.c delete mode 100644 drivers/staging/i2o/memory.c delete mode 100644 drivers/staging/i2o/pci.c diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index bfacf69f68f4..c204ab2693c1 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -108,8 +108,6 @@ source "drivers/staging/clocking-wizard/Kconfig" source "drivers/staging/fbtft/Kconfig" -source "drivers/staging/i2o/Kconfig" - source "drivers/staging/fsl-mc/Kconfig" endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index a12221f086c2..9b9151758bbd 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -46,5 +46,4 @@ obj-$(CONFIG_CRYPTO_SKEIN) += skein/ obj-$(CONFIG_UNISYSSPAR) += unisys/ obj-$(CONFIG_COMMON_CLK_XLNX_CLKWZRD) += clocking-wizard/ obj-$(CONFIG_FB_TFT) += fbtft/ -obj-$(CONFIG_I2O) += i2o/ obj-$(CONFIG_FSL_MC_BUS) += fsl-mc/ diff --git a/drivers/staging/i2o/Kconfig b/drivers/staging/i2o/Kconfig deleted file mode 100644 index 286c53f4b13d..000000000000 --- a/drivers/staging/i2o/Kconfig +++ /dev/null @@ -1,120 +0,0 @@ -menuconfig I2O - tristate "I2O device support" - depends on PCI - ---help--- - The Intelligent Input/Output (I2O) architecture allows hardware - drivers to be split into two parts: an operating system specific - module called the OSM and an hardware specific module called the - HDM. The OSM can talk to a whole range of HDM's, and ideally the - HDM's are not OS dependent. This allows for the same HDM driver to - be used under different operating systems if the relevant OSM is in - place. In order for this to work, you need to have an I2O interface - adapter card in your computer. This card contains a special I/O - processor (IOP), thus allowing high speeds since the CPU does not - have to deal with I/O. - - If you say Y here, you will get a choice of interface adapter - drivers and OSM's with the following questions. - - To compile this support as a module, choose M here: the - modules will be called i2o_core. - - If unsure, say N. - -if I2O - -config I2O_LCT_NOTIFY_ON_CHANGES - bool "Enable LCT notification" - default y - ---help--- - Only say N here if you have a I2O controller from SUN. The SUN - firmware doesn't support LCT notification on changes. If this option - is enabled on such a controller the driver will hang up in a endless - loop. On all other controllers say Y. - - If unsure, say Y. - -config I2O_EXT_ADAPTEC - bool "Enable Adaptec extensions" - default y - ---help--- - Say Y for support of raidutils for Adaptec I2O controllers. You also - have to say Y to "I2O Configuration support", "I2O SCSI OSM" below - and to "SCSI generic support" under "SCSI device configuration". - -config I2O_EXT_ADAPTEC_DMA64 - bool "Enable 64-bit DMA" - depends on I2O_EXT_ADAPTEC && ( 64BIT || HIGHMEM64G ) - default y - ---help--- - Say Y for support of 64-bit DMA transfer mode on Adaptec I2O - controllers. - Note: You need at least firmware version 3709. - -config I2O_CONFIG - tristate "I2O Configuration support" - depends on VIRT_TO_BUS - ---help--- - Say Y for support of the configuration interface for the I2O adapters. - If you have a RAID controller from Adaptec and you want to use the - raidutils to manage your RAID array, you have to say Y here. - - To compile this support as a module, choose M here: the - module will be called i2o_config. - - Note: If you want to use the new API you have to download the - i2o_config patch from http://i2o.shadowconnect.com/ - -config I2O_CONFIG_OLD_IOCTL - bool "Enable ioctls (OBSOLETE)" - depends on I2O_CONFIG - default y - ---help--- - Enables old ioctls. - -config I2O_BUS - tristate "I2O Bus Adapter OSM" - ---help--- - Include support for the I2O Bus Adapter OSM. The Bus Adapter OSM - provides access to the busses on the I2O controller. The main purpose - is to rescan the bus to find new devices. - - To compile this support as a module, choose M here: the - module will be called i2o_bus. - -config I2O_BLOCK - tristate "I2O Block OSM" - depends on BLOCK - ---help--- - Include support for the I2O Block OSM. The Block OSM presents disk - and other structured block devices to the operating system. If you - are using an RAID controller, you could access the array only by - the Block OSM driver. But it is possible to access the single disks - by the SCSI OSM driver, for example to monitor the disks. - - To compile this support as a module, choose M here: the - module will be called i2o_block. - -config I2O_SCSI - tristate "I2O SCSI OSM" - depends on SCSI - ---help--- - Allows direct SCSI access to SCSI devices on a SCSI or FibreChannel - I2O controller. You can use both the SCSI and Block OSM together if - you wish. To access a RAID array, you must use the Block OSM driver. - But you could use the SCSI OSM driver to monitor the single disks. - - To compile this support as a module, choose M here: the - module will be called i2o_scsi. - -config I2O_PROC - tristate "I2O /proc support" - ---help--- - If you say Y here and to "/proc file system support", you will be - able to read I2O related information from the virtual directory - /proc/i2o. - - To compile this support as a module, choose M here: the - module will be called i2o_proc. - -endif # I2O diff --git a/drivers/staging/i2o/Makefile b/drivers/staging/i2o/Makefile deleted file mode 100644 index b0982dacfd0a..000000000000 --- a/drivers/staging/i2o/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# -# Makefile for the kernel I2O OSM. -# -# Note : at this point, these files are compiled on all systems. -# In the future, some of these should be built conditionally. -# - -i2o_core-y += iop.o driver.o device.o debug.o pci.o exec-osm.o memory.o -i2o_bus-y += bus-osm.o -i2o_config-y += config-osm.o -obj-$(CONFIG_I2O) += i2o_core.o -obj-$(CONFIG_I2O_CONFIG)+= i2o_config.o -obj-$(CONFIG_I2O_BUS) += i2o_bus.o -obj-$(CONFIG_I2O_BLOCK) += i2o_block.o -obj-$(CONFIG_I2O_SCSI) += i2o_scsi.o -obj-$(CONFIG_I2O_PROC) += i2o_proc.o diff --git a/drivers/staging/i2o/README b/drivers/staging/i2o/README deleted file mode 100644 index f072a8eb3041..000000000000 --- a/drivers/staging/i2o/README +++ /dev/null @@ -1,98 +0,0 @@ - - Linux I2O Support (c) Copyright 1999 Red Hat Software - and others. - - 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. - -AUTHORS (so far) - -Alan Cox, Building Number Three Ltd. - Core code, SCSI and Block OSMs - -Steve Ralston, LSI Logic Corp. - Debugging SCSI and Block OSM - -Deepak Saxena, Intel Corp. - Various core/block extensions - /proc interface, bug fixes - Ioctl interfaces for control - Debugging LAN OSM - -Philip Rumpf - Fixed assorted dumb SMP locking bugs - -Juha Sievanen, University of Helsinki Finland - LAN OSM code - /proc interface to LAN class - Bug fixes - Core code extensions - -Auvo Häkkinen, University of Helsinki Finland - LAN OSM code - /Proc interface to LAN class - Bug fixes - Core code extensions - -Taneli Vähäkangas, University of Helsinki Finland - Fixes to i2o_config - -CREDITS - - This work was made possible by - -Red Hat Software - Funding for the Building #3 part of the project - -Symbios Logic (Now LSI) - Host adapters, hints, known to work platforms when I hit - compatibility problems - -BoxHill Corporation - Loan of initial FibreChannel disk array used for development work. - -European Commission - Funding the work done by the University of Helsinki - -SysKonnect - Loan of FDDI and Gigabit Ethernet cards - -ASUSTeK - Loan of I2O motherboard - -STATUS: - -o The core setup works within limits. -o The scsi layer seems to almost work. - I'm still chasing down the hang bug. -o The block OSM is mostly functional -o LAN OSM works with FDDI and Ethernet cards. - -TO DO: - -General: -o Provide hidden address space if asked -o Long term message flow control -o PCI IOP's without interrupts are not supported yet -o Push FAIL handling into the core -o DDM control interfaces for module load etc -o Add I2O 2.0 support (Deffered to 2.5 kernel) - -Block: -o Multiple major numbers -o Read ahead and cache handling stuff. Talk to Ingo and people -o Power management -o Finish Media changers - -SCSI: -o Find the right way to associate drives/luns/busses - -Lan: -o Performance tuning -o Test Fibre Channel code - -Tape: -o Anyone seen anything implementing this ? - (D.S: Will attempt to do so if spare cycles permit) diff --git a/drivers/staging/i2o/README.ioctl b/drivers/staging/i2o/README.ioctl deleted file mode 100644 index 4a7d2ebdfc97..000000000000 --- a/drivers/staging/i2o/README.ioctl +++ /dev/null @@ -1,394 +0,0 @@ - -Linux I2O User Space Interface -rev 0.3 - 04/20/99 - -============================================================================= -Originally written by Deepak Saxena(deepak@plexity.net) -Currently maintained by Deepak Saxena(deepak@plexity.net) -============================================================================= - -I. Introduction - -The Linux I2O subsystem provides a set of ioctl() commands that can be -utilized by user space applications to communicate with IOPs and devices -on individual IOPs. This document defines the specific ioctl() commands -that are available to the user and provides examples of their uses. - -This document assumes the reader is familiar with or has access to the -I2O specification as no I2O message parameters are outlined. For information -on the specification, see http://www.i2osig.org - -This document and the I2O user space interface are currently maintained -by Deepak Saxena. Please send all comments, errata, and bug fixes to -deepak@csociety.purdue.edu - -II. IOP Access - -Access to the I2O subsystem is provided through the device file named -/dev/i2o/ctl. This file is a character file with major number 10 and minor -number 166. It can be created through the following command: - - mknod /dev/i2o/ctl c 10 166 - -III. Determining the IOP Count - - SYNOPSIS - - ioctl(fd, I2OGETIOPS, int *count); - - u8 count[MAX_I2O_CONTROLLERS]; - - DESCRIPTION - - This function returns the system's active IOP table. count should - point to a buffer containing MAX_I2O_CONTROLLERS entries. Upon - returning, each entry will contain a non-zero value if the given - IOP unit is active, and NULL if it is inactive or non-existent. - - RETURN VALUE. - - Returns 0 if no errors occur, and -1 otherwise. If an error occurs, - errno is set appropriately: - - EFAULT Invalid user space pointer was passed - -IV. Getting Hardware Resource Table - - SYNOPSIS - - ioctl(fd, I2OHRTGET, struct i2o_cmd_hrt *hrt); - - struct i2o_cmd_hrtlct - { - u32 iop; /* IOP unit number */ - void *resbuf; /* Buffer for result */ - u32 *reslen; /* Buffer length in bytes */ - }; - - DESCRIPTION - - This function returns the Hardware Resource Table of the IOP specified - by hrt->iop in the buffer pointed to by hrt->resbuf. The actual size of - the data is written into *(hrt->reslen). - - RETURNS - - This function returns 0 if no errors occur. If an error occurs, -1 - is returned and errno is set appropriately: - - EFAULT Invalid user space pointer was passed - ENXIO Invalid IOP number - ENOBUFS Buffer not large enough. If this occurs, the required - buffer length is written into *(hrt->reslen) - -V. Getting Logical Configuration Table - - SYNOPSIS - - ioctl(fd, I2OLCTGET, struct i2o_cmd_lct *lct); - - struct i2o_cmd_hrtlct - { - u32 iop; /* IOP unit number */ - void *resbuf; /* Buffer for result */ - u32 *reslen; /* Buffer length in bytes */ - }; - - DESCRIPTION - - This function returns the Logical Configuration Table of the IOP specified - by lct->iop in the buffer pointed to by lct->resbuf. The actual size of - the data is written into *(lct->reslen). - - RETURNS - - This function returns 0 if no errors occur. If an error occurs, -1 - is returned and errno is set appropriately: - - EFAULT Invalid user space pointer was passed - ENXIO Invalid IOP number - ENOBUFS Buffer not large enough. If this occurs, the required - buffer length is written into *(lct->reslen) - -VI. Setting Parameters - - SYNOPSIS - - ioctl(fd, I2OPARMSET, struct i2o_parm_setget *ops); - - struct i2o_cmd_psetget - { - u32 iop; /* IOP unit number */ - u32 tid; /* Target device TID */ - void *opbuf; /* Operation List buffer */ - u32 oplen; /* Operation List buffer length in bytes */ - void *resbuf; /* Result List buffer */ - u32 *reslen; /* Result List buffer length in bytes */ - }; - - DESCRIPTION - - This function posts a UtilParamsSet message to the device identified - by ops->iop and ops->tid. The operation list for the message is - sent through the ops->opbuf buffer, and the result list is written - into the buffer pointed to by ops->resbuf. The number of bytes - written is placed into *(ops->reslen). - - RETURNS - - The return value is the size in bytes of the data written into - ops->resbuf if no errors occur. If an error occurs, -1 is returned - and errno is set appropriately: - - EFAULT Invalid user space pointer was passed - ENXIO Invalid IOP number - ENOBUFS Buffer not large enough. If this occurs, the required - buffer length is written into *(ops->reslen) - ETIMEDOUT Timeout waiting for reply message - ENOMEM Kernel memory allocation error - - A return value of 0 does not mean that the value was actually - changed properly on the IOP. The user should check the result - list to determine the specific status of the transaction. - -VII. Getting Parameters - - SYNOPSIS - - ioctl(fd, I2OPARMGET, struct i2o_parm_setget *ops); - - struct i2o_parm_setget - { - u32 iop; /* IOP unit number */ - u32 tid; /* Target device TID */ - void *opbuf; /* Operation List buffer */ - u32 oplen; /* Operation List buffer length in bytes */ - void *resbuf; /* Result List buffer */ - u32 *reslen; /* Result List buffer length in bytes */ - }; - - DESCRIPTION - - This function posts a UtilParamsGet message to the device identified - by ops->iop and ops->tid. The operation list for the message is - sent through the ops->opbuf buffer, and the result list is written - into the buffer pointed to by ops->resbuf. The actual size of data - written is placed into *(ops->reslen). - - RETURNS - - EFAULT Invalid user space pointer was passed - ENXIO Invalid IOP number - ENOBUFS Buffer not large enough. If this occurs, the required - buffer length is written into *(ops->reslen) - ETIMEDOUT Timeout waiting for reply message - ENOMEM Kernel memory allocation error - - A return value of 0 does not mean that the value was actually - properly retrieved. The user should check the result list - to determine the specific status of the transaction. - -VIII. Downloading Software - - SYNOPSIS - - ioctl(fd, I2OSWDL, struct i2o_sw_xfer *sw); - - struct i2o_sw_xfer - { - u32 iop; /* IOP unit number */ - u8 flags; /* DownloadFlags field */ - u8 sw_type; /* Software type */ - u32 sw_id; /* Software ID */ - void *buf; /* Pointer to software buffer */ - u32 *swlen; /* Length of software buffer */ - u32 *maxfrag; /* Number of fragments */ - u32 *curfrag; /* Current fragment number */ - }; - - DESCRIPTION - - This function downloads a software fragment pointed by sw->buf - to the iop identified by sw->iop. The DownloadFlags, SwID, SwType - and SwSize fields of the ExecSwDownload message are filled in with - the values of sw->flags, sw->sw_id, sw->sw_type and *(sw->swlen). - - The fragments _must_ be sent in order and be 8K in size. The last - fragment _may_ be shorter, however. The kernel will compute its - size based on information in the sw->swlen field. - - Please note that SW transfers can take a long time. - - RETURNS - - This function returns 0 no errors occur. If an error occurs, -1 - is returned and errno is set appropriately: - - EFAULT Invalid user space pointer was passed - ENXIO Invalid IOP number - ETIMEDOUT Timeout waiting for reply message - ENOMEM Kernel memory allocation error - -IX. Uploading Software - - SYNOPSIS - - ioctl(fd, I2OSWUL, struct i2o_sw_xfer *sw); - - struct i2o_sw_xfer - { - u32 iop; /* IOP unit number */ - u8 flags; /* UploadFlags */ - u8 sw_type; /* Software type */ - u32 sw_id; /* Software ID */ - void *buf; /* Pointer to software buffer */ - u32 *swlen; /* Length of software buffer */ - u32 *maxfrag; /* Number of fragments */ - u32 *curfrag; /* Current fragment number */ - }; - - DESCRIPTION - - This function uploads a software fragment from the IOP identified - by sw->iop, sw->sw_type, sw->sw_id and optionally sw->swlen fields. - The UploadFlags, SwID, SwType and SwSize fields of the ExecSwUpload - message are filled in with the values of sw->flags, sw->sw_id, - sw->sw_type and *(sw->swlen). - - The fragments _must_ be requested in order and be 8K in size. The - user is responsible for allocating memory pointed by sw->buf. The - last fragment _may_ be shorter. - - Please note that SW transfers can take a long time. - - RETURNS - - This function returns 0 if no errors occur. If an error occurs, -1 - is returned and errno is set appropriately: - - EFAULT Invalid user space pointer was passed - ENXIO Invalid IOP number - ETIMEDOUT Timeout waiting for reply message - ENOMEM Kernel memory allocation error - -X. Removing Software - - SYNOPSIS - - ioctl(fd, I2OSWDEL, struct i2o_sw_xfer *sw); - - struct i2o_sw_xfer - { - u32 iop; /* IOP unit number */ - u8 flags; /* RemoveFlags */ - u8 sw_type; /* Software type */ - u32 sw_id; /* Software ID */ - void *buf; /* Unused */ - u32 *swlen; /* Length of the software data */ - u32 *maxfrag; /* Unused */ - u32 *curfrag; /* Unused */ - }; - - DESCRIPTION - - This function removes software from the IOP identified by sw->iop. - The RemoveFlags, SwID, SwType and SwSize fields of the ExecSwRemove message - are filled in with the values of sw->flags, sw->sw_id, sw->sw_type and - *(sw->swlen). Give zero in *(sw->len) if the value is unknown. IOP uses - *(sw->swlen) value to verify correct identication of the module to remove. - The actual size of the module is written into *(sw->swlen). - - RETURNS - - This function returns 0 if no errors occur. If an error occurs, -1 - is returned and errno is set appropriately: - - EFAULT Invalid user space pointer was passed - ENXIO Invalid IOP number - ETIMEDOUT Timeout waiting for reply message - ENOMEM Kernel memory allocation error - -X. Validating Configuration - - SYNOPSIS - - ioctl(fd, I2OVALIDATE, int *iop); - u32 iop; - - DESCRIPTION - - This function posts an ExecConfigValidate message to the controller - identified by iop. This message indicates that the current - configuration is accepted. The iop changes the status of suspect drivers - to valid and may delete old drivers from its store. - - RETURNS - - This function returns 0 if no erro occur. If an error occurs, -1 is - returned and errno is set appropriately: - - ETIMEDOUT Timeout waiting for reply message - ENXIO Invalid IOP number - -XI. Configuration Dialog - - SYNOPSIS - - ioctl(fd, I2OHTML, struct i2o_html *htquery); - struct i2o_html - { - u32 iop; /* IOP unit number */ - u32 tid; /* Target device ID */ - u32 page; /* HTML page */ - void *resbuf; /* Buffer for reply HTML page */ - u32 *reslen; /* Length in bytes of reply buffer */ - void *qbuf; /* Pointer to HTTP query string */ - u32 qlen; /* Length in bytes of query string buffer */ - }; - - DESCRIPTION - - This function posts an UtilConfigDialog message to the device identified - by htquery->iop and htquery->tid. The requested HTML page number is - provided by the htquery->page field, and the resultant data is stored - in the buffer pointed to by htquery->resbuf. If there is an HTTP query - string that is to be sent to the device, it should be sent in the buffer - pointed to by htquery->qbuf. If there is no query string, this field - should be set to NULL. The actual size of the reply received is written - into *(htquery->reslen). - - RETURNS - - This function returns 0 if no error occur. If an error occurs, -1 - is returned and errno is set appropriately: - - EFAULT Invalid user space pointer was passed - ENXIO Invalid IOP number - ENOBUFS Buffer not large enough. If this occurs, the required - buffer length is written into *(ops->reslen) - ETIMEDOUT Timeout waiting for reply message - ENOMEM Kernel memory allocation error - -XII. Events - - In the process of determining this. Current idea is to have use - the select() interface to allow user apps to periodically poll - the /dev/i2o/ctl device for events. When select() notifies the user - that an event is available, the user would call read() to retrieve - a list of all the events that are pending for the specific device. - -============================================================================= -Revision History -============================================================================= - -Rev 0.1 - 04/01/99 -- Initial revision - -Rev 0.2 - 04/06/99 -- Changed return values to match UNIX ioctl() standard. Only return values - are 0 and -1. All errors are reported through errno. -- Added summary of proposed possible event interfaces - -Rev 0.3 - 04/20/99 -- Changed all ioctls() to use pointers to user data instead of actual data -- Updated error values to match the code diff --git a/drivers/staging/i2o/bus-osm.c b/drivers/staging/i2o/bus-osm.c deleted file mode 100644 index 43e357eeeb67..000000000000 --- a/drivers/staging/i2o/bus-osm.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Bus Adapter OSM - * - * Copyright (C) 2005 Markus Lidel - * - * 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. - * - * Fixes/additions: - * Markus Lidel - * initial version. - */ - -#include -#include "i2o.h" - -#define OSM_NAME "bus-osm" -#define OSM_VERSION "1.317" -#define OSM_DESCRIPTION "I2O Bus Adapter OSM" - -static struct i2o_driver i2o_bus_driver; - -/* Bus OSM class handling definition */ -static struct i2o_class_id i2o_bus_class_id[] = { - {I2O_CLASS_BUS_ADAPTER}, - {I2O_CLASS_END} -}; - -/** - * i2o_bus_scan - Scan the bus for new devices - * @dev: I2O device of the bus, which should be scanned - * - * Scans the bus dev for new / removed devices. After the scan a new LCT - * will be fetched automatically. - * - * Returns 0 on success or negative error code on failure. - */ -static int i2o_bus_scan(struct i2o_device *dev) -{ - struct i2o_message *msg; - - msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return -ETIMEDOUT; - - msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0); - msg->u.head[1] = - cpu_to_le32(I2O_CMD_BUS_SCAN << 24 | HOST_TID << 12 | dev->lct_data. - tid); - - return i2o_msg_post_wait(dev->iop, msg, 60); -}; - -/** - * i2o_bus_store_scan - Scan the I2O Bus Adapter - * @d: device which should be scanned - * @attr: device_attribute - * @buf: output buffer - * @count: buffer size - * - * Returns count. - */ -static ssize_t i2o_bus_store_scan(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct i2o_device *i2o_dev = to_i2o_device(d); - int rc; - - rc = i2o_bus_scan(i2o_dev); - if (rc) - osm_warn("bus scan failed %d\n", rc); - - return count; -} - -/* Bus Adapter OSM device attributes */ -static DEVICE_ATTR(scan, S_IWUSR, NULL, i2o_bus_store_scan); - -/** - * i2o_bus_probe - verify if dev is a I2O Bus Adapter device and install it - * @dev: device to verify if it is a I2O Bus Adapter device - * - * Because we want all Bus Adapters always return 0. - * Except when we fail. Then we are sad. - * - * Returns 0, except when we fail to excel. - */ -static int i2o_bus_probe(struct device *dev) -{ - struct i2o_device *i2o_dev = to_i2o_device(get_device(dev)); - int rc; - - rc = device_create_file(dev, &dev_attr_scan); - if (rc) - goto err_out; - - osm_info("device added (TID: %03x)\n", i2o_dev->lct_data.tid); - - return 0; - -err_out: - put_device(dev); - return rc; -}; - -/** - * i2o_bus_remove - remove the I2O Bus Adapter device from the system again - * @dev: I2O Bus Adapter device which should be removed - * - * Always returns 0. - */ -static int i2o_bus_remove(struct device *dev) -{ - struct i2o_device *i2o_dev = to_i2o_device(dev); - - device_remove_file(dev, &dev_attr_scan); - - put_device(dev); - - osm_info("device removed (TID: %03x)\n", i2o_dev->lct_data.tid); - - return 0; -}; - -/* Bus Adapter OSM driver struct */ -static struct i2o_driver i2o_bus_driver = { - .name = OSM_NAME, - .classes = i2o_bus_class_id, - .driver = { - .probe = i2o_bus_probe, - .remove = i2o_bus_remove, - }, -}; - -/** - * i2o_bus_init - Bus Adapter OSM initialization function - * - * Only register the Bus Adapter OSM in the I2O core. - * - * Returns 0 on success or negative error code on failure. - */ -static int __init i2o_bus_init(void) -{ - int rc; - - printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n"); - - /* Register Bus Adapter OSM into I2O core */ - rc = i2o_driver_register(&i2o_bus_driver); - if (rc) { - osm_err("Could not register Bus Adapter OSM\n"); - return rc; - } - - return 0; -}; - -/** - * i2o_bus_exit - Bus Adapter OSM exit function - * - * Unregisters Bus Adapter OSM from I2O core. - */ -static void __exit i2o_bus_exit(void) -{ - i2o_driver_unregister(&i2o_bus_driver); -}; - -MODULE_AUTHOR("Markus Lidel "); -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION(OSM_DESCRIPTION); -MODULE_VERSION(OSM_VERSION); - -module_init(i2o_bus_init); -module_exit(i2o_bus_exit); diff --git a/drivers/staging/i2o/config-osm.c b/drivers/staging/i2o/config-osm.c deleted file mode 100644 index 45091ac66154..000000000000 --- a/drivers/staging/i2o/config-osm.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Configuration OSM - * - * Copyright (C) 2005 Markus Lidel - * - * 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. - * - * Fixes/additions: - * Markus Lidel - * initial version. - */ - -#include -#include "i2o.h" -#include -#include -#include - -#include - -#define OSM_NAME "config-osm" -#define OSM_VERSION "1.323" -#define OSM_DESCRIPTION "I2O Configuration OSM" - -/* access mode user rw */ -#define S_IWRSR (S_IRUSR | S_IWUSR) - -static struct i2o_driver i2o_config_driver; - -/* Config OSM driver struct */ -static struct i2o_driver i2o_config_driver = { - .name = OSM_NAME, -}; - -#ifdef CONFIG_I2O_CONFIG_OLD_IOCTL -#include "i2o_config.c" -#endif - -/** - * i2o_config_init - Configuration OSM initialization function - * - * Registers Configuration OSM in the I2O core and if old ioctl's are - * compiled in initialize them. - * - * Returns 0 on success or negative error code on failure. - */ -static int __init i2o_config_init(void) -{ - printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n"); - - if (i2o_driver_register(&i2o_config_driver)) { - osm_err("handler register failed.\n"); - return -EBUSY; - } -#ifdef CONFIG_I2O_CONFIG_OLD_IOCTL - if (i2o_config_old_init()) { - osm_err("old config handler initialization failed\n"); - i2o_driver_unregister(&i2o_config_driver); - return -EBUSY; - } -#endif - - return 0; -} - -/** - * i2o_config_exit - Configuration OSM exit function - * - * If old ioctl's are compiled in exit remove them and unregisters - * Configuration OSM from I2O core. - */ -static void i2o_config_exit(void) -{ -#ifdef CONFIG_I2O_CONFIG_OLD_IOCTL - i2o_config_old_exit(); -#endif - - i2o_driver_unregister(&i2o_config_driver); -} - -MODULE_AUTHOR("Markus Lidel "); -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION(OSM_DESCRIPTION); -MODULE_VERSION(OSM_VERSION); - -module_init(i2o_config_init); -module_exit(i2o_config_exit); diff --git a/drivers/staging/i2o/core.h b/drivers/staging/i2o/core.h deleted file mode 100644 index 91614f11f89a..000000000000 --- a/drivers/staging/i2o/core.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * I2O core internal declarations - * - * Copyright (C) 2005 Markus Lidel - * - * 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. - * - * Fixes/additions: - * Markus Lidel - * initial version. - */ - -/* Exec-OSM */ -extern struct i2o_driver i2o_exec_driver; -extern int i2o_exec_lct_get(struct i2o_controller *); - -extern int __init i2o_exec_init(void); -extern void i2o_exec_exit(void); - -/* driver */ -extern struct bus_type i2o_bus_type; - -extern int i2o_driver_dispatch(struct i2o_controller *, u32); - -extern int __init i2o_driver_init(void); -extern void i2o_driver_exit(void); - -/* PCI */ -extern int __init i2o_pci_init(void); -extern void __exit i2o_pci_exit(void); - -/* device */ -extern const struct attribute_group *i2o_device_groups[]; - -extern void i2o_device_remove(struct i2o_device *); -extern int i2o_device_parse_lct(struct i2o_controller *); - -int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist, - int oplen, void *reslist, int reslen); - -/* IOP */ -extern struct i2o_controller *i2o_iop_alloc(void); - -/** - * i2o_iop_free - Free the i2o_controller struct - * @c: I2O controller to free - */ -static inline void i2o_iop_free(struct i2o_controller *c) -{ - i2o_pool_free(&c->in_msg); - kfree(c); -} - -extern int i2o_iop_add(struct i2o_controller *); -extern void i2o_iop_remove(struct i2o_controller *); - -/* control registers relative to c->base */ -#define I2O_IRQ_STATUS 0x30 -#define I2O_IRQ_MASK 0x34 -#define I2O_IN_PORT 0x40 -#define I2O_OUT_PORT 0x44 - -/* Motorola/Freescale specific register offset */ -#define I2O_MOTOROLA_PORT_OFFSET 0x10400 - -#define I2O_IRQ_OUTBOUND_POST 0x00000008 diff --git a/drivers/staging/i2o/debug.c b/drivers/staging/i2o/debug.c deleted file mode 100644 index 12b783b2a86c..000000000000 --- a/drivers/staging/i2o/debug.c +++ /dev/null @@ -1,473 +0,0 @@ -#include -#include -#include -#include "i2o.h" - -static void i2o_report_util_cmd(u8 cmd); -static void i2o_report_exec_cmd(u8 cmd); -static void i2o_report_fail_status(u8 req_status, u32 *msg); -static void i2o_report_common_status(u8 req_status); -static void i2o_report_common_dsc(u16 detailed_status); - -/* - * Used for error reporting/debugging purposes. - * Report Cmd name, Request status, Detailed Status. - */ -void i2o_report_status(const char *severity, const char *str, - struct i2o_message *m) -{ - u32 *msg = (u32 *) m; - u8 cmd = (msg[1] >> 24) & 0xFF; - u8 req_status = (msg[4] >> 24) & 0xFF; - u16 detailed_status = msg[4] & 0xFFFF; - - if (cmd == I2O_CMD_UTIL_EVT_REGISTER) - return; /* No status in this reply */ - - printk("%s%s: ", severity, str); - - if (cmd < 0x1F) // Utility cmd - i2o_report_util_cmd(cmd); - - else if (cmd >= 0xA0 && cmd <= 0xEF) // Executive cmd - i2o_report_exec_cmd(cmd); - else - printk("Cmd = %0#2x, ", cmd); // Other cmds - - if (msg[0] & MSG_FAIL) { - i2o_report_fail_status(req_status, msg); - return; - } - - i2o_report_common_status(req_status); - - if (cmd < 0x1F || (cmd >= 0xA0 && cmd <= 0xEF)) - i2o_report_common_dsc(detailed_status); - else - printk(" / DetailedStatus = %0#4x.\n", - detailed_status); -} - -/* Used to dump a message to syslog during debugging */ -void i2o_dump_message(struct i2o_message *m) -{ -#ifdef DEBUG - u32 *msg = (u32 *) m; - int i; - - printk(KERN_INFO "Dumping I2O message size %d @ %p\n", - msg[0] >> 16 & 0xffff, msg); - for (i = 0; i < ((msg[0] >> 16) & 0xffff); i++) - printk(KERN_INFO " msg[%d] = %0#10x\n", i, msg[i]); -#endif -} - -/* - * Used for error reporting/debugging purposes. - * Following fail status are common to all classes. - * The preserved message must be handled in the reply handler. - */ -static void i2o_report_fail_status(u8 req_status, u32 *msg) -{ - static char *FAIL_STATUS[] = { - "0x80", /* not used */ - "SERVICE_SUSPENDED", /* 0x81 */ - "SERVICE_TERMINATED", /* 0x82 */ - "CONGESTION", - "FAILURE", - "STATE_ERROR", - "TIME_OUT", - "ROUTING_FAILURE", - "INVALID_VERSION", - "INVALID_OFFSET", - "INVALID_MSG_FLAGS", - "FRAME_TOO_SMALL", - "FRAME_TOO_LARGE", - "INVALID_TARGET_ID", - "INVALID_INITIATOR_ID", - "INVALID_INITIATOR_CONTEX", /* 0x8F */ - "UNKNOWN_FAILURE" /* 0xFF */ - }; - - if (req_status == I2O_FSC_TRANSPORT_UNKNOWN_FAILURE) - printk("TRANSPORT_UNKNOWN_FAILURE (%0#2x).\n", - req_status); - else - printk("TRANSPORT_%s.\n", - FAIL_STATUS[req_status & 0x0F]); - - /* Dump some details */ - - printk(KERN_ERR " InitiatorId = %d, TargetId = %d\n", - (msg[1] >> 12) & 0xFFF, msg[1] & 0xFFF); - printk(KERN_ERR " LowestVersion = 0x%02X, HighestVersion = 0x%02X\n", - (msg[4] >> 8) & 0xFF, msg[4] & 0xFF); - printk(KERN_ERR " FailingHostUnit = 0x%04X, FailingIOP = 0x%03X\n", - msg[5] >> 16, msg[5] & 0xFFF); - - printk(KERN_ERR " Severity: 0x%02X\n", (msg[4] >> 16) & 0xFF); - if (msg[4] & (1 << 16)) - printk(KERN_DEBUG "(FormatError), " - "this msg can never be delivered/processed.\n"); - if (msg[4] & (1 << 17)) - printk(KERN_DEBUG "(PathError), " - "this msg can no longer be delivered/processed.\n"); - if (msg[4] & (1 << 18)) - printk(KERN_DEBUG "(PathState), " - "the system state does not allow delivery.\n"); - if (msg[4] & (1 << 19)) - printk(KERN_DEBUG - "(Congestion), resources temporarily not available;" - "do not retry immediately.\n"); -} - -/* - * Used for error reporting/debugging purposes. - * Following reply status are common to all classes. - */ -static void i2o_report_common_status(u8 req_status) -{ - static char *REPLY_STATUS[] = { - "SUCCESS", - "ABORT_DIRTY", - "ABORT_NO_DATA_TRANSFER", - "ABORT_PARTIAL_TRANSFER", - "ERROR_DIRTY", - "ERROR_NO_DATA_TRANSFER", - "ERROR_PARTIAL_TRANSFER", - "PROCESS_ABORT_DIRTY", - "PROCESS_ABORT_NO_DATA_TRANSFER", - "PROCESS_ABORT_PARTIAL_TRANSFER", - "TRANSACTION_ERROR", - "PROGRESS_REPORT" - }; - - if (req_status >= ARRAY_SIZE(REPLY_STATUS)) - printk("RequestStatus = %0#2x", req_status); - else - printk("%s", REPLY_STATUS[req_status]); -} - -/* - * Used for error reporting/debugging purposes. - * Following detailed status are valid for executive class, - * utility class, DDM class and for transaction error replies. - */ -static void i2o_report_common_dsc(u16 detailed_status) -{ - static char *COMMON_DSC[] = { - "SUCCESS", - "0x01", // not used - "BAD_KEY", - "TCL_ERROR", - "REPLY_BUFFER_FULL", - "NO_SUCH_PAGE", - "INSUFFICIENT_RESOURCE_SOFT", - "INSUFFICIENT_RESOURCE_HARD", - "0x08", // not used - "CHAIN_BUFFER_TOO_LARGE", - "UNSUPPORTED_FUNCTION", - "DEVICE_LOCKED", - "DEVICE_RESET", - "INAPPROPRIATE_FUNCTION", - "INVALID_INITIATOR_ADDRESS", - "INVALID_MESSAGE_FLAGS", - "INVALID_OFFSET", - "INVALID_PARAMETER", - "INVALID_REQUEST", - "INVALID_TARGET_ADDRESS", - "MESSAGE_TOO_LARGE", - "MESSAGE_TOO_SMALL", - "MISSING_PARAMETER", - "TIMEOUT", - "UNKNOWN_ERROR", - "UNKNOWN_FUNCTION", - "UNSUPPORTED_VERSION", - "DEVICE_BUSY", - "DEVICE_NOT_AVAILABLE" - }; - - if (detailed_status > I2O_DSC_DEVICE_NOT_AVAILABLE) - printk(" / DetailedStatus = %0#4x.\n", - detailed_status); - else - printk(" / %s.\n", COMMON_DSC[detailed_status]); -} - -/* - * Used for error reporting/debugging purposes - */ -static void i2o_report_util_cmd(u8 cmd) -{ - switch (cmd) { - case I2O_CMD_UTIL_NOP: - printk("UTIL_NOP, "); - break; - case I2O_CMD_UTIL_ABORT: - printk("UTIL_ABORT, "); - break; - case I2O_CMD_UTIL_CLAIM: - printk("UTIL_CLAIM, "); - break; - case I2O_CMD_UTIL_RELEASE: - printk("UTIL_CLAIM_RELEASE, "); - break; - case I2O_CMD_UTIL_CONFIG_DIALOG: - printk("UTIL_CONFIG_DIALOG, "); - break; - case I2O_CMD_UTIL_DEVICE_RESERVE: - printk("UTIL_DEVICE_RESERVE, "); - break; - case I2O_CMD_UTIL_DEVICE_RELEASE: - printk("UTIL_DEVICE_RELEASE, "); - break; - case I2O_CMD_UTIL_EVT_ACK: - printk("UTIL_EVENT_ACKNOWLEDGE, "); - break; - case I2O_CMD_UTIL_EVT_REGISTER: - printk("UTIL_EVENT_REGISTER, "); - break; - case I2O_CMD_UTIL_LOCK: - printk("UTIL_LOCK, "); - break; - case I2O_CMD_UTIL_LOCK_RELEASE: - printk("UTIL_LOCK_RELEASE, "); - break; - case I2O_CMD_UTIL_PARAMS_GET: - printk("UTIL_PARAMS_GET, "); - break; - case I2O_CMD_UTIL_PARAMS_SET: - printk("UTIL_PARAMS_SET, "); - break; - case I2O_CMD_UTIL_REPLY_FAULT_NOTIFY: - printk("UTIL_REPLY_FAULT_NOTIFY, "); - break; - default: - printk("Cmd = %0#2x, ", cmd); - } -} - -/* - * Used for error reporting/debugging purposes - */ -static void i2o_report_exec_cmd(u8 cmd) -{ - switch (cmd) { - case I2O_CMD_ADAPTER_ASSIGN: - printk("EXEC_ADAPTER_ASSIGN, "); - break; - case I2O_CMD_ADAPTER_READ: - printk("EXEC_ADAPTER_READ, "); - break; - case I2O_CMD_ADAPTER_RELEASE: - printk("EXEC_ADAPTER_RELEASE, "); - break; - case I2O_CMD_BIOS_INFO_SET: - printk("EXEC_BIOS_INFO_SET, "); - break; - case I2O_CMD_BOOT_DEVICE_SET: - printk("EXEC_BOOT_DEVICE_SET, "); - break; - case I2O_CMD_CONFIG_VALIDATE: - printk("EXEC_CONFIG_VALIDATE, "); - break; - case I2O_CMD_CONN_SETUP: - printk("EXEC_CONN_SETUP, "); - break; - case I2O_CMD_DDM_DESTROY: - printk("EXEC_DDM_DESTROY, "); - break; - case I2O_CMD_DDM_ENABLE: - printk("EXEC_DDM_ENABLE, "); - break; - case I2O_CMD_DDM_QUIESCE: - printk("EXEC_DDM_QUIESCE, "); - break; - case I2O_CMD_DDM_RESET: - printk("EXEC_DDM_RESET, "); - break; - case I2O_CMD_DDM_SUSPEND: - printk("EXEC_DDM_SUSPEND, "); - break; - case I2O_CMD_DEVICE_ASSIGN: - printk("EXEC_DEVICE_ASSIGN, "); - break; - case I2O_CMD_DEVICE_RELEASE: - printk("EXEC_DEVICE_RELEASE, "); - break; - case I2O_CMD_HRT_GET: - printk("EXEC_HRT_GET, "); - break; - case I2O_CMD_ADAPTER_CLEAR: - printk("EXEC_IOP_CLEAR, "); - break; - case I2O_CMD_ADAPTER_CONNECT: - printk("EXEC_IOP_CONNECT, "); - break; - case I2O_CMD_ADAPTER_RESET: - printk("EXEC_IOP_RESET, "); - break; - case I2O_CMD_LCT_NOTIFY: - printk("EXEC_LCT_NOTIFY, "); - break; - case I2O_CMD_OUTBOUND_INIT: - printk("EXEC_OUTBOUND_INIT, "); - break; - case I2O_CMD_PATH_ENABLE: - printk("EXEC_PATH_ENABLE, "); - break; - case I2O_CMD_PATH_QUIESCE: - printk("EXEC_PATH_QUIESCE, "); - break; - case I2O_CMD_PATH_RESET: - printk("EXEC_PATH_RESET, "); - break; - case I2O_CMD_STATIC_MF_CREATE: - printk("EXEC_STATIC_MF_CREATE, "); - break; - case I2O_CMD_STATIC_MF_RELEASE: - printk("EXEC_STATIC_MF_RELEASE, "); - break; - case I2O_CMD_STATUS_GET: - printk("EXEC_STATUS_GET, "); - break; - case I2O_CMD_SW_DOWNLOAD: - printk("EXEC_SW_DOWNLOAD, "); - break; - case I2O_CMD_SW_UPLOAD: - printk("EXEC_SW_UPLOAD, "); - break; - case I2O_CMD_SW_REMOVE: - printk("EXEC_SW_REMOVE, "); - break; - case I2O_CMD_SYS_ENABLE: - printk("EXEC_SYS_ENABLE, "); - break; - case I2O_CMD_SYS_MODIFY: - printk("EXEC_SYS_MODIFY, "); - break; - case I2O_CMD_SYS_QUIESCE: - printk("EXEC_SYS_QUIESCE, "); - break; - case I2O_CMD_SYS_TAB_SET: - printk("EXEC_SYS_TAB_SET, "); - break; - default: - printk("Cmd = %#02x, ", cmd); - } -} - -void i2o_debug_state(struct i2o_controller *c) -{ - printk(KERN_INFO "%s: State = ", c->name); - switch (((i2o_status_block *) c->status_block.virt)->iop_state) { - case 0x01: - printk("INIT\n"); - break; - case 0x02: - printk("RESET\n"); - break; - case 0x04: - printk("HOLD\n"); - break; - case 0x05: - printk("READY\n"); - break; - case 0x08: - printk("OPERATIONAL\n"); - break; - case 0x10: - printk("FAILED\n"); - break; - case 0x11: - printk("FAULTED\n"); - break; - default: - printk("%x (unknown !!)\n", - ((i2o_status_block *) c->status_block.virt)->iop_state); - } -}; - -void i2o_dump_hrt(struct i2o_controller *c) -{ - u32 *rows = (u32 *) c->hrt.virt; - u8 *p = (u8 *) c->hrt.virt; - u8 *d; - int count; - int length; - int i; - int state; - - if (p[3] != 0) { - printk(KERN_ERR - "%s: HRT table for controller is too new a version.\n", - c->name); - return; - } - - count = p[0] | (p[1] << 8); - length = p[2]; - - printk(KERN_INFO "%s: HRT has %d entries of %d bytes each.\n", - c->name, count, length << 2); - - rows += 2; - - for (i = 0; i < count; i++) { - printk(KERN_INFO "Adapter %08X: ", rows[0]); - p = (u8 *) (rows + 1); - d = (u8 *) (rows + 2); - state = p[1] << 8 | p[0]; - - printk("TID %04X:[", state & 0xFFF); - state >>= 12; - if (state & (1 << 0)) - printk("H"); /* Hidden */ - if (state & (1 << 2)) { - printk("P"); /* Present */ - if (state & (1 << 1)) - printk("C"); /* Controlled */ - } - if (state > 9) - printk("*"); /* Hard */ - - printk("]:"); - - switch (p[3] & 0xFFFF) { - case 0: - /* Adapter private bus - easy */ - printk("Local bus %d: I/O at 0x%04X Mem 0x%08X", p[2], - d[1] << 8 | d[0], *(u32 *) (d + 4)); - break; - case 1: - /* ISA bus */ - printk("ISA %d: CSN %d I/O at 0x%04X Mem 0x%08X", p[2], - d[2], d[1] << 8 | d[0], *(u32 *) (d + 4)); - break; - - case 2: /* EISA bus */ - printk("EISA %d: Slot %d I/O at 0x%04X Mem 0x%08X", - p[2], d[3], d[1] << 8 | d[0], *(u32 *) (d + 4)); - break; - - case 3: /* MCA bus */ - printk("MCA %d: Slot %d I/O at 0x%04X Mem 0x%08X", p[2], - d[3], d[1] << 8 | d[0], *(u32 *) (d + 4)); - break; - - case 4: /* PCI bus */ - printk("PCI %d: Bus %d Device %d Function %d", p[2], - d[2], d[1], d[0]); - break; - - case 0x80: /* Other */ - default: - printk("Unsupported bus type."); - break; - } - printk("\n"); - rows += length; - } -} - -EXPORT_SYMBOL(i2o_dump_message); diff --git a/drivers/staging/i2o/device.c b/drivers/staging/i2o/device.c deleted file mode 100644 index e47496cb0ac2..000000000000 --- a/drivers/staging/i2o/device.c +++ /dev/null @@ -1,592 +0,0 @@ -/* - * Functions to handle I2O devices - * - * Copyright (C) 2004 Markus Lidel - * - * 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. - * - * Fixes/additions: - * Markus Lidel - * initial version. - */ - -#include -#include "i2o.h" -#include -#include -#include -#include "core.h" - -/** - * i2o_device_issue_claim - claim or release a device - * @dev: I2O device to claim or release - * @cmd: claim or release command - * @type: type of claim - * - * Issue I2O UTIL_CLAIM or UTIL_RELEASE messages. The message to be sent - * is set by cmd. dev is the I2O device which should be claim or - * released and the type is the claim type (see the I2O spec). - * - * Returs 0 on success or negative error code on failure. - */ -static inline int i2o_device_issue_claim(struct i2o_device *dev, u32 cmd, - u32 type) -{ - struct i2o_message *msg; - - msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0); - msg->u.head[1] = - cpu_to_le32(cmd << 24 | HOST_TID << 12 | dev->lct_data.tid); - msg->body[0] = cpu_to_le32(type); - - return i2o_msg_post_wait(dev->iop, msg, 60); -} - -/** - * i2o_device_claim - claim a device for use by an OSM - * @dev: I2O device to claim - * - * Do the leg work to assign a device to a given OSM. If the claim succeeds, - * the owner is the primary. If the attempt fails a negative errno code - * is returned. On success zero is returned. - */ -int i2o_device_claim(struct i2o_device *dev) -{ - int rc = 0; - - mutex_lock(&dev->lock); - - rc = i2o_device_issue_claim(dev, I2O_CMD_UTIL_CLAIM, I2O_CLAIM_PRIMARY); - if (!rc) - pr_debug("i2o: claim of device %d succeeded\n", - dev->lct_data.tid); - else - pr_debug("i2o: claim of device %d failed %d\n", - dev->lct_data.tid, rc); - - mutex_unlock(&dev->lock); - - return rc; -} - -/** - * i2o_device_claim_release - release a device that the OSM is using - * @dev: device to release - * - * Drop a claim by an OSM on a given I2O device. - * - * AC - some devices seem to want to refuse an unclaim until they have - * finished internal processing. It makes sense since you don't want a - * new device to go reconfiguring the entire system until you are done. - * Thus we are prepared to wait briefly. - * - * Returns 0 on success or negative error code on failure. - */ -int i2o_device_claim_release(struct i2o_device *dev) -{ - int tries; - int rc = 0; - - mutex_lock(&dev->lock); - - /* - * If the controller takes a nonblocking approach to - * releases we have to sleep/poll for a few times. - */ - for (tries = 0; tries < 10; tries++) { - rc = i2o_device_issue_claim(dev, I2O_CMD_UTIL_RELEASE, - I2O_CLAIM_PRIMARY); - if (!rc) - break; - - ssleep(1); - } - - if (!rc) - pr_debug("i2o: claim release of device %d succeeded\n", - dev->lct_data.tid); - else - pr_debug("i2o: claim release of device %d failed %d\n", - dev->lct_data.tid, rc); - - mutex_unlock(&dev->lock); - - return rc; -} - -/** - * i2o_device_release - release the memory for a I2O device - * @dev: I2O device which should be released - * - * Release the allocated memory. This function is called if refcount of - * device reaches 0 automatically. - */ -static void i2o_device_release(struct device *dev) -{ - struct i2o_device *i2o_dev = to_i2o_device(dev); - - pr_debug("i2o: device %s released\n", dev_name(dev)); - - kfree(i2o_dev); -} - -/** - * class_id_show - Displays class id of I2O device - * @dev: device of which the class id should be displayed - * @attr: pointer to device attribute - * @buf: buffer into which the class id should be printed - * - * Returns the number of bytes which are printed into the buffer. - */ -static ssize_t class_id_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct i2o_device *i2o_dev = to_i2o_device(dev); - - sprintf(buf, "0x%03x\n", i2o_dev->lct_data.class_id); - return strlen(buf) + 1; -} -static DEVICE_ATTR_RO(class_id); - -/** - * tid_show - Displays TID of I2O device - * @dev: device of which the TID should be displayed - * @attr: pointer to device attribute - * @buf: buffer into which the TID should be printed - * - * Returns the number of bytes which are printed into the buffer. - */ -static ssize_t tid_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct i2o_device *i2o_dev = to_i2o_device(dev); - - sprintf(buf, "0x%03x\n", i2o_dev->lct_data.tid); - return strlen(buf) + 1; -} -static DEVICE_ATTR_RO(tid); - -/* I2O device attributes */ -static struct attribute *i2o_device_attrs[] = { - &dev_attr_class_id.attr, - &dev_attr_tid.attr, - NULL, -}; - -static const struct attribute_group i2o_device_group = { - .attrs = i2o_device_attrs, -}; - -const struct attribute_group *i2o_device_groups[] = { - &i2o_device_group, - NULL, -}; - -/** - * i2o_device_alloc - Allocate a I2O device and initialize it - * - * Allocate the memory for a I2O device and initialize locks and lists - * - * Returns the allocated I2O device or a negative error code if the device - * could not be allocated. - */ -static struct i2o_device *i2o_device_alloc(void) -{ - struct i2o_device *dev; - - dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (!dev) - return ERR_PTR(-ENOMEM); - - INIT_LIST_HEAD(&dev->list); - mutex_init(&dev->lock); - - dev->device.bus = &i2o_bus_type; - dev->device.release = &i2o_device_release; - - return dev; -} - -/** - * i2o_device_add - allocate a new I2O device and add it to the IOP - * @c: I2O controller that the device is on - * @entry: LCT entry of the I2O device - * - * Allocate a new I2O device and initialize it with the LCT entry. The - * device is appended to the device list of the controller. - * - * Returns zero on success, or a -ve errno. - */ -static int i2o_device_add(struct i2o_controller *c, i2o_lct_entry *entry) -{ - struct i2o_device *i2o_dev, *tmp; - int rc; - - i2o_dev = i2o_device_alloc(); - if (IS_ERR(i2o_dev)) { - printk(KERN_ERR "i2o: unable to allocate i2o device\n"); - return PTR_ERR(i2o_dev); - } - - i2o_dev->lct_data = *entry; - - dev_set_name(&i2o_dev->device, "%d:%03x", c->unit, - i2o_dev->lct_data.tid); - - i2o_dev->iop = c; - i2o_dev->device.parent = &c->device; - - rc = device_register(&i2o_dev->device); - if (rc) - goto err; - - list_add_tail(&i2o_dev->list, &c->devices); - - /* create user entries for this device */ - tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.user_tid); - if (tmp && (tmp != i2o_dev)) { - rc = sysfs_create_link(&i2o_dev->device.kobj, - &tmp->device.kobj, "user"); - if (rc) - goto unreg_dev; - } - - /* create user entries referring to this device */ - list_for_each_entry(tmp, &c->devices, list) - if ((tmp->lct_data.user_tid == i2o_dev->lct_data.tid) - && (tmp != i2o_dev)) { - rc = sysfs_create_link(&tmp->device.kobj, - &i2o_dev->device.kobj, "user"); - if (rc) - goto rmlink1; - } - - /* create parent entries for this device */ - tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid); - if (tmp && (tmp != i2o_dev)) { - rc = sysfs_create_link(&i2o_dev->device.kobj, - &tmp->device.kobj, "parent"); - if (rc) - goto rmlink1; - } - - /* create parent entries referring to this device */ - list_for_each_entry(tmp, &c->devices, list) - if ((tmp->lct_data.parent_tid == i2o_dev->lct_data.tid) - && (tmp != i2o_dev)) { - rc = sysfs_create_link(&tmp->device.kobj, - &i2o_dev->device.kobj, "parent"); - if (rc) - goto rmlink2; - } - - i2o_driver_notify_device_add_all(i2o_dev); - - pr_debug("i2o: device %s added\n", dev_name(&i2o_dev->device)); - - return 0; - -rmlink2: - /* If link creating failed halfway, we loop whole list to cleanup. - * And we don't care wrong removing of link, because sysfs_remove_link - * will take care of it. - */ - list_for_each_entry(tmp, &c->devices, list) { - if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid) - sysfs_remove_link(&tmp->device.kobj, "parent"); - } - sysfs_remove_link(&i2o_dev->device.kobj, "parent"); -rmlink1: - list_for_each_entry(tmp, &c->devices, list) - if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid) - sysfs_remove_link(&tmp->device.kobj, "user"); - sysfs_remove_link(&i2o_dev->device.kobj, "user"); -unreg_dev: - list_del(&i2o_dev->list); - device_unregister(&i2o_dev->device); -err: - kfree(i2o_dev); - return rc; -} - -/** - * i2o_device_remove - remove an I2O device from the I2O core - * @i2o_dev: I2O device which should be released - * - * Is used on I2O controller removal or LCT modification, when the device - * is removed from the system. Note that the device could still hang - * around until the refcount reaches 0. - */ -void i2o_device_remove(struct i2o_device *i2o_dev) -{ - struct i2o_device *tmp; - struct i2o_controller *c = i2o_dev->iop; - - i2o_driver_notify_device_remove_all(i2o_dev); - - sysfs_remove_link(&i2o_dev->device.kobj, "parent"); - sysfs_remove_link(&i2o_dev->device.kobj, "user"); - - list_for_each_entry(tmp, &c->devices, list) { - if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid) - sysfs_remove_link(&tmp->device.kobj, "parent"); - if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid) - sysfs_remove_link(&tmp->device.kobj, "user"); - } - list_del(&i2o_dev->list); - - device_unregister(&i2o_dev->device); -} - -/** - * i2o_device_parse_lct - Parse a previously fetched LCT and create devices - * @c: I2O controller from which the LCT should be parsed. - * - * The Logical Configuration Table tells us what we can talk to on the - * board. For every entry we create an I2O device, which is registered in - * the I2O core. - * - * Returns 0 on success or negative error code on failure. - */ -int i2o_device_parse_lct(struct i2o_controller *c) -{ - struct i2o_device *dev, *tmp; - i2o_lct *lct; - u32 *dlct = c->dlct.virt; - int max = 0, i = 0; - u16 table_size; - u32 buf; - - mutex_lock(&c->lct_lock); - - kfree(c->lct); - - buf = le32_to_cpu(*dlct++); - table_size = buf & 0xffff; - - lct = c->lct = kmalloc(table_size * 4, GFP_KERNEL); - if (!lct) { - mutex_unlock(&c->lct_lock); - return -ENOMEM; - } - - lct->lct_ver = buf >> 28; - lct->boot_tid = buf >> 16 & 0xfff; - lct->table_size = table_size; - lct->change_ind = le32_to_cpu(*dlct++); - lct->iop_flags = le32_to_cpu(*dlct++); - - table_size -= 3; - - pr_debug("%s: LCT has %d entries (LCT size: %d)\n", c->name, max, - lct->table_size); - - while (table_size > 0) { - i2o_lct_entry *entry = &lct->lct_entry[max]; - int found = 0; - - buf = le32_to_cpu(*dlct++); - entry->entry_size = buf & 0xffff; - entry->tid = buf >> 16 & 0xfff; - - entry->change_ind = le32_to_cpu(*dlct++); - entry->device_flags = le32_to_cpu(*dlct++); - - buf = le32_to_cpu(*dlct++); - entry->class_id = buf & 0xfff; - entry->version = buf >> 12 & 0xf; - entry->vendor_id = buf >> 16; - - entry->sub_class = le32_to_cpu(*dlct++); - - buf = le32_to_cpu(*dlct++); - entry->user_tid = buf & 0xfff; - entry->parent_tid = buf >> 12 & 0xfff; - entry->bios_info = buf >> 24; - - memcpy(&entry->identity_tag, dlct, 8); - dlct += 2; - - entry->event_capabilities = le32_to_cpu(*dlct++); - - /* add new devices, which are new in the LCT */ - list_for_each_entry_safe(dev, tmp, &c->devices, list) { - if (entry->tid == dev->lct_data.tid) { - found = 1; - break; - } - } - - if (!found) - i2o_device_add(c, entry); - - table_size -= 9; - max++; - } - - /* remove devices, which are not in the LCT anymore */ - list_for_each_entry_safe(dev, tmp, &c->devices, list) { - int found = 0; - - for (i = 0; i < max; i++) { - if (lct->lct_entry[i].tid == dev->lct_data.tid) { - found = 1; - break; - } - } - - if (!found) - i2o_device_remove(dev); - } - - mutex_unlock(&c->lct_lock); - - return 0; -} - -/* - * Run time support routines - */ - -/* Issue UTIL_PARAMS_GET or UTIL_PARAMS_SET - * - * This function can be used for all UtilParamsGet/Set operations. - * The OperationList is given in oplist-buffer, - * and results are returned in reslist-buffer. - * Note that the minimum sized reslist is 8 bytes and contains - * ResultCount, ErrorInfoSize, BlockStatus and BlockSize. - */ -int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist, - int oplen, void *reslist, int reslen) -{ - struct i2o_message *msg; - int i = 0; - int rc; - struct i2o_dma res; - struct i2o_controller *c = i2o_dev->iop; - struct device *dev = &c->pdev->dev; - - res.virt = NULL; - - if (i2o_dma_alloc(dev, &res, reslen)) - return -ENOMEM; - - msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) { - i2o_dma_free(dev, &res); - return PTR_ERR(msg); - } - - i = 0; - msg->u.head[1] = - cpu_to_le32(cmd << 24 | HOST_TID << 12 | i2o_dev->lct_data.tid); - msg->body[i++] = cpu_to_le32(0x00000000); - msg->body[i++] = cpu_to_le32(0x4C000000 | oplen); /* OperationList */ - memcpy(&msg->body[i], oplist, oplen); - i += (oplen / 4 + (oplen % 4 ? 1 : 0)); - msg->body[i++] = cpu_to_le32(0xD0000000 | res.len); /* ResultList */ - msg->body[i++] = cpu_to_le32(res.phys); - - msg->u.head[0] = - cpu_to_le32(I2O_MESSAGE_SIZE(i + sizeof(struct i2o_message) / 4) | - SGL_OFFSET_5); - - rc = i2o_msg_post_wait_mem(c, msg, 10, &res); - - /* This only looks like a memory leak - don't "fix" it. */ - if (rc == -ETIMEDOUT) - return rc; - - memcpy(reslist, res.virt, res.len); - i2o_dma_free(dev, &res); - - return rc; -} - -/* - * Query one field group value or a whole scalar group. - */ -int i2o_parm_field_get(struct i2o_device *i2o_dev, int group, int field, - void *buf, int buflen) -{ - u32 opblk[] = { cpu_to_le32(0x00000001), - cpu_to_le32((u16) group << 16 | I2O_PARAMS_FIELD_GET), - cpu_to_le32((s16) field << 16 | 0x00000001) - }; - u8 *resblk; /* 8 bytes for header */ - int rc; - - resblk = kmalloc(buflen + 8, GFP_KERNEL); - if (!resblk) - return -ENOMEM; - - rc = i2o_parm_issue(i2o_dev, I2O_CMD_UTIL_PARAMS_GET, opblk, - sizeof(opblk), resblk, buflen + 8); - - memcpy(buf, resblk + 8, buflen); /* cut off header */ - - kfree(resblk); - - return rc; -} - -/* - * if oper == I2O_PARAMS_TABLE_GET, get from all rows - * if fieldcount == -1 return all fields - * ibuf and ibuflen are unused (use NULL, 0) - * else return specific fields - * ibuf contains fieldindexes - * - * if oper == I2O_PARAMS_LIST_GET, get from specific rows - * if fieldcount == -1 return all fields - * ibuf contains rowcount, keyvalues - * else return specific fields - * fieldcount is # of fieldindexes - * ibuf contains fieldindexes, rowcount, keyvalues - * - * You could also use directly function i2o_issue_params(). - */ -int i2o_parm_table_get(struct i2o_device *dev, int oper, int group, - int fieldcount, void *ibuf, int ibuflen, void *resblk, - int reslen) -{ - u16 *opblk; - int size; - - size = 10 + ibuflen; - if (size % 4) - size += 4 - size % 4; - - opblk = kmalloc(size, GFP_KERNEL); - if (opblk == NULL) - return -ENOMEM; - - opblk[0] = 1; /* operation count */ - opblk[1] = 0; /* pad */ - opblk[2] = oper; - opblk[3] = group; - opblk[4] = fieldcount; - memcpy(opblk + 5, ibuf, ibuflen); /* other params */ - - size = i2o_parm_issue(dev, I2O_CMD_UTIL_PARAMS_GET, opblk, - size, resblk, reslen); - - kfree(opblk); - if (size > reslen) - return reslen; - - return size; -} - -EXPORT_SYMBOL(i2o_device_claim); -EXPORT_SYMBOL(i2o_device_claim_release); -EXPORT_SYMBOL(i2o_parm_field_get); -EXPORT_SYMBOL(i2o_parm_table_get); -EXPORT_SYMBOL(i2o_parm_issue); diff --git a/drivers/staging/i2o/driver.c b/drivers/staging/i2o/driver.c deleted file mode 100644 index 06119bb3eb5f..000000000000 --- a/drivers/staging/i2o/driver.c +++ /dev/null @@ -1,381 +0,0 @@ -/* - * Functions to handle I2O drivers (OSMs) and I2O bus type for sysfs - * - * Copyright (C) 2004 Markus Lidel - * - * 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. - * - * Fixes/additions: - * Markus Lidel - * initial version. - */ - -#include -#include -#include -#include "i2o.h" -#include -#include -#include -#include "core.h" - -#define OSM_NAME "i2o" - -/* max_drivers - Maximum I2O drivers (OSMs) which could be registered */ -static unsigned int i2o_max_drivers = I2O_MAX_DRIVERS; -module_param_named(max_drivers, i2o_max_drivers, uint, 0); -MODULE_PARM_DESC(max_drivers, "maximum number of OSM's to support"); - -/* I2O drivers lock and array */ -static spinlock_t i2o_drivers_lock; -static struct i2o_driver **i2o_drivers; - -/** - * i2o_bus_match - Tell if I2O device class id matches the class ids of the I2O driver (OSM) - * @dev: device which should be verified - * @drv: the driver to match against - * - * Used by the bus to check if the driver wants to handle the device. - * - * Returns 1 if the class ids of the driver match the class id of the - * device, otherwise 0. - */ -static int i2o_bus_match(struct device *dev, struct device_driver *drv) -{ - struct i2o_device *i2o_dev = to_i2o_device(dev); - struct i2o_driver *i2o_drv = to_i2o_driver(drv); - struct i2o_class_id *ids = i2o_drv->classes; - - if (ids) - while (ids->class_id != I2O_CLASS_END) { - if (ids->class_id == i2o_dev->lct_data.class_id) - return 1; - ids++; - } - return 0; -}; - -/* I2O bus type */ -struct bus_type i2o_bus_type = { - .name = "i2o", - .match = i2o_bus_match, - .dev_groups = i2o_device_groups, -}; - -/** - * i2o_driver_register - Register a I2O driver (OSM) in the I2O core - * @drv: I2O driver which should be registered - * - * Registers the OSM drv in the I2O core and creates an event queues if - * necessary. - * - * Returns 0 on success or negative error code on failure. - */ -int i2o_driver_register(struct i2o_driver *drv) -{ - struct i2o_controller *c; - int i; - int rc = 0; - unsigned long flags; - - osm_debug("Register driver %s\n", drv->name); - - if (drv->event) { - drv->event_queue = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, - drv->name); - if (!drv->event_queue) { - osm_err("Could not initialize event queue for driver " - "%s\n", drv->name); - return -EFAULT; - } - osm_debug("Event queue initialized for driver %s\n", drv->name); - } else - drv->event_queue = NULL; - - drv->driver.name = drv->name; - drv->driver.bus = &i2o_bus_type; - - spin_lock_irqsave(&i2o_drivers_lock, flags); - - for (i = 0; i2o_drivers[i]; i++) - if (i >= i2o_max_drivers) { - osm_err("too many drivers registered, increase max_drivers\n"); - spin_unlock_irqrestore(&i2o_drivers_lock, flags); - rc = -EFAULT; - goto out; - } - - drv->context = i; - i2o_drivers[i] = drv; - - spin_unlock_irqrestore(&i2o_drivers_lock, flags); - - osm_debug("driver %s gets context id %d\n", drv->name, drv->context); - - list_for_each_entry(c, &i2o_controllers, list) { - struct i2o_device *i2o_dev; - - i2o_driver_notify_controller_add(drv, c); - list_for_each_entry(i2o_dev, &c->devices, list) - i2o_driver_notify_device_add(drv, i2o_dev); - } - - rc = driver_register(&drv->driver); - if (rc) - goto out; - - return 0; -out: - if (drv->event_queue) { - destroy_workqueue(drv->event_queue); - drv->event_queue = NULL; - } - - return rc; -}; - -/** - * i2o_driver_unregister - Unregister a I2O driver (OSM) from the I2O core - * @drv: I2O driver which should be unregistered - * - * Unregisters the OSM drv from the I2O core and cleanup event queues if - * necessary. - */ -void i2o_driver_unregister(struct i2o_driver *drv) -{ - struct i2o_controller *c; - unsigned long flags; - - osm_debug("unregister driver %s\n", drv->name); - - driver_unregister(&drv->driver); - - list_for_each_entry(c, &i2o_controllers, list) { - struct i2o_device *i2o_dev; - - list_for_each_entry(i2o_dev, &c->devices, list) - i2o_driver_notify_device_remove(drv, i2o_dev); - - i2o_driver_notify_controller_remove(drv, c); - } - - spin_lock_irqsave(&i2o_drivers_lock, flags); - i2o_drivers[drv->context] = NULL; - spin_unlock_irqrestore(&i2o_drivers_lock, flags); - - if (drv->event_queue) { - destroy_workqueue(drv->event_queue); - drv->event_queue = NULL; - osm_debug("event queue removed for %s\n", drv->name); - } -}; - -/** - * i2o_driver_dispatch - dispatch an I2O reply message - * @c: I2O controller of the message - * @m: I2O message number - * - * The reply is delivered to the driver from which the original message - * was. This function is only called from interrupt context. - * - * Returns 0 on success and the message should not be flushed. Returns > 0 - * on success and if the message should be flushed afterwords. Returns - * negative error code on failure (the message will be flushed too). - */ -int i2o_driver_dispatch(struct i2o_controller *c, u32 m) -{ - struct i2o_driver *drv; - struct i2o_message *msg = i2o_msg_out_to_virt(c, m); - u32 context = le32_to_cpu(msg->u.s.icntxt); - unsigned long flags; - - if (unlikely(context >= i2o_max_drivers)) { - osm_warn("%s: Spurious reply to unknown driver %d\n", c->name, - context); - return -EIO; - } - - spin_lock_irqsave(&i2o_drivers_lock, flags); - drv = i2o_drivers[context]; - spin_unlock_irqrestore(&i2o_drivers_lock, flags); - - if (unlikely(!drv)) { - osm_warn("%s: Spurious reply to unknown driver %d\n", c->name, - context); - return -EIO; - } - - if ((le32_to_cpu(msg->u.head[1]) >> 24) == I2O_CMD_UTIL_EVT_REGISTER) { - struct i2o_device *dev, *tmp; - struct i2o_event *evt; - u16 size; - u16 tid = le32_to_cpu(msg->u.head[1]) & 0xfff; - - osm_debug("event received from device %d\n", tid); - - if (!drv->event) - return -EIO; - - /* cut of header from message size (in 32-bit words) */ - size = (le32_to_cpu(msg->u.head[0]) >> 16) - 5; - - evt = kzalloc(size * 4 + sizeof(*evt), GFP_ATOMIC); - if (!evt) - return -ENOMEM; - - evt->size = size; - evt->tcntxt = le32_to_cpu(msg->u.s.tcntxt); - evt->event_indicator = le32_to_cpu(msg->body[0]); - memcpy(&evt->data, &msg->body[1], size * 4); - - list_for_each_entry_safe(dev, tmp, &c->devices, list) - if (dev->lct_data.tid == tid) { - evt->i2o_dev = dev; - break; - } - - INIT_WORK(&evt->work, drv->event); - queue_work(drv->event_queue, &evt->work); - return 1; - } - - if (unlikely(!drv->reply)) { - osm_debug("%s: Reply to driver %s, but no reply function defined!\n", - c->name, drv->name); - return -EIO; - } - - return drv->reply(c, m, msg); -} - -/** - * i2o_driver_notify_controller_add_all - Send notify of added controller - * @c: newly added controller - * - * Send notifications to all registered drivers that a new controller was - * added. - */ -void i2o_driver_notify_controller_add_all(struct i2o_controller *c) -{ - int i; - struct i2o_driver *drv; - - for (i = 0; i < i2o_max_drivers; i++) { - drv = i2o_drivers[i]; - - if (drv) - i2o_driver_notify_controller_add(drv, c); - } -} - -/** - * i2o_driver_notify_controller_remove_all - Send notify of removed controller - * @c: controller that is being removed - * - * Send notifications to all registered drivers that a controller was - * removed. - */ -void i2o_driver_notify_controller_remove_all(struct i2o_controller *c) -{ - int i; - struct i2o_driver *drv; - - for (i = 0; i < i2o_max_drivers; i++) { - drv = i2o_drivers[i]; - - if (drv) - i2o_driver_notify_controller_remove(drv, c); - } -} - -/** - * i2o_driver_notify_device_add_all - Send notify of added device - * @i2o_dev: newly added I2O device - * - * Send notifications to all registered drivers that a device was added. - */ -void i2o_driver_notify_device_add_all(struct i2o_device *i2o_dev) -{ - int i; - struct i2o_driver *drv; - - for (i = 0; i < i2o_max_drivers; i++) { - drv = i2o_drivers[i]; - - if (drv) - i2o_driver_notify_device_add(drv, i2o_dev); - } -} - -/** - * i2o_driver_notify_device_remove_all - Send notify of removed device - * @i2o_dev: device that is being removed - * - * Send notifications to all registered drivers that a device was removed. - */ -void i2o_driver_notify_device_remove_all(struct i2o_device *i2o_dev) -{ - int i; - struct i2o_driver *drv; - - for (i = 0; i < i2o_max_drivers; i++) { - drv = i2o_drivers[i]; - - if (drv) - i2o_driver_notify_device_remove(drv, i2o_dev); - } -} - -/** - * i2o_driver_init - initialize I2O drivers (OSMs) - * - * Registers the I2O bus and allocate memory for the array of OSMs. - * - * Returns 0 on success or negative error code on failure. - */ -int __init i2o_driver_init(void) -{ - int rc = 0; - - spin_lock_init(&i2o_drivers_lock); - - if ((i2o_max_drivers < 2) || (i2o_max_drivers > 64)) { - osm_warn("max_drivers set to %d, but must be >=2 and <= 64\n", - i2o_max_drivers); - i2o_max_drivers = I2O_MAX_DRIVERS; - } - osm_info("max drivers = %d\n", i2o_max_drivers); - - i2o_drivers = - kcalloc(i2o_max_drivers, sizeof(*i2o_drivers), GFP_KERNEL); - if (!i2o_drivers) - return -ENOMEM; - - rc = bus_register(&i2o_bus_type); - - if (rc < 0) - kfree(i2o_drivers); - - return rc; -}; - -/** - * i2o_driver_exit - clean up I2O drivers (OSMs) - * - * Unregisters the I2O bus and frees driver array. - */ -void i2o_driver_exit(void) -{ - bus_unregister(&i2o_bus_type); - kfree(i2o_drivers); -}; - -EXPORT_SYMBOL(i2o_driver_register); -EXPORT_SYMBOL(i2o_driver_unregister); -EXPORT_SYMBOL(i2o_driver_notify_controller_add_all); -EXPORT_SYMBOL(i2o_driver_notify_controller_remove_all); -EXPORT_SYMBOL(i2o_driver_notify_device_add_all); -EXPORT_SYMBOL(i2o_driver_notify_device_remove_all); diff --git a/drivers/staging/i2o/exec-osm.c b/drivers/staging/i2o/exec-osm.c deleted file mode 100644 index dce16e425a6e..000000000000 --- a/drivers/staging/i2o/exec-osm.c +++ /dev/null @@ -1,612 +0,0 @@ -/* - * Executive OSM - * - * Copyright (C) 1999-2002 Red Hat Software - * - * Written by Alan Cox, Building Number Three Ltd - * - * 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. - * - * A lot of the I2O message side code from this is taken from the Red - * Creek RCPCI45 adapter driver by Red Creek Communications - * - * Fixes/additions: - * Philipp Rumpf - * Juha Sievänen - * Auvo Häkkinen - * Deepak Saxena - * Boji T Kannanthanam - * Alan Cox : - * Ported to Linux 2.5. - * Markus Lidel : - * Minor fixes for 2.6. - * Markus Lidel : - * Support for sysfs included. - */ - -#include -#include "i2o.h" -#include -#include -#include -#include -#include /* wait_event_interruptible_timeout() needs this */ -#include /* HZ */ -#include "core.h" - -#define OSM_NAME "exec-osm" - -struct i2o_driver i2o_exec_driver; - -/* global wait list for POST WAIT */ -static LIST_HEAD(i2o_exec_wait_list); - -/* Wait struct needed for POST WAIT */ -struct i2o_exec_wait { - wait_queue_head_t *wq; /* Pointer to Wait queue */ - struct i2o_dma dma; /* DMA buffers to free on failure */ - u32 tcntxt; /* transaction context from reply */ - int complete; /* 1 if reply received otherwise 0 */ - u32 m; /* message id */ - struct i2o_message *msg; /* pointer to the reply message */ - struct list_head list; /* node in global wait list */ - spinlock_t lock; /* lock before modifying */ -}; - -/* Work struct needed to handle LCT NOTIFY replies */ -struct i2o_exec_lct_notify_work { - struct work_struct work; /* work struct */ - struct i2o_controller *c; /* controller on which the LCT NOTIFY - was received */ -}; - -/* Exec OSM class handling definition */ -static struct i2o_class_id i2o_exec_class_id[] = { - {I2O_CLASS_EXECUTIVE}, - {I2O_CLASS_END} -}; - -/** - * i2o_exec_wait_alloc - Allocate a i2o_exec_wait struct an initialize it - * - * Allocate the i2o_exec_wait struct and initialize the wait. - * - * Returns i2o_exec_wait pointer on success or negative error code on - * failure. - */ -static struct i2o_exec_wait *i2o_exec_wait_alloc(void) -{ - struct i2o_exec_wait *wait; - - wait = kzalloc(sizeof(*wait), GFP_KERNEL); - if (!wait) - return NULL; - - INIT_LIST_HEAD(&wait->list); - spin_lock_init(&wait->lock); - - return wait; -}; - -/** - * i2o_exec_wait_free - Free an i2o_exec_wait struct - * @wait: I2O wait data which should be cleaned up - */ -static void i2o_exec_wait_free(struct i2o_exec_wait *wait) -{ - kfree(wait); -}; - -/** - * i2o_msg_post_wait_mem - Post and wait a message with DMA buffers - * @c: controller - * @msg: message to post - * @timeout: time in seconds to wait - * @dma: i2o_dma struct of the DMA buffer to free on failure - * - * This API allows an OSM to post a message and then be told whether or - * not the system received a successful reply. If the message times out - * then the value '-ETIMEDOUT' is returned. This is a special case. In - * this situation the message may (should) complete at an indefinite time - * in the future. When it completes it will use the memory buffer - * attached to the request. If -ETIMEDOUT is returned then the memory - * buffer must not be freed. Instead the event completion will free them - * for you. In all other cases the buffer are your problem. - * - * Returns 0 on success, negative error code on timeout or positive error - * code from reply. - */ -int i2o_msg_post_wait_mem(struct i2o_controller *c, struct i2o_message *msg, - unsigned long timeout, struct i2o_dma *dma) -{ - DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); - struct i2o_exec_wait *wait; - static u32 tcntxt = 0x80000000; - unsigned long flags; - int rc = 0; - - wait = i2o_exec_wait_alloc(); - if (!wait) { - i2o_msg_nop(c, msg); - return -ENOMEM; - } - - if (tcntxt == 0xffffffff) - tcntxt = 0x80000000; - - if (dma) - wait->dma = *dma; - - /* - * Fill in the message initiator context and transaction context. - * We will only use transaction contexts >= 0x80000000 for POST WAIT, - * so we could find a POST WAIT reply easier in the reply handler. - */ - msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context); - wait->tcntxt = tcntxt++; - msg->u.s.tcntxt = cpu_to_le32(wait->tcntxt); - - wait->wq = &wq; - /* - * we add elements to the head, because if a entry in the list will - * never be removed, we have to iterate over it every time - */ - list_add(&wait->list, &i2o_exec_wait_list); - - /* - * Post the message to the controller. At some point later it will - * return. If we time out before it returns then complete will be zero. - */ - i2o_msg_post(c, msg); - - wait_event_interruptible_timeout(wq, wait->complete, timeout * HZ); - - spin_lock_irqsave(&wait->lock, flags); - - wait->wq = NULL; - - if (wait->complete) - rc = le32_to_cpu(wait->msg->body[0]) >> 24; - else { - /* - * We cannot remove it now. This is important. When it does - * terminate (which it must do if the controller has not - * died...) then it will otherwise scribble on stuff. - * - * FIXME: try abort message - */ - if (dma) - dma->virt = NULL; - - rc = -ETIMEDOUT; - } - - spin_unlock_irqrestore(&wait->lock, flags); - - if (rc != -ETIMEDOUT) { - i2o_flush_reply(c, wait->m); - i2o_exec_wait_free(wait); - } - - return rc; -}; - -/** - * i2o_msg_post_wait_complete - Reply to a i2o_msg_post request from IOP - * @c: I2O controller which answers - * @m: message id - * @msg: pointer to the I2O reply message - * @context: transaction context of request - * - * This function is called in interrupt context only. If the reply reached - * before the timeout, the i2o_exec_wait struct is filled with the message - * and the task will be waked up. The task is now responsible for returning - * the message m back to the controller! If the message reaches us after - * the timeout clean up the i2o_exec_wait struct (including allocated - * DMA buffer). - * - * Return 0 on success and if the message m should not be given back to the - * I2O controller, or >0 on success and if the message should be given back - * afterwords. Returns negative error code on failure. In this case the - * message must also be given back to the controller. - */ -static int i2o_msg_post_wait_complete(struct i2o_controller *c, u32 m, - struct i2o_message *msg, u32 context) -{ - struct i2o_exec_wait *wait, *tmp; - unsigned long flags; - int rc = 1; - - /* - * We need to search through the i2o_exec_wait_list to see if the given - * message is still outstanding. If not, it means that the IOP took - * longer to respond to the message than we had allowed and timer has - * already expired. Not much we can do about that except log it for - * debug purposes, increase timeout, and recompile. - */ - list_for_each_entry_safe(wait, tmp, &i2o_exec_wait_list, list) { - if (wait->tcntxt == context) { - spin_lock_irqsave(&wait->lock, flags); - - list_del(&wait->list); - - wait->m = m; - wait->msg = msg; - wait->complete = 1; - - if (wait->wq) - rc = 0; - else - rc = -1; - - spin_unlock_irqrestore(&wait->lock, flags); - - if (rc) { - struct device *dev; - - dev = &c->pdev->dev; - - pr_debug("%s: timedout reply received!\n", - c->name); - i2o_dma_free(dev, &wait->dma); - i2o_exec_wait_free(wait); - } else - wake_up_interruptible(wait->wq); - - return rc; - } - } - - osm_warn("%s: Bogus reply in POST WAIT (tr-context: %08x)!\n", c->name, - context); - - return -1; -}; - -/** - * i2o_exec_show_vendor_id - Displays Vendor ID of controller - * @d: device of which the Vendor ID should be displayed - * @attr: device_attribute to display - * @buf: buffer into which the Vendor ID should be printed - * - * Returns number of bytes printed into buffer. - */ -static ssize_t i2o_exec_show_vendor_id(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct i2o_device *dev = to_i2o_device(d); - u16 id; - - if (!i2o_parm_field_get(dev, 0x0000, 0, &id, 2)) { - sprintf(buf, "0x%04x", le16_to_cpu(id)); - return strlen(buf) + 1; - } - - return 0; -}; - -/** - * i2o_exec_show_product_id - Displays Product ID of controller - * @d: device of which the Product ID should be displayed - * @attr: device_attribute to display - * @buf: buffer into which the Product ID should be printed - * - * Returns number of bytes printed into buffer. - */ -static ssize_t i2o_exec_show_product_id(struct device *d, - struct device_attribute *attr, - char *buf) -{ - struct i2o_device *dev = to_i2o_device(d); - u16 id; - - if (!i2o_parm_field_get(dev, 0x0000, 1, &id, 2)) { - sprintf(buf, "0x%04x", le16_to_cpu(id)); - return strlen(buf) + 1; - } - - return 0; -}; - -/* Exec-OSM device attributes */ -static DEVICE_ATTR(vendor_id, S_IRUGO, i2o_exec_show_vendor_id, NULL); -static DEVICE_ATTR(product_id, S_IRUGO, i2o_exec_show_product_id, NULL); - -/** - * i2o_exec_probe - Called if a new I2O device (executive class) appears - * @dev: I2O device which should be probed - * - * Registers event notification for every event from Executive device. The - * return is always 0, because we want all devices of class Executive. - * - * Returns 0 on success. - */ -static int i2o_exec_probe(struct device *dev) -{ - struct i2o_device *i2o_dev = to_i2o_device(dev); - int rc; - - rc = i2o_event_register(i2o_dev, &i2o_exec_driver, 0, 0xffffffff); - if (rc) goto err_out; - - rc = device_create_file(dev, &dev_attr_vendor_id); - if (rc) goto err_evtreg; - rc = device_create_file(dev, &dev_attr_product_id); - if (rc) goto err_vid; - - i2o_dev->iop->exec = i2o_dev; - - return 0; - -err_vid: - device_remove_file(dev, &dev_attr_vendor_id); -err_evtreg: - i2o_event_register(to_i2o_device(dev), &i2o_exec_driver, 0, 0); -err_out: - return rc; -}; - -/** - * i2o_exec_remove - Called on I2O device removal - * @dev: I2O device which was removed - * - * Unregisters event notification from Executive I2O device. - * - * Returns 0 on success. - */ -static int i2o_exec_remove(struct device *dev) -{ - device_remove_file(dev, &dev_attr_product_id); - device_remove_file(dev, &dev_attr_vendor_id); - - i2o_event_register(to_i2o_device(dev), &i2o_exec_driver, 0, 0); - - return 0; -}; - -#ifdef CONFIG_I2O_LCT_NOTIFY_ON_CHANGES -/** - * i2o_exec_lct_notify - Send a asynchronus LCT NOTIFY request - * @c: I2O controller to which the request should be send - * @change_ind: change indicator - * - * This function sends a LCT NOTIFY request to the I2O controller with - * the change indicator change_ind. If the change_ind == 0 the controller - * replies immediately after the request. If change_ind > 0 the reply is - * send after change indicator of the LCT is > change_ind. - */ -static int i2o_exec_lct_notify(struct i2o_controller *c, u32 change_ind) -{ - i2o_status_block *sb = c->status_block.virt; - struct device *dev; - struct i2o_message *msg; - - mutex_lock(&c->lct_lock); - - dev = &c->pdev->dev; - - if (i2o_dma_realloc(dev, &c->dlct, - le32_to_cpu(sb->expected_lct_size))) { - mutex_unlock(&c->lct_lock); - return -ENOMEM; - } - - msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) { - mutex_unlock(&c->lct_lock); - return PTR_ERR(msg); - } - - msg->u.head[0] = cpu_to_le32(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6); - msg->u.head[1] = cpu_to_le32(I2O_CMD_LCT_NOTIFY << 24 | HOST_TID << 12 | - ADAPTER_TID); - msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context); - msg->u.s.tcntxt = cpu_to_le32(0x00000000); - msg->body[0] = cpu_to_le32(0xffffffff); - msg->body[1] = cpu_to_le32(change_ind); - msg->body[2] = cpu_to_le32(0xd0000000 | c->dlct.len); - msg->body[3] = cpu_to_le32(c->dlct.phys); - - i2o_msg_post(c, msg); - - mutex_unlock(&c->lct_lock); - - return 0; -} -#endif - -/** - * i2o_exec_lct_modified - Called on LCT NOTIFY reply - * @_work: work struct for a specific controller - * - * This function handles asynchronus LCT NOTIFY replies. It parses the - * new LCT and if the buffer for the LCT was to small sends a LCT NOTIFY - * again, otherwise send LCT NOTIFY to get informed on next LCT change. - */ -static void i2o_exec_lct_modified(struct work_struct *_work) -{ - struct i2o_exec_lct_notify_work *work = - container_of(_work, struct i2o_exec_lct_notify_work, work); - u32 change_ind = 0; - struct i2o_controller *c = work->c; - - kfree(work); - - if (i2o_device_parse_lct(c) != -EAGAIN) - change_ind = c->lct->change_ind + 1; - -#ifdef CONFIG_I2O_LCT_NOTIFY_ON_CHANGES - i2o_exec_lct_notify(c, change_ind); -#endif -}; - -/** - * i2o_exec_reply - I2O Executive reply handler - * @c: I2O controller from which the reply comes - * @m: message id - * @msg: pointer to the I2O reply message - * - * This function is always called from interrupt context. If a POST WAIT - * reply was received, pass it to the complete function. If a LCT NOTIFY - * reply was received, a new event is created to handle the update. - * - * Returns 0 on success and if the reply should not be flushed or > 0 - * on success and if the reply should be flushed. Returns negative error - * code on failure and if the reply should be flushed. - */ -static int i2o_exec_reply(struct i2o_controller *c, u32 m, - struct i2o_message *msg) -{ - u32 context; - - if (le32_to_cpu(msg->u.head[0]) & MSG_FAIL) { - struct i2o_message __iomem *pmsg; - u32 pm; - - /* - * If Fail bit is set we must take the transaction context of - * the preserved message to find the right request again. - */ - - pm = le32_to_cpu(msg->body[3]); - pmsg = i2o_msg_in_to_virt(c, pm); - context = readl(&pmsg->u.s.tcntxt); - - i2o_report_status(KERN_INFO, "i2o_core", msg); - - /* Release the preserved msg */ - i2o_msg_nop_mfa(c, pm); - } else - context = le32_to_cpu(msg->u.s.tcntxt); - - if (context & 0x80000000) - return i2o_msg_post_wait_complete(c, m, msg, context); - - if ((le32_to_cpu(msg->u.head[1]) >> 24) == I2O_CMD_LCT_NOTIFY) { - struct i2o_exec_lct_notify_work *work; - - pr_debug("%s: LCT notify received\n", c->name); - - work = kmalloc(sizeof(*work), GFP_ATOMIC); - if (!work) - return -ENOMEM; - - work->c = c; - - INIT_WORK(&work->work, i2o_exec_lct_modified); - queue_work(i2o_exec_driver.event_queue, &work->work); - return 1; - } - - /* - * If this happens, we want to dump the message to the syslog so - * it can be sent back to the card manufacturer by the end user - * to aid in debugging. - * - */ - printk(KERN_WARNING "%s: Unsolicited message reply sent to core! Message dumped to syslog\n", - c->name); - i2o_dump_message(msg); - - return -EFAULT; -} - -/** - * i2o_exec_event - Event handling function - * @work: Work item in occurring event - * - * Handles events send by the Executive device. At the moment does not do - * anything useful. - */ -static void i2o_exec_event(struct work_struct *work) -{ - struct i2o_event *evt = container_of(work, struct i2o_event, work); - - if (likely(evt->i2o_dev)) - osm_debug("Event received from device: %d\n", - evt->i2o_dev->lct_data.tid); - kfree(evt); -}; - -/** - * i2o_exec_lct_get - Get the IOP's Logical Configuration Table - * @c: I2O controller from which the LCT should be fetched - * - * Send a LCT NOTIFY request to the controller, and wait - * I2O_TIMEOUT_LCT_GET seconds until arrival of response. If the LCT is - * to large, retry it. - * - * Returns 0 on success or negative error code on failure. - */ -int i2o_exec_lct_get(struct i2o_controller *c) -{ - struct i2o_message *msg; - int i = 0; - int rc = -EAGAIN; - - for (i = 1; i <= I2O_LCT_GET_TRIES; i++) { - msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->u.head[0] = - cpu_to_le32(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6); - msg->u.head[1] = - cpu_to_le32(I2O_CMD_LCT_NOTIFY << 24 | HOST_TID << 12 | - ADAPTER_TID); - msg->body[0] = cpu_to_le32(0xffffffff); - msg->body[1] = cpu_to_le32(0x00000000); - msg->body[2] = cpu_to_le32(0xd0000000 | c->dlct.len); - msg->body[3] = cpu_to_le32(c->dlct.phys); - - rc = i2o_msg_post_wait(c, msg, I2O_TIMEOUT_LCT_GET); - if (rc < 0) - break; - - rc = i2o_device_parse_lct(c); - if (rc != -EAGAIN) - break; - } - - return rc; -} - -/* Exec OSM driver struct */ -struct i2o_driver i2o_exec_driver = { - .name = OSM_NAME, - .reply = i2o_exec_reply, - .event = i2o_exec_event, - .classes = i2o_exec_class_id, - .driver = { - .probe = i2o_exec_probe, - .remove = i2o_exec_remove, - }, -}; - -/** - * i2o_exec_init - Registers the Exec OSM - * - * Registers the Exec OSM in the I2O core. - * - * Returns 0 on success or negative error code on failure. - */ -int __init i2o_exec_init(void) -{ - return i2o_driver_register(&i2o_exec_driver); -}; - -/** - * i2o_exec_exit - Removes the Exec OSM - * - * Unregisters the Exec OSM from the I2O core. - */ -void i2o_exec_exit(void) -{ - i2o_driver_unregister(&i2o_exec_driver); -}; - -EXPORT_SYMBOL(i2o_msg_post_wait_mem); -EXPORT_SYMBOL(i2o_exec_lct_get); diff --git a/drivers/staging/i2o/i2o.h b/drivers/staging/i2o/i2o.h deleted file mode 100644 index d23c3c20b201..000000000000 --- a/drivers/staging/i2o/i2o.h +++ /dev/null @@ -1,988 +0,0 @@ -/* - * I2O kernel space accessible structures/APIs - * - * (c) Copyright 1999, 2000 Red Hat Software - * - * 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 header file defined the I2O APIs/structures for use by - * the I2O kernel modules. - * - */ - -#ifndef _I2O_H -#define _I2O_H - -#include - -/* How many different OSM's are we allowing */ -#define I2O_MAX_DRIVERS 8 - -#include -#include -#include -#include -#include -#include /* work_struct */ -#include -#include -#include -#include /* Needed for MUTEX init macros */ - -#include - -/* message queue empty */ -#define I2O_QUEUE_EMPTY 0xffffffff - -/* - * Cache strategies - */ - -/* The NULL strategy leaves everything up to the controller. This tends to be a - * pessimal but functional choice. - */ -#define CACHE_NULL 0 -/* Prefetch data when reading. We continually attempt to load the next 32 sectors - * into the controller cache. - */ -#define CACHE_PREFETCH 1 -/* Prefetch data when reading. We sometimes attempt to load the next 32 sectors - * into the controller cache. When an I/O is less <= 8K we assume its probably - * not sequential and don't prefetch (default) - */ -#define CACHE_SMARTFETCH 2 -/* Data is written to the cache and then out on to the disk. The I/O must be - * physically on the medium before the write is acknowledged (default without - * NVRAM) - */ -#define CACHE_WRITETHROUGH 17 -/* Data is written to the cache and then out on to the disk. The controller - * is permitted to write back the cache any way it wants. (default if battery - * backed NVRAM is present). It can be useful to set this for swap regardless of - * battery state. - */ -#define CACHE_WRITEBACK 18 -/* Optimise for under powered controllers, especially on RAID1 and RAID0. We - * write large I/O's directly to disk bypassing the cache to avoid the extra - * memory copy hits. Small writes are writeback cached - */ -#define CACHE_SMARTBACK 19 -/* Optimise for under powered controllers, especially on RAID1 and RAID0. We - * write large I/O's directly to disk bypassing the cache to avoid the extra - * memory copy hits. Small writes are writethrough cached. Suitable for devices - * lacking battery backup - */ -#define CACHE_SMARTTHROUGH 20 - -/* - * Ioctl structures - */ - -#define BLKI2OGRSTRAT _IOR('2', 1, int) -#define BLKI2OGWSTRAT _IOR('2', 2, int) -#define BLKI2OSRSTRAT _IOW('2', 3, int) -#define BLKI2OSWSTRAT _IOW('2', 4, int) - -/* - * I2O Function codes - */ - -/* - * Executive Class - */ -#define I2O_CMD_ADAPTER_ASSIGN 0xB3 -#define I2O_CMD_ADAPTER_READ 0xB2 -#define I2O_CMD_ADAPTER_RELEASE 0xB5 -#define I2O_CMD_BIOS_INFO_SET 0xA5 -#define I2O_CMD_BOOT_DEVICE_SET 0xA7 -#define I2O_CMD_CONFIG_VALIDATE 0xBB -#define I2O_CMD_CONN_SETUP 0xCA -#define I2O_CMD_DDM_DESTROY 0xB1 -#define I2O_CMD_DDM_ENABLE 0xD5 -#define I2O_CMD_DDM_QUIESCE 0xC7 -#define I2O_CMD_DDM_RESET 0xD9 -#define I2O_CMD_DDM_SUSPEND 0xAF -#define I2O_CMD_DEVICE_ASSIGN 0xB7 -#define I2O_CMD_DEVICE_RELEASE 0xB9 -#define I2O_CMD_HRT_GET 0xA8 -#define I2O_CMD_ADAPTER_CLEAR 0xBE -#define I2O_CMD_ADAPTER_CONNECT 0xC9 -#define I2O_CMD_ADAPTER_RESET 0xBD -#define I2O_CMD_LCT_NOTIFY 0xA2 -#define I2O_CMD_OUTBOUND_INIT 0xA1 -#define I2O_CMD_PATH_ENABLE 0xD3 -#define I2O_CMD_PATH_QUIESCE 0xC5 -#define I2O_CMD_PATH_RESET 0xD7 -#define I2O_CMD_STATIC_MF_CREATE 0xDD -#define I2O_CMD_STATIC_MF_RELEASE 0xDF -#define I2O_CMD_STATUS_GET 0xA0 -#define I2O_CMD_SW_DOWNLOAD 0xA9 -#define I2O_CMD_SW_UPLOAD 0xAB -#define I2O_CMD_SW_REMOVE 0xAD -#define I2O_CMD_SYS_ENABLE 0xD1 -#define I2O_CMD_SYS_MODIFY 0xC1 -#define I2O_CMD_SYS_QUIESCE 0xC3 -#define I2O_CMD_SYS_TAB_SET 0xA3 - -/* - * Utility Class - */ -#define I2O_CMD_UTIL_NOP 0x00 -#define I2O_CMD_UTIL_ABORT 0x01 -#define I2O_CMD_UTIL_CLAIM 0x09 -#define I2O_CMD_UTIL_RELEASE 0x0B -#define I2O_CMD_UTIL_PARAMS_GET 0x06 -#define I2O_CMD_UTIL_PARAMS_SET 0x05 -#define I2O_CMD_UTIL_EVT_REGISTER 0x13 -#define I2O_CMD_UTIL_EVT_ACK 0x14 -#define I2O_CMD_UTIL_CONFIG_DIALOG 0x10 -#define I2O_CMD_UTIL_DEVICE_RESERVE 0x0D -#define I2O_CMD_UTIL_DEVICE_RELEASE 0x0F -#define I2O_CMD_UTIL_LOCK 0x17 -#define I2O_CMD_UTIL_LOCK_RELEASE 0x19 -#define I2O_CMD_UTIL_REPLY_FAULT_NOTIFY 0x15 - -/* - * SCSI Host Bus Adapter Class - */ -#define I2O_CMD_SCSI_EXEC 0x81 -#define I2O_CMD_SCSI_ABORT 0x83 -#define I2O_CMD_SCSI_BUSRESET 0x27 - -/* - * Bus Adapter Class - */ -#define I2O_CMD_BUS_ADAPTER_RESET 0x85 -#define I2O_CMD_BUS_RESET 0x87 -#define I2O_CMD_BUS_SCAN 0x89 -#define I2O_CMD_BUS_QUIESCE 0x8b - -/* - * Random Block Storage Class - */ -#define I2O_CMD_BLOCK_READ 0x30 -#define I2O_CMD_BLOCK_WRITE 0x31 -#define I2O_CMD_BLOCK_CFLUSH 0x37 -#define I2O_CMD_BLOCK_MLOCK 0x49 -#define I2O_CMD_BLOCK_MUNLOCK 0x4B -#define I2O_CMD_BLOCK_MMOUNT 0x41 -#define I2O_CMD_BLOCK_MEJECT 0x43 -#define I2O_CMD_BLOCK_POWER 0x70 - -#define I2O_CMD_PRIVATE 0xFF - -/* Command status values */ - -#define I2O_CMD_IN_PROGRESS 0x01 -#define I2O_CMD_REJECTED 0x02 -#define I2O_CMD_FAILED 0x03 -#define I2O_CMD_COMPLETED 0x04 - -/* I2O API function return values */ - -#define I2O_RTN_NO_ERROR 0 -#define I2O_RTN_NOT_INIT 1 -#define I2O_RTN_FREE_Q_EMPTY 2 -#define I2O_RTN_TCB_ERROR 3 -#define I2O_RTN_TRANSACTION_ERROR 4 -#define I2O_RTN_ADAPTER_ALREADY_INIT 5 -#define I2O_RTN_MALLOC_ERROR 6 -#define I2O_RTN_ADPTR_NOT_REGISTERED 7 -#define I2O_RTN_MSG_REPLY_TIMEOUT 8 -#define I2O_RTN_NO_STATUS 9 -#define I2O_RTN_NO_FIRM_VER 10 -#define I2O_RTN_NO_LINK_SPEED 11 - -/* Reply message status defines for all messages */ - -#define I2O_REPLY_STATUS_SUCCESS 0x00 -#define I2O_REPLY_STATUS_ABORT_DIRTY 0x01 -#define I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER 0x02 -#define I2O_REPLY_STATUS_ABORT_PARTIAL_TRANSFER 0x03 -#define I2O_REPLY_STATUS_ERROR_DIRTY 0x04 -#define I2O_REPLY_STATUS_ERROR_NO_DATA_TRANSFER 0x05 -#define I2O_REPLY_STATUS_ERROR_PARTIAL_TRANSFER 0x06 -#define I2O_REPLY_STATUS_PROCESS_ABORT_DIRTY 0x08 -#define I2O_REPLY_STATUS_PROCESS_ABORT_NO_DATA_TRANSFER 0x09 -#define I2O_REPLY_STATUS_PROCESS_ABORT_PARTIAL_TRANSFER 0x0A -#define I2O_REPLY_STATUS_TRANSACTION_ERROR 0x0B -#define I2O_REPLY_STATUS_PROGRESS_REPORT 0x80 - -/* Status codes and Error Information for Parameter functions */ - -#define I2O_PARAMS_STATUS_SUCCESS 0x00 -#define I2O_PARAMS_STATUS_BAD_KEY_ABORT 0x01 -#define I2O_PARAMS_STATUS_BAD_KEY_CONTINUE 0x02 -#define I2O_PARAMS_STATUS_BUFFER_FULL 0x03 -#define I2O_PARAMS_STATUS_BUFFER_TOO_SMALL 0x04 -#define I2O_PARAMS_STATUS_FIELD_UNREADABLE 0x05 -#define I2O_PARAMS_STATUS_FIELD_UNWRITEABLE 0x06 -#define I2O_PARAMS_STATUS_INSUFFICIENT_FIELDS 0x07 -#define I2O_PARAMS_STATUS_INVALID_GROUP_ID 0x08 -#define I2O_PARAMS_STATUS_INVALID_OPERATION 0x09 -#define I2O_PARAMS_STATUS_NO_KEY_FIELD 0x0A -#define I2O_PARAMS_STATUS_NO_SUCH_FIELD 0x0B -#define I2O_PARAMS_STATUS_NON_DYNAMIC_GROUP 0x0C -#define I2O_PARAMS_STATUS_OPERATION_ERROR 0x0D -#define I2O_PARAMS_STATUS_SCALAR_ERROR 0x0E -#define I2O_PARAMS_STATUS_TABLE_ERROR 0x0F -#define I2O_PARAMS_STATUS_WRONG_GROUP_TYPE 0x10 - -/* DetailedStatusCode defines for Executive, DDM, Util and Transaction error - * messages: Table 3-2 Detailed Status Codes.*/ - -#define I2O_DSC_SUCCESS 0x0000 -#define I2O_DSC_BAD_KEY 0x0002 -#define I2O_DSC_TCL_ERROR 0x0003 -#define I2O_DSC_REPLY_BUFFER_FULL 0x0004 -#define I2O_DSC_NO_SUCH_PAGE 0x0005 -#define I2O_DSC_INSUFFICIENT_RESOURCE_SOFT 0x0006 -#define I2O_DSC_INSUFFICIENT_RESOURCE_HARD 0x0007 -#define I2O_DSC_CHAIN_BUFFER_TOO_LARGE 0x0009 -#define I2O_DSC_UNSUPPORTED_FUNCTION 0x000A -#define I2O_DSC_DEVICE_LOCKED 0x000B -#define I2O_DSC_DEVICE_RESET 0x000C -#define I2O_DSC_INAPPROPRIATE_FUNCTION 0x000D -#define I2O_DSC_INVALID_INITIATOR_ADDRESS 0x000E -#define I2O_DSC_INVALID_MESSAGE_FLAGS 0x000F -#define I2O_DSC_INVALID_OFFSET 0x0010 -#define I2O_DSC_INVALID_PARAMETER 0x0011 -#define I2O_DSC_INVALID_REQUEST 0x0012 -#define I2O_DSC_INVALID_TARGET_ADDRESS 0x0013 -#define I2O_DSC_MESSAGE_TOO_LARGE 0x0014 -#define I2O_DSC_MESSAGE_TOO_SMALL 0x0015 -#define I2O_DSC_MISSING_PARAMETER 0x0016 -#define I2O_DSC_TIMEOUT 0x0017 -#define I2O_DSC_UNKNOWN_ERROR 0x0018 -#define I2O_DSC_UNKNOWN_FUNCTION 0x0019 -#define I2O_DSC_UNSUPPORTED_VERSION 0x001A -#define I2O_DSC_DEVICE_BUSY 0x001B -#define I2O_DSC_DEVICE_NOT_AVAILABLE 0x001C - -/* DetailedStatusCode defines for Block Storage Operation: Table 6-7 Detailed - Status Codes.*/ - -#define I2O_BSA_DSC_SUCCESS 0x0000 -#define I2O_BSA_DSC_MEDIA_ERROR 0x0001 -#define I2O_BSA_DSC_ACCESS_ERROR 0x0002 -#define I2O_BSA_DSC_DEVICE_FAILURE 0x0003 -#define I2O_BSA_DSC_DEVICE_NOT_READY 0x0004 -#define I2O_BSA_DSC_MEDIA_NOT_PRESENT 0x0005 -#define I2O_BSA_DSC_MEDIA_LOCKED 0x0006 -#define I2O_BSA_DSC_MEDIA_FAILURE 0x0007 -#define I2O_BSA_DSC_PROTOCOL_FAILURE 0x0008 -#define I2O_BSA_DSC_BUS_FAILURE 0x0009 -#define I2O_BSA_DSC_ACCESS_VIOLATION 0x000A -#define I2O_BSA_DSC_WRITE_PROTECTED 0x000B -#define I2O_BSA_DSC_DEVICE_RESET 0x000C -#define I2O_BSA_DSC_VOLUME_CHANGED 0x000D -#define I2O_BSA_DSC_TIMEOUT 0x000E - -/* FailureStatusCodes, Table 3-3 Message Failure Codes */ - -#define I2O_FSC_TRANSPORT_SERVICE_SUSPENDED 0x81 -#define I2O_FSC_TRANSPORT_SERVICE_TERMINATED 0x82 -#define I2O_FSC_TRANSPORT_CONGESTION 0x83 -#define I2O_FSC_TRANSPORT_FAILURE 0x84 -#define I2O_FSC_TRANSPORT_STATE_ERROR 0x85 -#define I2O_FSC_TRANSPORT_TIME_OUT 0x86 -#define I2O_FSC_TRANSPORT_ROUTING_FAILURE 0x87 -#define I2O_FSC_TRANSPORT_INVALID_VERSION 0x88 -#define I2O_FSC_TRANSPORT_INVALID_OFFSET 0x89 -#define I2O_FSC_TRANSPORT_INVALID_MSG_FLAGS 0x8A -#define I2O_FSC_TRANSPORT_FRAME_TOO_SMALL 0x8B -#define I2O_FSC_TRANSPORT_FRAME_TOO_LARGE 0x8C -#define I2O_FSC_TRANSPORT_INVALID_TARGET_ID 0x8D -#define I2O_FSC_TRANSPORT_INVALID_INITIATOR_ID 0x8E -#define I2O_FSC_TRANSPORT_INVALID_INITIATOR_CONTEXT 0x8F -#define I2O_FSC_TRANSPORT_UNKNOWN_FAILURE 0xFF - -/* Device Claim Types */ -#define I2O_CLAIM_PRIMARY 0x01000000 -#define I2O_CLAIM_MANAGEMENT 0x02000000 -#define I2O_CLAIM_AUTHORIZED 0x03000000 -#define I2O_CLAIM_SECONDARY 0x04000000 - -/* Message header defines for VersionOffset */ -#define I2OVER15 0x0001 -#define I2OVER20 0x0002 - -/* Default is 1.5 */ -#define I2OVERSION I2OVER15 - -#define SGL_OFFSET_0 I2OVERSION -#define SGL_OFFSET_4 (0x0040 | I2OVERSION) -#define SGL_OFFSET_5 (0x0050 | I2OVERSION) -#define SGL_OFFSET_6 (0x0060 | I2OVERSION) -#define SGL_OFFSET_7 (0x0070 | I2OVERSION) -#define SGL_OFFSET_8 (0x0080 | I2OVERSION) -#define SGL_OFFSET_9 (0x0090 | I2OVERSION) -#define SGL_OFFSET_10 (0x00A0 | I2OVERSION) -#define SGL_OFFSET_11 (0x00B0 | I2OVERSION) -#define SGL_OFFSET_12 (0x00C0 | I2OVERSION) -#define SGL_OFFSET(x) (((x)<<4) | I2OVERSION) - -/* Transaction Reply Lists (TRL) Control Word structure */ -#define TRL_SINGLE_FIXED_LENGTH 0x00 -#define TRL_SINGLE_VARIABLE_LENGTH 0x40 -#define TRL_MULTIPLE_FIXED_LENGTH 0x80 - - /* msg header defines for MsgFlags */ -#define MSG_STATIC 0x0100 -#define MSG_64BIT_CNTXT 0x0200 -#define MSG_MULTI_TRANS 0x1000 -#define MSG_FAIL 0x2000 -#define MSG_FINAL 0x4000 -#define MSG_REPLY 0x8000 - - /* minimum size msg */ -#define THREE_WORD_MSG_SIZE 0x00030000 -#define FOUR_WORD_MSG_SIZE 0x00040000 -#define FIVE_WORD_MSG_SIZE 0x00050000 -#define SIX_WORD_MSG_SIZE 0x00060000 -#define SEVEN_WORD_MSG_SIZE 0x00070000 -#define EIGHT_WORD_MSG_SIZE 0x00080000 -#define NINE_WORD_MSG_SIZE 0x00090000 -#define TEN_WORD_MSG_SIZE 0x000A0000 -#define ELEVEN_WORD_MSG_SIZE 0x000B0000 -#define I2O_MESSAGE_SIZE(x) ((x)<<16) - -/* special TID assignments */ -#define ADAPTER_TID 0 -#define HOST_TID 1 - -/* outbound queue defines */ -#define I2O_MAX_OUTBOUND_MSG_FRAMES 128 -#define I2O_OUTBOUND_MSG_FRAME_SIZE 128 /* in 32-bit words */ - -/* inbound queue definitions */ -#define I2O_MSG_INPOOL_MIN 32 -#define I2O_INBOUND_MSG_FRAME_SIZE 128 /* in 32-bit words */ - -#define I2O_POST_WAIT_OK 0 -#define I2O_POST_WAIT_TIMEOUT -ETIMEDOUT - -#define I2O_CONTEXT_LIST_MIN_LENGTH 15 -#define I2O_CONTEXT_LIST_USED 0x01 -#define I2O_CONTEXT_LIST_DELETED 0x02 - -/* timeouts */ -#define I2O_TIMEOUT_INIT_OUTBOUND_QUEUE 15 -#define I2O_TIMEOUT_MESSAGE_GET 5 -#define I2O_TIMEOUT_RESET 30 -#define I2O_TIMEOUT_STATUS_GET 5 -#define I2O_TIMEOUT_LCT_GET 360 -#define I2O_TIMEOUT_SCSI_SCB_ABORT 240 - -/* retries */ -#define I2O_HRT_GET_TRIES 3 -#define I2O_LCT_GET_TRIES 3 - -/* defines for max_sectors and max_phys_segments */ -#define I2O_MAX_SECTORS 1024 -#define I2O_MAX_SECTORS_LIMITED 128 -#define I2O_MAX_PHYS_SEGMENTS BLK_MAX_SEGMENTS - -/* - * Message structures - */ -struct i2o_message { - union { - struct { - u8 version_offset; - u8 flags; - u16 size; - u32 target_tid:12; - u32 init_tid:12; - u32 function:8; - u32 icntxt; /* initiator context */ - u32 tcntxt; /* transaction context */ - } s; - u32 head[4]; - } u; - /* List follows */ - u32 body[0]; -}; - -/* MFA and I2O message used by mempool */ -struct i2o_msg_mfa { - u32 mfa; /* MFA returned by the controller */ - struct i2o_message msg; /* I2O message */ -}; - -/* - * Each I2O device entity has one of these. There is one per device. - */ -struct i2o_device { - i2o_lct_entry lct_data; /* Device LCT information */ - - struct i2o_controller *iop; /* Controlling IOP */ - struct list_head list; /* node in IOP devices list */ - - struct device device; - - struct mutex lock; /* device lock */ -}; - -/* - * Event structure provided to the event handling function - */ -struct i2o_event { - struct work_struct work; - struct i2o_device *i2o_dev; /* I2O device pointer from which the - event reply was initiated */ - u16 size; /* Size of data in 32-bit words */ - u32 tcntxt; /* Transaction context used at - registration */ - u32 event_indicator; /* Event indicator from reply */ - u32 data[0]; /* Event data from reply */ -}; - -/* - * I2O classes which could be handled by the OSM - */ -struct i2o_class_id { - u16 class_id:12; -}; - -/* - * I2O driver structure for OSMs - */ -struct i2o_driver { - char *name; /* OSM name */ - int context; /* Low 8 bits of the transaction info */ - struct i2o_class_id *classes; /* I2O classes that this OSM handles */ - - /* Message reply handler */ - int (*reply) (struct i2o_controller *, u32, struct i2o_message *); - - /* Event handler */ - work_func_t event; - - struct workqueue_struct *event_queue; /* Event queue */ - - struct device_driver driver; - - /* notification of changes */ - void (*notify_controller_add) (struct i2o_controller *); - void (*notify_controller_remove) (struct i2o_controller *); - void (*notify_device_add) (struct i2o_device *); - void (*notify_device_remove) (struct i2o_device *); - - struct semaphore lock; -}; - -/* - * Contains DMA mapped address information - */ -struct i2o_dma { - void *virt; - dma_addr_t phys; - size_t len; -}; - -/* - * Contains slab cache and mempool information - */ -struct i2o_pool { - char *name; - struct kmem_cache *slab; - mempool_t *mempool; -}; - -/* - * Contains IO mapped address information - */ -struct i2o_io { - void __iomem *virt; - unsigned long phys; - unsigned long len; -}; - -/* - * Context queue entry, used for 32-bit context on 64-bit systems - */ -struct i2o_context_list_element { - struct list_head list; - u32 context; - void *ptr; - unsigned long timestamp; -}; - -/* - * Each I2O controller has one of these objects - */ -struct i2o_controller { - char name[16]; - int unit; - int type; - - struct pci_dev *pdev; /* PCI device */ - - unsigned int promise:1; /* Promise controller */ - unsigned int adaptec:1; /* DPT / Adaptec controller */ - unsigned int raptor:1; /* split bar */ - unsigned int no_quiesce:1; /* dont quiesce before reset */ - unsigned int short_req:1; /* use small block sizes */ - unsigned int limit_sectors:1; /* limit number of sectors / request */ - unsigned int pae_support:1; /* controller has 64-bit SGL support */ - - struct list_head devices; /* list of I2O devices */ - struct list_head list; /* Controller list */ - - void __iomem *in_port; /* Inbout port address */ - void __iomem *out_port; /* Outbound port address */ - void __iomem *irq_status; /* Interrupt status register address */ - void __iomem *irq_mask; /* Interrupt mask register address */ - - struct i2o_dma status; /* IOP status block */ - - struct i2o_dma hrt; /* HW Resource Table */ - i2o_lct *lct; /* Logical Config Table */ - struct i2o_dma dlct; /* Temp LCT */ - struct mutex lct_lock; /* Lock for LCT updates */ - struct i2o_dma status_block; /* IOP status block */ - - struct i2o_io base; /* controller messaging unit */ - struct i2o_io in_queue; /* inbound message queue Host->IOP */ - struct i2o_dma out_queue; /* outbound message queue IOP->Host */ - - struct i2o_pool in_msg; /* mempool for inbound messages */ - - unsigned int battery:1; /* Has a battery backup */ - unsigned int io_alloc:1; /* An I/O resource was allocated */ - unsigned int mem_alloc:1; /* A memory resource was allocated */ - - struct resource io_resource; /* I/O resource allocated to the IOP */ - struct resource mem_resource; /* Mem resource allocated to the IOP */ - - struct device device; - struct i2o_device *exec; /* Executive */ -#if BITS_PER_LONG == 64 - spinlock_t context_list_lock; /* lock for context_list */ - atomic_t context_list_counter; /* needed for unique contexts */ - struct list_head context_list; /* list of context id's - and pointers */ -#endif - spinlock_t lock; /* lock for controller - configuration */ - void *driver_data[I2O_MAX_DRIVERS]; /* storage for drivers */ -}; - -/* - * I2O System table entry - * - * The system table contains information about all the IOPs in the - * system. It is sent to all IOPs so that they can create peer2peer - * connections between them. - */ -struct i2o_sys_tbl_entry { - u16 org_id; - u16 reserved1; - u32 iop_id:12; - u32 reserved2:20; - u16 seg_num:12; - u16 i2o_version:4; - u8 iop_state; - u8 msg_type; - u16 frame_size; - u16 reserved3; - u32 last_changed; - u32 iop_capabilities; - u32 inbound_low; - u32 inbound_high; -}; - -struct i2o_sys_tbl { - u8 num_entries; - u8 version; - u16 reserved1; - u32 change_ind; - u32 reserved2; - u32 reserved3; - struct i2o_sys_tbl_entry iops[0]; -}; - -extern struct list_head i2o_controllers; - -/* Message functions */ -extern struct i2o_message *i2o_msg_get_wait(struct i2o_controller *, int); -extern int i2o_msg_post_wait_mem(struct i2o_controller *, struct i2o_message *, - unsigned long, struct i2o_dma *); - -/* IOP functions */ -extern int i2o_status_get(struct i2o_controller *); - -extern int i2o_event_register(struct i2o_device *, struct i2o_driver *, int, - u32); -extern struct i2o_device *i2o_iop_find_device(struct i2o_controller *, u16); -extern struct i2o_controller *i2o_find_iop(int); - -/* Functions needed for handling 64-bit pointers in 32-bit context */ -#if BITS_PER_LONG == 64 -extern u32 i2o_cntxt_list_add(struct i2o_controller *, void *); -extern void *i2o_cntxt_list_get(struct i2o_controller *, u32); -extern u32 i2o_cntxt_list_remove(struct i2o_controller *, void *); -extern u32 i2o_cntxt_list_get_ptr(struct i2o_controller *, void *); - -static inline u32 i2o_ptr_low(void *ptr) -{ - return (u32) (u64) ptr; -}; - -static inline u32 i2o_ptr_high(void *ptr) -{ - return (u32) ((u64) ptr >> 32); -}; - -static inline u32 i2o_dma_low(dma_addr_t dma_addr) -{ - return (u32) (u64) dma_addr; -}; - -static inline u32 i2o_dma_high(dma_addr_t dma_addr) -{ - return (u32) ((u64) dma_addr >> 32); -}; -#else -static inline u32 i2o_cntxt_list_add(struct i2o_controller *c, void *ptr) -{ - return (u32) ptr; -}; - -static inline void *i2o_cntxt_list_get(struct i2o_controller *c, u32 context) -{ - return (void *)context; -}; - -static inline u32 i2o_cntxt_list_remove(struct i2o_controller *c, void *ptr) -{ - return (u32) ptr; -}; - -static inline u32 i2o_cntxt_list_get_ptr(struct i2o_controller *c, void *ptr) -{ - return (u32) ptr; -}; - -static inline u32 i2o_ptr_low(void *ptr) -{ - return (u32) ptr; -}; - -static inline u32 i2o_ptr_high(void *ptr) -{ - return 0; -}; - -static inline u32 i2o_dma_low(dma_addr_t dma_addr) -{ - return (u32) dma_addr; -}; - -static inline u32 i2o_dma_high(dma_addr_t dma_addr) -{ - return 0; -}; -#endif - -extern u16 i2o_sg_tablesize(struct i2o_controller *c, u16 body_size); -extern dma_addr_t i2o_dma_map_single(struct i2o_controller *c, void *ptr, - size_t size, - enum dma_data_direction direction, - u32 ** sg_ptr); -extern int i2o_dma_map_sg(struct i2o_controller *c, - struct scatterlist *sg, int sg_count, - enum dma_data_direction direction, - u32 ** sg_ptr); -extern int i2o_dma_alloc(struct device *dev, struct i2o_dma *addr, size_t len); -extern void i2o_dma_free(struct device *dev, struct i2o_dma *addr); -extern int i2o_dma_realloc(struct device *dev, struct i2o_dma *addr, - size_t len); -extern int i2o_pool_alloc(struct i2o_pool *pool, const char *name, - size_t size, int min_nr); -extern void i2o_pool_free(struct i2o_pool *pool); -/* I2O driver (OSM) functions */ -extern int i2o_driver_register(struct i2o_driver *); -extern void i2o_driver_unregister(struct i2o_driver *); - -/** - * i2o_driver_notify_controller_add - Send notification of added controller - * @drv: I2O driver - * @c: I2O controller - * - * Send notification of added controller to a single registered driver. - */ -static inline void i2o_driver_notify_controller_add(struct i2o_driver *drv, - struct i2o_controller *c) -{ - if (drv->notify_controller_add) - drv->notify_controller_add(c); -}; - -/** - * i2o_driver_notify_controller_remove - Send notification of removed controller - * @drv: I2O driver - * @c: I2O controller - * - * Send notification of removed controller to a single registered driver. - */ -static inline void i2o_driver_notify_controller_remove(struct i2o_driver *drv, - struct i2o_controller *c) -{ - if (drv->notify_controller_remove) - drv->notify_controller_remove(c); -}; - -/** - * i2o_driver_notify_device_add - Send notification of added device - * @drv: I2O driver - * @i2o_dev: the added i2o_device - * - * Send notification of added device to a single registered driver. - */ -static inline void i2o_driver_notify_device_add(struct i2o_driver *drv, - struct i2o_device *i2o_dev) -{ - if (drv->notify_device_add) - drv->notify_device_add(i2o_dev); -}; - -/** - * i2o_driver_notify_device_remove - Send notification of removed device - * @drv: I2O driver - * @i2o_dev: the added i2o_device - * - * Send notification of removed device to a single registered driver. - */ -static inline void i2o_driver_notify_device_remove(struct i2o_driver *drv, - struct i2o_device *i2o_dev) -{ - if (drv->notify_device_remove) - drv->notify_device_remove(i2o_dev); -}; - -extern void i2o_driver_notify_controller_add_all(struct i2o_controller *); -extern void i2o_driver_notify_controller_remove_all(struct i2o_controller *); -extern void i2o_driver_notify_device_add_all(struct i2o_device *); -extern void i2o_driver_notify_device_remove_all(struct i2o_device *); - -/* I2O device functions */ -extern int i2o_device_claim(struct i2o_device *); -extern int i2o_device_claim_release(struct i2o_device *); - -/* Exec OSM functions */ -extern int i2o_exec_lct_get(struct i2o_controller *); - -/* device / driver / kobject conversion functions */ -#define to_i2o_driver(drv) container_of(drv,struct i2o_driver, driver) -#define to_i2o_device(dev) container_of(dev, struct i2o_device, device) -#define to_i2o_controller(dev) container_of(dev, struct i2o_controller, device) - -/** - * i2o_out_to_virt - Turn an I2O message to a virtual address - * @c: controller - * @m: message engine value - * - * Turn a receive message from an I2O controller bus address into - * a Linux virtual address. The shared page frame is a linear block - * so we simply have to shift the offset. This function does not - * work for sender side messages as they are ioremap objects - * provided by the I2O controller. - */ -static inline struct i2o_message *i2o_msg_out_to_virt(struct i2o_controller *c, - u32 m) -{ - BUG_ON(m < c->out_queue.phys - || m >= c->out_queue.phys + c->out_queue.len); - - return c->out_queue.virt + (m - c->out_queue.phys); -}; - -/** - * i2o_msg_in_to_virt - Turn an I2O message to a virtual address - * @c: controller - * @m: message engine value - * - * Turn a send message from an I2O controller bus address into - * a Linux virtual address. The shared page frame is a linear block - * so we simply have to shift the offset. This function does not - * work for receive side messages as they are kmalloc objects - * in a different pool. - */ -static inline struct i2o_message __iomem *i2o_msg_in_to_virt(struct - i2o_controller *c, - u32 m) -{ - return c->in_queue.virt + m; -}; - -/** - * i2o_msg_get - obtain an I2O message from the IOP - * @c: I2O controller - * - * This function tries to get a message frame. If no message frame is - * available do not wait until one is available (see also i2o_msg_get_wait). - * The returned pointer to the message frame is not in I/O memory, it is - * allocated from a mempool. But because a MFA is allocated from the - * controller too it is guaranteed that i2o_msg_post() will never fail. - * - * On a success a pointer to the message frame is returned. If the message - * queue is empty -EBUSY is returned and if no memory is available -ENOMEM - * is returned. - */ -static inline struct i2o_message *i2o_msg_get(struct i2o_controller *c) -{ - struct i2o_msg_mfa *mmsg = mempool_alloc(c->in_msg.mempool, GFP_ATOMIC); - if (!mmsg) - return ERR_PTR(-ENOMEM); - - mmsg->mfa = readl(c->in_port); - if (unlikely(mmsg->mfa >= c->in_queue.len)) { - u32 mfa = mmsg->mfa; - - mempool_free(mmsg, c->in_msg.mempool); - - if (mfa == I2O_QUEUE_EMPTY) - return ERR_PTR(-EBUSY); - return ERR_PTR(-EFAULT); - } - - return &mmsg->msg; -}; - -/** - * i2o_msg_post - Post I2O message to I2O controller - * @c: I2O controller to which the message should be send - * @msg: message returned by i2o_msg_get() - * - * Post the message to the I2O controller and return immediately. - */ -static inline void i2o_msg_post(struct i2o_controller *c, - struct i2o_message *msg) -{ - struct i2o_msg_mfa *mmsg; - - mmsg = container_of(msg, struct i2o_msg_mfa, msg); - memcpy_toio(i2o_msg_in_to_virt(c, mmsg->mfa), msg, - (le32_to_cpu(msg->u.head[0]) >> 16) << 2); - writel(mmsg->mfa, c->in_port); - mempool_free(mmsg, c->in_msg.mempool); -}; - -/** - * i2o_msg_post_wait - Post and wait a message and wait until return - * @c: controller - * @msg: message to post - * @timeout: time in seconds to wait - * - * This API allows an OSM to post a message and then be told whether or - * not the system received a successful reply. If the message times out - * then the value '-ETIMEDOUT' is returned. - * - * Returns 0 on success or negative error code on failure. - */ -static inline int i2o_msg_post_wait(struct i2o_controller *c, - struct i2o_message *msg, - unsigned long timeout) -{ - return i2o_msg_post_wait_mem(c, msg, timeout, NULL); -}; - -/** - * i2o_msg_nop_mfa - Returns a fetched MFA back to the controller - * @c: I2O controller from which the MFA was fetched - * @mfa: MFA which should be returned - * - * This function must be used for preserved messages, because i2o_msg_nop() - * also returns the allocated memory back to the msg_pool mempool. - */ -static inline void i2o_msg_nop_mfa(struct i2o_controller *c, u32 mfa) -{ - struct i2o_message __iomem *msg; - u32 nop[3] = { - THREE_WORD_MSG_SIZE | SGL_OFFSET_0, - I2O_CMD_UTIL_NOP << 24 | HOST_TID << 12 | ADAPTER_TID, - 0x00000000 - }; - - msg = i2o_msg_in_to_virt(c, mfa); - memcpy_toio(msg, nop, sizeof(nop)); - writel(mfa, c->in_port); -}; - -/** - * i2o_msg_nop - Returns a message which is not used - * @c: I2O controller from which the message was created - * @msg: message which should be returned - * - * If you fetch a message via i2o_msg_get, and can't use it, you must - * return the message with this function. Otherwise the MFA is lost as well - * as the allocated memory from the mempool. - */ -static inline void i2o_msg_nop(struct i2o_controller *c, - struct i2o_message *msg) -{ - struct i2o_msg_mfa *mmsg; - mmsg = container_of(msg, struct i2o_msg_mfa, msg); - - i2o_msg_nop_mfa(c, mmsg->mfa); - mempool_free(mmsg, c->in_msg.mempool); -}; - -/** - * i2o_flush_reply - Flush reply from I2O controller - * @c: I2O controller - * @m: the message identifier - * - * The I2O controller must be informed that the reply message is not needed - * anymore. If you forget to flush the reply, the message frame can't be - * used by the controller anymore and is therefore lost. - */ -static inline void i2o_flush_reply(struct i2o_controller *c, u32 m) -{ - writel(m, c->out_port); -}; - -/* - * Endian handling wrapped into the macro - keeps the core code - * cleaner. - */ - -#define i2o_raw_writel(val, mem) __raw_writel(cpu_to_le32(val), mem) - -extern int i2o_parm_field_get(struct i2o_device *, int, int, void *, int); -extern int i2o_parm_table_get(struct i2o_device *, int, int, int, void *, int, - void *, int); - -/* debugging and troubleshooting/diagnostic helpers. */ -#define osm_printk(level, format, arg...) \ - printk(level "%s: " format, OSM_NAME , ## arg) - -#ifdef DEBUG -#define osm_debug(format, arg...) \ - osm_printk(KERN_DEBUG, format , ## arg) -#else -#define osm_debug(format, arg...) \ - do { } while (0) -#endif - -#define osm_err(format, arg...) \ - osm_printk(KERN_ERR, format , ## arg) -#define osm_info(format, arg...) \ - osm_printk(KERN_INFO, format , ## arg) -#define osm_warn(format, arg...) \ - osm_printk(KERN_WARNING, format , ## arg) - -/* debugging functions */ -extern void i2o_report_status(const char *, const char *, struct i2o_message *); -extern void i2o_dump_message(struct i2o_message *); -extern void i2o_dump_hrt(struct i2o_controller *c); -extern void i2o_debug_state(struct i2o_controller *c); - -#endif /* _I2O_H */ diff --git a/drivers/staging/i2o/i2o_block.c b/drivers/staging/i2o/i2o_block.c deleted file mode 100644 index 406758f755ee..000000000000 --- a/drivers/staging/i2o/i2o_block.c +++ /dev/null @@ -1,1228 +0,0 @@ -/* - * Block OSM - * - * Copyright (C) 1999-2002 Red Hat Software - * - * Written by Alan Cox, Building Number Three Ltd - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * For the purpose of avoiding doubt the preferred form of the work - * for making modifications shall be a standards compliant form such - * gzipped tar and not one requiring a proprietary or patent encumbered - * tool to unpack. - * - * Fixes/additions: - * Steve Ralston: - * Multiple device handling error fixes, - * Added a queue depth. - * Alan Cox: - * FC920 has an rmw bug. Dont or in the end marker. - * Removed queue walk, fixed for 64bitness. - * Rewrote much of the code over time - * Added indirect block lists - * Handle 64K limits on many controllers - * Don't use indirects on the Promise (breaks) - * Heavily chop down the queue depths - * Deepak Saxena: - * Independent queues per IOP - * Support for dynamic device creation/deletion - * Code cleanup - * Support for larger I/Os through merge* functions - * (taken from DAC960 driver) - * Boji T Kannanthanam: - * Set the I2O Block devices to be detected in increasing - * order of TIDs during boot. - * Search and set the I2O block device that we boot off - * from as the first device to be claimed (as /dev/i2o/hda) - * Properly attach/detach I2O gendisk structure from the - * system gendisk list. The I2O block devices now appear in - * /proc/partitions. - * Markus Lidel : - * Minor bugfixes for 2.6. - */ - -#include -#include -#include "i2o.h" -#include - -#include - -#include -#include -#include - -#include - -#include "i2o_block.h" - -#define OSM_NAME "block-osm" -#define OSM_VERSION "1.325" -#define OSM_DESCRIPTION "I2O Block Device OSM" - -static DEFINE_MUTEX(i2o_block_mutex); -static struct i2o_driver i2o_block_driver; - -/* global Block OSM request mempool */ -static struct i2o_block_mempool i2o_blk_req_pool; - -/* Block OSM class handling definition */ -static struct i2o_class_id i2o_block_class_id[] = { - {I2O_CLASS_RANDOM_BLOCK_STORAGE}, - {I2O_CLASS_END} -}; - -/** - * i2o_block_device_free - free the memory of the I2O Block device - * @dev: I2O Block device, which should be cleaned up - * - * Frees the request queue, gendisk and the i2o_block_device structure. - */ -static void i2o_block_device_free(struct i2o_block_device *dev) -{ - blk_cleanup_queue(dev->gd->queue); - - put_disk(dev->gd); - - kfree(dev); -}; - -/** - * i2o_block_remove - remove the I2O Block device from the system again - * @dev: I2O Block device which should be removed - * - * Remove gendisk from system and free all allocated memory. - * - * Always returns 0. - */ -static int i2o_block_remove(struct device *dev) -{ - struct i2o_device *i2o_dev = to_i2o_device(dev); - struct i2o_block_device *i2o_blk_dev = dev_get_drvdata(dev); - - osm_info("device removed (TID: %03x): %s\n", i2o_dev->lct_data.tid, - i2o_blk_dev->gd->disk_name); - - i2o_event_register(i2o_dev, &i2o_block_driver, 0, 0); - - del_gendisk(i2o_blk_dev->gd); - - dev_set_drvdata(dev, NULL); - - i2o_device_claim_release(i2o_dev); - - i2o_block_device_free(i2o_blk_dev); - - return 0; -}; - -/** - * i2o_block_device flush - Flush all dirty data of I2O device dev - * @dev: I2O device which should be flushed - * - * Flushes all dirty data on device dev. - * - * Returns 0 on success or negative error code on failure. - */ -static int i2o_block_device_flush(struct i2o_device *dev) -{ - struct i2o_message *msg; - - msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0); - msg->u.head[1] = - cpu_to_le32(I2O_CMD_BLOCK_CFLUSH << 24 | HOST_TID << 12 | dev-> - lct_data.tid); - msg->body[0] = cpu_to_le32(60 << 16); - osm_debug("Flushing...\n"); - - return i2o_msg_post_wait(dev->iop, msg, 60); -}; - -/** - * i2o_block_device_mount - Mount (load) the media of device dev - * @dev: I2O device which should receive the mount request - * @media_id: Media Identifier - * - * Load a media into drive. Identifier should be set to -1, because the - * spec does not support any other value. - * - * Returns 0 on success or negative error code on failure. - */ -static int i2o_block_device_mount(struct i2o_device *dev, u32 media_id) -{ - struct i2o_message *msg; - - msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0); - msg->u.head[1] = - cpu_to_le32(I2O_CMD_BLOCK_MMOUNT << 24 | HOST_TID << 12 | dev-> - lct_data.tid); - msg->body[0] = cpu_to_le32(-1); - msg->body[1] = cpu_to_le32(0x00000000); - osm_debug("Mounting...\n"); - - return i2o_msg_post_wait(dev->iop, msg, 2); -}; - -/** - * i2o_block_device_lock - Locks the media of device dev - * @dev: I2O device which should receive the lock request - * @media_id: Media Identifier - * - * Lock media of device dev to prevent removal. The media identifier - * should be set to -1, because the spec does not support any other value. - * - * Returns 0 on success or negative error code on failure. - */ -static int i2o_block_device_lock(struct i2o_device *dev, u32 media_id) -{ - struct i2o_message *msg; - - msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0); - msg->u.head[1] = - cpu_to_le32(I2O_CMD_BLOCK_MLOCK << 24 | HOST_TID << 12 | dev-> - lct_data.tid); - msg->body[0] = cpu_to_le32(-1); - osm_debug("Locking...\n"); - - return i2o_msg_post_wait(dev->iop, msg, 2); -}; - -/** - * i2o_block_device_unlock - Unlocks the media of device dev - * @dev: I2O device which should receive the unlocked request - * @media_id: Media Identifier - * - * Unlocks the media in device dev. The media identifier should be set to - * -1, because the spec does not support any other value. - * - * Returns 0 on success or negative error code on failure. - */ -static int i2o_block_device_unlock(struct i2o_device *dev, u32 media_id) -{ - struct i2o_message *msg; - - msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0); - msg->u.head[1] = - cpu_to_le32(I2O_CMD_BLOCK_MUNLOCK << 24 | HOST_TID << 12 | dev-> - lct_data.tid); - msg->body[0] = cpu_to_le32(media_id); - osm_debug("Unlocking...\n"); - - return i2o_msg_post_wait(dev->iop, msg, 2); -}; - -/** - * i2o_block_device_power - Power management for device dev - * @dev: I2O device which should receive the power management request - * @op: Operation to send - * - * Send a power management request to the device dev. - * - * Returns 0 on success or negative error code on failure. - */ -static int i2o_block_device_power(struct i2o_block_device *dev, u8 op) -{ - struct i2o_device *i2o_dev = dev->i2o_dev; - struct i2o_controller *c = i2o_dev->iop; - struct i2o_message *msg; - int rc; - - msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0); - msg->u.head[1] = - cpu_to_le32(I2O_CMD_BLOCK_POWER << 24 | HOST_TID << 12 | i2o_dev-> - lct_data.tid); - msg->body[0] = cpu_to_le32(op << 24); - osm_debug("Power...\n"); - - rc = i2o_msg_post_wait(c, msg, 60); - if (!rc) - dev->power = op; - - return rc; -}; - -/** - * i2o_block_request_alloc - Allocate an I2O block request struct - * - * Allocates an I2O block request struct and initialize the list. - * - * Returns a i2o_block_request pointer on success or negative error code - * on failure. - */ -static inline struct i2o_block_request *i2o_block_request_alloc(void) -{ - struct i2o_block_request *ireq; - - ireq = mempool_alloc(i2o_blk_req_pool.pool, GFP_ATOMIC); - if (!ireq) - return ERR_PTR(-ENOMEM); - - INIT_LIST_HEAD(&ireq->queue); - sg_init_table(ireq->sg_table, I2O_MAX_PHYS_SEGMENTS); - - return ireq; -}; - -/** - * i2o_block_request_free - Frees a I2O block request - * @ireq: I2O block request which should be freed - * - * Frees the allocated memory (give it back to the request mempool). - */ -static inline void i2o_block_request_free(struct i2o_block_request *ireq) -{ - mempool_free(ireq, i2o_blk_req_pool.pool); -}; - -/** - * i2o_block_sglist_alloc - Allocate the SG list and map it - * @c: I2O controller to which the request belongs - * @ireq: I2O block request - * @mptr: message body pointer - * - * Builds the SG list and map it to be accessible by the controller. - * - * Returns 0 on failure or 1 on success. - */ -static inline int i2o_block_sglist_alloc(struct i2o_controller *c, - struct i2o_block_request *ireq, - u32 ** mptr) -{ - int nents; - enum dma_data_direction direction; - - ireq->dev = &c->pdev->dev; - nents = blk_rq_map_sg(ireq->req->q, ireq->req, ireq->sg_table); - - if (rq_data_dir(ireq->req) == READ) - direction = PCI_DMA_FROMDEVICE; - else - direction = PCI_DMA_TODEVICE; - - ireq->sg_nents = nents; - - return i2o_dma_map_sg(c, ireq->sg_table, nents, direction, mptr); -}; - -/** - * i2o_block_sglist_free - Frees the SG list - * @ireq: I2O block request from which the SG should be freed - * - * Frees the SG list from the I2O block request. - */ -static inline void i2o_block_sglist_free(struct i2o_block_request *ireq) -{ - enum dma_data_direction direction; - - if (rq_data_dir(ireq->req) == READ) - direction = PCI_DMA_FROMDEVICE; - else - direction = PCI_DMA_TODEVICE; - - dma_unmap_sg(ireq->dev, ireq->sg_table, ireq->sg_nents, direction); -}; - -/** - * i2o_block_prep_req_fn - Allocates I2O block device specific struct - * @q: request queue for the request - * @req: the request to prepare - * - * Allocate the necessary i2o_block_request struct and connect it to - * the request. This is needed that we not lose the SG list later on. - * - * Returns BLKPREP_OK on success or BLKPREP_DEFER on failure. - */ -static int i2o_block_prep_req_fn(struct request_queue *q, struct request *req) -{ - struct i2o_block_device *i2o_blk_dev = q->queuedata; - struct i2o_block_request *ireq; - - if (unlikely(!i2o_blk_dev)) { - osm_err("block device already removed\n"); - return BLKPREP_KILL; - } - - /* connect the i2o_block_request to the request */ - if (!req->special) { - ireq = i2o_block_request_alloc(); - if (IS_ERR(ireq)) { - osm_debug("unable to allocate i2o_block_request!\n"); - return BLKPREP_DEFER; - } - - ireq->i2o_blk_dev = i2o_blk_dev; - req->special = ireq; - ireq->req = req; - } - /* do not come back here */ - req->cmd_flags |= REQ_DONTPREP; - - return BLKPREP_OK; -}; - -/** - * i2o_block_delayed_request_fn - delayed request queue function - * @work: the delayed request with the queue to start - * - * If the request queue is stopped for a disk, and there is no open - * request, a new event is created, which calls this function to start - * the queue after I2O_BLOCK_REQUEST_TIME. Otherwise the queue will never - * be started again. - */ -static void i2o_block_delayed_request_fn(struct work_struct *work) -{ - struct i2o_block_delayed_request *dreq = - container_of(work, struct i2o_block_delayed_request, - work.work); - struct request_queue *q = dreq->queue; - unsigned long flags; - - spin_lock_irqsave(q->queue_lock, flags); - blk_start_queue(q); - spin_unlock_irqrestore(q->queue_lock, flags); - kfree(dreq); -}; - -/** - * i2o_block_end_request - Post-processing of completed commands - * @req: request which should be completed - * @error: 0 for success, < 0 for error - * @nr_bytes: number of bytes to complete - * - * Mark the request as complete. The lock must not be held when entering. - * - */ -static void i2o_block_end_request(struct request *req, int error, - int nr_bytes) -{ - struct i2o_block_request *ireq = req->special; - struct i2o_block_device *dev = ireq->i2o_blk_dev; - struct request_queue *q = req->q; - unsigned long flags; - - if (blk_end_request(req, error, nr_bytes)) - if (error) - blk_end_request_all(req, -EIO); - - spin_lock_irqsave(q->queue_lock, flags); - - if (likely(dev)) { - dev->open_queue_depth--; - list_del(&ireq->queue); - } - - blk_start_queue(q); - - spin_unlock_irqrestore(q->queue_lock, flags); - - i2o_block_sglist_free(ireq); - i2o_block_request_free(ireq); -}; - -/** - * i2o_block_reply - Block OSM reply handler. - * @c: I2O controller from which the message arrives - * @m: message id of reply - * @msg: the actual I2O message reply - * - * This function gets all the message replies. - * - */ -static int i2o_block_reply(struct i2o_controller *c, u32 m, - struct i2o_message *msg) -{ - struct request *req; - int error = 0; - - req = i2o_cntxt_list_get(c, le32_to_cpu(msg->u.s.tcntxt)); - if (unlikely(!req)) { - osm_err("NULL reply received!\n"); - return -1; - } - - /* - * Lets see what is cooking. We stuffed the - * request in the context. - */ - - if ((le32_to_cpu(msg->body[0]) >> 24) != 0) { - u32 status = le32_to_cpu(msg->body[0]); - /* - * Device not ready means two things. One is that the - * the thing went offline (but not a removal media) - * - * The second is that you have a SuperTrak 100 and the - * firmware got constipated. Unlike standard i2o card - * setups the supertrak returns an error rather than - * blocking for the timeout in these cases. - * - * Don't stick a supertrak100 into cache aggressive modes - */ - - osm_err("TID %03x error status: 0x%02x, detailed status: " - "0x%04x\n", (le32_to_cpu(msg->u.head[1]) >> 12 & 0xfff), - status >> 24, status & 0xffff); - - req->errors++; - - error = -EIO; - } - - i2o_block_end_request(req, error, le32_to_cpu(msg->body[1])); - - return 1; -}; - -static void i2o_block_event(struct work_struct *work) -{ - struct i2o_event *evt = container_of(work, struct i2o_event, work); - osm_debug("event received\n"); - kfree(evt); -}; - -/* - * SCSI-CAM for ioctl geometry mapping - * Duplicated with SCSI - this should be moved into somewhere common - * perhaps genhd ? - * - * LBA -> CHS mapping table taken from: - * - * "Incorporating the I2O Architecture into BIOS for Intel Architecture - * Platforms" - * - * This is an I2O document that is only available to I2O members, - * not developers. - * - * From my understanding, this is how all the I2O cards do this - * - * Disk Size | Sectors | Heads | Cylinders - * ---------------+---------+-------+------------------- - * 1 < X <= 528M | 63 | 16 | X/(63 * 16 * 512) - * 528M < X <= 1G | 63 | 32 | X/(63 * 32 * 512) - * 1 < X <528M | 63 | 16 | X/(63 * 16 * 512) - * 1 < X <528M | 63 | 16 | X/(63 * 16 * 512) - * - */ -#define BLOCK_SIZE_528M 1081344 -#define BLOCK_SIZE_1G 2097152 -#define BLOCK_SIZE_21G 4403200 -#define BLOCK_SIZE_42G 8806400 -#define BLOCK_SIZE_84G 17612800 - -static void i2o_block_biosparam(unsigned long capacity, unsigned short *cyls, - unsigned char *hds, unsigned char *secs) -{ - unsigned long heads, sectors, cylinders; - - sectors = 63L; /* Maximize sectors per track */ - if (capacity <= BLOCK_SIZE_528M) - heads = 16; - else if (capacity <= BLOCK_SIZE_1G) - heads = 32; - else if (capacity <= BLOCK_SIZE_21G) - heads = 64; - else if (capacity <= BLOCK_SIZE_42G) - heads = 128; - else - heads = 255; - - cylinders = (unsigned long)capacity / (heads * sectors); - - *cyls = (unsigned short)cylinders; /* Stuff return values */ - *secs = (unsigned char)sectors; - *hds = (unsigned char)heads; -} - -/** - * i2o_block_open - Open the block device - * @bdev: block device being opened - * @mode: file open mode - * - * Power up the device, mount and lock the media. This function is called, - * if the block device is opened for access. - * - * Returns 0 on success or negative error code on failure. - */ -static int i2o_block_open(struct block_device *bdev, fmode_t mode) -{ - struct i2o_block_device *dev = bdev->bd_disk->private_data; - - if (!dev->i2o_dev) - return -ENODEV; - - mutex_lock(&i2o_block_mutex); - if (dev->power > 0x1f) - i2o_block_device_power(dev, 0x02); - - i2o_block_device_mount(dev->i2o_dev, -1); - - i2o_block_device_lock(dev->i2o_dev, -1); - - osm_debug("Ready.\n"); - mutex_unlock(&i2o_block_mutex); - - return 0; -}; - -/** - * i2o_block_release - Release the I2O block device - * @disk: gendisk device being released - * @mode: file open mode - * - * Unlock and unmount the media, and power down the device. Gets called if - * the block device is closed. - */ -static void i2o_block_release(struct gendisk *disk, fmode_t mode) -{ - struct i2o_block_device *dev = disk->private_data; - u8 operation; - - /* - * This is to deal with the case of an application - * opening a device and then the device disappears while - * it's in use, and then the application tries to release - * it. ex: Unmounting a deleted RAID volume at reboot. - * If we send messages, it will just cause FAILs since - * the TID no longer exists. - */ - if (!dev->i2o_dev) - return; - - mutex_lock(&i2o_block_mutex); - i2o_block_device_flush(dev->i2o_dev); - - i2o_block_device_unlock(dev->i2o_dev, -1); - - if (dev->flags & (1 << 3 | 1 << 4)) /* Removable */ - operation = 0x21; - else - operation = 0x24; - - i2o_block_device_power(dev, operation); - mutex_unlock(&i2o_block_mutex); -} - -static int i2o_block_getgeo(struct block_device *bdev, struct hd_geometry *geo) -{ - i2o_block_biosparam(get_capacity(bdev->bd_disk), - &geo->cylinders, &geo->heads, &geo->sectors); - return 0; -} - -/** - * i2o_block_ioctl - Issue device specific ioctl calls. - * @bdev: block device being opened - * @mode: file open mode - * @cmd: ioctl command - * @arg: arg - * - * Handles ioctl request for the block device. - * - * Return 0 on success or negative error on failure. - */ -static int i2o_block_ioctl(struct block_device *bdev, fmode_t mode, - unsigned int cmd, unsigned long arg) -{ - struct gendisk *disk = bdev->bd_disk; - struct i2o_block_device *dev = disk->private_data; - int ret = -ENOTTY; - - /* Anyone capable of this syscall can do *real bad* things */ - - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - - mutex_lock(&i2o_block_mutex); - switch (cmd) { - case BLKI2OGRSTRAT: - ret = put_user(dev->rcache, (int __user *)arg); - break; - case BLKI2OGWSTRAT: - ret = put_user(dev->wcache, (int __user *)arg); - break; - case BLKI2OSRSTRAT: - ret = -EINVAL; - if (arg < 0 || arg > CACHE_SMARTFETCH) - break; - dev->rcache = arg; - ret = 0; - break; - case BLKI2OSWSTRAT: - ret = -EINVAL; - if (arg != 0 - && (arg < CACHE_WRITETHROUGH || arg > CACHE_SMARTBACK)) - break; - dev->wcache = arg; - ret = 0; - break; - } - mutex_unlock(&i2o_block_mutex); - - return ret; -}; - -/** - * i2o_block_check_events - Have we seen a media change? - * @disk: gendisk which should be verified - * @clearing: events being cleared - * - * Verifies if the media has changed. - * - * Returns 1 if the media was changed or 0 otherwise. - */ -static unsigned int i2o_block_check_events(struct gendisk *disk, - unsigned int clearing) -{ - struct i2o_block_device *p = disk->private_data; - - if (p->media_change_flag) { - p->media_change_flag = 0; - return DISK_EVENT_MEDIA_CHANGE; - } - return 0; -} - -/** - * i2o_block_transfer - Transfer a request to/from the I2O controller - * @req: the request which should be transferred - * - * This function converts the request into a I2O message. The necessary - * DMA buffers are allocated and after everything is setup post the message - * to the I2O controller. No cleanup is done by this function. It is done - * on the interrupt side when the reply arrives. - * - * Return 0 on success or negative error code on failure. - */ -static int i2o_block_transfer(struct request *req) -{ - struct i2o_block_device *dev = req->rq_disk->private_data; - struct i2o_controller *c; - u32 tid; - struct i2o_message *msg; - u32 *mptr; - struct i2o_block_request *ireq = req->special; - u32 tcntxt; - u32 sgl_offset = SGL_OFFSET_8; - u32 ctl_flags = 0x00000000; - int rc; - u32 cmd; - - if (unlikely(!dev->i2o_dev)) { - osm_err("transfer to removed drive\n"); - rc = -ENODEV; - goto exit; - } - - tid = dev->i2o_dev->lct_data.tid; - c = dev->i2o_dev->iop; - - msg = i2o_msg_get(c); - if (IS_ERR(msg)) { - rc = PTR_ERR(msg); - goto exit; - } - - tcntxt = i2o_cntxt_list_add(c, req); - if (!tcntxt) { - rc = -ENOMEM; - goto nop_msg; - } - - msg->u.s.icntxt = cpu_to_le32(i2o_block_driver.context); - msg->u.s.tcntxt = cpu_to_le32(tcntxt); - - mptr = &msg->body[0]; - - if (rq_data_dir(req) == READ) { - cmd = I2O_CMD_BLOCK_READ << 24; - - switch (dev->rcache) { - case CACHE_PREFETCH: - ctl_flags = 0x201F0008; - break; - - case CACHE_SMARTFETCH: - if (blk_rq_sectors(req) > 16) - ctl_flags = 0x201F0008; - else - ctl_flags = 0x001F0000; - break; - - default: - break; - } - } else { - cmd = I2O_CMD_BLOCK_WRITE << 24; - - switch (dev->wcache) { - case CACHE_WRITETHROUGH: - ctl_flags = 0x001F0008; - break; - case CACHE_WRITEBACK: - ctl_flags = 0x001F0010; - break; - case CACHE_SMARTBACK: - if (blk_rq_sectors(req) > 16) - ctl_flags = 0x001F0004; - else - ctl_flags = 0x001F0010; - break; - case CACHE_SMARTTHROUGH: - if (blk_rq_sectors(req) > 16) - ctl_flags = 0x001F0004; - else - ctl_flags = 0x001F0010; - default: - break; - } - } - -#ifdef CONFIG_I2O_EXT_ADAPTEC - if (c->adaptec) { - u8 cmd[10]; - u32 scsi_flags; - u16 hwsec; - - hwsec = queue_logical_block_size(req->q) >> KERNEL_SECTOR_SHIFT; - memset(cmd, 0, 10); - - sgl_offset = SGL_OFFSET_12; - - msg->u.head[1] = - cpu_to_le32(I2O_CMD_PRIVATE << 24 | HOST_TID << 12 | tid); - - *mptr++ = cpu_to_le32(I2O_VENDOR_DPT << 16 | I2O_CMD_SCSI_EXEC); - *mptr++ = cpu_to_le32(tid); - - /* - * ENABLE_DISCONNECT - * SIMPLE_TAG - * RETURN_SENSE_DATA_IN_REPLY_MESSAGE_FRAME - */ - if (rq_data_dir(req) == READ) { - cmd[0] = READ_10; - scsi_flags = 0x60a0000a; - } else { - cmd[0] = WRITE_10; - scsi_flags = 0xa0a0000a; - } - - *mptr++ = cpu_to_le32(scsi_flags); - - *((u32 *) & cmd[2]) = cpu_to_be32(blk_rq_pos(req) * hwsec); - *((u16 *) & cmd[7]) = cpu_to_be16(blk_rq_sectors(req) * hwsec); - - memcpy(mptr, cmd, 10); - mptr += 4; - *mptr++ = cpu_to_le32(blk_rq_bytes(req)); - } else -#endif - { - msg->u.head[1] = cpu_to_le32(cmd | HOST_TID << 12 | tid); - *mptr++ = cpu_to_le32(ctl_flags); - *mptr++ = cpu_to_le32(blk_rq_bytes(req)); - *mptr++ = - cpu_to_le32((u32) (blk_rq_pos(req) << KERNEL_SECTOR_SHIFT)); - *mptr++ = - cpu_to_le32(blk_rq_pos(req) >> (32 - KERNEL_SECTOR_SHIFT)); - } - - if (!i2o_block_sglist_alloc(c, ireq, &mptr)) { - rc = -ENOMEM; - goto context_remove; - } - - msg->u.head[0] = - cpu_to_le32(I2O_MESSAGE_SIZE(mptr - &msg->u.head[0]) | sgl_offset); - - list_add_tail(&ireq->queue, &dev->open_queue); - dev->open_queue_depth++; - - i2o_msg_post(c, msg); - - return 0; - -context_remove: - i2o_cntxt_list_remove(c, req); - -nop_msg: - i2o_msg_nop(c, msg); - -exit: - return rc; -}; - -/** - * i2o_block_request_fn - request queue handling function - * @q: request queue from which the request could be fetched - * - * Takes the next request from the queue, transfers it and if no error - * occurs dequeue it from the queue. On arrival of the reply the message - * will be processed further. If an error occurs requeue the request. - */ -static void i2o_block_request_fn(struct request_queue *q) -{ - struct request *req; - - while ((req = blk_peek_request(q)) != NULL) { - if (req->cmd_type == REQ_TYPE_FS) { - struct i2o_block_delayed_request *dreq; - struct i2o_block_request *ireq = req->special; - unsigned int queue_depth; - - queue_depth = ireq->i2o_blk_dev->open_queue_depth; - - if (queue_depth < I2O_BLOCK_MAX_OPEN_REQUESTS) { - if (!i2o_block_transfer(req)) { - blk_start_request(req); - continue; - } else - osm_info("transfer error\n"); - } - - if (queue_depth) - break; - - /* stop the queue and retry later */ - dreq = kmalloc(sizeof(*dreq), GFP_ATOMIC); - if (!dreq) - continue; - - dreq->queue = q; - INIT_DELAYED_WORK(&dreq->work, - i2o_block_delayed_request_fn); - - if (!queue_delayed_work(i2o_block_driver.event_queue, - &dreq->work, - I2O_BLOCK_RETRY_TIME)) - kfree(dreq); - else { - blk_stop_queue(q); - break; - } - } else { - blk_start_request(req); - __blk_end_request_all(req, -EIO); - } - } -}; - -/* I2O Block device operations definition */ -static const struct block_device_operations i2o_block_fops = { - .owner = THIS_MODULE, - .open = i2o_block_open, - .release = i2o_block_release, - .ioctl = i2o_block_ioctl, - .compat_ioctl = i2o_block_ioctl, - .getgeo = i2o_block_getgeo, - .check_events = i2o_block_check_events, -}; - -/** - * i2o_block_device_alloc - Allocate memory for a I2O Block device - * - * Allocate memory for the i2o_block_device struct, gendisk and request - * queue and initialize them as far as no additional information is needed. - * - * Returns a pointer to the allocated I2O Block device on success or a - * negative error code on failure. - */ -static struct i2o_block_device *i2o_block_device_alloc(void) -{ - struct i2o_block_device *dev; - struct gendisk *gd; - struct request_queue *queue; - int rc; - - dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (!dev) { - osm_err("Insufficient memory to allocate I2O Block disk.\n"); - rc = -ENOMEM; - goto exit; - } - - INIT_LIST_HEAD(&dev->open_queue); - spin_lock_init(&dev->lock); - dev->rcache = CACHE_PREFETCH; - dev->wcache = CACHE_WRITEBACK; - - /* allocate a gendisk with 16 partitions */ - gd = alloc_disk(16); - if (!gd) { - osm_err("Insufficient memory to allocate gendisk.\n"); - rc = -ENOMEM; - goto cleanup_dev; - } - - /* initialize the request queue */ - queue = blk_init_queue(i2o_block_request_fn, &dev->lock); - if (!queue) { - osm_err("Insufficient memory to allocate request queue.\n"); - rc = -ENOMEM; - goto cleanup_queue; - } - - blk_queue_prep_rq(queue, i2o_block_prep_req_fn); - - gd->major = I2O_MAJOR; - gd->queue = queue; - gd->fops = &i2o_block_fops; - gd->private_data = dev; - - dev->gd = gd; - - return dev; - -cleanup_queue: - put_disk(gd); - -cleanup_dev: - kfree(dev); - -exit: - return ERR_PTR(rc); -}; - -/** - * i2o_block_probe - verify if dev is a I2O Block device and install it - * @dev: device to verify if it is a I2O Block device - * - * We only verify if the user_tid of the device is 0xfff and then install - * the device. Otherwise it is used by some other device (e. g. RAID). - * - * Returns 0 on success or negative error code on failure. - */ -static int i2o_block_probe(struct device *dev) -{ - struct i2o_device *i2o_dev = to_i2o_device(dev); - struct i2o_controller *c = i2o_dev->iop; - struct i2o_block_device *i2o_blk_dev; - struct gendisk *gd; - struct request_queue *queue; - static int unit; - int rc; - u64 size; - u32 blocksize; - u16 body_size = 4; - u16 power; - unsigned short max_sectors; - -#ifdef CONFIG_I2O_EXT_ADAPTEC - if (c->adaptec) - body_size = 8; -#endif - - if (c->limit_sectors) - max_sectors = I2O_MAX_SECTORS_LIMITED; - else - max_sectors = I2O_MAX_SECTORS; - - /* skip devices which are used by IOP */ - if (i2o_dev->lct_data.user_tid != 0xfff) { - osm_debug("skipping used device %03x\n", i2o_dev->lct_data.tid); - return -ENODEV; - } - - if (i2o_device_claim(i2o_dev)) { - osm_warn("Unable to claim device. Installation aborted\n"); - rc = -EFAULT; - goto exit; - } - - i2o_blk_dev = i2o_block_device_alloc(); - if (IS_ERR(i2o_blk_dev)) { - osm_err("could not alloc a new I2O block device"); - rc = PTR_ERR(i2o_blk_dev); - goto claim_release; - } - - i2o_blk_dev->i2o_dev = i2o_dev; - dev_set_drvdata(dev, i2o_blk_dev); - - /* setup gendisk */ - gd = i2o_blk_dev->gd; - gd->first_minor = unit << 4; - sprintf(gd->disk_name, "i2o/hd%c", 'a' + unit); - gd->driverfs_dev = &i2o_dev->device; - - /* setup request queue */ - queue = gd->queue; - queue->queuedata = i2o_blk_dev; - - blk_queue_max_hw_sectors(queue, max_sectors); - blk_queue_max_segments(queue, i2o_sg_tablesize(c, body_size)); - - osm_debug("max sectors = %d\n", queue->max_sectors); - osm_debug("phys segments = %d\n", queue->max_phys_segments); - osm_debug("max hw segments = %d\n", queue->max_hw_segments); - - /* - * Ask for the current media data. If that isn't supported - * then we ask for the device capacity data - */ - if (!i2o_parm_field_get(i2o_dev, 0x0004, 1, &blocksize, 4) || - !i2o_parm_field_get(i2o_dev, 0x0000, 3, &blocksize, 4)) { - blk_queue_logical_block_size(queue, le32_to_cpu(blocksize)); - } else - osm_warn("unable to get blocksize of %s\n", gd->disk_name); - - if (!i2o_parm_field_get(i2o_dev, 0x0004, 0, &size, 8) || - !i2o_parm_field_get(i2o_dev, 0x0000, 4, &size, 8)) { - set_capacity(gd, le64_to_cpu(size) >> KERNEL_SECTOR_SHIFT); - } else - osm_warn("could not get size of %s\n", gd->disk_name); - - if (!i2o_parm_field_get(i2o_dev, 0x0000, 2, &power, 2)) - i2o_blk_dev->power = power; - - i2o_event_register(i2o_dev, &i2o_block_driver, 0, 0xffffffff); - - add_disk(gd); - - unit++; - - osm_info("device added (TID: %03x): %s\n", i2o_dev->lct_data.tid, - i2o_blk_dev->gd->disk_name); - - return 0; - -claim_release: - i2o_device_claim_release(i2o_dev); - -exit: - return rc; -}; - -/* Block OSM driver struct */ -static struct i2o_driver i2o_block_driver = { - .name = OSM_NAME, - .event = i2o_block_event, - .reply = i2o_block_reply, - .classes = i2o_block_class_id, - .driver = { - .probe = i2o_block_probe, - .remove = i2o_block_remove, - }, -}; - -/** - * i2o_block_init - Block OSM initialization function - * - * Allocate the slab and mempool for request structs, registers i2o_block - * block device and finally register the Block OSM in the I2O core. - * - * Returns 0 on success or negative error code on failure. - */ -static int __init i2o_block_init(void) -{ - int rc; - int size; - - printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n"); - - /* Allocate request mempool and slab */ - size = sizeof(struct i2o_block_request); - i2o_blk_req_pool.slab = kmem_cache_create("i2o_block_req", size, 0, - SLAB_HWCACHE_ALIGN, NULL); - if (!i2o_blk_req_pool.slab) { - osm_err("can't init request slab\n"); - rc = -ENOMEM; - goto exit; - } - - i2o_blk_req_pool.pool = - mempool_create_slab_pool(I2O_BLOCK_REQ_MEMPOOL_SIZE, - i2o_blk_req_pool.slab); - if (!i2o_blk_req_pool.pool) { - osm_err("can't init request mempool\n"); - rc = -ENOMEM; - goto free_slab; - } - - /* Register the block device interfaces */ - rc = register_blkdev(I2O_MAJOR, "i2o_block"); - if (rc) { - osm_err("unable to register block device\n"); - goto free_mempool; - } -#ifdef MODULE - osm_info("registered device at major %d\n", I2O_MAJOR); -#endif - - /* Register Block OSM into I2O core */ - rc = i2o_driver_register(&i2o_block_driver); - if (rc) { - osm_err("Could not register Block driver\n"); - goto unregister_blkdev; - } - - return 0; - -unregister_blkdev: - unregister_blkdev(I2O_MAJOR, "i2o_block"); - -free_mempool: - mempool_destroy(i2o_blk_req_pool.pool); - -free_slab: - kmem_cache_destroy(i2o_blk_req_pool.slab); - -exit: - return rc; -}; - -/** - * i2o_block_exit - Block OSM exit function - * - * Unregisters Block OSM from I2O core, unregisters i2o_block block device - * and frees the mempool and slab. - */ -static void __exit i2o_block_exit(void) -{ - /* Unregister I2O Block OSM from I2O core */ - i2o_driver_unregister(&i2o_block_driver); - - /* Unregister block device */ - unregister_blkdev(I2O_MAJOR, "i2o_block"); - - /* Free request mempool and slab */ - mempool_destroy(i2o_blk_req_pool.pool); - kmem_cache_destroy(i2o_blk_req_pool.slab); -}; - -MODULE_AUTHOR("Red Hat"); -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION(OSM_DESCRIPTION); -MODULE_VERSION(OSM_VERSION); - -module_init(i2o_block_init); -module_exit(i2o_block_exit); diff --git a/drivers/staging/i2o/i2o_block.h b/drivers/staging/i2o/i2o_block.h deleted file mode 100644 index cf8873cbca3f..000000000000 --- a/drivers/staging/i2o/i2o_block.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Block OSM structures/API - * - * Copyright (C) 1999-2002 Red Hat Software - * - * Written by Alan Cox, Building Number Three Ltd - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * For the purpose of avoiding doubt the preferred form of the work - * for making modifications shall be a standards compliant form such - * gzipped tar and not one requiring a proprietary or patent encumbered - * tool to unpack. - * - * Fixes/additions: - * Steve Ralston: - * Multiple device handling error fixes, - * Added a queue depth. - * Alan Cox: - * FC920 has an rmw bug. Dont or in the end marker. - * Removed queue walk, fixed for 64bitness. - * Rewrote much of the code over time - * Added indirect block lists - * Handle 64K limits on many controllers - * Don't use indirects on the Promise (breaks) - * Heavily chop down the queue depths - * Deepak Saxena: - * Independent queues per IOP - * Support for dynamic device creation/deletion - * Code cleanup - * Support for larger I/Os through merge* functions - * (taken from DAC960 driver) - * Boji T Kannanthanam: - * Set the I2O Block devices to be detected in increasing - * order of TIDs during boot. - * Search and set the I2O block device that we boot off - * from as the first device to be claimed (as /dev/i2o/hda) - * Properly attach/detach I2O gendisk structure from the - * system gendisk list. The I2O block devices now appear in - * /proc/partitions. - * Markus Lidel : - * Minor bugfixes for 2.6. - */ - -#ifndef I2O_BLOCK_OSM_H -#define I2O_BLOCK_OSM_H - -#define I2O_BLOCK_RETRY_TIME HZ/4 -#define I2O_BLOCK_MAX_OPEN_REQUESTS 50 - -/* request queue sizes */ -#define I2O_BLOCK_REQ_MEMPOOL_SIZE 32 - -#define KERNEL_SECTOR_SHIFT 9 -#define KERNEL_SECTOR_SIZE (1 << KERNEL_SECTOR_SHIFT) - -/* I2O Block OSM mempool struct */ -struct i2o_block_mempool { - struct kmem_cache *slab; - mempool_t *pool; -}; - -/* I2O Block device descriptor */ -struct i2o_block_device { - struct i2o_device *i2o_dev; /* pointer to I2O device */ - struct gendisk *gd; - spinlock_t lock; /* queue lock */ - struct list_head open_queue; /* list of transferred, but unfinished - requests */ - unsigned int open_queue_depth; /* number of requests in the queue */ - - int rcache; /* read cache flags */ - int wcache; /* write cache flags */ - int flags; - u16 power; /* power state */ - int media_change_flag; /* media changed flag */ -}; - -/* I2O Block device request */ -struct i2o_block_request { - struct list_head queue; - struct request *req; /* corresponding request */ - struct i2o_block_device *i2o_blk_dev; /* I2O block device */ - struct device *dev; /* device used for DMA */ - int sg_nents; /* number of SG elements */ - struct scatterlist sg_table[I2O_MAX_PHYS_SEGMENTS]; /* SG table */ -}; - -/* I2O Block device delayed request */ -struct i2o_block_delayed_request { - struct delayed_work work; - struct request_queue *queue; -}; - -#endif diff --git a/drivers/staging/i2o/i2o_config.c b/drivers/staging/i2o/i2o_config.c deleted file mode 100644 index cd7ca5eb18ff..000000000000 --- a/drivers/staging/i2o/i2o_config.c +++ /dev/null @@ -1,1162 +0,0 @@ -/* - * I2O Configuration Interface Driver - * - * (C) Copyright 1999-2002 Red Hat - * - * Written by Alan Cox, Building Number Three Ltd - * - * Fixes/additions: - * Deepak Saxena (04/20/1999): - * Added basic ioctl() support - * Deepak Saxena (06/07/1999): - * Added software download ioctl (still testing) - * Auvo Häkkinen (09/10/1999): - * Changes to i2o_cfg_reply(), ioctl_parms() - * Added ioct_validate() - * Taneli Vähäkangas (09/30/1999): - * Fixed ioctl_swdl() - * Taneli Vähäkangas (10/04/1999): - * Changed ioctl_swdl(), implemented ioctl_swul() and ioctl_swdel() - * Deepak Saxena (11/18/1999): - * Added event managmenet support - * Alan Cox : - * 2.4 rewrite ported to 2.5 - * Markus Lidel : - * Added pass-thru support for Adaptec's raidutils - * - * 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. - */ - -#include -#include -#include -#include -#include - -#include "core.h" - -#define SG_TABLESIZE 30 - -static DEFINE_MUTEX(i2o_cfg_mutex); -static long i2o_cfg_ioctl(struct file *, unsigned int, unsigned long); - -static spinlock_t i2o_config_lock; - -#define MODINC(x,y) ((x) = ((x) + 1) % (y)) - -struct sg_simple_element { - u32 flag_count; - u32 addr_bus; -}; - -struct i2o_cfg_info { - struct file *fp; - struct fasync_struct *fasync; - struct i2o_evt_info event_q[I2O_EVT_Q_LEN]; - u16 q_in; // Queue head index - u16 q_out; // Queue tail index - u16 q_len; // Queue length - u16 q_lost; // Number of lost events - ulong q_id; // Event queue ID...used as tx_context - struct i2o_cfg_info *next; -}; -static struct i2o_cfg_info *open_files = NULL; -static ulong i2o_cfg_info_id; - -static int i2o_cfg_getiops(unsigned long arg) -{ - struct i2o_controller *c; - u8 __user *user_iop_table = (void __user *)arg; - u8 tmp[MAX_I2O_CONTROLLERS]; - int ret = 0; - - memset(tmp, 0, MAX_I2O_CONTROLLERS); - - list_for_each_entry(c, &i2o_controllers, list) - tmp[c->unit] = 1; - - if (copy_to_user(user_iop_table, tmp, MAX_I2O_CONTROLLERS)) - ret = -EFAULT; - - return ret; -}; - -static int i2o_cfg_gethrt(unsigned long arg) -{ - struct i2o_controller *c; - struct i2o_cmd_hrtlct __user *cmd = (struct i2o_cmd_hrtlct __user *)arg; - struct i2o_cmd_hrtlct kcmd; - i2o_hrt *hrt; - int len; - u32 reslen; - int ret = 0; - - if (copy_from_user(&kcmd, cmd, sizeof(struct i2o_cmd_hrtlct))) - return -EFAULT; - - if (get_user(reslen, kcmd.reslen) < 0) - return -EFAULT; - - if (kcmd.resbuf == NULL) - return -EFAULT; - - c = i2o_find_iop(kcmd.iop); - if (!c) - return -ENXIO; - - hrt = (i2o_hrt *) c->hrt.virt; - - len = 8 + ((hrt->entry_len * hrt->num_entries) << 2); - - if (put_user(len, kcmd.reslen)) - ret = -EFAULT; - else if (len > reslen) - ret = -ENOBUFS; - else if (copy_to_user(kcmd.resbuf, (void *)hrt, len)) - ret = -EFAULT; - - return ret; -}; - -static int i2o_cfg_getlct(unsigned long arg) -{ - struct i2o_controller *c; - struct i2o_cmd_hrtlct __user *cmd = (struct i2o_cmd_hrtlct __user *)arg; - struct i2o_cmd_hrtlct kcmd; - i2o_lct *lct; - int len; - int ret = 0; - u32 reslen; - - if (copy_from_user(&kcmd, cmd, sizeof(struct i2o_cmd_hrtlct))) - return -EFAULT; - - if (get_user(reslen, kcmd.reslen) < 0) - return -EFAULT; - - if (kcmd.resbuf == NULL) - return -EFAULT; - - c = i2o_find_iop(kcmd.iop); - if (!c) - return -ENXIO; - - lct = (i2o_lct *) c->lct; - - len = (unsigned int)lct->table_size << 2; - if (put_user(len, kcmd.reslen)) - ret = -EFAULT; - else if (len > reslen) - ret = -ENOBUFS; - else if (copy_to_user(kcmd.resbuf, lct, len)) - ret = -EFAULT; - - return ret; -}; - -static int i2o_cfg_parms(unsigned long arg, unsigned int type) -{ - int ret = 0; - struct i2o_controller *c; - struct i2o_device *dev; - struct i2o_cmd_psetget __user *cmd = - (struct i2o_cmd_psetget __user *)arg; - struct i2o_cmd_psetget kcmd; - u32 reslen; - u8 *ops; - u8 *res; - int len = 0; - - u32 i2o_cmd = (type == I2OPARMGET ? - I2O_CMD_UTIL_PARAMS_GET : I2O_CMD_UTIL_PARAMS_SET); - - if (copy_from_user(&kcmd, cmd, sizeof(struct i2o_cmd_psetget))) - return -EFAULT; - - if (get_user(reslen, kcmd.reslen)) - return -EFAULT; - - c = i2o_find_iop(kcmd.iop); - if (!c) - return -ENXIO; - - dev = i2o_iop_find_device(c, kcmd.tid); - if (!dev) - return -ENXIO; - - /* - * Stop users being able to try and allocate arbitrary amounts - * of DMA space. 64K is way more than sufficient for this. - */ - if (kcmd.oplen > 65536) - return -EMSGSIZE; - - ops = memdup_user(kcmd.opbuf, kcmd.oplen); - if (IS_ERR(ops)) - return PTR_ERR(ops); - - /* - * It's possible to have a _very_ large table - * and that the user asks for all of it at once... - */ - res = kmalloc(65536, GFP_KERNEL); - if (!res) { - kfree(ops); - return -ENOMEM; - } - - len = i2o_parm_issue(dev, i2o_cmd, ops, kcmd.oplen, res, 65536); - kfree(ops); - - if (len < 0) { - kfree(res); - return -EAGAIN; - } - - if (put_user(len, kcmd.reslen)) - ret = -EFAULT; - else if (len > reslen) - ret = -ENOBUFS; - else if (copy_to_user(kcmd.resbuf, res, len)) - ret = -EFAULT; - - kfree(res); - - return ret; -}; - -static int i2o_cfg_swdl(unsigned long arg) -{ - struct i2o_sw_xfer kxfer; - struct i2o_sw_xfer __user *pxfer = (struct i2o_sw_xfer __user *)arg; - unsigned char maxfrag = 0, curfrag = 1; - struct i2o_dma buffer; - struct i2o_message *msg; - unsigned int status = 0, swlen = 0, fragsize = 8192; - struct i2o_controller *c; - - if (copy_from_user(&kxfer, pxfer, sizeof(struct i2o_sw_xfer))) - return -EFAULT; - - if (get_user(swlen, kxfer.swlen) < 0) - return -EFAULT; - - if (get_user(maxfrag, kxfer.maxfrag) < 0) - return -EFAULT; - - if (get_user(curfrag, kxfer.curfrag) < 0) - return -EFAULT; - - if (curfrag == maxfrag) - fragsize = swlen - (maxfrag - 1) * 8192; - - if (!kxfer.buf || !access_ok(VERIFY_READ, kxfer.buf, fragsize)) - return -EFAULT; - - c = i2o_find_iop(kxfer.iop); - if (!c) - return -ENXIO; - - msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - if (i2o_dma_alloc(&c->pdev->dev, &buffer, fragsize)) { - i2o_msg_nop(c, msg); - return -ENOMEM; - } - - if (__copy_from_user(buffer.virt, kxfer.buf, fragsize)) { - i2o_msg_nop(c, msg); - i2o_dma_free(&c->pdev->dev, &buffer); - return -EFAULT; - } - - msg->u.head[0] = cpu_to_le32(NINE_WORD_MSG_SIZE | SGL_OFFSET_7); - msg->u.head[1] = - cpu_to_le32(I2O_CMD_SW_DOWNLOAD << 24 | HOST_TID << 12 | - ADAPTER_TID); - msg->u.head[2] = cpu_to_le32(i2o_config_driver.context); - msg->u.head[3] = cpu_to_le32(0); - msg->body[0] = - cpu_to_le32((((u32) kxfer.flags) << 24) | (((u32) kxfer. - sw_type) << 16) | - (((u32) maxfrag) << 8) | (((u32) curfrag))); - msg->body[1] = cpu_to_le32(swlen); - msg->body[2] = cpu_to_le32(kxfer.sw_id); - msg->body[3] = cpu_to_le32(0xD0000000 | fragsize); - msg->body[4] = cpu_to_le32(buffer.phys); - - osm_debug("swdl frag %d/%d (size %d)\n", curfrag, maxfrag, fragsize); - status = i2o_msg_post_wait_mem(c, msg, 60, &buffer); - - if (status != -ETIMEDOUT) - i2o_dma_free(&c->pdev->dev, &buffer); - - if (status != I2O_POST_WAIT_OK) { - // it fails if you try and send frags out of order - // and for some yet unknown reasons too - osm_info("swdl failed, DetailedStatus = %d\n", status); - return status; - } - - return 0; -}; - -static int i2o_cfg_swul(unsigned long arg) -{ - struct i2o_sw_xfer kxfer; - struct i2o_sw_xfer __user *pxfer = (struct i2o_sw_xfer __user *)arg; - unsigned char maxfrag = 0, curfrag = 1; - struct i2o_dma buffer; - struct i2o_message *msg; - unsigned int status = 0, swlen = 0, fragsize = 8192; - struct i2o_controller *c; - int ret = 0; - - if (copy_from_user(&kxfer, pxfer, sizeof(struct i2o_sw_xfer))) - return -EFAULT; - - if (get_user(swlen, kxfer.swlen) < 0) - return -EFAULT; - - if (get_user(maxfrag, kxfer.maxfrag) < 0) - return -EFAULT; - - if (get_user(curfrag, kxfer.curfrag) < 0) - return -EFAULT; - - if (curfrag == maxfrag) - fragsize = swlen - (maxfrag - 1) * 8192; - - if (!kxfer.buf) - return -EFAULT; - - c = i2o_find_iop(kxfer.iop); - if (!c) - return -ENXIO; - - msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - if (i2o_dma_alloc(&c->pdev->dev, &buffer, fragsize)) { - i2o_msg_nop(c, msg); - return -ENOMEM; - } - - msg->u.head[0] = cpu_to_le32(NINE_WORD_MSG_SIZE | SGL_OFFSET_7); - msg->u.head[1] = - cpu_to_le32(I2O_CMD_SW_UPLOAD << 24 | HOST_TID << 12 | ADAPTER_TID); - msg->u.head[2] = cpu_to_le32(i2o_config_driver.context); - msg->u.head[3] = cpu_to_le32(0); - msg->body[0] = - cpu_to_le32((u32) kxfer.flags << 24 | (u32) kxfer. - sw_type << 16 | (u32) maxfrag << 8 | (u32) curfrag); - msg->body[1] = cpu_to_le32(swlen); - msg->body[2] = cpu_to_le32(kxfer.sw_id); - msg->body[3] = cpu_to_le32(0xD0000000 | fragsize); - msg->body[4] = cpu_to_le32(buffer.phys); - - osm_debug("swul frag %d/%d (size %d)\n", curfrag, maxfrag, fragsize); - status = i2o_msg_post_wait_mem(c, msg, 60, &buffer); - - if (status != I2O_POST_WAIT_OK) { - if (status != -ETIMEDOUT) - i2o_dma_free(&c->pdev->dev, &buffer); - - osm_info("swul failed, DetailedStatus = %d\n", status); - return status; - } - - if (copy_to_user(kxfer.buf, buffer.virt, fragsize)) - ret = -EFAULT; - - i2o_dma_free(&c->pdev->dev, &buffer); - - return ret; -} - -static int i2o_cfg_swdel(unsigned long arg) -{ - struct i2o_controller *c; - struct i2o_sw_xfer kxfer; - struct i2o_sw_xfer __user *pxfer = (struct i2o_sw_xfer __user *)arg; - struct i2o_message *msg; - unsigned int swlen; - int token; - - if (copy_from_user(&kxfer, pxfer, sizeof(struct i2o_sw_xfer))) - return -EFAULT; - - if (get_user(swlen, kxfer.swlen) < 0) - return -EFAULT; - - c = i2o_find_iop(kxfer.iop); - if (!c) - return -ENXIO; - - msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->u.head[0] = cpu_to_le32(SEVEN_WORD_MSG_SIZE | SGL_OFFSET_0); - msg->u.head[1] = - cpu_to_le32(I2O_CMD_SW_REMOVE << 24 | HOST_TID << 12 | ADAPTER_TID); - msg->u.head[2] = cpu_to_le32(i2o_config_driver.context); - msg->u.head[3] = cpu_to_le32(0); - msg->body[0] = - cpu_to_le32((u32) kxfer.flags << 24 | (u32) kxfer.sw_type << 16); - msg->body[1] = cpu_to_le32(swlen); - msg->body[2] = cpu_to_le32(kxfer.sw_id); - - token = i2o_msg_post_wait(c, msg, 10); - - if (token != I2O_POST_WAIT_OK) { - osm_info("swdel failed, DetailedStatus = %d\n", token); - return -ETIMEDOUT; - } - - return 0; -}; - -static int i2o_cfg_validate(unsigned long arg) -{ - int token; - int iop = (int)arg; - struct i2o_message *msg; - struct i2o_controller *c; - - c = i2o_find_iop(iop); - if (!c) - return -ENXIO; - - msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0); - msg->u.head[1] = - cpu_to_le32(I2O_CMD_CONFIG_VALIDATE << 24 | HOST_TID << 12 | iop); - msg->u.head[2] = cpu_to_le32(i2o_config_driver.context); - msg->u.head[3] = cpu_to_le32(0); - - token = i2o_msg_post_wait(c, msg, 10); - - if (token != I2O_POST_WAIT_OK) { - osm_info("Can't validate configuration, ErrorStatus = %d\n", - token); - return -ETIMEDOUT; - } - - return 0; -}; - -static int i2o_cfg_evt_reg(unsigned long arg, struct file *fp) -{ - struct i2o_message *msg; - struct i2o_evt_id __user *pdesc = (struct i2o_evt_id __user *)arg; - struct i2o_evt_id kdesc; - struct i2o_controller *c; - struct i2o_device *d; - - if (copy_from_user(&kdesc, pdesc, sizeof(struct i2o_evt_id))) - return -EFAULT; - - /* IOP exists? */ - c = i2o_find_iop(kdesc.iop); - if (!c) - return -ENXIO; - - /* Device exists? */ - d = i2o_iop_find_device(c, kdesc.tid); - if (!d) - return -ENODEV; - - msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0); - msg->u.head[1] = - cpu_to_le32(I2O_CMD_UTIL_EVT_REGISTER << 24 | HOST_TID << 12 | - kdesc.tid); - msg->u.head[2] = cpu_to_le32(i2o_config_driver.context); - msg->u.head[3] = cpu_to_le32(i2o_cntxt_list_add(c, fp->private_data)); - msg->body[0] = cpu_to_le32(kdesc.evt_mask); - - i2o_msg_post(c, msg); - - return 0; -} - -static int i2o_cfg_evt_get(unsigned long arg, struct file *fp) -{ - struct i2o_cfg_info *p = NULL; - struct i2o_evt_get __user *uget = (struct i2o_evt_get __user *)arg; - struct i2o_evt_get kget; - unsigned long flags; - - for (p = open_files; p; p = p->next) - if (p->q_id == (ulong) fp->private_data) - break; - - if (!p->q_len) - return -ENOENT; - - memcpy(&kget.info, &p->event_q[p->q_out], sizeof(struct i2o_evt_info)); - MODINC(p->q_out, I2O_EVT_Q_LEN); - spin_lock_irqsave(&i2o_config_lock, flags); - p->q_len--; - kget.pending = p->q_len; - kget.lost = p->q_lost; - spin_unlock_irqrestore(&i2o_config_lock, flags); - - if (copy_to_user(uget, &kget, sizeof(struct i2o_evt_get))) - return -EFAULT; - return 0; -} - -#ifdef CONFIG_COMPAT -static int i2o_cfg_passthru32(struct file *file, unsigned cmnd, - unsigned long arg) -{ - struct i2o_cmd_passthru32 __user *cmd; - struct i2o_controller *c; - u32 __user *user_msg; - u32 *reply = NULL; - u32 __user *user_reply = NULL; - u32 size = 0; - u32 reply_size = 0; - u32 rcode = 0; - struct i2o_dma sg_list[SG_TABLESIZE]; - u32 sg_offset = 0; - u32 sg_count = 0; - u32 i = 0; - u32 sg_index = 0; - i2o_status_block *sb; - struct i2o_message *msg; - unsigned int iop; - - cmd = (struct i2o_cmd_passthru32 __user *)arg; - - if (get_user(iop, &cmd->iop) || get_user(i, &cmd->msg)) - return -EFAULT; - - user_msg = compat_ptr(i); - - c = i2o_find_iop(iop); - if (!c) { - osm_debug("controller %d not found\n", iop); - return -ENXIO; - } - - sb = c->status_block.virt; - - if (get_user(size, &user_msg[0])) { - osm_warn("unable to get size!\n"); - return -EFAULT; - } - size = size >> 16; - - if (size > sb->inbound_frame_size) { - osm_warn("size of message > inbound_frame_size"); - return -EFAULT; - } - - user_reply = &user_msg[size]; - - size <<= 2; // Convert to bytes - - msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - rcode = -EFAULT; - /* Copy in the user's I2O command */ - if (copy_from_user(msg, user_msg, size)) { - osm_warn("unable to copy user message\n"); - goto out; - } - i2o_dump_message(msg); - - if (get_user(reply_size, &user_reply[0]) < 0) - goto out; - - reply_size >>= 16; - reply_size <<= 2; - - rcode = -ENOMEM; - reply = kzalloc(reply_size, GFP_KERNEL); - if (!reply) { - printk(KERN_WARNING "%s: Could not allocate reply buffer\n", - c->name); - goto out; - } - - sg_offset = (msg->u.head[0] >> 4) & 0x0f; - - memset(sg_list, 0, sizeof(sg_list[0]) * SG_TABLESIZE); - if (sg_offset) { - struct sg_simple_element *sg; - - if (sg_offset * 4 >= size) { - rcode = -EFAULT; - goto cleanup; - } - // TODO 64bit fix - sg = (struct sg_simple_element *)((&msg->u.head[0]) + - sg_offset); - sg_count = - (size - sg_offset * 4) / sizeof(struct sg_simple_element); - if (sg_count > SG_TABLESIZE) { - printk(KERN_DEBUG "%s:IOCTL SG List too large (%u)\n", - c->name, sg_count); - rcode = -EINVAL; - goto cleanup; - } - - for (i = 0; i < sg_count; i++) { - int sg_size; - struct i2o_dma *p; - - if (!(sg[i].flag_count & 0x10000000 - /*I2O_SGL_FLAGS_SIMPLE_ADDRESS_ELEMENT */ )) { - printk(KERN_DEBUG - "%s:Bad SG element %d - not simple (%x)\n", - c->name, i, sg[i].flag_count); - rcode = -EINVAL; - goto cleanup; - } - sg_size = sg[i].flag_count & 0xffffff; - p = &(sg_list[sg_index]); - /* Allocate memory for the transfer */ - if (i2o_dma_alloc(&c->pdev->dev, p, sg_size)) { - printk(KERN_DEBUG - "%s: Could not allocate SG buffer - size = %d buffer number %d of %d\n", - c->name, sg_size, i, sg_count); - rcode = -ENOMEM; - goto sg_list_cleanup; - } - sg_index++; - /* Copy in the user's SG buffer if necessary */ - if (sg[i]. - flag_count & 0x04000000 /*I2O_SGL_FLAGS_DIR */ ) { - // TODO 64bit fix - if (copy_from_user - (p->virt, - (void __user *)(unsigned long)sg[i]. - addr_bus, sg_size)) { - printk(KERN_DEBUG - "%s: Could not copy SG buf %d FROM user\n", - c->name, i); - rcode = -EFAULT; - goto sg_list_cleanup; - } - } - //TODO 64bit fix - sg[i].addr_bus = (u32) p->phys; - } - } - - rcode = i2o_msg_post_wait(c, msg, 60); - msg = NULL; - if (rcode) { - reply[4] = ((u32) rcode) << 24; - goto sg_list_cleanup; - } - - if (sg_offset) { - u32 rmsg[I2O_OUTBOUND_MSG_FRAME_SIZE]; - /* Copy back the Scatter Gather buffers back to user space */ - u32 j; - // TODO 64bit fix - struct sg_simple_element *sg; - int sg_size; - - // re-acquire the original message to handle correctly the sg copy operation - memset(&rmsg, 0, I2O_OUTBOUND_MSG_FRAME_SIZE * 4); - // get user msg size in u32s - if (get_user(size, &user_msg[0])) { - rcode = -EFAULT; - goto sg_list_cleanup; - } - size = size >> 16; - size *= 4; - if (size > sizeof(rmsg)) { - rcode = -EINVAL; - goto sg_list_cleanup; - } - - /* Copy in the user's I2O command */ - if (copy_from_user(rmsg, user_msg, size)) { - rcode = -EFAULT; - goto sg_list_cleanup; - } - sg_count = - (size - sg_offset * 4) / sizeof(struct sg_simple_element); - - // TODO 64bit fix - sg = (struct sg_simple_element *)(rmsg + sg_offset); - for (j = 0; j < sg_count; j++) { - /* Copy out the SG list to user's buffer if necessary */ - if (! - (sg[j]. - flag_count & 0x4000000 /*I2O_SGL_FLAGS_DIR */ )) { - sg_size = sg[j].flag_count & 0xffffff; - // TODO 64bit fix - if (copy_to_user - ((void __user *)(u64) sg[j].addr_bus, - sg_list[j].virt, sg_size)) { - printk(KERN_WARNING - "%s: Could not copy %p TO user %x\n", - c->name, sg_list[j].virt, - sg[j].addr_bus); - rcode = -EFAULT; - goto sg_list_cleanup; - } - } - } - } - -sg_list_cleanup: - /* Copy back the reply to user space */ - if (reply_size) { - // we wrote our own values for context - now restore the user supplied ones - if (copy_from_user(reply + 2, user_msg + 2, sizeof(u32) * 2)) { - printk(KERN_WARNING - "%s: Could not copy message context FROM user\n", - c->name); - rcode = -EFAULT; - } - if (copy_to_user(user_reply, reply, reply_size)) { - printk(KERN_WARNING - "%s: Could not copy reply TO user\n", c->name); - rcode = -EFAULT; - } - } - for (i = 0; i < sg_index; i++) - i2o_dma_free(&c->pdev->dev, &sg_list[i]); - -cleanup: - kfree(reply); -out: - if (msg) - i2o_msg_nop(c, msg); - return rcode; -} - -static long i2o_cfg_compat_ioctl(struct file *file, unsigned cmd, - unsigned long arg) -{ - int ret; - switch (cmd) { - case I2OGETIOPS: - ret = i2o_cfg_ioctl(file, cmd, arg); - break; - case I2OPASSTHRU32: - mutex_lock(&i2o_cfg_mutex); - ret = i2o_cfg_passthru32(file, cmd, arg); - mutex_unlock(&i2o_cfg_mutex); - break; - default: - ret = -ENOIOCTLCMD; - break; - } - return ret; -} - -#endif - -#ifdef CONFIG_I2O_EXT_ADAPTEC -static int i2o_cfg_passthru(unsigned long arg) -{ - struct i2o_cmd_passthru __user *cmd = - (struct i2o_cmd_passthru __user *)arg; - struct i2o_controller *c; - u32 __user *user_msg; - u32 *reply = NULL; - u32 __user *user_reply = NULL; - u32 size = 0; - u32 reply_size = 0; - u32 rcode = 0; - struct i2o_dma sg_list[SG_TABLESIZE]; - u32 sg_offset = 0; - u32 sg_count = 0; - int sg_index = 0; - u32 i = 0; - i2o_status_block *sb; - struct i2o_message *msg; - unsigned int iop; - - if (get_user(iop, &cmd->iop) || get_user(user_msg, &cmd->msg)) - return -EFAULT; - - c = i2o_find_iop(iop); - if (!c) { - osm_warn("controller %d not found\n", iop); - return -ENXIO; - } - - sb = c->status_block.virt; - - if (get_user(size, &user_msg[0])) - return -EFAULT; - size = size >> 16; - - if (size > sb->inbound_frame_size) { - osm_warn("size of message > inbound_frame_size"); - return -EFAULT; - } - - user_reply = &user_msg[size]; - - size <<= 2; // Convert to bytes - - msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - rcode = -EFAULT; - /* Copy in the user's I2O command */ - if (copy_from_user(msg, user_msg, size)) - goto out; - - if (get_user(reply_size, &user_reply[0]) < 0) - goto out; - - reply_size >>= 16; - reply_size <<= 2; - - reply = kzalloc(reply_size, GFP_KERNEL); - if (!reply) { - printk(KERN_WARNING "%s: Could not allocate reply buffer\n", - c->name); - rcode = -ENOMEM; - goto out; - } - - sg_offset = (msg->u.head[0] >> 4) & 0x0f; - - memset(sg_list, 0, sizeof(sg_list[0]) * SG_TABLESIZE); - if (sg_offset) { - struct sg_simple_element *sg; - struct i2o_dma *p; - - if (sg_offset * 4 >= size) { - rcode = -EFAULT; - goto cleanup; - } - // TODO 64bit fix - sg = (struct sg_simple_element *)((&msg->u.head[0]) + - sg_offset); - sg_count = - (size - sg_offset * 4) / sizeof(struct sg_simple_element); - if (sg_count > SG_TABLESIZE) { - printk(KERN_DEBUG "%s:IOCTL SG List too large (%u)\n", - c->name, sg_count); - rcode = -EINVAL; - goto cleanup; - } - - for (i = 0; i < sg_count; i++) { - int sg_size; - - if (!(sg[i].flag_count & 0x10000000 - /*I2O_SGL_FLAGS_SIMPLE_ADDRESS_ELEMENT */ )) { - printk(KERN_DEBUG - "%s:Bad SG element %d - not simple (%x)\n", - c->name, i, sg[i].flag_count); - rcode = -EINVAL; - goto sg_list_cleanup; - } - sg_size = sg[i].flag_count & 0xffffff; - p = &(sg_list[sg_index]); - if (i2o_dma_alloc(&c->pdev->dev, p, sg_size)) { - /* Allocate memory for the transfer */ - printk(KERN_DEBUG - "%s: Could not allocate SG buffer - size = %d buffer number %d of %d\n", - c->name, sg_size, i, sg_count); - rcode = -ENOMEM; - goto sg_list_cleanup; - } - sg_index++; - /* Copy in the user's SG buffer if necessary */ - if (sg[i]. - flag_count & 0x04000000 /*I2O_SGL_FLAGS_DIR */ ) { - // TODO 64bit fix - if (copy_from_user - (p->virt, (void __user *)sg[i].addr_bus, - sg_size)) { - printk(KERN_DEBUG - "%s: Could not copy SG buf %d FROM user\n", - c->name, i); - rcode = -EFAULT; - goto sg_list_cleanup; - } - } - sg[i].addr_bus = p->phys; - } - } - - rcode = i2o_msg_post_wait(c, msg, 60); - msg = NULL; - if (rcode) { - reply[4] = ((u32) rcode) << 24; - goto sg_list_cleanup; - } - - if (sg_offset) { - u32 rmsg[I2O_OUTBOUND_MSG_FRAME_SIZE]; - /* Copy back the Scatter Gather buffers back to user space */ - u32 j; - // TODO 64bit fix - struct sg_simple_element *sg; - int sg_size; - - // re-acquire the original message to handle correctly the sg copy operation - memset(&rmsg, 0, I2O_OUTBOUND_MSG_FRAME_SIZE * 4); - // get user msg size in u32s - if (get_user(size, &user_msg[0])) { - rcode = -EFAULT; - goto sg_list_cleanup; - } - size = size >> 16; - size *= 4; - if (size > sizeof(rmsg)) { - rcode = -EFAULT; - goto sg_list_cleanup; - } - - /* Copy in the user's I2O command */ - if (copy_from_user(rmsg, user_msg, size)) { - rcode = -EFAULT; - goto sg_list_cleanup; - } - sg_count = - (size - sg_offset * 4) / sizeof(struct sg_simple_element); - - // TODO 64bit fix - sg = (struct sg_simple_element *)(rmsg + sg_offset); - for (j = 0; j < sg_count; j++) { - /* Copy out the SG list to user's buffer if necessary */ - if (! - (sg[j]. - flag_count & 0x4000000 /*I2O_SGL_FLAGS_DIR */ )) { - sg_size = sg[j].flag_count & 0xffffff; - // TODO 64bit fix - if (copy_to_user - ((void __user *)sg[j].addr_bus, sg_list[j].virt, - sg_size)) { - printk(KERN_WARNING - "%s: Could not copy %p TO user %x\n", - c->name, sg_list[j].virt, - sg[j].addr_bus); - rcode = -EFAULT; - goto sg_list_cleanup; - } - } - } - } - -sg_list_cleanup: - /* Copy back the reply to user space */ - if (reply_size) { - // we wrote our own values for context - now restore the user supplied ones - if (copy_from_user(reply + 2, user_msg + 2, sizeof(u32) * 2)) { - printk(KERN_WARNING - "%s: Could not copy message context FROM user\n", - c->name); - rcode = -EFAULT; - } - if (copy_to_user(user_reply, reply, reply_size)) { - printk(KERN_WARNING - "%s: Could not copy reply TO user\n", c->name); - rcode = -EFAULT; - } - } - - for (i = 0; i < sg_index; i++) - i2o_dma_free(&c->pdev->dev, &sg_list[i]); - -cleanup: - kfree(reply); -out: - if (msg) - i2o_msg_nop(c, msg); - return rcode; -} -#endif - -/* - * IOCTL Handler - */ -static long i2o_cfg_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) -{ - int ret; - - mutex_lock(&i2o_cfg_mutex); - switch (cmd) { - case I2OGETIOPS: - ret = i2o_cfg_getiops(arg); - break; - - case I2OHRTGET: - ret = i2o_cfg_gethrt(arg); - break; - - case I2OLCTGET: - ret = i2o_cfg_getlct(arg); - break; - - case I2OPARMSET: - ret = i2o_cfg_parms(arg, I2OPARMSET); - break; - - case I2OPARMGET: - ret = i2o_cfg_parms(arg, I2OPARMGET); - break; - - case I2OSWDL: - ret = i2o_cfg_swdl(arg); - break; - - case I2OSWUL: - ret = i2o_cfg_swul(arg); - break; - - case I2OSWDEL: - ret = i2o_cfg_swdel(arg); - break; - - case I2OVALIDATE: - ret = i2o_cfg_validate(arg); - break; - - case I2OEVTREG: - ret = i2o_cfg_evt_reg(arg, fp); - break; - - case I2OEVTGET: - ret = i2o_cfg_evt_get(arg, fp); - break; - -#ifdef CONFIG_I2O_EXT_ADAPTEC - case I2OPASSTHRU: - ret = i2o_cfg_passthru(arg); - break; -#endif - - default: - osm_debug("unknown ioctl called!\n"); - ret = -EINVAL; - } - mutex_unlock(&i2o_cfg_mutex); - return ret; -} - -static int cfg_open(struct inode *inode, struct file *file) -{ - struct i2o_cfg_info *tmp = kmalloc(sizeof(struct i2o_cfg_info), - GFP_KERNEL); - unsigned long flags; - - if (!tmp) - return -ENOMEM; - - mutex_lock(&i2o_cfg_mutex); - file->private_data = (void *)(i2o_cfg_info_id++); - tmp->fp = file; - tmp->fasync = NULL; - tmp->q_id = (ulong) file->private_data; - tmp->q_len = 0; - tmp->q_in = 0; - tmp->q_out = 0; - tmp->q_lost = 0; - tmp->next = open_files; - - spin_lock_irqsave(&i2o_config_lock, flags); - open_files = tmp; - spin_unlock_irqrestore(&i2o_config_lock, flags); - mutex_unlock(&i2o_cfg_mutex); - - return 0; -} - -static int cfg_fasync(int fd, struct file *fp, int on) -{ - ulong id = (ulong) fp->private_data; - struct i2o_cfg_info *p; - int ret = -EBADF; - - mutex_lock(&i2o_cfg_mutex); - for (p = open_files; p; p = p->next) - if (p->q_id == id) - break; - - if (p) - ret = fasync_helper(fd, fp, on, &p->fasync); - mutex_unlock(&i2o_cfg_mutex); - return ret; -} - -static int cfg_release(struct inode *inode, struct file *file) -{ - ulong id = (ulong) file->private_data; - struct i2o_cfg_info *p, **q; - unsigned long flags; - - mutex_lock(&i2o_cfg_mutex); - spin_lock_irqsave(&i2o_config_lock, flags); - for (q = &open_files; (p = *q) != NULL; q = &p->next) { - if (p->q_id == id) { - *q = p->next; - kfree(p); - break; - } - } - spin_unlock_irqrestore(&i2o_config_lock, flags); - mutex_unlock(&i2o_cfg_mutex); - - return 0; -} - -static const struct file_operations config_fops = { - .owner = THIS_MODULE, - .llseek = no_llseek, - .unlocked_ioctl = i2o_cfg_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = i2o_cfg_compat_ioctl, -#endif - .open = cfg_open, - .release = cfg_release, - .fasync = cfg_fasync, -}; - -static struct miscdevice i2o_miscdev = { - I2O_MINOR, - "i2octl", - &config_fops -}; - -static int __init i2o_config_old_init(void) -{ - spin_lock_init(&i2o_config_lock); - - if (misc_register(&i2o_miscdev) < 0) { - osm_err("can't register device.\n"); - return -EBUSY; - } - - return 0; -} - -static void i2o_config_old_exit(void) -{ - misc_deregister(&i2o_miscdev); -} - -MODULE_AUTHOR("Red Hat Software"); diff --git a/drivers/staging/i2o/i2o_proc.c b/drivers/staging/i2o/i2o_proc.c deleted file mode 100644 index 780fee3224ea..000000000000 --- a/drivers/staging/i2o/i2o_proc.c +++ /dev/null @@ -1,2049 +0,0 @@ -/* - * procfs handler for Linux I2O subsystem - * - * (c) Copyright 1999 Deepak Saxena - * - * Originally written by Deepak Saxena(deepak@plexity.net) - * - * 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 is an initial test release. The code is based on the design of the - * ide procfs system (drivers/block/ide-proc.c). Some code taken from - * i2o-core module by Alan Cox. - * - * DISCLAIMER: This code is still under development/test and may cause - * your system to behave unpredictably. Use at your own discretion. - * - * - * Fixes/additions: - * Juha Sievänen (Juha.Sievanen@cs.Helsinki.FI), - * Auvo Häkkinen (Auvo.Hakkinen@cs.Helsinki.FI) - * University of Helsinki, Department of Computer Science - * LAN entries - * Markus Lidel - * Changes for new I2O API - */ - -#define OSM_NAME "proc-osm" -#define OSM_VERSION "1.316" -#define OSM_DESCRIPTION "I2O ProcFS OSM" - -#define I2O_MAX_MODULES 4 -// FIXME! -#define FMT_U64_HEX "0x%08x%08x" -#define U64_VAL(pu64) *((u32*)(pu64)+1), *((u32*)(pu64)) - -#include -#include -#include -#include "i2o.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -/* Structure used to define /proc entries */ -typedef struct _i2o_proc_entry_t { - char *name; /* entry name */ - umode_t mode; /* mode */ - const struct file_operations *fops; /* open function */ -} i2o_proc_entry; - -/* global I2O /proc/i2o entry */ -static struct proc_dir_entry *i2o_proc_dir_root; - -/* proc OSM driver struct */ -static struct i2o_driver i2o_proc_driver = { - .name = OSM_NAME, -}; - -static int print_serial_number(struct seq_file *seq, u8 * serialno, int max_len) -{ - int i; - - /* 19990419 -sralston - * The I2O v1.5 (and v2.0 so far) "official specification" - * got serial numbers WRONG! - * Apparently, and despite what Section 3.4.4 says and - * Figure 3-35 shows (pg 3-39 in the pdf doc), - * the convention / consensus seems to be: - * + First byte is SNFormat - * + Second byte is SNLen (but only if SNFormat==7 (?)) - * + (v2.0) SCSI+BS may use IEEE Registered (64 or 128 bit) format - */ - switch (serialno[0]) { - case I2O_SNFORMAT_BINARY: /* Binary */ - seq_printf(seq, "0x"); - for (i = 0; i < serialno[1]; i++) - seq_printf(seq, "%02X", serialno[2 + i]); - break; - - case I2O_SNFORMAT_ASCII: /* ASCII */ - if (serialno[1] < ' ') { /* printable or SNLen? */ - /* sanity */ - max_len = - (max_len < serialno[1]) ? max_len : serialno[1]; - serialno[1 + max_len] = '\0'; - - /* just print it */ - seq_printf(seq, "%s", &serialno[2]); - } else { - /* print chars for specified length */ - for (i = 0; i < serialno[1]; i++) - seq_printf(seq, "%c", serialno[2 + i]); - } - break; - - case I2O_SNFORMAT_UNICODE: /* UNICODE */ - seq_printf(seq, "UNICODE Format. Can't Display\n"); - break; - - case I2O_SNFORMAT_LAN48_MAC: /* LAN-48 MAC Address */ - seq_printf(seq, "LAN-48 MAC address @ %pM", &serialno[2]); - break; - - case I2O_SNFORMAT_WAN: /* WAN MAC Address */ - /* FIXME: Figure out what a WAN access address looks like?? */ - seq_printf(seq, "WAN Access Address"); - break; - -/* plus new in v2.0 */ - case I2O_SNFORMAT_LAN64_MAC: /* LAN-64 MAC Address */ - /* FIXME: Figure out what a LAN-64 address really looks like?? */ - seq_printf(seq, - "LAN-64 MAC address @ [?:%02X:%02X:?] %pM", - serialno[8], serialno[9], &serialno[2]); - break; - - case I2O_SNFORMAT_DDM: /* I2O DDM */ - seq_printf(seq, - "DDM: Tid=%03Xh, Rsvd=%04Xh, OrgId=%04Xh", - *(u16 *) & serialno[2], - *(u16 *) & serialno[4], *(u16 *) & serialno[6]); - break; - - case I2O_SNFORMAT_IEEE_REG64: /* IEEE Registered (64-bit) */ - case I2O_SNFORMAT_IEEE_REG128: /* IEEE Registered (128-bit) */ - /* FIXME: Figure if this is even close?? */ - seq_printf(seq, - "IEEE NodeName(hi,lo)=(%08Xh:%08Xh), PortName(hi,lo)=(%08Xh:%08Xh)\n", - *(u32 *) & serialno[2], - *(u32 *) & serialno[6], - *(u32 *) & serialno[10], *(u32 *) & serialno[14]); - break; - - case I2O_SNFORMAT_UNKNOWN: /* Unknown 0 */ - case I2O_SNFORMAT_UNKNOWN2: /* Unknown 0xff */ - default: - seq_printf(seq, "Unknown data format (0x%02x)", serialno[0]); - break; - } - - return 0; -} - -/** - * i2o_get_class_name - do i2o class name lookup - * @class: class number - * - * Return a descriptive string for an i2o class. - */ -static const char *i2o_get_class_name(int class) -{ - int idx = 16; - static char *i2o_class_name[] = { - "Executive", - "Device Driver Module", - "Block Device", - "Tape Device", - "LAN Interface", - "WAN Interface", - "Fibre Channel Port", - "Fibre Channel Device", - "SCSI Device", - "ATE Port", - "ATE Device", - "Floppy Controller", - "Floppy Device", - "Secondary Bus Port", - "Peer Transport Agent", - "Peer Transport", - "Unknown" - }; - - switch (class & 0xfff) { - case I2O_CLASS_EXECUTIVE: - idx = 0; - break; - case I2O_CLASS_DDM: - idx = 1; - break; - case I2O_CLASS_RANDOM_BLOCK_STORAGE: - idx = 2; - break; - case I2O_CLASS_SEQUENTIAL_STORAGE: - idx = 3; - break; - case I2O_CLASS_LAN: - idx = 4; - break; - case I2O_CLASS_WAN: - idx = 5; - break; - case I2O_CLASS_FIBRE_CHANNEL_PORT: - idx = 6; - break; - case I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL: - idx = 7; - break; - case I2O_CLASS_SCSI_PERIPHERAL: - idx = 8; - break; - case I2O_CLASS_ATE_PORT: - idx = 9; - break; - case I2O_CLASS_ATE_PERIPHERAL: - idx = 10; - break; - case I2O_CLASS_FLOPPY_CONTROLLER: - idx = 11; - break; - case I2O_CLASS_FLOPPY_DEVICE: - idx = 12; - break; - case I2O_CLASS_BUS_ADAPTER: - idx = 13; - break; - case I2O_CLASS_PEER_TRANSPORT_AGENT: - idx = 14; - break; - case I2O_CLASS_PEER_TRANSPORT: - idx = 15; - break; - } - - return i2o_class_name[idx]; -} - -#define SCSI_TABLE_SIZE 13 -static char *scsi_devices[] = { - "Direct-Access Read/Write", - "Sequential-Access Storage", - "Printer", - "Processor", - "WORM Device", - "CD-ROM Device", - "Scanner Device", - "Optical Memory Device", - "Medium Changer Device", - "Communications Device", - "Graphics Art Pre-Press Device", - "Graphics Art Pre-Press Device", - "Array Controller Device" -}; - -static char *chtostr(char *tmp, u8 *chars, int n) -{ - tmp[0] = 0; - return strncat(tmp, (char *)chars, n); -} - -static int i2o_report_query_status(struct seq_file *seq, int block_status, - char *group) -{ - switch (block_status) { - case -ETIMEDOUT: - seq_printf(seq, "Timeout reading group %s.\n", group); - break; - case -ENOMEM: - seq_puts(seq, "No free memory to read the table.\n"); - break; - case -I2O_PARAMS_STATUS_INVALID_GROUP_ID: - seq_printf(seq, "Group %s not supported.\n", group); - break; - default: - seq_printf(seq, - "Error reading group %s. BlockStatus 0x%02X\n", - group, -block_status); - break; - } - - return 0; -} - -static char *bus_strings[] = { - "Local Bus", - "ISA", - "EISA", - "PCI", - "PCMCIA", - "NUBUS", - "CARDBUS" -}; - -static int i2o_seq_show_hrt(struct seq_file *seq, void *v) -{ - struct i2o_controller *c = (struct i2o_controller *)seq->private; - i2o_hrt *hrt = (i2o_hrt *) c->hrt.virt; - u32 bus; - int i; - - if (hrt->hrt_version) { - seq_printf(seq, - "HRT table for controller is too new a version.\n"); - return 0; - } - - seq_printf(seq, "HRT has %d entries of %d bytes each.\n", - hrt->num_entries, hrt->entry_len << 2); - - for (i = 0; i < hrt->num_entries; i++) { - seq_printf(seq, "Entry %d:\n", i); - seq_printf(seq, " Adapter ID: %0#10x\n", - hrt->hrt_entry[i].adapter_id); - seq_printf(seq, " Controlling tid: %0#6x\n", - hrt->hrt_entry[i].parent_tid); - - if (hrt->hrt_entry[i].bus_type != 0x80) { - bus = hrt->hrt_entry[i].bus_type; - seq_printf(seq, " %s Information\n", - bus_strings[bus]); - - switch (bus) { - case I2O_BUS_LOCAL: - seq_printf(seq, " IOBase: %0#6x,", - hrt->hrt_entry[i].bus.local_bus. - LbBaseIOPort); - seq_printf(seq, " MemoryBase: %0#10x\n", - hrt->hrt_entry[i].bus.local_bus. - LbBaseMemoryAddress); - break; - - case I2O_BUS_ISA: - seq_printf(seq, " IOBase: %0#6x,", - hrt->hrt_entry[i].bus.isa_bus. - IsaBaseIOPort); - seq_printf(seq, " MemoryBase: %0#10x,", - hrt->hrt_entry[i].bus.isa_bus. - IsaBaseMemoryAddress); - seq_printf(seq, " CSN: %0#4x,", - hrt->hrt_entry[i].bus.isa_bus.CSN); - break; - - case I2O_BUS_EISA: - seq_printf(seq, " IOBase: %0#6x,", - hrt->hrt_entry[i].bus.eisa_bus. - EisaBaseIOPort); - seq_printf(seq, " MemoryBase: %0#10x,", - hrt->hrt_entry[i].bus.eisa_bus. - EisaBaseMemoryAddress); - seq_printf(seq, " Slot: %0#4x,", - hrt->hrt_entry[i].bus.eisa_bus. - EisaSlotNumber); - break; - - case I2O_BUS_PCI: - seq_printf(seq, " Bus: %0#4x", - hrt->hrt_entry[i].bus.pci_bus. - PciBusNumber); - seq_printf(seq, " Dev: %0#4x", - hrt->hrt_entry[i].bus.pci_bus. - PciDeviceNumber); - seq_printf(seq, " Func: %0#4x", - hrt->hrt_entry[i].bus.pci_bus. - PciFunctionNumber); - seq_printf(seq, " Vendor: %0#6x", - hrt->hrt_entry[i].bus.pci_bus. - PciVendorID); - seq_printf(seq, " Device: %0#6x\n", - hrt->hrt_entry[i].bus.pci_bus. - PciDeviceID); - break; - - default: - seq_printf(seq, " Unsupported Bus Type\n"); - } - } else - seq_printf(seq, " Unknown Bus Type\n"); - } - - return 0; -} - -static int i2o_seq_show_lct(struct seq_file *seq, void *v) -{ - struct i2o_controller *c = (struct i2o_controller *)seq->private; - i2o_lct *lct = (i2o_lct *) c->lct; - int entries; - int i; - -#define BUS_TABLE_SIZE 3 - static char *bus_ports[] = { - "Generic Bus", - "SCSI Bus", - "Fibre Channel Bus" - }; - - entries = (lct->table_size - 3) / 9; - - seq_printf(seq, "LCT contains %d %s\n", entries, - entries == 1 ? "entry" : "entries"); - if (lct->boot_tid) - seq_printf(seq, "Boot Device @ ID %d\n", lct->boot_tid); - - seq_printf(seq, "Current Change Indicator: %#10x\n", lct->change_ind); - - for (i = 0; i < entries; i++) { - seq_printf(seq, "Entry %d\n", i); - seq_printf(seq, " Class, SubClass : %s", - i2o_get_class_name(lct->lct_entry[i].class_id)); - - /* - * Classes which we'll print subclass info for - */ - switch (lct->lct_entry[i].class_id & 0xFFF) { - case I2O_CLASS_RANDOM_BLOCK_STORAGE: - switch (lct->lct_entry[i].sub_class) { - case 0x00: - seq_printf(seq, ", Direct-Access Read/Write"); - break; - - case 0x04: - seq_printf(seq, ", WORM Drive"); - break; - - case 0x05: - seq_printf(seq, ", CD-ROM Drive"); - break; - - case 0x07: - seq_printf(seq, ", Optical Memory Device"); - break; - - default: - seq_printf(seq, ", Unknown (0x%02x)", - lct->lct_entry[i].sub_class); - break; - } - break; - - case I2O_CLASS_LAN: - switch (lct->lct_entry[i].sub_class & 0xFF) { - case 0x30: - seq_printf(seq, ", Ethernet"); - break; - - case 0x40: - seq_printf(seq, ", 100base VG"); - break; - - case 0x50: - seq_printf(seq, ", IEEE 802.5/Token-Ring"); - break; - - case 0x60: - seq_printf(seq, ", ANSI X3T9.5 FDDI"); - break; - - case 0x70: - seq_printf(seq, ", Fibre Channel"); - break; - - default: - seq_printf(seq, ", Unknown Sub-Class (0x%02x)", - lct->lct_entry[i].sub_class & 0xFF); - break; - } - break; - - case I2O_CLASS_SCSI_PERIPHERAL: - if (lct->lct_entry[i].sub_class < SCSI_TABLE_SIZE) - seq_printf(seq, ", %s", - scsi_devices[lct->lct_entry[i]. - sub_class]); - else - seq_printf(seq, ", Unknown Device Type"); - break; - - case I2O_CLASS_BUS_ADAPTER: - if (lct->lct_entry[i].sub_class < BUS_TABLE_SIZE) - seq_printf(seq, ", %s", - bus_ports[lct->lct_entry[i]. - sub_class]); - else - seq_printf(seq, ", Unknown Bus Type"); - break; - } - seq_printf(seq, "\n"); - - seq_printf(seq, " Local TID : 0x%03x\n", - lct->lct_entry[i].tid); - seq_printf(seq, " User TID : 0x%03x\n", - lct->lct_entry[i].user_tid); - seq_printf(seq, " Parent TID : 0x%03x\n", - lct->lct_entry[i].parent_tid); - seq_printf(seq, " Identity Tag : 0x%x%x%x%x%x%x%x%x\n", - lct->lct_entry[i].identity_tag[0], - lct->lct_entry[i].identity_tag[1], - lct->lct_entry[i].identity_tag[2], - lct->lct_entry[i].identity_tag[3], - lct->lct_entry[i].identity_tag[4], - lct->lct_entry[i].identity_tag[5], - lct->lct_entry[i].identity_tag[6], - lct->lct_entry[i].identity_tag[7]); - seq_printf(seq, " Change Indicator : %0#10x\n", - lct->lct_entry[i].change_ind); - seq_printf(seq, " Event Capab Mask : %0#10x\n", - lct->lct_entry[i].device_flags); - } - - return 0; -} - -static int i2o_seq_show_status(struct seq_file *seq, void *v) -{ - struct i2o_controller *c = (struct i2o_controller *)seq->private; - char prodstr[25]; - int version; - i2o_status_block *sb = c->status_block.virt; - - i2o_status_get(c); // reread the status block - - seq_printf(seq, "Organization ID : %0#6x\n", sb->org_id); - - version = sb->i2o_version; - -/* FIXME for Spec 2.0 - if (version == 0x02) { - seq_printf(seq, "Lowest I2O version supported: "); - switch(workspace[2]) { - case 0x00: - seq_printf(seq, "1.0\n"); - break; - case 0x01: - seq_printf(seq, "1.5\n"); - break; - case 0x02: - seq_printf(seq, "2.0\n"); - break; - } - - seq_printf(seq, "Highest I2O version supported: "); - switch(workspace[3]) { - case 0x00: - seq_printf(seq, "1.0\n"); - break; - case 0x01: - seq_printf(seq, "1.5\n"); - break; - case 0x02: - seq_printf(seq, "2.0\n"); - break; - } - } -*/ - seq_printf(seq, "IOP ID : %0#5x\n", sb->iop_id); - seq_printf(seq, "Host Unit ID : %0#6x\n", sb->host_unit_id); - seq_printf(seq, "Segment Number : %0#5x\n", sb->segment_number); - - seq_printf(seq, "I2O version : "); - switch (version) { - case 0x00: - seq_printf(seq, "1.0\n"); - break; - case 0x01: - seq_printf(seq, "1.5\n"); - break; - case 0x02: - seq_printf(seq, "2.0\n"); - break; - default: - seq_printf(seq, "Unknown version\n"); - } - - seq_printf(seq, "IOP State : "); - switch (sb->iop_state) { - case 0x01: - seq_printf(seq, "INIT\n"); - break; - - case 0x02: - seq_printf(seq, "RESET\n"); - break; - - case 0x04: - seq_printf(seq, "HOLD\n"); - break; - - case 0x05: - seq_printf(seq, "READY\n"); - break; - - case 0x08: - seq_printf(seq, "OPERATIONAL\n"); - break; - - case 0x10: - seq_printf(seq, "FAILED\n"); - break; - - case 0x11: - seq_printf(seq, "FAULTED\n"); - break; - - default: - seq_printf(seq, "Unknown\n"); - break; - } - - seq_printf(seq, "Messenger Type : "); - switch (sb->msg_type) { - case 0x00: - seq_printf(seq, "Memory mapped\n"); - break; - case 0x01: - seq_printf(seq, "Memory mapped only\n"); - break; - case 0x02: - seq_printf(seq, "Remote only\n"); - break; - case 0x03: - seq_printf(seq, "Memory mapped and remote\n"); - break; - default: - seq_printf(seq, "Unknown\n"); - } - - seq_printf(seq, "Inbound Frame Size : %d bytes\n", - sb->inbound_frame_size << 2); - seq_printf(seq, "Max Inbound Frames : %d\n", - sb->max_inbound_frames); - seq_printf(seq, "Current Inbound Frames : %d\n", - sb->cur_inbound_frames); - seq_printf(seq, "Max Outbound Frames : %d\n", - sb->max_outbound_frames); - - /* Spec doesn't say if NULL terminated or not... */ - memcpy(prodstr, sb->product_id, 24); - prodstr[24] = '\0'; - seq_printf(seq, "Product ID : %s\n", prodstr); - seq_printf(seq, "Expected LCT Size : %d bytes\n", - sb->expected_lct_size); - - seq_printf(seq, "IOP Capabilities\n"); - seq_printf(seq, " Context Field Size Support : "); - switch (sb->iop_capabilities & 0x0000003) { - case 0: - seq_printf(seq, "Supports only 32-bit context fields\n"); - break; - case 1: - seq_printf(seq, "Supports only 64-bit context fields\n"); - break; - case 2: - seq_printf(seq, "Supports 32-bit and 64-bit context fields, " - "but not concurrently\n"); - break; - case 3: - seq_printf(seq, "Supports 32-bit and 64-bit context fields " - "concurrently\n"); - break; - default: - seq_printf(seq, "0x%08x\n", sb->iop_capabilities); - } - seq_printf(seq, " Current Context Field Size : "); - switch (sb->iop_capabilities & 0x0000000C) { - case 0: - seq_printf(seq, "not configured\n"); - break; - case 4: - seq_printf(seq, "Supports only 32-bit context fields\n"); - break; - case 8: - seq_printf(seq, "Supports only 64-bit context fields\n"); - break; - case 12: - seq_printf(seq, "Supports both 32-bit or 64-bit context fields " - "concurrently\n"); - break; - default: - seq_printf(seq, "\n"); - } - seq_printf(seq, " Inbound Peer Support : %s\n", - (sb-> - iop_capabilities & 0x00000010) ? "Supported" : - "Not supported"); - seq_printf(seq, " Outbound Peer Support : %s\n", - (sb-> - iop_capabilities & 0x00000020) ? "Supported" : - "Not supported"); - seq_printf(seq, " Peer to Peer Support : %s\n", - (sb-> - iop_capabilities & 0x00000040) ? "Supported" : - "Not supported"); - - seq_printf(seq, "Desired private memory size : %d kB\n", - sb->desired_mem_size >> 10); - seq_printf(seq, "Allocated private memory size : %d kB\n", - sb->current_mem_size >> 10); - seq_printf(seq, "Private memory base address : %0#10x\n", - sb->current_mem_base); - seq_printf(seq, "Desired private I/O size : %d kB\n", - sb->desired_io_size >> 10); - seq_printf(seq, "Allocated private I/O size : %d kB\n", - sb->current_io_size >> 10); - seq_printf(seq, "Private I/O base address : %0#10x\n", - sb->current_io_base); - - return 0; -} - -static int i2o_seq_show_hw(struct seq_file *seq, void *v) -{ - struct i2o_controller *c = (struct i2o_controller *)seq->private; - static u32 work32[5]; - static u8 *work8 = (u8 *) work32; - static u16 *work16 = (u16 *) work32; - int token; - u32 hwcap; - - static char *cpu_table[] = { - "Intel 80960 series", - "AMD2900 series", - "Motorola 68000 series", - "ARM series", - "MIPS series", - "Sparc series", - "PowerPC series", - "Intel x86 series" - }; - - token = - i2o_parm_field_get(c->exec, 0x0000, -1, &work32, sizeof(work32)); - - if (token < 0) { - i2o_report_query_status(seq, token, "0x0000 IOP Hardware"); - return 0; - } - - seq_printf(seq, "I2O Vendor ID : %0#6x\n", work16[0]); - seq_printf(seq, "Product ID : %0#6x\n", work16[1]); - seq_printf(seq, "CPU : "); - if (work8[16] > 8) - seq_printf(seq, "Unknown\n"); - else - seq_printf(seq, "%s\n", cpu_table[work8[16]]); - /* Anyone using ProcessorVersion? */ - - seq_printf(seq, "RAM : %dkB\n", work32[1] >> 10); - seq_printf(seq, "Non-Volatile Mem : %dkB\n", work32[2] >> 10); - - hwcap = work32[3]; - seq_printf(seq, "Capabilities : 0x%08x\n", hwcap); - seq_printf(seq, " [%s] Self booting\n", - (hwcap & 0x00000001) ? "+" : "-"); - seq_printf(seq, " [%s] Upgradable IRTOS\n", - (hwcap & 0x00000002) ? "+" : "-"); - seq_printf(seq, " [%s] Supports downloading DDMs\n", - (hwcap & 0x00000004) ? "+" : "-"); - seq_printf(seq, " [%s] Supports installing DDMs\n", - (hwcap & 0x00000008) ? "+" : "-"); - seq_printf(seq, " [%s] Battery-backed RAM\n", - (hwcap & 0x00000010) ? "+" : "-"); - - return 0; -} - -/* Executive group 0003h - Executing DDM List (table) */ -static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v) -{ - struct i2o_controller *c = (struct i2o_controller *)seq->private; - int token; - int i; - - typedef struct _i2o_exec_execute_ddm_table { - u16 ddm_tid; - u8 module_type; - u8 reserved; - u16 i2o_vendor_id; - u16 module_id; - u8 module_name_version[28]; - u32 data_size; - u32 code_size; - } i2o_exec_execute_ddm_table; - - struct { - u16 result_count; - u16 pad; - u16 block_size; - u8 block_status; - u8 error_info_size; - u16 row_count; - u16 more_flag; - i2o_exec_execute_ddm_table ddm_table[I2O_MAX_MODULES]; - } *result; - - i2o_exec_execute_ddm_table ddm_table; - char tmp[28 + 1]; - - result = kmalloc(sizeof(*result), GFP_KERNEL); - if (!result) - return -ENOMEM; - - token = i2o_parm_table_get(c->exec, I2O_PARAMS_TABLE_GET, 0x0003, -1, - NULL, 0, result, sizeof(*result)); - - if (token < 0) { - i2o_report_query_status(seq, token, - "0x0003 Executing DDM List"); - goto out; - } - - seq_printf(seq, - "Tid Module_type Vendor Mod_id Module_name Vrs Data_size Code_size\n"); - ddm_table = result->ddm_table[0]; - - for (i = 0; i < result->row_count; ddm_table = result->ddm_table[++i]) { - seq_printf(seq, "0x%03x ", ddm_table.ddm_tid & 0xFFF); - - switch (ddm_table.module_type) { - case 0x01: - seq_printf(seq, "Downloaded DDM "); - break; - case 0x22: - seq_printf(seq, "Embedded DDM "); - break; - default: - seq_printf(seq, " "); - } - - seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id); - seq_printf(seq, "%-#8x", ddm_table.module_id); - seq_printf(seq, "%-29s", - chtostr(tmp, ddm_table.module_name_version, 28)); - seq_printf(seq, "%9d ", ddm_table.data_size); - seq_printf(seq, "%8d", ddm_table.code_size); - - seq_printf(seq, "\n"); - } - out: - kfree(result); - return 0; -} - -/* Executive group 0004h - Driver Store (scalar) */ -static int i2o_seq_show_driver_store(struct seq_file *seq, void *v) -{ - struct i2o_controller *c = (struct i2o_controller *)seq->private; - u32 work32[8]; - int token; - - token = - i2o_parm_field_get(c->exec, 0x0004, -1, &work32, sizeof(work32)); - if (token < 0) { - i2o_report_query_status(seq, token, "0x0004 Driver Store"); - return 0; - } - - seq_printf(seq, "Module limit : %d\n" - "Module count : %d\n" - "Current space : %d kB\n" - "Free space : %d kB\n", - work32[0], work32[1], work32[2] >> 10, work32[3] >> 10); - - return 0; -} - -/* Executive group 0005h - Driver Store Table (table) */ -static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v) -{ - typedef struct _i2o_driver_store { - u16 stored_ddm_index; - u8 module_type; - u8 reserved; - u16 i2o_vendor_id; - u16 module_id; - u8 module_name_version[28]; - u8 date[8]; - u32 module_size; - u32 mpb_size; - u32 module_flags; - } i2o_driver_store_table; - - struct i2o_controller *c = (struct i2o_controller *)seq->private; - int token; - int i; - - typedef struct { - u16 result_count; - u16 pad; - u16 block_size; - u8 block_status; - u8 error_info_size; - u16 row_count; - u16 more_flag; - i2o_driver_store_table dst[I2O_MAX_MODULES]; - } i2o_driver_result_table; - - i2o_driver_result_table *result; - i2o_driver_store_table *dst; - char tmp[28 + 1]; - - result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL); - if (result == NULL) - return -ENOMEM; - - token = i2o_parm_table_get(c->exec, I2O_PARAMS_TABLE_GET, 0x0005, -1, - NULL, 0, result, sizeof(*result)); - - if (token < 0) { - i2o_report_query_status(seq, token, - "0x0005 DRIVER STORE TABLE"); - kfree(result); - return 0; - } - - seq_printf(seq, - "# Module_type Vendor Mod_id Module_name Vrs" - "Date Mod_size Par_size Flags\n"); - for (i = 0, dst = &result->dst[0]; i < result->row_count; - dst = &result->dst[++i]) { - seq_printf(seq, "%-3d", dst->stored_ddm_index); - switch (dst->module_type) { - case 0x01: - seq_printf(seq, "Downloaded DDM "); - break; - case 0x22: - seq_printf(seq, "Embedded DDM "); - break; - default: - seq_printf(seq, " "); - } - - seq_printf(seq, "%-#7x", dst->i2o_vendor_id); - seq_printf(seq, "%-#8x", dst->module_id); - seq_printf(seq, "%-29s", - chtostr(tmp, dst->module_name_version, 28)); - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8)); - seq_printf(seq, "%8d ", dst->module_size); - seq_printf(seq, "%8d ", dst->mpb_size); - seq_printf(seq, "0x%04x", dst->module_flags); - seq_printf(seq, "\n"); - } - - kfree(result); - return 0; -} - -/* Generic group F000h - Params Descriptor (table) */ -static int i2o_seq_show_groups(struct seq_file *seq, void *v) -{ - struct i2o_device *d = (struct i2o_device *)seq->private; - int token; - int i; - u8 properties; - - typedef struct _i2o_group_info { - u16 group_number; - u16 field_count; - u16 row_count; - u8 properties; - u8 reserved; - } i2o_group_info; - - struct { - u16 result_count; - u16 pad; - u16 block_size; - u8 block_status; - u8 error_info_size; - u16 row_count; - u16 more_flag; - i2o_group_info group[256]; - } *result; - - result = kmalloc(sizeof(*result), GFP_KERNEL); - if (!result) - return -ENOMEM; - - token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF000, -1, NULL, 0, - result, sizeof(*result)); - - if (token < 0) { - i2o_report_query_status(seq, token, "0xF000 Params Descriptor"); - goto out; - } - - seq_printf(seq, - "# Group FieldCount RowCount Type Add Del Clear\n"); - - for (i = 0; i < result->row_count; i++) { - seq_printf(seq, "%-3d", i); - seq_printf(seq, "0x%04X ", result->group[i].group_number); - seq_printf(seq, "%10d ", result->group[i].field_count); - seq_printf(seq, "%8d ", result->group[i].row_count); - - properties = result->group[i].properties; - if (properties & 0x1) - seq_printf(seq, "Table "); - else - seq_printf(seq, "Scalar "); - if (properties & 0x2) - seq_printf(seq, " + "); - else - seq_printf(seq, " - "); - if (properties & 0x4) - seq_printf(seq, " + "); - else - seq_printf(seq, " - "); - if (properties & 0x8) - seq_printf(seq, " + "); - else - seq_printf(seq, " - "); - - seq_printf(seq, "\n"); - } - - if (result->more_flag) - seq_printf(seq, "There is more...\n"); - out: - kfree(result); - return 0; -} - -/* Generic group F001h - Physical Device Table (table) */ -static int i2o_seq_show_phys_device(struct seq_file *seq, void *v) -{ - struct i2o_device *d = (struct i2o_device *)seq->private; - int token; - int i; - - struct { - u16 result_count; - u16 pad; - u16 block_size; - u8 block_status; - u8 error_info_size; - u16 row_count; - u16 more_flag; - u32 adapter_id[64]; - } result; - - token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF001, -1, NULL, 0, - &result, sizeof(result)); - - if (token < 0) { - i2o_report_query_status(seq, token, - "0xF001 Physical Device Table"); - return 0; - } - - if (result.row_count) - seq_printf(seq, "# AdapterId\n"); - - for (i = 0; i < result.row_count; i++) { - seq_printf(seq, "%-2d", i); - seq_printf(seq, "%#7x\n", result.adapter_id[i]); - } - - if (result.more_flag) - seq_printf(seq, "There is more...\n"); - - return 0; -} - -/* Generic group F002h - Claimed Table (table) */ -static int i2o_seq_show_claimed(struct seq_file *seq, void *v) -{ - struct i2o_device *d = (struct i2o_device *)seq->private; - int token; - int i; - - struct { - u16 result_count; - u16 pad; - u16 block_size; - u8 block_status; - u8 error_info_size; - u16 row_count; - u16 more_flag; - u16 claimed_tid[64]; - } result; - - token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF002, -1, NULL, 0, - &result, sizeof(result)); - - if (token < 0) { - i2o_report_query_status(seq, token, "0xF002 Claimed Table"); - return 0; - } - - if (result.row_count) - seq_printf(seq, "# ClaimedTid\n"); - - for (i = 0; i < result.row_count; i++) { - seq_printf(seq, "%-2d", i); - seq_printf(seq, "%#7x\n", result.claimed_tid[i]); - } - - if (result.more_flag) - seq_printf(seq, "There is more...\n"); - - return 0; -} - -/* Generic group F003h - User Table (table) */ -static int i2o_seq_show_users(struct seq_file *seq, void *v) -{ - struct i2o_device *d = (struct i2o_device *)seq->private; - int token; - int i; - - typedef struct _i2o_user_table { - u16 instance; - u16 user_tid; - u8 claim_type; - u8 reserved1; - u16 reserved2; - } i2o_user_table; - - struct { - u16 result_count; - u16 pad; - u16 block_size; - u8 block_status; - u8 error_info_size; - u16 row_count; - u16 more_flag; - i2o_user_table user[64]; - } *result; - - result = kmalloc(sizeof(*result), GFP_KERNEL); - if (!result) - return -ENOMEM; - - token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF003, -1, NULL, 0, - result, sizeof(*result)); - - if (token < 0) { - i2o_report_query_status(seq, token, "0xF003 User Table"); - goto out; - } - - seq_printf(seq, "# Instance UserTid ClaimType\n"); - - for (i = 0; i < result->row_count; i++) { - seq_printf(seq, "%-3d", i); - seq_printf(seq, "%#8x ", result->user[i].instance); - seq_printf(seq, "%#7x ", result->user[i].user_tid); - seq_printf(seq, "%#9x\n", result->user[i].claim_type); - } - - if (result->more_flag) - seq_printf(seq, "There is more...\n"); - out: - kfree(result); - return 0; -} - -/* Generic group F005h - Private message extensions (table) (optional) */ -static int i2o_seq_show_priv_msgs(struct seq_file *seq, void *v) -{ - struct i2o_device *d = (struct i2o_device *)seq->private; - int token; - int i; - - typedef struct _i2o_private { - u16 ext_instance; - u16 organization_id; - u16 x_function_code; - } i2o_private; - - struct { - u16 result_count; - u16 pad; - u16 block_size; - u8 block_status; - u8 error_info_size; - u16 row_count; - u16 more_flag; - i2o_private extension[64]; - } result; - - token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF000, -1, NULL, 0, - &result, sizeof(result)); - - if (token < 0) { - i2o_report_query_status(seq, token, - "0xF005 Private Message Extensions (optional)"); - return 0; - } - - seq_printf(seq, "Instance# OrgId FunctionCode\n"); - - for (i = 0; i < result.row_count; i++) { - seq_printf(seq, "%0#9x ", result.extension[i].ext_instance); - seq_printf(seq, "%0#6x ", result.extension[i].organization_id); - seq_printf(seq, "%0#6x", result.extension[i].x_function_code); - - seq_printf(seq, "\n"); - } - - if (result.more_flag) - seq_printf(seq, "There is more...\n"); - - return 0; -} - -/* Generic group F006h - Authorized User Table (table) */ -static int i2o_seq_show_authorized_users(struct seq_file *seq, void *v) -{ - struct i2o_device *d = (struct i2o_device *)seq->private; - int token; - int i; - - struct { - u16 result_count; - u16 pad; - u16 block_size; - u8 block_status; - u8 error_info_size; - u16 row_count; - u16 more_flag; - u32 alternate_tid[64]; - } result; - - token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF006, -1, NULL, 0, - &result, sizeof(result)); - - if (token < 0) { - i2o_report_query_status(seq, token, - "0xF006 Autohorized User Table"); - return 0; - } - - if (result.row_count) - seq_printf(seq, "# AlternateTid\n"); - - for (i = 0; i < result.row_count; i++) { - seq_printf(seq, "%-2d", i); - seq_printf(seq, "%#7x ", result.alternate_tid[i]); - } - - if (result.more_flag) - seq_printf(seq, "There is more...\n"); - - return 0; -} - -/* Generic group F100h - Device Identity (scalar) */ -static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v) -{ - struct i2o_device *d = (struct i2o_device *)seq->private; - static u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number - // == (allow) 512d bytes (max) - static u16 *work16 = (u16 *) work32; - int token; - char tmp[16 + 1]; - - token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32)); - - if (token < 0) { - i2o_report_query_status(seq, token, "0xF100 Device Identity"); - return 0; - } - - seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0])); - seq_printf(seq, "Owner TID : %0#5x\n", work16[2]); - seq_printf(seq, "Parent TID : %0#5x\n", work16[3]); - seq_printf(seq, "Vendor info : %s\n", - chtostr(tmp, (u8 *) (work32 + 2), 16)); - seq_printf(seq, "Product info : %s\n", - chtostr(tmp, (u8 *) (work32 + 6), 16)); - seq_printf(seq, "Description : %s\n", - chtostr(tmp, (u8 *) (work32 + 10), 16)); - seq_printf(seq, "Product rev. : %s\n", - chtostr(tmp, (u8 *) (work32 + 14), 8)); - - seq_printf(seq, "Serial number : "); - print_serial_number(seq, (u8 *) (work32 + 16), - /* allow for SNLen plus - * possible trailing '\0' - */ - sizeof(work32) - (16 * sizeof(u32)) - 2); - seq_printf(seq, "\n"); - - return 0; -} - -static int i2o_seq_show_dev_name(struct seq_file *seq, void *v) -{ - struct i2o_device *d = (struct i2o_device *)seq->private; - - seq_printf(seq, "%s\n", dev_name(&d->device)); - - return 0; -} - -/* Generic group F101h - DDM Identity (scalar) */ -static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v) -{ - struct i2o_device *d = (struct i2o_device *)seq->private; - int token; - - struct { - u16 ddm_tid; - u8 module_name[24]; - u8 module_rev[8]; - u8 sn_format; - u8 serial_number[12]; - u8 pad[256]; // allow up to 256 byte (max) serial number - } result; - - char tmp[24 + 1]; - - token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result)); - - if (token < 0) { - i2o_report_query_status(seq, token, "0xF101 DDM Identity"); - return 0; - } - - seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid); - seq_printf(seq, "Module name : %s\n", - chtostr(tmp, result.module_name, 24)); - seq_printf(seq, "Module revision : %s\n", - chtostr(tmp, result.module_rev, 8)); - - seq_printf(seq, "Serial number : "); - print_serial_number(seq, result.serial_number, sizeof(result) - 36); - /* allow for SNLen plus possible trailing '\0' */ - - seq_printf(seq, "\n"); - - return 0; -} - -/* Generic group F102h - User Information (scalar) */ -static int i2o_seq_show_uinfo(struct seq_file *seq, void *v) -{ - struct i2o_device *d = (struct i2o_device *)seq->private; - int token; - - struct { - u8 device_name[64]; - u8 service_name[64]; - u8 physical_location[64]; - u8 instance_number[4]; - } result; - - char tmp[64 + 1]; - - token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result)); - - if (token < 0) { - i2o_report_query_status(seq, token, "0xF102 User Information"); - return 0; - } - - seq_printf(seq, "Device name : %s\n", - chtostr(tmp, result.device_name, 64)); - seq_printf(seq, "Service name : %s\n", - chtostr(tmp, result.service_name, 64)); - seq_printf(seq, "Physical name : %s\n", - chtostr(tmp, result.physical_location, 64)); - seq_printf(seq, "Instance number : %s\n", - chtostr(tmp, result.instance_number, 4)); - - return 0; -} - -/* Generic group F103h - SGL Operating Limits (scalar) */ -static int i2o_seq_show_sgl_limits(struct seq_file *seq, void *v) -{ - struct i2o_device *d = (struct i2o_device *)seq->private; - static u32 work32[12]; - static u16 *work16 = (u16 *) work32; - static u8 *work8 = (u8 *) work32; - int token; - - token = i2o_parm_field_get(d, 0xF103, -1, &work32, sizeof(work32)); - - if (token < 0) { - i2o_report_query_status(seq, token, - "0xF103 SGL Operating Limits"); - return 0; - } - - seq_printf(seq, "SGL chain size : %d\n", work32[0]); - seq_printf(seq, "Max SGL chain size : %d\n", work32[1]); - seq_printf(seq, "SGL chain size target : %d\n", work32[2]); - seq_printf(seq, "SGL frag count : %d\n", work16[6]); - seq_printf(seq, "Max SGL frag count : %d\n", work16[7]); - seq_printf(seq, "SGL frag count target : %d\n", work16[8]); - -/* FIXME - if (d->i2oversion == 0x02) - { -*/ - seq_printf(seq, "SGL data alignment : %d\n", work16[8]); - seq_printf(seq, "SGL addr limit : %d\n", work8[20]); - seq_printf(seq, "SGL addr sizes supported : "); - if (work8[21] & 0x01) - seq_printf(seq, "32 bit "); - if (work8[21] & 0x02) - seq_printf(seq, "64 bit "); - if (work8[21] & 0x04) - seq_printf(seq, "96 bit "); - if (work8[21] & 0x08) - seq_printf(seq, "128 bit "); - seq_printf(seq, "\n"); -/* - } -*/ - - return 0; -} - -/* Generic group F200h - Sensors (scalar) */ -static int i2o_seq_show_sensors(struct seq_file *seq, void *v) -{ - struct i2o_device *d = (struct i2o_device *)seq->private; - int token; - - struct { - u16 sensor_instance; - u8 component; - u16 component_instance; - u8 sensor_class; - u8 sensor_type; - u8 scaling_exponent; - u32 actual_reading; - u32 minimum_reading; - u32 low2lowcat_treshold; - u32 lowcat2low_treshold; - u32 lowwarn2low_treshold; - u32 low2lowwarn_treshold; - u32 norm2lowwarn_treshold; - u32 lowwarn2norm_treshold; - u32 nominal_reading; - u32 hiwarn2norm_treshold; - u32 norm2hiwarn_treshold; - u32 high2hiwarn_treshold; - u32 hiwarn2high_treshold; - u32 hicat2high_treshold; - u32 hi2hicat_treshold; - u32 maximum_reading; - u8 sensor_state; - u16 event_enable; - } result; - - token = i2o_parm_field_get(d, 0xF200, -1, &result, sizeof(result)); - - if (token < 0) { - i2o_report_query_status(seq, token, - "0xF200 Sensors (optional)"); - return 0; - } - - seq_printf(seq, "Sensor instance : %d\n", result.sensor_instance); - - seq_printf(seq, "Component : %d = ", result.component); - switch (result.component) { - case 0: - seq_printf(seq, "Other"); - break; - case 1: - seq_printf(seq, "Planar logic Board"); - break; - case 2: - seq_printf(seq, "CPU"); - break; - case 3: - seq_printf(seq, "Chassis"); - break; - case 4: - seq_printf(seq, "Power Supply"); - break; - case 5: - seq_printf(seq, "Storage"); - break; - case 6: - seq_printf(seq, "External"); - break; - } - seq_printf(seq, "\n"); - - seq_printf(seq, "Component instance : %d\n", - result.component_instance); - seq_printf(seq, "Sensor class : %s\n", - result.sensor_class ? "Analog" : "Digital"); - - seq_printf(seq, "Sensor type : %d = ", result.sensor_type); - switch (result.sensor_type) { - case 0: - seq_printf(seq, "Other\n"); - break; - case 1: - seq_printf(seq, "Thermal\n"); - break; - case 2: - seq_printf(seq, "DC voltage (DC volts)\n"); - break; - case 3: - seq_printf(seq, "AC voltage (AC volts)\n"); - break; - case 4: - seq_printf(seq, "DC current (DC amps)\n"); - break; - case 5: - seq_printf(seq, "AC current (AC volts)\n"); - break; - case 6: - seq_printf(seq, "Door open\n"); - break; - case 7: - seq_printf(seq, "Fan operational\n"); - break; - } - - seq_printf(seq, "Scaling exponent : %d\n", - result.scaling_exponent); - seq_printf(seq, "Actual reading : %d\n", result.actual_reading); - seq_printf(seq, "Minimum reading : %d\n", result.minimum_reading); - seq_printf(seq, "Low2LowCat treshold : %d\n", - result.low2lowcat_treshold); - seq_printf(seq, "LowCat2Low treshold : %d\n", - result.lowcat2low_treshold); - seq_printf(seq, "LowWarn2Low treshold : %d\n", - result.lowwarn2low_treshold); - seq_printf(seq, "Low2LowWarn treshold : %d\n", - result.low2lowwarn_treshold); - seq_printf(seq, "Norm2LowWarn treshold : %d\n", - result.norm2lowwarn_treshold); - seq_printf(seq, "LowWarn2Norm treshold : %d\n", - result.lowwarn2norm_treshold); - seq_printf(seq, "Nominal reading : %d\n", result.nominal_reading); - seq_printf(seq, "HiWarn2Norm treshold : %d\n", - result.hiwarn2norm_treshold); - seq_printf(seq, "Norm2HiWarn treshold : %d\n", - result.norm2hiwarn_treshold); - seq_printf(seq, "High2HiWarn treshold : %d\n", - result.high2hiwarn_treshold); - seq_printf(seq, "HiWarn2High treshold : %d\n", - result.hiwarn2high_treshold); - seq_printf(seq, "HiCat2High treshold : %d\n", - result.hicat2high_treshold); - seq_printf(seq, "High2HiCat treshold : %d\n", - result.hi2hicat_treshold); - seq_printf(seq, "Maximum reading : %d\n", result.maximum_reading); - - seq_printf(seq, "Sensor state : %d = ", result.sensor_state); - switch (result.sensor_state) { - case 0: - seq_printf(seq, "Normal\n"); - break; - case 1: - seq_printf(seq, "Abnormal\n"); - break; - case 2: - seq_printf(seq, "Unknown\n"); - break; - case 3: - seq_printf(seq, "Low Catastrophic (LoCat)\n"); - break; - case 4: - seq_printf(seq, "Low (Low)\n"); - break; - case 5: - seq_printf(seq, "Low Warning (LoWarn)\n"); - break; - case 6: - seq_printf(seq, "High Warning (HiWarn)\n"); - break; - case 7: - seq_printf(seq, "High (High)\n"); - break; - case 8: - seq_printf(seq, "High Catastrophic (HiCat)\n"); - break; - } - - seq_printf(seq, "Event_enable : 0x%02X\n", result.event_enable); - seq_printf(seq, " [%s] Operational state change. \n", - (result.event_enable & 0x01) ? "+" : "-"); - seq_printf(seq, " [%s] Low catastrophic. \n", - (result.event_enable & 0x02) ? "+" : "-"); - seq_printf(seq, " [%s] Low reading. \n", - (result.event_enable & 0x04) ? "+" : "-"); - seq_printf(seq, " [%s] Low warning. \n", - (result.event_enable & 0x08) ? "+" : "-"); - seq_printf(seq, - " [%s] Change back to normal from out of range state. \n", - (result.event_enable & 0x10) ? "+" : "-"); - seq_printf(seq, " [%s] High warning. \n", - (result.event_enable & 0x20) ? "+" : "-"); - seq_printf(seq, " [%s] High reading. \n", - (result.event_enable & 0x40) ? "+" : "-"); - seq_printf(seq, " [%s] High catastrophic. \n", - (result.event_enable & 0x80) ? "+" : "-"); - - return 0; -} - -static int i2o_seq_open_hrt(struct inode *inode, struct file *file) -{ - return single_open(file, i2o_seq_show_hrt, PDE_DATA(inode)); -}; - -static int i2o_seq_open_lct(struct inode *inode, struct file *file) -{ - return single_open(file, i2o_seq_show_lct, PDE_DATA(inode)); -}; - -static int i2o_seq_open_status(struct inode *inode, struct file *file) -{ - return single_open(file, i2o_seq_show_status, PDE_DATA(inode)); -}; - -static int i2o_seq_open_hw(struct inode *inode, struct file *file) -{ - return single_open(file, i2o_seq_show_hw, PDE_DATA(inode)); -}; - -static int i2o_seq_open_ddm_table(struct inode *inode, struct file *file) -{ - return single_open(file, i2o_seq_show_ddm_table, PDE_DATA(inode)); -}; - -static int i2o_seq_open_driver_store(struct inode *inode, struct file *file) -{ - return single_open(file, i2o_seq_show_driver_store, PDE_DATA(inode)); -}; - -static int i2o_seq_open_drivers_stored(struct inode *inode, struct file *file) -{ - return single_open(file, i2o_seq_show_drivers_stored, PDE_DATA(inode)); -}; - -static int i2o_seq_open_groups(struct inode *inode, struct file *file) -{ - return single_open(file, i2o_seq_show_groups, PDE_DATA(inode)); -}; - -static int i2o_seq_open_phys_device(struct inode *inode, struct file *file) -{ - return single_open(file, i2o_seq_show_phys_device, PDE_DATA(inode)); -}; - -static int i2o_seq_open_claimed(struct inode *inode, struct file *file) -{ - return single_open(file, i2o_seq_show_claimed, PDE_DATA(inode)); -}; - -static int i2o_seq_open_users(struct inode *inode, struct file *file) -{ - return single_open(file, i2o_seq_show_users, PDE_DATA(inode)); -}; - -static int i2o_seq_open_priv_msgs(struct inode *inode, struct file *file) -{ - return single_open(file, i2o_seq_show_priv_msgs, PDE_DATA(inode)); -}; - -static int i2o_seq_open_authorized_users(struct inode *inode, struct file *file) -{ - return single_open(file, i2o_seq_show_authorized_users, - PDE_DATA(inode)); -}; - -static int i2o_seq_open_dev_identity(struct inode *inode, struct file *file) -{ - return single_open(file, i2o_seq_show_dev_identity, PDE_DATA(inode)); -}; - -static int i2o_seq_open_ddm_identity(struct inode *inode, struct file *file) -{ - return single_open(file, i2o_seq_show_ddm_identity, PDE_DATA(inode)); -}; - -static int i2o_seq_open_uinfo(struct inode *inode, struct file *file) -{ - return single_open(file, i2o_seq_show_uinfo, PDE_DATA(inode)); -}; - -static int i2o_seq_open_sgl_limits(struct inode *inode, struct file *file) -{ - return single_open(file, i2o_seq_show_sgl_limits, PDE_DATA(inode)); -}; - -static int i2o_seq_open_sensors(struct inode *inode, struct file *file) -{ - return single_open(file, i2o_seq_show_sensors, PDE_DATA(inode)); -}; - -static int i2o_seq_open_dev_name(struct inode *inode, struct file *file) -{ - return single_open(file, i2o_seq_show_dev_name, PDE_DATA(inode)); -}; - -static const struct file_operations i2o_seq_fops_lct = { - .open = i2o_seq_open_lct, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations i2o_seq_fops_hrt = { - .open = i2o_seq_open_hrt, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations i2o_seq_fops_status = { - .open = i2o_seq_open_status, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations i2o_seq_fops_hw = { - .open = i2o_seq_open_hw, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations i2o_seq_fops_ddm_table = { - .open = i2o_seq_open_ddm_table, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations i2o_seq_fops_driver_store = { - .open = i2o_seq_open_driver_store, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations i2o_seq_fops_drivers_stored = { - .open = i2o_seq_open_drivers_stored, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations i2o_seq_fops_groups = { - .open = i2o_seq_open_groups, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations i2o_seq_fops_phys_device = { - .open = i2o_seq_open_phys_device, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations i2o_seq_fops_claimed = { - .open = i2o_seq_open_claimed, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations i2o_seq_fops_users = { - .open = i2o_seq_open_users, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations i2o_seq_fops_priv_msgs = { - .open = i2o_seq_open_priv_msgs, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations i2o_seq_fops_authorized_users = { - .open = i2o_seq_open_authorized_users, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations i2o_seq_fops_dev_name = { - .open = i2o_seq_open_dev_name, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations i2o_seq_fops_dev_identity = { - .open = i2o_seq_open_dev_identity, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations i2o_seq_fops_ddm_identity = { - .open = i2o_seq_open_ddm_identity, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations i2o_seq_fops_uinfo = { - .open = i2o_seq_open_uinfo, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations i2o_seq_fops_sgl_limits = { - .open = i2o_seq_open_sgl_limits, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations i2o_seq_fops_sensors = { - .open = i2o_seq_open_sensors, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -/* - * IOP specific entries...write field just in case someone - * ever wants one. - */ -static i2o_proc_entry i2o_proc_generic_iop_entries[] = { - {"hrt", S_IFREG | S_IRUGO, &i2o_seq_fops_hrt}, - {"lct", S_IFREG | S_IRUGO, &i2o_seq_fops_lct}, - {"status", S_IFREG | S_IRUGO, &i2o_seq_fops_status}, - {"hw", S_IFREG | S_IRUGO, &i2o_seq_fops_hw}, - {"ddm_table", S_IFREG | S_IRUGO, &i2o_seq_fops_ddm_table}, - {"driver_store", S_IFREG | S_IRUGO, &i2o_seq_fops_driver_store}, - {"drivers_stored", S_IFREG | S_IRUGO, &i2o_seq_fops_drivers_stored}, - {NULL, 0, NULL} -}; - -/* - * Device specific entries - */ -static i2o_proc_entry generic_dev_entries[] = { - {"groups", S_IFREG | S_IRUGO, &i2o_seq_fops_groups}, - {"phys_dev", S_IFREG | S_IRUGO, &i2o_seq_fops_phys_device}, - {"claimed", S_IFREG | S_IRUGO, &i2o_seq_fops_claimed}, - {"users", S_IFREG | S_IRUGO, &i2o_seq_fops_users}, - {"priv_msgs", S_IFREG | S_IRUGO, &i2o_seq_fops_priv_msgs}, - {"authorized_users", S_IFREG | S_IRUGO, &i2o_seq_fops_authorized_users}, - {"dev_identity", S_IFREG | S_IRUGO, &i2o_seq_fops_dev_identity}, - {"ddm_identity", S_IFREG | S_IRUGO, &i2o_seq_fops_ddm_identity}, - {"user_info", S_IFREG | S_IRUGO, &i2o_seq_fops_uinfo}, - {"sgl_limits", S_IFREG | S_IRUGO, &i2o_seq_fops_sgl_limits}, - {"sensors", S_IFREG | S_IRUGO, &i2o_seq_fops_sensors}, - {NULL, 0, NULL} -}; - -/* - * Storage unit specific entries (SCSI Periph, BS) with device names - */ -static i2o_proc_entry rbs_dev_entries[] = { - {"dev_name", S_IFREG | S_IRUGO, &i2o_seq_fops_dev_name}, - {NULL, 0, NULL} -}; - -/** - * i2o_proc_create_entries - Creates proc dir entries - * @dir: proc dir entry under which the entries should be placed - * @i2o_pe: pointer to the entries which should be added - * @data: pointer to I2O controller or device - * - * Create proc dir entries for a I2O controller or I2O device. - * - * Returns 0 on success or negative error code on failure. - */ -static int i2o_proc_create_entries(struct proc_dir_entry *dir, - i2o_proc_entry * i2o_pe, void *data) -{ - struct proc_dir_entry *tmp; - - while (i2o_pe->name) { - tmp = proc_create_data(i2o_pe->name, i2o_pe->mode, dir, - i2o_pe->fops, data); - if (!tmp) - return -1; - - i2o_pe++; - } - - return 0; -} - -/** - * i2o_proc_device_add - Add an I2O device to the proc dir - * @dir: proc dir entry to which the device should be added - * @dev: I2O device which should be added - * - * Add an I2O device to the proc dir entry dir and create the entries for - * the device depending on the class of the I2O device. - */ -static void i2o_proc_device_add(struct proc_dir_entry *dir, - struct i2o_device *dev) -{ - char buff[10]; - struct proc_dir_entry *devdir; - i2o_proc_entry *i2o_pe = NULL; - - sprintf(buff, "%03x", dev->lct_data.tid); - - osm_debug("adding device /proc/i2o/%s/%s\n", dev->iop->name, buff); - - devdir = proc_mkdir_data(buff, 0, dir, dev); - if (!devdir) { - osm_warn("Could not allocate procdir!\n"); - return; - } - - i2o_proc_create_entries(devdir, generic_dev_entries, dev); - - /* Inform core that we want updates about this device's status */ - switch (dev->lct_data.class_id) { - case I2O_CLASS_SCSI_PERIPHERAL: - case I2O_CLASS_RANDOM_BLOCK_STORAGE: - i2o_pe = rbs_dev_entries; - break; - default: - break; - } - if (i2o_pe) - i2o_proc_create_entries(devdir, i2o_pe, dev); -} - -/** - * i2o_proc_iop_add - Add an I2O controller to the i2o proc tree - * @dir: parent proc dir entry - * @c: I2O controller which should be added - * - * Add the entries to the parent proc dir entry. Also each device is added - * to the controllers proc dir entry. - * - * Returns 0 on success or negative error code on failure. - */ -static int i2o_proc_iop_add(struct proc_dir_entry *dir, - struct i2o_controller *c) -{ - struct proc_dir_entry *iopdir; - struct i2o_device *dev; - - osm_debug("adding IOP /proc/i2o/%s\n", c->name); - - iopdir = proc_mkdir_data(c->name, 0, dir, c); - if (!iopdir) - return -1; - - i2o_proc_create_entries(iopdir, i2o_proc_generic_iop_entries, c); - - list_for_each_entry(dev, &c->devices, list) - i2o_proc_device_add(iopdir, dev); - - return 0; -} - -/** - * i2o_proc_fs_create - Create the i2o proc fs. - * - * Iterate over each I2O controller and create the entries for it. - * - * Returns 0 on success or negative error code on failure. - */ -static int __init i2o_proc_fs_create(void) -{ - struct i2o_controller *c; - - i2o_proc_dir_root = proc_mkdir("i2o", NULL); - if (!i2o_proc_dir_root) - return -1; - - list_for_each_entry(c, &i2o_controllers, list) - i2o_proc_iop_add(i2o_proc_dir_root, c); - - return 0; -}; - -/** - * i2o_proc_fs_destroy - Cleanup the all i2o proc entries - * - * Iterate over each I2O controller and remove the entries for it. - * - * Returns 0 on success or negative error code on failure. - */ -static int __exit i2o_proc_fs_destroy(void) -{ - remove_proc_subtree("i2o", NULL); - - return 0; -}; - -/** - * i2o_proc_init - Init function for procfs - * - * Registers Proc OSM and creates procfs entries. - * - * Returns 0 on success or negative error code on failure. - */ -static int __init i2o_proc_init(void) -{ - int rc; - - printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n"); - - rc = i2o_driver_register(&i2o_proc_driver); - if (rc) - return rc; - - rc = i2o_proc_fs_create(); - if (rc) { - i2o_driver_unregister(&i2o_proc_driver); - return rc; - } - - return 0; -}; - -/** - * i2o_proc_exit - Exit function for procfs - * - * Unregisters Proc OSM and removes procfs entries. - */ -static void __exit i2o_proc_exit(void) -{ - i2o_driver_unregister(&i2o_proc_driver); - i2o_proc_fs_destroy(); -}; - -MODULE_AUTHOR("Deepak Saxena"); -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION(OSM_DESCRIPTION); -MODULE_VERSION(OSM_VERSION); - -module_init(i2o_proc_init); -module_exit(i2o_proc_exit); diff --git a/drivers/staging/i2o/i2o_scsi.c b/drivers/staging/i2o/i2o_scsi.c deleted file mode 100644 index 1b11dcb3faea..000000000000 --- a/drivers/staging/i2o/i2o_scsi.c +++ /dev/null @@ -1,814 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * For the avoidance of doubt the "preferred form" of this code is one which - * is in an open non patent encumbered format. Where cryptographic key signing - * forms part of the process of creating an executable the information - * including keys needed to generate an equivalently functional executable - * are deemed to be part of the source code. - * - * Complications for I2O scsi - * - * o Each (bus,lun) is a logical device in I2O. We keep a map - * table. We spoof failed selection for unmapped units - * o Request sense buffers can come back for free. - * o Scatter gather is a bit dynamic. We have to investigate at - * setup time. - * o Some of our resources are dynamically shared. The i2o core - * needs a message reservation protocol to avoid swap v net - * deadlocking. We need to back off queue requests. - * - * In general the firmware wants to help. Where its help isn't performance - * useful we just ignore the aid. Its not worth the code in truth. - * - * Fixes/additions: - * Steve Ralston: - * Scatter gather now works - * Markus Lidel : - * Minor fixes for 2.6. - * - * To Do: - * 64bit cleanups - * Fix the resource management problems. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "i2o.h" -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#define OSM_NAME "scsi-osm" -#define OSM_VERSION "1.316" -#define OSM_DESCRIPTION "I2O SCSI Peripheral OSM" - -static struct i2o_driver i2o_scsi_driver; - -static unsigned int i2o_scsi_max_id = 16; -static unsigned int i2o_scsi_max_lun = 255; - -struct i2o_scsi_host { - struct Scsi_Host *scsi_host; /* pointer to the SCSI host */ - struct i2o_controller *iop; /* pointer to the I2O controller */ - u64 lun; /* lun's used for block devices */ - struct i2o_device *channel[0]; /* channel->i2o_dev mapping table */ -}; - -static struct scsi_host_template i2o_scsi_host_template; - -#define I2O_SCSI_CAN_QUEUE 4 - -/* SCSI OSM class handling definition */ -static struct i2o_class_id i2o_scsi_class_id[] = { - {I2O_CLASS_SCSI_PERIPHERAL}, - {I2O_CLASS_END} -}; - -static struct i2o_scsi_host *i2o_scsi_host_alloc(struct i2o_controller *c) -{ - struct i2o_scsi_host *i2o_shost; - struct i2o_device *i2o_dev; - struct Scsi_Host *scsi_host; - int max_channel = 0; - u8 type; - int i; - size_t size; - u16 body_size = 6; - -#ifdef CONFIG_I2O_EXT_ADAPTEC - if (c->adaptec) - body_size = 8; -#endif - - list_for_each_entry(i2o_dev, &c->devices, list) - if (i2o_dev->lct_data.class_id == I2O_CLASS_BUS_ADAPTER) { - if (!i2o_parm_field_get(i2o_dev, 0x0000, 0, &type, 1) - && (type == 0x01)) /* SCSI bus */ - max_channel++; - } - - if (!max_channel) { - osm_warn("no channels found on %s\n", c->name); - return ERR_PTR(-EFAULT); - } - - size = max_channel * sizeof(struct i2o_device *) - + sizeof(struct i2o_scsi_host); - - scsi_host = scsi_host_alloc(&i2o_scsi_host_template, size); - if (!scsi_host) { - osm_warn("Could not allocate SCSI host\n"); - return ERR_PTR(-ENOMEM); - } - - scsi_host->max_channel = max_channel - 1; - scsi_host->max_id = i2o_scsi_max_id; - scsi_host->max_lun = i2o_scsi_max_lun; - scsi_host->this_id = c->unit; - scsi_host->sg_tablesize = i2o_sg_tablesize(c, body_size); - - i2o_shost = (struct i2o_scsi_host *)scsi_host->hostdata; - i2o_shost->scsi_host = scsi_host; - i2o_shost->iop = c; - i2o_shost->lun = 1; - - i = 0; - list_for_each_entry(i2o_dev, &c->devices, list) - if (i2o_dev->lct_data.class_id == I2O_CLASS_BUS_ADAPTER) { - if (!i2o_parm_field_get(i2o_dev, 0x0000, 0, &type, 1) - && (type == 0x01)) /* only SCSI bus */ - i2o_shost->channel[i++] = i2o_dev; - - if (i >= max_channel) - break; - } - - return i2o_shost; -}; - -/** - * i2o_scsi_get_host - Get an I2O SCSI host - * @c: I2O controller to for which to get the SCSI host - * - * If the I2O controller already exists as SCSI host, the SCSI host - * is returned, otherwise the I2O controller is added to the SCSI - * core. - * - * Returns pointer to the I2O SCSI host on success or NULL on failure. - */ -static struct i2o_scsi_host *i2o_scsi_get_host(struct i2o_controller *c) -{ - return c->driver_data[i2o_scsi_driver.context]; -}; - -/** - * i2o_scsi_remove - Remove I2O device from SCSI core - * @dev: device which should be removed - * - * Removes the I2O device from the SCSI core again. - * - * Returns 0 on success. - */ -static int i2o_scsi_remove(struct device *dev) -{ - struct i2o_device *i2o_dev = to_i2o_device(dev); - struct i2o_controller *c = i2o_dev->iop; - struct i2o_scsi_host *i2o_shost; - struct scsi_device *scsi_dev; - - osm_info("device removed (TID: %03x)\n", i2o_dev->lct_data.tid); - - i2o_shost = i2o_scsi_get_host(c); - - shost_for_each_device(scsi_dev, i2o_shost->scsi_host) - if (scsi_dev->hostdata == i2o_dev) { - sysfs_remove_link(&i2o_dev->device.kobj, "scsi"); - scsi_remove_device(scsi_dev); - scsi_device_put(scsi_dev); - break; - } - - return 0; -}; - -/** - * i2o_scsi_probe - verify if dev is a I2O SCSI device and install it - * @dev: device to verify if it is a I2O SCSI device - * - * Retrieve channel, id and lun for I2O device. If everything goes well - * register the I2O device as SCSI device on the I2O SCSI controller. - * - * Returns 0 on success or negative error code on failure. - */ -static int i2o_scsi_probe(struct device *dev) -{ - struct i2o_device *i2o_dev = to_i2o_device(dev); - struct i2o_controller *c = i2o_dev->iop; - struct i2o_scsi_host *i2o_shost; - struct Scsi_Host *scsi_host; - struct i2o_device *parent; - struct scsi_device *scsi_dev; - u32 id = -1; - u64 lun = -1; - int channel = -1; - int i, rc; - - i2o_shost = i2o_scsi_get_host(c); - if (!i2o_shost) - return -EFAULT; - - scsi_host = i2o_shost->scsi_host; - - switch (i2o_dev->lct_data.class_id) { - case I2O_CLASS_RANDOM_BLOCK_STORAGE: - case I2O_CLASS_EXECUTIVE: -#ifdef CONFIG_I2O_EXT_ADAPTEC - if (c->adaptec) { - u8 type; - struct i2o_device *d = i2o_shost->channel[0]; - - if (!i2o_parm_field_get(d, 0x0000, 0, &type, 1) - && (type == 0x01)) /* SCSI bus */ - if (!i2o_parm_field_get(d, 0x0200, 4, &id, 4)) { - channel = 0; - if (i2o_dev->lct_data.class_id == - I2O_CLASS_RANDOM_BLOCK_STORAGE) - lun = - cpu_to_le64(i2o_shost-> - lun++); - else - lun = 0; - } - } -#endif - break; - - case I2O_CLASS_SCSI_PERIPHERAL: - if (i2o_parm_field_get(i2o_dev, 0x0000, 3, &id, 4)) - return -EFAULT; - - if (i2o_parm_field_get(i2o_dev, 0x0000, 4, &lun, 8)) - return -EFAULT; - - parent = i2o_iop_find_device(c, i2o_dev->lct_data.parent_tid); - if (!parent) { - osm_warn("can not find parent of device %03x\n", - i2o_dev->lct_data.tid); - return -EFAULT; - } - - for (i = 0; i <= i2o_shost->scsi_host->max_channel; i++) - if (i2o_shost->channel[i] == parent) - channel = i; - break; - - default: - return -EFAULT; - } - - if (channel == -1) { - osm_warn("can not find channel of device %03x\n", - i2o_dev->lct_data.tid); - return -EFAULT; - } - - if (le32_to_cpu(id) >= scsi_host->max_id) { - osm_warn("SCSI device id (%d) >= max_id of I2O host (%d)", - le32_to_cpu(id), scsi_host->max_id); - return -EFAULT; - } - - if (le64_to_cpu(lun) >= scsi_host->max_lun) { - osm_warn("SCSI device lun (%llu) >= max_lun of I2O host (%llu)", - le64_to_cpu(lun), scsi_host->max_lun); - return -EFAULT; - } - - scsi_dev = - __scsi_add_device(i2o_shost->scsi_host, channel, le32_to_cpu(id), - le64_to_cpu(lun), i2o_dev); - - if (IS_ERR(scsi_dev)) { - osm_warn("can not add SCSI device %03x\n", - i2o_dev->lct_data.tid); - return PTR_ERR(scsi_dev); - } - - rc = sysfs_create_link(&i2o_dev->device.kobj, - &scsi_dev->sdev_gendev.kobj, "scsi"); - if (rc) - goto err; - - osm_info("device added (TID: %03x) channel: %d, id: %d, lun: %llu\n", - i2o_dev->lct_data.tid, channel, le32_to_cpu(id), - le64_to_cpu(lun)); - - return 0; - -err: - scsi_remove_device(scsi_dev); - return rc; -}; - -static const char *i2o_scsi_info(struct Scsi_Host *SChost) -{ - struct i2o_scsi_host *hostdata; - hostdata = (struct i2o_scsi_host *)SChost->hostdata; - return hostdata->iop->name; -} - -/** - * i2o_scsi_reply - SCSI OSM message reply handler - * @c: controller issuing the reply - * @m: message id for flushing - * @msg: the message from the controller - * - * Process reply messages (interrupts in normal scsi controller think). - * We can get a variety of messages to process. The normal path is - * scsi command completions. We must also deal with IOP failures, - * the reply to a bus reset and the reply to a LUN query. - * - * Returns 0 on success and if the reply should not be flushed or > 0 - * on success and if the reply should be flushed. Returns negative error - * code on failure and if the reply should be flushed. - */ -static int i2o_scsi_reply(struct i2o_controller *c, u32 m, - struct i2o_message *msg) -{ - struct scsi_cmnd *cmd; - u32 error; - struct device *dev; - - cmd = i2o_cntxt_list_get(c, le32_to_cpu(msg->u.s.tcntxt)); - if (unlikely(!cmd)) { - osm_err("NULL reply received!\n"); - return -1; - } - - /* - * Low byte is device status, next is adapter status, - * (then one byte reserved), then request status. - */ - error = le32_to_cpu(msg->body[0]); - - osm_debug("Completed %0x%p\n", cmd); - - cmd->result = error & 0xff; - /* - * if DeviceStatus is not SCSI_SUCCESS copy over the sense data and let - * the SCSI layer handle the error - */ - if (cmd->result) - memcpy(cmd->sense_buffer, &msg->body[3], - min(SCSI_SENSE_BUFFERSIZE, 40)); - - /* only output error code if AdapterStatus is not HBA_SUCCESS */ - if ((error >> 8) & 0xff) - osm_err("SCSI error %08x\n", error); - - dev = &c->pdev->dev; - - scsi_dma_unmap(cmd); - - cmd->scsi_done(cmd); - - return 1; -}; - -/** - * i2o_scsi_notify_device_add - Retrieve notifications of added devices - * @i2o_dev: the I2O device which was added - * - * If a I2O device is added we catch the notification, because I2O classes - * other than SCSI peripheral will not be received through - * i2o_scsi_probe(). - */ -static void i2o_scsi_notify_device_add(struct i2o_device *i2o_dev) -{ - switch (i2o_dev->lct_data.class_id) { - case I2O_CLASS_EXECUTIVE: - case I2O_CLASS_RANDOM_BLOCK_STORAGE: - i2o_scsi_probe(&i2o_dev->device); - break; - - default: - break; - } -}; - -/** - * i2o_scsi_notify_device_remove - Retrieve notifications of removed devices - * @i2o_dev: the I2O device which was removed - * - * If a I2O device is removed, we catch the notification to remove the - * corresponding SCSI device. - */ -static void i2o_scsi_notify_device_remove(struct i2o_device *i2o_dev) -{ - switch (i2o_dev->lct_data.class_id) { - case I2O_CLASS_EXECUTIVE: - case I2O_CLASS_RANDOM_BLOCK_STORAGE: - i2o_scsi_remove(&i2o_dev->device); - break; - - default: - break; - } -}; - -/** - * i2o_scsi_notify_controller_add - Retrieve notifications of added controllers - * @c: the controller which was added - * - * If a I2O controller is added, we catch the notification to add a - * corresponding Scsi_Host. - */ -static void i2o_scsi_notify_controller_add(struct i2o_controller *c) -{ - struct i2o_scsi_host *i2o_shost; - int rc; - - i2o_shost = i2o_scsi_host_alloc(c); - if (IS_ERR(i2o_shost)) { - osm_err("Could not initialize SCSI host\n"); - return; - } - - rc = scsi_add_host(i2o_shost->scsi_host, &c->device); - if (rc) { - osm_err("Could not add SCSI host\n"); - scsi_host_put(i2o_shost->scsi_host); - return; - } - - c->driver_data[i2o_scsi_driver.context] = i2o_shost; - - osm_debug("new I2O SCSI host added\n"); -}; - -/** - * i2o_scsi_notify_controller_remove - Retrieve notifications of removed controllers - * @c: the controller which was removed - * - * If a I2O controller is removed, we catch the notification to remove the - * corresponding Scsi_Host. - */ -static void i2o_scsi_notify_controller_remove(struct i2o_controller *c) -{ - struct i2o_scsi_host *i2o_shost; - i2o_shost = i2o_scsi_get_host(c); - if (!i2o_shost) - return; - - c->driver_data[i2o_scsi_driver.context] = NULL; - - scsi_remove_host(i2o_shost->scsi_host); - scsi_host_put(i2o_shost->scsi_host); - osm_debug("I2O SCSI host removed\n"); -}; - -/* SCSI OSM driver struct */ -static struct i2o_driver i2o_scsi_driver = { - .name = OSM_NAME, - .reply = i2o_scsi_reply, - .classes = i2o_scsi_class_id, - .notify_device_add = i2o_scsi_notify_device_add, - .notify_device_remove = i2o_scsi_notify_device_remove, - .notify_controller_add = i2o_scsi_notify_controller_add, - .notify_controller_remove = i2o_scsi_notify_controller_remove, - .driver = { - .probe = i2o_scsi_probe, - .remove = i2o_scsi_remove, - }, -}; - -/** - * i2o_scsi_queuecommand - queue a SCSI command - * @SCpnt: scsi command pointer - * @done: callback for completion - * - * Issue a scsi command asynchronously. Return 0 on success or 1 if - * we hit an error (normally message queue congestion). The only - * minor complication here is that I2O deals with the device addressing - * so we have to map the bus/dev/lun back to an I2O handle as well - * as faking absent devices ourself. - * - * Locks: takes the controller lock on error path only - */ - -static int i2o_scsi_queuecommand_lck(struct scsi_cmnd *SCpnt, - void (*done) (struct scsi_cmnd *)) -{ - struct i2o_controller *c; - struct i2o_device *i2o_dev; - int tid; - struct i2o_message *msg; - /* - * ENABLE_DISCONNECT - * SIMPLE_TAG - * RETURN_SENSE_DATA_IN_REPLY_MESSAGE_FRAME - */ - u32 scsi_flags = 0x20a00000; - u32 sgl_offset; - u32 *mptr; - u32 cmd = I2O_CMD_SCSI_EXEC << 24; - int rc = 0; - - /* - * Do the incoming paperwork - */ - i2o_dev = SCpnt->device->hostdata; - - SCpnt->scsi_done = done; - - if (unlikely(!i2o_dev)) { - osm_warn("no I2O device in request\n"); - SCpnt->result = DID_NO_CONNECT << 16; - done(SCpnt); - goto exit; - } - c = i2o_dev->iop; - tid = i2o_dev->lct_data.tid; - - osm_debug("qcmd: Tid = %03x\n", tid); - osm_debug("Real scsi messages.\n"); - - /* - * Put together a scsi execscb message - */ - switch (SCpnt->sc_data_direction) { - case PCI_DMA_NONE: - /* DATA NO XFER */ - sgl_offset = SGL_OFFSET_0; - break; - - case PCI_DMA_TODEVICE: - /* DATA OUT (iop-->dev) */ - scsi_flags |= 0x80000000; - sgl_offset = SGL_OFFSET_10; - break; - - case PCI_DMA_FROMDEVICE: - /* DATA IN (iop<--dev) */ - scsi_flags |= 0x40000000; - sgl_offset = SGL_OFFSET_10; - break; - - default: - /* Unknown - kill the command */ - SCpnt->result = DID_NO_CONNECT << 16; - done(SCpnt); - goto exit; - } - - /* - * Obtain an I2O message. If there are none free then - * throw it back to the scsi layer - */ - - msg = i2o_msg_get(c); - if (IS_ERR(msg)) { - rc = SCSI_MLQUEUE_HOST_BUSY; - goto exit; - } - - mptr = &msg->body[0]; - -#if 0 /* this code can't work */ -#ifdef CONFIG_I2O_EXT_ADAPTEC - if (c->adaptec) { - u32 adpt_flags = 0; - - if (SCpnt->sc_request && SCpnt->sc_request->upper_private_data) { - i2o_sg_io_hdr_t __user *usr_ptr = - ((Sg_request *) (SCpnt->sc_request-> - upper_private_data))->header. - usr_ptr; - - if (usr_ptr) - get_user(adpt_flags, &usr_ptr->flags); - } - - switch (i2o_dev->lct_data.class_id) { - case I2O_CLASS_EXECUTIVE: - case I2O_CLASS_RANDOM_BLOCK_STORAGE: - /* interpret flag has to be set for executive */ - adpt_flags ^= I2O_DPT_SG_FLAG_INTERPRET; - break; - - default: - break; - } - - /* - * for Adaptec controllers we use the PRIVATE command, because - * the normal SCSI EXEC doesn't support all SCSI commands on - * all controllers (for example READ CAPACITY). - */ - if (sgl_offset == SGL_OFFSET_10) - sgl_offset = SGL_OFFSET_12; - cmd = I2O_CMD_PRIVATE << 24; - *mptr++ = cpu_to_le32(I2O_VENDOR_DPT << 16 | I2O_CMD_SCSI_EXEC); - *mptr++ = cpu_to_le32(adpt_flags | tid); - } -#endif -#endif - - msg->u.head[1] = cpu_to_le32(cmd | HOST_TID << 12 | tid); - msg->u.s.icntxt = cpu_to_le32(i2o_scsi_driver.context); - - /* We want the SCSI control block back */ - msg->u.s.tcntxt = cpu_to_le32(i2o_cntxt_list_add(c, SCpnt)); - - /* LSI_920_PCI_QUIRK - * - * Intermittant observations of msg frame word data corruption - * observed on msg[4] after: - * WRITE, READ-MODIFY-WRITE - * operations. 19990606 -sralston - * - * (Hence we build this word via tag. Its good practice anyway - * we don't want fetches over PCI needlessly) - */ - - /* Attach tags to the devices */ - /* FIXME: implement - if(SCpnt->device->tagged_supported) { - if(SCpnt->tag == HEAD_OF_QUEUE_TAG) - scsi_flags |= 0x01000000; - else if(SCpnt->tag == ORDERED_QUEUE_TAG) - scsi_flags |= 0x01800000; - } - */ - - *mptr++ = cpu_to_le32(scsi_flags | SCpnt->cmd_len); - - /* Write SCSI command into the message - always 16 byte block */ - memcpy(mptr, SCpnt->cmnd, 16); - mptr += 4; - - if (sgl_offset != SGL_OFFSET_0) { - /* write size of data addressed by SGL */ - *mptr++ = cpu_to_le32(scsi_bufflen(SCpnt)); - - /* Now fill in the SGList and command */ - - if (scsi_sg_count(SCpnt)) { - if (!i2o_dma_map_sg(c, scsi_sglist(SCpnt), - scsi_sg_count(SCpnt), - SCpnt->sc_data_direction, &mptr)) - goto nomem; - } - } - - /* Stick the headers on */ - msg->u.head[0] = - cpu_to_le32(I2O_MESSAGE_SIZE(mptr - &msg->u.head[0]) | sgl_offset); - - /* Queue the message */ - i2o_msg_post(c, msg); - - osm_debug("Issued %0x%p\n", SCpnt); - - return 0; - - nomem: - rc = -ENOMEM; - i2o_msg_nop(c, msg); - - exit: - return rc; -} - -static DEF_SCSI_QCMD(i2o_scsi_queuecommand) - -/** - * i2o_scsi_abort - abort a running command - * @SCpnt: command to abort - * - * Ask the I2O controller to abort a command. This is an asynchrnous - * process and our callback handler will see the command complete with an - * aborted message if it succeeds. - * - * Returns 0 if the command is successfully aborted or negative error code - * on failure. - */ -static int i2o_scsi_abort(struct scsi_cmnd *SCpnt) -{ - struct i2o_device *i2o_dev; - struct i2o_controller *c; - struct i2o_message *msg; - int tid; - int status = FAILED; - - osm_warn("Aborting command block.\n"); - - i2o_dev = SCpnt->device->hostdata; - c = i2o_dev->iop; - tid = i2o_dev->lct_data.tid; - - msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return SCSI_MLQUEUE_HOST_BUSY; - - msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0); - msg->u.head[1] = - cpu_to_le32(I2O_CMD_SCSI_ABORT << 24 | HOST_TID << 12 | tid); - msg->body[0] = cpu_to_le32(i2o_cntxt_list_get_ptr(c, SCpnt)); - - if (!i2o_msg_post_wait(c, msg, I2O_TIMEOUT_SCSI_SCB_ABORT)) - status = SUCCESS; - - return status; -} - -/** - * i2o_scsi_bios_param - Invent disk geometry - * @sdev: scsi device - * @dev: block layer device - * @capacity: size in sectors - * @ip: geometry array - * - * This is anyone's guess quite frankly. We use the same rules everyone - * else appears to and hope. It seems to work. - */ - -static int i2o_scsi_bios_param(struct scsi_device *sdev, - struct block_device *dev, sector_t capacity, - int *ip) -{ - int size; - - size = capacity; - ip[0] = 64; /* heads */ - ip[1] = 32; /* sectors */ - if ((ip[2] = size >> 11) > 1024) { /* cylinders, test for big disk */ - ip[0] = 255; /* heads */ - ip[1] = 63; /* sectors */ - ip[2] = size / (255 * 63); /* cylinders */ - } - return 0; -} - -static struct scsi_host_template i2o_scsi_host_template = { - .proc_name = OSM_NAME, - .name = OSM_DESCRIPTION, - .info = i2o_scsi_info, - .queuecommand = i2o_scsi_queuecommand, - .eh_abort_handler = i2o_scsi_abort, - .bios_param = i2o_scsi_bios_param, - .can_queue = I2O_SCSI_CAN_QUEUE, - .sg_tablesize = 8, - .cmd_per_lun = 6, - .use_clustering = ENABLE_CLUSTERING, -}; - -/** - * i2o_scsi_init - SCSI OSM initialization function - * - * Register SCSI OSM into I2O core. - * - * Returns 0 on success or negative error code on failure. - */ -static int __init i2o_scsi_init(void) -{ - int rc; - - printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n"); - - /* Register SCSI OSM into I2O core */ - rc = i2o_driver_register(&i2o_scsi_driver); - if (rc) { - osm_err("Could not register SCSI driver\n"); - return rc; - } - - return 0; -}; - -/** - * i2o_scsi_exit - SCSI OSM exit function - * - * Unregisters SCSI OSM from I2O core. - */ -static void __exit i2o_scsi_exit(void) -{ - /* Unregister I2O SCSI OSM from I2O core */ - i2o_driver_unregister(&i2o_scsi_driver); -}; - -MODULE_AUTHOR("Red Hat Software"); -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION(OSM_DESCRIPTION); -MODULE_VERSION(OSM_VERSION); - -module_init(i2o_scsi_init); -module_exit(i2o_scsi_exit); diff --git a/drivers/staging/i2o/iop.c b/drivers/staging/i2o/iop.c deleted file mode 100644 index 3c2379097586..000000000000 --- a/drivers/staging/i2o/iop.c +++ /dev/null @@ -1,1254 +0,0 @@ -/* - * Functions to handle I2O controllers and I2O message handling - * - * Copyright (C) 1999-2002 Red Hat Software - * - * Written by Alan Cox, Building Number Three Ltd - * - * 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. - * - * A lot of the I2O message side code from this is taken from the - * Red Creek RCPCI45 adapter driver by Red Creek Communications - * - * Fixes/additions: - * Philipp Rumpf - * Juha Sievänen - * Auvo Häkkinen - * Deepak Saxena - * Boji T Kannanthanam - * Alan Cox : - * Ported to Linux 2.5. - * Markus Lidel : - * Minor fixes for 2.6. - */ - -#include -#include "i2o.h" -#include -#include -#include -#include "core.h" - -#define OSM_NAME "i2o" -#define OSM_VERSION "1.325" -#define OSM_DESCRIPTION "I2O subsystem" - -/* global I2O controller list */ -LIST_HEAD(i2o_controllers); - -/* - * global I2O System Table. Contains information about all the IOPs in the - * system. Used to inform IOPs about each others existence. - */ -static struct i2o_dma i2o_systab; - -static int i2o_hrt_get(struct i2o_controller *c); - -/** - * i2o_msg_get_wait - obtain an I2O message from the IOP - * @c: I2O controller - * @wait: how long to wait until timeout - * - * This function waits up to wait seconds for a message slot to be - * available. - * - * On a success the message is returned and the pointer to the message is - * set in msg. The returned message is the physical page frame offset - * address from the read port (see the i2o spec). If no message is - * available returns I2O_QUEUE_EMPTY and msg is leaved untouched. - */ -struct i2o_message *i2o_msg_get_wait(struct i2o_controller *c, int wait) -{ - unsigned long timeout = jiffies + wait * HZ; - struct i2o_message *msg; - - while (IS_ERR(msg = i2o_msg_get(c))) { - if (time_after(jiffies, timeout)) { - osm_debug("%s: Timeout waiting for message frame.\n", - c->name); - return ERR_PTR(-ETIMEDOUT); - } - schedule_timeout_uninterruptible(1); - } - - return msg; -} - -#if BITS_PER_LONG == 64 -/** - * i2o_cntxt_list_add - Append a pointer to context list and return a id - * @c: controller to which the context list belong - * @ptr: pointer to add to the context list - * - * Because the context field in I2O is only 32-bit large, on 64-bit the - * pointer is to large to fit in the context field. The i2o_cntxt_list - * functions therefore map pointers to context fields. - * - * Returns context id > 0 on success or 0 on failure. - */ -u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr) -{ - struct i2o_context_list_element *entry; - unsigned long flags; - - if (!ptr) - osm_err("%s: couldn't add NULL pointer to context list!\n", - c->name); - - entry = kmalloc(sizeof(*entry), GFP_ATOMIC); - if (!entry) { - osm_err("%s: Could not allocate memory for context list element" - "\n", c->name); - return 0; - } - - entry->ptr = ptr; - entry->timestamp = jiffies; - INIT_LIST_HEAD(&entry->list); - - spin_lock_irqsave(&c->context_list_lock, flags); - - if (unlikely(atomic_inc_and_test(&c->context_list_counter))) - atomic_inc(&c->context_list_counter); - - entry->context = atomic_read(&c->context_list_counter); - - list_add(&entry->list, &c->context_list); - - spin_unlock_irqrestore(&c->context_list_lock, flags); - - osm_debug("%s: Add context to list %p -> %d\n", c->name, ptr, context); - - return entry->context; -} - -/** - * i2o_cntxt_list_remove - Remove a pointer from the context list - * @c: controller to which the context list belong - * @ptr: pointer which should be removed from the context list - * - * Removes a previously added pointer from the context list and returns - * the matching context id. - * - * Returns context id on success or 0 on failure. - */ -u32 i2o_cntxt_list_remove(struct i2o_controller * c, void *ptr) -{ - struct i2o_context_list_element *entry; - u32 context = 0; - unsigned long flags; - - spin_lock_irqsave(&c->context_list_lock, flags); - list_for_each_entry(entry, &c->context_list, list) - if (entry->ptr == ptr) { - list_del(&entry->list); - context = entry->context; - kfree(entry); - break; - } - spin_unlock_irqrestore(&c->context_list_lock, flags); - - if (!context) - osm_warn("%s: Could not remove nonexistent ptr %p\n", c->name, - ptr); - - osm_debug("%s: remove ptr from context list %d -> %p\n", c->name, - context, ptr); - - return context; -} - -/** - * i2o_cntxt_list_get - Get a pointer from the context list and remove it - * @c: controller to which the context list belong - * @context: context id to which the pointer belong - * - * Returns pointer to the matching context id on success or NULL on - * failure. - */ -void *i2o_cntxt_list_get(struct i2o_controller *c, u32 context) -{ - struct i2o_context_list_element *entry; - unsigned long flags; - void *ptr = NULL; - - spin_lock_irqsave(&c->context_list_lock, flags); - list_for_each_entry(entry, &c->context_list, list) - if (entry->context == context) { - list_del(&entry->list); - ptr = entry->ptr; - kfree(entry); - break; - } - spin_unlock_irqrestore(&c->context_list_lock, flags); - - if (!ptr) - osm_warn("%s: context id %d not found\n", c->name, context); - - osm_debug("%s: get ptr from context list %d -> %p\n", c->name, context, - ptr); - - return ptr; -} - -/** - * i2o_cntxt_list_get_ptr - Get a context id from the context list - * @c: controller to which the context list belong - * @ptr: pointer to which the context id should be fetched - * - * Returns context id which matches to the pointer on success or 0 on - * failure. - */ -u32 i2o_cntxt_list_get_ptr(struct i2o_controller * c, void *ptr) -{ - struct i2o_context_list_element *entry; - u32 context = 0; - unsigned long flags; - - spin_lock_irqsave(&c->context_list_lock, flags); - list_for_each_entry(entry, &c->context_list, list) - if (entry->ptr == ptr) { - context = entry->context; - break; - } - spin_unlock_irqrestore(&c->context_list_lock, flags); - - if (!context) - osm_warn("%s: Could not find nonexistent ptr %p\n", c->name, - ptr); - - osm_debug("%s: get context id from context list %p -> %d\n", c->name, - ptr, context); - - return context; -} -#endif - -/** - * i2o_iop_find - Find an I2O controller by id - * @unit: unit number of the I2O controller to search for - * - * Lookup the I2O controller on the controller list. - * - * Returns pointer to the I2O controller on success or NULL if not found. - */ -struct i2o_controller *i2o_find_iop(int unit) -{ - struct i2o_controller *c; - - list_for_each_entry(c, &i2o_controllers, list) { - if (c->unit == unit) - return c; - } - - return NULL; -} - -/** - * i2o_iop_find_device - Find a I2O device on an I2O controller - * @c: I2O controller where the I2O device hangs on - * @tid: TID of the I2O device to search for - * - * Searches the devices of the I2O controller for a device with TID tid and - * returns it. - * - * Returns a pointer to the I2O device if found, otherwise NULL. - */ -struct i2o_device *i2o_iop_find_device(struct i2o_controller *c, u16 tid) -{ - struct i2o_device *dev; - - list_for_each_entry(dev, &c->devices, list) - if (dev->lct_data.tid == tid) - return dev; - - return NULL; -} - -/** - * i2o_quiesce_controller - quiesce controller - * @c: controller - * - * Quiesce an IOP. Causes IOP to make external operation quiescent - * (i2o 'READY' state). Internal operation of the IOP continues normally. - * - * Returns 0 on success or negative error code on failure. - */ -static int i2o_iop_quiesce(struct i2o_controller *c) -{ - struct i2o_message *msg; - i2o_status_block *sb = c->status_block.virt; - int rc; - - i2o_status_get(c); - - /* SysQuiesce discarded if IOP not in READY or OPERATIONAL state */ - if ((sb->iop_state != ADAPTER_STATE_READY) && - (sb->iop_state != ADAPTER_STATE_OPERATIONAL)) - return 0; - - msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0); - msg->u.head[1] = - cpu_to_le32(I2O_CMD_SYS_QUIESCE << 24 | HOST_TID << 12 | - ADAPTER_TID); - - /* Long timeout needed for quiesce if lots of devices */ - rc = i2o_msg_post_wait(c, msg, 240); - if (rc) - osm_info("%s: Unable to quiesce (status=%#x).\n", c->name, -rc); - else - osm_debug("%s: Quiesced.\n", c->name); - - i2o_status_get(c); // Entered READY state - - return rc; -} - -/** - * i2o_iop_enable - move controller from ready to OPERATIONAL - * @c: I2O controller - * - * Enable IOP. This allows the IOP to resume external operations and - * reverses the effect of a quiesce. Returns zero or an error code if - * an error occurs. - */ -static int i2o_iop_enable(struct i2o_controller *c) -{ - struct i2o_message *msg; - i2o_status_block *sb = c->status_block.virt; - int rc; - - i2o_status_get(c); - - /* Enable only allowed on READY state */ - if (sb->iop_state != ADAPTER_STATE_READY) - return -EINVAL; - - msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0); - msg->u.head[1] = - cpu_to_le32(I2O_CMD_SYS_ENABLE << 24 | HOST_TID << 12 | - ADAPTER_TID); - - /* How long of a timeout do we need? */ - rc = i2o_msg_post_wait(c, msg, 240); - if (rc) - osm_err("%s: Could not enable (status=%#x).\n", c->name, -rc); - else - osm_debug("%s: Enabled.\n", c->name); - - i2o_status_get(c); // entered OPERATIONAL state - - return rc; -} - -/** - * i2o_iop_quiesce_all - Quiesce all I2O controllers on the system - * - * Quiesce all I2O controllers which are connected to the system. - */ -static inline void i2o_iop_quiesce_all(void) -{ - struct i2o_controller *c, *tmp; - - list_for_each_entry_safe(c, tmp, &i2o_controllers, list) { - if (!c->no_quiesce) - i2o_iop_quiesce(c); - } -} - -/** - * i2o_iop_enable_all - Enables all controllers on the system - * - * Enables all I2O controllers which are connected to the system. - */ -static inline void i2o_iop_enable_all(void) -{ - struct i2o_controller *c, *tmp; - - list_for_each_entry_safe(c, tmp, &i2o_controllers, list) - i2o_iop_enable(c); -} - -/** - * i2o_clear_controller - Bring I2O controller into HOLD state - * @c: controller - * - * Clear an IOP to HOLD state, ie. terminate external operations, clear all - * input queues and prepare for a system restart. IOP's internal operation - * continues normally and the outbound queue is alive. The IOP is not - * expected to rebuild its LCT. - * - * Returns 0 on success or negative error code on failure. - */ -static int i2o_iop_clear(struct i2o_controller *c) -{ - struct i2o_message *msg; - int rc; - - msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - /* Quiesce all IOPs first */ - i2o_iop_quiesce_all(); - - msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0); - msg->u.head[1] = - cpu_to_le32(I2O_CMD_ADAPTER_CLEAR << 24 | HOST_TID << 12 | - ADAPTER_TID); - - rc = i2o_msg_post_wait(c, msg, 30); - if (rc) - osm_info("%s: Unable to clear (status=%#x).\n", c->name, -rc); - else - osm_debug("%s: Cleared.\n", c->name); - - /* Enable all IOPs */ - i2o_iop_enable_all(); - - return rc; -} - -/** - * i2o_iop_init_outbound_queue - setup the outbound message queue - * @c: I2O controller - * - * Clear and (re)initialize IOP's outbound queue and post the message - * frames to the IOP. - * - * Returns 0 on success or negative error code on failure. - */ -static int i2o_iop_init_outbound_queue(struct i2o_controller *c) -{ - u32 m; - volatile u8 *status = c->status.virt; - struct i2o_message *msg; - ulong timeout; - int i; - - osm_debug("%s: Initializing Outbound Queue...\n", c->name); - - memset(c->status.virt, 0, 4); - - msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->u.head[0] = cpu_to_le32(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6); - msg->u.head[1] = - cpu_to_le32(I2O_CMD_OUTBOUND_INIT << 24 | HOST_TID << 12 | - ADAPTER_TID); - msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context); - msg->u.s.tcntxt = cpu_to_le32(0x00000000); - msg->body[0] = cpu_to_le32(PAGE_SIZE); - /* Outbound msg frame size in words and Initcode */ - msg->body[1] = cpu_to_le32(I2O_OUTBOUND_MSG_FRAME_SIZE << 16 | 0x80); - msg->body[2] = cpu_to_le32(0xd0000004); - msg->body[3] = cpu_to_le32(i2o_dma_low(c->status.phys)); - msg->body[4] = cpu_to_le32(i2o_dma_high(c->status.phys)); - - i2o_msg_post(c, msg); - - timeout = jiffies + I2O_TIMEOUT_INIT_OUTBOUND_QUEUE * HZ; - while (*status <= I2O_CMD_IN_PROGRESS) { - if (time_after(jiffies, timeout)) { - osm_warn("%s: Timeout Initializing\n", c->name); - return -ETIMEDOUT; - } - schedule_timeout_uninterruptible(1); - } - - m = c->out_queue.phys; - - /* Post frames */ - for (i = 0; i < I2O_MAX_OUTBOUND_MSG_FRAMES; i++) { - i2o_flush_reply(c, m); - udelay(1); /* Promise */ - m += I2O_OUTBOUND_MSG_FRAME_SIZE * sizeof(u32); - } - - return 0; -} - -/** - * i2o_iop_reset - reset an I2O controller - * @c: controller to reset - * - * Reset the IOP into INIT state and wait until IOP gets into RESET state. - * Terminate all external operations, clear IOP's inbound and outbound - * queues, terminate all DDMs, and reload the IOP's operating environment - * and all local DDMs. The IOP rebuilds its LCT. - */ -static int i2o_iop_reset(struct i2o_controller *c) -{ - volatile u8 *status = c->status.virt; - struct i2o_message *msg; - unsigned long timeout; - i2o_status_block *sb = c->status_block.virt; - int rc = 0; - - osm_debug("%s: Resetting controller\n", c->name); - - msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - memset(c->status_block.virt, 0, 8); - - /* Quiesce all IOPs first */ - i2o_iop_quiesce_all(); - - msg->u.head[0] = cpu_to_le32(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_0); - msg->u.head[1] = - cpu_to_le32(I2O_CMD_ADAPTER_RESET << 24 | HOST_TID << 12 | - ADAPTER_TID); - msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context); - msg->u.s.tcntxt = cpu_to_le32(0x00000000); - msg->body[0] = cpu_to_le32(0x00000000); - msg->body[1] = cpu_to_le32(0x00000000); - msg->body[2] = cpu_to_le32(i2o_dma_low(c->status.phys)); - msg->body[3] = cpu_to_le32(i2o_dma_high(c->status.phys)); - - i2o_msg_post(c, msg); - - /* Wait for a reply */ - timeout = jiffies + I2O_TIMEOUT_RESET * HZ; - while (!*status) { - if (time_after(jiffies, timeout)) - break; - - schedule_timeout_uninterruptible(1); - } - - switch (*status) { - case I2O_CMD_REJECTED: - osm_warn("%s: IOP reset rejected\n", c->name); - rc = -EPERM; - break; - - case I2O_CMD_IN_PROGRESS: - /* - * Once the reset is sent, the IOP goes into the INIT state - * which is indeterminate. We need to wait until the IOP has - * rebooted before we can let the system talk to it. We read - * the inbound Free_List until a message is available. If we - * can't read one in the given amount of time, we assume the - * IOP could not reboot properly. - */ - osm_debug("%s: Reset in progress, waiting for reboot...\n", - c->name); - - while (IS_ERR(msg = i2o_msg_get_wait(c, I2O_TIMEOUT_RESET))) { - if (time_after(jiffies, timeout)) { - osm_err("%s: IOP reset timeout.\n", c->name); - rc = PTR_ERR(msg); - goto exit; - } - schedule_timeout_uninterruptible(1); - } - i2o_msg_nop(c, msg); - - /* from here all quiesce commands are safe */ - c->no_quiesce = 0; - - /* verify if controller is in state RESET */ - i2o_status_get(c); - - if (!c->promise && (sb->iop_state != ADAPTER_STATE_RESET)) - osm_warn("%s: reset completed, but adapter not in RESET" - " state.\n", c->name); - else - osm_debug("%s: reset completed.\n", c->name); - - break; - - default: - osm_err("%s: IOP reset timeout.\n", c->name); - rc = -ETIMEDOUT; - break; - } - - exit: - /* Enable all IOPs */ - i2o_iop_enable_all(); - - return rc; -} - -/** - * i2o_iop_activate - Bring controller up to HOLD - * @c: controller - * - * This function brings an I2O controller into HOLD state. The adapter - * is reset if necessary and then the queues and resource table are read. - * - * Returns 0 on success or negative error code on failure. - */ -static int i2o_iop_activate(struct i2o_controller *c) -{ - i2o_status_block *sb = c->status_block.virt; - int rc; - int state; - - /* In INIT state, Wait Inbound Q to initialize (in i2o_status_get) */ - /* In READY state, Get status */ - - rc = i2o_status_get(c); - if (rc) { - osm_info("%s: Unable to obtain status, attempting a reset.\n", - c->name); - rc = i2o_iop_reset(c); - if (rc) - return rc; - } - - if (sb->i2o_version > I2OVER15) { - osm_err("%s: Not running version 1.5 of the I2O Specification." - "\n", c->name); - return -ENODEV; - } - - switch (sb->iop_state) { - case ADAPTER_STATE_FAULTED: - osm_err("%s: hardware fault\n", c->name); - return -EFAULT; - - case ADAPTER_STATE_READY: - case ADAPTER_STATE_OPERATIONAL: - case ADAPTER_STATE_HOLD: - case ADAPTER_STATE_FAILED: - osm_debug("%s: already running, trying to reset...\n", c->name); - rc = i2o_iop_reset(c); - if (rc) - return rc; - } - - /* preserve state */ - state = sb->iop_state; - - rc = i2o_iop_init_outbound_queue(c); - if (rc) - return rc; - - /* if adapter was not in RESET state clear now */ - if (state != ADAPTER_STATE_RESET) - i2o_iop_clear(c); - - i2o_status_get(c); - - if (sb->iop_state != ADAPTER_STATE_HOLD) { - osm_err("%s: failed to bring IOP into HOLD state\n", c->name); - return -EIO; - } - - return i2o_hrt_get(c); -} - -static void i2o_res_alloc(struct i2o_controller *c, unsigned long flags) -{ - i2o_status_block *sb = c->status_block.virt; - struct resource *res = &c->mem_resource; - resource_size_t size, align; - int err; - - res->name = c->pdev->bus->name; - res->flags = flags; - res->start = 0; - res->end = 0; - osm_info("%s: requires private memory resources.\n", c->name); - - if (flags & IORESOURCE_MEM) { - size = sb->desired_mem_size; - align = 1 << 20; /* unspecified, use 1Mb and play safe */ - } else { - size = sb->desired_io_size; - align = 1 << 12; /* unspecified, use 4Kb and play safe */ - } - - err = pci_bus_alloc_resource(c->pdev->bus, res, size, align, 0, 0, - NULL, NULL); - if (err < 0) - return; - - if (flags & IORESOURCE_MEM) { - c->mem_alloc = 1; - sb->current_mem_size = resource_size(res); - sb->current_mem_base = res->start; - } else if (flags & IORESOURCE_IO) { - c->io_alloc = 1; - sb->current_io_size = resource_size(res); - sb->current_io_base = res->start; - } - osm_info("%s: allocated PCI space %pR\n", c->name, res); -} - -/** - * i2o_iop_systab_set - Set the I2O System Table of the specified IOP - * @c: I2O controller to which the system table should be send - * - * Before the systab could be set i2o_systab_build() must be called. - * - * Returns 0 on success or negative error code on failure. - */ -static int i2o_iop_systab_set(struct i2o_controller *c) -{ - struct i2o_message *msg; - i2o_status_block *sb = c->status_block.virt; - struct device *dev = &c->pdev->dev; - int rc; - - if (sb->current_mem_size < sb->desired_mem_size) - i2o_res_alloc(c, IORESOURCE_MEM); - - if (sb->current_io_size < sb->desired_io_size) - i2o_res_alloc(c, IORESOURCE_IO); - - msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - i2o_systab.phys = dma_map_single(dev, i2o_systab.virt, i2o_systab.len, - PCI_DMA_TODEVICE); - if (!i2o_systab.phys) { - i2o_msg_nop(c, msg); - return -ENOMEM; - } - - msg->u.head[0] = cpu_to_le32(I2O_MESSAGE_SIZE(12) | SGL_OFFSET_6); - msg->u.head[1] = - cpu_to_le32(I2O_CMD_SYS_TAB_SET << 24 | HOST_TID << 12 | - ADAPTER_TID); - - /* - * Provide three SGL-elements: - * System table (SysTab), Private memory space declaration and - * Private i/o space declaration - */ - - msg->body[0] = cpu_to_le32(c->unit + 2); - msg->body[1] = cpu_to_le32(0x00000000); - msg->body[2] = cpu_to_le32(0x54000000 | i2o_systab.len); - msg->body[3] = cpu_to_le32(i2o_systab.phys); - msg->body[4] = cpu_to_le32(0x54000000 | sb->current_mem_size); - msg->body[5] = cpu_to_le32(sb->current_mem_base); - msg->body[6] = cpu_to_le32(0xd4000000 | sb->current_io_size); - msg->body[6] = cpu_to_le32(sb->current_io_base); - - rc = i2o_msg_post_wait(c, msg, 120); - - dma_unmap_single(dev, i2o_systab.phys, i2o_systab.len, - PCI_DMA_TODEVICE); - - if (rc < 0) - osm_err("%s: Unable to set SysTab (status=%#x).\n", c->name, - -rc); - else - osm_debug("%s: SysTab set.\n", c->name); - - return rc; -} - -/** - * i2o_iop_online - Bring a controller online into OPERATIONAL state. - * @c: I2O controller - * - * Send the system table and enable the I2O controller. - * - * Returns 0 on success or negative error code on failure. - */ -static int i2o_iop_online(struct i2o_controller *c) -{ - int rc; - - rc = i2o_iop_systab_set(c); - if (rc) - return rc; - - /* In READY state */ - osm_debug("%s: Attempting to enable...\n", c->name); - return i2o_iop_enable(c); -} - -/** - * i2o_iop_remove - Remove the I2O controller from the I2O core - * @c: I2O controller - * - * Remove the I2O controller from the I2O core. If devices are attached to - * the controller remove these also and finally reset the controller. - */ -void i2o_iop_remove(struct i2o_controller *c) -{ - struct i2o_device *dev, *tmp; - - osm_debug("%s: deleting controller\n", c->name); - - i2o_driver_notify_controller_remove_all(c); - - list_del(&c->list); - - list_for_each_entry_safe(dev, tmp, &c->devices, list) - i2o_device_remove(dev); - - device_del(&c->device); - - /* Ask the IOP to switch to RESET state */ - i2o_iop_reset(c); -} - -/** - * i2o_systab_build - Build system table - * - * The system table contains information about all the IOPs in the system - * (duh) and is used by the Executives on the IOPs to establish peer2peer - * connections. We're not supporting peer2peer at the moment, but this - * will be needed down the road for things like lan2lan forwarding. - * - * Returns 0 on success or negative error code on failure. - */ -static int i2o_systab_build(void) -{ - struct i2o_controller *c, *tmp; - int num_controllers = 0; - u32 change_ind = 0; - int count = 0; - struct i2o_sys_tbl *systab = i2o_systab.virt; - - list_for_each_entry_safe(c, tmp, &i2o_controllers, list) - num_controllers++; - - if (systab) { - change_ind = systab->change_ind; - kfree(i2o_systab.virt); - } - - /* Header + IOPs */ - i2o_systab.len = sizeof(struct i2o_sys_tbl) + num_controllers * - sizeof(struct i2o_sys_tbl_entry); - - systab = i2o_systab.virt = kzalloc(i2o_systab.len, GFP_KERNEL); - if (!systab) { - osm_err("unable to allocate memory for System Table\n"); - return -ENOMEM; - } - - systab->version = I2OVERSION; - systab->change_ind = change_ind + 1; - - list_for_each_entry_safe(c, tmp, &i2o_controllers, list) { - i2o_status_block *sb; - - if (count >= num_controllers) { - osm_err("controller added while building system table" - "\n"); - break; - } - - sb = c->status_block.virt; - - /* - * Get updated IOP state so we have the latest information - * - * We should delete the controller at this point if it - * doesn't respond since if it's not on the system table - * it is techninically not part of the I2O subsystem... - */ - if (unlikely(i2o_status_get(c))) { - osm_err("%s: Deleting b/c could not get status while " - "attempting to build system table\n", c->name); - i2o_iop_remove(c); - continue; // try the next one - } - - systab->iops[count].org_id = sb->org_id; - systab->iops[count].iop_id = c->unit + 2; - systab->iops[count].seg_num = 0; - systab->iops[count].i2o_version = sb->i2o_version; - systab->iops[count].iop_state = sb->iop_state; - systab->iops[count].msg_type = sb->msg_type; - systab->iops[count].frame_size = sb->inbound_frame_size; - systab->iops[count].last_changed = change_ind; - systab->iops[count].iop_capabilities = sb->iop_capabilities; - systab->iops[count].inbound_low = - i2o_dma_low(c->base.phys + I2O_IN_PORT); - systab->iops[count].inbound_high = - i2o_dma_high(c->base.phys + I2O_IN_PORT); - - count++; - } - - systab->num_entries = count; - - return 0; -} - -/** - * i2o_parse_hrt - Parse the hardware resource table. - * @c: I2O controller - * - * We don't do anything with it except dumping it (in debug mode). - * - * Returns 0. - */ -static int i2o_parse_hrt(struct i2o_controller *c) -{ - i2o_dump_hrt(c); - return 0; -} - -/** - * i2o_status_get - Get the status block from the I2O controller - * @c: I2O controller - * - * Issue a status query on the controller. This updates the attached - * status block. The status block could then be accessed through - * c->status_block. - * - * Returns 0 on success or negative error code on failure. - */ -int i2o_status_get(struct i2o_controller *c) -{ - struct i2o_message *msg; - volatile u8 *status_block; - unsigned long timeout; - - status_block = (u8 *) c->status_block.virt; - memset(c->status_block.virt, 0, sizeof(i2o_status_block)); - - msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->u.head[0] = cpu_to_le32(NINE_WORD_MSG_SIZE | SGL_OFFSET_0); - msg->u.head[1] = - cpu_to_le32(I2O_CMD_STATUS_GET << 24 | HOST_TID << 12 | - ADAPTER_TID); - msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context); - msg->u.s.tcntxt = cpu_to_le32(0x00000000); - msg->body[0] = cpu_to_le32(0x00000000); - msg->body[1] = cpu_to_le32(0x00000000); - msg->body[2] = cpu_to_le32(i2o_dma_low(c->status_block.phys)); - msg->body[3] = cpu_to_le32(i2o_dma_high(c->status_block.phys)); - msg->body[4] = cpu_to_le32(sizeof(i2o_status_block)); /* always 88 bytes */ - - i2o_msg_post(c, msg); - - /* Wait for a reply */ - timeout = jiffies + I2O_TIMEOUT_STATUS_GET * HZ; - while (status_block[87] != 0xFF) { - if (time_after(jiffies, timeout)) { - osm_err("%s: Get status timeout.\n", c->name); - return -ETIMEDOUT; - } - - schedule_timeout_uninterruptible(1); - } - -#ifdef DEBUG - i2o_debug_state(c); -#endif - - return 0; -} - -/* - * i2o_hrt_get - Get the Hardware Resource Table from the I2O controller - * @c: I2O controller from which the HRT should be fetched - * - * The HRT contains information about possible hidden devices but is - * mostly useless to us. - * - * Returns 0 on success or negative error code on failure. - */ -static int i2o_hrt_get(struct i2o_controller *c) -{ - int rc; - int i; - i2o_hrt *hrt = c->hrt.virt; - u32 size = sizeof(i2o_hrt); - struct device *dev = &c->pdev->dev; - - for (i = 0; i < I2O_HRT_GET_TRIES; i++) { - struct i2o_message *msg; - - msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->u.head[0] = cpu_to_le32(SIX_WORD_MSG_SIZE | SGL_OFFSET_4); - msg->u.head[1] = - cpu_to_le32(I2O_CMD_HRT_GET << 24 | HOST_TID << 12 | - ADAPTER_TID); - msg->body[0] = cpu_to_le32(0xd0000000 | c->hrt.len); - msg->body[1] = cpu_to_le32(c->hrt.phys); - - rc = i2o_msg_post_wait_mem(c, msg, 20, &c->hrt); - - if (rc < 0) { - osm_err("%s: Unable to get HRT (status=%#x)\n", c->name, - -rc); - return rc; - } - - size = hrt->num_entries * hrt->entry_len << 2; - if (size > c->hrt.len) { - if (i2o_dma_realloc(dev, &c->hrt, size)) - return -ENOMEM; - else - hrt = c->hrt.virt; - } else - return i2o_parse_hrt(c); - } - - osm_err("%s: Unable to get HRT after %d tries, giving up\n", c->name, - I2O_HRT_GET_TRIES); - - return -EBUSY; -} - -/** - * i2o_iop_release - release the memory for a I2O controller - * @dev: I2O controller which should be released - * - * Release the allocated memory. This function is called if refcount of - * device reaches 0 automatically. - */ -static void i2o_iop_release(struct device *dev) -{ - struct i2o_controller *c = to_i2o_controller(dev); - - i2o_iop_free(c); -} - -/** - * i2o_iop_alloc - Allocate and initialize a i2o_controller struct - * - * Allocate the necessary memory for a i2o_controller struct and - * initialize the lists and message mempool. - * - * Returns a pointer to the I2O controller or a negative error code on - * failure. - */ -struct i2o_controller *i2o_iop_alloc(void) -{ - static int unit; /* 0 and 1 are NULL IOP and Local Host */ - struct i2o_controller *c; - char poolname[32]; - - c = kzalloc(sizeof(*c), GFP_KERNEL); - if (!c) { - osm_err("i2o: Insufficient memory to allocate a I2O controller." - "\n"); - return ERR_PTR(-ENOMEM); - } - - c->unit = unit++; - sprintf(c->name, "iop%d", c->unit); - - snprintf(poolname, sizeof(poolname), "i2o_%s_msg_inpool", c->name); - if (i2o_pool_alloc - (&c->in_msg, poolname, I2O_INBOUND_MSG_FRAME_SIZE * 4 + sizeof(u32), - I2O_MSG_INPOOL_MIN)) { - kfree(c); - return ERR_PTR(-ENOMEM); - } - - INIT_LIST_HEAD(&c->devices); - spin_lock_init(&c->lock); - mutex_init(&c->lct_lock); - - device_initialize(&c->device); - - c->device.release = &i2o_iop_release; - - dev_set_name(&c->device, "iop%d", c->unit); - -#if BITS_PER_LONG == 64 - spin_lock_init(&c->context_list_lock); - atomic_set(&c->context_list_counter, 0); - INIT_LIST_HEAD(&c->context_list); -#endif - - return c; -} - -/** - * i2o_iop_add - Initialize the I2O controller and add him to the I2O core - * @c: controller - * - * Initialize the I2O controller and if no error occurs add him to the I2O - * core. - * - * Returns 0 on success or negative error code on failure. - */ -int i2o_iop_add(struct i2o_controller *c) -{ - int rc; - - rc = device_add(&c->device); - if (rc) { - osm_err("%s: could not add controller\n", c->name); - goto iop_reset; - } - - osm_info("%s: Activating I2O controller...\n", c->name); - osm_info("%s: This may take a few minutes if there are many devices\n", - c->name); - - rc = i2o_iop_activate(c); - if (rc) { - osm_err("%s: could not activate controller\n", c->name); - goto device_del; - } - - osm_debug("%s: building sys table...\n", c->name); - - rc = i2o_systab_build(); - if (rc) - goto device_del; - - osm_debug("%s: online controller...\n", c->name); - - rc = i2o_iop_online(c); - if (rc) - goto device_del; - - osm_debug("%s: getting LCT...\n", c->name); - - rc = i2o_exec_lct_get(c); - if (rc) - goto device_del; - - list_add(&c->list, &i2o_controllers); - - i2o_driver_notify_controller_add_all(c); - - osm_info("%s: Controller added\n", c->name); - - return 0; - - device_del: - device_del(&c->device); - - iop_reset: - i2o_iop_reset(c); - - return rc; -} - -/** - * i2o_event_register - Turn on/off event notification for a I2O device - * @dev: I2O device which should receive the event registration request - * @drv: driver which want to get notified - * @tcntxt: transaction context to use with this notifier - * @evt_mask: mask of events - * - * Create and posts an event registration message to the task. No reply - * is waited for, or expected. If you do not want further notifications, - * call the i2o_event_register again with a evt_mask of 0. - * - * Returns 0 on success or negative error code on failure. - */ -int i2o_event_register(struct i2o_device *dev, struct i2o_driver *drv, - int tcntxt, u32 evt_mask) -{ - struct i2o_controller *c = dev->iop; - struct i2o_message *msg; - - msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0); - msg->u.head[1] = - cpu_to_le32(I2O_CMD_UTIL_EVT_REGISTER << 24 | HOST_TID << 12 | dev-> - lct_data.tid); - msg->u.s.icntxt = cpu_to_le32(drv->context); - msg->u.s.tcntxt = cpu_to_le32(tcntxt); - msg->body[0] = cpu_to_le32(evt_mask); - - i2o_msg_post(c, msg); - - return 0; -} - -/** - * i2o_iop_init - I2O main initialization function - * - * Initialize the I2O drivers (OSM) functions, register the Executive OSM, - * initialize the I2O PCI part and finally initialize I2O device stuff. - * - * Returns 0 on success or negative error code on failure. - */ -static int __init i2o_iop_init(void) -{ - int rc = 0; - - printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n"); - - rc = i2o_driver_init(); - if (rc) - goto exit; - - rc = i2o_exec_init(); - if (rc) - goto driver_exit; - - rc = i2o_pci_init(); - if (rc) - goto exec_exit; - - return 0; - - exec_exit: - i2o_exec_exit(); - - driver_exit: - i2o_driver_exit(); - - exit: - return rc; -} - -/** - * i2o_iop_exit - I2O main exit function - * - * Removes I2O controllers from PCI subsystem and shut down OSMs. - */ -static void __exit i2o_iop_exit(void) -{ - i2o_pci_exit(); - i2o_exec_exit(); - i2o_driver_exit(); -} - -module_init(i2o_iop_init); -module_exit(i2o_iop_exit); - -MODULE_AUTHOR("Red Hat Software"); -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION(OSM_DESCRIPTION); -MODULE_VERSION(OSM_VERSION); - -#if BITS_PER_LONG == 64 -EXPORT_SYMBOL(i2o_cntxt_list_add); -EXPORT_SYMBOL(i2o_cntxt_list_get); -EXPORT_SYMBOL(i2o_cntxt_list_remove); -EXPORT_SYMBOL(i2o_cntxt_list_get_ptr); -#endif -EXPORT_SYMBOL(i2o_msg_get_wait); -EXPORT_SYMBOL(i2o_find_iop); -EXPORT_SYMBOL(i2o_iop_find_device); -EXPORT_SYMBOL(i2o_event_register); -EXPORT_SYMBOL(i2o_status_get); -EXPORT_SYMBOL(i2o_controllers); diff --git a/drivers/staging/i2o/memory.c b/drivers/staging/i2o/memory.c deleted file mode 100644 index 78b702c18537..000000000000 --- a/drivers/staging/i2o/memory.c +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Functions to handle I2O memory - * - * Pulled from the inlines in i2o headers and uninlined - * - * - * 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. - */ - -#include -#include "i2o.h" -#include -#include -#include -#include "core.h" - -/* Protects our 32/64bit mask switching */ -static DEFINE_MUTEX(mem_lock); - -/** - * i2o_sg_tablesize - Calculate the maximum number of elements in a SGL - * @c: I2O controller for which the calculation should be done - * @body_size: maximum body size used for message in 32-bit words. - * - * Return the maximum number of SG elements in a SG list. - */ -u16 i2o_sg_tablesize(struct i2o_controller *c, u16 body_size) -{ - i2o_status_block *sb = c->status_block.virt; - u16 sg_count = - (sb->inbound_frame_size - sizeof(struct i2o_message) / 4) - - body_size; - - if (c->pae_support) { - /* - * for 64-bit a SG attribute element must be added and each - * SG element needs 12 bytes instead of 8. - */ - sg_count -= 2; - sg_count /= 3; - } else - sg_count /= 2; - - if (c->short_req && (sg_count > 8)) - sg_count = 8; - - return sg_count; -} -EXPORT_SYMBOL_GPL(i2o_sg_tablesize); - - -/** - * i2o_dma_map_single - Map pointer to controller and fill in I2O message. - * @c: I2O controller - * @ptr: pointer to the data which should be mapped - * @size: size of data in bytes - * @direction: DMA_TO_DEVICE / DMA_FROM_DEVICE - * @sg_ptr: pointer to the SG list inside the I2O message - * - * This function does all necessary DMA handling and also writes the I2O - * SGL elements into the I2O message. For details on DMA handling see also - * dma_map_single(). The pointer sg_ptr will only be set to the end of the - * SG list if the allocation was successful. - * - * Returns DMA address which must be checked for failures using - * dma_mapping_error(). - */ -dma_addr_t i2o_dma_map_single(struct i2o_controller *c, void *ptr, - size_t size, - enum dma_data_direction direction, - u32 ** sg_ptr) -{ - u32 sg_flags; - u32 *mptr = *sg_ptr; - dma_addr_t dma_addr; - - switch (direction) { - case DMA_TO_DEVICE: - sg_flags = 0xd4000000; - break; - case DMA_FROM_DEVICE: - sg_flags = 0xd0000000; - break; - default: - return 0; - } - - dma_addr = dma_map_single(&c->pdev->dev, ptr, size, direction); - if (!dma_mapping_error(&c->pdev->dev, dma_addr)) { -#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64 - if ((sizeof(dma_addr_t) > 4) && c->pae_support) { - *mptr++ = cpu_to_le32(0x7C020002); - *mptr++ = cpu_to_le32(PAGE_SIZE); - } -#endif - - *mptr++ = cpu_to_le32(sg_flags | size); - *mptr++ = cpu_to_le32(i2o_dma_low(dma_addr)); -#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64 - if ((sizeof(dma_addr_t) > 4) && c->pae_support) - *mptr++ = cpu_to_le32(i2o_dma_high(dma_addr)); -#endif - *sg_ptr = mptr; - } - return dma_addr; -} -EXPORT_SYMBOL_GPL(i2o_dma_map_single); - -/** - * i2o_dma_map_sg - Map a SG List to controller and fill in I2O message. - * @c: I2O controller - * @sg: SG list to be mapped - * @sg_count: number of elements in the SG list - * @direction: DMA_TO_DEVICE / DMA_FROM_DEVICE - * @sg_ptr: pointer to the SG list inside the I2O message - * - * This function does all necessary DMA handling and also writes the I2O - * SGL elements into the I2O message. For details on DMA handling see also - * dma_map_sg(). The pointer sg_ptr will only be set to the end of the SG - * list if the allocation was successful. - * - * Returns 0 on failure or 1 on success. - */ -int i2o_dma_map_sg(struct i2o_controller *c, struct scatterlist *sg, - int sg_count, enum dma_data_direction direction, u32 ** sg_ptr) -{ - u32 sg_flags; - u32 *mptr = *sg_ptr; - - switch (direction) { - case DMA_TO_DEVICE: - sg_flags = 0x14000000; - break; - case DMA_FROM_DEVICE: - sg_flags = 0x10000000; - break; - default: - return 0; - } - - sg_count = dma_map_sg(&c->pdev->dev, sg, sg_count, direction); - if (!sg_count) - return 0; - -#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64 - if ((sizeof(dma_addr_t) > 4) && c->pae_support) { - *mptr++ = cpu_to_le32(0x7C020002); - *mptr++ = cpu_to_le32(PAGE_SIZE); - } -#endif - - while (sg_count-- > 0) { - if (!sg_count) - sg_flags |= 0xC0000000; - *mptr++ = cpu_to_le32(sg_flags | sg_dma_len(sg)); - *mptr++ = cpu_to_le32(i2o_dma_low(sg_dma_address(sg))); -#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64 - if ((sizeof(dma_addr_t) > 4) && c->pae_support) - *mptr++ = cpu_to_le32(i2o_dma_high(sg_dma_address(sg))); -#endif - sg = sg_next(sg); - } - *sg_ptr = mptr; - - return 1; -} -EXPORT_SYMBOL_GPL(i2o_dma_map_sg); - -/** - * i2o_dma_alloc - Allocate DMA memory - * @dev: struct device pointer to the PCI device of the I2O controller - * @addr: i2o_dma struct which should get the DMA buffer - * @len: length of the new DMA memory - * - * Allocate a coherent DMA memory and write the pointers into addr. - * - * Returns 0 on success or -ENOMEM on failure. - */ -int i2o_dma_alloc(struct device *dev, struct i2o_dma *addr, size_t len) -{ - struct pci_dev *pdev = to_pci_dev(dev); - int dma_64 = 0; - - mutex_lock(&mem_lock); - if ((sizeof(dma_addr_t) > 4) && (pdev->dma_mask == DMA_BIT_MASK(64))) { - dma_64 = 1; - if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { - mutex_unlock(&mem_lock); - return -ENOMEM; - } - } - - addr->virt = dma_alloc_coherent(dev, len, &addr->phys, GFP_KERNEL); - - if ((sizeof(dma_addr_t) > 4) && dma_64) - if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) - printk(KERN_WARNING "i2o: unable to set 64-bit DMA"); - mutex_unlock(&mem_lock); - - if (!addr->virt) - return -ENOMEM; - - memset(addr->virt, 0, len); - addr->len = len; - - return 0; -} -EXPORT_SYMBOL_GPL(i2o_dma_alloc); - - -/** - * i2o_dma_free - Free DMA memory - * @dev: struct device pointer to the PCI device of the I2O controller - * @addr: i2o_dma struct which contains the DMA buffer - * - * Free a coherent DMA memory and set virtual address of addr to NULL. - */ -void i2o_dma_free(struct device *dev, struct i2o_dma *addr) -{ - if (addr->virt) { - if (addr->phys) - dma_free_coherent(dev, addr->len, addr->virt, - addr->phys); - else - kfree(addr->virt); - addr->virt = NULL; - } -} -EXPORT_SYMBOL_GPL(i2o_dma_free); - - -/** - * i2o_dma_realloc - Realloc DMA memory - * @dev: struct device pointer to the PCI device of the I2O controller - * @addr: pointer to a i2o_dma struct DMA buffer - * @len: new length of memory - * - * If there was something allocated in the addr, free it first. If len > 0 - * than try to allocate it and write the addresses back to the addr - * structure. If len == 0 set the virtual address to NULL. - * - * Returns the 0 on success or negative error code on failure. - */ -int i2o_dma_realloc(struct device *dev, struct i2o_dma *addr, size_t len) -{ - i2o_dma_free(dev, addr); - - if (len) - return i2o_dma_alloc(dev, addr, len); - - return 0; -} -EXPORT_SYMBOL_GPL(i2o_dma_realloc); - -/* - * i2o_pool_alloc - Allocate an slab cache and mempool - * @mempool: pointer to struct i2o_pool to write data into. - * @name: name which is used to identify cache - * @size: size of each object - * @min_nr: minimum number of objects - * - * First allocates a slab cache with name and size. Then allocates a - * mempool which uses the slab cache for allocation and freeing. - * - * Returns 0 on success or negative error code on failure. - */ -int i2o_pool_alloc(struct i2o_pool *pool, const char *name, - size_t size, int min_nr) -{ - pool->name = kstrdup(name, GFP_KERNEL); - if (!pool->name) - goto exit; - - pool->slab = - kmem_cache_create(pool->name, size, 0, SLAB_HWCACHE_ALIGN, NULL); - if (!pool->slab) - goto free_name; - - pool->mempool = mempool_create_slab_pool(min_nr, pool->slab); - if (!pool->mempool) - goto free_slab; - - return 0; - -free_slab: - kmem_cache_destroy(pool->slab); - -free_name: - kfree(pool->name); - -exit: - return -ENOMEM; -} -EXPORT_SYMBOL_GPL(i2o_pool_alloc); - -/* - * i2o_pool_free - Free slab cache and mempool again - * @mempool: pointer to struct i2o_pool which should be freed - * - * Note that you have to return all objects to the mempool again before - * calling i2o_pool_free(). - */ -void i2o_pool_free(struct i2o_pool *pool) -{ - mempool_destroy(pool->mempool); - kmem_cache_destroy(pool->slab); - kfree(pool->name); -}; -EXPORT_SYMBOL_GPL(i2o_pool_free); diff --git a/drivers/staging/i2o/pci.c b/drivers/staging/i2o/pci.c deleted file mode 100644 index 49804c9cf74f..000000000000 --- a/drivers/staging/i2o/pci.c +++ /dev/null @@ -1,500 +0,0 @@ -/* - * PCI handling of I2O controller - * - * Copyright (C) 1999-2002 Red Hat Software - * - * Written by Alan Cox, Building Number Three Ltd - * - * 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. - * - * A lot of the I2O message side code from this is taken from the Red - * Creek RCPCI45 adapter driver by Red Creek Communications - * - * Fixes/additions: - * Philipp Rumpf - * Juha Sievänen - * Auvo Häkkinen - * Deepak Saxena - * Boji T Kannanthanam - * Alan Cox : - * Ported to Linux 2.5. - * Markus Lidel : - * Minor fixes for 2.6. - * Markus Lidel : - * Support for sysfs included. - */ - -#include -#include -#include -#include "i2o.h" -#include -#include "core.h" - -#define OSM_DESCRIPTION "I2O-subsystem" - -/* PCI device id table for all I2O controllers */ -static struct pci_device_id i2o_pci_ids[] = { - {PCI_DEVICE_CLASS(PCI_CLASS_INTELLIGENT_I2O << 8, 0xffff00)}, - {PCI_DEVICE(PCI_VENDOR_ID_DPT, 0xa511)}, - {.vendor = PCI_VENDOR_ID_INTEL,.device = 0x1962, - .subvendor = PCI_VENDOR_ID_PROMISE,.subdevice = PCI_ANY_ID}, - {0} -}; - -/** - * i2o_pci_free - Frees the DMA memory for the I2O controller - * @c: I2O controller to free - * - * Remove all allocated DMA memory and unmap memory IO regions. If MTRR - * is enabled, also remove it again. - */ -static void i2o_pci_free(struct i2o_controller *c) -{ - struct device *dev; - - dev = &c->pdev->dev; - - i2o_dma_free(dev, &c->out_queue); - i2o_dma_free(dev, &c->status_block); - kfree(c->lct); - i2o_dma_free(dev, &c->dlct); - i2o_dma_free(dev, &c->hrt); - i2o_dma_free(dev, &c->status); - - if (c->raptor && c->in_queue.virt) - iounmap(c->in_queue.virt); - - if (c->base.virt) - iounmap(c->base.virt); - - pci_release_regions(c->pdev); -} - -/** - * i2o_pci_alloc - Allocate DMA memory, map IO memory for I2O controller - * @c: I2O controller - * - * Allocate DMA memory for a PCI (or in theory AGP) I2O controller. All - * IO mappings are also done here. If MTRR is enabled, also do add memory - * regions here. - * - * Returns 0 on success or negative error code on failure. - */ -static int i2o_pci_alloc(struct i2o_controller *c) -{ - struct pci_dev *pdev = c->pdev; - struct device *dev = &pdev->dev; - int i; - - if (pci_request_regions(pdev, OSM_DESCRIPTION)) { - printk(KERN_ERR "%s: device already claimed\n", c->name); - return -ENODEV; - } - - for (i = 0; i < 6; i++) { - /* Skip I/O spaces */ - if (!(pci_resource_flags(pdev, i) & IORESOURCE_IO)) { - if (!c->base.phys) { - c->base.phys = pci_resource_start(pdev, i); - c->base.len = pci_resource_len(pdev, i); - - /* - * If we know what card it is, set the size - * correctly. Code is taken from dpt_i2o.c - */ - if (pdev->device == 0xa501) { - if (pdev->subsystem_device >= 0xc032 && - pdev->subsystem_device <= 0xc03b) { - if (c->base.len > 0x400000) - c->base.len = 0x400000; - } else { - if (c->base.len > 0x100000) - c->base.len = 0x100000; - } - } - if (!c->raptor) - break; - } else { - c->in_queue.phys = pci_resource_start(pdev, i); - c->in_queue.len = pci_resource_len(pdev, i); - break; - } - } - } - - if (i == 6) { - printk(KERN_ERR "%s: I2O controller has no memory regions" - " defined.\n", c->name); - i2o_pci_free(c); - return -EINVAL; - } - - /* Map the I2O controller */ - if (c->raptor) { - printk(KERN_INFO "%s: PCI I2O controller\n", c->name); - printk(KERN_INFO " BAR0 at 0x%08lX size=%ld\n", - (unsigned long)c->base.phys, (unsigned long)c->base.len); - printk(KERN_INFO " BAR1 at 0x%08lX size=%ld\n", - (unsigned long)c->in_queue.phys, - (unsigned long)c->in_queue.len); - } else - printk(KERN_INFO "%s: PCI I2O controller at %08lX size=%ld\n", - c->name, (unsigned long)c->base.phys, - (unsigned long)c->base.len); - - c->base.virt = ioremap_nocache(c->base.phys, c->base.len); - if (!c->base.virt) { - printk(KERN_ERR "%s: Unable to map controller.\n", c->name); - i2o_pci_free(c); - return -ENOMEM; - } - - if (c->raptor) { - c->in_queue.virt = - ioremap_nocache(c->in_queue.phys, c->in_queue.len); - if (!c->in_queue.virt) { - printk(KERN_ERR "%s: Unable to map controller.\n", - c->name); - i2o_pci_free(c); - return -ENOMEM; - } - } else - c->in_queue = c->base; - - c->irq_status = c->base.virt + I2O_IRQ_STATUS; - c->irq_mask = c->base.virt + I2O_IRQ_MASK; - c->in_port = c->base.virt + I2O_IN_PORT; - c->out_port = c->base.virt + I2O_OUT_PORT; - - /* Motorola/Freescale chip does not follow spec */ - if (pdev->vendor == PCI_VENDOR_ID_MOTOROLA && pdev->device == 0x18c0) { - /* Check if CPU is enabled */ - if (be32_to_cpu(readl(c->base.virt + 0x10000)) & 0x10000000) { - printk(KERN_INFO "%s: MPC82XX needs CPU running to " - "service I2O.\n", c->name); - i2o_pci_free(c); - return -ENODEV; - } else { - c->irq_status += I2O_MOTOROLA_PORT_OFFSET; - c->irq_mask += I2O_MOTOROLA_PORT_OFFSET; - c->in_port += I2O_MOTOROLA_PORT_OFFSET; - c->out_port += I2O_MOTOROLA_PORT_OFFSET; - printk(KERN_INFO "%s: MPC82XX workarounds activated.\n", - c->name); - } - } - - if (i2o_dma_alloc(dev, &c->status, 8)) { - i2o_pci_free(c); - return -ENOMEM; - } - - if (i2o_dma_alloc(dev, &c->hrt, sizeof(i2o_hrt))) { - i2o_pci_free(c); - return -ENOMEM; - } - - if (i2o_dma_alloc(dev, &c->dlct, 8192)) { - i2o_pci_free(c); - return -ENOMEM; - } - - if (i2o_dma_alloc(dev, &c->status_block, sizeof(i2o_status_block))) { - i2o_pci_free(c); - return -ENOMEM; - } - - if (i2o_dma_alloc(dev, &c->out_queue, - I2O_MAX_OUTBOUND_MSG_FRAMES * I2O_OUTBOUND_MSG_FRAME_SIZE * - sizeof(u32))) { - i2o_pci_free(c); - return -ENOMEM; - } - - pci_set_drvdata(pdev, c); - - return 0; -} - -/** - * i2o_pci_interrupt - Interrupt handler for I2O controller - * @irq: interrupt line - * @dev_id: pointer to the I2O controller - * - * Handle an interrupt from a PCI based I2O controller. This turns out - * to be rather simple. We keep the controller pointer in the cookie. - */ -static irqreturn_t i2o_pci_interrupt(int irq, void *dev_id) -{ - struct i2o_controller *c = dev_id; - u32 m; - irqreturn_t rc = IRQ_NONE; - - while (readl(c->irq_status) & I2O_IRQ_OUTBOUND_POST) { - m = readl(c->out_port); - if (m == I2O_QUEUE_EMPTY) { - /* - * Old 960 steppings had a bug in the I2O unit that - * caused the queue to appear empty when it wasn't. - */ - m = readl(c->out_port); - if (unlikely(m == I2O_QUEUE_EMPTY)) - break; - } - - /* dispatch it */ - if (i2o_driver_dispatch(c, m)) - /* flush it if result != 0 */ - i2o_flush_reply(c, m); - - rc = IRQ_HANDLED; - } - - return rc; -} - -/** - * i2o_pci_irq_enable - Allocate interrupt for I2O controller - * @c: i2o_controller that the request is for - * - * Allocate an interrupt for the I2O controller, and activate interrupts - * on the I2O controller. - * - * Returns 0 on success or negative error code on failure. - */ -static int i2o_pci_irq_enable(struct i2o_controller *c) -{ - struct pci_dev *pdev = c->pdev; - int rc; - - writel(0xffffffff, c->irq_mask); - - if (pdev->irq) { - rc = request_irq(pdev->irq, i2o_pci_interrupt, IRQF_SHARED, - c->name, c); - if (rc < 0) { - printk(KERN_ERR "%s: unable to allocate interrupt %d." - "\n", c->name, pdev->irq); - return rc; - } - } - - writel(0x00000000, c->irq_mask); - - printk(KERN_INFO "%s: Installed at IRQ %d\n", c->name, pdev->irq); - - return 0; -} - -/** - * i2o_pci_irq_disable - Free interrupt for I2O controller - * @c: I2O controller - * - * Disable interrupts in I2O controller and then free interrupt. - */ -static void i2o_pci_irq_disable(struct i2o_controller *c) -{ - writel(0xffffffff, c->irq_mask); - - if (c->pdev->irq > 0) - free_irq(c->pdev->irq, c); -} - -/** - * i2o_pci_probe - Probe the PCI device for an I2O controller - * @pdev: PCI device to test - * @id: id which matched with the PCI device id table - * - * Probe the PCI device for any device which is a memory of the - * Intelligent, I2O class or an Adaptec Zero Channel Controller. We - * attempt to set up each such device and register it with the core. - * - * Returns 0 on success or negative error code on failure. - */ -static int i2o_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) -{ - struct i2o_controller *c; - int rc; - struct pci_dev *i960 = NULL; - - printk(KERN_INFO "i2o: Checking for PCI I2O controllers...\n"); - - if ((pdev->class & 0xff) > 1) { - printk(KERN_WARNING "i2o: %s does not support I2O 1.5 " - "(skipping).\n", pci_name(pdev)); - return -ENODEV; - } - - rc = pci_enable_device(pdev); - if (rc) { - printk(KERN_WARNING "i2o: couldn't enable device %s\n", - pci_name(pdev)); - return rc; - } - - if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { - printk(KERN_WARNING "i2o: no suitable DMA found for %s\n", - pci_name(pdev)); - rc = -ENODEV; - goto disable; - } - - pci_set_master(pdev); - - c = i2o_iop_alloc(); - if (IS_ERR(c)) { - printk(KERN_ERR "i2o: couldn't allocate memory for %s\n", - pci_name(pdev)); - rc = PTR_ERR(c); - goto disable; - } else - printk(KERN_INFO "%s: controller found (%s)\n", c->name, - pci_name(pdev)); - - c->pdev = pdev; - c->device.parent = &pdev->dev; - - /* Cards that fall apart if you hit them with large I/O loads... */ - if (pdev->vendor == PCI_VENDOR_ID_NCR && pdev->device == 0x0630) { - c->short_req = 1; - printk(KERN_INFO "%s: Symbios FC920 workarounds activated.\n", - c->name); - } - - if (pdev->subsystem_vendor == PCI_VENDOR_ID_PROMISE) { - /* - * Expose the ship behind i960 for initialization, or it will - * failed - */ - i960 = pci_get_slot(c->pdev->bus, - PCI_DEVFN(PCI_SLOT(c->pdev->devfn), 0)); - - if (i960) { - pci_write_config_word(i960, 0x42, 0); - pci_dev_put(i960); - } - - c->promise = 1; - c->limit_sectors = 1; - } - - if (pdev->subsystem_vendor == PCI_VENDOR_ID_DPT) - c->adaptec = 1; - - /* Cards that go bananas if you quiesce them before you reset them. */ - if (pdev->vendor == PCI_VENDOR_ID_DPT) { - c->no_quiesce = 1; - if (pdev->device == 0xa511) - c->raptor = 1; - - if (pdev->subsystem_device == 0xc05a) { - c->limit_sectors = 1; - printk(KERN_INFO - "%s: limit sectors per request to %d\n", c->name, - I2O_MAX_SECTORS_LIMITED); - } -#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64 - if (sizeof(dma_addr_t) > 4) { - if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) - printk(KERN_INFO "%s: 64-bit DMA unavailable\n", - c->name); - else { - c->pae_support = 1; - printk(KERN_INFO "%s: using 64-bit DMA\n", - c->name); - } - } -#endif - } - - rc = i2o_pci_alloc(c); - if (rc) { - printk(KERN_ERR "%s: DMA / IO allocation for I2O controller " - "failed\n", c->name); - goto free_controller; - } - - if (i2o_pci_irq_enable(c)) { - printk(KERN_ERR "%s: unable to enable interrupts for I2O " - "controller\n", c->name); - goto free_pci; - } - - rc = i2o_iop_add(c); - if (rc) - goto uninstall; - - if (i960) - pci_write_config_word(i960, 0x42, 0x03ff); - - return 0; - - uninstall: - i2o_pci_irq_disable(c); - - free_pci: - i2o_pci_free(c); - - free_controller: - i2o_iop_free(c); - - disable: - pci_disable_device(pdev); - - return rc; -} - -/** - * i2o_pci_remove - Removes a I2O controller from the system - * @pdev: I2O controller which should be removed - * - * Reset the I2O controller, disable interrupts and remove all allocated - * resources. - */ -static void i2o_pci_remove(struct pci_dev *pdev) -{ - struct i2o_controller *c; - c = pci_get_drvdata(pdev); - - i2o_iop_remove(c); - i2o_pci_irq_disable(c); - i2o_pci_free(c); - - pci_disable_device(pdev); - - printk(KERN_INFO "%s: Controller removed.\n", c->name); - - put_device(&c->device); -}; - -/* PCI driver for I2O controller */ -static struct pci_driver i2o_pci_driver = { - .name = "PCI_I2O", - .id_table = i2o_pci_ids, - .probe = i2o_pci_probe, - .remove = i2o_pci_remove, -}; - -/** - * i2o_pci_init - registers I2O PCI driver in PCI subsystem - * - * Returns > 0 on success or negative error code on failure. - */ -int __init i2o_pci_init(void) -{ - return pci_register_driver(&i2o_pci_driver); -}; - -/** - * i2o_pci_exit - unregisters I2O PCI driver from PCI subsystem - */ -void __exit i2o_pci_exit(void) -{ - pci_unregister_driver(&i2o_pci_driver); -}; - -MODULE_DEVICE_TABLE(pci, i2o_pci_ids); From dc05a7d70b824cbe26f00914e5f94e0b68d5aeda Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 5 May 2015 18:47:24 +0100 Subject: [PATCH 0410/1163] staging: comedi: gsc_hpdi: tidy up comments Use the usual style for block comments. Squash double spaces after comment opening sequence. Move some comments after opening braces to following line. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/gsc_hpdi.c | 59 +++++++++++++---------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index d9715ea1e2da..901025216971 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -139,11 +139,13 @@ static const struct hpdi_board hpdi_boards[] = { struct hpdi_private { void __iomem *plx9080_mmio; - uint32_t *dio_buffer[NUM_DMA_BUFFERS]; /* dma buffers */ + uint32_t *dio_buffer[NUM_DMA_BUFFERS]; /* dma buffers */ /* physical addresses of dma buffers */ dma_addr_t dio_buffer_phys_addr[NUM_DMA_BUFFERS]; - /* array of dma descriptors read by plx9080, allocated to get proper - * alignment */ + /* + * array of dma descriptors read by plx9080, allocated to get proper + * alignment + */ struct plx_dma_desc *dma_desc; /* physical address of dma descriptor array */ dma_addr_t dma_desc_phys_addr; @@ -195,7 +197,7 @@ static void gsc_hpdi_drain_dma(struct comedi_device *dev, unsigned int channel) devpriv->dma_desc_index = idx; } - /* XXX check for buffer overrun somehow */ + /* XXX check for buffer overrun somehow */ } static irqreturn_t gsc_hpdi_interrupt(int irq, void *d) @@ -223,10 +225,11 @@ static irqreturn_t gsc_hpdi_interrupt(int irq, void *d) if (hpdi_intr_status) writel(hpdi_intr_status, dev->mmio + INTERRUPT_STATUS_REG); - /* spin lock makes sure no one else changes plx dma control reg */ + /* spin lock makes sure no one else changes plx dma control reg */ spin_lock_irqsave(&dev->spinlock, flags); dma0_status = readb(devpriv->plx9080_mmio + PLX_DMA0_CS_REG); - if (plx_status & ICS_DMA0_A) { /* dma chan 0 interrupt */ + if (plx_status & ICS_DMA0_A) { + /* dma chan 0 interrupt */ writeb((dma0_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT, devpriv->plx9080_mmio + PLX_DMA0_CS_REG); @@ -235,17 +238,19 @@ static irqreturn_t gsc_hpdi_interrupt(int irq, void *d) } spin_unlock_irqrestore(&dev->spinlock, flags); - /* spin lock makes sure no one else changes plx dma control reg */ + /* spin lock makes sure no one else changes plx dma control reg */ spin_lock_irqsave(&dev->spinlock, flags); dma1_status = readb(devpriv->plx9080_mmio + PLX_DMA1_CS_REG); - if (plx_status & ICS_DMA1_A) { /* XXX *//* dma chan 1 interrupt */ + if (plx_status & ICS_DMA1_A) { + /* XXX */ /* dma chan 1 interrupt */ writeb((dma1_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT, devpriv->plx9080_mmio + PLX_DMA1_CS_REG); } spin_unlock_irqrestore(&dev->spinlock, flags); - /* clear possible plx9080 interrupt sources */ - if (plx_status & ICS_LDIA) { /* clear local doorbell interrupt */ + /* clear possible plx9080 interrupt sources */ + if (plx_status & ICS_LDIA) { + /* clear local doorbell interrupt */ plx_bits = readl(devpriv->plx9080_mmio + PLX_DBR_OUT_REG); writel(plx_bits, devpriv->plx9080_mmio + PLX_DBR_OUT_REG); } @@ -273,7 +278,7 @@ static void gsc_hpdi_abort_dma(struct comedi_device *dev, unsigned int channel) struct hpdi_private *devpriv = dev->private; unsigned long flags; - /* spinlock for plx dma control/status reg */ + /* spinlock for plx dma control/status reg */ spin_lock_irqsave(&dev->spinlock, flags); plx9080_abort_dma(devpriv->plx9080_mmio, channel); @@ -543,7 +548,7 @@ static int gsc_hpdi_init(struct comedi_device *dev) writel(0, dev->mmio + INTERRUPT_CONTROL_REG); - /* enable interrupts */ + /* enable interrupts */ plx_intcsr_bits = ICS_AERR | ICS_PERR | ICS_PIE | ICS_PLIE | ICS_PAIE | ICS_LIE | ICS_DMA0_E; @@ -570,23 +575,27 @@ static void gsc_hpdi_init_plx9080(struct comedi_device *dev) gsc_hpdi_abort_dma(dev, 0); gsc_hpdi_abort_dma(dev, 1); - /* configure dma0 mode */ + /* configure dma0 mode */ bits = 0; - /* enable ready input */ + /* enable ready input */ bits |= PLX_DMA_EN_READYIN_BIT; - /* enable dma chaining */ + /* enable dma chaining */ bits |= PLX_EN_CHAIN_BIT; - /* enable interrupt on dma done - * (probably don't need this, since chain never finishes) */ + /* + * enable interrupt on dma done + * (probably don't need this, since chain never finishes) + */ bits |= PLX_EN_DMA_DONE_INTR_BIT; - /* don't increment local address during transfers - * (we are transferring from a fixed fifo register) */ + /* + * don't increment local address during transfers + * (we are transferring from a fixed fifo register) + */ bits |= PLX_LOCAL_ADDR_CONST_BIT; - /* route dma interrupt to pci bus */ + /* route dma interrupt to pci bus */ bits |= PLX_DMA_INTR_PCI_BIT; - /* enable demand mode */ + /* enable demand mode */ bits |= PLX_DEMAND_MODE_BIT; - /* enable local burst mode */ + /* enable local burst mode */ bits |= PLX_DMA_LOCAL_BURST_EN_BIT; bits |= PLX_LOCAL_BUS_32_WIDE_BITS; writel(bits, plx_iobase + PLX_DMA0_MODE_REG); @@ -640,7 +649,7 @@ static int gsc_hpdi_auto_attach(struct comedi_device *dev, gsc_hpdi_init_plx9080(dev); - /* get irq */ + /* get irq */ if (request_irq(pcidev->irq, gsc_hpdi_interrupt, IRQF_SHARED, dev->board_name, dev)) { dev_warn(dev->class_dev, @@ -651,13 +660,13 @@ static int gsc_hpdi_auto_attach(struct comedi_device *dev, dev_dbg(dev->class_dev, " irq %u\n", dev->irq); - /* allocate pci dma buffers */ + /* allocate pci dma buffers */ for (i = 0; i < NUM_DMA_BUFFERS; i++) { devpriv->dio_buffer[i] = pci_alloc_consistent(pcidev, DMA_BUFFER_SIZE, &devpriv->dio_buffer_phys_addr[i]); } - /* allocate dma descriptors */ + /* allocate dma descriptors */ devpriv->dma_desc = pci_alloc_consistent(pcidev, sizeof(struct plx_dma_desc) * NUM_DMA_DESCRIPTORS, From e899a4165cffe3aa802f813c624e90ce7ca23189 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 5 May 2015 18:47:25 +0100 Subject: [PATCH 0411/1163] staging: comedi: gsc_hpdi: remove multiple board type support The code for determining which board type matches the PCI device ID is over-the-top since only a single board type is supported. Also, the method it uses match the PCI device ID to a board type is a little antiquated. Most comedi drivers for PCI devices use `driver_data` from the probed PCI device as an index into an array of supported board types, but "gsc_hpdi" uses a `for` loop to find an element of `hpdi_boards[]` that matches the PCI device. The only thing in `hpdi_boards[]` not used for finding a matching PCI device is the `name` member of `struct hpdi_board` which points to a string literal and ends up getting assigned to `dev->board_name`. Get rid of the multiple board type support, and set `dev->board_name` to point to the original string literal pointed to by `hpdi_boards[0].name`. This string is visible to userspace. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/gsc_hpdi.c | 35 +---------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index 901025216971..0e04f15feb38 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -123,20 +123,6 @@ #define NUM_DMA_BUFFERS 4 #define NUM_DMA_DESCRIPTORS 256 -struct hpdi_board { - const char *name; - int device_id; - int subdevice_id; -}; - -static const struct hpdi_board hpdi_boards[] = { - { - .name = "pci-hpdi32", - .device_id = PCI_DEVICE_ID_PLX_9080, - .subdevice_id = 0x2400, - }, -}; - struct hpdi_private { void __iomem *plx9080_mmio; uint32_t *dio_buffer[NUM_DMA_BUFFERS]; /* dma buffers */ @@ -601,35 +587,16 @@ static void gsc_hpdi_init_plx9080(struct comedi_device *dev) writel(bits, plx_iobase + PLX_DMA0_MODE_REG); } -static const struct hpdi_board *gsc_hpdi_find_board(struct pci_dev *pcidev) -{ - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(hpdi_boards); i++) - if (pcidev->device == hpdi_boards[i].device_id && - pcidev->subsystem_device == hpdi_boards[i].subdevice_id) - return &hpdi_boards[i]; - return NULL; -} - static int gsc_hpdi_auto_attach(struct comedi_device *dev, unsigned long context_unused) { struct pci_dev *pcidev = comedi_to_pci_dev(dev); - const struct hpdi_board *thisboard; struct hpdi_private *devpriv; struct comedi_subdevice *s; int i; int retval; - thisboard = gsc_hpdi_find_board(pcidev); - if (!thisboard) { - dev_err(dev->class_dev, "gsc_hpdi: pci %s not supported\n", - pci_name(pcidev)); - return -EINVAL; - } - dev->board_ptr = thisboard; - dev->board_name = thisboard->name; + dev->board_name = "pci-hpdi32"; devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) From 7b7afb469cfe9eb384028f86ce4ec2fb8946f772 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 5 May 2015 18:47:26 +0100 Subject: [PATCH 0412/1163] staging: comedi: gsc_hpdi: usleep_range is preferred over udelay Fix checkpatch issue: "CHECK: usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt". `udelay()` is only called once from a place where sleeping is allowed. Replace it with a call to `usleep_range()` with a reasonable upper limit. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/gsc_hpdi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index 0e04f15feb38..31ff10807260 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -520,7 +520,7 @@ static int gsc_hpdi_init(struct comedi_device *dev) /* wait 10usec after reset before accessing fifos */ writel(BOARD_RESET_BIT, dev->mmio + BOARD_CONTROL_REG); - udelay(10); + usleep_range(10, 1000); writel(ALMOST_EMPTY_BITS(32) | ALMOST_FULL_BITS(32), dev->mmio + RX_PROG_ALMOST_REG); From c5f2579ed3eae33d41299958af6af56c0c8a01ba Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 5 May 2015 18:47:27 +0100 Subject: [PATCH 0413/1163] staging: comedi: gsc_hpdi: prefer using the BIT() macro Fix all the checkpatch issues "CHECK: Prefer using the BIT macro". Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/gsc_hpdi.c | 82 +++++++++++------------ 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index 31ff10807260..2e459f6d6fe0 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -52,45 +52,45 @@ * PCI BAR2 Register map (dev->mmio) */ #define FIRMWARE_REV_REG 0x00 -#define FEATURES_REG_PRESENT_BIT (1 << 15) +#define FEATURES_REG_PRESENT_BIT BIT(15) #define BOARD_CONTROL_REG 0x04 -#define BOARD_RESET_BIT (1 << 0) -#define TX_FIFO_RESET_BIT (1 << 1) -#define RX_FIFO_RESET_BIT (1 << 2) -#define TX_ENABLE_BIT (1 << 4) -#define RX_ENABLE_BIT (1 << 5) -#define DEMAND_DMA_DIRECTION_TX_BIT (1 << 6) /* ch 0 only */ -#define LINE_VALID_ON_STATUS_VALID_BIT (1 << 7) -#define START_TX_BIT (1 << 8) -#define CABLE_THROTTLE_ENABLE_BIT (1 << 9) -#define TEST_MODE_ENABLE_BIT (1 << 31) +#define BOARD_RESET_BIT BIT(0) +#define TX_FIFO_RESET_BIT BIT(1) +#define RX_FIFO_RESET_BIT BIT(2) +#define TX_ENABLE_BIT BIT(4) +#define RX_ENABLE_BIT BIT(5) +#define DEMAND_DMA_DIRECTION_TX_BIT BIT(6) /* ch 0 only */ +#define LINE_VALID_ON_STATUS_VALID_BIT BIT(7) +#define START_TX_BIT BIT(8) +#define CABLE_THROTTLE_ENABLE_BIT BIT(9) +#define TEST_MODE_ENABLE_BIT BIT(31) #define BOARD_STATUS_REG 0x08 #define COMMAND_LINE_STATUS_MASK (0x7f << 0) -#define TX_IN_PROGRESS_BIT (1 << 7) -#define TX_NOT_EMPTY_BIT (1 << 8) -#define TX_NOT_ALMOST_EMPTY_BIT (1 << 9) -#define TX_NOT_ALMOST_FULL_BIT (1 << 10) -#define TX_NOT_FULL_BIT (1 << 11) -#define RX_NOT_EMPTY_BIT (1 << 12) -#define RX_NOT_ALMOST_EMPTY_BIT (1 << 13) -#define RX_NOT_ALMOST_FULL_BIT (1 << 14) -#define RX_NOT_FULL_BIT (1 << 15) -#define BOARD_JUMPER0_INSTALLED_BIT (1 << 16) -#define BOARD_JUMPER1_INSTALLED_BIT (1 << 17) -#define TX_OVERRUN_BIT (1 << 21) -#define RX_UNDERRUN_BIT (1 << 22) -#define RX_OVERRUN_BIT (1 << 23) +#define TX_IN_PROGRESS_BIT BIT(7) +#define TX_NOT_EMPTY_BIT BIT(8) +#define TX_NOT_ALMOST_EMPTY_BIT BIT(9) +#define TX_NOT_ALMOST_FULL_BIT BIT(10) +#define TX_NOT_FULL_BIT BIT(11) +#define RX_NOT_EMPTY_BIT BIT(12) +#define RX_NOT_ALMOST_EMPTY_BIT BIT(13) +#define RX_NOT_ALMOST_FULL_BIT BIT(14) +#define RX_NOT_FULL_BIT BIT(15) +#define BOARD_JUMPER0_INSTALLED_BIT BIT(16) +#define BOARD_JUMPER1_INSTALLED_BIT BIT(17) +#define TX_OVERRUN_BIT BIT(21) +#define RX_UNDERRUN_BIT BIT(22) +#define RX_OVERRUN_BIT BIT(23) #define TX_PROG_ALMOST_REG 0x0c #define RX_PROG_ALMOST_REG 0x10 #define ALMOST_EMPTY_BITS(x) (((x) & 0xffff) << 0) #define ALMOST_FULL_BITS(x) (((x) & 0xff) << 16) #define FEATURES_REG 0x14 -#define FIFO_SIZE_PRESENT_BIT (1 << 0) -#define FIFO_WORDS_PRESENT_BIT (1 << 1) -#define LEVEL_EDGE_INTERRUPTS_PRESENT_BIT (1 << 2) -#define GPIO_SUPPORTED_BIT (1 << 3) -#define PLX_DMA_CH1_SUPPORTED_BIT (1 << 4) -#define OVERRUN_UNDERRUN_SUPPORTED_BIT (1 << 5) +#define FIFO_SIZE_PRESENT_BIT BIT(0) +#define FIFO_WORDS_PRESENT_BIT BIT(1) +#define LEVEL_EDGE_INTERRUPTS_PRESENT_BIT BIT(2) +#define GPIO_SUPPORTED_BIT BIT(3) +#define PLX_DMA_CH1_SUPPORTED_BIT BIT(4) +#define OVERRUN_UNDERRUN_SUPPORTED_BIT BIT(5) #define FIFO_REG 0x18 #define TX_STATUS_COUNT_REG 0x1c #define TX_LINE_VALID_COUNT_REG 0x20, @@ -98,16 +98,16 @@ #define RX_STATUS_COUNT_REG 0x28 #define RX_LINE_COUNT_REG 0x2c #define INTERRUPT_CONTROL_REG 0x30 -#define FRAME_VALID_START_INTR (1 << 0) -#define FRAME_VALID_END_INTR (1 << 1) -#define TX_FIFO_EMPTY_INTR (1 << 8) -#define TX_FIFO_ALMOST_EMPTY_INTR (1 << 9) -#define TX_FIFO_ALMOST_FULL_INTR (1 << 10) -#define TX_FIFO_FULL_INTR (1 << 11) -#define RX_EMPTY_INTR (1 << 12) -#define RX_ALMOST_EMPTY_INTR (1 << 13) -#define RX_ALMOST_FULL_INTR (1 << 14) -#define RX_FULL_INTR (1 << 15) +#define FRAME_VALID_START_INTR BIT(0) +#define FRAME_VALID_END_INTR BIT(1) +#define TX_FIFO_EMPTY_INTR BIT(8) +#define TX_FIFO_ALMOST_EMPTY_INTR BIT(9) +#define TX_FIFO_ALMOST_FULL_INTR BIT(10) +#define TX_FIFO_FULL_INTR BIT(11) +#define RX_EMPTY_INTR BIT(12) +#define RX_ALMOST_EMPTY_INTR BIT(13) +#define RX_ALMOST_FULL_INTR BIT(14) +#define RX_FULL_INTR BIT(15) #define INTERRUPT_STATUS_REG 0x34 #define TX_CLOCK_DIVIDER_REG 0x38 #define TX_FIFO_SIZE_REG 0x40 From 86357d8ed81ba967eca4047574e1b73b8d93772f Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 5 May 2015 18:47:28 +0100 Subject: [PATCH 0414/1163] staging: comedi: gsc_hpdi: use PCI_DEVICE_SUB() Use the `PCI_DEVICE_SUB()` macro in the initializer of the PCI module device table `gsc_hpdi_pci_table[]`. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/gsc_hpdi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index 2e459f6d6fe0..51ab801e82b0 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -702,8 +702,8 @@ static int gsc_hpdi_pci_probe(struct pci_dev *dev, } static const struct pci_device_id gsc_hpdi_pci_table[] = { - { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9080, PCI_VENDOR_ID_PLX, - 0x2400, 0, 0, 0}, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9080, + PCI_VENDOR_ID_PLX, 0x2400) }, { 0 } }; MODULE_DEVICE_TABLE(pci, gsc_hpdi_pci_table); From cbba89f8a8de369d7d3e54c9d7a1f00fc4a358d7 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 5 May 2015 18:47:29 +0100 Subject: [PATCH 0415/1163] staging: comedi: gsc_hpdi: use a better MODULE_DESCRIPTION() Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/gsc_hpdi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index 51ab801e82b0..e9296182236e 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -717,5 +717,5 @@ static struct pci_driver gsc_hpdi_pci_driver = { module_comedi_pci_driver(gsc_hpdi_driver, gsc_hpdi_pci_driver); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("Comedi driver for General Standards PCI-HPDI32/PMC-HPDI32"); MODULE_LICENSE("GPL"); From 12cba5c9df234076d4643e78c131343422d609eb Mon Sep 17 00:00:00 2001 From: Arno Tiemersma Date: Sun, 3 May 2015 22:49:02 +0200 Subject: [PATCH 0416/1163] staging: comedi: daqboard2000: Use preferred comment style Use the preferred block comment style for the copyright and driver description header comments. Signed-off-by: Arno Tiemersma Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/daqboard2000.c | 196 +++++++++--------- 1 file changed, 98 insertions(+), 98 deletions(-) diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index 2ca8d3eec742..611b0a3ef5d7 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -1,105 +1,105 @@ /* - comedi/drivers/daqboard2000.c - hardware driver for IOtech DAQboard/2000 - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 1999 Anders Blomdell - - 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. + * comedi/drivers/daqboard2000.c + * hardware driver for IOtech DAQboard/2000 + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 1999 Anders Blomdell + * + * 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. */ /* -Driver: daqboard2000 -Description: IOTech DAQBoard/2000 -Author: Anders Blomdell -Status: works -Updated: Mon, 14 Apr 2008 15:28:52 +0100 -Devices: [IOTech] DAQBoard/2000 (daqboard2000) - -Much of the functionality of this driver was determined from reading -the source code for the Windows driver. - -The FPGA on the board requires fimware, which is available from -http://www.comedi.org in the comedi_nonfree_firmware tarball. - -Configuration options: not applicable, uses PCI auto config -*/ + * Driver: daqboard2000 + * Description: IOTech DAQBoard/2000 + * Author: Anders Blomdell + * Status: works + * Updated: Mon, 14 Apr 2008 15:28:52 +0100 + * Devices: [IOTech] DAQBoard/2000 (daqboard2000) + * + * Much of the functionality of this driver was determined from reading + * the source code for the Windows driver. + * + * The FPGA on the board requires fimware, which is available from + * http://www.comedi.org in the comedi_nonfree_firmware tarball. + * + * Configuration options: not applicable, uses PCI auto config + */ /* - This card was obviously never intended to leave the Windows world, - since it lacked all kind of hardware documentation (except for cable - pinouts, plug and pray has something to catch up with yet). - - With some help from our swedish distributor, we got the Windows sourcecode - for the card, and here are the findings so far. - - 1. A good document that describes the PCI interface chip is 9080db-106.pdf - available from http://www.plxtech.com/products/io/pci9080 - - 2. The initialization done so far is: - a. program the FPGA (windows code sans a lot of error messages) - b. - - 3. Analog out seems to work OK with DAC's disabled, if DAC's are enabled, - you have to output values to all enabled DAC's until result appears, I - guess that it has something to do with pacer clocks, but the source - gives me no clues. I'll keep it simple so far. - - 4. Analog in. - Each channel in the scanlist seems to be controlled by four - control words: - - Word0: - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - ! | | | ! | | | ! | | | ! | | | ! - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - Word1: - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - ! | | | ! | | | ! | | | ! | | | ! - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | | | | | | | - +------+------+ | | | | +-- Digital input (??) - | | | | +---- 10 us settling time - | | | +------ Suspend acquisition (last to scan) - | | +-------- Simultaneous sample and hold - | +---------- Signed data format - +------------------------- Correction offset low - - Word2: - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - ! | | | ! | | | ! | | | ! | | | ! - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | | | | | | | | | | - +-----+ +--+--+ +++ +++ +--+--+ - | | | | +----- Expansion channel - | | | +----------- Expansion gain - | | +--------------- Channel (low) - | +--------------------- Correction offset high - +----------------------------- Correction gain low - Word3: - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - ! | | | ! | | | ! | | | ! | | | ! - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | | | | | | | | | - +------+------+ | | +-+-+ | | +-- Low bank enable - | | | | | +---- High bank enable - | | | | +------ Hi/low select - | | | +---------- Gain (1,?,2,4,8,16,32,64) - | | +-------------- differential/single ended - | +---------------- Unipolar - +------------------------- Correction gain high - - 999. The card seems to have an incredible amount of capabilities, but - trying to reverse engineer them from the Windows source is beyond my - patience. - + * This card was obviously never intended to leave the Windows world, + * since it lacked all kind of hardware documentation (except for cable + * pinouts, plug and pray has something to catch up with yet). + * + * With some help from our swedish distributor, we got the Windows sourcecode + * for the card, and here are the findings so far. + * + * 1. A good document that describes the PCI interface chip is 9080db-106.pdf + * available from http://www.plxtech.com/products/io/pci9080 + * + * 2. The initialization done so far is: + * a. program the FPGA (windows code sans a lot of error messages) + * b. + * + * 3. Analog out seems to work OK with DAC's disabled, if DAC's are enabled, + * you have to output values to all enabled DAC's until result appears, I + * guess that it has something to do with pacer clocks, but the source + * gives me no clues. I'll keep it simple so far. + * + * 4. Analog in. + * Each channel in the scanlist seems to be controlled by four + * control words: + * + * Word0: + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * ! | | | ! | | | ! | | | ! | | | ! + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + * Word1: + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * ! | | | ! | | | ! | | | ! | | | ! + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | | | | | | | + * +------+------+ | | | | +-- Digital input (??) + * | | | | +---- 10 us settling time + * | | | +------ Suspend acquisition (last to scan) + * | | +-------- Simultaneous sample and hold + * | +---------- Signed data format + * +------------------------- Correction offset low + * + * Word2: + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * ! | | | ! | | | ! | | | ! | | | ! + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | | | | | | | | | | + * +-----+ +--+--+ +++ +++ +--+--+ + * | | | | +----- Expansion channel + * | | | +----------- Expansion gain + * | | +--------------- Channel (low) + * | +--------------------- Correction offset high + * +----------------------------- Correction gain low + * Word3: + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * ! | | | ! | | | ! | | | ! | | | ! + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | | | | | | | | | + * +------+------+ | | +-+-+ | | +-- Low bank enable + * | | | | | +---- High bank enable + * | | | | +------ Hi/low select + * | | | +---------- Gain (1,?,2,4,8,16,32,64) + * | | +-------------- differential/single ended + * | +---------------- Unipolar + * +------------------------- Correction gain high + * + * 999. The card seems to have an incredible amount of capabilities, but + * trying to reverse engineer them from the Windows source is beyond my + * patience. + * */ #include From b42031533560175fdda58a52e192693a2ad3b103 Mon Sep 17 00:00:00 2001 From: Jaime Arrocha Date: Wed, 6 May 2015 17:13:41 -0500 Subject: [PATCH 0417/1163] staging: comedi: coding style identation error fix Errors found by checkpatch.pl. ERROR: code indent should use tabs where possible /drivers/staging/comedi/drivers/das16m1.c:49 /drivers/staging/comedi/drivers/das16m1.c:50 Signed-off-by: Jaime Arrocha Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 1adf6a71a9f3..a18a8878bdb8 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -46,8 +46,8 @@ list has 2 or more channels in it, then two conditions must be satisfied: (2) - the list must have an even number of entries. Options: - [0] - base io address - [1] - irq (optional, but you probably want it) + [0] - base io address + [1] - irq (optional, but you probably want it) irq can be omitted, although the cmd interface will not work without it. */ From 94e057d7c4f01b1593773c7e8c5226cae23cf2c7 Mon Sep 17 00:00:00 2001 From: "Gujulan Elango, Hari Prasath (H.)" Date: Mon, 4 May 2015 09:29:05 +0000 Subject: [PATCH 0418/1163] staging: rtl8192e: fix wrong assignment This patch addresses a spatch warning on assigning a negative value to a unsigned integer.Similar patch has been submitted by Larry Finger earlier to silence the same spatch warning in another file. Signed-off-by: Hari Prasath Gujulan Elango Acked-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 47b5aadcb2bf..6d60ac47c8c5 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -2311,7 +2311,7 @@ static void rtl8192_rx_normal(struct net_device *dev) struct rtllib_rx_stats stats = { .signal = 0, - .noise = -98, + .noise = (u8) -98, .rate = 0, .freq = RTLLIB_24GHZ_BAND, }; From b68cecbedd5a66112b06ca22dce1ea06473b37b9 Mon Sep 17 00:00:00 2001 From: "Gujulan Elango, Hari Prasath (H.)" Date: Fri, 8 May 2015 07:58:43 +0000 Subject: [PATCH 0419/1163] staging: rtl8192e: Use time_after macro This patch replaces a condition check for time elapsed with a simple time_after macro Signed-off-by: Hari Prasath Gujulan Elango Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_ps.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c index 0bbffec0c2ae..840dda962f90 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c @@ -28,6 +28,7 @@ #include "r8192E_phyreg.h" #include "r8190P_rtl8256.h" /* RTL8225 Radio frontend */ #include "r8192E_cmdpkt.h" +#include static void rtl8192_hw_sleep_down(struct net_device *dev) { @@ -93,6 +94,7 @@ void rtl8192_hw_to_sleep(struct net_device *dev, u64 time) u32 tmp; unsigned long flags; + unsigned long timeout; spin_lock_irqsave(&priv->ps_lock, flags); @@ -104,8 +106,8 @@ void rtl8192_hw_to_sleep(struct net_device *dev, u64 time) time - jiffies, msecs_to_jiffies(MIN_SLEEP_TIME)); return; } - - if ((time - jiffies) > msecs_to_jiffies(MAX_SLEEP_TIME)) { + timeout = jiffies + msecs_to_jiffies(MAX_SLEEP_TIME); + if (time_after((unsigned long)time, timeout)) { netdev_info(dev, "========>too long to sleep:%lld > %ld\n", time - jiffies, msecs_to_jiffies(MAX_SLEEP_TIME)); spin_unlock_irqrestore(&priv->ps_lock, flags); From e32e1928146662d1cb7c4dc4385dcdcb0357340e Mon Sep 17 00:00:00 2001 From: "Gujulan Elango, Hari Prasath (H.)" Date: Fri, 8 May 2015 11:04:43 +0000 Subject: [PATCH 0420/1163] staging: rtl8192e: use time_before() macro This patch replaces the condition check for time elapsed with a simplified time_before() macro Signed-off-by: Hari Prasath Gujulan Elango Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_ps.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c index 840dda962f90..386ae0c5f253 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c @@ -100,7 +100,8 @@ void rtl8192_hw_to_sleep(struct net_device *dev, u64 time) time -= msecs_to_jiffies(8 + 16 + 7); - if ((time - jiffies) <= msecs_to_jiffies(MIN_SLEEP_TIME)) { + timeout = jiffies + msecs_to_jiffies(MIN_SLEEP_TIME); + if (time_before((unsigned long)time,timeout)) { spin_unlock_irqrestore(&priv->ps_lock, flags); netdev_info(dev, "too short to sleep::%lld < %ld\n", time - jiffies, msecs_to_jiffies(MIN_SLEEP_TIME)); From 640f7d6938a12f8f3f304d5e5e8680ab3cb5c8a5 Mon Sep 17 00:00:00 2001 From: Arno Tiemersma Date: Sat, 9 May 2015 22:27:16 +0200 Subject: [PATCH 0421/1163] staging: rtl8192e: Change cpu_to_le16 to le16_to_cpu Since the function auth_parse returns a u16, and struct rtllib_authentication.status is defined as an __le16, it seems that return cpu_to_le16(a->status); should be return le16_to_cpu(a->status); This change silences the following sparse warnings: drivers/staging/rtl8192e/rtllib_softmac.c:1817:16: warning: cast from restricted __le16 drivers/staging/rtl8192e/rtllib_softmac.c:1817:16: warning: incorrect type in return expression (different base types) drivers/staging/rtl8192e/rtllib_softmac.c:1817:16: expected unsigned short drivers/staging/rtl8192e/rtllib_softmac.c:1817:16: got restricted __le16 [usertype] Signed-off-by: Arno Tiemersma Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_softmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 8f5e88b802c8..98afd3b557c7 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1814,7 +1814,7 @@ static inline u16 auth_parse(struct sk_buff *skb, u8 **challenge, int *chlen) return -ENOMEM; } } - return cpu_to_le16(a->status); + return le16_to_cpu(a->status); } static int auth_rq_parse(struct sk_buff *skb, u8 *dest) From 99d56ff7c1c2ebfc8b54bcbdbce092714faefa3f Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Mon, 4 May 2015 12:48:09 -0400 Subject: [PATCH 0422/1163] staging/lustre: Always try kmalloc first for OBD_ALLOC_LARGE Create libcfs_kvzalloc and libcfs_kvzalloc_cpt that are designed to replace OBD_ALLOC_LARGE and OBD_CPT_ALLOC_LARGE. Not a drop-in replacement as they also take gfp flags armument for more flexibility. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/libcfs/libcfs.h | 4 ++ .../lustre/lustre/include/obd_support.h | 24 +------- drivers/staging/lustre/lustre/libcfs/Makefile | 1 + .../lustre/lustre/libcfs/linux/linux-mem.c | 59 +++++++++++++++++++ 4 files changed, 67 insertions(+), 21 deletions(-) create mode 100644 drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h index 4410d7fdc1b4..947df7eeca87 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h @@ -184,4 +184,8 @@ static inline void *__container_of(void *ptr, unsigned long shift) #define _LIBCFS_H +void *libcfs_kvzalloc(size_t size, gfp_t flags); +void *libcfs_kvzalloc_cpt(struct cfs_cpt_table *cptab, int cpt, size_t size, + gfp_t flags); + #endif /* _LIBCFS_H */ diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h index 2991d2ee780b..379266d6bcd9 100644 --- a/drivers/staging/lustre/lustre/include/obd_support.h +++ b/drivers/staging/lustre/lustre/include/obd_support.h @@ -676,37 +676,19 @@ do { \ __OBD_VMALLOC_VEROBSE(ptr, cptab, cpt, size) -/* Allocations above this size are considered too big and could not be done - * atomically. - * - * Be very careful when changing this value, especially when decreasing it, - * since vmalloc in Linux doesn't perform well on multi-cores system, calling - * vmalloc in critical path would hurt performance badly. See LU-66. - */ -#define OBD_ALLOC_BIG (4 * PAGE_CACHE_SIZE) - #define OBD_ALLOC_LARGE(ptr, size) \ do { \ - if (size > OBD_ALLOC_BIG) \ - OBD_VMALLOC(ptr, size); \ - else \ - OBD_ALLOC(ptr, size); \ + ptr = libcfs_kvzalloc(size, GFP_NOFS); \ } while (0) #define OBD_CPT_ALLOC_LARGE(ptr, cptab, cpt, size) \ do { \ - if (size > OBD_ALLOC_BIG) \ - OBD_CPT_VMALLOC(ptr, cptab, cpt, size); \ - else \ - OBD_CPT_ALLOC(ptr, cptab, cpt, size); \ + ptr = libcfs_kvzalloc_cpt(cptab, cpt, size, GFP_NOFS); \ } while (0) #define OBD_FREE_LARGE(ptr, size) \ do { \ - if (size > OBD_ALLOC_BIG) \ - OBD_VFREE(ptr, size); \ - else \ - OBD_FREE(ptr, size); \ + kvfree(ptr); \ } while (0) diff --git a/drivers/staging/lustre/lustre/libcfs/Makefile b/drivers/staging/lustre/lustre/libcfs/Makefile index 2996a48a31fb..fabdd3e5de9e 100644 --- a/drivers/staging/lustre/lustre/libcfs/Makefile +++ b/drivers/staging/lustre/lustre/libcfs/Makefile @@ -7,6 +7,7 @@ libcfs-linux-objs += linux-curproc.o libcfs-linux-objs += linux-module.o libcfs-linux-objs += linux-crypto.o libcfs-linux-objs += linux-crypto-adler.o +libcfs-linux-objs += linux-mem.o libcfs-linux-objs := $(addprefix linux/,$(libcfs-linux-objs)) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c new file mode 100644 index 000000000000..025e2f0028ab --- /dev/null +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c @@ -0,0 +1,59 @@ +/* + * 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 + * + */ +/* + * This file creates a memory allocation primitive for Lustre, that + * allows to fallback to vmalloc allocations should regular kernel allocations + * fail due to size or system memory fragmentation. + * + * Author: Oleg Drokin + * + */ +/* + * This file is part of Lustre, http://www.lustre.org/ + * Lustre is a trademark of Seagate Technology. + */ +#include +#include + +#include "../../../include/linux/libcfs/libcfs.h" + +void *libcfs_kvzalloc(size_t size, gfp_t flags) +{ + void *ret; + + ret = kzalloc(size, flags | __GFP_NOWARN); + if (!ret) + ret = __vmalloc(size, flags | __GFP_ZERO, PAGE_KERNEL); + return ret; +} +EXPORT_SYMBOL(libcfs_kvzalloc); + +void *libcfs_kvzalloc_cpt(struct cfs_cpt_table *cptab, int cpt, size_t size, + gfp_t flags) +{ + void *ret; + + ret = kzalloc_node(size, flags | __GFP_NOWARN, + cfs_cpt_spread_node(cptab, cpt)); + if (!ret) { + WARN_ON(!(flags & (__GFP_FS|__GFP_HIGH))); + ret = vmalloc_node(size, cfs_cpt_spread_node(cptab, cpt)); + } + + return ret; +} +EXPORT_SYMBOL(libcfs_kvzalloc_cpt); From d798a29dc4cbbdd31006f3b6e3f0b0589c712047 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Wed, 6 May 2015 18:16:18 +0530 Subject: [PATCH 0423/1163] staging: lustre: llite: remove unuse variables there variables were not used anywhere and was showing as build warning. Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/file.c | 2 -- drivers/staging/lustre/lustre/llite/llite_lib.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 702f62d44430..5c05f41d3575 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -3239,8 +3239,6 @@ void ll_iocontrol_unregister(void *magic) down_write(&llioc.ioc_sem); list_for_each_entry(tmp, &llioc.ioc_head, iocd_list) { if (tmp == magic) { - unsigned int size = tmp->iocd_size; - list_del(&tmp->iocd_list); up_write(&llioc.ioc_sem); diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index c6611b11779c..61acc70aaae4 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -904,8 +904,6 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) char *dt = NULL, *md = NULL; char *profilenm = get_profile_name(sb); struct config_llog_instance *cfg; - /* %p for void* in printf needs 16+2 characters: 0xffffffffffffffff */ - const int instlen = sizeof(cfg->cfg_instance) * 2 + 2; int err; CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb); From 9d9a3d06db9fd5f8c5760db76e0147b7e0c27c0c Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 8 May 2015 23:36:45 +0200 Subject: [PATCH 0424/1163] staging: lustre: cl_page: drop unneeded variable Drop variable made unnecessary by conversion of obd free functions to kfree. Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/cl_page.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index 88735530f91b..59d338aac137 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -248,7 +248,6 @@ EXPORT_SYMBOL(cl_page_gang_lookup); static void cl_page_free(const struct lu_env *env, struct cl_page *page) { struct cl_object *obj = page->cp_obj; - int pagesize = cl_object_header(obj)->coh_page_bufsize; PASSERT(env, page, list_empty(&page->cp_batch)); PASSERT(env, page, page->cp_owner == NULL); From 76c807210aeaefc164dad49d98927f1a84668d36 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 8 May 2015 23:36:46 +0200 Subject: [PATCH 0425/1163] staging: lustre: cl_page: delete empty macros CS_PAGE_INC etc. do nothing, so remove them. The semantic patch that performs this transformation is as follows: (http://coccinelle.lip6.fr/) // @@ expression o,item,state; @@ ( - CS_PAGE_INC(o, item); | - CS_PAGE_DEC(o, item); | - CS_PAGESTATE_INC(o, state); | - CS_PAGESTATE_DEC(o, state); ) // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/obdclass/cl_page.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index 59d338aac137..a7f3032f34dd 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -62,12 +62,6 @@ static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg, # define PINVRNT(env, page, exp) \ ((void)sizeof(env), (void)sizeof(page), (void)sizeof !!(exp)) -/* Disable page statistic by default due to huge performance penalty. */ -#define CS_PAGE_INC(o, item) -#define CS_PAGE_DEC(o, item) -#define CS_PAGESTATE_INC(o, state) -#define CS_PAGESTATE_DEC(o, state) - /** * Internal version of cl_page_top, it should be called if the page is * known to be not freed, says with page referenced, or radix tree lock held, @@ -264,8 +258,6 @@ static void cl_page_free(const struct lu_env *env, struct cl_page *page) list_del_init(page->cp_layers.next); slice->cpl_ops->cpo_fini(env, slice); } - CS_PAGE_DEC(obj, total); - CS_PAGESTATE_DEC(obj, page->cp_state); lu_object_ref_del_at(&obj->co_lu, &page->cp_obj_ref, "cl_page", page); cl_object_put(env, obj); lu_ref_fini(&page->cp_reference); @@ -323,11 +315,6 @@ static struct cl_page *cl_page_alloc(const struct lu_env *env, } } } - if (result == 0) { - CS_PAGE_INC(o, total); - CS_PAGE_INC(o, create); - CS_PAGESTATE_DEC(o, CPS_CACHED); - } } else { page = ERR_PTR(-ENOMEM); } @@ -360,7 +347,6 @@ static struct cl_page *cl_page_find0(const struct lu_env *env, might_sleep(); hdr = cl_object_header(o); - CS_PAGE_INC(o, lookup); CDEBUG(D_PAGE, "%lu@"DFID" %p %lx %d\n", idx, PFID(&hdr->coh_lu.loh_fid), vmpage, vmpage->private, type); @@ -387,7 +373,6 @@ static struct cl_page *cl_page_find0(const struct lu_env *env, } if (page != NULL) { - CS_PAGE_INC(o, hit); return page; } @@ -554,8 +539,6 @@ static void cl_page_state_set0(const struct lu_env *env, PASSERT(env, page, equi(state == CPS_OWNED, page->cp_owner != NULL)); - CS_PAGESTATE_DEC(page->cp_obj, page->cp_state); - CS_PAGESTATE_INC(page->cp_obj, state); cl_page_state_set_trust(page, state); } } From d1c9f3efc47f48bc93106b6bf3fd43f9915da46e Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Thu, 7 May 2015 16:42:20 +0530 Subject: [PATCH 0426/1163] staging: dgap: move function before remove move the cleanup function before the remove call as the next patch of the series is going to use that. Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 61 ++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 6766d5a91a90..63d70592219c 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -6987,6 +6987,36 @@ cleanup_brd: return rc; } +/* + * dgap_cleanup_board() + * + * Free all the memory associated with a board + */ +static void dgap_cleanup_board(struct board_t *brd) +{ + unsigned int i; + + if (!brd || brd->magic != DGAP_BOARD_MAGIC) + return; + + dgap_free_irq(brd); + + tasklet_kill(&brd->helper_tasklet); + + dgap_unmap(brd); + + /* Free all allocated channels structs */ + for (i = 0; i < MAXPORTS ; i++) + kfree(brd->channels[i]); + + kfree(brd->flipbuf); + kfree(brd->flipflagbuf); + + dgap_board[brd->boardnum] = NULL; + + kfree(brd); +} + static void dgap_remove_one(struct pci_dev *dev) { /* Do Nothing */ @@ -7071,37 +7101,6 @@ static void dgap_stop(void) unregister_chrdev(DIGI_DGAP_MAJOR, "dgap"); } -/* - * dgap_cleanup_board() - * - * Free all the memory associated with a board - */ -static void dgap_cleanup_board(struct board_t *brd) -{ - unsigned int i; - - if (!brd || brd->magic != DGAP_BOARD_MAGIC) - return; - - dgap_free_irq(brd); - - tasklet_kill(&brd->helper_tasklet); - - dgap_unmap(brd); - - /* Free all allocated channels structs */ - for (i = 0; i < MAXPORTS ; i++) - kfree(brd->channels[i]); - - kfree(brd->flipbuf); - kfree(brd->flipflagbuf); - - dgap_board[brd->boardnum] = NULL; - - kfree(brd); -} - - /************************************************************************ * * Driver load/unload functions From 1397e2fd065a87f623263e23028f3b252917121b Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Thu, 7 May 2015 16:42:21 +0530 Subject: [PATCH 0427/1163] staging: dgap: use remove function the remove callback will be called in two cases, 1) if the driver is removed and 2) if the pci device is removed. as of now all the board cleanups were being done in the module unload section so if the module is unloaded everything works. But if the pci device is removed then the loaded driver will be left in an inconsistent state. So moved the cleanups in the remove callback and since there was no reference of dgap_driver in remove_one(), so had to define the pci_driver in the function. Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 49 ++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 63d70592219c..ea833fc6addb 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -7019,7 +7019,30 @@ static void dgap_cleanup_board(struct board_t *brd) static void dgap_remove_one(struct pci_dev *dev) { - /* Do Nothing */ + unsigned int i; + ulong lock_flags; + struct pci_driver *drv = to_pci_driver(dev->dev.driver); + + spin_lock_irqsave(&dgap_poll_lock, lock_flags); + dgap_poll_stop = 1; + spin_unlock_irqrestore(&dgap_poll_lock, lock_flags); + + /* Turn off poller right away. */ + del_timer_sync(&dgap_poll_timer); + + dgap_remove_driver_sysfiles(drv); + + device_destroy(dgap_class, MKDEV(DIGI_DGAP_MAJOR, 0)); + 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_cleanup_tty(dgap_board[i]); + dgap_cleanup_board(dgap_board[i]); + } + + dgap_cleanup_nodes(); } static struct pci_driver dgap_driver = { @@ -7149,30 +7172,6 @@ err_stop: */ static void dgap_cleanup_module(void) { - unsigned int i; - ulong lock_flags; - - spin_lock_irqsave(&dgap_poll_lock, lock_flags); - dgap_poll_stop = 1; - spin_unlock_irqrestore(&dgap_poll_lock, lock_flags); - - /* Turn off poller right away. */ - del_timer_sync(&dgap_poll_timer); - - dgap_remove_driver_sysfiles(&dgap_driver); - - device_destroy(dgap_class, MKDEV(DIGI_DGAP_MAJOR, 0)); - 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_cleanup_tty(dgap_board[i]); - dgap_cleanup_board(dgap_board[i]); - } - - dgap_cleanup_nodes(); - if (dgap_numboards) pci_unregister_driver(&dgap_driver); } From 56f40e521047ae8623ad5dcbb5a08ad91684cab6 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Sat, 9 May 2015 17:59:42 +0530 Subject: [PATCH 0428/1163] staging: dgap: remove unused code dgap_sindex() is being only called from dgap_getword() which searches for either ' ' or '\t' or '\n'. this part of the code with '^' at the beginning is never used. Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index ea833fc6addb..92ae8da9b7a3 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -290,8 +290,7 @@ static struct toklist dgap_tlist[] = { /* * dgap_sindex: much like index(), but it looks for a match of any character in - * the group, and returns that position. If the first character is a ^, then - * this will match the first occurrence not in that group. + * the group, and returns that position. */ static char *dgap_sindex(char *string, char *group) { @@ -300,23 +299,11 @@ static char *dgap_sindex(char *string, char *group) if (!string || !group) return NULL; - if (*group == '^') { - group++; - for (; *string; string++) { - for (ptr = group; *ptr; ptr++) { - if (*ptr == *string) - break; - } - if (*ptr == '\0') + for (; *string; string++) { + for (ptr = group; *ptr; ptr++) { + if (*ptr == *string) return string; } - } else { - for (; *string; string++) { - for (ptr = group; *ptr; ptr++) { - if (*ptr == *string) - return string; - } - } } return NULL; From e1099a69a6244baa7d24ce52627bab253a3b52ac Mon Sep 17 00:00:00 2001 From: David Rientjes Date: Tue, 28 Apr 2015 15:50:46 -0700 Subject: [PATCH 0429/1163] android, lmk: avoid setting TIF_MEMDIE if process has already exited MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TIF_MEMDIE should not be set on a process if it does not have a valid ->mm, and this is protected by task_lock(). If TIF_MEMDIE gets set after the mm has detached, and the process fails to exit, then the oom killer will defer forever waiting for it to exit. Make sure that the mm is still valid before setting TIF_MEMDIE by way of mark_tsk_oom_victim(). Cc: "Arve Hjønnevåg" Cc: Riley Andrews Acked-by: Michal Hocko Signed-off-by: David Rientjes Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/lowmemorykiller.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c index feafa172b155..defddf5f80dd 100644 --- a/drivers/staging/android/lowmemorykiller.c +++ b/drivers/staging/android/lowmemorykiller.c @@ -156,20 +156,27 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc) p->pid, p->comm, oom_score_adj, tasksize); } if (selected) { - lowmem_print(1, "send sigkill to %d (%s), adj %hd, size %d\n", - selected->pid, selected->comm, - selected_oom_score_adj, selected_tasksize); - lowmem_deathpending_timeout = jiffies + HZ; + task_lock(selected); + if (!selected->mm) { + /* Already exited, cannot do mark_tsk_oom_victim() */ + task_unlock(selected); + goto out; + } /* * FIXME: lowmemorykiller shouldn't abuse global OOM killer * infrastructure. There is no real reason why the selected * task should have access to the memory reserves. */ mark_tsk_oom_victim(selected); + task_unlock(selected); + lowmem_print(1, "send sigkill to %d (%s), adj %hd, size %d\n", + selected->pid, selected->comm, + selected_oom_score_adj, selected_tasksize); + lowmem_deathpending_timeout = jiffies + HZ; send_sig(SIGKILL, selected, 0); rem += selected_tasksize; } - +out: lowmem_print(4, "lowmem_scan %lu, %x, return %lu\n", sc->nr_to_scan, sc->gfp_mask, rem); rcu_read_unlock(); From be9e6229d67696f94c2f2331a2e207beff9bfc7f Mon Sep 17 00:00:00 2001 From: Tiberiu Breana Date: Mon, 27 Apr 2015 18:34:00 +0300 Subject: [PATCH 0430/1163] iio: light: Add support for Sensortek STK3310 Minimal implementation of an IIO driver for the Sensortek STK3310 ambient light and proximity sensor. The STK3311 model is also supported. Includes: - ACPI support; - read_raw and write_raw; - reading and setting configuration parameters for gain/scale and integration time for both ALS and PS. - power management Signed-off-by: Tiberiu Breana Signed-off-by: Jonathan Cameron --- drivers/iio/light/Kconfig | 11 + drivers/iio/light/Makefile | 1 + drivers/iio/light/stk3310.c | 471 ++++++++++++++++++++++++++++++++++++ 3 files changed, 483 insertions(+) create mode 100644 drivers/iio/light/stk3310.c diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index a437bad46686..3d7bafa6a0e3 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -175,6 +175,17 @@ config LTR501 This driver can also be built as a module. If so, the module will be called ltr501. +config STK3310 + tristate "STK3310 ALS and proximity sensor" + depends on I2C + help + Say yes here to get support for the Sensortek STK3310 ambient light + and proximity sensor. The STK3311 model is also supported by this + driver. + + Choosing M will build the driver as a module. If so, the module + will be called stk3310. + config TCS3414 tristate "TAOS TCS3414 digital color sensor" depends on I2C diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile index ad7c30fe443b..90e7fd258557 100644 --- a/drivers/iio/light/Makefile +++ b/drivers/iio/light/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_JSA1212) += jsa1212.o obj-$(CONFIG_SENSORS_LM3533) += lm3533-als.o obj-$(CONFIG_LTR501) += ltr501.o obj-$(CONFIG_SENSORS_TSL2563) += tsl2563.o +obj-$(CONFIG_STK3310) += stk3310.o obj-$(CONFIG_TCS3414) += tcs3414.o obj-$(CONFIG_TCS3472) += tcs3472.o obj-$(CONFIG_TSL4531) += tsl4531.o diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c new file mode 100644 index 000000000000..0f8c450fc4a2 --- /dev/null +++ b/drivers/iio/light/stk3310.c @@ -0,0 +1,471 @@ +/** + * Sensortek STK3310/STK3311 Ambient Light and Proximity Sensor + * + * Copyright (c) 2015, Intel Corporation. + * + * 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. + * + * IIO driver for STK3310/STK3311. 7-bit I2C address: 0x48. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define STK3310_REG_STATE 0x00 +#define STK3310_REG_PSCTRL 0x01 +#define STK3310_REG_ALSCTRL 0x02 +#define STK3310_REG_PS_DATA_MSB 0x11 +#define STK3310_REG_PS_DATA_LSB 0x12 +#define STK3310_REG_ALS_DATA_MSB 0x13 +#define STK3310_REG_ALS_DATA_LSB 0x14 +#define STK3310_REG_ID 0x3E +#define STK3310_MAX_REG 0x80 + +#define STK3310_STATE_EN_PS 0x01 +#define STK3310_STATE_EN_ALS 0x02 +#define STK3310_STATE_STANDBY 0x00 + +#define STK3310_CHIP_ID_VAL 0x13 +#define STK3311_CHIP_ID_VAL 0x1D +#define STK3310_PS_MAX_VAL 0xFFFF + +#define STK3310_DRIVER_NAME "stk3310" +#define STK3310_REGMAP_NAME "stk3310_regmap" + +#define STK3310_SCALE_AVAILABLE "6.4 1.6 0.4 0.1" + +#define STK3310_IT_AVAILABLE \ + "0.000185 0.000370 0.000741 0.001480 0.002960 0.005920 0.011840 " \ + "0.023680 0.047360 0.094720 0.189440 0.378880 0.757760 1.515520 " \ + "3.031040 6.062080" + +#define STK3310_REGFIELD(name) \ + do { \ + data->reg_##name = \ + devm_regmap_field_alloc(&client->dev, regmap, \ + stk3310_reg_field_##name); \ + if (IS_ERR(data->reg_##name)) { \ + dev_err(&client->dev, "reg field alloc failed.\n"); \ + return PTR_ERR(data->reg_##name); \ + } \ + } while (0) + +static const struct reg_field stk3310_reg_field_state = + REG_FIELD(STK3310_REG_STATE, 0, 2); +static const struct reg_field stk3310_reg_field_als_gain = + REG_FIELD(STK3310_REG_ALSCTRL, 4, 5); +static const struct reg_field stk3310_reg_field_ps_gain = + REG_FIELD(STK3310_REG_PSCTRL, 4, 5); +static const struct reg_field stk3310_reg_field_als_it = + REG_FIELD(STK3310_REG_ALSCTRL, 0, 3); +static const struct reg_field stk3310_reg_field_ps_it = + REG_FIELD(STK3310_REG_PSCTRL, 0, 3); + +/* + * Maximum PS values with regard to scale. Used to export the 'inverse' + * PS value (high values for far objects, low values for near objects). + */ +static const int stk3310_ps_max[4] = { + STK3310_PS_MAX_VAL / 64, + STK3310_PS_MAX_VAL / 16, + STK3310_PS_MAX_VAL / 4, + STK3310_PS_MAX_VAL, +}; + +static const int stk3310_scale_table[][2] = { + {6, 400000}, {1, 600000}, {0, 400000}, {0, 100000} +}; + +/* Integration time in seconds, microseconds */ +static const int stk3310_it_table[][2] = { + {0, 185}, {0, 370}, {0, 741}, {0, 1480}, + {0, 2960}, {0, 5920}, {0, 11840}, {0, 23680}, + {0, 47360}, {0, 94720}, {0, 189440}, {0, 378880}, + {0, 757760}, {1, 515520}, {3, 31040}, {6, 62080}, +}; + +struct stk3310_data { + struct i2c_client *client; + struct mutex lock; + bool als_enabled; + bool ps_enabled; + struct regmap *regmap; + struct regmap_field *reg_state; + struct regmap_field *reg_als_gain; + struct regmap_field *reg_ps_gain; + struct regmap_field *reg_als_it; + struct regmap_field *reg_ps_it; +}; + +static const struct iio_chan_spec stk3310_channels[] = { + { + .type = IIO_LIGHT, + .info_mask_separate = + BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_INT_TIME), + }, + { + .type = IIO_PROXIMITY, + .info_mask_separate = + BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_INT_TIME), + } +}; + +static IIO_CONST_ATTR(in_illuminance_scale_available, STK3310_SCALE_AVAILABLE); + +static IIO_CONST_ATTR(in_proximity_scale_available, STK3310_SCALE_AVAILABLE); + +static IIO_CONST_ATTR(in_illuminance_integration_time_available, + STK3310_IT_AVAILABLE); + +static IIO_CONST_ATTR(in_proximity_integration_time_available, + STK3310_IT_AVAILABLE); + +static struct attribute *stk3310_attributes[] = { + &iio_const_attr_in_illuminance_scale_available.dev_attr.attr, + &iio_const_attr_in_proximity_scale_available.dev_attr.attr, + &iio_const_attr_in_illuminance_integration_time_available.dev_attr.attr, + &iio_const_attr_in_proximity_integration_time_available.dev_attr.attr, + NULL, +}; + +static const struct attribute_group stk3310_attribute_group = { + .attrs = stk3310_attributes +}; + +static int stk3310_get_index(const int table[][2], int table_size, + int val, int val2) +{ + int i; + + for (i = 0; i < table_size; i++) { + if (val == table[i][0] && val2 == table[i][1]) + return i; + } + + return -EINVAL; +} + +static int stk3310_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + u8 reg; + u16 buf; + int ret; + unsigned int index; + struct stk3310_data *data = iio_priv(indio_dev); + struct i2c_client *client = data->client; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + if (chan->type == IIO_LIGHT) + reg = STK3310_REG_ALS_DATA_MSB; + else if (chan->type == IIO_PROXIMITY) + reg = STK3310_REG_PS_DATA_MSB; + else + return -EINVAL; + mutex_lock(&data->lock); + ret = regmap_bulk_read(data->regmap, reg, &buf, 2); + if (ret < 0) { + dev_err(&client->dev, "register read failed\n"); + mutex_unlock(&data->lock); + return ret; + } + *val = swab16(buf); + if (chan->type == IIO_PROXIMITY) { + /* + * Invert the proximity data so we return low values + * for close objects and high values for far ones. + */ + regmap_field_read(data->reg_ps_gain, &index); + *val = stk3310_ps_max[index] - *val; + } + mutex_unlock(&data->lock); + return IIO_VAL_INT; + case IIO_CHAN_INFO_INT_TIME: + if (chan->type == IIO_LIGHT) + regmap_field_read(data->reg_als_it, &index); + else + regmap_field_read(data->reg_ps_it, &index); + *val = stk3310_it_table[index][0]; + *val2 = stk3310_it_table[index][1]; + return IIO_VAL_INT_PLUS_MICRO; + case IIO_CHAN_INFO_SCALE: + if (chan->type == IIO_LIGHT) + regmap_field_read(data->reg_als_gain, &index); + else + regmap_field_read(data->reg_ps_gain, &index); + *val = stk3310_scale_table[index][0]; + *val2 = stk3310_scale_table[index][1]; + return IIO_VAL_INT_PLUS_MICRO; + } + + return -EINVAL; +} + +static int stk3310_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + int ret; + unsigned int index; + struct stk3310_data *data = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_INT_TIME: + index = stk3310_get_index(stk3310_it_table, + ARRAY_SIZE(stk3310_it_table), + val, val2); + if (index < 0) + return -EINVAL; + mutex_lock(&data->lock); + if (chan->type == IIO_LIGHT) + ret = regmap_field_write(data->reg_als_it, index); + else + ret = regmap_field_write(data->reg_ps_it, index); + if (ret < 0) + dev_err(&data->client->dev, + "sensor configuration failed\n"); + mutex_unlock(&data->lock); + return ret; + + case IIO_CHAN_INFO_SCALE: + index = stk3310_get_index(stk3310_scale_table, + ARRAY_SIZE(stk3310_scale_table), + val, val2); + if (index < 0) + return -EINVAL; + mutex_lock(&data->lock); + if (chan->type == IIO_LIGHT) + ret = regmap_field_write(data->reg_als_gain, index); + else + ret = regmap_field_write(data->reg_ps_gain, index); + if (ret < 0) + dev_err(&data->client->dev, + "sensor configuration failed\n"); + mutex_unlock(&data->lock); + return ret; + } + + return -EINVAL; +} + +static const struct iio_info stk3310_info = { + .driver_module = THIS_MODULE, + .read_raw = stk3310_read_raw, + .write_raw = stk3310_write_raw, + .attrs = &stk3310_attribute_group, +}; + +static int stk3310_set_state(struct stk3310_data *data, u8 state) +{ + int ret; + struct i2c_client *client = data->client; + + /* 3-bit state; 0b100 is not supported. */ + if (state > 7 || state == 4) + return -EINVAL; + + mutex_lock(&data->lock); + ret = regmap_field_write(data->reg_state, state); + if (ret < 0) { + dev_err(&client->dev, "failed to change sensor state\n"); + } else if (state != STK3310_STATE_STANDBY) { + /* Don't reset the 'enabled' flags if we're going in standby */ + data->ps_enabled = !!(state & 0x01); + data->als_enabled = !!(state & 0x02); + } + mutex_unlock(&data->lock); + + return ret; +} + +static int stk3310_init(struct iio_dev *indio_dev) +{ + int ret; + int chipid; + u8 state; + struct stk3310_data *data = iio_priv(indio_dev); + struct i2c_client *client = data->client; + + regmap_read(data->regmap, STK3310_REG_ID, &chipid); + if (chipid != STK3310_CHIP_ID_VAL && + chipid != STK3311_CHIP_ID_VAL) { + dev_err(&client->dev, "invalid chip id: 0x%x\n", chipid); + return -ENODEV; + } + + state = STK3310_STATE_EN_ALS | STK3310_STATE_EN_PS; + ret = stk3310_set_state(data, state); + if (ret < 0) + dev_err(&client->dev, "failed to enable sensor"); + + return ret; +} + +static bool stk3310_is_volatile_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case STK3310_REG_ALS_DATA_MSB: + case STK3310_REG_ALS_DATA_LSB: + case STK3310_REG_PS_DATA_LSB: + case STK3310_REG_PS_DATA_MSB: + return true; + default: + return false; + } +} + +static struct regmap_config stk3310_regmap_config = { + .name = STK3310_REGMAP_NAME, + .reg_bits = 8, + .val_bits = 8, + .max_register = STK3310_MAX_REG, + .cache_type = REGCACHE_RBTREE, + .volatile_reg = stk3310_is_volatile_reg, +}; + +static int stk3310_regmap_init(struct stk3310_data *data) +{ + struct regmap *regmap; + struct i2c_client *client; + + client = data->client; + regmap = devm_regmap_init_i2c(client, &stk3310_regmap_config); + if (IS_ERR(regmap)) { + dev_err(&client->dev, "regmap initialization failed.\n"); + return PTR_ERR(regmap); + } + data->regmap = regmap; + + STK3310_REGFIELD(state); + STK3310_REGFIELD(als_gain); + STK3310_REGFIELD(ps_gain); + STK3310_REGFIELD(als_it); + STK3310_REGFIELD(ps_it); + + return 0; +} + +static int stk3310_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + int ret; + struct iio_dev *indio_dev; + struct stk3310_data *data; + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); + if (!indio_dev) { + dev_err(&client->dev, "iio allocation failed!\n"); + return -ENOMEM; + } + + data = iio_priv(indio_dev); + data->client = client; + i2c_set_clientdata(client, indio_dev); + mutex_init(&data->lock); + + ret = stk3310_regmap_init(data); + if (ret < 0) + return ret; + + indio_dev->dev.parent = &client->dev; + indio_dev->info = &stk3310_info; + indio_dev->name = STK3310_DRIVER_NAME; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = stk3310_channels; + indio_dev->num_channels = ARRAY_SIZE(stk3310_channels); + + ret = stk3310_init(indio_dev); + if (ret < 0) + return ret; + + ret = iio_device_register(indio_dev); + if (ret < 0) { + dev_err(&client->dev, "device_register failed\n"); + stk3310_set_state(data, STK3310_STATE_STANDBY); + } + + return ret; +} + +static int stk3310_remove(struct i2c_client *client) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(client); + + iio_device_unregister(indio_dev); + return stk3310_set_state(iio_priv(indio_dev), STK3310_STATE_STANDBY); +} + +#ifdef CONFIG_PM_SLEEP +static int stk3310_suspend(struct device *dev) +{ + struct stk3310_data *data; + + data = iio_priv(i2c_get_clientdata(to_i2c_client(dev))); + + return stk3310_set_state(data, STK3310_STATE_STANDBY); +} + +static int stk3310_resume(struct device *dev) +{ + int state = 0; + struct stk3310_data *data; + + data = iio_priv(i2c_get_clientdata(to_i2c_client(dev))); + if (data->ps_enabled) + state |= STK3310_STATE_EN_PS; + if (data->als_enabled) + state |= STK3310_STATE_EN_ALS; + + return stk3310_set_state(data, state); +} + +static SIMPLE_DEV_PM_OPS(stk3310_pm_ops, stk3310_suspend, stk3310_resume); + +#define STK3310_PM_OPS (&stk3310_pm_ops) +#else +#define STK3310_PM_OPS NULL +#endif + +static const struct i2c_device_id stk3310_i2c_id[] = { + {"STK3310", 0}, + {"STK3311", 0}, + {} +}; + +static const struct acpi_device_id stk3310_acpi_id[] = { + {"STK3310", 0}, + {"STK3311", 0}, + {} +}; + +MODULE_DEVICE_TABLE(acpi, stk3310_acpi_id); + +static struct i2c_driver stk3310_driver = { + .driver = { + .name = "stk3310", + .pm = STK3310_PM_OPS, + .acpi_match_table = ACPI_PTR(stk3310_acpi_id), + }, + .probe = stk3310_probe, + .remove = stk3310_remove, + .id_table = stk3310_i2c_id, +}; + +module_i2c_driver(stk3310_driver); + +MODULE_AUTHOR("Tiberiu Breana "); +MODULE_DESCRIPTION("STK3310 Ambient Light and Proximity Sensor driver"); +MODULE_LICENSE("GPL v2"); From 3dd477acbdd1f147f432a742afc5521168341461 Mon Sep 17 00:00:00 2001 From: Tiberiu Breana Date: Mon, 27 Apr 2015 18:34:01 +0300 Subject: [PATCH 0431/1163] iio: light: Add threshold interrupt support for STK3310 Added interrupt support for proximity threshold events to the stk3310 driver. Signed-off-by: Tiberiu Breana Signed-off-by: Jonathan Cameron --- drivers/iio/light/stk3310.c | 255 +++++++++++++++++++++++++++++++++++- 1 file changed, 253 insertions(+), 2 deletions(-) diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c index 0f8c450fc4a2..e79b9d89b024 100644 --- a/drivers/iio/light/stk3310.c +++ b/drivers/iio/light/stk3310.c @@ -12,15 +12,22 @@ #include #include +#include #include #include #include +#include +#include #include #include #define STK3310_REG_STATE 0x00 #define STK3310_REG_PSCTRL 0x01 #define STK3310_REG_ALSCTRL 0x02 +#define STK3310_REG_INT 0x04 +#define STK3310_REG_THDH_PS 0x06 +#define STK3310_REG_THDL_PS 0x08 +#define STK3310_REG_FLAG 0x10 #define STK3310_REG_PS_DATA_MSB 0x11 #define STK3310_REG_PS_DATA_LSB 0x12 #define STK3310_REG_ALS_DATA_MSB 0x13 @@ -34,10 +41,14 @@ #define STK3310_CHIP_ID_VAL 0x13 #define STK3311_CHIP_ID_VAL 0x1D +#define STK3310_PSINT_EN 0x01 #define STK3310_PS_MAX_VAL 0xFFFF +#define STK3310_THRESH_MAX 0xFFFF #define STK3310_DRIVER_NAME "stk3310" #define STK3310_REGMAP_NAME "stk3310_regmap" +#define STK3310_EVENT "stk3310_event" +#define STK3310_GPIO "stk3310_gpio" #define STK3310_SCALE_AVAILABLE "6.4 1.6 0.4 0.1" @@ -67,7 +78,12 @@ static const struct reg_field stk3310_reg_field_als_it = REG_FIELD(STK3310_REG_ALSCTRL, 0, 3); static const struct reg_field stk3310_reg_field_ps_it = REG_FIELD(STK3310_REG_PSCTRL, 0, 3); - +static const struct reg_field stk3310_reg_field_int_ps = + REG_FIELD(STK3310_REG_INT, 0, 2); +static const struct reg_field stk3310_reg_field_flag_psint = + REG_FIELD(STK3310_REG_FLAG, 4, 4); +static const struct reg_field stk3310_reg_field_flag_nf = + REG_FIELD(STK3310_REG_FLAG, 0, 0); /* * Maximum PS values with regard to scale. Used to export the 'inverse' * PS value (high values for far objects, low values for near objects). @@ -96,12 +112,33 @@ struct stk3310_data { struct mutex lock; bool als_enabled; bool ps_enabled; + u64 timestamp; struct regmap *regmap; struct regmap_field *reg_state; struct regmap_field *reg_als_gain; struct regmap_field *reg_ps_gain; struct regmap_field *reg_als_it; struct regmap_field *reg_ps_it; + struct regmap_field *reg_int_ps; + struct regmap_field *reg_flag_psint; + struct regmap_field *reg_flag_nf; +}; + +static const struct iio_event_spec stk3310_events[] = { + /* Proximity event */ + { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_FALLING, + .mask_separate = BIT(IIO_EV_INFO_VALUE) | + BIT(IIO_EV_INFO_ENABLE), + }, + /* Out-of-proximity event */ + { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_RISING, + .mask_separate = BIT(IIO_EV_INFO_VALUE) | + BIT(IIO_EV_INFO_ENABLE), + }, }; static const struct iio_chan_spec stk3310_channels[] = { @@ -118,6 +155,8 @@ static const struct iio_chan_spec stk3310_channels[] = { BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_INT_TIME), + .event_spec = stk3310_events, + .num_event_specs = ARRAY_SIZE(stk3310_events), } }; @@ -156,6 +195,118 @@ static int stk3310_get_index(const int table[][2], int table_size, return -EINVAL; } +static int stk3310_read_event(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) +{ + u8 reg; + u16 buf; + int ret; + unsigned int index; + struct stk3310_data *data = iio_priv(indio_dev); + + if (info != IIO_EV_INFO_VALUE) + return -EINVAL; + + /* + * Only proximity interrupts are implemented at the moment. + * Since we're inverting proximity values, the sensor's 'high' + * threshold will become our 'low' threshold, associated with + * 'near' events. Similarly, the sensor's 'low' threshold will + * be our 'high' threshold, associated with 'far' events. + */ + if (dir == IIO_EV_DIR_RISING) + reg = STK3310_REG_THDL_PS; + else if (dir == IIO_EV_DIR_FALLING) + reg = STK3310_REG_THDH_PS; + else + return -EINVAL; + + mutex_lock(&data->lock); + ret = regmap_bulk_read(data->regmap, reg, &buf, 2); + mutex_unlock(&data->lock); + if (ret < 0) { + dev_err(&data->client->dev, "register read failed\n"); + return ret; + } + regmap_field_read(data->reg_ps_gain, &index); + *val = swab16(stk3310_ps_max[index] - buf); + + return IIO_VAL_INT; +} + +static int stk3310_write_event(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) +{ + u8 reg; + u16 buf; + int ret; + unsigned int index; + struct stk3310_data *data = iio_priv(indio_dev); + struct i2c_client *client = data->client; + + regmap_field_read(data->reg_ps_gain, &index); + if (val > stk3310_ps_max[index]) + return -EINVAL; + + if (dir == IIO_EV_DIR_RISING) + reg = STK3310_REG_THDL_PS; + else if (dir == IIO_EV_DIR_FALLING) + reg = STK3310_REG_THDH_PS; + else + return -EINVAL; + + buf = swab16(stk3310_ps_max[index] - val); + ret = regmap_bulk_write(data->regmap, reg, &buf, 2); + if (ret < 0) + dev_err(&client->dev, "failed to set PS threshold!\n"); + + return ret; +} + +static int stk3310_read_event_config(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir) +{ + unsigned int event_val; + struct stk3310_data *data = iio_priv(indio_dev); + + regmap_field_read(data->reg_int_ps, &event_val); + + return event_val; +} + +static int stk3310_write_event_config(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir, + int state) +{ + int ret; + struct stk3310_data *data = iio_priv(indio_dev); + struct i2c_client *client = data->client; + + if (state < 0 || state > 7) + return -EINVAL; + + /* Set INT_PS value */ + mutex_lock(&data->lock); + ret = regmap_field_write(data->reg_int_ps, state); + if (ret < 0) + dev_err(&client->dev, "failed to set interrupt mode\n"); + mutex_unlock(&data->lock); + + return ret; +} + static int stk3310_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) @@ -266,6 +417,10 @@ static const struct iio_info stk3310_info = { .read_raw = stk3310_read_raw, .write_raw = stk3310_write_raw, .attrs = &stk3310_attribute_group, + .read_event_value = stk3310_read_event, + .write_event_value = stk3310_write_event, + .read_event_config = stk3310_read_event_config, + .write_event_config = stk3310_write_event_config, }; static int stk3310_set_state(struct stk3310_data *data, u8 state) @@ -308,8 +463,43 @@ static int stk3310_init(struct iio_dev *indio_dev) state = STK3310_STATE_EN_ALS | STK3310_STATE_EN_PS; ret = stk3310_set_state(data, state); - if (ret < 0) + if (ret < 0) { dev_err(&client->dev, "failed to enable sensor"); + return ret; + } + + /* Enable PS interrupts */ + ret = regmap_field_write(data->reg_int_ps, STK3310_PSINT_EN); + if (ret < 0) + dev_err(&client->dev, "failed to enable interrupts!\n"); + + return ret; +} + +static int stk3310_gpio_probe(struct i2c_client *client) +{ + struct device *dev; + struct gpio_desc *gpio; + int ret; + + if (!client) + return -EINVAL; + + dev = &client->dev; + + /* gpio interrupt pin */ + gpio = devm_gpiod_get_index(dev, STK3310_GPIO, 0); + if (IS_ERR(gpio)) { + dev_err(dev, "acpi gpio get index failed\n"); + return PTR_ERR(gpio); + } + + ret = gpiod_direction_input(gpio); + if (ret) + return ret; + + ret = gpiod_to_irq(gpio); + dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret); return ret; } @@ -321,6 +511,7 @@ static bool stk3310_is_volatile_reg(struct device *dev, unsigned int reg) case STK3310_REG_ALS_DATA_LSB: case STK3310_REG_PS_DATA_LSB: case STK3310_REG_PS_DATA_MSB: + case STK3310_REG_FLAG: return true; default: return false; @@ -354,10 +545,55 @@ static int stk3310_regmap_init(struct stk3310_data *data) STK3310_REGFIELD(ps_gain); STK3310_REGFIELD(als_it); STK3310_REGFIELD(ps_it); + STK3310_REGFIELD(int_ps); + STK3310_REGFIELD(flag_psint); + STK3310_REGFIELD(flag_nf); return 0; } +static irqreturn_t stk3310_irq_handler(int irq, void *private) +{ + struct iio_dev *indio_dev = private; + struct stk3310_data *data = iio_priv(indio_dev); + + data->timestamp = iio_get_time_ns(); + + return IRQ_WAKE_THREAD; +} + +static irqreturn_t stk3310_irq_event_handler(int irq, void *private) +{ + int ret; + unsigned int dir; + u64 event; + + struct iio_dev *indio_dev = private; + struct stk3310_data *data = iio_priv(indio_dev); + + /* Read FLAG_NF to figure out what threshold has been met. */ + mutex_lock(&data->lock); + ret = regmap_field_read(data->reg_flag_nf, &dir); + if (ret < 0) { + dev_err(&data->client->dev, "register read failed\n"); + mutex_unlock(&data->lock); + return ret; + } + event = IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, 1, + IIO_EV_TYPE_THRESH, + (dir ? IIO_EV_DIR_RISING : + IIO_EV_DIR_FALLING)); + iio_push_event(indio_dev, event, data->timestamp); + + /* Reset the interrupt flag */ + ret = regmap_field_write(data->reg_flag_psint, 0); + if (ret < 0) + dev_err(&data->client->dev, "failed to reset interrupts\n"); + mutex_unlock(&data->lock); + + return IRQ_HANDLED; +} + static int stk3310_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -397,6 +633,21 @@ static int stk3310_probe(struct i2c_client *client, stk3310_set_state(data, STK3310_STATE_STANDBY); } + if (client->irq <= 0) + client->irq = stk3310_gpio_probe(client); + + if (client->irq >= 0) { + ret = devm_request_threaded_irq(&client->dev, client->irq, + stk3310_irq_handler, + stk3310_irq_event_handler, + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, + STK3310_EVENT, indio_dev); + if (ret < 0) + dev_err(&client->dev, "request irq %d failed\n", + client->irq); + } + return ret; } From 8493585317b1fe1ab7a334faac71fb1e36fde508 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 5 May 2015 18:32:23 +0200 Subject: [PATCH 0432/1163] iio: Allow compile test of GPIO consumers if !GPIOLIB The GPIO subsystem provides dummy GPIO consumer functions if GPIOLIB is not enabled. Hence drivers that depend on GPIOLIB, but use GPIO consumer functionality only, can still be compiled if GPIOLIB is not enabled. Relax the dependency on GPIOLIB if COMPILE_TEST is enabled, where appropriate. Signed-off-by: Geert Uytterhoeven Cc: Jonathan Cameron Cc: linux-iio@vger.kernel.org Signed-off-by: Jonathan Cameron --- drivers/iio/humidity/Kconfig | 2 +- drivers/iio/magnetometer/Kconfig | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/humidity/Kconfig b/drivers/iio/humidity/Kconfig index 4813b793b9f7..688c0d1cb47d 100644 --- a/drivers/iio/humidity/Kconfig +++ b/drivers/iio/humidity/Kconfig @@ -5,7 +5,7 @@ menu "Humidity sensors" config DHT11 tristate "DHT11 (and compatible sensors) driver" - depends on GPIOLIB + depends on GPIOLIB || COMPILE_TEST help This driver supports reading data via a single interrupt generating GPIO line. Currently tested are DHT11 and DHT22. diff --git a/drivers/iio/magnetometer/Kconfig b/drivers/iio/magnetometer/Kconfig index a5d6de72c523..00297bbb7e4b 100644 --- a/drivers/iio/magnetometer/Kconfig +++ b/drivers/iio/magnetometer/Kconfig @@ -8,7 +8,7 @@ menu "Magnetometer sensors" config AK8975 tristate "Asahi Kasei AK 3-Axis Magnetometer" depends on I2C - depends on GPIOLIB + depends on GPIOLIB || COMPILE_TEST help Say yes here to build support for Asahi Kasei AK8975, AK8963, AK09911 or AK09912 3-Axis Magnetometer. @@ -19,7 +19,7 @@ config AK8975 config AK09911 tristate "Asahi Kasei AK09911 3-axis Compass" depends on I2C - depends on GPIOLIB + depends on GPIOLIB || COMPILE_TEST select AK8975 help Deprecated: AK09911 is now supported by AK8975 driver. From 9291766476f3b067c740fe9cc0b4cd78ace27409 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 5 May 2015 18:32:36 +0200 Subject: [PATCH 0433/1163] Staging: iio: Allow compile test of GPIO consumers if !GPIOLIB The GPIO subsystem provides dummy GPIO consumer functions if GPIOLIB is not enabled. Hence drivers that depend on GPIOLIB, but use GPIO consumer functionality only, can still be compiled if GPIOLIB is not enabled. Relax the dependency on GPIOLIB if COMPILE_TEST is enabled, where appropriate. Signed-off-by: Geert Uytterhoeven Cc: Jonathan Cameron Cc: linux-iio@vger.kernel.org Cc: devel@driverdev.osuosl.org Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/Kconfig | 2 +- drivers/staging/iio/adc/Kconfig | 6 +++--- drivers/staging/iio/addac/Kconfig | 2 +- drivers/staging/iio/resolver/Kconfig | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/iio/accel/Kconfig b/drivers/staging/iio/accel/Kconfig index 07b7ffa00ab5..fa67da9408b6 100644 --- a/drivers/staging/iio/accel/Kconfig +++ b/drivers/staging/iio/accel/Kconfig @@ -79,7 +79,7 @@ config LIS3L02DQ depends on SPI select IIO_TRIGGER if IIO_BUFFER depends on !IIO_BUFFER || IIO_KFIFO_BUF - depends on GPIOLIB + depends on GPIOLIB || COMPILE_TEST help Say Y here to build SPI support for the ST microelectronics accelerometer. The driver supplies direct access via sysfs files diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig index d0016ce6e658..94ae4232ee77 100644 --- a/drivers/staging/iio/adc/Kconfig +++ b/drivers/staging/iio/adc/Kconfig @@ -5,7 +5,7 @@ menu "Analog to digital converters" config AD7606 tristate "Analog Devices AD7606 ADC driver" - depends on GPIOLIB + depends on GPIOLIB || COMPILE_TEST select IIO_BUFFER select IIO_TRIGGERED_BUFFER help @@ -39,7 +39,7 @@ config AD7606_IFACE_SPI config AD7780 tristate "Analog Devices AD7780 and similar ADCs driver" depends on SPI - depends on GPIOLIB + depends on GPIOLIB || COMPILE_TEST select AD_SIGMA_DELTA help Say yes here to build support for Analog Devices AD7170, AD7171, @@ -52,7 +52,7 @@ config AD7780 config AD7816 tristate "Analog Devices AD7816/7/8 temperature sensor and ADC driver" depends on SPI - depends on GPIOLIB + depends on GPIOLIB || COMPILE_TEST help Say yes here to build support for Analog Devices AD7816/7/8 temperature sensors and ADC. diff --git a/drivers/staging/iio/addac/Kconfig b/drivers/staging/iio/addac/Kconfig index 0ed7e13e2283..ba18b8432d9c 100644 --- a/drivers/staging/iio/addac/Kconfig +++ b/drivers/staging/iio/addac/Kconfig @@ -5,7 +5,7 @@ menu "Analog digital bi-direction converters" config ADT7316 tristate "Analog Devices ADT7316/7/8 ADT7516/7/9 temperature sensor, ADC and DAC driver" - depends on GPIOLIB + depends on GPIOLIB || COMPILE_TEST help Say yes here to build support for Analog Devices ADT7316, ADT7317, ADT7318 and ADT7516, ADT7517, ADT7519 temperature sensors, ADC and DAC. diff --git a/drivers/staging/iio/resolver/Kconfig b/drivers/staging/iio/resolver/Kconfig index c7a742ec1227..1c7e2860d6b7 100644 --- a/drivers/staging/iio/resolver/Kconfig +++ b/drivers/staging/iio/resolver/Kconfig @@ -16,7 +16,7 @@ config AD2S90 config AD2S1200 tristate "Analog Devices ad2s1200/ad2s1205 driver" depends on SPI - depends on GPIOLIB + depends on GPIOLIB || COMPILE_TEST help Say yes here to build support for Analog Devices spi resolver to digital converters, ad2s1200 and ad2s1205, provides direct access @@ -28,7 +28,7 @@ config AD2S1200 config AD2S1210 tristate "Analog Devices ad2s1210 driver" depends on SPI - depends on GPIOLIB + depends on GPIOLIB || COMPILE_TEST help Say yes here to build support for Analog Devices spi resolver to digital converters, ad2s1210, provides direct access via sysfs. From c91746a2361d75bb8ded6ef4813a4a2dcdcd845e Mon Sep 17 00:00:00 2001 From: Irina Tirdea Date: Wed, 29 Apr 2015 21:16:37 +0300 Subject: [PATCH 0434/1163] iio: magn: Add support for BMC150 magnetometer Add support for the Bosh BMC150 Magnetometer. The specification can be downloaded from: http://ae-bst.resource.bosch.com/media/products/dokumente/bmc150/BST-BMC150-DS000-04.pdf. The chip contains both an accelerometer and a magnetometer. This patch adds support only for the magnetometer part. The temperature compensation formulas are based on bmm050_api.c authored by contact@bosch.sensortec.com. Signed-off-by: Irina Tirdea Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/Kconfig | 14 + drivers/iio/magnetometer/Makefile | 2 + drivers/iio/magnetometer/bmc150_magn.c | 984 +++++++++++++++++++++++++ 3 files changed, 1000 insertions(+) create mode 100644 drivers/iio/magnetometer/bmc150_magn.c diff --git a/drivers/iio/magnetometer/Kconfig b/drivers/iio/magnetometer/Kconfig index 00297bbb7e4b..9746a2a88640 100644 --- a/drivers/iio/magnetometer/Kconfig +++ b/drivers/iio/magnetometer/Kconfig @@ -76,4 +76,18 @@ config IIO_ST_MAGN_SPI_3AXIS depends on IIO_ST_MAGN_3AXIS depends on IIO_ST_SENSORS_SPI +config BMC150_MAGN + tristate "Bosch BMC150 Magnetometer Driver" + depends on I2C + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + help + Say yes here to build support for the BMC150 magnetometer. + + Currently this only supports the device via an i2c interface. + + This is a combo module with both accelerometer and magnetometer. + This driver is only implementing magnetometer part, which has + its own address and register map. + endmenu diff --git a/drivers/iio/magnetometer/Makefile b/drivers/iio/magnetometer/Makefile index 0f5d3c985799..e2c34594ff3f 100644 --- a/drivers/iio/magnetometer/Makefile +++ b/drivers/iio/magnetometer/Makefile @@ -13,3 +13,5 @@ st_magn-$(CONFIG_IIO_BUFFER) += st_magn_buffer.o obj-$(CONFIG_IIO_ST_MAGN_I2C_3AXIS) += st_magn_i2c.o obj-$(CONFIG_IIO_ST_MAGN_SPI_3AXIS) += st_magn_spi.o + +obj-$(CONFIG_BMC150_MAGN) += bmc150_magn.o diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c new file mode 100644 index 000000000000..7bbaea8e036c --- /dev/null +++ b/drivers/iio/magnetometer/bmc150_magn.c @@ -0,0 +1,984 @@ +/* + * Bosch BMC150 three-axis magnetic field sensor driver + * + * Copyright (c) 2015, Intel Corporation. + * + * This code is based on bmm050_api.c authored by contact@bosch.sensortec.com: + * + * (C) Copyright 2011~2014 Bosch Sensortec GmbH All Rights Reserved + * + * 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 +#include +#include +#include +#include + +#define BMC150_MAGN_DRV_NAME "bmc150_magn" +#define BMC150_MAGN_IRQ_NAME "bmc150_magn_event" +#define BMC150_MAGN_GPIO_INT "interrupt" + +#define BMC150_MAGN_REG_CHIP_ID 0x40 +#define BMC150_MAGN_CHIP_ID_VAL 0x32 + +#define BMC150_MAGN_REG_X_L 0x42 +#define BMC150_MAGN_REG_X_M 0x43 +#define BMC150_MAGN_REG_Y_L 0x44 +#define BMC150_MAGN_REG_Y_M 0x45 +#define BMC150_MAGN_SHIFT_XY_L 3 +#define BMC150_MAGN_REG_Z_L 0x46 +#define BMC150_MAGN_REG_Z_M 0x47 +#define BMC150_MAGN_SHIFT_Z_L 1 +#define BMC150_MAGN_REG_RHALL_L 0x48 +#define BMC150_MAGN_REG_RHALL_M 0x49 +#define BMC150_MAGN_SHIFT_RHALL_L 2 + +#define BMC150_MAGN_REG_INT_STATUS 0x4A + +#define BMC150_MAGN_REG_POWER 0x4B +#define BMC150_MAGN_MASK_POWER_CTL BIT(0) + +#define BMC150_MAGN_REG_OPMODE_ODR 0x4C +#define BMC150_MAGN_MASK_OPMODE GENMASK(2, 1) +#define BMC150_MAGN_SHIFT_OPMODE 1 +#define BMC150_MAGN_MODE_NORMAL 0x00 +#define BMC150_MAGN_MODE_FORCED 0x01 +#define BMC150_MAGN_MODE_SLEEP 0x03 +#define BMC150_MAGN_MASK_ODR GENMASK(5, 3) +#define BMC150_MAGN_SHIFT_ODR 3 + +#define BMC150_MAGN_REG_INT 0x4D + +#define BMC150_MAGN_REG_INT_DRDY 0x4E +#define BMC150_MAGN_MASK_DRDY_EN BIT(7) +#define BMC150_MAGN_SHIFT_DRDY_EN 7 +#define BMC150_MAGN_MASK_DRDY_INT3 BIT(6) +#define BMC150_MAGN_MASK_DRDY_Z_EN BIT(5) +#define BMC150_MAGN_MASK_DRDY_Y_EN BIT(4) +#define BMC150_MAGN_MASK_DRDY_X_EN BIT(3) +#define BMC150_MAGN_MASK_DRDY_DR_POLARITY BIT(2) +#define BMC150_MAGN_MASK_DRDY_LATCHING BIT(1) +#define BMC150_MAGN_MASK_DRDY_INT3_POLARITY BIT(0) + +#define BMC150_MAGN_REG_LOW_THRESH 0x4F +#define BMC150_MAGN_REG_HIGH_THRESH 0x50 +#define BMC150_MAGN_REG_REP_XY 0x51 +#define BMC150_MAGN_REG_REP_Z 0x52 + +#define BMC150_MAGN_REG_TRIM_START 0x5D +#define BMC150_MAGN_REG_TRIM_END 0x71 + +#define BMC150_MAGN_XY_OVERFLOW_VAL -4096 +#define BMC150_MAGN_Z_OVERFLOW_VAL -16384 + +/* Time from SUSPEND to SLEEP */ +#define BMC150_MAGN_START_UP_TIME_MS 3 + +#define BMC150_MAGN_AUTO_SUSPEND_DELAY_MS 2000 + +#define BMC150_MAGN_REGVAL_TO_REPXY(regval) (((regval) * 2) + 1) +#define BMC150_MAGN_REGVAL_TO_REPZ(regval) ((regval) + 1) +#define BMC150_MAGN_REPXY_TO_REGVAL(rep) (((rep) - 1) / 2) +#define BMC150_MAGN_REPZ_TO_REGVAL(rep) ((rep) - 1) + +enum bmc150_magn_axis { + AXIS_X, + AXIS_Y, + AXIS_Z, + RHALL, + AXIS_XYZ_MAX = RHALL, + AXIS_XYZR_MAX, +}; + +enum bmc150_magn_power_modes { + BMC150_MAGN_POWER_MODE_SUSPEND, + BMC150_MAGN_POWER_MODE_SLEEP, + BMC150_MAGN_POWER_MODE_NORMAL, +}; + +struct bmc150_magn_trim_regs { + s8 x1; + s8 y1; + __le16 reserved1; + u8 reserved2; + __le16 z4; + s8 x2; + s8 y2; + __le16 reserved3; + __le16 z2; + __le16 z1; + __le16 xyz1; + __le16 z3; + s8 xy2; + u8 xy1; +} __packed; + +struct bmc150_magn_data { + struct i2c_client *client; + /* + * 1. Protect this structure. + * 2. Serialize sequences that power on/off the device and access HW. + */ + struct mutex mutex; + struct regmap *regmap; + /* 4 x 32 bits for x, y z, 4 bytes align, 64 bits timestamp */ + s32 buffer[6]; + struct iio_trigger *dready_trig; + bool dready_trigger_on; +}; + +static const struct { + int freq; + u8 reg_val; +} bmc150_magn_samp_freq_table[] = { {2, 0x01}, + {6, 0x02}, + {8, 0x03}, + {10, 0x00}, + {15, 0x04}, + {20, 0x05}, + {25, 0x06}, + {30, 0x07} }; + +enum bmc150_magn_presets { + LOW_POWER_PRESET, + REGULAR_PRESET, + ENHANCED_REGULAR_PRESET, + HIGH_ACCURACY_PRESET +}; + +static const struct bmc150_magn_preset { + u8 rep_xy; + u8 rep_z; + u8 odr; +} bmc150_magn_presets_table[] = { + [LOW_POWER_PRESET] = {3, 3, 10}, + [REGULAR_PRESET] = {9, 15, 10}, + [ENHANCED_REGULAR_PRESET] = {15, 27, 10}, + [HIGH_ACCURACY_PRESET] = {47, 83, 20}, +}; + +#define BMC150_MAGN_DEFAULT_PRESET REGULAR_PRESET + +static bool bmc150_magn_is_writeable_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case BMC150_MAGN_REG_POWER: + case BMC150_MAGN_REG_OPMODE_ODR: + case BMC150_MAGN_REG_INT: + case BMC150_MAGN_REG_INT_DRDY: + case BMC150_MAGN_REG_LOW_THRESH: + case BMC150_MAGN_REG_HIGH_THRESH: + case BMC150_MAGN_REG_REP_XY: + case BMC150_MAGN_REG_REP_Z: + return true; + default: + return false; + }; +} + +static bool bmc150_magn_is_volatile_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case BMC150_MAGN_REG_X_L: + case BMC150_MAGN_REG_X_M: + case BMC150_MAGN_REG_Y_L: + case BMC150_MAGN_REG_Y_M: + case BMC150_MAGN_REG_Z_L: + case BMC150_MAGN_REG_Z_M: + case BMC150_MAGN_REG_RHALL_L: + case BMC150_MAGN_REG_RHALL_M: + case BMC150_MAGN_REG_INT_STATUS: + return true; + default: + return false; + } +} + +static const struct regmap_config bmc150_magn_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + + .max_register = BMC150_MAGN_REG_TRIM_END, + .cache_type = REGCACHE_RBTREE, + + .writeable_reg = bmc150_magn_is_writeable_reg, + .volatile_reg = bmc150_magn_is_volatile_reg, +}; + +static int bmc150_magn_set_power_mode(struct bmc150_magn_data *data, + enum bmc150_magn_power_modes mode, + bool state) +{ + int ret; + + switch (mode) { + case BMC150_MAGN_POWER_MODE_SUSPEND: + ret = regmap_update_bits(data->regmap, BMC150_MAGN_REG_POWER, + BMC150_MAGN_MASK_POWER_CTL, !state); + if (ret < 0) + return ret; + usleep_range(BMC150_MAGN_START_UP_TIME_MS * 1000, 20000); + return 0; + case BMC150_MAGN_POWER_MODE_SLEEP: + return regmap_update_bits(data->regmap, + BMC150_MAGN_REG_OPMODE_ODR, + BMC150_MAGN_MASK_OPMODE, + BMC150_MAGN_MODE_SLEEP << + BMC150_MAGN_SHIFT_OPMODE); + case BMC150_MAGN_POWER_MODE_NORMAL: + return regmap_update_bits(data->regmap, + BMC150_MAGN_REG_OPMODE_ODR, + BMC150_MAGN_MASK_OPMODE, + BMC150_MAGN_MODE_NORMAL << + BMC150_MAGN_SHIFT_OPMODE); + } + + return -EINVAL; +} + +static int bmc150_magn_set_power_state(struct bmc150_magn_data *data, bool on) +{ +#ifdef CONFIG_PM + int ret; + + if (on) { + ret = pm_runtime_get_sync(&data->client->dev); + } else { + pm_runtime_mark_last_busy(&data->client->dev); + ret = pm_runtime_put_autosuspend(&data->client->dev); + } + + if (ret < 0) { + dev_err(&data->client->dev, + "failed to change power state to %d\n", on); + if (on) + pm_runtime_put_noidle(&data->client->dev); + + return ret; + } +#endif + + return 0; +} + +static int bmc150_magn_get_odr(struct bmc150_magn_data *data, int *val) +{ + int ret, reg_val; + u8 i, odr_val; + + ret = regmap_read(data->regmap, BMC150_MAGN_REG_OPMODE_ODR, ®_val); + if (ret < 0) + return ret; + odr_val = (reg_val & BMC150_MAGN_MASK_ODR) >> BMC150_MAGN_SHIFT_ODR; + + for (i = 0; i < ARRAY_SIZE(bmc150_magn_samp_freq_table); i++) + if (bmc150_magn_samp_freq_table[i].reg_val == odr_val) { + *val = bmc150_magn_samp_freq_table[i].freq; + return 0; + } + + return -EINVAL; +} + +static int bmc150_magn_set_odr(struct bmc150_magn_data *data, int val) +{ + int ret; + u8 i; + + for (i = 0; i < ARRAY_SIZE(bmc150_magn_samp_freq_table); i++) { + if (bmc150_magn_samp_freq_table[i].freq == val) { + ret = regmap_update_bits(data->regmap, + BMC150_MAGN_REG_OPMODE_ODR, + BMC150_MAGN_MASK_ODR, + bmc150_magn_samp_freq_table[i]. + reg_val << + BMC150_MAGN_SHIFT_ODR); + if (ret < 0) + return ret; + return 0; + } + } + + return -EINVAL; +} + +static s32 bmc150_magn_compensate_x(struct bmc150_magn_trim_regs *tregs, s16 x, + u16 rhall) +{ + s16 val; + u16 xyz1 = le16_to_cpu(tregs->xyz1); + + if (x == BMC150_MAGN_XY_OVERFLOW_VAL) + return S32_MIN; + + if (!rhall) + rhall = xyz1; + + val = ((s16)(((u16)((((s32)xyz1) << 14) / rhall)) - ((u16)0x4000))); + val = ((s16)((((s32)x) * ((((((((s32)tregs->xy2) * ((((s32)val) * + ((s32)val)) >> 7)) + (((s32)val) * + ((s32)(((s16)tregs->xy1) << 7)))) >> 9) + ((s32)0x100000)) * + ((s32)(((s16)tregs->x2) + ((s16)0xA0)))) >> 12)) >> 13)) + + (((s16)tregs->x1) << 3); + + return (s32)val; +} + +static s32 bmc150_magn_compensate_y(struct bmc150_magn_trim_regs *tregs, s16 y, + u16 rhall) +{ + s16 val; + u16 xyz1 = le16_to_cpu(tregs->xyz1); + + if (y == BMC150_MAGN_XY_OVERFLOW_VAL) + return S32_MIN; + + if (!rhall) + rhall = xyz1; + + val = ((s16)(((u16)((((s32)xyz1) << 14) / rhall)) - ((u16)0x4000))); + val = ((s16)((((s32)y) * ((((((((s32)tregs->xy2) * ((((s32)val) * + ((s32)val)) >> 7)) + (((s32)val) * + ((s32)(((s16)tregs->xy1) << 7)))) >> 9) + ((s32)0x100000)) * + ((s32)(((s16)tregs->y2) + ((s16)0xA0)))) >> 12)) >> 13)) + + (((s16)tregs->y1) << 3); + + return (s32)val; +} + +static s32 bmc150_magn_compensate_z(struct bmc150_magn_trim_regs *tregs, s16 z, + u16 rhall) +{ + s32 val; + u16 xyz1 = le16_to_cpu(tregs->xyz1); + u16 z1 = le16_to_cpu(tregs->z1); + s16 z2 = le16_to_cpu(tregs->z2); + s16 z3 = le16_to_cpu(tregs->z3); + s16 z4 = le16_to_cpu(tregs->z4); + + if (z == BMC150_MAGN_Z_OVERFLOW_VAL) + return S32_MIN; + + val = (((((s32)(z - z4)) << 15) - ((((s32)z3) * ((s32)(((s16)rhall) - + ((s16)xyz1)))) >> 2)) / (z2 + ((s16)(((((s32)z1) * + ((((s16)rhall) << 1))) + (1 << 15)) >> 16)))); + + return val; +} + +static int bmc150_magn_read_xyz(struct bmc150_magn_data *data, s32 *buffer) +{ + int ret; + __le16 values[AXIS_XYZR_MAX]; + s16 raw_x, raw_y, raw_z; + u16 rhall; + struct bmc150_magn_trim_regs tregs; + + ret = regmap_bulk_read(data->regmap, BMC150_MAGN_REG_X_L, + values, sizeof(values)); + if (ret < 0) + return ret; + + raw_x = (s16)le16_to_cpu(values[AXIS_X]) >> BMC150_MAGN_SHIFT_XY_L; + raw_y = (s16)le16_to_cpu(values[AXIS_Y]) >> BMC150_MAGN_SHIFT_XY_L; + raw_z = (s16)le16_to_cpu(values[AXIS_Z]) >> BMC150_MAGN_SHIFT_Z_L; + rhall = le16_to_cpu(values[RHALL]) >> BMC150_MAGN_SHIFT_RHALL_L; + + ret = regmap_bulk_read(data->regmap, BMC150_MAGN_REG_TRIM_START, + &tregs, sizeof(tregs)); + if (ret < 0) + return ret; + + buffer[AXIS_X] = bmc150_magn_compensate_x(&tregs, raw_x, rhall); + buffer[AXIS_Y] = bmc150_magn_compensate_y(&tregs, raw_y, rhall); + buffer[AXIS_Z] = bmc150_magn_compensate_z(&tregs, raw_z, rhall); + + return 0; +} + +static int bmc150_magn_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct bmc150_magn_data *data = iio_priv(indio_dev); + int ret; + s32 values[AXIS_XYZ_MAX]; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + if (iio_buffer_enabled(indio_dev)) + return -EBUSY; + mutex_lock(&data->mutex); + + ret = bmc150_magn_set_power_state(data, true); + if (ret < 0) { + mutex_unlock(&data->mutex); + return ret; + } + + ret = bmc150_magn_read_xyz(data, values); + if (ret < 0) { + bmc150_magn_set_power_state(data, false); + mutex_unlock(&data->mutex); + return ret; + } + *val = values[chan->scan_index]; + + ret = bmc150_magn_set_power_state(data, false); + if (ret < 0) { + mutex_unlock(&data->mutex); + return ret; + } + + mutex_unlock(&data->mutex); + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + /* + * The API/driver performs an off-chip temperature + * compensation and outputs x/y/z magnetic field data in + * 16 LSB/uT to the upper application layer. + */ + *val = 0; + *val2 = 625; + return IIO_VAL_INT_PLUS_MICRO; + case IIO_CHAN_INFO_SAMP_FREQ: + ret = bmc150_magn_get_odr(data, val); + if (ret < 0) + return ret; + return IIO_VAL_INT; + default: + return -EINVAL; + } +} + +static int bmc150_magn_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + struct bmc150_magn_data *data = iio_priv(indio_dev); + int ret; + + switch (mask) { + case IIO_CHAN_INFO_SAMP_FREQ: + mutex_lock(&data->mutex); + ret = bmc150_magn_set_odr(data, val); + mutex_unlock(&data->mutex); + return ret; + default: + return -EINVAL; + } +} + +static int bmc150_magn_validate_trigger(struct iio_dev *indio_dev, + struct iio_trigger *trig) +{ + struct bmc150_magn_data *data = iio_priv(indio_dev); + + if (data->dready_trig != trig) + return -EINVAL; + + return 0; +} + +static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("2 6 8 10 15 20 25 30"); + +static struct attribute *bmc150_magn_attributes[] = { + &iio_const_attr_sampling_frequency_available.dev_attr.attr, + NULL, +}; + +static const struct attribute_group bmc150_magn_attrs_group = { + .attrs = bmc150_magn_attributes, +}; + +#define BMC150_MAGN_CHANNEL(_axis) { \ + .type = IIO_MAGN, \ + .modified = 1, \ + .channel2 = IIO_MOD_##_axis, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \ + BIT(IIO_CHAN_INFO_SCALE), \ + .scan_index = AXIS_##_axis, \ + .scan_type = { \ + .sign = 's', \ + .realbits = 32, \ + .storagebits = 32, \ + .endianness = IIO_LE \ + }, \ +} + +static const struct iio_chan_spec bmc150_magn_channels[] = { + BMC150_MAGN_CHANNEL(X), + BMC150_MAGN_CHANNEL(Y), + BMC150_MAGN_CHANNEL(Z), + IIO_CHAN_SOFT_TIMESTAMP(3), +}; + +static const struct iio_info bmc150_magn_info = { + .attrs = &bmc150_magn_attrs_group, + .read_raw = bmc150_magn_read_raw, + .write_raw = bmc150_magn_write_raw, + .validate_trigger = bmc150_magn_validate_trigger, + .driver_module = THIS_MODULE, +}; + +static const unsigned long bmc150_magn_scan_masks[] = {0x07, 0}; + +static irqreturn_t bmc150_magn_trigger_handler(int irq, void *p) +{ + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + struct bmc150_magn_data *data = iio_priv(indio_dev); + int ret; + + mutex_lock(&data->mutex); + ret = bmc150_magn_read_xyz(data, data->buffer); + mutex_unlock(&data->mutex); + if (ret < 0) + goto err; + + iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, + pf->timestamp); + +err: + iio_trigger_notify_done(data->dready_trig); + + return IRQ_HANDLED; +} + +static int bmc150_magn_init(struct bmc150_magn_data *data) +{ + int ret, chip_id; + struct bmc150_magn_preset preset; + + ret = bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_SUSPEND, + false); + if (ret < 0) { + dev_err(&data->client->dev, + "Failed to bring up device from suspend mode\n"); + return ret; + } + + ret = regmap_read(data->regmap, BMC150_MAGN_REG_CHIP_ID, &chip_id); + if (ret < 0) { + dev_err(&data->client->dev, "Failed reading chip id\n"); + goto err_poweroff; + } + if (chip_id != BMC150_MAGN_CHIP_ID_VAL) { + dev_err(&data->client->dev, "Invalid chip id 0x%x\n", ret); + ret = -ENODEV; + goto err_poweroff; + } + dev_dbg(&data->client->dev, "Chip id %x\n", ret); + + preset = bmc150_magn_presets_table[BMC150_MAGN_DEFAULT_PRESET]; + ret = bmc150_magn_set_odr(data, preset.odr); + if (ret < 0) { + dev_err(&data->client->dev, "Failed to set ODR to %d\n", + preset.odr); + goto err_poweroff; + } + + ret = regmap_write(data->regmap, BMC150_MAGN_REG_REP_XY, + BMC150_MAGN_REPXY_TO_REGVAL(preset.rep_xy)); + if (ret < 0) { + dev_err(&data->client->dev, "Failed to set REP XY to %d\n", + preset.rep_xy); + goto err_poweroff; + } + + ret = regmap_write(data->regmap, BMC150_MAGN_REG_REP_Z, + BMC150_MAGN_REPZ_TO_REGVAL(preset.rep_z)); + if (ret < 0) { + dev_err(&data->client->dev, "Failed to set REP Z to %d\n", + preset.rep_z); + goto err_poweroff; + } + + ret = bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_NORMAL, + true); + if (ret < 0) { + dev_err(&data->client->dev, "Failed to power on device\n"); + goto err_poweroff; + } + + return 0; + +err_poweroff: + bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_SUSPEND, true); + return ret; +} + +static int bmc150_magn_reset_intr(struct bmc150_magn_data *data) +{ + int tmp; + + /* + * Data Ready (DRDY) is always cleared after + * readout of data registers ends. + */ + return regmap_read(data->regmap, BMC150_MAGN_REG_X_L, &tmp); +} + +static int bmc150_magn_trig_try_reen(struct iio_trigger *trig) +{ + struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); + struct bmc150_magn_data *data = iio_priv(indio_dev); + int ret; + + if (!data->dready_trigger_on) + return 0; + + mutex_lock(&data->mutex); + ret = bmc150_magn_reset_intr(data); + mutex_unlock(&data->mutex); + + return ret; +} + +static int bmc150_magn_data_rdy_trigger_set_state(struct iio_trigger *trig, + bool state) +{ + struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); + struct bmc150_magn_data *data = iio_priv(indio_dev); + int ret = 0; + + mutex_lock(&data->mutex); + if (state == data->dready_trigger_on) + goto err_unlock; + + ret = bmc150_magn_set_power_state(data, state); + if (ret < 0) + goto err_unlock; + + ret = regmap_update_bits(data->regmap, BMC150_MAGN_REG_INT_DRDY, + BMC150_MAGN_MASK_DRDY_EN, + state << BMC150_MAGN_SHIFT_DRDY_EN); + if (ret < 0) + goto err_poweroff; + + data->dready_trigger_on = state; + + if (state) { + ret = bmc150_magn_reset_intr(data); + if (ret < 0) + goto err_poweroff; + } + mutex_unlock(&data->mutex); + + return 0; + +err_poweroff: + bmc150_magn_set_power_state(data, false); +err_unlock: + mutex_unlock(&data->mutex); + return ret; +} + +static const struct iio_trigger_ops bmc150_magn_trigger_ops = { + .set_trigger_state = bmc150_magn_data_rdy_trigger_set_state, + .try_reenable = bmc150_magn_trig_try_reen, + .owner = THIS_MODULE, +}; + +static int bmc150_magn_gpio_probe(struct i2c_client *client) +{ + struct device *dev; + struct gpio_desc *gpio; + int ret; + + if (!client) + return -EINVAL; + + dev = &client->dev; + + /* data ready GPIO interrupt pin */ + gpio = devm_gpiod_get_index(dev, BMC150_MAGN_GPIO_INT, 0); + if (IS_ERR(gpio)) { + dev_err(dev, "ACPI GPIO get index failed\n"); + return PTR_ERR(gpio); + } + + ret = gpiod_direction_input(gpio); + if (ret) + return ret; + + ret = gpiod_to_irq(gpio); + + dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret); + + return ret; +} + +static const char *bmc150_magn_match_acpi_device(struct device *dev) +{ + const struct acpi_device_id *id; + + id = acpi_match_device(dev->driver->acpi_match_table, dev); + if (!id) + return NULL; + + return dev_name(dev); +} + +static int bmc150_magn_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct bmc150_magn_data *data; + struct iio_dev *indio_dev; + const char *name = NULL; + int ret; + + 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; + + if (id) + name = id->name; + else if (ACPI_HANDLE(&client->dev)) + name = bmc150_magn_match_acpi_device(&client->dev); + else + return -ENOSYS; + + mutex_init(&data->mutex); + data->regmap = devm_regmap_init_i2c(client, &bmc150_magn_regmap_config); + if (IS_ERR(data->regmap)) { + dev_err(&client->dev, "Failed to allocate register map\n"); + return PTR_ERR(data->regmap); + } + + ret = bmc150_magn_init(data); + if (ret < 0) + return ret; + + indio_dev->dev.parent = &client->dev; + indio_dev->channels = bmc150_magn_channels; + indio_dev->num_channels = ARRAY_SIZE(bmc150_magn_channels); + indio_dev->available_scan_masks = bmc150_magn_scan_masks; + indio_dev->name = name; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->info = &bmc150_magn_info; + + if (client->irq <= 0) + client->irq = bmc150_magn_gpio_probe(client); + + if (client->irq > 0) { + data->dready_trig = devm_iio_trigger_alloc(&client->dev, + "%s-dev%d", + indio_dev->name, + indio_dev->id); + if (!data->dready_trig) { + ret = -ENOMEM; + dev_err(&client->dev, "iio trigger alloc failed\n"); + goto err_poweroff; + } + + data->dready_trig->dev.parent = &client->dev; + data->dready_trig->ops = &bmc150_magn_trigger_ops; + iio_trigger_set_drvdata(data->dready_trig, indio_dev); + ret = iio_trigger_register(data->dready_trig); + if (ret) { + dev_err(&client->dev, "iio trigger register failed\n"); + goto err_poweroff; + } + + ret = iio_triggered_buffer_setup(indio_dev, + &iio_pollfunc_store_time, + bmc150_magn_trigger_handler, + NULL); + if (ret < 0) { + dev_err(&client->dev, + "iio triggered buffer setup failed\n"); + goto err_trigger_unregister; + } + + ret = request_threaded_irq(client->irq, + iio_trigger_generic_data_rdy_poll, + NULL, + IRQF_TRIGGER_RISING | IRQF_ONESHOT, + BMC150_MAGN_IRQ_NAME, + data->dready_trig); + if (ret < 0) { + dev_err(&client->dev, "request irq %d failed\n", + client->irq); + goto err_buffer_cleanup; + } + } + + ret = iio_device_register(indio_dev); + if (ret < 0) { + dev_err(&client->dev, "unable to register iio device\n"); + goto err_free_irq; + } + + ret = pm_runtime_set_active(&client->dev); + if (ret) + goto err_iio_unregister; + + pm_runtime_enable(&client->dev); + pm_runtime_set_autosuspend_delay(&client->dev, + BMC150_MAGN_AUTO_SUSPEND_DELAY_MS); + pm_runtime_use_autosuspend(&client->dev); + + dev_dbg(&indio_dev->dev, "Registered device %s\n", name); + + return 0; + +err_iio_unregister: + iio_device_unregister(indio_dev); +err_free_irq: + if (client->irq > 0) + free_irq(client->irq, data->dready_trig); +err_buffer_cleanup: + if (data->dready_trig) + iio_triggered_buffer_cleanup(indio_dev); +err_trigger_unregister: + if (data->dready_trig) + iio_trigger_unregister(data->dready_trig); +err_poweroff: + bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_SUSPEND, true); + return ret; +} + +static int bmc150_magn_remove(struct i2c_client *client) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct bmc150_magn_data *data = iio_priv(indio_dev); + + pm_runtime_disable(&client->dev); + pm_runtime_set_suspended(&client->dev); + pm_runtime_put_noidle(&client->dev); + + iio_device_unregister(indio_dev); + + if (client->irq > 0) + free_irq(data->client->irq, data->dready_trig); + + if (data->dready_trig) { + iio_triggered_buffer_cleanup(indio_dev); + iio_trigger_unregister(data->dready_trig); + } + + mutex_lock(&data->mutex); + bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_SUSPEND, true); + mutex_unlock(&data->mutex); + + return 0; +} + +#ifdef CONFIG_PM +static int bmc150_magn_runtime_suspend(struct device *dev) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); + struct bmc150_magn_data *data = iio_priv(indio_dev); + int ret; + + mutex_lock(&data->mutex); + ret = bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_SLEEP, + true); + mutex_unlock(&data->mutex); + if (ret < 0) { + dev_err(&data->client->dev, "powering off device failed\n"); + return ret; + } + return 0; +} + +static int bmc150_magn_runtime_resume(struct device *dev) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); + struct bmc150_magn_data *data = iio_priv(indio_dev); + + return bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_NORMAL, + true); +} +#endif + +#ifdef CONFIG_PM_SLEEP +static int bmc150_magn_suspend(struct device *dev) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); + struct bmc150_magn_data *data = iio_priv(indio_dev); + int ret; + + mutex_lock(&data->mutex); + ret = bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_SLEEP, + true); + mutex_unlock(&data->mutex); + + return ret; +} + +static int bmc150_magn_resume(struct device *dev) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); + struct bmc150_magn_data *data = iio_priv(indio_dev); + int ret; + + mutex_lock(&data->mutex); + ret = bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_NORMAL, + true); + mutex_unlock(&data->mutex); + + return ret; +} +#endif + +static const struct dev_pm_ops bmc150_magn_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(bmc150_magn_suspend, bmc150_magn_resume) + SET_RUNTIME_PM_OPS(bmc150_magn_runtime_suspend, + bmc150_magn_runtime_resume, NULL) +}; + +static const struct acpi_device_id bmc150_magn_acpi_match[] = { + {"BMC150B", 0}, + {}, +}; +MODULE_DEVICE_TABLE(acpi, bmc150_magn_acpi_match); + +static const struct i2c_device_id bmc150_magn_id[] = { + {"bmc150_magn", 0}, + {}, +}; +MODULE_DEVICE_TABLE(i2c, bmc150_magn_id); + +static struct i2c_driver bmc150_magn_driver = { + .driver = { + .name = BMC150_MAGN_DRV_NAME, + .acpi_match_table = ACPI_PTR(bmc150_magn_acpi_match), + .pm = &bmc150_magn_pm_ops, + }, + .probe = bmc150_magn_probe, + .remove = bmc150_magn_remove, + .id_table = bmc150_magn_id, +}; +module_i2c_driver(bmc150_magn_driver); + +MODULE_AUTHOR("Irina Tirdea "); +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("BMC150 magnetometer driver"); From 42a95584f31c5f11a669f0db72f6b6e9ff00b8d9 Mon Sep 17 00:00:00 2001 From: Irina Tirdea Date: Wed, 29 Apr 2015 21:16:38 +0300 Subject: [PATCH 0435/1163] iio: magn: bmc150_magn: Add devicetree binding documentation Add binding documentation for Bosch BMC150 magnetometer. Signed-off-by: Irina Tirdea Signed-off-by: Jonathan Cameron --- .../bindings/iio/magnetometer/bmc150_magn.txt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/magnetometer/bmc150_magn.txt diff --git a/Documentation/devicetree/bindings/iio/magnetometer/bmc150_magn.txt b/Documentation/devicetree/bindings/iio/magnetometer/bmc150_magn.txt new file mode 100644 index 000000000000..9f263b7df162 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/magnetometer/bmc150_magn.txt @@ -0,0 +1,22 @@ +* Bosch BMC150 magnetometer sensor + +http://ae-bst.resource.bosch.com/media/products/dokumente/bmc150/BST-BMC150-DS000-04.pdf + +Required properties: + + - compatible : should be "bosch,bmc150_magn" + - reg : the I2C address of the magnetometer + +Optional properties: + + - interrupt-parent : phandle to the parent interrupt controller + - interrupts : interrupt mapping for GPIO IRQ + +Example: + +bmc150_magn@12 { + compatible = "bosch,bmc150_magn"; + reg = <0x12>; + interrupt-parent = <&gpio1>; + interrupts = <0 1>; +}; From faaa44955dedc661f083636d816af90975a359ee Mon Sep 17 00:00:00 2001 From: Irina Tirdea Date: Wed, 29 Apr 2015 21:16:39 +0300 Subject: [PATCH 0436/1163] iio: core: Introduce IIO_CHAN_INFO_OVERSAMPLING_RATIO Some magnetometers can perform a number of repetitions in HW for each measurement to increase accuracy. One example is Bosch BMC150: http://ae-bst.resource.bosch.com/media/products/dokumente/bmc150/BST-BMC150-DS000-04.pdf. Introduce an interface to set the oversampling ratio for these devices. Signed-off-by: Irina Tirdea Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 12 ++++++++++++ drivers/iio/industrialio-core.c | 1 + include/linux/iio/iio.h | 1 + 3 files changed, 14 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index 866b4ec4aab6..e46c71fbd047 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -1375,3 +1375,15 @@ Description: The emissivity ratio of the surface in the field of view of the contactless temperature sensor. Emissivity varies from 0 to 1, with 1 being the emissivity of a black body. + +What: /sys/bus/iio/devices/iio:deviceX/in_magn_x_oversampling_ratio +What: /sys/bus/iio/devices/iio:deviceX/in_magn_y_oversampling_ratio +What: /sys/bus/iio/devices/iio:deviceX/in_magn_z_oversampling_ratio +KernelVersion: 4.2 +Contact: linux-iio@vger.kernel.org +Description: + Hardware applied number of measurements for acquiring one + data point. The HW will do [_name]_oversampling_ratio + measurements and return the average value as output data. Each + value resulted from [_name]_oversampling_ratio measurements + is considered as one sample for [_name]_sampling_frequency. diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 7c98bc1504e6..dfa81db3b910 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -129,6 +129,7 @@ static const char * const iio_chan_info_postfix[] = { [IIO_CHAN_INFO_DEBOUNCE_COUNT] = "debounce_count", [IIO_CHAN_INFO_DEBOUNCE_TIME] = "debounce_time", [IIO_CHAN_INFO_CALIBEMISSIVITY] = "calibemissivity", + [IIO_CHAN_INFO_OVERSAMPLING_RATIO] = "oversampling_ratio", }; /** diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index b1e46ae89aa7..058441da4984 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -44,6 +44,7 @@ enum iio_chan_info_enum { IIO_CHAN_INFO_DEBOUNCE_COUNT, IIO_CHAN_INFO_DEBOUNCE_TIME, IIO_CHAN_INFO_CALIBEMISSIVITY, + IIO_CHAN_INFO_OVERSAMPLING_RATIO, }; enum iio_shared_by { From 5990dc9703679a6c9eef17ca042edb755541d6b1 Mon Sep 17 00:00:00 2001 From: Irina Tirdea Date: Wed, 29 Apr 2015 21:16:40 +0300 Subject: [PATCH 0437/1163] iio: magn: bmc150_magn: add oversampling ratio Export the oversampling ratio so that the user can change the number of repetions for x/y/z axis. The sampling frequency is limited by the oversampling ratio. The available sampling frequencies might change depending on the values of oversampling_ratio. The specification can be downloaded from: http://ae-bst.resource.bosch.com/media/products/dokumente/bmc150/BST-BMC150-DS000-04.pdf. Signed-off-by: Irina Tirdea Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/bmc150_magn.c | 133 ++++++++++++++++++++++++- 1 file changed, 129 insertions(+), 4 deletions(-) diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c index 7bbaea8e036c..d4c178869991 100644 --- a/drivers/iio/magnetometer/bmc150_magn.c +++ b/drivers/iio/magnetometer/bmc150_magn.c @@ -146,6 +146,7 @@ struct bmc150_magn_data { s32 buffer[6]; struct iio_trigger *dready_trig; bool dready_trigger_on; + int max_odr; }; static const struct { @@ -323,6 +324,43 @@ static int bmc150_magn_set_odr(struct bmc150_magn_data *data, int val) return -EINVAL; } +static int bmc150_magn_set_max_odr(struct bmc150_magn_data *data, int rep_xy, + int rep_z, int odr) +{ + int ret, reg_val, max_odr; + + if (rep_xy <= 0) { + ret = regmap_read(data->regmap, BMC150_MAGN_REG_REP_XY, + ®_val); + if (ret < 0) + return ret; + rep_xy = BMC150_MAGN_REGVAL_TO_REPXY(reg_val); + } + if (rep_z <= 0) { + ret = regmap_read(data->regmap, BMC150_MAGN_REG_REP_Z, + ®_val); + if (ret < 0) + return ret; + rep_z = BMC150_MAGN_REGVAL_TO_REPZ(reg_val); + } + if (odr <= 0) { + ret = bmc150_magn_get_odr(data, &odr); + if (ret < 0) + return ret; + } + /* the maximum selectable read-out frequency from datasheet */ + max_odr = 1000000 / (145 * rep_xy + 500 * rep_z + 980); + if (odr > max_odr) { + dev_err(&data->client->dev, + "Can't set oversampling with sampling freq %d\n", + odr); + return -EINVAL; + } + data->max_odr = max_odr; + + return 0; +} + static s32 bmc150_magn_compensate_x(struct bmc150_magn_trim_regs *tregs, s16 x, u16 rhall) { @@ -422,7 +460,7 @@ static int bmc150_magn_read_raw(struct iio_dev *indio_dev, int *val, int *val2, long mask) { struct bmc150_magn_data *data = iio_priv(indio_dev); - int ret; + int ret, tmp; s32 values[AXIS_XYZ_MAX]; switch (mask) { @@ -467,6 +505,26 @@ static int bmc150_magn_read_raw(struct iio_dev *indio_dev, if (ret < 0) return ret; return IIO_VAL_INT; + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + switch (chan->channel2) { + case IIO_MOD_X: + case IIO_MOD_Y: + ret = regmap_read(data->regmap, BMC150_MAGN_REG_REP_XY, + &tmp); + if (ret < 0) + return ret; + *val = BMC150_MAGN_REGVAL_TO_REPXY(tmp); + return IIO_VAL_INT; + case IIO_MOD_Z: + ret = regmap_read(data->regmap, BMC150_MAGN_REG_REP_Z, + &tmp); + if (ret < 0) + return ret; + *val = BMC150_MAGN_REGVAL_TO_REPZ(tmp); + return IIO_VAL_INT; + default: + return -EINVAL; + } default: return -EINVAL; } @@ -481,10 +539,50 @@ static int bmc150_magn_write_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_SAMP_FREQ: + if (val > data->max_odr) + return -EINVAL; mutex_lock(&data->mutex); ret = bmc150_magn_set_odr(data, val); mutex_unlock(&data->mutex); return ret; + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + switch (chan->channel2) { + case IIO_MOD_X: + case IIO_MOD_Y: + if (val < 1 || val > 511) + return -EINVAL; + mutex_lock(&data->mutex); + ret = bmc150_magn_set_max_odr(data, val, 0, 0); + if (ret < 0) { + mutex_unlock(&data->mutex); + return ret; + } + ret = regmap_update_bits(data->regmap, + BMC150_MAGN_REG_REP_XY, + 0xFF, + BMC150_MAGN_REPXY_TO_REGVAL + (val)); + mutex_unlock(&data->mutex); + return ret; + case IIO_MOD_Z: + if (val < 1 || val > 256) + return -EINVAL; + mutex_lock(&data->mutex); + ret = bmc150_magn_set_max_odr(data, 0, val, 0); + if (ret < 0) { + mutex_unlock(&data->mutex); + return ret; + } + ret = regmap_update_bits(data->regmap, + BMC150_MAGN_REG_REP_Z, + 0xFF, + BMC150_MAGN_REPZ_TO_REGVAL + (val)); + mutex_unlock(&data->mutex); + return ret; + default: + return -EINVAL; + } default: return -EINVAL; } @@ -501,10 +599,31 @@ static int bmc150_magn_validate_trigger(struct iio_dev *indio_dev, return 0; } -static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("2 6 8 10 15 20 25 30"); +static ssize_t bmc150_magn_show_samp_freq_avail(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct bmc150_magn_data *data = iio_priv(indio_dev); + size_t len = 0; + u8 i; + + for (i = 0; i < ARRAY_SIZE(bmc150_magn_samp_freq_table); i++) { + if (bmc150_magn_samp_freq_table[i].freq > data->max_odr) + break; + len += scnprintf(buf + len, PAGE_SIZE - len, "%d ", + bmc150_magn_samp_freq_table[i].freq); + } + /* replace last space with a newline */ + buf[len - 1] = '\n'; + + return len; +} + +static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(bmc150_magn_show_samp_freq_avail); static struct attribute *bmc150_magn_attributes[] = { - &iio_const_attr_sampling_frequency_available.dev_attr.attr, + &iio_dev_attr_sampling_frequency_available.dev_attr.attr, NULL, }; @@ -516,7 +635,8 @@ static const struct attribute_group bmc150_magn_attrs_group = { .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_OVERSAMPLING_RATIO), \ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \ BIT(IIO_CHAN_INFO_SCALE), \ .scan_index = AXIS_##_axis, \ @@ -616,6 +736,11 @@ static int bmc150_magn_init(struct bmc150_magn_data *data) goto err_poweroff; } + ret = bmc150_magn_set_max_odr(data, preset.rep_xy, preset.rep_z, + preset.odr); + if (ret < 0) + goto err_poweroff; + ret = bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_NORMAL, true); if (ret < 0) { From abeb6b1e7bbffb3dbcd918827673feafecc378d1 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Fri, 24 Apr 2015 18:58:30 +0300 Subject: [PATCH 0438/1163] iio: magnetometer: Add support for MEMSIC MMC35240 sensor Minimal implementation for MMC35240 3-axis magnetometer sensor. It provides processed readings and possiblity to change the sampling frequency. Signed-off-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/Kconfig | 11 + drivers/iio/magnetometer/Makefile | 1 + drivers/iio/magnetometer/mmc35240.c | 469 ++++++++++++++++++++++++++++ 3 files changed, 481 insertions(+) create mode 100644 drivers/iio/magnetometer/mmc35240.c diff --git a/drivers/iio/magnetometer/Kconfig b/drivers/iio/magnetometer/Kconfig index 9746a2a88640..dcadfc4f0661 100644 --- a/drivers/iio/magnetometer/Kconfig +++ b/drivers/iio/magnetometer/Kconfig @@ -47,6 +47,17 @@ config HID_SENSOR_MAGNETOMETER_3D Say yes here to build support for the HID SENSOR Magnetometer 3D. +config MMC35240 + tristate "MEMSIC MMC35240 3-axis magnetic sensor" + select REGMAP_I2C + depends on I2C + help + Say yes here to build support for the MEMSIC MMC35240 3-axis + magnetic sensor. + + To compile this driver as a module, choose M here: the module + will be called mmc35240. + config IIO_ST_MAGN_3AXIS tristate "STMicroelectronics magnetometers 3-Axis Driver" depends on (I2C || SPI_MASTER) && SYSFS diff --git a/drivers/iio/magnetometer/Makefile b/drivers/iio/magnetometer/Makefile index e2c34594ff3f..33b1d4d54ee7 100644 --- a/drivers/iio/magnetometer/Makefile +++ b/drivers/iio/magnetometer/Makefile @@ -6,6 +6,7 @@ obj-$(CONFIG_AK8975) += ak8975.o obj-$(CONFIG_MAG3110) += mag3110.o obj-$(CONFIG_HID_SENSOR_MAGNETOMETER_3D) += hid-sensor-magn-3d.o +obj-$(CONFIG_MMC35240) += mmc35240.o obj-$(CONFIG_IIO_ST_MAGN_3AXIS) += st_magn.o st_magn-y := st_magn_core.o diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c new file mode 100644 index 000000000000..46728006bbdb --- /dev/null +++ b/drivers/iio/magnetometer/mmc35240.c @@ -0,0 +1,469 @@ +/* + * MMC35240 - MEMSIC 3-axis Magnetic Sensor + * + * Copyright (c) 2015, Intel Corporation. + * + * 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. + * + * IIO driver for MMC35240 (7-bit I2C slave address 0x30). + * + * TODO: offset, ACPI, continuous measurement mode, PM + */ + +#include +#include +#include +#include +#include + +#include +#include + +#define MMC35240_DRV_NAME "mmc35240" +#define MMC35240_REGMAP_NAME "mmc35240_regmap" + +#define MMC35240_REG_XOUT_L 0x00 +#define MMC35240_REG_XOUT_H 0x01 +#define MMC35240_REG_YOUT_L 0x02 +#define MMC35240_REG_YOUT_H 0x03 +#define MMC35240_REG_ZOUT_L 0x04 +#define MMC35240_REG_ZOUT_H 0x05 + +#define MMC35240_REG_STATUS 0x06 +#define MMC35240_REG_CTRL0 0x07 +#define MMC35240_REG_CTRL1 0x08 + +#define MMC35240_REG_ID 0x20 + +#define MMC35240_STATUS_MEAS_DONE_BIT BIT(0) + +#define MMC35240_CTRL0_REFILL_BIT BIT(7) +#define MMC35240_CTRL0_RESET_BIT BIT(6) +#define MMC35240_CTRL0_SET_BIT BIT(5) +#define MMC35240_CTRL0_CMM_BIT BIT(1) +#define MMC35240_CTRL0_TM_BIT BIT(0) + +/* output resolution bits */ +#define MMC35240_CTRL1_BW0_BIT BIT(0) +#define MMC35240_CTRL1_BW1_BIT BIT(1) + +#define MMC35240_CTRL1_BW_MASK (MMC35240_CTRL1_BW0_BIT | \ + MMC35240_CTRL1_BW1_BIT) +#define MMC35240_CTRL1_BW_SHIFT 0 + +#define MMC35240_WAIT_CHARGE_PUMP 50000 /* us */ +#define MMC53240_WAIT_SET_RESET 1000 /* us */ + +enum mmc35240_resolution { + MMC35240_16_BITS_SLOW = 0, /* 100 Hz */ + MMC35240_16_BITS_FAST, /* 200 Hz */ + MMC35240_14_BITS, /* 333 Hz */ + MMC35240_12_BITS, /* 666 Hz */ +}; + +enum mmc35240_axis { + AXIS_X = 0, + AXIS_Y, + AXIS_Z, +}; + +static const struct { + int sens[3]; /* sensitivity per X, Y, Z axis */ + int nfo; /* null field output */ +} mmc35240_props_table[] = { + /* 16 bits, 100Hz ODR */ + { + {1024, 1024, 770}, + 32768, + }, + /* 16 bits, 200Hz ODR */ + { + {1024, 1024, 770}, + 32768, + }, + /* 14 bits, 333Hz ODR */ + { + {256, 256, 193}, + 8192, + }, + /* 12 bits, 666Hz ODR */ + { + {64, 64, 48}, + 2048, + }, +}; + +struct mmc35240_data { + struct i2c_client *client; + struct mutex mutex; + struct regmap *regmap; + enum mmc35240_resolution res; +}; + +static const int mmc35240_samp_freq[] = {100, 200, 333, 666}; + +static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("100 200 333 666"); + +#define MMC35240_CHANNEL(_axis) { \ + .type = IIO_MAGN, \ + .modified = 1, \ + .channel2 = IIO_MOD_ ## _axis, \ + .address = AXIS_ ## _axis, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ), \ +} + +static const struct iio_chan_spec mmc35240_channels[] = { + MMC35240_CHANNEL(X), + MMC35240_CHANNEL(Y), + MMC35240_CHANNEL(Z), +}; + +static struct attribute *mmc35240_attributes[] = { + &iio_const_attr_sampling_frequency_available.dev_attr.attr, +}; + +static const struct attribute_group mmc35240_attribute_group = { + .attrs = mmc35240_attributes, +}; + +static int mmc35240_get_samp_freq_index(struct mmc35240_data *data, + int val, int val2) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(mmc35240_samp_freq); i++) + if (mmc35240_samp_freq[i] == val) + return i; + return -EINVAL; +} + +static int mmc35240_hw_set(struct mmc35240_data *data, bool set) +{ + int ret; + u8 coil_bit; + + /* + * Recharge the capacitor at VCAP pin, requested to be issued + * before a SET/RESET command. + */ + ret = regmap_update_bits(data->regmap, MMC35240_REG_CTRL0, + MMC35240_CTRL0_REFILL_BIT, + MMC35240_CTRL0_REFILL_BIT); + if (ret < 0) + return ret; + usleep_range(MMC35240_WAIT_CHARGE_PUMP, MMC35240_WAIT_CHARGE_PUMP + 1); + + if (set) + coil_bit = MMC35240_CTRL0_SET_BIT; + else + coil_bit = MMC35240_CTRL0_RESET_BIT; + + return regmap_update_bits(data->regmap, MMC35240_REG_CTRL0, + MMC35240_CTRL0_REFILL_BIT, + coil_bit); +} + +static int mmc35240_init(struct mmc35240_data *data) +{ + int ret; + unsigned int reg_id; + + ret = regmap_read(data->regmap, MMC35240_REG_ID, ®_id); + if (ret < 0) { + dev_err(&data->client->dev, "Error reading product id\n"); + return ret; + } + + dev_dbg(&data->client->dev, "MMC35240 chip id %x\n", reg_id); + + /* + * make sure we restore sensor characteristics, by doing + * a RESET/SET sequence + */ + ret = mmc35240_hw_set(data, false); + if (ret < 0) + return ret; + usleep_range(MMC53240_WAIT_SET_RESET, MMC53240_WAIT_SET_RESET + 1); + + ret = mmc35240_hw_set(data, true); + if (ret < 0) + return ret; + + /* set default sampling frequency */ + return regmap_update_bits(data->regmap, MMC35240_REG_CTRL1, + MMC35240_CTRL1_BW_MASK, + data->res << MMC35240_CTRL1_BW_SHIFT); +} + +static int mmc35240_take_measurement(struct mmc35240_data *data) +{ + int ret, tries = 100; + unsigned int reg_status; + + ret = regmap_write(data->regmap, MMC35240_REG_CTRL0, + MMC35240_CTRL0_TM_BIT); + if (ret < 0) + return ret; + + while (tries-- > 0) { + ret = regmap_read(data->regmap, MMC35240_REG_STATUS, + ®_status); + if (ret < 0) + return ret; + if (reg_status & MMC35240_STATUS_MEAS_DONE_BIT) + break; + msleep(20); + } + + if (tries < 0) { + dev_err(&data->client->dev, "data not ready\n"); + return -EIO; + } + + return 0; +} + +static int mmc35240_read_measurement(struct mmc35240_data *data, __le16 buf[3]) +{ + int ret; + + ret = mmc35240_take_measurement(data); + if (ret < 0) + return ret; + + return regmap_bulk_read(data->regmap, MMC35240_REG_XOUT_L, (u8 *)buf, + 3 * sizeof(__le16)); +} + +static int mmc35240_raw_to_gauss(struct mmc35240_data *data, int index, + __le16 buf[], + int *val, int *val2) +{ + int raw_x, raw_y, raw_z; + int sens_x, sens_y, sens_z; + int nfo; + + raw_x = le16_to_cpu(buf[AXIS_X]); + raw_y = le16_to_cpu(buf[AXIS_Y]); + raw_z = le16_to_cpu(buf[AXIS_Z]); + + sens_x = mmc35240_props_table[data->res].sens[AXIS_X]; + sens_y = mmc35240_props_table[data->res].sens[AXIS_Y]; + sens_z = mmc35240_props_table[data->res].sens[AXIS_Z]; + + nfo = mmc35240_props_table[data->res].nfo; + + switch (index) { + case AXIS_X: + *val = (raw_x - nfo) / sens_x; + *val2 = ((raw_x - nfo) % sens_x) * 1000000; + break; + case AXIS_Y: + *val = (raw_y - nfo) / sens_y - (raw_z - nfo) / sens_z; + *val2 = (((raw_y - nfo) % sens_y - (raw_z - nfo) % sens_z)) + * 1000000; + break; + case AXIS_Z: + *val = (raw_y - nfo) / sens_y + (raw_z - nfo) / sens_z; + *val2 = (((raw_y - nfo) % sens_y + (raw_z - nfo) % sens_z)) + * 1000000; + break; + default: + return -EINVAL; + } + return 0; +} + +static int mmc35240_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int *val, + int *val2, long mask) +{ + struct mmc35240_data *data = iio_priv(indio_dev); + int ret, i; + unsigned int reg; + __le16 buf[3]; + + switch (mask) { + case IIO_CHAN_INFO_PROCESSED: + mutex_lock(&data->mutex); + ret = mmc35240_read_measurement(data, buf); + mutex_unlock(&data->mutex); + if (ret < 0) + return ret; + ret = mmc35240_raw_to_gauss(data, chan->address, + buf, val, val2); + if (ret < 0) + return ret; + return IIO_VAL_INT_PLUS_MICRO; + case IIO_CHAN_INFO_SAMP_FREQ: + mutex_lock(&data->mutex); + ret = regmap_read(data->regmap, MMC35240_REG_CTRL1, ®); + mutex_unlock(&data->mutex); + if (ret < 0) + return ret; + + i = (reg & MMC35240_CTRL1_BW_MASK) >> MMC35240_CTRL1_BW_SHIFT; + if (i < 0 || i > ARRAY_SIZE(mmc35240_samp_freq)) + return -EINVAL; + + *val = mmc35240_samp_freq[i]; + *val2 = 0; + return IIO_VAL_INT; + default: + return -EINVAL; + } +} + +static int mmc35240_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int val, + int val2, long mask) +{ + struct mmc35240_data *data = iio_priv(indio_dev); + int i, ret; + + switch (mask) { + case IIO_CHAN_INFO_SAMP_FREQ: + i = mmc35240_get_samp_freq_index(data, val, val2); + if (i < 0) + return -EINVAL; + mutex_lock(&data->mutex); + ret = regmap_update_bits(data->regmap, MMC35240_REG_CTRL1, + MMC35240_CTRL1_BW_MASK, + i << MMC35240_CTRL1_BW_SHIFT); + mutex_unlock(&data->mutex); + return ret; + default: + return -EINVAL; + } +} + +static const struct iio_info mmc35240_info = { + .driver_module = THIS_MODULE, + .read_raw = mmc35240_read_raw, + .write_raw = mmc35240_write_raw, + .attrs = &mmc35240_attribute_group, +}; + +static bool mmc35240_is_writeable_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case MMC35240_REG_CTRL0: + case MMC35240_REG_CTRL1: + return true; + default: + return false; + } +} + +static bool mmc35240_is_readable_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case MMC35240_REG_XOUT_L: + case MMC35240_REG_XOUT_H: + case MMC35240_REG_YOUT_L: + case MMC35240_REG_YOUT_H: + case MMC35240_REG_ZOUT_L: + case MMC35240_REG_ZOUT_H: + case MMC35240_REG_STATUS: + case MMC35240_REG_ID: + return true; + default: + return false; + } +} + +static bool mmc35240_is_volatile_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case MMC35240_REG_CTRL0: + case MMC35240_REG_CTRL1: + return false; + default: + return true; + } +} + +static struct reg_default mmc35240_reg_defaults[] = { + { MMC35240_REG_CTRL0, 0x00 }, + { MMC35240_REG_CTRL1, 0x00 }, +}; + +static const struct regmap_config mmc35240_regmap_config = { + .name = MMC35240_REGMAP_NAME, + + .reg_bits = 8, + .val_bits = 8, + + .max_register = MMC35240_REG_ID, + .cache_type = REGCACHE_FLAT, + + .writeable_reg = mmc35240_is_writeable_reg, + .readable_reg = mmc35240_is_readable_reg, + .volatile_reg = mmc35240_is_volatile_reg, + + .reg_defaults = mmc35240_reg_defaults, + .num_reg_defaults = ARRAY_SIZE(mmc35240_reg_defaults), +}; + +static int mmc35240_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct mmc35240_data *data; + struct iio_dev *indio_dev; + struct regmap *regmap; + int ret; + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); + if (!indio_dev) + return -ENOMEM; + + regmap = devm_regmap_init_i2c(client, &mmc35240_regmap_config); + if (IS_ERR(regmap)) { + dev_err(&client->dev, "regmap initialization failed\n"); + return PTR_ERR(regmap); + } + + data = iio_priv(indio_dev); + data->client = client; + data->regmap = regmap; + data->res = MMC35240_16_BITS_SLOW; + + mutex_init(&data->mutex); + + indio_dev->dev.parent = &client->dev; + indio_dev->info = &mmc35240_info; + indio_dev->name = MMC35240_DRV_NAME; + indio_dev->channels = mmc35240_channels; + indio_dev->num_channels = ARRAY_SIZE(mmc35240_channels); + indio_dev->modes = INDIO_DIRECT_MODE; + + ret = mmc35240_init(data); + if (ret < 0) { + dev_err(&client->dev, "mmc35240 chip init failed\n"); + return ret; + } + return devm_iio_device_register(&client->dev, indio_dev); +} + +static const struct i2c_device_id mmc35240_id[] = { + {"MMC35240", 0}, + {} +}; +MODULE_DEVICE_TABLE(i2c, mmc35240_id); + +static struct i2c_driver mmc35240_driver = { + .driver = { + .name = MMC35240_DRV_NAME, + }, + .probe = mmc35240_probe, + .id_table = mmc35240_id, +}; + +module_i2c_driver(mmc35240_driver); + +MODULE_AUTHOR("Daniel Baluta "); +MODULE_DESCRIPTION("MEMSIC MMC35240 magnetic sensor driver"); +MODULE_LICENSE("GPL v2"); From 553a776b790816161cd334647eae2093fd126e36 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Fri, 24 Apr 2015 18:58:31 +0300 Subject: [PATCH 0439/1163] iio: magnetometer: mmc35240: Add PM sleep support We rely on regmap to save the state of the registers at suspend, and then we do an explicit sync at resume. Signed-off-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/mmc35240.c | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c index 46728006bbdb..0c7d64c41575 100644 --- a/drivers/iio/magnetometer/mmc35240.c +++ b/drivers/iio/magnetometer/mmc35240.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -448,6 +449,39 @@ static int mmc35240_probe(struct i2c_client *client, return devm_iio_device_register(&client->dev, indio_dev); } +#ifdef CONFIG_PM_SLEEP +static int mmc35240_suspend(struct device *dev) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); + struct mmc35240_data *data = iio_priv(indio_dev); + + regcache_cache_only(data->regmap, true); + + return 0; +} + +static int mmc35240_resume(struct device *dev) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); + struct mmc35240_data *data = iio_priv(indio_dev); + int ret; + + regcache_mark_dirty(data->regmap); + ret = regcache_sync_region(data->regmap, MMC35240_REG_CTRL0, + MMC35240_REG_CTRL1); + if (ret < 0) + dev_err(dev, "Failed to restore control registers\n"); + + regcache_cache_only(data->regmap, false); + + return 0; +} +#endif + +static const struct dev_pm_ops mmc35240_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(mmc35240_suspend, mmc35240_resume) +}; + static const struct i2c_device_id mmc35240_id[] = { {"MMC35240", 0}, {} @@ -457,6 +491,7 @@ MODULE_DEVICE_TABLE(i2c, mmc35240_id); static struct i2c_driver mmc35240_driver = { .driver = { .name = MMC35240_DRV_NAME, + .pm = &mmc35240_pm_ops, }, .probe = mmc35240_probe, .id_table = mmc35240_id, From d11715f087e0c0608de8ec030ca260892e8b8739 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Fri, 24 Apr 2015 18:58:32 +0300 Subject: [PATCH 0440/1163] iio: magnetometer: Add ACPI support for MMC35240 We assume that ACPI device tables use MMC35240 to identify MEMSIC's 3 axis magnetic sensor. Signed-off-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/mmc35240.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c index 0c7d64c41575..aa6e25d3bfc3 100644 --- a/drivers/iio/magnetometer/mmc35240.c +++ b/drivers/iio/magnetometer/mmc35240.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -482,6 +483,12 @@ static const struct dev_pm_ops mmc35240_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(mmc35240_suspend, mmc35240_resume) }; +static const struct acpi_device_id mmc35240_acpi_match[] = { + {"MMC35240", 0}, + { }, +}; +MODULE_DEVICE_TABLE(acpi, mmc35240_acpi_match); + static const struct i2c_device_id mmc35240_id[] = { {"MMC35240", 0}, {} @@ -492,6 +499,7 @@ static struct i2c_driver mmc35240_driver = { .driver = { .name = MMC35240_DRV_NAME, .pm = &mmc35240_pm_ops, + .acpi_match_table = ACPI_PTR(mmc35240_acpi_match), }, .probe = mmc35240_probe, .id_table = mmc35240_id, From 54628687fa2df2d3755912954afa67665ed122cc Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 5 May 2015 10:42:12 +0200 Subject: [PATCH 0441/1163] iio: make tools more cross-compilation friendly When cross-compiling the IIO tools we need to opportunity to specify a cross compiler prefix and some extra CFLAGS. This patch enables this in the same way as for other stuff in tools. Signed-off-by: Linus Walleij Acked-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- tools/iio/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/iio/Makefile b/tools/iio/Makefile index bf7ae6d6612a..3a7a54f59713 100644 --- a/tools/iio/Makefile +++ b/tools/iio/Makefile @@ -1,5 +1,5 @@ -CC = gcc -CFLAGS = -Wall -g -D_GNU_SOURCE +CC = $(CROSS_COMPILE)gcc +CFLAGS += -Wall -g -D_GNU_SOURCE all: iio_event_monitor lsiio generic_buffer From 3a11fbb037a1ecd3e1070ee484f1ea887133f21b Mon Sep 17 00:00:00 2001 From: Tomasz Duszynski Date: Sun, 3 May 2015 20:37:21 +0200 Subject: [PATCH 0442/1163] iio: light: add support for ROHM BH1710/BH1715/BH1721/BH1750/BH1751 ambient light sensors Add support for ROHM BH1710/BH1715/BH1721/BH1750/BH1751 ambient light sensors. Signed-off-by: Tomasz Duszynski Signed-off-by: Jonathan Cameron --- drivers/iio/light/Kconfig | 10 ++ drivers/iio/light/Makefile | 1 + drivers/iio/light/bh1750.c | 334 +++++++++++++++++++++++++++++++++++++ 3 files changed, 345 insertions(+) create mode 100644 drivers/iio/light/bh1750.c diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index 3d7bafa6a0e3..0ce46fd5a646 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -37,6 +37,16 @@ config APDS9300 To compile this driver as a module, choose M here: the module will be called apds9300. +config BH1750 + tristate "ROHM BH1750 ambient light sensor" + depends on I2C + help + Say Y here to build support for the ROHM BH1710, BH1715, BH1721, + BH1750, BH1751 ambient light sensors. + + To compile this driver as a module, choose M here: the module will + be called bh1750. + config CM32181 depends on I2C tristate "CM32181 driver" diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile index 90e7fd258557..11c181cf5abb 100644 --- a/drivers/iio/light/Makefile +++ b/drivers/iio/light/Makefile @@ -6,6 +6,7 @@ obj-$(CONFIG_ADJD_S311) += adjd_s311.o obj-$(CONFIG_AL3320A) += al3320a.o obj-$(CONFIG_APDS9300) += apds9300.o +obj-$(CONFIG_BH1750) += bh1750.o obj-$(CONFIG_CM32181) += cm32181.o obj-$(CONFIG_CM3232) += cm3232.o obj-$(CONFIG_CM3323) += cm3323.o diff --git a/drivers/iio/light/bh1750.c b/drivers/iio/light/bh1750.c new file mode 100644 index 000000000000..564c2b3c1a83 --- /dev/null +++ b/drivers/iio/light/bh1750.c @@ -0,0 +1,334 @@ +/* + * ROHM BH1710/BH1715/BH1721/BH1750/BH1751 ambient light sensor driver + * + * Copyright (c) Tomasz Duszynski + * + * 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. + * + * Data sheets: + * http://rohmfs.rohm.com/en/products/databook/datasheet/ic/sensor/light/bh1710fvc-e.pdf + * http://rohmfs.rohm.com/en/products/databook/datasheet/ic/sensor/light/bh1715fvc-e.pdf + * http://rohmfs.rohm.com/en/products/databook/datasheet/ic/sensor/light/bh1721fvc-e.pdf + * http://rohmfs.rohm.com/en/products/databook/datasheet/ic/sensor/light/bh1750fvi-e.pdf + * http://rohmfs.rohm.com/en/products/databook/datasheet/ic/sensor/light/bh1751fvi-e.pdf + * + * 7-bit I2C slave addresses: + * 0x23 (ADDR pin low) + * 0x5C (ADDR pin high) + * + */ + +#include +#include +#include +#include +#include + +#define BH1750_POWER_DOWN 0x00 +#define BH1750_ONE_TIME_H_RES_MODE 0x20 /* auto-mode for BH1721 */ +#define BH1750_CHANGE_INT_TIME_H_BIT 0x40 +#define BH1750_CHANGE_INT_TIME_L_BIT 0x60 + +enum { + BH1710, + BH1721, + BH1750, +}; + +struct bh1750_chip_info; +struct bh1750_data { + struct i2c_client *client; + struct mutex lock; + const struct bh1750_chip_info *chip_info; + u16 mtreg; +}; + +struct bh1750_chip_info { + u16 mtreg_min; + u16 mtreg_max; + u16 mtreg_default; + int mtreg_to_usec; + int mtreg_to_scale; + + /* + * For BH1710/BH1721 all possible integration time values won't fit + * into one page so displaying is limited to every second one. + * Note, that user can still write proper values which were not + * listed. + */ + int inc; + + u16 int_time_low_mask; + u16 int_time_high_mask; +} + +static const bh1750_chip_info_tbl[] = { + [BH1710] = { 140, 1022, 300, 400, 250000000, 2, 0x001F, 0x03E0 }, + [BH1721] = { 140, 1020, 300, 400, 250000000, 2, 0x0010, 0x03E0 }, + [BH1750] = { 31, 254, 69, 1740, 57500000, 1, 0x001F, 0x00E0 }, +}; + +static int bh1750_change_int_time(struct bh1750_data *data, int usec) +{ + int ret; + u16 val; + u8 regval; + const struct bh1750_chip_info *chip_info = data->chip_info; + + if ((usec % chip_info->mtreg_to_usec) != 0) + return -EINVAL; + + val = usec / chip_info->mtreg_to_usec; + if (val < chip_info->mtreg_min || val > chip_info->mtreg_max) + return -EINVAL; + + ret = i2c_smbus_write_byte(data->client, BH1750_POWER_DOWN); + if (ret < 0) + return ret; + + regval = (val & chip_info->int_time_high_mask) >> 5; + ret = i2c_smbus_write_byte(data->client, + BH1750_CHANGE_INT_TIME_H_BIT | regval); + if (ret < 0) + return ret; + + regval = val & chip_info->int_time_low_mask; + ret = i2c_smbus_write_byte(data->client, + BH1750_CHANGE_INT_TIME_L_BIT | regval); + if (ret < 0) + return ret; + + data->mtreg = val; + + return 0; +} + +static int bh1750_read(struct bh1750_data *data, int *val) +{ + int ret; + __be16 result; + const struct bh1750_chip_info *chip_info = data->chip_info; + unsigned long delay = chip_info->mtreg_to_usec * data->mtreg; + + /* + * BH1721 will enter continuous mode on receiving this command. + * Note, that this eliminates need for bh1750_resume(). + */ + ret = i2c_smbus_write_byte(data->client, BH1750_ONE_TIME_H_RES_MODE); + if (ret < 0) + return ret; + + usleep_range(delay + 15000, delay + 40000); + + ret = i2c_master_recv(data->client, (char *)&result, 2); + if (ret < 0) + return ret; + + *val = be16_to_cpu(result); + + return 0; +} + +static int bh1750_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + int ret, tmp; + struct bh1750_data *data = iio_priv(indio_dev); + const struct bh1750_chip_info *chip_info = data->chip_info; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + switch (chan->type) { + case IIO_LIGHT: + mutex_lock(&data->lock); + ret = bh1750_read(data, val); + mutex_unlock(&data->lock); + if (ret < 0) + return ret; + + return IIO_VAL_INT; + default: + return -EINVAL; + } + case IIO_CHAN_INFO_SCALE: + tmp = chip_info->mtreg_to_scale / data->mtreg; + *val = tmp / 1000000; + *val2 = tmp % 1000000; + return IIO_VAL_INT_PLUS_MICRO; + case IIO_CHAN_INFO_INT_TIME: + *val = 0; + *val2 = chip_info->mtreg_to_usec * data->mtreg; + return IIO_VAL_INT_PLUS_MICRO; + default: + return -EINVAL; + } +} + +static int bh1750_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + int ret; + struct bh1750_data *data = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_INT_TIME: + if (val != 0) + return -EINVAL; + + mutex_lock(&data->lock); + ret = bh1750_change_int_time(data, val2); + mutex_unlock(&data->lock); + return ret; + default: + return -EINVAL; + } +} + +static ssize_t bh1750_show_int_time_available(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int i; + size_t len = 0; + struct bh1750_data *data = iio_priv(dev_to_iio_dev(dev)); + const struct bh1750_chip_info *chip_info = data->chip_info; + + for (i = chip_info->mtreg_min; i <= chip_info->mtreg_max; i += chip_info->inc) + len += scnprintf(buf + len, PAGE_SIZE - len, "0.%06d ", + chip_info->mtreg_to_usec * i); + + buf[len - 1] = '\n'; + + return len; +} + +static IIO_DEV_ATTR_INT_TIME_AVAIL(bh1750_show_int_time_available); + +static struct attribute *bh1750_attributes[] = { + &iio_dev_attr_integration_time_available.dev_attr.attr, + NULL, +}; + +static struct attribute_group bh1750_attribute_group = { + .attrs = bh1750_attributes, +}; + +static const struct iio_info bh1750_info = { + .driver_module = THIS_MODULE, + .attrs = &bh1750_attribute_group, + .read_raw = bh1750_read_raw, + .write_raw = bh1750_write_raw, +}; + +static const struct iio_chan_spec bh1750_channels[] = { + { + .type = IIO_LIGHT, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_INT_TIME) + } +}; + +static int bh1750_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + int ret, usec; + struct bh1750_data *data; + struct iio_dev *indio_dev; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C | + I2C_FUNC_SMBUS_WRITE_BYTE)) + 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; + data->chip_info = &bh1750_chip_info_tbl[id->driver_data]; + + usec = data->chip_info->mtreg_to_usec * data->chip_info->mtreg_default; + ret = bh1750_change_int_time(data, usec); + if (ret < 0) + return ret; + + mutex_init(&data->lock); + indio_dev->dev.parent = &client->dev; + indio_dev->info = &bh1750_info; + indio_dev->name = id->name; + indio_dev->channels = bh1750_channels; + indio_dev->num_channels = ARRAY_SIZE(bh1750_channels); + indio_dev->modes = INDIO_DIRECT_MODE; + + return iio_device_register(indio_dev); +} + +static int bh1750_remove(struct i2c_client *client) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct bh1750_data *data = iio_priv(indio_dev); + + iio_device_unregister(indio_dev); + + mutex_lock(&data->lock); + i2c_smbus_write_byte(client, BH1750_POWER_DOWN); + mutex_unlock(&data->lock); + + return 0; +} + +#ifdef CONFIG_PM_SLEEP +static int bh1750_suspend(struct device *dev) +{ + int ret; + struct bh1750_data *data = + iio_priv(i2c_get_clientdata(to_i2c_client(dev))); + + /* + * This is mainly for BH1721 which doesn't enter power down + * mode automatically. + */ + mutex_lock(&data->lock); + ret = i2c_smbus_write_byte(data->client, BH1750_POWER_DOWN); + mutex_unlock(&data->lock); + + return ret; +} + +static SIMPLE_DEV_PM_OPS(bh1750_pm_ops, bh1750_suspend, NULL); +#define BH1750_PM_OPS (&bh1750_pm_ops) +#else +#define BH1750_PM_OPS NULL +#endif + +static const struct i2c_device_id bh1750_id[] = { + { "bh1710", BH1710 }, + { "bh1715", BH1750 }, + { "bh1721", BH1721 }, + { "bh1750", BH1750 }, + { "bh1751", BH1750 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, bh1750_id); + +static struct i2c_driver bh1750_driver = { + .driver = { + .name = "bh1750", + .owner = THIS_MODULE, + .pm = BH1750_PM_OPS, + }, + .probe = bh1750_probe, + .remove = bh1750_remove, + .id_table = bh1750_id, + +}; +module_i2c_driver(bh1750_driver); + +MODULE_AUTHOR("Tomasz Duszynski "); +MODULE_DESCRIPTION("ROHM BH1710/BH1715/BH1721/BH1750/BH1751 als driver"); +MODULE_LICENSE("GPL v2"); From 76ec50a1bcee1e294f282fcf54655c07bc40383e Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Sat, 2 May 2015 00:53:30 +0900 Subject: [PATCH 0443/1163] iio: hid-sensor-accel-3d: Constify platform_device_id The platform_device_id is not modified by the driver and core uses it as const. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Jonathan Cameron --- drivers/iio/accel/hid-sensor-accel-3d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c index 2b4fad6998c1..ab711495d56e 100644 --- a/drivers/iio/accel/hid-sensor-accel-3d.c +++ b/drivers/iio/accel/hid-sensor-accel-3d.c @@ -400,7 +400,7 @@ static int hid_accel_3d_remove(struct platform_device *pdev) return 0; } -static struct platform_device_id hid_accel_3d_ids[] = { +static const struct platform_device_id hid_accel_3d_ids[] = { { /* Format: HID-SENSOR-usage_id_in_hex_lowercase */ .name = "HID-SENSOR-200073", From e682173f3753a73feb8336c8b6cdd8c6b74bdd75 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Sat, 2 May 2015 00:53:31 +0900 Subject: [PATCH 0444/1163] iio: adc: axp288: Constify platform_device_id The platform_device_id is not modified by the driver and core uses it as const. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Jonathan Cameron --- drivers/iio/adc/axp288_adc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c index 08bcfb061ca5..27197fd1517e 100644 --- a/drivers/iio/adc/axp288_adc.c +++ b/drivers/iio/adc/axp288_adc.c @@ -238,7 +238,7 @@ static int axp288_adc_remove(struct platform_device *pdev) return 0; } -static struct platform_device_id axp288_adc_id_table[] = { +static const struct platform_device_id axp288_adc_id_table[] = { { .name = "axp288_adc" }, {}, }; From 322a3b1ea2b1844acb957efbcf4388062bc5684b Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Sat, 2 May 2015 00:53:32 +0900 Subject: [PATCH 0445/1163] iio: hid-sensor-gyro-3d: Constify platform_device_id The platform_device_id is not modified by the driver and core uses it as const. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Jonathan Cameron --- drivers/iio/gyro/hid-sensor-gyro-3d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c index b5883b6f4e50..2e10799fe287 100644 --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c @@ -397,7 +397,7 @@ static int hid_gyro_3d_remove(struct platform_device *pdev) return 0; } -static struct platform_device_id hid_gyro_3d_ids[] = { +static const struct platform_device_id hid_gyro_3d_ids[] = { { /* Format: HID-SENSOR-usage_id_in_hex_lowercase */ .name = "HID-SENSOR-200076", From 4e617fc1b6ce543e71c9aeb60b81ad55d2fefe91 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Sat, 2 May 2015 00:53:33 +0900 Subject: [PATCH 0446/1163] iio: light: hid-sensor-als: Constify platform_device_id The platform_device_id is not modified by the driver and core uses it as const. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Jonathan Cameron --- drivers/iio/light/hid-sensor-als.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c index 1609ecdd01b0..cf13a18bafd0 100644 --- a/drivers/iio/light/hid-sensor-als.c +++ b/drivers/iio/light/hid-sensor-als.c @@ -361,7 +361,7 @@ static int hid_als_remove(struct platform_device *pdev) return 0; } -static struct platform_device_id hid_als_ids[] = { +static const struct platform_device_id hid_als_ids[] = { { /* Format: HID-SENSOR-usage_id_in_hex_lowercase */ .name = "HID-SENSOR-200041", From 4205086119a70e9eb57330755b62680802e325b9 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Sat, 2 May 2015 00:53:34 +0900 Subject: [PATCH 0447/1163] iio: light: hid-sensor-prox: Constify platform_device_id The platform_device_id is not modified by the driver and core uses it as const. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Jonathan Cameron --- drivers/iio/light/hid-sensor-prox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c index 91ecc46ffeaa..be9db9d985b2 100644 --- a/drivers/iio/light/hid-sensor-prox.c +++ b/drivers/iio/light/hid-sensor-prox.c @@ -352,7 +352,7 @@ static int hid_prox_remove(struct platform_device *pdev) return 0; } -static struct platform_device_id hid_prox_ids[] = { +static const struct platform_device_id hid_prox_ids[] = { { /* Format: HID-SENSOR-usage_id_in_hex_lowercase */ .name = "HID-SENSOR-200011", From df5e94b4823d6cb3af30312b4cc08759c6306e06 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Sat, 2 May 2015 00:53:35 +0900 Subject: [PATCH 0448/1163] iio: hid-sensor-magn-3d: Constify platform_device_id The platform_device_id is not modified by the driver and core uses it as const. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/hid-sensor-magn-3d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c index 4f9c0be24451..d8a0c8da8db0 100644 --- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c +++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c @@ -510,7 +510,7 @@ static int hid_magn_3d_remove(struct platform_device *pdev) return 0; } -static struct platform_device_id hid_magn_3d_ids[] = { +static const struct platform_device_id hid_magn_3d_ids[] = { { /* Format: HID-SENSOR-usage_id_in_hex_lowercase */ .name = "HID-SENSOR-200083", From 5dd86df009064b4ba25eabc78ea97d5c92154d13 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Sat, 2 May 2015 00:53:36 +0900 Subject: [PATCH 0449/1163] iio: hid-sensor-incl-3d: Constify platform_device_id The platform_device_id is not modified by the driver and core uses it as const. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Jonathan Cameron --- drivers/iio/orientation/hid-sensor-incl-3d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c index 5930fa32a2ab..e75c301988f2 100644 --- a/drivers/iio/orientation/hid-sensor-incl-3d.c +++ b/drivers/iio/orientation/hid-sensor-incl-3d.c @@ -417,7 +417,7 @@ static int hid_incl_3d_remove(struct platform_device *pdev) return 0; } -static struct platform_device_id hid_incl_3d_ids[] = { +static const struct platform_device_id hid_incl_3d_ids[] = { { /* Format: HID-SENSOR-usage_id_in_hex_lowercase */ .name = "HID-SENSOR-200086", From 6b490c6c6702b1404d3ae93a9d0ace211d40c094 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Sat, 2 May 2015 00:53:37 +0900 Subject: [PATCH 0450/1163] iio: hid-sensor-rotation: Constify platform_device_id The platform_device_id is not modified by the driver and core uses it as const. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Jonathan Cameron --- drivers/iio/orientation/hid-sensor-rotation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c index 4afb6c79ccbc..603fe1419581 100644 --- a/drivers/iio/orientation/hid-sensor-rotation.c +++ b/drivers/iio/orientation/hid-sensor-rotation.c @@ -321,7 +321,7 @@ static int hid_dev_rot_remove(struct platform_device *pdev) return 0; } -static struct platform_device_id hid_dev_rot_ids[] = { +static const struct platform_device_id hid_dev_rot_ids[] = { { /* Format: HID-SENSOR-usage_id_in_hex_lowercase */ .name = "HID-SENSOR-20008a", From 85b4ba7055d4cf624b6a608125e3d0c57768cc10 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Sat, 2 May 2015 00:53:38 +0900 Subject: [PATCH 0451/1163] iio: hid-sensor-press: Constify platform_device_id The platform_device_id is not modified by the driver and core uses it as const. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/hid-sensor-press.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c index 7bb8d4c1f7df..f3305d80c0b8 100644 --- a/drivers/iio/pressure/hid-sensor-press.c +++ b/drivers/iio/pressure/hid-sensor-press.c @@ -362,7 +362,7 @@ static int hid_press_remove(struct platform_device *pdev) return 0; } -static struct platform_device_id hid_press_ids[] = { +static const struct platform_device_id hid_press_ids[] = { { /* Format: HID-SENSOR-usage_id_in_hex_lowercase */ .name = "HID-SENSOR-200031", From ee1a81f90f28a5a2c3339ec62b2a6a6d165075d2 Mon Sep 17 00:00:00 2001 From: Varka Bhadram Date: Fri, 24 Apr 2015 14:53:07 +0530 Subject: [PATCH 0452/1163] imu: inv_mpu6050: adds device tree bindings Signed-off-by: Varka Bhadram Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/imu/inv_mpu6050.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt diff --git a/Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt b/Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt new file mode 100644 index 000000000000..e4d8f1c52f4a --- /dev/null +++ b/Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt @@ -0,0 +1,17 @@ +InvenSense MPU-6050 Six-Axis (Gyro + Accelerometer) MEMS MotionTracking Device + +http://www.invensense.com/mems/gyro/mpu6050.html + +Required properties: + - compatible : should be "invensense,mpu6050" + - reg : the I2C address of the sensor + - interrupt-parent : should be the phandle for the interrupt controller + - interrupts : interrupt mapping for GPIO IRQ + +Example: + mpu6050@68 { + compatible = "invensense,mpu6050"; + reg = <0x68>; + interrupt-parent = <&gpio1>; + interrupts = <18 1>; + }; From feca56ff400b7b166c86af9ff5c131d1d33cf615 Mon Sep 17 00:00:00 2001 From: Gabriele Mazzotta Date: Sat, 2 May 2015 14:30:57 +0200 Subject: [PATCH 0453/1163] iio: acpi: Add support for ACPI0008 Ambient Light Sensor This driver adds the initial support for the ACPI Ambient Light Sensor as defined in Section 9.2 of the ACPI specification (Revision 5.0) [1]. Sensors complying with the standard are exposed as ACPI devices with ACPI0008 as hardware ID and provide standard methods by which the OS can query properties of the ambient light environment the system is currently operating in. This driver currently allows only to get the current ambient light illuminance reading through the _ALI method, but is ready to be extended extended to handle _ALC, _ALT and _ALP as well. [1] http://www.acpi.info/DOWNLOADS/ACPIspec50.pdf Signed-off-by: Martin Liska Signed-off-by: Marek Vasut Signed-off-by: Gabriele Mazzotta Cc: Zhang Rui Signed-off-by: Jonathan Cameron --- drivers/iio/light/Kconfig | 13 ++ drivers/iio/light/Makefile | 1 + drivers/iio/light/acpi-als.c | 231 +++++++++++++++++++++++++++++++++++ 3 files changed, 245 insertions(+) create mode 100644 drivers/iio/light/acpi-als.c diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index 0ce46fd5a646..e6198b7c9cbf 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -5,6 +5,19 @@ menu "Light sensors" +config ACPI_ALS + tristate "ACPI Ambient Light Sensor" + depends on ACPI + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + select IIO_KFIFO_BUF + help + Say Y here if you want to build a driver for the ACPI0008 + Ambient Light Sensor. + + To compile this driver as a module, choose M here: the module will + be called acpi-als. + config ADJD_S311 tristate "ADJD-S311-CR999 digital color sensor" select IIO_BUFFER diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile index 11c181cf5abb..e2d50fd59c66 100644 --- a/drivers/iio/light/Makefile +++ b/drivers/iio/light/Makefile @@ -3,6 +3,7 @@ # # When adding new entries keep the list in alphabetical order +obj-$(CONFIG_ACPI_ALS) += acpi-als.o obj-$(CONFIG_ADJD_S311) += adjd_s311.o obj-$(CONFIG_AL3320A) += al3320a.o obj-$(CONFIG_APDS9300) += apds9300.o diff --git a/drivers/iio/light/acpi-als.c b/drivers/iio/light/acpi-als.c new file mode 100644 index 000000000000..1dafa0756bfa --- /dev/null +++ b/drivers/iio/light/acpi-als.c @@ -0,0 +1,231 @@ +/* + * ACPI Ambient Light Sensor Driver + * + * Based on ALS driver: + * Copyright (C) 2009 Zhang Rui + * + * Rework for IIO subsystem: + * Copyright (C) 2012-2013 Martin Liska + * + * Final cleanup and debugging: + * Copyright (C) 2013-2014 Marek Vasut + * Copyright (C) 2015 Gabriele Mazzotta + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include +#include +#include +#include + +#include +#include +#include + +#define ACPI_ALS_CLASS "als" +#define ACPI_ALS_DEVICE_NAME "acpi-als" +#define ACPI_ALS_NOTIFY_ILLUMINANCE 0x80 + +ACPI_MODULE_NAME("acpi-als"); + +/* + * So far, there's only one channel in here, but the specification for + * ACPI0008 says there can be more to what the block can report. Like + * chromaticity and such. We are ready for incoming additions! + */ +static const struct iio_chan_spec acpi_als_channels[] = { + { + .type = IIO_LIGHT, + .scan_type = { + .sign = 's', + .realbits = 32, + .storagebits = 32, + }, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + }, +}; + +/* + * The event buffer contains timestamp and all the data from + * the ACPI0008 block. There are multiple, but so far we only + * support _ALI (illuminance). Once someone adds new channels + * to acpi_als_channels[], the evt_buffer below will grow + * automatically. + */ +#define EVT_NR_SOURCES ARRAY_SIZE(acpi_als_channels) +#define EVT_BUFFER_SIZE \ + (sizeof(s64) + (EVT_NR_SOURCES * sizeof(s32))) + +struct acpi_als { + struct acpi_device *device; + struct mutex lock; + + s32 evt_buffer[EVT_BUFFER_SIZE]; +}; + +/* + * All types of properties the ACPI0008 block can report. The ALI, ALC, ALT + * and ALP can all be handled by als_read_value() below, while the ALR is + * special. + * + * The _ALR property returns tables that can be used to fine-tune the values + * reported by the other props based on the particular hardware type and it's + * location (it contains tables for "rainy", "bright inhouse lighting" etc.). + * + * So far, we support only ALI (illuminance). + */ +#define ACPI_ALS_ILLUMINANCE "_ALI" +#define ACPI_ALS_CHROMATICITY "_ALC" +#define ACPI_ALS_COLOR_TEMP "_ALT" +#define ACPI_ALS_POLLING "_ALP" +#define ACPI_ALS_TABLES "_ALR" + +static int als_read_value(struct acpi_als *als, char *prop, s32 *val) +{ + unsigned long long temp_val; + acpi_status status; + + status = acpi_evaluate_integer(als->device->handle, prop, NULL, + &temp_val); + + if (ACPI_FAILURE(status)) { + ACPI_EXCEPTION((AE_INFO, status, "Error reading ALS %s", prop)); + return -EIO; + } + + *val = temp_val; + + return 0; +} + +static void acpi_als_notify(struct acpi_device *device, u32 event) +{ + struct iio_dev *indio_dev = acpi_driver_data(device); + struct acpi_als *als = iio_priv(indio_dev); + s32 *buffer = als->evt_buffer; + s64 time_ns = iio_get_time_ns(); + s32 val; + int ret; + + mutex_lock(&als->lock); + + memset(buffer, 0, EVT_BUFFER_SIZE); + + switch (event) { + case ACPI_ALS_NOTIFY_ILLUMINANCE: + ret = als_read_value(als, ACPI_ALS_ILLUMINANCE, &val); + if (ret < 0) + goto out; + *buffer++ = val; + break; + default: + /* Unhandled event */ + dev_dbg(&device->dev, "Unhandled ACPI ALS event (%08x)!\n", + event); + goto out; + } + + iio_push_to_buffers_with_timestamp(indio_dev, als->evt_buffer, time_ns); + +out: + mutex_unlock(&als->lock); +} + +static int acpi_als_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int *val, + int *val2, long mask) +{ + struct acpi_als *als = iio_priv(indio_dev); + s32 temp_val; + int ret; + + if (mask != IIO_CHAN_INFO_RAW) + return -EINVAL; + + /* we support only illumination (_ALI) so far. */ + if (chan->type != IIO_LIGHT) + return -EINVAL; + + ret = als_read_value(als, ACPI_ALS_ILLUMINANCE, &temp_val); + if (ret < 0) + return ret; + + *val = temp_val; + + return IIO_VAL_INT; +} + +static const struct iio_info acpi_als_info = { + .driver_module = THIS_MODULE, + .read_raw = acpi_als_read_raw, +}; + +static int acpi_als_add(struct acpi_device *device) +{ + struct acpi_als *als; + struct iio_dev *indio_dev; + struct iio_buffer *buffer; + + indio_dev = devm_iio_device_alloc(&device->dev, sizeof(*als)); + if (!indio_dev) + return -ENOMEM; + + als = iio_priv(indio_dev); + + device->driver_data = indio_dev; + als->device = device; + mutex_init(&als->lock); + + indio_dev->name = ACPI_ALS_DEVICE_NAME; + indio_dev->dev.parent = &device->dev; + indio_dev->info = &acpi_als_info; + indio_dev->modes = INDIO_BUFFER_SOFTWARE; + indio_dev->channels = acpi_als_channels; + indio_dev->num_channels = ARRAY_SIZE(acpi_als_channels); + + buffer = devm_iio_kfifo_allocate(&device->dev); + if (!buffer) + return -ENOMEM; + + iio_device_attach_buffer(indio_dev, buffer); + + return devm_iio_device_register(&device->dev, indio_dev); +} + +static const struct acpi_device_id acpi_als_device_ids[] = { + {"ACPI0008", 0}, + {}, +}; + +MODULE_DEVICE_TABLE(acpi, acpi_als_device_ids); + +static struct acpi_driver acpi_als_driver = { + .name = "acpi_als", + .class = ACPI_ALS_CLASS, + .ids = acpi_als_device_ids, + .ops = { + .add = acpi_als_add, + .notify = acpi_als_notify, + }, +}; + +module_acpi_driver(acpi_als_driver); + +MODULE_AUTHOR("Zhang Rui "); +MODULE_AUTHOR("Martin Liska "); +MODULE_AUTHOR("Marek Vasut "); +MODULE_DESCRIPTION("ACPI Ambient Light Sensor Driver"); +MODULE_LICENSE("GPL"); From 5dc11e810676ec4a5acb4423ccd33314bf74f4e5 Mon Sep 17 00:00:00 2001 From: Vignesh R Date: Tue, 31 Mar 2015 16:42:37 +0530 Subject: [PATCH 0454/1163] iio: adc: ti_am335x_adc: make sample delay, open delay, averaging DT parameters Add optional DT properties to set open delay, sample delay and number of averages per sample for each adc step. Open delay, sample delay and averaging are some of the parameters that affect the sampling rate and accuracy of the sample. Making these parameters configurable via DT will help in balancing speed vs accuracy. Signed-off-by: Vignesh R Signed-off-by: Jonathan Cameron --- .../bindings/input/touchscreen/ti-tsc-adc.txt | 24 +++++++++ drivers/iio/adc/ti_am335x_adc.c | 54 ++++++++++++++++--- 2 files changed, 72 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt b/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt index 6c4fb34823d3..b1163bf97146 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt @@ -42,6 +42,27 @@ Optional properties: hardware knob for adjusting the amount of "settling time". +- child "adc" + ti,chan-step-opendelay: List of open delays for each channel of + ADC in the order of ti,adc-channels. The + value corresponds to the number of ADC + clock cycles to wait after applying the + step configuration registers and before + sending the start of ADC conversion. + Maximum value is 0x3FFFF. + ti,chan-step-sampledelay: List of sample delays for each channel + of ADC in the order of ti,adc-channels. + The value corresponds to the number of + ADC clock cycles to sample (to hold + start of conversion high). + Maximum value is 0xFF. + ti,chan-step-avg: Number of averages to be performed for each + channel of ADC. If average is 16 then input + is sampled 16 times and averaged to get more + accurate value. This increases the time taken + by ADC to generate a sample. Valid range is 0 + average to 16 averages. Maximum value is 16. + Example: tscadc: tscadc@44e0d000 { compatible = "ti,am3359-tscadc"; @@ -55,5 +76,8 @@ Example: adc { ti,adc-channels = <4 5 6 7>; + ti,chan-step-opendelay = <0x098 0x3ffff 0x098 0x0>; + ti,chan-step-sampledelay = <0xff 0x0 0xf 0x0>; + ti,chan-step-avg = <16 2 4 8>; }; } diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index 42e444044ea5..942320e32753 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c @@ -37,6 +37,7 @@ struct tiadc_device { u8 channel_step[8]; int buffer_en_ch_steps; u16 data[8]; + u32 open_delay[8], sample_delay[8], step_avg[8]; }; static unsigned int tiadc_readl(struct tiadc_device *adc, unsigned int reg) @@ -85,6 +86,7 @@ static u32 get_adc_step_bit(struct tiadc_device *adc_dev, int chan) static void tiadc_step_config(struct iio_dev *indio_dev) { struct tiadc_device *adc_dev = iio_priv(indio_dev); + struct device *dev = adc_dev->mfd_tscadc->dev; unsigned int stepconfig; int i, steps = 0; @@ -98,20 +100,47 @@ static void tiadc_step_config(struct iio_dev *indio_dev) * needs to be given to ADC to digitalize data. */ - if (iio_buffer_enabled(indio_dev)) - stepconfig = STEPCONFIG_AVG_16 | STEPCONFIG_FIFO1 - | STEPCONFIG_MODE_SWCNT; - else - stepconfig = STEPCONFIG_AVG_16 | STEPCONFIG_FIFO1; for (i = 0; i < adc_dev->channels; i++) { int chan; chan = adc_dev->channel_line[i]; + + if (adc_dev->step_avg[i] > STEPCONFIG_AVG_16) { + dev_warn(dev, "chan %d step_avg truncating to %d\n", + chan, STEPCONFIG_AVG_16); + adc_dev->step_avg[i] = STEPCONFIG_AVG_16; + } + + if (adc_dev->step_avg[i]) + stepconfig = + STEPCONFIG_AVG(ffs(adc_dev->step_avg[i]) - 1) | + STEPCONFIG_FIFO1; + else + stepconfig = STEPCONFIG_FIFO1; + + if (iio_buffer_enabled(indio_dev)) + stepconfig |= STEPCONFIG_MODE_SWCNT; + tiadc_writel(adc_dev, REG_STEPCONFIG(steps), stepconfig | STEPCONFIG_INP(chan)); + + if (adc_dev->open_delay[i] > STEPDELAY_OPEN_MASK) { + dev_warn(dev, "chan %d open delay truncating to 0x3FFFF\n", + chan); + adc_dev->open_delay[i] = STEPDELAY_OPEN_MASK; + } + + if (adc_dev->sample_delay[i] > 0xFF) { + dev_warn(dev, "chan %d sample delay truncating to 0xFF\n", + chan); + adc_dev->sample_delay[i] = 0xFF; + } + tiadc_writel(adc_dev, REG_STEPDELAY(steps), - STEPCONFIG_OPENDLY); + STEPDELAY_OPEN(adc_dev->open_delay[i]) | + STEPDELAY_SAMPLE(adc_dev->sample_delay[i])); + adc_dev->channel_step[i] = steps; steps++; } @@ -406,9 +435,22 @@ static int tiadc_parse_dt(struct platform_device *pdev, of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) { adc_dev->channel_line[channels] = val; + + /* Set Default values for optional DT parameters */ + adc_dev->open_delay[channels] = STEPCONFIG_OPENDLY; + adc_dev->sample_delay[channels] = STEPCONFIG_SAMPLEDLY; + adc_dev->step_avg[channels] = 16; + channels++; } + of_property_read_u32_array(node, "ti,chan-step-avg", + adc_dev->step_avg, channels); + of_property_read_u32_array(node, "ti,chan-step-opendelay", + adc_dev->open_delay, channels); + of_property_read_u32_array(node, "ti,chan-step-sampledelay", + adc_dev->sample_delay, channels); + adc_dev->channels = channels; return 0; } From f2c714a0a230c9b4ffdf45c5d203b8cd35126353 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 2 May 2015 11:35:02 +0100 Subject: [PATCH 0455/1163] iio:temp:mlx90614 trivial drop of unnecessary ret return from write_raw. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is mostly part of an effort to clean out our current warnings and make the autobuilder build reports more useful. Still a worthwhile if trivial cleanup! Signed-off-by: Jonathan Cameron Reported-by: kbuild test robot Cc: Vianney le Clément de Saint-Marcq Cc: Peter Meerwald --- drivers/iio/temperature/mlx90614.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c index b2d3b56f1260..cb2e8ad8bfdc 100644 --- a/drivers/iio/temperature/mlx90614.c +++ b/drivers/iio/temperature/mlx90614.c @@ -254,9 +254,7 @@ static int mlx90614_write_raw(struct iio_dev *indio_dev, mutex_unlock(&data->lock); mlx90614_power_put(data); - if (ret < 0) - return ret; - return 0; + return ret; default: return -EINVAL; } From 1645b55b50f032888fef7855e80a23d78dfa067b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 11 May 2015 10:22:45 -0700 Subject: [PATCH 0456/1163] staging: comedi: ni_mio_common: fix build warning The kbuild test robot detected a build warning causes by commit f878071a. >> drivers/staging/comedi/drivers/ni_mio_common.c:2274:34: warning: right-hand operand of comma expression has no effect [-Wunused-value] That line should have been terminated by ';' and the following line removed. Not sure why it even builds on my test system... Reported-by: kbuild test robot Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index c741dde9c0bb..9dfd4e6e6ced 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -2268,8 +2268,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) case TRIG_INT: case TRIG_NOW: ai_trig |= NISTC_AI_TRIG_START1_EDGE | - NISTC_AI_TRIG_START1_SEL(0), - NISTC_AI_TRIG_SEL_REG; + NISTC_AI_TRIG_START1_SEL(0); break; case TRIG_EXT: ai_trig |= NISTC_AI_TRIG_START1_SEL(CR_CHAN(cmd->start_arg) + From eafe600205cb9299bf32a3117e03046f09a71190 Mon Sep 17 00:00:00 2001 From: David Matlack Date: Mon, 11 May 2015 20:40:35 -0700 Subject: [PATCH 0457/1163] staging: slicoss: remove slic_spinlock wrapper As per TODO. This commit introduces no functional changes. Signed-off-by: David Matlack Signed-off-by: Greg Kroah-Hartman --- drivers/staging/slicoss/TODO | 1 - drivers/staging/slicoss/slic.h | 19 ++--- drivers/staging/slicoss/slicoss.c | 125 ++++++++++++++---------------- 3 files changed, 65 insertions(+), 80 deletions(-) diff --git a/drivers/staging/slicoss/TODO b/drivers/staging/slicoss/TODO index 20cc9abdc466..9019729b7be6 100644 --- a/drivers/staging/slicoss/TODO +++ b/drivers/staging/slicoss/TODO @@ -25,7 +25,6 @@ TODO: - state variables for things that are easily available and shouldn't be kept in card structure, cardnum, ... slotnumber, events, ... - - get rid of slic_spinlock wrapper - volatile == bad design => bad code - locking too fine grained, not designed just throw more locks at problem diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h index 3a5aa882b957..5b23254f811a 100644 --- a/drivers/staging/slicoss/slic.h +++ b/drivers/staging/slicoss/slic.h @@ -56,11 +56,6 @@ static u32 OasisRcvUCodeLen = 512; static u32 GBRcvUCodeLen = 512; #define SECTION_SIZE 65536 -struct slic_spinlock { - spinlock_t lock; - unsigned long flags; -}; - #define SLIC_RSPQ_PAGES_GB 10 #define SLIC_RSPQ_BUFSINPAGE (PAGE_SIZE / SLIC_RSPBUF_SIZE) @@ -165,7 +160,7 @@ struct slic_cmdqueue { struct slic_hostcmd *head; struct slic_hostcmd *tail; int count; - struct slic_spinlock lock; + spinlock_t lock; }; #define SLIC_MAX_CARDS 32 @@ -346,7 +341,7 @@ struct physcard { }; struct base_driver { - struct slic_spinlock driver_lock; + spinlock_t driver_lock; u32 num_slic_cards; u32 num_slic_ports; u32 num_slic_ports_active; @@ -401,8 +396,8 @@ struct adapter { uint card_size; uint chipid; struct net_device *netdev; - struct slic_spinlock adapter_lock; - struct slic_spinlock reset_lock; + spinlock_t adapter_lock; + spinlock_t reset_lock; struct pci_dev *pcidev; uint busnumber; uint slotnumber; @@ -441,8 +436,8 @@ struct adapter { u32 pingtimerset; struct timer_list loadtimer; u32 loadtimerset; - struct slic_spinlock upr_lock; - struct slic_spinlock bit64reglock; + spinlock_t upr_lock; + spinlock_t bit64reglock; struct slic_rspqueue rspqueue; struct slic_rcvqueue rcvqueue; struct slic_cmdqueue cmdq_free; @@ -457,7 +452,7 @@ struct adapter { /* Free object handles*/ struct slic_handle *pfree_slic_handles; /* Object handle list lock*/ - struct slic_spinlock handle_lock; + spinlock_t handle_lock; ushort slic_handle_ix; u32 xmitq_full; diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index c2bda1d38e41..39c140ccdcbb 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -144,8 +144,9 @@ static inline void slic_reg64_write(struct adapter *adapter, void __iomem *reg, u32 value, void __iomem *regh, u32 paddrh, bool flush) { - spin_lock_irqsave(&adapter->bit64reglock.lock, - adapter->bit64reglock.flags); + unsigned long flags; + + spin_lock_irqsave(&adapter->bit64reglock, flags); if (paddrh != adapter->curaddrupper) { adapter->curaddrupper = paddrh; writel(paddrh, regh); @@ -153,8 +154,7 @@ static inline void slic_reg64_write(struct adapter *adapter, void __iomem *reg, writel(value, reg); if (flush) mb(); - spin_unlock_irqrestore(&adapter->bit64reglock.lock, - adapter->bit64reglock.flags); + spin_unlock_irqrestore(&adapter->bit64reglock, flags); } static void slic_mcast_set_bit(struct adapter *adapter, char *address) @@ -936,9 +936,10 @@ static int slic_upr_request(struct adapter *adapter, u32 upr_data_h, u32 upr_buffer, u32 upr_buffer_h) { + unsigned long flags; int rc; - spin_lock_irqsave(&adapter->upr_lock.lock, adapter->upr_lock.flags); + spin_lock_irqsave(&adapter->upr_lock, flags); rc = slic_upr_queue_request(adapter, upr_request, upr_data, @@ -948,8 +949,7 @@ static int slic_upr_request(struct adapter *adapter, slic_upr_start(adapter); err_unlock_irq: - spin_unlock_irqrestore(&adapter->upr_lock.lock, - adapter->upr_lock.flags); + spin_unlock_irqrestore(&adapter->upr_lock, flags); return rc; } @@ -1029,12 +1029,12 @@ static void slic_upr_request_complete(struct adapter *adapter, u32 isr) { struct sliccard *card = adapter->card; struct slic_upr *upr; + unsigned long flags; - spin_lock_irqsave(&adapter->upr_lock.lock, adapter->upr_lock.flags); + spin_lock_irqsave(&adapter->upr_lock, flags); upr = adapter->upr_list; if (!upr) { - spin_unlock_irqrestore(&adapter->upr_lock.lock, - adapter->upr_lock.flags); + spin_unlock_irqrestore(&adapter->upr_lock, flags); return; } adapter->upr_list = upr->next; @@ -1127,8 +1127,7 @@ static void slic_upr_request_complete(struct adapter *adapter, u32 isr) } kfree(upr); slic_upr_start(adapter); - spin_unlock_irqrestore(&adapter->upr_lock.lock, - adapter->upr_lock.flags); + spin_unlock_irqrestore(&adapter->upr_lock, flags); } static int slic_config_get(struct adapter *adapter, u32 config, u32 config_h) @@ -1310,6 +1309,7 @@ static void slic_cmdq_addcmdpage(struct adapter *adapter, u32 *page) u32 phys_addrl; u32 phys_addrh; struct slic_handle *pslic_handle; + unsigned long flags; cmdaddr = page; cmd = (struct slic_hostcmd *)cmdaddr; @@ -1324,12 +1324,10 @@ static void slic_cmdq_addcmdpage(struct adapter *adapter, u32 *page) while ((cmdcnt < SLIC_CMDQ_CMDSINPAGE) && (adapter->slic_handle_ix < 256)) { /* Allocate and initialize a SLIC_HANDLE for this command */ - spin_lock_irqsave(&adapter->handle_lock.lock, - adapter->handle_lock.flags); + spin_lock_irqsave(&adapter->handle_lock, flags); pslic_handle = adapter->pfree_slic_handles; adapter->pfree_slic_handles = pslic_handle->next; - spin_unlock_irqrestore(&adapter->handle_lock.lock, - adapter->handle_lock.flags); + spin_unlock_irqrestore(&adapter->handle_lock, flags); pslic_handle->type = SLIC_HANDLE_CMD; pslic_handle->address = (void *) cmd; pslic_handle->offset = (ushort) adapter->slic_handle_ix++; @@ -1356,11 +1354,11 @@ static void slic_cmdq_addcmdpage(struct adapter *adapter, u32 *page) tail->next_all = cmdq->head; cmdq->head = prev; cmdq = &adapter->cmdq_free; - spin_lock_irqsave(&cmdq->lock.lock, cmdq->lock.flags); + spin_lock_irqsave(&cmdq->lock, flags); cmdq->count += cmdcnt; /* SLIC_CMDQ_CMDSINPAGE; mooktodo */ tail->next = cmdq->head; cmdq->head = prev; - spin_unlock_irqrestore(&cmdq->lock.lock, cmdq->lock.flags); + spin_unlock_irqrestore(&cmdq->lock, flags); } static int slic_cmdq_init(struct adapter *adapter) @@ -1371,9 +1369,9 @@ static int slic_cmdq_init(struct adapter *adapter) memset(&adapter->cmdq_all, 0, sizeof(struct slic_cmdqueue)); memset(&adapter->cmdq_free, 0, sizeof(struct slic_cmdqueue)); memset(&adapter->cmdq_done, 0, sizeof(struct slic_cmdqueue)); - spin_lock_init(&adapter->cmdq_all.lock.lock); - spin_lock_init(&adapter->cmdq_free.lock.lock); - spin_lock_init(&adapter->cmdq_done.lock.lock); + spin_lock_init(&adapter->cmdq_all.lock); + spin_lock_init(&adapter->cmdq_free.lock); + spin_lock_init(&adapter->cmdq_done.lock); memset(&adapter->cmdqmem, 0, sizeof(struct slic_cmdqmem)); adapter->slic_handle_ix = 1; for (i = 0; i < SLIC_CMDQ_INITPAGES; i++) { @@ -1394,11 +1392,10 @@ static void slic_cmdq_reset(struct adapter *adapter) struct slic_hostcmd *hcmd; struct sk_buff *skb; u32 outstanding; + unsigned long flags; - spin_lock_irqsave(&adapter->cmdq_free.lock.lock, - adapter->cmdq_free.lock.flags); - spin_lock_irqsave(&adapter->cmdq_done.lock.lock, - adapter->cmdq_done.lock.flags); + spin_lock_irqsave(&adapter->cmdq_free.lock, flags); + spin_lock_irqsave(&adapter->cmdq_done.lock, flags); outstanding = adapter->cmdq_all.count - adapter->cmdq_done.count; outstanding -= adapter->cmdq_free.count; hcmd = adapter->cmdq_all.head; @@ -1429,40 +1426,40 @@ static void slic_cmdq_reset(struct adapter *adapter) "free_count %d != all count %d\n", adapter->cmdq_free.count, adapter->cmdq_all.count); } - spin_unlock_irqrestore(&adapter->cmdq_done.lock.lock, - adapter->cmdq_done.lock.flags); - spin_unlock_irqrestore(&adapter->cmdq_free.lock.lock, - adapter->cmdq_free.lock.flags); + spin_unlock_irqrestore(&adapter->cmdq_done.lock, flags); + spin_unlock_irqrestore(&adapter->cmdq_free.lock, flags); } static void slic_cmdq_getdone(struct adapter *adapter) { struct slic_cmdqueue *done_cmdq = &adapter->cmdq_done; struct slic_cmdqueue *free_cmdq = &adapter->cmdq_free; + unsigned long flags; - spin_lock_irqsave(&done_cmdq->lock.lock, done_cmdq->lock.flags); + spin_lock_irqsave(&done_cmdq->lock, flags); free_cmdq->head = done_cmdq->head; free_cmdq->count = done_cmdq->count; done_cmdq->head = NULL; done_cmdq->tail = NULL; done_cmdq->count = 0; - spin_unlock_irqrestore(&done_cmdq->lock.lock, done_cmdq->lock.flags); + spin_unlock_irqrestore(&done_cmdq->lock, flags); } static struct slic_hostcmd *slic_cmdq_getfree(struct adapter *adapter) { struct slic_cmdqueue *cmdq = &adapter->cmdq_free; struct slic_hostcmd *cmd = NULL; + unsigned long flags; lock_and_retry: - spin_lock_irqsave(&cmdq->lock.lock, cmdq->lock.flags); + spin_lock_irqsave(&cmdq->lock, flags); retry: cmd = cmdq->head; if (cmd) { cmdq->head = cmd->next; cmdq->count--; - spin_unlock_irqrestore(&cmdq->lock.lock, cmdq->lock.flags); + spin_unlock_irqrestore(&cmdq->lock, flags); } else { slic_cmdq_getdone(adapter); cmd = cmdq->head; @@ -1471,8 +1468,7 @@ retry: } else { u32 *pageaddr; - spin_unlock_irqrestore(&cmdq->lock.lock, - cmdq->lock.flags); + spin_unlock_irqrestore(&cmdq->lock, flags); pageaddr = slic_cmdqmem_addpage(adapter); if (pageaddr) { slic_cmdq_addcmdpage(adapter, pageaddr); @@ -1488,14 +1484,14 @@ static void slic_cmdq_putdone_irq(struct adapter *adapter, { struct slic_cmdqueue *cmdq = &adapter->cmdq_done; - spin_lock(&cmdq->lock.lock); + spin_lock(&cmdq->lock); cmd->busy = 0; cmd->next = cmdq->head; cmdq->head = cmd; cmdq->count++; if ((adapter->xmitq_full) && (cmdq->count > 10)) netif_wake_queue(adapter->netdev); - spin_unlock(&cmdq->lock.lock); + spin_unlock(&cmdq->lock); } static int slic_rcvqueue_fill(struct adapter *adapter) @@ -2250,21 +2246,20 @@ static void slic_adapter_freeresources(struct adapter *adapter) adapter->rcv_unicasts = 0; } -static int slic_adapter_allocresources(struct adapter *adapter) +static int slic_adapter_allocresources(struct adapter *adapter, + unsigned long *flags) { if (!adapter->intrregistered) { int retval; - spin_unlock_irqrestore(&slic_global.driver_lock.lock, - slic_global.driver_lock.flags); + spin_unlock_irqrestore(&slic_global.driver_lock, *flags); retval = request_irq(adapter->netdev->irq, &slic_interrupt, IRQF_SHARED, adapter->netdev->name, adapter->netdev); - spin_lock_irqsave(&slic_global.driver_lock.lock, - slic_global.driver_lock.flags); + spin_lock_irqsave(&slic_global.driver_lock, *flags); if (retval) { dev_err(&adapter->netdev->dev, @@ -2283,7 +2278,7 @@ static int slic_adapter_allocresources(struct adapter *adapter) * Perform initialization of our slic interface. * */ -static int slic_if_init(struct adapter *adapter) +static int slic_if_init(struct adapter *adapter, unsigned long *flags) { struct sliccard *card = adapter->card; struct net_device *dev = adapter->netdev; @@ -2311,7 +2306,7 @@ static int slic_if_init(struct adapter *adapter) if (dev->flags & IFF_MULTICAST) adapter->macopts |= MAC_MCAST; } - rc = slic_adapter_allocresources(adapter); + rc = slic_adapter_allocresources(adapter, flags); if (rc) { dev_err(&dev->dev, "slic_adapter_allocresources FAILED %x\n", rc); @@ -2336,11 +2331,11 @@ static int slic_if_init(struct adapter *adapter) mdelay(1); if (!adapter->isp_initialized) { + unsigned long flags; pshmem = (struct slic_shmem *)(unsigned long) adapter->phys_shmem; - spin_lock_irqsave(&adapter->bit64reglock.lock, - adapter->bit64reglock.flags); + spin_lock_irqsave(&adapter->bit64reglock, flags); #if BITS_PER_LONG == 64 slic_reg32_write(&slic_regs->slic_addr_upper, @@ -2352,8 +2347,7 @@ static int slic_if_init(struct adapter *adapter) slic_reg32_write(&slic_regs->slic_isp, (u32)&pshmem->isr, FLUSH); #endif - spin_unlock_irqrestore(&adapter->bit64reglock.lock, - adapter->bit64reglock.flags); + spin_unlock_irqrestore(&adapter->bit64reglock, flags); adapter->isp_initialized = 1; } @@ -2396,18 +2390,18 @@ static int slic_entry_open(struct net_device *dev) { struct adapter *adapter = netdev_priv(dev); struct sliccard *card = adapter->card; + unsigned long flags; int status; netif_stop_queue(adapter->netdev); - spin_lock_irqsave(&slic_global.driver_lock.lock, - slic_global.driver_lock.flags); + spin_lock_irqsave(&slic_global.driver_lock, flags); if (!adapter->activated) { card->adapters_activated++; slic_global.num_slic_ports_active++; adapter->activated = 1; } - status = slic_if_init(adapter); + status = slic_if_init(adapter, &flags); if (status != 0) { if (adapter->activated) { @@ -2421,8 +2415,7 @@ static int slic_entry_open(struct net_device *dev) card->master = adapter; spin_unlock: - spin_unlock_irqrestore(&slic_global.driver_lock.lock, - slic_global.driver_lock.flags); + spin_unlock_irqrestore(&slic_global.driver_lock, flags); return status; } @@ -2481,9 +2474,9 @@ static int slic_entry_halt(struct net_device *dev) struct adapter *adapter = netdev_priv(dev); struct sliccard *card = adapter->card; __iomem struct slic_regs *slic_regs = adapter->slic_regs; + unsigned long flags; - spin_lock_irqsave(&slic_global.driver_lock.lock, - slic_global.driver_lock.flags); + spin_lock_irqsave(&slic_global.driver_lock, flags); netif_stop_queue(adapter->netdev); adapter->state = ADAPT_DOWN; adapter->linkstate = LINK_DOWN; @@ -2512,8 +2505,7 @@ static int slic_entry_halt(struct net_device *dev) slic_card_init(card, adapter); #endif - spin_unlock_irqrestore(&slic_global.driver_lock.lock, - slic_global.driver_lock.flags); + spin_unlock_irqrestore(&slic_global.driver_lock, flags); return 0; } @@ -2663,6 +2655,7 @@ static int slic_card_init(struct sliccard *card, struct adapter *adapter) unsigned char oemfruformat; struct atk_fru *patkfru; union oemfru *poemfru; + unsigned long flags; /* Reset everything except PCI configuration space */ slic_soft_reset(adapter); @@ -2693,14 +2686,12 @@ static int slic_card_init(struct sliccard *card, struct adapter *adapter) pshmem = (struct slic_shmem *)(unsigned long) adapter->phys_shmem; - spin_lock_irqsave(&adapter->bit64reglock.lock, - adapter->bit64reglock.flags); + spin_lock_irqsave(&adapter->bit64reglock, flags); 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, - adapter->bit64reglock.flags); + spin_unlock_irqrestore(&adapter->bit64reglock, flags); status = slic_config_get(adapter, phys_configl, phys_configh); if (status) { @@ -2854,7 +2845,7 @@ static void slic_init_driver(void) { if (slic_first_init) { slic_first_init = 0; - spin_lock_init(&slic_global.driver_lock.lock); + spin_lock_init(&slic_global.driver_lock); } } @@ -2880,11 +2871,11 @@ static void slic_init_adapter(struct net_device *netdev, adapter->chipid = chip_idx; adapter->port = 0; /*adapter->functionnumber;*/ adapter->cardindex = adapter->port; - spin_lock_init(&adapter->upr_lock.lock); - spin_lock_init(&adapter->bit64reglock.lock); - spin_lock_init(&adapter->adapter_lock.lock); - spin_lock_init(&adapter->reset_lock.lock); - spin_lock_init(&adapter->handle_lock.lock); + spin_lock_init(&adapter->upr_lock); + spin_lock_init(&adapter->bit64reglock); + spin_lock_init(&adapter->adapter_lock); + spin_lock_init(&adapter->reset_lock); + spin_lock_init(&adapter->handle_lock); adapter->card_size = 1; /* From 36bf51acc89d113f101e40f40af4ab53fbf5b60a Mon Sep 17 00:00:00 2001 From: David Matlack Date: Mon, 11 May 2015 20:40:36 -0700 Subject: [PATCH 0458/1163] staging: slicoss: fix occasionally writing out only half of a dma address curaddrupper caches the last written upper 32-bits of a dma address (the device has one register for the upper 32-bits of all dma address registers). The problem is, not every dma address write checks and sets curaddrupper. This causes the driver to occasionally not write the upper 32-bits of a dma address to the device when it really should. I've seen this manifest particularly when the driver is trying to read config data from the device (RCONFIG) in order to checksum the device's eeprom. Since the device writes its config data to the wrong DMA address the driver reads 0 as the eeprom size and the eeprom checksum fails. This patch fixes the issue by removing curaddrupper and always writing the upper 32-bits of dma addresses. Signed-off-by: David Matlack Signed-off-by: Greg Kroah-Hartman --- drivers/staging/slicoss/slic.h | 1 - drivers/staging/slicoss/slicoss.c | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h index 5b23254f811a..67a8c9eb2dca 100644 --- a/drivers/staging/slicoss/slic.h +++ b/drivers/staging/slicoss/slic.h @@ -414,7 +414,6 @@ struct adapter { u32 intrregistered; uint isp_initialized; uint gennumber; - u32 curaddrupper; struct slic_shmem *pshmem; dma_addr_t phys_shmem; u32 isrcopy; diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index 39c140ccdcbb..5f34ebbf7b31 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -147,10 +147,7 @@ static inline void slic_reg64_write(struct adapter *adapter, void __iomem *reg, unsigned long flags; spin_lock_irqsave(&adapter->bit64reglock, flags); - if (paddrh != adapter->curaddrupper) { - adapter->curaddrupper = paddrh; - writel(paddrh, regh); - } + writel(paddrh, regh); writel(value, reg); if (flush) mb(); From 01e537f73335339196be3ef2bbfe53c20a6cb200 Mon Sep 17 00:00:00 2001 From: Kuppuswamy Sathyanarayanan Date: Fri, 15 May 2015 16:42:56 -0700 Subject: [PATCH 0459/1163] iio: ltr501: Fix proximity threshold boundary check Currently, proximity sensor boundary check is done inside the switch block but outside the case statement.Since this code will never get executed, moved the check outside the switch case statement. 867 case IIO_PROXIMITY: 868 switch (dir) { // Following line has been moved outside the switch block. 869 if (val > LTR501_PS_THRESH_MASK) 870 return -EINVAL; 871 case IIO_EV_DIR_RISING: Signed-off-by: Kuppuswamy Sathyanarayanan Signed-off-by: Jonathan Cameron --- drivers/iio/light/ltr501.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c index 280eff19b872..64e235281cef 100644 --- a/drivers/iio/light/ltr501.c +++ b/drivers/iio/light/ltr501.c @@ -865,9 +865,9 @@ static int ltr501_write_thresh(struct iio_dev *indio_dev, return -EINVAL; } case IIO_PROXIMITY: - switch (dir) { if (val > LTR501_PS_THRESH_MASK) return -EINVAL; + switch (dir) { case IIO_EV_DIR_RISING: mutex_lock(&data->lock_ps); ret = regmap_bulk_write(data->regmap, From b136faff9bc2f4adea050ed2119c01199f9a86a5 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 13 May 2015 15:06:09 -0300 Subject: [PATCH 0460/1163] iio: accel: hid-sensor-accel-3d: Fix memory leak in probe() 'channels' is allocated via kmemdup and it is never freed in the subsequent error paths. Use 'indio_dev->channels' directly instead, so that we avoid such memory leak problem. Signed-off-by: Fabio Estevam Reviewed-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/accel/hid-sensor-accel-3d.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c index ab711495d56e..ab1e238d5c75 100644 --- a/drivers/iio/accel/hid-sensor-accel-3d.c +++ b/drivers/iio/accel/hid-sensor-accel-3d.c @@ -299,7 +299,6 @@ static int hid_accel_3d_probe(struct platform_device *pdev) struct iio_dev *indio_dev; struct accel_3d_state *accel_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 accel_3d_state)); @@ -320,21 +319,21 @@ static int hid_accel_3d_probe(struct platform_device *pdev) return ret; } - channels = kmemdup(accel_3d_channels, sizeof(accel_3d_channels), - GFP_KERNEL); - if (!channels) { + indio_dev->channels = kmemdup(accel_3d_channels, + sizeof(accel_3d_channels), GFP_KERNEL); + if (!indio_dev->channels) { dev_err(&pdev->dev, "failed to duplicate channels\n"); return -ENOMEM; } - ret = accel_3d_parse_report(pdev, hsdev, channels, - HID_USAGE_SENSOR_ACCEL_3D, accel_state); + ret = accel_3d_parse_report(pdev, hsdev, + (struct iio_chan_spec *)indio_dev->channels, + HID_USAGE_SENSOR_ACCEL_3D, accel_state); if (ret) { dev_err(&pdev->dev, "failed to setup attributes\n"); goto error_free_dev_mem; } - indio_dev->channels = channels; indio_dev->num_channels = ARRAY_SIZE(accel_3d_channels); indio_dev->dev.parent = &pdev->dev; indio_dev->info = &accel_3d_info; From d8c9d23e29e3d758ea477adaa95e28cbf3556518 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 13 May 2015 15:06:10 -0300 Subject: [PATCH 0461/1163] iio: gyro: hid-sensor-gyro-3d: Fix memory leak in probe() 'channels' is allocated via kmemdup and it is never freed in the subsequent error paths. Use 'indio_dev->channels' directly instead, so that we avoid such memory leak problem. Signed-off-by: Fabio Estevam Reviewed-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/gyro/hid-sensor-gyro-3d.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c index 2e10799fe287..c67ce2ac4715 100644 --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c @@ -298,7 +298,6 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) struct iio_dev *indio_dev; struct gyro_3d_state *gyro_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(*gyro_state)); if (!indio_dev) @@ -317,21 +316,21 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) return ret; } - channels = kmemdup(gyro_3d_channels, sizeof(gyro_3d_channels), - GFP_KERNEL); - if (!channels) { + indio_dev->channels = kmemdup(gyro_3d_channels, + sizeof(gyro_3d_channels), GFP_KERNEL); + if (!indio_dev->channels) { dev_err(&pdev->dev, "failed to duplicate channels\n"); return -ENOMEM; } - ret = gyro_3d_parse_report(pdev, hsdev, channels, - HID_USAGE_SENSOR_GYRO_3D, gyro_state); + ret = gyro_3d_parse_report(pdev, hsdev, + (struct iio_chan_spec *)indio_dev->channels, + HID_USAGE_SENSOR_GYRO_3D, gyro_state); if (ret) { dev_err(&pdev->dev, "failed to setup attributes\n"); goto error_free_dev_mem; } - indio_dev->channels = channels; indio_dev->num_channels = ARRAY_SIZE(gyro_3d_channels); indio_dev->dev.parent = &pdev->dev; indio_dev->info = &gyro_3d_info; From 9ecdbed7903921f29adae63a3155814b453e7186 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 13 May 2015 15:06:11 -0300 Subject: [PATCH 0462/1163] iio: light: hid-sensor-als.c: Fix memory leak in probe() 'channels' is allocated via kmemdup and it is never freed in the subsequent error paths. Use 'indio_dev->channels' directly instead, so that we avoid such memory leak problem. Signed-off-by: Fabio Estevam Reviewed-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/light/hid-sensor-als.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c index cf13a18bafd0..8bb1f90ecd51 100644 --- a/drivers/iio/light/hid-sensor-als.c +++ b/drivers/iio/light/hid-sensor-als.c @@ -263,7 +263,6 @@ static int hid_als_probe(struct platform_device *pdev) struct iio_dev *indio_dev; struct als_state *als_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 als_state)); if (!indio_dev) @@ -281,20 +280,21 @@ static int hid_als_probe(struct platform_device *pdev) return ret; } - channels = kmemdup(als_channels, sizeof(als_channels), GFP_KERNEL); - if (!channels) { + indio_dev->channels = kmemdup(als_channels, + sizeof(als_channels), GFP_KERNEL); + if (!indio_dev->channels) { dev_err(&pdev->dev, "failed to duplicate channels\n"); return -ENOMEM; } - ret = als_parse_report(pdev, hsdev, channels, - HID_USAGE_SENSOR_ALS, als_state); + ret = als_parse_report(pdev, hsdev, + (struct iio_chan_spec *)indio_dev->channels, + HID_USAGE_SENSOR_ALS, als_state); if (ret) { dev_err(&pdev->dev, "failed to setup attributes\n"); goto error_free_dev_mem; } - indio_dev->channels = channels; indio_dev->num_channels = ARRAY_SIZE(als_channels); indio_dev->dev.parent = &pdev->dev; From 32ee56e306b09568619466efe109ab9722e89245 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 13 May 2015 15:06:12 -0300 Subject: [PATCH 0463/1163] iio: orientation: hid-sensor-incl-3d: Fix memory leak in probe() 'channels' is allocated via kmemdup and it is never freed in the subsequent error paths. Use 'indio_dev->channels' directly instead, so that we avoid such memory leak problem. Signed-off-by: Fabio Estevam Reviewed-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/orientation/hid-sensor-incl-3d.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c index e75c301988f2..fd1b3696ee42 100644 --- a/drivers/iio/orientation/hid-sensor-incl-3d.c +++ b/drivers/iio/orientation/hid-sensor-incl-3d.c @@ -315,7 +315,6 @@ static int hid_incl_3d_probe(struct platform_device *pdev) struct iio_dev *indio_dev; struct incl_3d_state *incl_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 incl_3d_state)); @@ -336,21 +335,22 @@ static int hid_incl_3d_probe(struct platform_device *pdev) return ret; } - channels = kmemdup(incl_3d_channels, sizeof(incl_3d_channels), - GFP_KERNEL); - if (!channels) { + indio_dev->channels = kmemdup(incl_3d_channels, + sizeof(incl_3d_channels), GFP_KERNEL); + if (!indio_dev->channels) { dev_err(&pdev->dev, "failed to duplicate channels\n"); return -ENOMEM; } - ret = incl_3d_parse_report(pdev, hsdev, channels, - HID_USAGE_SENSOR_INCLINOMETER_3D, incl_state); + ret = incl_3d_parse_report(pdev, hsdev, + (struct iio_chan_spec *)indio_dev->channels, + HID_USAGE_SENSOR_INCLINOMETER_3D, + incl_state); if (ret) { dev_err(&pdev->dev, "failed to setup attributes\n"); goto error_free_dev_mem; } - indio_dev->channels = channels; indio_dev->num_channels = ARRAY_SIZE(incl_3d_channels); indio_dev->dev.parent = &pdev->dev; indio_dev->info = &incl_3d_info; From 2bd04628435ff57a2fefa71e7d3e5c005db5c978 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 13 May 2015 15:06:13 -0300 Subject: [PATCH 0464/1163] iio: orientation: hid-sensor-rotation: Fix memory leak in probe() 'channels' is allocated via kmemdup and it is never freed in the subsequent error paths. Use 'indio_dev->channels' directly instead, so that we avoid such memory leak problem. Signed-off-by: Fabio Estevam Reviewed-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/orientation/hid-sensor-rotation.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c index 603fe1419581..b98b9d94d184 100644 --- a/drivers/iio/orientation/hid-sensor-rotation.c +++ b/drivers/iio/orientation/hid-sensor-rotation.c @@ -222,7 +222,6 @@ static int hid_dev_rot_probe(struct platform_device *pdev) 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)); @@ -243,21 +242,23 @@ static int hid_dev_rot_probe(struct platform_device *pdev) return ret; } - channels = devm_kmemdup(&pdev->dev, dev_rot_channels, - sizeof(dev_rot_channels), GFP_KERNEL); - if (!channels) { + indio_dev->channels = devm_kmemdup(&pdev->dev, dev_rot_channels, + sizeof(dev_rot_channels), + GFP_KERNEL); + if (!indio_dev->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); + ret = dev_rot_parse_report(pdev, hsdev, + (struct iio_chan_spec *)indio_dev->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; From c24e7daf823256c83ce3efe6fa9b9b8ab5b78480 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 13 May 2015 15:06:14 -0300 Subject: [PATCH 0465/1163] iio: pressure: hid-sensor-press: Fix memory leak in probe() 'channels' is allocated via kmemdup and it is never freed in the subsequent error paths. Use 'indio_dev->channels' directly instead, so that we avoid such memory leak problem. Signed-off-by: Fabio Estevam Reviewed-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/hid-sensor-press.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c index f3305d80c0b8..c060bd847f54 100644 --- a/drivers/iio/pressure/hid-sensor-press.c +++ b/drivers/iio/pressure/hid-sensor-press.c @@ -262,7 +262,6 @@ static int hid_press_probe(struct platform_device *pdev) struct iio_dev *indio_dev; struct press_state *press_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 press_state)); @@ -282,20 +281,21 @@ static int hid_press_probe(struct platform_device *pdev) return ret; } - channels = kmemdup(press_channels, sizeof(press_channels), GFP_KERNEL); - if (!channels) { + indio_dev->channels = kmemdup(press_channels, sizeof(press_channels), + GFP_KERNEL); + if (!indio_dev->channels) { dev_err(&pdev->dev, "failed to duplicate channels\n"); return -ENOMEM; } - ret = press_parse_report(pdev, hsdev, channels, - HID_USAGE_SENSOR_PRESSURE, press_state); + ret = press_parse_report(pdev, hsdev, + (struct iio_chan_spec *)indio_dev->channels, + HID_USAGE_SENSOR_PRESSURE, press_state); if (ret) { dev_err(&pdev->dev, "failed to setup attributes\n"); goto error_free_dev_mem; } - indio_dev->channels = channels; indio_dev->num_channels = ARRAY_SIZE(press_channels); indio_dev->dev.parent = &pdev->dev; From c06cee8d0865b7478484d9472155d8df83a10c06 Mon Sep 17 00:00:00 2001 From: Kuppuswamy Sathyanarayanan Date: Fri, 15 May 2015 18:23:21 -0700 Subject: [PATCH 0466/1163] iio: ltr501: Add light channel support Added support to calculate lux value from visible and IR spectrum adc count values. Also added IIO_LIGHT channel to enable user read the lux value directly from device using illuminance input ABI. Signed-off-by: Kuppuswamy Sathyanarayanan Signed-off-by: Jonathan Cameron --- drivers/iio/light/ltr501.c | 51 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c index 64e235281cef..1ef7d3773ab9 100644 --- a/drivers/iio/light/ltr501.c +++ b/drivers/iio/light/ltr501.c @@ -66,6 +66,9 @@ #define LTR501_REGMAP_NAME "ltr501_regmap" +#define LTR501_LUX_CONV(vis_coeff, vis_data, ir_coeff, ir_data) \ + ((vis_coeff * vis_data) - (ir_coeff * ir_data)) + static const int int_time_mapping[] = {100000, 50000, 200000, 400000}; static const struct reg_field reg_field_it = @@ -298,6 +301,29 @@ static int ltr501_ps_read_samp_period(struct ltr501_data *data, int *val) return IIO_VAL_INT; } +/* IR and visible spectrum coeff's are given in data sheet */ +static unsigned long ltr501_calculate_lux(u16 vis_data, u16 ir_data) +{ + unsigned long ratio, lux; + + if (vis_data == 0) + return 0; + + /* multiply numerator by 100 to avoid handling ratio < 1 */ + ratio = DIV_ROUND_UP(ir_data * 100, ir_data + vis_data); + + if (ratio < 45) + lux = LTR501_LUX_CONV(1774, vis_data, -1105, ir_data); + else if (ratio >= 45 && ratio < 64) + lux = LTR501_LUX_CONV(3772, vis_data, 1336, ir_data); + else if (ratio >= 64 && ratio < 85) + lux = LTR501_LUX_CONV(1690, vis_data, 169, ir_data); + else + lux = 0; + + return lux / 1000; +} + static int ltr501_drdy(struct ltr501_data *data, u8 drdy_mask) { int tries = 100; @@ -548,7 +574,14 @@ static const struct iio_event_spec ltr501_pxs_event_spec[] = { .num_event_specs = _evsize,\ } +#define LTR501_LIGHT_CHANNEL() { \ + .type = IIO_LIGHT, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), \ + .scan_index = -1, \ +} + static const struct iio_chan_spec ltr501_channels[] = { + LTR501_LIGHT_CHANNEL(), LTR501_INTENSITY_CHANNEL(0, LTR501_ALS_DATA0, IIO_MOD_LIGHT_BOTH, 0, ltr501_als_event_spec, ARRAY_SIZE(ltr501_als_event_spec)), @@ -576,6 +609,7 @@ static const struct iio_chan_spec ltr501_channels[] = { }; static const struct iio_chan_spec ltr301_channels[] = { + LTR501_LIGHT_CHANNEL(), LTR501_INTENSITY_CHANNEL(0, LTR501_ALS_DATA0, IIO_MOD_LIGHT_BOTH, 0, ltr501_als_event_spec, ARRAY_SIZE(ltr501_als_event_spec)), @@ -596,6 +630,23 @@ static int ltr501_read_raw(struct iio_dev *indio_dev, int ret, i; switch (mask) { + case IIO_CHAN_INFO_PROCESSED: + if (iio_buffer_enabled(indio_dev)) + return -EBUSY; + + switch (chan->type) { + case IIO_LIGHT: + mutex_lock(&data->lock_als); + ret = ltr501_read_als(data, buf); + mutex_unlock(&data->lock_als); + if (ret < 0) + return ret; + *val = ltr501_calculate_lux(le16_to_cpu(buf[1]), + le16_to_cpu(buf[0])); + return IIO_VAL_INT; + default: + return -EINVAL; + } case IIO_CHAN_INFO_RAW: if (iio_buffer_enabled(indio_dev)) return -EBUSY; From b87b0c0f81e8d11c881b726b886b7502ab67d884 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin-Solenikov Date: Thu, 14 May 2015 17:21:16 +0300 Subject: [PATCH 0467/1163] iio: add m62332 DAC driver m62332 is a simple 2-channel DAC used on several Sharp Zaurus boards to control LCD voltage, backlight and sound. The driver use regulators to control the reference voltage and enabling/disabling the DAC. Signed-off-by: Dmitry Eremin-Solenikov Signed-off-by: Jonathan Cameron --- drivers/iio/dac/Kconfig | 10 ++ drivers/iio/dac/Makefile | 1 + drivers/iio/dac/m62332.c | 269 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 280 insertions(+) create mode 100644 drivers/iio/dac/m62332.c diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig index 13471a76e5bf..e701e28fb1cd 100644 --- a/drivers/iio/dac/Kconfig +++ b/drivers/iio/dac/Kconfig @@ -142,6 +142,16 @@ config AD7303 To compile this driver as module choose M here: the module will be called ad7303. +config M62332 + tristate "Mitsubishi M62332 DAC driver" + depends on I2C + help + If you say yes here you get support for the Mitsubishi M62332 + (I2C 8-Bit DACs with rail-to-rail outputs). + + This driver can also be built as a module. If so, the module + will be called m62332. + config MAX517 tristate "Maxim MAX517/518/519/520/521 DAC driver" depends on I2C diff --git a/drivers/iio/dac/Makefile b/drivers/iio/dac/Makefile index 52be7e1acf16..63ae05633e0c 100644 --- a/drivers/iio/dac/Makefile +++ b/drivers/iio/dac/Makefile @@ -16,6 +16,7 @@ obj-$(CONFIG_AD5764) += ad5764.o obj-$(CONFIG_AD5791) += ad5791.o obj-$(CONFIG_AD5686) += ad5686.o obj-$(CONFIG_AD7303) += ad7303.o +obj-$(CONFIG_M62332) += m62332.o obj-$(CONFIG_MAX517) += max517.o obj-$(CONFIG_MAX5821) += max5821.o obj-$(CONFIG_MCP4725) += mcp4725.o diff --git a/drivers/iio/dac/m62332.c b/drivers/iio/dac/m62332.c new file mode 100644 index 000000000000..c23d7fa889ee --- /dev/null +++ b/drivers/iio/dac/m62332.c @@ -0,0 +1,269 @@ +/* + * m62332.c - Support for Mitsubishi m62332 DAC + * + * Copyright (c) 2014 Dmitry Eremin-Solenikov + * + * Based on max517 driver: + * Copyright (C) 2010, 2011 Roland Stigge + * + * 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 + +#define M62332_CHANNELS 2 + +struct m62332_data { + struct i2c_client *client; + u16 vref_mv; + struct regulator *vcc; + struct mutex mutex; + u8 raw[M62332_CHANNELS]; +#ifdef CONFIG_PM_SLEEP + u8 save[M62332_CHANNELS]; +#endif +}; + +static int m62332_set_value(struct iio_dev *indio_dev, + u8 val, int channel) +{ + struct m62332_data *data = iio_priv(indio_dev); + struct i2c_client *client = data->client; + u8 outbuf[2]; + int res; + + if (val == data->raw[channel]) + return 0; + + outbuf[0] = channel; + outbuf[1] = val; + + mutex_lock(&data->mutex); + + if (val) { + res = regulator_enable(data->vcc); + if (res) + goto out; + } + + res = i2c_master_send(client, outbuf, 2); + if (res >= 0 && res != 2) + res = -EIO; + if (res < 0) + goto out; + + data->raw[channel] = val; + + if (!val) + regulator_disable(data->vcc); + + mutex_unlock(&data->mutex); + + return 0; + +out: + mutex_unlock(&data->mutex); + + return res; +} + +static int m62332_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long m) +{ + struct m62332_data *data = iio_priv(indio_dev); + + switch (m) { + case IIO_CHAN_INFO_SCALE: + /* Corresponds to Vref / 2^(bits) */ + *val = data->vref_mv; + *val2 = 8; + return IIO_VAL_FRACTIONAL_LOG2; + case IIO_CHAN_INFO_RAW: + *val = data->raw[chan->channel]; + return IIO_VAL_INT; + case IIO_CHAN_INFO_OFFSET: + *val = 1; + return IIO_VAL_INT; + default: + break; + } + return -EINVAL; +} + +static int m62332_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int val, int val2, long mask) +{ + int ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + if (val < 0 || val > 255) + return -EINVAL; + + ret = m62332_set_value(indio_dev, val, chan->channel); + break; + default: + ret = -EINVAL; + break; + } + + return ret; +} + +#ifdef CONFIG_PM_SLEEP +static int m62332_suspend(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct m62332_data *data = iio_priv(indio_dev); + int ret; + + data->save[0] = data->raw[0]; + data->save[1] = data->raw[1]; + + ret = m62332_set_value(indio_dev, 0, 0); + if (ret < 0) + return ret; + + return m62332_set_value(indio_dev, 0, 1); +} + +static int m62332_resume(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct m62332_data *data = iio_priv(indio_dev); + int ret; + + ret = m62332_set_value(indio_dev, data->save[0], 0); + if (ret < 0) + return ret; + + return m62332_set_value(indio_dev, data->save[1], 1); +} + +static SIMPLE_DEV_PM_OPS(m62332_pm_ops, m62332_suspend, m62332_resume); +#define M62332_PM_OPS (&m62332_pm_ops) +#else +#define M62332_PM_OPS NULL +#endif + +static const struct iio_info m62332_info = { + .read_raw = m62332_read_raw, + .write_raw = m62332_write_raw, + .driver_module = THIS_MODULE, +}; + +#define M62332_CHANNEL(chan) { \ + .type = IIO_VOLTAGE, \ + .indexed = 1, \ + .output = 1, \ + .channel = (chan), \ + .datasheet_name = "CH" #chan, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_OFFSET), \ +} + +static const struct iio_chan_spec m62332_channels[M62332_CHANNELS] = { + M62332_CHANNEL(0), + M62332_CHANNEL(1) +}; + +static int m62332_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct m62332_data *data; + struct iio_dev *indio_dev; + int ret; + + 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; + + mutex_init(&data->mutex); + + data->vcc = devm_regulator_get(&client->dev, "VCC"); + if (IS_ERR(data->vcc)) + return PTR_ERR(data->vcc); + + /* establish that the iio_dev is a child of the i2c device */ + indio_dev->dev.parent = &client->dev; + + indio_dev->num_channels = M62332_CHANNELS; + indio_dev->channels = m62332_channels; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->info = &m62332_info; + + ret = regulator_get_voltage(data->vcc); + if (ret < 0) + return ret; + data->vref_mv = ret / 1000; /* mV */ + + ret = iio_map_array_register(indio_dev, client->dev.platform_data); + if (ret < 0) + return ret; + + ret = iio_device_register(indio_dev); + if (ret < 0) + goto err; + + return 0; + +err: + iio_map_array_unregister(indio_dev); + return ret; +} + +static int m62332_remove(struct i2c_client *client) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(client); + + iio_device_unregister(indio_dev); + iio_map_array_unregister(indio_dev); + + return 0; +} + +static const struct i2c_device_id m62332_id[] = { + { "m62332", }, + { } +}; +MODULE_DEVICE_TABLE(i2c, m62332_id); + +static struct i2c_driver m62332_driver = { + .driver = { + .name = "m62332", + .pm = M62332_PM_OPS, + }, + .probe = m62332_probe, + .remove = m62332_remove, + .id_table = m62332_id, +}; +module_i2c_driver(m62332_driver); + +MODULE_AUTHOR("Dmitry Eremin-Solenikov"); +MODULE_DESCRIPTION("M62332 8-bit DAC"); +MODULE_LICENSE("GPL v2"); From 63223c5f5c11b832586edca28cfc7d2850bc3e44 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 13 May 2015 16:04:44 +0200 Subject: [PATCH 0468/1163] iio: Replace printk in __iio_update_buffers with dev_dbg While more verbose error messages are useful for debugging we should really not put those error messages into the kernel log for normal errors that are already reported to the application via the error code, when running in non-debug mode. Otherwise application authors might expect that this is part of the ABI and to get the error they should scan the kernel log. Which would be rather error prone itself since there is no direct mapping between a operation and the error message so it is impossible to find out which error message belongs to which error. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-buffer.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index df919f44d513..1f91031aa460 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -663,7 +663,7 @@ static int __iio_update_buffers(struct iio_dev *indio_dev, if (indio_dev->setup_ops->preenable) { ret = indio_dev->setup_ops->preenable(indio_dev); if (ret) { - printk(KERN_ERR + dev_dbg(&indio_dev->dev, "Buffer not started: buffer preenable failed (%d)\n", ret); goto error_remove_inserted; } @@ -677,7 +677,7 @@ static int __iio_update_buffers(struct iio_dev *indio_dev, if (buffer->access->request_update) { ret = buffer->access->request_update(buffer); if (ret) { - printk(KERN_INFO + dev_dbg(&indio_dev->dev, "Buffer not started: buffer parameter update failed (%d)\n", ret); goto error_run_postdisable; } @@ -688,7 +688,9 @@ static int __iio_update_buffers(struct iio_dev *indio_dev, ->update_scan_mode(indio_dev, indio_dev->active_scan_mask); if (ret < 0) { - printk(KERN_INFO "Buffer not started: update scan mode failed (%d)\n", ret); + dev_dbg(&indio_dev->dev, + "Buffer not started: update scan mode failed (%d)\n", + ret); goto error_run_postdisable; } } @@ -702,7 +704,7 @@ static int __iio_update_buffers(struct iio_dev *indio_dev, } else { /* Should never be reached */ /* Can only occur on first buffer */ if (indio_dev->modes & INDIO_BUFFER_TRIGGERED) - pr_info("Buffer not started: no trigger\n"); + dev_dbg(&indio_dev->dev, "Buffer not started: no trigger\n"); ret = -EINVAL; goto error_run_postdisable; } @@ -710,7 +712,7 @@ static int __iio_update_buffers(struct iio_dev *indio_dev, if (indio_dev->setup_ops->postenable) { ret = indio_dev->setup_ops->postenable(indio_dev); if (ret) { - printk(KERN_INFO + dev_dbg(&indio_dev->dev, "Buffer not started: postenable failed (%d)\n", ret); indio_dev->currentmode = INDIO_DIRECT_MODE; if (indio_dev->setup_ops->postdisable) From 248be5aafc7cfe860b8f310bfc3f433e51f9fb11 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 13 May 2015 16:04:45 +0200 Subject: [PATCH 0469/1163] iio: __iio_update_buffers: Slightly refactor scan mask memory management Add a small helper function iio_free_scan_mask() that takes a mask and frees its memory if the scan masks for the device are dynamically allocated, otherwise does nothing. This means we don't have to open-code the same check over and over again in __iio_update_buffers. Also free compound_mask as soon a we are done using it. This constrains its usage to a specific region of the function will make further refactoring and splitting the function into smaller sub-parts more easier. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-buffer.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 1f91031aa460..2afe3dbd8d3d 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -575,6 +575,14 @@ static void iio_buffer_update_bytes_per_datum(struct iio_dev *indio_dev, buffer->access->set_bytes_per_datum(buffer, bytes); } +static void iio_free_scan_mask(struct iio_dev *indio_dev, + const unsigned long *mask) +{ + /* If the mask is dynamically allocated free it, otherwise do nothing */ + if (!indio_dev->available_scan_masks) + kfree(mask); +} + static int __iio_update_buffers(struct iio_dev *indio_dev, struct iio_buffer *insert_buffer, struct iio_buffer *remove_buffer) @@ -612,8 +620,7 @@ static int __iio_update_buffers(struct iio_dev *indio_dev, /* If no buffers in list, we are done */ if (list_empty(&indio_dev->buffer_list)) { indio_dev->currentmode = INDIO_DIRECT_MODE; - if (indio_dev->available_scan_masks == NULL) - kfree(old_mask); + iio_free_scan_mask(indio_dev, old_mask); return 0; } @@ -621,8 +628,7 @@ static int __iio_update_buffers(struct iio_dev *indio_dev, compound_mask = kcalloc(BITS_TO_LONGS(indio_dev->masklength), sizeof(long), GFP_KERNEL); if (compound_mask == NULL) { - if (indio_dev->available_scan_masks == NULL) - kfree(old_mask); + iio_free_scan_mask(indio_dev, old_mask); return -ENOMEM; } indio_dev->scan_timestamp = 0; @@ -637,6 +643,7 @@ static int __iio_update_buffers(struct iio_dev *indio_dev, iio_scan_mask_match(indio_dev->available_scan_masks, indio_dev->masklength, compound_mask); + kfree(compound_mask); if (indio_dev->active_scan_mask == NULL) { /* * Roll back. @@ -648,7 +655,6 @@ static int __iio_update_buffers(struct iio_dev *indio_dev, success = -EINVAL; } else { - kfree(compound_mask); ret = -EINVAL; return ret; } @@ -721,10 +727,7 @@ static int __iio_update_buffers(struct iio_dev *indio_dev, } } - if (indio_dev->available_scan_masks) - kfree(compound_mask); - else - kfree(old_mask); + iio_free_scan_mask(indio_dev, old_mask); return success; @@ -736,8 +739,8 @@ error_run_postdisable: error_remove_inserted: if (insert_buffer) iio_buffer_deactivate(insert_buffer); + iio_free_scan_mask(indio_dev, indio_dev->active_scan_mask); indio_dev->active_scan_mask = old_mask; - kfree(compound_mask); return ret; } From fcc1b2f57d89142acf6173a8e6ffb19f5f5ec876 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 13 May 2015 16:04:46 +0200 Subject: [PATCH 0470/1163] iio: __iio_update_buffers: Perform request_update() only for new buffers We only have to call the request_update() callback for a newly inserted buffer. The configuration of the already previously active buffers will not have changed. This also allows us to move the request_update() call to the beginning of __iio_update_buffers(), before any currently active buffers are stopped. This makes the error handling a lot easier since no changes were made to the buffer list and no rollback needs to be performed. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-buffer.c | 36 +++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 2afe3dbd8d3d..21ed3168b70b 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -575,6 +575,25 @@ static void iio_buffer_update_bytes_per_datum(struct iio_dev *indio_dev, buffer->access->set_bytes_per_datum(buffer, bytes); } +static int iio_buffer_request_update(struct iio_dev *indio_dev, + struct iio_buffer *buffer) +{ + int ret; + + iio_buffer_update_bytes_per_datum(indio_dev, buffer); + if (buffer->access->request_update) { + ret = buffer->access->request_update(buffer); + if (ret) { + dev_dbg(&indio_dev->dev, + "Buffer not started: buffer parameter update failed (%d)\n", + ret); + return ret; + } + } + + return 0; +} + static void iio_free_scan_mask(struct iio_dev *indio_dev, const unsigned long *mask) { @@ -593,6 +612,12 @@ static int __iio_update_buffers(struct iio_dev *indio_dev, unsigned long *compound_mask; const unsigned long *old_mask; + if (insert_buffer) { + ret = iio_buffer_request_update(indio_dev, insert_buffer); + if (ret) + return ret; + } + /* Wind down existing buffers - iff there are any */ if (!list_empty(&indio_dev->buffer_list)) { if (indio_dev->setup_ops->predisable) { @@ -678,17 +703,6 @@ static int __iio_update_buffers(struct iio_dev *indio_dev, iio_compute_scan_bytes(indio_dev, indio_dev->active_scan_mask, indio_dev->scan_timestamp); - list_for_each_entry(buffer, &indio_dev->buffer_list, buffer_list) { - iio_buffer_update_bytes_per_datum(indio_dev, buffer); - if (buffer->access->request_update) { - ret = buffer->access->request_update(buffer); - if (ret) { - dev_dbg(&indio_dev->dev, - "Buffer not started: buffer parameter update failed (%d)\n", ret); - goto error_run_postdisable; - } - } - } if (indio_dev->info->update_scan_mode) { ret = indio_dev->info ->update_scan_mode(indio_dev, From eb2191017e3063c7269be81e1543ccd157bb1e8b Mon Sep 17 00:00:00 2001 From: Vlad Dogaru Date: Wed, 13 May 2015 16:30:08 +0300 Subject: [PATCH 0471/1163] iio: gyro: bmg160: remove redundant field Replace the 'timestamp' field in struct bmg160_data with the identically named field in iio_poll_func and with calls to iio_get_time_ns(). The reported timestamps may be slightly different, but the advantage is that we no longer assume that the buffer of bmg160 is triggered by its own trigger. Signed-off-by: Vlad Dogaru Signed-off-by: Jonathan Cameron --- drivers/iio/gyro/bmg160.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/iio/gyro/bmg160.c b/drivers/iio/gyro/bmg160.c index 4415f55d26b6..d36af62ea230 100644 --- a/drivers/iio/gyro/bmg160.c +++ b/drivers/iio/gyro/bmg160.c @@ -108,7 +108,6 @@ struct bmg160_data { int slope_thres; bool dready_trigger_on; bool motion_trigger_on; - int64_t timestamp; }; enum bmg160_axis { @@ -835,7 +834,7 @@ static irqreturn_t bmg160_trigger_handler(int irq, void *p) mutex_unlock(&data->mutex); iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, - data->timestamp); + pf->timestamp); err: iio_trigger_notify_done(indio_dev->trig); @@ -938,21 +937,21 @@ static irqreturn_t bmg160_event_handler(int irq, void *private) IIO_MOD_X, IIO_EV_TYPE_ROC, dir), - data->timestamp); + iio_get_time_ns()); if (ret & BMG160_ANY_MOTION_BIT_Y) iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL, 0, IIO_MOD_Y, IIO_EV_TYPE_ROC, dir), - data->timestamp); + iio_get_time_ns()); if (ret & BMG160_ANY_MOTION_BIT_Z) iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL, 0, IIO_MOD_Z, IIO_EV_TYPE_ROC, dir), - data->timestamp); + iio_get_time_ns()); ack_intr_status: if (!data->dready_trigger_on) { @@ -973,8 +972,6 @@ static irqreturn_t bmg160_data_rdy_trig_poll(int irq, void *private) struct iio_dev *indio_dev = private; struct bmg160_data *data = iio_priv(indio_dev); - data->timestamp = iio_get_time_ns(); - if (data->dready_trigger_on) iio_trigger_poll(data->dready_trig); else if (data->motion_trigger_on) @@ -1105,7 +1102,7 @@ static int bmg160_probe(struct i2c_client *client, } ret = iio_triggered_buffer_setup(indio_dev, - NULL, + iio_pollfunc_store_time, bmg160_trigger_handler, NULL); if (ret < 0) { From 00e0c8e8e865730b34f2e5f46b5d745f74346065 Mon Sep 17 00:00:00 2001 From: Vlad Dogaru Date: Wed, 13 May 2015 16:30:09 +0300 Subject: [PATCH 0472/1163] iio: gyro: bmg160: decouple buffer and triggers Make it possible to use buffering with an external trigger, such as one based on sysfs or hrtimer. Signed-off-by: Vlad Dogaru Signed-off-by: Jonathan Cameron --- drivers/iio/gyro/bmg160.c | 56 ++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/drivers/iio/gyro/bmg160.c b/drivers/iio/gyro/bmg160.c index d36af62ea230..460bf715d541 100644 --- a/drivers/iio/gyro/bmg160.c +++ b/drivers/iio/gyro/bmg160.c @@ -737,17 +737,6 @@ static int bmg160_write_event_config(struct iio_dev *indio_dev, return 0; } -static int bmg160_validate_trigger(struct iio_dev *indio_dev, - struct iio_trigger *trig) -{ - struct bmg160_data *data = iio_priv(indio_dev); - - if (data->dready_trig != trig && data->motion_trig != trig) - return -EINVAL; - - return 0; -} - static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("100 200 400 1000 2000"); static IIO_CONST_ATTR(in_anglvel_scale_available, @@ -809,7 +798,6 @@ static const struct iio_info bmg160_info = { .write_event_value = bmg160_write_event, .write_event_config = bmg160_write_event_config, .read_event_config = bmg160_read_event_config, - .validate_trigger = bmg160_validate_trigger, .driver_module = THIS_MODULE, }; @@ -984,6 +972,27 @@ static irqreturn_t bmg160_data_rdy_trig_poll(int irq, void *private) } +static int bmg160_buffer_preenable(struct iio_dev *indio_dev) +{ + struct bmg160_data *data = iio_priv(indio_dev); + + return bmg160_set_power_state(data, true); +} + +static int bmg160_buffer_postdisable(struct iio_dev *indio_dev) +{ + struct bmg160_data *data = iio_priv(indio_dev); + + return bmg160_set_power_state(data, false); +} + +static const struct iio_buffer_setup_ops bmg160_buffer_setup_ops = { + .preenable = bmg160_buffer_preenable, + .postenable = iio_triggered_buffer_postenable, + .predisable = iio_triggered_buffer_predisable, + .postdisable = bmg160_buffer_postdisable, +}; + static int bmg160_gpio_probe(struct i2c_client *client, struct bmg160_data *data) @@ -1100,16 +1109,16 @@ static int bmg160_probe(struct i2c_client *client, data->motion_trig = NULL; goto err_trigger_unregister; } + } - ret = iio_triggered_buffer_setup(indio_dev, - iio_pollfunc_store_time, - bmg160_trigger_handler, - NULL); - if (ret < 0) { - dev_err(&client->dev, - "iio triggered buffer setup failed\n"); - goto err_trigger_unregister; - } + ret = iio_triggered_buffer_setup(indio_dev, + iio_pollfunc_store_time, + bmg160_trigger_handler, + &bmg160_buffer_setup_ops); + if (ret < 0) { + dev_err(&client->dev, + "iio triggered buffer setup failed\n"); + goto err_trigger_unregister; } ret = iio_device_register(indio_dev); @@ -1132,8 +1141,7 @@ static int bmg160_probe(struct i2c_client *client, err_iio_unregister: iio_device_unregister(indio_dev); err_buffer_cleanup: - if (data->dready_trig) - iio_triggered_buffer_cleanup(indio_dev); + iio_triggered_buffer_cleanup(indio_dev); err_trigger_unregister: if (data->dready_trig) iio_trigger_unregister(data->dready_trig); @@ -1153,9 +1161,9 @@ static int bmg160_remove(struct i2c_client *client) pm_runtime_put_noidle(&client->dev); iio_device_unregister(indio_dev); + iio_triggered_buffer_cleanup(indio_dev); if (data->dready_trig) { - iio_triggered_buffer_cleanup(indio_dev); iio_trigger_unregister(data->dready_trig); iio_trigger_unregister(data->motion_trig); } From ecabae71319695fd1434f72840dd00898cb1c4dd Mon Sep 17 00:00:00 2001 From: Martin Fuzzey Date: Wed, 13 May 2015 12:26:38 +0200 Subject: [PATCH 0473/1163] iio: mma8452: Initialise before activating Many of the hardware configuration registers may only be modified while the device is inactive. Currently the probe code first activates the device and then modifies the registers (eg to set the scale). This doesn't actually work but is not noticed since the scale used is the default value. While at it also issue a hardware reset command at probe time. Signed-off-by: Martin Fuzzey Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma8452.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index 5b80657883bb..001a7dbc863c 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -32,6 +32,7 @@ #define MMA8452_OFF_Z 0x31 #define MMA8452_CTRL_REG1 0x2a #define MMA8452_CTRL_REG2 0x2b +#define MMA8452_CTRL_REG2_RST BIT(6) #define MMA8452_STATUS_DRDY (BIT(2) | BIT(1) | BIT(0)) @@ -335,6 +336,30 @@ static const struct iio_info mma8452_info = { static const unsigned long mma8452_scan_masks[] = {0x7, 0}; +static int mma8452_reset(struct i2c_client *client) +{ + int i; + int ret; + + ret = i2c_smbus_write_byte_data(client, MMA8452_CTRL_REG2, + MMA8452_CTRL_REG2_RST); + if (ret < 0) + return ret; + + for (i = 0; i < 10; i++) { + usleep_range(100, 200); + ret = i2c_smbus_read_byte_data(client, MMA8452_CTRL_REG2); + if (ret == -EIO) + continue; /* I2C comm reset */ + if (ret < 0) + return ret; + if (!(ret & MMA8452_CTRL_REG2_RST)) + return 0; + } + + return -ETIMEDOUT; +} + static int mma8452_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -365,10 +390,7 @@ static int mma8452_probe(struct i2c_client *client, 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); + ret = mma8452_reset(client); if (ret < 0) return ret; @@ -378,6 +400,13 @@ static int mma8452_probe(struct i2c_client *client, if (ret < 0) return ret; + 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; + ret = iio_triggered_buffer_setup(indio_dev, NULL, mma8452_trigger_handler, NULL); if (ret < 0) From 2a17698c0e23f3548db2c698e0da80a00814361d Mon Sep 17 00:00:00 2001 From: Martin Fuzzey Date: Wed, 13 May 2015 12:26:40 +0200 Subject: [PATCH 0474/1163] iio: mma8452: Add access to registers via DebugFS Signed-off-by: Martin Fuzzey Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma8452.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index 001a7dbc863c..877ce2954196 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -34,6 +34,8 @@ #define MMA8452_CTRL_REG2 0x2b #define MMA8452_CTRL_REG2_RST BIT(6) +#define MMA8452_MAX_REG 0x31 + #define MMA8452_STATUS_DRDY (BIT(2) | BIT(1) | BIT(0)) #define MMA8452_CTRL_DR_MASK (BIT(5) | BIT(4) | BIT(3)) @@ -292,6 +294,28 @@ done: return IRQ_HANDLED; } +static int mma8452_reg_access_dbg(struct iio_dev *indio_dev, + unsigned reg, unsigned writeval, + unsigned *readval) +{ + int ret; + struct mma8452_data *data = iio_priv(indio_dev); + + if (reg > MMA8452_MAX_REG) + return -EINVAL; + + if (!readval) + return mma8452_change_config(data, reg, writeval); + + ret = i2c_smbus_read_byte_data(data->client, reg); + if (ret < 0) + return ret; + + *readval = ret; + + return 0; +} + #define MMA8452_CHANNEL(axis, idx) { \ .type = IIO_ACCEL, \ .modified = 1, \ @@ -331,6 +355,7 @@ static const struct iio_info mma8452_info = { .attrs = &mma8452_group, .read_raw = &mma8452_read_raw, .write_raw = &mma8452_write_raw, + .debugfs_reg_access = &mma8452_reg_access_dbg, .driver_module = THIS_MODULE, }; From 3f7f642b9bc46453e1435e8b67f1c4f7949be7ff Mon Sep 17 00:00:00 2001 From: Martin Fuzzey Date: Wed, 13 May 2015 12:26:42 +0200 Subject: [PATCH 0475/1163] iio: core: add high pass filter attributes Add a high pass filter attribute for measurements (like the existing low pass) Also add both high and low pass attributes for events. Signed-off-by: Martin Fuzzey Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 30 +++++++++++++++++++++++++ drivers/iio/industrialio-core.c | 2 ++ drivers/iio/industrialio-event.c | 2 ++ include/linux/iio/iio.h | 1 + include/linux/iio/types.h | 2 ++ 5 files changed, 37 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index e46c71fbd047..f66262c64e2f 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -420,6 +420,16 @@ Description: to the underlying data channel, then this parameter gives the 3dB frequency of the filter in Hz. +What: /sys/.../in_accel_filter_high_pass_3db_frequency +What: /sys/.../in_anglvel_filter_high_pass_3db_frequency +What: /sys/.../in_magn_filter_high_pass_3db_frequency +KernelVersion: 4.2 +Contact: linux-iio@vger.kernel.org +Description: + If a known or controllable high pass filter is applied + to the underlying data channel, then this parameter + gives the 3dB frequency of the filter in Hz. + What: /sys/bus/iio/devices/iio:deviceX/out_voltageY_raw What: /sys/bus/iio/devices/iio:deviceX/out_altvoltageY_raw KernelVersion: 2.6.37 @@ -880,6 +890,26 @@ Description: met before an event is generated. If direction is not specified then this period applies to both directions. +What: /sys/.../events/in_accel_thresh_rising_low_pass_filter_3db +What: /sys/.../events/in_anglvel_thresh_rising_low_pass_filter_3db +What: /sys/.../events/in_magn_thresh_rising_low_pass_filter_3db +KernelVersion: 4.2 +Contact: linux-iio@vger.kernel.org +Description: + If a low pass filter can be applied to the event generation + this property gives its 3db frequency in Hz. + A value of zero disables the filter. + +What: /sys/.../events/in_accel_thresh_rising_high_pass_filter_3db +What: /sys/.../events/in_anglvel_thresh_rising_high_pass_filter_3db +What: /sys/.../events/in_magn_thresh_rising_high_pass_filter_3db +KernelVersion: 4.2 +Contact: linux-iio@vger.kernel.org +Description: + If a high pass filter can be applied to the event generation + this property gives its 3db frequency in Hz. + A value of zero disables the filter. + What: /sys/.../events/in_activity_still_thresh_rising_en What: /sys/.../events/in_activity_still_thresh_falling_en What: /sys/.../events/in_activity_walking_thresh_rising_en diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index dfa81db3b910..9688a88b6198 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -117,6 +117,8 @@ static const char * const iio_chan_info_postfix[] = { [IIO_CHAN_INFO_AVERAGE_RAW] = "mean_raw", [IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY] = "filter_low_pass_3db_frequency", + [IIO_CHAN_INFO_HIGH_PASS_FILTER_3DB_FREQUENCY] + = "filter_high_pass_3db_frequency", [IIO_CHAN_INFO_SAMP_FREQ] = "sampling_frequency", [IIO_CHAN_INFO_FREQUENCY] = "frequency", [IIO_CHAN_INFO_PHASE] = "phase", diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c index a99692ba91bc..894d8137c4cf 100644 --- a/drivers/iio/industrialio-event.c +++ b/drivers/iio/industrialio-event.c @@ -211,6 +211,8 @@ static const char * const iio_ev_info_text[] = { [IIO_EV_INFO_VALUE] = "value", [IIO_EV_INFO_HYSTERESIS] = "hysteresis", [IIO_EV_INFO_PERIOD] = "period", + [IIO_EV_INFO_HIGH_PASS_FILTER_3DB] = "high_pass_filter_3db", + [IIO_EV_INFO_LOW_PASS_FILTER_3DB] = "low_pass_filter_3db", }; static enum iio_event_direction iio_ev_attr_dir(struct iio_dev_attr *attr) diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 058441da4984..f79148261d16 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -32,6 +32,7 @@ enum iio_chan_info_enum { IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW, IIO_CHAN_INFO_AVERAGE_RAW, IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY, + IIO_CHAN_INFO_HIGH_PASS_FILTER_3DB_FREQUENCY, IIO_CHAN_INFO_SAMP_FREQ, IIO_CHAN_INFO_FREQUENCY, IIO_CHAN_INFO_PHASE, diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h index 942b6de68e2f..32b579525004 100644 --- a/include/linux/iio/types.h +++ b/include/linux/iio/types.h @@ -17,6 +17,8 @@ enum iio_event_info { IIO_EV_INFO_VALUE, IIO_EV_INFO_HYSTERESIS, IIO_EV_INFO_PERIOD, + IIO_EV_INFO_HIGH_PASS_FILTER_3DB, + IIO_EV_INFO_LOW_PASS_FILTER_3DB, }; #define IIO_VAL_INT 1 From c16bff4844ffa678ba0c9d077e9797506924ccdd Mon Sep 17 00:00:00 2001 From: Vlad Dogaru Date: Tue, 12 May 2015 17:03:24 +0300 Subject: [PATCH 0476/1163] iio: accel: bmc150: decouple buffer and triggers If the interrupt pins are not available, we should still be able to use the buffer with an external trigger. However, we won't be able to use the hardware fifo since we have no means of signalling when the watermark is reached. I also added a comment to indicate that the timestamps in bmc150_accel_data are only used for hardware fifo, since initially I was confused about duplication with pf->timestamp. Signed-off-by: Vlad Dogaru Reviewed-by: Octavian Purdila Reviewed-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/accel/bmc150-accel.c | 55 ++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/drivers/iio/accel/bmc150-accel.c b/drivers/iio/accel/bmc150-accel.c index 73e87739d219..4e70f51c2370 100644 --- a/drivers/iio/accel/bmc150-accel.c +++ b/drivers/iio/accel/bmc150-accel.c @@ -196,7 +196,7 @@ struct bmc150_accel_data { u32 slope_thres; u32 range; int ev_enable_state; - int64_t timestamp, old_timestamp; + int64_t timestamp, old_timestamp; /* Only used in hw fifo mode. */ const struct bmc150_accel_chip_info *chip_info; }; @@ -1183,7 +1183,6 @@ static const struct iio_info bmc150_accel_info = { .write_event_value = bmc150_accel_write_event, .write_event_config = bmc150_accel_write_event_config, .read_event_config = bmc150_accel_read_event_config, - .validate_trigger = bmc150_accel_validate_trigger, .driver_module = THIS_MODULE, }; @@ -1222,7 +1221,7 @@ static irqreturn_t bmc150_accel_trigger_handler(int irq, void *p) mutex_unlock(&data->mutex); iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, - data->timestamp); + pf->timestamp); err_read: iio_trigger_notify_done(indio_dev->trig); @@ -1535,6 +1534,13 @@ static int bmc150_accel_fifo_set_mode(struct bmc150_accel_data *data) return ret; } +static int bmc150_accel_buffer_preenable(struct iio_dev *indio_dev) +{ + struct bmc150_accel_data *data = iio_priv(indio_dev); + + return bmc150_accel_set_power_state(data, true); +} + static int bmc150_accel_buffer_postenable(struct iio_dev *indio_dev) { struct bmc150_accel_data *data = iio_priv(indio_dev); @@ -1591,9 +1597,18 @@ out: return 0; } +static int bmc150_accel_buffer_postdisable(struct iio_dev *indio_dev) +{ + struct bmc150_accel_data *data = iio_priv(indio_dev); + + return bmc150_accel_set_power_state(data, false); +} + static const struct iio_buffer_setup_ops bmc150_accel_buffer_ops = { + .preenable = bmc150_accel_buffer_preenable, .postenable = bmc150_accel_buffer_postenable, .predisable = bmc150_accel_buffer_predisable, + .postdisable = bmc150_accel_buffer_postdisable, }; static int bmc150_accel_probe(struct i2c_client *client, @@ -1636,6 +1651,15 @@ static int bmc150_accel_probe(struct i2c_client *client, indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &bmc150_accel_info; + ret = iio_triggered_buffer_setup(indio_dev, + &iio_pollfunc_store_time, + bmc150_accel_trigger_handler, + &bmc150_accel_buffer_ops); + if (ret < 0) { + dev_err(&client->dev, "Failed: iio triggered buffer setup\n"); + return ret; + } + if (client->irq < 0) client->irq = bmc150_accel_gpio_probe(client, data); @@ -1648,7 +1672,7 @@ static int bmc150_accel_probe(struct i2c_client *client, BMC150_ACCEL_IRQ_NAME, indio_dev); if (ret) - return ret; + goto err_buffer_cleanup; /* * Set latched mode interrupt. While certain interrupts are @@ -1661,24 +1685,14 @@ static int bmc150_accel_probe(struct i2c_client *client, BMC150_ACCEL_INT_MODE_LATCH_RESET); if (ret < 0) { dev_err(&data->client->dev, "Error writing reg_int_rst_latch\n"); - return ret; + goto err_buffer_cleanup; } bmc150_accel_interrupts_setup(indio_dev, data); ret = bmc150_accel_triggers_setup(indio_dev, data); if (ret) - return ret; - - ret = iio_triggered_buffer_setup(indio_dev, - &iio_pollfunc_store_time, - bmc150_accel_trigger_handler, - &bmc150_accel_buffer_ops); - if (ret < 0) { - dev_err(&client->dev, - "Failed: iio triggered buffer setup\n"); - goto err_trigger_unregister; - } + goto err_buffer_cleanup; if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) || i2c_check_functionality(client->adapter, @@ -1692,7 +1706,7 @@ static int bmc150_accel_probe(struct i2c_client *client, ret = iio_device_register(indio_dev); if (ret < 0) { dev_err(&client->dev, "Unable to register iio device\n"); - goto err_buffer_cleanup; + goto err_trigger_unregister; } ret = pm_runtime_set_active(&client->dev); @@ -1708,11 +1722,10 @@ static int bmc150_accel_probe(struct i2c_client *client, err_iio_unregister: iio_device_unregister(indio_dev); -err_buffer_cleanup: - if (indio_dev->pollfunc) - iio_triggered_buffer_cleanup(indio_dev); err_trigger_unregister: bmc150_accel_unregister_triggers(data, BMC150_ACCEL_TRIGGERS - 1); +err_buffer_cleanup: + iio_triggered_buffer_cleanup(indio_dev); return ret; } @@ -1730,6 +1743,8 @@ static int bmc150_accel_remove(struct i2c_client *client) bmc150_accel_unregister_triggers(data, BMC150_ACCEL_TRIGGERS - 1); + iio_triggered_buffer_cleanup(indio_dev); + mutex_lock(&data->mutex); bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_DEEP_SUSPEND, 0); mutex_unlock(&data->mutex); From 90bad33acbd82437cbf54eb1cefa6f6153fab927 Mon Sep 17 00:00:00 2001 From: Tiberiu Breana Date: Tue, 12 May 2015 18:48:42 +0300 Subject: [PATCH 0477/1163] iio: accel: Add support for Sensortek STK8312 Minimal implementation of an IIO driver for the Sensortek STK8312 3-axis accelerometer. Datasheet: http://www.syi-group.com/uploadpic/data/201361817562681623.pdf Includes: - ACPI support; - read_raw for x,y,z axes; - reading and setting the scale (range) parameter. - power management Signed-off-by: Tiberiu Breana Signed-off-by: Jonathan Cameron --- drivers/iio/accel/Kconfig | 11 + drivers/iio/accel/Makefile | 2 + drivers/iio/accel/stk8312.c | 390 ++++++++++++++++++++++++++++++++++++ 3 files changed, 403 insertions(+) create mode 100644 drivers/iio/accel/stk8312.c diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig index 7c9a9a94a8ce..8bd8ccbe8187 100644 --- a/drivers/iio/accel/Kconfig +++ b/drivers/iio/accel/Kconfig @@ -136,4 +136,15 @@ config MMA9553 To compile this driver as a module, choose M here: the module will be called mma9553. + +config STK8312 + tristate "Sensortek STK8312 3-Axis Accelerometer Driver" + depends on I2C + help + Say yes here to get support for the Sensortek STK8312 3-axis + accelerometer. + + Choosing M will build the driver as a module. If so, the module + will be called stk8312. + endmenu diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile index 99d89e46cad1..8b327c19edef 100644 --- a/drivers/iio/accel/Makefile +++ b/drivers/iio/accel/Makefile @@ -14,6 +14,8 @@ obj-$(CONFIG_MMA9551_CORE) += mma9551_core.o obj-$(CONFIG_MMA9551) += mma9551.o obj-$(CONFIG_MMA9553) += mma9553.o +obj-$(CONFIG_STK8312) += stk8312.o + obj-$(CONFIG_IIO_SSP_SENSORS_COMMONS) += ssp_accel_sensor.o obj-$(CONFIG_IIO_ST_ACCEL_3AXIS) += st_accel.o diff --git a/drivers/iio/accel/stk8312.c b/drivers/iio/accel/stk8312.c new file mode 100644 index 000000000000..d211d9f3975b --- /dev/null +++ b/drivers/iio/accel/stk8312.c @@ -0,0 +1,390 @@ +/** + * Sensortek STK8312 3-Axis Accelerometer + * + * Copyright (c) 2015, Intel Corporation. + * + * 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. + * + * IIO driver for STK8312; 7-bit I2C address: 0x3D. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define STK8312_REG_XOUT 0x00 +#define STK8312_REG_YOUT 0x01 +#define STK8312_REG_ZOUT 0x02 +#define STK8312_REG_MODE 0x07 +#define STK8312_REG_STH 0x13 +#define STK8312_REG_RESET 0x20 +#define STK8312_REG_AFECTRL 0x24 +#define STK8312_REG_OTPADDR 0x3D +#define STK8312_REG_OTPDATA 0x3E +#define STK8312_REG_OTPCTRL 0x3F + +#define STK8312_MODE_ACTIVE 1 +#define STK8312_MODE_STANDBY 0 +#define STK8312_MODE_MASK 0x01 +#define STK8312_RNG_MASK 0xC0 +#define STK8312_RNG_SHIFT 6 +#define STK8312_READ_RETRIES 16 + +#define STK8312_DRIVER_NAME "stk8312" + +/* + * The accelerometer has two measurement ranges: + * + * -6g - +6g (8-bit, signed) + * -16g - +16g (8-bit, signed) + * + * scale1 = (6 + 6) * 9.81 / (2^8 - 1) = 0.4616 + * scale2 = (16 + 16) * 9.81 / (2^8 - 1) = 1.2311 + */ +#define STK8312_SCALE_AVAIL "0.4616 1.2311" + +static const int stk8312_scale_table[][2] = { + {0, 461600}, {1, 231100} +}; + +#define STK8312_ACCEL_CHANNEL(reg, axis) { \ + .type = IIO_ACCEL, \ + .address = reg, \ + .modified = 1, \ + .channel2 = IIO_MOD_##axis, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ +} + +static const struct iio_chan_spec stk8312_channels[] = { + STK8312_ACCEL_CHANNEL(STK8312_REG_XOUT, X), + STK8312_ACCEL_CHANNEL(STK8312_REG_YOUT, Y), + STK8312_ACCEL_CHANNEL(STK8312_REG_ZOUT, Z), +}; + +struct stk8312_data { + struct i2c_client *client; + struct mutex lock; + int range; + u8 mode; +}; + +static IIO_CONST_ATTR(in_accel_scale_available, STK8312_SCALE_AVAIL); + +static struct attribute *stk8312_attributes[] = { + &iio_const_attr_in_accel_scale_available.dev_attr.attr, + NULL, +}; + +static const struct attribute_group stk8312_attribute_group = { + .attrs = stk8312_attributes +}; + +static int stk8312_otp_init(struct stk8312_data *data) +{ + int ret; + int count = 10; + struct i2c_client *client = data->client; + + ret = i2c_smbus_write_byte_data(client, STK8312_REG_OTPADDR, 0x70); + if (ret < 0) + goto exit_err; + ret = i2c_smbus_write_byte_data(client, STK8312_REG_OTPCTRL, 0x02); + if (ret < 0) + goto exit_err; + + do { + usleep_range(1000, 5000); + ret = i2c_smbus_read_byte_data(client, STK8312_REG_OTPCTRL); + if (ret < 0) + goto exit_err; + count--; + } while (!(ret & 0x80) && count > 0); + + if (count == 0) + goto exit_err; + + ret = i2c_smbus_read_byte_data(client, STK8312_REG_OTPDATA); + if (ret < 0) + goto exit_err; + + ret = i2c_smbus_write_byte_data(data->client, + STK8312_REG_AFECTRL, ret); + if (ret < 0) + goto exit_err; + msleep(150); + + return ret; + +exit_err: + dev_err(&client->dev, "failed to initialize sensor\n"); + return ret; +} + +static int stk8312_set_mode(struct stk8312_data *data, u8 mode) +{ + int ret; + u8 masked_reg; + struct i2c_client *client = data->client; + + if (mode > 1) + return -EINVAL; + else if (mode == data->mode) + return 0; + + ret = i2c_smbus_read_byte_data(client, STK8312_REG_MODE); + if (ret < 0) { + dev_err(&client->dev, "failed to change sensor mode\n"); + return ret; + } + masked_reg = ret & (~STK8312_MODE_MASK); + masked_reg |= mode; + + ret = i2c_smbus_write_byte_data(client, + STK8312_REG_MODE, masked_reg); + if (ret < 0) { + dev_err(&client->dev, "failed to change sensor mode\n"); + return ret; + } + + data->mode = mode; + if (mode == STK8312_MODE_ACTIVE) { + /* Need to run OTP sequence before entering active mode */ + usleep_range(1000, 5000); + ret = stk8312_otp_init(data); + } + + return ret; +} + +static int stk8312_set_range(struct stk8312_data *data, u8 range) +{ + int ret; + u8 masked_reg; + u8 mode; + struct i2c_client *client = data->client; + + if (range != 1 && range != 2) + return -EINVAL; + else if (range == data->range) + return 0; + + mode = data->mode; + /* We need to go in standby mode to modify registers */ + ret = stk8312_set_mode(data, STK8312_MODE_STANDBY); + if (ret < 0) + return ret; + + ret = i2c_smbus_read_byte_data(client, STK8312_REG_STH); + if (ret < 0) { + dev_err(&client->dev, "failed to change sensor range\n"); + return ret; + } + + masked_reg = ret & (~STK8312_RNG_MASK); + masked_reg |= range << STK8312_RNG_SHIFT; + + ret = i2c_smbus_write_byte_data(client, STK8312_REG_STH, masked_reg); + if (ret < 0) + dev_err(&client->dev, "failed to change sensor range\n"); + else + data->range = range; + + return stk8312_set_mode(data, mode); +} + +static int stk8312_read_accel(struct stk8312_data *data, u8 address) +{ + int ret; + struct i2c_client *client = data->client; + + if (address > 2) + return -EINVAL; + + ret = i2c_smbus_read_byte_data(client, address); + if (ret < 0) { + dev_err(&client->dev, "register read failed\n"); + return ret; + } + + return sign_extend32(ret, 7); +} + +static int stk8312_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct stk8312_data *data = iio_priv(indio_dev); + + if (chan->type != IIO_ACCEL) + return -EINVAL; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + mutex_lock(&data->lock); + *val = stk8312_read_accel(data, chan->address); + mutex_unlock(&data->lock); + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + *val = stk8312_scale_table[data->range - 1][0]; + *val2 = stk8312_scale_table[data->range - 1][1]; + return IIO_VAL_INT_PLUS_MICRO; + } + + return -EINVAL; +} + +static int stk8312_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + int i; + int index = -1; + int ret; + struct stk8312_data *data = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_SCALE: + for (i = 0; i < ARRAY_SIZE(stk8312_scale_table); i++) + if (val == stk8312_scale_table[i][0] && + val2 == stk8312_scale_table[i][1]) { + index = i + 1; + break; + } + if (index < 0) + return -EINVAL; + + mutex_lock(&data->lock); + ret = stk8312_set_range(data, index); + mutex_unlock(&data->lock); + + return ret; + } + + return -EINVAL; +} + +static const struct iio_info stk8312_info = { + .driver_module = THIS_MODULE, + .read_raw = stk8312_read_raw, + .write_raw = stk8312_write_raw, + .attrs = &stk8312_attribute_group, +}; + +static int stk8312_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + int ret; + struct iio_dev *indio_dev; + struct stk8312_data *data; + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); + if (!indio_dev) { + dev_err(&client->dev, "iio allocation failed!\n"); + return -ENOMEM; + } + + data = iio_priv(indio_dev); + data->client = client; + i2c_set_clientdata(client, indio_dev); + mutex_init(&data->lock); + + indio_dev->dev.parent = &client->dev; + indio_dev->info = &stk8312_info; + indio_dev->name = STK8312_DRIVER_NAME; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = stk8312_channels; + indio_dev->num_channels = ARRAY_SIZE(stk8312_channels); + + /* A software reset is recommended at power-on */ + ret = i2c_smbus_write_byte_data(data->client, STK8312_REG_RESET, 0x00); + if (ret < 0) { + dev_err(&client->dev, "failed to reset sensor\n"); + return ret; + } + ret = stk8312_set_range(data, 1); + if (ret < 0) + return ret; + + ret = stk8312_set_mode(data, STK8312_MODE_ACTIVE); + if (ret < 0) + return ret; + + ret = iio_device_register(indio_dev); + if (ret < 0) { + dev_err(&client->dev, "device_register failed\n"); + stk8312_set_mode(data, STK8312_MODE_STANDBY); + } + + return ret; +} + +static int stk8312_remove(struct i2c_client *client) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(client); + + iio_device_unregister(indio_dev); + + return stk8312_set_mode(iio_priv(indio_dev), STK8312_MODE_STANDBY); +} + +#ifdef CONFIG_PM_SLEEP +static int stk8312_suspend(struct device *dev) +{ + struct stk8312_data *data; + + data = iio_priv(i2c_get_clientdata(to_i2c_client(dev))); + + return stk8312_set_mode(data, STK8312_MODE_STANDBY); +} + +static int stk8312_resume(struct device *dev) +{ + struct stk8312_data *data; + + data = iio_priv(i2c_get_clientdata(to_i2c_client(dev))); + + return stk8312_set_mode(data, STK8312_MODE_ACTIVE); +} + +static SIMPLE_DEV_PM_OPS(stk8312_pm_ops, stk8312_suspend, stk8312_resume); + +#define STK8312_PM_OPS (&stk8312_pm_ops) +#else +#define STK8312_PM_OPS NULL +#endif + +static const struct i2c_device_id stk8312_i2c_id[] = { + {"STK8312", 0}, + {} +}; + +static const struct acpi_device_id stk8312_acpi_id[] = { + {"STK8312", 0}, + {} +}; + +MODULE_DEVICE_TABLE(acpi, stk8312_acpi_id); + +static struct i2c_driver stk8312_driver = { + .driver = { + .name = "stk8312", + .pm = STK8312_PM_OPS, + .acpi_match_table = ACPI_PTR(stk8312_acpi_id), + }, + .probe = stk8312_probe, + .remove = stk8312_remove, + .id_table = stk8312_i2c_id, +}; + +module_i2c_driver(stk8312_driver); + +MODULE_AUTHOR("Tiberiu Breana "); +MODULE_DESCRIPTION("STK8312 3-Axis Accelerometer driver"); +MODULE_LICENSE("GPL v2"); From 70f1937911caebd961833314b41a618a33a5130a Mon Sep 17 00:00:00 2001 From: Antoine Tenart Date: Mon, 18 May 2015 11:19:18 +0200 Subject: [PATCH 0478/1163] iio: adc: add support for Berlin This patch adds the support of the Berlin ADC, available on Berlin SoCs. This ADC has 8 channels available, with one connected to a temperature sensor. The particularity here, is that the temperature sensor connected to the ADC has its own registers, and both the ADC and the temperature sensor must be configured when using it. Signed-off-by: Antoine Tenart Signed-off-by: Jonathan Cameron --- drivers/iio/adc/Kconfig | 7 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/berlin2-adc.c | 378 ++++++++++++++++++++++++++++++++++ 3 files changed, 386 insertions(+) create mode 100644 drivers/iio/adc/berlin2-adc.c diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index e36a73e7c3a8..cee50de76fb1 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -135,6 +135,13 @@ config AXP288_ADC device. Depending on platform configuration, this general purpose ADC can be used for sampling sensors such as thermal resistors. +config BERLIN2_ADC + tristate "Marvell Berlin2 ADC driver" + depends on ARCH_BERLIN + help + Marvell Berlin2 ADC driver. This ADC has 8 channels, with one used for + temperature measurement. + config DA9150_GPADC tristate "Dialog DA9150 GPADC driver support" depends on MFD_DA9150 diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index 3930e63e84bc..a0962103e866 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_AD7887) += ad7887.o obj-$(CONFIG_AD799X) += ad799x.o obj-$(CONFIG_AT91_ADC) += at91_adc.o obj-$(CONFIG_AXP288_ADC) += axp288_adc.o +obj-$(CONFIG_BERLIN2_ADC) += berlin2-adc.o obj-$(CONFIG_DA9150_GPADC) += da9150-gpadc.o obj-$(CONFIG_CC10001_ADC) += cc10001_adc.o obj-$(CONFIG_EXYNOS_ADC) += exynos_adc.o diff --git a/drivers/iio/adc/berlin2-adc.c b/drivers/iio/adc/berlin2-adc.c new file mode 100644 index 000000000000..aecc9ad995ad --- /dev/null +++ b/drivers/iio/adc/berlin2-adc.c @@ -0,0 +1,378 @@ +/* + * Marvell Berlin2 ADC driver + * + * Copyright (C) 2015 Marvell Technology Group Ltd. + * + * Antoine Tenart + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BERLIN2_SM_CTRL 0x14 +#define BERLIN2_SM_CTRL_SM_SOC_INT BIT(1) +#define BERLIN2_SM_CTRL_SOC_SM_INT BIT(2) +#define BERLIN2_SM_CTRL_ADC_SEL(x) (BIT(x) << 5) /* 0-15 */ +#define BERLIN2_SM_CTRL_ADC_SEL_MASK (0xf << 5) +#define BERLIN2_SM_CTRL_ADC_POWER BIT(9) +#define BERLIN2_SM_CTRL_ADC_CLKSEL_DIV2 (0x0 << 10) +#define BERLIN2_SM_CTRL_ADC_CLKSEL_DIV3 (0x1 << 10) +#define BERLIN2_SM_CTRL_ADC_CLKSEL_DIV4 (0x2 << 10) +#define BERLIN2_SM_CTRL_ADC_CLKSEL_DIV8 (0x3 << 10) +#define BERLIN2_SM_CTRL_ADC_CLKSEL_MASK (0x3 << 10) +#define BERLIN2_SM_CTRL_ADC_START BIT(12) +#define BERLIN2_SM_CTRL_ADC_RESET BIT(13) +#define BERLIN2_SM_CTRL_ADC_BANDGAP_RDY BIT(14) +#define BERLIN2_SM_CTRL_ADC_CONT_SINGLE (0x0 << 15) +#define BERLIN2_SM_CTRL_ADC_CONT_CONTINUOUS (0x1 << 15) +#define BERLIN2_SM_CTRL_ADC_BUFFER_EN BIT(16) +#define BERLIN2_SM_CTRL_ADC_VREF_EXT (0x0 << 17) +#define BERLIN2_SM_CTRL_ADC_VREF_INT (0x1 << 17) +#define BERLIN2_SM_CTRL_ADC_ROTATE BIT(19) +#define BERLIN2_SM_CTRL_TSEN_EN BIT(20) +#define BERLIN2_SM_CTRL_TSEN_CLK_SEL_125 (0x0 << 21) /* 1.25 MHz */ +#define BERLIN2_SM_CTRL_TSEN_CLK_SEL_250 (0x1 << 21) /* 2.5 MHz */ +#define BERLIN2_SM_CTRL_TSEN_MODE_0_125 (0x0 << 22) /* 0-125 C */ +#define BERLIN2_SM_CTRL_TSEN_MODE_10_50 (0x1 << 22) /* 10-50 C */ +#define BERLIN2_SM_CTRL_TSEN_RESET BIT(29) +#define BERLIN2_SM_ADC_DATA 0x20 +#define BERLIN2_SM_ADC_MASK 0x3ff +#define BERLIN2_SM_ADC_STATUS 0x1c +#define BERLIN2_SM_ADC_STATUS_DATA_RDY(x) BIT(x) /* 0-15 */ +#define BERLIN2_SM_ADC_STATUS_DATA_RDY_MASK 0xf +#define BERLIN2_SM_ADC_STATUS_INT_EN(x) (BIT(x) << 16) /* 0-15 */ +#define BERLIN2_SM_ADC_STATUS_INT_EN_MASK (0xf << 16) +#define BERLIN2_SM_TSEN_STATUS 0x24 +#define BERLIN2_SM_TSEN_STATUS_DATA_RDY BIT(0) +#define BERLIN2_SM_TSEN_STATUS_INT_EN BIT(1) +#define BERLIN2_SM_TSEN_DATA 0x28 +#define BERLIN2_SM_TSEN_MASK 0xfff +#define BERLIN2_SM_TSEN_CTRL 0x74 +#define BERLIN2_SM_TSEN_CTRL_START BIT(8) +#define BERLIN2_SM_TSEN_CTRL_SETTLING_4 (0x0 << 21) /* 4 us */ +#define BERLIN2_SM_TSEN_CTRL_SETTLING_12 (0x1 << 21) /* 12 us */ +#define BERLIN2_SM_TSEN_CTRL_SETTLING_MASK (0x1 << 21) +#define BERLIN2_SM_TSEN_CTRL_TRIM(x) ((x) << 22) +#define BERLIN2_SM_TSEN_CTRL_TRIM_MASK (0xf << 22) + +struct berlin2_adc_priv { + struct regmap *regmap; + struct mutex lock; + wait_queue_head_t wq; + bool data_available; + int data; +}; + +#define BERLIN2_ADC_CHANNEL(n, t) \ + { \ + .channel = n, \ + .datasheet_name = "channel"#n, \ + .type = t, \ + .indexed = 1, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + } + +static struct iio_chan_spec berlin2_adc_channels[] = { + BERLIN2_ADC_CHANNEL(0, IIO_VOLTAGE), /* external input */ + BERLIN2_ADC_CHANNEL(1, IIO_VOLTAGE), /* external input */ + BERLIN2_ADC_CHANNEL(2, IIO_VOLTAGE), /* external input */ + BERLIN2_ADC_CHANNEL(3, IIO_VOLTAGE), /* external input */ + BERLIN2_ADC_CHANNEL(4, IIO_VOLTAGE), /* reserved */ + BERLIN2_ADC_CHANNEL(5, IIO_VOLTAGE), /* reserved */ + { /* temperature sensor */ + .channel = 6, + .datasheet_name = "channel6", + .type = IIO_TEMP, + .indexed = 0, + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), + }, + BERLIN2_ADC_CHANNEL(7, IIO_VOLTAGE), /* reserved */ + IIO_CHAN_SOFT_TIMESTAMP(8), /* timestamp */ +}; +#define BERLIN2_N_CHANNELS ARRAY_SIZE(berlin2_adc_channels) + +static int berlin2_adc_read(struct iio_dev *indio_dev, int channel) +{ + struct berlin2_adc_priv *priv = iio_priv(indio_dev); + int data, ret; + + mutex_lock(&priv->lock); + + /* Configure the ADC */ + regmap_update_bits(priv->regmap, BERLIN2_SM_CTRL, + BERLIN2_SM_CTRL_ADC_RESET | BERLIN2_SM_CTRL_ADC_SEL_MASK + | BERLIN2_SM_CTRL_ADC_START, + BERLIN2_SM_CTRL_ADC_SEL(channel) | BERLIN2_SM_CTRL_ADC_START); + + ret = wait_event_interruptible_timeout(priv->wq, priv->data_available, + msecs_to_jiffies(1000)); + + /* Disable the interrupts */ + regmap_update_bits(priv->regmap, BERLIN2_SM_ADC_STATUS, + BERLIN2_SM_ADC_STATUS_INT_EN(channel), 0); + + if (ret == 0) + ret = -ETIMEDOUT; + if (ret < 0) { + mutex_unlock(&priv->lock); + return ret; + } + + regmap_update_bits(priv->regmap, BERLIN2_SM_CTRL, + BERLIN2_SM_CTRL_ADC_START, 0); + + data = priv->data; + priv->data_available = false; + + mutex_unlock(&priv->lock); + + return data; +} + +static int berlin2_adc_tsen_read(struct iio_dev *indio_dev) +{ + struct berlin2_adc_priv *priv = iio_priv(indio_dev); + int data, ret; + + mutex_lock(&priv->lock); + + /* Configure the ADC */ + regmap_update_bits(priv->regmap, BERLIN2_SM_CTRL, + BERLIN2_SM_CTRL_TSEN_RESET | BERLIN2_SM_CTRL_ADC_ROTATE, + BERLIN2_SM_CTRL_ADC_ROTATE); + + /* Configure the temperature sensor */ + regmap_update_bits(priv->regmap, BERLIN2_SM_TSEN_CTRL, + BERLIN2_SM_TSEN_CTRL_TRIM_MASK | BERLIN2_SM_TSEN_CTRL_SETTLING_MASK + | BERLIN2_SM_TSEN_CTRL_START, + BERLIN2_SM_TSEN_CTRL_TRIM(3) | BERLIN2_SM_TSEN_CTRL_SETTLING_12 + | BERLIN2_SM_TSEN_CTRL_START); + + ret = wait_event_interruptible_timeout(priv->wq, priv->data_available, + msecs_to_jiffies(1000)); + + /* Disable interrupts */ + regmap_update_bits(priv->regmap, BERLIN2_SM_TSEN_STATUS, + BERLIN2_SM_TSEN_STATUS_INT_EN, 0); + + if (ret == 0) + ret = -ETIMEDOUT; + if (ret < 0) { + mutex_unlock(&priv->lock); + return ret; + } + + regmap_update_bits(priv->regmap, BERLIN2_SM_TSEN_CTRL, + BERLIN2_SM_TSEN_CTRL_START, 0); + + data = priv->data; + priv->data_available = false; + + mutex_unlock(&priv->lock); + + return data; +} + +static int berlin2_adc_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int *val, int *val2, + long mask) +{ + struct berlin2_adc_priv *priv = iio_priv(indio_dev); + int temp; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + if (chan->type != IIO_VOLTAGE) + return -EINVAL; + + /* Enable the interrupts */ + regmap_write(priv->regmap, BERLIN2_SM_ADC_STATUS, + BERLIN2_SM_ADC_STATUS_INT_EN(chan->channel)); + + *val = berlin2_adc_read(indio_dev, chan->channel); + if (*val < 0) + return *val; + + return IIO_VAL_INT; + case IIO_CHAN_INFO_PROCESSED: + if (chan->type != IIO_TEMP) + return -EINVAL; + + /* Enable interrupts */ + regmap_write(priv->regmap, BERLIN2_SM_TSEN_STATUS, + BERLIN2_SM_TSEN_STATUS_INT_EN); + + temp = berlin2_adc_tsen_read(indio_dev); + if (temp < 0) + return temp; + + if (temp > 2047) + temp = -(4096 - temp); + + /* Convert to milli Celsius */ + *val = ((temp * 100000) / 264 - 270000); + return IIO_VAL_INT; + default: + break; + } + + return -EINVAL; +} + +static irqreturn_t berlin2_adc_irq(int irq, void *private) +{ + struct berlin2_adc_priv *priv = iio_priv(private); + unsigned val; + + regmap_read(priv->regmap, BERLIN2_SM_ADC_STATUS, &val); + if (val & BERLIN2_SM_ADC_STATUS_DATA_RDY_MASK) { + regmap_read(priv->regmap, BERLIN2_SM_ADC_DATA, &priv->data); + priv->data &= BERLIN2_SM_ADC_MASK; + + val &= ~BERLIN2_SM_ADC_STATUS_DATA_RDY_MASK; + regmap_write(priv->regmap, BERLIN2_SM_ADC_STATUS, val); + + priv->data_available = true; + wake_up_interruptible(&priv->wq); + } + + return IRQ_HANDLED; +} + +static irqreturn_t berlin2_adc_tsen_irq(int irq, void *private) +{ + struct berlin2_adc_priv *priv = iio_priv(private); + unsigned val; + + regmap_read(priv->regmap, BERLIN2_SM_TSEN_STATUS, &val); + if (val & BERLIN2_SM_TSEN_STATUS_DATA_RDY) { + regmap_read(priv->regmap, BERLIN2_SM_TSEN_DATA, &priv->data); + priv->data &= BERLIN2_SM_TSEN_MASK; + + val &= ~BERLIN2_SM_TSEN_STATUS_DATA_RDY; + regmap_write(priv->regmap, BERLIN2_SM_TSEN_STATUS, val); + + priv->data_available = true; + wake_up_interruptible(&priv->wq); + } + + return IRQ_HANDLED; +} + +static const struct iio_info berlin2_adc_info = { + .driver_module = THIS_MODULE, + .read_raw = berlin2_adc_read_raw, +}; + +static int berlin2_adc_probe(struct platform_device *pdev) +{ + struct iio_dev *indio_dev; + struct berlin2_adc_priv *priv; + struct device_node *parent_np = of_get_parent(pdev->dev.of_node); + int irq, tsen_irq; + int ret; + + indio_dev = devm_iio_device_alloc(&pdev->dev, + sizeof(struct berlin2_adc_priv)); + if (!indio_dev) + return -ENOMEM; + + priv = iio_priv(indio_dev); + platform_set_drvdata(pdev, indio_dev); + + priv->regmap = syscon_node_to_regmap(parent_np); + of_node_put(parent_np); + if (IS_ERR(priv->regmap)) + return PTR_ERR(priv->regmap); + + irq = platform_get_irq_byname(pdev, "adc"); + if (irq < 0) + return -ENODEV; + + tsen_irq = platform_get_irq_byname(pdev, "tsen"); + if (tsen_irq < 0) + return -ENODEV; + + ret = devm_request_irq(&pdev->dev, irq, berlin2_adc_irq, 0, + pdev->dev.driver->name, indio_dev); + if (ret) + return ret; + + ret = devm_request_irq(&pdev->dev, tsen_irq, berlin2_adc_tsen_irq, + 0, pdev->dev.driver->name, indio_dev); + if (ret) + return ret; + + init_waitqueue_head(&priv->wq); + mutex_init(&priv->lock); + + indio_dev->dev.parent = &pdev->dev; + indio_dev->name = dev_name(&pdev->dev); + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->info = &berlin2_adc_info; + + indio_dev->num_channels = BERLIN2_N_CHANNELS; + indio_dev->channels = berlin2_adc_channels; + + /* Power up the ADC */ + regmap_update_bits(priv->regmap, BERLIN2_SM_CTRL, + BERLIN2_SM_CTRL_ADC_POWER, BERLIN2_SM_CTRL_ADC_POWER); + + ret = iio_device_register(indio_dev); + if (ret) { + /* Power down the ADC */ + regmap_update_bits(priv->regmap, BERLIN2_SM_CTRL, + BERLIN2_SM_CTRL_ADC_POWER, 0); + return ret; + } + + return 0; +} + +static int berlin2_adc_remove(struct platform_device *pdev) +{ + struct iio_dev *indio_dev = platform_get_drvdata(pdev); + struct berlin2_adc_priv *priv = iio_priv(indio_dev); + + iio_device_unregister(indio_dev); + + /* Power down the ADC */ + regmap_update_bits(priv->regmap, BERLIN2_SM_CTRL, + BERLIN2_SM_CTRL_ADC_POWER, 0); + + return 0; +} + +static const struct of_device_id berlin2_adc_match[] = { + { .compatible = "marvell,berlin2-adc", }, + { }, +}; +MODULE_DEVICE_TABLE(of, berlin2_adc_match); + +static struct platform_driver berlin2_adc_driver = { + .driver = { + .name = "berlin2-adc", + .of_match_table = berlin2_adc_match, + }, + .probe = berlin2_adc_probe, + .remove = berlin2_adc_remove, +}; +module_platform_driver(berlin2_adc_driver); + +MODULE_AUTHOR("Antoine Tenart "); +MODULE_DESCRIPTION("Marvell Berlin2 ADC driver"); +MODULE_LICENSE("GPL v2"); From 2f4adaeebfb6f30fd6cd7a1a1dffe31f8e93a4c9 Mon Sep 17 00:00:00 2001 From: Antoine Tenart Date: Mon, 18 May 2015 11:19:19 +0200 Subject: [PATCH 0479/1163] Documentation: bindings: document the Berlin ADC driver Following the addition of a Berlin ADC driver, this patch adds the corresponding bindings documentation. Signed-off-by: Antoine Tenart Acked-by: Jonathan Cameron Signed-off-by: Jonathan Cameron --- .../bindings/iio/adc/berlin2_adc.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/berlin2_adc.txt diff --git a/Documentation/devicetree/bindings/iio/adc/berlin2_adc.txt b/Documentation/devicetree/bindings/iio/adc/berlin2_adc.txt new file mode 100644 index 000000000000..908334c6b07f --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/berlin2_adc.txt @@ -0,0 +1,19 @@ +* Berlin Analog to Digital Converter (ADC) + +The Berlin ADC has 8 channels, with one connected to a temperature sensor. +It is part of the system controller register set. The ADC node should be a +sub-node of the system controller node. + +Required properties: +- compatible: must be "marvell,berlin2-adc" +- interrupts: the interrupts for the ADC and the temperature sensor +- interrupt-names: should be "adc" and "tsen" + +Example: + +adc: adc { + compatible = "marvell,berlin2-adc"; + interrupt-parent = <&sic>; + interrupts = <12>, <14>; + interrupt-names = "adc", "tsen"; +}; From 1ce87f21edf6a071a7cc6bc77d628d7c7650d0d8 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 22 May 2015 18:17:38 +0200 Subject: [PATCH 0480/1163] iio: Add I/Q modifiers I/Q modifiers can be used to denote signals which are represented by a in-phase and a quadrature component. The ABI documentation describes the I and Q modifiers for current and voltage channels for now as those will be the most likely users. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 46 +++++++++++++++++++++++++ drivers/iio/industrialio-core.c | 2 ++ include/uapi/linux/iio/types.h | 2 ++ 3 files changed, 50 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index f66262c64e2f..bbed111c31b4 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -71,6 +71,8 @@ Description: What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_raw What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_supply_raw +What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_i_raw +What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_q_raw KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -81,6 +83,11 @@ Description: unique to allow association with event codes. Units after application of scale and offset are millivolts. + Channels with 'i' and 'q' modifiers always exist in pairs and both + channels refer to the same signal. The 'i' channel contains the in-phase + component of the signal while the 'q' channel contains the quadrature + component. + What: /sys/bus/iio/devices/iio:deviceX/in_voltageY-voltageZ_raw KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org @@ -246,8 +253,16 @@ What: /sys/bus/iio/devices/iio:deviceX/in_accel_y_offset What: /sys/bus/iio/devices/iio:deviceX/in_accel_z_offset What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_offset What: /sys/bus/iio/devices/iio:deviceX/in_voltage_offset +What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_i_offset +What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_q_offset +What: /sys/bus/iio/devices/iio:deviceX/in_voltage_q_offset +What: /sys/bus/iio/devices/iio:deviceX/in_voltage_i_offset What: /sys/bus/iio/devices/iio:deviceX/in_currentY_offset What: /sys/bus/iio/devices/iio:deviceX/in_current_offset +What: /sys/bus/iio/devices/iio:deviceX/in_currentY_i_offset +What: /sys/bus/iio/devices/iio:deviceX/in_currentY_q_offset +What: /sys/bus/iio/devices/iio:deviceX/in_current_q_offset +What: /sys/bus/iio/devices/iio:deviceX/in_current_i_offset What: /sys/bus/iio/devices/iio:deviceX/in_tempY_offset What: /sys/bus/iio/devices/iio:deviceX/in_temp_offset What: /sys/bus/iio/devices/iio:deviceX/in_pressureY_offset @@ -273,14 +288,22 @@ Description: to the _raw output. What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_scale +What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_i_scale +What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_q_scale What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_supply_scale What: /sys/bus/iio/devices/iio:deviceX/in_voltage_scale +What: /sys/bus/iio/devices/iio:deviceX/in_voltage_i_scale +What: /sys/bus/iio/devices/iio:deviceX/in_voltage_q_scale What: /sys/bus/iio/devices/iio:deviceX/in_voltage-voltage_scale What: /sys/bus/iio/devices/iio:deviceX/out_voltageY_scale What: /sys/bus/iio/devices/iio:deviceX/out_altvoltageY_scale What: /sys/bus/iio/devices/iio:deviceX/in_currentY_scale What: /sys/bus/iio/devices/iio:deviceX/in_currentY_supply_scale What: /sys/bus/iio/devices/iio:deviceX/in_current_scale +What: /sys/bus/iio/devices/iio:deviceX/in_currentY_i_scale +What: /sys/bus/iio/devices/iio:deviceX/in_currentY_q_scale +What: /sys/bus/iio/devices/iio:deviceX/in_current_i_scale +What: /sys/bus/iio/devices/iio:deviceX/in_current_q_scale What: /sys/bus/iio/devices/iio:deviceX/in_accel_scale What: /sys/bus/iio/devices/iio:deviceX/in_accel_peak_scale What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_scale @@ -328,6 +351,10 @@ Description: What /sys/bus/iio/devices/iio:deviceX/in_voltageY_calibscale What /sys/bus/iio/devices/iio:deviceX/in_voltageY_supply_calibscale +What /sys/bus/iio/devices/iio:deviceX/in_voltageY_i_calibscale +What /sys/bus/iio/devices/iio:deviceX/in_voltageY_q_calibscale +What /sys/bus/iio/devices/iio:deviceX/in_voltage_i_calibscale +What /sys/bus/iio/devices/iio:deviceX/in_voltage_q_calibscale What /sys/bus/iio/devices/iio:deviceX/in_voltage_calibscale What /sys/bus/iio/devices/iio:deviceX/in_accel_x_calibscale What /sys/bus/iio/devices/iio:deviceX/in_accel_y_calibscale @@ -1046,6 +1073,10 @@ What: /sys/.../iio:deviceX/scan_elements/in_timestamp_en What: /sys/.../iio:deviceX/scan_elements/in_voltageY_supply_en What: /sys/.../iio:deviceX/scan_elements/in_voltageY_en What: /sys/.../iio:deviceX/scan_elements/in_voltageY-voltageZ_en +What: /sys/.../iio:deviceX/scan_elements/in_voltageY_i_en +What: /sys/.../iio:deviceX/scan_elements/in_voltageY_q_en +What: /sys/.../iio:deviceX/scan_elements/in_voltage_i_en +What: /sys/.../iio:deviceX/scan_elements/in_voltage_q_en 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 @@ -1064,6 +1095,10 @@ What: /sys/.../iio:deviceX/scan_elements/in_incli_type What: /sys/.../iio:deviceX/scan_elements/in_voltageY_type What: /sys/.../iio:deviceX/scan_elements/in_voltage_type What: /sys/.../iio:deviceX/scan_elements/in_voltageY_supply_type +What: /sys/.../iio:deviceX/scan_elements/in_voltageY_i_type +What: /sys/.../iio:deviceX/scan_elements/in_voltageY_q_type +What: /sys/.../iio:deviceX/scan_elements/in_voltage_i_type +What: /sys/.../iio:deviceX/scan_elements/in_voltage_q_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 @@ -1101,6 +1136,10 @@ Description: What: /sys/.../iio:deviceX/scan_elements/in_voltageY_index What: /sys/.../iio:deviceX/scan_elements/in_voltageY_supply_index +What: /sys/.../iio:deviceX/scan_elements/in_voltageY_i_index +What: /sys/.../iio:deviceX/scan_elements/in_voltageY_q_index +What: /sys/.../iio:deviceX/scan_elements/in_voltage_i_index +What: /sys/.../iio:deviceX/scan_elements/in_voltage_q_index What: /sys/.../iio:deviceX/scan_elements/in_accel_x_index What: /sys/.../iio:deviceX/scan_elements/in_accel_y_index What: /sys/.../iio:deviceX/scan_elements/in_accel_z_index @@ -1260,6 +1299,8 @@ Description: or without compensation from tilt sensors. What: /sys/bus/iio/devices/iio:deviceX/in_currentX_raw +What: /sys/bus/iio/devices/iio:deviceX/in_currentX_i_raw +What: /sys/bus/iio/devices/iio:deviceX/in_currentX_q_raw KernelVersion: 3.18 Contact: linux-iio@vger.kernel.org Description: @@ -1268,6 +1309,11 @@ Description: present, output should be considered as processed with the unit in milliamps. + Channels with 'i' and 'q' modifiers always exist in pairs and both + channels refer to the same signal. The 'i' channel contains the in-phase + component of the signal while the 'q' channel contains the quadrature + component. + What: /sys/.../iio:deviceX/in_energy_en What: /sys/.../iio:deviceX/in_distance_en What: /sys/.../iio:deviceX/in_velocity_sqrt(x^2+y^2+z^2)_en diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 9688a88b6198..3524b0de8721 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -101,6 +101,8 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_WALKING] = "walking", [IIO_MOD_STILL] = "still", [IIO_MOD_ROOT_SUM_SQUARED_X_Y_Z] = "sqrt(x^2+y^2+z^2)", + [IIO_MOD_I] = "i", + [IIO_MOD_Q] = "q", }; /* relies on pairs of these shared then separate */ diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h index 5c4601935005..2f8b11722204 100644 --- a/include/uapi/linux/iio/types.h +++ b/include/uapi/linux/iio/types.h @@ -70,6 +70,8 @@ enum iio_modifier { IIO_MOD_WALKING, IIO_MOD_STILL, IIO_MOD_ROOT_SUM_SQUARED_X_Y_Z, + IIO_MOD_I, + IIO_MOD_Q, }; enum iio_event_type { From 2a67dfba7fae36af0233452d19b40594f62bc019 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Urs=20F=C3=A4ssler?= Date: Mon, 18 May 2015 15:22:44 +0200 Subject: [PATCH 0481/1163] iio:adc128s052: add support for adc122s021 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Urs Fässler Signed-off-by: Jonathan Cameron --- .../bindings/iio/adc/ti-adc128s052.txt | 4 +-- drivers/iio/adc/Kconfig | 4 +-- drivers/iio/adc/ti-adc128s052.c | 30 +++++++++++++++---- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt b/Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt index 42ca7deec97d..15ca6b47958e 100644 --- a/Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt +++ b/Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt @@ -1,7 +1,7 @@ -* Texas Instruments' ADC128S052 ADC chip +* Texas Instruments' ADC128S052 and ADC122S021 ADC chip Required properties: - - compatible: Should be "ti,adc128s052" + - compatible: Should be "ti,adc128s052" or "ti,adc122s021" - reg: spi chip select number for the device - vref-supply: The regulator supply for ADC reference voltage diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index cee50de76fb1..7c5565891cb8 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -292,11 +292,11 @@ config TI_ADC081C called ti-adc081c. config TI_ADC128S052 - tristate "Texas Instruments ADC128S052" + tristate "Texas Instruments ADC128S052/ADC122S021" depends on SPI help If you say yes here you get support for Texas Instruments ADC128S052 - chip. + and ADC122S021 chips. This driver can also be built as a module. If so, the module will be called ti-adc128s052. diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c index 655cb564ec54..915be6b60097 100644 --- a/drivers/iio/adc/ti-adc128s052.c +++ b/drivers/iio/adc/ti-adc128s052.c @@ -1,9 +1,10 @@ /* * Copyright (C) 2014 Angelo Compagnucci * - * Driver for Texas Instruments' ADC128S052 ADC chip. - * Datasheet can be found here: + * Driver for Texas Instruments' ADC128S052 and ADC122S021 ADC chip. + * Datasheets can be found here: * http://www.ti.com/lit/ds/symlink/adc128s052.pdf + * http://www.ti.com/lit/ds/symlink/adc122s021.pdf * * 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 @@ -16,6 +17,11 @@ #include #include +struct adc128_configuration { + const struct iio_chan_spec *channels; + u8 num_channels; +}; + struct adc128 { struct spi_device *spi; @@ -92,7 +98,7 @@ static int adc128_read_raw(struct iio_dev *indio_dev, .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) \ } -static const struct iio_chan_spec adc128_channels[] = { +static const struct iio_chan_spec adc128s052_channels[] = { ADC128_VOLTAGE_CHANNEL(0), ADC128_VOLTAGE_CHANNEL(1), ADC128_VOLTAGE_CHANNEL(2), @@ -103,6 +109,16 @@ static const struct iio_chan_spec adc128_channels[] = { ADC128_VOLTAGE_CHANNEL(7), }; +static const struct iio_chan_spec adc122s021_channels[] = { + ADC128_VOLTAGE_CHANNEL(0), + ADC128_VOLTAGE_CHANNEL(1), +}; + +static const struct adc128_configuration adc128_config[] = { + { adc128s052_channels, ARRAY_SIZE(adc128s052_channels) }, + { adc122s021_channels, ARRAY_SIZE(adc122s021_channels) }, +}; + static const struct iio_info adc128_info = { .read_raw = adc128_read_raw, .driver_module = THIS_MODULE, @@ -112,6 +128,7 @@ static int adc128_probe(struct spi_device *spi) { struct iio_dev *indio_dev; struct adc128 *adc; + int config = spi_get_device_id(spi)->driver_data; int ret; indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc)); @@ -128,8 +145,8 @@ static int adc128_probe(struct spi_device *spi) indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &adc128_info; - indio_dev->channels = adc128_channels; - indio_dev->num_channels = ARRAY_SIZE(adc128_channels); + indio_dev->channels = adc128_config[config].channels; + indio_dev->num_channels = adc128_config[config].num_channels; adc->reg = devm_regulator_get(&spi->dev, "vref"); if (IS_ERR(adc->reg)) @@ -158,7 +175,8 @@ static int adc128_remove(struct spi_device *spi) } static const struct spi_device_id adc128_id[] = { - { "adc128s052", 0}, + { "adc128s052", 0}, /* index into adc128_config */ + { "adc122s021", 1}, { } }; MODULE_DEVICE_TABLE(spi, adc128_id); From 6e509c4d91632b6f8f05f0bee3a20fd50ca2263b Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 18 May 2015 13:34:47 +0200 Subject: [PATCH 0482/1163] iio: __iio_update_buffers: Verify configuration before starting to apply it Currently __iio_update_buffers() verifies whether the new configuration will work in the middle of the update sequence. This means if the new configuration is invalid we need to rollback the changes already made. This patch moves the validation of the new configuration at the beginning of __iio_update_buffers() and will not start to make any changes if the new configuration is invalid. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-buffer.c | 164 ++++++++++++++++++------------ 1 file changed, 101 insertions(+), 63 deletions(-) diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 21ed3168b70b..0b4fe63c529e 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -602,20 +602,104 @@ static void iio_free_scan_mask(struct iio_dev *indio_dev, kfree(mask); } +struct iio_device_config { + unsigned int mode; + const unsigned long *scan_mask; + unsigned int scan_bytes; + bool scan_timestamp; +}; + +static int iio_verify_update(struct iio_dev *indio_dev, + struct iio_buffer *insert_buffer, struct iio_buffer *remove_buffer, + struct iio_device_config *config) +{ + unsigned long *compound_mask; + const unsigned long *scan_mask; + struct iio_buffer *buffer; + bool scan_timestamp; + + memset(config, 0, sizeof(*config)); + + /* + * If there is just one buffer and we are removing it there is nothing + * to verify. + */ + if (remove_buffer && !insert_buffer && + list_is_singular(&indio_dev->buffer_list)) + return 0; + + /* Definitely possible for devices to support both of these. */ + if ((indio_dev->modes & INDIO_BUFFER_TRIGGERED) && indio_dev->trig) { + config->mode = INDIO_BUFFER_TRIGGERED; + } else if (indio_dev->modes & INDIO_BUFFER_HARDWARE) { + config->mode = INDIO_BUFFER_HARDWARE; + } else if (indio_dev->modes & INDIO_BUFFER_SOFTWARE) { + config->mode = INDIO_BUFFER_SOFTWARE; + } else { + /* Can only occur on first buffer */ + if (indio_dev->modes & INDIO_BUFFER_TRIGGERED) + dev_dbg(&indio_dev->dev, "Buffer not started: no trigger\n"); + return -EINVAL; + } + + /* What scan mask do we actually have? */ + compound_mask = kcalloc(BITS_TO_LONGS(indio_dev->masklength), + sizeof(long), GFP_KERNEL); + if (compound_mask == NULL) + return -ENOMEM; + + scan_timestamp = false; + + list_for_each_entry(buffer, &indio_dev->buffer_list, buffer_list) { + if (buffer == remove_buffer) + continue; + bitmap_or(compound_mask, compound_mask, buffer->scan_mask, + indio_dev->masklength); + scan_timestamp |= buffer->scan_timestamp; + } + + if (insert_buffer) { + bitmap_or(compound_mask, compound_mask, + insert_buffer->scan_mask, indio_dev->masklength); + scan_timestamp |= insert_buffer->scan_timestamp; + } + + if (indio_dev->available_scan_masks) { + scan_mask = iio_scan_mask_match(indio_dev->available_scan_masks, + indio_dev->masklength, + compound_mask); + kfree(compound_mask); + if (scan_mask == NULL) + return -EINVAL; + } else { + scan_mask = compound_mask; + } + + config->scan_bytes = iio_compute_scan_bytes(indio_dev, + scan_mask, scan_timestamp); + config->scan_mask = scan_mask; + config->scan_timestamp = scan_timestamp; + + return 0; +} + static int __iio_update_buffers(struct iio_dev *indio_dev, struct iio_buffer *insert_buffer, struct iio_buffer *remove_buffer) { int ret; - int success = 0; - struct iio_buffer *buffer; - unsigned long *compound_mask; const unsigned long *old_mask; + struct iio_device_config new_config; + + ret = iio_verify_update(indio_dev, insert_buffer, remove_buffer, + &new_config); + if (ret) + return ret; if (insert_buffer) { ret = iio_buffer_request_update(indio_dev, insert_buffer); if (ret) - return ret; + goto err_free_config; } /* Wind down existing buffers - iff there are any */ @@ -623,13 +707,13 @@ static int __iio_update_buffers(struct iio_dev *indio_dev, if (indio_dev->setup_ops->predisable) { ret = indio_dev->setup_ops->predisable(indio_dev); if (ret) - return ret; + goto err_free_config; } indio_dev->currentmode = INDIO_DIRECT_MODE; if (indio_dev->setup_ops->postdisable) { ret = indio_dev->setup_ops->postdisable(indio_dev); if (ret) - return ret; + goto err_free_config; } } /* Keep a copy of current setup to allow roll back */ @@ -649,44 +733,9 @@ static int __iio_update_buffers(struct iio_dev *indio_dev, return 0; } - /* What scan mask do we actually have? */ - compound_mask = kcalloc(BITS_TO_LONGS(indio_dev->masklength), - sizeof(long), GFP_KERNEL); - if (compound_mask == NULL) { - iio_free_scan_mask(indio_dev, old_mask); - return -ENOMEM; - } - indio_dev->scan_timestamp = 0; - - list_for_each_entry(buffer, &indio_dev->buffer_list, buffer_list) { - bitmap_or(compound_mask, compound_mask, buffer->scan_mask, - indio_dev->masklength); - indio_dev->scan_timestamp |= buffer->scan_timestamp; - } - if (indio_dev->available_scan_masks) { - indio_dev->active_scan_mask = - iio_scan_mask_match(indio_dev->available_scan_masks, - indio_dev->masklength, - compound_mask); - kfree(compound_mask); - if (indio_dev->active_scan_mask == NULL) { - /* - * Roll back. - * Note can only occur when adding a buffer. - */ - iio_buffer_deactivate(insert_buffer); - if (old_mask) { - indio_dev->active_scan_mask = old_mask; - success = -EINVAL; - } - else { - ret = -EINVAL; - return ret; - } - } - } else { - indio_dev->active_scan_mask = compound_mask; - } + indio_dev->active_scan_mask = new_config.scan_mask; + indio_dev->scan_timestamp = new_config.scan_timestamp; + indio_dev->scan_bytes = new_config.scan_bytes; iio_update_demux(indio_dev); @@ -699,10 +748,7 @@ static int __iio_update_buffers(struct iio_dev *indio_dev, goto error_remove_inserted; } } - indio_dev->scan_bytes = - iio_compute_scan_bytes(indio_dev, - indio_dev->active_scan_mask, - indio_dev->scan_timestamp); + if (indio_dev->info->update_scan_mode) { ret = indio_dev->info ->update_scan_mode(indio_dev, @@ -714,20 +760,8 @@ static int __iio_update_buffers(struct iio_dev *indio_dev, goto error_run_postdisable; } } - /* Definitely possible for devices to support both of these. */ - if ((indio_dev->modes & INDIO_BUFFER_TRIGGERED) && indio_dev->trig) { - indio_dev->currentmode = INDIO_BUFFER_TRIGGERED; - } else if (indio_dev->modes & INDIO_BUFFER_HARDWARE) { - indio_dev->currentmode = INDIO_BUFFER_HARDWARE; - } else if (indio_dev->modes & INDIO_BUFFER_SOFTWARE) { - indio_dev->currentmode = INDIO_BUFFER_SOFTWARE; - } else { /* Should never be reached */ - /* Can only occur on first buffer */ - if (indio_dev->modes & INDIO_BUFFER_TRIGGERED) - dev_dbg(&indio_dev->dev, "Buffer not started: no trigger\n"); - ret = -EINVAL; - goto error_run_postdisable; - } + + indio_dev->currentmode = new_config.mode; if (indio_dev->setup_ops->postenable) { ret = indio_dev->setup_ops->postenable(indio_dev); @@ -743,7 +777,7 @@ static int __iio_update_buffers(struct iio_dev *indio_dev, iio_free_scan_mask(indio_dev, old_mask); - return success; + return 0; error_disable_all_buffers: indio_dev->currentmode = INDIO_DIRECT_MODE; @@ -756,6 +790,10 @@ error_remove_inserted: iio_free_scan_mask(indio_dev, indio_dev->active_scan_mask); indio_dev->active_scan_mask = old_mask; return ret; + +err_free_config: + iio_free_scan_mask(indio_dev, new_config.scan_mask); + return ret; } int iio_update_buffers(struct iio_dev *indio_dev, From 623d74e37f12c9276b15c2c0540b438e684af0d2 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 18 May 2015 13:34:48 +0200 Subject: [PATCH 0483/1163] iio: __iio_update_buffers: Split enable and disable path into helper functions __iio_update_buffers is already a rather large function with many different error paths and it is going to get even larger. This patch factors out the device enable and device disable paths into separate helper functions. The patch also re-implements iio_disable_all_buffers() using the new iio_disable_buffers() function removing a fair bit of redundant code. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-buffer.c | 199 ++++++++++++++++-------------- 1 file changed, 107 insertions(+), 92 deletions(-) diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 0b4fe63c529e..b4d7dba163cf 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -539,28 +539,6 @@ static void iio_buffer_deactivate(struct iio_buffer *buffer) iio_buffer_put(buffer); } -void iio_disable_all_buffers(struct iio_dev *indio_dev) -{ - struct iio_buffer *buffer, *_buffer; - - if (list_empty(&indio_dev->buffer_list)) - return; - - if (indio_dev->setup_ops->predisable) - indio_dev->setup_ops->predisable(indio_dev); - - list_for_each_entry_safe(buffer, _buffer, - &indio_dev->buffer_list, buffer_list) - iio_buffer_deactivate(buffer); - - indio_dev->currentmode = INDIO_DIRECT_MODE; - if (indio_dev->setup_ops->postdisable) - indio_dev->setup_ops->postdisable(indio_dev); - - if (indio_dev->available_scan_masks == NULL) - kfree(indio_dev->active_scan_mask); -} - static void iio_buffer_update_bytes_per_datum(struct iio_dev *indio_dev, struct iio_buffer *buffer) { @@ -683,6 +661,87 @@ static int iio_verify_update(struct iio_dev *indio_dev, return 0; } +static int iio_enable_buffers(struct iio_dev *indio_dev, + struct iio_device_config *config) +{ + int ret; + + indio_dev->active_scan_mask = config->scan_mask; + indio_dev->scan_timestamp = config->scan_timestamp; + indio_dev->scan_bytes = config->scan_bytes; + + iio_update_demux(indio_dev); + + /* Wind up again */ + if (indio_dev->setup_ops->preenable) { + ret = indio_dev->setup_ops->preenable(indio_dev); + if (ret) { + dev_dbg(&indio_dev->dev, + "Buffer not started: buffer preenable failed (%d)\n", ret); + goto err_undo_config; + } + } + + if (indio_dev->info->update_scan_mode) { + ret = indio_dev->info + ->update_scan_mode(indio_dev, + indio_dev->active_scan_mask); + if (ret < 0) { + dev_dbg(&indio_dev->dev, + "Buffer not started: update scan mode failed (%d)\n", + ret); + goto err_run_postdisable; + } + } + + indio_dev->currentmode = config->mode; + + if (indio_dev->setup_ops->postenable) { + ret = indio_dev->setup_ops->postenable(indio_dev); + if (ret) { + dev_dbg(&indio_dev->dev, + "Buffer not started: postenable failed (%d)\n", ret); + goto err_run_postdisable; + } + } + + return 0; + +err_run_postdisable: + indio_dev->currentmode = INDIO_DIRECT_MODE; + if (indio_dev->setup_ops->postdisable) + indio_dev->setup_ops->postdisable(indio_dev); +err_undo_config: + indio_dev->active_scan_mask = NULL; + + return ret; +} + +static int iio_disable_buffers(struct iio_dev *indio_dev) +{ + int ret; + + /* Wind down existing buffers - iff there are any */ + if (list_empty(&indio_dev->buffer_list)) + return 0; + + if (indio_dev->setup_ops->predisable) { + ret = indio_dev->setup_ops->predisable(indio_dev); + if (ret) + return ret; + } + + indio_dev->currentmode = INDIO_DIRECT_MODE; + + if (indio_dev->setup_ops->postdisable) { + ret = indio_dev->setup_ops->postdisable(indio_dev); + if (ret) + return ret; + } + + return 0; +} + static int __iio_update_buffers(struct iio_dev *indio_dev, struct iio_buffer *insert_buffer, struct iio_buffer *remove_buffer) @@ -702,24 +761,15 @@ static int __iio_update_buffers(struct iio_dev *indio_dev, goto err_free_config; } - /* Wind down existing buffers - iff there are any */ - if (!list_empty(&indio_dev->buffer_list)) { - if (indio_dev->setup_ops->predisable) { - ret = indio_dev->setup_ops->predisable(indio_dev); - if (ret) - goto err_free_config; - } - indio_dev->currentmode = INDIO_DIRECT_MODE; - if (indio_dev->setup_ops->postdisable) { - ret = indio_dev->setup_ops->postdisable(indio_dev); - if (ret) - goto err_free_config; - } - } /* Keep a copy of current setup to allow roll back */ old_mask = indio_dev->active_scan_mask; - if (!indio_dev->available_scan_masks) - indio_dev->active_scan_mask = NULL; + indio_dev->active_scan_mask = NULL; + + ret = iio_disable_buffers(indio_dev); + if (ret) { + iio_free_scan_mask(indio_dev, old_mask); + goto err_free_config; + } if (remove_buffer) iio_buffer_deactivate(remove_buffer); @@ -728,69 +778,21 @@ static int __iio_update_buffers(struct iio_dev *indio_dev, /* If no buffers in list, we are done */ if (list_empty(&indio_dev->buffer_list)) { - indio_dev->currentmode = INDIO_DIRECT_MODE; iio_free_scan_mask(indio_dev, old_mask); return 0; } - indio_dev->active_scan_mask = new_config.scan_mask; - indio_dev->scan_timestamp = new_config.scan_timestamp; - indio_dev->scan_bytes = new_config.scan_bytes; - - iio_update_demux(indio_dev); - - /* Wind up again */ - if (indio_dev->setup_ops->preenable) { - ret = indio_dev->setup_ops->preenable(indio_dev); - if (ret) { - dev_dbg(&indio_dev->dev, - "Buffer not started: buffer preenable failed (%d)\n", ret); - goto error_remove_inserted; - } - } - - if (indio_dev->info->update_scan_mode) { - ret = indio_dev->info - ->update_scan_mode(indio_dev, - indio_dev->active_scan_mask); - if (ret < 0) { - dev_dbg(&indio_dev->dev, - "Buffer not started: update scan mode failed (%d)\n", - ret); - goto error_run_postdisable; - } - } - - indio_dev->currentmode = new_config.mode; - - if (indio_dev->setup_ops->postenable) { - ret = indio_dev->setup_ops->postenable(indio_dev); - if (ret) { - dev_dbg(&indio_dev->dev, - "Buffer not started: postenable failed (%d)\n", ret); - indio_dev->currentmode = INDIO_DIRECT_MODE; - if (indio_dev->setup_ops->postdisable) - indio_dev->setup_ops->postdisable(indio_dev); - goto error_disable_all_buffers; - } + ret = iio_enable_buffers(indio_dev, &new_config); + if (ret) { + if (insert_buffer) + iio_buffer_deactivate(insert_buffer); + indio_dev->active_scan_mask = old_mask; + goto err_free_config; } iio_free_scan_mask(indio_dev, old_mask); - return 0; -error_disable_all_buffers: - indio_dev->currentmode = INDIO_DIRECT_MODE; -error_run_postdisable: - if (indio_dev->setup_ops->postdisable) - indio_dev->setup_ops->postdisable(indio_dev); -error_remove_inserted: - if (insert_buffer) - iio_buffer_deactivate(insert_buffer); - iio_free_scan_mask(indio_dev, indio_dev->active_scan_mask); - indio_dev->active_scan_mask = old_mask; - return ret; - err_free_config: iio_free_scan_mask(indio_dev, new_config.scan_mask); return ret; @@ -834,6 +836,19 @@ out_unlock: } EXPORT_SYMBOL_GPL(iio_update_buffers); +void iio_disable_all_buffers(struct iio_dev *indio_dev) +{ + struct iio_buffer *buffer, *_buffer; + + iio_disable_buffers(indio_dev); + iio_free_scan_mask(indio_dev, indio_dev->active_scan_mask); + indio_dev->active_scan_mask = NULL; + + list_for_each_entry_safe(buffer, _buffer, + &indio_dev->buffer_list, buffer_list) + iio_buffer_deactivate(buffer); +} + static ssize_t iio_buffer_store_enable(struct device *dev, struct device_attribute *attr, const char *buf, From 1250186a936a169a32f5101392deec18788877b9 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 18 May 2015 13:34:49 +0200 Subject: [PATCH 0484/1163] iio: __iio_update_buffers: Leave device in sane state on error Currently when something goes wrong at some step when disabling the buffers we immediately abort. This has the effect that the enable/disable calls are no longer balanced. So make sure that even if one step in the disable sequence fails the other steps are still executed. The other issue is that when either enable or disable fails buffers that were active at that time stay active while the device itself is disabled. This leaves things in a inconsistent state and can cause unbalanced enable/disable calls. Furthermore when enable fails we restore the old scan mask, but still keeps things disabled. Given that verification of the configuration was performed earlier and it is valid at the point where we try to enable/disable the most likely reason of failure is a communication failure with the device or maybe a out-of-memory situation. There is not really a good recovery strategy in such a case, so it makes sense to leave the device disabled, but we should still leave it in a consistent state. What the patch does if disable/enable fails is to deactivate all buffers and make sure that the device will be in the same state as if all buffers had been manually disabled. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-buffer.c | 82 +++++++++++++++++-------------- 1 file changed, 46 insertions(+), 36 deletions(-) diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index b4d7dba163cf..11291259b7b9 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -539,6 +539,15 @@ static void iio_buffer_deactivate(struct iio_buffer *buffer) iio_buffer_put(buffer); } +static void iio_buffer_deactivate_all(struct iio_dev *indio_dev) +{ + struct iio_buffer *buffer, *_buffer; + + list_for_each_entry_safe(buffer, _buffer, + &indio_dev->buffer_list, buffer_list) + iio_buffer_deactivate(buffer); +} + static void iio_buffer_update_bytes_per_datum(struct iio_dev *indio_dev, struct iio_buffer *buffer) { @@ -719,36 +728,46 @@ err_undo_config: static int iio_disable_buffers(struct iio_dev *indio_dev) { - int ret; + int ret = 0; + int ret2; /* Wind down existing buffers - iff there are any */ if (list_empty(&indio_dev->buffer_list)) return 0; + /* + * If things go wrong at some step in disable we still need to continue + * to perform the other steps, otherwise we leave the device in a + * inconsistent state. We return the error code for the first error we + * encountered. + */ + if (indio_dev->setup_ops->predisable) { - ret = indio_dev->setup_ops->predisable(indio_dev); - if (ret) - return ret; + ret2 = indio_dev->setup_ops->predisable(indio_dev); + if (ret2 && !ret) + ret = ret2; } indio_dev->currentmode = INDIO_DIRECT_MODE; if (indio_dev->setup_ops->postdisable) { - ret = indio_dev->setup_ops->postdisable(indio_dev); - if (ret) - return ret; + ret2 = indio_dev->setup_ops->postdisable(indio_dev); + if (ret2 && !ret) + ret = ret2; } - return 0; + iio_free_scan_mask(indio_dev, indio_dev->active_scan_mask); + indio_dev->active_scan_mask = NULL; + + return ret; } static int __iio_update_buffers(struct iio_dev *indio_dev, struct iio_buffer *insert_buffer, struct iio_buffer *remove_buffer) { - int ret; - const unsigned long *old_mask; struct iio_device_config new_config; + int ret; ret = iio_verify_update(indio_dev, insert_buffer, remove_buffer, &new_config); @@ -761,15 +780,9 @@ static int __iio_update_buffers(struct iio_dev *indio_dev, goto err_free_config; } - /* Keep a copy of current setup to allow roll back */ - old_mask = indio_dev->active_scan_mask; - indio_dev->active_scan_mask = NULL; - ret = iio_disable_buffers(indio_dev); - if (ret) { - iio_free_scan_mask(indio_dev, old_mask); - goto err_free_config; - } + if (ret) + goto err_deactivate_all; if (remove_buffer) iio_buffer_deactivate(remove_buffer); @@ -777,22 +790,26 @@ static int __iio_update_buffers(struct iio_dev *indio_dev, iio_buffer_activate(indio_dev, insert_buffer); /* If no buffers in list, we are done */ - if (list_empty(&indio_dev->buffer_list)) { - iio_free_scan_mask(indio_dev, old_mask); + if (list_empty(&indio_dev->buffer_list)) return 0; - } ret = iio_enable_buffers(indio_dev, &new_config); - if (ret) { - if (insert_buffer) - iio_buffer_deactivate(insert_buffer); - indio_dev->active_scan_mask = old_mask; - goto err_free_config; - } + if (ret) + goto err_deactivate_all; - iio_free_scan_mask(indio_dev, old_mask); return 0; +err_deactivate_all: + /* + * We've already verified that the config is valid earlier. If things go + * wrong in either enable or disable the most likely reason is an IO + * error from the device. In this case there is no good recovery + * strategy. Just make sure to disable everything and leave the device + * in a sane state. With a bit of luck the device might come back to + * life again later and userspace can try again. + */ + iio_buffer_deactivate_all(indio_dev); + err_free_config: iio_free_scan_mask(indio_dev, new_config.scan_mask); return ret; @@ -838,15 +855,8 @@ EXPORT_SYMBOL_GPL(iio_update_buffers); void iio_disable_all_buffers(struct iio_dev *indio_dev) { - struct iio_buffer *buffer, *_buffer; - iio_disable_buffers(indio_dev); - iio_free_scan_mask(indio_dev, indio_dev->active_scan_mask); - indio_dev->active_scan_mask = NULL; - - list_for_each_entry_safe(buffer, _buffer, - &indio_dev->buffer_list, buffer_list) - iio_buffer_deactivate(buffer); + iio_buffer_deactivate_all(indio_dev); } static ssize_t iio_buffer_store_enable(struct device *dev, From 884ca45613c47efe4b0b1238f6ee677d74fe3419 Mon Sep 17 00:00:00 2001 From: Tiberiu Breana Date: Mon, 18 May 2015 14:49:50 +0300 Subject: [PATCH 0485/1163] iio: accel: Add support for Sensortek STK8BA50 Minimal implementation of an IIO driver for the Sensortek STK8BA50 3-axis accelerometer. Datasheet: http://szgsensor.com/uploads/soft/141229/STK8BA50%D2%E5%BC%CE.pdf Includes: - ACPI support; - read_raw for x,y,z axes; - reading and setting the scale (range) parameter. - power management Signed-off-by: Tiberiu Breana Signed-off-by: Jonathan Cameron --- drivers/iio/accel/Kconfig | 10 ++ drivers/iio/accel/Makefile | 1 + drivers/iio/accel/stk8ba50.c | 302 +++++++++++++++++++++++++++++++++++ 3 files changed, 313 insertions(+) create mode 100644 drivers/iio/accel/stk8ba50.c diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig index 8bd8ccbe8187..00e7bcbdbe24 100644 --- a/drivers/iio/accel/Kconfig +++ b/drivers/iio/accel/Kconfig @@ -147,4 +147,14 @@ config STK8312 Choosing M will build the driver as a module. If so, the module will be called stk8312. +config STK8BA50 + tristate "Sensortek STK8BA50 3-Axis Accelerometer Driver" + depends on I2C + help + Say yes here to get support for the Sensortek STK8BA50 3-axis + accelerometer. + + Choosing M will build the driver as a module. If so, the module + will be called stk8ba50. + endmenu diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile index 8b327c19edef..ebd2675b2a02 100644 --- a/drivers/iio/accel/Makefile +++ b/drivers/iio/accel/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_MMA9551) += mma9551.o obj-$(CONFIG_MMA9553) += mma9553.o obj-$(CONFIG_STK8312) += stk8312.o +obj-$(CONFIG_STK8BA50) += stk8ba50.o obj-$(CONFIG_IIO_SSP_SENSORS_COMMONS) += ssp_accel_sensor.o diff --git a/drivers/iio/accel/stk8ba50.c b/drivers/iio/accel/stk8ba50.c new file mode 100644 index 000000000000..30950c6b36de --- /dev/null +++ b/drivers/iio/accel/stk8ba50.c @@ -0,0 +1,302 @@ +/** + * Sensortek STK8BA50 3-Axis Accelerometer + * + * Copyright (c) 2015, Intel Corporation. + * + * 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. + * + * STK8BA50 7-bit I2C address: 0x18. + */ + +#include +#include +#include +#include +#include +#include + +#define STK8BA50_REG_XOUT 0x02 +#define STK8BA50_REG_YOUT 0x04 +#define STK8BA50_REG_ZOUT 0x06 +#define STK8BA50_REG_RANGE 0x0F +#define STK8BA50_REG_POWMODE 0x11 +#define STK8BA50_REG_SWRST 0x14 + +#define STK8BA50_MODE_NORMAL 0 +#define STK8BA50_MODE_SUSPEND 1 +#define STK8BA50_MODE_POWERBIT BIT(7) +#define STK8BA50_DATA_SHIFT 6 +#define STK8BA50_RESET_CMD 0xB6 + +#define STK8BA50_DRIVER_NAME "stk8ba50" + +#define STK8BA50_SCALE_AVAIL "0.0384 0.0767 0.1534 0.3069" + +/* + * The accelerometer has four measurement ranges: + * +/-2g; +/-4g; +/-8g; +/-16g + * + * Acceleration values are 10-bit, 2's complement. + * Scales are calculated as following: + * + * scale1 = (2 + 2) * 9.81 / (2^10 - 1) = 0.0384 + * scale2 = (4 + 4) * 9.81 / (2^10 - 1) = 0.0767 + * etc. + * + * Scales are stored in this format: + * { , } + * + * Locally, the range is stored as a table index. + */ +static const int stk8ba50_scale_table[][2] = { + {3, 38400}, {5, 76700}, {8, 153400}, {12, 306900} +}; + +struct stk8ba50_data { + struct i2c_client *client; + struct mutex lock; + int range; +}; + +#define STK8BA50_ACCEL_CHANNEL(reg, axis) { \ + .type = IIO_ACCEL, \ + .address = reg, \ + .modified = 1, \ + .channel2 = IIO_MOD_##axis, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ +} + +static const struct iio_chan_spec stk8ba50_channels[] = { + STK8BA50_ACCEL_CHANNEL(STK8BA50_REG_XOUT, X), + STK8BA50_ACCEL_CHANNEL(STK8BA50_REG_YOUT, Y), + STK8BA50_ACCEL_CHANNEL(STK8BA50_REG_ZOUT, Z), +}; + +static IIO_CONST_ATTR(in_accel_scale_available, STK8BA50_SCALE_AVAIL); + +static struct attribute *stk8ba50_attributes[] = { + &iio_const_attr_in_accel_scale_available.dev_attr.attr, + NULL, +}; + +static const struct attribute_group stk8ba50_attribute_group = { + .attrs = stk8ba50_attributes +}; + +static int stk8ba50_read_accel(struct stk8ba50_data *data, u8 reg) +{ + int ret; + struct i2c_client *client = data->client; + + ret = i2c_smbus_read_word_data(client, reg); + if (ret < 0) { + dev_err(&client->dev, "register read failed\n"); + return ret; + } + + return sign_extend32(ret >> STK8BA50_DATA_SHIFT, 9); +} + +static int stk8ba50_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct stk8ba50_data *data = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_RAW: + mutex_lock(&data->lock); + *val = stk8ba50_read_accel(data, chan->address); + mutex_unlock(&data->lock); + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + *val = 0; + *val2 = stk8ba50_scale_table[data->range][1]; + return IIO_VAL_INT_PLUS_MICRO; + } + + return -EINVAL; +} + +static int stk8ba50_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + int ret; + int i; + int index = -1; + struct stk8ba50_data *data = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_SCALE: + if (val != 0) + return -EINVAL; + + for (i = 0; i < ARRAY_SIZE(stk8ba50_scale_table); i++) + if (val2 == stk8ba50_scale_table[i][1]) { + index = i; + break; + } + if (index < 0) + return -EINVAL; + + ret = i2c_smbus_write_byte_data(data->client, + STK8BA50_REG_RANGE, + stk8ba50_scale_table[index][0]); + if (ret < 0) + dev_err(&data->client->dev, + "failed to set measurement range\n"); + else + data->range = index; + + return ret; + } + + return -EINVAL; +} + +static const struct iio_info stk8ba50_info = { + .driver_module = THIS_MODULE, + .read_raw = stk8ba50_read_raw, + .write_raw = stk8ba50_write_raw, + .attrs = &stk8ba50_attribute_group, +}; + +static int stk8ba50_set_power(struct stk8ba50_data *data, bool mode) +{ + int ret; + u8 masked_reg; + struct i2c_client *client = data->client; + + ret = i2c_smbus_read_byte_data(client, STK8BA50_REG_POWMODE); + if (ret < 0) + goto exit_err; + + if (mode) + masked_reg = ret | STK8BA50_MODE_POWERBIT; + else + masked_reg = ret & (~STK8BA50_MODE_POWERBIT); + + ret = i2c_smbus_write_byte_data(client, STK8BA50_REG_POWMODE, + masked_reg); + if (ret < 0) + goto exit_err; + + return ret; + +exit_err: + dev_err(&client->dev, "failed to change sensor mode\n"); + return ret; +} + +static int stk8ba50_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + int ret; + struct iio_dev *indio_dev; + struct stk8ba50_data *data; + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); + if (!indio_dev) { + dev_err(&client->dev, "iio allocation failed!\n"); + return -ENOMEM; + } + + data = iio_priv(indio_dev); + data->client = client; + i2c_set_clientdata(client, indio_dev); + mutex_init(&data->lock); + + indio_dev->dev.parent = &client->dev; + indio_dev->info = &stk8ba50_info; + indio_dev->name = STK8BA50_DRIVER_NAME; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = stk8ba50_channels; + indio_dev->num_channels = ARRAY_SIZE(stk8ba50_channels); + + /* Reset all registers on startup */ + ret = i2c_smbus_write_byte_data(client, + STK8BA50_REG_SWRST, STK8BA50_RESET_CMD); + if (ret < 0) { + dev_err(&client->dev, "failed to reset sensor\n"); + return ret; + } + + /* The default range is +/-2g */ + data->range = 0; + + ret = iio_device_register(indio_dev); + if (ret < 0) { + dev_err(&client->dev, "device_register failed\n"); + stk8ba50_set_power(data, STK8BA50_MODE_SUSPEND); + } + + return ret; +} + +static int stk8ba50_remove(struct i2c_client *client) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(client); + + iio_device_unregister(indio_dev); + + return stk8ba50_set_power(iio_priv(indio_dev), STK8BA50_MODE_SUSPEND); +} + +#ifdef CONFIG_PM_SLEEP +static int stk8ba50_suspend(struct device *dev) +{ + struct stk8ba50_data *data; + + data = iio_priv(i2c_get_clientdata(to_i2c_client(dev))); + + return stk8ba50_set_power(data, STK8BA50_MODE_SUSPEND); +} + +static int stk8ba50_resume(struct device *dev) +{ + struct stk8ba50_data *data; + + data = iio_priv(i2c_get_clientdata(to_i2c_client(dev))); + + return stk8ba50_set_power(data, STK8BA50_MODE_NORMAL); +} + +static SIMPLE_DEV_PM_OPS(stk8ba50_pm_ops, stk8ba50_suspend, stk8ba50_resume); + +#define STK8BA50_PM_OPS (&stk8ba50_pm_ops) +#else +#define STK8BA50_PM_OPS NULL +#endif + +static const struct i2c_device_id stk8ba50_i2c_id[] = { + {"stk8ba50", 0}, + {} +}; + +static const struct acpi_device_id stk8ba50_acpi_id[] = { + {"STK8BA50", 0}, + {} +}; + +MODULE_DEVICE_TABLE(acpi, stk8ba50_acpi_id); + +static struct i2c_driver stk8ba50_driver = { + .driver = { + .name = "stk8ba50", + .pm = STK8BA50_PM_OPS, + .acpi_match_table = ACPI_PTR(stk8ba50_acpi_id), + }, + .probe = stk8ba50_probe, + .remove = stk8ba50_remove, + .id_table = stk8ba50_i2c_id, +}; + +module_i2c_driver(stk8ba50_driver); + +MODULE_AUTHOR("Tiberiu Breana "); +MODULE_DESCRIPTION("STK8BA50 3-Axis Accelerometer driver"); +MODULE_LICENSE("GPL v2"); From 163a1f19f45b4ee3cf7180bf78ea7f71948b33c8 Mon Sep 17 00:00:00 2001 From: Colin Cronin Date: Wed, 13 May 2015 18:05:15 -0700 Subject: [PATCH 0486/1163] Drivers: staging: comedi: comedi: Fixed comment spelling error Fixed a spelling error in a comment. Signed-off-by: Colin Cronin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/comedi.h b/drivers/staging/comedi/comedi.h index 745574077352..66edda190b75 100644 --- a/drivers/staging/comedi/comedi.h +++ b/drivers/staging/comedi/comedi.h @@ -217,7 +217,7 @@ #define SDF_RUNNING 0x08000000 /* subdevice is acquiring data */ #define SDF_LSAMPL 0x10000000 /* subdevice uses 32-bit samples */ #define SDF_PACKED 0x20000000 /* subdevice can do packed DIO */ -/* re recyle these flags for PWM */ +/* re recycle these flags for PWM */ #define SDF_PWM_COUNTER SDF_MODE0 /* PWM can automatically switch off */ #define SDF_PWM_HBRIDGE SDF_MODE1 /* PWM is signed (H-bridge) */ From f51ff7e40645891b211ed349d142e5c028a1c5e5 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Tue, 19 May 2015 19:57:49 +0200 Subject: [PATCH 0487/1163] Staging: comedi: fix line longer than 80 chars in cb_pcidas64.c This patch fixes coding style errors reported by checkpatch.pl for cb_pcidas64.c, about too long source code lines. Signed-off-by: Amaury Denoyelle Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index a94c33c3d962..f1bba2b6c935 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -243,7 +243,8 @@ enum adc_control0_contents { ADC_SOFT_GATE_BITS = 0x1, /* software gate */ ADC_EXT_GATE_BITS = 0x2, /* external digital gate */ ADC_ANALOG_GATE_BITS = 0x3, /* analog level gate */ - ADC_GATE_LEVEL_BIT = 0x4, /* level-sensitive gate (for digital) */ + /* level-sensitive gate (for digital) */ + ADC_GATE_LEVEL_BIT = 0x4, ADC_GATE_POLARITY_BIT = 0x8, /* gate active low */ ADC_START_TRIG_SOFT_BITS = 0x10, ADC_START_TRIG_EXT_BITS = 0x20, @@ -1381,7 +1382,9 @@ static int set_ai_fifo_segment_length(struct comedi_device *dev, return devpriv->ai_fifo_segment_length; } -/* adjusts the size of hardware fifo (which determines block size for dma xfers) */ +/* + * adjusts the size of hardware fifo (which determines block size for dma xfers) + */ static int set_ai_fifo_size(struct comedi_device *dev, unsigned int num_samples) { const struct pcidas64_board *thisboard = dev->board_ptr; @@ -1588,7 +1591,9 @@ static inline void warn_external_queue(struct comedi_device *dev) "Use internal AI channel queue (channels must be consecutive and use same range/aref)\n"); } -/* Their i2c requires a huge delay on setting clock or data high for some reason */ +/* + * their i2c requires a huge delay on setting clock or data high for some reason + */ static const int i2c_high_udelay = 1000; static const int i2c_low_udelay = 10; @@ -1987,7 +1992,8 @@ static unsigned int get_divisor(unsigned int ns, unsigned int flags) /* utility function that rounds desired timing to an achievable time, and * sets cmd members appropriately. - * adc paces conversions from master clock by dividing by (x + 3) where x is 24 bit number + * adc paces conversions from master clock by dividing by (x + 3) where x is + * 24 bit number */ static void check_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd) { From 85c12b82c6090c04838cf3ba7216afdfae6157cb Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Tue, 19 May 2015 19:57:50 +0200 Subject: [PATCH 0488/1163] Staging: comedi: fix style for multi-line comments in cb_pcidas64.c This patch reformat multi-line comments which are not properly written according to the kernel coding style in cb_pcidas64.c Signed-off-by: Amaury Denoyelle Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 140 ++++++++++++------- 1 file changed, 93 insertions(+), 47 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index f1bba2b6c935..3d646c19f352 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -155,8 +155,10 @@ static inline unsigned int dac_msb_4020_reg(unsigned int channel) } enum read_only_registers { - /* hardware status register, - * reading this apparently clears pending interrupts as well */ + /* + * hardware status register, + * reading this apparently clears pending interrupts as well + */ HW_STATUS_REG = 0x0, PIPE1_READ_REG = 0x4, ADC_READ_PNTR_REG = 0x8, @@ -301,7 +303,8 @@ enum calibration_contents { CAL_GAIN_BIT = 0x800, }; -/* calibration sources for 6025 are: +/* + * calibration sources for 6025 are: * 0 : ground * 1 : 10V * 2 : 5V @@ -661,8 +664,10 @@ static const struct hw_fifo_info ai_fifo_60xx = { .fifo_size_reg_mask = 0x7f, }; -/* maximum number of dma transfers we will chain together into a ring - * (and the maximum number of dma buffers we maintain) */ +/* + * maximum number of dma transfers we will chain together into a ring + * (and the maximum number of dma buffers we maintain) + */ #define MAX_AI_DMA_RING_COUNT (0x80000 / DMA_BUFFER_SIZE) #define MIN_AI_DMA_RING_COUNT (0x10000 / DMA_BUFFER_SIZE) #define AO_DMA_RING_COUNT (0x10000 / DMA_BUFFER_SIZE) @@ -1261,8 +1266,10 @@ static void enable_ai_interrupts(struct comedi_device *dev, bits = EN_ADC_OVERRUN_BIT | EN_ADC_DONE_INTR_BIT | EN_ADC_ACTIVE_INTR_BIT | EN_ADC_STOP_INTR_BIT; - /* Use pio transfer and interrupt on end of conversion - * if CMDF_WAKE_EOS flag is set. */ + /* + * Use pio transfer and interrupt on end of conversion + * if CMDF_WAKE_EOS flag is set. + */ if (cmd->flags & CMDF_WAKE_EOS) { /* 4020 doesn't support pio transfers except for fifo dregs */ if (thisboard->layout != LAYOUT_4020) @@ -1425,8 +1432,10 @@ static void init_stc_registers(struct comedi_device *dev) spin_lock_irqsave(&dev->spinlock, flags); - /* bit should be set for 6025, - * although docs say boards with <= 16 chans should be cleared XXX */ + /* + * bit should be set for 6025, + * although docs say boards with <= 16 chans should be cleared XXX + */ if (1) devpriv->adc_control1_bits |= ADC_QUEUE_CONFIG_BIT; writew(devpriv->adc_control1_bits, @@ -1689,8 +1698,10 @@ static void i2c_write(struct comedi_device *dev, unsigned int address, uint8_t bitstream; static const int read_bit = 0x1; - /* XXX need mutex to prevent simultaneous attempts to access - * eeprom and i2c bus */ + /* + * XXX need mutex to prevent simultaneous attempts to access + * eeprom and i2c bus + */ /* make sure we dont send anything to eeprom */ devpriv->plx_control_bits &= ~CTL_EE_CS; @@ -1782,14 +1793,18 @@ static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, cal_en_bit = CAL_EN_60XX_BIT; else cal_en_bit = CAL_EN_64XX_BIT; - /* select internal reference source to connect - * to channel 0 */ + /* + * select internal reference source to connect + * to channel 0 + */ writew(cal_en_bit | adc_src_bits(devpriv->calibration_source), devpriv->main_iobase + CALIBRATION_REG); } else { - /* make sure internal calibration source - * is turned off */ + /* + * make sure internal calibration source + * is turned off + */ writew(0, devpriv->main_iobase + CALIBRATION_REG); } /* load internal queue */ @@ -1821,8 +1836,10 @@ static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, devpriv->i2c_cal_range_bits |= attenuate_bit(channel); else devpriv->i2c_cal_range_bits &= ~attenuate_bit(channel); - /* update calibration/range i2c register only if necessary, - * as it is very slow */ + /* + * update calibration/range i2c register only if necessary, + * as it is very slow + */ if (old_cal_range_bits != devpriv->i2c_cal_range_bits) { uint8_t i2c_data = devpriv->i2c_cal_range_bits; @@ -1830,10 +1847,12 @@ static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, sizeof(i2c_data)); } - /* 4020 manual asks that sample interval register to be set + /* + * 4020 manual asks that sample interval register to be set * before writing to convert register. * Using somewhat arbitrary setting of 4 master clock ticks - * = 0.1 usec */ + * = 0.1 usec + */ writew(0, devpriv->main_iobase + ADC_SAMPLE_INTERVAL_UPPER_REG); writew(2, devpriv->main_iobase + ADC_SAMPLE_INTERVAL_LOWER_REG); } @@ -1968,9 +1987,11 @@ static int ai_config_insn(struct comedi_device *dev, struct comedi_subdevice *s, return -EINVAL; } -/* Gets nearest achievable timing given master clock speed, does not +/* + * Gets nearest achievable timing given master clock speed, does not * take into account possible minimum/maximum divisor values. Used - * by other timing checking functions. */ + * by other timing checking functions. + */ static unsigned int get_divisor(unsigned int ns, unsigned int flags) { unsigned int divisor; @@ -1990,7 +2011,8 @@ static unsigned int get_divisor(unsigned int ns, unsigned int flags) return divisor; } -/* utility function that rounds desired timing to an achievable time, and +/* + * utility function that rounds desired timing to an achievable time, and * sets cmd members appropriately. * adc paces conversions from master clock by dividing by (x + 3) where x is * 24 bit number @@ -2474,8 +2496,10 @@ static int setup_channel_queue(struct comedi_device *dev, devpriv->main_iobase + ADC_QUEUE_FIFO_REG); } - /* doing a queue clear is not specified in board docs, - * but required for reliable operation */ + /* + * doing a queue clear is not specified in board docs, + * but required for reliable operation + */ writew(0, devpriv->main_iobase + ADC_QUEUE_CLEAR_REG); /* prime queue holding register */ writew(0, devpriv->main_iobase + ADC_QUEUE_LOAD_REG); @@ -2498,8 +2522,10 @@ static int setup_channel_queue(struct comedi_device *dev, devpriv->i2c_cal_range_bits &= ~attenuate_bit(channel); } - /* update calibration/range i2c register only if necessary, - * as it is very slow */ + /* + * update calibration/range i2c register only if necessary, + * as it is very slow + */ if (old_cal_range_bits != devpriv->i2c_cal_range_bits) { uint8_t i2c_data = devpriv->i2c_cal_range_bits; @@ -2516,11 +2542,13 @@ static inline void load_first_dma_descriptor(struct comedi_device *dev, { struct pcidas64_private *devpriv = dev->private; - /* The transfer size, pci address, and local address registers + /* + * The transfer size, pci address, and local address registers * are supposedly unused during chained dma, * but I have found that left over values from last operation * occasionally cause problems with transfer of first dma - * block. Initializing them to zero seems to fix the problem. */ + * block. Initializing them to zero seems to fix the problem. + */ if (dma_channel) { writel(0, devpriv->plx9080_iobase + PLX_DMA1_TRANSFER_SIZE_REG); @@ -2675,15 +2703,19 @@ static void pio_drain_ai_fifo_16(struct comedi_device *dev) 0x7fff; write_index = readw(devpriv->main_iobase + ADC_WRITE_PNTR_REG) & 0x7fff; - /* Get most significant bits (grey code). + /* + * Get most significant bits (grey code). * Different boards use different code so use a scheme * that doesn't depend on encoding. This read must * occur after reading least significant 15 bits to avoid race - * with fifo switching to next segment. */ + * with fifo switching to next segment. + */ prepost_bits = readw(devpriv->main_iobase + PREPOST_REG); - /* if read and write pointers are not on the same fifo segment, - * read to the end of the read segment */ + /* + * if read and write pointers are not on the same fifo segment, + * read to the end of the read segment + */ read_segment = adc_upper_read_ptr_code(prepost_bits); write_segment = adc_upper_write_ptr_code(prepost_bits); @@ -2712,7 +2744,8 @@ static void pio_drain_ai_fifo_16(struct comedi_device *dev) } while (read_segment != write_segment); } -/* Read from 32 bit wide ai fifo of 4020 - deal with insane grey coding of +/* + * Read from 32 bit wide ai fifo of 4020 - deal with insane grey coding of * pointers. The pci-4020 hardware only supports dma transfers (it only * supports the use of pio for draining the last remaining points from the * fifo when a data acquisition operation has completed). @@ -2790,8 +2823,10 @@ static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel) devpriv->ai_dma_index = (devpriv->ai_dma_index + 1) % ai_dma_ring_count(thisboard); } - /* XXX check for dma ring buffer overrun - * (use end-of-chain bit to mark last unused buffer) */ + /* + * XXX check for dma ring buffer overrun + * (use end-of-chain bit to mark last unused buffer) + */ } static void handle_ai_interrupt(struct comedi_device *dev, @@ -2939,8 +2974,10 @@ static unsigned int load_ao_dma_buffer(struct comedi_device *dev, next_bits = le32_to_cpu(devpriv->ao_dma_desc[buffer_index].next); next_bits |= PLX_END_OF_CHAIN_BIT; devpriv->ao_dma_desc[buffer_index].next = cpu_to_le32(next_bits); - /* clear end of chain bit on previous buffer now that we have set it - * for the last buffer */ + /* + * clear end of chain bit on previous buffer now that we have set it + * for the last buffer + */ next_bits = le32_to_cpu(devpriv->ao_dma_desc[prev_buffer_index].next); next_bits &= ~PLX_END_OF_CHAIN_BIT; devpriv->ao_dma_desc[prev_buffer_index].next = cpu_to_le32(next_bits); @@ -3033,9 +3070,11 @@ static irqreturn_t handle_interrupt(int irq, void *d) plx_status = readl(devpriv->plx9080_iobase + PLX_INTRCS_REG); status = readw(devpriv->main_iobase + HW_STATUS_REG); - /* an interrupt before all the postconfig stuff gets done could + /* + * an interrupt before all the postconfig stuff gets done could * cause a NULL dereference if we continue through the - * interrupt handler */ + * interrupt handler + */ if (!dev->attached) return IRQ_HANDLED; @@ -3195,8 +3234,10 @@ static int prep_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd) unsigned int nbytes; int i; - /* clear queue pointer too, since external queue has - * weird interactions with ao fifo */ + /* + * clear queue pointer too, since external queue has + * weird interactions with ao fifo + */ writew(0, devpriv->main_iobase + ADC_QUEUE_CLEAR_REG); writew(0, devpriv->main_iobase + DAC_BUFFER_CLEAR_REG); @@ -3465,7 +3506,8 @@ static int dio_60xx_wbits(struct comedi_device *dev, return insn->n; } -/* pci-6025 8800 caldac: +/* + * pci-6025 8800 caldac: * address 0 == dac channel 0 offset * address 1 == dac channel 0 gain * address 2 == dac channel 1 offset @@ -3475,7 +3517,8 @@ static int dio_60xx_wbits(struct comedi_device *dev, * address 6 == coarse adc gain * address 7 == fine adc gain */ -/* pci-6402/16 uses all 8 channels for dac: +/* + * pci-6402/16 uses all 8 channels for dac: * address 0 == dac channel 0 fine gain * address 1 == dac channel 0 coarse gain * address 2 == dac channel 0 coarse offset @@ -3484,7 +3527,7 @@ static int dio_60xx_wbits(struct comedi_device *dev, * address 5 == dac channel 1 coarse gain * address 6 == dac channel 0 fine offset * address 7 == dac channel 1 fine offset -*/ + */ static int caldac_8800_write(struct comedi_device *dev, unsigned int address, uint8_t value) @@ -3744,7 +3787,8 @@ static int eeprom_read_insn(struct comedi_device *dev, return 1; } -/* Allocate and initialize the subdevice structures. +/* + * Allocate and initialize the subdevice structures. */ static int setup_subdevices(struct comedi_device *dev) { @@ -3779,8 +3823,10 @@ static int setup_subdevices(struct comedi_device *dev) s->cancel = ai_cancel; if (thisboard->layout == LAYOUT_4020) { uint8_t data; - /* set adc to read from inputs - * (not internal calibration sources) */ + /* + * set adc to read from inputs + * (not internal calibration sources) + */ devpriv->i2c_cal_range_bits = adc_src_4020_bits(4); /* set channels to +-5 volt input ranges */ for (i = 0; i < s->n_chan; i++) From ad5b0d07b1ae1bc82d7dbca943ebae95361a10fb Mon Sep 17 00:00:00 2001 From: Jagan Teki Date: Mon, 18 May 2015 19:50:17 +0530 Subject: [PATCH 0489/1163] staging: android: Add more help description on Kconfig This patch adds more help description on android Kconfig for - lowmemory killer - Timed gpio (same for timed output) Signed-off-by: Jagan Teki Cc: Greg Kroah-Hartman Cc: Brian Swetland Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/Kconfig | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig index 8feb9048e62f..24d657b3ab99 100644 --- a/drivers/staging/android/Kconfig +++ b/drivers/staging/android/Kconfig @@ -22,11 +22,20 @@ config ANDROID_TIMED_GPIO tristate "Android timed gpio driver" depends on GPIOLIB && ANDROID_TIMED_OUTPUT default n + ---help--- + Unlike generic gpio is to allow programs to access and manipulate gpio + registers from user space, timed output/gpio is a system to allow changing + a gpio pin and restore it automatically after a specified timeout. config ANDROID_LOW_MEMORY_KILLER bool "Android Low Memory Killer" ---help--- - Registers processes to be killed when memory is low + Registers processes to be killed when low memory conditions, this is useful + as there is no particular swap space on android. + + The registered process will kills according to the priorities in android init + scripts (/init.rc), and it defines priority values with minimum free memory size + for each priority. config SYNC bool "Synchronization framework" From 283d93041a424a6152626940f4bc0deb78faacae Mon Sep 17 00:00:00 2001 From: Shailendra Verma Date: Tue, 19 May 2015 20:29:00 +0530 Subject: [PATCH 0490/1163] Staging:Android:ion - Fix for memory leak if ion device registration get failed. Fix to avoid possible memory leak if the ion device registration get failed.Free the allocated device creation memory before return in case the ion device registration get failed. Signed-off-by: Shailendra Verma Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index b0b96ab31954..6f4811263557 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -1579,6 +1579,7 @@ struct ion_device *ion_device_create(long (*custom_ioctl) ret = misc_register(&idev->dev); if (ret) { pr_err("ion: failed to register misc device.\n"); + kfree(idev); return ERR_PTR(ret); } From 0f570fc0ae56a5b7c8cdd1d1dff4e77ea2b8fa1c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 13 May 2015 13:21:55 -0400 Subject: [PATCH 0491/1163] staging: unisys: visorchipset_file_{init, cleanup}(): mark static Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchipset.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index ca22f49f386b..66ae3d0b6441 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -2351,7 +2351,7 @@ static const struct file_operations visorchipset_fops = { .mmap = visorchipset_mmap, }; -int +static int visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel) { int rc = 0; @@ -2460,7 +2460,7 @@ cleanup: return rc; } -void +static void visorchipset_file_cleanup(dev_t major_dev) { if (file_cdev.ops) From fa2cc0af658afbee8fa16fd3f40d53c58493da1d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 13 May 2015 13:21:56 -0400 Subject: [PATCH 0492/1163] staging: unisys: Remove unused visorchipset_save_message() Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorchipset.c | 56 ------------------- 1 file changed, 56 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 66ae3d0b6441..d88f11fa4258 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -933,62 +933,6 @@ enum crash_obj_type { CRASH_BUS, }; -void -visorchipset_save_message(struct controlvm_message *msg, - enum crash_obj_type type) -{ - u32 crash_msg_offset; - u16 crash_msg_count; - - /* get saved message count */ - if (visorchannel_read(controlvm_channel, - offsetof(struct spar_controlvm_channel_protocol, - saved_crash_message_count), - &crash_msg_count, sizeof(u16)) < 0) { - POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC, - POSTCODE_SEVERITY_ERR); - return; - } - - if (crash_msg_count != CONTROLVM_CRASHMSG_MAX) { - POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC, - crash_msg_count, - POSTCODE_SEVERITY_ERR); - return; - } - - /* get saved crash message offset */ - if (visorchannel_read(controlvm_channel, - offsetof(struct spar_controlvm_channel_protocol, - saved_crash_message_offset), - &crash_msg_offset, sizeof(u32)) < 0) { - POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC, - POSTCODE_SEVERITY_ERR); - return; - } - - if (type == CRASH_BUS) { - if (visorchannel_write(controlvm_channel, - crash_msg_offset, - msg, - sizeof(struct controlvm_message)) < 0) { - POSTCODE_LINUX_2(SAVE_MSG_BUS_FAILURE_PC, - POSTCODE_SEVERITY_ERR); - return; - } - } else { /* CRASH_DEV */ - if (visorchannel_write(controlvm_channel, - crash_msg_offset + - sizeof(struct controlvm_message), msg, - sizeof(struct controlvm_message)) < 0) { - POSTCODE_LINUX_2(SAVE_MSG_DEV_FAILURE_PC, - POSTCODE_SEVERITY_ERR); - return; - } - } -} -EXPORT_SYMBOL_GPL(visorchipset_save_message); - static void bus_responder(enum controlvm_id cmd_id, u32 bus_no, int response) { From d3368a58776bfdd7ca22db35ea83567e9657b6e5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 13 May 2015 13:21:57 -0400 Subject: [PATCH 0493/1163] staging: unisys: visorchipset_init(): Simplify initial checks Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorchipset.c | 40 ++++++++----------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index d88f11fa4258..88a2b5e52323 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -1474,15 +1474,14 @@ initialize_controlvm_payload(void) /* Send ACTION=online for DEVPATH=/sys/devices/platform/visorchipset. * Returns CONTROLVM_RESP_xxx code. */ -int +static int visorchipset_chipset_ready(void) { kobject_uevent(&visorchipset_platform_device.dev.kobj, KOBJ_ONLINE); return CONTROLVM_RESP_SUCCESS; } -EXPORT_SYMBOL_GPL(visorchipset_chipset_ready); -int +static int visorchipset_chipset_selftest(void) { char env_selftest[20]; @@ -1493,18 +1492,16 @@ visorchipset_chipset_selftest(void) envp); return CONTROLVM_RESP_SUCCESS; } -EXPORT_SYMBOL_GPL(visorchipset_chipset_selftest); /* Send ACTION=offline for DEVPATH=/sys/devices/platform/visorchipset. * Returns CONTROLVM_RESP_xxx code. */ -int +static int visorchipset_chipset_notready(void) { kobject_uevent(&visorchipset_platform_device.dev.kobj, KOBJ_OFFLINE); return CONTROLVM_RESP_SUCCESS; } -EXPORT_SYMBOL_GPL(visorchipset_chipset_notready); static void chipset_ready(struct controlvm_message_header *msg_hdr) @@ -2099,14 +2096,13 @@ device_destroy_response(u32 bus_no, u32 dev_no, int response) device_responder(CONTROLVM_DEVICE_DESTROY, bus_no, dev_no, response); } -void +static void visorchipset_device_pause_response(u32 bus_no, u32 dev_no, int response) { device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE, bus_no, dev_no, response, segment_state_standby); } -EXPORT_SYMBOL_GPL(visorchipset_device_pause_response); static void device_resume_response(u32 bus_no, u32 dev_no, int response) @@ -2327,28 +2323,26 @@ visorchipset_init(struct acpi_device *acpi_device) { int rc = 0; u64 addr; + int tmp_sz = sizeof(struct spar_controlvm_channel_protocol); + uuid_le uuid = SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID; + + addr = controlvm_get_channel_address(); + if (!addr) + return -ENODEV; memset(&busdev_notifiers, 0, sizeof(busdev_notifiers)); memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info)); memset(&livedump_info, 0, sizeof(livedump_info)); atomic_set(&livedump_info.buffers_in_use, 0); - addr = controlvm_get_channel_address(); - if (addr) { - int tmp_sz = sizeof(struct spar_controlvm_channel_protocol); - uuid_le uuid = SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID; - controlvm_channel = - visorchannel_create_with_lock(addr, tmp_sz, - GFP_KERNEL, uuid); - if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT( - visorchannel_get_header(controlvm_channel))) { - initialize_controlvm_payload(); - } else { - visorchannel_destroy(controlvm_channel); - controlvm_channel = NULL; - return -ENODEV; - } + controlvm_channel = visorchannel_create_with_lock(addr, tmp_sz, + GFP_KERNEL, uuid); + if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT( + visorchannel_get_header(controlvm_channel))) { + initialize_controlvm_payload(); } else { + visorchannel_destroy(controlvm_channel); + controlvm_channel = NULL; return -ENODEV; } From 5d0adb24181cda13cab63c863647ec19a7f5dc9f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 13 May 2015 13:21:58 -0400 Subject: [PATCH 0494/1163] staging: unisys: Remove unused livedump_info Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchipset.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 88a2b5e52323..e6d7075ab8fb 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -135,22 +135,6 @@ struct visor_controlvm_payload_info { static struct visor_controlvm_payload_info controlvm_payload_info; -/* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE / - * CONTROLVM_DUMP_GETTEXTDUMP / CONTROLVM_DUMP_COMPLETE conversation. - */ -struct visor_livedump_info { - struct controlvm_message_header dumpcapture_header; - struct controlvm_message_header gettextdump_header; - struct controlvm_message_header dumpcomplete_header; - bool gettextdump_outstanding; - u32 crc32; - unsigned long length; - atomic_t buffers_in_use; - unsigned long destination; -}; - -static struct visor_livedump_info livedump_info; - /* The following globals are used to handle the scenario where we are unable to * offload the payload from a controlvm message due to memory requirements. In * this scenario, we simply stash the controlvm message, then attempt to @@ -2332,8 +2316,6 @@ visorchipset_init(struct acpi_device *acpi_device) memset(&busdev_notifiers, 0, sizeof(busdev_notifiers)); memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info)); - memset(&livedump_info, 0, sizeof(livedump_info)); - atomic_set(&livedump_info.buffers_in_use, 0); controlvm_channel = visorchannel_create_with_lock(addr, tmp_sz, GFP_KERNEL, uuid); From 372d872a0012408cac6973d72dda0cec13ccb9e6 Mon Sep 17 00:00:00 2001 From: David Kershner Date: Wed, 13 May 2015 13:21:59 -0400 Subject: [PATCH 0495/1163] staging: unisys: Remove appos_subsystems.h Get rid of common-spar/include/diagnostics/appos_subsystems.h. No one is using it. Signed-off-by: David Kershner Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../include/diagnostics/appos_subsystems.h | 310 ------------------ drivers/staging/unisys/include/uisutils.h | 1 - 2 files changed, 311 deletions(-) delete mode 100644 drivers/staging/unisys/common-spar/include/diagnostics/appos_subsystems.h diff --git a/drivers/staging/unisys/common-spar/include/diagnostics/appos_subsystems.h b/drivers/staging/unisys/common-spar/include/diagnostics/appos_subsystems.h deleted file mode 100644 index 18cc9ed2748b..000000000000 --- a/drivers/staging/unisys/common-spar/include/diagnostics/appos_subsystems.h +++ /dev/null @@ -1,310 +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. - */ - -/* Please note that this file is to be used ONLY for defining diagnostic - * subsystem values for the appos (sPAR Linux service partitions) component. - */ -#ifndef __APPOS_SUBSYSTEMS_H__ -#define __APPOS_SUBSYSTEMS_H__ - -#ifdef __KERNEL__ -#include -#include -#else -#include -#include -#endif - -static inline char * -subsys_unknown_to_s(int subsys, char *s, int n) -{ - snprintf(s, n, "SUBSYS-%-2.2d", subsys); - s[n - 1] = '\0'; - return s; -} - -#define SUBSYS_TO_MASK(subsys) (1ULL << (subsys)) - -/* The first SUBSYS_APPOS_MAX subsystems are the same for each AppOS type - * (IOVM, SMS, etc.) The rest have unique values for each AppOS type. - */ -#define SUBSYS_APPOS_MAX 16 - -#define SUBSYS_APPOS_DEFAULT 1 /* or "other" */ -#define SUBSYS_APPOS_CHIPSET 2 /* controlvm and other */ - /* low-level sPAR activity */ -#define SUBSYS_APPOS_BUS 3 /* sPAR bus */ -/* DAK #define SUBSYS_APPOS_DIAG 4 // diagnostics and dump */ -#define SUBSYS_APPOS_CHANNELACCESS 5 /* generic channel access */ -#define SUBSYS_APPOS_NICCLIENT 6 /* virtual NIC client */ -#define SUBSYS_APPOS_HBACLIENT 7 /* virtual HBA client */ -#define SUBSYS_APPOS_CONSOLESERIAL 8 /* sPAR virtual serial console */ -#define SUBSYS_APPOS_UISLIB 9 /* */ -#define SUBSYS_APPOS_VRTCUPDD 10 /* */ -#define SUBSYS_APPOS_WATCHDOG 11 /* watchdog timer and healthcheck */ -#define SUBSYS_APPOS_13 13 /* available */ -#define SUBSYS_APPOS_14 14 /* available */ -#define SUBSYS_APPOS_15 15 /* available */ -#define SUBSYS_APPOS_16 16 /* available */ -static inline char * -subsys_generic_to_s(int subsys, char *s, int n) -{ - switch (subsys) { - case SUBSYS_APPOS_DEFAULT: - strncpy(s, "APPOS_DEFAULT", n); - break; - case SUBSYS_APPOS_CHIPSET: - strncpy(s, "APPOS_CHIPSET", n); - break; - case SUBSYS_APPOS_BUS: - strncpy(s, "APPOS_BUS", n); - break; - case SUBSYS_APPOS_CHANNELACCESS: - strncpy(s, "APPOS_CHANNELACCESS", n); - break; - case SUBSYS_APPOS_NICCLIENT: - strncpy(s, "APPOS_NICCLIENT", n); - break; - case SUBSYS_APPOS_HBACLIENT: - strncpy(s, "APPOS_HBACLIENT", n); - break; - case SUBSYS_APPOS_CONSOLESERIAL: - strncpy(s, "APPOS_CONSOLESERIAL", n); - break; - case SUBSYS_APPOS_UISLIB: - strncpy(s, "APPOS_UISLIB", n); - break; - case SUBSYS_APPOS_VRTCUPDD: - strncpy(s, "APPOS_VRTCUPDD", n); - break; - case SUBSYS_APPOS_WATCHDOG: - strncpy(s, "APPOS_WATCHDOG", n); - break; - case SUBSYS_APPOS_13: - strncpy(s, "APPOS_13", n); - break; - case SUBSYS_APPOS_14: - strncpy(s, "APPOS_14", n); - break; - case SUBSYS_APPOS_15: - strncpy(s, "APPOS_15", n); - break; - case SUBSYS_APPOS_16: - strncpy(s, "APPOS_16", n); - break; - default: - subsys_unknown_to_s(subsys, s, n); - break; - } - s[n - 1] = '\0'; - return s; -} - -/* CONSOLE */ - -#define SUBSYS_CONSOLE_VIDEO (SUBSYS_APPOS_MAX + 1) /* 17 */ -#define SUBSYS_CONSOLE_KBDMOU (SUBSYS_APPOS_MAX + 2) /* 18 */ -#define SUBSYS_CONSOLE_04 (SUBSYS_APPOS_MAX + 4) -#define SUBSYS_CONSOLE_05 (SUBSYS_APPOS_MAX + 5) -#define SUBSYS_CONSOLE_06 (SUBSYS_APPOS_MAX + 6) -#define SUBSYS_CONSOLE_07 (SUBSYS_APPOS_MAX + 7) -#define SUBSYS_CONSOLE_08 (SUBSYS_APPOS_MAX + 8) -#define SUBSYS_CONSOLE_09 (SUBSYS_APPOS_MAX + 9) -#define SUBSYS_CONSOLE_10 (SUBSYS_APPOS_MAX + 10) -#define SUBSYS_CONSOLE_11 (SUBSYS_APPOS_MAX + 11) -#define SUBSYS_CONSOLE_12 (SUBSYS_APPOS_MAX + 12) -#define SUBSYS_CONSOLE_13 (SUBSYS_APPOS_MAX + 13) -#define SUBSYS_CONSOLE_14 (SUBSYS_APPOS_MAX + 14) -#define SUBSYS_CONSOLE_15 (SUBSYS_APPOS_MAX + 15) -#define SUBSYS_CONSOLE_16 (SUBSYS_APPOS_MAX + 16) -#define SUBSYS_CONSOLE_17 (SUBSYS_APPOS_MAX + 17) -#define SUBSYS_CONSOLE_18 (SUBSYS_APPOS_MAX + 18) -#define SUBSYS_CONSOLE_19 (SUBSYS_APPOS_MAX + 19) -#define SUBSYS_CONSOLE_20 (SUBSYS_APPOS_MAX + 20) -#define SUBSYS_CONSOLE_21 (SUBSYS_APPOS_MAX + 21) -#define SUBSYS_CONSOLE_22 (SUBSYS_APPOS_MAX + 22) -#define SUBSYS_CONSOLE_23 (SUBSYS_APPOS_MAX + 23) -#define SUBSYS_CONSOLE_24 (SUBSYS_APPOS_MAX + 24) -#define SUBSYS_CONSOLE_25 (SUBSYS_APPOS_MAX + 25) -#define SUBSYS_CONSOLE_26 (SUBSYS_APPOS_MAX + 26) -#define SUBSYS_CONSOLE_27 (SUBSYS_APPOS_MAX + 27) -#define SUBSYS_CONSOLE_28 (SUBSYS_APPOS_MAX + 28) -#define SUBSYS_CONSOLE_29 (SUBSYS_APPOS_MAX + 29) -#define SUBSYS_CONSOLE_30 (SUBSYS_APPOS_MAX + 30) -#define SUBSYS_CONSOLE_31 (SUBSYS_APPOS_MAX + 31) -#define SUBSYS_CONSOLE_32 (SUBSYS_APPOS_MAX + 32) -#define SUBSYS_CONSOLE_33 (SUBSYS_APPOS_MAX + 33) -#define SUBSYS_CONSOLE_34 (SUBSYS_APPOS_MAX + 34) -#define SUBSYS_CONSOLE_35 (SUBSYS_APPOS_MAX + 35) -#define SUBSYS_CONSOLE_36 (SUBSYS_APPOS_MAX + 36) -#define SUBSYS_CONSOLE_37 (SUBSYS_APPOS_MAX + 37) -#define SUBSYS_CONSOLE_38 (SUBSYS_APPOS_MAX + 38) -#define SUBSYS_CONSOLE_39 (SUBSYS_APPOS_MAX + 39) -#define SUBSYS_CONSOLE_40 (SUBSYS_APPOS_MAX + 40) -#define SUBSYS_CONSOLE_41 (SUBSYS_APPOS_MAX + 41) -#define SUBSYS_CONSOLE_42 (SUBSYS_APPOS_MAX + 42) -#define SUBSYS_CONSOLE_43 (SUBSYS_APPOS_MAX + 43) -#define SUBSYS_CONSOLE_44 (SUBSYS_APPOS_MAX + 44) -#define SUBSYS_CONSOLE_45 (SUBSYS_APPOS_MAX + 45) -#define SUBSYS_CONSOLE_46 (SUBSYS_APPOS_MAX + 46) - -static inline char * -subsys_console_to_s(int subsys, char *s, int n) -{ - switch (subsys) { - case SUBSYS_CONSOLE_VIDEO: - strncpy(s, "CONSOLE_VIDEO", n); - break; - case SUBSYS_CONSOLE_KBDMOU: - strncpy(s, "CONSOLE_KBDMOU", n); - break; - case SUBSYS_CONSOLE_04: - strncpy(s, "CONSOLE_04", n); - break; - case SUBSYS_CONSOLE_05: - strncpy(s, "CONSOLE_05", n); - break; - case SUBSYS_CONSOLE_06: - strncpy(s, "CONSOLE_06", n); - break; - case SUBSYS_CONSOLE_07: - strncpy(s, "CONSOLE_07", n); - break; - case SUBSYS_CONSOLE_08: - strncpy(s, "CONSOLE_08", n); - break; - case SUBSYS_CONSOLE_09: - strncpy(s, "CONSOLE_09", n); - break; - case SUBSYS_CONSOLE_10: - strncpy(s, "CONSOLE_10", n); - break; - case SUBSYS_CONSOLE_11: - strncpy(s, "CONSOLE_11", n); - break; - case SUBSYS_CONSOLE_12: - strncpy(s, "CONSOLE_12", n); - break; - case SUBSYS_CONSOLE_13: - strncpy(s, "CONSOLE_13", n); - break; - case SUBSYS_CONSOLE_14: - strncpy(s, "CONSOLE_14", n); - break; - case SUBSYS_CONSOLE_15: - strncpy(s, "CONSOLE_15", n); - break; - case SUBSYS_CONSOLE_16: - strncpy(s, "CONSOLE_16", n); - break; - case SUBSYS_CONSOLE_17: - strncpy(s, "CONSOLE_17", n); - break; - case SUBSYS_CONSOLE_18: - strncpy(s, "CONSOLE_18", n); - break; - case SUBSYS_CONSOLE_19: - strncpy(s, "CONSOLE_19", n); - break; - case SUBSYS_CONSOLE_20: - strncpy(s, "CONSOLE_20", n); - break; - case SUBSYS_CONSOLE_21: - strncpy(s, "CONSOLE_21", n); - break; - case SUBSYS_CONSOLE_22: - strncpy(s, "CONSOLE_22", n); - break; - case SUBSYS_CONSOLE_23: - strncpy(s, "CONSOLE_23", n); - break; - case SUBSYS_CONSOLE_24: - strncpy(s, "CONSOLE_24", n); - break; - case SUBSYS_CONSOLE_25: - strncpy(s, "CONSOLE_25", n); - break; - case SUBSYS_CONSOLE_26: - strncpy(s, "CONSOLE_26", n); - break; - case SUBSYS_CONSOLE_27: - strncpy(s, "CONSOLE_27", n); - break; - case SUBSYS_CONSOLE_28: - strncpy(s, "CONSOLE_28", n); - break; - case SUBSYS_CONSOLE_29: - strncpy(s, "CONSOLE_29", n); - break; - case SUBSYS_CONSOLE_30: - strncpy(s, "CONSOLE_30", n); - break; - case SUBSYS_CONSOLE_31: - strncpy(s, "CONSOLE_31", n); - break; - case SUBSYS_CONSOLE_32: - strncpy(s, "CONSOLE_32", n); - break; - case SUBSYS_CONSOLE_33: - strncpy(s, "CONSOLE_33", n); - break; - case SUBSYS_CONSOLE_34: - strncpy(s, "CONSOLE_34", n); - break; - case SUBSYS_CONSOLE_35: - strncpy(s, "CONSOLE_35", n); - break; - case SUBSYS_CONSOLE_36: - strncpy(s, "CONSOLE_36", n); - break; - case SUBSYS_CONSOLE_37: - strncpy(s, "CONSOLE_37", n); - break; - case SUBSYS_CONSOLE_38: - strncpy(s, "CONSOLE_38", n); - break; - case SUBSYS_CONSOLE_39: - strncpy(s, "CONSOLE_39", n); - break; - case SUBSYS_CONSOLE_40: - strncpy(s, "CONSOLE_40", n); - break; - case SUBSYS_CONSOLE_41: - strncpy(s, "CONSOLE_41", n); - break; - case SUBSYS_CONSOLE_42: - strncpy(s, "CONSOLE_42", n); - break; - case SUBSYS_CONSOLE_43: - strncpy(s, "CONSOLE_43", n); - break; - case SUBSYS_CONSOLE_44: - strncpy(s, "CONSOLE_44", n); - break; - case SUBSYS_CONSOLE_45: - strncpy(s, "CONSOLE_45", n); - break; - case SUBSYS_CONSOLE_46: - strncpy(s, "CONSOLE_46", n); - break; - default: - subsys_unknown_to_s(subsys, s, n); - break; - } - s[n - 1] = '\0'; - return s; -} - -#endif diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 4514772323ac..d58858b21f99 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -32,7 +32,6 @@ #include "channel.h" #include "uisthread.h" #include "uisqueue.h" -#include "diagnostics/appos_subsystems.h" #include "vbusdeviceinfo.h" #include From 0f41c727fc5c9b634dd8dfa985d1f73e0286cf1d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 13 May 2015 13:22:00 -0400 Subject: [PATCH 0496/1163] staging: unisys: Include missing headers This preps for the possible build breakage in the next few patches. Signed-off-by: Jes Sorensen [updated changelog to reflect new patch order; instead of 'fixes' the patch 'prevents' - dcz] Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/guestlinuxdebug.h | 1 - drivers/staging/unisys/include/vbushelper.h | 2 -- drivers/staging/unisys/visorbus/visorbus_main.c | 2 +- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/unisys/include/guestlinuxdebug.h b/drivers/staging/unisys/include/guestlinuxdebug.h index 98150aa5bd01..82ee565395ba 100644 --- a/drivers/staging/unisys/include/guestlinuxdebug.h +++ b/drivers/staging/unisys/include/guestlinuxdebug.h @@ -22,7 +22,6 @@ * ISSUE_IO_VMCALL_POSTCODE_SEVERITY */ /******* INFO ON ISSUE_POSTCODE_LINUX() BELOW *******/ -#include "vmcallinterface.h" enum driver_pc { /* POSTCODE driver identifier tuples */ /* visorchipset driver files */ VISOR_CHIPSET_PC = 0xA0, diff --git a/drivers/staging/unisys/include/vbushelper.h b/drivers/staging/unisys/include/vbushelper.h index 84abe5f99f54..f272975b2920 100644 --- a/drivers/staging/unisys/include/vbushelper.h +++ b/drivers/staging/unisys/include/vbushelper.h @@ -18,8 +18,6 @@ #ifndef __VBUSHELPER_H__ #define __VBUSHELPER_H__ -#include "vbusdeviceinfo.h" - /* TARGET_HOSTNAME specified as -DTARGET_HOSTNAME=\"thename\" on the * command line */ diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 77afa9dbbdc8..114a765dab59 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -23,7 +23,7 @@ #include "periodic_work.h" #include "vbuschannel.h" #include "guestlinuxdebug.h" -#include "vbusdeviceinfo.h" +#include "vmcallinterface.h" #define MYDRVNAME "visorbus" From 30058c7477d383d105735e56e9112ae879e17ea2 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Wed, 13 May 2015 13:22:01 -0400 Subject: [PATCH 0497/1163] staging: unisys: Temporarily add visorbus/ ccflags To prep for the moving of include files, temporarily add the visorbus/ as a ccflags -I. Once the header files are all transitioned, we can remove this. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile index 72d4d4429684..32f199e949ec 100644 --- a/drivers/staging/unisys/visorbus/Makefile +++ b/drivers/staging/unisys/visorbus/Makefile @@ -13,3 +13,4 @@ ccflags-y += -Idrivers/staging/unisys/include ccflags-y += -Idrivers/staging/unisys/common-spar/include ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels ccflags-y += -Idrivers/staging/unisys/visorutil +ccflags-y += -Idrivers/staging/unisys/visorbus From 512a67bc09d4194792cfaa100631fb628fbb3ff0 Mon Sep 17 00:00:00 2001 From: David Kershner Date: Wed, 13 May 2015 13:22:02 -0400 Subject: [PATCH 0498/1163] staging: unisys: move hypervisor calls into visorbus Move hypervisor calls into visorbus and move vbusdeviceinfo.h into visorbus. Drivers will call into that to update clientInfo field. Signed-off-by: David Kershner Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/{common-spar/include => visorbus}/iovmcall_gnuc.h | 0 .../unisys/{common-spar/include => visorbus}/vbusdeviceinfo.h | 0 .../{common-spar/include => visorbus}/vmcallinterface.h | 4 +--- 3 files changed, 1 insertion(+), 3 deletions(-) rename drivers/staging/unisys/{common-spar/include => visorbus}/iovmcall_gnuc.h (100%) rename drivers/staging/unisys/{common-spar/include => visorbus}/vbusdeviceinfo.h (100%) rename drivers/staging/unisys/{common-spar/include => visorbus}/vmcallinterface.h (99%) diff --git a/drivers/staging/unisys/common-spar/include/iovmcall_gnuc.h b/drivers/staging/unisys/visorbus/iovmcall_gnuc.h similarity index 100% rename from drivers/staging/unisys/common-spar/include/iovmcall_gnuc.h rename to drivers/staging/unisys/visorbus/iovmcall_gnuc.h diff --git a/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h b/drivers/staging/unisys/visorbus/vbusdeviceinfo.h similarity index 100% rename from drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h rename to drivers/staging/unisys/visorbus/vbusdeviceinfo.h diff --git a/drivers/staging/unisys/common-spar/include/vmcallinterface.h b/drivers/staging/unisys/visorbus/vmcallinterface.h similarity index 99% rename from drivers/staging/unisys/common-spar/include/vmcallinterface.h rename to drivers/staging/unisys/visorbus/vmcallinterface.h index 59a7459eb962..dc09caf7d075 100644 --- a/drivers/staging/unisys/common-spar/include/vmcallinterface.h +++ b/drivers/staging/unisys/visorbus/vmcallinterface.h @@ -85,10 +85,8 @@ enum vmcall_monitor_interface_method_tuple { /* VMCALL identification tuples */ /* The following uses VMCALL_POST_CODE_LOGEVENT interface but is currently * not used much */ #define ISSUE_IO_VMCALL_POSTCODE_SEVERITY(postcode, severity) \ -do { \ ISSUE_IO_EXTENDED_VMCALL(VMCALL_POST_CODE_LOGEVENT, severity, \ - MDS_APPOS, postcode); \ -} while (0) + MDS_APPOS, postcode) #endif /* Structures for IO VMCALLs */ From 389f55920bee9e00ce4007e62ef9ceac39caec3b Mon Sep 17 00:00:00 2001 From: David Kershner Date: Wed, 13 May 2015 13:22:03 -0400 Subject: [PATCH 0499/1163] staging: unisys: Move controlframework into controlvmchannel.h Controlframework was only needed by controlvmchannel, move the structures into that header file. Signed-off-by: David Kershner Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../include/channels/controlframework.h | 62 ------------------- .../include/channels/controlvmchannel.h | 32 +++++++++- 2 files changed, 31 insertions(+), 63 deletions(-) delete mode 100644 drivers/staging/unisys/common-spar/include/channels/controlframework.h diff --git a/drivers/staging/unisys/common-spar/include/channels/controlframework.h b/drivers/staging/unisys/common-spar/include/channels/controlframework.h deleted file mode 100644 index 33d9caf337c8..000000000000 --- a/drivers/staging/unisys/common-spar/include/channels/controlframework.h +++ /dev/null @@ -1,62 +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. - */ - -/* - * Module Name: - * controlframework.h - * - * Abstract: This file defines common structures in the unmanaged - * Ultravisor (mostly EFI) space. - * - */ - -#ifndef _CONTROL_FRAMEWORK_H_ -#define _CONTROL_FRAMEWORK_H_ - -#include -#include "channel.h" - -struct spar_segment_state { - u16 enabled:1; /* Bit 0: May enter other states */ - u16 active:1; /* Bit 1: Assigned to active partition */ - u16 alive:1; /* Bit 2: Configure message sent to - * service/server */ - u16 revoked:1; /* Bit 3: similar to partition state - * ShuttingDown */ - u16 allocated:1; /* Bit 4: memory (device/port number) - * has been selected by Command */ - u16 known:1; /* Bit 5: has been introduced to the - * service/guest partition */ - u16 ready:1; /* Bit 6: service/Guest partition has - * responded to introduction */ - u16 operating:1; /* Bit 7: resource is configured and - * operating */ - /* Note: don't use high bit unless we need to switch to ushort - * which is non-compliant */ -}; - -static const struct spar_segment_state segment_state_running = { - 1, 1, 1, 0, 1, 1, 1, 1 -}; - -static const struct spar_segment_state segment_state_paused = { - 1, 1, 1, 0, 1, 1, 1, 0 -}; - -static const struct spar_segment_state segment_state_standby = { - 1, 1, 0, 0, 1, 1, 1, 0 -}; - -#endif /* _CONTROL_FRAMEWORK_H_ not defined */ diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index f1c86fbc126c..a50d9cf4bed7 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -18,7 +18,6 @@ #include #include "channel.h" -#include "controlframework.h" /* {2B3C2D10-7EF5-4ad8-B966-3448B7386B3D} */ #define SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID \ @@ -56,6 +55,37 @@ /* Max num of messages stored during IOVM creation to be reused after crash */ #define CONTROLVM_CRASHMSG_MAX 2 +struct spar_segment_state { + u16 enabled:1; /* Bit 0: May enter other states */ + u16 active:1; /* Bit 1: Assigned to active partition */ + u16 alive:1; /* Bit 2: Configure message sent to + * service/server */ + u16 revoked:1; /* Bit 3: similar to partition state + * ShuttingDown */ + u16 allocated:1; /* Bit 4: memory (device/port number) + * has been selected by Command */ + u16 known:1; /* Bit 5: has been introduced to the + * service/guest partition */ + u16 ready:1; /* Bit 6: service/Guest partition has + * responded to introduction */ + u16 operating:1; /* Bit 7: resource is configured and + * operating */ + /* Note: don't use high bit unless we need to switch to ushort + * which is non-compliant */ +}; + +static const struct spar_segment_state segment_state_running = { + 1, 1, 1, 0, 1, 1, 1, 1 +}; + +static const struct spar_segment_state segment_state_paused = { + 1, 1, 1, 0, 1, 1, 1, 0 +}; + +static const struct spar_segment_state segment_state_standby = { + 1, 1, 0, 0, 1, 1, 1, 0 +}; + /* Ids for commands that may appear in either queue of a ControlVm channel. * * Commands that are initiated by the command partition (CP), by an IO or From 63b0179c397b70029dc28d166211354697fb1382 Mon Sep 17 00:00:00 2001 From: David Kershner Date: Wed, 13 May 2015 13:22:04 -0400 Subject: [PATCH 0500/1163] staging: unisys: Move channel.h to include. Controvlm to visorbus Channel.h is used by all channels, it needs to be in include. Controlvm Channel is only used by visorbus, it needs to just be there. Signed-off-by: David Kershner Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../include/channels => include}/channel.h | 35 ------------------- .../channels => include}/channel_guid.h | 0 .../channels => visorbus}/controlvmchannel.h | 0 3 files changed, 35 deletions(-) rename drivers/staging/unisys/{common-spar/include/channels => include}/channel.h (94%) rename drivers/staging/unisys/{common-spar/include/channels => include}/channel_guid.h (100%) rename drivers/staging/unisys/{common-spar/include/channels => visorbus}/controlvmchannel.h (100%) diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/include/channel.h similarity index 94% rename from drivers/staging/unisys/common-spar/include/channels/channel.h rename to drivers/staging/unisys/include/channel.h index 6fb6e5b3ddaf..da0b5387f884 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/include/channel.h @@ -114,41 +114,6 @@ ULTRA_CHANNELCLI_STRING(u32 v) (((o) == CHANNELCLI_BUSY) && ((n) == CHANNELCLI_OWNED)) || (0)) \ ? (1) : (0)) -#define SPAR_CHANNEL_CLIENT_CHK_TRANSITION(old, new, id, log, \ - file, line) \ - do { \ - if (!ULTRA_VALID_CHANNELCLI_TRANSITION(old, new)) \ - pr_info("%s Channel StateTransition INVALID! (%s) %s(%d)-->%s(%d) @%s:%d\n", \ - id, "CliState", \ - ULTRA_CHANNELCLI_STRING(old), \ - old, \ - ULTRA_CHANNELCLI_STRING(new), \ - new, \ - pathname_last_n_nodes((u8 *)file, 4), \ - line); \ - } while (0) - -#define SPAR_CHANNEL_CLIENT_TRANSITION(ch, id, newstate, log) \ - do { \ - SPAR_CHANNEL_CLIENT_CHK_TRANSITION( \ - readl(&(((struct channel_header __iomem *)\ - (ch))->cli_state_os)), \ - newstate, id, log, __FILE__, __LINE__); \ - pr_info("%s Channel StateTransition (%s) %s(%d)-->%s(%d) @%s:%d\n", \ - id, "CliStateOS", \ - ULTRA_CHANNELCLI_STRING( \ - readl(&((struct channel_header __iomem *)\ - (ch))->cli_state_os)), \ - readl(&((struct channel_header __iomem *)\ - (ch))->cli_state_os), \ - ULTRA_CHANNELCLI_STRING(newstate), \ - newstate, \ - pathname_last_n_nodes(__FILE__, 4), __LINE__); \ - writel(newstate, &((struct channel_header __iomem *)\ - (ch))->cli_state_os); \ - mb(); /* required for channel synch */ \ - } while (0) - /* Values for ULTRA_CHANNEL_PROTOCOL.CliErrorBoot: */ /* throttling invalid boot channel statetransition error due to client * disabled */ diff --git a/drivers/staging/unisys/common-spar/include/channels/channel_guid.h b/drivers/staging/unisys/include/channel_guid.h similarity index 100% rename from drivers/staging/unisys/common-spar/include/channels/channel_guid.h rename to drivers/staging/unisys/include/channel_guid.h diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/visorbus/controlvmchannel.h similarity index 100% rename from drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h rename to drivers/staging/unisys/visorbus/controlvmchannel.h From 199093a74710e39d93900c78a7028e07da31532f Mon Sep 17 00:00:00 2001 From: David Kershner Date: Wed, 13 May 2015 13:22:05 -0400 Subject: [PATCH 0501/1163] staging: unisys: vbuschannel belonsg to visorbus Move vbuschannel.h into visorbus. Signed-off-by: David Kershner Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../{common-spar/include/channels => visorbus}/vbuschannel.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename drivers/staging/unisys/{common-spar/include/channels => visorbus}/vbuschannel.h (100%) diff --git a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h b/drivers/staging/unisys/visorbus/vbuschannel.h similarity index 100% rename from drivers/staging/unisys/common-spar/include/channels/vbuschannel.h rename to drivers/staging/unisys/visorbus/vbuschannel.h From 6264451f7e650ee3937606ad61ecdadc7f31bc76 Mon Sep 17 00:00:00 2001 From: David Kershner Date: Wed, 13 May 2015 13:22:06 -0400 Subject: [PATCH 0502/1163] staging: unisys: Move diagchannel to include Diagchannel needs to go to standard include. Signed-off-by: David Kershner Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../{common-spar/include/channels => include}/diagchannel.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename drivers/staging/unisys/{common-spar/include/channels => include}/diagchannel.h (100%) diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/include/diagchannel.h similarity index 100% rename from drivers/staging/unisys/common-spar/include/channels/diagchannel.h rename to drivers/staging/unisys/include/diagchannel.h From a2713631515c2be2d43595ac20e8944b298b1801 Mon Sep 17 00:00:00 2001 From: David Kershner Date: Wed, 13 May 2015 13:22:07 -0400 Subject: [PATCH 0503/1163] staging: unisys: Move files out of common-spar Move last three files out of common-spar iochannel.h --> include (will be used by visorhba and visornic) version.h --> moved to include controlvmcompletionstatus.h --> moved to visorbus, part of controlvmchannel.h Signed-off-by: David Kershner Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/{common-spar/include/channels => include}/iochannel.h | 0 drivers/staging/unisys/{common-spar => }/include/version.h | 0 .../{common-spar/include => visorbus}/controlvmcompletionstatus.h | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename drivers/staging/unisys/{common-spar/include/channels => include}/iochannel.h (100%) rename drivers/staging/unisys/{common-spar => }/include/version.h (100%) rename drivers/staging/unisys/{common-spar/include => visorbus}/controlvmcompletionstatus.h (100%) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/include/iochannel.h similarity index 100% rename from drivers/staging/unisys/common-spar/include/channels/iochannel.h rename to drivers/staging/unisys/include/iochannel.h diff --git a/drivers/staging/unisys/common-spar/include/version.h b/drivers/staging/unisys/include/version.h similarity index 100% rename from drivers/staging/unisys/common-spar/include/version.h rename to drivers/staging/unisys/include/version.h diff --git a/drivers/staging/unisys/common-spar/include/controlvmcompletionstatus.h b/drivers/staging/unisys/visorbus/controlvmcompletionstatus.h similarity index 100% rename from drivers/staging/unisys/common-spar/include/controlvmcompletionstatus.h rename to drivers/staging/unisys/visorbus/controlvmcompletionstatus.h From 634213ca155c6526aa216047b3f8c6b3b83dc7ce Mon Sep 17 00:00:00 2001 From: David Kershner Date: Wed, 13 May 2015 13:22:08 -0400 Subject: [PATCH 0504/1163] staging: unisys: Get rid of references to common-spar Makefiles still had common-spar listed in ccflags. This gets rid of them. Signed-off-by: David Kershner Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/Makefile | 2 -- drivers/staging/unisys/visorchannel/Makefile | 2 -- 2 files changed, 4 deletions(-) diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile index 32f199e949ec..2650b7284869 100644 --- a/drivers/staging/unisys/visorbus/Makefile +++ b/drivers/staging/unisys/visorbus/Makefile @@ -10,7 +10,5 @@ visorbus-y += visorchipset.o visorbus-y += periodic_work.o ccflags-y += -Idrivers/staging/unisys/include -ccflags-y += -Idrivers/staging/unisys/common-spar/include -ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels ccflags-y += -Idrivers/staging/unisys/visorutil ccflags-y += -Idrivers/staging/unisys/visorbus diff --git a/drivers/staging/unisys/visorchannel/Makefile b/drivers/staging/unisys/visorchannel/Makefile index e079c96b1cdf..0c0cacbd8843 100644 --- a/drivers/staging/unisys/visorchannel/Makefile +++ b/drivers/staging/unisys/visorchannel/Makefile @@ -7,6 +7,4 @@ obj-$(CONFIG_UNISYS_VISORCHANNEL) += visorchannel.o visorchannel-y := visorchannel_main.o visorchannel_funcs.o ccflags-y += -Idrivers/staging/unisys/include -ccflags-y += -Idrivers/staging/unisys/common-spar/include -ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels ccflags-y += -Idrivers/staging/unisys/visorutil From 2d4752dde3da65fbc91814bc408d722b08d97b04 Mon Sep 17 00:00:00 2001 From: David Kershner Date: Wed, 13 May 2015 13:22:09 -0400 Subject: [PATCH 0505/1163] staging: unisys: get rid of sparstop Signed-off-by: David Kershner Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/sparstop.h | 29 ----------------------- 1 file changed, 29 deletions(-) delete mode 100644 drivers/staging/unisys/include/sparstop.h diff --git a/drivers/staging/unisys/include/sparstop.h b/drivers/staging/unisys/include/sparstop.h deleted file mode 100644 index 6150d2d58d69..000000000000 --- a/drivers/staging/unisys/include/sparstop.h +++ /dev/null @@ -1,29 +0,0 @@ -/* sparstop.h - * - * 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. - */ - -#ifndef __SPARSTOP_H__ -#define __SPARSTOP_H__ - -#include "version.h" -#include - -typedef void (*SPARSTOP_COMPLETE_FUNC) (void *context, int status); - -int sp_stop(void *context, SPARSTOP_COMPLETE_FUNC get_complete_func); -void test_remove_stop_device(void); - -#endif From 5f3a7e364608e9be2e97725f86bd14ff827b5c6a Mon Sep 17 00:00:00 2001 From: David Kershner Date: Wed, 13 May 2015 13:22:10 -0400 Subject: [PATCH 0506/1163] staging: unisys: remove remaining utility headers remove uisqueue.h, uisthread.h, and uisutils.h replace HOSTADDRESS with u64 remove "uisutils.h" from header list in visorchipset.c Signed-off-by: David Kershner Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisqueue.h | 396 ------------------ drivers/staging/unisys/include/uisthread.h | 42 -- drivers/staging/unisys/include/uisutils.h | 293 ------------- .../staging/unisys/visorbus/visorchipset.c | 37 +- 4 files changed, 36 insertions(+), 732 deletions(-) delete mode 100644 drivers/staging/unisys/include/uisqueue.h delete mode 100644 drivers/staging/unisys/include/uisthread.h delete mode 100644 drivers/staging/unisys/include/uisutils.h diff --git a/drivers/staging/unisys/include/uisqueue.h b/drivers/staging/unisys/include/uisqueue.h deleted file mode 100644 index 08ba16ea840e..000000000000 --- a/drivers/staging/unisys/include/uisqueue.h +++ /dev/null @@ -1,396 +0,0 @@ -/* uisqueue.h - * - * 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. - */ - -/* - * Unisys IO Virtualization header NOTE: This file contains only Linux - * specific structs. All OS-independent structs are in iochannel.h.xx - */ - -#ifndef __UISQUEUE_H__ -#define __UISQUEUE_H__ - -#include "linux/version.h" -#include "iochannel.h" -#include -#include -#include - -#include "controlvmchannel.h" -#include "controlvmcompletionstatus.h" - -struct uisqueue_info { - struct channel_header __iomem *chan; - /* channel containing queues in which scsi commands & - * responses are queued - */ - u64 packets_sent; - u64 packets_received; - u64 interrupts_sent; - u64 interrupts_received; - u64 max_not_empty_cnt; - u64 total_wakeup_cnt; - u64 non_empty_wakeup_cnt; - - struct { - struct signal_queue_header reserved1; /* */ - struct signal_queue_header reserved2; /* */ - } safe_uis_queue; - unsigned int (*send_int_if_needed)(struct uisqueue_info *info, - unsigned int whichcqueue, - unsigned char issue_irq_if_empty, - u64 irq_handle, - unsigned char io_termination); -}; - -/* uisqueue_put_cmdrsp_with_lock_client queues a commmand or response - * to the specified queue, at the tail if the queue is full but - * oktowait == 0, then it return 0 indicating failure. otherwise it - * wait for the queue to become non-full. If command is queued, return - * 1 for success. - */ -#define DONT_ISSUE_INTERRUPT 0 -#define ISSUE_INTERRUPT 1 - -#define DONT_WAIT 0 -#define OK_TO_WAIT 1 -#define UISLIB_LOCK_PREFIX \ - ".section .smp_locks,\"a\"\n" \ - _ASM_ALIGN "\n" \ - _ASM_PTR "661f\n" /* address */ \ - ".previous\n" \ - "661:\n\tlock; " - -unsigned long long uisqueue_interlocked_or(unsigned long long __iomem *tgt, - unsigned long long set); -unsigned long long uisqueue_interlocked_and(unsigned long long __iomem *tgt, - unsigned long long set); - -int uisqueue_put_cmdrsp_with_lock_client(struct uisqueue_info *queueinfo, - struct uiscmdrsp *cmdrsp, - unsigned int queue, - void *insertlock, - unsigned char issue_irq_if_empty, - u64 irq_handle, - char oktowait, - u8 *channel_id); - -/* uisqueue_get_cmdrsp gets the cmdrsp entry at the head of the queue - * and copies it to the area pointed by cmdrsp param. - * returns 0 if queue is empty, 1 otherwise - */ -int - -uisqueue_get_cmdrsp(struct uisqueue_info *queueinfo, void *cmdrsp, - unsigned int queue); - -#define MAX_NAME_SIZE_UISQUEUE 64 - -struct extport_info { - u8 valid:1; - /* if 1, indicates this extport slot is occupied - * if 0, indicates that extport slot is unoccupied */ - - u32 num_devs_using; - /* When extport is added, this is set to 0. For exports - * located in NETWORK switches: - * Each time a VNIC, i.e., intport, is added to the switch this - * is used to assign a pref_pnic for the VNIC and when assigned - * to a VNIC this counter is incremented. When a VNIC is - * deleted, the extport corresponding to the VNIC's pref_pnic - * is located and its num_devs_using is decremented. For VNICs, - * num_devs_using is basically used to load-balance transmit - * traffic from VNICs. - */ - - struct switch_info *swtch; - struct pci_id pci_id; - char name[MAX_NAME_SIZE_UISQUEUE]; - union { - struct vhba_wwnn wwnn; - unsigned char macaddr[MAX_MACADDR_LEN]; - }; -}; - -struct device_info { - void __iomem *chanptr; - u64 channel_addr; - u64 channel_bytes; - uuid_le channel_uuid; - uuid_le instance_uuid; - struct irq_info intr; - struct switch_info *swtch; - char devid[30]; /* "vbus:dev" */ - u16 polling; - struct semaphore interrupt_callback_lock; - u32 bus_no; - u32 dev_no; - int (*interrupt)(void *); - void *interrupt_context; - void *private_data; - struct list_head list_polling_device_channels; - unsigned long long moved_to_tail_cnt; - unsigned long long first_busy_cnt; - unsigned long long last_on_list_cnt; -}; - -enum switch_type { - RECOVERY_LAN = 1, - IB_LAN = 2 -}; - -struct bus_info { - u32 bus_no, device_count; - struct device_info **device; - u64 guest_handle, recv_bus_irq_handle; - uuid_le bus_inst_uuid; - struct ultra_vbus_channel_protocol __iomem *bus_channel; - int bus_channel_bytes; - struct proc_dir_entry *proc_dir; /* proc/uislib/vbus/ */ - struct proc_dir_entry *proc_info; /* proc/uislib/vbus//info */ - char name[25]; - char partition_name[99]; - struct bus_info *next; - u8 local_vnic; /* 1 if local vnic created internally - * by IOVM; 0 otherwise... */ -}; - -struct sn_list_entry { - struct uisscsi_dest pdest; /* scsi bus, target, lun for - * phys disk */ - u8 sernum[MAX_SERIAL_NUM]; /* serial num of physical - * disk.. The length is always - * MAX_SERIAL_NUM, padded with - * spaces */ - struct sn_list_entry *next; -}; - -/* - * IO messages sent to UisnicControlChanFunc & UissdControlChanFunc by - * code that processes the ControlVm channel messages. - */ - -enum iopart_msg_type { - IOPART_ADD_VNIC, - IOPART_DEL_VNIC, - IOPART_DEL_ALL_VNICS, - IOPART_ADD_VHBA, - IOPART_ADD_VDISK, - IOPART_DEL_VHBA, - IOPART_DEL_VDISK, - IOPART_DEL_ALL_VDISKS_FOR_VHBA, - IOPART_DEL_ALL_VHBAS, - IOPART_ATTACH_PHBA, - IOPART_DETACH_PHBA, /* 10 */ - IOPART_ATTACH_PNIC, - IOPART_DETACH_PNIC, - IOPART_DETACH_VHBA, - IOPART_DETACH_VNIC, - IOPART_PAUSE_VDISK, - IOPART_RESUME_VDISK, - IOPART_ADD_DEVICE, /* add generic device */ - IOPART_DEL_DEVICE, /* del generic device */ -}; - -struct add_virt_iopart { - void *chanptr; /* pointer to data channel */ - u64 guest_handle; /* used to convert guest physical - * address to real physical address - * for DMA, for ex. */ - u64 recv_bus_irq_handle; /* used to register to receive - * bus level interrupts. */ - struct irq_info intr; /* contains recv & send - * interrupt info */ - /* recvInterruptHandle is used to register to receive - * interrupts on the data channel. Used by GuestLinux/Windows - * IO drivers to connect to interrupt. sendInterruptHandle is - * used by IOPart drivers as parameter to - * Issue_VMCALL_IO_QUEUE_TRANSITION to interrupt thread in - * guest linux/windows IO drivers when data channel queue for - * vhba/vnic goes from EMPTY to NON-EMPTY. */ - struct switch_info *swtch; /* pointer to the virtual - * switch to which the vnic is - * connected */ - - u8 use_g2g_copy; /* Used to determine if a virtual HBA - * needs to use G2G copy. */ - u8 filler[7]; - - u32 bus_no; - u32 dev_no; - char *params; - ulong params_bytes; - -}; - -struct add_vdisk_iopart { - void *chanptr; /* pointer to data channel */ - int implicit; - struct uisscsi_dest vdest; /* scsi bus, target, lun for virt disk */ - struct uisscsi_dest pdest; /* scsi bus, target, lun for phys disk */ - u8 sernum[MAX_SERIAL_NUM]; /* serial num of physical disk */ - u32 serlen; /* length of serial num */ -}; - -struct del_vdisk_iopart { - void *chanptr; /* pointer to data channel */ - struct uisscsi_dest vdest; /* scsi bus, target, lun for virt disk */ -}; - -struct del_virt_iopart { - void *chanptr; /* pointer to data channel */ -}; - -struct det_virt_iopart { /* detach internal port */ - void *chanptr; /* pointer to data channel */ - struct switch_info *swtch; -}; - -struct paures_vdisk_iopart { - void *chanptr; /* pointer to data channel */ - struct uisscsi_dest vdest; /* scsi bus, target, lun for virt disk */ -}; - -struct add_switch_iopart { /* add switch */ - struct switch_info *swtch; - char *params; - ulong params_bytes; -}; - -struct del_switch_iopart { /* destroy switch */ - struct switch_info *swtch; -}; - -struct io_msgs { - enum iopart_msg_type msgtype; - - /* additional params needed by some messages */ - union { - struct add_virt_iopart add_vhba; - struct add_virt_iopart add_vnic; - struct add_vdisk_iopart add_vdisk; - struct del_virt_iopart del_vhba; - struct del_virt_iopart del_vnic; - struct det_virt_iopart det_vhba; - struct det_virt_iopart det_vnic; - struct del_vdisk_iopart del_vdisk; - struct del_virt_iopart del_all_vdisks_for_vhba; - struct add_virt_iopart add_device; - struct del_virt_iopart del_device; - struct det_virt_iopart det_intport; - struct add_switch_iopart add_switch; - struct del_switch_iopart del_switch; - struct extport_info *ext_port; /* for attach or detach - * pnic/generic delete all - * vhbas/allvnics need no - * parameters */ - struct paures_vdisk_iopart paures_vdisk; - }; -}; - -/* -* Guest messages sent to VirtControlChanFunc by code that processes -* the ControlVm channel messages. -*/ - -enum guestpart_msg_type { - GUEST_ADD_VBUS, - GUEST_ADD_VHBA, - GUEST_ADD_VNIC, - GUEST_DEL_VBUS, - GUEST_DEL_VHBA, - GUEST_DEL_VNIC, - GUEST_DEL_ALL_VHBAS, - GUEST_DEL_ALL_VNICS, - GUEST_DEL_ALL_VBUSES, /* deletes all vhbas & vnics on all - * buses and deletes all buses */ - GUEST_PAUSE_VHBA, - GUEST_PAUSE_VNIC, - GUEST_RESUME_VHBA, - GUEST_RESUME_VNIC -}; - -struct add_vbus_guestpart { - void __iomem *chanptr; /* pointer to data channel for bus - - * NOT YET USED */ - u32 bus_no; /* bus number to be created/deleted */ - u32 dev_count; /* max num of devices on bus */ - uuid_le bus_uuid; /* indicates type of bus */ - uuid_le instance_uuid; /* instance guid for device */ -}; - -struct del_vbus_guestpart { - u32 bus_no; /* bus number to be deleted */ - /* once we start using the bus's channel, add can dump busNo - * into the channel header and then delete will need only one - * parameter, chanptr. */ -}; - -struct add_virt_guestpart { - void __iomem *chanptr; /* pointer to data channel */ - u32 bus_no; /* bus number for the operation */ - u32 device_no; /* number of device on the bus */ - uuid_le instance_uuid; /* instance guid for device */ - struct irq_info intr; /* recv/send interrupt info */ - /* recvInterruptHandle contains info needed in order to - * register to receive interrupts on the data channel. - * sendInterruptHandle contains handle which is provided to - * monitor VMCALL that will cause an interrupt to be generated - * for the other end. - */ -}; - -struct pause_virt_guestpart { - void __iomem *chanptr; /* pointer to data channel */ -}; - -struct resume_virt_guestpart { - void __iomem *chanptr; /* pointer to data channel */ -}; - -struct del_virt_guestpart { - void __iomem *chanptr; /* pointer to data channel */ -}; - -struct init_chipset_guestpart { - u32 bus_count; /* indicates the max number of busses */ - u32 switch_count; /* indicates the max number of switches */ -}; - -struct guest_msgs { - enum guestpart_msg_type msgtype; - - /* additional params needed by messages */ - union { - struct add_vbus_guestpart add_vbus; - struct add_virt_guestpart add_vhba; - struct add_virt_guestpart add_vnic; - struct pause_virt_guestpart pause_vhba; - struct pause_virt_guestpart pause_vnic; - struct resume_virt_guestpart resume_vhba; - struct resume_virt_guestpart resume_vnic; - struct del_vbus_guestpart del_vbus; - struct del_virt_guestpart del_vhba; - struct del_virt_guestpart del_vnic; - struct del_vbus_guestpart del_all_vhbas; - struct del_vbus_guestpart del_all_vnics; - /* del_all_vbuses needs no parameters */ - }; - struct init_chipset_guestpart init_chipset; - -}; - -#endif /* __UISQUEUE_H__ */ diff --git a/drivers/staging/unisys/include/uisthread.h b/drivers/staging/unisys/include/uisthread.h deleted file mode 100644 index 52c3eb4ded2c..000000000000 --- a/drivers/staging/unisys/include/uisthread.h +++ /dev/null @@ -1,42 +0,0 @@ -/* uisthread.h - * - * 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. - */ - -/*****************************************************************************/ -/* Unisys thread utilities header */ -/*****************************************************************************/ - -#ifndef __UISTHREAD_H__ -#define __UISTHREAD_H__ - -#include "linux/completion.h" - -struct uisthread_info { - struct task_struct *task; - int id; - struct completion has_stopped; -}; - -/* returns 0 for failure, 1 for success */ -int uisthread_start( - struct uisthread_info *thrinfo, - int (*threadfn)(void *), - void *thrcontext, - char *name); - -void uisthread_stop(struct uisthread_info *thrinfo); - -#endif /* __UISTHREAD_H__ */ diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h deleted file mode 100644 index d58858b21f99..000000000000 --- a/drivers/staging/unisys/include/uisutils.h +++ /dev/null @@ -1,293 +0,0 @@ -/* uisutils.h - * - * 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. - */ - -/* - * Unisys Virtual HBA utilities header - */ - -#ifndef __UISUTILS__H__ -#define __UISUTILS__H__ -#include -#include -#include -#include -#include -#include - -#include "vmcallinterface.h" -#include "channel.h" -#include "uisthread.h" -#include "uisqueue.h" -#include "vbusdeviceinfo.h" -#include - -/* This is the MAGIC number stuffed by virthba in host->this_id. Used to - * identify virtual hbas. - */ -#define UIS_MAGIC_VHBA 707 - -/* global function pointers that act as callback functions into - * uisnicmod, uissdmod, and virtpcimod - */ -extern int (*uisnic_control_chan_func)(struct io_msgs *); -extern int (*uissd_control_chan_func)(struct io_msgs *); -extern int (*virt_control_chan_func)(struct guest_msgs *); - -/* Return values of above callback functions: */ -#define CCF_ERROR 0 /* completed and failed */ -#define CCF_OK 1 /* completed successfully */ -#define CCF_PENDING 2 /* operation still pending */ -extern atomic_t uisutils_registered_services; - -struct req_handler_info { - uuid_le switch_uuid; - int (*controlfunc)(struct io_msgs *); - unsigned long min_channel_bytes; - int (*server_channel_ok)(unsigned long channel_bytes); - int (*server_channel_init)(void *x, unsigned char *client_str, - u32 client_str_len, u64 bytes); - char switch_type_name[99]; - struct list_head list_link; /* links into ReqHandlerInfo_list */ -}; - -struct req_handler_info *req_handler_find(uuid_le switch_uuid); - -#define uislib_ioremap_cache(addr, size) \ - dbg_ioremap_cache(addr, size, __FILE__, __LINE__) - -static inline void __iomem * -dbg_ioremap_cache(u64 addr, unsigned long size, char *file, int line) -{ - void __iomem *new; - - new = ioremap_cache(addr, size); - return new; -} - -#define uislib_ioremap(addr, size) dbg_ioremap(addr, size, __FILE__, __LINE__) - -static inline void * -dbg_ioremap(u64 addr, unsigned long size, char *file, int line) -{ - void *new; - - new = ioremap(addr, size); - return new; -} - -#define uislib_iounmap(addr) dbg_iounmap(addr, __FILE__, __LINE__) - -static inline void -dbg_iounmap(void __iomem *addr, char *file, int line) -{ - iounmap(addr); -} - -#define PROC_READ_BUFFER_SIZE 131072 /* size of the buffer to allocate to - * hold all of /proc/XXX/info */ -int uisutil_add_proc_line_ex(int *total, char **buffer, int *buffer_remaining, - char *format, ...); - -int uisctrl_register_req_handler(int type, void *fptr, - struct ultra_vbus_deviceinfo *chipset_driver_info); - -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); -void util_unmap_virt_atomic(void *buf); -int uislib_client_inject_add_bus(u32 bus_no, uuid_le inst_uuid, - u64 channel_addr, ulong n_channel_bytes); -int uislib_client_inject_del_bus(u32 bus_no); - -int uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no, - u64 phys_chan_addr, u32 chan_bytes, - int is_test_addr, uuid_le inst_uuid, - struct irq_info *intr); -int uislib_client_inject_pause_vhba(u32 bus_no, u32 dev_no); -int uislib_client_inject_resume_vhba(u32 bus_no, u32 dev_no); -int uislib_client_inject_del_vhba(u32 bus_no, u32 dev_no); -int uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no, - u64 phys_chan_addr, u32 chan_bytes, - int is_test_addr, uuid_le inst_uuid, - struct irq_info *intr); -int uislib_client_inject_pause_vnic(u32 bus_no, u32 dev_no); -int uislib_client_inject_resume_vnic(u32 bus_no, u32 dev_no); -int uislib_client_inject_del_vnic(u32 bus_no, u32 dev_no); -#ifdef STORAGE_CHANNEL -u64 uislib_storage_channel(int client_id); -#endif -int uislib_get_owned_pdest(struct uisscsi_dest *pdest); - -int uislib_send_event(enum controlvm_id id, - struct controlvm_message_packet *event); - -/* structure used by vhba & vnic to keep track of queue & thread info */ -struct chaninfo { - struct uisqueue_info *queueinfo; - /* this specifies the queue structures for a channel */ - /* ALLOCATED BY THE OTHER END - WE JUST GET A POINTER TO THE MEMORY */ - spinlock_t insertlock; - /* currently used only in virtnic when sending data to uisnic */ - /* to synchronize the inserts into the signal queue */ - struct uisthread_info threadinfo; - /* this specifies the thread structures used by the thread that */ - /* handles this channel */ -}; - -/* this is the wait code for all the threads - it is used to get -* something from a queue choices: wait_for_completion_interruptible, -* _timeout, interruptible_timeout -*/ -#define UIS_THREAD_WAIT_MSEC(x) { \ - set_current_state(TASK_INTERRUPTIBLE); \ - schedule_timeout(msecs_to_jiffies(x)); \ -} - -#define UIS_THREAD_WAIT_USEC(x) { \ - set_current_state(TASK_INTERRUPTIBLE); \ - schedule_timeout(usecs_to_jiffies(x)); \ -} - -#define UIS_THREAD_WAIT UIS_THREAD_WAIT_MSEC(5) - -#define UIS_THREAD_WAIT_SEC(x) { \ - set_current_state(TASK_INTERRUPTIBLE); \ - schedule_timeout((x)*HZ); \ -} - -/* This is a hack until we fix IOVM to initialize the channel header - * correctly at DEVICE_CREATE time, INSTEAD OF waiting until - * DEVICE_CONFIGURE time. - */ -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; - UIS_THREAD_WAIT_SEC(5); - } -} - -static inline unsigned int -issue_vmcall_io_controlvm_addr(u64 *control_addr, u32 *control_bytes) -{ - struct vmcall_io_controlvm_addr_params params; - int result = VMCALL_SUCCESS; - u64 physaddr; - - physaddr = virt_to_phys(¶ms); - ISSUE_IO_VMCALL(VMCALL_IO_CONTROLVM_ADDR, physaddr, result); - if (VMCALL_SUCCESSFUL(result)) { - *control_addr = params.address; - *control_bytes = params.channel_bytes; - } - return result; -} - -static inline unsigned int issue_vmcall_io_diag_addr(u64 *diag_channel_addr) -{ - struct vmcall_io_diag_addr_params params; - int result = VMCALL_SUCCESS; - u64 physaddr; - - physaddr = virt_to_phys(¶ms); - ISSUE_IO_VMCALL(VMCALL_IO_DIAG_ADDR, physaddr, result); - if (VMCALL_SUCCESSFUL(result)) - *diag_channel_addr = params.address; - return result; -} - -static inline unsigned int issue_vmcall_io_visorserial_addr(u64 *channel_addr) -{ - struct vmcall_io_visorserial_addr_params params; - int result = VMCALL_SUCCESS; - u64 physaddr; - - physaddr = virt_to_phys(¶ms); - ISSUE_IO_VMCALL(VMCALL_IO_VISORSERIAL_ADDR, physaddr, result); - if (VMCALL_SUCCESSFUL(result)) - *channel_addr = params.address; - return result; -} - -static inline s64 issue_vmcall_query_guest_virtual_time_offset(void) -{ - u64 result = VMCALL_SUCCESS; - u64 physaddr = 0; - - ISSUE_IO_VMCALL(VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET, physaddr, - result); - return result; -} - -struct log_info_t { - unsigned long long last_cycles; - unsigned long long delta_sum[64]; - unsigned long long delta_cnt[64]; - unsigned long long max_delta[64]; - unsigned long long min_delta[64]; -}; - -static inline int issue_vmcall_update_physical_time(u64 adjustment) -{ - int result = VMCALL_SUCCESS; - - ISSUE_IO_VMCALL(VMCALL_UPDATE_PHYSICAL_TIME, adjustment, result); - return result; -} - -static inline unsigned int issue_vmcall_channel_mismatch(const char *chname, - const char *item_name, u32 line_no, - const char *path_n_fn) -{ - struct vmcall_channel_version_mismatch_params params; - int result = VMCALL_SUCCESS; - u64 physaddr; - char *last_slash = NULL; - - strlcpy(params.chname, chname, sizeof(params.chname)); - strlcpy(params.item_name, item_name, sizeof(params.item_name)); - params.line_no = line_no; - - last_slash = strrchr(path_n_fn, '/'); - if (last_slash != NULL) { - last_slash++; - strlcpy(params.file_name, last_slash, sizeof(params.file_name)); - } else - strlcpy(params.file_name, - "Cannot determine source filename", - sizeof(params.file_name)); - - physaddr = virt_to_phys(¶ms); - ISSUE_IO_VMCALL(VMCALL_CHANNEL_VERSION_MISMATCH, physaddr, result); - return result; -} - -#define UIS_DAEMONIZE(nam) - -void uislib_enable_channel_interrupts(u32 bus_no, u32 dev_no, - int (*interrupt)(void *), - void *interrupt_context); -void uislib_disable_channel_interrupts(u32 bus_no, u32 dev_no); -void uislib_force_channel_interrupt(u32 bus_no, u32 dev_no); - -#endif /* __UISUTILS__H__ */ diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index e6d7075ab8fb..b96a40cf9124 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -26,14 +26,15 @@ #include #include +#include "channel_guid.h" #include "controlvmchannel.h" #include "controlvmcompletionstatus.h" #include "guestlinuxdebug.h" #include "periodic_work.h" -#include "uisutils.h" #include "version.h" #include "visorbus.h" #include "visorbus_private.h" +#include "vmcallinterface.h" #define CURRENT_FILE_PC VISOR_CHIPSET_PC_visorchipset_main_c @@ -1856,6 +1857,22 @@ handle_command(struct controlvm_message inmsg, u64 channel_addr) return true; } +static inline unsigned int +issue_vmcall_io_controlvm_addr(u64 *control_addr, u32 *control_bytes) +{ + struct vmcall_io_controlvm_addr_params params; + int result = VMCALL_SUCCESS; + u64 physaddr; + + physaddr = virt_to_phys(¶ms); + ISSUE_IO_VMCALL(VMCALL_IO_CONTROLVM_ADDR, physaddr, result); + if (VMCALL_SUCCESSFUL(result)) { + *control_addr = params.address; + *control_bytes = params.channel_bytes; + } + return result; +} + static u64 controlvm_get_channel_address(void) { u64 addr = 0; @@ -2239,6 +2256,24 @@ visorchipset_mmap(struct file *file, struct vm_area_struct *vma) return 0; } +static inline s64 issue_vmcall_query_guest_virtual_time_offset(void) +{ + u64 result = VMCALL_SUCCESS; + u64 physaddr = 0; + + ISSUE_IO_VMCALL(VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET, physaddr, + result); + return result; +} + +static inline int issue_vmcall_update_physical_time(u64 adjustment) +{ + int result = VMCALL_SUCCESS; + + ISSUE_IO_VMCALL(VMCALL_UPDATE_PHYSICAL_TIME, adjustment, result); + return result; +} + static long visorchipset_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { From 1b56ac48c1c643aacd078b9f100ba448376a0183 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Wed, 13 May 2015 13:22:11 -0400 Subject: [PATCH 0507/1163] staging: unisys: Remove temporarily added visorbus/ include in Makefile Now that the header file movement is complete, remove the temporary ccflags include Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile index 2650b7284869..fa27ee5f336c 100644 --- a/drivers/staging/unisys/visorbus/Makefile +++ b/drivers/staging/unisys/visorbus/Makefile @@ -11,4 +11,3 @@ visorbus-y += periodic_work.o ccflags-y += -Idrivers/staging/unisys/include ccflags-y += -Idrivers/staging/unisys/visorutil -ccflags-y += -Idrivers/staging/unisys/visorbus From 03274d38c39e13f075b2b318646acd5518331c31 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Wed, 13 May 2015 13:22:12 -0400 Subject: [PATCH 0508/1163] staging: unisys: Embed struct device for easier handling of attr Handling the sysfs attributes become easier to deal with when you can just run container_of(dev) to get devdata. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorbus_main.c | 36 +++++++------------ 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 114a765dab59..228aec51cdd8 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -41,7 +41,7 @@ int visorbus_debugref; struct visorbus_devdata { int devno; /* this is the chipset busNo */ struct list_head list_all; - struct device *dev; + struct device dev; struct kobject kobj; struct visorchannel *chan; /* channel area for bus itself */ bool vbus_valid; @@ -1329,7 +1329,7 @@ create_visor_device(struct visorbus_devdata *devdata, dev->channel_bytes = chan_info.n_channel_bytes; dev->chipset_bus_no = chipset_bus_no; dev->chipset_dev_no = chipset_dev_no; - dev->device.parent = devdata->dev; + dev->device.parent = &devdata->dev; sema_init(&dev->visordriver_callback_lock, 1); /* unlocked */ dev->device.bus = &visorbus_type; device_initialize(&dev->device); @@ -1636,34 +1636,24 @@ create_bus_instance(int id) { struct visorbus_devdata *rc = NULL; struct visorbus_devdata *devdata = NULL; - struct device *dev; struct visorchipset_bus_info bus_info; POSTCODE_LINUX_2(BUS_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); - dev = kmalloc(sizeof(*dev), GFP_KERNEL); - if (!dev) { - POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR); - rc = NULL; - goto away; - } - memset(dev, 0, sizeof(struct device)); - dev_set_name(dev, "visorbus%d", id); - dev->release = visorbus_release_busdevice; - if (device_register(dev) < 0) { - POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, id, - POSTCODE_SEVERITY_ERR); - rc = NULL; - goto away; - } - devdata = kmalloc(sizeof(*devdata), GFP_KERNEL); + devdata = kzalloc(sizeof(*devdata), GFP_KERNEL); if (!devdata) { POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR); rc = NULL; goto away; } - memset(devdata, 0, sizeof(struct visorbus_devdata)); + dev_set_name(&devdata->dev, "visorbus%d", id); + devdata->dev.release = visorbus_release_busdevice; + if (device_register(&devdata->dev) < 0) { + POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, id, + POSTCODE_SEVERITY_ERR); + rc = NULL; + goto away; + } devdata->devno = id; - devdata->dev = dev; if ((visorchipset_get_bus_info(id, &bus_info)) && (bus_info.chan_info.channel_addr > 0) && (bus_info.chan_info.n_channel_bytes > 0)) { @@ -1707,7 +1697,7 @@ create_bus_instance(int id) list_add_tail(&devdata->list_all, &list_all_bus_instances); if (id == 0) devdata = devdata; /* for testing ONLY */ - dev_set_drvdata(dev, devdata); + dev_set_drvdata(&devdata->dev, devdata); rc = devdata; away: return rc; @@ -1732,7 +1722,7 @@ remove_bus_instance(struct visorbus_devdata *devdata) devdata->chan = NULL; } list_del(&devdata->list_all); - device_unregister(devdata->dev); + device_unregister(&devdata->dev); } /** Create and register the one-and-only one instance of From d181dd03715b4aeed77c933ca4d5306539e41e03 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Wed, 13 May 2015 13:22:13 -0400 Subject: [PATCH 0509/1163] staging: unisys: Wire up proper device attr for bus This patch moves the attributes to underneath the bus device correctly. This will help remove a bunch of cruft from the code and let the kernel infrastructure manage the sysfs files instead of the driver. After the move remove all the leftover code. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorbus_main.c | 264 ++++-------------- 1 file changed, 54 insertions(+), 210 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 228aec51cdd8..e2993717fb62 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -606,113 +606,8 @@ void unregister_channel_attributes(struct visor_device *dev) kobject_put(&dev->kobjchannel); dev->kobjchannel.parent = NULL; } -/* This is actually something they forgot to put in the kernel. - * struct bus_type in the kernel SHOULD have a "busses" member, which - * should be treated similarly to the "devices" and "drivers" members. - * There SHOULD be: - * - a "businst_attribute" analogous to the existing "bus_attribute" - * - a "businst_create_file" and "businst_remove_file" analogous to the - * existing "bus_create_file" and "bus_remove_file". - * That's what I created businst.c and businst.h to do. - * - * We want to add the "busses" sub-tree in sysfs, where we will house the - * names and properties of each bus instance: - * - * /sys/bus// - * version - * devices - * --> /sys/devices/ - * --> /sys/devices/ - * drivers - * - * - * - * ... - * - * - * - * ... - * >> busses - * >> - * >> - * >> - * >> ... - * >> - * >> - * >> - * >> ... - * - * I considered adding bus instance properties under - * /sys/devices/. But I thought there may be existing - * notions that ONLY device sub-trees should live under - * /sys/devices/. So I stayed out of there. - * - */ - -struct businst_attribute { - struct attribute attr; - ssize_t (*show)(struct visorbus_devdata*, char *buf); - ssize_t (*store)(struct visorbus_devdata*, const char *buf, - size_t count); -}; - -#define to_businst_attr(_attr) \ - container_of(_attr, struct businst_attribute, attr) #define to_visorbus_devdata(obj) \ - container_of(obj, struct visorbus_devdata, kobj) - -static ssize_t -businst_attr_show(struct kobject *kobj, struct attribute *attr, - char *buf) -{ - struct businst_attribute *businst_attr = to_businst_attr(attr); - struct visorbus_devdata *bus = to_visorbus_devdata(kobj); - ssize_t ret = 0; - - if (businst_attr->show) - ret = businst_attr->show(bus, buf); - return ret; -} - -static ssize_t -businst_attr_store(struct kobject *kobj, struct attribute *attr, - const char *buf, size_t count) -{ - struct businst_attribute *businst_attr = to_businst_attr(attr); - struct visorbus_devdata *bus = to_visorbus_devdata(kobj); - ssize_t ret = 0; - - if (businst_attr->store) - ret = businst_attr->store(bus, buf, count); - return ret; -} - -static int -businst_create_file(struct visorbus_devdata *bus, - struct businst_attribute *attr) -{ - return sysfs_create_file(&bus->kobj, &attr->attr); -} - -static void -businst_remove_file(struct visorbus_devdata *bus, - struct businst_attribute *attr) -{ - sysfs_remove_file(&bus->kobj, &attr->attr); -} - -static const struct sysfs_ops businst_sysfs_ops = { - .show = businst_attr_show, - .store = businst_attr_store, -}; - -static struct kobj_type businst_kobj_type = { - .sysfs_ops = &businst_sysfs_ops -}; - -static struct kset businstances = { /* should actually be a member of - * bus_type */ -}; + container_of(obj, struct visorbus_devdata, dev) /* BUS type attributes * @@ -736,23 +631,6 @@ register_bustype_attributes(void) int rc = 0; rc = bus_create_file(&visorbus_type, &bustype_attr_version); - if (rc < 0) - goto away; - - /* Here we make up for the fact that bus_type does not yet have a - * member to keep track of multiple bus instances for a given bus - * type. This is useful for stashing properties for each bus - * instance. - */ - kobject_set_name(&businstances.kobj, "busses"); - businstances.kobj.ktype = &businst_kobj_type; - businstances.kobj.parent = &visorbus_type.p->subsys.kobj; - rc = kset_register(&businstances); - if (rc < 0) - goto away; - - rc = 0; -away: return rc; } @@ -760,7 +638,6 @@ static void unregister_bustype_attributes(void) { bus_remove_file(&visorbus_type, &bustype_attr_version); - kset_unregister(&businstances); } /* BUS instance attributes @@ -774,8 +651,10 @@ unregister_bustype_attributes(void) * */ -static ssize_t businst_attr_partition_handle(struct visorbus_devdata *businst, - char *buf) { +static ssize_t partition_handle_show(struct device *dev, + struct device_attribute *attr, + char *buf) { + struct visorbus_devdata *businst = to_visorbus_devdata(dev); struct visorchipset_bus_info bus_info; int len = 0; @@ -786,8 +665,10 @@ static ssize_t businst_attr_partition_handle(struct visorbus_devdata *businst, return len; } -static ssize_t businst_attr_partition_guid(struct visorbus_devdata *businst, - char *buf) { +static ssize_t partition_guid_show(struct device *dev, + struct device_attribute *attr, + char *buf) { + struct visorbus_devdata *businst = to_visorbus_devdata(dev); struct visorchipset_bus_info bus_info; int len = 0; @@ -797,8 +678,10 @@ static ssize_t businst_attr_partition_guid(struct visorbus_devdata *businst, return len; } -static ssize_t businst_attr_partition_name(struct visorbus_devdata *businst, - char *buf) { +static ssize_t partition_name_show(struct device *dev, + struct device_attribute *attr, + char *buf) { + struct visorbus_devdata *businst = to_visorbus_devdata(dev); struct visorchipset_bus_info bus_info; int len = 0; @@ -809,8 +692,10 @@ static ssize_t businst_attr_partition_name(struct visorbus_devdata *businst, return len; } -static ssize_t businst_attr_channel_addr(struct visorbus_devdata *businst, - char *buf) { +static ssize_t channel_addr_show(struct device *dev, + struct device_attribute *attr, + char *buf) { + struct visorbus_devdata *businst = to_visorbus_devdata(dev); struct visorchipset_bus_info bus_info; int len = 0; @@ -820,8 +705,10 @@ static ssize_t businst_attr_channel_addr(struct visorbus_devdata *businst, return len; } -static ssize_t businst_attr_nchannel_bytes(struct visorbus_devdata *businst, - char *buf) { +static ssize_t channel_bytes_show(struct device *dev, + struct device_attribute *attr, + char *buf) { + struct visorbus_devdata *businst = to_visorbus_devdata(dev); struct visorchipset_bus_info bus_info; int len = 0; @@ -831,8 +718,10 @@ static ssize_t businst_attr_nchannel_bytes(struct visorbus_devdata *businst, return len; } -static ssize_t businst_attr_channel_id(struct visorbus_devdata *businst, - char *buf) { +static ssize_t channel_id_show(struct device *dev, + struct device_attribute *attr, + char *buf) { + struct visorbus_devdata *businst = to_visorbus_devdata(dev); int len = 0; if (businst && businst->chan) { @@ -843,8 +732,10 @@ static ssize_t businst_attr_channel_id(struct visorbus_devdata *businst, return len; } -static ssize_t businst_attr_client_bus_info(struct visorbus_devdata *businst, - char *buf) { +static ssize_t client_bus_info_show(struct device *dev, + struct device_attribute *attr, + char *buf) { + struct visorbus_devdata *businst = to_visorbus_devdata(dev); struct visorchipset_bus_info bus_info; int i, x, remain = PAGE_SIZE; unsigned long off; @@ -903,79 +794,33 @@ static ssize_t businst_attr_client_bus_info(struct visorbus_devdata *businst, return PAGE_SIZE - remain; } -static struct businst_attribute ba_partition_handle = - __ATTR(partition_handle, S_IRUGO, businst_attr_partition_handle, NULL); -static struct businst_attribute ba_partition_guid = - __ATTR(partition_guid, S_IRUGO, businst_attr_partition_guid, NULL); -static struct businst_attribute ba_partition_name = - __ATTR(partition_name, S_IRUGO, businst_attr_partition_name, NULL); -static struct businst_attribute ba_channel_addr = - __ATTR(channel_addr, S_IRUGO, businst_attr_channel_addr, NULL); -static struct businst_attribute ba_nchannel_bytes = - __ATTR(nchannel_bytes, S_IRUGO, businst_attr_nchannel_bytes, NULL); -static struct businst_attribute ba_channel_id = - __ATTR(channel_id, S_IRUGO, businst_attr_channel_id, NULL); -static struct businst_attribute ba_client_bus_info = - __ATTR(client_bus_info, S_IRUGO, businst_attr_client_bus_info, NULL); +static DEVICE_ATTR_RO(partition_handle); +static DEVICE_ATTR_RO(partition_guid); +static DEVICE_ATTR_RO(partition_name); +static DEVICE_ATTR_RO(channel_addr); +static DEVICE_ATTR_RO(channel_bytes); +static DEVICE_ATTR_RO(channel_id); +static DEVICE_ATTR_RO(client_bus_info); -static int -register_businst_attributes(struct visorbus_devdata *businst) -{ - int rc = 0; +static struct attribute *dev_attrs[] = { + &dev_attr_partition_handle.attr, + &dev_attr_partition_guid.attr, + &dev_attr_partition_name.attr, + &dev_attr_channel_addr.attr, + &dev_attr_channel_bytes.attr, + &dev_attr_channel_id.attr, + &dev_attr_client_bus_info.attr, + NULL +}; - businst->kobj.kset = &businstances; /* identify parent sysfs dir */ - rc = kobject_init_and_add(&businst->kobj, &businst_kobj_type, - NULL, "visorbus%d", businst->devno); - if (rc < 0) - goto away; +static struct attribute_group dev_attr_grp = { + .attrs = dev_attrs, +}; - rc = businst_create_file(businst, &ba_partition_handle); - if (rc < 0) - goto away; - - rc = businst_create_file(businst, &ba_partition_guid); - if (rc < 0) - goto away; - - rc = businst_create_file(businst, &ba_partition_name); - if (rc < 0) - goto away; - - rc = businst_create_file(businst, &ba_channel_addr); - if (rc < 0) - goto away; - - rc = businst_create_file(businst, &ba_nchannel_bytes); - if (rc < 0) - goto away; - - rc = businst_create_file(businst, &ba_channel_id); - if (rc < 0) - goto away; - - rc = businst_create_file(businst, &ba_client_bus_info); - if (rc < 0) - goto away; - - kobject_uevent(&businst->kobj, KOBJ_ADD); - - rc = 0; -away: - return rc; -} - -static void -unregister_businst_attributes(struct visorbus_devdata *businst) -{ - businst_remove_file(businst, &ba_partition_handle); - businst_remove_file(businst, &ba_partition_guid); - businst_remove_file(businst, &ba_partition_name); - businst_remove_file(businst, &ba_channel_addr); - businst_remove_file(businst, &ba_nchannel_bytes); - businst_remove_file(businst, &ba_channel_id); - businst_remove_file(businst, &ba_client_bus_info); - kobject_put(&businst->kobj); -} +static const struct attribute_group *visorbus_groups[] = { + &dev_attr_grp, + NULL +}; /* DRIVER attributes * @@ -1646,6 +1491,7 @@ create_bus_instance(int id) goto away; } dev_set_name(&devdata->dev, "visorbus%d", id); + devdata->dev.groups = visorbus_groups; devdata->dev.release = visorbus_release_busdevice; if (device_register(&devdata->dev) < 0) { POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, id, @@ -1692,7 +1538,6 @@ create_bus_instance(int id) } } } - register_businst_attributes(devdata); bus_count++; list_add_tail(&devdata->list_all, &list_all_bus_instances); if (id == 0) @@ -1715,7 +1560,6 @@ remove_bus_instance(struct visorbus_devdata *devdata) * successfully been able to trace thru the code to see where/how * release() gets called. But I know it does. */ - unregister_businst_attributes(devdata); bus_count--; if (devdata->chan) { visorchannel_destroy(devdata->chan); From f3aa5fe83f35d13be84e162c6cbceb534c9f5591 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Wed, 13 May 2015 13:22:14 -0400 Subject: [PATCH 0510/1163] staging: unisys: Move the visorbus device underneath devices Mimicing what other drivers do, this seems appropriate. Yeah, it is a bus, but it is a bus _device_. This makes things work better and smoother. Now the sysfs looks like [root@dhcp-17-174 visorbus]# ls -l /sys/bus/visorbus/devices/ total 0 lrwxrwxrwx. 1 root root 0 Apr 17 16:09 vbus1:dev2 -> ../../../devices/visorbus1/vbus1:dev2 lrwxrwxrwx. 1 root root 0 Apr 17 16:09 visorbus1 -> ../../../devices/visorbus1 Which looks correct. All the attributes are still correct too, based on my very minimal testing of 'ls -lR'. :-) Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorbus_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index e2993717fb62..a9cbaa6b15cd 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -1491,6 +1491,7 @@ create_bus_instance(int id) goto away; } dev_set_name(&devdata->dev, "visorbus%d", id); + devdata->dev.bus = &visorbus_type; devdata->dev.groups = visorbus_groups; devdata->dev.release = visorbus_release_busdevice; if (device_register(&devdata->dev) < 0) { From 68b04f1f342d35d439f11b675c5adbcaa85a75be Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Wed, 13 May 2015 13:22:15 -0400 Subject: [PATCH 0511/1163] staging: unisys: Properly move version file into bus attr Simplify things by moving the version file handling into the core. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorbus_main.c | 66 +++++++++---------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index a9cbaa6b15cd..1bad050684dc 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -88,6 +88,35 @@ static int visorbus_uevent(struct device *xdev, struct kobj_uevent_env *env); static int visorbus_match(struct device *xdev, struct device_driver *xdrv); static void fix_vbus_dev_info(struct visor_device *visordev); +/* BUS type attributes + * + * define & implement display of bus attributes under + * /sys/bus/visorbus. + * + */ + +static ssize_t version_show(struct bus_type *bus, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%s\n", VERSION); +} + +static BUS_ATTR_RO(version); + +static struct attribute *visorbus_bus_attrs[] = { + &bus_attr_version.attr, + NULL, +}; + +static const struct attribute_group visorbus_bus_group = { + .attrs = visorbus_bus_attrs, +}; + +const struct attribute_group *visorbus_bus_groups[] = { + &visorbus_bus_group, + NULL, +}; + + /** This describes the TYPE of bus. * (Don't confuse this with an INSTANCE of the bus.) */ @@ -95,6 +124,7 @@ static struct bus_type visorbus_type = { .name = "visorbus", .match = visorbus_match, .uevent = visorbus_uevent, + .bus_groups = visorbus_bus_groups, }; static struct delayed_work periodic_work; @@ -609,37 +639,6 @@ void unregister_channel_attributes(struct visor_device *dev) #define to_visorbus_devdata(obj) \ container_of(obj, struct visorbus_devdata, dev) -/* BUS type attributes - * - * define & implement display of bus attributes under - * /sys/bus/visorbus. - * - */ - -static ssize_t -BUSTYPE_ATTR_version(struct bus_type *bus, char *buf) -{ - return snprintf(buf, PAGE_SIZE, "%s\n", VERSION); -} - -static struct bus_attribute bustype_attr_version = -__ATTR(version, S_IRUGO, BUSTYPE_ATTR_version, NULL); - -static int -register_bustype_attributes(void) -{ - int rc = 0; - - rc = bus_create_file(&visorbus_type, &bustype_attr_version); - return rc; -} - -static void -unregister_bustype_attributes(void) -{ - bus_remove_file(&visorbus_type, &bustype_attr_version); -} - /* BUS instance attributes * * define & implement display of bus attributes under @@ -1580,10 +1579,6 @@ create_bus_type(void) visorbus_type.dev_attrs = visor_device_attrs; rc = bus_register(&visorbus_type); - if (rc < 0) - return rc; - - rc = register_bustype_attributes(); return rc; } @@ -1592,7 +1587,6 @@ create_bus_type(void) static void remove_bus_type(void) { - unregister_bustype_attributes(); bus_unregister(&visorbus_type); } From 5ace402e390e99e72d4c4d15bfd1fe9b0bdfec58 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Wed, 13 May 2015 13:22:16 -0400 Subject: [PATCH 0512/1163] staging: unisys: Remove dead kobj structs Remove stale code. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorbus_main.c | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 1bad050684dc..cacc5346c0b6 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -48,38 +48,6 @@ struct visorbus_devdata { struct spar_vbus_headerinfo vbus_hdr_info; }; -/* These forward declarations are required since our drivers are out-of-tree. - * The structures referenced are kernel-private and are not in the headers, but - * it is impossible to make a functioning bus driver without them. - */ -struct subsys_private { - struct kset subsys; - struct kset *devices_kset; - - struct kset *drivers_kset; - struct klist klist_devices; - struct klist klist_drivers; - struct blocking_notifier_head bus_notifier; - unsigned int drivers_autoprobe:1; - struct bus_type *bus; - - struct list_head class_interfaces; - struct kset glue_dirs; - struct mutex class_mutex; /* ignore */ - struct class *class; -}; - -struct bus_type_private { - struct kset subsys; - struct kset *drivers_kset; - struct kset *devices_kset; - struct klist klist_devices; - struct klist klist_drivers; - struct blocking_notifier_head bus_notifier; - unsigned int drivers_autoprobe:1; - struct bus_type *bus; -}; - #define CURRENT_FILE_PC VISOR_BUS_PC_visorbus_main_c #define POLLJIFFIES_TESTWORK 100 #define POLLJIFFIES_NORMALCHANNEL 10 From 795731627c74f2bcf6b289bcc5c06d7d822f11a5 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Wed, 13 May 2015 13:22:17 -0400 Subject: [PATCH 0513/1163] staging: unisys: Clean up device sysfs attributes Properly hook into the struct device groups element. This allows the core infrastructure to manage the files instead of the bus layer. And makes the code easier to read. I didn't clean up the _show functions just modified them a bit to handle the different args for now and to prevent a build warning. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/visorbus.h | 1 - .../staging/unisys/visorbus/visorbus_main.c | 229 ++++++------------ 2 files changed, 70 insertions(+), 160 deletions(-) diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h index d54282222f65..6c551df1adc0 100644 --- a/drivers/staging/unisys/include/visorbus.h +++ b/drivers/staging/unisys/include/visorbus.h @@ -128,7 +128,6 @@ struct visor_device { struct periodic_work *periodic_work; bool being_removed; bool responded_to_device_create; - struct kobject kobjchannel; /* visorbus/dev/channel/ */ struct kobject kobjdevmajorminor; /* visorbus/dev/devmajorminor/*/ struct { int major, minor; diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index cacc5346c0b6..c654c67b782f 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -396,214 +396,134 @@ unregister_devmajorminor_attributes(struct visor_device *dev) dev->kobjdevmajorminor.parent = NULL; } -/* Implement publishing of channel attributes under: - * - * /sys/bus/visorbus/dev/channel - * - */ - -#define to_channel_attr(_attr) \ - container_of(_attr, struct channel_attribute, attr) -#define to_visor_device_from_kobjchannel(obj) \ - container_of(obj, struct visor_device, kobjchannel) - -struct channel_attribute { - struct attribute attr; - ssize_t (*show)(struct visor_device*, char *buf); - ssize_t (*store)(struct visor_device*, const char *buf, size_t count); -}; - /* begin implementation of specific channel attributes to appear under * /sys/bus/visorbus/dev/channel */ -static ssize_t devicechannel_attr_physaddr(struct visor_device *dev, char *buf) +static ssize_t physaddr_show(struct device *dev, struct device_attribute *attr, + char *buf) { - if (!dev->visorchannel) + struct visor_device *vdev = to_visor_device(dev); + + if (!vdev->visorchannel) return 0; return snprintf(buf, PAGE_SIZE, "0x%Lx\n", - visorchannel_get_physaddr(dev->visorchannel)); + visorchannel_get_physaddr(vdev->visorchannel)); } -static ssize_t devicechannel_attr_nbytes(struct visor_device *dev, char *buf) +static ssize_t nbytes_show(struct device *dev, struct device_attribute *attr, + char *buf) { - if (!dev->visorchannel) + struct visor_device *vdev = to_visor_device(dev); + + if (!vdev->visorchannel) return 0; return snprintf(buf, PAGE_SIZE, "0x%lx\n", - visorchannel_get_nbytes(dev->visorchannel)); + visorchannel_get_nbytes(vdev->visorchannel)); } -static ssize_t devicechannel_attr_clientpartition(struct visor_device *dev, - char *buf) { - if (!dev->visorchannel) +static ssize_t clientpartition_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct visor_device *vdev = to_visor_device(dev); + + if (!vdev->visorchannel) return 0; return snprintf(buf, PAGE_SIZE, "0x%Lx\n", - visorchannel_get_clientpartition(dev->visorchannel)); + visorchannel_get_clientpartition(vdev->visorchannel)); } -static ssize_t devicechannel_attr_typeguid(struct visor_device *dev, char *buf) +static ssize_t typeguid_show(struct device *dev, struct device_attribute *attr, + char *buf) { + struct visor_device *vdev = to_visor_device(dev); char s[99]; - if (!dev->visorchannel) + if (!vdev->visorchannel) return 0; return snprintf(buf, PAGE_SIZE, "%s\n", - visorchannel_id(dev->visorchannel, s)); + visorchannel_id(vdev->visorchannel, s)); } -static ssize_t devicechannel_attr_zoneguid(struct visor_device *dev, char *buf) +static ssize_t zoneguid_show(struct device *dev, struct device_attribute *attr, + char *buf) { + struct visor_device *vdev = to_visor_device(dev); char s[99]; - if (!dev->visorchannel) + if (!vdev->visorchannel) return 0; return snprintf(buf, PAGE_SIZE, "%s\n", - visorchannel_zoneid(dev->visorchannel, s)); + visorchannel_zoneid(vdev->visorchannel, s)); } -static ssize_t devicechannel_attr_typename(struct visor_device *dev, char *buf) +static ssize_t typename_show(struct device *dev, struct device_attribute *attr, + char *buf) { + struct visor_device *vdev = to_visor_device(dev); int i = 0; - struct bus_type *xbus = dev->device.bus; - struct device_driver *xdrv = dev->device.driver; + struct bus_type *xbus = dev->bus; + struct device_driver *xdrv = dev->driver; struct visor_driver *drv = NULL; - if (!dev->visorchannel || !xbus || !xdrv) + if (!vdev->visorchannel || !xbus || !xdrv) return 0; - i = xbus->match(&dev->device, xdrv); + i = xbus->match(dev, xdrv); if (!i) return 0; drv = to_visor_driver(xdrv); return snprintf(buf, PAGE_SIZE, "%s\n", drv->channel_types[i - 1].name); } -static ssize_t devicechannel_attr_dump(struct visor_device *dev, char *buf) +static ssize_t dump_show(struct device *dev, struct device_attribute *attr, + char *buf) { - int count = 0; /* TODO: replace this with debugfs code + struct visor_device *vdev = to_visor_device(dev); + int count = 0; struct seq_file *m = NULL; - if (dev->visorchannel == NULL) + if (vdev->visorchannel == NULL) return 0; m = visor_seq_file_new_buffer(buf, PAGE_SIZE - 1); if (m == NULL) return 0; - visorchannel_debug(dev->visorchannel, 1, m, 0); + visorchannel_debug(vdev->visorchannel, 1, m, 0); count = m->count; visor_seq_file_done_buffer(m); m = NULL; */ - return count; + return 0; } -static struct channel_attribute all_channel_attrs[] = { - __ATTR(physaddr, S_IRUGO, - devicechannel_attr_physaddr, NULL), - __ATTR(nbytes, S_IRUGO, - devicechannel_attr_nbytes, NULL), - __ATTR(clientpartition, S_IRUGO, - devicechannel_attr_clientpartition, NULL), - __ATTR(typeguid, S_IRUGO, - devicechannel_attr_typeguid, NULL), - __ATTR(zoneguid, S_IRUGO, - devicechannel_attr_zoneguid, NULL), - __ATTR(typename, S_IRUGO, - devicechannel_attr_typename, NULL), - __ATTR(dump, S_IRUGO, - devicechannel_attr_dump, NULL), +static DEVICE_ATTR_RO(physaddr); +static DEVICE_ATTR_RO(nbytes); +static DEVICE_ATTR_RO(clientpartition); +static DEVICE_ATTR_RO(typeguid); +static DEVICE_ATTR_RO(zoneguid); +static DEVICE_ATTR_RO(typename); +static DEVICE_ATTR_RO(dump); + +static struct attribute *channel_attrs[] = { + &dev_attr_physaddr.attr, + &dev_attr_nbytes.attr, + &dev_attr_clientpartition.attr, + &dev_attr_typeguid.attr, + &dev_attr_zoneguid.attr, + &dev_attr_typename.attr, + &dev_attr_dump.attr, +}; + +static struct attribute_group channel_attr_grp = { + .name = "channel", + .attrs = channel_attrs, +}; + +static const struct attribute_group *visorbus_dev_groups[] = { + &channel_attr_grp, + NULL }; /* end implementation of specific channel attributes */ -static ssize_t channel_attr_show(struct kobject *kobj, struct attribute *attr, - char *buf) -{ - struct channel_attribute *channel_attr = to_channel_attr(attr); - struct visor_device *dev = to_visor_device_from_kobjchannel(kobj); - ssize_t ret = 0; - - if (channel_attr->show) - ret = channel_attr->show(dev, buf); - return ret; -} - -static ssize_t channel_attr_store(struct kobject *kobj, struct attribute *attr, - const char *buf, size_t count) -{ - struct channel_attribute *channel_attr = to_channel_attr(attr); - struct visor_device *dev = to_visor_device_from_kobjchannel(kobj); - ssize_t ret = 0; - - if (channel_attr->store) - ret = channel_attr->store(dev, buf, count); - return ret; -} - -static int channel_create_file(struct visor_device *dev, - struct channel_attribute *attr) -{ - return sysfs_create_file(&dev->kobjchannel, &attr->attr); -} - -static void channel_remove_file(struct visor_device *dev, - struct channel_attribute *attr) -{ - sysfs_remove_file(&dev->kobjchannel, &attr->attr); -} - -static const struct sysfs_ops channel_sysfs_ops = { - .show = channel_attr_show, - .store = channel_attr_store, -}; - -static struct kobj_type channel_kobj_type = { - .sysfs_ops = &channel_sysfs_ops -}; - -int register_channel_attributes(struct visor_device *dev) -{ - int rc = 0, i = 0, x = 0; - - if (dev->kobjchannel.parent) - goto away; /* already registered */ - x = kobject_init_and_add(&dev->kobjchannel, &channel_kobj_type, - &dev->device.kobj, "channel"); - if (x < 0) { - rc = x; - goto away; - } - - kobject_uevent(&dev->kobjchannel, KOBJ_ADD); - - for (i = 0; - i < sizeof(all_channel_attrs) / sizeof(struct channel_attribute); - i++) - x = channel_create_file(dev, &all_channel_attrs[i]); - if (x < 0) { - while (--i >= 0) - channel_remove_file(dev, &all_channel_attrs[i]); - kobject_del(&dev->kobjchannel); - kobject_put(&dev->kobjchannel); - rc = x; - goto away; - } -away: - return rc; -} - -void unregister_channel_attributes(struct visor_device *dev) -{ - int i = 0; - - if (!dev->kobjchannel.parent) - return; /* already unregistered */ - for (i = 0; - i < sizeof(all_channel_attrs) / sizeof(struct channel_attribute); - i++) - channel_remove_file(dev, &all_channel_attrs[i]); - - kobject_del(&dev->kobjchannel); - kobject_put(&dev->kobjchannel); - dev->kobjchannel.parent = NULL; -} #define to_visorbus_devdata(obj) \ container_of(obj, struct visorbus_devdata, dev) @@ -1144,6 +1064,7 @@ create_visor_device(struct visorbus_devdata *devdata, dev->device.parent = &devdata->dev; sema_init(&dev->visordriver_callback_lock, 1); /* unlocked */ dev->device.bus = &visorbus_type; + dev->device.groups = visorbus_dev_groups; device_initialize(&dev->device); dev->device.release = visorbus_release_device; /* keep a reference just for us (now 2) */ @@ -1191,13 +1112,6 @@ create_visor_device(struct visorbus_devdata *devdata, } /* note: device_register is simply device_initialize + device_add */ - rc = register_channel_attributes(dev); - if (rc < 0) { - POSTCODE_LINUX_3(DEVICE_REGISTER_FAILURE_PC, chipset_dev_no, - DIAG_SEVERITY_ERR); - goto away; - } - registered1 = true; rc = register_devmajorminor_attributes(dev); @@ -1214,8 +1128,6 @@ away: if (rc < 0) { if (registered2) unregister_devmajorminor_attributes(dev); - if (registered1) - unregister_channel_attributes(dev); if (gotten) put_device(&dev->device); if (visorchannel) @@ -1233,7 +1145,6 @@ remove_visor_device(struct visor_device *dev) { list_del(&dev->list_all); unregister_devmajorminor_attributes(dev); - unregister_channel_attributes(dev); put_device(&dev->device); device_unregister(&dev->device); } From 1fb3016eab6950b547e6ae794830c51165485b13 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Wed, 13 May 2015 13:22:18 -0400 Subject: [PATCH 0514/1163] staging: unisys: Prep for removing 'info' structs The visorbus driver has three _info structs lying around (device, bus, channel) that store subsets of info from the bigger structs. Having these structs around make resource handling very difficult and more complicated than it needs to be. Use the device infrastructure and instead pass 'struct visor_device' all over the place. In order to do that 'struct visor_device' needs to get smarter. This patch adds the pieces to prep for it. The new elements will be used in later patches. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/visorbus.h | 19 +++++++++++++++++++ .../staging/unisys/visorbus/visorbus_main.c | 2 +- .../unisys/visorbus/visorbus_private.h | 9 --------- .../staging/unisys/visorbus/visorchannel.c | 4 ++++ 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h index 6c551df1adc0..14f6f8e9426d 100644 --- a/drivers/staging/unisys/include/visorbus.h +++ b/drivers/staging/unisys/include/visorbus.h @@ -40,9 +40,18 @@ struct visor_driver; struct visor_device; +extern struct bus_type visorbus_type; typedef void (*visorbus_state_complete_func) (struct visor_device *dev, int status); +struct visorchipset_state { + u32 created:1; + u32 attached:1; + u32 configured:1; + u32 running:1; + /* Add new fields above. */ + /* Remaining bits in this 32-bit word are unused. */ +}; /** This struct describes a specific Supervisor channel, by providing its * GUID, name, and sizes. @@ -141,6 +150,16 @@ struct visor_device { bool resuming; unsigned long chipset_bus_no; unsigned long chipset_dev_no; + struct visorchipset_state state; + uuid_le type; + uuid_le inst; + u8 *name; + u8 *description; + struct controlvm_message_header *pending_msg_hdr; + void *vbus_hdr_info; + u32 switch_no; + u32 internal_port_no; + uuid_le partition_uuid; }; #define to_visor_device(x) container_of(x, struct visor_device, device) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index c654c67b782f..7dddb072a29e 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -88,7 +88,7 @@ const struct attribute_group *visorbus_bus_groups[] = { /** This describes the TYPE of bus. * (Don't confuse this with an INSTANCE of the bus.) */ -static struct bus_type visorbus_type = { +struct bus_type visorbus_type = { .name = "visorbus", .match = visorbus_match, .uevent = visorbus_uevent, diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h index 8326e4da56c1..bbc64bd88e0a 100644 --- a/drivers/staging/unisys/visorbus/visorbus_private.h +++ b/drivers/staging/unisys/visorbus/visorbus_private.h @@ -27,15 +27,6 @@ struct visorchannel; -struct visorchipset_state { - u32 created:1; - u32 attached:1; - u32 configured:1; - u32 running:1; - /* Add new fields above. */ - /* Remaining bits in this 32-bit word are unused. */ -}; - enum visorchipset_addresstype { /** address is guest physical, but outside of the physical memory * region that is controlled by the running OS (this is the normal diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index 2d3e4d6defea..a9c3ae160ce5 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -23,6 +23,7 @@ #include "version.h" #include "visorbus.h" #include +#include "controlvmchannel.h" #define MYDRVNAME "visorchannel" @@ -44,6 +45,9 @@ struct visorchannel { struct signal_queue_header event_queue; struct signal_queue_header ack_queue; } safe_uis_queue; + struct irq_info intr; + uuid_le type; + uuid_le inst; }; /* Creates the struct visorchannel abstraction for a data area in memory, From ab0592b9fb9b933f97b3795d21ce4356035aead8 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Wed, 13 May 2015 13:22:19 -0400 Subject: [PATCH 0515/1163] staging: unisys: Add visor device find routine If we are going to remove the bus_info structs than we need a way to find the devices when the *_create/destroy cmds are sent over the vmchannel. This function crudely impements what pci has. It takes a bus_no and dev_no and finds the matching 'struct visor_device'. This function can/should be optimzed later once we get our heads wrapped around its needs. For now, I am using dev_no=0 to mean the visorbus itself. The function is limited to chipset.c only because it is only needed to do the lookups upon receiving a vmchannel command. Future patches will make sure the resulting 'struct visor_device' is used every where else. Also allow visorbus_type to be more visible for use. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorchipset.c | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index b96a40cf9124..42bf02afb807 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -711,6 +711,45 @@ dev_info_clear(void *v) memset(p, 0, sizeof(struct visorchipset_device_info)); } +struct visor_busdev { + u32 bus_no; + u32 dev_no; +}; + +static int match_visorbus_dev_by_id(struct device *dev, void *data) +{ + struct visor_device *vdev = to_visor_device(dev); + struct visor_busdev *id = (struct visor_busdev *)data; + u32 bus_no = id->bus_no; + u32 dev_no = id->dev_no; + + if (((bus_no == -1) || (vdev->chipset_bus_no == bus_no)) && + ((dev_no == -1) || (vdev->chipset_dev_no == dev_no))) + return 1; + + return 0; +} +struct visor_device *visorbus_get_device_by_id(u32 bus_no, u32 dev_no, + struct visor_device *from) +{ + struct device *dev; + struct device *dev_start = NULL; + struct visor_device *vdev = NULL; + struct visor_busdev id = { + .bus_no = bus_no, + .dev_no = dev_no + }; + + if (from) + dev_start = &from->device; + dev = bus_find_device(&visorbus_type, dev_start, (void *)&id, + match_visorbus_dev_by_id); + if (dev) + vdev = to_visor_device(dev); + return vdev; +} +EXPORT_SYMBOL(visorbus_get_device_by_id); + static struct visorchipset_bus_info * bus_find(struct list_head *list, u32 bus_no) { From 4f6d8a97833f4640991f696d471486e5442eb0b2 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Wed, 13 May 2015 13:22:20 -0400 Subject: [PATCH 0516/1163] staging: unisys: Add a function to set the clientpartition This patch is an attempt to help hide the channel info behind accessory functions. I was trying to keep visorchannel as private as possible. The only function missing that seemed to be needed for now was the ability to set the clientpartition. So I expose that here. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/visorbus.h | 2 ++ drivers/staging/unisys/visorbus/visorchannel.c | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h index 14f6f8e9426d..3375ffdc7304 100644 --- a/drivers/staging/unisys/include/visorbus.h +++ b/drivers/staging/unisys/include/visorbus.h @@ -210,6 +210,8 @@ ulong visorchannel_get_nbytes(struct visorchannel *channel); char *visorchannel_id(struct visorchannel *channel, char *s); char *visorchannel_zoneid(struct visorchannel *channel, char *s); u64 visorchannel_get_clientpartition(struct visorchannel *channel); +int visorchannel_set_clientpartition(struct visorchannel *channel, + u64 partition_handle); uuid_le visorchannel_get_uuid(struct visorchannel *channel); char *visorchannel_uuid_id(uuid_le *guid, char *s); void visorchannel_debug(struct visorchannel *channel, int num_queues, diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index a9c3ae160ce5..1789f9d89c0d 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -190,6 +190,15 @@ visorchannel_get_clientpartition(struct visorchannel *channel) } EXPORT_SYMBOL_GPL(visorchannel_get_clientpartition); +int +visorchannel_set_clientpartition(struct visorchannel *channel, + u64 partition_handle) +{ + channel->chan_hdr.partition_handle = partition_handle; + return 0; +} +EXPORT_SYMBOL_GPL(visorchannel_set_clientpartition); + uuid_le visorchannel_get_uuid(struct visorchannel *channel) { From d5531f3701d7e1b1bef5f8a567d4ed6175f78202 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Wed, 13 May 2015 13:22:21 -0400 Subject: [PATCH 0517/1163] staging: unisys: Add checks for creation There was a bunch of channel creation checks before the visorchannel_create function was called, moving some of those checks inside. This keeps the outside code cleaner and handles the situation where a caller forgets to make these checks. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchannel.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index 1789f9d89c0d..6e7675e27b21 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -62,6 +62,9 @@ visorchannel_create_guts(u64 physaddr, unsigned long channel_bytes, int err; size_t size = sizeof(struct channel_header); + if (physaddr == 0) + return NULL; + channel = kzalloc(sizeof(*channel), gfp); if (!channel) goto cleanup; From 24c5a74e7d1792fc5921577676aea5f11a15bd45 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Wed, 13 May 2015 13:22:22 -0400 Subject: [PATCH 0518/1163] staging: unisys: Remove unused intr The conversion to visor_device caused some compile issues.The main problem was the new fields in 'struct visor_device' were not public. Remove one that wasn't being used for now. struct irq_info intr Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchannel.c | 1 - drivers/staging/unisys/visorbus/visorchipset.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index 6e7675e27b21..e0dfaa9c955d 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -45,7 +45,6 @@ struct visorchannel { struct signal_queue_header event_queue; struct signal_queue_header ack_queue; } safe_uis_queue; - struct irq_info intr; uuid_le type; uuid_le inst; }; diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 42bf02afb807..1487dafb18b9 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -1352,7 +1352,6 @@ my_device_create(struct controlvm_message *inmsg) dev_info->chan_info.n_channel_bytes = cmd->create_device.channel_bytes; dev_info->chan_info.channel_type_uuid = cmd->create_device.data_type_uuid; - dev_info->chan_info.intr = cmd->create_device.intr; list_add(&dev_info->entry, &dev_info_list); POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); From 5ecbd5d46d8ce16df024d15cd8dee9e536770552 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Wed, 13 May 2015 13:22:23 -0400 Subject: [PATCH 0519/1163] staging: unisys: Convert the device attributes to visor_device Convert the device attribute files to properly use visor_device. This removes a whole bunch of checks and assumptions and simplifies the code. Everything is straightforward. No testing down as I can't mimic channel info correctl. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorbus_main.c | 80 +++++++------------ 1 file changed, 28 insertions(+), 52 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 7dddb072a29e..b66fce5d63b5 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -541,78 +541,54 @@ static const struct attribute_group *visorbus_dev_groups[] = { static ssize_t partition_handle_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct visorbus_devdata *businst = to_visorbus_devdata(dev); - struct visorchipset_bus_info bus_info; - int len = 0; + struct visor_device *vdev = to_visor_device(dev); + u64 handle = visorchannel_get_clientpartition(vdev->visorchannel); - if (businst && visorchipset_get_bus_info(businst->devno, &bus_info)) - len = snprintf(buf, PAGE_SIZE, - "0x%Lx\n", - (unsigned long long)bus_info.partition_handle); - return len; + return snprintf(buf, PAGE_SIZE, "0x%Lx\n", handle); } static ssize_t partition_guid_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct visorbus_devdata *businst = to_visorbus_devdata(dev); - struct visorchipset_bus_info bus_info; - int len = 0; + struct visor_device *vdev = to_visor_device(dev); - if (businst && visorchipset_get_bus_info(businst->devno, &bus_info)) - len = snprintf(buf, PAGE_SIZE, "{%pUb}\n", - &bus_info.partition_uuid); - return len; + return snprintf(buf, PAGE_SIZE, "{%pUb}\n", &vdev->partition_uuid); } static ssize_t partition_name_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct visorbus_devdata *businst = to_visorbus_devdata(dev); - struct visorchipset_bus_info bus_info; - int len = 0; + struct visor_device *vdev = to_visor_device(dev); - if (businst && - visorchipset_get_bus_info(businst->devno, &bus_info) && - bus_info.name) - len = snprintf(buf, PAGE_SIZE, "%s\n", bus_info.name); - return len; + return snprintf(buf, PAGE_SIZE, "%s\n", vdev->name); } static ssize_t channel_addr_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct visorbus_devdata *businst = to_visorbus_devdata(dev); - struct visorchipset_bus_info bus_info; - int len = 0; + struct visor_device *vdev = to_visor_device(dev); + u64 addr = visorchannel_get_physaddr(vdev->visorchannel); - if (businst && visorchipset_get_bus_info(businst->devno, &bus_info)) - len = snprintf(buf, PAGE_SIZE, "0x%Lx\n", (unsigned long long) - bus_info.chan_info.channel_addr); - return len; + return snprintf(buf, PAGE_SIZE, "0x%Lx\n", addr); } static ssize_t channel_bytes_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct visorbus_devdata *businst = to_visorbus_devdata(dev); - struct visorchipset_bus_info bus_info; - int len = 0; + struct visor_device *vdev = to_visor_device(dev); + u64 nbytes = visorchannel_get_nbytes(vdev->visorchannel); - if (businst && visorchipset_get_bus_info(businst->devno, &bus_info)) - len = snprintf(buf, PAGE_SIZE, "0x%Lx\n", (unsigned long long) - bus_info.chan_info.n_channel_bytes); - return len; + return snprintf(buf, PAGE_SIZE, "0x%Lx\n", nbytes); } static ssize_t channel_id_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct visorbus_devdata *businst = to_visorbus_devdata(dev); + struct visor_device *vdev = to_visor_device(dev); int len = 0; - if (businst && businst->chan) { - visorchannel_id(businst->chan, buf); + if (vdev->visorchannel) { + visorchannel_id(vdev->visorchannel, buf); len = strlen(buf); buf[len++] = '\n'; } @@ -622,8 +598,9 @@ static ssize_t channel_id_show(struct device *dev, static ssize_t client_bus_info_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct visorbus_devdata *businst = to_visorbus_devdata(dev); - struct visorchipset_bus_info bus_info; + struct visor_device *vdev = to_visor_device(dev); + struct visorchannel *channel = vdev->visorchannel; + int i, x, remain = PAGE_SIZE; unsigned long off; char *p = buf; @@ -631,16 +608,15 @@ static ssize_t client_bus_info_show(struct device *dev, struct ultra_vbus_deviceinfo dev_info; partition_name = ""; - if (businst && businst->chan) { - if (visorchipset_get_bus_info(businst->devno, &bus_info) && - bus_info.name) - partition_name = bus_info.name; + if (channel) { + if (vdev->name) + partition_name = vdev->name; x = snprintf(p, remain, - "Client device / client driver info for %s partition (vbus #%d):\n", - partition_name, businst->devno); + "Client device / client driver info for %s partition (vbus #%ld):\n", + partition_name, vdev->chipset_dev_no); p += x; remain -= x; - x = visorchannel_read(businst->chan, + x = visorchannel_read(channel, offsetof(struct spar_vbus_channel_protocol, chp_info), @@ -651,7 +627,7 @@ static ssize_t client_bus_info_show(struct device *dev, p += x; remain -= x; } - x = visorchannel_read(businst->chan, + x = visorchannel_read(channel, offsetof(struct spar_vbus_channel_protocol, bus_info), @@ -665,8 +641,8 @@ static ssize_t client_bus_info_show(struct device *dev, off = offsetof(struct spar_vbus_channel_protocol, dev_info); i = 0; while (off + sizeof(dev_info) <= - visorchannel_get_nbytes(businst->chan)) { - x = visorchannel_read(businst->chan, + visorchannel_get_nbytes(channel)) { + x = visorchannel_read(channel, off, &dev_info, sizeof(dev_info)); if (x >= 0) { x = vbuschannel_devinfo_to_string From 3032aeddd85e6499cd118246ceb44b03dd393356 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Wed, 13 May 2015 13:22:24 -0400 Subject: [PATCH 0520/1163] staging: unisys: Convert bus functions to pass bus_info pointer around Most bus functions pass bus_no around and then do a lookup inside each function to find the bus_info struct. Instead just pass the pointer. This prepares us for a later conversion to using visor_device. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorbus_main.c | 44 ++++++++----------- .../unisys/visorbus/visorbus_private.h | 11 ++--- .../staging/unisys/visorbus/visorchipset.c | 39 +++++++--------- 3 files changed, 42 insertions(+), 52 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index b66fce5d63b5..dd36d7b7e743 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -108,8 +108,8 @@ static long long bus_count; /** number of bus instances */ static long long total_devices_created; /** ever-increasing */ -static void chipset_bus_create(u32 bus_no); -static void chipset_bus_destroy(u32 bus_no); +static void chipset_bus_create(struct visorchipset_bus_info *bus_info); +static void chipset_bus_destroy(struct visorchipset_bus_info *bus_info); static void chipset_device_create(u32 bus_no, u32 dev_no); static void chipset_device_destroy(u32 bus_no, u32 dev_no); static void chipset_device_pause(u32 bus_no, u32 dev_no); @@ -1331,11 +1331,11 @@ fix_vbus_dev_info(struct visor_device *visordev) /** Create a device instance for the visor bus itself. */ static struct visorbus_devdata * -create_bus_instance(int id) +create_bus_instance(struct visorchipset_bus_info *bus_info) { struct visorbus_devdata *rc = NULL; struct visorbus_devdata *devdata = NULL; - struct visorchipset_bus_info bus_info; + int id = bus_info->bus_no; POSTCODE_LINUX_2(BUS_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); devdata = kzalloc(sizeof(*devdata), GFP_KERNEL); @@ -1355,15 +1355,14 @@ create_bus_instance(int id) goto away; } devdata->devno = id; - if ((visorchipset_get_bus_info(id, &bus_info)) && - (bus_info.chan_info.channel_addr > 0) && - (bus_info.chan_info.n_channel_bytes > 0)) { - u64 channel_addr = bus_info.chan_info.channel_addr; + if ((bus_info->chan_info.channel_addr > 0) && + (bus_info->chan_info.n_channel_bytes > 0)) { + u64 channel_addr = bus_info->chan_info.channel_addr; unsigned long n_channel_bytes = (unsigned long) - bus_info.chan_info.n_channel_bytes; + bus_info->chan_info.n_channel_bytes; uuid_le channel_type_guid = - bus_info.chan_info.channel_type_uuid; + bus_info->chan_info.channel_type_uuid; devdata->chan = visorchannel_create(channel_addr, n_channel_bytes, @@ -1373,7 +1372,7 @@ create_bus_instance(int id) POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, channel_addr, POSTCODE_SEVERITY_ERR); } else { - if (bus_info.flags.server) { + if (bus_info->flags.server) { init_vbus_channel(devdata->chan); } else { if (get_vbus_header_info(devdata->chan, @@ -1466,19 +1465,17 @@ static unsigned long test_bus_nos[MAXDEVICETEST]; static unsigned long test_dev_nos[MAXDEVICETEST]; static void -chipset_bus_create(u32 bus_no) +chipset_bus_create(struct visorchipset_bus_info *bus_info) { - struct visorchipset_bus_info bus_info; struct visorbus_devdata *devdata; int rc = -1; + u32 bus_no = bus_info->bus_no; POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO); - if (!visorchipset_get_bus_info(bus_no, &bus_info)) - goto away; - devdata = create_bus_instance(bus_no); + devdata = create_bus_instance(bus_info); if (!devdata) goto away; - if (!visorchipset_set_bus_context(bus_no, devdata)) + if (!visorchipset_set_bus_context(bus_info, devdata)) goto away; POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO); rc = 0; @@ -1491,30 +1488,27 @@ away: POSTCODE_LINUX_3(CHIPSET_INIT_SUCCESS_PC, bus_no, POSTCODE_SEVERITY_INFO); if (chipset_responders.bus_create) - (*chipset_responders.bus_create) (bus_no, rc); + (*chipset_responders.bus_create) (bus_info, rc); } static void -chipset_bus_destroy(u32 bus_no) +chipset_bus_destroy(struct visorchipset_bus_info *bus_info) { - struct visorchipset_bus_info bus_info; struct visorbus_devdata *devdata; int rc = -1; - if (!visorchipset_get_bus_info(bus_no, &bus_info)) - goto away; - devdata = (struct visorbus_devdata *)(bus_info.bus_driver_context); + devdata = (struct visorbus_devdata *)(bus_info->bus_driver_context); if (!devdata) goto away; remove_bus_instance(devdata); - if (!visorchipset_set_bus_context(bus_no, NULL)) + if (!visorchipset_set_bus_context(bus_info, NULL)) goto away; rc = 0; away: if (rc < 0) return; if (chipset_responders.bus_destroy) - (*chipset_responders.bus_destroy)(bus_no, rc); + (*chipset_responders.bus_destroy)(bus_info, rc); } static void diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h index bbc64bd88e0a..9a2d5636db54 100644 --- a/drivers/staging/unisys/visorbus/visorbus_private.h +++ b/drivers/staging/unisys/visorbus/visorbus_private.h @@ -104,8 +104,8 @@ struct visorchipset_bus_info { * visorchipset.) */ struct visorchipset_busdev_notifiers { - void (*bus_create)(u32 bus_no); - void (*bus_destroy)(u32 bus_no); + void (*bus_create)(struct visorchipset_bus_info *bus_info); + void (*bus_destroy)(struct visorchipset_bus_info *bus_info); void (*device_create)(u32 bus_no, u32 dev_no); void (*device_destroy)(u32 bus_no, u32 dev_no); void (*device_pause)(u32 bus_no, u32 dev_no); @@ -119,8 +119,8 @@ struct visorchipset_busdev_notifiers { * -1 = it failed */ struct visorchipset_busdev_responders { - void (*bus_create)(u32 bus_no, int response); - void (*bus_destroy)(u32 bus_no, int response); + void (*bus_create)(struct visorchipset_bus_info *p, int response); + void (*bus_destroy)(struct visorchipset_bus_info *p, int response); void (*device_create)(u32 bus_no, u32 dev_no, int response); void (*device_destroy)(u32 bus_no, u32 dev_no, int response); void (*device_pause)(u32 bus_no, u32 dev_no, int response); @@ -142,7 +142,8 @@ bool visorchipset_get_bus_info(u32 bus_no, struct visorchipset_bus_info *bus_info); bool visorchipset_get_device_info(u32 bus_no, u32 dev_no, struct visorchipset_device_info *dev_info); -bool visorchipset_set_bus_context(u32 bus_no, void *context); +bool visorchipset_set_bus_context(struct visorchipset_bus_info *bus_info, + void *context); /* visorbus init and exit functions */ int visorbus_init(void); diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 1487dafb18b9..432158d2e318 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -228,8 +228,8 @@ static void parahotplug_process_list(void); */ static struct visorchipset_busdev_notifiers busdev_notifiers; -static void bus_create_response(u32 bus_no, int response); -static void bus_destroy_response(u32 bus_no, int response); +static void bus_create_response(struct visorchipset_bus_info *p, int response); +static void bus_destroy_response(struct visorchipset_bus_info *p, int response); static void device_create_response(u32 bus_no, u32 dev_no, int response); static void device_destroy_response(u32 bus_no, u32 dev_no, int response); static void device_resume_response(u32 bus_no, u32 dev_no, int response); @@ -958,12 +958,12 @@ enum crash_obj_type { }; static void -bus_responder(enum controlvm_id cmd_id, u32 bus_no, int response) +bus_responder(enum controlvm_id cmd_id, struct visorchipset_bus_info *p, + int response) { - struct visorchipset_bus_info *p; bool need_clear = false; + u32 bus_no = p->bus_no; - p = bus_find(&bus_info_list, bus_no); if (!p) return; @@ -1049,15 +1049,12 @@ device_responder(enum controlvm_id cmd_id, u32 bus_no, u32 dev_no, int response) } static void -bus_epilog(u32 bus_no, +bus_epilog(struct visorchipset_bus_info *bus_info, u32 cmd, struct controlvm_message_header *msg_hdr, int response, bool need_response) { - struct visorchipset_bus_info *bus_info; bool notified = false; - bus_info = bus_find(&bus_info_list, bus_no); - if (!bus_info) return; @@ -1073,13 +1070,13 @@ bus_epilog(u32 bus_no, switch (cmd) { case CONTROLVM_BUS_CREATE: if (busdev_notifiers.bus_create) { - (*busdev_notifiers.bus_create) (bus_no); + (*busdev_notifiers.bus_create) (bus_info); notified = true; } break; case CONTROLVM_BUS_DESTROY: if (busdev_notifiers.bus_destroy) { - (*busdev_notifiers.bus_destroy) (bus_no); + (*busdev_notifiers.bus_destroy) (bus_info); notified = true; } break; @@ -1092,7 +1089,7 @@ bus_epilog(u32 bus_no, */ ; else - bus_responder(cmd, bus_no, response); + bus_responder(cmd, bus_info, response); up(¬ifier_lock); } @@ -1236,7 +1233,7 @@ bus_create(struct controlvm_message *inmsg) POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO); cleanup: - bus_epilog(bus_no, CONTROLVM_BUS_CREATE, &inmsg->hdr, + bus_epilog(bus_info, CONTROLVM_BUS_CREATE, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1); } @@ -1254,7 +1251,7 @@ bus_destroy(struct controlvm_message *inmsg) else if (bus_info->state.created == 0) rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE; - bus_epilog(bus_no, CONTROLVM_BUS_DESTROY, &inmsg->hdr, + bus_epilog(bus_info, CONTROLVM_BUS_DESTROY, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1); } @@ -1295,7 +1292,7 @@ bus_configure(struct controlvm_message *inmsg, POSTCODE_LINUX_3(BUS_CONFIGURE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO); } - bus_epilog(bus_no, CONTROLVM_BUS_CONFIGURE, &inmsg->hdr, + bus_epilog(bus_info, CONTROLVM_BUS_CONFIGURE, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1); } @@ -2112,15 +2109,15 @@ cleanup: } static void -bus_create_response(u32 bus_no, int response) +bus_create_response(struct visorchipset_bus_info *bus_info, int response) { - bus_responder(CONTROLVM_BUS_CREATE, bus_no, response); + bus_responder(CONTROLVM_BUS_CREATE, bus_info, response); } static void -bus_destroy_response(u32 bus_no, int response) +bus_destroy_response(struct visorchipset_bus_info *bus_info, int response) { - bus_responder(CONTROLVM_BUS_DESTROY, bus_no, response); + bus_responder(CONTROLVM_BUS_DESTROY, bus_info, response); } static void @@ -2164,10 +2161,8 @@ visorchipset_get_bus_info(u32 bus_no, struct visorchipset_bus_info *bus_info) EXPORT_SYMBOL_GPL(visorchipset_get_bus_info); bool -visorchipset_set_bus_context(u32 bus_no, void *context) +visorchipset_set_bus_context(struct visorchipset_bus_info *p, void *context) { - struct visorchipset_bus_info *p = bus_find(&bus_info_list, bus_no); - if (!p) return false; p->bus_driver_context = context; From b4b598fdde2773f0f0498d7c1e41b088db781f11 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Wed, 13 May 2015 13:22:25 -0400 Subject: [PATCH 0521/1163] staging: unisys: Convert device functions to pass dev_info pointer around Most device functions pass bus_no and dev_no around and then do a lookup inside each function to find the dev_info struct. Instead just pass the pointer. This prepares us for a later conversion to using visor device. No real technical changes. Just function header changes and little cleanups as a result. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/visorbus.h | 8 +- .../staging/unisys/visorbus/visorbus_main.c | 95 ++++++++++--------- .../unisys/visorbus/visorbus_private.h | 17 ++-- .../staging/unisys/visorbus/visorchipset.c | 74 +++++++-------- 4 files changed, 103 insertions(+), 91 deletions(-) diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h index 3375ffdc7304..3152ba47c702 100644 --- a/drivers/staging/unisys/include/visorbus.h +++ b/drivers/staging/unisys/include/visorbus.h @@ -43,7 +43,7 @@ struct visor_device; extern struct bus_type visorbus_type; typedef void (*visorbus_state_complete_func) (struct visor_device *dev, - int status); + int status, void *dev_info); struct visorchipset_state { u32 created:1; u32 attached:1; @@ -106,9 +106,11 @@ struct visor_driver { * fails or completes successfully. */ int (*pause)(struct visor_device *dev, - visorbus_state_complete_func complete_func); + visorbus_state_complete_func complete_func, + void *dev_info); int (*resume)(struct visor_device *dev, - visorbus_state_complete_func complete_func); + visorbus_state_complete_func complete_func, + void *dev_info); /** These fields are for private use by the bus driver only. */ struct device_driver driver; diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index dd36d7b7e743..a89889607e71 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -110,10 +110,10 @@ static long long total_devices_created; static void chipset_bus_create(struct visorchipset_bus_info *bus_info); static void chipset_bus_destroy(struct visorchipset_bus_info *bus_info); -static void chipset_device_create(u32 bus_no, u32 dev_no); -static void chipset_device_destroy(u32 bus_no, u32 dev_no); -static void chipset_device_pause(u32 bus_no, u32 dev_no); -static void chipset_device_resume(u32 bus_no, u32 dev_no); +static void chipset_device_create(struct visorchipset_device_info *dev_info); +static void chipset_device_destroy(struct visorchipset_device_info *dev_info); +static void chipset_device_pause(struct visorchipset_device_info *dev_info); +static void chipset_device_resume(struct visorchipset_device_info *dev_info); /** These functions are implemented herein, and are called by the chipset * driver to notify us about specific events. @@ -813,11 +813,17 @@ away: * initialized. */ if (!dev->responded_to_device_create) { + struct visorchipset_device_info dev_info; + + if (!visorchipset_get_device_info(dev->chipset_bus_no, + dev->chipset_dev_no, + &dev_info)) + /* hmm, what to do here */ + return rc; + dev->responded_to_device_create = true; if (chipset_responders.device_create) - (*chipset_responders.device_create)(dev->chipset_bus_no, - dev->chipset_dev_no, - rc); + (*chipset_responders.device_create)(&dev_info, rc); } return rc; } @@ -1003,7 +1009,7 @@ EXPORT_SYMBOL_GPL(visorbus_disable_channel_interrupts); */ static int create_visor_device(struct visorbus_devdata *devdata, - unsigned long chipset_bus_no, unsigned long chipset_dev_no, + struct visorchipset_device_info *dev_info, struct visorchipset_channel_info chan_info, u64 partition_handle) { @@ -1011,6 +1017,8 @@ create_visor_device(struct visorbus_devdata *devdata, struct visorchannel *visorchannel = NULL; struct visor_device *dev = NULL; bool gotten = false, registered1 = false, registered2 = false; + u32 chipset_bus_no = dev_info->bus_no; + u32 chipset_dev_no = dev_info->dev_no; POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, chipset_dev_no, chipset_bus_no, POSTCODE_SEVERITY_INFO); @@ -1061,7 +1069,7 @@ create_visor_device(struct visorbus_devdata *devdata, * (NOT bus instance). That's why we need to include the bus * number within the name. */ - dev_set_name(&dev->device, "vbus%lu:dev%lu", + dev_set_name(&dev->device, "vbus%u:dev%u", chipset_bus_no, chipset_dev_no); /* device_add does this: @@ -1512,26 +1520,25 @@ away: } static void -chipset_device_create(u32 bus_no, u32 dev_no) +chipset_device_create(struct visorchipset_device_info *dev_info) { - struct visorchipset_device_info dev_info; struct visorchipset_bus_info bus_info; struct visorbus_devdata *devdata = NULL; int rc = -1; + u32 bus_no = dev_info->bus_no; + u32 dev_no = dev_info->dev_no; POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); if (entered_testing_mode) return; - if (!visorchipset_get_device_info(bus_no, dev_no, &dev_info)) - goto away; if (!visorchipset_get_bus_info(bus_no, &bus_info)) goto away; if (visorbus_devicetest) if (total_devices_created < MAXDEVICETEST) { test_channel_infos[total_devices_created] = - dev_info.chan_info; + dev_info->chan_info; test_bus_nos[total_devices_created] = bus_no; test_dev_nos[total_devices_created] = dev_no; } @@ -1545,27 +1552,25 @@ away: return; } devdata = (struct visorbus_devdata *)(bus_info.bus_driver_context); - rc = create_visor_device(devdata, bus_no, dev_no, - dev_info.chan_info, bus_info.partition_handle); + rc = create_visor_device(devdata, dev_info, + dev_info->chan_info, + bus_info.partition_handle); POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); if (rc < 0) if (chipset_responders.device_create) - (*chipset_responders.device_create)(bus_no, dev_no, rc); + (*chipset_responders.device_create)(dev_info, rc); } static void -chipset_device_destroy(u32 bus_no, u32 dev_no) +chipset_device_destroy(struct visorchipset_device_info *dev_info) { - struct visorchipset_device_info dev_info; struct visor_device *dev; int rc = -1; if (entered_testing_mode) return; - if (!visorchipset_get_device_info(bus_no, dev_no, &dev_info)) - goto away; - dev = find_visor_device_by_channel(dev_info.chan_info.channel_addr); + dev = find_visor_device_by_channel(dev_info->chan_info.channel_addr); if (!dev) goto away; rc = 0; @@ -1574,7 +1579,7 @@ away: return; if (chipset_responders.device_destroy) - (*chipset_responders.device_destroy) (bus_no, dev_no, rc); + (*chipset_responders.device_destroy) (dev_info, rc); remove_visor_device(dev); } @@ -1583,8 +1588,11 @@ away: * completed. */ static void -pause_state_change_complete(struct visor_device *dev, int status) +pause_state_change_complete(struct visor_device *dev, int status, + void *info) { + struct visorchipset_device_info *dev_info = info; + if (!dev->pausing) return; @@ -1595,8 +1603,7 @@ pause_state_change_complete(struct visor_device *dev, int status) /* Notify the chipset driver that the pause is complete, which * will presumably want to send some sort of response to the * initiator. */ - (*chipset_responders.device_pause) (dev->chipset_bus_no, - dev->chipset_dev_no, status); + (*chipset_responders.device_pause) (dev_info, status); } /* This is the callback function specified for a function driver, to @@ -1604,8 +1611,11 @@ pause_state_change_complete(struct visor_device *dev, int status) * completed. */ static void -resume_state_change_complete(struct visor_device *dev, int status) +resume_state_change_complete(struct visor_device *dev, int status, + void *info) { + struct visorchipset_device_info *dev_info = info; + if (!dev->resuming) return; @@ -1616,8 +1626,7 @@ resume_state_change_complete(struct visor_device *dev, int status) /* Notify the chipset driver that the resume is complete, * which will presumably want to send some sort of response to * the initiator. */ - (*chipset_responders.device_resume) (dev->chipset_bus_no, - dev->chipset_dev_no, status); + (*chipset_responders.device_resume) (dev_info, status); } /* Tell the subordinate function driver for a specific device to pause @@ -1625,13 +1634,14 @@ resume_state_change_complete(struct visor_device *dev, int status) * callback function. */ static void -initiate_chipset_device_pause_resume(u32 bus_no, u32 dev_no, bool is_pause) +initiate_chipset_device_pause_resume(struct visorchipset_device_info *dev_info, + bool is_pause) { - struct visorchipset_device_info dev_info; struct visor_device *dev = NULL; int rc = -1, x; struct visor_driver *drv = NULL; - void (*notify_func)(u32 bus_no, u32 dev_no, int response) = NULL; + void (*notify_func)(struct visorchipset_device_info *dev_info, + int response) = NULL; if (is_pause) notify_func = chipset_responders.device_pause; @@ -1640,10 +1650,7 @@ initiate_chipset_device_pause_resume(u32 bus_no, u32 dev_no, bool is_pause) if (!notify_func) goto away; - if (!visorchipset_get_device_info(bus_no, dev_no, &dev_info)) - goto away; - - dev = find_visor_device_by_channel(dev_info.chan_info.channel_addr); + dev = find_visor_device_by_channel(dev_info->chan_info.channel_addr); if (!dev) goto away; @@ -1666,7 +1673,8 @@ initiate_chipset_device_pause_resume(u32 bus_no, u32 dev_no, bool is_pause) goto away; dev->pausing = true; - x = drv->pause(dev, pause_state_change_complete); + x = drv->pause(dev, pause_state_change_complete, + (void *)dev_info); } else { /* This should be done at BUS resume time, but an * existing problem prevents us from ever getting a bus @@ -1678,7 +1686,8 @@ initiate_chipset_device_pause_resume(u32 bus_no, u32 dev_no, bool is_pause) goto away; dev->resuming = true; - x = drv->resume(dev, resume_state_change_complete); + x = drv->resume(dev, resume_state_change_complete, + (void *)dev_info); } if (x < 0) { if (is_pause) @@ -1691,20 +1700,20 @@ initiate_chipset_device_pause_resume(u32 bus_no, u32 dev_no, bool is_pause) away: if (rc < 0) { if (notify_func) - (*notify_func)(bus_no, dev_no, rc); + (*notify_func)(dev_info, rc); } } static void -chipset_device_pause(u32 bus_no, u32 dev_no) +chipset_device_pause(struct visorchipset_device_info *dev_info) { - initiate_chipset_device_pause_resume(bus_no, dev_no, true); + initiate_chipset_device_pause_resume(dev_info, true); } static void -chipset_device_resume(u32 bus_no, u32 dev_no) +chipset_device_resume(struct visorchipset_device_info *dev_info) { - initiate_chipset_device_pause_resume(bus_no, dev_no, false); + initiate_chipset_device_pause_resume(dev_info, false); } struct channel_size_info { diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h index 9a2d5636db54..81e4e8c24191 100644 --- a/drivers/staging/unisys/visorbus/visorbus_private.h +++ b/drivers/staging/unisys/visorbus/visorbus_private.h @@ -106,10 +106,10 @@ struct visorchipset_bus_info { struct visorchipset_busdev_notifiers { void (*bus_create)(struct visorchipset_bus_info *bus_info); void (*bus_destroy)(struct visorchipset_bus_info *bus_info); - void (*device_create)(u32 bus_no, u32 dev_no); - void (*device_destroy)(u32 bus_no, u32 dev_no); - void (*device_pause)(u32 bus_no, u32 dev_no); - void (*device_resume)(u32 bus_no, u32 dev_no); + void (*device_create)(struct visorchipset_device_info *bus_info); + void (*device_destroy)(struct visorchipset_device_info *bus_info); + void (*device_pause)(struct visorchipset_device_info *bus_info); + void (*device_resume)(struct visorchipset_device_info *bus_info); }; /* These functions live inside visorchipset, and will be called to indicate @@ -121,10 +121,11 @@ struct visorchipset_busdev_notifiers { struct visorchipset_busdev_responders { void (*bus_create)(struct visorchipset_bus_info *p, int response); void (*bus_destroy)(struct visorchipset_bus_info *p, int response); - void (*device_create)(u32 bus_no, u32 dev_no, int response); - void (*device_destroy)(u32 bus_no, u32 dev_no, int response); - void (*device_pause)(u32 bus_no, u32 dev_no, int response); - void (*device_resume)(u32 bus_no, u32 dev_no, int response); + void (*device_create)(struct visorchipset_device_info *p, int response); + void (*device_destroy)(struct visorchipset_device_info *p, + int response); + void (*device_pause)(struct visorchipset_device_info *p, int response); + void (*device_resume)(struct visorchipset_device_info *p, int response); }; /** Register functions (in the bus driver) to get called by visorchipset diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 432158d2e318..9bbc0804f878 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -230,12 +230,16 @@ static struct visorchipset_busdev_notifiers busdev_notifiers; static void bus_create_response(struct visorchipset_bus_info *p, int response); static void bus_destroy_response(struct visorchipset_bus_info *p, int response); -static void device_create_response(u32 bus_no, u32 dev_no, int response); -static void device_destroy_response(u32 bus_no, u32 dev_no, int response); -static void device_resume_response(u32 bus_no, u32 dev_no, int response); +static void device_create_response(struct visorchipset_device_info *p, + int response); +static void device_destroy_response(struct visorchipset_device_info *p, + int response); +static void device_resume_response(struct visorchipset_device_info *p, + int response); -static void visorchipset_device_pause_response(u32 bus_no, u32 dev_no, - int response); +static void +visorchipset_device_pause_response(struct visorchipset_device_info *p, + int response); static struct visorchipset_busdev_responders busdev_responders = { .bus_create = bus_create_response, @@ -993,13 +997,13 @@ bus_responder(enum controlvm_id cmd_id, struct visorchipset_bus_info *p, static void device_changestate_responder(enum controlvm_id cmd_id, - u32 bus_no, u32 dev_no, int response, + struct visorchipset_device_info *p, int response, struct spar_segment_state response_state) { - struct visorchipset_device_info *p; struct controlvm_message outmsg; + u32 bus_no = p->bus_no; + u32 dev_no = p->dev_no; - p = device_find(&dev_info_list, bus_no, dev_no); if (!p) return; if (p->pending_msg_hdr.id == CONTROLVM_INVALID) @@ -1021,12 +1025,11 @@ device_changestate_responder(enum controlvm_id cmd_id, } static void -device_responder(enum controlvm_id cmd_id, u32 bus_no, u32 dev_no, int response) +device_responder(enum controlvm_id cmd_id, struct visorchipset_device_info *p, + int response) { - struct visorchipset_device_info *p; bool need_clear = false; - p = device_find(&dev_info_list, bus_no, dev_no); if (!p) return; if (response >= 0) { @@ -1094,15 +1097,16 @@ bus_epilog(struct visorchipset_bus_info *bus_info, } static void -device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd, +device_epilog(struct visorchipset_device_info *dev_info, + struct spar_segment_state state, u32 cmd, struct controlvm_message_header *msg_hdr, int response, bool need_response, bool for_visorbus) { struct visorchipset_busdev_notifiers *notifiers; bool notified = false; + u32 bus_no = dev_info->bus_no; + u32 dev_no = dev_info->dev_no; - struct visorchipset_device_info *dev_info = - device_find(&dev_info_list, bus_no, dev_no); char *envp[] = { "SPARSP_DIAGPOOL_PAUSED_STATE = 1", NULL @@ -1125,7 +1129,7 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd, switch (cmd) { case CONTROLVM_DEVICE_CREATE: if (notifiers->device_create) { - (*notifiers->device_create) (bus_no, dev_no); + (*notifiers->device_create) (dev_info); notified = true; } break; @@ -1135,8 +1139,7 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd, state.operating == segment_state_running.operating) { if (notifiers->device_resume) { - (*notifiers->device_resume) (bus_no, - dev_no); + (*notifiers->device_resume) (dev_info); notified = true; } } @@ -1148,8 +1151,7 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd, * where server is lost */ if (notifiers->device_pause) { - (*notifiers->device_pause) (bus_no, - dev_no); + (*notifiers->device_pause) (dev_info); notified = true; } } else if (state.alive == segment_state_paused.alive && @@ -1171,7 +1173,7 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd, break; case CONTROLVM_DEVICE_DESTROY: if (notifiers->device_destroy) { - (*notifiers->device_destroy) (bus_no, dev_no); + (*notifiers->device_destroy) (dev_info); notified = true; } break; @@ -1184,7 +1186,7 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd, */ ; else - device_responder(cmd, bus_no, dev_no, response); + device_responder(cmd, dev_info, response); up(¬ifier_lock); } @@ -1359,7 +1361,7 @@ cleanup: g_diagpool_bus_no = bus_no; g_diagpool_dev_no = dev_no; } - device_epilog(bus_no, dev_no, segment_state_running, + device_epilog(dev_info, segment_state_running, CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1, 1); } @@ -1385,7 +1387,7 @@ my_device_changestate(struct controlvm_message *inmsg) rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID; } if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info) - device_epilog(bus_no, dev_no, state, + device_epilog(dev_info, state, CONTROLVM_DEVICE_CHANGESTATE, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1, 1); } @@ -1406,7 +1408,7 @@ my_device_destroy(struct controlvm_message *inmsg) rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE; if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info) - device_epilog(bus_no, dev_no, segment_state_running, + device_epilog(dev_info, segment_state_running, CONTROLVM_DEVICE_DESTROY, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1, 1); } @@ -2121,30 +2123,31 @@ bus_destroy_response(struct visorchipset_bus_info *bus_info, int response) } static void -device_create_response(u32 bus_no, u32 dev_no, int response) +device_create_response(struct visorchipset_device_info *dev_info, int response) { - device_responder(CONTROLVM_DEVICE_CREATE, bus_no, dev_no, response); + device_responder(CONTROLVM_DEVICE_CREATE, dev_info, response); } static void -device_destroy_response(u32 bus_no, u32 dev_no, int response) +device_destroy_response(struct visorchipset_device_info *dev_info, int response) { - device_responder(CONTROLVM_DEVICE_DESTROY, bus_no, dev_no, response); + device_responder(CONTROLVM_DEVICE_DESTROY, dev_info, response); } static void -visorchipset_device_pause_response(u32 bus_no, u32 dev_no, int response) +visorchipset_device_pause_response(struct visorchipset_device_info *dev_info, + int response) { device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE, - bus_no, dev_no, response, + dev_info, response, segment_state_standby); } static void -device_resume_response(u32 bus_no, u32 dev_no, int response) +device_resume_response(struct visorchipset_device_info *dev_info, int response) { device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE, - bus_no, dev_no, response, + dev_info, response, segment_state_running); } @@ -2184,12 +2187,9 @@ visorchipset_get_device_info(u32 bus_no, u32 dev_no, EXPORT_SYMBOL_GPL(visorchipset_get_device_info); bool -visorchipset_set_device_context(u32 bus_no, u32 dev_no, void *context) +visorchipset_set_device_context(struct visorchipset_device_info *p, + void *context) { - struct visorchipset_device_info *p; - - p = device_find(&dev_info_list, bus_no, dev_no); - if (!p) return false; p->bus_driver_context = context; From b99464b1da04657f52b9c35f320da727fc534e4b Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Thu, 14 May 2015 15:50:32 +0200 Subject: [PATCH 0522/1163] staging: unisys: cleanup UNISYS_VISORUTIL Commit 53490b545cb0 ("staging: unisys: move periodic_work.c into the visorbus directory") removed the Kconfig option UNISYS_VISORUTIL, but left one reference in a Kconfig select. Remove this last reference. Signed-off-by: Valentin Rothberg Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchannel/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/unisys/visorchannel/Kconfig b/drivers/staging/unisys/visorchannel/Kconfig index 8d31bebf039a..3148f6b2a2e9 100644 --- a/drivers/staging/unisys/visorchannel/Kconfig +++ b/drivers/staging/unisys/visorchannel/Kconfig @@ -4,7 +4,6 @@ config UNISYS_VISORCHANNEL tristate "Unisys visorchannel driver" - select UNISYS_VISORUTIL ---help--- If you say Y here, you will enable the Unisys visorchannel driver. From f6abdb502925b7e6e83180709fad9f6f857715c3 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Thu, 14 May 2015 15:43:59 +0200 Subject: [PATCH 0523/1163] staging: I2O cleanup Remove the last reference on menuconfig I20 that has been removed by commit 4a72a7af462d ("staging: remove i2o subsystem"). Signed-off-by: Valentin Rothberg Signed-off-by: Greg Kroah-Hartman --- drivers/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/Makefile b/drivers/Makefile index 46d2554be404..9a02fb7c5106 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -98,7 +98,6 @@ obj-$(CONFIG_USB_GADGET) += usb/ obj-$(CONFIG_SERIO) += input/serio/ obj-$(CONFIG_GAMEPORT) += input/gameport/ obj-$(CONFIG_INPUT) += input/ -obj-$(CONFIG_I2O) += message/ obj-$(CONFIG_RTC_LIB) += rtc/ obj-y += i2c/ media/ obj-$(CONFIG_PPS) += pps/ From 2e043a923eb25c2ebeb33c1053357cc69ce2494e Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 14 May 2015 07:07:55 -0700 Subject: [PATCH 0524/1163] staging: sm750fb: use arch_phys_wc_add() and ioremap_wc() The same area used for ioremap() is used for the MTRR area. Convert the driver from using the x86 specific MTRR code to the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add() will avoid MTRR if write-combining is available, in order to take advantage of that also ensure the ioremap'd area is requested as write-combining. There are a few motivations for this: a) Take advantage of PAT when available b) Help bury MTRR code away, MTRR is architecture specific and on x86 its replaced by PAT c) Help with the goal of eventually using _PAGE_CACHE_UC over _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (see commit de33c442e titled "x86 PAT: fix performance drop for glx, use UC minus for ioremap(), ioremap_nocache() and pci_mmap_page_range()") The conversion done is expressed by the following Coccinelle SmPL patch, it additionally required manual intervention to address all the #ifdery and removal of redundant things which arch_phys_wc_add() already addresses such as verbose message about when MTRR fails and doing nothing when we didn't get an MTRR. @ mtrr_found @ expression index, base, size; @@ -index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1); +index = arch_phys_wc_add(base, size); @ mtrr_rm depends on mtrr_found @ expression mtrr_found.index, mtrr_found.base, mtrr_found.size; @@ -mtrr_del(index, base, size); +arch_phys_wc_del(index); @ mtrr_rm_zero_arg depends on mtrr_found @ expression mtrr_found.index; @@ -mtrr_del(index, 0, 0); +arch_phys_wc_del(index); @ mtrr_rm_fb_info depends on mtrr_found @ struct fb_info *info; expression mtrr_found.index; @@ -mtrr_del(index, info->fix.smem_start, info->fix.smem_len); +arch_phys_wc_del(index); @ ioremap_replace_nocache depends on mtrr_found @ struct fb_info *info; expression base, size; @@ -info->screen_base = ioremap_nocache(base, size); +info->screen_base = ioremap_wc(base, size); @ ioremap_replace_default depends on mtrr_found @ struct fb_info *info; expression base, size; @@ -info->screen_base = ioremap(base, size); +info->screen_base = ioremap_wc(base, size); Generated-by: Coccinelle SmPL Cc: Sudip Mukherjee Cc: Teddy Wang Cc: Greg Kroah-Hartman Cc: Suresh Siddha Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Juergen Gross Cc: Daniel Vetter Cc: Andy Lutomirski Cc: Dave Airlie Cc: Antonino Daplas Cc: Jean-Christophe Plagniol-Villard Cc: Tomi Valkeinen Cc: devel@driverdev.osuosl.org Cc: linux-fbdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Luis R. Rodriguez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750.c | 36 ++++-------------------------- drivers/staging/sm750fb/sm750.h | 3 --- drivers/staging/sm750fb/sm750_hw.c | 3 +-- 3 files changed, 5 insertions(+), 37 deletions(-) diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c index 5529905ab88b..97fe04a9451f 100644 --- a/drivers/staging/sm750fb/sm750.c +++ b/drivers/staging/sm750fb/sm750.c @@ -16,9 +16,6 @@ #include #include #include -#ifdef CONFIG_MTRR -#include -#endif #include #include "sm750.h" #include "sm750_hw.h" @@ -47,9 +44,7 @@ typedef int (*PROC_SPEC_INITHW)(struct lynx_share*, struct pci_dev*); /* common var for all device */ static int g_hwcursor = 1; static int g_noaccel; -#ifdef CONFIG_MTRR static int g_nomtrr; -#endif static const char *g_fbmode[] = {NULL, NULL}; static const char *g_def_fbmode = "800x600-16@60"; static char *g_settings = NULL; @@ -1126,11 +1121,8 @@ static int lynxfb_pci_probe(struct pci_dev *pdev, pr_info("share->revid = %02x\n", share->revid); share->pdev = pdev; -#ifdef CONFIG_MTRR share->mtrr_off = g_nomtrr; share->mtrr.vram = 0; - share->mtrr.vram_added = 0; -#endif share->accel_off = g_noaccel; share->dual = g_dualview; spin_lock_init(&share->slock); @@ -1158,22 +1150,9 @@ static int lynxfb_pci_probe(struct pci_dev *pdev, goto err_map; } -#ifdef CONFIG_MTRR - if (!share->mtrr_off) { - pr_info("enable mtrr\n"); - share->mtrr.vram = mtrr_add(share->vidmem_start, - share->vidmem_size, - MTRR_TYPE_WRCOMB, 1); - - if (share->mtrr.vram < 0) { - /* don't block driver with the failure of MTRR */ - pr_err("Unable to setup MTRR.\n"); - } else { - share->mtrr.vram_added = 1; - pr_info("MTRR added successfully\n"); - } - } -#endif + if (!share->mtrr_off) + share->mtrr.vram = arch_phys_wc_add(share->vidmem_start, + share->vidmem_size); memset_io(share->pvMem, 0, share->vidmem_size); @@ -1274,12 +1253,7 @@ static void lynxfb_pci_remove(struct pci_dev *pdev) /* release frame buffer */ framebuffer_release(info); } -#ifdef CONFIG_MTRR - if (share->mtrr.vram_added) - mtrr_del(share->mtrr.vram, - share->vidmem_start, - share->vidmem_size); -#endif + arch_phys_wc_del(share->mtrr.vram); iounmap(share->pvReg); iounmap(share->pvMem); @@ -1321,10 +1295,8 @@ static int __init lynxfb_setup(char *options) /* options that mean for any lynx chips are configured here */ if (!strncmp(opt, "noaccel", strlen("noaccel"))) g_noaccel = 1; -#ifdef CONFIG_MTRR else if (!strncmp(opt, "nomtrr", strlen("nomtrr"))) g_nomtrr = 1; -#endif else if (!strncmp(opt, "dual", strlen("dual"))) g_dualview = 1; else { diff --git a/drivers/staging/sm750fb/sm750.h b/drivers/staging/sm750fb/sm750.h index 0847d2bd95c8..55289126f72c 100644 --- a/drivers/staging/sm750fb/sm750.h +++ b/drivers/staging/sm750fb/sm750.h @@ -51,13 +51,10 @@ struct lynx_share{ struct lynx_accel accel; int accel_off; int dual; -#ifdef CONFIG_MTRR int mtrr_off; struct{ int vram; - int vram_added; }mtrr; -#endif /* all smi graphic adaptor got below attributes */ unsigned long vidmem_start; unsigned long vidreg_start; diff --git a/drivers/staging/sm750fb/sm750_hw.c b/drivers/staging/sm750fb/sm750_hw.c index 9f0d06da12fb..4b77eb1b9277 100644 --- a/drivers/staging/sm750fb/sm750_hw.c +++ b/drivers/staging/sm750fb/sm750_hw.c @@ -85,8 +85,7 @@ int hw_sm750_map(struct lynx_share* share, struct pci_dev* pdev) } #endif - share->pvMem = ioremap(share->vidmem_start, - share->vidmem_size); + share->pvMem = ioremap_wc(share->vidmem_start, share->vidmem_size); if(!share->pvMem){ pr_err("Map video memory failed\n"); From 288ef567ab7b43f19838afbe12b471f1ff5fdfa3 Mon Sep 17 00:00:00 2001 From: Huacai Chen Date: Mon, 11 May 2015 11:08:22 +0800 Subject: [PATCH 0525/1163] staging: sm750: Fix lynxfb_ops_imageblit() if image->depth != 1 If image->depth != 1, lynxfb_ops_imageblit() should fallback to call cfb_imageblit(), not return directly. Otherwise it can't display the boot logo. Cc: Teddy Wang Acked-by: Sudip Mukherjee Signed-off-by: Huacai Chen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/TODO | 1 + drivers/staging/sm750fb/sm750.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/drivers/staging/sm750fb/TODO b/drivers/staging/sm750fb/TODO index ce23f3ccc3a4..a3a877d90066 100644 --- a/drivers/staging/sm750fb/TODO +++ b/drivers/staging/sm750fb/TODO @@ -2,6 +2,7 @@ TODO: - lots of checkpatch cleanup - use kernel coding style - refine the code and remove unused code +- Implement hardware acceleration for imageblit if image->depth > 1 - check on hardware effects of removal of USE_HW_I2C and USE_DVICHIP (these two are supposed to be sample code which is given here if someone wants to use those functionalities) diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c index 97fe04a9451f..69b18f399b90 100644 --- a/drivers/staging/sm750fb/sm750.c +++ b/drivers/staging/sm750fb/sm750.c @@ -274,7 +274,10 @@ static void lynxfb_ops_imageblit(struct fb_info *info, } goto _do_work; } + /* TODO: Implement hardware acceleration for image->depth > 1 */ + cfb_imageblit(info, image); return; + _do_work: /* * If not use spin_lock, system will die if user load driver From 7d98c63edc45e4ab3096af2c8d98fd2d94249640 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Tue, 12 May 2015 17:36:08 +0530 Subject: [PATCH 0526/1163] staging: panel: fix stackdump if we load the module, unload and then again try to load the module, we will get a stackdump. In the module_exit function we are unregistering the device and releasing the parport. So when we reach the detach function parport is already null and the unregister_reboot_notifier() is never called. When we again try to load the module it again tries register_reboot_notifier() and gives us a stackdump as its earlier registration is still not removed. It was caused by the commit bb046fef9668 ('staging: panel: register reboot') Fix this by moving all the unregistering and releasing in the detach function, which should be the ideal case as the detach will be called if we try to unregister the driver or if the parport is removed. Fixes: bb046fef9668 ('staging: panel: register reboot') Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 44 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index 1d8ed8b35375..0046ee0af8b9 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -2250,8 +2250,28 @@ static void panel_detach(struct parport *port) __func__, port->number, parport); return; } + if (scan_timer.function != NULL) + del_timer_sync(&scan_timer); - unregister_reboot_notifier(&panel_notifier); + if (pprt != NULL) { + if (keypad.enabled) { + misc_deregister(&keypad_dev); + keypad_initialized = 0; + } + + if (lcd.enabled) { + panel_lcd_print("\x0cLCD driver " PANEL_VERSION + "\nunloaded.\x1b[Lc\x1b[Lb\x1b[L-"); + misc_deregister(&lcd_dev); + lcd.initialized = false; + } + + /* TODO: free all input signals */ + parport_release(pprt); + parport_unregister_device(pprt); + pprt = NULL; + unregister_reboot_notifier(&panel_notifier); + } } static struct parport_driver panel_driver = { @@ -2384,28 +2404,6 @@ static int __init panel_init_module(void) static void __exit panel_cleanup_module(void) { - - if (scan_timer.function != NULL) - del_timer_sync(&scan_timer); - - if (pprt != NULL) { - if (keypad.enabled) { - misc_deregister(&keypad_dev); - keypad_initialized = 0; - } - - if (lcd.enabled) { - panel_lcd_print("\x0cLCD driver " PANEL_VERSION - "\nunloaded.\x1b[Lc\x1b[Lb\x1b[L-"); - misc_deregister(&lcd_dev); - lcd.initialized = false; - } - - /* TODO: free all input signals */ - parport_release(pprt); - parport_unregister_device(pprt); - pprt = NULL; - } parport_unregister_driver(&panel_driver); } From c5c77ba18ea66aa05441c71e38473efb787705a4 Mon Sep 17 00:00:00 2001 From: Johnny Kim Date: Mon, 11 May 2015 14:30:56 +0900 Subject: [PATCH 0527/1163] staging: wilc1000: Add SDIO/SPI 802.11 driver This driver is for the wilc1000 which is a single chip IEEE 802.11 b/g/n device. The driver works together with cfg80211, which is the kernel side of configuration management for wireless devices because the wilc1000 chipset is fullmac where the MLME is managed in hardware. The driver worked from kernel version 2.6.38 and being now ported to several others since then. A TODO file is included as well in this commit. Signed-off-by: Johnny Kim Signed-off-by: Rachel Kim Signed-off-by: Dean Lee Signed-off-by: Chris Park Acked-by: Nicolas Ferre Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + drivers/staging/wilc1000/Kconfig | 55 + drivers/staging/wilc1000/Makefile | 41 + drivers/staging/wilc1000/TODO | 8 + .../staging/wilc1000/coreconfigsimulator.h | 20 + drivers/staging/wilc1000/coreconfigurator.c | 2201 +++++ drivers/staging/wilc1000/coreconfigurator.h | 498 + drivers/staging/wilc1000/fifo_buffer.c | 142 + drivers/staging/wilc1000/fifo_buffer.h | 23 + drivers/staging/wilc1000/host_interface.c | 8074 +++++++++++++++++ drivers/staging/wilc1000/host_interface.h | 1344 +++ drivers/staging/wilc1000/itypes.h | 60 + drivers/staging/wilc1000/linux_mon.c | 643 ++ drivers/staging/wilc1000/linux_wlan.c | 2953 ++++++ drivers/staging/wilc1000/linux_wlan_common.h | 170 + drivers/staging/wilc1000/linux_wlan_sdio.c | 249 + drivers/staging/wilc1000/linux_wlan_sdio.h | 14 + drivers/staging/wilc1000/linux_wlan_spi.c | 510 ++ drivers/staging/wilc1000/linux_wlan_spi.h | 14 + drivers/staging/wilc1000/wilc_debugfs.c | 185 + drivers/staging/wilc1000/wilc_errorsupport.h | 84 + drivers/staging/wilc1000/wilc_event.h | 123 + drivers/staging/wilc1000/wilc_exported_buf.c | 76 + drivers/staging/wilc1000/wilc_log.h | 47 + drivers/staging/wilc1000/wilc_memory.c | 63 + drivers/staging/wilc1000/wilc_memory.h | 330 + drivers/staging/wilc1000/wilc_msgqueue.c | 211 + drivers/staging/wilc1000/wilc_msgqueue.h | 133 + drivers/staging/wilc1000/wilc_osconfig.h | 55 + drivers/staging/wilc1000/wilc_oswrapper.h | 133 + drivers/staging/wilc1000/wilc_platform.h | 181 + drivers/staging/wilc1000/wilc_sdio.c | 1298 +++ drivers/staging/wilc1000/wilc_semaphore.c | 70 + drivers/staging/wilc1000/wilc_semaphore.h | 115 + drivers/staging/wilc1000/wilc_sleep.c | 36 + drivers/staging/wilc1000/wilc_sleep.h | 45 + drivers/staging/wilc1000/wilc_spi.c | 1475 +++ drivers/staging/wilc1000/wilc_strutils.c | 431 + drivers/staging/wilc1000/wilc_strutils.h | 412 + drivers/staging/wilc1000/wilc_thread.c | 35 + drivers/staging/wilc1000/wilc_thread.h | 153 + drivers/staging/wilc1000/wilc_time.c | 163 + drivers/staging/wilc1000/wilc_time.h | 205 + drivers/staging/wilc1000/wilc_timer.c | 51 + drivers/staging/wilc1000/wilc_timer.h | 153 + drivers/staging/wilc1000/wilc_type.h | 34 + .../staging/wilc1000/wilc_wfi_cfgoperations.c | 4592 ++++++++++ .../staging/wilc1000/wilc_wfi_cfgoperations.h | 134 + drivers/staging/wilc1000/wilc_wfi_netdevice.c | 960 ++ drivers/staging/wilc1000/wilc_wfi_netdevice.h | 277 + drivers/staging/wilc1000/wilc_wlan.c | 2434 +++++ drivers/staging/wilc1000/wilc_wlan.h | 321 + drivers/staging/wilc1000/wilc_wlan_cfg.c | 643 ++ drivers/staging/wilc1000/wilc_wlan_cfg.h | 33 + drivers/staging/wilc1000/wilc_wlan_if.h | 991 ++ 56 files changed, 33704 insertions(+) create mode 100644 drivers/staging/wilc1000/Kconfig create mode 100644 drivers/staging/wilc1000/Makefile create mode 100644 drivers/staging/wilc1000/TODO create mode 100644 drivers/staging/wilc1000/coreconfigsimulator.h create mode 100644 drivers/staging/wilc1000/coreconfigurator.c create mode 100644 drivers/staging/wilc1000/coreconfigurator.h create mode 100644 drivers/staging/wilc1000/fifo_buffer.c create mode 100644 drivers/staging/wilc1000/fifo_buffer.h create mode 100644 drivers/staging/wilc1000/host_interface.c create mode 100644 drivers/staging/wilc1000/host_interface.h create mode 100644 drivers/staging/wilc1000/itypes.h create mode 100644 drivers/staging/wilc1000/linux_mon.c create mode 100644 drivers/staging/wilc1000/linux_wlan.c create mode 100644 drivers/staging/wilc1000/linux_wlan_common.h create mode 100644 drivers/staging/wilc1000/linux_wlan_sdio.c create mode 100644 drivers/staging/wilc1000/linux_wlan_sdio.h create mode 100644 drivers/staging/wilc1000/linux_wlan_spi.c create mode 100644 drivers/staging/wilc1000/linux_wlan_spi.h create mode 100644 drivers/staging/wilc1000/wilc_debugfs.c create mode 100644 drivers/staging/wilc1000/wilc_errorsupport.h create mode 100644 drivers/staging/wilc1000/wilc_event.h create mode 100644 drivers/staging/wilc1000/wilc_exported_buf.c create mode 100644 drivers/staging/wilc1000/wilc_log.h create mode 100644 drivers/staging/wilc1000/wilc_memory.c create mode 100644 drivers/staging/wilc1000/wilc_memory.h create mode 100644 drivers/staging/wilc1000/wilc_msgqueue.c create mode 100644 drivers/staging/wilc1000/wilc_msgqueue.h create mode 100644 drivers/staging/wilc1000/wilc_osconfig.h create mode 100644 drivers/staging/wilc1000/wilc_oswrapper.h create mode 100644 drivers/staging/wilc1000/wilc_platform.h create mode 100644 drivers/staging/wilc1000/wilc_sdio.c create mode 100644 drivers/staging/wilc1000/wilc_semaphore.c create mode 100644 drivers/staging/wilc1000/wilc_semaphore.h create mode 100644 drivers/staging/wilc1000/wilc_sleep.c create mode 100644 drivers/staging/wilc1000/wilc_sleep.h create mode 100644 drivers/staging/wilc1000/wilc_spi.c create mode 100644 drivers/staging/wilc1000/wilc_strutils.c create mode 100644 drivers/staging/wilc1000/wilc_strutils.h create mode 100644 drivers/staging/wilc1000/wilc_thread.c create mode 100644 drivers/staging/wilc1000/wilc_thread.h create mode 100644 drivers/staging/wilc1000/wilc_time.c create mode 100644 drivers/staging/wilc1000/wilc_time.h create mode 100644 drivers/staging/wilc1000/wilc_timer.c create mode 100644 drivers/staging/wilc1000/wilc_timer.h create mode 100644 drivers/staging/wilc1000/wilc_type.h create mode 100644 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c create mode 100644 drivers/staging/wilc1000/wilc_wfi_cfgoperations.h create mode 100644 drivers/staging/wilc1000/wilc_wfi_netdevice.c create mode 100644 drivers/staging/wilc1000/wilc_wfi_netdevice.h create mode 100644 drivers/staging/wilc1000/wilc_wlan.c create mode 100644 drivers/staging/wilc1000/wilc_wlan.h create mode 100644 drivers/staging/wilc1000/wilc_wlan_cfg.c create mode 100644 drivers/staging/wilc1000/wilc_wlan_cfg.h create mode 100644 drivers/staging/wilc1000/wilc_wlan_if.h diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index c204ab2693c1..7f6cae5beb90 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -110,4 +110,6 @@ source "drivers/staging/fbtft/Kconfig" source "drivers/staging/fsl-mc/Kconfig" +source "drivers/staging/wilc1000/Kconfig" + endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 9b9151758bbd..347f6477aa3e 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -47,3 +47,4 @@ obj-$(CONFIG_UNISYSSPAR) += unisys/ obj-$(CONFIG_COMMON_CLK_XLNX_CLKWZRD) += clocking-wizard/ obj-$(CONFIG_FB_TFT) += fbtft/ obj-$(CONFIG_FSL_MC_BUS) += fsl-mc/ +obj-$(CONFIG_WILC1000) += wilc1000/ diff --git a/drivers/staging/wilc1000/Kconfig b/drivers/staging/wilc1000/Kconfig new file mode 100644 index 000000000000..101f908bc9ed --- /dev/null +++ b/drivers/staging/wilc1000/Kconfig @@ -0,0 +1,55 @@ +config WILC1000 + tristate "WILC1000 support (WiFi only)" + ---help--- + This module only support IEEE 802.11n WiFi. + +choice + prompt "Memory Allocation" + depends on WILC1000 + default WILC1000_PREALLOCATE_AT_LOADING_DRIVER + + config WILC1000_PREALLOCATE_AT_LOADING_DRIVER + bool "Preallocate memory at loading driver" + ---help--- + This choice supports static allocation of the memory + for the receive buffer. The driver will allocate the RX buffer + during initial time. The driver will also free the buffer + by calling network device stop. + + config WILC1000_DYNAMICALLY_ALLOCATE_MEMROY + bool "Dynamically allocate memory in real time" + ---help--- + This choice supports dynamic allocation of the memory + for the receive buffer. The driver will allocate the RX buffer + when it is required. +endchoice + + +choice + prompt "Bus Type" + depends on WILC1000 + default WILC1000_SDIO + + config WILC1000_SDIO + bool "SDIO support" + depends on MMC + ---help--- + This module adds support for the SDIO interface of adapters using + WILC chipset. Select this if your platform is using the SDIO bus. + + config WILC1000_SPI + bool "SPI support" + ---help--- + This module adds support for the SPI interface of adapters using + WILC chipset. Select this if your platform is using the SPI bus. +endchoice + + +config WILC1000_HW_OOB_INTR + bool "Use out of band interrupt" + depends on WILC1000 && WILC1000_SDIO + default n + ---help--- + If your platform don't recognize SDIO IRQ, connect chipset external IRQ pin + and check this option. Or, Use this to get all interrupts including SDIO interrupts. + diff --git a/drivers/staging/wilc1000/Makefile b/drivers/staging/wilc1000/Makefile new file mode 100644 index 000000000000..84bd975ff3be --- /dev/null +++ b/drivers/staging/wilc1000/Makefile @@ -0,0 +1,41 @@ +obj-$(CONFIG_WILC1000) += wilc1000.o +obj-$(CONFIG_WILC1000_PREALLOCATE_DURING_SYSTEM_BOOT) += wilc_exported_buf.o + + +ccflags-$(CONFIG_WILC1000_SDIO) += -DWILC_SDIO -DCOMPLEMENT_BOOT +ccflags-$(CONFIG_WILC1000_HW_OOB_INTR) += -DWILC_SDIO_IRQ_GPIO +ccflags-$(CONFIG_WILC1000_SPI) += -DWILC_SPI + +ccflags-y += -DSTA_FIRMWARE=\"atmel/wilc1000_fw.bin\" \ + -DAP_FIRMWARE=\"atmel/wilc1000_ap_fw.bin\" \ + -DP2P_CONCURRENCY_FIRMWARE=\"atmel/wilc1000_p2p_fw.bin\" + +ccflags-y += -I$(src)/ -DEXPORT_SYMTAB -D__CHECK_ENDIAN__ -DWILC_ASIC_A0 \ + -DPLL_WORKAROUND -DCONNECT_DIRECT -DAGING_ALG \ + -DWILC_PARSE_SCAN_IN_HOST -DDISABLE_PWRSAVE_AND_SCAN_DURING_IP \ + -DWILC_PLATFORM=WILC_LINUXKERNEL -Wno-unused-function -DUSE_WIRELESS \ + -DWILC_DEBUGFS +#ccflags-y += -DTCP_ACK_FILTER + +ccflags-$(CONFIG_WILC1000_PREALLOCATE_DURING_SYSTEM_BOOT) += -DMEMORY_STATIC \ + -DWILC_PREALLOC_AT_BOOT + +ccflags-$(CONFIG_WILC1000_PREALLOCATE_AT_LOADING_DRIVER) += -DMEMORY_STATIC \ + -DWILC_PREALLOC_AT_INSMOD + +ccflags-$(CONFIG_WILC1000_DYNAMICALLY_ALLOCATE_MEMROY) += -DWILC_NORMAL_ALLOC + + +wilc1000-objs := wilc_wfi_netdevice.o wilc_wfi_cfgoperations.o linux_wlan.o linux_mon.o \ + wilc_memory.o wilc_msgqueue.o wilc_semaphore.o wilc_sleep.o wilc_strutils.o \ + wilc_thread.o wilc_time.o wilc_timer.o coreconfigurator.o host_interface.o \ + fifo_buffer.o wilc_sdio.o wilc_spi.o wilc_wlan_cfg.o wilc_debugfs.o + +wilc1000-$(CONFIG_WILC1000_SDIO) += linux_wlan_sdio.o +wilc1000-$(CONFIG_WILC1000_SPI) += linux_wlan_spi.o + +WILC1000_SRC_VERSION = 10.0 +PATCHLEVEL = 2 +WILC1000_FW_VERSION = 0 + +ccflags-y += -D__DRIVER_VERSION__=\"$(WILC1000_SRC_VERSION).$(PATCHLEVEL)\" diff --git a/drivers/staging/wilc1000/TODO b/drivers/staging/wilc1000/TODO new file mode 100644 index 000000000000..5dfeb3eda599 --- /dev/null +++ b/drivers/staging/wilc1000/TODO @@ -0,0 +1,8 @@ +TODO: +- remove the defined feature as kernel versions +- remove OS wrapper functions +- remove custom debug and tracing functions +- rework comments and function headers(also coding style) +- remove build warnings +- support soft-ap and p2p mode +- support resume/suspend function diff --git a/drivers/staging/wilc1000/coreconfigsimulator.h b/drivers/staging/wilc1000/coreconfigsimulator.h new file mode 100644 index 000000000000..6c3f431314fa --- /dev/null +++ b/drivers/staging/wilc1000/coreconfigsimulator.h @@ -0,0 +1,20 @@ + +/*! + * @file coreconfigsimulator.h + * @brief + * @author + * @sa coreconfigsimulator.c + * @date 1 Mar 2012 + * @version 1.0 + */ + + +#ifndef CORECONFIGSIMULATOR_H +#define CORECONFIGSIMULATOR_H + + +extern WILC_Sint32 CoreConfigSimulatorInit (void); +extern WILC_Sint32 CoreConfigSimulatorDeInit (void); + + +#endif \ No newline at end of file diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c new file mode 100644 index 000000000000..01625bdda454 --- /dev/null +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -0,0 +1,2201 @@ + +/*! + * @file coreconfigurator.c + * @brief + * @author + * @sa coreconfigurator.h + * @date 1 Mar 2012 + * @version 1.0 + */ + + +/*****************************************************************************/ +/* File Includes */ +/*****************************************************************************/ +#include "itypes.h" +#include "coreconfigurator.h" +/*****************************************************************************/ +/* Constants */ +/*****************************************************************************/ +#define INLINE static __inline +#define PHY_802_11n +#define MAX_CFG_PKTLEN 1450 +#define MSG_HEADER_LEN 4 +#define QUERY_MSG_TYPE 'Q' +#define WRITE_MSG_TYPE 'W' +#define RESP_MSG_TYPE 'R' +#define WRITE_RESP_SUCCESS 1 +#define INVALID 255 +#define MAC_ADDR_LEN 6 +#define TAG_PARAM_OFFSET (MAC_HDR_LEN + TIME_STAMP_LEN + \ + BEACON_INTERVAL_LEN + CAP_INFO_LEN) + +/*****************************************************************************/ +/* Function Macros */ +/*****************************************************************************/ + + +/*****************************************************************************/ +/* Type Definitions */ +/*****************************************************************************/ + +/* Basic Frame Type Codes (2-bit) */ +typedef enum {FRAME_TYPE_CONTROL = 0x04, + FRAME_TYPE_DATA = 0x08, + FRAME_TYPE_MANAGEMENT = 0x00, + FRAME_TYPE_RESERVED = 0x0C, + FRAME_TYPE_FORCE_32BIT = 0xFFFFFFFF +} tenuBasicFrmType; + +/* Frame Type and Subtype Codes (6-bit) */ +typedef enum { + ASSOC_REQ = 0x00, + ASSOC_RSP = 0x10, + REASSOC_REQ = 0x20, + REASSOC_RSP = 0x30, + PROBE_REQ = 0x40, + PROBE_RSP = 0x50, + BEACON = 0x80, + ATIM = 0x90, + DISASOC = 0xA0, + AUTH = 0xB0, + DEAUTH = 0xC0, + ACTION = 0xD0, + PS_POLL = 0xA4, + RTS = 0xB4, + CTS = 0xC4, + ACK = 0xD4, + CFEND = 0xE4, + CFEND_ACK = 0xF4, + DATA = 0x08, + DATA_ACK = 0x18, + DATA_POLL = 0x28, + DATA_POLL_ACK = 0x38, + NULL_FRAME = 0x48, + CFACK = 0x58, + CFPOLL = 0x68, + CFPOLL_ACK = 0x78, + QOS_DATA = 0x88, + QOS_DATA_ACK = 0x98, + QOS_DATA_POLL = 0xA8, + QOS_DATA_POLL_ACK = 0xB8, + QOS_NULL_FRAME = 0xC8, + QOS_CFPOLL = 0xE8, + QOS_CFPOLL_ACK = 0xF8, + BLOCKACK_REQ = 0x84, + BLOCKACK = 0x94, + FRAME_SUBTYPE_FORCE_32BIT = 0xFFFFFFFF +} tenuFrmSubtype; + +/* Basic Frame Classes */ +typedef enum { + CLASS1_FRAME_TYPE = 0x00, + CLASS2_FRAME_TYPE = 0x01, + CLASS3_FRAME_TYPE = 0x02, + FRAME_CLASS_FORCE_32BIT = 0xFFFFFFFF +} tenuFrameClass; + +/* Element ID of various Information Elements */ +typedef enum { + ISSID = 0, /* Service Set Identifier */ + ISUPRATES = 1, /* Supported Rates */ + IFHPARMS = 2, /* FH parameter set */ + IDSPARMS = 3, /* DS parameter set */ + ICFPARMS = 4, /* CF parameter set */ + ITIM = 5, /* Traffic Information Map */ + IIBPARMS = 6, /* IBSS parameter set */ + ICOUNTRY = 7, /* Country element */ + IEDCAPARAMS = 12, /* EDCA parameter set */ + ITSPEC = 13, /* Traffic Specification */ + ITCLAS = 14, /* Traffic Classification */ + ISCHED = 15, /* Schedule */ + ICTEXT = 16, /* Challenge Text */ + IPOWERCONSTRAINT = 32, /* Power Constraint */ + IPOWERCAPABILITY = 33, /* Power Capability */ + ITPCREQUEST = 34, /* TPC Request */ + ITPCREPORT = 35, /* TPC Report */ + ISUPCHANNEL = 36, /* Supported channel list */ + ICHSWANNOUNC = 37, /* Channel Switch Announcement */ + IMEASUREMENTREQUEST = 38, /* Measurement request */ + IMEASUREMENTREPORT = 39, /* Measurement report */ + IQUIET = 40, /* Quiet element Info */ + IIBSSDFS = 41, /* IBSS DFS */ + IERPINFO = 42, /* ERP Information */ + ITSDELAY = 43, /* TS Delay */ + ITCLASPROCESS = 44, /* TCLAS Processing */ + IHTCAP = 45, /* HT Capabilities */ + IQOSCAP = 46, /* QoS Capability */ + IRSNELEMENT = 48, /* RSN Information Element */ + IEXSUPRATES = 50, /* Extended Supported Rates */ + IEXCHSWANNOUNC = 60, /* Extended Ch Switch Announcement*/ + IHTOPERATION = 61, /* HT Information */ + ISECCHOFF = 62, /* Secondary Channel Offeset */ + I2040COEX = 72, /* 20/40 Coexistence IE */ + I2040INTOLCHREPORT = 73, /* 20/40 Intolerant channel report*/ + IOBSSSCAN = 74, /* OBSS Scan parameters */ + IEXTCAP = 127, /* Extended capability */ + IWMM = 221, /* WMM parameters */ + IWPAELEMENT = 221, /* WPA Information Element */ + INFOELEM_ID_FORCE_32BIT = 0xFFFFFFFF +} tenuInfoElemID; + + +typedef struct { + WILC_Char *pcRespBuffer; + WILC_Sint32 s32MaxRespBuffLen; + WILC_Sint32 s32BytesRead; + WILC_Bool bRespRequired; +} tstrConfigPktInfo; + + + +/*****************************************************************************/ +/* Extern Variable Declarations */ +/*****************************************************************************/ + + +/*****************************************************************************/ +/* Extern Function Declarations */ +/*****************************************************************************/ +extern WILC_Sint32 SendRawPacket(WILC_Sint8 *ps8Packet, WILC_Sint32 s32PacketLen); +extern void NetworkInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length); +extern void GnrlAsyncInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length); +extern void host_int_ScanCompleteReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length); +/*****************************************************************************/ +/* Global Variables */ +/*****************************************************************************/ +static WILC_SemaphoreHandle SemHandleSendPkt; +static WILC_SemaphoreHandle SemHandlePktResp; + +static WILC_Sint8 *gps8ConfigPacket; + +static tstrConfigPktInfo gstrConfigPktInfo; + +static WILC_Uint8 g_seqno; + +static WILC_Sint16 g_wid_num = -1; + +static WILC_Uint16 Res_Len; + +static WILC_Uint8 g_oper_mode = SET_CFG; + +/* WID Switches */ +static tstrWID gastrWIDs[] = { + {WID_FIRMWARE_VERSION, WID_STR}, + {WID_PHY_VERSION, WID_STR}, + {WID_HARDWARE_VERSION, WID_STR}, + {WID_BSS_TYPE, WID_CHAR}, + {WID_QOS_ENABLE, WID_CHAR}, + {WID_11I_MODE, WID_CHAR}, + {WID_CURRENT_TX_RATE, WID_CHAR}, + {WID_LINKSPEED, WID_CHAR}, + {WID_RTS_THRESHOLD, WID_SHORT}, + {WID_FRAG_THRESHOLD, WID_SHORT}, + {WID_SSID, WID_STR}, + {WID_BSSID, WID_ADR}, + {WID_BEACON_INTERVAL, WID_SHORT}, + {WID_POWER_MANAGEMENT, WID_CHAR}, + {WID_LISTEN_INTERVAL, WID_CHAR}, + {WID_DTIM_PERIOD, WID_CHAR}, + {WID_CURRENT_CHANNEL, WID_CHAR}, + {WID_TX_POWER_LEVEL_11A, WID_CHAR}, + {WID_TX_POWER_LEVEL_11B, WID_CHAR}, + {WID_PREAMBLE, WID_CHAR}, + {WID_11G_OPERATING_MODE, WID_CHAR}, + {WID_MAC_ADDR, WID_ADR}, + {WID_IP_ADDRESS, WID_ADR}, + {WID_ACK_POLICY, WID_CHAR}, + {WID_PHY_ACTIVE_REG, WID_CHAR}, + {WID_AUTH_TYPE, WID_CHAR}, + {WID_REKEY_POLICY, WID_CHAR}, + {WID_REKEY_PERIOD, WID_INT}, + {WID_REKEY_PACKET_COUNT, WID_INT}, +#if 0 + {WID_WEP_KEY_VALUE0, WID_STR}, +#endif + {WID_11I_PSK, WID_STR}, + {WID_1X_KEY, WID_STR}, + {WID_1X_SERV_ADDR, WID_IP}, + {WID_SUPP_USERNAME, WID_STR}, + {WID_SUPP_PASSWORD, WID_STR}, + {WID_USER_CONTROL_ON_TX_POWER, WID_CHAR}, + {WID_MEMORY_ADDRESS, WID_INT}, + {WID_MEMORY_ACCESS_32BIT, WID_INT}, + {WID_MEMORY_ACCESS_16BIT, WID_SHORT}, + {WID_MEMORY_ACCESS_8BIT, WID_CHAR}, + {WID_SITE_SURVEY_RESULTS, WID_STR}, + {WID_PMKID_INFO, WID_STR}, + {WID_ASSOC_RES_INFO, WID_STR}, + {WID_MANUFACTURER, WID_STR}, /* 4 Wids added for the CAPI tool*/ + {WID_MODEL_NAME, WID_STR}, + {WID_MODEL_NUM, WID_STR}, + {WID_DEVICE_NAME, WID_STR}, + {WID_SSID_PROBE_REQ, WID_STR}, + +#ifdef MAC_802_11N + {WID_11N_ENABLE, WID_CHAR}, + {WID_11N_CURRENT_TX_MCS, WID_CHAR}, + {WID_TX_POWER_LEVEL_11N, WID_CHAR}, + {WID_11N_OPERATING_MODE, WID_CHAR}, + {WID_11N_SMPS_MODE, WID_CHAR}, + {WID_11N_PROT_MECH, WID_CHAR}, + {WID_11N_ERP_PROT_TYPE, WID_CHAR}, + {WID_11N_HT_PROT_TYPE, WID_CHAR}, + {WID_11N_PHY_ACTIVE_REG_VAL, WID_INT}, + {WID_11N_PRINT_STATS, WID_CHAR}, + {WID_11N_AUTORATE_TABLE, WID_BIN_DATA}, + {WID_HOST_CONFIG_IF_TYPE, WID_CHAR}, + {WID_HOST_DATA_IF_TYPE, WID_CHAR}, + {WID_11N_SIG_QUAL_VAL, WID_SHORT}, + {WID_11N_IMMEDIATE_BA_ENABLED, WID_CHAR}, + {WID_11N_TXOP_PROT_DISABLE, WID_CHAR}, + {WID_11N_SHORT_GI_20MHZ_ENABLE, WID_CHAR}, + {WID_SHORT_SLOT_ALLOWED, WID_CHAR}, + {WID_11W_ENABLE, WID_CHAR}, + {WID_11W_MGMT_PROT_REQ, WID_CHAR}, + {WID_2040_ENABLE, WID_CHAR}, + {WID_2040_COEXISTENCE, WID_CHAR}, + {WID_USER_SEC_CHANNEL_OFFSET, WID_CHAR}, + {WID_2040_CURR_CHANNEL_OFFSET, WID_CHAR}, + {WID_2040_40MHZ_INTOLERANT, WID_CHAR}, + {WID_HUT_RESTART, WID_CHAR}, + {WID_HUT_NUM_TX_PKTS, WID_INT}, + {WID_HUT_FRAME_LEN, WID_SHORT}, + {WID_HUT_TX_FORMAT, WID_CHAR}, + {WID_HUT_BANDWIDTH, WID_CHAR}, + {WID_HUT_OP_BAND, WID_CHAR}, + {WID_HUT_STBC, WID_CHAR}, + {WID_HUT_ESS, WID_CHAR}, + {WID_HUT_ANTSET, WID_CHAR}, + {WID_HUT_HT_OP_MODE, WID_CHAR}, + {WID_HUT_RIFS_MODE, WID_CHAR}, + {WID_HUT_SMOOTHING_REC, WID_CHAR}, + {WID_HUT_SOUNDING_PKT, WID_CHAR}, + {WID_HUT_HT_CODING, WID_CHAR}, + {WID_HUT_TEST_DIR, WID_CHAR}, + {WID_HUT_TXOP_LIMIT, WID_SHORT}, + {WID_HUT_DEST_ADDR, WID_ADR}, + {WID_HUT_TX_PATTERN, WID_BIN_DATA}, + {WID_HUT_TX_TIME_TAKEN, WID_INT}, + {WID_HUT_PHY_TEST_MODE, WID_CHAR}, + {WID_HUT_PHY_TEST_RATE_HI, WID_CHAR}, + {WID_HUT_PHY_TEST_RATE_LO, WID_CHAR}, + {WID_HUT_TX_TEST_TIME, WID_INT}, + {WID_HUT_LOG_INTERVAL, WID_INT}, + {WID_HUT_DISABLE_RXQ_REPLENISH, WID_CHAR}, + {WID_HUT_TEST_ID, WID_STR}, + {WID_HUT_KEY_ORIGIN, WID_CHAR}, + {WID_HUT_BCST_PERCENT, WID_CHAR}, + {WID_HUT_GROUP_CIPHER_TYPE, WID_CHAR}, + {WID_HUT_STATS, WID_BIN_DATA}, + {WID_HUT_TSF_TEST_MODE, WID_CHAR}, + {WID_HUT_SIG_QUAL_AVG, WID_SHORT}, + {WID_HUT_SIG_QUAL_AVG_CNT, WID_SHORT}, + {WID_HUT_TSSI_VALUE, WID_CHAR}, + {WID_HUT_MGMT_PERCENT, WID_CHAR}, + {WID_HUT_MGMT_BCST_PERCENT, WID_CHAR}, + {WID_HUT_MGMT_ALLOW_HT, WID_CHAR}, + {WID_HUT_UC_MGMT_TYPE, WID_CHAR}, + {WID_HUT_BC_MGMT_TYPE, WID_CHAR}, + {WID_HUT_UC_MGMT_FRAME_LEN, WID_SHORT}, + {WID_HUT_BC_MGMT_FRAME_LEN, WID_SHORT}, + {WID_HUT_11W_MFP_REQUIRED_TX, WID_CHAR}, + {WID_HUT_11W_MFP_PEER_CAPABLE, WID_CHAR}, + {WID_HUT_11W_TX_IGTK_ID, WID_CHAR}, + {WID_HUT_FC_TXOP_MOD, WID_CHAR}, + {WID_HUT_FC_PROT_TYPE, WID_CHAR}, + {WID_HUT_SEC_CCA_ASSERT, WID_CHAR}, +#endif /* MAC_802_11N */ +}; + +WILC_Uint16 g_num_total_switches = (sizeof(gastrWIDs) / sizeof(tstrWID)); +/*****************************************************************************/ +/* Static Function Declarations */ +/*****************************************************************************/ + + + +/*****************************************************************************/ +/* Functions */ +/*****************************************************************************/ +INLINE WILC_Uint8 ascii_hex_to_dec(WILC_Uint8 num) +{ + if ((num >= '0') && (num <= '9')) + return (num - '0'); + else if ((num >= 'A') && (num <= 'F')) + return (10 + (num - 'A')); + else if ((num >= 'a') && (num <= 'f')) + return (10 + (num - 'a')); + + return INVALID; +} + +INLINE WILC_Uint8 get_hex_char(WILC_Uint8 inp) +{ + WILC_Uint8 *d2htab = "0123456789ABCDEF"; + + return d2htab[inp & 0xF]; +} + +/* This function extracts the MAC address held in a string in standard format */ +/* into another buffer as integers. */ +INLINE WILC_Uint16 extract_mac_addr(WILC_Char *str, WILC_Uint8 *buff) +{ + *buff = 0; + while (*str != '\0') { + if ((*str == ':') || (*str == '-')) + *(++buff) = 0; + else + *buff = (*buff << 4) + ascii_hex_to_dec(*str); + + str++; + } + + return MAC_ADDR_LEN; +} + +/* This function creates MAC address in standard format from a buffer of */ +/* integers. */ +INLINE void create_mac_addr(WILC_Uint8 *str, WILC_Uint8 *buff) +{ + WILC_Uint32 i = 0; + WILC_Uint32 j = 0; + + for (i = 0; i < MAC_ADDR_LEN; i++) { + str[j++] = get_hex_char((WILC_Uint8)((buff[i] >> 4) & 0x0F)); + str[j++] = get_hex_char((WILC_Uint8)(buff[i] & 0x0F)); + str[j++] = ':'; + } + str[--j] = '\0'; +} + +/* This function converts the IP address string in dotted decimal format to */ +/* unsigned integer. This functionality is similar to the library function */ +/* inet_addr() but is reimplemented here since I could not confirm that */ +/* inet_addr is platform independent. */ +/* ips=>IP Address String in dotted decimal format */ +/* ipn=>Pointer to IP Address in integer format */ +INLINE WILC_Uint8 conv_ip_to_int(WILC_Uint8 *ips, WILC_Uint32 *ipn) +{ + WILC_Uint8 i = 0; + WILC_Uint8 ipb = 0; + *ipn = 0; + /* Integer to string for each component */ + while (ips[i] != '\0') { + if (ips[i] == '.') { + *ipn = ((*ipn) << 8) | ipb; + ipb = 0; + } else { + ipb = ipb * 10 + ascii_hex_to_dec(ips[i]); + } + + i++; + } + + /* The last byte of the IP address is read in here */ + *ipn = ((*ipn) << 8) | ipb; + + return 0; +} + +/* This function converts the IP address from integer format to dotted */ +/* decimal string format. Alternative to std library fn inet_ntoa(). */ +/* ips=>Buffer to hold IP Address String dotted decimal format (Min 17B) */ +/* ipn=>IP Address in integer format */ +INLINE WILC_Uint8 conv_int_to_ip(WILC_Uint8 *ips, WILC_Uint32 ipn) +{ + WILC_Uint8 i = 0; + WILC_Uint8 ipb = 0; + WILC_Uint8 cnt = 0; + WILC_Uint8 ipbsize = 0; + + for (cnt = 4; cnt > 0; cnt--) { + ipb = (ipn >> (8 * (cnt - 1))) & 0xFF; + + if (ipb >= 100) + ipbsize = 2; + else if (ipb >= 10) + ipbsize = 1; + else + ipbsize = 0; + + switch (ipbsize) { + case 2: + ips[i++] = get_hex_char(ipb / 100); + ipb %= 100; + + case 1: + ips[i++] = get_hex_char(ipb / 10); + ipb %= 10; + + default: + ips[i++] = get_hex_char(ipb); + } + + if (cnt > 1) + ips[i++] = '.'; + } + + ips[i] = '\0'; + + return i; +} + +INLINE tenuWIDtype get_wid_type(WILC_Uint32 wid_num) +{ + /* Check for iconfig specific WID types first */ + if ((wid_num == WID_BSSID) || + (wid_num == WID_MAC_ADDR) || + (wid_num == WID_IP_ADDRESS) || + (wid_num == WID_HUT_DEST_ADDR)) { + return WID_ADR; + } + + if ((WID_1X_SERV_ADDR == wid_num) || + (WID_STACK_IP_ADDR == wid_num) || + (WID_STACK_NETMASK_ADDR == wid_num)) { + return WID_IP; + } + + /* Next check for standard WID types */ + if (wid_num < 0x1000) + return WID_CHAR; + else if (wid_num < 0x2000) + return WID_SHORT; + else if (wid_num < 0x3000) + return WID_INT; + else if (wid_num < 0x4000) + return WID_STR; + else if (wid_num < 0x5000) + return WID_BIN_DATA; + + return WID_UNDEF; +} + + +/* This function extracts the beacon period field from the beacon or probe */ +/* response frame. */ +INLINE WILC_Uint16 get_beacon_period(WILC_Uint8 *data) +{ + WILC_Uint16 bcn_per = 0; + + bcn_per = data[0]; + bcn_per |= (data[1] << 8); + + return bcn_per; +} + +INLINE WILC_Uint32 get_beacon_timestamp_lo(WILC_Uint8 *data) +{ + WILC_Uint32 time_stamp = 0; + WILC_Uint32 index = MAC_HDR_LEN; + + time_stamp |= data[index++]; + time_stamp |= (data[index++] << 8); + time_stamp |= (data[index++] << 16); + time_stamp |= (data[index] << 24); + + return time_stamp; +} + +INLINE UWORD32 get_beacon_timestamp_hi(UWORD8 *data) +{ + UWORD32 time_stamp = 0; + UWORD32 index = (MAC_HDR_LEN + 4); + + time_stamp |= data[index++]; + time_stamp |= (data[index++] << 8); + time_stamp |= (data[index++] << 16); + time_stamp |= (data[index] << 24); + + return time_stamp; +} + +/* This function extracts the 'frame type' bits from the MAC header of the */ +/* input frame. */ +/* Returns the value in the LSB of the returned value. */ +INLINE tenuBasicFrmType get_type(WILC_Uint8 *header) +{ + return ((tenuBasicFrmType)(header[0] & 0x0C)); +} + +/* This function extracts the 'frame type and sub type' bits from the MAC */ +/* header of the input frame. */ +/* Returns the value in the LSB of the returned value. */ +INLINE tenuFrmSubtype get_sub_type(WILC_Uint8 *header) +{ + return ((tenuFrmSubtype)(header[0] & 0xFC)); +} + +/* This function extracts the 'to ds' bit from the MAC header of the input */ +/* frame. */ +/* Returns the value in the LSB of the returned value. */ +INLINE WILC_Uint8 get_to_ds(WILC_Uint8 *header) +{ + return (header[1] & 0x01); +} + +/* This function extracts the 'from ds' bit from the MAC header of the input */ +/* frame. */ +/* Returns the value in the LSB of the returned value. */ +INLINE WILC_Uint8 get_from_ds(WILC_Uint8 *header) +{ + return ((header[1] & 0x02) >> 1); +} + +/* This function extracts the MAC Address in 'address1' field of the MAC */ +/* header and updates the MAC Address in the allocated 'addr' variable. */ +INLINE void get_address1(WILC_Uint8 *pu8msa, WILC_Uint8 *addr) +{ + WILC_memcpy(addr, pu8msa + 4, 6); +} + +/* This function extracts the MAC Address in 'address2' field of the MAC */ +/* header and updates the MAC Address in the allocated 'addr' variable. */ +INLINE void get_address2(WILC_Uint8 *pu8msa, WILC_Uint8 *addr) +{ + WILC_memcpy(addr, pu8msa + 10, 6); +} + +/* This function extracts the MAC Address in 'address3' field of the MAC */ +/* header and updates the MAC Address in the allocated 'addr' variable. */ +INLINE void get_address3(WILC_Uint8 *pu8msa, WILC_Uint8 *addr) +{ + WILC_memcpy(addr, pu8msa + 16, 6); +} + +/* This function extracts the BSSID from the incoming WLAN packet based on */ +/* the 'from ds' bit, and updates the MAC Address in the allocated 'addr' */ +/* variable. */ +INLINE void get_BSSID(WILC_Uint8 *data, WILC_Uint8 *bssid) +{ + if (get_from_ds(data) == 1) + get_address2(data, bssid); + else if (get_to_ds(data) == 1) + get_address1(data, bssid); + else + get_address3(data, bssid); +} + +/* This function extracts the SSID from a beacon/probe response frame */ +INLINE void get_ssid(WILC_Uint8 *data, WILC_Uint8 *ssid, WILC_Uint8 *p_ssid_len) +{ + WILC_Uint8 len = 0; + WILC_Uint8 i = 0; + WILC_Uint8 j = 0; + + len = data[MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN + + CAP_INFO_LEN + 1]; + j = MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN + + CAP_INFO_LEN + 2; + + /* If the SSID length field is set wrongly to a value greater than the */ + /* allowed maximum SSID length limit, reset the length to 0 */ + if (len >= MAX_SSID_LEN) + len = 0; + + for (i = 0; i < len; i++, j++) + ssid[i] = data[j]; + + ssid[len] = '\0'; + + *p_ssid_len = len; +} + +/* This function extracts the capability info field from the beacon or probe */ +/* response frame. */ +INLINE WILC_Uint16 get_cap_info(WILC_Uint8 *data) +{ + WILC_Uint16 cap_info = 0; + WILC_Uint16 index = MAC_HDR_LEN; + tenuFrmSubtype st = BEACON; + + st = get_sub_type(data); + + /* Location of the Capability field is different for Beacon and */ + /* Association frames. */ + if ((st == BEACON) || (st == PROBE_RSP)) + index += TIME_STAMP_LEN + BEACON_INTERVAL_LEN; + + cap_info = data[index]; + cap_info |= (data[index + 1] << 8); + + return cap_info; +} + +/* This function extracts the capability info field from the Association */ +/* response frame. */ +INLINE WILC_Uint16 get_assoc_resp_cap_info(WILC_Uint8 *data) +{ + WILC_Uint16 cap_info = 0; + + cap_info = data[0]; + cap_info |= (data[1] << 8); + + return cap_info; +} + +/* This funcion extracts the association status code from the incoming */ +/* association response frame and returns association status code */ +INLINE WILC_Uint16 get_asoc_status(WILC_Uint8 *data) +{ + WILC_Uint16 asoc_status = 0; + + asoc_status = data[3]; + asoc_status = (asoc_status << 8) | data[2]; + + return asoc_status; +} + +/* This function extracts association ID from the incoming association */ +/* response frame */ +INLINE WILC_Uint16 get_asoc_id(WILC_Uint8 *data) +{ + WILC_Uint16 asoc_id = 0; + + asoc_id = data[4]; + asoc_id |= (data[5] << 8); + + return asoc_id; +} + +/** + * @brief initializes the Core Configurator + * @details + * @return Error code indicating success/failure + * @note + * @author mabubakr + * @date 1 Mar 2012 + * @version 1.0 + */ + +WILC_Sint32 CoreConfiguratorInit(void) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_SemaphoreAttrs strSemSendPktAttrs; + tstrWILC_SemaphoreAttrs strSemPktRespAttrs; + + PRINT_D(CORECONFIG_DBG, "CoreConfiguratorInit() \n"); + + WILC_SemaphoreFillDefault(&strSemSendPktAttrs); + strSemSendPktAttrs.u32InitCount = 1; + WILC_SemaphoreCreate(&SemHandleSendPkt, &strSemSendPktAttrs); + + WILC_SemaphoreFillDefault(&strSemPktRespAttrs); + strSemPktRespAttrs.u32InitCount = 0; + WILC_SemaphoreCreate(&SemHandlePktResp, &strSemPktRespAttrs); + + gps8ConfigPacket = (WILC_Sint8 *)WILC_MALLOC(MAX_PACKET_BUFF_SIZE); + if (gps8ConfigPacket == NULL) { + PRINT_ER("failed in gps8ConfigPacket allocation \n"); + s32Error = WILC_NO_MEM; + goto _fail_; + } + + WILC_memset((void *)gps8ConfigPacket, 0, MAX_PACKET_BUFF_SIZE); + + WILC_memset((void *)(&gstrConfigPktInfo), 0, sizeof(tstrConfigPktInfo)); +_fail_: + return s32Error; +} + +WILC_Uint8 *get_tim_elm(WILC_Uint8 *pu8msa, WILC_Uint16 u16RxLen, WILC_Uint16 u16TagParamOffset) +{ + WILC_Uint16 u16index = 0; + + /*************************************************************************/ + /* Beacon Frame - Frame Body */ + /* --------------------------------------------------------------------- */ + /* |Timestamp |BeaconInt |CapInfo |SSID |SupRates |DSParSet |TIM elm | */ + /* --------------------------------------------------------------------- */ + /* |8 |2 |2 |2-34 |3-10 |3 |4-256 | */ + /* --------------------------------------------------------------------- */ + /* */ + /*************************************************************************/ + + u16index = u16TagParamOffset; + + /* Search for the TIM Element Field and return if the element is found */ + while (u16index < (u16RxLen - FCS_LEN)) { + if (pu8msa[u16index] == ITIM) { + return(&pu8msa[u16index]); + } else { + u16index += (IE_HDR_LEN + pu8msa[u16index + 1]); + } + } + + return(0); +} + +/* This function gets the current channel information from + * the 802.11n beacon/probe response frame */ +WILC_Uint8 get_current_channel_802_11n(WILC_Uint8 *pu8msa, WILC_Uint16 u16RxLen) +{ + WILC_Uint16 index; + + index = TAG_PARAM_OFFSET; + while (index < (u16RxLen - FCS_LEN)) { + if (pu8msa[index] == IDSPARMS) + return (pu8msa[index + 2]); + else + /* Increment index by length information and header */ + index += pu8msa[index + 1] + IE_HDR_LEN; + } + + /* Return current channel information from the MIB, if beacon/probe */ + /* response frame does not contain the DS parameter set IE */ + /* return (mget_CurrentChannel() + 1); */ + return 0; /* no MIB here */ +} + +WILC_Uint8 get_current_channel(WILC_Uint8 *pu8msa, WILC_Uint16 u16RxLen) +{ +#ifdef PHY_802_11n +#ifdef FIVE_GHZ_BAND + /* Get the current channel as its not set in */ + /* 802.11a beacons/probe response */ + return (get_rf_channel() + 1); +#else /* FIVE_GHZ_BAND */ + /* Extract current channel information from */ + /* the beacon/probe response frame */ + return (get_current_channel_802_11n(pu8msa, u16RxLen)); +#endif /* FIVE_GHZ_BAND */ +#else + return 0; +#endif /* PHY_802_11n */ +} + +/** + * @brief parses the received 'N' message + * @details + * @param[in] pu8MsgBuffer The message to be parsed + * @param[out] ppstrNetworkInfo pointer to pointer to the structure containing the parsed Network Info + * @return Error code indicating success/failure + * @note + * @author mabubakr + * @date 1 Mar 2012 + * @version 1.0 + */ +WILC_Sint32 ParseNetworkInfo(WILC_Uint8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrNetworkInfo *pstrNetworkInfo = WILC_NULL; + WILC_Uint8 u8MsgType = 0; + WILC_Uint8 u8MsgID = 0; + WILC_Uint16 u16MsgLen = 0; + + WILC_Uint16 u16WidID = (WILC_Uint16)WID_NIL; + WILC_Uint16 u16WidLen = 0; + WILC_Uint8 *pu8WidVal = 0; + + u8MsgType = pu8MsgBuffer[0]; + + /* Check whether the received message type is 'N' */ + if ('N' != u8MsgType) { + PRINT_ER("Received Message format incorrect.\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + + /* Extract message ID */ + u8MsgID = pu8MsgBuffer[1]; + + /* Extract message Length */ + u16MsgLen = MAKE_WORD16(pu8MsgBuffer[2], pu8MsgBuffer[3]); + + /* Extract WID ID */ + u16WidID = MAKE_WORD16(pu8MsgBuffer[4], pu8MsgBuffer[5]); + + /* Extract WID Length */ + u16WidLen = MAKE_WORD16(pu8MsgBuffer[6], pu8MsgBuffer[7]); + + /* Assign a pointer to the WID value */ + pu8WidVal = &pu8MsgBuffer[8]; + + /* parse the WID value of the WID "WID_NEWORK_INFO" */ + { + WILC_Uint8 *pu8msa = 0; + WILC_Uint16 u16RxLen = 0; + WILC_Uint8 *pu8TimElm = 0; + WILC_Uint8 *pu8IEs = 0; + WILC_Uint16 u16IEsLen = 0; + WILC_Uint8 u8index = 0; + WILC_Uint32 u32Tsf_Lo; + WILC_Uint32 u32Tsf_Hi; + + pstrNetworkInfo = (tstrNetworkInfo *)WILC_MALLOC(sizeof(tstrNetworkInfo)); + WILC_memset((void *)(pstrNetworkInfo), 0, sizeof(tstrNetworkInfo)); + + pstrNetworkInfo->s8rssi = pu8WidVal[0]; + + /* Assign a pointer to msa "Mac Header Start Address" */ + pu8msa = &pu8WidVal[1]; + + u16RxLen = u16WidLen - 1; + + /* parse msa*/ + + /* Get the cap_info */ + pstrNetworkInfo->u16CapInfo = get_cap_info(pu8msa); + #ifdef WILC_P2P + /* Get time-stamp [Low only 32 bit] */ + pstrNetworkInfo->u32Tsf = get_beacon_timestamp_lo(pu8msa); + PRINT_D(CORECONFIG_DBG, "TSF :%x\n", pstrNetworkInfo->u32Tsf); + #endif + + /* Get full time-stamp [Low and High 64 bit] */ + u32Tsf_Lo = get_beacon_timestamp_lo(pu8msa); + u32Tsf_Hi = get_beacon_timestamp_hi(pu8msa); + + pstrNetworkInfo->u64Tsf = u32Tsf_Lo | ((WILC_Uint64)u32Tsf_Hi << 32); + + /* Get SSID */ + get_ssid(pu8msa, pstrNetworkInfo->au8ssid, &(pstrNetworkInfo->u8SsidLen)); + + /* Get BSSID */ + get_BSSID(pu8msa, pstrNetworkInfo->au8bssid); + + /* Get the current channel */ + pstrNetworkInfo->u8channel = get_current_channel(pu8msa, (u16RxLen + FCS_LEN)); + + /* Get beacon period */ + u8index = (MAC_HDR_LEN + TIME_STAMP_LEN); + + pstrNetworkInfo->u16BeaconPeriod = get_beacon_period(pu8msa + u8index); + + u8index += BEACON_INTERVAL_LEN + CAP_INFO_LEN; + + /* Get DTIM Period */ + pu8TimElm = get_tim_elm(pu8msa, (u16RxLen + FCS_LEN), u8index); + if (pu8TimElm != 0) { + pstrNetworkInfo->u8DtimPeriod = pu8TimElm[3]; + } + pu8IEs = &pu8msa[MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN + CAP_INFO_LEN]; + u16IEsLen = u16RxLen - (MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN + CAP_INFO_LEN); + + if (u16IEsLen > 0) { + pstrNetworkInfo->pu8IEs = (WILC_Uint8 *)WILC_MALLOC(u16IEsLen); + WILC_memset((void *)(pstrNetworkInfo->pu8IEs), 0, u16IEsLen); + + WILC_memcpy(pstrNetworkInfo->pu8IEs, pu8IEs, u16IEsLen); + } + pstrNetworkInfo->u16IEsLen = u16IEsLen; + + } + + *ppstrNetworkInfo = pstrNetworkInfo; + +ERRORHANDLER: + return s32Error; +} + +/** + * @brief Deallocates the parsed Network Info + * @details + * @param[in] pstrNetworkInfo Network Info to be deallocated + * @return Error code indicating success/failure + * @note + * @author mabubakr + * @date 1 Mar 2012 + * @version 1.0 + */ +WILC_Sint32 DeallocateNetworkInfo(tstrNetworkInfo *pstrNetworkInfo) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + + if (pstrNetworkInfo != WILC_NULL) { + if (pstrNetworkInfo->pu8IEs != WILC_NULL) { + WILC_FREE(pstrNetworkInfo->pu8IEs); + pstrNetworkInfo->pu8IEs = WILC_NULL; + } else { + s32Error = WILC_FAIL; + } + + WILC_FREE(pstrNetworkInfo); + pstrNetworkInfo = WILC_NULL; + + } else { + s32Error = WILC_FAIL; + } + + return s32Error; +} + +/** + * @brief parses the received Association Response frame + * @details + * @param[in] pu8Buffer The Association Response frame to be parsed + * @param[out] ppstrConnectRespInfo pointer to pointer to the structure containing the parsed Association Response Info + * @return Error code indicating success/failure + * @note + * @author mabubakr + * @date 2 Apr 2012 + * @version 1.0 + */ +WILC_Sint32 ParseAssocRespInfo(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32BufferLen, + tstrConnectRespInfo **ppstrConnectRespInfo) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrConnectRespInfo *pstrConnectRespInfo = WILC_NULL; + WILC_Uint16 u16AssocRespLen = 0; + WILC_Uint8 *pu8IEs = 0; + WILC_Uint16 u16IEsLen = 0; + + pstrConnectRespInfo = (tstrConnectRespInfo *)WILC_MALLOC(sizeof(tstrConnectRespInfo)); + WILC_memset((void *)(pstrConnectRespInfo), 0, sizeof(tstrConnectRespInfo)); + + /* u16AssocRespLen = pu8Buffer[0]; */ + u16AssocRespLen = (WILC_Uint16)u32BufferLen; + + /* get the status code */ + pstrConnectRespInfo->u16ConnectStatus = get_asoc_status(pu8Buffer); + if (pstrConnectRespInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE) { + + /* get the capability */ + pstrConnectRespInfo->u16capability = get_assoc_resp_cap_info(pu8Buffer); + + /* get the Association ID */ + pstrConnectRespInfo->u16AssocID = get_asoc_id(pu8Buffer); + + /* get the Information Elements */ + pu8IEs = &pu8Buffer[CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN]; + u16IEsLen = u16AssocRespLen - (CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN); + + pstrConnectRespInfo->pu8RespIEs = (WILC_Uint8 *)WILC_MALLOC(u16IEsLen); + WILC_memset((void *)(pstrConnectRespInfo->pu8RespIEs), 0, u16IEsLen); + + WILC_memcpy(pstrConnectRespInfo->pu8RespIEs, pu8IEs, u16IEsLen); + pstrConnectRespInfo->u16RespIEsLen = u16IEsLen; + } + + *ppstrConnectRespInfo = pstrConnectRespInfo; + + + return s32Error; +} + +/** + * @brief Deallocates the parsed Association Response Info + * @details + * @param[in] pstrNetworkInfo Network Info to be deallocated + * @return Error code indicating success/failure + * @note + * @author mabubakr + * @date 2 Apr 2012 + * @version 1.0 + */ +WILC_Sint32 DeallocateAssocRespInfo(tstrConnectRespInfo *pstrConnectRespInfo) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + + if (pstrConnectRespInfo != WILC_NULL) { + if (pstrConnectRespInfo->pu8RespIEs != WILC_NULL) { + WILC_FREE(pstrConnectRespInfo->pu8RespIEs); + pstrConnectRespInfo->pu8RespIEs = WILC_NULL; + } else { + s32Error = WILC_FAIL; + } + + WILC_FREE(pstrConnectRespInfo); + pstrConnectRespInfo = WILC_NULL; + + } else { + s32Error = WILC_FAIL; + } + + return s32Error; +} + +#ifndef CONNECT_DIRECT +WILC_Sint32 ParseSurveyResults(WILC_Uint8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE], + wid_site_survey_reslts_s **ppstrSurveyResults, + WILC_Uint32 *pu32SurveyResultsCount) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + wid_site_survey_reslts_s *pstrSurveyResults = NULL; + WILC_Uint32 u32SurveyResultsCount = 0; + WILC_Uint32 u32SurveyBytesLength = 0; + WILC_Uint8 *pu8BufferPtr; + WILC_Uint32 u32RcvdSurveyResultsNum = 2; + WILC_Uint8 u8ReadSurveyResFragNum; + WILC_Uint32 i; + WILC_Uint32 j; + + for (i = 0; i < u32RcvdSurveyResultsNum; i++) { + u32SurveyBytesLength = ppu8RcvdSiteSurveyResults[i][0]; + + + for (j = 0; j < u32SurveyBytesLength; j += SURVEY_RESULT_LENGTH) { + u32SurveyResultsCount++; + } + } + + pstrSurveyResults = (wid_site_survey_reslts_s *)WILC_MALLOC(u32SurveyResultsCount * sizeof(wid_site_survey_reslts_s)); + if (pstrSurveyResults == NULL) { + u32SurveyResultsCount = 0; + WILC_ERRORREPORT(s32Error, WILC_NO_MEM); + } + + WILC_memset((void *)(pstrSurveyResults), 0, u32SurveyResultsCount * sizeof(wid_site_survey_reslts_s)); + + u32SurveyResultsCount = 0; + + for (i = 0; i < u32RcvdSurveyResultsNum; i++) { + pu8BufferPtr = ppu8RcvdSiteSurveyResults[i]; + + u32SurveyBytesLength = pu8BufferPtr[0]; + + /* TODO: mostafa: pu8BufferPtr[1] contains the fragment num */ + u8ReadSurveyResFragNum = pu8BufferPtr[1]; + + pu8BufferPtr += 2; + + for (j = 0; j < u32SurveyBytesLength; j += SURVEY_RESULT_LENGTH) { + WILC_memcpy(&pstrSurveyResults[u32SurveyResultsCount], pu8BufferPtr, SURVEY_RESULT_LENGTH); + pu8BufferPtr += SURVEY_RESULT_LENGTH; + u32SurveyResultsCount++; + } + } + +ERRORHANDLER: + *ppstrSurveyResults = pstrSurveyResults; + *pu32SurveyResultsCount = u32SurveyResultsCount; + + return s32Error; +} + + +WILC_Sint32 DeallocateSurveyResults(wid_site_survey_reslts_s *pstrSurveyResults) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + + if (pstrSurveyResults != WILC_NULL) { + WILC_FREE(pstrSurveyResults); + } + + return s32Error; +} +#endif + +/*****************************************************************************/ +/* */ +/* Function Name : ProcessCharWid */ +/* */ +/* Description : This function processes a WID of type WID_CHAR and */ +/* updates the cfg packet with the supplied value. */ +/* */ +/* Inputs : 1) Pointer to WID cfg structure */ +/* 2) Value to set */ +/* */ +/* Globals : */ +/* */ +/* Processing : */ +/* */ +/* Outputs : None */ +/* */ +/* Returns : None */ +/* */ +/* Issues : None */ +/* */ +/* Revision History: */ +/* */ +/* DD MM YYYY Author(s) Changes (Describe the changes made) */ +/* 08 01 2008 Ittiam Draft */ +/* */ +/*****************************************************************************/ + +void ProcessCharWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, + tstrWID *pstrWID, WILC_Sint8 *ps8WidVal) +{ + WILC_Uint8 *pu8val = (WILC_Uint8 *)ps8WidVal; + WILC_Uint8 u8val = 0; + WILC_Sint32 s32PktLen = *ps32PktLen; + if (pstrWID == NULL) { + PRINT_WRN(CORECONFIG_DBG, "Can't set CHAR val 0x%x ,NULL structure\n", u8val); + return; + } + + /* WID */ + pcPacket[s32PktLen++] = (WILC_Uint8)(pstrWID->u16WIDid & 0xFF); + pcPacket[s32PktLen++] = (WILC_Uint8)(pstrWID->u16WIDid >> 8) & 0xFF; + if (g_oper_mode == SET_CFG) { + u8val = *pu8val; + + /* Length */ + pcPacket[s32PktLen++] = sizeof(WILC_Uint8); + + + /* Value */ + pcPacket[s32PktLen++] = u8val; + } + *ps32PktLen = s32PktLen; +} + +/*****************************************************************************/ +/* */ +/* Function Name : ProcessShortWid */ +/* */ +/* Description : This function processes a WID of type WID_SHORT and */ +/* updates the cfg packet with the supplied value. */ +/* */ +/* Inputs : 1) Pointer to WID cfg structure */ +/* 2) Value to set */ +/* */ +/* Globals : */ +/* */ +/* Processing : */ +/* */ +/* Outputs : None */ +/* */ +/* Returns : None */ +/* */ +/* Issues : None */ +/* */ +/* Revision History: */ +/* */ +/* DD MM YYYY Author(s) Changes (Describe the changes made) */ +/* 08 01 2008 Ittiam Draft */ +/* */ +/*****************************************************************************/ + +void ProcessShortWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, + tstrWID *pstrWID, WILC_Sint8 *ps8WidVal) +{ + WILC_Uint16 *pu16val = (WILC_Uint16 *)ps8WidVal; + WILC_Uint16 u16val = 0; + WILC_Sint32 s32PktLen = *ps32PktLen; + if (pstrWID == NULL) { + PRINT_WRN(CORECONFIG_DBG, "Can't set SHORT val 0x%x ,NULL structure\n", u16val); + return; + } + + /* WID */ + pcPacket[s32PktLen++] = (WILC_Uint8)(pstrWID->u16WIDid & 0xFF); + pcPacket[s32PktLen++] = (WILC_Uint8)((pstrWID->u16WIDid >> 8) & 0xFF); + + if (g_oper_mode == SET_CFG) { + u16val = *pu16val; + + /* Length */ + pcPacket[s32PktLen++] = sizeof(WILC_Uint16); + + /* Value */ + pcPacket[s32PktLen++] = (WILC_Uint8)(u16val & 0xFF); + pcPacket[s32PktLen++] = (WILC_Uint8)((u16val >> 8) & 0xFF); + } + *ps32PktLen = s32PktLen; +} + +/*****************************************************************************/ +/* */ +/* Function Name : ProcessIntWid */ +/* */ +/* Description : This function processes a WID of type WID_INT and */ +/* updates the cfg packet with the supplied value. */ +/* */ +/* Inputs : 1) Pointer to WID cfg structure */ +/* 2) Value to set */ +/* */ +/* Globals : */ +/* */ +/* Processing : */ +/* */ +/* Outputs : None */ +/* */ +/* Returns : None */ +/* */ +/* Issues : None */ +/* */ +/* Revision History: */ +/* */ +/* DD MM YYYY Author(s) Changes (Describe the changes made) */ +/* 08 01 2008 Ittiam Draft */ +/* */ +/*****************************************************************************/ + +void ProcessIntWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, + tstrWID *pstrWID, WILC_Sint8 *ps8WidVal) +{ + WILC_Uint32 *pu32val = (WILC_Uint32 *)ps8WidVal; + WILC_Uint32 u32val = 0; + WILC_Sint32 s32PktLen = *ps32PktLen; + if (pstrWID == NULL) { + PRINT_WRN(CORECONFIG_DBG, "Can't set INT val 0x%x , NULL structure\n", u32val); + return; + } + + /* WID */ + pcPacket[s32PktLen++] = (WILC_Uint8)(pstrWID->u16WIDid & 0xFF); + pcPacket[s32PktLen++] = (WILC_Uint8)((pstrWID->u16WIDid >> 8) & 0xFF); + + if (g_oper_mode == SET_CFG) { + u32val = *pu32val; + + /* Length */ + pcPacket[s32PktLen++] = sizeof(WILC_Uint32); + + /* Value */ + pcPacket[s32PktLen++] = (WILC_Uint8)(u32val & 0xFF); + pcPacket[s32PktLen++] = (WILC_Uint8)((u32val >> 8) & 0xFF); + pcPacket[s32PktLen++] = (WILC_Uint8)((u32val >> 16) & 0xFF); + pcPacket[s32PktLen++] = (WILC_Uint8)((u32val >> 24) & 0xFF); + } + *ps32PktLen = s32PktLen; +} + +/*****************************************************************************/ +/* */ +/* Function Name : ProcessIPwid */ +/* */ +/* Description : This function processes a WID of type WID_IP and */ +/* updates the cfg packet with the supplied value. */ +/* */ +/* Inputs : 1) Pointer to WID cfg structure */ +/* 2) Value to set */ +/* */ +/* Globals : */ +/* */ +/* */ +/* Processing : */ +/* */ +/* Outputs : None */ +/* */ +/* Returns : None */ +/* */ +/* Issues : None */ +/* */ +/* Revision History: */ +/* */ +/* DD MM YYYY Author(s) Changes (Describe the changes made) */ +/* 08 01 2008 Ittiam Draft */ +/* */ +/*****************************************************************************/ + +void ProcessIPwid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, + tstrWID *pstrWID, WILC_Uint8 *pu8ip) +{ + WILC_Uint32 u32val = 0; + WILC_Sint32 s32PktLen = *ps32PktLen; + + if (pstrWID == NULL) { + PRINT_WRN(CORECONFIG_DBG, "Can't set IP Addr , NULL structure\n"); + return; + } + + /* WID */ + pcPacket[s32PktLen++] = (WILC_Uint8)(pstrWID->u16WIDid & 0xFF); + pcPacket[s32PktLen++] = (WILC_Uint8)((pstrWID->u16WIDid >> 8) & 0xFF); + + if (g_oper_mode == SET_CFG) { + /* Length */ + pcPacket[s32PktLen++] = sizeof(WILC_Uint32); + + /* Convert the IP Address String to Integer */ + conv_ip_to_int(pu8ip, &u32val); + + /* Value */ + pcPacket[s32PktLen++] = (WILC_Uint8)(u32val & 0xFF); + pcPacket[s32PktLen++] = (WILC_Uint8)((u32val >> 8) & 0xFF); + pcPacket[s32PktLen++] = (WILC_Uint8)((u32val >> 16) & 0xFF); + pcPacket[s32PktLen++] = (WILC_Uint8)((u32val >> 24) & 0xFF); + } + *ps32PktLen = s32PktLen; +} + +/*****************************************************************************/ +/* */ +/* Function Name : ProcessStrWid */ +/* */ +/* Description : This function processes a WID of type WID_STR and */ +/* updates the cfg packet with the supplied value. */ +/* */ +/* Inputs : 1) Pointer to WID cfg structure */ +/* 2) Value to set */ +/* */ +/* Globals : */ +/* */ +/* Processing : */ +/* */ +/* Outputs : None */ +/* */ +/* Returns : None */ +/* */ +/* Issues : None */ +/* */ +/* Revision History: */ +/* */ +/* DD MM YYYY Author(s) Changes (Describe the changes made) */ +/* 08 01 2008 Ittiam Draft */ +/* */ +/*****************************************************************************/ + +void ProcessStrWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, + tstrWID *pstrWID, WILC_Uint8 *pu8val, WILC_Sint32 s32ValueSize) +{ + WILC_Uint16 u16MsgLen = 0; + WILC_Uint16 idx = 0; + WILC_Sint32 s32PktLen = *ps32PktLen; + if (pstrWID == NULL) { + PRINT_WRN(CORECONFIG_DBG, "Can't set STR val, NULL structure\n"); + return; + } + + /* WID */ + pcPacket[s32PktLen++] = (WILC_Uint8)(pstrWID->u16WIDid & 0xFF); + pcPacket[s32PktLen++] = (WILC_Uint8)((pstrWID->u16WIDid >> 8) & 0xFF); + + if (g_oper_mode == SET_CFG) { + /* Message Length */ + /* u16MsgLen = WILC_strlen(pu8val); */ + u16MsgLen = (WILC_Uint16)s32ValueSize; + + /* Length */ + pcPacket[s32PktLen++] = (WILC_Uint8)u16MsgLen; + + /* Value */ + for (idx = 0; idx < u16MsgLen; idx++) + pcPacket[s32PktLen++] = pu8val[idx]; + } + *ps32PktLen = s32PktLen; +} + +/*****************************************************************************/ +/* */ +/* Function Name : ProcessAdrWid */ +/* */ +/* Description : This function processes a WID of type WID_ADR and */ +/* updates the cfg packet with the supplied value. */ +/* */ +/* Inputs : 1) Pointer to WID cfg structure */ +/* 2) Value to set */ +/* */ +/* Globals : */ +/* */ +/* Processing : */ +/* */ +/* Outputs : None */ +/* */ +/* Returns : None */ +/* */ +/* Issues : None */ +/* */ +/* Revision History: */ +/* */ +/* DD MM YYYY Author(s) Changes (Describe the changes made) */ +/* 08 01 2008 Ittiam Draft */ +/* */ +/*****************************************************************************/ + +void ProcessAdrWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, + tstrWID *pstrWID, WILC_Uint8 *pu8val) +{ + WILC_Uint16 u16MsgLen = 0; + WILC_Sint32 s32PktLen = *ps32PktLen; + + if (pstrWID == NULL) { + PRINT_WRN(CORECONFIG_DBG, "Can't set Addr WID, NULL structure\n"); + return; + } + + /* WID */ + pcPacket[s32PktLen++] = (WILC_Uint8)(pstrWID->u16WIDid & 0xFF); + pcPacket[s32PktLen++] = (WILC_Uint8)((pstrWID->u16WIDid >> 8) & 0xFF); + + if (g_oper_mode == SET_CFG) { + /* Message Length */ + u16MsgLen = MAC_ADDR_LEN; + + /* Length */ + pcPacket[s32PktLen++] = (WILC_Uint8)u16MsgLen; + + /* Value */ + extract_mac_addr(pu8val, pcPacket + s32PktLen); + s32PktLen += u16MsgLen; + } + *ps32PktLen = s32PktLen; +} + +/*****************************************************************************/ +/* */ +/* Function Name : ProcessBinWid */ +/* */ +/* Description : This function processes a WID of type WID_BIN_DATA and */ +/* updates the cfg packet with the supplied value. */ +/* */ +/* Inputs : 1) Pointer to WID cfg structure */ +/* 2) Name of file containing the binary data in text mode */ +/* */ +/* Globals : */ +/* */ +/* Processing : The binary data is expected to be supplied through a */ +/* file in text mode. This file is expected to be in the */ +/* finject format. It is parsed, converted to binary format */ +/* and copied into g_cfg_pkt for further processing. This */ +/* is obviously a round-about way of processing involving */ +/* multiple (re)conversions between bin & ascii formats. */ +/* But it is done nevertheless to retain uniformity and for */ +/* ease of debugging. */ +/* */ +/* Outputs : None */ +/* */ +/* Returns : None */ +/* */ + +/* Issues : None */ +/* */ +/* Revision History: */ +/* */ +/* DD MM YYYY Author(s) Changes (Describe the changes made) */ +/* 08 01 2008 Ittiam Draft */ +/* */ +/*****************************************************************************/ + +void ProcessBinWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, + tstrWID *pstrWID, WILC_Uint8 *pu8val, WILC_Sint32 s32ValueSize) +{ + /* WILC_ERROR("processing Binary WIDs is not supported \n"); */ + + WILC_Uint16 u16MsgLen = 0; + WILC_Uint16 idx = 0; + WILC_Sint32 s32PktLen = *ps32PktLen; + WILC_Uint8 u8checksum = 0; + + if (pstrWID == NULL) { + PRINT_WRN(CORECONFIG_DBG, "Can't set BIN val, NULL structure\n"); + return; + } + + /* WID */ + pcPacket[s32PktLen++] = (WILC_Uint8)(pstrWID->u16WIDid & 0xFF); + pcPacket[s32PktLen++] = (WILC_Uint8)((pstrWID->u16WIDid >> 8) & 0xFF); + + if (g_oper_mode == SET_CFG) { + /* Message Length */ + u16MsgLen = (WILC_Uint16)s32ValueSize; + + /* Length */ + /* pcPacket[s32PktLen++] = (WILC_Uint8)u16MsgLen; */ + pcPacket[s32PktLen++] = (WILC_Uint8)(u16MsgLen & 0xFF); + pcPacket[s32PktLen++] = (WILC_Uint8)((u16MsgLen >> 8) & 0xFF); + + /* Value */ + for (idx = 0; idx < u16MsgLen; idx++) + pcPacket[s32PktLen++] = pu8val[idx]; + + /* checksum */ + for (idx = 0; idx < u16MsgLen; idx++) + u8checksum += pcPacket[MSG_HEADER_LEN + idx + 4]; + + pcPacket[s32PktLen++] = u8checksum; + } + *ps32PktLen = s32PktLen; +} + + +/*****************************************************************************/ +/* */ +/* Function Name : further_process_response */ +/* */ +/* Description : This function parses the response frame got from the */ +/* device. */ +/* */ +/* Inputs : 1) The received response frame */ +/* 2) WID */ +/* 3) WID Length */ +/* 4) Output file handle */ +/* 5) Process Wid Number(i.e wid from --widn switch) */ +/* 6) Index the array in the Global Wid Structure. */ +/* */ +/* Globals : g_wid_num, gastrWIDs */ +/* */ +/* Processing : This function parses the response of the device depending*/ +/* WID type and writes it to the output file in Hex or */ +/* decimal notation depending on the --getx or --get switch.*/ +/* */ +/* Outputs : None */ +/* */ +/* Returns : 0 on Success & -2 on Failure */ +/* */ +/* Issues : None */ +/* */ +/* Revision History: */ +/* */ +/* DD MM YYYY Author(s) Changes (Describe the changes made) */ +/* 08 01 2009 Ittiam Draft */ +/* */ +/*****************************************************************************/ + +WILC_Sint32 further_process_response(WILC_Uint8 *resp, + WILC_Uint16 u16WIDid, + WILC_Uint16 cfg_len, + WILC_Bool process_wid_num, + WILC_Uint32 cnt, + tstrWID *pstrWIDresult) +{ + WILC_Uint32 retval = 0; + WILC_Uint32 idx = 0; + WILC_Uint8 cfg_chr = 0; + WILC_Uint16 cfg_sht = 0; + WILC_Uint32 cfg_int = 0; + WILC_Uint8 cfg_str[256] = {0}; + tenuWIDtype enuWIDtype = WID_UNDEF; + + if (process_wid_num) { + enuWIDtype = get_wid_type(g_wid_num); + } else { + enuWIDtype = gastrWIDs[cnt].enuWIDtype; + } + + + switch (enuWIDtype) { + case WID_CHAR: + cfg_chr = resp[idx]; + /*Set local copy of WID*/ + *(pstrWIDresult->ps8WidVal) = cfg_chr; + break; + + case WID_SHORT: + { + WILC_Uint16 *pu16val = (WILC_Uint16 *)(pstrWIDresult->ps8WidVal); + cfg_sht = MAKE_WORD16(resp[idx], resp[idx + 1]); + /*Set local copy of WID*/ + /* pstrWIDresult->ps8WidVal = (WILC_Sint8*)(WILC_Sint32)cfg_sht; */ + *pu16val = cfg_sht; + break; + } + + case WID_INT: + { + WILC_Uint32 *pu32val = (WILC_Uint32 *)(pstrWIDresult->ps8WidVal); + cfg_int = MAKE_WORD32( + MAKE_WORD16(resp[idx], resp[idx + 1]), + MAKE_WORD16(resp[idx + 2], resp[idx + 3]) + ); + /*Set local copy of WID*/ + /* pstrWIDresult->ps8WidVal = (WILC_Sint8*)cfg_int; */ + *pu32val = cfg_int; + break; + } + + case WID_STR: + WILC_memcpy(cfg_str, resp + idx, cfg_len); + /* cfg_str[cfg_len] = '\0'; //mostafa: no need currently for NULL termination */ + if (process_wid_num) { + /*fprintf(out_file,"0x%4.4x = %s\n",g_wid_num, + * cfg_str);*/ + } else { + /*fprintf(out_file,"%s = %s\n",gastrWIDs[cnt].cfg_switch, + * cfg_str);*/ + } + + if (pstrWIDresult->s32ValueSize >= cfg_len) { + WILC_memcpy(pstrWIDresult->ps8WidVal, cfg_str, cfg_len); /* mostafa: no need currently for the extra NULL byte */ + pstrWIDresult->s32ValueSize = cfg_len; + } else { + PRINT_ER("allocated WID buffer length is smaller than the received WID Length \n"); + retval = -2; + } + + break; + + case WID_ADR: + create_mac_addr(cfg_str, resp + idx); + + WILC_strncpy(pstrWIDresult->ps8WidVal, cfg_str, WILC_strlen(cfg_str)); + pstrWIDresult->ps8WidVal[WILC_strlen(cfg_str)] = '\0'; + if (process_wid_num) { + /*fprintf(out_file,"0x%4.4x = %s\n",g_wid_num, + * cfg_str);*/ + } else { + /*fprintf(out_file,"%s = %s\n",gastrWIDs[cnt].cfg_switch, + * cfg_str);*/ + } + break; + + case WID_IP: + cfg_int = MAKE_WORD32( + MAKE_WORD16(resp[idx], resp[idx + 1]), + MAKE_WORD16(resp[idx + 2], resp[idx + 3]) + ); + conv_int_to_ip(cfg_str, cfg_int); + if (process_wid_num) { + /*fprintf(out_file,"0x%4.4x = %s\n",g_wid_num, + * cfg_str);*/ + } else { + /*fprintf(out_file,"%s = %s\n",gastrWIDs[cnt].cfg_switch, + * cfg_str);*/ + } + break; + + case WID_BIN_DATA: + #if 0 + /* FILE *fp_bin = NULL; */ + WILC_Uint8 first_bin_wid = 1; + if (first_bin_wid) { + /* fp_bin = fopen("wid_response.bin","wb"); */ + first_bin_wid = 0; + } else { + /* fp_bin = fopen("wid_response.bin","ab"); */ + } + + if (/*fp_bin == NULL*/ 0) { + PRINT_ER("Error: Could not open wid_response.bin for write\n"); + return -2; + } + + /* fwrite(resp + idx, cfg_len, 1, fp_bin); */ + + /* fclose(fp_bin); */ + #endif + + if (pstrWIDresult->s32ValueSize >= cfg_len) { + WILC_memcpy(pstrWIDresult->ps8WidVal, resp + idx, cfg_len); + pstrWIDresult->s32ValueSize = cfg_len; + } else { + PRINT_ER("Allocated WID buffer length is smaller than the received WID Length Err(%d)\n", retval); + retval = -2; + } + break; + + default: + PRINT_ER("ERROR: Check config database: Error(%d)\n", retval); + retval = -2; + break; + } + + return retval; +} + +/*****************************************************************************/ +/* */ +/* Function Name : ParseResponse */ +/* */ +/* Description : This function parses the command-line options and */ +/* creates the config packets which can be sent to the WLAN */ +/* station. */ +/* */ +/* Inputs : 1) The received response frame */ +/* */ +/* Globals : g_opt_list, gastrWIDs */ +/* */ +/* Processing : This function parses the options and creates different */ +/* types of packets depending upon the WID-type */ +/* corresponding to the option. */ +/* */ +/* Outputs : None */ +/* */ +/* Returns : 0 on Success & -1 on Failure */ +/* */ +/* Issues : None */ +/* */ +/* Revision History: */ +/* */ +/* DD MM YYYY Author(s) Changes (Describe the changes made) */ +/* 08 01 2008 Ittiam Draft */ +/* */ +/*****************************************************************************/ + +WILC_Sint32 ParseResponse(WILC_Uint8 *resp, tstrWID *pstrWIDcfgResult) +{ + WILC_Uint16 u16RespLen = 0; + WILC_Uint16 u16WIDid = 0; + WILC_Uint16 cfg_len = 0; + tenuWIDtype enuWIDtype = WID_UNDEF; + WILC_Bool num_wid_processed = WILC_FALSE; + WILC_Uint32 cnt = 0; + WILC_Uint32 idx = 0; + WILC_Uint32 ResCnt = 0; + /* Check whether the received frame is a valid response */ + if (RESP_MSG_TYPE != resp[0]) { + PRINT_INFO(CORECONFIG_DBG, "Received Message format incorrect.\n"); + return -1; + } + + /* Extract Response Length */ + u16RespLen = MAKE_WORD16(resp[2], resp[3]); + Res_Len = u16RespLen; + + for (idx = MSG_HEADER_LEN; idx < u16RespLen; ) { + u16WIDid = MAKE_WORD16(resp[idx], resp[idx + 1]); + cfg_len = resp[idx + 2]; + /* Incase of Bin Type Wid, the length is given by two byte field */ + enuWIDtype = get_wid_type(u16WIDid); + if (WID_BIN_DATA == enuWIDtype) { + cfg_len |= ((WILC_Uint16)resp[idx + 3] << 8) & 0xFF00; + idx++; + } + idx += 3; + if ((u16WIDid == g_wid_num) && (num_wid_processed == WILC_FALSE)) { + num_wid_processed = WILC_TRUE; + + if (-2 == further_process_response(&resp[idx], u16WIDid, cfg_len, WILC_TRUE, 0, &pstrWIDcfgResult[ResCnt])) { + return -2; + } + ResCnt++; + } else { + for (cnt = 0; cnt < g_num_total_switches; cnt++) { + if (gastrWIDs[cnt].u16WIDid == u16WIDid) { + if (-2 == further_process_response(&resp[idx], u16WIDid, cfg_len, WILC_FALSE, cnt, + &pstrWIDcfgResult[ResCnt])) { + return -2; + } + ResCnt++; + } + } + } + idx += cfg_len; + /* In case if BIN type Wid, The last byte of the Cfg packet is the */ + /* Checksum. The WID Length field does not accounts for the checksum. */ + /* The Checksum is discarded. */ + if (WID_BIN_DATA == enuWIDtype) { + idx++; + } + } + + return 0; +} + +/** + * @brief parses the write response [just detects its status: success or failure] + * @details + * @param[in] pu8RespBuffer The Response to be parsed + * @return Error code indicating Write Operation status: + * WRITE_RESP_SUCCESS (1) => Write Success. + * WILC_FAIL (-100) => Write Failure. + * @note + * @author Ittiam + * @date 11 Aug 2009 + * @version 1.0 + */ + +WILC_Sint32 ParseWriteResponse(WILC_Uint8 *pu8RespBuffer) +{ + WILC_Sint32 s32Error = WILC_FAIL; + WILC_Uint16 u16RespLen = 0; + WILC_Uint16 u16WIDtype = (WILC_Uint16)WID_NIL; + + /* Check whether the received frame is a valid response */ + if (RESP_MSG_TYPE != pu8RespBuffer[0]) { + PRINT_ER("Received Message format incorrect.\n"); + return WILC_FAIL; + } + + /* Extract Response Length */ + u16RespLen = MAKE_WORD16(pu8RespBuffer[2], pu8RespBuffer[3]); + + u16WIDtype = MAKE_WORD16(pu8RespBuffer[4], pu8RespBuffer[5]); + + /* Check for WID_STATUS ID and then check the length and status value */ + if ((u16WIDtype == WID_STATUS) && + (pu8RespBuffer[6] == 1) && + (pu8RespBuffer[7] == WRITE_RESP_SUCCESS)) { + s32Error = WRITE_RESP_SUCCESS; + return s32Error; + } + + /* If the length or status are not as expected return failure */ + s32Error = WILC_FAIL; + return s32Error; + +} + +/** + * @brief creates the header of the Configuration Packet + * @details + * @param[in,out] pcpacket The Configuration Packet + * @param[in,out] ps32PacketLength Length of the Configuration Packet + * @return Error code indicating success/failure + * @note + * @author aismail + * @date 18 Feb 2012 + * @version 1.0 + */ + +WILC_Sint32 CreatePacketHeader(WILC_Char *pcpacket, WILC_Sint32 *ps32PacketLength) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + WILC_Uint16 u16MsgLen = (WILC_Uint16)(*ps32PacketLength); + WILC_Uint16 u16MsgInd = 0; + + /* The format of the message is: */ + /* +-------------------------------------------------------------------+ */ + /* | Message Type | Message ID | Message Length |Message body | */ + /* +-------------------------------------------------------------------+ */ + /* | 1 Byte | 1 Byte | 2 Bytes | Message Length - 4 | */ + /* +-------------------------------------------------------------------+ */ + + /* The format of a message body of a message type 'W' is: */ + /* +-------------------------------------------------------------------+ */ + /* | WID0 | WID0 Length | WID0 Value | ......................... | */ + /* +-------------------------------------------------------------------+ */ + /* | 2 Bytes | 1 Byte | WID0 Length | ......................... | */ + /* +-------------------------------------------------------------------+ */ + + + + /* Message Type */ + if (g_oper_mode == SET_CFG) + pcpacket[u16MsgInd++] = WRITE_MSG_TYPE; + else + pcpacket[u16MsgInd++] = QUERY_MSG_TYPE; + + /* Sequence Number */ + pcpacket[u16MsgInd++] = g_seqno++; + + /* Message Length */ + pcpacket[u16MsgInd++] = (WILC_Uint8)(u16MsgLen & 0xFF); + pcpacket[u16MsgInd++] = (WILC_Uint8)((u16MsgLen >> 8) & 0xFF); + + *ps32PacketLength = u16MsgLen; + + return s32Error; +} + +/** + * @brief creates Configuration packet based on the Input WIDs + * @details + * @param[in] pstrWIDs WIDs to be sent in the configuration packet + * @param[in] u32WIDsCount number of WIDs to be sent in the configuration packet + * @param[out] ps8packet The created Configuration Packet + * @param[out] ps32PacketLength Length of the created Configuration Packet + * @return Error code indicating success/failure + * @note + * @author + * @date 1 Mar 2012 + * @version 1.0 + */ + +WILC_Sint32 CreateConfigPacket(WILC_Sint8 *ps8packet, WILC_Sint32 *ps32PacketLength, + tstrWID *pstrWIDs, WILC_Uint32 u32WIDsCount) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + WILC_Uint32 u32idx = 0; + *ps32PacketLength = MSG_HEADER_LEN; + for (u32idx = 0; u32idx < u32WIDsCount; u32idx++) { + switch (pstrWIDs[u32idx].enuWIDtype) { + case WID_CHAR: + ProcessCharWid(ps8packet, ps32PacketLength, &pstrWIDs[u32idx], + pstrWIDs[u32idx].ps8WidVal); + break; + + case WID_SHORT: + ProcessShortWid(ps8packet, ps32PacketLength, &pstrWIDs[u32idx], + pstrWIDs[u32idx].ps8WidVal); + break; + + case WID_INT: + ProcessIntWid(ps8packet, ps32PacketLength, &pstrWIDs[u32idx], + pstrWIDs[u32idx].ps8WidVal); + break; + + case WID_STR: + ProcessStrWid(ps8packet, ps32PacketLength, &pstrWIDs[u32idx], + pstrWIDs[u32idx].ps8WidVal, pstrWIDs[u32idx].s32ValueSize); + break; + + #if 0 + case WID_ADR: + ProcessAdrWid(ps8packet, ps32PacketLength, &pstrWIDs[u32idx], + pstrWIDs[u32idx].ps8WidVal); + break; + + #endif + case WID_IP: + ProcessIPwid(ps8packet, ps32PacketLength, &pstrWIDs[u32idx], + pstrWIDs[u32idx].ps8WidVal); + break; + + case WID_BIN_DATA: + ProcessBinWid(ps8packet, ps32PacketLength, &pstrWIDs[u32idx], + pstrWIDs[u32idx].ps8WidVal, pstrWIDs[u32idx].s32ValueSize); + break; + + default: + PRINT_ER("ERROR: Check Config database\n"); + } + } + + CreatePacketHeader(ps8packet, ps32PacketLength); + + return s32Error; +} + +WILC_Sint32 ConfigWaitResponse(WILC_Char *pcRespBuffer, WILC_Sint32 s32MaxRespBuffLen, WILC_Sint32 *ps32BytesRead, + WILC_Bool bRespRequired) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + /*bug 3878*/ + /*removed to caller function*/ + /*gstrConfigPktInfo.pcRespBuffer = pcRespBuffer; + * gstrConfigPktInfo.s32MaxRespBuffLen = s32MaxRespBuffLen; + * gstrConfigPktInfo.bRespRequired = bRespRequired;*/ + + + if (gstrConfigPktInfo.bRespRequired == WILC_TRUE) { + WILC_SemaphoreAcquire(&SemHandlePktResp, WILC_NULL); + + *ps32BytesRead = gstrConfigPktInfo.s32BytesRead; + } + + WILC_memset((void *)(&gstrConfigPktInfo), 0, sizeof(tstrConfigPktInfo)); + + return s32Error; +} + +/** + * @brief sends certain Configuration Packet based on the input WIDs pstrWIDs + * and retrieves the packet response pu8RxResp + * @details + * @param[in] pstrWIDs WIDs to be sent in the configuration packet + * @param[in] u32WIDsCount number of WIDs to be sent in the configuration packet + * @param[out] pu8RxResp The received Packet Response + * @param[out] ps32RxRespLen Length of the received Packet Response + * @return Error code indicating success/failure + * @note + * @author mabubakr + * @date 1 Mar 2012 + * @version 1.0 + */ +#ifdef SIMULATION +WILC_Sint32 SendConfigPkt(WILC_Uint8 u8Mode, tstrWID *pstrWIDs, + WILC_Uint32 u32WIDsCount, WILC_Bool bRespRequired, WILC_Uint32 drvHandler) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + WILC_Sint32 err = WILC_SUCCESS; + WILC_Sint32 s32ConfigPacketLen = 0; + WILC_Sint32 s32RcvdRespLen = 0; + + WILC_SemaphoreAcquire(&SemHandleSendPkt, WILC_NULL); + + /*set the packet mode*/ + g_oper_mode = u8Mode; + + WILC_memset((void *)gps8ConfigPacket, 0, MAX_PACKET_BUFF_SIZE); + + if (CreateConfigPacket(gps8ConfigPacket, &s32ConfigPacketLen, pstrWIDs, u32WIDsCount) != WILC_SUCCESS) { + s32Error = WILC_FAIL; + goto End_ConfigPkt; + } + /*bug 3878*/ + gstrConfigPktInfo.pcRespBuffer = gps8ConfigPacket; + gstrConfigPktInfo.s32MaxRespBuffLen = MAX_PACKET_BUFF_SIZE; + PRINT_INFO(CORECONFIG_DBG, "GLOBAL =bRespRequired =%d\n", bRespRequired); + gstrConfigPktInfo.bRespRequired = bRespRequired; + + s32Error = SendRawPacket(gps8ConfigPacket, s32ConfigPacketLen); + if (s32Error != WILC_SUCCESS) { + goto End_ConfigPkt; + } + + WILC_memset((void *)gps8ConfigPacket, 0, MAX_PACKET_BUFF_SIZE); + + ConfigWaitResponse(gps8ConfigPacket, MAX_PACKET_BUFF_SIZE, &s32RcvdRespLen, bRespRequired); + + + if (bRespRequired == WILC_TRUE) { + /* If the operating Mode is GET, then we expect a response frame from */ + /* the driver. Hence start listening to the port for response */ + if (g_oper_mode == GET_CFG) { + #if 1 + err = ParseResponse(gps8ConfigPacket, pstrWIDs); + if (err != 0) { + s32Error = WILC_FAIL; + goto End_ConfigPkt; + } else { + s32Error = WILC_SUCCESS; + } + #endif + } else { + err = ParseWriteResponse(gps8ConfigPacket); + if (err != WRITE_RESP_SUCCESS) { + s32Error = WILC_FAIL; + goto End_ConfigPkt; + } else { + s32Error = WILC_SUCCESS; + } + } + + + } + + +End_ConfigPkt: + WILC_SemaphoreRelease(&SemHandleSendPkt, WILC_NULL); + + return s32Error; +} +#endif +WILC_Sint32 ConfigProvideResponse(WILC_Char *pcRespBuffer, WILC_Sint32 s32RespLen) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + + if (gstrConfigPktInfo.bRespRequired == WILC_TRUE) { + if (s32RespLen <= gstrConfigPktInfo.s32MaxRespBuffLen) { + WILC_memcpy(gstrConfigPktInfo.pcRespBuffer, pcRespBuffer, s32RespLen); + gstrConfigPktInfo.s32BytesRead = s32RespLen; + } else { + WILC_memcpy(gstrConfigPktInfo.pcRespBuffer, pcRespBuffer, gstrConfigPktInfo.s32MaxRespBuffLen); + gstrConfigPktInfo.s32BytesRead = gstrConfigPktInfo.s32MaxRespBuffLen; + PRINT_ER("BusProvideResponse() Response greater than the prepared Buffer Size \n"); + } + + WILC_SemaphoreRelease(&SemHandlePktResp, WILC_NULL); + } + + return s32Error; +} + +/** + * @brief writes the received packet pu8RxPacket in the global Rx FIFO buffer + * @details + * @param[in] pu8RxPacket The received packet + * @param[in] s32RxPacketLen Length of the received packet + * @return Error code indicating success/failure + * @note + * + * @author mabubakr + * @date 1 Mar 2012 + * @version 1.0 + */ + +WILC_Sint32 ConfigPktReceived(WILC_Uint8 *pu8RxPacket, WILC_Sint32 s32RxPacketLen) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + WILC_Uint8 u8MsgType = 0; + + u8MsgType = pu8RxPacket[0]; + + switch (u8MsgType) { + case 'R': + ConfigProvideResponse(pu8RxPacket, s32RxPacketLen); + + break; + + case 'N': + PRINT_INFO(CORECONFIG_DBG, "NetworkInfo packet received\n"); + NetworkInfoReceived(pu8RxPacket, s32RxPacketLen); + break; + + case 'I': + GnrlAsyncInfoReceived(pu8RxPacket, s32RxPacketLen); + break; + + case 'S': + host_int_ScanCompleteReceived(pu8RxPacket, s32RxPacketLen); + break; + + default: + PRINT_ER("ConfigPktReceived(): invalid received msg type at the Core Configurator \n"); + break; + } + + return s32Error; +} + +/** + * @brief Deinitializes the Core Configurator + * @details + * @return Error code indicating success/failure + * @note + * @author mabubakr + * @date 1 Mar 2012 + * @version 1.0 + */ + +WILC_Sint32 CoreConfiguratorDeInit(void) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + + PRINT_D(CORECONFIG_DBG, "CoreConfiguratorDeInit() \n"); + + + WILC_SemaphoreDestroy(&SemHandleSendPkt, WILC_NULL); + WILC_SemaphoreDestroy(&SemHandlePktResp, WILC_NULL); + + + if (gps8ConfigPacket != NULL) { + + WILC_FREE(gps8ConfigPacket); + gps8ConfigPacket = NULL; + } + + return s32Error; +} + + +#ifndef SIMULATION +#if WILC_PLATFORM != WILC_WIN32 +/*Using the global handle of the driver*/ +extern wilc_wlan_oup_t *gpstrWlanOps; +/** + * @brief sends certain Configuration Packet based on the input WIDs pstrWIDs + * using driver config layer + * + * @details + * @param[in] pstrWIDs WIDs to be sent in the configuration packet + * @param[in] u32WIDsCount number of WIDs to be sent in the configuration packet + * @param[out] pu8RxResp The received Packet Response + * @param[out] ps32RxRespLen Length of the received Packet Response + * @return Error code indicating success/failure + * @note + * @author mabubakr + * @date 1 Mar 2012 + * @version 1.0 + */ +WILC_Sint32 SendConfigPkt(WILC_Uint8 u8Mode, tstrWID *pstrWIDs, + WILC_Uint32 u32WIDsCount, WILC_Bool bRespRequired, WILC_Uint32 drvHandler) +{ + WILC_Sint32 counter = 0, ret = 0; + if (gpstrWlanOps == NULL) { + PRINT_D(CORECONFIG_DBG, "Net Dev is still not initialized\n"); + return 1; + } else { + PRINT_D(CORECONFIG_DBG, "Net Dev is initialized\n"); + } + if (gpstrWlanOps->wlan_cfg_set == NULL || + gpstrWlanOps->wlan_cfg_get == NULL) { + PRINT_D(CORECONFIG_DBG, "Set and Get is still not initialized\n"); + return 1; + } else { + PRINT_D(CORECONFIG_DBG, "SET is initialized\n"); + } + if (u8Mode == GET_CFG) { + for (counter = 0; counter < u32WIDsCount; counter++) { + PRINT_INFO(CORECONFIG_DBG, "Sending CFG packet [%d][%d]\n", !counter, + (counter == u32WIDsCount - 1)); + if (!gpstrWlanOps->wlan_cfg_get(!counter, + pstrWIDs[counter].u16WIDid, + (counter == u32WIDsCount - 1), drvHandler)) { + ret = -1; + printk("[Sendconfigpkt]Get Timed out\n"); + break; + } + } + /** + * get the value + **/ + /* WILC_Sleep(1000); */ + counter = 0; + for (counter = 0; counter < u32WIDsCount; counter++) { + pstrWIDs[counter].s32ValueSize = gpstrWlanOps->wlan_cfg_get_value( + pstrWIDs[counter].u16WIDid, + pstrWIDs[counter].ps8WidVal, pstrWIDs[counter].s32ValueSize); + + } + } else if (u8Mode == SET_CFG) { + for (counter = 0; counter < u32WIDsCount; counter++) { + PRINT_D(CORECONFIG_DBG, "Sending config SET PACKET WID:%x\n", pstrWIDs[counter].u16WIDid); + if (!gpstrWlanOps->wlan_cfg_set(!counter, + pstrWIDs[counter].u16WIDid, pstrWIDs[counter].ps8WidVal, + pstrWIDs[counter].s32ValueSize, + (counter == u32WIDsCount - 1), drvHandler)) { + ret = -1; + printk("[Sendconfigpkt]Set Timed out\n"); + break; + } + } + } + + return ret; +} +#endif +#endif diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h new file mode 100644 index 000000000000..9cdfa2ac8fca --- /dev/null +++ b/drivers/staging/wilc1000/coreconfigurator.h @@ -0,0 +1,498 @@ + +/*! + * @file coreconfigurator.h + * @brief + * @author + * @sa coreconfigurator.c + * @date 1 Mar 2012 + * @version 1.0 + */ + + +#ifndef CORECONFIGURATOR_H +#define CORECONFIGURATOR_H + +#include "wilc_oswrapper.h" +#include "wilc_wlan_if.h" +/*****************************************************************************/ +/* Constants */ +/*****************************************************************************/ +/* Number of WID Options Supported */ +#define NUM_BASIC_SWITCHES 45 +#define NUM_FHSS_SWITCHES 0 + +#define NUM_RSSI 5 + +#ifdef MAC_802_11N +#define NUM_11N_BASIC_SWITCHES 25 +#define NUM_11N_HUT_SWITCHES 47 +#else /* MAC_802_11N */ +#define NUM_11N_BASIC_SWITCHES 0 +#define NUM_11N_HUT_SWITCHES 0 +#endif /* MAC_802_11N */ + +extern WILC_Uint16 g_num_total_switches; + +#define MAC_HDR_LEN 24 /* No Address4 - non-ESS */ +#define MAX_SSID_LEN 33 +#define FCS_LEN 4 +#define TIME_STAMP_LEN 8 +#define BEACON_INTERVAL_LEN 2 +#define CAP_INFO_LEN 2 +#define STATUS_CODE_LEN 2 +#define AID_LEN 2 +#define IE_HDR_LEN 2 + + +/* Operating Mode: SET */ +#define SET_CFG 0 +/* Operating Mode: GET */ +#define GET_CFG 1 + +#define MAX_PACKET_BUFF_SIZE 1596 + +#define MAX_STRING_LEN 256 +#define MAX_SURVEY_RESULT_FRAG_SIZE MAX_STRING_LEN +#define SURVEY_RESULT_LENGTH 44 +#define MAX_ASSOC_RESP_FRAME_SIZE MAX_STRING_LEN + +#define STATUS_MSG_LEN 12 +#define MAC_CONNECTED 1 +#define MAC_DISCONNECTED 0 + + + +/*****************************************************************************/ +/* Function Macros */ +/*****************************************************************************/ +#define MAKE_WORD16(lsb, msb) ((((WILC_Uint16)(msb) << 8) & 0xFF00) | (lsb)) +#define MAKE_WORD32(lsw, msw) ((((WILC_Uint32)(msw) << 16) & 0xFFFF0000) | (lsw)) + + +/*****************************************************************************/ +/* Type Definitions */ +/*****************************************************************************/ +/* WID Data Types */ +#if 0 +typedef enum { + WID_CHAR = 0, + WID_SHORT = 1, + WID_INT = 2, + WID_STR = 3, + WID_ADR = 4, + WID_BIN = 5, + WID_IP = 6, + WID_UNDEF = 7, + WID_TYPE_FORCE_32BIT = 0xFFFFFFFF +} tenuWIDtype; + +/* WLAN Identifiers */ +typedef enum { + WID_NIL = -1, + /* EMAC Character WID list */ + WID_BSS_TYPE = 0x0000, + WID_CURRENT_TX_RATE = 0x0001, + WID_CURRENT_CHANNEL = 0x0002, + WID_PREAMBLE = 0x0003, + WID_11G_OPERATING_MODE = 0x0004, + WID_STATUS = 0x0005, + WID_11G_PROT_MECH = 0x0006, + WID_SCAN_TYPE = 0x0007, + WID_PRIVACY_INVOKED = 0x0008, + WID_KEY_ID = 0x0009, + WID_QOS_ENABLE = 0x000A, + WID_POWER_MANAGEMENT = 0x000B, + WID_11I_MODE = 0x000C, + WID_AUTH_TYPE = 0x000D, + WID_SITE_SURVEY = 0x000E, + WID_LISTEN_INTERVAL = 0x000F, + WID_DTIM_PERIOD = 0x0010, + WID_ACK_POLICY = 0x0011, + WID_RESET = 0x0012, + WID_PCF_MODE = 0x0013, + WID_CFP_PERIOD = 0x0014, + WID_BCAST_SSID = 0x0015, + WID_PHY_TEST_PATTERN = 0x0016, + WID_DISCONNECT = 0x0016, + WID_READ_ADDR_SDRAM = 0x0017, + WID_TX_POWER_LEVEL_11A = 0x0018, + WID_REKEY_POLICY = 0x0019, + WID_SHORT_SLOT_ALLOWED = 0x001A, + WID_PHY_ACTIVE_REG = 0x001B, + WID_PHY_ACTIVE_REG_VAL = 0x001C, + WID_TX_POWER_LEVEL_11B = 0x001D, + WID_START_SCAN_REQ = 0x001E, + WID_RSSI = 0x001F, + WID_JOIN_REQ = 0x0020, + WID_ANTENNA_SELECTION = 0x0021, + WID_USER_CONTROL_ON_TX_POWER = 0x0027, + WID_MEMORY_ACCESS_8BIT = 0x0029, + WID_UAPSD_SUPPORT_AP = 0x002A, + WID_CURRENT_MAC_STATUS = 0x0031, + WID_AUTO_RX_SENSITIVITY = 0x0032, + WID_DATAFLOW_CONTROL = 0x0033, + WID_SCAN_FILTER = 0x0036, + WID_LINK_LOSS_THRESHOLD = 0x0037, + WID_AUTORATE_TYPE = 0x0038, + WID_CCA_THRESHOLD = 0x0039, + WID_802_11H_DFS_MODE = 0x003B, + WID_802_11H_TPC_MODE = 0x003C, + WID_DEVICE_READY = 0x003D, + WID_PM_NULL_FRAME_INTERVAL = 0x003E, + WID_PM_ACTIVITY_TIMER = 0x003F, + WID_PM_NULL_FRAME_WAIT_ENABLE = 0x0040, + WID_SCAN_WAIT_TIME = 0x0041, + WID_WSC_IE_EN = 0x0042, + WID_WPS_START = 0x0043, + WID_WPS_DEV_MODE = 0x0044, + WID_BT_COEXISTENCE = 0x0050, + WID_TRACKING_ROAMING = 0x0070, + WID_NUM_PKTS_FOR_RSSI_AVG = 0x0071, + WID_FHSS_SCAN_CHAN_INDEX = 0x0072, + WID_FHSS_SCAN_STEP_INDEX = 0x0073, + + /* NMAC Character WID list */ + WID_11N_PROT_MECH = 0x0080, + WID_11N_ERP_PROT_TYPE = 0x0081, + WID_11N_ENABLE = 0x0082, + WID_11N_OPERATING_MODE = 0x0083, + WID_11N_OBSS_NONHT_DETECTION = 0x0084, + WID_11N_HT_PROT_TYPE = 0x0085, + WID_11N_RIFS_PROT_ENABLE = 0x0086, + WID_11N_SMPS_MODE = 0x0087, + WID_11N_CURRENT_TX_MCS = 0x0088, + WID_11N_PRINT_STATS = 0x0089, + WID_HUT_FCS_CORRUPT_MODE = 0x008A, + WID_HUT_RESTART = 0x008B, + WID_HUT_TX_FORMAT = 0x008C, + WID_11N_SHORT_GI_20MHZ_ENABLE = 0x008D, + WID_HUT_BANDWIDTH = 0x008E, + WID_HUT_OP_BAND = 0x008F, + WID_HUT_STBC = 0x0090, + WID_HUT_ESS = 0x0091, + WID_HUT_ANTSET = 0x0092, + WID_HUT_HT_OP_MODE = 0x0093, + WID_HUT_RIFS_MODE = 0x0094, + WID_HUT_SMOOTHING_REC = 0x0095, + WID_HUT_SOUNDING_PKT = 0x0096, + WID_HUT_HT_CODING = 0x0097, + WID_HUT_TEST_DIR = 0x0098, + WID_HUT_CAPTURE_MODE = 0x0099, + WID_HUT_PHY_TEST_MODE = 0x009A, + WID_HUT_PHY_TEST_RATE_HI = 0x009B, + WID_HUT_PHY_TEST_RATE_LO = 0x009C, + WID_HUT_DISABLE_RXQ_REPLENISH = 0x009D, + WID_HUT_KEY_ORIGIN = 0x009E, + WID_HUT_BCST_PERCENT = 0x009F, + WID_HUT_GROUP_CIPHER_TYPE = 0x00A0, + WID_TX_ABORT_CONFIG = 0x00A1, + WID_HOST_DATA_IF_TYPE = 0x00A2, + WID_HOST_CONFIG_IF_TYPE = 0x00A3, + WID_HUT_TSF_TEST_MODE = 0x00A4, + WID_HUT_TSSI_VALUE = 0x00A5, + WID_HUT_PKT_TSSI_VALUE = 0x00A5, + WID_REG_TSSI_11B_VALUE = 0x00A6, + WID_REG_TSSI_11G_VALUE = 0x00A7, + WID_REG_TSSI_11N_VALUE = 0x00A8, + WID_TX_CALIBRATION = 0x00A9, + WID_DSCR_TSSI_11B_VALUE = 0x00AA, + WID_DSCR_TSSI_11G_VALUE = 0x00AB, + WID_DSCR_TSSI_11N_VALUE = 0x00AC, + WID_HUT_RSSI_EX = 0x00AD, + WID_HUT_ADJ_RSSI_EX = 0x00AE, + WID_11N_IMMEDIATE_BA_ENABLED = 0x00AF, + WID_11N_TXOP_PROT_DISABLE = 0x00B0, + WID_TX_POWER_LEVEL_11N = 0x00B1, + WID_HUT_MGMT_PERCENT = 0x00B3, + WID_HUT_MGMT_BCST_PERCENT = 0x00B4, + WID_HUT_MGMT_ALLOW_HT = 0x00B5, + WID_HUT_UC_MGMT_TYPE = 0x00B6, + WID_HUT_BC_MGMT_TYPE = 0x00B7, + WID_HUT_11W_MFP_REQUIRED_TX = 0x00B8, + WID_HUT_11W_MFP_PEER_CAPABLE = 0x00B9, + WID_HUT_11W_TX_IGTK_ID = 0x00BA, + WID_11W_ENABLE = 0x00BB, + WID_11W_MGMT_PROT_REQ = 0x00BC, + WID_USER_SEC_CHANNEL_OFFSET = 0x00C0, + WID_2040_COEXISTENCE = 0x00C1, + WID_HUT_FC_TXOP_MOD = 0x00C2, + WID_HUT_FC_PROT_TYPE = 0x00C3, + WID_HUT_SEC_CCA_ASSERT = 0x00C4, + WID_2040_ENABLE = 0x00C5, + WID_2040_CURR_CHANNEL_OFFSET = 0x00C6, + WID_2040_40MHZ_INTOLERANT = 0x00C7, + + + /* Custom Character WID list */ + WID_POWER_SAVE = 0x0100, + WID_WAKE_STATUS = 0x0101, + WID_WAKE_CONTROL = 0x0102, + WID_CCA_BUSY_START = 0x0103, + + /* EMAC Short WID list */ + WID_RTS_THRESHOLD = 0x1000, + WID_FRAG_THRESHOLD = 0x1001, + WID_SHORT_RETRY_LIMIT = 0x1002, + WID_LONG_RETRY_LIMIT = 0x1003, + WID_CFP_MAX_DUR = 0x1004, + WID_PHY_TEST_FRAME_LEN = 0x1005, + WID_BEACON_INTERVAL = 0x1006, + WID_MEMORY_ACCESS_16BIT = 0x1008, + WID_RX_SENSE = 0x100B, + WID_ACTIVE_SCAN_TIME = 0x100C, + WID_PASSIVE_SCAN_TIME = 0x100D, + WID_SITE_SURVEY_SCAN_TIME = 0x100E, + WID_JOIN_START_TIMEOUT = 0x100F, + WID_AUTH_TIMEOUT = 0x1010, + WID_ASOC_TIMEOUT = 0x1011, + WID_11I_PROTOCOL_TIMEOUT = 0x1012, + WID_EAPOL_RESPONSE_TIMEOUT = 0x1013, + WID_WPS_PASS_ID = 0x1017, + WID_WPS_CONFIG_METHOD = 0x1018, + WID_FHSS_INIT_SCAN_TIME = 0x1070, + WID_FHSS_ROAM_SCAN_TIME = 0x1071, + + /* NMAC Short WID list */ + WID_11N_RF_REG_VAL = 0x1080, + WID_HUT_FRAME_LEN = 0x1081, + WID_HUT_TXOP_LIMIT = 0x1082, + WID_HUT_SIG_QUAL_AVG = 0x1083, + WID_HUT_SIG_QUAL_AVG_CNT = 0x1084, + WID_11N_SIG_QUAL_VAL = 0x1085, + WID_HUT_RSSI_EX_COUNT = 0x1086, + WID_HUT_UC_MGMT_FRAME_LEN = 0x1088, + WID_HUT_BC_MGMT_FRAME_LEN = 0x1089, + + /* Custom Short WID list */ + + WID_CCA_BUSY_STATUS = 0x1100, + + /* EMAC Integer WID list */ + WID_FAILED_COUNT = 0x2000, + WID_RETRY_COUNT = 0x2001, + WID_MULTIPLE_RETRY_COUNT = 0x2002, + WID_FRAME_DUPLICATE_COUNT = 0x2003, + WID_ACK_FAILURE_COUNT = 0x2004, + WID_RECEIVED_FRAGMENT_COUNT = 0x2005, + WID_MCAST_RECEIVED_FRAME_COUNT = 0x2006, + WID_FCS_ERROR_COUNT = 0x2007, + WID_SUCCESS_FRAME_COUNT = 0x2008, + WID_PHY_TEST_PKT_CNT = 0x2009, + WID_HUT_TX_COUNT = 0x200A, + WID_TX_FRAGMENT_COUNT = 0x200B, + WID_TX_MULTICAST_FRAME_COUNT = 0x200C, + WID_RTS_SUCCESS_COUNT = 0x200D, + WID_RTS_FAILURE_COUNT = 0x200E, + WID_WEP_UNDECRYPTABLE_COUNT = 0x200F, + WID_REKEY_PERIOD = 0x2010, + WID_REKEY_PACKET_COUNT = 0x2011, + WID_1X_SERV_ADDR = 0x2012, + WID_STACK_IP_ADDR = 0x2013, + WID_STACK_NETMASK_ADDR = 0x2014, + WID_HW_RX_COUNT = 0x2015, + WID_MEMORY_ADDRESS = 0x201E, + WID_MEMORY_ACCESS_32BIT = 0x201F, + WID_RF_REG_VAL = 0x2021, + WID_FIRMWARE_INFO = 0x2023, + WID_DEV_OS_VERSION = 0x2025, + WID_ROAM_RSSI_THESHOLDS = 0x2070, + WID_TRACK_INTERVAL_SEC = 0x2071, + WID_FHSS_HOPPING_PARAMS = 0x2072, + WID_FHSS_HOP_DWELL_TIME = 0x2073, + + /* NMAC Integer WID list */ + WID_11N_PHY_ACTIVE_REG_VAL = 0x2080, + WID_HUT_NUM_TX_PKTS = 0x2081, + WID_HUT_TX_TIME_TAKEN = 0x2082, + WID_HUT_TX_TEST_TIME = 0x2083, + WID_HUT_LOG_INTERVAL = 0x2084, + + /* EMAC String WID list */ + WID_SSID = 0x3000, + WID_FIRMWARE_VERSION = 0x3001, + WID_OPERATIONAL_RATE_SET = 0x3002, + WID_BSSID = 0x3003, + #if 0 + WID_WEP_KEY_VALUE0 = 0x3004, + #endif + WID_11I_PSK = 0x3008, + WID_11E_P_ACTION_REQ = 0x3009, + WID_1X_KEY = 0x300A, + WID_HARDWARE_VERSION = 0x300B, + WID_MAC_ADDR = 0x300C, + WID_HUT_DEST_ADDR = 0x300D, + /*WID_HUT_STATS = 0x300E,*/ + WID_PHY_VERSION = 0x300F, + WID_SUPP_USERNAME = 0x3010, + WID_SUPP_PASSWORD = 0x3011, + WID_SITE_SURVEY_RESULTS = 0x3012, + WID_RX_POWER_LEVEL = 0x3013, + WID_MANUFACTURER = 0x3026, /*Added for CAPI tool */ + WID_MODEL_NAME = 0x3027, /*Added for CAPI tool */ + WID_MODEL_NUM = 0x3028, /*Added for CAPI tool */ + WID_DEVICE_NAME = 0x3029, /*Added for CAPI tool */ + + WID_ASSOC_RES_INFO = 0x3020, + + /* NMAC String WID list */ + WID_11N_P_ACTION_REQ = 0x3080, + WID_HUT_TEST_ID = 0x3081, + WID_PMKID_INFO = 0x3082, + + /* Custom String WID list */ + WID_FLASH_DATA = 0x3100, + WID_EEPROM_DATA = 0x3101, + WID_SERIAL_NUMBER = 0x3102, + + /* EMAC Binary WID list */ + WID_UAPSD_CONFIG = 0x4001, + WID_UAPSD_STATUS = 0x4002, + WID_AC_PARAMS_AP = 0x4003, + WID_AC_PARAMS_STA = 0x4004, + WID_NEWORK_INFO = 0x4005, + WID_WPS_CRED_LIST = 0x4006, + WID_PRIM_DEV_TYPE = 0x4007, + WID_STA_JOIN_INFO = 0x4008, + WID_CONNECTED_STA_LIST = 0x4009, + + /* NMAC Binary WID list */ + WID_11N_AUTORATE_TABLE = 0x4080, + WID_HUT_TX_PATTERN = 0x4081, + WID_HUT_STATS = 0x4082, + WID_HUT_LOG_STATS = 0x4083, + + /*BugID_3746 WID to add IE to be added in next probe request*/ + WID_INFO_ELEMENT_PROBE = 0x4085, + /*BugID_3746 WID to add IE to be added in next associate request*/ + WID_INFO_ELEMENT_ASSOCIATE = 0x4086, + + /* Miscellaneous WIDs */ + WID_ALL = 0x7FFE, + WID_MAX = 0xFFFF +} tenuWIDid; +#endif + +/* Status Codes for Authentication and Association Frames */ +typedef enum { + SUCCESSFUL_STATUSCODE = 0, + UNSPEC_FAIL = 1, + UNSUP_CAP = 10, + REASOC_NO_ASOC = 11, + FAIL_OTHER = 12, + UNSUPT_ALG = 13, + AUTH_SEQ_FAIL = 14, + CHLNG_FAIL = 15, + AUTH_TIMEOUT = 16, + AP_FULL = 17, + UNSUP_RATE = 18, + SHORT_PREAMBLE_UNSUP = 19, + PBCC_UNSUP = 20, + CHANNEL_AGIL_UNSUP = 21, + SHORT_SLOT_UNSUP = 25, + OFDM_DSSS_UNSUP = 26, + CONNECT_STS_FORCE_16_BIT = 0xFFFF +} tenuConnectSts; + +typedef struct { + WILC_Uint16 u16WIDid; + tenuWIDtype enuWIDtype; + WILC_Sint32 s32ValueSize; + WILC_Sint8 *ps8WidVal; + +} tstrWID; + +typedef struct { + WILC_Uint8 u8Full; + WILC_Uint8 u8Index; + WILC_Sint8 as8RSSI[NUM_RSSI]; +} tstrRSSI; +/* This structure is used to support parsing of the received 'N' message */ +typedef struct { + WILC_Sint8 s8rssi; + WILC_Uint16 u16CapInfo; + WILC_Uint8 au8ssid[MAX_SSID_LEN]; + WILC_Uint8 u8SsidLen; + WILC_Uint8 au8bssid[6]; + WILC_Uint16 u16BeaconPeriod; + WILC_Uint8 u8DtimPeriod; + WILC_Uint8 u8channel; + unsigned long u32TimeRcvdInScanCached; /* of type unsigned long to be accepted by the linux kernel macro time_after() */ + unsigned long u32TimeRcvdInScan; + WILC_Bool bNewNetwork; +#ifdef AGING_ALG + WILC_Uint8 u8Found; +#endif +#ifdef WILC_P2P + WILC_Uint32 u32Tsf; /* time-stamp [Low only 32 bit] */ +#endif + WILC_Uint8 *pu8IEs; + WILC_Uint16 u16IEsLen; + void *pJoinParams; + tstrRSSI strRssi; + WILC_Uint64 u64Tsf; /* time-stamp [Low and High 64 bit] */ +} tstrNetworkInfo; + +/* This structure is used to support parsing of the received Association Response frame */ +typedef struct { + WILC_Uint16 u16capability; + WILC_Uint16 u16ConnectStatus; + WILC_Uint16 u16AssocID; + WILC_Uint8 *pu8RespIEs; + WILC_Uint16 u16RespIEsLen; +} tstrConnectRespInfo; + + +typedef struct { + WILC_Uint8 au8bssid[6]; + WILC_Uint8 *pu8ReqIEs; + size_t ReqIEsLen; + WILC_Uint8 *pu8RespIEs; + WILC_Uint16 u16RespIEsLen; + WILC_Uint16 u16ConnectStatus; +} tstrConnectInfo; + + + +typedef struct { + WILC_Uint16 u16reason; + WILC_Uint8 *ie; + size_t ie_len; +} tstrDisconnectNotifInfo; + +#ifndef CONNECT_DIRECT +typedef struct wid_site_survey_reslts { + WILC_Char SSID[MAX_SSID_LEN]; + WILC_Uint8 BssType; + WILC_Uint8 Channel; + WILC_Uint8 SecurityStatus; + WILC_Uint8 BSSID[6]; + WILC_Char RxPower; + WILC_Uint8 Reserved; + +} wid_site_survey_reslts_s; +#endif + +extern WILC_Sint32 CoreConfiguratorInit(void); +extern WILC_Sint32 CoreConfiguratorDeInit(void); + +extern WILC_Sint32 SendConfigPkt(WILC_Uint8 u8Mode, tstrWID *pstrWIDs, + WILC_Uint32 u32WIDsCount, WILC_Bool bRespRequired, WILC_Uint32 drvHandler); +extern WILC_Sint32 ParseNetworkInfo(WILC_Uint8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo); +extern WILC_Sint32 DeallocateNetworkInfo(tstrNetworkInfo *pstrNetworkInfo); + +extern WILC_Sint32 ParseAssocRespInfo(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32BufferLen, + tstrConnectRespInfo **ppstrConnectRespInfo); +extern WILC_Sint32 DeallocateAssocRespInfo(tstrConnectRespInfo *pstrConnectRespInfo); + +#ifndef CONNECT_DIRECT +extern WILC_Sint32 ParseSurveyResults(WILC_Uint8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE], + wid_site_survey_reslts_s **ppstrSurveyResults, WILC_Uint32 *pu32SurveyResultsCount); +extern WILC_Sint32 DeallocateSurveyResults(wid_site_survey_reslts_s *pstrSurveyResults); +#endif + +extern WILC_Sint32 SendRawPacket(WILC_Sint8 *pspacket, WILC_Sint32 s32PacketLen); +extern void NetworkInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length); +void GnrlAsyncInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length); +void host_int_ScanCompleteReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length); + +#endif diff --git a/drivers/staging/wilc1000/fifo_buffer.c b/drivers/staging/wilc1000/fifo_buffer.c new file mode 100644 index 000000000000..733d81f2eeca --- /dev/null +++ b/drivers/staging/wilc1000/fifo_buffer.c @@ -0,0 +1,142 @@ + + +#include "wilc_oswrapper.h" +#include "fifo_buffer.h" + + + +WILC_Uint32 FIFO_InitBuffer(tHANDLE *hBuffer, WILC_Uint32 u32BufferLength) +{ + WILC_Uint32 u32Error = 0; + tstrFifoHandler *pstrFifoHandler = WILC_MALLOC (sizeof (tstrFifoHandler)); + if (pstrFifoHandler) { + WILC_memset (pstrFifoHandler, 0, sizeof (tstrFifoHandler)); + pstrFifoHandler->pu8Buffer = WILC_MALLOC (u32BufferLength); + if (pstrFifoHandler->pu8Buffer) { + tstrWILC_SemaphoreAttrs strSemBufferAttrs; + pstrFifoHandler->u32BufferLength = u32BufferLength; + WILC_memset (pstrFifoHandler->pu8Buffer, 0, u32BufferLength); + /* create semaphore */ + WILC_SemaphoreFillDefault (&strSemBufferAttrs); + strSemBufferAttrs.u32InitCount = 1; + WILC_SemaphoreCreate(&pstrFifoHandler->SemBuffer, &strSemBufferAttrs); + *hBuffer = pstrFifoHandler; + } else { + *hBuffer = NULL; + u32Error = 1; + } + } else { + u32Error = 1; + } + return u32Error; +} +WILC_Uint32 FIFO_DeInit(tHANDLE hFifo) +{ + WILC_Uint32 u32Error = 0; + tstrFifoHandler *pstrFifoHandler = (tstrFifoHandler *) hFifo; + if (pstrFifoHandler) { + if (pstrFifoHandler->pu8Buffer) { + WILC_FREE (pstrFifoHandler->pu8Buffer); + } else { + u32Error = 1; + } + + WILC_SemaphoreDestroy (&pstrFifoHandler->SemBuffer, WILC_NULL); + + WILC_FREE (pstrFifoHandler); + } else { + u32Error = 1; + } + return u32Error; +} + +WILC_Uint32 FIFO_ReadBytes(tHANDLE hFifo, WILC_Uint8 *pu8Buffer, WILC_Uint32 u32BytesToRead, WILC_Uint32 *pu32BytesRead) +{ + WILC_Uint32 u32Error = 0; + tstrFifoHandler *pstrFifoHandler = (tstrFifoHandler *) hFifo; + if (pstrFifoHandler && pu32BytesRead) { + if (pstrFifoHandler->u32TotalBytes) { + if (WILC_SemaphoreAcquire(&pstrFifoHandler->SemBuffer, WILC_NULL) == WILC_SUCCESS) { + if (u32BytesToRead > pstrFifoHandler->u32TotalBytes) { + *pu32BytesRead = pstrFifoHandler->u32TotalBytes; + } else { + *pu32BytesRead = u32BytesToRead; + } + if ((pstrFifoHandler->u32ReadOffset + u32BytesToRead) <= pstrFifoHandler->u32BufferLength) { + WILC_memcpy(pu8Buffer, pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32ReadOffset, + *pu32BytesRead); + /* update read offset and total bytes */ + pstrFifoHandler->u32ReadOffset += u32BytesToRead; + pstrFifoHandler->u32TotalBytes -= u32BytesToRead; + + } else { + WILC_Uint32 u32FirstPart = + pstrFifoHandler->u32BufferLength - pstrFifoHandler->u32ReadOffset; + WILC_memcpy(pu8Buffer, pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32ReadOffset, + u32FirstPart); + WILC_memcpy(pu8Buffer + u32FirstPart, pstrFifoHandler->pu8Buffer, + u32BytesToRead - u32FirstPart); + /* update read offset and total bytes */ + pstrFifoHandler->u32ReadOffset = u32BytesToRead - u32FirstPart; + pstrFifoHandler->u32TotalBytes -= u32BytesToRead; + } + WILC_SemaphoreRelease (&pstrFifoHandler->SemBuffer, WILC_NULL); + } else { + u32Error = 1; + } + } else { + u32Error = 1; + } + } else { + u32Error = 1; + } + return u32Error; +} + +WILC_Uint32 FIFO_WriteBytes(tHANDLE hFifo, WILC_Uint8 *pu8Buffer, WILC_Uint32 u32BytesToWrite, WILC_Bool bForceOverWrite) +{ + WILC_Uint32 u32Error = 0; + tstrFifoHandler *pstrFifoHandler = (tstrFifoHandler *) hFifo; + if (pstrFifoHandler) { + if (u32BytesToWrite < pstrFifoHandler->u32BufferLength) { + if ((pstrFifoHandler->u32TotalBytes + u32BytesToWrite) <= pstrFifoHandler->u32BufferLength || + bForceOverWrite) { + if (WILC_SemaphoreAcquire(&pstrFifoHandler->SemBuffer, WILC_NULL) == WILC_SUCCESS) { + if ((pstrFifoHandler->u32WriteOffset + u32BytesToWrite) <= pstrFifoHandler->u32BufferLength) { + WILC_memcpy(pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32WriteOffset, pu8Buffer, + u32BytesToWrite); + /* update read offset and total bytes */ + pstrFifoHandler->u32WriteOffset += u32BytesToWrite; + pstrFifoHandler->u32TotalBytes += u32BytesToWrite; + + } else { + WILC_Uint32 u32FirstPart = + pstrFifoHandler->u32BufferLength - pstrFifoHandler->u32WriteOffset; + WILC_memcpy(pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32WriteOffset, pu8Buffer, + u32FirstPart); + WILC_memcpy(pstrFifoHandler->pu8Buffer, pu8Buffer + u32FirstPart, + u32BytesToWrite - u32FirstPart); + /* update read offset and total bytes */ + pstrFifoHandler->u32WriteOffset = u32BytesToWrite - u32FirstPart; + pstrFifoHandler->u32TotalBytes += u32BytesToWrite; + } + /* if data overwriten */ + if (pstrFifoHandler->u32TotalBytes > pstrFifoHandler->u32BufferLength) { + /* adjust read offset to the oldest data available */ + pstrFifoHandler->u32ReadOffset = pstrFifoHandler->u32WriteOffset; + /* data availabe is the buffer length */ + pstrFifoHandler->u32TotalBytes = pstrFifoHandler->u32BufferLength; + } + WILC_SemaphoreRelease(&pstrFifoHandler->SemBuffer, WILC_NULL); + } + } else { + u32Error = 1; + } + } else { + u32Error = 1; + } + } else { + u32Error = 1; + } + return u32Error; +} \ No newline at end of file diff --git a/drivers/staging/wilc1000/fifo_buffer.h b/drivers/staging/wilc1000/fifo_buffer.h new file mode 100644 index 000000000000..0700e7929c00 --- /dev/null +++ b/drivers/staging/wilc1000/fifo_buffer.h @@ -0,0 +1,23 @@ + +#include "wilc_oswrapper.h" + + +#define tHANDLE void * + +typedef struct { + WILC_Uint8 *pu8Buffer; + WILC_Uint32 u32BufferLength; + WILC_Uint32 u32WriteOffset; + WILC_Uint32 u32ReadOffset; + WILC_Uint32 u32TotalBytes; + WILC_SemaphoreHandle SemBuffer; +} tstrFifoHandler; + + +extern WILC_Uint32 FIFO_InitBuffer(tHANDLE *hBuffer, + WILC_Uint32 u32BufferLength); +extern WILC_Uint32 FIFO_DeInit(tHANDLE hFifo); +extern WILC_Uint32 FIFO_ReadBytes(tHANDLE hFifo, WILC_Uint8 *pu8Buffer, + WILC_Uint32 u32BytesToRead, WILC_Uint32 *pu32BytesRead); +extern WILC_Uint32 FIFO_WriteBytes(tHANDLE hFifo, WILC_Uint8 *pu8Buffer, + WILC_Uint32 u32BytesToWrite, WILC_Bool bForceOverWrite); \ No newline at end of file diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c new file mode 100644 index 000000000000..fcbadd1885de --- /dev/null +++ b/drivers/staging/wilc1000/host_interface.c @@ -0,0 +1,8074 @@ +#include "host_interface.h" +#include "wilc_oswrapper.h" +#include "itypes.h" +#include "coreconfigurator.h" + +extern WILC_Sint32 TransportInit(void); +extern WILC_Sint32 TransportDeInit(void); +extern WILC_Uint8 connecting; + +#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP +extern WILC_TimerHandle hDuringIpTimer; +#endif + +extern WILC_Bool bEnablePS; +/*BugID_5137*/ +extern WILC_Uint8 g_wilc_initialized; +/*****************************************************************************/ +/* Macros */ +/*****************************************************************************/ + +/* Message types of the Host IF Message Queue*/ +#define HOST_IF_MSG_SCAN ((WILC_Uint16)0) +#define HOST_IF_MSG_CONNECT ((WILC_Uint16)1) +#define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO ((WILC_Uint16)2) +#define HOST_IF_MSG_KEY ((WILC_Uint16)3) +#define HOST_IF_MSG_RCVD_NTWRK_INFO ((WILC_Uint16)4) +#define HOST_IF_MSG_RCVD_SCAN_COMPLETE ((WILC_Uint16)5) +#define HOST_IF_MSG_CFG_PARAMS ((WILC_Uint16)6) +#define HOST_IF_MSG_SET_CHANNEL ((WILC_Uint16)7) +#define HOST_IF_MSG_DISCONNECT ((WILC_Uint16)8) +#define HOST_IF_MSG_GET_RSSI ((WILC_Uint16)9) +#define HOST_IF_MSG_GET_CHNL ((WILC_Uint16)10) +#define HOST_IF_MSG_ADD_BEACON ((WILC_Uint16)11) +#define HOST_IF_MSG_DEL_BEACON ((WILC_Uint16)12) +#define HOST_IF_MSG_ADD_STATION ((WILC_Uint16)13) +#define HOST_IF_MSG_DEL_STATION ((WILC_Uint16)14) +#define HOST_IF_MSG_EDIT_STATION ((WILC_Uint16)15) +#define HOST_IF_MSG_SCAN_TIMER_FIRED ((WILC_Uint16)16) +#define HOST_IF_MSG_CONNECT_TIMER_FIRED ((WILC_Uint16)17) +#define HOST_IF_MSG_POWER_MGMT ((WILC_Uint16)18) +#define HOST_IF_MSG_GET_INACTIVETIME ((WILC_Uint16)19) +#define HOST_IF_MSG_REMAIN_ON_CHAN ((WILC_Uint16)20) +#define HOST_IF_MSG_REGISTER_FRAME ((WILC_Uint16)21) +#define HOST_IF_MSG_LISTEN_TIMER_FIRED ((WILC_Uint16)22) +#define HOST_IF_MSG_GET_LINKSPEED ((WILC_Uint16)23) +#define HOST_IF_MSG_SET_WFIDRV_HANDLER ((WILC_Uint16)24) +#define HOST_IF_MSG_SET_MAC_ADDRESS ((WILC_Uint16)25) +#define HOST_IF_MSG_GET_MAC_ADDRESS ((WILC_Uint16)26) +#define HOST_IF_MSG_SET_OPERATION_MODE ((WILC_Uint16)27) +#define HOST_IF_MSG_SET_IPADDRESS ((WILC_Uint16)28) +#define HOST_IF_MSG_GET_IPADDRESS ((WILC_Uint16)29) +#define HOST_IF_MSG_FLUSH_CONNECT ((WILC_Uint16)30) +#define HOST_IF_MSG_GET_STATISTICS ((WILC_Uint16)31) +#define HOST_IF_MSG_SET_MULTICAST_FILTER ((WILC_Uint16)32) +#define HOST_IF_MSG_ADD_BA_SESSION ((WILC_Uint16)33) +#define HOST_IF_MSG_DEL_BA_SESSION ((WILC_Uint16)34) +#define HOST_IF_MSG_Q_IDLE ((WILC_Uint16)35) +#define HOST_IF_MSG_DEL_ALL_STA ((WILC_Uint16)36) +#define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS ((WILC_Uint16)34) + +#define HOST_IF_MSG_EXIT ((WILC_Uint16)100) + +#define HOST_IF_SCAN_TIMEOUT 4000 +#define HOST_IF_CONNECT_TIMEOUT 9500 + +#define BA_SESSION_DEFAULT_BUFFER_SIZE 16 +#define BA_SESSION_DEFAULT_TIMEOUT 1000 +#define BLOCK_ACK_REQ_SIZE 0x14 +/*****************************************************************************/ +/* Type Definitions */ +/*****************************************************************************/ + +/*! + * @struct tstrHostIFCfgParamAttr + * @brief Structure to hold Host IF CFG Params Attributes + * @details + * @todo + * @sa + * @author Mai Daftedar + * @date 02 April 2012 + * @version 1.0 + */ +typedef struct _tstrHostIFCfgParamAttr { + tstrCfgParamVal pstrCfgParamVal; + +} tstrHostIFCfgParamAttr; + +/*! + * @struct tstrHostIFwpaAttr + * @brief Structure to hold Host IF Scan Attributes + * @details + * @todo + * @sa + * @author Mai Daftedar + * @date 25 March 2012 + * @version 1.0 + */ +typedef struct _tstrHostIFwpaAttr { + WILC_Uint8 *pu8key; + const WILC_Uint8 *pu8macaddr; + WILC_Uint8 *pu8seq; + WILC_Uint8 u8seqlen; + WILC_Uint8 u8keyidx; + WILC_Uint8 u8Keylen; + WILC_Uint8 u8Ciphermode; +} tstrHostIFwpaAttr; + + +/*! + * @struct tstrHostIFwepAttr + * @brief Structure to hold Host IF Scan Attributes + * @details + * @todo + * @sa + * @author Mai Daftedar + * @date 25 March 2012 + * @version 1.0 + */ +typedef struct _tstrHostIFwepAttr { + WILC_Uint8 *pu8WepKey; + WILC_Uint8 u8WepKeylen; + WILC_Uint8 u8Wepidx; + WILC_Uint8 u8mode; + AUTHTYPE_T tenuAuth_type; + +} tstrHostIFwepAttr; + +/*! + * @struct tuniHostIFkeyAttr + * @brief Structure to hold Host IF Scan Attributes + * @details + * @todo + * @sa + * @author Mai Daftedar + * @date 25 March 2012 + * @version 1.0 + */ +typedef union _tuniHostIFkeyAttr { + tstrHostIFwepAttr strHostIFwepAttr; + tstrHostIFwpaAttr strHostIFwpaAttr; + tstrHostIFpmkidAttr strHostIFpmkidAttr; +} tuniHostIFkeyAttr; + +/*! + * @struct tstrHostIFkeyAttr + * @brief Structure to hold Host IF Scan Attributes + * @details + * @todo + * @sa + * @author Mai Daftedar + * @date 25 March 2012 + * @version 1.0 + */ +typedef struct _tstrHostIFkeyAttr { + tenuKeyType enuKeyType; + WILC_Uint8 u8KeyAction; + tuniHostIFkeyAttr uniHostIFkeyAttr; +} tstrHostIFkeyAttr; + + + + +/*! + * @struct tstrHostIFscanAttr + * @brief Structure to hold Host IF Scan Attributes + * @details + * @todo + * @sa + * @author Mostafa Abu Bakr + * @date 25 March 2012 + * @version 1.0 + */ +typedef struct _tstrHostIFscanAttr { + WILC_Uint8 u8ScanSource; + WILC_Uint8 u8ScanType; + WILC_Uint8 *pu8ChnlFreqList; + WILC_Uint8 u8ChnlListLen; + WILC_Uint8 *pu8IEs; + size_t IEsLen; + tWILCpfScanResult pfScanResult; + void *pvUserArg; + /*BugID_4189*/ + tstrHiddenNetwork strHiddenNetwork; + +} tstrHostIFscanAttr; + +/*! + * @struct tstrHostIFconnectAttr + * @brief Structure to hold Host IF Connect Attributes + * @details + * @todo + * @sa + * @author Mostafa Abu Bakr + * @date 25 March 2012 + * @version 1.0 + */ +typedef struct _tstrHostIFconnectAttr { + WILC_Uint8 *pu8bssid; + WILC_Uint8 *pu8ssid; + size_t ssidLen; + WILC_Uint8 *pu8IEs; + size_t IEsLen; + WILC_Uint8 u8security; + tWILCpfConnectResult pfConnectResult; + void *pvUserArg; + AUTHTYPE_T tenuAuth_type; + WILC_Uint8 u8channel; + void *pJoinParams; +} tstrHostIFconnectAttr; + +/*! + * @struct tstrRcvdGnrlAsyncInfo + * @brief Structure to hold Received General Asynchronous info + * @details + * @todo + * @sa + * @author Mostafa Abu Bakr + * @date 25 March 2012 + * @version 1.0 + */ +typedef struct _tstrRcvdGnrlAsyncInfo { + WILC_Uint8 *pu8Buffer; + WILC_Uint32 u32Length; +} tstrRcvdGnrlAsyncInfo; + +/*! + * @struct tstrHostIFSetChan + * @brief Set Channel message body + * @details + * @todo + * @sa + * @author Mai Daftedar + * @date 25 March 2012 + * @version 1.0 + */ +typedef struct _tstrHostIFSetChan { + WILC_Uint8 u8SetChan; +} tstrHostIFSetChan; + +/*! + * @struct tstrHostIFSetChan + * @brief Get Channel message body + * @details + * @todo + * @sa + * @author Mai Daftedar + * @date 01 Jule 2012 + * @version 1.0 + */ +typedef struct _tstrHostIFGetChan { + WILC_Uint8 u8GetChan; +} tstrHostIFGetChan; + +/*bug3819: Add Scan acomplete notification to host*/ +/*! + * @struct tstrScanComplete + * @brief hold received Async. Scan Complete message body + * @details + * @todo + * @sa + * @author zsalah + * @date 25 March 2012 + * @version 1.0 + */ +/*typedef struct _tstrScanComplete + * { + * WILC_Uint8* pu8Buffer; + * WILC_Uint32 u32Length; + * } tstrScanComplete;*/ + +/*! + * @struct tstrHostIFSetBeacon + * @brief Set Beacon message body + * @details + * @todo + * @sa + * @author Adham Abozaeid + * @date 10 July 2012 + * @version 1.0 + */ +typedef struct _tstrHostIFSetBeacon { + WILC_Uint32 u32Interval; /*!< Beacon Interval. Period between two successive beacons on air */ + WILC_Uint32 u32DTIMPeriod; /*!< DTIM Period. Indicates how many Beacon frames + * (including the current frame) appear before the next DTIM */ + WILC_Uint32 u32HeadLen; /*!< Length of the head buffer in bytes */ + WILC_Uint8 *pu8Head; /*!< Pointer to the beacon's head buffer. Beacon's head is the part + * from the beacon's start till the TIM element, NOT including the TIM */ + WILC_Uint32 u32TailLen; /*!< Length of the tail buffer in bytes */ + WILC_Uint8 *pu8Tail; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just + * after the TIM inormation element */ +} tstrHostIFSetBeacon; + + + +/*! + * @struct tstrHostIFDelBeacon + * @brief Del Beacon message body + * @details + * @todo + * @sa + * @author Adham Abozaeid + * @date 15 July 2012 + * @version 1.0 + */ +typedef struct _tstrHostIFDelBeacon { + WILC_Uint8 u8dummy; +} tstrHostIFDelBeacon; + +/*! + * @struct tstrHostIFSetMulti + * @brief set Multicast filter Address + * @details + * @todo + * @sa + * @author Abdelrahman Sobhy + * @date 30 August 2013 + * @version 1.0 Description + */ + +typedef struct { + WILC_Bool bIsEnabled; + WILC_Uint32 u32count; +} tstrHostIFSetMulti; + +/*! + * @struct tstrHostIFDelAllSta + * @brief Deauth station message body + * @details + * @todo + * @sa + * @author Mai Daftedar + * @date 09 April 2014 + * @version 1.0 Description + */ + +typedef struct { + WILC_Uint8 au8Sta_DelAllSta[MAX_NUM_STA][ETH_ALEN]; + WILC_Uint8 u8Num_AssocSta; +} tstrHostIFDelAllSta; + +/*! + * @struct tstrHostIFDelSta + * @brief Delete station message body + * @details + * @todo + * @sa + * @author Adham Abozaeid + * @date 15 July 2012 + * @version 1.0 Description + */ + +typedef struct { + WILC_Uint8 au8MacAddr[ETH_ALEN]; +} tstrHostIFDelSta; + +/*! + * @struct tstrTimerCb + * @brief Timer callback message body + * @details + * @todo + * @sa + * @author Mostafa Abu Bakr + * @date 25 March 2012 + * @version 1.0 + */ +typedef struct _tstrTimerCb { + void *pvUsrArg; /*!< Private data passed at timer start */ +} tstrTimerCb; + +/*! + * @struct tstrHostIfPowerMgmtParam + * @brief Power management message body + * @details + * @todo + * @sa + * @author Adham Abozaeid + * @date 24 November 2012 + * @version 1.0 + */ +typedef struct { + + WILC_Bool bIsEnabled; + WILC_Uint32 u32Timeout; +} tstrHostIfPowerMgmtParam; + +/*! + * @struct tstrHostIFSetIPAddr + * @brief set IP Address message body + * @details + * @todo + * @sa + * @author Abdelrahman Sobhy + * @date 30 August 2013 + * @version 1.0 Description + */ + +typedef struct { + WILC_Uint8 *au8IPAddr; + WILC_Uint8 idx; +} tstrHostIFSetIPAddr; + +/*! + * @struct tstrHostIfStaInactiveT + * @brief Get station message body + * @details + * @todo + * @sa + * @author Mai Daftedar + * @date 16 April 2013 + * @version 1.0 + */ +typedef struct { + WILC_Uint8 mac[6]; + +} tstrHostIfStaInactiveT; +/**/ +/*! + * @union tuniHostIFmsgBody + * @brief Message body for the Host Interface message_q + * @details + * @todo + * @sa + * @author Mostafa Abu Bakr + * @date 25 March 2012 + * @version 1.0 + */ +typedef union _tuniHostIFmsgBody { + tstrHostIFscanAttr strHostIFscanAttr; /*!< Host IF Scan Request Attributes message body */ + tstrHostIFconnectAttr strHostIFconnectAttr; /*!< Host IF Connect Request Attributes message body */ + tstrRcvdNetworkInfo strRcvdNetworkInfo; /*!< Received Asynchronous Network Info message body */ + tstrRcvdGnrlAsyncInfo strRcvdGnrlAsyncInfo; /*!< Received General Asynchronous Info message body */ + tstrHostIFkeyAttr strHostIFkeyAttr; /*!<>*/ + tstrHostIFCfgParamAttr strHostIFCfgParamAttr; /*! */ + tstrHostIFSetChan strHostIFSetChan; + tstrHostIFGetChan strHostIFGetChan; + tstrHostIFSetBeacon strHostIFSetBeacon; /*!< Set beacon message body */ + tstrHostIFDelBeacon strHostIFDelBeacon; /*!< Del beacon message body */ + tstrWILC_AddStaParam strAddStaParam; /*!< Add station message body */ + tstrHostIFDelSta strDelStaParam; /*!< Del Station message body */ + tstrWILC_AddStaParam strEditStaParam; /*!< Edit station message body */ + /* tstrScanComplete strScanComplete; / *Received Async. Scan Complete message body* / */ + tstrTimerCb strTimerCb; /*!< Timer callback message body */ + tstrHostIfPowerMgmtParam strPowerMgmtparam; /*!< Power Management message body */ + tstrHostIfStaInactiveT strHostIfStaInactiveT; + tstrHostIFSetIPAddr strHostIfSetIP; + tstrHostIfSetDrvHandler strHostIfSetDrvHandler; + tstrHostIFSetMulti strHostIfSetMulti; + tstrHostIfSetOperationMode strHostIfSetOperationMode; + tstrHostIfSetMacAddress strHostIfSetMacAddress; + tstrHostIfGetMacAddress strHostIfGetMacAddress; + tstrHostIfBASessionInfo strHostIfBASessionInfo; + #ifdef WILC_P2P + tstrHostIfRemainOnChan strHostIfRemainOnChan; + tstrHostIfRegisterFrame strHostIfRegisterFrame; + #endif + WILC_Char *pUserData; + tstrHostIFDelAllSta strHostIFDelAllSta; +} tuniHostIFmsgBody; + +/*! + * @struct tstrHostIFmsg + * @brief Host Interface message + * @details + * @todo + * @sa + * @author Mostafa Abu Bakr + * @date 25 March 2012 + * @version 1.0 + */ +typedef struct _tstrHostIFmsg { + WILC_Uint16 u16MsgId; /*!< Message ID */ + tuniHostIFmsgBody uniHostIFmsgBody; /*!< Message body */ + void *drvHandler; +} tstrHostIFmsg; + +#ifdef CONNECT_DIRECT +typedef struct _tstrWidJoinReqExt { + WILC_Char SSID[MAX_SSID_LEN]; + WILC_Uint8 u8channel; + WILC_Uint8 BSSID[6]; +} tstrWidJoinReqExt; +#endif + +/*Bug4218: Parsing Join Param*/ +#ifdef WILC_PARSE_SCAN_IN_HOST +/*Struct containg joinParam of each AP*/ +typedef struct _tstrJoinBssParam { + BSSTYPE_T bss_type; + WILC_Uint8 dtim_period; + WILC_Uint16 beacon_period; + WILC_Uint16 cap_info; + WILC_Uint8 au8bssid[6]; + WILC_Char ssid[MAX_SSID_LEN]; + WILC_Uint8 ssidLen; + WILC_Uint8 supp_rates[MAX_RATES_SUPPORTED + 1]; + WILC_Uint8 ht_capable; + WILC_Uint8 wmm_cap; + WILC_Uint8 uapsd_cap; + WILC_Bool rsn_found; + WILC_Uint8 rsn_grp_policy; + WILC_Uint8 mode_802_11i; + WILC_Uint8 rsn_pcip_policy[3]; + WILC_Uint8 rsn_auth_policy[3]; + WILC_Uint8 rsn_cap[2]; + struct _tstrJoinParam *nextJoinBss; + #ifdef WILC_P2P + WILC_Uint32 tsf; + WILC_Uint8 u8NoaEnbaled; + WILC_Uint8 u8OppEnable; + WILC_Uint8 u8CtWindow; + WILC_Uint8 u8Count; + WILC_Uint8 u8Index; + WILC_Uint8 au8Duration[4]; + WILC_Uint8 au8Interval[4]; + WILC_Uint8 au8StartTime[4]; + #endif +} tstrJoinBssParam; +/*Bug4218: Parsing Join Param*/ +/*a linked list table containing needed join parameters entries for each AP found in most recent scan*/ +typedef struct _tstrBssTable { + WILC_Uint8 u8noBssEntries; + tstrJoinBssParam *head; + tstrJoinBssParam *tail; +} tstrBssTable; +#endif /*WILC_PARSE_SCAN_IN_HOST*/ + +typedef enum { + SCAN_TIMER = 0, + CONNECT_TIMER = 1, + SCAN_CONNECT_TIMER_FORCE_32BIT = 0xFFFFFFFF +} tenuScanConnTimer; + +/*****************************************************************************/ +/* */ +/* Global Variabls */ +/* */ +/*****************************************************************************/ + + +tstrWILC_WFIDrv *terminated_handle = WILC_NULL; +tstrWILC_WFIDrv *gWFiDrvHandle = WILC_NULL; +#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP +WILC_Bool g_obtainingIP = WILC_FALSE; +#endif +WILC_Uint8 P2P_LISTEN_STATE; +static WILC_ThreadHandle HostIFthreadHandler; +static WILC_MsgQueueHandle gMsgQHostIF; +static WILC_SemaphoreHandle hSemHostIFthrdEnd; + +WILC_SemaphoreHandle hSemDeinitDrvHandle; +static WILC_SemaphoreHandle hWaitResponse; +WILC_SemaphoreHandle hSemHostIntDeinit; +WILC_TimerHandle g_hPeriodicRSSI; + + + +WILC_Uint8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN]; + +#ifndef CONNECT_DIRECT +static WILC_Uint8 gapu8RcvdSurveyResults[2][MAX_SURVEY_RESULT_FRAG_SIZE]; +#endif + +static WILC_Uint8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE]; + +WILC_Bool gbScanWhileConnected = WILC_FALSE; + +static WILC_Sint8 gs8Rssi; +static WILC_Sint8 gs8lnkspd; +static WILC_Uint8 gu8Chnl; +static WILC_Uint8 gs8SetIP[2][4]; +static WILC_Uint8 gs8GetIP[2][4]; +#ifdef WILC_AP_EXTERNAL_MLME +static WILC_Uint32 gu32InactiveTime; +static WILC_Uint8 gu8DelBcn; +#endif +#ifndef SIMULATION +static WILC_Uint32 gu32WidConnRstHack; +#endif + +/*BugID_5137*/ +WILC_Uint8 *gu8FlushedJoinReq; +WILC_Uint8 *gu8FlushedInfoElemAsoc; +WILC_Uint8 gu8Flushed11iMode; +WILC_Uint8 gu8FlushedAuthType; +WILC_Uint32 gu32FlushedJoinReqSize; +WILC_Uint32 gu32FlushedInfoElemAsocSize; +WILC_Uint32 gu8FlushedJoinReqDrvHandler; +#define REAL_JOIN_REQ 0 +#define FLUSHED_JOIN_REQ 1 +#define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */ + +/*Bug4218: Parsing Join Param*/ +#ifdef WILC_PARSE_SCAN_IN_HOST +/*Bug4218: Parsing Join Param*/ +static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo); +#endif /*WILC_PARSE_SCAN_IN_HOST*/ + +extern void chip_sleep_manually(WILC_Uint32 u32SleepTime); +extern int linux_wlan_get_num_conn_ifcs(void); + +/** + * @brief Handle_SetChannel + * @details Sending config packet to firmware to set channel + * @param[in] tstrHostIFSetChan* pstrHostIFSetChan + * @return Error code. + * @author + * @date + * @version 1.0 + */ +static WILC_Sint32 Handle_SetChannel(void *drvHandler, tstrHostIFSetChan *pstrHostIFSetChan) +{ + + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + + /*prepare configuration packet*/ + strWID.u16WIDid = (WILC_Uint16)WID_CURRENT_CHANNEL; + strWID.enuWIDtype = WID_CHAR; + strWID.ps8WidVal = (WILC_Char *)&(pstrHostIFSetChan->u8SetChan); + strWID.s32ValueSize = sizeof(WILC_Char); + + PRINT_D(HOSTINF_DBG, "Setting channel\n"); + /*Sending Cfg*/ + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + if (s32Error) { + PRINT_ER("Failed to set channel\n"); + WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); + } + WILC_CATCH(s32Error) + { + + } + + return s32Error; +} +/** + * @brief Handle_SetWfiDrvHandler + * @details Sending config packet to firmware to set driver handler + * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler + * @return Error code. + * @author + * @date + * @version 1.0 + */ +static WILC_Sint32 Handle_SetWfiDrvHandler(tstrHostIfSetDrvHandler *pstrHostIfSetDrvHandler) +{ + + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)((pstrHostIfSetDrvHandler->u32Address)); + + + /*prepare configuration packet*/ + strWID.u16WIDid = (WILC_Uint16)WID_SET_DRV_HANDLER; + strWID.enuWIDtype = WID_INT; + strWID.ps8WidVal = (WILC_Sint8 *)&(pstrHostIfSetDrvHandler->u32Address); + strWID.s32ValueSize = sizeof(WILC_Uint32); + + /*Sending Cfg*/ + + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + + + if ((pstrHostIfSetDrvHandler->u32Address) == (WILC_Uint32)NULL) { + WILC_SemaphoreRelease(&hSemDeinitDrvHandle, WILC_NULL); + } + + + if (s32Error) { + PRINT_ER("Failed to set driver handler\n"); + WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); + } + WILC_CATCH(s32Error) + { + + } + + return s32Error; +} + +/** + * @brief Handle_SetWfiAPDrvHandler + * @details Sending config packet to firmware to set driver handler + * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler + * @return Error code. + * @author + * @date + * @version 1.0 + */ +static WILC_Sint32 Handle_SetOperationMode(void *drvHandler, tstrHostIfSetOperationMode *pstrHostIfSetOperationMode) +{ + + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + + + /*prepare configuration packet*/ + strWID.u16WIDid = (WILC_Uint16)WID_SET_OPERATION_MODE; + strWID.enuWIDtype = WID_INT; + strWID.ps8WidVal = (WILC_Sint8 *)&(pstrHostIfSetOperationMode->u32Mode); + strWID.s32ValueSize = sizeof(WILC_Uint32); + + /*Sending Cfg*/ + PRINT_INFO(HOSTINF_DBG, "(WILC_Uint32)pstrWFIDrv= %x \n", (WILC_Uint32)pstrWFIDrv); + + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + + + if ((pstrHostIfSetOperationMode->u32Mode) == (WILC_Uint32)NULL) { + WILC_SemaphoreRelease(&hSemDeinitDrvHandle, WILC_NULL); + } + + + if (s32Error) { + PRINT_ER("Failed to set driver handler\n"); + WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); + } + WILC_CATCH(s32Error) + { + + } + + return s32Error; +} + +/** + * @brief host_int_set_IPAddress + * @details Setting IP address params in message queue + * @param[in] WILC_WFIDrvHandle hWFIDrv, WILC_Uint8* pu8IPAddr + * @return Error code. + * @author + * @date + * @version 1.0 + */ +WILC_Sint32 Handle_set_IPAddress(void *drvHandler, WILC_Uint8 *pu8IPAddr, WILC_Uint8 idx) +{ + + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + char firmwareIPAddress[4] = {0}; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + + if (pu8IPAddr[0] < 192) + pu8IPAddr[0] = 0; + + PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %d.%d.%d.%d \n", idx, pu8IPAddr[0], pu8IPAddr[1], pu8IPAddr[2], pu8IPAddr[3]); + + WILC_memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN); + + /*prepare configuration packet*/ + strWID.u16WIDid = (WILC_Uint16)WID_IP_ADDRESS; + strWID.enuWIDtype = WID_STR; + strWID.ps8WidVal = (WILC_Uint8 *)pu8IPAddr; + strWID.s32ValueSize = IP_ALEN; + + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + + + + host_int_get_ipaddress((WILC_WFIDrvHandle)drvHandler, firmwareIPAddress, idx); + + if (s32Error) { + PRINT_D(HOSTINF_DBG, "Failed to set IP address\n"); + WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); + } else { + PRINT_INFO(HOSTINF_DBG, "IP address set\n"); + } + + WILC_CATCH(s32Error) + { + + } + + return s32Error; +} + + +/** + * @brief Handle_get_IPAddress + * @details Setting IP address params in message queue + * @param[in] WILC_WFIDrvHandle hWFIDrv, WILC_Uint8* pu8IPAddr + * @return Error code. + * @author + * @date + * @version 1.0 + */ +WILC_Sint32 Handle_get_IPAddress(void *drvHandler, WILC_Uint8 *pu8IPAddr, WILC_Uint8 idx) +{ + + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + + /*prepare configuration packet*/ + strWID.u16WIDid = (WILC_Uint16)WID_IP_ADDRESS; + strWID.enuWIDtype = WID_STR; + strWID.ps8WidVal = (WILC_Uint8 *)WILC_MALLOC(IP_ALEN); + strWID.s32ValueSize = IP_ALEN; + + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + + PRINT_INFO(HOSTINF_DBG, "%d.%d.%d.%d\n", (WILC_Uint8)(strWID.ps8WidVal[0]), (WILC_Uint8)(strWID.ps8WidVal[1]), (WILC_Uint8)(strWID.ps8WidVal[2]), (WILC_Uint8)(strWID.ps8WidVal[3])); + + WILC_memcpy(gs8GetIP[idx], strWID.ps8WidVal, IP_ALEN); + + /*get the value by searching the local copy*/ + WILC_FREE(strWID.ps8WidVal); + + if (WILC_memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0) + host_int_setup_ipaddress((WILC_WFIDrvHandle)pstrWFIDrv, gs8SetIP[idx], idx); + + if (s32Error != WILC_SUCCESS) { + PRINT_ER("Failed to get IP address\n"); + WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); + } else { + PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d \n", idx); + PRINT_INFO(HOSTINF_DBG, "%d.%d.%d.%d\n", gs8GetIP[idx][0], gs8GetIP[idx][1], gs8GetIP[idx][2], gs8GetIP[idx][3]); + PRINT_INFO(HOSTINF_DBG, "\n"); + } + + WILC_CATCH(s32Error) + { + + } + + return s32Error; +} + + +/*BugId_5077*/ +/** + * @brief Handle_SetMacAddress + * @details Setting mac address + * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler + * @return Error code. + * @author Amr Abdel-Moghny + * @date November 2013 + * @version 7.0 + */ +static WILC_Sint32 Handle_SetMacAddress(void *drvHandler, tstrHostIfSetMacAddress *pstrHostIfSetMacAddress) +{ + + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + WILC_Uint8 *mac_buf = (WILC_Uint8 *)WILC_MALLOC(ETH_ALEN); + if (mac_buf == NULL) { + PRINT_ER("No buffer to send mac address\n"); + return WILC_FAIL; + } + WILC_memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN); + + /*prepare configuration packet*/ + strWID.u16WIDid = (WILC_Uint16)WID_MAC_ADDR; + strWID.enuWIDtype = WID_STR; + strWID.ps8WidVal = mac_buf; + strWID.s32ValueSize = ETH_ALEN; + PRINT_D(GENERIC_DBG, "mac addr = :%x:%x:%x:%x:%x:%x\n", strWID.ps8WidVal[0], strWID.ps8WidVal[1], strWID.ps8WidVal[2], strWID.ps8WidVal[3], strWID.ps8WidVal[4], strWID.ps8WidVal[5]); + /*Sending Cfg*/ + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + if (s32Error) { + PRINT_ER("Failed to set mac address\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + + WILC_CATCH(s32Error) + { + + } + WILC_FREE(mac_buf); + return s32Error; +} + + +/*BugID_5213*/ +/** + * @brief Handle_GetMacAddress + * @details Getting mac address + * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler + * @return Error code. + * @author Amr Abdel-Moghny + * @date JAN 2013 + * @version 8.0 + */ +static WILC_Sint32 Handle_GetMacAddress(void *drvHandler, tstrHostIfGetMacAddress *pstrHostIfGetMacAddress) +{ + + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + + /*prepare configuration packet*/ + strWID.u16WIDid = (WILC_Uint16)WID_MAC_ADDR; + strWID.enuWIDtype = WID_STR; + strWID.ps8WidVal = pstrHostIfGetMacAddress->u8MacAddress; + strWID.s32ValueSize = ETH_ALEN; + + /*Sending Cfg*/ + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)drvHandler); + if (s32Error) { + PRINT_ER("Failed to get mac address\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + WILC_CATCH(s32Error) + { + + } + WILC_SemaphoreRelease(&hWaitResponse, NULL); + + return s32Error; +} + + +/** + * @brief Handle_CfgParam + * @details Sending config packet to firmware to set CFG params + * @param[in] tstrHostIFCfgParamAttr* strHostIFCfgParamAttr + * @return Error code. + * @author + * @date + * @version 1.0 + */ +static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *strHostIFCfgParamAttr) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWIDList[32]; + WILC_Uint8 u8WidCnt = 0; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + + + WILC_SemaphoreAcquire(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + + + PRINT_D(HOSTINF_DBG, "Setting CFG params\n"); + + if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BSS_TYPE) { + /*----------------------------------------------------------*/ + /*Input Value: INFRASTRUCTURE = 1, */ + /* INDEPENDENT= 2, */ + /* ANY_BSS= 3 */ + /*----------------------------------------------------------*/ + /* validate input then copy>> need to check value 4 and 5 */ + if (strHostIFCfgParamAttr->pstrCfgParamVal.bss_type < 6) { + strWIDList[u8WidCnt].u16WIDid = WID_BSS_TYPE; + strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type; + strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; + strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); + pstrWFIDrv->strCfgValues.bss_type = (WILC_Uint8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type; + } else { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + u8WidCnt++; + } + if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTH_TYPE) { + /*------------------------------------------------------*/ + /*Input Values: OPEN_SYSTEM = 0, */ + /* SHARED_KEY = 1, */ + /* ANY = 2 */ + /*------------------------------------------------------*/ + /*validate Possible values*/ + if ((strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 1 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 2 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 5) { + strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TYPE; + strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type; + strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; + strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); + pstrWFIDrv->strCfgValues.auth_type = (WILC_Uint8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type; + } else { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + u8WidCnt++; + } + if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTHEN_TIMEOUT) { + /* range is 1 to 65535. */ + if (strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout < 65536) { + strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TIMEOUT; + strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout; + strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; + strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16); + pstrWFIDrv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout; + } else { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + u8WidCnt++; + } + if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & POWER_MANAGEMENT) { + /*-----------------------------------------------------------*/ + /*Input Values: NO_POWERSAVE = 0, */ + /* MIN_FAST_PS = 1, */ + /* MAX_FAST_PS = 2, */ + /* MIN_PSPOLL_PS = 3, */ + /* MAX_PSPOLL_PS = 4 */ + /*----------------------------------------------------------*/ + if (strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode < 5) { + strWIDList[u8WidCnt].u16WIDid = WID_POWER_MANAGEMENT; + strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode; + strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; + strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); + pstrWFIDrv->strCfgValues.power_mgmt_mode = (WILC_Uint8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode; + } else { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + u8WidCnt++; + } + if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_SHORT) { + /* range from 1 to 256 */ + if ((strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit < 256)) { + strWIDList[u8WidCnt].u16WIDid = WID_SHORT_RETRY_LIMIT; + strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit; + strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; + strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16); + pstrWFIDrv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit; + } else { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + u8WidCnt++; + } + if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_LONG) { + /* range from 1 to 256 */ + if ((strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit < 256)) { + strWIDList[u8WidCnt].u16WIDid = WID_LONG_RETRY_LIMIT; + strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit; + + strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; + strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16); + pstrWFIDrv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit; + } else { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + u8WidCnt++; + } + if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & FRAG_THRESHOLD) { + + if (strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold < 7937) { + strWIDList[u8WidCnt].u16WIDid = WID_FRAG_THRESHOLD; + strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold; + strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; + strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16); + pstrWFIDrv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold; + } else { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + u8WidCnt++; + } + if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RTS_THRESHOLD) { + /* range 256 to 65535 */ + if (strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold < 65536) { + strWIDList[u8WidCnt].u16WIDid = WID_RTS_THRESHOLD; + strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold; + strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; + strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16); + pstrWFIDrv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold; + } else { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + u8WidCnt++; + } + if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PREAMBLE) { + /*-----------------------------------------------------*/ + /*Input Values: Short= 0, */ + /* Long= 1, */ + /* Auto= 2 */ + /*------------------------------------------------------*/ + if (strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type < 3) { + strWIDList[u8WidCnt].u16WIDid = WID_PREAMBLE; + strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type; + strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; + strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); + pstrWFIDrv->strCfgValues.preamble_type = strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type; + } else { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + u8WidCnt++; + } + if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SHORT_SLOT_ALLOWED) { + if (strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed < 2) { + strWIDList[u8WidCnt].u16WIDid = WID_SHORT_SLOT_ALLOWED; + strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed; + strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; + strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); + pstrWFIDrv->strCfgValues.short_slot_allowed = (WILC_Uint8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed; + } else { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + u8WidCnt++; + } + if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & TXOP_PROT_DISABLE) { + /*Description: used to Disable RTS-CTS protection for TXOP burst*/ + /*transmission when the acknowledgement policy is No-Ack or Block-Ack */ + /* this information is useful for external supplicant */ + /*Input Values: 1 for enable and 0 for disable. */ + if (strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled < 2) { + strWIDList[u8WidCnt].u16WIDid = WID_11N_TXOP_PROT_DISABLE; + strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled; + strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; + strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); + pstrWFIDrv->strCfgValues.txop_prot_disabled = (WILC_Uint8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled; + } else { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + u8WidCnt++; + } + if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BEACON_INTERVAL) { + /* range is 1 to 65535. */ + if (strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval < 65536) { + strWIDList[u8WidCnt].u16WIDid = WID_BEACON_INTERVAL; + strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval; + strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; + strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16); + pstrWFIDrv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval; + } else { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + u8WidCnt++; + } + if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & DTIM_PERIOD) { + /* range is 1 to 255. */ + if (strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period < 256) { + strWIDList[u8WidCnt].u16WIDid = WID_DTIM_PERIOD; + strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period; + strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; + strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); + pstrWFIDrv->strCfgValues.dtim_period = strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period; + } else { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + u8WidCnt++; + } + if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY) { + /*----------------------------------------------------------------------*/ + /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */ + /* SITE_SURVEY_ALL_CH = 1, */ + /* SITE_SURVEY_OFF = 2 */ + /*----------------------------------------------------------------------*/ + if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled < 3) { + strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY; + strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled; + strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; + strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); + pstrWFIDrv->strCfgValues.site_survey_enabled = (WILC_Uint8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled; + } else { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + u8WidCnt++; + } + if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY_SCAN_TIME) { + /* range is 1 to 65535. */ + if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time < 65536) { + strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY_SCAN_TIME; + strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time; + strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; + strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16); + pstrWFIDrv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time; + } else { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + u8WidCnt++; + } + if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & ACTIVE_SCANTIME) { + /* range is 1 to 65535. */ + if (strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time < 65536) { + strWIDList[u8WidCnt].u16WIDid = WID_ACTIVE_SCAN_TIME; + strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time; + strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; + strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16); + pstrWFIDrv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time; + } else { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + u8WidCnt++; + } + if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PASSIVE_SCANTIME) { + /* range is 1 to 65535. */ + if (strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time < 65536) { + strWIDList[u8WidCnt].u16WIDid = WID_PASSIVE_SCAN_TIME; + strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time; + strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; + strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16); + pstrWFIDrv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time; + } else { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + u8WidCnt++; + } + if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & CURRENT_TX_RATE) { + CURRENT_TX_RATE_T curr_tx_rate = strHostIFCfgParamAttr->pstrCfgParamVal.curr_tx_rate; + /*----------------------------------------------------------------------*/ + /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */ + /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */ + /*----------------------------------------------------------------------*/ + /* validate rate */ + if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1 + || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5 + || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6 + || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12 + || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24 + || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) { + strWIDList[u8WidCnt].u16WIDid = WID_CURRENT_TX_RATE; + strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&curr_tx_rate; + strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; + strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16); + pstrWFIDrv->strCfgValues.curr_tx_rate = (WILC_Uint8)curr_tx_rate; + } else { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + u8WidCnt++; + } + s32Error = SendConfigPkt(SET_CFG, strWIDList, u8WidCnt, WILC_FALSE, (WILC_Uint32)pstrWFIDrv); + + if (s32Error) { + PRINT_ER("Error in setting CFG params\n"); + + } + WILC_CATCH(s32Error) + { + } + WILC_SemaphoreRelease(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + return s32Error; +} + + +/** + * @brief Handle_wait_msg_q_empty + * @details this should be the last msg and then the msg Q becomes idle + * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr + * @return Error code. + * @author + * @date + * @version 1.0 + */ +static WILC_Sint32 Handle_wait_msg_q_empty(void) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + g_wilc_initialized = 0; + WILC_SemaphoreRelease(&hWaitResponse, NULL); + return s32Error; +} + +/** + * @brief Handle_Scan + * @details Sending config packet to firmware to set the scan params + * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr + * @return Error code. + * @author + * @date + * @version 1.0 + */ +static WILC_Sint32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFscanAttr) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWIDList[5]; + WILC_Uint32 u32WidsCount = 0; + WILC_Uint32 i; + WILC_Uint8 *pu8Buffer; + WILC_Uint8 valuesize = 0; + WILC_Uint8 *pu8HdnNtwrksWidVal = NULL; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler; + + PRINT_D(HOSTINF_DBG, "Setting SCAN params\n"); + PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state \n", pstrWFIDrv->enuHostIFstate); + + pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->pfScanResult; + pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->pvUserArg; + + #ifdef WILC_P2P + #if 0 + if (pstrWFIDrv->enuHostIFstate == HOST_IF_P2P_LISTEN || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED && pstrWFIDrv->u8P2PConnect)) { + PRINT_INFO(GENERIC_DBG, "Busy: State: %d\n", pstrWFIDrv->enuHostIFstate); + PRINT_INFO(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n", jiffies, pstrWFIDrv->u64P2p_MgmtTimeout); + WILC_ERRORREPORT(s32Error, WILC_BUSY); + } + #endif + #endif + + if ((pstrWFIDrv->enuHostIFstate >= HOST_IF_SCANNING) && (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTED)) { + /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */ + PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", pstrWFIDrv->enuHostIFstate); + WILC_ERRORREPORT(s32Error, WILC_BUSY); + } + + #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP + if (g_obtainingIP || connecting) { + PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n"); + WILC_ERRORREPORT(s32Error, WILC_BUSY); + } + #endif + + PRINT_D(HOSTINF_DBG, "Setting SCAN params\n"); + + + pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount = 0; + + /*BugID_4189*/ + strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_SSID_PROBE_REQ; + strWIDList[u32WidsCount].enuWIDtype = WID_STR; + + for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) { + valuesize += ((pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen) + 1); + } + pu8HdnNtwrksWidVal = WILC_MALLOC(valuesize + 1); + strWIDList[u32WidsCount].ps8WidVal = pu8HdnNtwrksWidVal; + if (strWIDList[u32WidsCount].ps8WidVal != WILC_NULL) { + pu8Buffer = strWIDList[u32WidsCount].ps8WidVal; + + *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; + + PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum); + + for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) { + *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen; + WILC_memcpy(pu8Buffer, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen); + pu8Buffer += pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen; + } + + + + strWIDList[u32WidsCount].s32ValueSize = (WILC_Sint32)(valuesize + 1); + u32WidsCount++; + } + + /*filling cfg param array*/ + + /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */ + { + /* IEs to be inserted in Probe Request */ + strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_PROBE; + strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA; + strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8IEs; + strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->IEsLen; + u32WidsCount++; + } + + /*Scan Type*/ + strWIDList[u32WidsCount].u16WIDid = WID_SCAN_TYPE; + strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; + strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); + strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFscanAttr->u8ScanType)); + u32WidsCount++; + + /*list of channels to be scanned*/ + strWIDList[u32WidsCount].u16WIDid = WID_SCAN_CHANNEL_LIST; + strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA; + + /* Bug 4648: Convert channel numbers to start from 0 not 1. */ + if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL && pstrHostIFscanAttr->u8ChnlListLen > 0) { + int i; + + for (i = 0; i < pstrHostIFscanAttr->u8ChnlListLen; i++) { + if (pstrHostIFscanAttr->pu8ChnlFreqList[i] > 0) { + pstrHostIFscanAttr->pu8ChnlFreqList[i] = pstrHostIFscanAttr->pu8ChnlFreqList[i] - 1; + } + } + } + + strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8ChnlFreqList; + strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->u8ChnlListLen; + u32WidsCount++; + + /*Scan Request*/ + strWIDList[u32WidsCount].u16WIDid = WID_START_SCAN_REQ; + strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; + strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); + strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFscanAttr->u8ScanSource)); + u32WidsCount++; + + /*keep the state as is , no need to change it*/ + /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */ + + if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) { + gbScanWhileConnected = WILC_TRUE; + } else if (pstrWFIDrv->enuHostIFstate == HOST_IF_IDLE) { + gbScanWhileConnected = WILC_FALSE; + } + + s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, WILC_FALSE, (WILC_Uint32)pstrWFIDrv); + + if (s32Error) { + PRINT_ER("Failed to send scan paramters config packet\n"); + WILC_ERRORREPORT(s32Error, s32Error); + } else { + PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n"); + } + + WILC_CATCH(s32Error) + { + WILC_TimerStop(&(pstrWFIDrv->hScanTimer), WILC_NULL); + /*if there is an ongoing scan request*/ + Handle_ScanDone(drvHandler, SCAN_EVENT_ABORTED); + } + + /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */ + if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) { + WILC_FREE(pstrHostIFscanAttr->pu8ChnlFreqList); + pstrHostIFscanAttr->pu8ChnlFreqList = NULL; + } + + /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */ + if (pstrHostIFscanAttr->pu8IEs != NULL) { + WILC_FREE(pstrHostIFscanAttr->pu8IEs); + pstrHostIFscanAttr->pu8IEs = NULL; + } + if (pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo != NULL) { + WILC_FREE(pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo); + pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo = NULL; + } + + /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */ + if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) { + WILC_FREE(pstrHostIFscanAttr->pu8ChnlFreqList); + pstrHostIFscanAttr->pu8ChnlFreqList = NULL; + } + + if (pu8HdnNtwrksWidVal != NULL) { + WILC_FREE(pu8HdnNtwrksWidVal); + } + + return s32Error; +} + +/** + * @brief Handle_ScanDone + * @details Call scan notification callback function + * @param[in] NONE + * @return Error code. + * @author + * @date + * @version 1.0 + */ +static WILC_Sint32 Handle_ScanDone(void *drvHandler, tenuScanEvent enuEvent) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + + + WILC_Uint8 u8abort_running_scan; + tstrWID strWID; + + + PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n"); + + /*BugID_4978*/ + /*Ask FW to abort the running scan, if any*/ + if (enuEvent == SCAN_EVENT_ABORTED) { + PRINT_D(GENERIC_DBG, "Abort running scan\n"); + u8abort_running_scan = 1; + strWID.u16WIDid = (WILC_Uint16)WID_ABORT_RUNNING_SCAN; + strWID.enuWIDtype = WID_CHAR; + strWID.ps8WidVal = (WILC_Sint8 *)&u8abort_running_scan; + strWID.s32ValueSize = sizeof(WILC_Char); + + /*Sending Cfg*/ + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + if (s32Error != WILC_SUCCESS) { + PRINT_ER("Failed to set abort running scan\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + WILC_CATCH(s32Error) + { + } + } + + if (pstrWFIDrv == NULL) { + PRINT_ER("Driver handler is NULL\n"); + return s32Error; + } + + /*if there is an ongoing scan request*/ + if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) { + pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, WILC_NULL, + pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL); + /*delete current scan request*/ + pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL; + } + + return s32Error; +} + +/** + * @brief Handle_Connect + * @details Sending config packet to firmware to starting connection + * @param[in] tstrHostIFconnectAttr* pstrHostIFconnectAttr + * @return Error code. + * @author + * @date + * @version 1.0 + */ +WILC_Uint8 u8ConnectedSSID[6] = {0}; +static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFconnectAttr) +{ + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler; + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWIDList[8]; + WILC_Uint32 u32WidsCount = 0, dummyval = 0; + /* char passphrase[] = "12345678"; */ + #ifndef CONNECT_DIRECT + WILC_Sint32 s32Err = WILC_SUCCESS; + WILC_Uint32 i; + WILC_Uint8 u8bssDscListIndex; + wid_site_survey_reslts_s *pstrSurveyResults = WILC_NULL; + #else + WILC_Uint8 *pu8CurrByte = WILC_NULL; + /*Bug4218: Parsing Join Param*/ + #ifdef WILC_PARSE_SCAN_IN_HOST + tstrJoinBssParam *ptstrJoinBssParam; + #endif /*WILC_PARSE_SCAN_IN_HOST*/ + + #endif + + PRINT_D(GENERIC_DBG, "Handling connect request\n"); + + #ifndef CONNECT_DIRECT + WILC_memset(gapu8RcvdSurveyResults[0], 0, MAX_SURVEY_RESULT_FRAG_SIZE); + WILC_memset(gapu8RcvdSurveyResults[1], 0, MAX_SURVEY_RESULT_FRAG_SIZE); + + + PRINT_D(HOSTINF_DBG, "Getting site survey results\n"); + s32Err = host_int_get_site_survey_results((WILC_WFIDrvHandle)pstrWFIDrv, + gapu8RcvdSurveyResults, + MAX_SURVEY_RESULT_FRAG_SIZE); + if (s32Err) { + PRINT_ER("Failed to get site survey results\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + + } + s32Err = ParseSurveyResults(gapu8RcvdSurveyResults, &pstrSurveyResults, + &pstrWFIDrv->u32SurveyResultsCount); + + + if (s32Err == WILC_SUCCESS) { + /* use the parsed info in pstrSurveyResults, then deallocate it */ + PRINT_D(HOSTINF_DBG, "Copying site survey results in global structure, then deallocate\n"); + for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) { + WILC_memcpy(&pstrWFIDrv->astrSurveyResults[i], &pstrSurveyResults[i], + sizeof(wid_site_survey_reslts_s)); + } + + DeallocateSurveyResults(pstrSurveyResults); + } else { + WILC_ERRORREPORT(s32Error, WILC_FAIL); + PRINT_ER("ParseSurveyResults() Error(%d) \n", s32Err); + } + + + for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) { + if (WILC_memcmp(pstrWFIDrv->astrSurveyResults[i].SSID, + pstrHostIFconnectAttr->pu8ssid, + pstrHostIFconnectAttr->ssidLen) == 0) { + PRINT_INFO(HOSTINF_DBG, "Network with required SSID is found %s\n", pstrHostIFconnectAttr->pu8ssid); + if (pstrHostIFconnectAttr->pu8bssid == NULL) { + /* BSSID is not passed from the user, so decision of matching + * is done by SSID only */ + PRINT_INFO(HOSTINF_DBG, "BSSID is not passed from the user\n"); + break; + } else { + /* BSSID is also passed from the user, so decision of matching + * should consider also this passed BSSID */ + + if (WILC_memcmp(pstrWFIDrv->astrSurveyResults[i].BSSID, + pstrHostIFconnectAttr->pu8bssid, + 6) == 0) { + PRINT_INFO(HOSTINF_DBG, "BSSID is passed from the user and matched\n"); + break; + } + } + } + } + + if (i < pstrWFIDrv->u32SurveyResultsCount) { + u8bssDscListIndex = i; + + PRINT_INFO(HOSTINF_DBG, "Connecting to network of Bss Idx %d and SSID %s and channel %d \n", + u8bssDscListIndex, pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].SSID, + pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].Channel); + + PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n"); + + if (pstrHostIFconnectAttr->pu8bssid != NULL) { + pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = (WILC_Uint8 *)WILC_MALLOC(6); + WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6); + } + + pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen; + if (pstrHostIFconnectAttr->pu8ssid != NULL) { + pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = (WILC_Uint8 *)WILC_MALLOC(pstrHostIFconnectAttr->ssidLen + 1); + WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid, + pstrHostIFconnectAttr->ssidLen); + pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0'; + } + + pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen; + if (pstrHostIFconnectAttr->pu8IEs != NULL) { + pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = (WILC_Uint8 *)WILC_MALLOC(pstrHostIFconnectAttr->IEsLen); + WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs, + pstrHostIFconnectAttr->IEsLen); + } + + pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security; + pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type; + pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult; + pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg; + + + /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */ + /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */ + { + /* IEs to be inserted in Association Request */ + strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE; + strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA; + strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs; + strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen; + u32WidsCount++; + } + strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_11I_MODE; + strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; + strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); + strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security)); + u32WidsCount++; + + PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security); + + strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_AUTH_TYPE; + strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; + strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); + strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type); + u32WidsCount++; + + PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type); + /* + * strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_11I_PSK; + * strWIDList[u32WidsCount].enuWIDtype = WID_STR; + * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase); + * strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8*)(passphrase); + * u32WidsCount++; + */ + + strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_JOIN_REQ; + strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; + strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); + strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)&u8bssDscListIndex; + u32WidsCount++; + + #ifndef SIMULATION + /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the + * firmware at chip reset when processing the WIDs of the Connect Request. + * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */ + /* ////////////////////// */ + gu32WidConnRstHack = 0; + /* ////////////////////// */ + #endif + + s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, WILC_FALSE, (WILC_Uint32)pstrWFIDrv); + if (s32Error) { + PRINT_ER("Handle_Connect()] failed to send config packet\n"); + WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); + } else { + pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP; + } + + } else { + PRINT_ER("Required BSSID not found\n"); + WILC_ERRORREPORT(s32Error, WILC_NOT_FOUND); + } + + #else + + /* if we try to connect to an already connected AP then discard the request */ + + if (WILC_memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) { + + s32Error = WILC_SUCCESS; + PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n"); + return s32Error; + } + + PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n"); + + /*Bug4218: Parsing Join Param*/ + #ifdef WILC_PARSE_SCAN_IN_HOST + ptstrJoinBssParam = (tstrJoinBssParam *)pstrHostIFconnectAttr->pJoinParams; + if (ptstrJoinBssParam == NULL) { + PRINT_ER("Required BSSID not found\n"); + WILC_ERRORREPORT(s32Error, WILC_NOT_FOUND); + } + #endif /*WILC_PARSE_SCAN_IN_HOST*/ + +#if 0 + /* if we try to connect to an already connected AP then discard the request */ + PRINT_D(GENERIC_DBG, "Bssid = %x:%x:%x:%x:%x:%x\n", (pstrHostIFconnectAttr->pu8bssid[0]), (pstrHostIFconnectAttr->pu8bssid[1]), (pstrHostIFconnectAttr->pu8bssid[2]), (pstrHostIFconnectAttr->pu8bssid[3]), (pstrHostIFconnectAttr->pu8bssid[4]), (pstrHostIFconnectAttr->pu8bssid[5])); + PRINT_D(GENERIC_DBG, "bssid = %x:%x:%x:%x:%x:%x\n", (u8ConnectedSSID[0]), (u8ConnectedSSID[1]), (u8ConnectedSSID[2]), (u8ConnectedSSID[3]), (u8ConnectedSSID[4]), (u8ConnectedSSID[5])); + if (WILC_memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) { + PRINT_ER("Discard connect request\n"); + s32Error = WILC_FAIL; + return s32Error; + } +#endif + + if (pstrHostIFconnectAttr->pu8bssid != NULL) { + pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = (WILC_Uint8 *)WILC_MALLOC(6); + WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6); + } + + pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen; + if (pstrHostIFconnectAttr->pu8ssid != NULL) { + pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = (WILC_Uint8 *)WILC_MALLOC(pstrHostIFconnectAttr->ssidLen + 1); + WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid, + pstrHostIFconnectAttr->ssidLen); + pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0'; + } + + pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen; + if (pstrHostIFconnectAttr->pu8IEs != NULL) { + pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = (WILC_Uint8 *)WILC_MALLOC(pstrHostIFconnectAttr->IEsLen); + WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs, + pstrHostIFconnectAttr->IEsLen); + } + + pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security; + pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type; + pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult; + pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg; + + strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT; + strWIDList[u32WidsCount].enuWIDtype = WID_INT; + strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Uint32); + strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(dummyval)); + u32WidsCount++; + + strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT; + strWIDList[u32WidsCount].enuWIDtype = WID_INT; + strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Uint32); + strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(dummyval)); + u32WidsCount++; + + strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT; + strWIDList[u32WidsCount].enuWIDtype = WID_INT; + strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Uint32); + strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(dummyval)); + u32WidsCount++; + + /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */ + /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */ + { + /* IEs to be inserted in Association Request */ + strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE; + strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA; + strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs; + strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen; + u32WidsCount++; + + /*BugID_5137*/ + if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) { + + gu32FlushedInfoElemAsocSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen; + gu8FlushedInfoElemAsoc = WILC_MALLOC(gu32FlushedInfoElemAsocSize); + memcpy(gu8FlushedInfoElemAsoc, pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, + gu32FlushedInfoElemAsocSize); + } + } + strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_11I_MODE; + strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; + strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); + strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security)); + u32WidsCount++; + + /*BugID_5137*/ + if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) + gu8Flushed11iMode = pstrWFIDrv->strWILC_UsrConnReq.u8security; + + PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security); + + + strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_AUTH_TYPE; + strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; + strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); + strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type); + u32WidsCount++; + + /*BugID_5137*/ + if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) + gu8FlushedAuthType = (WILC_Uint8)pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type; + + PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type); + /* + * strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_11I_PSK; + * strWIDList[u32WidsCount].enuWIDtype = WID_STR; + * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase); + * strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8*)(passphrase); + * u32WidsCount++; + */ + + PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n", + pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->u8channel); + + +#ifndef WILC_PARSE_SCAN_IN_HOST + strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_JOIN_REQ_EXTENDED; + strWIDList[u32WidsCount].enuWIDtype = WID_STR; + strWIDList[u32WidsCount].s32ValueSize = MAX_SSID_LEN + 7; + strWIDList[u32WidsCount].ps8WidVal = WILC_MALLOC(strWIDList[u32WidsCount].s32ValueSize); + + if (strWIDList[u32WidsCount].ps8WidVal == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_NO_MEM); + } + + pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal; + + if (pstrHostIFconnectAttr->pu8ssid != NULL) { + WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen); + pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0'; + } + pu8CurrByte += MAX_SSID_LEN; + if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) { + *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel; + } else { + PRINT_ER("Channel out of range\n"); + *(pu8CurrByte++) = 0xFF; + } + if (pstrHostIFconnectAttr->pu8bssid != NULL) { + WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6); + } + pu8CurrByte += 6; + + /* keep the buffer at the start of the allocated pointer to use it with the free*/ + pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal; + + #else + + strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_JOIN_REQ_EXTENDED; + strWIDList[u32WidsCount].enuWIDtype = WID_STR; + + /*Sending NoA attributes during connection*/ + strWIDList[u32WidsCount].s32ValueSize = 112; /* 79; */ + strWIDList[u32WidsCount].ps8WidVal = WILC_MALLOC(strWIDList[u32WidsCount].s32ValueSize); + + /*BugID_5137*/ + if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) { + gu32FlushedJoinReqSize = strWIDList[u32WidsCount].s32ValueSize; + gu8FlushedJoinReq = WILC_MALLOC(gu32FlushedJoinReqSize); + } + if (strWIDList[u32WidsCount].ps8WidVal == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_NO_MEM); + } + + pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal; + + + if (pstrHostIFconnectAttr->pu8ssid != NULL) { + WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen); + pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0'; + } + pu8CurrByte += MAX_SSID_LEN; + + /* BSS type*/ + *(pu8CurrByte++) = INFRASTRUCTURE; + /* Channel*/ + if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) { + *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel; + } else { + PRINT_ER("Channel out of range\n"); + *(pu8CurrByte++) = 0xFF; + } + /* Cap Info*/ + *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF; + *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF; + PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8))); + + /* sa*/ + if (pstrHostIFconnectAttr->pu8bssid != NULL) { + WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6); + } + pu8CurrByte += 6; + + /* bssid*/ + if (pstrHostIFconnectAttr->pu8bssid != NULL) { + WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6); + } + pu8CurrByte += 6; + + /* Beacon Period*/ + *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF; + *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF; + PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8))); + /* DTIM Period*/ + *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period; + PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1))); + /* Supported rates*/ + WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1); + pu8CurrByte += (MAX_RATES_SUPPORTED + 1); + + /* wmm cap*/ + *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap; + PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1))); + /* uapsd cap*/ + *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap; + + /* ht cap*/ + *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable; + /* copy this information to the user request */ + pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable; + + /* rsn found*/ + *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found; + PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1)); + /* rsn group policy*/ + *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy; + PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1))); + /* mode_802_11i*/ + *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i; + PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1))); + /* rsn pcip policy*/ + WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy)); + pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy); + + /* rsn auth policy*/ + WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy)); + pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy); + + /* rsn auth policy*/ + WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap)); + pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap); + + /*BugID_5137*/ + *(pu8CurrByte++) = REAL_JOIN_REQ; + + #ifdef WILC_P2P + *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled; + if (ptstrJoinBssParam->u8NoaEnbaled) { + PRINT_D(HOSTINF_DBG, "NOA present\n"); + + *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF; + *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF; + *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF; + *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF; + + *(pu8CurrByte++) = ptstrJoinBssParam->u8Index; + + *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable; + + if (ptstrJoinBssParam->u8OppEnable) + *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow; + + *(pu8CurrByte++) = ptstrJoinBssParam->u8Count; + + WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration)); + + pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration); + + WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval)); + + pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval); + + WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime)); + + pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime); + + } else + PRINT_D(HOSTINF_DBG, "NOA not present\n"); + #endif + + + /* keep the buffer at the start of the allocated pointer to use it with the free*/ + pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal; + + + #endif /* #ifdef WILC_PARSE_SCAN_IN_HOST*/ + u32WidsCount++; + + #ifndef SIMULATION + /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the + * firmware at chip reset when processing the WIDs of the Connect Request. + * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */ + /* ////////////////////// */ + gu32WidConnRstHack = 0; + /* ////////////////////// */ + #endif + + /*BugID_5137*/ + if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) { + memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize); + gu8FlushedJoinReqDrvHandler = (WILC_Uint32)pstrWFIDrv; + } + + PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n"); + + if (pstrHostIFconnectAttr->pu8bssid != NULL) { + WILC_memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->pu8bssid, ETH_ALEN); + + PRINT_D(GENERIC_DBG, "save Bssid = %x:%x:%x:%x:%x:%x\n", (pstrHostIFconnectAttr->pu8bssid[0]), (pstrHostIFconnectAttr->pu8bssid[1]), (pstrHostIFconnectAttr->pu8bssid[2]), (pstrHostIFconnectAttr->pu8bssid[3]), (pstrHostIFconnectAttr->pu8bssid[4]), (pstrHostIFconnectAttr->pu8bssid[5])); + PRINT_D(GENERIC_DBG, "save bssid = %x:%x:%x:%x:%x:%x\n", (u8ConnectedSSID[0]), (u8ConnectedSSID[1]), (u8ConnectedSSID[2]), (u8ConnectedSSID[3]), (u8ConnectedSSID[4]), (u8ConnectedSSID[5])); + } + + s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, WILC_FALSE, (WILC_Uint32)pstrWFIDrv); + if (s32Error) { + PRINT_ER("Handle_Connect()] failed to send config packet\n"); + WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); + } else { + PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n"); + pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP; + } + #endif + + WILC_CATCH(s32Error) + { + tstrConnectInfo strConnectInfo; + + WILC_TimerStop(&(pstrWFIDrv->hConnectTimer), WILC_NULL); + + PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n"); + + WILC_memset(&strConnectInfo, 0, sizeof(tstrConnectInfo)); + + if (pstrHostIFconnectAttr->pfConnectResult != NULL) { + if (pstrHostIFconnectAttr->pu8bssid != NULL) { + WILC_memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->pu8bssid, 6); + } + + if (pstrHostIFconnectAttr->pu8IEs != NULL) { + strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen; + strConnectInfo.pu8ReqIEs = (WILC_Uint8 *)WILC_MALLOC(pstrHostIFconnectAttr->IEsLen); + WILC_memcpy(strConnectInfo.pu8ReqIEs, + pstrHostIFconnectAttr->pu8IEs, + pstrHostIFconnectAttr->IEsLen); + } + + pstrHostIFconnectAttr->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP, + &strConnectInfo, + MAC_DISCONNECTED, + NULL, + pstrHostIFconnectAttr->pvUserArg); + /*Change state to idle*/ + pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE; + /* Deallocation */ + if (strConnectInfo.pu8ReqIEs != NULL) { + WILC_FREE(strConnectInfo.pu8ReqIEs); + strConnectInfo.pu8ReqIEs = NULL; + } + + } else { + PRINT_ER("Connect callback function pointer is NULL \n"); + } + } + + PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n"); + /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */ + if (pstrHostIFconnectAttr->pu8bssid != NULL) { + WILC_FREE(pstrHostIFconnectAttr->pu8bssid); + pstrHostIFconnectAttr->pu8bssid = NULL; + } + + /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */ + if (pstrHostIFconnectAttr->pu8ssid != NULL) { + WILC_FREE(pstrHostIFconnectAttr->pu8ssid); + pstrHostIFconnectAttr->pu8ssid = NULL; + } + + /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */ + if (pstrHostIFconnectAttr->pu8IEs != NULL) { + WILC_FREE(pstrHostIFconnectAttr->pu8IEs); + pstrHostIFconnectAttr->pu8IEs = NULL; + } + + if (pu8CurrByte != WILC_NULL) { + WILC_FREE(pu8CurrByte); + } + return s32Error; +} + +/** + * @brief Handle_FlushConnect + * @details Sending config packet to firmware to flush an old connection + * after switching FW from station one to hybrid one + * @param[in] void * drvHandler + * @return Error code. + * @author Amr Abdel-Moghny + * @date 19 DEC 2013 + * @version 8.0 + */ + +static WILC_Sint32 Handle_FlushConnect(void *drvHandler) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWIDList[5]; + WILC_Uint32 u32WidsCount = 0; + WILC_Uint8 *pu8CurrByte = WILC_NULL; + + + /* IEs to be inserted in Association Request */ + strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE; + strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA; + strWIDList[u32WidsCount].ps8WidVal = gu8FlushedInfoElemAsoc; + strWIDList[u32WidsCount].s32ValueSize = gu32FlushedInfoElemAsocSize; + u32WidsCount++; + + strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_11I_MODE; + strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; + strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); + strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(gu8Flushed11iMode)); + u32WidsCount++; + + + + strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_AUTH_TYPE; + strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; + strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); + strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&gu8FlushedAuthType); + u32WidsCount++; + + + #ifdef WILC_PARSE_SCAN_IN_HOST + strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_JOIN_REQ_EXTENDED; + strWIDList[u32WidsCount].enuWIDtype = WID_STR; + strWIDList[u32WidsCount].s32ValueSize = gu32FlushedJoinReqSize; + strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)gu8FlushedJoinReq; + pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal; + + pu8CurrByte += FLUSHED_BYTE_POS; + *(pu8CurrByte) = FLUSHED_JOIN_REQ; + + u32WidsCount++; + + #endif + + s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, WILC_FALSE, gu8FlushedJoinReqDrvHandler); + if (s32Error) { + PRINT_ER("Handle_Flush_Connect()] failed to send config packet\n"); + WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); + } + + WILC_CATCH(s32Error) + { + + } + + return s32Error; +} + +/** + * @brief Handle_ConnectTimeout + * @details Call connect notification callback function indicating connection failure + * @param[in] NONE + * @return Error code. + * @author + * @date + * @version 1.0 + */ +static WILC_Sint32 Handle_ConnectTimeout(void *drvHandler) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrConnectInfo strConnectInfo; + tstrWID strWID; + WILC_Uint16 u16DummyReasonCode = 0; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler; + + if (pstrWFIDrv == NULL) { + PRINT_ER("Driver handler is NULL\n"); + return s32Error; + } + + pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE; + + gbScanWhileConnected = WILC_FALSE; + + + WILC_memset(&strConnectInfo, 0, sizeof(tstrConnectInfo)); + + + /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function}, + * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying + * WID_DISCONNECT} */ + if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) { + if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) { + WILC_memcpy(strConnectInfo.au8bssid, + pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6); + } + + if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) { + strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen; + strConnectInfo.pu8ReqIEs = (WILC_Uint8 *)WILC_MALLOC(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen); + WILC_memcpy(strConnectInfo.pu8ReqIEs, + pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, + pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen); + } + + pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP, + &strConnectInfo, + MAC_DISCONNECTED, + NULL, + pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid); + + /* Deallocation of strConnectInfo.pu8ReqIEs */ + if (strConnectInfo.pu8ReqIEs != NULL) { + WILC_FREE(strConnectInfo.pu8ReqIEs); + strConnectInfo.pu8ReqIEs = NULL; + } + } else { + PRINT_ER("Connect callback function pointer is NULL \n"); + } + + /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying + * WID_DISCONNECT} */ + strWID.u16WIDid = (WILC_Uint16)WID_DISCONNECT; + strWID.enuWIDtype = WID_CHAR; + strWID.ps8WidVal = (WILC_Sint8 *)&u16DummyReasonCode; + strWID.s32ValueSize = sizeof(WILC_Char); + + PRINT_D(HOSTINF_DBG, "Sending disconnect request\n"); + + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)pstrWFIDrv); + if (s32Error) { + PRINT_ER("Failed to send dissconect config packet\n"); + } + + /* Deallocation of the Saved Connect Request in the global Handle */ + pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0; + if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) { + WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid); + pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL; + } + + if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) { + WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid); + pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL; + } + + pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0; + if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) { + WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs); + pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL; + } + + WILC_memset(u8ConnectedSSID, 0, ETH_ALEN); + /*BugID_5213*/ + /*Freeing flushed join request params on connect timeout*/ + if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (WILC_Uint32)drvHandler) { + WILC_FREE(gu8FlushedJoinReq); + gu8FlushedJoinReq = NULL; + } + if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (WILC_Uint32)drvHandler) { + WILC_FREE(gu8FlushedInfoElemAsoc); + gu8FlushedInfoElemAsoc = NULL; + } + + return s32Error; +} + +/** + * @brief Handle_RcvdNtwrkInfo + * @details Handling received network information + * @param[in] tstrRcvdNetworkInfo* pstrRcvdNetworkInfo + * @return Error code. + * @author + * @date + * @version 1.0 + */ +static WILC_Sint32 Handle_RcvdNtwrkInfo(void *drvHandler, tstrRcvdNetworkInfo *pstrRcvdNetworkInfo) +{ + WILC_Uint32 i; + WILC_Bool bNewNtwrkFound; + + + + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrNetworkInfo *pstrNetworkInfo = NULL; + void *pJoinParams = NULL; + + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + + + + bNewNtwrkFound = WILC_TRUE; + PRINT_INFO(HOSTINF_DBG, "Handling received network info\n"); + + /*if there is a an ongoing scan request*/ + if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) { + PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n"); + ParseNetworkInfo(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo); + if ((pstrNetworkInfo == NULL) + || (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult == WILC_NULL)) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + /* check whether this network is discovered before */ + for (i = 0; i < pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount; i++) { + + if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) && + (pstrNetworkInfo->au8bssid != NULL)) { + if (WILC_memcmp(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid, + pstrNetworkInfo->au8bssid, 6) == 0) { + if (pstrNetworkInfo->s8rssi <= pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) { + /*we have already found this network with better rssi, so keep the old cached one and don't + * send anything to the upper layer */ + PRINT_D(HOSTINF_DBG, "Network previously discovered\n"); + goto done; + } else { + /* here the same already found network is found again but with a better rssi, so just update + * the rssi for this cached network and send this updated network to the upper layer but + * don't add a new record for it */ + pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi; + bNewNtwrkFound = WILC_FALSE; + break; + } + } + } + } + + if (bNewNtwrkFound == WILC_TRUE) { + /* here it is confirmed that it is a new discovered network, + * so add its record then call the User CallBack function */ + + PRINT_D(HOSTINF_DBG, "New network found\n"); + + if (pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { + pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi; + + if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL) + && (pstrNetworkInfo->au8bssid != NULL)) { + WILC_memcpy(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid, + pstrNetworkInfo->au8bssid, 6); + + pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount++; + + pstrNetworkInfo->bNewNetwork = WILC_TRUE; + /*Bug4218: Parsing Join Param*/ + /* add new BSS to JoinBssTable */ + #ifdef WILC_PARSE_SCAN_IN_HOST + pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo); + #endif /*WILC_PARSE_SCAN_IN_HOST*/ + + pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo, + pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, + pJoinParams); + + + } + } else { + PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit \n"); + } + } else { + pstrNetworkInfo->bNewNetwork = WILC_FALSE; + /* just call the User CallBack function to send the same discovered network with its updated RSSI */ + pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo, + pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL); + } + } + + + WILC_CATCH(s32Error) + { + + } + +done: + /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */ + if (pstrRcvdNetworkInfo->pu8Buffer != NULL) { + WILC_FREE(pstrRcvdNetworkInfo->pu8Buffer); + pstrRcvdNetworkInfo->pu8Buffer = NULL; + } + + /*free structure allocated*/ + if (pstrNetworkInfo != WILC_NULL) { + DeallocateNetworkInfo(pstrNetworkInfo); + pstrNetworkInfo = WILC_NULL; + } + + return s32Error; +} + +/** + * @brief Handle_RcvdGnrlAsyncInfo + * @details Handling received asynchrous general network information + * @param[in] tstrRcvdGnrlAsyncInfo* pstrRcvdGnrlAsyncInfo + * @return Error code. + * @author + * @date + * @version 1.0 + */ +static WILC_Sint32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncInfo *pstrRcvdGnrlAsyncInfo) +{ + /* TODO: mostafa: till now, this function just handles only the received mac status msg, */ + /* which carries only 1 WID which have WID ID = WID_STATUS */ + WILC_Sint32 s32Error = WILC_SUCCESS; + WILC_Uint8 u8MsgType = 0; + WILC_Uint8 u8MsgID = 0; + WILC_Uint16 u16MsgLen = 0; + WILC_Uint16 u16WidID = (WILC_Uint16)WID_NIL; + WILC_Uint8 u8WidLen = 0; + WILC_Uint8 u8MacStatus; + WILC_Uint8 u8MacStatusReasonCode; + WILC_Uint8 u8MacStatusAdditionalInfo; + tstrConnectInfo strConnectInfo; + tstrDisconnectNotifInfo strDisconnectNotifInfo; + WILC_Sint32 s32Err = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler; + if (pstrWFIDrv == NULL) { + PRINT_ER("Driver handler is NULL\n"); + } + PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", pstrWFIDrv->enuHostIFstate, + pstrRcvdGnrlAsyncInfo->pu8Buffer[7]); + + if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || + (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) || + pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) { + if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) || + (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == WILC_NULL)) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + u8MsgType = pstrRcvdGnrlAsyncInfo->pu8Buffer[0]; + + /* Check whether the received message type is 'I' */ + if ('I' != u8MsgType) { + PRINT_ER("Received Message format incorrect.\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + + /* Extract message ID */ + u8MsgID = pstrRcvdGnrlAsyncInfo->pu8Buffer[1]; + + /* Extract message Length */ + u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[2], pstrRcvdGnrlAsyncInfo->pu8Buffer[3]); + + /* Extract WID ID [expected to be = WID_STATUS] */ + u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[4], pstrRcvdGnrlAsyncInfo->pu8Buffer[5]); + + /* Extract WID Length [expected to be = 1] */ + u8WidLen = pstrRcvdGnrlAsyncInfo->pu8Buffer[6]; + + /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */ + u8MacStatus = pstrRcvdGnrlAsyncInfo->pu8Buffer[7]; + u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->pu8Buffer[8]; + u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->pu8Buffer[9]; + PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo); + if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) { + /* our station had sent Association Request frame, so here it will get the Association Response frame then parse it */ + WILC_Uint32 u32RcvdAssocRespInfoLen; + tstrConnectRespInfo *pstrConnectRespInfo = NULL; + + PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo); + + WILC_memset(&strConnectInfo, 0, sizeof(tstrConnectInfo)); + + if (u8MacStatus == MAC_CONNECTED) { + WILC_memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE); + + host_int_get_assoc_res_info((WILC_WFIDrvHandle)pstrWFIDrv, + gapu8RcvdAssocResp, + MAX_ASSOC_RESP_FRAME_SIZE, + &u32RcvdAssocRespInfoLen); + + PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen); + + if (u32RcvdAssocRespInfoLen != 0) { + + PRINT_D(HOSTINF_DBG, "Parsing association response\n"); + s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen, + &pstrConnectRespInfo); + if (s32Err) { + PRINT_ER("ParseAssocRespInfo() returned error %d \n", s32Err); + } else { + /* use the necessary parsed Info from the Received Association Response */ + strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus; + + if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) { + PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n"); + if (pstrConnectRespInfo->pu8RespIEs != NULL) { + strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen; + + + strConnectInfo.pu8RespIEs = (WILC_Uint8 *)WILC_MALLOC(pstrConnectRespInfo->u16RespIEsLen); + WILC_memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs, + pstrConnectRespInfo->u16RespIEsLen); + } + } + + /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */ + if (pstrConnectRespInfo != NULL) { + DeallocateAssocRespInfo(pstrConnectRespInfo); + pstrConnectRespInfo = NULL; + } + } + } + } + + /* The station has just received mac status and it also received assoc. response which + * it was waiting for. + * So check first the matching between the received mac status and the received status code in Asoc Resp */ + if ((u8MacStatus == MAC_CONNECTED) && + (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) { + PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE \n"); + WILC_memset(u8ConnectedSSID, 0, ETH_ALEN); + + } else if (u8MacStatus == MAC_DISCONNECTED) { + PRINT_ER("Received MAC status is MAC_DISCONNECTED\n"); + WILC_memset(u8ConnectedSSID, 0, ETH_ALEN); + } + + /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */ + /* through a structure of type tstrConnectRespInfo */ + if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) { + PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n"); + WILC_memcpy(strConnectInfo.au8bssid, pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6); + + if ((u8MacStatus == MAC_CONNECTED) && + (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) { + WILC_memcpy(pstrWFIDrv->au8AssociatedBSSID, + pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN); + } + } + + + if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) { + strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen; + strConnectInfo.pu8ReqIEs = (WILC_Uint8 *)WILC_MALLOC(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen); + WILC_memcpy(strConnectInfo.pu8ReqIEs, + pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, + pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen); + } + + + WILC_TimerStop(&(pstrWFIDrv->hConnectTimer), WILC_NULL); + pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP, + &strConnectInfo, + u8MacStatus, + NULL, + pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid); + + + /* if received mac status is MAC_CONNECTED and + * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED + * else change state to IDLE */ + if ((u8MacStatus == MAC_CONNECTED) && + (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) { + #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP + + host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 0, 0); + #endif + + PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n"); + pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTED; + + #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP + PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n"); + g_obtainingIP = WILC_TRUE; + WILC_TimerStart(&hDuringIpTimer, 10000, WILC_NULL, WILC_NULL); + #endif + + #ifdef WILC_PARSE_SCAN_IN_HOST + /* open a BA session if possible */ + /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */ + + #endif + + /* host_int_addBASession(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid,0, */ + /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */ + } else { + PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus); + pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE; + gbScanWhileConnected = WILC_FALSE; + } + + /* Deallocation */ + if (strConnectInfo.pu8RespIEs != NULL) { + WILC_FREE(strConnectInfo.pu8RespIEs); + strConnectInfo.pu8RespIEs = NULL; + } + + if (strConnectInfo.pu8ReqIEs != NULL) { + WILC_FREE(strConnectInfo.pu8ReqIEs); + strConnectInfo.pu8ReqIEs = NULL; + } + + + pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0; + if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) { + WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid); + pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL; + } + + if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) { + WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid); + pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL; + } + + pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0; + if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) { + WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs); + pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL; + } + + } else if ((u8MacStatus == MAC_DISCONNECTED) && + (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)) { + /* Disassociation or Deauthentication frame has been received */ + PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n"); + + WILC_memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo)); + + if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) { + PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >> \n\n"); + WILC_TimerStop(&(pstrWFIDrv->hScanTimer), WILC_NULL); + Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED); + } + + strDisconnectNotifInfo.u16reason = 0; + strDisconnectNotifInfo.ie = NULL; + strDisconnectNotifInfo.ie_len = 0; + + if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) { + #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP + + g_obtainingIP = WILC_FALSE; + host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 0, 0); + #endif + + pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, + NULL, + 0, + &strDisconnectNotifInfo, + pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid); + + } else { + PRINT_ER("Connect result callback function is NULL \n"); + } + + WILC_memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN); + + + /* Deallocation */ + + /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they + * should be deallocated here */ + /* + * if(strDisconnectNotifInfo.ie != NULL) + * { + * WILC_FREE(strDisconnectNotifInfo.ie); + * strDisconnectNotifInfo.ie = NULL; + * } + */ + + pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0; + if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) { + WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid); + pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL; + } + + if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) { + WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid); + pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL; + } + + pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0; + if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) { + WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs); + pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL; + } + + /*BugID_5213*/ + /*Freeing flushed join request params on receiving*/ + /*MAC_DISCONNECTED while connected*/ + if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (WILC_Uint32)drvHandler) { + WILC_FREE(gu8FlushedJoinReq); + gu8FlushedJoinReq = NULL; + } + if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (WILC_Uint32)drvHandler) { + WILC_FREE(gu8FlushedInfoElemAsoc); + gu8FlushedInfoElemAsoc = NULL; + } + + pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE; + gbScanWhileConnected = WILC_FALSE; + + } else if ((u8MacStatus == MAC_DISCONNECTED) && + (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL)) { + PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n"); + PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >> \n\n"); + /*Abort the running scan*/ + WILC_TimerStop(&(pstrWFIDrv->hScanTimer), WILC_NULL); + if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) { + Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED); + + } + } + + } + + WILC_CATCH(s32Error) + { + + } + + /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */ + if (pstrRcvdGnrlAsyncInfo->pu8Buffer != NULL) { + WILC_FREE(pstrRcvdGnrlAsyncInfo->pu8Buffer); + pstrRcvdGnrlAsyncInfo->pu8Buffer = NULL; + } + + return s32Error; +} + +/** + * @brief Handle_Key + * @details Sending config packet to firmware to set key + * @param[in] tstrHostIFkeyAttr* pstrHostIFkeyAttr + * @return Error code. + * @author + * @date + * @version 1.0 + */ +static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + #ifdef WILC_AP_EXTERNAL_MLME + tstrWID strWIDList[5]; + #endif + WILC_Uint8 i; + WILC_Uint8 *pu8keybuf; + WILC_Sint8 s8idxarray[1]; + WILC_Sint8 ret = 0; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + + + switch (pstrHostIFkeyAttr->enuKeyType) { + + + case WEP: + +#ifdef WILC_AP_EXTERNAL_MLME + if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) { + + PRINT_D(HOSTINF_DBG, "Handling WEP key\n"); + PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx)); + strWIDList[0].u16WIDid = (WILC_Uint16)WID_11I_MODE; + strWIDList[0].enuWIDtype = WID_CHAR; + strWIDList[0].s32ValueSize = sizeof(WILC_Char); + strWIDList[0].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode)); + + strWIDList[1].u16WIDid = WID_AUTH_TYPE; + strWIDList[1].enuWIDtype = WID_CHAR; + strWIDList[1].s32ValueSize = sizeof(WILC_Char); + strWIDList[1].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type)); + + strWIDList[2].u16WIDid = (WILC_Uint16)WID_KEY_ID; + strWIDList[2].enuWIDtype = WID_CHAR; + + strWIDList[2].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx)); + strWIDList[2].s32ValueSize = sizeof(WILC_Char); + + + pu8keybuf = (WILC_Uint8 *)WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen); + + + if (pu8keybuf == NULL) { + PRINT_ER("No buffer to send Key\n"); + return -1; + } + + WILC_memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey, + pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen); + + + WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey); + + strWIDList[3].u16WIDid = (WILC_Uint16)WID_WEP_KEY_VALUE; + strWIDList[3].enuWIDtype = WID_STR; + strWIDList[3].s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen; + strWIDList[3].ps8WidVal = (WILC_Sint8 *)pu8keybuf; + + + s32Error = SendConfigPkt(SET_CFG, strWIDList, 4, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + WILC_FREE(pu8keybuf); + + + } +#endif + + if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) { + PRINT_D(HOSTINF_DBG, "Handling WEP key\n"); + pu8keybuf = (WILC_Uint8 *)WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2); + if (pu8keybuf == NULL) { + PRINT_ER("No buffer to send Key\n"); + return -1; + } + pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx; + + WILC_memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, 1); + + WILC_memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey, + pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen); + + WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey); + + strWID.u16WIDid = (WILC_Uint16)WID_ADD_WEP_KEY; + strWID.enuWIDtype = WID_STR; + strWID.ps8WidVal = (WILC_Sint8 *)pu8keybuf; + strWID.s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2; + + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + WILC_FREE(pu8keybuf); + } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY) { + + PRINT_D(HOSTINF_DBG, "Removing key\n"); + strWID.u16WIDid = (WILC_Uint16)WID_REMOVE_WEP_KEY; + strWID.enuWIDtype = WID_STR; + + s8idxarray[0] = (WILC_Sint8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx; + strWID.ps8WidVal = s8idxarray; + strWID.s32ValueSize = 1; + + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + } else { + strWID.u16WIDid = (WILC_Uint16)WID_KEY_ID; + strWID.enuWIDtype = WID_CHAR; + strWID.ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx)); + strWID.s32ValueSize = sizeof(WILC_Char); + + PRINT_D(HOSTINF_DBG, "Setting default key index\n"); + + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + } + WILC_SemaphoreRelease(&(pstrWFIDrv->hSemTestKeyBlock), WILC_NULL); + break; + + case WPARxGtk: + #ifdef WILC_AP_EXTERNAL_MLME + if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) { + pu8keybuf = (WILC_Uint8 *)WILC_MALLOC(RX_MIC_KEY_MSG_LEN); + if (pu8keybuf == NULL) { + PRINT_ER("No buffer to send RxGTK Key\n"); + ret = -1; + goto _WPARxGtk_end_case_; + } + + WILC_memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN); + + + /*|----------------------------------------------------------------------------| + * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key | + * |------------|---------|-------|------------|---------------|----------------| + | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/ + + + + if (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq != NULL) + WILC_memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8); + + + WILC_memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1); + + WILC_memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1); + + WILC_memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key, + pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen); + /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */ + strWIDList[0].u16WIDid = (WILC_Uint16)WID_11I_MODE; + strWIDList[0].enuWIDtype = WID_CHAR; + strWIDList[0].s32ValueSize = sizeof(WILC_Char); + strWIDList[0].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode)); + + strWIDList[1].u16WIDid = (WILC_Uint16)WID_ADD_RX_GTK; + strWIDList[1].enuWIDtype = WID_STR; + strWIDList[1].ps8WidVal = (WILC_Sint8 *)pu8keybuf; + strWIDList[1].s32ValueSize = RX_MIC_KEY_MSG_LEN; + + s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + + WILC_FREE(pu8keybuf); + + /* ////////////////////////// */ + WILC_SemaphoreRelease(&(pstrWFIDrv->hSemTestKeyBlock), WILC_NULL); + /* ///////////////////////// */ + } + + #endif + if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) { + PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n"); + + pu8keybuf = (WILC_Uint8 *)WILC_MALLOC(RX_MIC_KEY_MSG_LEN); + if (pu8keybuf == NULL) { + PRINT_ER("No buffer to send RxGTK Key\n"); + ret = -1; + goto _WPARxGtk_end_case_; + } + + WILC_memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN); + + + /*|----------------------------------------------------------------------------| + * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key | + * |------------|---------|-------|------------|---------------|----------------| + | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/ + + if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) { + WILC_memcpy(pu8keybuf, pstrWFIDrv->au8AssociatedBSSID, ETH_ALEN); + } else { + PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED \n"); + } + + WILC_memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8); + + WILC_memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1); + + WILC_memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1); + WILC_memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key, + pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen); + + strWID.u16WIDid = (WILC_Uint16)WID_ADD_RX_GTK; + strWID.enuWIDtype = WID_STR; + strWID.ps8WidVal = (WILC_Sint8 *)pu8keybuf; + strWID.s32ValueSize = RX_MIC_KEY_MSG_LEN; + + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + + WILC_FREE(pu8keybuf); + + /* ////////////////////////// */ + WILC_SemaphoreRelease(&(pstrWFIDrv->hSemTestKeyBlock), WILC_NULL); + /* ///////////////////////// */ + } +_WPARxGtk_end_case_: + WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key); + WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq); + if (ret == -1) + return ret; + + break; + + case WPAPtk: + #ifdef WILC_AP_EXTERNAL_MLME + if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) { + + + pu8keybuf = (WILC_Uint8 *)WILC_MALLOC(PTK_KEY_MSG_LEN + 1); + + + + if (pu8keybuf == NULL) { + PRINT_ER("No buffer to send PTK Key\n"); + ret = -1; + goto _WPAPtk_end_case_; + + } + + /*|-----------------------------------------------------------------------------| + * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key | + * |----------------|------------ |--------------|----------------|---------------| + | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes | + |-----------------------------------------------------------------------------|*/ + + WILC_memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */ + + WILC_memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1); + WILC_memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1); + /*16 byte TK*/ + WILC_memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key, + pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen); + + + strWIDList[0].u16WIDid = (WILC_Uint16)WID_11I_MODE; + strWIDList[0].enuWIDtype = WID_CHAR; + strWIDList[0].s32ValueSize = sizeof(WILC_Char); + strWIDList[0].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode)); + + strWIDList[1].u16WIDid = (WILC_Uint16)WID_ADD_PTK; + strWIDList[1].enuWIDtype = WID_STR; + strWIDList[1].ps8WidVal = (WILC_Sint8 *)pu8keybuf; + strWIDList[1].s32ValueSize = PTK_KEY_MSG_LEN + 1; + + s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + WILC_FREE(pu8keybuf); + + /* ////////////////////////// */ + WILC_SemaphoreRelease(&(pstrWFIDrv->hSemTestKeyBlock), WILC_NULL); + /* ///////////////////////// */ + } + #endif + if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) { + + + pu8keybuf = (WILC_Uint8 *)WILC_MALLOC(PTK_KEY_MSG_LEN); + + + + if (pu8keybuf == NULL) { + PRINT_ER("No buffer to send PTK Key\n"); + ret = -1; + goto _WPAPtk_end_case_; + + } + + /*|-----------------------------------------------------------------------------| + * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key | + * |----------------|------------|--------------|----------------|---------------| + | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes | + |-----------------------------------------------------------------------------|*/ + + WILC_memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */ + + WILC_memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1); + /*16 byte TK*/ + WILC_memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key, + pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen); + + + strWID.u16WIDid = (WILC_Uint16)WID_ADD_PTK; + strWID.enuWIDtype = WID_STR; + strWID.ps8WidVal = (WILC_Sint8 *)pu8keybuf; + strWID.s32ValueSize = PTK_KEY_MSG_LEN; + + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + WILC_FREE(pu8keybuf); + + /* ////////////////////////// */ + WILC_SemaphoreRelease(&(pstrWFIDrv->hSemTestKeyBlock), WILC_NULL); + /* ///////////////////////// */ + } + +_WPAPtk_end_case_: + WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key); + if (ret == -1) + return ret; + + break; + + + case PMKSA: + + PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n"); + + pu8keybuf = (WILC_Uint8 *)WILC_MALLOC((pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1); + if (pu8keybuf == NULL) { + PRINT_ER("No buffer to send PMKSA Key\n"); + return -1; + } + + pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid; + + for (i = 0; i < pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid; i++) { + + WILC_memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, ETH_ALEN); + WILC_memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, PMKID_LEN); + } + + strWID.u16WIDid = (WILC_Uint16)WID_PMKID_INFO; + strWID.enuWIDtype = WID_STR; + strWID.ps8WidVal = (WILC_Sint8 *)pu8keybuf; + strWID.s32ValueSize = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1; + + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + + WILC_FREE(pu8keybuf); + break; + } + + if (s32Error) + PRINT_ER("Failed to send key config packet\n"); + + + return s32Error; +} + + +/** + * @brief Handle_Disconnect + * @details Sending config packet to firmware to disconnect + * @param[in] NONE + * @return NONE + * @author + * @date + * @version 1.0 + */ +static void Handle_Disconnect(void *drvHandler) +{ + tstrWID strWID; + + WILC_Sint32 s32Error = WILC_SUCCESS; + WILC_Uint16 u16DummyReasonCode = 0; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + + + strWID.u16WIDid = (WILC_Uint16)WID_DISCONNECT; + strWID.enuWIDtype = WID_CHAR; + strWID.ps8WidVal = (WILC_Sint8 *)&u16DummyReasonCode; + strWID.s32ValueSize = sizeof(WILC_Char); + + + + PRINT_D(HOSTINF_DBG, "Sending disconnect request\n"); + + #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP + + g_obtainingIP = WILC_FALSE; + host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 0, 0); + #endif + + WILC_memset(u8ConnectedSSID, 0, ETH_ALEN); + + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)pstrWFIDrv); + + if (s32Error) { + PRINT_ER("Failed to send dissconect config packet\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } else { + tstrDisconnectNotifInfo strDisconnectNotifInfo; + + WILC_memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo)); + + strDisconnectNotifInfo.u16reason = 0; + strDisconnectNotifInfo.ie = NULL; + strDisconnectNotifInfo.ie_len = 0; + + if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) { + WILC_TimerStop(&(pstrWFIDrv->hScanTimer), WILC_NULL); + pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, WILC_NULL, + pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL); + + pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = WILC_NULL; + } + + if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) { + + /*BugID_5193*/ + /*Stop connect timer, if connection in progress*/ + if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) { + PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n"); + WILC_TimerStop(&(pstrWFIDrv->hConnectTimer), WILC_NULL); + } + + pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL, + 0, &strDisconnectNotifInfo, pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid); + } else { + PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL \n"); + } + + gbScanWhileConnected = WILC_FALSE; + + pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE; + + WILC_memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN); + + + /* Deallocation */ + pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0; + if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) { + WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid); + pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL; + } + + if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) { + WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid); + pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL; + } + + pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0; + if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) { + WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs); + pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL; + } + + + /*BugID_5137*/ + if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (WILC_Uint32)drvHandler) { + WILC_FREE(gu8FlushedJoinReq); + gu8FlushedJoinReq = NULL; + } + if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (WILC_Uint32)drvHandler) { + WILC_FREE(gu8FlushedInfoElemAsoc); + gu8FlushedInfoElemAsoc = NULL; + } + + } + + WILC_CATCH(s32Error) + { + + } + + /* ////////////////////////// */ + WILC_SemaphoreRelease(&(pstrWFIDrv->hSemTestDisconnectBlock), WILC_NULL); + /* ///////////////////////// */ + +} + + +void resolve_disconnect_aberration(void *drvHandler) +{ + tstrWILC_WFIDrv *pstrWFIDrv; + + pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + if (pstrWFIDrv == WILC_NULL) + return; + if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTING)) { + PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n"); + host_int_disconnect((WILC_WFIDrvHandle)pstrWFIDrv, 1); + } +} +static WILC_Sint32 Switch_Log_Terminal(void *drvHandler) +{ + + + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + static char dummy = 9; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + + strWID.u16WIDid = (WILC_Uint16)WID_LOGTerminal_Switch; + strWID.enuWIDtype = WID_CHAR; + strWID.ps8WidVal = &dummy; + strWID.s32ValueSize = sizeof(WILC_Char); + + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + + + if (s32Error) { + PRINT_D(HOSTINF_DBG, "Failed to switch log terminal\n"); + WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); + } else { + PRINT_INFO(HOSTINF_DBG, "MAC address set :: \n"); + + + } + + WILC_CATCH(s32Error) + { + + } + + return s32Error; +} + +/** + * @brief Handle_GetChnl + * @details Sending config packet to get channel + * @param[in] NONE + * @return NONE + * + * @author + * @date + * @version 1.0 + */ +static WILC_Sint32 Handle_GetChnl(void *drvHandler) +{ + + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + strWID.u16WIDid = (WILC_Uint16)WID_CURRENT_CHANNEL; + strWID.enuWIDtype = WID_CHAR; + strWID.ps8WidVal = (WILC_Sint8 *)&gu8Chnl; + strWID.s32ValueSize = sizeof(WILC_Char); + + PRINT_D(HOSTINF_DBG, "Getting channel value\n"); + + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + /*get the value by searching the local copy*/ + if (s32Error) { + PRINT_ER("Failed to get channel number\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + + + WILC_CATCH(s32Error) + { + + } + WILC_SemaphoreRelease(&(pstrWFIDrv->hSemGetCHNL), WILC_NULL); + + return s32Error; + + + +} + + +/** + * @brief Handle_GetRssi + * @details Sending config packet to get RSSI + * @param[in] NONE + * @return NONE + * @author + * @date + * @version 1.0 + */ +static void Handle_GetRssi(void *drvHandler) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + + strWID.u16WIDid = (WILC_Uint16)WID_RSSI; + strWID.enuWIDtype = WID_CHAR; + strWID.ps8WidVal = &gs8Rssi; + strWID.s32ValueSize = sizeof(WILC_Char); + + /*Sending Cfg*/ + PRINT_D(HOSTINF_DBG, "Getting RSSI value\n"); + + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + if (s32Error) { + PRINT_ER("Failed to get RSSI value\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + + WILC_CATCH(s32Error) + { + + } + WILC_SemaphoreRelease(&(pstrWFIDrv->hSemGetRSSI), WILC_NULL); + + +} + + +static void Handle_GetLinkspeed(void *drvHandler) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + + gs8lnkspd = 0; + + strWID.u16WIDid = (WILC_Uint16)WID_LINKSPEED; + strWID.enuWIDtype = WID_CHAR; + strWID.ps8WidVal = &gs8lnkspd; + strWID.s32ValueSize = sizeof(WILC_Char); + /*Sending Cfg*/ + PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n"); + + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + if (s32Error) { + PRINT_ER("Failed to get LINKSPEED value\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + + WILC_CATCH(s32Error) + { + + } + WILC_SemaphoreRelease(&(pstrWFIDrv->hSemGetLINKSPEED), WILC_NULL); + + +} + +WILC_Sint32 Handle_GetStatistics(void *drvHandler, tstrStatistics *pstrStatistics) +{ + tstrWID strWIDList[5]; + uint32_t u32WidsCount = 0, s32Error = 0; + + strWIDList[u32WidsCount].u16WIDid = WID_LINKSPEED; + strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; + strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); + strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrStatistics->u8LinkSpeed)); + u32WidsCount++; + + strWIDList[u32WidsCount].u16WIDid = WID_RSSI; + strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; + strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); + strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrStatistics->s8RSSI)); + u32WidsCount++; + + strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT; + strWIDList[u32WidsCount].enuWIDtype = WID_INT; + strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Uint32); + strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrStatistics->u32TxCount)); + u32WidsCount++; + + strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT; + strWIDList[u32WidsCount].enuWIDtype = WID_INT; + strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Uint32); + strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrStatistics->u32RxCount)); + u32WidsCount++; + + strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT; + strWIDList[u32WidsCount].enuWIDtype = WID_INT; + strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Uint32); + strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrStatistics->u32TxFailureCount)); + u32WidsCount++; + + s32Error = SendConfigPkt(GET_CFG, strWIDList, u32WidsCount, WILC_FALSE, (WILC_Uint32)drvHandler); + + if (s32Error) { + PRINT_ER("Failed to send scan paramters config packet\n"); + /* WILC_ERRORREPORT(s32Error, s32Error); */ + } + WILC_SemaphoreRelease(&hWaitResponse, NULL); + return 0; + +} + + +#ifdef WILC_AP_EXTERNAL_MLME + + +/** + * @brief Handle_Get_InActiveTime + * @details Sending config packet to set mac adddress for station and + * get inactive time + * @param[in] NONE + * @return NONE + * + * @author + * @date + * @version 1.0 + */ +static WILC_Sint32 Handle_Get_InActiveTime(void *drvHandler, tstrHostIfStaInactiveT *strHostIfStaInactiveT) +{ + + WILC_Sint32 s32Error = WILC_SUCCESS; + WILC_Uint8 *stamac; + tstrWID strWID; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + + + strWID.u16WIDid = (WILC_Uint16)WID_SET_STA_MAC_INACTIVE_TIME; + strWID.enuWIDtype = WID_STR; + strWID.s32ValueSize = ETH_ALEN; + strWID.ps8WidVal = (WILC_Uint8 *)WILC_MALLOC(strWID.s32ValueSize); + + + stamac = strWID.ps8WidVal; + WILC_memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN); + + + PRINT_D(CFG80211_DBG, "SETING STA inactive time\n"); + + + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + /*get the value by searching the local copy*/ + if (s32Error) { + PRINT_ER("Failed to SET incative time\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + + + strWID.u16WIDid = (WILC_Uint16)WID_GET_INACTIVE_TIME; + strWID.enuWIDtype = WID_INT; + strWID.ps8WidVal = (WILC_Sint8 *)&gu32InactiveTime; + strWID.s32ValueSize = sizeof(WILC_Uint32); + + + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + /*get the value by searching the local copy*/ + if (s32Error) { + PRINT_ER("Failed to get incative time\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + + + PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime); + + WILC_SemaphoreRelease(&(pstrWFIDrv->hSemInactiveTime), WILC_NULL); + WILC_CATCH(s32Error) + { + + } + + + return s32Error; + + + +} + + +/** + * @brief Handle_AddBeacon + * @details Sending config packet to add beacon + * @param[in] tstrHostIFSetBeacon* pstrSetBeaconParam + * @return NONE + * @author + * @date + * @version 1.0 + */ +static void Handle_AddBeacon(void *drvHandler, tstrHostIFSetBeacon *pstrSetBeaconParam) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + WILC_Uint8 *pu8CurrByte; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + PRINT_D(HOSTINF_DBG, "Adding BEACON\n"); + + strWID.u16WIDid = (WILC_Uint16)WID_ADD_BEACON; + strWID.enuWIDtype = WID_BIN; + strWID.s32ValueSize = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16; + strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize); + if (strWID.ps8WidVal == NULL) { + WILC_ERRORREPORT(s32Error, WILC_NO_MEM); + } + + pu8CurrByte = strWID.ps8WidVal; + *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF); + *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 8) & 0xFF); + *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 16) & 0xFF); + *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 24) & 0xFF); + + *pu8CurrByte++ = (pstrSetBeaconParam->u32DTIMPeriod & 0xFF); + *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 8) & 0xFF); + *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 16) & 0xFF); + *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 24) & 0xFF); + + *pu8CurrByte++ = (pstrSetBeaconParam->u32HeadLen & 0xFF); + *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 8) & 0xFF); + *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 16) & 0xFF); + *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 24) & 0xFF); + + memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Head, pstrSetBeaconParam->u32HeadLen); + pu8CurrByte += pstrSetBeaconParam->u32HeadLen; + + *pu8CurrByte++ = (pstrSetBeaconParam->u32TailLen & 0xFF); + *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 8) & 0xFF); + *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 16) & 0xFF); + *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 24) & 0xFF); + + /* Bug 4599 : if tail length = 0 skip copying */ + if (pstrSetBeaconParam->pu8Tail > 0) + memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Tail, pstrSetBeaconParam->u32TailLen); + pu8CurrByte += pstrSetBeaconParam->u32TailLen; + + + + /*Sending Cfg*/ + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)pstrWFIDrv); + if (s32Error) { + PRINT_ER("Failed to send add beacon config packet\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + + WILC_CATCH(s32Error) + { + } + WILC_FREE_IF_TRUE(strWID.ps8WidVal); + WILC_FREE_IF_TRUE(pstrSetBeaconParam->pu8Head); + WILC_FREE_IF_TRUE(pstrSetBeaconParam->pu8Tail); +} + + +/** + * @brief Handle_AddBeacon + * @details Sending config packet to delete beacon + * @param[in] tstrHostIFDelBeacon* pstrDelBeacon + * @return NONE + * @author + * @date + * @version 1.0 + */ +static void Handle_DelBeacon(void *drvHandler, tstrHostIFDelBeacon *pstrDelBeacon) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + WILC_Uint8 *pu8CurrByte; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + strWID.u16WIDid = (WILC_Uint16)WID_DEL_BEACON; + strWID.enuWIDtype = WID_CHAR; + strWID.s32ValueSize = sizeof(WILC_Char); + strWID.ps8WidVal = &gu8DelBcn; + + if (strWID.ps8WidVal == NULL) { + WILC_ERRORREPORT(s32Error, WILC_NO_MEM); + } + + pu8CurrByte = strWID.ps8WidVal; + + PRINT_D(HOSTINF_DBG, "Deleting BEACON\n"); + /* TODO: build del beacon message*/ + + /*Sending Cfg*/ + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)pstrWFIDrv); + if (s32Error) { + + PRINT_ER("Failed to send delete beacon config packet\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + + WILC_CATCH(s32Error) + { + } +} + + +/** + * @brief WILC_HostIf_PackStaParam + * @details Handling packing of the station params in a buffer + * @param[in] WILC_Uint8* pu8Buffer, tstrWILC_AddStaParam* pstrStationParam + * @return NONE + * @author + * @date + * @version 1.0 + */ +static WILC_Uint32 WILC_HostIf_PackStaParam(WILC_Uint8 *pu8Buffer, tstrWILC_AddStaParam *pstrStationParam) +{ + WILC_Uint8 *pu8CurrByte; + + pu8CurrByte = pu8Buffer; + + PRINT_D(HOSTINF_DBG, "Packing STA params\n"); + WILC_memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN); + pu8CurrByte += ETH_ALEN; + + *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF; + *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF; + + *pu8CurrByte++ = pstrStationParam->u8NumRates; + if (pstrStationParam->u8NumRates > 0) { + WILC_memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates); + } + pu8CurrByte += pstrStationParam->u8NumRates; + + *pu8CurrByte++ = pstrStationParam->bIsHTSupported; + *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF; + *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF; + + *pu8CurrByte++ = pstrStationParam->u8AmpduParams; + WILC_memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE); + pu8CurrByte += WILC_SUPP_MCS_SET_SIZE; + + *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF; + *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF; + + *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF; + *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF; + *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF; + *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF; + + *pu8CurrByte++ = pstrStationParam->u8ASELCap; + + *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF; + *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF; + + *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF; + *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF; + + return pu8CurrByte - pu8Buffer; +} + +/** + * @brief Handle_AddStation + * @details Sending config packet to add station + * @param[in] tstrWILC_AddStaParam* pstrStationParam + * @return NONE + * @author + * @date + * @version 1.0 + */ +static void Handle_AddStation(void *drvHandler, tstrWILC_AddStaParam *pstrStationParam) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + WILC_Uint8 *pu8CurrByte; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + PRINT_D(HOSTINF_DBG, "Handling add station\n"); + strWID.u16WIDid = (WILC_Uint16)WID_ADD_STA; + strWID.enuWIDtype = WID_BIN; + strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates; + + strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize); + if (strWID.ps8WidVal == NULL) { + WILC_ERRORREPORT(s32Error, WILC_NO_MEM); + } + + pu8CurrByte = strWID.ps8WidVal; + pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam); + + /*Sending Cfg*/ + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)pstrWFIDrv); + if (s32Error != WILC_SUCCESS) { + + PRINT_ER("Failed to send add station config packet\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + + WILC_CATCH(s32Error) + { + } + WILC_FREE_IF_TRUE(pstrStationParam->pu8Rates); + WILC_FREE_IF_TRUE(strWID.ps8WidVal); +} + +/** + * @brief Handle_DelAllSta + * @details Sending config packet to delete station + * @param[in] tstrHostIFDelSta* pstrDelStaParam + * @return NONE + * @author + * @date + * @version 1.0 + */ +static void Handle_DelAllSta(void *drvHandler, tstrHostIFDelAllSta *pstrDelAllStaParam) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + WILC_Uint8 *pu8CurrByte; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + WILC_Uint8 i; + UWORD8 au8Zero_Buff[6] = {0}; + strWID.u16WIDid = (WILC_Uint16)WID_DEL_ALL_STA; + strWID.enuWIDtype = WID_STR; + strWID.s32ValueSize = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1; + + PRINT_D(HOSTINF_DBG, "Handling delete station \n"); + + strWID.ps8WidVal = WILC_MALLOC((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1); + if (strWID.ps8WidVal == NULL) { + WILC_ERRORREPORT(s32Error, WILC_NO_MEM); + } + + pu8CurrByte = strWID.ps8WidVal; + + *(pu8CurrByte++) = pstrDelAllStaParam->u8Num_AssocSta; + + for (i = 0; i < MAX_NUM_STA; i++) { + if (memcmp(pstrDelAllStaParam->au8Sta_DelAllSta[i], au8Zero_Buff, ETH_ALEN)) + WILC_memcpy(pu8CurrByte, pstrDelAllStaParam->au8Sta_DelAllSta[i], ETH_ALEN); + else + continue; + + pu8CurrByte += ETH_ALEN; + } + + /*Sending Cfg*/ + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + if (s32Error) { + + PRINT_ER("Failed to send add station config packe\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + + WILC_CATCH(s32Error) + { + } + WILC_FREE_IF_TRUE(strWID.ps8WidVal); + + WILC_SemaphoreRelease(&hWaitResponse, NULL); +} + + +/** + * @brief Handle_DelStation + * @details Sending config packet to delete station + * @param[in] tstrHostIFDelSta* pstrDelStaParam + * @return NONE + * @author + * @date + * @version 1.0 + */ +static void Handle_DelStation(void *drvHandler, tstrHostIFDelSta *pstrDelStaParam) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + WILC_Uint8 *pu8CurrByte; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + + strWID.u16WIDid = (WILC_Uint16)WID_REMOVE_STA; + strWID.enuWIDtype = WID_BIN; + strWID.s32ValueSize = ETH_ALEN; + + PRINT_D(HOSTINF_DBG, "Handling delete station \n"); + + strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize); + if (strWID.ps8WidVal == NULL) { + WILC_ERRORREPORT(s32Error, WILC_NO_MEM); + } + + pu8CurrByte = strWID.ps8WidVal; + + WILC_memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN); + + /*Sending Cfg*/ + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)pstrWFIDrv); + if (s32Error) { + + PRINT_ER("Failed to send add station config packe\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + + WILC_CATCH(s32Error) + { + } + WILC_FREE_IF_TRUE(strWID.ps8WidVal); +} + + +/** + * @brief Handle_EditStation + * @details Sending config packet to edit station + * @param[in] tstrWILC_AddStaParam* pstrStationParam + * @return NONE + * @author + * @date + * @version 1.0 + */ +static void Handle_EditStation(void *drvHandler, tstrWILC_AddStaParam *pstrStationParam) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + WILC_Uint8 *pu8CurrByte; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + + strWID.u16WIDid = (WILC_Uint16)WID_EDIT_STA; + strWID.enuWIDtype = WID_BIN; + strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates; + + PRINT_D(HOSTINF_DBG, "Handling edit station\n"); + strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize); + if (strWID.ps8WidVal == NULL) { + WILC_ERRORREPORT(s32Error, WILC_NO_MEM); + } + + pu8CurrByte = strWID.ps8WidVal; + pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam); + + /*Sending Cfg*/ + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)pstrWFIDrv); + if (s32Error) { + + PRINT_ER("Failed to send edit station config packet\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + + WILC_CATCH(s32Error) + { + } + WILC_FREE_IF_TRUE(pstrStationParam->pu8Rates); + WILC_FREE_IF_TRUE(strWID.ps8WidVal); +} +#endif /*WILC_AP_EXTERNAL_MLME*/ + +#ifdef WILC_P2P +/** + * @brief Handle_RemainOnChan + * @details Sending config packet to edit station + * @param[in] tstrWILC_AddStaParam* pstrStationParam + * @return NONE + * @author + * @date + * @version 1.0 + */ +static int Handle_RemainOnChan(void *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + WILC_Uint8 u8remain_on_chan_flag; + tstrWID strWID; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler; + + /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/ + if (!pstrWFIDrv->u8RemainOnChan_pendingreq) { + pstrWFIDrv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid; + pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired; + pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady; + pstrWFIDrv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel; + pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID; + } else { + /*Set the channel to use it as a wid val*/ + pstrHostIfRemainOnChan->u16Channel = pstrWFIDrv->strHostIfRemainOnChan.u16Channel; + } + + if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) { + PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n"); + pstrWFIDrv->u8RemainOnChan_pendingreq = 1; + WILC_ERRORREPORT(s32Error, WILC_BUSY); + } + if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) { + PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n"); + WILC_ERRORREPORT(s32Error, WILC_BUSY); + } + + #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP + if (g_obtainingIP || connecting) { + PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n"); + WILC_ERRORREPORT(s32Error, WILC_BUSY); + } + #endif + + PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel); + + u8remain_on_chan_flag = WILC_TRUE; + strWID.u16WIDid = (WILC_Uint16)WID_REMAIN_ON_CHAN; + strWID.enuWIDtype = WID_STR; + strWID.s32ValueSize = 2; + strWID.ps8WidVal = (WILC_Sint8 *)WILC_MALLOC(strWID.s32ValueSize); + + if (strWID.ps8WidVal == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_NO_MEM); + } + + strWID.ps8WidVal[0] = u8remain_on_chan_flag; + strWID.ps8WidVal[1] = (WILC_Sint8)pstrHostIfRemainOnChan->u16Channel; + + /*Sending Cfg*/ + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + if (s32Error != WILC_SUCCESS) { + PRINT_ER("Failed to set remain on channel\n"); + } + + WILC_CATCH(-1) + { + P2P_LISTEN_STATE = 1; + WILC_TimerStart(&(pstrWFIDrv->hRemainOnChannel), pstrHostIfRemainOnChan->u32duration, (void *)pstrWFIDrv, WILC_NULL); + + /*Calling CFG ready_on_channel*/ + if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady) { + pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady(pstrWFIDrv->strHostIfRemainOnChan.pVoid); + } + + if (pstrWFIDrv->u8RemainOnChan_pendingreq) + pstrWFIDrv->u8RemainOnChan_pendingreq = 0; + } + return s32Error; +} + +/** + * @brief Handle_RegisterFrame + * @details + * @param[in] + * @return NONE + * @author + * @date + * @version 1.0 + */ +static int Handle_RegisterFrame(void *drvHandler, tstrHostIfRegisterFrame *pstrHostIfRegisterFrame) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + WILC_Uint8 *pu8CurrByte; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + + PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType); + + /*prepare configuration packet*/ + strWID.u16WIDid = (WILC_Uint16)WID_REGISTER_FRAME; + strWID.enuWIDtype = WID_STR; + strWID.ps8WidVal = WILC_MALLOC(sizeof(WILC_Uint16) + 2); + if (strWID.ps8WidVal == NULL) { + WILC_ERRORREPORT(s32Error, WILC_NO_MEM); + } + + pu8CurrByte = strWID.ps8WidVal; + + *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg; + *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid; + WILC_memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(WILC_Uint16)); + + + strWID.s32ValueSize = sizeof(WILC_Uint16) + 2; + + + /*Sending Cfg*/ + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + if (s32Error) { + PRINT_ER("Failed to frame register config packet\n"); + WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); + } + + + WILC_CATCH(s32Error) + { + } + + return s32Error; + +} + +/** + * @brief Handle_ListenStateExpired + * @details Handle of listen state expiration + * @param[in] NONE + * @return Error code. + * @author + * @date + * @version 1.0 + */ +#define FALSE_FRMWR_CHANNEL 100 +static WILC_Uint32 Handle_ListenStateExpired(void *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan) +{ + WILC_Uint8 u8remain_on_chan_flag; + tstrWID strWID; + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler; + + PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n"); + + /*BugID_5477*/ + /*Make sure we are already in listen state*/ + /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/ + if (P2P_LISTEN_STATE) { + u8remain_on_chan_flag = WILC_FALSE; + strWID.u16WIDid = (WILC_Uint16)WID_REMAIN_ON_CHAN; + strWID.enuWIDtype = WID_STR; + strWID.s32ValueSize = 2; + strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize); + + if (strWID.ps8WidVal == WILC_NULL) { + PRINT_ER("Failed to allocate memory\n"); + } + + strWID.ps8WidVal[0] = u8remain_on_chan_flag; + strWID.ps8WidVal[1] = FALSE_FRMWR_CHANNEL; + + /*Sending Cfg*/ + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + if (s32Error != WILC_SUCCESS) { + PRINT_ER("Failed to set remain on channel\n"); + goto _done_; + } + + if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired) { + pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired(pstrWFIDrv->strHostIfRemainOnChan.pVoid + , pstrHostIfRemainOnChan->u32ListenSessionID); + } + P2P_LISTEN_STATE = 0; + } else { + PRINT_D(GENERIC_DBG, "Not in listen state\n"); + s32Error = WILC_FAIL; + } + +_done_: + return s32Error; +} + + +/** + * @brief ListenTimerCB + * @details Callback function of remain-on-channel timer + * @param[in] NONE + * @return Error code. + * @author + * @date + * @version 1.0 + */ +static void ListenTimerCB(void *pvArg) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrHostIFmsg strHostIFmsg; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)pvArg; + /*Stopping remain-on-channel timer*/ + WILC_TimerStop(&(pstrWFIDrv->hRemainOnChannel), WILC_NULL); + + /* prepare the Timer Callback message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + strHostIFmsg.u16MsgId = HOST_IF_MSG_LISTEN_TIMER_FIRED; + strHostIFmsg.drvHandler = pstrWFIDrv; + strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID; + + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + WILC_ERRORREPORT(s32Error, s32Error); + } + WILC_CATCH(s32Error) + { + + } +} +#endif + + +/** + * @brief Handle_EditStation + * @details Sending config packet to edit station + * @param[in] tstrWILC_AddStaParam* pstrStationParam + * @return NONE + * @author + * @date + * @version 1.0 + */ +static void Handle_PowerManagement(void *drvHandler, tstrHostIfPowerMgmtParam *strPowerMgmtParam) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + WILC_Sint8 s8PowerMode; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + strWID.u16WIDid = (WILC_Uint16)WID_POWER_MANAGEMENT; + + if (strPowerMgmtParam->bIsEnabled == WILC_TRUE) { + s8PowerMode = MIN_FAST_PS; + } else { + s8PowerMode = NO_POWERSAVE; + } + PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode); + strWID.ps8WidVal = &s8PowerMode; + strWID.s32ValueSize = sizeof(WILC_Char); + + PRINT_D(HOSTINF_DBG, "Handling Power Management\n"); + + /*Sending Cfg*/ + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + if (s32Error) { + PRINT_ER("Failed to send power management config packet\n"); + WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); + } + + WILC_CATCH(s32Error) + { + + } +} + +/** + * @brief Handle_SetMulticastFilter + * @details Set Multicast filter in firmware + * @param[in] tstrHostIFSetMulti* strHostIfSetMulti + * @return NONE + * @author asobhy + * @date + * @version 1.0 + */ +static void Handle_SetMulticastFilter(void *drvHandler, tstrHostIFSetMulti *strHostIfSetMulti) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + WILC_Uint8 *pu8CurrByte; + + PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n"); + + strWID.u16WIDid = (WILC_Uint16)WID_SETUP_MULTICAST_FILTER; + strWID.enuWIDtype = WID_BIN; + strWID.s32ValueSize = sizeof(tstrHostIFSetMulti) + ((strHostIfSetMulti->u32count) * ETH_ALEN); + strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize); + if (strWID.ps8WidVal == NULL) { + WILC_ERRORREPORT(s32Error, WILC_NO_MEM); + } + + pu8CurrByte = strWID.ps8WidVal; + *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF); + *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 8) & 0xFF); + *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 16) & 0xFF); + *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 24) & 0xFF); + + *pu8CurrByte++ = (strHostIfSetMulti->u32count & 0xFF); + *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 8) & 0xFF); + *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 16) & 0xFF); + *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 24) & 0xFF); + + if ((strHostIfSetMulti->u32count) > 0) + memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN)); + + /*Sending Cfg*/ + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)drvHandler); + if (s32Error) { + PRINT_ER("Failed to send setup multicast config packet\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + + WILC_CATCH(s32Error) + { + } + WILC_FREE_IF_TRUE(strWID.ps8WidVal); + +} + + +/*BugID_5222*/ +/** + * @brief Handle_AddBASession + * @details Add block ack session + * @param[in] tstrHostIFSetMulti* strHostIfSetMulti + * @return NONE + * @author Amr Abdel-Moghny + * @date Feb. 2014 + * @version 9.0 + */ +static WILC_Sint32 Handle_AddBASession(void *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + int AddbaTimeout = 100; + char *ptr = NULL; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + + PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x \nTID=%d \nBufferSize == %d \nSessionTimeOut = %d\n", + strHostIfBASessionInfo->au8Bssid[0], + strHostIfBASessionInfo->au8Bssid[1], + strHostIfBASessionInfo->au8Bssid[2], + strHostIfBASessionInfo->u16BufferSize, + strHostIfBASessionInfo->u16SessionTimeout, + strHostIfBASessionInfo->u8Ted); + + strWID.u16WIDid = (WILC_Uint16)WID_11E_P_ACTION_REQ; + strWID.enuWIDtype = WID_STR; + strWID.ps8WidVal = (WILC_Uint8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE); + strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE; + ptr = strWID.ps8WidVal; + /* *ptr++ = 0x14; */ + *ptr++ = 0x14; + *ptr++ = 0x3; + *ptr++ = 0x0; + WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN); + ptr += ETH_ALEN; + *ptr++ = strHostIfBASessionInfo->u8Ted; + /* BA Policy*/ + *ptr++ = 1; + /* Buffer size*/ + *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF); + *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF); + /* BA timeout*/ + *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF); + *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF); + /* ADDBA timeout*/ + *ptr++ = (AddbaTimeout & 0xFF); + *ptr++ = ((AddbaTimeout >> 16) & 0xFF); + /* Group Buffer Max Frames*/ + *ptr++ = 8; + /* Group Buffer Timeout */ + *ptr++ = 0; + + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + if (s32Error) + PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n"); + + + strWID.u16WIDid = (WILC_Uint16)WID_11E_P_ACTION_REQ; + strWID.enuWIDtype = WID_STR; + strWID.s32ValueSize = 15; + ptr = strWID.ps8WidVal; + /* *ptr++ = 0x14; */ + *ptr++ = 15; + *ptr++ = 7; + *ptr++ = 0x2; + WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN); + ptr += ETH_ALEN; + /* TID*/ + *ptr++ = strHostIfBASessionInfo->u8Ted; + /* Max Num MSDU */ + *ptr++ = 8; + /* BA timeout*/ + *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF); + *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF); + /*Ack-Policy */ + *ptr++ = 3; + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + + if (strWID.ps8WidVal != NULL) + WILC_FREE(strWID.ps8WidVal); + + return s32Error; + +} + + +/*BugID_5222*/ +/** + * @brief Handle_DelBASession + * @details Delete block ack session + * @param[in] tstrHostIFSetMulti* strHostIfSetMulti + * @return NONE + * @author Amr Abdel-Moghny + * @date Feb. 2013 + * @version 9.0 + */ +static WILC_Sint32 Handle_DelBASession(void *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + char *ptr = NULL; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + + PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x \nTID=%d\n", + strHostIfBASessionInfo->au8Bssid[0], + strHostIfBASessionInfo->au8Bssid[1], + strHostIfBASessionInfo->au8Bssid[2], + strHostIfBASessionInfo->u8Ted); + + strWID.u16WIDid = (WILC_Uint16)WID_11E_P_ACTION_REQ; + strWID.enuWIDtype = WID_STR; + strWID.ps8WidVal = (WILC_Uint8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE); + strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE; + ptr = strWID.ps8WidVal; + /* *ptr++ = 0x14; */ + *ptr++ = 0x14; + *ptr++ = 0x3; + *ptr++ = 0x2; + WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN); + ptr += ETH_ALEN; + *ptr++ = strHostIfBASessionInfo->u8Ted; + /* BA direction = recipent*/ + *ptr++ = 0; + /* Delba Reason */ + *ptr++ = 32; /* Unspecific QOS reason */ + + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + if (s32Error) + PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n"); + + + strWID.u16WIDid = (WILC_Uint16)WID_11E_P_ACTION_REQ; + strWID.enuWIDtype = WID_STR; + strWID.s32ValueSize = 15; + ptr = strWID.ps8WidVal; + /* *ptr++ = 0x14; */ + *ptr++ = 15; + *ptr++ = 7; + *ptr++ = 0x3; + WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN); + ptr += ETH_ALEN; + /* TID*/ + *ptr++ = strHostIfBASessionInfo->u8Ted; + + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + + if (strWID.ps8WidVal != NULL) + WILC_FREE(strWID.ps8WidVal); + + /*BugID_5222*/ + WILC_SemaphoreRelease(&hWaitResponse, NULL); + + return s32Error; + +} + + +/** + * @brief Handle_DelAllRxBASessions + * @details Delete all Rx BA sessions + * @param[in] tstrHostIFSetMulti* strHostIfSetMulti + * @return NONE + * @author Abdelrahman Sobhy + * @date Feb. 2013 + * @version 9.0 + */ +static WILC_Sint32 Handle_DelAllRxBASessions(void *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + char *ptr = NULL; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + + PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x \nTID=%d\n", + strHostIfBASessionInfo->au8Bssid[0], + strHostIfBASessionInfo->au8Bssid[1], + strHostIfBASessionInfo->au8Bssid[2], + strHostIfBASessionInfo->u8Ted); + + strWID.u16WIDid = (WILC_Uint16)WID_DEL_ALL_RX_BA; + strWID.enuWIDtype = WID_STR; + strWID.ps8WidVal = (WILC_Uint8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE); + strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE; + ptr = strWID.ps8WidVal; + *ptr++ = 0x14; + *ptr++ = 0x3; + *ptr++ = 0x2; + WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN); + ptr += ETH_ALEN; + *ptr++ = strHostIfBASessionInfo->u8Ted; + /* BA direction = recipent*/ + *ptr++ = 0; + /* Delba Reason */ + *ptr++ = 32; /* Unspecific QOS reason */ + + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + if (s32Error) + PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n"); + + + if (strWID.ps8WidVal != NULL) + WILC_FREE(strWID.ps8WidVal); + + /*BugID_5222*/ + WILC_SemaphoreRelease(&hWaitResponse, NULL); + + return s32Error; + +} + +/** + * @brief hostIFthread + * @details Main thread to handle message queue requests + * @param[in] void* pvArg + * @return NONE + * @author + * @date + * @version 1.0 + */ +static void hostIFthread(void *pvArg) +{ + WILC_Uint32 u32Ret; + tstrHostIFmsg strHostIFmsg; + tstrWILC_WFIDrv *pstrWFIDrv; + + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + while (1) { + WILC_MsgQueueRecv(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), &u32Ret, WILC_NULL); + pstrWFIDrv = (tstrWILC_WFIDrv *)strHostIFmsg.drvHandler; + if (strHostIFmsg.u16MsgId == HOST_IF_MSG_EXIT) { + PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n"); + break; + } + + + /*Re-Queue HIF message*/ + if ((!g_wilc_initialized)) { + PRINT_D(GENERIC_DBG, "--WAIT--"); + WILC_Sleep(200); + WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + continue; + } + + if (strHostIFmsg.u16MsgId == HOST_IF_MSG_CONNECT && pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) { + PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n"); + WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + WILC_Sleep(2); + continue; + } + + switch (strHostIFmsg.u16MsgId) { + case HOST_IF_MSG_Q_IDLE: + Handle_wait_msg_q_empty(); + break; + + case HOST_IF_MSG_SCAN: + Handle_Scan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr); + break; + + case HOST_IF_MSG_CONNECT: + Handle_Connect(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr); + break; + + /*BugID_5137*/ + case HOST_IF_MSG_FLUSH_CONNECT: + Handle_FlushConnect(strHostIFmsg.drvHandler); + break; + + case HOST_IF_MSG_RCVD_NTWRK_INFO: + Handle_RcvdNtwrkInfo(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo); + break; + + case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO: + Handle_RcvdGnrlAsyncInfo(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo); + break; + + case HOST_IF_MSG_KEY: + Handle_Key(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr); + break; + + case HOST_IF_MSG_CFG_PARAMS: + + Handle_CfgParam(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFCfgParamAttr); + break; + + case HOST_IF_MSG_SET_CHANNEL: + Handle_SetChannel(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFSetChan); + break; + + case HOST_IF_MSG_DISCONNECT: + Handle_Disconnect(strHostIFmsg.drvHandler); + break; + + case HOST_IF_MSG_RCVD_SCAN_COMPLETE: + WILC_TimerStop(&(pstrWFIDrv->hScanTimer), WILC_NULL); + PRINT_D(HOSTINF_DBG, "scan completed successfully\n"); + + /*BugID_5213*/ + /*Allow chip sleep, only if both interfaces are not connected*/ + if (!linux_wlan_get_num_conn_ifcs()) { + chip_sleep_manually(INFINITE_SLEEP_TIME); + } + + Handle_ScanDone(strHostIFmsg.drvHandler, SCAN_EVENT_DONE); + + #ifdef WILC_P2P + if (pstrWFIDrv->u8RemainOnChan_pendingreq) + Handle_RemainOnChan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan); + #endif + + break; + + case HOST_IF_MSG_GET_RSSI: + Handle_GetRssi(strHostIFmsg.drvHandler); + break; + + case HOST_IF_MSG_GET_LINKSPEED: + Handle_GetLinkspeed(strHostIFmsg.drvHandler); + break; + + case HOST_IF_MSG_GET_STATISTICS: + Handle_GetStatistics(strHostIFmsg.drvHandler, (tstrStatistics *)strHostIFmsg.uniHostIFmsgBody.pUserData); + break; + + case HOST_IF_MSG_GET_CHNL: + Handle_GetChnl(strHostIFmsg.drvHandler); + break; + +#ifdef WILC_AP_EXTERNAL_MLME + case HOST_IF_MSG_ADD_BEACON: + Handle_AddBeacon(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon); + break; + + case HOST_IF_MSG_DEL_BEACON: + Handle_DelBeacon(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFDelBeacon); + break; + + case HOST_IF_MSG_ADD_STATION: + Handle_AddStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strAddStaParam); + break; + + case HOST_IF_MSG_DEL_STATION: + Handle_DelStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strDelStaParam); + break; + + case HOST_IF_MSG_EDIT_STATION: + Handle_EditStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strEditStaParam); + break; + + case HOST_IF_MSG_GET_INACTIVETIME: + Handle_Get_InActiveTime(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfStaInactiveT); + break; + +#endif /*WILC_AP_EXTERNAL_MLME*/ + case HOST_IF_MSG_SCAN_TIMER_FIRED: + PRINT_D(HOSTINF_DBG, "Scan Timeout\n"); + + Handle_ScanDone(strHostIFmsg.drvHandler, SCAN_EVENT_ABORTED); + break; + + case HOST_IF_MSG_CONNECT_TIMER_FIRED: + PRINT_D(HOSTINF_DBG, "Connect Timeout \n"); + Handle_ConnectTimeout(strHostIFmsg.drvHandler); + break; + + case HOST_IF_MSG_POWER_MGMT: + Handle_PowerManagement(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strPowerMgmtparam); + break; + + case HOST_IF_MSG_SET_WFIDRV_HANDLER: + Handle_SetWfiDrvHandler(&strHostIFmsg.uniHostIFmsgBody.strHostIfSetDrvHandler); + break; + + case HOST_IF_MSG_SET_OPERATION_MODE: + Handle_SetOperationMode(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetOperationMode); + break; + + case HOST_IF_MSG_SET_IPADDRESS: + PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n"); + Handle_set_IPAddress(strHostIFmsg.drvHandler, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx); + break; + + case HOST_IF_MSG_GET_IPADDRESS: + PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n"); + Handle_get_IPAddress(strHostIFmsg.drvHandler, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx); + break; + + /*BugID_5077*/ + case HOST_IF_MSG_SET_MAC_ADDRESS: + Handle_SetMacAddress(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMacAddress); + break; + + /*BugID_5213*/ + case HOST_IF_MSG_GET_MAC_ADDRESS: + Handle_GetMacAddress(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfGetMacAddress); + break; + +#ifdef WILC_P2P + case HOST_IF_MSG_REMAIN_ON_CHAN: + PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n"); + Handle_RemainOnChan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan); + break; + + case HOST_IF_MSG_REGISTER_FRAME: + PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n"); + Handle_RegisterFrame(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame); + break; + + case HOST_IF_MSG_LISTEN_TIMER_FIRED: + Handle_ListenStateExpired(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan); + break; + + #endif + case HOST_IF_MSG_SET_MULTICAST_FILTER: + PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n"); + Handle_SetMulticastFilter(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMulti); + break; + + /*BugID_5222*/ + case HOST_IF_MSG_ADD_BA_SESSION: + Handle_AddBASession(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo); + break; + + case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS: + Handle_DelAllRxBASessions(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo); + break; + + case HOST_IF_MSG_DEL_ALL_STA: + Handle_DelAllSta(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFDelAllSta); + break; + + default: + PRINT_ER("[Host Interface] undefined Received Msg ID \n"); + break; + } + } + + PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n"); + WILC_SemaphoreRelease(&hSemHostIFthrdEnd, WILC_NULL); + return; + /* do_exit(error); */ + /* PRINT_D(HOSTINF_DBG,"do_exit error code %d\n",error); */ + +} + +static void TimerCB_Scan(void *pvArg) +{ + tstrHostIFmsg strHostIFmsg; + + /* prepare the Timer Callback message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + strHostIFmsg.drvHandler = pvArg; + strHostIFmsg.u16MsgId = HOST_IF_MSG_SCAN_TIMER_FIRED; + + /* send the message */ + WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); +} + +static void TimerCB_Connect(void *pvArg) +{ + tstrHostIFmsg strHostIFmsg; + + /* prepare the Timer Callback message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + strHostIFmsg.drvHandler = pvArg; + strHostIFmsg.u16MsgId = HOST_IF_MSG_CONNECT_TIMER_FIRED; + + /* send the message */ + WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); +} + + +/** + * @brief removes wpa/wpa2 keys + * @details only in BSS STA mode if External Supplicant support is enabled. + * removes all WPA/WPA2 station key entries from MAC hardware. + * @param[in,out] handle to the wifi driver + * @param[in] 6 bytes of Station Adress in the station entry table + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +/* Check implementation in core adding 9 bytes to the input! */ +WILC_Sint32 host_int_remove_key(WILC_WFIDrvHandle hWFIDrv, const WILC_Uint8 *pu8StaAddress) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ + + strWID.u16WIDid = (WILC_Uint16)WID_REMOVE_KEY; + strWID.enuWIDtype = WID_STR; + strWID.ps8WidVal = (WILC_Sint8 *)pu8StaAddress; + strWID.s32ValueSize = 6; + + return s32Error; + +} + +/** + * @brief removes WEP key + * @details valid only in BSS STA mode if External Supplicant support is enabled. + * remove a WEP key entry from MAC HW. + * The BSS Station automatically finds the index of the entry using its + * BSS ID and removes that entry from the MAC hardware. + * @param[in,out] handle to the wifi driver + * @param[in] 6 bytes of Station Adress in the station entry table + * @return Error code indicating success/failure + * @note NO need for the STA add since it is not used for processing + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8keyIdx) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + /* prepare the Remove Wep Key Message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + + strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY; + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP; + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = REMOVEKEY; + strHostIFmsg.drvHandler = hWFIDrv; + + + + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. + uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8keyIdx; + + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) + PRINT_ER("Error in sending message queue : Request to remove WEP key \n"); + WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemTestKeyBlock), NULL); + + WILC_CATCH(s32Error) + { + + } + return s32Error; +} + +/** + * @brief sets WEP default key + * @details Sets the index of the WEP encryption key in use, + * in the key table + * @param[in,out] handle to the wifi driver + * @param[in] key index ( 0, 1, 2, 3) + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_set_WEPDefaultKeyID(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8Index) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + /* prepare the Key Message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + + strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY; + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP; + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = DEFAULTKEY; + strHostIFmsg.drvHandler = hWFIDrv; + + + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. + uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Index; + + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) + PRINT_ER("Error in sending message queue : Default key index\n"); + WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemTestKeyBlock), NULL); + + WILC_CATCH(s32Error) + { + + } + + return s32Error; +} + +/** + * @brief sets WEP deafault key + * @details valid only in BSS STA mode if External Supplicant support is enabled. + * sets WEP key entry into MAC hardware when it receives the + * corresponding request from NDIS. + * @param[in,out] handle to the wifi driver + * @param[in] message containing WEP Key in the following format + *|---------------------------------------| + *|Key ID Value | Key Length | Key | + *|-------------|------------|------------| + | 1byte | 1byte | Key Length | + ||---------------------------------------| + | + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv, const WILC_Uint8 *pu8WepKey, WILC_Uint8 u8WepKeylen, WILC_Uint8 u8Keyidx) +{ + + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + + } + + /* prepare the Key Message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + + strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY; + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP; + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY; + strHostIFmsg.drvHandler = hWFIDrv; + + + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. + uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = (WILC_Uint8 *)WILC_MALLOC(u8WepKeylen); + + WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey, + pu8WepKey, u8WepKeylen); + + + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. + uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen); + + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. + uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx; + + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) + PRINT_ER("Error in sending message queue :WEP Key\n"); + WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemTestKeyBlock), NULL); + + WILC_CATCH(s32Error) + { + + } + return s32Error; + +} + +#ifdef WILC_AP_EXTERNAL_MLME +/** + * + * @brief host_int_add_wep_key_bss_ap + * @details valid only in BSS AP mode if External Supplicant support is enabled. + * sets WEP key entry into MAC hardware when it receives the + * + * corresponding request from NDIS. + * @param[in,out] handle to the wifi driver + * + * + * @return Error code indicating success/failure + * @note + * @author mdaftedar + * @date 28 FEB 2013 + * @version 1.0 + */ +WILC_Sint32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const WILC_Uint8 *pu8WepKey, WILC_Uint8 u8WepKeylen, WILC_Uint8 u8Keyidx, WILC_Uint8 u8mode, AUTHTYPE_T tenuAuth_type) +{ + + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + WILC_Uint8 i; + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + + } + + /* prepare the Key Message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + if (INFO) { + for (i = 0; i < u8WepKeylen; i++) + PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]); + } + strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY; + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP; + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP; + strHostIFmsg.drvHandler = hWFIDrv; + + + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. + uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = (WILC_Uint8 *)WILC_MALLOC((u8WepKeylen)); + + + WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey, + pu8WepKey, (u8WepKeylen)); + + + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. + uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen); + + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. + uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx; + + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. + uniHostIFkeyAttr.strHostIFwepAttr.u8mode = u8mode; + + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. + uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type = tenuAuth_type; + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + + if (s32Error) + PRINT_ER("Error in sending message queue :WEP Key\n"); + WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemTestKeyBlock), NULL); + + WILC_CATCH(s32Error) + { + + } + return s32Error; + +} +#endif +/** + * @brief adds ptk Key + * @details + * @param[in,out] handle to the wifi driver + * @param[in] message containing PTK Key in the following format + *|-----------------------------------------------------------------------------| + *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key | + *|----------------|------------|--------------|----------------|---------------| + | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes | + ||-----------------------------------------------------------------------------| + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8Ptk, WILC_Uint8 u8PtkKeylen, + const WILC_Uint8 *mac_addr, WILC_Uint8 *pu8RxMic, WILC_Uint8 *pu8TxMic, WILC_Uint8 mode, WILC_Uint8 u8Ciphermode, WILC_Uint8 u8Idx) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + WILC_Uint8 u8KeyLen = u8PtkKeylen; + WILC_Uint32 i; + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + if (pu8RxMic != NULL) { + u8KeyLen += RX_MIC_KEY_LEN; + } + if (pu8TxMic != NULL) { + u8KeyLen += TX_MIC_KEY_LEN; + } + + /* prepare the Key Message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + + strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY; + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPAPtk; + #ifdef WILC_AP_EXTERNAL_MLME + if (mode == AP_MODE) { + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP; + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. + uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8Idx; + } + #endif + if (mode == STATION_MODE) + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY; + + + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. + uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = (WILC_Uint8 *)WILC_MALLOC(u8PtkKeylen); + + + WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key, + pu8Ptk, u8PtkKeylen); + + if (pu8RxMic != NULL) { + + WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16, + pu8RxMic, RX_MIC_KEY_LEN); + if (INFO) { + for (i = 0; i < RX_MIC_KEY_LEN; i++) + PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]); + } + } + if (pu8TxMic != NULL) { + + WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24, + pu8TxMic, TX_MIC_KEY_LEN); + if (INFO) { + for (i = 0; i < TX_MIC_KEY_LEN; i++) + PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]); + } + } + + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. + uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen; + + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. + uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode; + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. + uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr = mac_addr; + strHostIFmsg.drvHandler = hWFIDrv; + + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + + if (s32Error) + PRINT_ER("Error in sending message queue: PTK Key\n"); + + /* ////////////// */ + WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemTestKeyBlock), NULL); + /* WILC_Sleep(100); */ + /* /////// */ + + WILC_CATCH(s32Error) + { + + } + + return s32Error; +} + +/** + * @brief adds Rx GTk Key + * @details + * @param[in,out] handle to the wifi driver + * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic + * u8GtkKeylen :The total key length + * + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8RxGtk, WILC_Uint8 u8GtkKeylen, + WILC_Uint8 u8KeyIdx, WILC_Uint32 u32KeyRSClen, WILC_Uint8 *KeyRSC, + WILC_Uint8 *pu8RxMic, WILC_Uint8 *pu8TxMic, WILC_Uint8 mode, WILC_Uint8 u8Ciphermode) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + WILC_Uint8 u8KeyLen = u8GtkKeylen; + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + /* prepare the Key Message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + + if (pu8RxMic != NULL) { + u8KeyLen += RX_MIC_KEY_LEN; + } + if (pu8TxMic != NULL) { + u8KeyLen += TX_MIC_KEY_LEN; + } + if (KeyRSC != NULL) { + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. + uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = (WILC_Uint8 *)WILC_MALLOC(u32KeyRSClen); + + WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, + KeyRSC, u32KeyRSClen); + } + + + strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY; + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPARxGtk; + strHostIFmsg.drvHandler = hWFIDrv; + + #ifdef WILC_AP_EXTERNAL_MLME + if (mode == AP_MODE) { + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP; + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode; + } + #endif + if (mode == STATION_MODE) + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY; + + + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. + uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = (WILC_Uint8 *)WILC_MALLOC(u8KeyLen); + + WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key, + pu8RxGtk, u8GtkKeylen); + + if (pu8RxMic != NULL) { + + WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16, + pu8RxMic, RX_MIC_KEY_LEN); + + } + if (pu8TxMic != NULL) { + + WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24, + pu8TxMic, TX_MIC_KEY_LEN); + + } + + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. + uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8KeyIdx; + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. + uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen; + + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. + uniHostIFkeyAttr.strHostIFwpaAttr.u8seqlen = u32KeyRSClen; + + + + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) + PRINT_ER("Error in sending message queue: RX GTK\n"); + /* ////////////// */ + WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemTestKeyBlock), NULL); + /* WILC_Sleep(100); */ + /* /////// */ + + WILC_CATCH(s32Error) + { + + } + return s32Error; +} +#if 0 +/** + * @brief host_int_add_tx_gtk + * @details adds Tx GTk Key + * @param[in,out] handle to the wifi driver + * @param[in] message containing Tx GTK Key in the following format + *|----------------------------------------------------| + | KeyID | Key Length | Temporal Key | Tx Michael Key | + ||-------|------------|--------------|----------------| + ||1 byte | 1 byte | 16 bytes | 8 bytes | + ||----------------------------------------------------| + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_add_tx_gtk(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8KeyLen, WILC_Uint8 *pu8TxGtk, WILC_Uint8 u8KeyIdx) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + /* prepare the Key Message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY; + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPATxGtk; + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY; + + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. + uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = (WILC_Uint8 *)WILC_MALLOC(u8KeyLen); + + WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key, + pu8TxGtk, u8KeyLen); + + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen; + + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) + PRINT_ER("Error in sending message queue: TX GTK\n"); + + /* ////////////// */ + WILC_SemaphoreAcquire(&hSemTestKeyBlock, NULL); + WILC_Sleep(100); + /* /////// */ + + WILC_CATCH(s32Error) + { + + } + return s32Error; +} +#endif +/** + * @brief host_int_set_pmkid_info + * @details caches the pmkid valid only in BSS STA mode if External Supplicant + * support is enabled. This Function sets the PMKID in firmware + * when host drivr receives the corresponding request from NDIS. + * The firmware then includes theset PMKID in the appropriate + * management frames + * @param[in,out] handle to the wifi driver + * @param[in] message containing PMKID Info in the following format + *|-----------------------------------------------------------------| + *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] | + *|-----------|------------|----------|-------|----------|----------| + | 1 | 6 | 16 | ... | 6 | 16 | + ||-----------------------------------------------------------------| + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_set_pmkid_info(WILC_WFIDrvHandle hWFIDrv, tstrHostIFpmkidAttr *pu8PmkidInfoArray) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + WILC_Uint32 i; + + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + /* prepare the Key Message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY; + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = PMKSA; + strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY; + strHostIFmsg.drvHandler = hWFIDrv; + + for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) { + + WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid, + ETH_ALEN); + + WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid, + PMKID_LEN); + } + + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) + PRINT_ER(" Error in sending messagequeue: PMKID Info\n"); + + WILC_CATCH(s32Error) + { + + } + + return s32Error; +} + +/** + * @brief gets the cached the pmkid info + * @details valid only in BSS STA mode if External Supplicant + * support is enabled. This Function sets the PMKID in firmware + * when host drivr receives the corresponding request from NDIS. + * The firmware then includes theset PMKID in the appropriate + * management frames + * @param[in,out] handle to the wifi driver, + * message containing PMKID Info in the following format + *|-----------------------------------------------------------------| + *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] | + *|-----------|------------|----------|-------|----------|----------| + | 1 | 6 | 16 | ... | 6 | 16 | + ||-----------------------------------------------------------------| + * @param[in] + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_get_pmkid_info(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8PmkidInfoArray, + WILC_Uint32 u32PmkidInfoLen) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ + + strWID.u16WIDid = (WILC_Uint16)WID_PMKID_INFO; + strWID.enuWIDtype = WID_STR; + strWID.s32ValueSize = u32PmkidInfoLen; + strWID.ps8WidVal = pu8PmkidInfoArray; + + return s32Error; +} + +/** + * @brief sets the pass phrase + * @details AP/STA mode. This function gives the pass phrase used to + * generate the Pre-Shared Key when WPA/WPA2 is enabled + * The length of the field can vary from 8 to 64 bytes, + * the lower layer should get the + * @param[in,out] handle to the wifi driver, + * @param[in] String containing PSK + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_set_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8PassPhrase, + WILC_Uint8 u8Psklength) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ + + /* WILC_Uint8 u8Psklength = WILC_strlen(pu8PassPhrase); */ + /*validating psk length*/ + if ((u8Psklength > 7) && (u8Psklength < 65)) { + strWID.u16WIDid = (WILC_Uint16)WID_11I_PSK; + strWID.enuWIDtype = WID_STR; + strWID.ps8WidVal = pu8PassPhrase; + strWID.s32ValueSize = u8Psklength; + } + + return s32Error; +} +/** + * @brief host_int_get_MacAddress + * @details gets mac address + * @param[in,out] handle to the wifi driver, + * + * @return Error code indicating success/failure + * @note + * @author mdaftedar + * @date 19 April 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_get_MacAddress(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8MacAddress) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrHostIFmsg strHostIFmsg; + + + /* prepare the Message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_MAC_ADDRESS; + strHostIFmsg.uniHostIFmsgBody.strHostIfGetMacAddress.u8MacAddress = pu8MacAddress; + strHostIFmsg.drvHandler = hWFIDrv; + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + PRINT_ER("Failed to send get mac address\n"); + return WILC_FAIL; + } + + WILC_SemaphoreAcquire(&hWaitResponse, NULL); + return s32Error; +} + +/** + * @brief host_int_set_MacAddress + * @details sets mac address + * @param[in,out] handle to the wifi driver, + * + * @return Error code indicating success/failure + * @note + * @author mabubakr + * @date 16 July 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_set_MacAddress(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8MacAddress) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrHostIFmsg strHostIFmsg; + + PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]); + + /* prepare setting mac address message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_MAC_ADDRESS; + WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIfSetMacAddress.u8MacAddress, pu8MacAddress, ETH_ALEN); + strHostIFmsg.drvHandler = hWFIDrv; + + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + PRINT_ER("Failed to send message queue: Set mac address\n"); + WILC_ERRORREPORT(s32Error, s32Error); + } + WILC_CATCH(s32Error) + { + + } + + return s32Error; + +} + +/** + * @brief host_int_get_RSNAConfigPSKPassPhrase + * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to + * generate the Pre-Shared Key when WPA/WPA2 is enabled + * The length of the field can vary from 8 to 64 bytes, + * the lower layer should get the + * @param[in,out] handle to the wifi driver, + * String containing PSK + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_get_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, + WILC_Uint8 *pu8PassPhrase, WILC_Uint8 u8Psklength) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ + + strWID.u16WIDid = (WILC_Uint16)WID_11I_PSK; + strWID.enuWIDtype = WID_STR; + strWID.s32ValueSize = u8Psklength; + strWID.ps8WidVal = pu8PassPhrase; + + return s32Error; +} + +/** + * @brief host_int_get_site_survey_results + * @details gets the site survey results + * @param[in,out] handle to the wifi driver, + * Message containing site survey results in the + * following format + *|---------------------------------------------------| + | MsgLength | fragNo. | MsgBodyLength | MsgBody | + ||-----------|-----------|---------------|-----------| + | 1 | 1 | 1 | 1 | + | ----------------------------------------- | ---------------- + | + ||---------------------------------------| + | Network1 | Netweork2 | ... | Network5 | + ||---------------------------------------| + | 44 | 44 | ... | 44 | + | -------------------------- | --------------------------------------- + | + ||---------------------------------------------------------------------| + | SSID | BSS Type | Channel | Security Status| BSSID | RSSI |Reserved | + | + | + ||------|----------|---------|----------------|-------|------|---------| + | 33 | 1 | 1 | 1 | 6 | 1 | 1 | + ||---------------------------------------------------------------------| + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +#ifndef CONNECT_DIRECT +WILC_Sint32 host_int_get_site_survey_results(WILC_WFIDrvHandle hWFIDrv, + WILC_Uint8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE], + WILC_Uint32 u32MaxSiteSrvyFragLen) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID astrWIDList[2]; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + + astrWIDList[0].u16WIDid = (WILC_Uint16)WID_SITE_SURVEY_RESULTS; + astrWIDList[0].enuWIDtype = WID_STR; + astrWIDList[0].ps8WidVal = ppu8RcvdSiteSurveyResults[0]; + astrWIDList[0].s32ValueSize = u32MaxSiteSrvyFragLen; + + astrWIDList[1].u16WIDid = (WILC_Uint16)WID_SITE_SURVEY_RESULTS; + astrWIDList[1].enuWIDtype = WID_STR; + astrWIDList[1].ps8WidVal = ppu8RcvdSiteSurveyResults[1]; + astrWIDList[1].s32ValueSize = u32MaxSiteSrvyFragLen; + + s32Error = SendConfigPkt(GET_CFG, astrWIDList, 2, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + + /*get the value by searching the local copy*/ + if (s32Error) { + PRINT_ER("Failed to send config packet to get survey results\n"); + WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); + } + + WILC_CATCH(s32Error) + { + + } + + return s32Error; +} +#endif + +/** + * @brief sets a start scan request + * @details + * @param[in,out] handle to the wifi driver, + * @param[in] Scan Source one of the following values + * DEFAULT_SCAN 0 + * USER_SCAN BIT0 + * OBSS_PERIODIC_SCAN BIT1 + * OBSS_ONETIME_SCAN BIT2 + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_set_start_scan_req(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 scanSource) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ + + strWID.u16WIDid = (WILC_Uint16)WID_START_SCAN_REQ; + strWID.enuWIDtype = WID_CHAR; + strWID.ps8WidVal = (WILC_Sint8 *)&scanSource; + strWID.s32ValueSize = sizeof(WILC_Char); + + return s32Error; +} + +/** + * @brief host_int_get_start_scan_req + * @details gets a start scan request + * @param[in,out] handle to the wifi driver, + * @param[in] Scan Source one of the following values + * DEFAULT_SCAN 0 + * USER_SCAN BIT0 + * OBSS_PERIODIC_SCAN BIT1 + * OBSS_ONETIME_SCAN BIT2 + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ + +WILC_Sint32 host_int_get_start_scan_req(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8ScanSource) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ + + strWID.u16WIDid = (WILC_Uint16)WID_START_SCAN_REQ; + strWID.enuWIDtype = WID_CHAR; + strWID.ps8WidVal = (WILC_Sint8 *)pu8ScanSource; + strWID.s32ValueSize = sizeof(WILC_Char); + + return s32Error; +} + +/** + * @brief host_int_set_join_req + * @details sets a join request + * @param[in,out] handle to the wifi driver, + * @param[in] Index of the bss descriptor + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8bssid, + WILC_Uint8 *pu8ssid, size_t ssidLen, + const WILC_Uint8 *pu8IEs, size_t IEsLen, + tWILCpfConnectResult pfConnectResult, void *pvUserArg, + WILC_Uint8 u8security, AUTHTYPE_T tenuAuth_type, + WILC_Uint8 u8channel, + void *pJoinParams) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + tenuScanConnTimer enuScanConnTimer; + + if (pstrWFIDrv == WILC_NULL || pfConnectResult == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + if (hWFIDrv == NULL) { + PRINT_ER("Driver not initialized: gWFiDrvHandle = NULL\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + + if (pJoinParams == NULL) { + PRINT_ER("Unable to Join - JoinParams is NULL\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + + } +/* + * if(gWFiDrvHandle->strWILC_UsrScanReq.u32RcvdChCount == 0) + * { + * PRINT_ER("No scan results exist: Scanning should be done\n"); + * WILC_ERRORREPORT(s32Error, WILC_FAIL); + * } + */ + /* prepare the Connect Message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + strHostIFmsg.u16MsgId = HOST_IF_MSG_CONNECT; + + strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.u8security = u8security; + strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.tenuAuth_type = tenuAuth_type; + strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.u8channel = u8channel; + strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pfConnectResult = pfConnectResult; + strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pvUserArg = pvUserArg; + strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pJoinParams = pJoinParams; + strHostIFmsg.drvHandler = hWFIDrv; + + if (pu8bssid != NULL) { + strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid = (WILC_Uint8 *)WILC_MALLOC(6); /* will be deallocated by the receiving thread */ + WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid, + pu8bssid, 6); + } + + if (pu8ssid != NULL) { + strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.ssidLen = ssidLen; + strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid = (WILC_Uint8 *)WILC_MALLOC(ssidLen); /* will be deallocated by the receiving thread */ + WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid, + + pu8ssid, ssidLen); + } + + if (pu8IEs != NULL) { + strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.IEsLen = IEsLen; + strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs = (WILC_Uint8 *)WILC_MALLOC(IEsLen); /* will be deallocated by the receiving thread */ + WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs, + pu8IEs, IEsLen); + } + if (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTING) { + pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTING; + } else + PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv->enuHostIFstate); + + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + PRINT_ER("Failed to send message queue: Set join request\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + + enuScanConnTimer = CONNECT_TIMER; + WILC_TimerStart(&(pstrWFIDrv->hConnectTimer), HOST_IF_CONNECT_TIMEOUT, (void *) hWFIDrv, WILC_NULL); + + WILC_CATCH(s32Error) + { + + } + + return s32Error; +} + +/** + * @brief Flush a join request parameters to FW, but actual connection + * @details The function is called in situation where WILC is connected to AP and + * required to switch to hybrid FW for P2P connection + * @param[in] handle to the wifi driver, + * @return Error code indicating success/failure + * @note + * @author Amr Abdel-Moghny + * @date 19 DEC 2013 + * @version 8.0 + */ + +WILC_Sint32 host_int_flush_join_req(WILC_WFIDrvHandle hWFIDrv) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrHostIFmsg strHostIFmsg; + + if (!gu8FlushedJoinReq) { + s32Error = WILC_FAIL; + return s32Error; + } + + + if (hWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + + strHostIFmsg.u16MsgId = HOST_IF_MSG_FLUSH_CONNECT; + strHostIFmsg.drvHandler = hWFIDrv; + + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + PRINT_ER("Failed to send message queue: Flush join request\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + + WILC_CATCH(s32Error) + { + + } + return s32Error; +} + +/** + * @brief host_int_disconnect + * @details disconnects from the currently associated network + * @param[in,out] handle to the wifi driver, + * @param[in] Reason Code of the Disconnection + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_disconnect(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16ReasonCode) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrHostIFmsg strHostIFmsg; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + + if (pstrWFIDrv == WILC_NULL) { + PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n"); + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + if (pstrWFIDrv == NULL) { + PRINT_ER("gWFiDrvHandle = NULL\n"); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + + /* prepare the Disconnect Message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + strHostIFmsg.u16MsgId = HOST_IF_MSG_DISCONNECT; + strHostIFmsg.drvHandler = hWFIDrv; + + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) + PRINT_ER("Failed to send message queue: disconnect\n"); + /* ////////////// */ + WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemTestDisconnectBlock), NULL); + /* /////// */ + + WILC_CATCH(s32Error) + { + + } + + return s32Error; +} + +/** + * @brief host_int_disconnect_station + * @details disconnects a sta + * @param[in,out] handle to the wifi driver, + * @param[in] Association Id of the station to be disconnected + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_disconnect_station(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 assoc_id) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ + + strWID.u16WIDid = (WILC_Uint16)WID_DISCONNECT; + strWID.enuWIDtype = WID_CHAR; + strWID.ps8WidVal = (WILC_Sint8 *)&assoc_id; + strWID.s32ValueSize = sizeof(WILC_Char); + + return s32Error; +} + +/** + * @brief host_int_get_assoc_req_info + * @details gets a Association request info + * @param[in,out] handle to the wifi driver, + * Message containg assoc. req info in the following format + * ------------------------------------------------------------------------ + | Management Frame Format | + ||-------------------------------------------------------------------| + ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS | + ||-------------|--------|--|--|-----|----------------|----------|----| + | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 | + ||-------------------------------------------------------------------| + | | + | Association Request Frame - Frame Body | + ||-------------------------------------------------------------------| + | Capability Information | Listen Interval | SSID | Supported Rates | + ||------------------------|-----------------|------|-----------------| + | 2 | 2 | 2-34 | 3-10 | + | --------------------------------------------------------------------- + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ + +WILC_Sint32 host_int_get_assoc_req_info(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8AssocReqInfo, + WILC_Uint32 u32AssocReqInfoLen) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ + + strWID.u16WIDid = (WILC_Uint16)WID_ASSOC_REQ_INFO; + strWID.enuWIDtype = WID_STR; + strWID.ps8WidVal = pu8AssocReqInfo; + strWID.s32ValueSize = u32AssocReqInfoLen; + + + return s32Error; +} + +/** + * @brief gets a Association Response info + * @details + * @param[in,out] handle to the wifi driver, + * Message containg assoc. resp info + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8AssocRespInfo, + WILC_Uint32 u32MaxAssocRespInfoLen, WILC_Uint32 *pu32RcvdAssocRespInfoLen) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + + if (pstrWFIDrv == WILC_NULL) { + PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n"); + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + strWID.u16WIDid = (WILC_Uint16)WID_ASSOC_RES_INFO; + strWID.enuWIDtype = WID_STR; + strWID.ps8WidVal = pu8AssocRespInfo; + strWID.s32ValueSize = u32MaxAssocRespInfoLen; + + + /* Sending Configuration packet */ + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + if (s32Error) { + PRINT_ER("Failed to send association response config packet\n"); + *pu32RcvdAssocRespInfoLen = 0; + WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); + } else { + *pu32RcvdAssocRespInfoLen = strWID.s32ValueSize; + } + + WILC_CATCH(s32Error) + { + + } + return s32Error; +} + +/** + * @brief gets a Association Response info + * @details Valid only in STA mode. This function gives the RSSI + * values observed in all the channels at the time of scanning. + * The length of the field is 1 greater that the total number of + * channels supported. Byte 0 contains the number of channels while + * each of Byte N contains the observed RSSI value for the channel index N. + * @param[in,out] handle to the wifi driver, + * array of scanned channels' RSSI + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_get_rx_power_level(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8RxPowerLevel, + WILC_Uint32 u32RxPowerLevelLen) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ + + strWID.u16WIDid = (WILC_Uint16)WID_RX_POWER_LEVEL; + strWID.enuWIDtype = WID_STR; + strWID.ps8WidVal = pu8RxPowerLevel; + strWID.s32ValueSize = u32RxPowerLevelLen; + + + return s32Error; +} + +/** + * @brief sets a channel + * @details + * @param[in,out] handle to the wifi driver, + * @param[in] Index of the channel to be set + *|-------------------------------------------------------------------| + | CHANNEL1 CHANNEL2 .... CHANNEL14 | + | Input: 1 2 14 | + ||-------------------------------------------------------------------| + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_set_mac_chnl_num(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8ChNum) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + /* prepare the set channel message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_CHANNEL; + strHostIFmsg.uniHostIFmsgBody.strHostIFSetChan.u8SetChan = u8ChNum; + strHostIFmsg.drvHandler = hWFIDrv; + + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + WILC_ERRORREPORT(s32Error, s32Error); + } + WILC_CATCH(s32Error) + { + + } + + return s32Error; +} + + +WILC_Sint32 host_int_wait_msg_queue_idle(void) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + + tstrHostIFmsg strHostIFmsg; + + /* prepare the set driver handler message */ + + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + strHostIFmsg.u16MsgId = HOST_IF_MSG_Q_IDLE; + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + WILC_ERRORREPORT(s32Error, s32Error); + } + WILC_CATCH(s32Error) + { + + } + + /* wait untill MSG Q is empty */ + WILC_SemaphoreAcquire(&hWaitResponse, NULL); + + return s32Error; + +} + +WILC_Sint32 host_int_set_wfi_drv_handler(WILC_Uint32 u32address) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + + tstrHostIFmsg strHostIFmsg; + + + /* prepare the set driver handler message */ + + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_WFIDRV_HANDLER; + strHostIFmsg.uniHostIFmsgBody.strHostIfSetDrvHandler.u32Address = u32address; + /* strHostIFmsg.drvHandler=hWFIDrv; */ + + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + WILC_ERRORREPORT(s32Error, s32Error); + } + WILC_CATCH(s32Error) + { + + } + + return s32Error; +} + + + +WILC_Sint32 host_int_set_operation_mode(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32mode) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + + tstrHostIFmsg strHostIFmsg; + + + /* prepare the set driver handler message */ + + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_OPERATION_MODE; + strHostIFmsg.uniHostIFmsgBody.strHostIfSetOperationMode.u32Mode = u32mode; + strHostIFmsg.drvHandler = hWFIDrv; + + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + WILC_ERRORREPORT(s32Error, s32Error); + } + WILC_CATCH(s32Error) + { + + } + + return s32Error; +} + +/** + * @brief gets the current channel index + * @details + * @param[in,out] handle to the wifi driver, + * current channel index + *|-----------------------------------------------------------------------| + | CHANNEL1 CHANNEL2 .... CHANNEL14 | + | Input: 1 2 14 | + ||-----------------------------------------------------------------------| + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_get_host_chnl_num(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8ChNo) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + + if (pstrWFIDrv == WILC_NULL) { + PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n"); + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + /* prepare the Get Channel Message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_CHNL; + strHostIFmsg.drvHandler = hWFIDrv; + + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) + PRINT_ER("Failed to send get host channel param's message queue "); + WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemGetCHNL), NULL); + /* gu8Chnl = 11; */ + + *pu8ChNo = gu8Chnl; + + WILC_CATCH(s32Error) + { + } + + return s32Error; + + +} + + +/** + * @brief host_int_test_set_int_wid + * @details Test function for setting wids + * @param[in,out] WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32TestMemAddr + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_test_set_int_wid(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32TestMemAddr) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + + + if (pstrWFIDrv == WILC_NULL) { + PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n"); + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + /*prepare configuration packet*/ + strWID.u16WIDid = (WILC_Uint16)WID_MEMORY_ADDRESS; + strWID.enuWIDtype = WID_INT; + strWID.ps8WidVal = (WILC_Char *)&u32TestMemAddr; + strWID.s32ValueSize = sizeof(WILC_Uint32); + + /*Sending Cfg*/ + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + if (s32Error) { + PRINT_ER("Test Function: Failed to set wid value\n"); + WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); + } else { + PRINT_D(HOSTINF_DBG, "Successfully set wid value\n"); + + } + + WILC_CATCH(s32Error) + { + + } + return s32Error; +} + +#ifdef WILC_AP_EXTERNAL_MLME +/** + * @brief host_int_get_inactive_time + * @details + * @param[in,out] handle to the wifi driver, + * current sta macaddress, inactive_time + * @return + * @note + * @author + * @date + * @version 1.0 + */ +WILC_Sint32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *mac, WILC_Uint32 *pu32InactiveTime) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + + if (pstrWFIDrv == WILC_NULL) { + PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n"); + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + + WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIfStaInactiveT.mac, + mac, ETH_ALEN); + + strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_INACTIVETIME; + strHostIFmsg.drvHandler = hWFIDrv; + + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) + PRINT_ER("Failed to send get host channel param's message queue "); + + WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemInactiveTime), NULL); + + *pu32InactiveTime = gu32InactiveTime; + + WILC_CATCH(s32Error) + { + } + + return s32Error; +} +#endif +/** + * @brief host_int_test_get_int_wid + * @details Test function for getting wids + * @param[in,out] WILC_WFIDrvHandle hWFIDrv, WILC_Uint32* pu32TestMemAddr + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_test_get_int_wid(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 *pu32TestMemAddr) +{ + + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWID strWID; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + + + if (pstrWFIDrv == WILC_NULL) { + PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n"); + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + strWID.u16WIDid = (WILC_Uint16)WID_MEMORY_ADDRESS; + strWID.enuWIDtype = WID_INT; + strWID.ps8WidVal = (WILC_Sint8 *)pu32TestMemAddr; + strWID.s32ValueSize = sizeof(WILC_Uint32); + + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + /*get the value by searching the local copy*/ + if (s32Error) { + PRINT_ER("Test Function: Failed to get wid value\n"); + WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); + } else { + PRINT_D(HOSTINF_DBG, "Successfully got wid value\n"); + + } + + WILC_CATCH(s32Error) + { + + } + return s32Error; +} + + +/** + * @brief host_int_get_rssi + * @details gets the currently maintained RSSI value for the station. + * The received signal strength value in dB. + * The range of valid values is -128 to 0. + * @param[in,out] handle to the wifi driver, + * rssi value in dB + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_get_rssi(WILC_WFIDrvHandle hWFIDrv, WILC_Sint8 *ps8Rssi) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrHostIFmsg strHostIFmsg; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + + + /* prepare the Get RSSI Message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_RSSI; + strHostIFmsg.drvHandler = hWFIDrv; + + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + PRINT_ER("Failed to send get host channel param's message queue "); + return WILC_FAIL; + } + + WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemGetRSSI), NULL); + + + if (ps8Rssi == NULL) { + PRINT_ER("RSS pointer value is null"); + return WILC_FAIL; + } + + + *ps8Rssi = gs8Rssi; + + + return s32Error; +} + +WILC_Sint32 host_int_get_link_speed(WILC_WFIDrvHandle hWFIDrv, WILC_Sint8 *ps8lnkspd) +{ + tstrHostIFmsg strHostIFmsg; + WILC_Sint32 s32Error = WILC_SUCCESS; + + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + + + + /* prepare the Get LINKSPEED Message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_LINKSPEED; + strHostIFmsg.drvHandler = hWFIDrv; + + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + PRINT_ER("Failed to send GET_LINKSPEED to message queue "); + return WILC_FAIL; + } + + WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemGetLINKSPEED), NULL); + + + if (ps8lnkspd == NULL) { + PRINT_ER("LINKSPEED pointer value is null"); + return WILC_FAIL; + } + + + *ps8lnkspd = gs8lnkspd; + + + return s32Error; +} + +WILC_Sint32 host_int_get_statistics(WILC_WFIDrvHandle hWFIDrv, tstrStatistics *pstrStatistics) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrHostIFmsg strHostIFmsg; + + + /* prepare the Get RSSI Message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_STATISTICS; + strHostIFmsg.uniHostIFmsgBody.pUserData = (WILC_Char *)pstrStatistics; + strHostIFmsg.drvHandler = hWFIDrv; + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + PRINT_ER("Failed to send get host channel param's message queue "); + return WILC_FAIL; + } + + WILC_SemaphoreAcquire(&hWaitResponse, NULL); + return s32Error; +} + + +/** + * @brief host_int_scan + * @details scans a set of channels + * @param[in,out] handle to the wifi driver, + * @param[in] Scan source + * Scan Type PASSIVE_SCAN = 0, + * ACTIVE_SCAN = 1 + * Channels Array + * Channels Array length + * Scan Callback function + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 host_int_scan(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8ScanSource, + WILC_Uint8 u8ScanType, WILC_Uint8 *pu8ChnlFreqList, + WILC_Uint8 u8ChnlListLen, const WILC_Uint8 *pu8IEs, + size_t IEsLen, tWILCpfScanResult ScanResult, + void *pvUserArg, tstrHiddenNetwork *pstrHiddenNetwork) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + tenuScanConnTimer enuScanConnTimer; + + if (pstrWFIDrv == WILC_NULL || ScanResult == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + + /* prepare the Scan Message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + strHostIFmsg.u16MsgId = HOST_IF_MSG_SCAN; + + if (pstrHiddenNetwork != NULL) { + strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.strHiddenNetwork.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo; + strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.strHiddenNetwork.u8ssidnum = pstrHiddenNetwork->u8ssidnum; + + } else + PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n"); + + strHostIFmsg.drvHandler = hWFIDrv; + strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ScanSource = u8ScanSource; + strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ScanType = u8ScanType; + strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pfScanResult = ScanResult; + strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pvUserArg = pvUserArg; + + strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ChnlListLen = u8ChnlListLen; + strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList = (WILC_Uint8 *)WILC_MALLOC(u8ChnlListLen); /* will be deallocated by the receiving thread */ + WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList, + pu8ChnlFreqList, u8ChnlListLen); + + strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.IEsLen = IEsLen; + strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs = (WILC_Uint8 *)WILC_MALLOC(IEsLen); /* will be deallocated by the receiving thread */ + WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs, + pu8IEs, IEsLen); + + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + PRINT_ER("Error in sending message queue scanning parameters: Error(%d)\n", s32Error); + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + + enuScanConnTimer = SCAN_TIMER; + PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n"); + WILC_TimerStart(&(pstrWFIDrv->hScanTimer), HOST_IF_SCAN_TIMEOUT, (void *) hWFIDrv, WILC_NULL); + + + WILC_CATCH(s32Error) + { + + } + return s32Error; + +} +/** + * @brief hif_set_cfg + * @details sets configuration wids values + * @param[in,out] handle to the wifi driver, + * @param[in] WID, WID value + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 hif_set_cfg(WILC_WFIDrvHandle hWFIDrv, tstrCfgParamVal *pstrCfgParamVal) +{ + + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + + tstrHostIFmsg strHostIFmsg; + + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + /* prepare the WiphyParams Message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + strHostIFmsg.u16MsgId = HOST_IF_MSG_CFG_PARAMS; + strHostIFmsg.uniHostIFmsgBody.strHostIFCfgParamAttr.pstrCfgParamVal = *pstrCfgParamVal; + strHostIFmsg.drvHandler = hWFIDrv; + + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + + WILC_CATCH(s32Error) + { + } + + return s32Error; + +} + + +/** + * @brief hif_get_cfg + * @details gets configuration wids values + * @param[in,out] handle to the wifi driver, + * WID value + * @param[in] WID, + * @return Error code indicating success/failure + * @note + * @author zsalah + * + * @date 8 March 2012 + * @version 1.0 + */ +WILC_Sint32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16WID, WILC_Uint16 *pu16WID_Value) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + + WILC_SemaphoreAcquire(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + + if (pstrWFIDrv == WILC_NULL) { + PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n"); + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n"); + switch (u16WID) { + + case WID_BSS_TYPE: + *pu16WID_Value = (WILC_Uint16)pstrWFIDrv->strCfgValues.bss_type; + break; + + case WID_AUTH_TYPE: + *pu16WID_Value = (WILC_Uint16)pstrWFIDrv->strCfgValues.auth_type; + break; + + case WID_AUTH_TIMEOUT: + *pu16WID_Value = pstrWFIDrv->strCfgValues.auth_timeout; + break; + + case WID_POWER_MANAGEMENT: + *pu16WID_Value = (WILC_Uint16)pstrWFIDrv->strCfgValues.power_mgmt_mode; + break; + + case WID_SHORT_RETRY_LIMIT: + *pu16WID_Value = pstrWFIDrv->strCfgValues.short_retry_limit; + break; + + case WID_LONG_RETRY_LIMIT: + *pu16WID_Value = pstrWFIDrv->strCfgValues.long_retry_limit; + break; + + case WID_FRAG_THRESHOLD: + *pu16WID_Value = pstrWFIDrv->strCfgValues.frag_threshold; + break; + + case WID_RTS_THRESHOLD: + *pu16WID_Value = pstrWFIDrv->strCfgValues.rts_threshold; + break; + + case WID_PREAMBLE: + *pu16WID_Value = (WILC_Uint16)pstrWFIDrv->strCfgValues.preamble_type; + break; + + case WID_SHORT_SLOT_ALLOWED: + *pu16WID_Value = (WILC_Uint16) pstrWFIDrv->strCfgValues.short_slot_allowed; + break; + + case WID_11N_TXOP_PROT_DISABLE: + *pu16WID_Value = (WILC_Uint16)pstrWFIDrv->strCfgValues.txop_prot_disabled; + break; + + case WID_BEACON_INTERVAL: + *pu16WID_Value = pstrWFIDrv->strCfgValues.beacon_interval; + break; + + case WID_DTIM_PERIOD: + *pu16WID_Value = (WILC_Uint16)pstrWFIDrv->strCfgValues.dtim_period; + break; + + case WID_SITE_SURVEY: + *pu16WID_Value = (WILC_Uint16)pstrWFIDrv->strCfgValues.site_survey_enabled; + break; + + case WID_SITE_SURVEY_SCAN_TIME: + *pu16WID_Value = pstrWFIDrv->strCfgValues.site_survey_scan_time; + break; + + case WID_ACTIVE_SCAN_TIME: + *pu16WID_Value = pstrWFIDrv->strCfgValues.active_scan_time; + break; + + case WID_PASSIVE_SCAN_TIME: + *pu16WID_Value = pstrWFIDrv->strCfgValues.passive_scan_time; + break; + + case WID_CURRENT_TX_RATE: + *pu16WID_Value = pstrWFIDrv->strCfgValues.curr_tx_rate; + break; + + default: + break; + } + + WILC_SemaphoreRelease(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + + WILC_CATCH(s32Error) + { + } + return s32Error; + +} + +/*****************************************************************************/ +/* Notification Functions */ +/*****************************************************************************/ +/** + * @brief notifies host with join and leave requests + * @details This function prepares an Information frame having the + * information about a joining/leaving station. + * @param[in,out] handle to the wifi driver, + * @param[in] 6 byte Sta Adress + * Join or leave flag: + * Join = 1, + * Leave =0 + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +void host_int_send_join_leave_info_to_host + (WILC_Uint16 assocId, WILC_Uint8 *stationAddr, WILC_Bool joining) +{ +} +/** + * @brief notifies host with stations found in scan + * @details sends the beacon/probe response from scan + * @param[in,out] handle to the wifi driver, + * @param[in] Sta Address, + * Frame length, + * Rssi of the Station found + * @return Error code indicating success/failure + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ + +void GetPeriodicRSSI(void *pvArg) +{ + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)pvArg; + if (pstrWFIDrv == NULL) { + PRINT_ER("Driver handler is NULL\n"); + return; + } + + if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) { + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrHostIFmsg strHostIFmsg; + + /* prepare the Get RSSI Message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_RSSI; + strHostIFmsg.drvHandler = pstrWFIDrv; + + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + PRINT_ER("Failed to send get host channel param's message queue "); + return; + } + } + WILC_TimerStart(&(g_hPeriodicRSSI), 5000, (void *)pstrWFIDrv, NULL); +} + + +void host_int_send_network_info_to_host + (WILC_Uint8 *macStartAddress, WILC_Uint16 u16RxFrameLen, WILC_Sint8 s8Rssi) +{ +} +/** + * @brief host_int_init + * @details host interface initialization function + * @param[in,out] handle to the wifi driver, + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ +static WILC_Uint32 u32Intialized; +static WILC_Uint32 msgQ_created; +static WILC_Uint32 clients_count; + +WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv; + tstrWILC_SemaphoreAttrs strSemaphoreAttrs; + + + /*if(u32Intialized == 1) + * { + * PRINT_D(HOSTINF_DBG,"Host interface is previously initialized\n"); + * *phWFIDrv = (WILC_WFIDrvHandle)gWFiDrvHandle; //Will be adjusted later for P2P + * return 0; + * } */ + PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1); + + gbScanWhileConnected = WILC_FALSE; + + WILC_SemaphoreFillDefault(&strSemaphoreAttrs); + + + strSemaphoreAttrs.u32InitCount = 0; + WILC_SemaphoreCreate(&hWaitResponse, &strSemaphoreAttrs); + + + + /*Allocate host interface private structure*/ + pstrWFIDrv = (tstrWILC_WFIDrv *)WILC_MALLOC(sizeof(tstrWILC_WFIDrv)); + if (pstrWFIDrv == WILC_NULL) { + /* WILC_ERRORREPORT(s32Error,WILC_NO_MEM); */ + s32Error = WILC_NO_MEM; + PRINT_ER("Failed to allocate memory\n"); + goto _fail_timer_2; + } + WILC_memset(pstrWFIDrv, 0, sizeof(tstrWILC_WFIDrv)); + /*return driver handle to user*/ + *phWFIDrv = (WILC_WFIDrvHandle)pstrWFIDrv; + /*save into globl handle*/ + + #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP + + g_obtainingIP = WILC_FALSE; + #endif + + PRINT_D(HOSTINF_DBG, "Global handle pointer value=%x\n", (WILC_Uint32)pstrWFIDrv); + /* /////////////////////////////////////// */ + if (clients_count == 0) { + strSemaphoreAttrs.u32InitCount = 0; + WILC_SemaphoreCreate(&hSemHostIFthrdEnd, &strSemaphoreAttrs); + + strSemaphoreAttrs.u32InitCount = 0; + WILC_SemaphoreCreate(&hSemDeinitDrvHandle, &strSemaphoreAttrs); + + /*BugID_5348*/ + strSemaphoreAttrs.u32InitCount = 1; + WILC_SemaphoreCreate(&hSemHostIntDeinit, &strSemaphoreAttrs); + } + + strSemaphoreAttrs.u32InitCount = 0; + WILC_SemaphoreCreate(&(pstrWFIDrv->hSemTestKeyBlock), &strSemaphoreAttrs); + strSemaphoreAttrs.u32InitCount = 0; + WILC_SemaphoreCreate(&(pstrWFIDrv->hSemTestDisconnectBlock), &strSemaphoreAttrs); + strSemaphoreAttrs.u32InitCount = 0; + WILC_SemaphoreCreate(&(pstrWFIDrv->hSemGetRSSI), &strSemaphoreAttrs); + strSemaphoreAttrs.u32InitCount = 0; + WILC_SemaphoreCreate(&(pstrWFIDrv->hSemGetLINKSPEED), &strSemaphoreAttrs); + strSemaphoreAttrs.u32InitCount = 0; + WILC_SemaphoreCreate(&(pstrWFIDrv->hSemGetCHNL), &strSemaphoreAttrs); + strSemaphoreAttrs.u32InitCount = 0; + WILC_SemaphoreCreate(&(pstrWFIDrv->hSemInactiveTime), &strSemaphoreAttrs); + + /* /////////////////////////////////////// */ + + + + PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count); + + if (clients_count == 0) { + + s32Error = WILC_MsgQueueCreate(&gMsgQHostIF, WILC_NULL); + + + if (s32Error < 0) { + PRINT_ER("Failed to creat MQ\n"); + goto _fail_; + } + msgQ_created = 1; + s32Error = WILC_ThreadCreate(&HostIFthreadHandler, hostIFthread, WILC_NULL, WILC_NULL); + if (s32Error < 0) { + PRINT_ER("Failed to creat Thread\n"); + goto _fail_mq_; + } + s32Error = WILC_TimerCreate(&(g_hPeriodicRSSI), GetPeriodicRSSI, WILC_NULL); + if (s32Error < 0) { + PRINT_ER("Failed to creat Timer\n"); + goto _fail_timer_1; + } + WILC_TimerStart(&(g_hPeriodicRSSI), 5000, (void *)pstrWFIDrv, NULL); + + } + + + s32Error = WILC_TimerCreate(&(pstrWFIDrv->hScanTimer), TimerCB_Scan, WILC_NULL); + if (s32Error < 0) { + PRINT_ER("Failed to creat Timer\n"); + goto _fail_thread_; + } + + s32Error = WILC_TimerCreate(&(pstrWFIDrv->hConnectTimer), TimerCB_Connect, WILC_NULL); + if (s32Error < 0) { + PRINT_ER("Failed to creat Timer\n"); + goto _fail_timer_1; + } + + + #ifdef WILC_P2P + /*Remain on channel timer*/ + s32Error = WILC_TimerCreate(&(pstrWFIDrv->hRemainOnChannel), ListenTimerCB, WILC_NULL); + if (s32Error < 0) { + PRINT_ER("Failed to creat Remain-on-channel Timer\n"); + goto _fail_timer_3; + } + #endif + + WILC_SemaphoreCreate(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + WILC_SemaphoreAcquire(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + + + +#ifdef SIMULATION + TransportInit(); +#endif + + pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE; + /* gWFiDrvHandle->bPendingConnRequest = WILC_FALSE; */ + + /*Initialize CFG WIDS Defualt Values*/ + + pstrWFIDrv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF; + pstrWFIDrv->strCfgValues.scan_source = DEFAULT_SCAN; + pstrWFIDrv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME; + pstrWFIDrv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME; + pstrWFIDrv->strCfgValues.curr_tx_rate = AUTORATE; + + + #ifdef WILC_P2P + + pstrWFIDrv->u64P2p_MgmtTimeout = 0; + + #endif + + PRINT_INFO(HOSTINF_DBG, "Initialization values, Site survey value: %d\n Scan source: %d\n Active scan time: %d\n Passive scan time: %d\nCurrent tx Rate = %d\n", + + pstrWFIDrv->strCfgValues.site_survey_enabled, pstrWFIDrv->strCfgValues.scan_source, + pstrWFIDrv->strCfgValues.active_scan_time, pstrWFIDrv->strCfgValues.passive_scan_time, + pstrWFIDrv->strCfgValues.curr_tx_rate); + + + WILC_SemaphoreRelease(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + + /*TODO Code to setup simulation to be removed later*/ + /*Intialize configurator module*/ + s32Error = CoreConfiguratorInit(); + if (s32Error < 0) { + PRINT_ER("Failed to initialize core configurator\n"); + goto _fail_mem_; + } + +#ifdef SIMULATION + /*Initialize Simulaor*/ + CoreConfigSimulatorInit(); +#endif + + u32Intialized = 1; + clients_count++; /* increase number of created entities */ + + return s32Error; + + +_fail_mem_: + if (pstrWFIDrv != WILC_NULL) + WILC_FREE(pstrWFIDrv); +#ifdef WILC_P2P +_fail_timer_3: + WILC_TimerDestroy(&(pstrWFIDrv->hRemainOnChannel), WILC_NULL); +#endif +_fail_timer_2: + WILC_SemaphoreRelease(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + WILC_TimerDestroy(&(pstrWFIDrv->hConnectTimer), WILC_NULL); +_fail_timer_1: + WILC_TimerDestroy(&(pstrWFIDrv->hScanTimer), WILC_NULL); +_fail_thread_: + WILC_ThreadDestroy(&HostIFthreadHandler, WILC_NULL); +_fail_mq_: + WILC_MsgQueueDestroy(&gMsgQHostIF, WILC_NULL); +_fail_: + return s32Error; + + +} +/** + * @brief host_int_deinit + * @details host interface initialization function + * @param[in,out] handle to the wifi driver, + * @note + * @author zsalah + * @date 8 March 2012 + * @version 1.0 + */ + +WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrHostIFmsg strHostIFmsg; + + + /*obtain driver handle*/ + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + /*if(u32Intialized == 0) + * { + * PRINT_ER("Host Interface is not initialized\n"); + * return 0; + * }*/ + + /*BugID_5348*/ + + if (pstrWFIDrv == NULL) { + PRINT_ER("pstrWFIDrv = NULL\n"); + return 0; + } + + WILC_SemaphoreAcquire(&hSemHostIntDeinit, NULL); + + terminated_handle = pstrWFIDrv; + PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count); + + /*BugID_5348*/ + /*Destroy all timers before acquiring hSemDeinitDrvHandle*/ + /*to guarantee handling all messages befor proceeding*/ + if (WILC_TimerDestroy(&(pstrWFIDrv->hScanTimer), WILC_NULL)) { + PRINT_D(HOSTINF_DBG, ">> Scan timer is active \n"); + /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */ + } + + if (WILC_TimerDestroy(&(pstrWFIDrv->hConnectTimer), WILC_NULL)) { + PRINT_D(HOSTINF_DBG, ">> Connect timer is active \n"); + /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */ + } + + + if (WILC_TimerDestroy(&(g_hPeriodicRSSI), WILC_NULL)) { + PRINT_D(HOSTINF_DBG, ">> Connect timer is active \n"); + /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */ + } + + #ifdef WILC_P2P + /*Destroy Remain-onchannel Timer*/ + WILC_TimerDestroy(&(pstrWFIDrv->hRemainOnChannel), WILC_NULL); + #endif + + host_int_set_wfi_drv_handler((WILC_Uint32)WILC_NULL); + WILC_SemaphoreAcquire(&hSemDeinitDrvHandle, NULL); + + + /*Calling the CFG80211 scan done function with the abort flag set to true*/ + if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) { + pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, WILC_NULL, + pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL); + + pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = WILC_NULL; + } + /*deinit configurator and simulator*/ +#ifdef SIMULATION + CoreConfigSimulatorDeInit(); +#endif + CoreConfiguratorDeInit(); +#ifdef SIMULATION + TransportDeInit(); +#endif + + pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE; + + gbScanWhileConnected = WILC_FALSE; + + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + if (clients_count == 1) { + if (WILC_TimerDestroy(&g_hPeriodicRSSI, WILC_NULL)) { + PRINT_D(HOSTINF_DBG, ">> Connect timer is active \n"); + /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */ + } + strHostIFmsg.u16MsgId = HOST_IF_MSG_EXIT; + strHostIFmsg.drvHandler = hWFIDrv; + + + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error != WILC_SUCCESS) { + PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error); + } + + WILC_SemaphoreAcquire(&hSemHostIFthrdEnd, NULL); + + + + WILC_MsgQueueDestroy(&gMsgQHostIF, WILC_NULL); + msgQ_created = 0; + + + WILC_SemaphoreDestroy(&hSemHostIFthrdEnd, NULL); + WILC_SemaphoreDestroy(&hSemDeinitDrvHandle, NULL); + + } + + WILC_SemaphoreDestroy(&(pstrWFIDrv->hSemTestKeyBlock), NULL); + WILC_SemaphoreDestroy(&(pstrWFIDrv->hSemTestDisconnectBlock), NULL); + WILC_SemaphoreDestroy(&(pstrWFIDrv->hSemGetRSSI), NULL); + WILC_SemaphoreDestroy(&(pstrWFIDrv->hSemGetLINKSPEED), NULL); + WILC_SemaphoreDestroy(&(pstrWFIDrv->hSemGetCHNL), NULL); + WILC_SemaphoreDestroy(&(pstrWFIDrv->hSemInactiveTime), NULL); + WILC_SemaphoreDestroy(&hWaitResponse, NULL); + + WILC_SemaphoreAcquire(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + WILC_SemaphoreDestroy(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + + /*Setting the gloabl driver handler with NULL*/ + u32Intialized = 0; + /* gWFiDrvHandle = NULL; */ + if (pstrWFIDrv != WILC_NULL) { + WILC_FREE(pstrWFIDrv); + /* pstrWFIDrv=WILC_NULL; */ + + } + + clients_count--; /* Decrease number of created entities */ + terminated_handle = WILC_NULL; + WILC_SemaphoreRelease(&hSemHostIntDeinit, NULL); + return s32Error; +} + + +/** + * @brief NetworkInfoReceived + * @details function to to be called when network info packet is received + * @param[in] pu8Buffer the received packet + * @param[in] u32Length length of the received packet + * @return none + * @note + * @author + * @date 1 Mar 2012 + * @version 1.0 + */ +void NetworkInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrHostIFmsg strHostIFmsg; + WILC_Uint32 drvHandler; + tstrWILC_WFIDrv *pstrWFIDrv = WILC_NULL; + + drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24)); + pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + + + + + if (pstrWFIDrv == WILC_NULL || pstrWFIDrv == terminated_handle) { + PRINT_ER("NetworkInfo received but driver not init[%x]\n", (WILC_Uint32)pstrWFIDrv); + return; + } + + /* prepare the Asynchronous Network Info message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_NTWRK_INFO; + strHostIFmsg.drvHandler = pstrWFIDrv; + + strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.u32Length = u32Length; + strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer = (WILC_Uint8 *)WILC_MALLOC(u32Length); /* will be deallocated by the receiving thread */ + WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer, + pu8Buffer, u32Length); + + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error); + } + + + return; +} + +/** + * @brief GnrlAsyncInfoReceived + * @details function to be called when general Asynchronous info packet is received + * @param[in] pu8Buffer the received packet + * @param[in] u32Length length of the received packet + * @return none + * @note + * @author + * @date 15 Mar 2012 + * @version 1.0 + */ +void GnrlAsyncInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrHostIFmsg strHostIFmsg; + WILC_Uint32 drvHandler; + tstrWILC_WFIDrv *pstrWFIDrv = WILC_NULL; + + /*BugID_5348*/ + WILC_SemaphoreAcquire(&hSemHostIntDeinit, NULL); + + drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24)); + pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + PRINT_D(HOSTINF_DBG, "General asynchronous info packet received \n"); + + + if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) { + PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n"); + /*BugID_5348*/ + WILC_SemaphoreRelease(&hSemHostIntDeinit, NULL); + return; + } + + if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == WILC_NULL) { + /* received mac status is not needed when there is no current Connect Request */ + PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n"); + /*BugID_5348*/ + WILC_SemaphoreRelease(&hSemHostIntDeinit, NULL); + return; + } + + /* prepare the General Asynchronous Info message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + + strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO; + strHostIFmsg.drvHandler = pstrWFIDrv; + + + strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.u32Length = u32Length; + strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer = (WILC_Uint8 *)WILC_MALLOC(u32Length); /* will be deallocated by the receiving thread */ + WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer, + pu8Buffer, u32Length); + + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error); + } + + /*BugID_5348*/ + WILC_SemaphoreRelease(&hSemHostIntDeinit, NULL); + return; +} + +/** + * @brief host_int_ScanCompleteReceived + * @details Setting scan complete received notifcation in message queue + * @param[in] WILC_Uint8* pu8Buffer, WILC_Uint32 u32Length + * @return Error code. + * @author + * @date + * @version 1.0 + */ +void host_int_ScanCompleteReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrHostIFmsg strHostIFmsg; + WILC_Uint32 drvHandler; + tstrWILC_WFIDrv *pstrWFIDrv = WILC_NULL; + drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24)); + pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; + + + PRINT_D(GENERIC_DBG, "Scan notification received %x\n", (WILC_Uint32)pstrWFIDrv); + + if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) { + return; + } + + /*if there is an ongoing scan request*/ + if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) { + /* prepare theScan Done message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_SCAN_COMPLETE; + strHostIFmsg.drvHandler = pstrWFIDrv; + + + /* will be deallocated by the receiving thread */ + /*no need to send message body*/ + + /*strHostIFmsg.uniHostIFmsgBody.strScanComplete.u32Length = u32Length; + * strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer = (WILC_Uint8*)WILC_MALLOC(u32Length); + * WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer, + * pu8Buffer, u32Length); */ + + /* send the message */ + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error); + } + } + + + return; + +} + +#ifdef WILC_P2P +/** + * @brief host_int_remain_on_channel + * @details + * @param[in] Handle to wifi driver + * Duration to remain on channel + * Channel to remain on + * Pointer to fn to be called on receive frames in listen state + * Pointer to remain-on-channel expired fn + * Priv + * @return Error code. + * @author + * @date + * @version 1.0 + */ +WILC_Sint32 host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32SessionID, WILC_Uint32 u32duration, WILC_Uint16 chan, tWILCpfRemainOnChanExpired RemainOnChanExpired, tWILCpfRemainOnChanReady RemainOnChanReady, void *pvUserArg) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + /* prepare the remainonchan Message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + /* prepare the WiphyParams Message */ + strHostIFmsg.u16MsgId = HOST_IF_MSG_REMAIN_ON_CHAN; + strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u16Channel = chan; + strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pRemainOnChanExpired = RemainOnChanExpired; + strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pRemainOnChanReady = RemainOnChanReady; + strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pVoid = pvUserArg; + strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32duration = u32duration; + strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID; + strHostIFmsg.drvHandler = hWFIDrv; + + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + WILC_ERRORREPORT(s32Error, s32Error); + } + WILC_CATCH(s32Error) + { + + } + + return s32Error; +} + +/** + * @brief host_int_ListenStateExpired + * @details + * @param[in] Handle to wifi driver + * Duration to remain on channel + * Channel to remain on + * Pointer to fn to be called on receive frames in listen state + * Pointer to remain-on-channel expired fn + * Priv + * @return Error code. + * @author + * @date + * @version 1.0 + */ +WILC_Sint32 host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32SessionID) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + /*Stopping remain-on-channel timer*/ + WILC_TimerStop(&(pstrWFIDrv->hRemainOnChannel), WILC_NULL); + + /* prepare the timer fire Message */ + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + strHostIFmsg.u16MsgId = HOST_IF_MSG_LISTEN_TIMER_FIRED; + strHostIFmsg.drvHandler = hWFIDrv; + strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID; + + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + WILC_ERRORREPORT(s32Error, s32Error); + } + WILC_CATCH(s32Error) + { + + } + return s32Error; +} + +/** + * @brief host_int_frame_register + * @details + * @param[in] Handle to wifi driver + * @return Error code. + * @author + * @date + * @version 1.0*/ +WILC_Sint32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16FrameType, WILC_Bool bReg) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + /* prepare the WiphyParams Message */ + strHostIFmsg.u16MsgId = HOST_IF_MSG_REGISTER_FRAME; + switch (u16FrameType) { + case ACTION: + PRINT_D(HOSTINF_DBG, "ACTION\n"); + strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u8Regid = ACTION_FRM_IDX; + break; + + case PROBE_REQ: + PRINT_D(HOSTINF_DBG, "PROBE REQ\n"); + strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u8Regid = PROBE_REQ_IDX; + break; + + default: + PRINT_D(HOSTINF_DBG, "Not valid frame type\n"); + break; + } + strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u16FrameType = u16FrameType; + strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.bReg = bReg; + strHostIFmsg.drvHandler = hWFIDrv; + + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + WILC_ERRORREPORT(s32Error, s32Error); + } + WILC_CATCH(s32Error) + { + + } + + return s32Error; + + +} +#endif + +#ifdef WILC_AP_EXTERNAL_MLME +/** + * @brief host_int_add_beacon + * @details Setting add beacon params in message queue + * @param[in] WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32Interval, + * WILC_Uint32 u32DTIMPeriod,WILC_Uint32 u32HeadLen, WILC_Uint8* pu8Head, + * WILC_Uint32 u32TailLen, WILC_Uint8* pu8Tail + * @return Error code. + * @author + * @date + * @version 1.0 + */ +WILC_Sint32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32Interval, + WILC_Uint32 u32DTIMPeriod, + WILC_Uint32 u32HeadLen, WILC_Uint8 *pu8Head, + WILC_Uint32 u32TailLen, WILC_Uint8 *pu8Tail) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + tstrHostIFSetBeacon *pstrSetBeaconParam = &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon; + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n"); + + + /* prepare the WiphyParams Message */ + strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_BEACON; + strHostIFmsg.drvHandler = hWFIDrv; + pstrSetBeaconParam->u32Interval = u32Interval; + pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod; + pstrSetBeaconParam->u32HeadLen = u32HeadLen; + pstrSetBeaconParam->pu8Head = (WILC_Uint8 *)WILC_MALLOC(u32HeadLen); + if (pstrSetBeaconParam->pu8Head == NULL) { + WILC_ERRORREPORT(s32Error, WILC_NO_MEM); + } + WILC_memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen); + pstrSetBeaconParam->u32TailLen = u32TailLen; + + /* Bug 4599 : if tail length = 0 skip allocating & copying */ + if (u32TailLen > 0) { + pstrSetBeaconParam->pu8Tail = (WILC_Uint8 *)WILC_MALLOC(u32TailLen); + if (pstrSetBeaconParam->pu8Tail == NULL) { + WILC_ERRORREPORT(s32Error, WILC_NO_MEM); + } + WILC_memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen); + } else { + pstrSetBeaconParam->pu8Tail = NULL; + } + + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + WILC_ERRORREPORT(s32Error, s32Error); + } + + WILC_CATCH(s32Error) + { + if (pstrSetBeaconParam->pu8Head != NULL) { + WILC_FREE(pstrSetBeaconParam->pu8Head); + } + + if (pstrSetBeaconParam->pu8Tail != NULL) { + WILC_FREE(pstrSetBeaconParam->pu8Tail); + } + } + + return s32Error; + +} + + +/** + * @brief host_int_del_beacon + * @details Setting add beacon params in message queue + * @param[in] WILC_WFIDrvHandle hWFIDrv + * @return Error code. + * @author + * @date + * @version 1.0 + */ +WILC_Sint32 host_int_del_beacon(WILC_WFIDrvHandle hWFIDrv) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + /* prepare the WiphyParams Message */ + strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_BEACON; + strHostIFmsg.drvHandler = hWFIDrv; + PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n"); + + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + WILC_ERRORCHECK(s32Error); + + WILC_CATCH(s32Error) + { + } + return s32Error; +} + + +/** + * @brief host_int_add_station + * @details Setting add station params in message queue + * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams + * @return Error code. + * @author + * @date + * @version 1.0 + */ +WILC_Sint32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrStaParams) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam; + + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n"); + + + /* prepare the WiphyParams Message */ + strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_STATION; + strHostIFmsg.drvHandler = hWFIDrv; + + WILC_memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam)); + if (pstrAddStationMsg->u8NumRates > 0) { + pstrAddStationMsg->pu8Rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates); + WILC_NULLCHECK(s32Error, pstrAddStationMsg->pu8Rates); + + WILC_memcpy(pstrAddStationMsg->pu8Rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates); + } + + + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + WILC_ERRORREPORT(s32Error, s32Error); + } + + WILC_CATCH(s32Error) + { + } + return s32Error; +} + +/** + * @brief host_int_del_station + * @details Setting delete station params in message queue + * @param[in] WILC_WFIDrvHandle hWFIDrv, WILC_Uint8* pu8MacAddr + * @return Error code. + * @author + * @date + * @version 1.0 + */ +WILC_Sint32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8MacAddr) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + tstrHostIFDelSta *pstrDelStationMsg = &strHostIFmsg.uniHostIFmsgBody.strDelStaParam; + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n"); + + + + /* prepare the WiphyParams Message */ + strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_STATION; + strHostIFmsg.drvHandler = hWFIDrv; + + /*BugID_4795: Handling situation of deleting all stations*/ + if (pu8MacAddr == WILC_NULL) + WILC_memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN); + else + WILC_memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN); + + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + WILC_ERRORREPORT(s32Error, s32Error); + } + + WILC_CATCH(s32Error) + { + } + return s32Error; +} +/** + * @brief host_int_del_allstation + * @details Setting del station params in message queue + * @param[in] WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 pu8MacAddr[][ETH_ALEN]s + * @return Error code. + * @author + * @date + * @version 1.0 + */ +WILC_Sint32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 pu8MacAddr[][ETH_ALEN]) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + tstrHostIFDelAllSta *pstrDelAllStationMsg = &strHostIFmsg.uniHostIFmsgBody.strHostIFDelAllSta; + WILC_Uint8 au8Zero_Buff[ETH_ALEN] = {0}; + WILC_Uint32 i; + WILC_Uint8 u8AssocNumb = 0; + + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n"); + + /* prepare the WiphyParams Message */ + strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_ALL_STA; + strHostIFmsg.drvHandler = hWFIDrv; + + /* Handling situation of deauthenticing all associated stations*/ + for (i = 0; i < MAX_NUM_STA; i++) { + if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) { + WILC_memcpy(pstrDelAllStationMsg->au8Sta_DelAllSta[i], pu8MacAddr[i], ETH_ALEN); + PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n", pstrDelAllStationMsg->au8Sta_DelAllSta[i][0], pstrDelAllStationMsg->au8Sta_DelAllSta[i][1], pstrDelAllStationMsg->au8Sta_DelAllSta[i][2], pstrDelAllStationMsg->au8Sta_DelAllSta[i][3], pstrDelAllStationMsg->au8Sta_DelAllSta[i][4], + pstrDelAllStationMsg->au8Sta_DelAllSta[i][5]); + u8AssocNumb++; + } + } + if (!u8AssocNumb) { + PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n"); + return s32Error; + } + + pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb; + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + + + if (s32Error) { + WILC_ERRORREPORT(s32Error, s32Error); + + } + WILC_CATCH(s32Error) + { + + } + WILC_SemaphoreAcquire(&hWaitResponse, NULL); + + return s32Error; + +} + +/** + * @brief host_int_edit_station + * @details Setting edit station params in message queue + * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams + * @return Error code. + * @author + * @date + * @version 1.0 + */ +WILC_Sint32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrStaParams) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam; + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n"); + + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + + /* prepare the WiphyParams Message */ + strHostIFmsg.u16MsgId = HOST_IF_MSG_EDIT_STATION; + strHostIFmsg.drvHandler = hWFIDrv; + + WILC_memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam)); + if (pstrAddStationMsg->u8NumRates > 0) { + pstrAddStationMsg->pu8Rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates); + WILC_memcpy(pstrAddStationMsg->pu8Rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates); + WILC_NULLCHECK(s32Error, pstrAddStationMsg->pu8Rates); + } + + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + WILC_ERRORREPORT(s32Error, s32Error); + } + WILC_CATCH(s32Error) + { + } + return s32Error; +} +#endif /*WILC_AP_EXTERNAL_MLME*/ +uint32_t wilc_get_chipid(uint8_t); + +WILC_Sint32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, WILC_Uint32 u32Timeout) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + tstrHostIfPowerMgmtParam *pstrPowerMgmtParam = &strHostIFmsg.uniHostIFmsgBody.strPowerMgmtparam; + + PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d << \n\n", bIsEnabled); + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n"); + + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + + /* prepare the WiphyParams Message */ + strHostIFmsg.u16MsgId = HOST_IF_MSG_POWER_MGMT; + strHostIFmsg.drvHandler = hWFIDrv; + + pstrPowerMgmtParam->bIsEnabled = bIsEnabled; + pstrPowerMgmtParam->u32Timeout = u32Timeout; + + + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + WILC_ERRORREPORT(s32Error, s32Error); + } + WILC_CATCH(s32Error) + { + } + return s32Error; +} + +WILC_Sint32 host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, WILC_Uint32 u32count) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + tstrHostIFSetMulti *pstrMulticastFilterParam = &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMulti; + + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n"); + + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + + /* prepare the WiphyParams Message */ + strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_MULTICAST_FILTER; + strHostIFmsg.drvHandler = hWFIDrv; + + pstrMulticastFilterParam->bIsEnabled = bIsEnabled; + pstrMulticastFilterParam->u32count = u32count; + + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + WILC_ERRORREPORT(s32Error, s32Error); + } + WILC_CATCH(s32Error) + { + } + return s32Error; +} + + + +/*Bug4218: Parsing Join Param*/ +#ifdef WILC_PARSE_SCAN_IN_HOST + +/*Bug4218: Parsing Join Param*/ +/** + * @brief host_int_ParseJoinBssParam + * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry + * @param[in] tstrNetworkInfo* ptstrNetworkInfo + * @return + * @author zsalah + * @date + * @version 1.0**/ +static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo) +{ + tstrJoinBssParam *pNewJoinBssParam = NULL; + WILC_Uint8 *pu8IEs; + WILC_Uint16 u16IEsLen; + WILC_Uint16 index = 0; + WILC_Uint8 suppRatesNo = 0; + WILC_Uint8 extSuppRatesNo; + WILC_Uint16 jumpOffset; + WILC_Uint8 pcipherCount; + WILC_Uint8 authCount; + WILC_Uint8 pcipherTotalCount = 0; + WILC_Uint8 authTotalCount = 0; + WILC_Uint8 i, j; + + pu8IEs = ptstrNetworkInfo->pu8IEs; + u16IEsLen = ptstrNetworkInfo->u16IEsLen; + + pNewJoinBssParam = WILC_MALLOC(sizeof(tstrJoinBssParam)); + if (pNewJoinBssParam != NULL) { + WILC_memset(pNewJoinBssParam, 0, sizeof(tstrJoinBssParam)); + pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod; + pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod; + pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo; + WILC_memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6); + /*for(i=0; i<6;i++) + * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/ + WILC_memcpy((WILC_Uint8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1); + pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen; + WILC_memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3); + WILC_memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3); + /*for(i=0; issidLen;i++) + * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/ + + /* parse supported rates: */ + while (index < u16IEsLen) { + /* supportedRates IE */ + if (pu8IEs[index] == SUPP_RATES_IE) { + /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */ + suppRatesNo = pu8IEs[index + 1]; + pNewJoinBssParam->supp_rates[0] = suppRatesNo; + index += 2; /* skipping ID and length bytes; */ + + for (i = 0; i < suppRatesNo; i++) { + pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i]; + /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */ + } + index += suppRatesNo; + continue; + } + /* Ext SupportedRates IE */ + else if (pu8IEs[index] == EXT_SUPP_RATES_IE) { + /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */ + /* checking if no of ext. supp and supp rates < max limit */ + extSuppRatesNo = pu8IEs[index + 1]; + if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo)) + pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED; + else + pNewJoinBssParam->supp_rates[0] += extSuppRatesNo; + index += 2; + /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */ + for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) { + pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i]; + /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */ + } + index += extSuppRatesNo; + continue; + } + /* HT Cap. IE */ + else if (pu8IEs[index] == HT_CAPABILITY_IE) { + /* if IE found set the flag */ + pNewJoinBssParam->ht_capable = BTRUE; + index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */ + /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */ + continue; + } else if ((pu8IEs[index] == WMM_IE) && /* WMM Element ID */ + (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) && + (pu8IEs[index + 4] == 0xF2) && /* OUI */ + (pu8IEs[index + 5] == 0x02) && /* OUI Type */ + ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && /* OUI Sub Type */ + (pu8IEs[index + 7] == 0x01)) { + /* Presence of WMM Info/Param element indicates WMM capability */ + pNewJoinBssParam->wmm_cap = BTRUE; + + /* Check if Bit 7 is set indicating U-APSD capability */ + if (pu8IEs[index + 8] & (1 << 7)) { + pNewJoinBssParam->uapsd_cap = BTRUE; + } + index += pu8IEs[index + 1] + 2; + continue; + } + #ifdef WILC_P2P + else if ((pu8IEs[index] == P2P_IE) && /* P2P Element ID */ + (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) && + (pu8IEs[index + 4] == 0x9a) && /* OUI */ + (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type */ + WILC_Uint16 u16P2P_count; + pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf; + pNewJoinBssParam->u8NoaEnbaled = 1; + pNewJoinBssParam->u8Index = pu8IEs[index + 9]; + + /* Check if Bit 7 is set indicating Opss capability */ + if (pu8IEs[index + 10] & (1 << 7)) { + pNewJoinBssParam->u8OppEnable = 1; + pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10]; + } else + pNewJoinBssParam->u8OppEnable = 0; + /* HOSTINF_DBG */ + PRINT_D(GENERIC_DBG, "P2P Dump \n"); + for (i = 0; i < pu8IEs[index + 7]; i++) + PRINT_D(GENERIC_DBG, " %x \n", pu8IEs[index + 9 + i]); + + pNewJoinBssParam->u8Count = pu8IEs[index + 11]; + u16P2P_count = index + 12; + + WILC_memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4); + u16P2P_count += 4; + + WILC_memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4); + u16P2P_count += 4; + + WILC_memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4); + + index += pu8IEs[index + 1] + 2; + continue; + + } + #endif + else if ((pu8IEs[index] == RSN_IE) || + ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) && + (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) && + (pu8IEs[index + 5] == 0x01))) { + WILC_Uint16 rsnIndex = index; + /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]); + * for(i=0; imode_802_11i = 2; + /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */ + } else { /* check if rsn was previously parsed */ + if (pNewJoinBssParam->mode_802_11i == 0) + pNewJoinBssParam->mode_802_11i = 1; + /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */ + rsnIndex += 4; + } + rsnIndex += 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */ + pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex]; + rsnIndex++; + /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x \n",pNewJoinBssParam->rsn_grp_policy); */ + /* initialize policies with invalid values */ + + jumpOffset = pu8IEs[rsnIndex] * 4; /* total no.of bytes of pcipher field (count*4) */ + + /*parsing pairwise cipher*/ + + /* saving 3 pcipher max. */ + pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex]; + rsnIndex += 2; /* jump 2 bytes of pcipher count */ + + /* PRINT_D(HOSTINF_DBG,"\npcipher:%d \n",pcipherCount); */ + for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) { + /* each count corresponds to 4 bytes, only last byte is saved */ + pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1]; + /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */ + } + pcipherTotalCount += pcipherCount; + rsnIndex += jumpOffset; + + jumpOffset = pu8IEs[rsnIndex] * 4; + + /*parsing AKM suite (auth_policy)*/ + /* saving 3 auth policies max. */ + authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex]; + rsnIndex += 2; /* jump 2 bytes of pcipher count */ + + for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) { + /* each count corresponds to 4 bytes, only last byte is saved */ + pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1]; + } + authTotalCount += authCount; + rsnIndex += jumpOffset; + /*pasring rsn cap. only if rsn IE*/ + if (pu8IEs[index] == RSN_IE) { + pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex]; + pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1]; + rsnIndex += 2; + } + pNewJoinBssParam->rsn_found = 1; + index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */ + continue; + } else + index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */ + + } + + + } + + return (void *)pNewJoinBssParam; + +} + +void host_int_freeJoinParams(void *pJoinParams) +{ + if ((tstrJoinBssParam *)pJoinParams != NULL) + WILC_FREE((tstrJoinBssParam *)pJoinParams); + else + PRINT_ER("Unable to FREE null pointer\n"); +} +#endif /*WILC_PARSE_SCAN_IN_HOST*/ + + +/** + * @brief host_int_addBASession + * @details Open a block Ack session with the given parameters + * @param[in] tstrNetworkInfo* ptstrNetworkInfo + * @return + * @author anoureldin + * @date + * @version 1.0**/ + +static int host_int_addBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID, short int BufferSize, + short int SessionTimeout, void *drvHandler) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo; + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + /* prepare the WiphyParams Message */ + strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_BA_SESSION; + + memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN); + pBASessionInfo->u8Ted = TID; + pBASessionInfo->u16BufferSize = BufferSize; + pBASessionInfo->u16SessionTimeout = SessionTimeout; + strHostIFmsg.drvHandler = hWFIDrv; + + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + WILC_ERRORREPORT(s32Error, s32Error); + } + WILC_CATCH(s32Error) + { + + } + + return s32Error; +} + + +WILC_Sint32 host_int_delBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo; + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + /* prepare the WiphyParams Message */ + strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_BA_SESSION; + + memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN); + pBASessionInfo->u8Ted = TID; + strHostIFmsg.drvHandler = hWFIDrv; + + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + WILC_ERRORREPORT(s32Error, s32Error); + } + WILC_CATCH(s32Error) + { + + } + + /*BugID_5222*/ + WILC_SemaphoreAcquire(&hWaitResponse, NULL); + + return s32Error; +} + +WILC_Sint32 host_int_del_All_Rx_BASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo; + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + /* prepare the WiphyParams Message */ + strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS; + + memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN); + pBASessionInfo->u8Ted = TID; + strHostIFmsg.drvHandler = hWFIDrv; + + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + WILC_ERRORREPORT(s32Error, s32Error); + } + WILC_CATCH(s32Error) + { + + } + + /*BugID_5222*/ + WILC_SemaphoreAcquire(&hWaitResponse, NULL); + + return s32Error; +} + +/** + * @brief host_int_setup_ipaddress + * @details setup IP in firmware + * @param[in] Handle to wifi driver + * @return Error code. + * @author Abdelrahman Sobhy + * @date + * @version 1.0*/ +WILC_Sint32 host_int_setup_ipaddress(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *u16ipadd, WILC_Uint8 idx) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + + /* TODO: Enable This feature on softap firmware */ + return 0; + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + /* prepare the WiphyParams Message */ + strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_IPADDRESS; + + strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr = u16ipadd; + strHostIFmsg.drvHandler = hWFIDrv; + strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx = idx; + + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + WILC_ERRORREPORT(s32Error, s32Error); + } + WILC_CATCH(s32Error) + { + + } + + return s32Error; + + +} + +/** + * @brief host_int_get_ipaddress + * @details Get IP from firmware + * @param[in] Handle to wifi driver + * @return Error code. + * @author Abdelrahman Sobhy + * @date + * @version 1.0*/ +WILC_Sint32 host_int_get_ipaddress(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *u16ipadd, WILC_Uint8 idx) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; + tstrHostIFmsg strHostIFmsg; + + if (pstrWFIDrv == WILC_NULL) { + WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); + } + + WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); + + /* prepare the WiphyParams Message */ + strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_IPADDRESS; + + strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr = u16ipadd; + strHostIFmsg.drvHandler=hWFIDrv; + strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx= idx; + + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + if (s32Error) { + WILC_ERRORREPORT(s32Error, s32Error); + } + WILC_CATCH(s32Error) + { + + } + + return s32Error; + + +} + diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h new file mode 100644 index 000000000000..f2a348506a8b --- /dev/null +++ b/drivers/staging/wilc1000/host_interface.h @@ -0,0 +1,1344 @@ +/*! + * @file host_interface.h + * @brief File containg host interface APIs + * @author zsalah + * @sa host_interface.c + * @date 8 March 2012 + * @version 1.0 + */ + +#ifndef HOST_INT_H +#define HOST_INT_H + +#include "coreconfigurator.h" +#include "coreconfigsimulator.h" +/*****************************************************************************/ +/* Macros */ +/*****************************************************************************/ +#if 0 +#define WID_BSS_TYPE 0x0000 +#define WID_CURRENT_TX_RATE 0x0001 +#define WID_CURRENT_CHANNEL 0x0002 +#define WID_PREAMBLE 0x0003 +#define WID_STATUS 0x0005 +#define WID_SCAN_TYPE 0x0007 +#define WID_KEY_ID 0x0009 +#define WID_DTIM_PERIOD 0x0010 +#define WID_POWER_MANAGEMENT 0x000B +#define WID_AUTH_TYPE 0x000D +#define WID_SITE_SURVEY 0x000E +#define WID_DTIM_PERIOD 0x0010 +#define WID_DISCONNECT 0x0016 +#define WID_SHORT_SLOT_ALLOWED 0x001A +#define WID_START_SCAN_REQ 0x001E +#define WID_RSSI 0x001F +#define WID_JOIN_REQ 0x0020 +#define WID_11N_TXOP_PROT_DISABLE 0x00B0 +#define WID_RTS_THRESHOLD 0x1000 +#define WID_FRAG_THRESHOLD 0x1001 +#define WID_SHORT_RETRY_LIMIT 0x1002 +#define WID_LONG_RETRY_LIMIT 0x1003 +#define WID_BEACON_INTERVAL 0x1006 +#define WID_ACTIVE_SCAN_TIME 0x100C +#define WID_PASSIVE_SCAN_TIME 0x100D +#define WID_SITE_SURVEY_SCAN_TIME 0x100E +#define WID_AUTH_TIMEOUT 0x1010 +#define WID_11I_PSK 0x3008 +#define WID_SITE_SURVEY_RESULTS 0x3012 +#define WID_ADD_PTK 0x301B +#define WID_ADD_RX_GTK 0x301C +#define WID_ADD_TX_GTK 0x301D +#define WID_ADD_WEP_KEY 0x3019 +#define WID_REMOVE_WEP_KEY 0x301A +#define WID_REMOVE_KEY 0x301E +#define WID_ASSOC_REQ_INFO 0x301F +#define WID_ASSOC_RES_INFO 0x3020 +#define WID_PMKID_INFO 0x3082 +#define WID_SCAN_CHANNEL_LIST 0x4084 +#define WID_11I_MODE 0x000C +#endif +#define FAIL 0x0000 +#define SUCCESS 0x0001 + +#define IP_ALEN 4 + +#define BIT2 ((WILC_Uint32)(1 << 2)) +#define BIT1 ((WILC_Uint32)(1 << 1)) +#define BIT0 ((WILC_Uint32)(1 << 0)) + +#define AP_MODE 0x01 +#define STATION_MODE 0x02 +#define GO_MODE 0x03 +#define CLIENT_MODE 0x04 + + +#define MAX_NUM_STA 9 +#define ACTIVE_SCAN_TIME 10 +#define PASSIVE_SCAN_TIME 1200 +#define MIN_SCAN_TIME 10 +#define MAX_SCAN_TIME 1200 +#define DEFAULT_SCAN 0 +#define USER_SCAN BIT0 +#define OBSS_PERIODIC_SCAN BIT1 +#define OBSS_ONETIME_SCAN BIT2 +#define GTK_RX_KEY_BUFF_LEN 24 +#define ADDKEY 0x1 +#define REMOVEKEY 0x2 +#define DEFAULTKEY 0x4 +#define ADDKEY_AP 0x8 +#define MAX_NUM_SCANNED_NETWORKS 100 /* 30 // rachel */ +#define MAX_NUM_SCANNED_NETWORKS_SHADOW 130 +#define MAX_NUM_PROBED_SSID 10 /*One more than the number of scanned ssids*/ +#define CHANNEL_SCAN_TIME 250 /* 250 */ + +#define TX_MIC_KEY_LEN 8 +#define RX_MIC_KEY_LEN 8 +#define PTK_KEY_LEN 16 + +#define TX_MIC_KEY_MSG_LEN 26 +#define RX_MIC_KEY_MSG_LEN 48 +#define PTK_KEY_MSG_LEN 39 + +#define PMKSA_KEY_LEN 22 +#define ETH_ALEN 6 +#define PMKID_LEN 16 +#define WILC_MAX_NUM_PMKIDS 16 +#define WILC_SUPP_MCS_SET_SIZE 16 +#define WILC_ADD_STA_LENGTH 40 /* Not including the rates field cause it has variable length*/ +#define SCAN_EVENT_DONE_ABORTED +/*****************************************************************************/ +/* Data Types */ +/*****************************************************************************/ +/* typedef unsigned char uint8; */ +/* typedef signed char int8; */ +/* typedef unsigned short uint16; */ +/* typedef unsigned long uint32; */ +/* typedef uint32 Bool; */ + +#if 0 +typedef enum {WID_CHAR = 0, + WID_SHORT = 1, + WID_INT = 2, + WID_STR = 3, + WID_ADR = 4, + WID_BIN = 5, + WID_IP = 6, + WID_UNDEF = 7} WID_TYPE_T; +#endif +typedef struct { + WILC_Uint16 cfg_wid; + WID_TYPE_T cfg_type; + WILC_Sint8 *pu8Para; +} cfg_param_t; + +typedef struct _tstrStatistics { + WILC_Uint8 u8LinkSpeed; + WILC_Sint8 s8RSSI; + WILC_Uint32 u32TxCount; + WILC_Uint32 u32RxCount; + WILC_Uint32 u32TxFailureCount; + +} tstrStatistics; + + +typedef enum { + HOST_IF_IDLE = 0, + HOST_IF_SCANNING = 1, + HOST_IF_CONNECTING = 2, + HOST_IF_WAITING_CONN_RESP = 3, + HOST_IF_CONNECTED = 4, + HOST_IF_P2P_LISTEN = 5, + HOST_IF_FORCE_32BIT = 0xFFFFFFFF +} tenuHostIFstate; + +typedef struct _tstrHostIFpmkid { + WILC_Uint8 bssid[ETH_ALEN]; + WILC_Uint8 pmkid[PMKID_LEN]; +} tstrHostIFpmkid; + +typedef struct _tstrHostIFpmkidAttr { + WILC_Uint8 numpmkid; + tstrHostIFpmkid pmkidlist[WILC_MAX_NUM_PMKIDS]; +} tstrHostIFpmkidAttr; +#if 0 +/* Scan type parameter for scan request */ +typedef enum { + PASSIVE_SCAN = 0, + ACTIVE_SCAN = 1, + NUM_SCANTYPE +} tenuScanType; + +typedef enum {SITE_SURVEY_1CH = 0, + SITE_SURVEY_ALL_CH = 1, + SITE_SURVEY_OFF = 2} SITE_SURVEY_T; +#endif +typedef enum { + AUTORATE = 0, + MBPS_1 = 1, + MBPS_2 = 2, + MBPS_5_5 = 5, + MBPS_11 = 11, + MBPS_6 = 6, + MBPS_9 = 9, + MBPS_12 = 12, + MBPS_18 = 18, + MBPS_24 = 24, + MBPS_36 = 36, + MBPS_48 = 48, + MBPS_54 = 54 +} CURRENT_TX_RATE_T; + +typedef struct { + WILC_Uint32 u32SetCfgFlag; + WILC_Uint8 ht_enable; + WILC_Uint8 bss_type; + WILC_Uint8 auth_type; + WILC_Uint16 auth_timeout; + WILC_Uint8 power_mgmt_mode; + WILC_Uint16 short_retry_limit; + WILC_Uint16 long_retry_limit; + WILC_Uint16 frag_threshold; + WILC_Uint16 rts_threshold; + WILC_Uint16 preamble_type; + WILC_Uint8 short_slot_allowed; + WILC_Uint8 txop_prot_disabled; + WILC_Uint16 beacon_interval; + WILC_Uint16 dtim_period; + SITE_SURVEY_T site_survey_enabled; + WILC_Uint16 site_survey_scan_time; + WILC_Uint8 scan_source; + WILC_Uint16 active_scan_time; + WILC_Uint16 passive_scan_time; + CURRENT_TX_RATE_T curr_tx_rate; + +} tstrCfgParamVal; + +typedef enum { + RETRY_SHORT = 1 << 0, + RETRY_LONG = 1 << 1, + FRAG_THRESHOLD = 1 << 2, + RTS_THRESHOLD = 1 << 3, + BSS_TYPE = 1 << 4, + AUTH_TYPE = 1 << 5, + AUTHEN_TIMEOUT = 1 << 6, + POWER_MANAGEMENT = 1 << 7, + PREAMBLE = 1 << 8, + SHORT_SLOT_ALLOWED = 1 << 9, + TXOP_PROT_DISABLE = 1 << 10, + BEACON_INTERVAL = 1 << 11, + DTIM_PERIOD = 1 << 12, + SITE_SURVEY = 1 << 13, + SITE_SURVEY_SCAN_TIME = 1 << 14, + ACTIVE_SCANTIME = 1 << 15, + PASSIVE_SCANTIME = 1 << 16, + CURRENT_TX_RATE = 1 << 17, + HT_ENABLE = 1 << 18, +} tenuCfgParam; + +typedef struct { + WILC_Uint8 au8bssid[6]; + WILC_Sint8 s8rssi; +} tstrFoundNetworkInfo; + +typedef enum {SCAN_EVENT_NETWORK_FOUND = 0, + SCAN_EVENT_DONE = 1, + SCAN_EVENT_ABORTED = 2, + SCAN_EVENT_FORCE_32BIT = 0xFFFFFFFF} tenuScanEvent; + +typedef enum { + CONN_DISCONN_EVENT_CONN_RESP = 0, + CONN_DISCONN_EVENT_DISCONN_NOTIF = 1, + CONN_DISCONN_EVENT_FORCE_32BIT = 0xFFFFFFFF +} tenuConnDisconnEvent; + +typedef enum { + WEP, + WPARxGtk, + /* WPATxGtk, */ + WPAPtk, + PMKSA, +} tenuKeyType; + + +/*Scan callBack function definition*/ +typedef void (*tWILCpfScanResult)(tenuScanEvent, tstrNetworkInfo *, void *, void *); + +/*Connect callBack function definition*/ +typedef void (*tWILCpfConnectResult)(tenuConnDisconnEvent, + tstrConnectInfo *, + WILC_Uint8, + tstrDisconnectNotifInfo *, + void *); + +#ifdef WILC_P2P +typedef void (*tWILCpfRemainOnChanExpired)(void *, WILC_Uint32); /*Remain on channel expiration callback function*/ +typedef void (*tWILCpfRemainOnChanReady)(void *); /*Remain on channel callback function*/ +#endif + +/* typedef WILC_Uint32 WILC_WFIDrvHandle; */ +typedef struct { + WILC_Sint32 s32Dummy; +} *WILC_WFIDrvHandle; + +/*! + * @struct tstrRcvdNetworkInfo + * @brief Structure to hold Received Asynchronous Network info + * @details + * @todo + * @sa + * @author Mostafa Abu Bakr + * @date 25 March 2012 + * @version 1.0 + */ +typedef struct _tstrRcvdNetworkInfo { + WILC_Uint8 *pu8Buffer; + WILC_Uint32 u32Length; +} tstrRcvdNetworkInfo; + +/*BugID_4156*/ +typedef struct _tstrHiddenNetworkInfo { + WILC_Uint8 *pu8ssid; + WILC_Uint8 u8ssidlen; + +} tstrHiddenNetworkInfo; + +typedef struct _tstrHiddenNetwork { + /* MAX_SSID_LEN */ + tstrHiddenNetworkInfo *pstrHiddenNetworkInfo; + WILC_Uint8 u8ssidnum; + +} tstrHiddenNetwork; + +typedef struct { + /* Scan user call back function */ + tWILCpfScanResult pfUserScanResult; + + /* User specific parameter to be delivered through the Scan User Callback function */ + void *u32UserScanPvoid; + + WILC_Uint32 u32RcvdChCount; + tstrFoundNetworkInfo astrFoundNetworkInfo[MAX_NUM_SCANNED_NETWORKS]; +} tstrWILC_UsrScanReq; + +typedef struct { + WILC_Uint8 *pu8bssid; + WILC_Uint8 *pu8ssid; + WILC_Uint8 u8security; + AUTHTYPE_T tenuAuth_type; + size_t ssidLen; + WILC_Uint8 *pu8ConnReqIEs; + size_t ConnReqIEsLen; + /* Connect user call back function */ + tWILCpfConnectResult pfUserConnectResult; + WILC_Bool IsHTCapable; + /* User specific parameter to be delivered through the Connect User Callback function */ + void *u32UserConnectPvoid; +} tstrWILC_UsrConnReq; + +typedef struct { + WILC_Uint32 u32Address; +} tstrHostIfSetDrvHandler; + +typedef struct { + WILC_Uint32 u32Mode; +} tstrHostIfSetOperationMode; + +/*BugID_5077*/ +typedef struct { + WILC_Uint8 u8MacAddress[ETH_ALEN]; +} tstrHostIfSetMacAddress; + +/*BugID_5213*/ +typedef struct { + WILC_Uint8 *u8MacAddress; +} tstrHostIfGetMacAddress; + +/*BugID_5222*/ +typedef struct { + WILC_Uint8 au8Bssid[ETH_ALEN]; + WILC_Uint8 u8Ted; + WILC_Uint16 u16BufferSize; + WILC_Uint16 u16SessionTimeout; +} tstrHostIfBASessionInfo; + +#ifdef WILC_P2P +typedef struct { + WILC_Uint16 u16Channel; + WILC_Uint32 u32duration; + tWILCpfRemainOnChanExpired pRemainOnChanExpired; + tWILCpfRemainOnChanReady pRemainOnChanReady; + void *pVoid; + WILC_Uint32 u32ListenSessionID; +} tstrHostIfRemainOnChan; + +typedef struct { + + WILC_Bool bReg; + WILC_Uint16 u16FrameType; + WILC_Uint8 u8Regid; + + +} tstrHostIfRegisterFrame; + + +#define ACTION 0xD0 +#define PROBE_REQ 0x40 +#define PROBE_RESP 0x50 +#define ACTION_FRM_IDX 0 +#define PROBE_REQ_IDX 1 + + +enum p2p_listen_state { + P2P_IDLE, + P2P_LISTEN, + P2P_GRP_FORMATION +}; + +#endif +typedef struct { + /* Scan user structure */ + tstrWILC_UsrScanReq strWILC_UsrScanReq; + + /* Connect User structure */ + tstrWILC_UsrConnReq strWILC_UsrConnReq; + + #ifdef WILC_P2P + /*Remain on channel struvture*/ + tstrHostIfRemainOnChan strHostIfRemainOnChan; + WILC_Uint8 u8RemainOnChan_pendingreq; + WILC_Uint64 u64P2p_MgmtTimeout; + WILC_Uint8 u8P2PConnect; + #endif + + tenuHostIFstate enuHostIFstate; + + /* WILC_Bool bPendingConnRequest; */ + + #ifndef CONNECT_DIRECT + WILC_Uint32 u32SurveyResultsCount; + wid_site_survey_reslts_s astrSurveyResults[MAX_NUM_SCANNED_NETWORKS]; + #endif + + WILC_Uint8 au8AssociatedBSSID[ETH_ALEN]; + tstrCfgParamVal strCfgValues; +/* semaphores */ + WILC_SemaphoreHandle gtOsCfgValuesSem; + WILC_SemaphoreHandle hSemTestKeyBlock; + + WILC_SemaphoreHandle hSemTestDisconnectBlock; + WILC_SemaphoreHandle hSemGetRSSI; + WILC_SemaphoreHandle hSemGetLINKSPEED; + WILC_SemaphoreHandle hSemGetCHNL; + WILC_SemaphoreHandle hSemInactiveTime; +/* timer handlers */ + WILC_TimerHandle hScanTimer; + WILC_TimerHandle hConnectTimer; + #ifdef WILC_P2P + WILC_TimerHandle hRemainOnChannel; + #endif + + WILC_Bool IFC_UP; +} tstrWILC_WFIDrv; + +/*! + * @enum tenuWILC_StaFlag + * @brief Used to decode the station flag set and mask in tstrWILC_AddStaParam + * @details + * @todo + * @sa tstrWILC_AddStaParam, enum nl80211_sta_flags + * @author Enumeraion's creator + * @date 12 July 2012 + * @version 1.0 Description + */ + +typedef enum { + WILC_STA_FLAG_INVALID = 0, + WILC_STA_FLAG_AUTHORIZED, /*!< station is authorized (802.1X)*/ + WILC_STA_FLAG_SHORT_PREAMBLE, /*!< station is capable of receiving frames with short barker preamble*/ + WILC_STA_FLAG_WME, /*!< station is WME/QoS capable*/ + WILC_STA_FLAG_MFP, /*!< station uses management frame protection*/ + WILC_STA_FLAG_AUTHENTICATED /*!< station is authenticated*/ +} tenuWILC_StaFlag; + +typedef struct { + WILC_Uint8 au8BSSID[ETH_ALEN]; + WILC_Uint16 u16AssocID; + WILC_Uint8 u8NumRates; + WILC_Uint8 *pu8Rates; + WILC_Bool bIsHTSupported; + WILC_Uint16 u16HTCapInfo; + WILC_Uint8 u8AmpduParams; + WILC_Uint8 au8SuppMCsSet[16]; + WILC_Uint16 u16HTExtParams; + WILC_Uint32 u32TxBeamformingCap; + WILC_Uint8 u8ASELCap; + WILC_Uint16 u16FlagsMask; /**/ + WILC_Uint16 u16FlagsSet; /*> 22) & 0x1ff) + +void WILC_WFI_monitor_rx(uint8_t *buff, uint32_t size) +{ + uint32_t header, pkt_offset; + struct sk_buff *skb = NULL; + struct wilc_wfi_radiotap_hdr *hdr; + struct wilc_wfi_radiotap_cb_hdr *cb_hdr; + + PRINT_INFO(HOSTAPD_DBG, "In monitor interface receive function\n"); + + /* struct WILC_WFI_priv *priv = netdev_priv(dev); */ + + /* priv = wiphy_priv(priv->dev->ieee80211_ptr->wiphy); */ + + /* Bug 4601 */ + if (wilc_wfi_mon == NULL) + return; + + if (!netif_running(wilc_wfi_mon)) { + PRINT_INFO(HOSTAPD_DBG, "Monitor interface already RUNNING\n"); + return; + } + + /* Get WILC header */ + memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET); + + /* The packet offset field conain info about what type of managment frame */ + /* we are dealing with and ack status */ + pkt_offset = GET_PKT_OFFSET(header); + + if (pkt_offset & IS_MANAGMEMENT_CALLBACK) { + + /* hostapd callback mgmt frame */ + + skb = dev_alloc_skb(size + sizeof(struct wilc_wfi_radiotap_cb_hdr)); + if (skb == NULL) { + PRINT_INFO(HOSTAPD_DBG, "Monitor if : No memory to allocate skb"); + return; + } + + memcpy(skb_put(skb, size), buff, size); + + cb_hdr = (struct wilc_wfi_radiotap_cb_hdr *) skb_push(skb, sizeof(*cb_hdr)); + memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr)); + + cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */ + + cb_hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_cb_hdr)); + + cb_hdr->hdr.it_present = cpu_to_le32( + (1 << IEEE80211_RADIOTAP_RATE) | + (1 << IEEE80211_RADIOTAP_TX_FLAGS)); + + cb_hdr->rate = 5; /* txrate->bitrate / 5; */ + + if (pkt_offset & IS_MGMT_STATUS_SUCCES) { + /* success */ + cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_RTS; + } else { + cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_FAIL; + } + + } else { + + skb = dev_alloc_skb(size + sizeof(struct wilc_wfi_radiotap_hdr)); + + if (skb == NULL) { + PRINT_INFO(HOSTAPD_DBG, "Monitor if : No memory to allocate skb"); + return; + } + + /* skb = skb_copy_expand(tx_skb, sizeof(*hdr), 0, GFP_ATOMIC); */ + /* if (skb == NULL) */ + /* return; */ + + memcpy(skb_put(skb, size), buff, size); + hdr = (struct wilc_wfi_radiotap_hdr *) skb_push(skb, sizeof(*hdr)); + memset(hdr, 0, sizeof(struct wilc_wfi_radiotap_hdr)); + hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */ + /* hdr->hdr.it_pad = 0; */ + hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_hdr)); + PRINT_INFO(HOSTAPD_DBG, "Radiotap len %d\n", hdr->hdr.it_len); + hdr->hdr.it_present = cpu_to_le32 + (1 << IEEE80211_RADIOTAP_RATE); /* | */ + /* (1 << IEEE80211_RADIOTAP_CHANNEL)); */ + PRINT_INFO(HOSTAPD_DBG, "Presentflags %d\n", hdr->hdr.it_present); + hdr->rate = 5; /* txrate->bitrate / 5; */ + + } + +/* if(INFO || if(skb->data[9] == 0x00 || skb->data[9] == 0xb0)) + * { + * for(i=0;ilen;i++) + * PRINT_INFO(HOSTAPD_DBG,"Mon RxData[%d] = %02x\n",i,skb->data[i]); + * }*/ + + + skb->dev = wilc_wfi_mon; + skb_set_mac_header(skb, 0); + skb->ip_summed = CHECKSUM_UNNECESSARY; + skb->pkt_type = PACKET_OTHERHOST; + skb->protocol = htons(ETH_P_802_2); + memset(skb->cb, 0, sizeof(skb->cb)); + + netif_rx(skb); + + +} + +struct tx_complete_mon_data { + int size; + void *buff; +}; + +static void mgmt_tx_complete(void *priv, int status) +{ + + /* struct sk_buff *skb2; */ + /* struct wilc_wfi_radiotap_cb_hdr *cb_hdr; */ + + struct tx_complete_mon_data *pv_data = (struct tx_complete_mon_data *)priv; + WILC_Uint8 *buf = pv_data->buff; + + + + if (status == 1) { + if (INFO || buf[0] == 0x10 || buf[0] == 0xb0) + PRINT_INFO(HOSTAPD_DBG, "Packet sent successfully - Size = %d - Address = %p.\n", pv_data->size, pv_data->buff); + } else { + PRINT_INFO(HOSTAPD_DBG, "Couldn't send packet - Size = %d - Address = %p.\n", pv_data->size, pv_data->buff); + } + + +/* //(skb->data[9] == 0x00 || skb->data[9] == 0xb0 || skb->data[9] == 0x40 || skb->data[9] == 0xd0 ) + * { + * skb2 = dev_alloc_skb(pv_data->size+sizeof(struct wilc_wfi_radiotap_cb_hdr)); + * + * memcpy(skb_put(skb2,pv_data->size),pv_data->buff, pv_data->size); + * + * cb_hdr = (struct wilc_wfi_radiotap_cb_hdr *) skb_push(skb2, sizeof(*cb_hdr)); + * memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr)); + * + * cb_hdr->hdr.it_version = 0;//PKTHDR_RADIOTAP_VERSION; + * + * cb_hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_cb_hdr)); + * + * cb_hdr->hdr.it_present = cpu_to_le32( + * (1 << IEEE80211_RADIOTAP_RATE) | + * (1 << IEEE80211_RADIOTAP_TX_FLAGS)); + * + * cb_hdr->rate = 5;//txrate->bitrate / 5; + * cb_hdr->tx_flags = 0x0004; + * + * skb2->dev = wilc_wfi_mon; + * skb_set_mac_header(skb2, 0); + * skb2->ip_summed = CHECKSUM_UNNECESSARY; + * skb2->pkt_type = PACKET_OTHERHOST; + * skb2->protocol = htons(ETH_P_802_2); + * memset(skb2->cb, 0, sizeof(skb2->cb)); + * + * netif_rx(skb2); + * }*/ + + /* incase of fully hosting mode, the freeing will be done in response to the cfg packet */ + #ifndef WILC_FULLY_HOSTING_AP + kfree(pv_data->buff); + + kfree(pv_data); + #endif +} +static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len) +{ + linux_wlan_t *nic; + struct tx_complete_mon_data *mgmt_tx = NULL; + + if (dev == NULL) { + PRINT_D(HOSTAPD_DBG, "ERROR: dev == NULL\n"); + return WILC_FAIL; + } + nic = netdev_priv(dev); + + netif_stop_queue(dev); + mgmt_tx = (struct tx_complete_mon_data *)kmalloc(sizeof(struct tx_complete_mon_data), GFP_ATOMIC); + if (mgmt_tx == NULL) { + PRINT_ER("Failed to allocate memory for mgmt_tx structure\n"); + return WILC_FAIL; + } + + #ifdef WILC_FULLY_HOSTING_AP + /* add space for the pointer to tx_complete_mon_data */ + len += sizeof(struct tx_complete_mon_data *); + #endif + + mgmt_tx->buff = (char *)kmalloc(len, GFP_ATOMIC); + if (mgmt_tx->buff == NULL) { + PRINT_ER("Failed to allocate memory for mgmt_tx buff\n"); + return WILC_FAIL; + + } + + mgmt_tx->size = len; + + #ifndef WILC_FULLY_HOSTING_AP + memcpy(mgmt_tx->buff, buf, len); + #else + memcpy(mgmt_tx->buff, buf, len - sizeof(struct tx_complete_mon_data *)); + memcpy((mgmt_tx->buff) + (len - sizeof(struct tx_complete_mon_data *)), &mgmt_tx, sizeof(struct tx_complete_mon_data *)); + + /* filter data frames to handle it's PS */ + if (filter_monitor_data_frames((mgmt_tx->buff), len) == WILC_TRUE) { + return; + } + + #endif /* WILC_FULLY_HOSTING_AP */ + + g_linux_wlan->oup.wlan_add_mgmt_to_tx_que(mgmt_tx, mgmt_tx->buff, mgmt_tx->size, mgmt_tx_complete); + + netif_wake_queue(dev); + return 0; +} + +/** + * @brief WILC_WFI_mon_xmit + * @details + * @param[in] + * @return int : Return 0 on Success + * @author mdaftedar + * @date 12 JUL 2012 + * @version 1.0 + */ +static netdev_tx_t WILC_WFI_mon_xmit(struct sk_buff *skb, + struct net_device *dev) +{ + struct ieee80211_radiotap_header *rtap_hdr; + WILC_Uint32 rtap_len, i, ret = 0; + struct WILC_WFI_mon_priv *mon_priv; + + struct sk_buff *skb2; + struct wilc_wfi_radiotap_cb_hdr *cb_hdr; + + /* Bug 4601 */ + if (wilc_wfi_mon == NULL) + return WILC_FAIL; + + /* if(skb->data[3] == 0x10 || skb->data[3] == 0xb0) */ + + mon_priv = netdev_priv(wilc_wfi_mon); + + if (mon_priv == NULL) { + PRINT_ER("Monitor interface private structure is NULL\n"); + return WILC_FAIL; + } + + rtap_hdr = (struct ieee80211_radiotap_header *)skb->data; + + rtap_len = ieee80211_get_radiotap_len(skb->data); + if (skb->len < rtap_len) { + PRINT_ER("Error in radiotap header\n"); + return -1; + } + /* skip the radiotap header */ + PRINT_INFO(HOSTAPD_DBG, "Radiotap len: %d\n", rtap_len); + + if (INFO) { + for (i = 0; i < rtap_len; i++) + PRINT_INFO(HOSTAPD_DBG, "Radiotap_hdr[%d] %02x\n", i, skb->data[i]); + } + /* Skip the ratio tap header */ + skb_pull(skb, rtap_len); + + if (skb->data[0] == 0xc0) + PRINT_INFO(HOSTAPD_DBG, "%x:%x:%x:%x:%x%x\n", skb->data[4], skb->data[5], skb->data[6], skb->data[7], skb->data[8], skb->data[9]); + + if (skb->data[0] == 0xc0 && (!(memcmp(broadcast, &skb->data[4], 6)))) { + skb2 = dev_alloc_skb(skb->len + sizeof(struct wilc_wfi_radiotap_cb_hdr)); + + memcpy(skb_put(skb2, skb->len), skb->data, skb->len); + + cb_hdr = (struct wilc_wfi_radiotap_cb_hdr *) skb_push(skb2, sizeof(*cb_hdr)); + memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr)); + + cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */ + + cb_hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_cb_hdr)); + + cb_hdr->hdr.it_present = cpu_to_le32( + (1 << IEEE80211_RADIOTAP_RATE) | + (1 << IEEE80211_RADIOTAP_TX_FLAGS)); + + cb_hdr->rate = 5; /* txrate->bitrate / 5; */ + cb_hdr->tx_flags = 0x0004; + + skb2->dev = wilc_wfi_mon; + skb_set_mac_header(skb2, 0); + skb2->ip_summed = CHECKSUM_UNNECESSARY; + skb2->pkt_type = PACKET_OTHERHOST; + skb2->protocol = htons(ETH_P_802_2); + memset(skb2->cb, 0, sizeof(skb2->cb)); + + netif_rx(skb2); + + return 0; + } + skb->dev = mon_priv->real_ndev; + + PRINT_INFO(HOSTAPD_DBG, "Skipping the radiotap header\n"); + + + + /* actual deliver of data is device-specific, and not shown here */ + PRINT_INFO(HOSTAPD_DBG, "SKB netdevice name = %s\n", skb->dev->name); + PRINT_INFO(HOSTAPD_DBG, "MONITOR real dev name = %s\n", mon_priv->real_ndev->name); + + #ifdef SIMULATION + ret = WILC_WFI_Tx(skb, mon_priv->real_ndev); + #elif USE_WIRELESS + /* Identify if Ethernet or MAC header (data or mgmt) */ + memcpy(srcAdd, &skb->data[10], 6); + memcpy(bssid, &skb->data[16], 6); + /* if source address and bssid fields are equal>>Mac header */ + /*send it to mgmt frames handler */ + if (!(memcmp(srcAdd, bssid, 6))) { + mon_mgmt_tx(mon_priv->real_ndev, skb->data, skb->len); + dev_kfree_skb(skb); + } else + ret = mac_xmit(skb, mon_priv->real_ndev); + #endif + + /* return NETDEV_TX_OK; */ + return ret; +} + +static const struct net_device_ops wilc_wfi_netdev_ops = { + .ndo_start_xmit = WILC_WFI_mon_xmit, + +}; + +#ifdef WILC_FULLY_HOSTING_AP +/* + * @brief WILC_mgm_HOSTAPD_ACK + * @details report the status of transmitted mgmt frames to HOSTAPD + * @param[in] priv : pointer to tx_complete_mon_data struct + * bStatus : status of transmission + * @author Abd Al-Rahman Diab + * @date 9 May 2013 + * @version 1.0 + */ +void WILC_mgm_HOSTAPD_ACK(void *priv, WILC_Bool bStatus) +{ + struct sk_buff *skb; + struct wilc_wfi_radiotap_cb_hdr *cb_hdr; + + struct tx_complete_mon_data *pv_data = (struct tx_complete_mon_data *)priv; + WILC_Uint8 *buf = pv_data->buff; + + /* len of the original frame without the added pointer at the tail */ + WILC_Uint16 u16len = (pv_data->size) - sizeof(struct tx_complete_mon_data *); + + + /*if(bStatus == 1){ + * if(INFO || buf[0] == 0x10 || buf[0] == 0xb0) + * PRINT_D(HOSTAPD_DBG,"Packet sent successfully - Size = %d - Address = %p.\n",u16len,pv_data->buff); + * }else{ + * PRINT_D(HOSTAPD_DBG,"Couldn't send packet - Size = %d - Address = %p.\n",u16len,pv_data->buff); + * } + */ + + /* (skb->data[9] == 0x00 || skb->data[9] == 0xb0 || skb->data[9] == 0x40 || skb->data[9] == 0xd0 ) */ + { + skb = dev_alloc_skb(u16len + sizeof(struct wilc_wfi_radiotap_cb_hdr)); + + memcpy(skb_put(skb, u16len), pv_data->buff, u16len); + + cb_hdr = (struct wilc_wfi_radiotap_cb_hdr *) skb_push(skb, sizeof(*cb_hdr)); + memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr)); + + cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */ + + cb_hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_cb_hdr)); + + cb_hdr->hdr.it_present = cpu_to_le32( + (1 << IEEE80211_RADIOTAP_RATE) | + (1 << IEEE80211_RADIOTAP_TX_FLAGS)); + + cb_hdr->rate = 5; /* txrate->bitrate / 5; */ + + + if (WILC_TRUE == bStatus) { + /* success */ + cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_RTS; + } else { + cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_FAIL; + } + + skb->dev = wilc_wfi_mon; + skb_set_mac_header(skb, 0); + skb->ip_summed = CHECKSUM_UNNECESSARY; + skb->pkt_type = PACKET_OTHERHOST; + skb->protocol = htons(ETH_P_802_2); + memset(skb->cb, 0, sizeof(skb->cb)); + + netif_rx(skb); + } + + /* incase of fully hosting mode, the freeing will be done in response to the cfg packet */ + kfree(pv_data->buff); + + kfree(pv_data); + +} +#endif /* WILC_FULLY_HOSTING_AP */ + +/** + * @brief WILC_WFI_mon_setup + * @details + * @param[in] + * @return int : Return 0 on Success + * @author mdaftedar + * @date 12 JUL 2012 + * @version 1.0 + */ +static void WILC_WFI_mon_setup(struct net_device *dev) +{ + + dev->netdev_ops = &wilc_wfi_netdev_ops; + /* dev->destructor = free_netdev; */ + PRINT_INFO(CORECONFIG_DBG, "In Ethernet setup function\n"); + ether_setup(dev); + dev->tx_queue_len = 0; + dev->type = ARPHRD_IEEE80211_RADIOTAP; + memset(dev->dev_addr, 0, ETH_ALEN); + + #ifdef USE_WIRELESS + { + /* u8 * mac_add; */ + unsigned char mac_add[] = {0x00, 0x50, 0xc2, 0x5e, 0x10, 0x8f}; + /* priv = wiphy_priv(priv->dev->ieee80211_ptr->wiphy); */ + /* mac_add = (WILC_Uint8*)WILC_MALLOC(ETH_ALEN); */ + /* status = host_int_get_MacAddress(priv->hWILCWFIDrv,mac_add); */ + /* mac_add[ETH_ALEN-1]+=1; */ + memcpy(dev->dev_addr, mac_add, ETH_ALEN); + } + #else + dev->dev_addr[0] = 0x12; + #endif + +} + +/** + * @brief WILC_WFI_init_mon_interface + * @details + * @param[in] + * @return int : Return 0 on Success + * @author mdaftedar + * @date 12 JUL 2012 + * @version 1.0 + */ +struct net_device *WILC_WFI_init_mon_interface(char *name, struct net_device *real_dev) +{ + + + WILC_Uint32 ret = WILC_SUCCESS; + struct WILC_WFI_mon_priv *priv; + + /*If monitor interface is already initialized, return it*/ + if (wilc_wfi_mon) { + return wilc_wfi_mon; + } +#if 0 + wilc_wfi_mon = alloc_netdev(sizeof(struct WILC_WFI_mon_priv), name, WILC_WFI_mon_setup); + if (wilc_wfi_mon == NULL) { + PRINT_ER("Failed to allocate netdevice\n"); + goto failed; + } + + /* rtnl_lock(); */ + PRINT_INFO(HOSTAPD_DBG, "Monitor interface name %s\n", wilc_wfi_mon->name); + + + ret = dev_alloc_name(wilc_wfi_mon, wilc_wfi_mon->name); + if (ret < 0) + goto failed_mon; + + + priv = netdev_priv(wilc_wfi_mon); + if (priv == NULL) { + PRINT_ER("private structure is NULL\n"); + return WILC_FAIL; + } + + priv->real_ndev = real_dev; + + + ret = register_netdevice(wilc_wfi_mon); + + + if (ret < 0) { + PRINT_ER("Failed to register netdevice\n"); + goto failed_mon; + } + + + return WILC_SUCCESS; + /* rtnl_unlock(); */ + +failed: + return ret; + +failed_mon: + /* rtnl_unlock(); */ + free_netdev(wilc_wfi_mon); + return ret; +#endif + + wilc_wfi_mon = alloc_etherdev(sizeof(struct WILC_WFI_mon_priv)); + if (!wilc_wfi_mon) { + PRINT_ER("failed to allocate memory\n"); + return NULL; + + } + + wilc_wfi_mon->type = ARPHRD_IEEE80211_RADIOTAP; + strncpy(wilc_wfi_mon->name, name, IFNAMSIZ); + wilc_wfi_mon->name[IFNAMSIZ - 1] = 0; + wilc_wfi_mon->netdev_ops = &wilc_wfi_netdev_ops; + + ret = register_netdevice(wilc_wfi_mon); + if (ret) { + PRINT_ER(" register_netdevice failed (%d)\n", ret); + return NULL; + } + priv = netdev_priv(wilc_wfi_mon); + if (priv == NULL) { + PRINT_ER("private structure is NULL\n"); + return NULL; + } + + priv->real_ndev = real_dev; + + return wilc_wfi_mon; +} + +/** + * @brief WILC_WFI_deinit_mon_interface + * @details + * @param[in] + * @return int : Return 0 on Success + * @author mdaftedar + * @date 12 JUL 2012 + * @version 1.0 + */ +int WILC_WFI_deinit_mon_interface() +{ + bool rollback_lock = false; + + if (wilc_wfi_mon != NULL) { + PRINT_D(HOSTAPD_DBG, "In Deinit monitor interface\n"); + PRINT_D(HOSTAPD_DBG, "RTNL is being locked\n"); + if (rtnl_is_locked()) { + rtnl_unlock(); + rollback_lock = true; + } + PRINT_D(HOSTAPD_DBG, "Unregister netdev\n"); + unregister_netdev(wilc_wfi_mon); + /* free_netdev(wilc_wfi_mon); */ + + if (rollback_lock) { + rtnl_lock(); + rollback_lock = false; + } + wilc_wfi_mon = NULL; + } + return WILC_SUCCESS; + +} +#endif /* WILC_AP_EXTERNAL_MLME */ diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c new file mode 100644 index 000000000000..49b238a05a88 --- /dev/null +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -0,0 +1,2953 @@ +#ifndef SIMULATION +#include "wilc_wfi_cfgoperations.h" +#include "linux_wlan_common.h" +#include "wilc_wlan_if.h" +#include "wilc_wlan.h" +#ifdef USE_WIRELESS +#include "wilc_wfi_cfgoperations.h" +#endif + +#include "linux_wlan_common.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP +#include +#endif +#include +#include +#include +#include + +#include +#include + +#ifdef WILC_SDIO +#include "linux_wlan_sdio.h" +#else +#include "linux_wlan_spi.h" +#endif + +#ifdef WILC_FULLY_HOSTING_AP +#include "wilc_host_ap.h" +#endif + +#ifdef STATIC_MACADDRESS /* brandy_0724 [[ */ +#include +#include +struct task_struct *wilc_mac_thread; +unsigned char mac_add[] = {0x00, 0x80, 0xC2, 0x5E, 0xa2, 0xb2}; +#endif /* brandy_0724 ]] */ + +#if defined(CUSTOMER_PLATFORM) +/* + TODO : Write power control functions as customer platform. + */ +#else + + #define _linux_wlan_device_power_on() {} + #define _linux_wlan_device_power_off() {} + + #define _linux_wlan_device_detection() {} + #define _linux_wlan_device_removal() {} +#endif + +#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP +extern WILC_Bool g_obtainingIP; +#endif +extern WILC_Uint16 Set_machw_change_vir_if(WILC_Bool bValue); +extern void resolve_disconnect_aberration(void *drvHandler); +extern WILC_Uint8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN]; +void wilc1000_wlan_deinit(linux_wlan_t *nic); +#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP +extern WILC_TimerHandle hDuringIpTimer; +#endif + +static int linux_wlan_device_power(int on_off) +{ + PRINT_D(INIT_DBG, "linux_wlan_device_power.. (%d)\n", on_off); + + if (on_off) { + _linux_wlan_device_power_on(); + } else { + _linux_wlan_device_power_off(); + } + + return 0; +} + +static int linux_wlan_device_detection(int on_off) +{ + PRINT_D(INIT_DBG, "linux_wlan_device_detection.. (%d)\n", on_off); + +#ifdef WILC_SDIO + if (on_off) { + _linux_wlan_device_detection(); + } else { + _linux_wlan_device_removal(); + } +#endif + + return 0; +} + + +#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP +static int dev_state_ev_handler(struct notifier_block *this, unsigned long event, void *ptr); + +static struct notifier_block g_dev_notifier = { + .notifier_call = dev_state_ev_handler +}; +#endif + +#define wilc_wlan_deinit(nic) { if (&g_linux_wlan->oup != NULL) \ + if (g_linux_wlan->oup.wlan_cleanup != NULL) \ + g_linux_wlan->oup.wlan_cleanup(); } + + +#ifndef STA_FIRMWARE +#define STA_FIRMWARE "wifi_firmware.bin" +#endif + +#ifndef AP_FIRMWARE +#define AP_FIRMWARE "wifi_firmware_ap.bin" +#endif + +#ifndef P2P_CONCURRENCY_FIRMWARE +#define P2P_CONCURRENCY_FIRMWARE "wifi_firmware_p2p_concurrency.bin" +#endif + + + +typedef struct android_wifi_priv_cmd { + char *buf; + int used_len; + int total_len; +} android_wifi_priv_cmd; + + +#define IRQ_WAIT 1 +#define IRQ_NO_WAIT 0 +/* + * to sync between mac_close and module exit. + * don't initialize or de-initialize from init/deinitlocks + * to be initialized from module wilc_netdev_init and + * deinitialized from mdoule_exit + */ +static struct semaphore close_exit_sync; +unsigned int int_rcvdU; +unsigned int int_rcvdB; +unsigned int int_clrd; + +static int wlan_deinit_locks(linux_wlan_t *nic); +static void wlan_deinitialize_threads(linux_wlan_t *nic); +static void linux_wlan_lock(void *vp); +void linux_wlan_unlock(void *vp); +extern void WILC_WFI_monitor_rx(uint8_t *buff, uint32_t size); +extern void WILC_WFI_p2p_rx(struct net_device *dev, uint8_t *buff, uint32_t size); + + +static void *internal_alloc(uint32_t size, uint32_t flag); +static void linux_wlan_tx_complete(void *priv, int status); +void frmw_to_linux(uint8_t *buff, uint32_t size, uint32_t pkt_offset); +static int mac_init_fn(struct net_device *ndev); +int mac_xmit(struct sk_buff *skb, struct net_device *dev); +int mac_open(struct net_device *ndev); +int mac_close(struct net_device *ndev); +static struct net_device_stats *mac_stats(struct net_device *dev); +static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd); +static void wilc_set_multicast_list(struct net_device *dev); + + + +/* + * for now - in frmw_to_linux there should be private data to be passed to it + * and this data should be pointer to net device + */ +linux_wlan_t *g_linux_wlan; +wilc_wlan_oup_t *gpstrWlanOps; +WILC_Bool bEnablePS = WILC_TRUE; + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) +static const struct net_device_ops wilc_netdev_ops = { + .ndo_init = mac_init_fn, + .ndo_open = mac_open, + .ndo_stop = mac_close, + .ndo_start_xmit = mac_xmit, + .ndo_do_ioctl = mac_ioctl, + .ndo_get_stats = mac_stats, + .ndo_set_rx_mode = wilc_set_multicast_list, + +}; +#define wilc_set_netdev_ops(ndev) do { (ndev)->netdev_ops = &wilc_netdev_ops; } while (0) +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) + +static const struct net_device_ops wilc_netdev_ops = { + .ndo_init = mac_init_fn, + .ndo_open = mac_open, + .ndo_stop = mac_close, + .ndo_start_xmit = mac_xmit, + .ndo_do_ioctl = mac_ioctl, + .ndo_get_stats = mac_stats, + .ndo_set_multicast_list = wilc_set_multicast_list, + +}; + +#define wilc_set_netdev_ops(ndev) do { (ndev)->netdev_ops = &wilc_netdev_ops; } while (0) + +#else + +static void wilc_set_netdev_ops(struct net_device *ndev) +{ + + ndev->init = mac_init_fn; + ndev->open = mac_open; + ndev->stop = mac_close; + ndev->hard_start_xmit = mac_xmit; + ndev->do_ioctl = mac_ioctl; + ndev->get_stats = mac_stats; + ndev->set_multicast_list = wilc_set_multicast_list, +} + +#endif +#ifdef DEBUG_MODE + +extern volatile int timeNo; + +#define DEGUG_BUFFER_LENGTH 1000 +volatile int WatchDogdebuggerCounter; +char DebugBuffer[DEGUG_BUFFER_LENGTH + 20] = {0}; +static char *ps8current = DebugBuffer; + + + +void printk_later(const char *format, ...) +{ + va_list args; + va_start (args, format); + ps8current += vsprintf (ps8current, format, args); + va_end (args); + if ((ps8current - DebugBuffer) > DEGUG_BUFFER_LENGTH) { + ps8current = DebugBuffer; + } + +} + + +void dump_logs() +{ + if (DebugBuffer[0]) { + DebugBuffer[DEGUG_BUFFER_LENGTH] = 0; + PRINT_INFO(GENERIC_DBG, "early printed\n"); + PRINT_D(GENERIC_DBG, ps8current + 1); + ps8current[1] = 0; + PRINT_INFO(GENERIC_DBG, "latest printed\n"); + PRINT_D(GENERIC_DBG, DebugBuffer); + DebugBuffer[0] = 0; + ps8current = DebugBuffer; + } +} + +void Reset_WatchDogdebugger() +{ + WatchDogdebuggerCounter = 0; +} + +static int DebuggingThreadTask(void *vp) +{ + while (1) { + while (!WatchDogdebuggerCounter) { + PRINT_D(GENERIC_DBG, "Debug Thread Running %d\n", timeNo); + WatchDogdebuggerCounter = 1; + msleep(10000); + } + dump_logs(); + WatchDogdebuggerCounter = 0; + } +} + + +#endif + + +#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP +static int dev_state_ev_handler(struct notifier_block *this, unsigned long event, void *ptr) +{ + struct in_ifaddr *dev_iface = (struct in_ifaddr *)ptr; + struct WILC_WFI_priv *priv; + tstrWILC_WFIDrv *pstrWFIDrv; + struct net_device *dev; + WILC_Uint8 *pIP_Add_buff; + WILC_Sint32 s32status = WILC_FAIL; + perInterface_wlan_t *nic; + WILC_Uint8 null_ip[4] = {0}; + char wlan_dev_name[5] = "wlan0"; + + if (dev_iface == NULL || dev_iface->ifa_dev == NULL || dev_iface->ifa_dev->dev == NULL) { + PRINT_D(GENERIC_DBG, "dev_iface = NULL\n"); + return NOTIFY_DONE; + } + + if ((memcmp(dev_iface->ifa_label, "wlan0", 5)) && (memcmp(dev_iface->ifa_label, "p2p0", 4))) { + PRINT_D(GENERIC_DBG, "Interface is neither WLAN0 nor P2P0\n"); + return NOTIFY_DONE; + } + + dev = (struct net_device *)dev_iface->ifa_dev->dev; + if (dev->ieee80211_ptr == NULL || dev->ieee80211_ptr->wiphy == NULL) { + PRINT_D(GENERIC_DBG, "No Wireless registerd\n"); + return NOTIFY_DONE; + } + priv = wiphy_priv(dev->ieee80211_ptr->wiphy); + if (priv == NULL) { + PRINT_D(GENERIC_DBG, "No Wireless Priv\n"); + return NOTIFY_DONE; + } + pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv; + nic = netdev_priv(dev); + if (nic == NULL || pstrWFIDrv == NULL) { + PRINT_D(GENERIC_DBG, "No Wireless Priv\n"); + return NOTIFY_DONE; + } + + PRINT_INFO(GENERIC_DBG, "dev_state_ev_handler +++\n"); /* tony */ + + switch (event) { + case NETDEV_UP: + PRINT_D(GENERIC_DBG, "dev_state_ev_handler event=NETDEV_UP %p\n", dev); /* tony */ + + PRINT_INFO(GENERIC_DBG, "\n ============== IP Address Obtained ===============\n\n"); + + + /*If we are in station mode or client mode*/ + if (nic->iftype == STATION_MODE || nic->iftype == CLIENT_MODE) { + pstrWFIDrv->IFC_UP = 1; + g_obtainingIP = WILC_FALSE; + WILC_TimerStop(&hDuringIpTimer, WILC_NULL); + PRINT_D(GENERIC_DBG, "IP obtained , enable scan\n"); + } + + + + if (bEnablePS == WILC_TRUE) + host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 1, 0); + + PRINT_D(GENERIC_DBG, "[%s] Up IP\n", dev_iface->ifa_label); + + pIP_Add_buff = (char *) (&(dev_iface->ifa_address)); + PRINT_D(GENERIC_DBG, "IP add=%d:%d:%d:%d \n", pIP_Add_buff[0], pIP_Add_buff[1], pIP_Add_buff[2], pIP_Add_buff[3]); + s32status = host_int_setup_ipaddress((WILC_WFIDrvHandle)pstrWFIDrv, pIP_Add_buff, nic->u8IfIdx); + + break; + + case NETDEV_DOWN: + PRINT_D(GENERIC_DBG, "dev_state_ev_handler event=NETDEV_DOWN %p\n", dev); /* tony */ + + PRINT_INFO(GENERIC_DBG, "\n ============== IP Address Released ===============\n\n"); + if (nic->iftype == STATION_MODE || nic->iftype == CLIENT_MODE) { + pstrWFIDrv->IFC_UP = 0; + g_obtainingIP = WILC_FALSE; + } + + if (memcmp(dev_iface->ifa_label, wlan_dev_name, 5) == 0) + host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 0, 0); + + resolve_disconnect_aberration(pstrWFIDrv); + + + PRINT_D(GENERIC_DBG, "[%s] Down IP\n", dev_iface->ifa_label); + + pIP_Add_buff = null_ip; + PRINT_D(GENERIC_DBG, "IP add=%d:%d:%d:%d \n", pIP_Add_buff[0], pIP_Add_buff[1], pIP_Add_buff[2], pIP_Add_buff[3]); + + s32status = host_int_setup_ipaddress((WILC_WFIDrvHandle)pstrWFIDrv, pIP_Add_buff, nic->u8IfIdx); + + break; + + default: + PRINT_INFO(GENERIC_DBG, "dev_state_ev_handler event=default\n"); /* tony */ + PRINT_INFO(GENERIC_DBG, "[%s] unknown dev event: %lu\n", dev_iface->ifa_label, event); + + break; + } + + return NOTIFY_DONE; + +} +#endif + +/* + * Interrupt initialization and handling functions + */ + +void linux_wlan_enable_irq(void) +{ + +#if (RX_BH_TYPE != RX_BH_THREADED_IRQ) +#if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO) + PRINT_D(INT_DBG, "Enabling IRQ ...\n"); + enable_irq(g_linux_wlan->dev_irq_num); +#endif +#endif +} + +void linux_wlan_disable_irq(int wait) +{ +#if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO) + if (wait) { + PRINT_D(INT_DBG, "Disabling IRQ ...\n"); + disable_irq(g_linux_wlan->dev_irq_num); + } else { + PRINT_D(INT_DBG, "Disabling IRQ ...\n"); + disable_irq_nosync(g_linux_wlan->dev_irq_num); + } +#endif +} + +#if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO) +static irqreturn_t isr_uh_routine(int irq, void *user_data) +{ + + + int_rcvdU++; +#if (RX_BH_TYPE != RX_BH_THREADED_IRQ) + linux_wlan_disable_irq(IRQ_NO_WAIT); +#endif + PRINT_D(INT_DBG, "Interrupt received UH\n"); + + /*While mac is closing cacncel the handling of any interrupts received*/ + if (g_linux_wlan->close) { + PRINT_ER("Driver is CLOSING: Can't handle UH interrupt\n"); + #if (RX_BH_TYPE == RX_BH_THREADED_IRQ) + return IRQ_HANDLED; + #else + return IRQ_NONE; + #endif + + } +#if (RX_BH_TYPE == RX_BH_WORK_QUEUE) + schedule_work(&g_linux_wlan->rx_work_queue); + return IRQ_HANDLED; +#elif (RX_BH_TYPE == RX_BH_KTHREAD) + linux_wlan_unlock(&g_linux_wlan->rx_sem); + return IRQ_HANDLED; +#elif (RX_BH_TYPE == RX_BH_THREADED_IRQ) + return IRQ_WAKE_THREAD; +#endif + +} +#endif + +#if (RX_BH_TYPE == RX_BH_WORK_QUEUE || RX_BH_TYPE == RX_BH_THREADED_IRQ) + +#if (RX_BH_TYPE == RX_BH_THREADED_IRQ) +irqreturn_t isr_bh_routine(int irq, void *userdata) +{ + linux_wlan_t *nic; + nic = (linux_wlan_t *)userdata; +#else +static void isr_bh_routine(struct work_struct *work) +{ + perInterface_wlan_t *nic; + nic = (perInterface_wlan_t *)container_of(work, linux_wlan_t, rx_work_queue); +#endif + + /*While mac is closing cacncel the handling of any interrupts received*/ + if (g_linux_wlan->close) { + PRINT_ER("Driver is CLOSING: Can't handle BH interrupt\n"); + #if (RX_BH_TYPE == RX_BH_THREADED_IRQ) + return IRQ_HANDLED; + #else + return; + #endif + + + + } + + int_rcvdB++; + PRINT_D(INT_DBG, "Interrupt received BH\n"); + if (g_linux_wlan->oup.wlan_handle_rx_isr != 0) { + g_linux_wlan->oup.wlan_handle_rx_isr(); + } else { + PRINT_ER("wlan_handle_rx_isr() hasn't been initialized\n"); + } + + +#if (RX_BH_TYPE == RX_BH_THREADED_IRQ) + return IRQ_HANDLED; +#endif +} +#elif (RX_BH_TYPE == RX_BH_KTHREAD) +static int isr_bh_routine(void *vp) +{ + linux_wlan_t *nic; + + nic = (linux_wlan_t *)vp; + + while (1) { + linux_wlan_lock(&nic->rx_sem); + if (g_linux_wlan->close) { + + while (!kthread_should_stop()) + schedule(); + + break; + } + int_rcvdB++; + PRINT_D(INT_DBG, "Interrupt received BH\n"); + if (g_linux_wlan->oup.wlan_handle_rx_isr != 0) { + g_linux_wlan->oup.wlan_handle_rx_isr(); + } else { + PRINT_ER("wlan_handle_rx_isr() hasn't been initialized\n"); + } + } + + return 0; +} +#endif + + +#if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO) +static int init_irq(linux_wlan_t *p_nic) +{ + int ret = 0; + linux_wlan_t *nic = p_nic; + + /*initialize GPIO and register IRQ num*/ + /*GPIO request*/ + if ((gpio_request(GPIO_NUM, "WILC_INTR") == 0) && + (gpio_direction_input(GPIO_NUM) == 0)) { +#if defined(CUSTOMER_PLATFORM) +/* + TODO : save the registerd irq number to the private wilc context in kernel. + * + * ex) nic->dev_irq_num = gpio_to_irq(GPIO_NUM); + */ +#elif defined (NM73131_0_BOARD) + nic->dev_irq_num = IRQ_WILC1000; +#elif defined (PANDA_BOARD) + gpio_export(GPIO_NUM, 1); + nic->dev_irq_num = OMAP_GPIO_IRQ(GPIO_NUM); + irq_set_irq_type(nic->dev_irq_num, IRQ_TYPE_LEVEL_LOW); +#else + nic->dev_irq_num = gpio_to_irq(GPIO_NUM); +#endif + } else { + ret = -1; + PRINT_ER("could not obtain gpio for WILC_INTR\n"); + } + + +#if (RX_BH_TYPE == RX_BH_THREADED_IRQ) + if ((ret != -1) && (request_threaded_irq(nic->dev_irq_num, isr_uh_routine, isr_bh_routine, + IRQF_TRIGGER_LOW | IRQF_ONESHOT, /*Without IRQF_ONESHOT the uh will remain kicked in and dont gave a chance to bh*/ + "WILC_IRQ", nic)) < 0) { + +#else + /*Request IRQ*/ + if ((ret != -1) && (request_irq(nic->dev_irq_num, isr_uh_routine, + IRQF_TRIGGER_LOW, "WILC_IRQ", nic) < 0)) { + +#endif + PRINT_ER("Failed to request IRQ for GPIO: %d\n", GPIO_NUM); + ret = -1; + } else { + + PRINT_D(INIT_DBG, "IRQ request succeeded IRQ-NUM= %d on GPIO: %d\n", + nic->dev_irq_num, GPIO_NUM); + } + + return ret; +} +#endif + +static void deinit_irq(linux_wlan_t *nic) +{ +#if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO) + /* Deintialize IRQ */ + if (&nic->dev_irq_num != 0) { + free_irq(nic->dev_irq_num, g_linux_wlan); + + gpio_free(GPIO_NUM); + } +#endif +} + + +/* + * OS functions + */ +static void linux_wlan_msleep(uint32_t msc) +{ + if (msc <= 4000000) { + WILC_Uint32 u32Temp = msc * 1000; +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 35) + usleep_range(u32Temp, u32Temp); +#else + /* This is delay not sleep !!!, has to be changed*/ + msleep(msc); +#endif + } else { + msleep(msc); + } +} + +static void linux_wlan_atomic_msleep(uint32_t msc) +{ + mdelay(msc); +} +static void linux_wlan_dbg(uint8_t *buff) +{ + PRINT_D(INIT_DBG, "%d\n", *buff); +} + +static void *linux_wlan_malloc_atomic(uint32_t sz) +{ + char *pntr = NULL; + pntr = (char *)kmalloc(sz, GFP_ATOMIC); + PRINT_D(MEM_DBG, "Allocating %d bytes at address %p\n", sz, pntr); + return (void *)pntr; + +} +static void *linux_wlan_malloc(uint32_t sz) +{ + char *pntr = NULL; + pntr = (char *)kmalloc(sz, GFP_KERNEL); + PRINT_D(MEM_DBG, "Allocating %d bytes at address %p\n", sz, pntr); + return (void *)pntr; +} + +void linux_wlan_free(void *vp) +{ + if (vp != NULL) { + PRINT_D(MEM_DBG, "Freeing %p\n", vp); + kfree(vp); + } +} + + +static void *internal_alloc(uint32_t size, uint32_t flag) +{ + char *pntr = NULL; + pntr = (char *)kmalloc(size, flag); + PRINT_D(MEM_DBG, "Allocating %d bytes at address %p\n", size, pntr); + return (void *)pntr; +} + + +static void linux_wlan_init_lock(char *lockName, void *plock, int count) +{ + sema_init((struct semaphore *)plock, count); + PRINT_D(LOCK_DBG, "Initializing [%s][%p]\n", lockName, plock); + +} + +static void linux_wlan_deinit_lock(void *plock) +{ + /* mutex_destroy((struct mutex*)plock); */ +} + +static void linux_wlan_lock(void *vp) +{ + PRINT_D(LOCK_DBG, "Locking %p\n", vp); + if (vp != NULL) { + while (down_interruptible((struct semaphore *) vp)) + ; + } else { + PRINT_ER("Failed, mutex is NULL\n"); + } +} + +static int linux_wlan_lock_timeout(void *vp, WILC_Uint32 timeout) +{ + int error = -1; + PRINT_D(LOCK_DBG, "Locking %p\n", vp); + if (vp != NULL) { + error = down_timeout((struct semaphore *)vp, msecs_to_jiffies(timeout)); + } else { + PRINT_ER("Failed, mutex is NULL\n"); + } + return error; +} + +void linux_wlan_unlock(void *vp) +{ + PRINT_D(LOCK_DBG, "Unlocking %p\n", vp); + if (vp != NULL) { + up((struct semaphore *)vp); + } else { + PRINT_ER("Failed, mutex is NULL\n"); + } +} + + +static void linux_wlan_init_mutex(char *lockName, void *plock, int count) +{ + mutex_init((struct mutex *)plock); + PRINT_D(LOCK_DBG, "Initializing mutex [%s][%p]\n", lockName, plock); + +} + +static void linux_wlan_deinit_mutex(void *plock) +{ + mutex_destroy((struct mutex *)plock); +} + +static void linux_wlan_lock_mutex(void *vp) +{ + PRINT_D(LOCK_DBG, "Locking mutex %p\n", vp); + if (vp != NULL) { + /* + * if(mutex_is_locked((struct mutex*)vp)) + * { + * //PRINT_ER("Mutex already locked - %p \n",vp); + * } + */ + mutex_lock((struct mutex *)vp); + + } else { + PRINT_ER("Failed, mutex is NULL\n"); + } +} + +static void linux_wlan_unlock_mutex(void *vp) +{ + PRINT_D(LOCK_DBG, "Unlocking mutex %p\n", vp); + if (vp != NULL) { + + if (mutex_is_locked((struct mutex *)vp)) { + mutex_unlock((struct mutex *)vp); + } else { + /* PRINT_ER("Mutex already unlocked - %p\n",vp); */ + } + + } else { + PRINT_ER("Failed, mutex is NULL\n"); + } +} + + +/*Added by Amr - BugID_4720*/ +static void linux_wlan_init_spin_lock(char *lockName, void *plock, int count) +{ + spin_lock_init((spinlock_t *)plock); + PRINT_D(SPIN_DEBUG, "Initializing mutex [%s][%p]\n", lockName, plock); + +} + +static void linux_wlan_deinit_spin_lock(void *plock) +{ + +} +static void linux_wlan_spin_lock(void *vp, unsigned long *flags) +{ + unsigned long lflags; + PRINT_D(SPIN_DEBUG, "Lock spin %p\n", vp); + if (vp != NULL) { + spin_lock_irqsave((spinlock_t *)vp, lflags); + *flags = lflags; + } else { + PRINT_ER("Failed, spin lock is NULL\n"); + } +} +static void linux_wlan_spin_unlock(void *vp, unsigned long *flags) +{ + unsigned long lflags = *flags; + PRINT_D(SPIN_DEBUG, "Unlock spin %p\n", vp); + if (vp != NULL) { + spin_unlock_irqrestore((spinlock_t *)vp, lflags); + *flags = lflags; + } else { + PRINT_ER("Failed, spin lock is NULL\n"); + } +} + +static void linux_wlan_mac_indicate(int flag) +{ + /*I have to do it that way becuase there is no mean to encapsulate device pointer + * as a parameter + */ + linux_wlan_t *pd = g_linux_wlan; + int status; + + if (flag == WILC_MAC_INDICATE_STATUS) { + pd->oup.wlan_cfg_get_value(WID_STATUS, (unsigned char *)&status, 4); + if (pd->mac_status == WILC_MAC_STATUS_INIT) { + pd->mac_status = status; + linux_wlan_unlock(&pd->sync_event); + } else { + pd->mac_status = status; + } + + if (pd->mac_status == WILC_MAC_STATUS_CONNECT) { /* Connect */ +#if 0 + /** + * get the mac and bssid address + **/ + PRINT_D(RX_DBG, "Calling cfg_get to get MAC_ADDR\n"); + pd->oup.wlan_cfg_get(1, WID_MAC_ADDR, 0); + PRINT_D(RX_DBG, "Calling cfg_get to get BSSID\n"); + pd->oup.wlan_cfg_get(0, WID_BSSID, 1); + + /** + * get the value + **/ + pd->oup.wlan_cfg_get_value(WID_MAC_ADDR, pd->eth_src_address, 6); + pd->oup.wlan_cfg_get_value(WID_BSSID, pd->eth_dst_address, 6); + + PRINT_D(GENERIC_DBG, "Source Address = %s", pd->eth_src_address); + PRINT_D(GENERIC_DBG, "Destiation Address = %s", pd->eth_dst_address); + + /** + * launch ndis + **/ +#endif + } + + } else if (flag == WILC_MAC_INDICATE_SCAN) { + PRINT_D(GENERIC_DBG, "Scanning ...\n"); + + } + +} + +struct net_device *GetIfHandler(uint8_t *pMacHeader) +{ + uint8_t *Bssid, *Bssid1; + int i = 0; + + Bssid = pMacHeader + 10; + Bssid1 = pMacHeader + 4; + + for (i = 0; i < g_linux_wlan->u8NoIfcs; i++) { + if (!memcmp(Bssid1, g_linux_wlan->strInterfaceInfo[i].aBSSID, ETH_ALEN) || + !memcmp(Bssid, g_linux_wlan->strInterfaceInfo[i].aBSSID, ETH_ALEN)) { + return g_linux_wlan->strInterfaceInfo[i].wilc_netdev; + } + } + PRINT_INFO(INIT_DBG, "Invalide handle\n"); + for (i = 0; i < 25; i++) { + PRINT_D(INIT_DBG, "%02x ", pMacHeader[i]); + } + Bssid = pMacHeader + 18; + Bssid1 = pMacHeader + 12; + for (i = 0; i < g_linux_wlan->u8NoIfcs; i++) { + if (!memcmp(Bssid1, g_linux_wlan->strInterfaceInfo[i].aBSSID, ETH_ALEN) || + !memcmp(Bssid, g_linux_wlan->strInterfaceInfo[i].aBSSID, ETH_ALEN)) { + PRINT_D(INIT_DBG, "Ctx [%p]\n", g_linux_wlan->strInterfaceInfo[i].wilc_netdev); + return g_linux_wlan->strInterfaceInfo[i].wilc_netdev; + } + } + PRINT_INFO(INIT_DBG, "\n"); + return NULL; +} + +int linux_wlan_set_bssid(struct net_device *wilc_netdev, uint8_t *pBSSID) +{ + int i = 0; + int ret = -1; + + PRINT_D(INIT_DBG, "set bssid on[%p]\n", wilc_netdev); + for (i = 0; i < g_linux_wlan->u8NoIfcs; i++) { + if (g_linux_wlan->strInterfaceInfo[i].wilc_netdev == wilc_netdev) { + PRINT_D(INIT_DBG, "set bssid [%x][%x][%x]\n", pBSSID[0], pBSSID[1], pBSSID[2]); + memcpy(g_linux_wlan->strInterfaceInfo[i].aBSSID, pBSSID, 6); + ret = 0; + break; + } + } + return ret; +} + +/*BugID_5213*/ +/*Function to get number of connected interfaces*/ +int linux_wlan_get_num_conn_ifcs(void) +{ + uint8_t i = 0; + uint8_t null_bssid[6] = {0}; + uint8_t ret_val = 0; + + for (i = 0; i < g_linux_wlan->u8NoIfcs; i++) { + if (memcmp(g_linux_wlan->strInterfaceInfo[i].aBSSID, null_bssid, 6)) { + ret_val++; + } + } + return ret_val; +} + +static int linux_wlan_rxq_task(void *vp) +{ + + /* inform wilc1000_wlan_init that RXQ task is started. */ + linux_wlan_unlock(&g_linux_wlan->rxq_thread_started); + while (1) { + linux_wlan_lock(&g_linux_wlan->rxq_event); + /* wait_for_completion(&g_linux_wlan->rxq_event); */ + + if (g_linux_wlan->close) { + /*Unlock the mutex in the mac_close function to indicate the exiting of the RX thread */ + linux_wlan_unlock(&g_linux_wlan->rxq_thread_started); + + while (!kthread_should_stop()) + schedule(); + + PRINT_D(RX_DBG, " RX thread stopped\n"); + break; + } + PRINT_D(RX_DBG, "Calling wlan_handle_rx_que()\n"); + + g_linux_wlan->oup.wlan_handle_rx_que(); + } + return 0; +} + +#define USE_TX_BACKOFF_DELAY_IF_NO_BUFFERS + +static int linux_wlan_txq_task(void *vp) +{ + int ret, txq_count; + +#if defined USE_TX_BACKOFF_DELAY_IF_NO_BUFFERS +#define TX_BACKOFF_WEIGHT_INCR_STEP (1) +#define TX_BACKOFF_WEIGHT_DECR_STEP (1) +#define TX_BACKOFF_WEIGHT_MAX (7) +#define TX_BACKOFF_WEIGHT_MIN (0) +#define TX_BACKOFF_WEIGHT_UNIT_MS (10) + int backoff_weight = TX_BACKOFF_WEIGHT_MIN; + signed long timeout; +#endif + + /* inform wilc1000_wlan_init that TXQ task is started. */ + linux_wlan_unlock(&g_linux_wlan->txq_thread_started); + while (1) { + + PRINT_D(TX_DBG, "txq_task Taking a nap :)\n"); + linux_wlan_lock(&g_linux_wlan->txq_event); + /* wait_for_completion(&pd->txq_event); */ + PRINT_D(TX_DBG, "txq_task Who waked me up :$\n"); + + if (g_linux_wlan->close) { + /*Unlock the mutex in the mac_close function to indicate the exiting of the TX thread */ + linux_wlan_unlock(&g_linux_wlan->txq_thread_started); + + while (!kthread_should_stop()) + schedule(); + + PRINT_D(TX_DBG, "TX thread stopped\n"); + break; + } + PRINT_D(TX_DBG, "txq_task handle the sending packet and let me go to sleep.\n"); +#if !defined USE_TX_BACKOFF_DELAY_IF_NO_BUFFERS + g_linux_wlan->oup.wlan_handle_tx_que(); +#else + do { + ret = g_linux_wlan->oup.wlan_handle_tx_que(&txq_count); + if (txq_count < FLOW_CONTROL_LOWER_THRESHOLD /* && netif_queue_stopped(pd->wilc_netdev)*/) { + PRINT_D(TX_DBG, "Waking up queue\n"); + /* netif_wake_queue(pd->wilc_netdev); */ + if (netif_queue_stopped(g_linux_wlan->strInterfaceInfo[0].wilc_netdev)) + netif_wake_queue(g_linux_wlan->strInterfaceInfo[0].wilc_netdev); + if (netif_queue_stopped(g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) + netif_wake_queue(g_linux_wlan->strInterfaceInfo[1].wilc_netdev); + } + + if (ret == WILC_TX_ERR_NO_BUF) { /* failed to allocate buffers in chip. */ + timeout = msecs_to_jiffies(TX_BACKOFF_WEIGHT_UNIT_MS << backoff_weight); + do { + /* Back off from sending packets for some time. */ + /* schedule_timeout will allow RX task to run and free buffers.*/ + /* set_current_state(TASK_UNINTERRUPTIBLE); */ + /* timeout = schedule_timeout(timeout); */ + msleep(TX_BACKOFF_WEIGHT_UNIT_MS << backoff_weight); + } while (/*timeout*/ 0); + backoff_weight += TX_BACKOFF_WEIGHT_INCR_STEP; + if (backoff_weight > TX_BACKOFF_WEIGHT_MAX) { + backoff_weight = TX_BACKOFF_WEIGHT_MAX; + } + } else { + if (backoff_weight > TX_BACKOFF_WEIGHT_MIN) { + backoff_weight -= TX_BACKOFF_WEIGHT_DECR_STEP; + if (backoff_weight < TX_BACKOFF_WEIGHT_MIN) { + backoff_weight = TX_BACKOFF_WEIGHT_MIN; + } + } + } + /*TODO: drop packets after a certain time/number of retry count. */ + } while (ret == WILC_TX_ERR_NO_BUF && !g_linux_wlan->close); /* retry sending packets if no more buffers in chip. */ +#endif + } + return 0; +} + +static void linux_wlan_rx_complete(void) +{ + PRINT_D(RX_DBG, "RX completed\n"); +} + +int linux_wlan_get_firmware(perInterface_wlan_t *p_nic) +{ + + perInterface_wlan_t *nic = p_nic; + int ret = 0; + const struct firmware *wilc_firmware; + char *firmware; + + + if (nic->iftype == AP_MODE) + firmware = AP_FIRMWARE; + else if (nic->iftype == STATION_MODE) + firmware = STA_FIRMWARE; + + /*BugID_5137*/ + else { + PRINT_D(INIT_DBG, "Get P2P_CONCURRENCY_FIRMWARE\n"); + firmware = P2P_CONCURRENCY_FIRMWARE; + } + + + + if (nic == NULL) { + PRINT_ER("NIC is NULL\n"); + goto _fail_; + } + + if (&nic->wilc_netdev->dev == NULL) { + PRINT_ER("&nic->wilc_netdev->dev is NULL\n"); + goto _fail_; + } + + + /* the firmare should be located in /lib/firmware in + * root file system with the name specified above */ + +#ifdef WILC_SDIO + if (request_firmware(&wilc_firmware, firmware, &g_linux_wlan->wilc_sdio_func->dev) != 0) { + PRINT_ER("%s - firmare not available\n", firmware); + ret = -1; + goto _fail_; + } +#else + if (request_firmware(&wilc_firmware, firmware, &g_linux_wlan->wilc_spidev->dev) != 0) { + PRINT_ER("%s - firmare not available\n", firmware); + ret = -1; + goto _fail_; + } +#endif + g_linux_wlan->wilc_firmware = wilc_firmware; /* Bug 4703 */ + +_fail_: + + return ret; + +} + +#ifdef COMPLEMENT_BOOT +int repeat_power_cycle(perInterface_wlan_t *nic); +#endif + +static int linux_wlan_start_firmware(perInterface_wlan_t *nic) +{ + + static int timeout = 5; + int ret = 0; + /* start firmware */ + PRINT_D(INIT_DBG, "Starting Firmware ...\n"); + ret = g_linux_wlan->oup.wlan_start(); + if (ret < 0) { + PRINT_ER("Failed to start Firmware\n"); + goto _fail_; + } + + /* wait for mac ready */ + PRINT_D(INIT_DBG, "Waiting for Firmware to get ready ...\n"); + ret = linux_wlan_lock_timeout(&g_linux_wlan->sync_event, 5000); + if (ret) { +#ifdef COMPLEMENT_BOOT + + if (timeout--) { + PRINT_D(INIT_DBG, "repeat power cycle[%d]", timeout); + ret = repeat_power_cycle(nic); + } else { + timeout = 5; + ret = -1; + goto _fail_; + } +#endif + PRINT_D(INIT_DBG, "Firmware start timed out"); + goto _fail_; + } + /* + * TODO: Driver shouoldn't wait forever for firmware to get started - + * in case of timeout this should be handled properly + */ + PRINT_D(INIT_DBG, "Firmware successfully started\n"); + +_fail_: + return ret; +} +static int linux_wlan_firmware_download(linux_wlan_t *p_nic) +{ + + int ret = 0; + + if (g_linux_wlan->wilc_firmware == NULL) { + PRINT_ER("Firmware buffer is NULL\n"); + ret = -ENOBUFS; + goto _FAIL_; + } + /** + * do the firmware download + **/ + PRINT_D(INIT_DBG, "Downloading Firmware ...\n"); + ret = g_linux_wlan->oup.wlan_firmware_download(g_linux_wlan->wilc_firmware->data, g_linux_wlan->wilc_firmware->size); + if (ret < 0) { + goto _FAIL_; + } + + /* Freeing FW buffer */ + PRINT_D(INIT_DBG, "Freeing FW buffer ...\n"); + PRINT_D(INIT_DBG, "Releasing firmware\n"); + release_firmware(g_linux_wlan->wilc_firmware); + g_linux_wlan->wilc_firmware = NULL; + + PRINT_D(INIT_DBG, "Download Succeeded \n"); + +_FAIL_: + return ret; +} + + +/* startup configuration - could be changed later using iconfig*/ +static int linux_wlan_init_test_config(struct net_device *dev, linux_wlan_t *p_nic) +{ + + unsigned char c_val[64]; + #ifndef STATIC_MACADDRESS + unsigned char mac_add[] = {0x00, 0x80, 0xC2, 0x5E, 0xa2, 0xff}; + #endif + unsigned int chipid = 0; + + /*BugID_5077*/ + struct WILC_WFI_priv *priv; + tstrWILC_WFIDrv *pstrWFIDrv; + + PRINT_D(TX_DBG, "Start configuring Firmware\n"); + #ifndef STATIC_MACADDRESS + get_random_bytes(&mac_add[5], 1); + get_random_bytes(&mac_add[4], 1); + #endif + priv = wiphy_priv(dev->ieee80211_ptr->wiphy); + pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv; + PRINT_D(INIT_DBG, "Host = %x\n", (WILC_Uint32)pstrWFIDrv); + + PRINT_D(INIT_DBG, "MAC address is : %02x-%02x-%02x-%02x-%02x-%02x\n", mac_add[0], mac_add[1], mac_add[2], mac_add[3], mac_add[4], mac_add[5]); + chipid = wilc_get_chipid(0); + + + if (g_linux_wlan->oup.wlan_cfg_set == NULL) { + PRINT_D(INIT_DBG, "Null p[ointer\n"); + goto _fail_; + } + + *(int *)c_val = (WILC_Uint32)pstrWFIDrv; + + if (!g_linux_wlan->oup.wlan_cfg_set(1, WID_SET_DRV_HANDLER, c_val, 4, 0, 0)) + goto _fail_; + + /*to tell fw that we are going to use PC test - WILC specific*/ + c_val[0] = 0; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_PC_TEST_MODE, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = INFRASTRUCTURE; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_BSS_TYPE, c_val, 1, 0, 0)) + goto _fail_; + + + /* c_val[0] = RATE_AUTO; / * bug 4275: Enable autorate and limit it to 24Mbps * / */ + c_val[0] = RATE_AUTO; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_CURRENT_TX_RATE, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = G_MIXED_11B_2_MODE; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11G_OPERATING_MODE, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = 1; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_CURRENT_CHANNEL, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = G_SHORT_PREAMBLE; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_PREAMBLE, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = AUTO_PROT; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_PROT_MECH, c_val, 1, 0, 0)) + goto _fail_; + +#ifdef SWITCH_LOG_TERMINAL + c_val[0] = AUTO_PROT; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_LOGTerminal_Switch, c_val, 1, 0, 0)) + goto _fail_; +#endif + + c_val[0] = ACTIVE_SCAN; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_SCAN_TYPE, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = SITE_SURVEY_OFF; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_SITE_SURVEY, c_val, 1, 0, 0)) + goto _fail_; + + *((int *)c_val) = 0xffff; /* Never use RTS-CTS */ + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_RTS_THRESHOLD, c_val, 2, 0, 0)) + goto _fail_; + + *((int *)c_val) = 2346; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_FRAG_THRESHOLD, c_val, 2, 0, 0)) + goto _fail_; + + /* SSID */ + /* -------------------------------------------------------------- */ + /* Configuration : String with length less than 32 bytes */ + /* Values to set : Any string with length less than 32 bytes */ + /* ( In BSS Station Set SSID to "" (null string) */ + /* to enable Broadcast SSID suppport ) */ + /* -------------------------------------------------------------- */ +#ifndef USE_WIRELESS + strcpy(c_val, "nwifi"); + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_SSID, c_val, (strlen(c_val) + 1), 0, 0)) + goto _fail_; +#endif + + c_val[0] = 0; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_BCAST_SSID, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = 1; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_QOS_ENABLE, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = NO_POWERSAVE; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_POWER_MANAGEMENT, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = NO_ENCRYPT; /* NO_ENCRYPT, 0x79 */ + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11I_MODE, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = OPEN_SYSTEM; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_AUTH_TYPE, c_val, 1, 0, 0)) + goto _fail_; + + /* WEP/802 11I Configuration */ + /* ------------------------------------------------------------------ */ + /* Configuration : WEP Key */ + /* Values (0x) : 5 byte for WEP40 and 13 bytes for WEP104 */ + /* In case more than 5 bytes are passed on for WEP 40 */ + /* only first 5 bytes will be used as the key */ + /* ------------------------------------------------------------------ */ + + strcpy(c_val, "123456790abcdef1234567890"); + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_WEP_KEY_VALUE, c_val, (strlen(c_val) + 1), 0, 0)) + goto _fail_; + + /* WEP/802 11I Configuration */ + /* ------------------------------------------------------------------ */ + /* Configuration : AES/TKIP WPA/RSNA Pre-Shared Key */ + /* Values to set : Any string with length greater than equal to 8 bytes */ + /* and less than 64 bytes */ + /* ------------------------------------------------------------------ */ + strcpy(c_val, "12345678"); + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11I_PSK, c_val, (strlen(c_val)), 0, 0)) + goto _fail_; + + /* IEEE802.1X Key Configuration */ + /* ------------------------------------------------------------------ */ + /* Configuration : Radius Server Access Secret Key */ + /* Values to set : Any string with length greater than equal to 8 bytes */ + /* and less than 65 bytes */ + /* ------------------------------------------------------------------ */ + strcpy(c_val, "password"); + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_1X_KEY, c_val, (strlen(c_val) + 1), 0, 0)) + goto _fail_; + + /* IEEE802.1X Server Address Configuration */ + /* ------------------------------------------------------------------ */ + /* Configuration : Radius Server IP Address */ + /* Values to set : Any valid IP Address */ + /* ------------------------------------------------------------------ */ + c_val[0] = 192; + c_val[1] = 168; + c_val[2] = 1; + c_val[3] = 112; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_1X_SERV_ADDR, c_val, 4, 0, 0)) + goto _fail_; + + c_val[0] = 3; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_LISTEN_INTERVAL, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = 3; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_DTIM_PERIOD, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = NORMAL_ACK; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_ACK_POLICY, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = 0; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_USER_CONTROL_ON_TX_POWER, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = 48; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_TX_POWER_LEVEL_11A, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = 28; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_TX_POWER_LEVEL_11B, c_val, 1, 0, 0)) + goto _fail_; + + /* Beacon Interval */ + /* -------------------------------------------------------------------- */ + /* Configuration : Sets the beacon interval value */ + /* Values to set : Any 16-bit value */ + /* -------------------------------------------------------------------- */ + + *((int *)c_val) = 100; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_BEACON_INTERVAL, c_val, 2, 0, 0)) + goto _fail_; + + c_val[0] = REKEY_DISABLE; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_REKEY_POLICY, c_val, 1, 0, 0)) + goto _fail_; + + /* Rekey Time (s) (Used only when the Rekey policy is 2 or 4) */ + /* -------------------------------------------------------------------- */ + /* Configuration : Sets the Rekey Time (s) */ + /* Values to set : 32-bit value */ + /* -------------------------------------------------------------------- */ + *((int *)c_val) = 84600; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_REKEY_PERIOD, c_val, 4, 0, 0)) + goto _fail_; + + /* Rekey Packet Count (in 1000s; used when Rekey Policy is 3) */ + /* -------------------------------------------------------------------- */ + /* Configuration : Sets Rekey Group Packet count */ + /* Values to set : 32-bit Value */ + /* -------------------------------------------------------------------- */ + *((int *)c_val) = 500; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_REKEY_PACKET_COUNT, c_val, 4, 0, 0)) + goto _fail_; + + c_val[0] = 1; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_SHORT_SLOT_ALLOWED, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = G_SELF_CTS_PROT; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_ERP_PROT_TYPE, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = 1; /* Enable N */ + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_ENABLE, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = HT_MIXED_MODE; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_OPERATING_MODE, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = 1; /* TXOP Prot disable in N mode: No RTS-CTS on TX A-MPDUs to save air-time. */ + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_TXOP_PROT_DISABLE, c_val, 1, 0, 0)) + goto _fail_; + + memcpy(c_val, mac_add, 6); + + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_MAC_ADDR, c_val, 6, 0, 0)) + goto _fail_; + + /** + * AP only + **/ + c_val[0] = DETECT_PROTECT_REPORT; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_OBSS_NONHT_DETECTION, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = RTS_CTS_NONHT_PROT; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_HT_PROT_TYPE, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = 0; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_RIFS_PROT_ENABLE, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = MIMO_MODE; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_SMPS_MODE, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = 7; + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_CURRENT_TX_MCS, c_val, 1, 0, 0)) + goto _fail_; + + c_val[0] = 1; /* Enable N with immediate block ack. */ + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_IMMEDIATE_BA_ENABLED, c_val, 1, 1, (WILC_Uint32)pstrWFIDrv)) + goto _fail_; + + return 0; + +_fail_: + return -1; +} + + +/**************************/ +void wilc1000_wlan_deinit(linux_wlan_t *nic) +{ + + if (g_linux_wlan->wilc1000_initialized) { + + printk("Deinitializing wilc1000 ...\n"); + + if (nic == NULL) { + PRINT_ER("nic is NULL\n"); + return; + } + +#if defined(PLAT_ALLWINNER_A20) || defined(PLAT_ALLWINNER_A23) || defined(PLAT_ALLWINNER_A31) + /* johnny : remove */ + PRINT_D(INIT_DBG, "skip wilc_bus_set_default_speed\n"); +#else + wilc_bus_set_default_speed(); +#endif + + PRINT_D(INIT_DBG, "Disabling IRQ\n"); + #if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO) + linux_wlan_disable_irq(IRQ_WAIT); + #else + #if defined(PLAT_ALLWINNER_A20) || defined(PLAT_ALLWINNER_A23) || defined(PLAT_ALLWINNER_A31) + + #else + linux_wlan_lock_mutex((void *)&g_linux_wlan->hif_cs); + disable_sdio_interrupt(); + linux_wlan_unlock_mutex((void *)&g_linux_wlan->hif_cs); + #endif + #endif + + + /* not sure if the following unlocks are needed or not*/ + if (&g_linux_wlan->rxq_event != NULL) { + linux_wlan_unlock(&g_linux_wlan->rxq_event); + } + + if (&g_linux_wlan->txq_event != NULL) { + linux_wlan_unlock(&g_linux_wlan->txq_event); + } + + + #if (RX_BH_TYPE == RX_BH_WORK_QUEUE) + /*Removing the work struct from the linux kernel workqueue*/ + if (&g_linux_wlan->rx_work_queue != NULL) + flush_work(&g_linux_wlan->rx_work_queue); + + #elif (RX_BH_TYPE == RX_BH_KTHREAD) + /* if(&nic->rx_sem != NULL) */ + /* linux_wlan_unlock(&nic->rx_sem); */ + #endif + + PRINT_D(INIT_DBG, "Deinitializing Threads\n"); + wlan_deinitialize_threads(nic); + + PRINT_D(INIT_DBG, "Deinitializing IRQ\n"); + deinit_irq(g_linux_wlan); + + + if (&g_linux_wlan->oup != NULL) { + if (g_linux_wlan->oup.wlan_stop != NULL) + g_linux_wlan->oup.wlan_stop(); + } + + PRINT_D(INIT_DBG, "Deinitializing WILC Wlan\n"); + wilc_wlan_deinit(nic); +#if (defined WILC_SDIO) && (!defined WILC_SDIO_IRQ_GPIO) + #if defined(PLAT_ALLWINNER_A20) || defined(PLAT_ALLWINNER_A23) || defined(PLAT_ALLWINNER_A31) + PRINT_D(INIT_DBG, "Disabling IRQ 2\n"); + + linux_wlan_lock_mutex((void *)&g_linux_wlan->hif_cs); + disable_sdio_interrupt(); + linux_wlan_unlock_mutex((void *)&g_linux_wlan->hif_cs); + #endif +#endif + + /*De-Initialize locks*/ + PRINT_D(INIT_DBG, "Deinitializing Locks\n"); + wlan_deinit_locks(g_linux_wlan); + + /* announce that wilc1000 is not initialized */ + g_linux_wlan->wilc1000_initialized = 0; + + PRINT_D(INIT_DBG, "wilc1000 deinitialization Done\n"); + + } else { + PRINT_D(INIT_DBG, "wilc1000 is not initialized\n"); + } + return; +} + +int wlan_init_locks(linux_wlan_t *p_nic) +{ + + PRINT_D(INIT_DBG, "Initializing Locks ...\n"); + + /*initialize mutexes*/ + linux_wlan_init_mutex("hif_lock/hif_cs", &g_linux_wlan->hif_cs, 1); + linux_wlan_init_mutex("rxq_lock/rxq_cs", &g_linux_wlan->rxq_cs, 1); + linux_wlan_init_mutex("txq_lock/txq_cs", &g_linux_wlan->txq_cs, 1); + + /*Added by Amr - BugID_4720*/ + linux_wlan_init_spin_lock("txq_spin_lock/txq_cs", &g_linux_wlan->txq_spinlock, 1); + + /*Added by Amr - BugID_4720*/ + linux_wlan_init_lock("txq_add_to_head_lock/txq_cs", &g_linux_wlan->txq_add_to_head_cs, 1); + + linux_wlan_init_lock("txq_wait/txq_event", &g_linux_wlan->txq_event, 0); + linux_wlan_init_lock("rxq_wait/rxq_event", &g_linux_wlan->rxq_event, 0); + + linux_wlan_init_lock("cfg_wait/cfg_event", &g_linux_wlan->cfg_event, 0); + linux_wlan_init_lock("sync_event", &g_linux_wlan->sync_event, 0); + + linux_wlan_init_lock("rxq_lock/rxq_started", &g_linux_wlan->rxq_thread_started, 0); + linux_wlan_init_lock("rxq_lock/txq_started", &g_linux_wlan->txq_thread_started, 0); + + #if (RX_BH_TYPE == RX_BH_KTHREAD) + linux_wlan_init_lock("BH_SEM", &g_linux_wlan->rx_sem, 0); + #endif + + return 0; +} + +static int wlan_deinit_locks(linux_wlan_t *nic) +{ + PRINT_D(INIT_DBG, "De-Initializing Locks\n"); + + if (&g_linux_wlan->hif_cs != NULL) + linux_wlan_deinit_mutex(&g_linux_wlan->hif_cs); + + if (&g_linux_wlan->rxq_cs != NULL) + linux_wlan_deinit_mutex(&g_linux_wlan->rxq_cs); + + if (&g_linux_wlan->txq_cs != NULL) + linux_wlan_deinit_mutex(&g_linux_wlan->txq_cs); + + /*Added by Amr - BugID_4720*/ + if (&g_linux_wlan->txq_spinlock != NULL) + linux_wlan_deinit_spin_lock(&g_linux_wlan->txq_spinlock); + + if (&g_linux_wlan->rxq_event != NULL) + linux_wlan_deinit_lock(&g_linux_wlan->rxq_event); + + if (&g_linux_wlan->txq_event != NULL) + linux_wlan_deinit_lock(&g_linux_wlan->txq_event); + + /*Added by Amr - BugID_4720*/ + if (&g_linux_wlan->txq_add_to_head_cs != NULL) + linux_wlan_deinit_lock(&g_linux_wlan->txq_add_to_head_cs); + + if (&g_linux_wlan->rxq_thread_started != NULL) + linux_wlan_deinit_lock(&g_linux_wlan->rxq_thread_started); + + if (&g_linux_wlan->txq_thread_started != NULL) + linux_wlan_deinit_lock(&g_linux_wlan->txq_thread_started); + + if (&g_linux_wlan->cfg_event != NULL) + linux_wlan_deinit_lock(&g_linux_wlan->cfg_event); + + if (&g_linux_wlan->sync_event != NULL) + linux_wlan_deinit_lock(&g_linux_wlan->sync_event); + + return 0; +} +void linux_to_wlan(wilc_wlan_inp_t *nwi, linux_wlan_t *nic) +{ + + PRINT_D(INIT_DBG, "Linux to Wlan services ...\n"); + + nwi->os_context.hif_critical_section = (void *)&g_linux_wlan->hif_cs; + nwi->os_context.os_private = (void *)nic; + nwi->os_context.tx_buffer_size = LINUX_TX_SIZE; + nwi->os_context.txq_critical_section = (void *)&g_linux_wlan->txq_cs; + + /*Added by Amr - BugID_4720*/ + nwi->os_context.txq_add_to_head_critical_section = (void *)&g_linux_wlan->txq_add_to_head_cs; + + /*Added by Amr - BugID_4720*/ + nwi->os_context.txq_spin_lock = (void *)&g_linux_wlan->txq_spinlock; + + nwi->os_context.txq_wait_event = (void *)&g_linux_wlan->txq_event; + +#if defined (MEMORY_STATIC) + nwi->os_context.rx_buffer_size = LINUX_RX_SIZE; +#endif + nwi->os_context.rxq_critical_section = (void *)&g_linux_wlan->rxq_cs; + nwi->os_context.rxq_wait_event = (void *)&g_linux_wlan->rxq_event; + nwi->os_context.cfg_wait_event = (void *)&g_linux_wlan->cfg_event; + + nwi->os_func.os_sleep = linux_wlan_msleep; + nwi->os_func.os_atomic_sleep = linux_wlan_atomic_msleep; + nwi->os_func.os_debug = linux_wlan_dbg; + nwi->os_func.os_malloc = linux_wlan_malloc; + nwi->os_func.os_malloc_atomic = linux_wlan_malloc_atomic; + nwi->os_func.os_free = linux_wlan_free; + nwi->os_func.os_lock = linux_wlan_lock; + nwi->os_func.os_unlock = linux_wlan_unlock; + nwi->os_func.os_wait = linux_wlan_lock_timeout; + nwi->os_func.os_signal = linux_wlan_unlock; + nwi->os_func.os_enter_cs = linux_wlan_lock_mutex; + nwi->os_func.os_leave_cs = linux_wlan_unlock_mutex; + + /*Added by Amr - BugID_4720*/ + nwi->os_func.os_spin_lock = linux_wlan_spin_lock; + nwi->os_func.os_spin_unlock = linux_wlan_spin_unlock; + +#ifdef WILC_SDIO + nwi->io_func.io_type = HIF_SDIO; + nwi->io_func.io_init = linux_sdio_init; + nwi->io_func.io_deinit = linux_sdio_deinit; + nwi->io_func.u.sdio.sdio_cmd52 = linux_sdio_cmd52; + nwi->io_func.u.sdio.sdio_cmd53 = linux_sdio_cmd53; + nwi->io_func.u.sdio.sdio_set_max_speed = linux_sdio_set_max_speed; + nwi->io_func.u.sdio.sdio_set_default_speed = linux_sdio_set_default_speed; +#else + nwi->io_func.io_type = HIF_SPI; + nwi->io_func.io_init = linux_spi_init; + nwi->io_func.io_deinit = linux_spi_deinit; + nwi->io_func.u.spi.spi_tx = linux_spi_write; + nwi->io_func.u.spi.spi_rx = linux_spi_read; + nwi->io_func.u.spi.spi_trx = linux_spi_write_read; + nwi->io_func.u.spi.spi_max_speed = linux_spi_set_max_speed; +#endif + + /*for now - to be revised*/ + #ifdef WILC_FULLY_HOSTING_AP + /* incase of Fully hosted AP, all non cfg pkts are processed here*/ + nwi->net_func.rx_indicate = WILC_Process_rx_frame; + #else + nwi->net_func.rx_indicate = frmw_to_linux; + #endif + nwi->net_func.rx_complete = linux_wlan_rx_complete; + nwi->indicate_func.mac_indicate = linux_wlan_mac_indicate; +} + +int wlan_initialize_threads(perInterface_wlan_t *nic) +{ + + int ret = 0; + PRINT_D(INIT_DBG, "Initializing Threads ...\n"); + +#if (RX_BH_TYPE == RX_BH_WORK_QUEUE) + /*Initialize rx work queue task*/ + INIT_WORK(&g_linux_wlan->rx_work_queue, isr_bh_routine); +#elif (RX_BH_TYPE == RX_BH_KTHREAD) + PRINT_D(INIT_DBG, "Creating kthread for Rxq BH\n"); + g_linux_wlan->rx_bh_thread = kthread_run(isr_bh_routine, (void *)g_linux_wlan, "K_RXQ_BH"); + if (g_linux_wlan->rx_bh_thread == 0) { + PRINT_ER("couldn't create RX BH thread\n"); + ret = -ENOBUFS; + goto _fail_; + } +#endif + +#ifndef TCP_ENHANCEMENTS + /* create rx task */ + PRINT_D(INIT_DBG, "Creating kthread for reception\n"); + g_linux_wlan->rxq_thread = kthread_run(linux_wlan_rxq_task, (void *)g_linux_wlan, "K_RXQ_TASK"); + if (g_linux_wlan->rxq_thread == 0) { + PRINT_ER("couldn't create RXQ thread\n"); + ret = -ENOBUFS; + goto _fail_1; + } + + /* wait for RXQ task to start. */ + linux_wlan_lock(&g_linux_wlan->rxq_thread_started); + +#endif + + /* create tx task */ + PRINT_D(INIT_DBG, "Creating kthread for transmission\n"); + g_linux_wlan->txq_thread = kthread_run(linux_wlan_txq_task, (void *)g_linux_wlan, "K_TXQ_TASK"); + if (g_linux_wlan->txq_thread == 0) { + PRINT_ER("couldn't create TXQ thread\n"); + ret = -ENOBUFS; + goto _fail_2; + } +#ifdef DEBUG_MODE + PRINT_D(INIT_DBG, "Creating kthread for Debugging\n"); + g_linux_wlan->txq_thread = kthread_run(DebuggingThreadTask, (void *)g_linux_wlan, "DebugThread"); + if (g_linux_wlan->txq_thread == 0) { + PRINT_ER("couldn't create TXQ thread\n"); + ret = -ENOBUFS; + goto _fail_2; + } +#endif + /* wait for TXQ task to start. */ + linux_wlan_lock(&g_linux_wlan->txq_thread_started); + + return 0; + +_fail_2: + /*De-Initialize 2nd thread*/ + g_linux_wlan->close = 1; + linux_wlan_unlock(&g_linux_wlan->rxq_event); + kthread_stop(g_linux_wlan->rxq_thread); + +_fail_1: + #if (RX_BH_TYPE == RX_BH_KTHREAD) + /*De-Initialize 1st thread*/ + g_linux_wlan->close = 1; + linux_wlan_unlock(&g_linux_wlan->rx_sem); + kthread_stop(g_linux_wlan->rx_bh_thread); +_fail_: + #endif + g_linux_wlan->close = 0; + return ret; +} + +static void wlan_deinitialize_threads(linux_wlan_t *nic) +{ + + g_linux_wlan->close = 1; + PRINT_D(INIT_DBG, "Deinitializing Threads\n"); + if (&g_linux_wlan->rxq_event != NULL) + linux_wlan_unlock(&g_linux_wlan->rxq_event); + + + if (g_linux_wlan->rxq_thread != NULL) { + kthread_stop(g_linux_wlan->rxq_thread); + g_linux_wlan->rxq_thread = NULL; + } + + + if (&g_linux_wlan->txq_event != NULL) + linux_wlan_unlock(&g_linux_wlan->txq_event); + + + if (g_linux_wlan->txq_thread != NULL) { + kthread_stop(g_linux_wlan->txq_thread); + g_linux_wlan->txq_thread = NULL; + } + + #if (RX_BH_TYPE == RX_BH_KTHREAD) + if (&g_linux_wlan->rx_sem != NULL) + linux_wlan_unlock(&g_linux_wlan->rx_sem); + + if (g_linux_wlan->rx_bh_thread != NULL) { + kthread_stop(g_linux_wlan->rx_bh_thread); + g_linux_wlan->rx_bh_thread = NULL; + } + #endif +} + +#ifdef STATIC_MACADDRESS +const char *path_string[] = { + "/etc/wlan", + "/data/wlan", +}; + +static int linux_wlan_read_mac_addr(void *vp) +{ + int ret = 0; + struct file *fp = (struct file *)-ENOENT; + mm_segment_t old_fs; + loff_t pos = 0; + int index; + int array_size = sizeof(path_string) / sizeof(path_string[0]); + + /* change to KERNEL_DS address limit */ + old_fs = get_fs(); + set_fs(KERNEL_DS); + + for (index = 0; index < array_size; index++) { + fp = filp_open(path_string[index], O_WRONLY, 0640); + if (!fp) { + ret = -1; + goto exit; + } + + /*No such file or directory */ + if (IS_ERR(fp) || !fp->f_op) { + get_random_bytes(&mac_add[3], 3); + /* open file to write */ + fp = filp_open(path_string[index], O_WRONLY | O_CREAT, 0640); + + if (!fp || IS_ERR(fp)) { + ret = -1; + continue; + } else { + /* write buf to file */ + fp->f_op->write(fp, mac_add, 6, &pos); + break; + } + } else { + /* read file to buf */ + fp->f_op->read(fp, mac_add, 6, &pos); + break; + } + } + + if (index == array_size) { + PRINT_ER("random MAC\n"); + } + +exit: + if (fp && !IS_ERR(fp)) { + filp_close(fp, NULL); + } + + set_fs(old_fs); + + return ret; +} +#endif + +#ifdef COMPLEMENT_BOOT + +extern volatile int probe; +extern uint8_t core_11b_ready(void); + +#define READY_CHECK_THRESHOLD 30 +extern void wilc_wlan_global_reset(void); +uint8_t wilc1000_prepare_11b_core(wilc_wlan_inp_t *nwi, wilc_wlan_oup_t *nwo, linux_wlan_t *nic) +{ + uint8_t trials = 0; + while ((core_11b_ready() && (READY_CHECK_THRESHOLD > (trials++)))) { + PRINT_D(INIT_DBG, "11b core not ready yet: %u\n", trials); + wilc_wlan_deinit(nic); + wilc_wlan_global_reset(); + sdio_unregister_driver(&wilc_bus); + + linux_wlan_device_detection(0); + + mdelay(100); + + linux_wlan_device_detection(1); + + sdio_register_driver(&wilc_bus); + + while (!probe) { + msleep(100); + } + probe = 0; + g_linux_wlan->wilc_sdio_func = local_sdio_func; + linux_to_wlan(nwi, nic); + wilc_wlan_init(nwi, nwo); + } + + if (READY_CHECK_THRESHOLD <= trials) + return 1; + else + return 0; + +} + +int repeat_power_cycle(perInterface_wlan_t *nic) +{ + int ret = 0; + wilc_wlan_inp_t nwi; + wilc_wlan_oup_t nwo; + sdio_unregister_driver(&wilc_bus); + + linux_wlan_device_detection(0); + linux_wlan_device_power(0); + msleep(100); + linux_wlan_device_power(1); + msleep(80); + linux_wlan_device_detection(1); + msleep(20); + + sdio_register_driver(&wilc_bus); + + /* msleep(1000); */ + while (!probe) { + msleep(100); + } + probe = 0; + g_linux_wlan->wilc_sdio_func = local_sdio_func; + linux_to_wlan(&nwi, g_linux_wlan); + ret = wilc_wlan_init(&nwi, &nwo); + + g_linux_wlan->mac_status = WILC_MAC_STATUS_INIT; + #if (defined WILC_SDIO) && (!defined WILC_SDIO_IRQ_GPIO) + enable_sdio_interrupt(); + #endif + + if (linux_wlan_get_firmware(nic)) { + PRINT_ER("Can't get firmware \n"); + ret = -1; + goto __fail__; + } + + /*Download firmware*/ + ret = linux_wlan_firmware_download(g_linux_wlan); + if (ret < 0) { + PRINT_ER("Failed to download firmware\n"); + goto __fail__; + } + /* Start firmware*/ + ret = linux_wlan_start_firmware(nic); + if (ret < 0) { + PRINT_ER("Failed to start firmware\n"); + } +__fail__: + return ret; +} +#endif + +int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic) +{ + wilc_wlan_inp_t nwi; + wilc_wlan_oup_t nwo; + perInterface_wlan_t *nic = p_nic; + int ret = 0; + + if (!g_linux_wlan->wilc1000_initialized) { + g_linux_wlan->mac_status = WILC_MAC_STATUS_INIT; + g_linux_wlan->close = 0; + g_linux_wlan->wilc1000_initialized = 0; + + wlan_init_locks(g_linux_wlan); + +#ifdef STATIC_MACADDRESS + wilc_mac_thread = kthread_run(linux_wlan_read_mac_addr, NULL, "wilc_mac_thread"); + if (wilc_mac_thread < 0) { + PRINT_ER("couldn't create Mac addr thread\n"); + } +#endif + + linux_to_wlan(&nwi, g_linux_wlan); + + ret = wilc_wlan_init(&nwi, &nwo); + if (ret < 0) { + PRINT_ER("Initializing WILC_Wlan FAILED\n"); + ret = -EIO; + goto _fail_locks_; + } + memcpy(&g_linux_wlan->oup, &nwo, sizeof(wilc_wlan_oup_t)); + + /*Save the oup structre into global pointer*/ + gpstrWlanOps = &g_linux_wlan->oup; + + + ret = wlan_initialize_threads(nic); + if (ret < 0) { + PRINT_ER("Initializing Threads FAILED\n"); + ret = -EIO; + goto _fail_wilc_wlan_; + } + +#if (defined WILC_SDIO) && (defined COMPLEMENT_BOOT) + if (wilc1000_prepare_11b_core(&nwi, &nwo, g_linux_wlan)) { + PRINT_ER("11b Core is not ready\n"); + ret = -EIO; + goto _fail_threads_; + } +#endif + +#if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO) + if (init_irq(g_linux_wlan)) { + PRINT_ER("couldn't initialize IRQ\n"); + ret = -EIO; + goto _fail_threads_; + } +#endif + +#if (defined WILC_SDIO) && (!defined WILC_SDIO_IRQ_GPIO) + if (enable_sdio_interrupt()) { + PRINT_ER("couldn't initialize IRQ\n"); + ret = -EIO; + goto _fail_irq_init_; + } +#endif + + if (linux_wlan_get_firmware(nic)) { + PRINT_ER("Can't get firmware \n"); + ret = -EIO; + goto _fail_irq_enable_; + } + + + /*Download firmware*/ + ret = linux_wlan_firmware_download(g_linux_wlan); + if (ret < 0) { + PRINT_ER("Failed to download firmware\n"); + ret = -EIO; + goto _fail_irq_enable_; + } + + /* Start firmware*/ + ret = linux_wlan_start_firmware(nic); + if (ret < 0) { + PRINT_ER("Failed to start firmware\n"); + ret = -EIO; + goto _fail_irq_enable_; + } + + wilc_bus_set_max_speed(); + + if (g_linux_wlan->oup.wlan_cfg_get(1, WID_FIRMWARE_VERSION, 1, 0)) { + int size; + char Firmware_ver[20]; + size = g_linux_wlan->oup.wlan_cfg_get_value( + WID_FIRMWARE_VERSION, + Firmware_ver, sizeof(Firmware_ver)); + Firmware_ver[size] = '\0'; + PRINT_D(INIT_DBG, "***** Firmware Ver = %s *******\n", Firmware_ver); + } + /* Initialize firmware with default configuration */ + ret = linux_wlan_init_test_config(dev, g_linux_wlan); + + if (ret < 0) { + PRINT_ER("Failed to configure firmware\n"); + ret = -EIO; + goto _fail_fw_start_; + } + + g_linux_wlan->wilc1000_initialized = 1; + return 0; /*success*/ + + +_fail_fw_start_: + if (&g_linux_wlan->oup != NULL) { + if (g_linux_wlan->oup.wlan_stop != NULL) + g_linux_wlan->oup.wlan_stop(); + } + +_fail_irq_enable_: +#if (defined WILC_SDIO) && (!defined WILC_SDIO_IRQ_GPIO) + disable_sdio_interrupt(); +#endif +_fail_irq_init_: +#if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO) + deinit_irq(g_linux_wlan); + +#endif +_fail_threads_: + wlan_deinitialize_threads(g_linux_wlan); +_fail_wilc_wlan_: + wilc_wlan_deinit(g_linux_wlan); +_fail_locks_: + wlan_deinit_locks(g_linux_wlan); + PRINT_ER("WLAN Iinitialization FAILED\n"); + } else { + PRINT_D(INIT_DBG, "wilc1000 already initialized\n"); + } + return ret; +} + + +/* + * - this function will be called automatically by OS when module inserted. + */ + +#if !defined (NM73131_0_BOARD) +int mac_init_fn(struct net_device *ndev) +{ + + /*Why we do this !!!*/ + netif_start_queue(ndev); /* ma */ + netif_stop_queue(ndev); /* ma */ + + return 0; +} +#else +int mac_init_fn(struct net_device *ndev) +{ + + unsigned char mac_add[] = {0x00, 0x50, 0xc2, 0x5e, 0x10, 0x00}; + /* TODO: get MAC address whenever the source is EPROM - hardcoded and copy it to ndev*/ + memcpy(ndev->dev_addr, mac_add, 6); + + if (!is_valid_ether_addr(ndev->dev_addr)) { + PRINT_ER("Error: Wrong MAC address\n"); + return -EINVAL; + } + + return 0; +} +#endif + + +void WILC_WFI_frame_register(struct wiphy *wiphy, struct net_device *dev, + u16 frame_type, bool reg); + +/* This fn is called, when this device is setup using ifconfig */ +#if !defined (NM73131_0_BOARD) +int mac_open(struct net_device *ndev) +{ + perInterface_wlan_t *nic; + + /*BugID_5213*/ + /*No need for setting mac address here anymore,*/ + /*Just set it in init_test_config()*/ + unsigned char mac_add[ETH_ALEN] = {0}; + int status; + int ret = 0; + int i = 0; + struct WILC_WFI_priv *priv; + + nic = netdev_priv(ndev); + priv = wiphy_priv(nic->wilc_netdev->ieee80211_ptr->wiphy); + PRINT_D(INIT_DBG, "MAC OPEN[%p]\n", ndev); + + #ifdef USE_WIRELESS + ret = WILC_WFI_InitHostInt(ndev); + if (ret < 0) { + PRINT_ER("Failed to initialize host interface\n"); + + return ret; + } + #endif + + /*initialize platform*/ + PRINT_D(INIT_DBG, "*** re-init ***\n"); + ret = wilc1000_wlan_init(ndev, nic); + if (ret < 0) { + PRINT_ER("Failed to initialize wilc1000\n"); + WILC_WFI_DeInitHostInt(ndev); + return ret; + } + + Set_machw_change_vir_if(WILC_FALSE); + + status = host_int_get_MacAddress(priv->hWILCWFIDrv, mac_add); + PRINT_D(INIT_DBG, "Mac address: %x:%x:%x:%x:%x:%x\n", mac_add[0], mac_add[1], mac_add[2], + mac_add[3], mac_add[4], mac_add[5]); + + /* loop through the NUM of supported devices and set the MAC address */ + for (i = 0; i < g_linux_wlan->u8NoIfcs; i++) { + if (ndev == g_linux_wlan->strInterfaceInfo[i].wilc_netdev) { + memcpy(g_linux_wlan->strInterfaceInfo[i].aSrcAddress, mac_add, ETH_ALEN); + g_linux_wlan->strInterfaceInfo[i].drvHandler = (WILC_Uint32)priv->hWILCWFIDrv; + break; + } + } + + /* TODO: get MAC address whenever the source is EPROM - hardcoded and copy it to ndev*/ + memcpy(ndev->dev_addr, g_linux_wlan->strInterfaceInfo[i].aSrcAddress, ETH_ALEN); + + if (!is_valid_ether_addr(ndev->dev_addr)) { + PRINT_ER("Error: Wrong MAC address\n"); + ret = -EINVAL; + goto _err_; + } + + + WILC_WFI_frame_register(nic->wilc_netdev->ieee80211_ptr->wiphy, nic->wilc_netdev, + nic->g_struct_frame_reg[0].frame_type, nic->g_struct_frame_reg[0].reg); + WILC_WFI_frame_register(nic->wilc_netdev->ieee80211_ptr->wiphy, nic->wilc_netdev, + nic->g_struct_frame_reg[1].frame_type, nic->g_struct_frame_reg[1].reg); + netif_wake_queue(ndev); + g_linux_wlan->open_ifcs++; + nic->mac_opened = 1; + return 0; + +_err_: + WILC_WFI_DeInitHostInt(ndev); + wilc1000_wlan_deinit(g_linux_wlan); + return ret; +} +#else +int mac_open(struct net_device *ndev) +{ + + linux_wlan_t *nic; + nic = netdev_priv(ndev); + + /*initialize platform*/ + if (wilc1000_wlan_init(nic)) { + PRINT_ER("Failed to initialize platform\n"); + return 1; + } + /* Start the network interface queue for this device */ + PRINT_D(INIT_DBG, "Starting netifQ\n"); + netif_start_queue(ndev); +/* linux_wlan_lock(&close_exit_sync); */ + return 0; +} +#endif + +struct net_device_stats *mac_stats(struct net_device *dev) +{ + perInterface_wlan_t *nic = netdev_priv(dev); + + + return &nic->netstats; +} + +/* Setup the multicast filter */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) +static void wilc_set_multicast_list(struct net_device *dev) +{ + + struct netdev_hw_addr *ha; + struct WILC_WFI_priv *priv; + tstrWILC_WFIDrv *pstrWFIDrv; + int i = 0; + priv = wiphy_priv(dev->ieee80211_ptr->wiphy); + pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv; + + + if (!dev) + return; + + PRINT_D(INIT_DBG, "Setting Multicast List with count = %d. \n", dev->mc.count); + + if (dev->flags & IFF_PROMISC) { + /* Normally, we should configure the chip to retrive all packets + * but we don't wanna support this right now */ + /* TODO: add promiscuous mode support */ + PRINT_D(INIT_DBG, "Set promiscuous mode ON, retrive all packets \n"); + return; + } + + /* If there's more addresses than we handle, get all multicast + * packets and sort them out in software. */ + if ((dev->flags & IFF_ALLMULTI) || (dev->mc.count) > WILC_MULTICAST_TABLE_SIZE) { + PRINT_D(INIT_DBG, "Disable multicast filter, retrive all multicast packets\n"); + /* get all multicast packets */ + host_int_setup_multicast_filter((WILC_WFIDrvHandle)pstrWFIDrv, WILC_FALSE, 0); + return; + } + + /* No multicast? Just get our own stuff */ + if ((dev->mc.count) == 0) { + PRINT_D(INIT_DBG, "Enable multicast filter, retrive directed packets only.\n"); + host_int_setup_multicast_filter((WILC_WFIDrvHandle)pstrWFIDrv, WILC_TRUE, 0); + return; + } + + /* Store all of the multicast addresses in the hardware filter */ + netdev_for_each_mc_addr(ha, dev) + { + WILC_memcpy(gau8MulticastMacAddrList[i], ha->addr, ETH_ALEN); + PRINT_D(INIT_DBG, "Entry[%d]: %x:%x:%x:%x:%x:%x\n", i, + gau8MulticastMacAddrList[i][0], gau8MulticastMacAddrList[i][1], gau8MulticastMacAddrList[i][2], gau8MulticastMacAddrList[i][3], gau8MulticastMacAddrList[i][4], gau8MulticastMacAddrList[i][5]); + i++; + } + + host_int_setup_multicast_filter((WILC_WFIDrvHandle)pstrWFIDrv, WILC_TRUE, (dev->mc.count)); + + return; + +} + +#else + +static void wilc_set_multicast_list(struct net_device *dev) +{ + /* BIG Warning, Beware : Uncompiled, untested... */ + struct dev_mc_list *mc_ptr; + int i = 0; + + if (!dev) + return; + + PRINT_D(INIT_DBG, "Setting Multicast List. \n"); + PRINT_D(INIT_DBG, "dev->mc_count = %d\n", dev->mc_count); + + if (dev->flags & IFF_PROMISC) { + /* Normally, we should configure the chip to retrive all packets + * but we don't wanna support this right now */ + /* TODO: add promiscuous mode support */ + PRINT_D(INIT_DBG, "Set promiscuous mode ON, retrive all packets \n"); + return; + } + + /* If there's more addresses than we handle, get all multicast + * packets and sort them out in software. */ + if ((dev->flags & IFF_ALLMULTI) || (dev->mc_count > WILC_MULTICAST_TABLE_SIZE)) { + PRINT_D(INIT_DBG, "Disable multicast filter, retrive all multicast packets\n"); + host_int_setup_multicast_filter((WILC_WFIDrvHandle)gWFiDrvHandle, WILC_FALSE, 0); + return; + } + + /* No multicast? Just get our own stuff */ + if (dev->mc_count == 0) { + PRINT_D(INIT_DBG, "Enable multicast filter, retrive directed packets only.\n"); + host_int_setup_multicast_filter((WILC_WFIDrvHandle)gWFiDrvHandle, WILC_TRUE, 0); + return; + } + + /* Store all of the multicast addresses in the hardware filter */ + + for (mc_ptr = dev->mc_list; mc_ptr; mc_ptr = mc_ptr->next, i++) { + WILC_memcpy(gau8MulticastMacAddrList[i], mc_ptr->dmi_addr, ETH_ALEN) + i++; + } + + host_int_setup_multicast_filter((WILC_WFIDrvHandle)gWFiDrvHandle, WILC_TRUE, (dev->mc_count)); + +} +#endif + +static void linux_wlan_tx_complete(void *priv, int status) +{ + + struct tx_complete_data *pv_data = (struct tx_complete_data *)priv; + if (status == 1) { + PRINT_D(TX_DBG, "Packet sent successfully - Size = %d - Address = %p - SKB = %p\n", pv_data->size, pv_data->buff, pv_data->skb); + } else { + PRINT_D(TX_DBG, "Couldn't send packet - Size = %d - Address = %p - SKB = %p\n", pv_data->size, pv_data->buff, pv_data->skb); + } + /* Free the SK Buffer, its work is done */ + dev_kfree_skb(pv_data->skb); + linux_wlan_free(pv_data); +} + +int mac_xmit(struct sk_buff *skb, struct net_device *ndev) +{ + perInterface_wlan_t *nic; + struct tx_complete_data *tx_data = NULL; + int QueueCount; + char *pu8UdpBuffer; + struct iphdr *ih; + struct ethhdr *eth_h; + nic = netdev_priv(ndev); + + PRINT_D(INT_DBG, "\n========\n IntUH: %d - IntBH: %d - IntCld: %d \n========\n", int_rcvdU, int_rcvdB, int_clrd); + PRINT_D(TX_DBG, "Sending packet just received from TCP/IP\n"); + + /* Stop the network interface queue */ + if (skb->dev != ndev) { + PRINT_ER("Packet not destined to this device\n"); + return 0; + } + + tx_data = (struct tx_complete_data *)internal_alloc(sizeof(struct tx_complete_data), GFP_ATOMIC); + if (tx_data == NULL) { + PRINT_ER("Failed to allocate memory for tx_data structure\n"); + dev_kfree_skb(skb); + netif_wake_queue(ndev); + return 0; + } + + tx_data->buff = skb->data; + tx_data->size = skb->len; + tx_data->skb = skb; + + eth_h = (struct ethhdr *)(skb->data); + if (eth_h->h_proto == 0x8e88) { + PRINT_D(INIT_DBG, "EAPOL transmitted\n"); + } + + /*get source and dest ip addresses*/ + ih = (struct iphdr *)(skb->data + sizeof(struct ethhdr)); + + pu8UdpBuffer = (char *)ih + sizeof(struct iphdr); + if ((pu8UdpBuffer[1] == 68 && pu8UdpBuffer[3] == 67) || (pu8UdpBuffer[1] == 67 && pu8UdpBuffer[3] == 68)) { + PRINT_D(GENERIC_DBG, "DHCP Message transmitted, type:%x %x %x\n", pu8UdpBuffer[248], pu8UdpBuffer[249], pu8UdpBuffer[250]); + + } + PRINT_D(TX_DBG, "Sending packet - Size = %d - Address = %p - SKB = %p\n", tx_data->size, tx_data->buff, tx_data->skb); + + /* Send packet to MAC HW - for now the tx_complete function will be just status + * indicator. still not sure if I need to suspend host transmission till the tx_complete + * function called or not? + * allocated buffer will be freed in tx_complete function. + */ + PRINT_D(TX_DBG, "Adding tx packet to TX Queue\n"); + nic->netstats.tx_packets++; + nic->netstats.tx_bytes += tx_data->size; + tx_data->pBssid = g_linux_wlan->strInterfaceInfo[nic->u8IfIdx].aBSSID; + #ifndef WILC_FULLY_HOSTING_AP + QueueCount = g_linux_wlan->oup.wlan_add_to_tx_que((void *)tx_data, + tx_data->buff, + tx_data->size, + linux_wlan_tx_complete); + #else + QueueCount = WILC_Xmit_data((void *)tx_data, HOST_TO_WLAN); + #endif /* WILC_FULLY_HOSTING_AP */ + + + if (QueueCount > FLOW_CONTROL_UPPER_THRESHOLD) { + netif_stop_queue(g_linux_wlan->strInterfaceInfo[0].wilc_netdev); + netif_stop_queue(g_linux_wlan->strInterfaceInfo[1].wilc_netdev); + } + + return 0; +} + + +int mac_close(struct net_device *ndev) +{ + struct WILC_WFI_priv *priv; + perInterface_wlan_t *nic; + tstrWILC_WFIDrv *pstrWFIDrv; + + nic = netdev_priv(ndev); + + if ((nic == NULL) || (nic->wilc_netdev == NULL) || (nic->wilc_netdev->ieee80211_ptr == NULL) || (nic->wilc_netdev->ieee80211_ptr->wiphy == NULL)) { + PRINT_ER("nic = NULL\n"); + return 0; + } + + priv = wiphy_priv(nic->wilc_netdev->ieee80211_ptr->wiphy); + + if (priv == NULL) { + PRINT_ER("priv = NULL\n"); + return 0; + } + + pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv; + + + + PRINT_D(GENERIC_DBG, "Mac close\n"); + + if (g_linux_wlan == NULL) { + PRINT_ER("g_linux_wlan = NULL\n"); + return 0; + } + + if (pstrWFIDrv == NULL) { + PRINT_ER("pstrWFIDrv = NULL\n"); + return 0; + } + + if ((g_linux_wlan->open_ifcs) > 0) { + g_linux_wlan->open_ifcs--; + } else { + PRINT_ER("ERROR: MAC close called while number of opened interfaces is zero\n"); + return 0; + } + + if (nic->wilc_netdev != NULL) { + /* Stop the network interface queue */ + netif_stop_queue(nic->wilc_netdev); + + #ifdef USE_WIRELESS + WILC_WFI_DeInitHostInt(nic->wilc_netdev); + #endif + } + + if (g_linux_wlan->open_ifcs == 0) { + PRINT_D(GENERIC_DBG, "Deinitializing wilc1000\n"); + g_linux_wlan->close = 1; + wilc1000_wlan_deinit(g_linux_wlan); + #ifdef USE_WIRELESS + #ifdef WILC_AP_EXTERNAL_MLME + WILC_WFI_deinit_mon_interface(); + #endif + #endif + } + + linux_wlan_unlock(&close_exit_sync); + nic->mac_opened = 0; + + return 0; +} + + +int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) +{ + + WILC_Uint8 *buff = NULL; + WILC_Sint8 rssi; + WILC_Uint32 size = 0, length = 0; + perInterface_wlan_t *nic; + struct WILC_WFI_priv *priv; + WILC_Sint32 s32Error = WILC_SUCCESS; + + + + /* struct iwreq *wrq = (struct iwreq *) req; // tony moved to case SIOCSIWPRIV */ + #ifdef USE_WIRELESS + nic = netdev_priv(ndev); + + if (!g_linux_wlan->wilc1000_initialized) + return 0; + + #endif + + switch (cmd) { + /* [[ added by tony for SIOCDEVPRIVATE */ + case SIOCDEVPRIVATE + 1: + { + android_wifi_priv_cmd priv_cmd; + + PRINT_INFO(GENERIC_DBG, "in SIOCDEVPRIVATE+1\n"); + + if (copy_from_user(&priv_cmd, req->ifr_data, sizeof(android_wifi_priv_cmd))) { + s32Error = -EFAULT; + goto done; + } + + buff = kmalloc(priv_cmd.total_len, GFP_KERNEL); + if (!buff) { + s32Error = -ENOMEM; + goto done; + } + + if (copy_from_user(buff, priv_cmd.buf, priv_cmd.total_len)) { + s32Error = -EFAULT; + goto done; + } + + PRINT_INFO(GENERIC_DBG, "%s: Android private cmd \"%s\" on %s\n", __FUNCTION__, buff, req->ifr_name); + + if (strncasecmp(buff, "SCAN-ACTIVE", strlen("SCAN-ACTIVE")) == 0) { + PRINT_INFO(GENERIC_DBG, "%s, SCAN-ACTIVE command\n", __FUNCTION__); + } else if (strncasecmp(buff, "SCAN-PASSIVE", strlen("SCAN-PASSIVE")) == 0) { + PRINT_INFO(GENERIC_DBG, "%s, SCAN-PASSIVE command\n", __FUNCTION__); + } else if (strncasecmp(buff, "RXFILTER-START", strlen("RXFILTER-START")) == 0) { + PRINT_INFO(GENERIC_DBG, "%s, RXFILTER-START command\n", __FUNCTION__); + } else if (strncasecmp(buff, "RXFILTER-STOP", strlen("RXFILTER-STOP")) == 0) { + PRINT_INFO(GENERIC_DBG, "%s, RXFILTER-STOP command\n", __FUNCTION__); + } else if (strncasecmp(buff, "RXFILTER-ADD", strlen("RXFILTER-ADD")) == 0) { + int filter_num = *(buff + strlen("RXFILTER-ADD") + 1) - '0'; + PRINT_INFO(GENERIC_DBG, "%s, RXFILTER-ADD command, filter_num=%d\n", __FUNCTION__, filter_num); + } else if (strncasecmp(buff, "RXFILTER-REMOVE", strlen("RXFILTER-REMOVE")) == 0) { + int filter_num = *(buff + strlen("RXFILTER-REMOVE") + 1) - '0'; + PRINT_INFO(GENERIC_DBG, "%s, RXFILTER-REMOVE command, filter_num=%d\n", __FUNCTION__, filter_num); + } else if (strncasecmp(buff, "BTCOEXSCAN-START", strlen("BTCOEXSCAN-START")) == 0) { + PRINT_INFO(GENERIC_DBG, "%s, BTCOEXSCAN-START command\n", __FUNCTION__); + } else if (strncasecmp(buff, "BTCOEXSCAN-STOP", strlen("BTCOEXSCAN-STOP")) == 0) { + PRINT_INFO(GENERIC_DBG, "%s, BTCOEXSCAN-STOP command\n", __FUNCTION__); + } else if (strncasecmp(buff, "BTCOEXMODE", strlen("BTCOEXMODE")) == 0) { + PRINT_INFO(GENERIC_DBG, "%s, BTCOEXMODE command\n", __FUNCTION__); + } else if (strncasecmp(buff, "SETBAND", strlen("SETBAND")) == 0) { + uint band = *(buff + strlen("SETBAND") + 1) - '0'; + PRINT_INFO(GENERIC_DBG, "%s, SETBAND command, band=%d\n", __FUNCTION__, band); + } else if (strncasecmp(buff, "GETBAND", strlen("GETBAND")) == 0) { + PRINT_INFO(GENERIC_DBG, "%s, GETBAND command\n", __FUNCTION__); + } else if (strncasecmp(buff, "COUNTRY", strlen("COUNTRY")) == 0) { + char *country_code = buff + strlen("COUNTRY") + 1; + PRINT_INFO(GENERIC_DBG, "%s, COUNTRY command, country_code=%s\n", __FUNCTION__, country_code); + } else { + PRINT_INFO(GENERIC_DBG, "%s, Unknown command\n", __FUNCTION__); + } + } break; + + /* ]] 2013-06-24 */ + case SIOCSIWPRIV: + { + struct iwreq *wrq = (struct iwreq *) req; /* added by tony */ + + size = wrq->u.data.length; + + if (size && wrq->u.data.pointer) { + buff = kmalloc(size, GFP_KERNEL); + if (!buff) { + s32Error = -ENOMEM; + goto done; + } + + if (copy_from_user + (buff, wrq->u.data.pointer, + wrq->u.data.length)) { + s32Error = -EFAULT; + goto done; + } + + if (strncasecmp(buff, "RSSI", length) == 0) { + + #ifdef USE_WIRELESS + priv = wiphy_priv(nic->wilc_netdev->ieee80211_ptr->wiphy); + s32Error = host_int_get_rssi(priv->hWILCWFIDrv, &(rssi)); + if (s32Error) + PRINT_ER("Failed to send get rssi param's message queue "); + #endif + PRINT_INFO(GENERIC_DBG, "RSSI :%d\n", rssi); + + /*Rounding up the rssi negative value*/ + rssi += 5; + + snprintf(buff, size, "rssi %d", rssi); + + if (copy_to_user(wrq->u.data.pointer, buff, size)) { + PRINT_ER("%s: failed to copy data to user buffer\n", __FUNCTION__); + s32Error = -EFAULT; + goto done; + } + } + } + } + break; + + default: + { + PRINT_INFO(GENERIC_DBG, "Command - %d - has been received\n", cmd); + s32Error = -EOPNOTSUPP; + goto done; + } + } + +done: + + if (buff != NULL) { + kfree(buff); + } + + return s32Error; +} + +void frmw_to_linux(uint8_t *buff, uint32_t size, uint32_t pkt_offset) +{ + + unsigned int frame_len = 0; + int stats; + unsigned char *buff_to_send = NULL; + struct sk_buff *skb; + char *pu8UdpBuffer; + struct iphdr *ih; + struct net_device *wilc_netdev; + perInterface_wlan_t *nic; + + wilc_netdev = GetIfHandler(buff); + if (wilc_netdev == NULL) + return; + + buff += pkt_offset; + nic = netdev_priv(wilc_netdev); + + if (size > 0) { + + frame_len = size; + buff_to_send = buff; + + + /* Need to send the packet up to the host, allocate a skb buffer */ + skb = dev_alloc_skb(frame_len); + if (skb == NULL) { + PRINT_ER("Low memory - packet droped\n"); + return; + } + + skb_reserve(skb, (unsigned int)skb->data & 0x3); + + if (g_linux_wlan == NULL || wilc_netdev == NULL) { + PRINT_ER("wilc_netdev in g_linux_wlan is NULL"); + } + skb->dev = wilc_netdev; + + if (skb->dev == NULL) { + PRINT_ER("skb->dev is NULL\n"); + } + + /* + * for(i=0;i<40;i++) + * { + * if(imonitor_flag) + * { + * WILC_WFI_monitor_rx(nic->wilc_netdev,skb); + * return; + * }*/ +#endif + skb->protocol = eth_type_trans(skb, wilc_netdev); + #ifndef TCP_ENHANCEMENTS + /*get source and dest ip addresses*/ + ih = (struct iphdr *)(skb->data + sizeof(struct ethhdr)); + + pu8UdpBuffer = (char *)ih + sizeof(struct iphdr); + if (buff_to_send[35] == 67 && buff_to_send[37] == 68) { + PRINT_D(RX_DBG, "DHCP Message received\n"); + } + if (buff_to_send[12] == 0x88 && buff_to_send[13] == 0x8e) + PRINT_D(GENERIC_DBG, "eapol received\n"); + #endif + /* Send the packet to the stack by giving it to the bridge */ + nic->netstats.rx_packets++; + nic->netstats.rx_bytes += frame_len; + skb->ip_summed = CHECKSUM_UNNECESSARY; + stats = netif_rx(skb); + PRINT_D(RX_DBG, "netif_rx ret value is: %d\n", stats); + } + #ifndef TCP_ENHANCEMENTS + else { + PRINT_ER("Discard sending packet with len = %d\n", size); + } + #endif +} + +void WILC_WFI_mgmt_rx(uint8_t *buff, uint32_t size) +{ + int i = 0; + perInterface_wlan_t *nic; + + /*BugID_5450*/ + /*Pass the frame on the monitor interface, if any.*/ + /*Otherwise, pass it on p2p0 netdev, if registered on it*/ + for (i = 0; i < g_linux_wlan->u8NoIfcs; i++) { + nic = netdev_priv(g_linux_wlan->strInterfaceInfo[i].wilc_netdev); + if (nic->monitor_flag) { + WILC_WFI_monitor_rx(buff, size); + return; + } + } + + #ifdef WILC_P2P + nic = netdev_priv(g_linux_wlan->strInterfaceInfo[1].wilc_netdev); /* p2p0 */ + if ((buff[0] == nic->g_struct_frame_reg[0].frame_type && nic->g_struct_frame_reg[0].reg) || + (buff[0] == nic->g_struct_frame_reg[1].frame_type && nic->g_struct_frame_reg[1].reg)) { + WILC_WFI_p2p_rx(g_linux_wlan->strInterfaceInfo[1].wilc_netdev, buff, size); + } + #endif +} + +int wilc_netdev_init(void) +{ + + int i; + perInterface_wlan_t *nic; + struct net_device *ndev; + + linux_wlan_init_lock("close_exit_sync", &close_exit_sync, 0); + + /*create the common structure*/ + g_linux_wlan = (linux_wlan_t *)WILC_MALLOC(sizeof(linux_wlan_t)); + memset(g_linux_wlan, 0, sizeof(linux_wlan_t)); + + /*Reset interrupt count debug*/ + int_rcvdU = 0; + int_rcvdB = 0; + int_clrd = 0; + #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP + register_inetaddr_notifier(&g_dev_notifier); + #endif + + for (i = 0; i < NUM_CONCURRENT_IFC; i++) { + /*allocate first ethernet device with perinterface_wlan_t as its private data*/ + ndev = alloc_etherdev(sizeof(perInterface_wlan_t)); + if (!ndev) { + PRINT_ER("Failed to allocate ethernet dev\n"); + return -1; + } + + nic = netdev_priv(ndev); + memset(nic, 0, sizeof(perInterface_wlan_t)); + + /*Name the Devices*/ + if (i == 0) { + #if defined(NM73131) /* tony, 2012-09-20 */ + strcpy(ndev->name, "wilc_eth%d"); + #elif defined(PLAT_CLM9722) /* rachel */ + strcpy(ndev->name, "eth%d"); + #else /* PANDA_BOARD, PLAT_ALLWINNER_A10, PLAT_ALLWINNER_A20, PLAT_ALLWINNER_A31, PLAT_AML8726_M3 or PLAT_WMS8304 */ + strcpy(ndev->name, "wlan%d"); + #endif + } else + strcpy(ndev->name, "p2p%d"); + + nic->u8IfIdx = g_linux_wlan->u8NoIfcs; + nic->wilc_netdev = ndev; + g_linux_wlan->strInterfaceInfo[g_linux_wlan->u8NoIfcs].wilc_netdev = ndev; + g_linux_wlan->u8NoIfcs++; + wilc_set_netdev_ops(ndev); + + #ifdef USE_WIRELESS + { + struct wireless_dev *wdev; + /*Register WiFi*/ + wdev = WILC_WFI_WiphyRegister(ndev); + + #ifdef WILC_SDIO + /* set netdev, tony */ + SET_NETDEV_DEV(ndev, &local_sdio_func->dev); + #endif + + if (wdev == NULL) { + PRINT_ER("Can't register WILC Wiphy\n"); + return -1; + } + + /*linking the wireless_dev structure with the netdevice*/ + nic->wilc_netdev->ieee80211_ptr = wdev; + nic->wilc_netdev->ml_priv = nic; + wdev->netdev = nic->wilc_netdev; + nic->netstats.rx_packets = 0; + nic->netstats.tx_packets = 0; + nic->netstats.rx_bytes = 0; + nic->netstats.tx_bytes = 0; + + } + #endif + + + if (register_netdev(ndev)) { + PRINT_ER("Device couldn't be registered - %s\n", ndev->name); + return -1; /* ERROR */ + } + + nic->iftype = STATION_MODE; + nic->mac_opened = 0; + + } + + #ifndef WILC_SDIO + if (!linux_spi_init(&g_linux_wlan->wilc_spidev)) { + PRINT_ER("Can't initialize SPI \n"); + return -1; /* ERROR */ + } + g_linux_wlan->wilc_spidev = wilc_spi_dev; + #else + g_linux_wlan->wilc_sdio_func = local_sdio_func; + #endif + + return 0; +} + + +/*The 1st function called after module inserted*/ +static int __init init_wilc_driver(void) +{ + + +#if defined (WILC_DEBUGFS) + if (wilc_debugfs_init() < 0) { + PRINT_D(GENERIC_DBG, "fail to create debugfs for wilc driver\n"); + return -1; + } +#endif + + printk("IN INIT FUNCTION\n"); + printk("*** WILC1000 driver VERSION=[%s] FW_VER=[%s] ***\n", __DRIVER_VERSION__, __DRIVER_VERSION__); + + linux_wlan_device_power(1); + msleep(100); + linux_wlan_device_detection(1); + +#ifdef WILC_SDIO + { + int ret; + + ret = sdio_register_driver(&wilc_bus); + if (ret < 0) { + PRINT_D(INIT_DBG, "init_wilc_driver: Failed register sdio driver\n"); + } + + return ret; + } +#else + PRINT_D(INIT_DBG, "Initializing netdev\n"); + if (wilc_netdev_init()) { + PRINT_ER("Couldn't initialize netdev\n"); + } + return 0; +#endif +} +late_initcall(init_wilc_driver); + +static void __exit exit_wilc_driver(void) +{ + int i = 0; + perInterface_wlan_t *nic[NUM_CONCURRENT_IFC]; + #define CLOSE_TIMEOUT (12 * 1000) + + if ((g_linux_wlan != NULL) && (((g_linux_wlan->strInterfaceInfo[0].wilc_netdev) != NULL) + || ((g_linux_wlan->strInterfaceInfo[1].wilc_netdev) != NULL))) { + #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP + unregister_inetaddr_notifier(&g_dev_notifier); + #endif + + for (i = 0; i < NUM_CONCURRENT_IFC; i++) { + nic[i] = netdev_priv(g_linux_wlan->strInterfaceInfo[i].wilc_netdev); + } + } + + + if ((g_linux_wlan != NULL) && g_linux_wlan->wilc_firmware != NULL) { + release_firmware(g_linux_wlan->wilc_firmware); + g_linux_wlan->wilc_firmware = NULL; + } + + + if ((g_linux_wlan != NULL) && (((g_linux_wlan->strInterfaceInfo[0].wilc_netdev) != NULL) + || ((g_linux_wlan->strInterfaceInfo[1].wilc_netdev) != NULL))) { + PRINT_D(INIT_DBG, "Waiting for mac_close ....\n"); + + if (linux_wlan_lock_timeout(&close_exit_sync, CLOSE_TIMEOUT) < 0) + PRINT_D(INIT_DBG, "Closed TimedOUT\n"); + else + PRINT_D(INIT_DBG, "mac_closed\n"); + + + for (i = 0; i < NUM_CONCURRENT_IFC; i++) { + /* close all opened interfaces */ + if (g_linux_wlan->strInterfaceInfo[i].wilc_netdev != NULL) { + if (nic[i]->mac_opened) { + mac_close(g_linux_wlan->strInterfaceInfo[i].wilc_netdev); + } + } + } + for (i = 0; i < NUM_CONCURRENT_IFC; i++) { + PRINT_D(INIT_DBG, "Unregistering netdev %p \n", g_linux_wlan->strInterfaceInfo[i].wilc_netdev); + unregister_netdev(g_linux_wlan->strInterfaceInfo[i].wilc_netdev); + #ifdef USE_WIRELESS + PRINT_D(INIT_DBG, "Freeing Wiphy...\n"); + WILC_WFI_WiphyFree(g_linux_wlan->strInterfaceInfo[i].wilc_netdev); + #endif + PRINT_D(INIT_DBG, "Freeing netdev...\n"); + free_netdev(g_linux_wlan->strInterfaceInfo[i].wilc_netdev); + } + } + + +#ifdef USE_WIRELESS +#ifdef WILC_AP_EXTERNAL_MLME + /* Bug 4600 : WILC_WFI_deinit_mon_interface was already called at mac_close */ + /* WILC_WFI_deinit_mon_interface(); */ +#endif +#endif + + /* if(g_linux_wlan->open_ifcs==0) */ + { + #ifndef WILC_SDIO + PRINT_D(INIT_DBG, "SPI unregsiter...\n"); + spi_unregister_driver(&wilc_bus); + #else + PRINT_D(INIT_DBG, "SDIO unregsiter...\n"); + sdio_unregister_driver(&wilc_bus); + #endif + + linux_wlan_deinit_lock(&close_exit_sync); + if (g_linux_wlan != NULL) { + WILC_FREE(g_linux_wlan); + g_linux_wlan = NULL; + } + printk("Module_exit Done.\n"); + +#if defined (WILC_DEBUGFS) + wilc_debugfs_remove(); +#endif + + linux_wlan_device_detection(0); + linux_wlan_device_power(0); + } +} +module_exit(exit_wilc_driver); + +MODULE_LICENSE("GPL"); +#endif diff --git a/drivers/staging/wilc1000/linux_wlan_common.h b/drivers/staging/wilc1000/linux_wlan_common.h new file mode 100644 index 000000000000..541f19cf44ae --- /dev/null +++ b/drivers/staging/wilc1000/linux_wlan_common.h @@ -0,0 +1,170 @@ +#ifndef LINUX_WLAN_COMMON_H +#define LINUX_WLAN_COMMON_H + +enum debug_region { + Generic_debug = 0, + Hostapd_debug, + Hostinf_debug, + CFG80211_debug, + Coreconfig_debug, + Interrupt_debug, + TX_debug, + RX_debug, + Lock_debug, + Tcp_enhance, + /*Added by amr - BugID_4720*/ + Spin_debug, + + Init_debug, + Bus_debug, + Mem_debug, + Firmware_debug, + COMP = 0xFFFFFFFF, +}; + +#define GENERIC_DBG (1 << Generic_debug) +#define HOSTAPD_DBG (1 << Hostapd_debug) +#define HOSTINF_DBG (1 << Hostinf_debug) +#define CORECONFIG_DBG (1 << Coreconfig_debug) +#define CFG80211_DBG (1 << CFG80211_debug) +#define INT_DBG (1 << Interrupt_debug) +#define TX_DBG (1 << TX_debug) +#define RX_DBG (1 << RX_debug) +#define LOCK_DBG (1 << Lock_debug) +#define TCP_ENH (1 << Tcp_enhance) + + +/*Added by Amr - BugID_4720*/ +#define SPIN_DEBUG (1 << Spin_debug) + +#define INIT_DBG (1 << Init_debug) +#define BUS_DBG (1 << Bus_debug) +#define MEM_DBG (1 << Mem_debug) +#define FIRM_DBG (1 << Firmware_debug) + +#if defined (WILC_DEBUGFS) +extern int wilc_debugfs_init(void); +extern void wilc_debugfs_remove(void); + +extern atomic_t REGION; +extern atomic_t DEBUG_LEVEL; + +#define DEBUG (1 << 0) +#define INFO (1 << 1) +#define WRN (1 << 2) +#define ERR (1 << 3) + +#define PRINT_D(region, ...) do { \ + if ((atomic_read(&DEBUG_LEVEL) & DEBUG) && ((atomic_read(®ION)) & (region))) { \ + printk("DBG [%s: %d]", __FUNCTION__, __LINE__); \ + printk(__VA_ARGS__); \ + } \ +} while (0) + +#define PRINT_INFO(region, ...) do { \ + if ((atomic_read(&DEBUG_LEVEL) & INFO) && ((atomic_read(®ION)) & (region))) { \ + printk("INFO [%s]", __FUNCTION__); \ + printk(__VA_ARGS__); \ + } \ +} while (0) + +#define PRINT_WRN(region, ...) do { \ + if ((atomic_read(&DEBUG_LEVEL) & WRN) && ((atomic_read(®ION)) & (region))) { \ + printk("WRN [%s: %d]", __FUNCTION__, __LINE__); \ + printk(__VA_ARGS__); \ + } \ +} while (0) + +#define PRINT_ER(...) do { \ + if ((atomic_read(&DEBUG_LEVEL) & ERR)) { \ + printk("ERR [%s: %d]", __FUNCTION__, __LINE__); \ + printk(__VA_ARGS__); \ + } \ +} while (0) + +#else + +#define REGION (INIT_DBG | GENERIC_DBG | CFG80211_DBG | FIRM_DBG | HOSTAPD_DBG) + +#define DEBUG 1 +#define INFO 0 +#define WRN 0 +#define PRINT_D(region, ...) do { if (DEBUG == 1 && ((REGION)&(region))) { \ + printk("DBG [%s: %d]", __FUNCTION__, __LINE__); \ + printk(__VA_ARGS__); \ + } \ + } while (0) + +#define PRINT_INFO(region, ...) do { if (INFO == 1 && ((REGION)&(region))) { \ + printk("INFO [%s]", __FUNCTION__); \ + printk(__VA_ARGS__); \ + } \ + } while (0) + +#define PRINT_WRN(region, ...) do { if (WRN == 1 && ((REGION)&(region))) { \ + printk("WRN [%s: %d]", __FUNCTION__, __LINE__); \ + printk(__VA_ARGS__); \ + } \ + } while (0) + +#define PRINT_ER(...) do { printk("ERR [%s: %d]", __FUNCTION__, __LINE__); \ + printk(__VA_ARGS__); \ + } while (0) +#endif + +#define FN_IN /* PRINT_D(">>> \n") */ +#define FN_OUT /* PRINT_D("<<<\n") */ + +#ifdef MEMORY_STATIC +#define LINUX_RX_SIZE (96 * 1024) +#endif +#define LINUX_TX_SIZE (64 * 1024) + + +#define WILC_MULTICAST_TABLE_SIZE 8 + +#if defined (NM73131_0_BOARD) + +#define MODALIAS "wilc_spi" +#define GPIO_NUM IRQ_WILC1000_GPIO + +#elif defined (BEAGLE_BOARD) + #define SPI_CHANNEL 4 + + #if SPI_CHANNEL == 4 + #define MODALIAS "wilc_spi4" + #define GPIO_NUM 162 + #else + #define MODALIAS "wilc_spi3" + #define GPIO_NUM 133 + #endif +#elif defined(PANDA_BOARD) + #define MODALIAS "WILC_SPI" + #define GPIO_NUM 139 +#elif defined(PLAT_WMS8304) /* rachel */ + #define MODALIAS "wilc_spi" + #define GPIO_NUM 139 +#elif defined (PLAT_RKXXXX) + #define MODALIAS "WILC_IRQ" + #define GPIO_NUM RK30_PIN3_PD2 /* RK30_PIN3_PA1 */ +/* RK30_PIN3_PD2 */ +/* RK2928_PIN1_PA7 */ + +#elif defined(CUSTOMER_PLATFORM) +/* + TODO : specify MODALIAS name and GPIO number. This is certainly necessary for SPI interface. + * + * ex) + * #define MODALIAS "WILC_SPI" + * #define GPIO_NUM 139 + */ + +#else +/* base on SAMA5D3_Xplained Board */ + #define MODALIAS "WILC_SPI" + #define GPIO_NUM 0x44 +#endif + + +void linux_wlan_enable_irq(void); +#endif diff --git a/drivers/staging/wilc1000/linux_wlan_sdio.c b/drivers/staging/wilc1000/linux_wlan_sdio.c new file mode 100644 index 000000000000..858e3a191bce --- /dev/null +++ b/drivers/staging/wilc1000/linux_wlan_sdio.c @@ -0,0 +1,249 @@ +#include "wilc_wfi_netdevice.h" + +#include +#include +#include +#include +#include + + + +#if defined (NM73131_0_BOARD) +#define SDIO_MODALIAS "wilc_sdio" +#else +#define SDIO_MODALIAS "wilc1000_sdio" +#endif + +#if defined (NM73131_0_BOARD) + #define MAX_SPEED 50000000 +#elif defined(CUSTOMER_PLATFORM) +/* TODO : User have to stable bus clock as user's environment. */ + #ifdef MAX_BUS_SPEED + #define MAX_SPEED MAX_BUS_SPEED + #else + #define MAX_SPEED 50000000 + #endif +#else + #define MAX_SPEED (6 * 1000000) /* Max 50M */ +#endif + + +struct sdio_func *local_sdio_func; +extern linux_wlan_t *g_linux_wlan; +extern int wilc_netdev_init(void); +extern int sdio_clear_int(void); +extern void wilc_handle_isr(void); + +static unsigned int sdio_default_speed; + +#define SDIO_VENDOR_ID_WILC 0x0296 +#define SDIO_DEVICE_ID_WILC 0x5347 + +static const struct sdio_device_id wilc_sdio_ids[] = { + { SDIO_DEVICE(SDIO_VENDOR_ID_WILC, SDIO_DEVICE_ID_WILC) }, +}; + + +static void wilc_sdio_interrupt(struct sdio_func *func) +{ +#ifndef WILC_SDIO_IRQ_GPIO + sdio_release_host(func); + wilc_handle_isr(); + sdio_claim_host(func); +#endif +} + + +int linux_sdio_cmd52(sdio_cmd52_t *cmd) +{ + struct sdio_func *func = g_linux_wlan->wilc_sdio_func; + int ret; + u8 data; + + sdio_claim_host(func); + + func->num = cmd->function; + if (cmd->read_write) { /* write */ + if (cmd->raw) { + sdio_writeb(func, cmd->data, cmd->address, &ret); + data = sdio_readb(func, cmd->address, &ret); + cmd->data = data; + } else { + sdio_writeb(func, cmd->data, cmd->address, &ret); + } + } else { /* read */ + data = sdio_readb(func, cmd->address, &ret); + cmd->data = data; + } + + sdio_release_host(func); + + if (ret < 0) { + PRINT_ER("wilc_sdio_cmd52..failed, err(%d)\n", ret); + return 0; + } + return 1; +} + + +int linux_sdio_cmd53(sdio_cmd53_t *cmd) +{ + struct sdio_func *func = g_linux_wlan->wilc_sdio_func; + int size, ret; + + sdio_claim_host(func); + + func->num = cmd->function; + func->cur_blksize = cmd->block_size; + if (cmd->block_mode) + size = cmd->count * cmd->block_size; + else + size = cmd->count; + + if (cmd->read_write) { /* write */ + ret = sdio_memcpy_toio(func, cmd->address, (void *)cmd->buffer, size); + } else { /* read */ + ret = sdio_memcpy_fromio(func, (void *)cmd->buffer, cmd->address, size); + } + + sdio_release_host(func); + + + if (ret < 0) { + PRINT_ER("wilc_sdio_cmd53..failed, err(%d)\n", ret); + return 0; + } + + return 1; +} + +volatile int probe; /* COMPLEMENT_BOOT */ +static int linux_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id) +{ + PRINT_D(INIT_DBG, "probe function\n"); + +#ifdef COMPLEMENT_BOOT + if (local_sdio_func != NULL) { + local_sdio_func = func; + probe = 1; + PRINT_D(INIT_DBG, "local_sdio_func isn't NULL\n"); + return 0; + } +#endif + PRINT_D(INIT_DBG, "Initializing netdev\n"); + local_sdio_func = func; + if (wilc_netdev_init()) { + PRINT_ER("Couldn't initialize netdev\n"); + return -1; + } + + printk("Driver Initializing success\n"); + return 0; +} + +static void linux_sdio_remove(struct sdio_func *func) +{ + /** + * TODO + **/ + +} + +struct sdio_driver wilc_bus = { + .name = SDIO_MODALIAS, + .id_table = wilc_sdio_ids, + .probe = linux_sdio_probe, + .remove = linux_sdio_remove, +}; + +int enable_sdio_interrupt(void) +{ + int ret = 0; +#ifndef WILC_SDIO_IRQ_GPIO + + sdio_claim_host(local_sdio_func); + ret = sdio_claim_irq(local_sdio_func, wilc_sdio_interrupt); + sdio_release_host(local_sdio_func); + + if (ret < 0) { + PRINT_ER("can't claim sdio_irq, err(%d)\n", ret); + ret = -EIO; + } +#endif + return ret; +} + +void disable_sdio_interrupt(void) +{ + +#ifndef WILC_SDIO_IRQ_GPIO + int ret; + + PRINT_D(INIT_DBG, "disable_sdio_interrupt IN\n"); + + sdio_claim_host(local_sdio_func); + ret = sdio_release_irq(local_sdio_func); + if (ret < 0) { + PRINT_ER("can't release sdio_irq, err(%d)\n", ret); + } + sdio_release_host(local_sdio_func); + + PRINT_D(INIT_DBG, "disable_sdio_interrupt OUT\n"); +#endif +} + +static int linux_sdio_set_speed(int speed) +{ + struct mmc_ios ios; + sdio_claim_host(local_sdio_func); + + memcpy((void *)&ios, (void *)&local_sdio_func->card->host->ios, sizeof(struct mmc_ios)); + local_sdio_func->card->host->ios.clock = speed; + ios.clock = speed; + local_sdio_func->card->host->ops->set_ios(local_sdio_func->card->host, &ios); + sdio_release_host(local_sdio_func); + PRINT_INFO(INIT_DBG, "@@@@@@@@@@@@ change SDIO speed to %d @@@@@@@@@\n", speed); + + return 1; +} + +static int linux_sdio_get_speed(void) +{ + return local_sdio_func->card->host->ios.clock; +} + +int linux_sdio_init(void *pv) +{ + + /** + * TODO : + **/ + + + sdio_default_speed = linux_sdio_get_speed(); + return 1; +} + +void linux_sdio_deinit(void *pv) +{ + + /** + * TODO : + **/ + + + sdio_unregister_driver(&wilc_bus); +} + +int linux_sdio_set_max_speed(void) +{ + return linux_sdio_set_speed(MAX_SPEED); +} + +int linux_sdio_set_default_speed(void) +{ + return linux_sdio_set_speed(sdio_default_speed); +} + + + diff --git a/drivers/staging/wilc1000/linux_wlan_sdio.h b/drivers/staging/wilc1000/linux_wlan_sdio.h new file mode 100644 index 000000000000..4b515f5108e7 --- /dev/null +++ b/drivers/staging/wilc1000/linux_wlan_sdio.h @@ -0,0 +1,14 @@ +extern struct sdio_func *local_sdio_func; +extern struct sdio_driver wilc_bus; + +#include + +int linux_sdio_init(void *); +void linux_sdio_deinit(void *); +int linux_sdio_cmd52(sdio_cmd52_t *cmd); +int linux_sdio_cmd53(sdio_cmd53_t *cmd); +int enable_sdio_interrupt(void); +void disable_sdio_interrupt(void); +int linux_sdio_set_max_speed(void); +int linux_sdio_set_default_speed(void); + diff --git a/drivers/staging/wilc1000/linux_wlan_spi.c b/drivers/staging/wilc1000/linux_wlan_spi.c new file mode 100644 index 000000000000..0c30bbb5fa65 --- /dev/null +++ b/drivers/staging/wilc1000/linux_wlan_spi.c @@ -0,0 +1,510 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "linux_wlan_common.h" + +#define USE_SPI_DMA 0 /* johnny add */ + +#ifdef WILC_ASIC_A0 + #if defined(PLAT_PANDA_ES_OMAP4460) + #define MIN_SPEED 12000000 + #define MAX_SPEED 24000000 + #elif defined(PLAT_WMS8304) + #define MIN_SPEED 12000000 + #define MAX_SPEED 24000000 /* 4000000 */ + #elif defined(CUSTOMER_PLATFORM) +/* + TODO : define Clock speed under 48M. + * + * ex) + * #define MIN_SPEED 24000000 + * #define MAX_SPEED 48000000 + */ + #else + #define MIN_SPEED 24000000 + #define MAX_SPEED 48000000 + #endif +#else /* WILC_ASIC_A0 */ +/* Limit clk to 6MHz on FPGA. */ + #define MIN_SPEED 6000000 + #define MAX_SPEED 6000000 +#endif /* WILC_ASIC_A0 */ + +static uint32_t SPEED = MIN_SPEED; + +struct spi_device *wilc_spi_dev; +void linux_spi_deinit(void *vp); + +static int __init wilc_bus_probe(struct spi_device *spi) +{ + + PRINT_D(BUS_DBG, "spiModalias: %s\n", spi->modalias); + PRINT_D(BUS_DBG, "spiMax-Speed: %d\n", spi->max_speed_hz); + wilc_spi_dev = spi; + + printk("Driver Initializing success\n"); + return 0; +} + +static int __exit wilc_bus_remove(struct spi_device *spi) +{ + + /* linux_spi_deinit(NULL); */ + + return 0; +} + +#ifdef CONFIG_OF +static const struct of_device_id wilc1000_of_match[] = { + { .compatible = "atmel,wilc_spi", }, + {} +}; +MODULE_DEVICE_TABLE(of, wilc1000_of_match); +#endif + +struct spi_driver wilc_bus __refdata = { + .driver = { + .name = MODALIAS, +#ifdef CONFIG_OF + .of_match_table = wilc1000_of_match, +#endif + }, + .probe = wilc_bus_probe, + .remove = __exit_p(wilc_bus_remove), +}; + + +void linux_spi_deinit(void *vp) +{ + + spi_unregister_driver(&wilc_bus); + + SPEED = MIN_SPEED; + PRINT_ER("@@@@@@@@@@@@ restore SPI speed to %d @@@@@@@@@\n", SPEED); + +} + + + +int linux_spi_init(void *vp) +{ + int ret = 1; + static int called; + + + if (called == 0) { + called++; + if (&wilc_bus == NULL) { + PRINT_ER("wilc_bus address is NULL\n"); + } + ret = spi_register_driver(&wilc_bus); + } + + /* change return value to match WILC interface */ + (ret < 0) ? (ret = 0) : (ret = 1); + + return ret; +} + +#if defined(PLAT_WMS8304) +#define TXRX_PHASE_SIZE (4096) +#endif + +#if defined (NM73131_0_BOARD) + +int linux_spi_write(uint8_t *b, uint32_t len) +{ + + int ret; + + if (len > 0 && b != NULL) { + struct spi_message msg; + PRINT_D(BUS_DBG, "Request writing %d bytes\n", len); + struct spi_transfer tr = { + .tx_buf = b, + .len = len, + .speed_hz = SPEED, + .delay_usecs = 0, + }; + + spi_message_init(&msg); + spi_message_add_tail(&tr, &msg); + ret = spi_sync(wilc_spi_dev, &msg); + if (ret < 0) { + PRINT_ER("SPI transaction failed\n"); + } + + } else { + PRINT_ER("can't write data with the following length: %d\n", len); + PRINT_ER("FAILED due to NULL buffer or ZERO length check the following length: %d\n", len); + ret = -1; + } + + /* change return value to match WILC interface */ + (ret < 0) ? (ret = 0) : (ret = 1); + + + return ret; +} + +#elif defined(TXRX_PHASE_SIZE) + +int linux_spi_write(uint8_t *b, uint32_t len) +{ + int ret; + if (len > 0 && b != NULL) { + int i = 0; + int blk = len / TXRX_PHASE_SIZE; + int remainder = len % TXRX_PHASE_SIZE; + + char *r_buffer = (char *) kzalloc(TXRX_PHASE_SIZE, GFP_KERNEL); + if (!r_buffer) { + PRINT_ER("Failed to allocate memory for r_buffer\n"); + } + + if (blk) { + while (i < blk) { + struct spi_message msg; + struct spi_transfer tr = { + .tx_buf = b + (i * TXRX_PHASE_SIZE), + /* .rx_buf = NULL, */ + .len = TXRX_PHASE_SIZE, + .speed_hz = SPEED, + .bits_per_word = 8, + .delay_usecs = 0, + }; + /* + * char *r_buffer = (char*) kzalloc(TXRX_PHASE_SIZE, GFP_KERNEL); + * if(! r_buffer){ + * PRINT_ER("Failed to allocate memory for r_buffer\n"); + * } + */ + tr.rx_buf = r_buffer; + + memset(&msg, 0, sizeof(msg)); + spi_message_init(&msg); + msg.spi = wilc_spi_dev; + msg.is_dma_mapped = USE_SPI_DMA; + + spi_message_add_tail(&tr, &msg); + ret = spi_sync(wilc_spi_dev, &msg); + if (ret < 0) { + PRINT_ER("SPI transaction failed\n"); + } + /* i += MJ_WRITE_SIZE; */ + i++; + + } + } + if (remainder) { + struct spi_message msg; + struct spi_transfer tr = { + .tx_buf = b + (blk * TXRX_PHASE_SIZE), + /* .rx_buf = NULL, */ + .len = remainder, + .speed_hz = SPEED, + .bits_per_word = 8, + .delay_usecs = 0, + }; + /* + * char *r_buffer = (char*) kzalloc(remainder, GFP_KERNEL); + * if(! r_buffer){ + * PRINT_ER("Failed to allocate memory for r_buffer\n"); + * } + */ + tr.rx_buf = r_buffer; + + memset(&msg, 0, sizeof(msg)); + spi_message_init(&msg); + msg.spi = wilc_spi_dev; + msg.is_dma_mapped = USE_SPI_DMA; /* rachel */ + + spi_message_add_tail(&tr, &msg); + ret = spi_sync(wilc_spi_dev, &msg); + if (ret < 0) { + PRINT_ER("SPI transaction failed\n"); + } + } + if (r_buffer) + kfree(r_buffer); + } else { + PRINT_ER("can't write data with the following length: %d\n", len); + PRINT_ER("FAILED due to NULL buffer or ZERO length check the following length: %d\n", len); + ret = -1; + } + + /* change return value to match WILC interface */ + (ret < 0) ? (ret = 0) : (ret = 1); + + return ret; + +} + +#else +int linux_spi_write(uint8_t *b, uint32_t len) +{ + + int ret; + struct spi_message msg; + + if (len > 0 && b != NULL) { + struct spi_transfer tr = { + .tx_buf = b, + /* .rx_buf = r_buffer, */ + .len = len, + .speed_hz = SPEED, + .delay_usecs = 0, + }; + char *r_buffer = (char *) kzalloc(len, GFP_KERNEL); + if (!r_buffer) { + PRINT_ER("Failed to allocate memory for r_buffer\n"); + } + tr.rx_buf = r_buffer; + PRINT_D(BUS_DBG, "Request writing %d bytes\n", len); + + memset(&msg, 0, sizeof(msg)); + spi_message_init(&msg); +/* [[johnny add */ + msg.spi = wilc_spi_dev; + msg.is_dma_mapped = USE_SPI_DMA; +/* ]] */ + spi_message_add_tail(&tr, &msg); + + ret = spi_sync(wilc_spi_dev, &msg); + if (ret < 0) { + PRINT_ER("SPI transaction failed\n"); + } + + kfree(r_buffer); + } else { + PRINT_ER("can't write data with the following length: %d\n", len); + PRINT_ER("FAILED due to NULL buffer or ZERO length check the following length: %d\n", len); + ret = -1; + } + + /* change return value to match WILC interface */ + (ret < 0) ? (ret = 0) : (ret = 1); + + + return ret; +} + +#endif + +#if defined (NM73131_0_BOARD) + +int linux_spi_read(unsigned char *rb, unsigned long rlen) +{ + + int ret; + + if (rlen > 0) { + struct spi_message msg; + struct spi_transfer tr = { + .rx_buf = rb, + .len = rlen, + .speed_hz = SPEED, + .delay_usecs = 0, + + }; + + spi_message_init(&msg); + spi_message_add_tail(&tr, &msg); + ret = spi_sync(wilc_spi_dev, &msg); + if (ret < 0) { + PRINT_ER("SPI transaction failed\n"); + } + } else { + PRINT_ER("can't read data with the following length: %ld\n", rlen); + ret = -1; + } + /* change return value to match WILC interface */ + (ret < 0) ? (ret = 0) : (ret = 1); + + return ret; +} + +#elif defined(TXRX_PHASE_SIZE) + +int linux_spi_read(unsigned char *rb, unsigned long rlen) +{ + int ret; + + if (rlen > 0) { + int i = 0; + + int blk = rlen / TXRX_PHASE_SIZE; + int remainder = rlen % TXRX_PHASE_SIZE; + + char *t_buffer = (char *) kzalloc(TXRX_PHASE_SIZE, GFP_KERNEL); + if (!t_buffer) { + PRINT_ER("Failed to allocate memory for t_buffer\n"); + } + + if (blk) { + while (i < blk) { + struct spi_message msg; + struct spi_transfer tr = { + /* .tx_buf = NULL, */ + .rx_buf = rb + (i * TXRX_PHASE_SIZE), + .len = TXRX_PHASE_SIZE, + .speed_hz = SPEED, + .bits_per_word = 8, + .delay_usecs = 0, + }; + tr.tx_buf = t_buffer; + + memset(&msg, 0, sizeof(msg)); + spi_message_init(&msg); + msg.spi = wilc_spi_dev; + msg.is_dma_mapped = USE_SPI_DMA; + + spi_message_add_tail(&tr, &msg); + ret = spi_sync(wilc_spi_dev, &msg); + if (ret < 0) { + PRINT_ER("SPI transaction failed\n"); + } + i++; + } + } + if (remainder) { + struct spi_message msg; + struct spi_transfer tr = { + /* .tx_buf = NULL, */ + .rx_buf = rb + (blk * TXRX_PHASE_SIZE), + .len = remainder, + .speed_hz = SPEED, + .bits_per_word = 8, + .delay_usecs = 0, + }; + /* + * char *t_buffer = (char*) kzalloc(remainder, GFP_KERNEL); + * if(! t_buffer){ + * PRINT_ER("Failed to allocate memory for t_buffer\n"); + * } + */ + tr.tx_buf = t_buffer; + + memset(&msg, 0, sizeof(msg)); + spi_message_init(&msg); + msg.spi = wilc_spi_dev; + msg.is_dma_mapped = USE_SPI_DMA; /* rachel */ + + spi_message_add_tail(&tr, &msg); + ret = spi_sync(wilc_spi_dev, &msg); + if (ret < 0) { + PRINT_ER("SPI transaction failed\n"); + } + } + + if (t_buffer) + kfree(t_buffer); + } else { + PRINT_ER("can't read data with the following length: %ld\n", rlen); + ret = -1; + } + /* change return value to match WILC interface */ + (ret < 0) ? (ret = 0) : (ret = 1); + + return ret; +} + +#else +int linux_spi_read(unsigned char *rb, unsigned long rlen) +{ + + int ret; + + if (rlen > 0) { + struct spi_message msg; + struct spi_transfer tr = { + /* .tx_buf = t_buffer, */ + .rx_buf = rb, + .len = rlen, + .speed_hz = SPEED, + .delay_usecs = 0, + + }; + char *t_buffer = (char *) kzalloc(rlen, GFP_KERNEL); + if (!t_buffer) { + PRINT_ER("Failed to allocate memory for t_buffer\n"); + } + tr.tx_buf = t_buffer; + + memset(&msg, 0, sizeof(msg)); + spi_message_init(&msg); +/* [[ johnny add */ + msg.spi = wilc_spi_dev; + msg.is_dma_mapped = USE_SPI_DMA; +/* ]] */ + spi_message_add_tail(&tr, &msg); + + ret = spi_sync(wilc_spi_dev, &msg); + if (ret < 0) { + PRINT_ER("SPI transaction failed\n"); + } + kfree(t_buffer); + } else { + PRINT_ER("can't read data with the following length: %ld\n", rlen); + ret = -1; + } + /* change return value to match WILC interface */ + (ret < 0) ? (ret = 0) : (ret = 1); + + return ret; +} + +#endif + +int linux_spi_write_read(unsigned char *wb, unsigned char *rb, unsigned int rlen) +{ + + int ret; + + if (rlen > 0) { + struct spi_message msg; + struct spi_transfer tr = { + .rx_buf = rb, + .tx_buf = wb, + .len = rlen, + .speed_hz = SPEED, + .bits_per_word = 8, + .delay_usecs = 0, + + }; + + memset(&msg, 0, sizeof(msg)); + spi_message_init(&msg); + msg.spi = wilc_spi_dev; + msg.is_dma_mapped = USE_SPI_DMA; + + spi_message_add_tail(&tr, &msg); + ret = spi_sync(wilc_spi_dev, &msg); + if (ret < 0) { + PRINT_ER("SPI transaction failed\n"); + } + } else { + PRINT_ER("can't read data with the following length: %d\n", rlen); + ret = -1; + } + /* change return value to match WILC interface */ + (ret < 0) ? (ret = 0) : (ret = 1); + + return ret; +} + +int linux_spi_set_max_speed(void) +{ + SPEED = MAX_SPEED; + + PRINT_INFO(BUS_DBG, "@@@@@@@@@@@@ change SPI speed to %d @@@@@@@@@\n", SPEED); + return 1; +} diff --git a/drivers/staging/wilc1000/linux_wlan_spi.h b/drivers/staging/wilc1000/linux_wlan_spi.h new file mode 100644 index 000000000000..0ecad477de1c --- /dev/null +++ b/drivers/staging/wilc1000/linux_wlan_spi.h @@ -0,0 +1,14 @@ +#ifndef LINUX_WLAN_SPI_H +#define LINUX_WLAN_SPI_H + +#include +extern struct spi_device *wilc_spi_dev; +extern struct spi_driver wilc_bus; + +int linux_spi_init(void *vp); +void linux_spi_deinit(void *vp); +int linux_spi_write(uint8_t *b, uint32_t len); +int linux_spi_read(uint8_t *rb, uint32_t rlen); +int linux_spi_write_read(unsigned char *wb, unsigned char *rb, unsigned int rlen); +int linux_spi_set_max_speed(void); +#endif diff --git a/drivers/staging/wilc1000/wilc_debugfs.c b/drivers/staging/wilc1000/wilc_debugfs.c new file mode 100644 index 000000000000..74b9fd5ba27b --- /dev/null +++ b/drivers/staging/wilc1000/wilc_debugfs.c @@ -0,0 +1,185 @@ +/* + * NewportMedia WiFi chipset driver test tools - wilc-debug + * Copyright (c) 2012 NewportMedia Inc. + * Author: SSW + * + * 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. + * + */ + +#if defined(WILC_DEBUGFS) +#include +#include +#include +#include + +#include "wilc_wlan_if.h" + + +static struct dentry *wilc_dir; + +/* + * -------------------------------------------------------------------------------- + */ + +#define DBG_REGION_ALL (GENERIC_DBG | HOSTAPD_DBG | HOSTINF_DBG | CORECONFIG_DBG | CFG80211_DBG | INT_DBG | TX_DBG | RX_DBG | LOCK_DBG | INIT_DBG | BUS_DBG | MEM_DBG) +#define DBG_LEVEL_ALL (DEBUG | INFO | WRN | ERR) +atomic_t REGION = ATOMIC_INIT(INIT_DBG | GENERIC_DBG | CFG80211_DBG | FIRM_DBG | HOSTAPD_DBG); +atomic_t DEBUG_LEVEL = ATOMIC_INIT(ERR); + +/* + * -------------------------------------------------------------------------------- + */ + + +static ssize_t wilc_debug_level_read(struct file *file, char __user *userbuf, size_t count, loff_t *ppos) +{ + char buf[128]; + int res = 0; + + /* only allow read from start */ + if (*ppos > 0) + return 0; + + res = scnprintf(buf, sizeof(buf), "Debug Level: %x\n", atomic_read(&DEBUG_LEVEL)); + + return simple_read_from_buffer(userbuf, count, ppos, buf, res); +} + +static ssize_t wilc_debug_level_write(struct file *filp, const char *buf, size_t count, loff_t *ppos) +{ + char buffer[128] = {}; + int flag = 0; + + if (copy_from_user(buffer, buf, count)) { + return -EFAULT; + } + + flag = buffer[0] - '0'; + + if (flag > 0) { + flag = DEBUG | ERR; + } else if (flag < 0) { + flag = 100; + } + + if (flag > DBG_LEVEL_ALL) { + printk("%s, value (0x%08x) is out of range, stay previous flag (0x%08x)\n", __func__, flag, atomic_read(&DEBUG_LEVEL)); + return -EFAULT; + } + + atomic_set(&DEBUG_LEVEL, (int)flag); + + if (flag == 0) { + printk("Debug-level disabled\n"); + } else { + printk("Debug-level enabled\n"); + } + return count; +} + +static ssize_t wilc_debug_region_read(struct file *file, char __user *userbuf, size_t count, loff_t *ppos) +{ + char buf[128]; + int res = 0; + + /* only allow read from start */ + if (*ppos > 0) + return 0; + + res = scnprintf(buf, sizeof(buf), "Debug region: %x\n", atomic_read(®ION)); + + return simple_read_from_buffer(userbuf, count, ppos, buf, res); +} + +static ssize_t wilc_debug_region_write(struct file *filp, const char *buf, size_t count, loff_t *ppos) +{ + char buffer[128] = {}; + int flag; + + if (copy_from_user(buffer, buf, count)) { + return -EFAULT; + } + + flag = buffer[0] - '0'; + + if (flag > DBG_REGION_ALL) { + printk("%s, value (0x%08x) is out of range, stay previous flag (0x%08x)\n", __func__, flag, atomic_read(®ION)); + return -EFAULT; + } + + atomic_set(®ION, (int)flag); + printk("new debug-region is %x\n", atomic_read(®ION)); + + return count; +} + +/* + * -------------------------------------------------------------------------------- + */ + +#define FOPS(_open, _read, _write, _poll) { \ + .owner = THIS_MODULE, \ + .open = (_open), \ + .read = (_read), \ + .write = (_write), \ + .poll = (_poll), \ +} + +struct wilc_debugfs_info_t { + const char *name; + int perm; + unsigned int data; + struct file_operations fops; +}; + +static struct wilc_debugfs_info_t debugfs_info[] = { + { "wilc_debug_level", 0666, (DEBUG | ERR), FOPS(NULL, wilc_debug_level_read, wilc_debug_level_write, NULL), }, + { "wilc_debug_region", 0666, (INIT_DBG | GENERIC_DBG | CFG80211_DBG), FOPS(NULL, wilc_debug_region_read, wilc_debug_region_write, NULL), }, +}; + +int wilc_debugfs_init(void) +{ + int i; + + struct dentry *debugfs_files; + struct wilc_debugfs_info_t *info; + + wilc_dir = debugfs_create_dir("wilc_wifi", NULL); + if (wilc_dir == ERR_PTR(-ENODEV)) { + /* it's not error. the debugfs is just not being enabled. */ + printk("ERR, kernel has built without debugfs support\n"); + return 0; + } + + if (!wilc_dir) { + printk("ERR, debugfs create dir\n"); + return -1; + } + + for (i = 0; i < ARRAY_SIZE(debugfs_info); i++) { + info = &debugfs_info[i]; + debugfs_files = debugfs_create_file(info->name, + info->perm, + wilc_dir, + &info->data, + &info->fops); + + if (!debugfs_files) { + printk("ERR fail to create the debugfs file, %s\n", info->name); + debugfs_remove_recursive(wilc_dir); + return -1; + } + } + return 0; +} + +void wilc_debugfs_remove(void) +{ + debugfs_remove_recursive(wilc_dir); +} + +#endif + diff --git a/drivers/staging/wilc1000/wilc_errorsupport.h b/drivers/staging/wilc1000/wilc_errorsupport.h new file mode 100644 index 000000000000..6405ef8ad431 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_errorsupport.h @@ -0,0 +1,84 @@ +#ifndef __WILC_ERRORSUPPORT_H__ +#define __WILC_ERRORSUPPORT_H__ + +/*! + * @file wilc_errorsupport.h + * @brief Error reporting and handling support + * @author syounan + * @sa wilc_oswrapper.h top level OS wrapper file + * @date 10 Aug 2010 + * @version 1.0 + */ + +#include "linux_wlan_common.h" + +/* Psitive Numbers to indicate sucess with special status */ +#define WILC_ALREADY_EXSIT (+100) /** The requested object already exists */ + +/* Generic success will return 0 */ +#define WILC_SUCCESS 0 /** Generic success */ + +/* Negative numbers to indicate failures */ +#define WILC_FAIL -100 /** Generic Fail */ +#define WILC_BUSY -101 /** Busy with another operation*/ +#define WILC_INVALID_ARGUMENT -102 /** A given argument is invalid*/ +#define WILC_INVALID_STATE -103 /** An API request would violate the Driver state machine (i.e. to start PID while not camped)*/ +#define WILC_BUFFER_OVERFLOW -104 /** In copy operations if the copied data is larger than the allocated buffer*/ +#define WILC_NULL_PTR -105 /** null pointer is passed or used */ +#define WILC_EMPTY -107 +#define WILC_FULL -108 +#define WILC_TIMEOUT -109 +#define WILC_CANCELED -110 /** The required operation have been canceled by the user*/ +#define WILC_INVALID_FILE -112 /** The Loaded file is corruped or having an invalid format */ +#define WILC_NOT_FOUND -113 /** Cant find the file to load */ +#define WILC_NO_MEM -114 +#define WILC_UNSUPPORTED_VERSION -115 +#define WILC_FILE_EOF -116 + + +/* Error type */ +typedef WILC_Sint32 WILC_ErrNo; + +#define WILC_IS_ERR(__status__) (__status__ < WILC_SUCCESS) + +#define WILC_ERRORCHECK(__status__) do { \ + if (WILC_IS_ERR(__status__)) { \ + PRINT_ER("PRINT_ER(%d)\n", __status__); \ + goto ERRORHANDLER; \ + } \ +} while (0) + +#define WILC_ERRORREPORT(__status__, __err__) do { \ + PRINT_ER("PRINT_ER(%d)\n", __err__); \ + __status__ = __err__; \ + goto ERRORHANDLER; \ +} while (0) + +#define WILC_NULLCHECK(__status__, __ptr__) do { \ + if (__ptr__ == WILC_NULL) { \ + WILC_ERRORREPORT(__status__, WILC_NULL_PTR); \ + } \ +} while (0) + +#define WILC_CATCH(__status__) \ +ERRORHANDLER: \ + if (WILC_IS_ERR(__status__)) \ + +#ifdef CONFIG_WILC_ASSERTION_SUPPORT + +/** + * @brief prints a diagnostic message and aborts the program + * @param[in] pcExpression The expression that triggered the assertion + * @param[in] pcFileName The name of the current source file. + * @param[in] u32LineNumber The line number in the current source file. + * @warning DO NOT CALL DIRECTLY. USE EQUIVALENT MACRO FUNCTION INSTEAD. + */ +void WILC_assert_INTERNAL(WILC_Char *pcExpression, WILC_Char *pcFileName, WILC_Uint32 u32LineNumber); + +#define WILC_assert(__expression__) (void)(!!(__expression__) || (WILC_assert_INTERNAL((# __expression__), __WILC_FILE__, __WILC_LINE__), 0)) + +#else +#define WILC_assert(__expression__) ((void)0) +#endif + +#endif diff --git a/drivers/staging/wilc1000/wilc_event.h b/drivers/staging/wilc1000/wilc_event.h new file mode 100644 index 000000000000..94e0f7c0bed5 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_event.h @@ -0,0 +1,123 @@ +#ifndef __WILC_EVENT_H__ +#define __WILC_EVENT_H__ + +/*! + * @file wilc_event.h + * @brief Event OS wrapper functionality + * @author syounan + * @sa wilc_oswrapper.h top level OS wrapper file + * @date 10 Oct 2010 + * @version 1.0 + */ + +#ifndef CONFIG_WILC_EVENT_FEATURE +#error the feature CONFIG_WILC_EVENT_FEATURE must be supported to include this file +#endif + + +/*! + * @struct tstrWILC_TimerAttrs + * @brief Timer API options + * @author syounan + * @date 10 Oct 2010 + * @version 1.0 + */ +typedef struct { + /* a dummy member to avoid compiler errors*/ + WILC_Uint8 dummy; + + #ifdef CONFIG_WILC_EVENT_TIMEOUT + /*!< + * Timeout for use with WILC_EventWait, 0 to return immediately and + * WILC_OS_INFINITY to wait forever. default is WILC_OS_INFINITY + */ + WILC_Uint32 u32TimeOut; + #endif + +} tstrWILC_EventAttrs; + +/*! + * @brief Fills the WILC_TimerAttrs with default parameters + * @param[out] pstrAttrs structure to be filled + * @sa WILC_TimerAttrs + * @author syounan + * @date 10 Oct 2010 + * @version 1.0 + */ +static void WILC_EventFillDefault(tstrWILC_EventAttrs *pstrAttrs) +{ + #ifdef CONFIG_WILC_EVENT_TIMEOUT + pstrAttrs->u32TimeOut = WILC_OS_INFINITY; + #endif +} + +/*! + * @brief Creates a new Event + * @details the Event is an object that allows a thread to wait until an external + * event occuers, Event objects have 2 states, either TRIGGERED or + * UNTRIGGERED + * @param[out] pHandle handle to the newly created event object + * @param[in] pstrAttrs Optional attributes, NULL for default + * @return Error code indicating sucess/failure + * @sa tstrWILC_EventAttrs + * @author syounan + * @date 10 Oct 2010 + * @version 1.0 + */ +WILC_ErrNo WILC_EventCreate(WILC_EventHandle *pHandle, tstrWILC_EventAttrs *pstrAttrs); + + +/*! + * @brief Destroys a given event + * @details This will destroy a given event freeing any resources used by it + * if there are any thread blocked by the WILC_EventWait call the the + * behaviour is undefined + * @param[in] pHandle handle to the event object + * @param[in] pstrAttrs Optional attributes, NULL for default + * @return Error code indicating sucess/failure + * @sa tstrWILC_EventAttrs + * @author syounan + * @date 10 Oct 2010 + * @version 1.0 + */ +WILC_ErrNo WILC_EventDestroy(WILC_EventHandle *pHandle, + tstrWILC_EventAttrs *pstrAttrs); + +/*! + * @brief Triggers a given event + * @details This function will set the given event into the TRIGGERED state, + * if the event is already in TRIGGERED, this function will have no + * effect + * @param[in] pHandle handle to the event object + * @param[in] pstrAttrs Optional attributes, NULL for default + * @return Error code indicating sucess/failure + * @sa tstrWILC_EventAttrs + * @author syounan + * @date 10 Oct 2010 + * @version 1.0 + */ +WILC_ErrNo WILC_EventTrigger(WILC_EventHandle *pHandle, + tstrWILC_EventAttrs *pstrAttrs); + + +/*! + * @brief waits until a given event is triggered + * @details This function will block the calling thread until the event becomes + * in the TRIGGERED state. the call will retun the event into the + * UNTRIGGERED state upon completion + * if multible threads are waiting on the same event at the same time, + * behaviour is undefined + * @param[in] pHandle handle to the event object + * @param[in] pstrAttrs Optional attributes, NULL for default + * @return Error code indicating sucess/failure + * @sa tstrWILC_EventAttrs + * @author syounan + * @date 10 Oct 2010 + * @version 1.0 + */ +WILC_ErrNo WILC_EventWait(WILC_EventHandle *pHandle, + tstrWILC_EventAttrs *pstrAttrs); + + + +#endif \ No newline at end of file diff --git a/drivers/staging/wilc1000/wilc_exported_buf.c b/drivers/staging/wilc1000/wilc_exported_buf.c new file mode 100644 index 000000000000..529457816f65 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_exported_buf.c @@ -0,0 +1,76 @@ +#include +#include +#include +#include +#include + +#define LINUX_RX_SIZE (96 * 1024) +#define LINUX_TX_SIZE (64 * 1024) +#define WILC1000_FW_SIZE (4 * 1024) + +#define DECLARE_WILC_BUFFER(name) \ + void *exported_ ## name = NULL; + +#define MALLOC_WILC_BUFFER(name, size) \ + exported_ ## name = kmalloc(size, GFP_KERNEL); \ + if (!exported_ ## name) { \ + printk("fail to alloc: %s memory\n", exported_ ## name); \ + return -ENOBUFS; \ + } + +#define FREE_WILC_BUFFER(name) \ + kfree(exported_ ## name); + +/* + * Add necessary buffer pointers + */ +DECLARE_WILC_BUFFER(g_tx_buf) +DECLARE_WILC_BUFFER(g_rx_buf) +DECLARE_WILC_BUFFER(g_fw_buf) + +void *get_tx_buffer(void) +{ + return exported_g_tx_buf; +} +EXPORT_SYMBOL(get_tx_buffer); + +void *get_rx_buffer(void) +{ + return exported_g_rx_buf; +} +EXPORT_SYMBOL(get_rx_buffer); + +void *get_fw_buffer(void) +{ + return exported_g_fw_buf; +} +EXPORT_SYMBOL(get_fw_buffer); + +static int __init wilc_module_init(void) +{ + printk("wilc_module_init\n"); + /* + * alloc necessary memory + */ + MALLOC_WILC_BUFFER(g_tx_buf, LINUX_TX_SIZE) + MALLOC_WILC_BUFFER(g_rx_buf, LINUX_RX_SIZE) + MALLOC_WILC_BUFFER(g_fw_buf, WILC1000_FW_SIZE) + + return 0; +} + +static void __exit wilc_module_deinit(void) +{ + printk("wilc_module_deinit\n"); + FREE_WILC_BUFFER(g_tx_buf) + FREE_WILC_BUFFER(g_rx_buf) + FREE_WILC_BUFFER(g_fw_buf) + + return; +} + +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_AUTHOR("Tony Cho"); +MODULE_DESCRIPTION("WILC1xxx Memory Manager"); +pure_initcall(wilc_module_init); +module_exit(wilc_module_deinit); \ No newline at end of file diff --git a/drivers/staging/wilc1000/wilc_log.h b/drivers/staging/wilc1000/wilc_log.h new file mode 100644 index 000000000000..2269ebdec129 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_log.h @@ -0,0 +1,47 @@ +#ifndef __WILC_LOG_H__ +#define __WILC_LOG_H__ + +/* Errors will always get printed */ +#define WILC_ERROR(...) do { WILC_PRINTF("(ERR)(%s:%d) ", __WILC_FUNCTION__, __WILC_LINE__); \ + WILC_PRINTF(__VA_ARGS__); \ + } while (0) + +/* Wraning only printed if verbosity is 1 or more */ +#if (WILC_LOG_VERBOSITY_LEVEL > 0) +#define WILC_WARN(...) do { WILC_PRINTF("(WRN)"); \ + WILC_PRINTF(__VA_ARGS__); \ + } while (0) +#else +#define WILC_WARN(...) (0) +#endif + +/* Info only printed if verbosity is 2 or more */ +#if (WILC_LOG_VERBOSITY_LEVEL > 1) +#define WILC_INFO(...) do { WILC_PRINTF("(INF)"); \ + WILC_PRINTF(__VA_ARGS__); \ + } while (0) +#else +#define WILC_INFO(...) (0) +#endif + +/* Debug is only printed if verbosity is 3 or more */ +#if (WILC_LOG_VERBOSITY_LEVEL > 2) +#define WILC_DBG(...) do { WILC_PRINTF("(DBG)(%s:%d) ", __WILC_FUNCTION__, __WILC_LINE__); \ + WILC_PRINTF(__VA_ARGS__); \ + } while (0) + +#else +#define WILC_DBG(...) (0) +#endif + +/* Function In/Out is only printed if verbosity is 4 or more */ +#if (WILC_LOG_VERBOSITY_LEVEL > 3) +#define WILC_FN_IN do { WILC_PRINTF("(FIN) (%s:%d) \n", __WILC_FUNCTION__, __WILC_LINE__); } while (0) +#define WILC_FN_OUT(ret) do { WILC_PRINTF("(FOUT) (%s:%d) %d.\n", __WILC_FUNCTION__, __WILC_LINE__, (ret)); } while (0) +#else +#define WILC_FN_IN (0) +#define WILC_FN_OUT(ret) (0) +#endif + + +#endif \ No newline at end of file diff --git a/drivers/staging/wilc1000/wilc_memory.c b/drivers/staging/wilc1000/wilc_memory.c new file mode 100644 index 000000000000..cf0976b443b8 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_memory.c @@ -0,0 +1,63 @@ + +#include "wilc_oswrapper.h" + +#ifdef CONFIG_WILC_MEMORY_FEATURE + + +/*! + * @author syounan + * @date 18 Aug 2010 + * @version 1.0 + */ +void *WILC_MemoryAlloc(WILC_Uint32 u32Size, tstrWILC_MemoryAttrs *strAttrs, + WILC_Char *pcFileName, WILC_Uint32 u32LineNo) +{ + if (u32Size > 0) { + return kmalloc(u32Size, GFP_ATOMIC); + } else { + return WILC_NULL; + } +} + +/*! + * @author syounan + * @date 18 Aug 2010 + * @version 1.0 + */ +void *WILC_MemoryCalloc(WILC_Uint32 u32Size, tstrWILC_MemoryAttrs *strAttrs, + WILC_Char *pcFileName, WILC_Uint32 u32LineNo) +{ + return kcalloc(u32Size, 1, GFP_KERNEL); +} + +/*! + * @author syounan + * @date 18 Aug 2010 + * @version 1.0 + */ +void *WILC_MemoryRealloc(void *pvOldBlock, WILC_Uint32 u32NewSize, + tstrWILC_MemoryAttrs *strAttrs, WILC_Char *pcFileName, WILC_Uint32 u32LineNo) +{ + if (u32NewSize == 0) { + kfree(pvOldBlock); + return WILC_NULL; + } else if (pvOldBlock == WILC_NULL) { + return kmalloc(u32NewSize, GFP_KERNEL); + } else { + return krealloc(pvOldBlock, u32NewSize, GFP_KERNEL); + } + +} + +/*! + * @author syounan + * @date 18 Aug 2010 + * @version 1.0 + */ +void WILC_MemoryFree(void *pvBlock, tstrWILC_MemoryAttrs *strAttrs, + WILC_Char *pcFileName, WILC_Uint32 u32LineNo) +{ + kfree(pvBlock); +} + +#endif diff --git a/drivers/staging/wilc1000/wilc_memory.h b/drivers/staging/wilc1000/wilc_memory.h new file mode 100644 index 000000000000..1e45641af454 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_memory.h @@ -0,0 +1,330 @@ +#ifndef __WILC_MEMORY_H__ +#define __WILC_MEMORY_H__ + +/*! + * @file wilc_memory.h + * @brief Memory OS wrapper functionality + * @author syounan + * @sa wilc_oswrapper.h top level OS wrapper file + * @date 16 Aug 2010 + * @version 1.0 + */ + +#ifndef CONFIG_WILC_MEMORY_FEATURE +#error the feature CONFIG_WILC_MEMORY_FEATURE must be supported to include this file +#endif + +/*! + * @struct tstrWILC_MemoryAttrs + * @brief Memory API options + * @author syounan + * @date 16 Aug 2010 + * @version 1.0 + */ +typedef struct { + #ifdef CONFIG_WILC_MEMORY_POOLS + /*!< the allocation pool to use for this memory, NULL for system + * allocation. Default is NULL + */ + WILC_MemoryPoolHandle *pAllocationPool; + #endif + + /* a dummy member to avoid compiler errors*/ + WILC_Uint8 dummy; +} tstrWILC_MemoryAttrs; + +/*! + * @brief Fills the tstrWILC_MemoryAttrs with default parameters + * @param[out] pstrAttrs structure to be filled + * @sa tstrWILC_MemoryAttrs + * @author syounan + * @date 16 Aug 2010 + * @version 1.0 + */ +static void WILC_MemoryFillDefault(tstrWILC_MemoryAttrs *pstrAttrs) +{ + #ifdef CONFIG_WILC_MEMORY_POOLS + pstrAttrs->pAllocationPool = WILC_NULL; + #endif +} + +/*! + * @brief Allocates a given size of bytes + * @param[in] u32Size size of memory in bytes to be allocated + * @param[in] strAttrs Optional attributes, NULL for default + * if not NULL, pAllocationPool should point to the pool to use for + * this allocation. if NULL memory will be allocated directly from + * the system + * @param[in] pcFileName file name of the calling code for debugging + * @param[in] u32LineNo line number of the calling code for debugging + * @return The new allocated block, NULL if allocation fails + * @note It is recommended to use of of the wrapper macros instead of + * calling this function directly + * @sa sttrWILC_MemoryAttrs + * @sa WILC_MALLOC + * @sa WILC_MALLOC_EX + * @sa WILC_NEW + * @sa WILC_NEW_EX + * @author syounan + * @date 16 Aug 2010 + * @version 1.0 + */ +void *WILC_MemoryAlloc(WILC_Uint32 u32Size, tstrWILC_MemoryAttrs *strAttrs, + WILC_Char *pcFileName, WILC_Uint32 u32LineNo); + +/*! + * @brief Allocates a given size of bytes and zero filling it + * @param[in] u32Size size of memory in bytes to be allocated + * @param[in] strAttrs Optional attributes, NULL for default + * if not NULL, pAllocationPool should point to the pool to use for + * this allocation. if NULL memory will be allocated directly from + * the system + * @param[in] pcFileName file name of the calling code for debugging + * @param[in] u32LineNo line number of the calling code for debugging + * @return The new allocated block, NULL if allocation fails + * @note It is recommended to use of of the wrapper macros instead of + * calling this function directly + * @sa sttrWILC_MemoryAttrs + * @sa WILC_CALLOC + * @sa WILC_CALLOC_EX + * @sa WILC_NEW_0 + * @sa WILC_NEW_0_EX + * @author syounan + * @date 16 Aug 2010 + * @version 1.0 + */ +void *WILC_MemoryCalloc(WILC_Uint32 u32Size, tstrWILC_MemoryAttrs *strAttrs, + WILC_Char *pcFileName, WILC_Uint32 u32LineNo); + +/*! + * @brief Reallocates a given block to a new size + * @param[in] pvOldBlock the old memory block, if NULL then this function + * behaves as a new allocation function + * @param[in] u32NewSize size of the new memory block in bytes, if zero then + * this function behaves as a free function + * @param[in] strAttrs Optional attributes, NULL for default + * if pAllocationPool!=NULL and pvOldBlock==NULL, pAllocationPool + * should point to the pool to use for this allocation. + * if pAllocationPool==NULL and pvOldBlock==NULL memory will be + * allocated directly from the system + * if and pvOldBlock!=NULL, pAllocationPool will not be inspected + * and reallocation is done from the same pool as the original block + * @param[in] pcFileName file name of the calling code for debugging + * @param[in] u32LineNo line number of the calling code for debugging + * @return The new allocated block, possibly same as pvOldBlock + * @note It is recommended to use of of the wrapper macros instead of + * calling this function directly + * @sa sttrWILC_MemoryAttrs + * @sa WILC_REALLOC + * @sa WILC_REALLOC_EX + * @author syounan + * @date 16 Aug 2010 + * @version 1.0 + */ +void *WILC_MemoryRealloc(void *pvOldBlock, WILC_Uint32 u32NewSize, + tstrWILC_MemoryAttrs *strAttrs, WILC_Char *pcFileName, WILC_Uint32 u32LineNo); + +/*! + * @brief Frees given block + * @param[in] pvBlock the memory block to be freed + * @param[in] strAttrs Optional attributes, NULL for default + * @param[in] pcFileName file name of the calling code for debugging + * @param[in] u32LineNo line number of the calling code for debugging + * @note It is recommended to use of of the wrapper macros instead of + * calling this function directly + * @sa sttrWILC_MemoryAttrs + * @sa WILC_FREE + * @sa WILC_FREE_EX + * @sa WILC_FREE_SET_NULL + * @sa WILC_FREE_IF_TRUE + * @author syounan + * @date 16 Aug 2010 + * @version 1.0 + */ +void WILC_MemoryFree(void *pvBlock, tstrWILC_MemoryAttrs *strAttrs, + WILC_Char *pcFileName, WILC_Uint32 u32LineNo); + +/*! + * @brief Creates a new memory pool + * @param[out] pHandle the handle to the new Pool + * @param[in] u32PoolSize The pool size in bytes + * @param[in] strAttrs Optional attributes, NULL for default + * @return Error code indicating sucess/failure + * @sa sttrWILC_MemoryAttrs + * @author syounan + * @date 16 Aug 2010 + * @version 1.0 + */ +WILC_ErrNo WILC_MemoryNewPool(WILC_MemoryPoolHandle *pHandle, WILC_Uint32 u32PoolSize, + tstrWILC_MemoryAttrs *strAttrs); + +/*! + * @brief Deletes a memory pool, freeing all memory allocated from it as well + * @param[in] pHandle the handle to the deleted Pool + * @param[in] strAttrs Optional attributes, NULL for default + * @return Error code indicating sucess/failure + * @sa sttrWILC_MemoryAttrs + * @author syounan + * @date 16 Aug 2010 + * @version 1.0 + */ +WILC_ErrNo WILC_MemoryDelPool(WILC_MemoryPoolHandle *pHandle, tstrWILC_MemoryAttrs *strAttrs); + + +#ifdef CONFIG_WILC_MEMORY_DEBUG + +/*! + * @brief standrad malloc wrapper with custom attributes + */ + #define WILC_MALLOC_EX(__size__, __attrs__) \ + (WILC_MemoryAlloc( \ + (__size__), __attrs__, \ + (WILC_Char *)__WILC_FILE__, (WILC_Uint32)__WILC_LINE__)) + +/*! + * @brief standrad calloc wrapper with custom attributes + */ + #define WILC_CALLOC_EX(__size__, __attrs__) \ + (WILC_MemoryCalloc( \ + (__size__), __attrs__, \ + (WILC_Char *)__WILC_FILE__, (WILC_Uint32)__WILC_LINE__)) + +/*! + * @brief standrad realloc wrapper with custom attributes + */ + #define WILC_REALLOC_EX(__ptr__, __new_size__, __attrs__) \ + (WILC_MemoryRealloc( \ + (__ptr__), (__new_size__), __attrs__, \ + (WILC_Char *)__WILC_FILE__, (WILC_Uint32)__WILC_LINE__)) + +/*! + * @brief standrad free wrapper with custom attributes + */ + #define WILC_FREE_EX(__ptr__, __attrs__) \ + (WILC_MemoryFree( \ + (__ptr__), __attrs__, \ + (WILC_Char *)__WILC_FILE__, (WILC_Uint32)__WILC_LINE__)) + +#else + +/*! + * @brief standrad malloc wrapper with custom attributes + */ + #define WILC_MALLOC_EX(__size__, __attrs__) \ + (WILC_MemoryAlloc( \ + (__size__), __attrs__, WILC_NULL, 0)) + +/*! + * @brief standrad calloc wrapper with custom attributes + */ + #define WILC_CALLOC_EX(__size__, __attrs__) \ + (WILC_MemoryCalloc( \ + (__size__), __attrs__, WILC_NULL, 0)) + +/*! + * @brief standrad realloc wrapper with custom attributes + */ + #define WILC_REALLOC_EX(__ptr__, __new_size__, __attrs__) \ + (WILC_MemoryRealloc( \ + (__ptr__), (__new_size__), __attrs__, WILC_NULL, 0)) +/*! + * @brief standrad free wrapper with custom attributes + */ + #define WILC_FREE_EX(__ptr__, __attrs__) \ + (WILC_MemoryFree( \ + (__ptr__), __attrs__, WILC_NULL, 0)) + +#endif + +/*! + * @brief Allocates a block (with custom attributes) of given type and number of + * elements + */ +#define WILC_NEW_EX(__struct_type__, __n_structs__, __attrs__) \ + ((__struct_type__ *)WILC_MALLOC_EX( \ + sizeof(__struct_type__) * (WILC_Uint32)(__n_structs__), __attrs__)) + +/*! + * @brief Allocates a block (with custom attributes) of given type and number of + * elements and Zero-fills it + */ +#define WILC_NEW_0_EX(__struct_type__, __n_structs__, __attrs__) \ + ((__struct_type__ *)WILC_CALLOC_EX( \ + sizeof(__struct_type__) * (WILC_Uint32)(__n_structs__), __attrs__)) + +/*! + * @brief Frees a block (with custom attributes), also setting the original pointer + * to NULL + */ +#define WILC_FREE_SET_NULL_EX(__ptr__, __attrs__) do { \ + if (__ptr__ != WILC_NULL) { \ + WILC_FREE_EX(__ptr__, __attrs__); \ + __ptr__ = WILC_NULL; \ + } \ +} while (0) + +/*! + * @brief Frees a block (with custom attributes) if the pointer expression evaluates + * to true + */ +#define WILC_FREE_IF_TRUE_EX(__ptr__, __attrs__) do { \ + if (__ptr__ != WILC_NULL) { \ + WILC_FREE_EX(__ptr__, __attrs__); \ + } \ +} while (0) + +/*! + * @brief standrad malloc wrapper with default attributes + */ +#define WILC_MALLOC(__size__) \ + WILC_MALLOC_EX(__size__, WILC_NULL) + +/*! + * @brief standrad calloc wrapper with default attributes + */ +#define WILC_CALLOC(__size__) \ + WILC_CALLOC_EX(__size__, WILC_NULL) + +/*! + * @brief standrad realloc wrapper with default attributes + */ +#define WILC_REALLOC(__ptr__, __new_size__) \ + WILC_REALLOC_EX(__ptr__, __new_size__, WILC_NULL) + +/*! + * @brief standrad free wrapper with default attributes + */ +#define WILC_FREE(__ptr__) \ + WILC_FREE_EX(__ptr__, WILC_NULL) + +/*! + * @brief Allocates a block (with default attributes) of given type and number of + * elements + */ +#define WILC_NEW(__struct_type__, __n_structs__) \ + WILC_NEW_EX(__struct_type__, __n_structs__, WILC_NULL) + +/*! + * @brief Allocates a block (with default attributes) of given type and number of + * elements and Zero-fills it + */ +#define WILC_NEW_0(__struct_type__, __n_structs__) \ + WILC_NEW_O_EX(__struct_type__, __n_structs__, WILC_NULL) + +/*! + * @brief Frees a block (with default attributes), also setting the original pointer + * to NULL + */ +#define WILC_FREE_SET_NULL(__ptr__) \ + WILC_FREE_SET_NULL_EX(__ptr__, WILC_NULL) + +/*! + * @brief Frees a block (with default attributes) if the pointer expression evaluates + * to true + */ +#define WILC_FREE_IF_TRUE(__ptr__) \ + WILC_FREE_IF_TRUE_EX(__ptr__, WILC_NULL) + + +#endif + diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c b/drivers/staging/wilc1000/wilc_msgqueue.c new file mode 100644 index 000000000000..c1d0dabed479 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_msgqueue.c @@ -0,0 +1,211 @@ + +#include "wilc_oswrapper.h" +#include +#ifdef CONFIG_WILC_MSG_QUEUE_FEATURE + + +/*! + * @author syounan + * @date 1 Sep 2010 + * @note copied from FLO glue implementatuion + * @version 1.0 + */ +WILC_ErrNo WILC_MsgQueueCreate(WILC_MsgQueueHandle *pHandle, + tstrWILC_MsgQueueAttrs *pstrAttrs) +{ + tstrWILC_SemaphoreAttrs strSemAttrs; + WILC_SemaphoreFillDefault(&strSemAttrs); + strSemAttrs.u32InitCount = 0; + + spin_lock_init(&pHandle->strCriticalSection); + if ((WILC_SemaphoreCreate(&pHandle->hSem, &strSemAttrs) == WILC_SUCCESS)) { + + pHandle->pstrMessageList = NULL; + pHandle->u32ReceiversCount = 0; + pHandle->bExiting = WILC_FALSE; + + return WILC_SUCCESS; + } else { + return WILC_FAIL; + } +} + +/*! + * @author syounan + * @date 1 Sep 2010 + * @note copied from FLO glue implementatuion + * @version 1.0 + */ +WILC_ErrNo WILC_MsgQueueDestroy(WILC_MsgQueueHandle *pHandle, + tstrWILC_MsgQueueAttrs *pstrAttrs) +{ + + pHandle->bExiting = WILC_TRUE; + + /* Release any waiting receiver thread. */ + while (pHandle->u32ReceiversCount > 0) { + WILC_SemaphoreRelease(&(pHandle->hSem), WILC_NULL); + pHandle->u32ReceiversCount--; + } + + WILC_SemaphoreDestroy(&pHandle->hSem, WILC_NULL); + + while (pHandle->pstrMessageList != NULL) { + Message *pstrMessge = pHandle->pstrMessageList->pstrNext; + WILC_FREE(pHandle->pstrMessageList); + pHandle->pstrMessageList = pstrMessge; + } + + return WILC_SUCCESS; +} + +/*! + * @author syounan + * @date 1 Sep 2010 + * @note copied from FLO glue implementatuion + * @version 1.0 + */ +WILC_ErrNo WILC_MsgQueueSend(WILC_MsgQueueHandle *pHandle, + const void *pvSendBuffer, WILC_Uint32 u32SendBufferSize, + tstrWILC_MsgQueueAttrs *pstrAttrs) +{ + WILC_ErrNo s32RetStatus = WILC_SUCCESS; + unsigned long flags; + Message *pstrMessage = NULL; + + if ((pHandle == NULL) || (u32SendBufferSize == 0) || (pvSendBuffer == NULL)) { + WILC_ERRORREPORT(s32RetStatus, WILC_INVALID_ARGUMENT); + } + + if (pHandle->bExiting == WILC_TRUE) { + WILC_ERRORREPORT(s32RetStatus, WILC_FAIL); + } + + spin_lock_irqsave(&pHandle->strCriticalSection, flags); + + /* construct a new message */ + pstrMessage = WILC_NEW(Message, 1); + WILC_NULLCHECK(s32RetStatus, pstrMessage); + pstrMessage->u32Length = u32SendBufferSize; + pstrMessage->pstrNext = NULL; + pstrMessage->pvBuffer = WILC_MALLOC(u32SendBufferSize); + WILC_NULLCHECK(s32RetStatus, pstrMessage->pvBuffer); + WILC_memcpy(pstrMessage->pvBuffer, pvSendBuffer, u32SendBufferSize); + + + /* add it to the message queue */ + if (pHandle->pstrMessageList == NULL) { + pHandle->pstrMessageList = pstrMessage; + } else { + Message *pstrTailMsg = pHandle->pstrMessageList; + while (pstrTailMsg->pstrNext != NULL) { + pstrTailMsg = pstrTailMsg->pstrNext; + } + pstrTailMsg->pstrNext = pstrMessage; + } + + spin_unlock_irqrestore(&pHandle->strCriticalSection, flags); + + WILC_SemaphoreRelease(&pHandle->hSem, WILC_NULL); + + WILC_CATCH(s32RetStatus) + { + /* error occured, free any allocations */ + if (pstrMessage != NULL) { + if (pstrMessage->pvBuffer != NULL) { + WILC_FREE(pstrMessage->pvBuffer); + } + WILC_FREE(pstrMessage); + } + } + + return s32RetStatus; +} + + + +/*! + * @author syounan + * @date 1 Sep 2010 + * @note copied from FLO glue implementatuion + * @version 1.0 + */ +WILC_ErrNo WILC_MsgQueueRecv(WILC_MsgQueueHandle *pHandle, + void *pvRecvBuffer, WILC_Uint32 u32RecvBufferSize, + WILC_Uint32 *pu32ReceivedLength, + tstrWILC_MsgQueueAttrs *pstrAttrs) +{ + + Message *pstrMessage; + WILC_ErrNo s32RetStatus = WILC_SUCCESS; + tstrWILC_SemaphoreAttrs strSemAttrs; + unsigned long flags; + if ((pHandle == NULL) || (u32RecvBufferSize == 0) + || (pvRecvBuffer == NULL) || (pu32ReceivedLength == NULL)) { + WILC_ERRORREPORT(s32RetStatus, WILC_INVALID_ARGUMENT); + } + + if (pHandle->bExiting == WILC_TRUE) { + WILC_ERRORREPORT(s32RetStatus, WILC_FAIL); + } + + spin_lock_irqsave(&pHandle->strCriticalSection, flags); + pHandle->u32ReceiversCount++; + spin_unlock_irqrestore(&pHandle->strCriticalSection, flags); + + WILC_SemaphoreFillDefault(&strSemAttrs); + #ifdef CONFIG_WILC_MSG_QUEUE_TIMEOUT + if (pstrAttrs != WILC_NULL) { + strSemAttrs.u32TimeOut = pstrAttrs->u32Timeout; + } + #endif + s32RetStatus = WILC_SemaphoreAcquire(&(pHandle->hSem), &strSemAttrs); + if (s32RetStatus == WILC_TIMEOUT) { + /* timed out, just exit without consumeing the message */ + spin_lock_irqsave(&pHandle->strCriticalSection, flags); + pHandle->u32ReceiversCount--; + spin_unlock_irqrestore(&pHandle->strCriticalSection, flags); + } else { + /* other non-timeout scenarios */ + WILC_ERRORCHECK(s32RetStatus); + + if (pHandle->bExiting) { + WILC_ERRORREPORT(s32RetStatus, WILC_FAIL); + } + + spin_lock_irqsave(&pHandle->strCriticalSection, flags); + + pstrMessage = pHandle->pstrMessageList; + if (pstrMessage == NULL) { + spin_unlock_irqrestore(&pHandle->strCriticalSection, flags); + WILC_ERRORREPORT(s32RetStatus, WILC_FAIL); + } + /* check buffer size */ + if (u32RecvBufferSize < pstrMessage->u32Length) { + spin_unlock_irqrestore(&pHandle->strCriticalSection, flags); + WILC_SemaphoreRelease(&pHandle->hSem, WILC_NULL); + WILC_ERRORREPORT(s32RetStatus, WILC_BUFFER_OVERFLOW); + } + + /* consume the message */ + pHandle->u32ReceiversCount--; + WILC_memcpy(pvRecvBuffer, pstrMessage->pvBuffer, pstrMessage->u32Length); + *pu32ReceivedLength = pstrMessage->u32Length; + + pHandle->pstrMessageList = pstrMessage->pstrNext; + + WILC_FREE(pstrMessage->pvBuffer); + WILC_FREE(pstrMessage); + + spin_unlock_irqrestore(&pHandle->strCriticalSection, flags); + + } + + WILC_CATCH(s32RetStatus) + { + } + + return s32RetStatus; +} + +#endif diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h b/drivers/staging/wilc1000/wilc_msgqueue.h new file mode 100644 index 000000000000..a48be533aad9 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_msgqueue.h @@ -0,0 +1,133 @@ +#ifndef __WILC_MSG_QUEUE_H__ +#define __WILC_MSG_QUEUE_H__ + +/*! + * @file wilc_msgqueue.h + * @brief Message Queue OS wrapper functionality + * @author syounan + * @sa wilc_oswrapper.h top level OS wrapper file + * @date 30 Aug 2010 + * @version 1.0 + */ + +#ifndef CONFIG_WILC_MSG_QUEUE_FEATURE +#error the feature CONFIG_WILC_MSG_QUEUE_FEATURE must be supported to include this file +#endif + +/*! + * @struct tstrWILC_MsgQueueAttrs + * @brief Message Queue API options + * @author syounan + * @date 30 Aug 2010 + * @version 1.0 + */ +typedef struct { + #ifdef CONFIG_WILC_MSG_QUEUE_IPC_NAME + WILC_Char *pcName; + #endif + + #ifdef CONFIG_WILC_MSG_QUEUE_TIMEOUT + WILC_Uint32 u32Timeout; + #endif + + /* a dummy member to avoid compiler errors*/ + WILC_Uint8 dummy; + +} tstrWILC_MsgQueueAttrs; + +/*! + * @brief Fills the MsgQueueAttrs with default parameters + * @param[out] pstrAttrs structure to be filled + * @sa WILC_TimerAttrs + * @author syounan + * @date 30 Aug 2010 + * @version 1.0 + */ +static void WILC_MsgQueueFillDefault(tstrWILC_MsgQueueAttrs *pstrAttrs) +{ + #ifdef CONFIG_WILC_MSG_QUEUE_IPC_NAME + pstrAttrs->pcName = WILC_NULL; + #endif + + #ifdef CONFIG_WILC_MSG_QUEUE_TIMEOUT + pstrAttrs->u32Timeout = WILC_OS_INFINITY; + #endif +} +/*! + * @brief Creates a new Message queue + * @details Creates a new Message queue, if the feature + * CONFIG_WILC_MSG_QUEUE_IPC_NAME is enabled and pstrAttrs->pcName + * is not Null, then this message queue can be used for IPC with + * any other message queue having the same name in the system + * @param[in,out] pHandle handle to the message queue object + * @param[in] pstrAttrs Optional attributes, NULL for default + * @return Error code indicating sucess/failure + * @sa tstrWILC_MsgQueueAttrs + * @author syounan + * @date 30 Aug 2010 + * @version 1.0 + */ +WILC_ErrNo WILC_MsgQueueCreate(WILC_MsgQueueHandle *pHandle, + tstrWILC_MsgQueueAttrs *pstrAttrs); + + +/*! + * @brief Sends a message + * @details Sends a message, this API will block unil the message is + * actually sent or until it is timedout (as long as the feature + * CONFIG_WILC_MSG_QUEUE_TIMEOUT is enabled and pstrAttrs->u32Timeout + * is not set to WILC_OS_INFINITY), zero timeout is a valid value + * @param[in] pHandle handle to the message queue object + * @param[in] pvSendBuffer pointer to the data to send + * @param[in] u32SendBufferSize the size of the data to send + * @param[in] pstrAttrs Optional attributes, NULL for default + * @return Error code indicating sucess/failure + * @sa tstrWILC_MsgQueueAttrs + * @author syounan + * @date 30 Aug 2010 + * @version 1.0 + */ +WILC_ErrNo WILC_MsgQueueSend(WILC_MsgQueueHandle *pHandle, + const void *pvSendBuffer, WILC_Uint32 u32SendBufferSize, + tstrWILC_MsgQueueAttrs *pstrAttrs); + + +/*! + * @brief Receives a message + * @details Receives a message, this API will block unil a message is + * received or until it is timedout (as long as the feature + * CONFIG_WILC_MSG_QUEUE_TIMEOUT is enabled and pstrAttrs->u32Timeout + * is not set to WILC_OS_INFINITY), zero timeout is a valid value + * @param[in] pHandle handle to the message queue object + * @param[out] pvRecvBuffer pointer to a buffer to fill with the received message + * @param[in] u32RecvBufferSize the size of the receive buffer + * @param[out] pu32ReceivedLength the length of received data + * @param[in] pstrAttrs Optional attributes, NULL for default + * @return Error code indicating sucess/failure + * @sa tstrWILC_MsgQueueAttrs + * @author syounan + * @date 30 Aug 2010 + * @version 1.0 + */ +WILC_ErrNo WILC_MsgQueueRecv(WILC_MsgQueueHandle *pHandle, + void *pvRecvBuffer, WILC_Uint32 u32RecvBufferSize, + WILC_Uint32 *pu32ReceivedLength, + tstrWILC_MsgQueueAttrs *pstrAttrs); + + +/*! + * @brief Destroys an existing Message queue + * @param[in] pHandle handle to the message queue object + * @param[in] pstrAttrs Optional attributes, NULL for default + * @return Error code indicating sucess/failure + * @sa tstrWILC_MsgQueueAttrs + * @author syounan + * @date 30 Aug 2010 + * @version 1.0 + */ +WILC_ErrNo WILC_MsgQueueDestroy(WILC_MsgQueueHandle *pHandle, + tstrWILC_MsgQueueAttrs *pstrAttrs); + + + +#endif diff --git a/drivers/staging/wilc1000/wilc_osconfig.h b/drivers/staging/wilc1000/wilc_osconfig.h new file mode 100644 index 000000000000..8e89702c79be --- /dev/null +++ b/drivers/staging/wilc1000/wilc_osconfig.h @@ -0,0 +1,55 @@ +/* + * Automatically generated C config: don't edit + * Tue Aug 10 19:52:12 2010 + */ + +/* OSes supported */ +#define WILC_WIN32 0 +#define WILC_NU 1 +#define WILC_MTK 2 +#define WILC_LINUX 3 +#define WILC_LINUXKERNEL 4 +/* the current OS */ +/* #define WILC_PLATFORM WILC_LINUXKERNEL */ + + +/* Logs options */ +#define WILC_LOGS_NOTHING 0 +#define WILC_LOGS_WARN 1 +#define WILC_LOGS_WARN_INFO 2 +#define WILC_LOGS_WARN_INFO_DBG 3 +#define WILC_LOGS_WARN_INFO_DBG_FN 4 +#define WILC_LOGS_ALL 5 + +#define WILC_LOG_VERBOSITY_LEVEL WILC_LOGS_ALL + +/* OS features supported */ + +#define CONFIG_WILC_THREAD_FEATURE 1 +/* #define CONFIG_WILC_THREAD_SUSPEND_CONTROL 1 */ +/* #define CONFIG_WILC_THREAD_STRICT_PRIORITY 1 */ +#define CONFIG_WILC_SEMAPHORE_FEATURE 1 +/* #define CONFIG_WILC_SEMAPHORE_TIMEOUT 1 */ +#define CONFIG_WILC_SLEEP_FEATURE 1 +#define CONFIG_WILC_SLEEP_HI_RES 1 +#define CONFIG_WILC_TIMER_FEATURE 1 +/* #define CONFIG_WILC_TIMER_PERIODIC 1 */ +#define CONFIG_WILC_MEMORY_FEATURE 1 +/* #define CONFIG_WILC_MEMORY_POOLS 1 */ +/* #define CONFIG_WILC_MEMORY_DEBUG 1 */ +/* #define CONFIG_WILC_ASSERTION_SUPPORT 1 */ +#define CONFIG_WILC_STRING_UTILS 1 +#define CONFIG_WILC_MSG_QUEUE_FEATURE +/* #define CONFIG_WILC_MSG_QUEUE_IPC_NAME */ +/* #define CONFIG_WILC_MSG_QUEUE_TIMEOUT */ +/* #define CONFIG_WILC_FILE_OPERATIONS_FEATURE */ +/* #define CONFIG_WILC_FILE_OPERATIONS_STRING_API */ +/* #define CONFIG_WILC_FILE_OPERATIONS_PATH_API */ +#define CONFIG_WILC_TIME_FEATURE +/* #define CONFIG_WILC_EVENT_FEATURE */ +/* #define CONFIG_WILC_EVENT_TIMEOUT */ +/* #define CONFIG_WILC_SOCKET_FEATURE */ +/* #define CONFIG_WILC_MATH_OPERATIONS_FEATURE */ +/* #define CONFIG_WILC_EXTENDED_FILE_OPERATIONS */ +/* #define CONFIG_WILC_EXTENDED_STRING_OPERATIONS */ +/* #define CONFIG_WILC_EXTENDED_TIME_OPERATIONS */ diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h new file mode 100644 index 000000000000..e50267ec1ef4 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -0,0 +1,133 @@ +#ifndef __WILC_OSWRAPPER_H__ +#define __WILC_OSWRAPPER_H__ + +/*! + * @file wilc_oswrapper.h + * @brief Top level OS Wrapper, include this file and it will include all + * other files as necessary + * @author syounan + * @date 10 Aug 2010 + * @version 1.0 + */ + +/* OS Wrapper interface version */ +#define WILC_OSW_INTERFACE_VER 2 + +/* Integer Types */ +typedef unsigned char WILC_Uint8; +typedef unsigned short WILC_Uint16; +typedef unsigned int WILC_Uint32; +typedef unsigned long long WILC_Uint64; +typedef signed char WILC_Sint8; +typedef signed short WILC_Sint16; +typedef signed int WILC_Sint32; +typedef signed long long WILC_Sint64; + +/* Floating types */ +typedef float WILC_Float; +typedef double WILC_Double; + +/* Boolean type */ +typedef enum { + WILC_FALSE = 0, + WILC_TRUE = 1 +} WILC_Bool; + +/* Character types */ +typedef char WILC_Char; +typedef WILC_Uint16 WILC_WideChar; + +#define WILC_OS_INFINITY (~((WILC_Uint32)0)) +#define WILC_NULL ((void *)0) + +/* standard min and max macros */ +#define WILC_MIN(a, b) (((a) < (b)) ? (a) : (b)) +#define WILC_MAX(a, b) (((a) > (b)) ? (a) : (b)) + +/* Os Configuration File */ +#include "wilc_osconfig.h" + +/* Platform specific include */ +#if WILC_PLATFORM == WILC_WIN32 +#include "wilc_platform.h" +#elif WILC_PLATFORM == WILC_NU +#include "wilc_platform.h" +#elif WILC_PLATFORM == WILC_MTK +#include "wilc_platform.h" +#elif WILC_PLATFORM == WILC_LINUX +#include "wilc_platform.h" +#elif WILC_PLATFORM == WILC_LINUXKERNEL +#include "wilc_platform.h" +#else +#error "OS not supported" +#endif + +/* Logging Functions */ +#include "wilc_log.h" + +/* Error reporting and handling support */ +#include "wilc_errorsupport.h" + +/* Thread support */ +#ifdef CONFIG_WILC_THREAD_FEATURE +#include "wilc_thread.h" +#endif + +/* Semaphore support */ +#ifdef CONFIG_WILC_SEMAPHORE_FEATURE +#include "wilc_semaphore.h" +#endif + +/* Sleep support */ +#ifdef CONFIG_WILC_SLEEP_FEATURE +#include "wilc_sleep.h" +#endif + +/* Timer support */ +#ifdef CONFIG_WILC_TIMER_FEATURE +#include "wilc_timer.h" +#endif + +/* Memory support */ +#ifdef CONFIG_WILC_MEMORY_FEATURE +#include "wilc_memory.h" +#endif + +/* String Utilities */ +#ifdef CONFIG_WILC_STRING_UTILS +#include "wilc_strutils.h" +#endif + +/* Message Queue */ +#ifdef CONFIG_WILC_MSG_QUEUE_FEATURE +#include "wilc_msgqueue.h" +#endif + +/* File operations */ +#ifdef CONFIG_WILC_FILE_OPERATIONS_FEATURE +#include "wilc_fileops.h" +#endif + +/* Time operations */ +#ifdef CONFIG_WILC_TIME_FEATURE +#include "wilc_time.h" +#endif + +/* Event support */ +#ifdef CONFIG_WILC_EVENT_FEATURE +#include "wilc_event.h" +#endif + +/* Socket operations */ +#ifdef CONFIG_WILC_SOCKET_FEATURE +#include "wilc_socket.h" +#endif + +/* Math operations */ +#ifdef CONFIG_WILC_MATH_OPERATIONS_FEATURE +#include "wilc_math.h" +#endif + + + +#endif diff --git a/drivers/staging/wilc1000/wilc_platform.h b/drivers/staging/wilc1000/wilc_platform.h new file mode 100644 index 000000000000..31d5034cb7fa --- /dev/null +++ b/drivers/staging/wilc1000/wilc_platform.h @@ -0,0 +1,181 @@ +#ifndef __WILC_platfrom_H__ +#define __WILC_platfrom_H__ + +/*! + * @file wilc_platform.h + * @brief platform specific file for Linux port + * @author syounan + * @sa wilc_oswrapper.h top level OS wrapper file + * @date 15 Dec 2010 + * @version 1.0 + */ + + +/****************************************************************** + * Feature support checks + *******************************************************************/ + +/* CONFIG_WILC_THREAD_FEATURE is implemented */ + +/* remove the following block when implementing its feature */ +#ifdef CONFIG_WILC_THREAD_SUSPEND_CONTROL +#error This feature is not supported by this OS +#endif + +/* remove the following block when implementing its feature */ +#ifdef CONFIG_WILC_THREAD_STRICT_PRIORITY +#error This feature is not supported by this OS +#endif + +/* CONFIG_WILC_SEMAPHORE_FEATURE is implemented */ + +/* remove the following block when implementing its feature + * #ifdef CONFIG_WILC_SEMAPHORE_TIMEOUT + * #error This feature is not supported by this OS + #endif*/ + +/* CONFIG_WILC_SLEEP_FEATURE is implemented */ + +/* remove the following block when implementing its feature */ +/* #ifdef CONFIG_WILC_SLEEP_HI_RES */ +/* #error This feature is not supported by this OS */ +/* #endif */ + +/* CONFIG_WILC_TIMER_FEATURE is implemented */ + +/* CONFIG_WILC_TIMER_PERIODIC is implemented */ + +/* CONFIG_WILC_MEMORY_FEATURE is implemented */ + +/* remove the following block when implementing its feature */ +#ifdef CONFIG_WILC_MEMORY_POOLS +#error This feature is not supported by this OS +#endif + +/* remove the following block when implementing its feature */ +#ifdef CONFIG_WILC_MEMORY_DEBUG +#error This feature is not supported by this OS +#endif + +/* remove the following block when implementing its feature */ +#ifdef CONFIG_WILC_ASSERTION_SUPPORT +#error This feature is not supported by this OS +#endif + +/* CONFIG_WILC_STRING_UTILS is implemented */ + +/* CONFIG_WILC_MSG_QUEUE_FEATURE is implemented */ + +/* remove the following block when implementing its feature */ +#ifdef CONFIG_WILC_MSG_QUEUE_IPC_NAME +#error This feature is not supported by this OS +#endif + +/* remove the following block when implementing its feature */ +/*#ifdef CONFIG_WILC_MSG_QUEUE_TIMEOUT + * #error This feature is not supported by this OS + #endif*/ + +/* CONFIG_WILC_FILE_OPERATIONS_FEATURE is implemented */ + +/* CONFIG_WILC_FILE_OPERATIONS_STRING_API is implemented */ + +/* remove the following block when implementing its feature */ +#ifdef CONFIG_WILC_FILE_OPERATIONS_PATH_API +#error This feature is not supported by this OS +#endif + +/* CONFIG_WILC_TIME_FEATURE is implemented */ + +/* remove the following block when implementing its feature */ +#ifdef CONFIG_WILC_TIME_UTC_SINCE_1970 +#error This feature is not supported by this OS +#endif + +/* remove the following block when implementing its feature */ +#ifdef CONFIG_WILC_TIME_CALENDER +#error This feature is not supported by this OS +#endif + +/* remove the following block when implementing its feature */ +#ifdef CONFIG_WILC_EVENT_FEATURE +#error This feature is not supported by this OS +#endif + +/* remove the following block when implementing its feature */ +#ifdef CONFIG_WILC_EVENT_TIMEOUT +#error This feature is not supported by this OS +#endif + +/* CONFIG_WILC_MATH_OPERATIONS_FEATURE is implemented */ + +/* CONFIG_WILC_EXTENDED_FILE_OPERATIONS is implemented */ + +/* CONFIG_WILC_EXTENDED_STRING_OPERATIONS is implemented */ + +/* CONFIG_WILC_EXTENDED_TIME_OPERATIONS is implemented */ + +/* remove the following block when implementing its feature */ +#ifdef CONFIG_WILC_SOCKET_FEATURE +#error This feature is not supported by this OS +#endif + +/****************************************************************** + * OS specific includes + *******************************************************************/ +#define _XOPEN_SOURCE 600 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "linux/string.h" +/****************************************************************** + * OS specific types + *******************************************************************/ + +typedef struct task_struct *WILC_ThreadHandle; + +typedef void *WILC_MemoryPoolHandle; +typedef struct semaphore WILC_SemaphoreHandle; + +typedef struct timer_list WILC_TimerHandle; + + + +/* Message Queue type is a structure */ +typedef struct __Message_struct { + void *pvBuffer; + WILC_Uint32 u32Length; + struct __Message_struct *pstrNext; +} Message; + +typedef struct __MessageQueue_struct { + WILC_SemaphoreHandle hSem; + spinlock_t strCriticalSection; + WILC_Bool bExiting; + WILC_Uint32 u32ReceiversCount; + Message *pstrMessageList; +} WILC_MsgQueueHandle; + + + +/*Time represented in 64 bit format*/ +typedef time_t WILC_Time; + + +/******************************************************************* + * others + ********************************************************************/ + +/* Generic printf function */ +#define __WILC_FILE__ __FILE__ +#define __WILC_FUNCTION__ __FUNCTION__ +#define __WILC_LINE__ __LINE__ +#endif diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c new file mode 100644 index 000000000000..d96abb05a83e --- /dev/null +++ b/drivers/staging/wilc1000/wilc_sdio.c @@ -0,0 +1,1298 @@ +/* ////////////////////////////////////////////////////////////////////////// */ +/* */ +/* Copyright (c) Atmel Corporation. All rights reserved. */ +/* */ +/* Module Name: wilc_sdio.c */ +/* */ +/* */ +/* //////////////////////////////////////////////////////////////////////////// */ + +#include "wilc_wlan_if.h" +#include "wilc_wlan.h" + + +#ifdef WILC1000_SINGLE_TRANSFER +#define WILC_SDIO_BLOCK_SIZE 256 +#else + #if defined(PLAT_AML8726_M3) /* johnny */ + #define WILC_SDIO_BLOCK_SIZE 512 + #define MAX_SEG_SIZE (1 << 12) /* 4096 */ + #else + #define WILC_SDIO_BLOCK_SIZE 512 + #endif +#endif + +typedef struct { + void *os_context; + wilc_wlan_os_func_t os_func; + uint32_t block_size; + int (*sdio_cmd52)(sdio_cmd52_t *); + int (*sdio_cmd53)(sdio_cmd53_t *); + int (*sdio_set_max_speed)(void); + int (*sdio_set_default_speed)(void); + wilc_debug_func dPrint; + int nint; +#define MAX_NUN_INT_THRPT_ENH2 (5) /* Max num interrupts allowed in registers 0xf7, 0xf8 */ + int has_thrpt_enh3; +} wilc_sdio_t; + +static wilc_sdio_t g_sdio; + +#ifdef WILC_SDIO_IRQ_GPIO +static int sdio_write_reg(uint32_t addr, uint32_t data); +static int sdio_read_reg(uint32_t addr, uint32_t *data); +#endif +extern unsigned int int_clrd; + +/******************************************** + * + * Function 0 + * + ********************************************/ + +static int sdio_set_func0_csa_address(uint32_t adr) +{ + sdio_cmd52_t cmd; + + /** + * Review: BIG ENDIAN + **/ + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 0; + cmd.address = 0x10c; + cmd.data = (uint8_t)adr; + if (!g_sdio.sdio_cmd52(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x10c data...\n"); + goto _fail_; + } + + cmd.address = 0x10d; + cmd.data = (uint8_t)(adr >> 8); + if (!g_sdio.sdio_cmd52(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x10d data...\n"); + goto _fail_; + } + + cmd.address = 0x10e; + cmd.data = (uint8_t)(adr >> 16); + if (!g_sdio.sdio_cmd52(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x10e data...\n"); + goto _fail_; + } + + return 1; +_fail_: + return 0; +} + +static int sdio_set_func0_csa_address_byte0(uint32_t adr) +{ + sdio_cmd52_t cmd; + + + /** + * Review: BIG ENDIAN + **/ + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 0; + cmd.address = 0x10c; + cmd.data = (uint8_t)adr; + if (!g_sdio.sdio_cmd52(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x10c data...\n"); + goto _fail_; + } + + return 1; +_fail_: + return 0; +} +static int sdio_set_func0_block_size(uint32_t block_size) +{ + sdio_cmd52_t cmd; + + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 0; + cmd.address = 0x10; + cmd.data = (uint8_t)block_size; + if (!g_sdio.sdio_cmd52(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x10 data...\n"); + goto _fail_; + } + + cmd.address = 0x11; + cmd.data = (uint8_t)(block_size >> 8); + if (!g_sdio.sdio_cmd52(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x11 data...\n"); + goto _fail_; + } + + return 1; +_fail_: + return 0; +} + +/******************************************** + * + * Function 1 + * + ********************************************/ + +static int sdio_set_func1_block_size(uint32_t block_size) +{ + sdio_cmd52_t cmd; + + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 0; + cmd.address = 0x110; + cmd.data = (uint8_t)block_size; + if (!g_sdio.sdio_cmd52(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x110 data...\n"); + goto _fail_; + } + cmd.address = 0x111; + cmd.data = (uint8_t)(block_size >> 8); + if (!g_sdio.sdio_cmd52(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x111 data...\n"); + goto _fail_; + } + + return 1; +_fail_: + return 0; +} + +static int sdio_clear_int(void) +{ +#ifndef WILC_SDIO_IRQ_GPIO + /* uint32_t sts; */ + sdio_cmd52_t cmd; + cmd.read_write = 0; + cmd.function = 1; + cmd.raw = 0; + cmd.address = 0x4; + cmd.data = 0; + g_sdio.sdio_cmd52(&cmd); + int_clrd++; + + return cmd.data; +#else + uint32_t reg; + if (!sdio_read_reg(WILC_HOST_RX_CTRL_0, ®)) { + g_sdio.dPrint(N_ERR, "[wilc spi]: Failed read reg (%08x)...\n", WILC_HOST_RX_CTRL_0); + return 0; + } + reg &= ~0x1; + sdio_write_reg(WILC_HOST_RX_CTRL_0, reg); + int_clrd++; + return 1; +#endif + +} + +uint32_t sdio_xfer_cnt(void) +{ + uint32_t cnt = 0; + sdio_cmd52_t cmd; + cmd.read_write = 0; + cmd.function = 1; + cmd.raw = 0; + cmd.address = 0x1C; + cmd.data = 0; + g_sdio.sdio_cmd52(&cmd); + cnt = cmd.data; + + cmd.read_write = 0; + cmd.function = 1; + cmd.raw = 0; + cmd.address = 0x1D; + cmd.data = 0; + g_sdio.sdio_cmd52(&cmd); + cnt |= (cmd.data << 8); + + cmd.read_write = 0; + cmd.function = 1; + cmd.raw = 0; + cmd.address = 0x1E; + cmd.data = 0; + g_sdio.sdio_cmd52(&cmd); + cnt |= (cmd.data << 16); + + return cnt; + + +} + +/******************************************** + * + * Sdio interfaces + * + ********************************************/ +int sdio_check_bs(void) +{ + sdio_cmd52_t cmd; + + /** + * poll until BS is 0 + **/ + cmd.read_write = 0; + cmd.function = 0; + cmd.raw = 0; + cmd.address = 0xc; + cmd.data = 0; + if (!g_sdio.sdio_cmd52(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Fail cmd 52, get BS register...\n"); + goto _fail_; + } + + return 1; + +_fail_: + + return 0; +} + +static int sdio_write_reg(uint32_t addr, uint32_t data) +{ +#ifdef BIG_ENDIAN + data = BYTE_SWAP(data); +#endif + + if ((addr >= 0xf0) && (addr <= 0xff)) { + sdio_cmd52_t cmd; + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 0; + cmd.address = addr; + cmd.data = data; + if (!g_sdio.sdio_cmd52(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd 52, read reg (%08x) ...\n", addr); + goto _fail_; + } + } else { + sdio_cmd53_t cmd; + + /** + * set the AHB address + **/ + if (!sdio_set_func0_csa_address(addr)) + goto _fail_; + + cmd.read_write = 1; + cmd.function = 0; + cmd.address = 0x10f; + cmd.block_mode = 0; + cmd.increment = 1; + cmd.count = 4; + cmd.buffer = (uint8_t *)&data; + cmd.block_size = g_sdio.block_size; /* johnny : prevent it from setting unexpected value */ + + if (!g_sdio.sdio_cmd53(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53, write reg (%08x)...\n", addr); + goto _fail_; + } + +#if 0 + if (!sdio_check_bs()) + goto _fail_; +#else + /* g_sdio.os_func.os_sleep(1); */ +#endif + } + + return 1; + +_fail_: + + return 0; +} + +static int sdio_write(uint32_t addr, uint8_t *buf, uint32_t size) +{ + uint32_t block_size = g_sdio.block_size; + sdio_cmd53_t cmd; + int nblk, nleft; + + cmd.read_write = 1; + if (addr > 0) { + /** + * has to be word aligned... + **/ + if (size & 0x3) { + size += 4; + size &= ~0x3; + } + + /** + * func 0 access + **/ + cmd.function = 0; + cmd.address = 0x10f; + } else { +#ifdef WILC1000_SINGLE_TRANSFER + /** + * has to be block aligned... + **/ + nleft = size % block_size; + if (nleft > 0) { + size += block_size; + size &= ~(block_size - 1); + } +#else + /** + * has to be word aligned... + **/ + if (size & 0x3) { + size += 4; + size &= ~0x3; + } +#endif + + /** + * func 1 access + **/ + cmd.function = 1; + cmd.address = 0; + } + + nblk = size / block_size; + nleft = size % block_size; + + if (nblk > 0) { + +#if defined(PLAT_AML8726_M3_BACKUP) /* johnny */ + int i; + + for (i = 0; i < nblk; i++) { + cmd.block_mode = 0; /* 1; */ + cmd.increment = 1; + cmd.count = block_size; /* nblk; */ + cmd.buffer = buf; + cmd.block_size = block_size; + if (addr > 0) { + if (!sdio_set_func0_csa_address(addr)) + goto _fail_; + } + if (!g_sdio.sdio_cmd53(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], block send...\n", addr); + goto _fail_; + } + + if (addr > 0) + addr += block_size; /* addr += nblk*block_size; */ + + buf += block_size; /* buf += nblk*block_size; */ + } + +#elif defined(PLAT_AML8726_M3) /* johnny */ + + int i; + int rest; + int seg_cnt; + + seg_cnt = (nblk * block_size) / MAX_SEG_SIZE; + rest = (nblk * block_size) & (MAX_SEG_SIZE - 1); + + for (i = 0; i < seg_cnt; i++) { + cmd.block_mode = 1; + cmd.increment = 1; + cmd.count = MAX_SEG_SIZE / block_size; + cmd.buffer = buf; + cmd.block_size = block_size; + + if (addr > 0) { + if (!sdio_set_func0_csa_address(addr)) + goto _fail_; + } + if (!g_sdio.sdio_cmd53(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], block send...\n", addr); + goto _fail_; + } + + if (addr > 0) + addr += MAX_SEG_SIZE; + + buf += MAX_SEG_SIZE; + + } + + + if (rest > 0) { + cmd.block_mode = 1; + cmd.increment = 1; + cmd.count = rest / block_size; + cmd.buffer = buf; + cmd.block_size = block_size; /* johnny : prevent it from setting unexpected value */ + + if (addr > 0) { + if (!sdio_set_func0_csa_address(addr)) + goto _fail_; + } + if (!g_sdio.sdio_cmd53(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], bytes send...\n", addr); + goto _fail_; + } + + if (addr > 0) + addr += rest; + + buf += rest; + + } + +#else + + cmd.block_mode = 1; + cmd.increment = 1; + cmd.count = nblk; + cmd.buffer = buf; + cmd.block_size = block_size; + if (addr > 0) { + if (!sdio_set_func0_csa_address(addr)) + goto _fail_; + } + if (!g_sdio.sdio_cmd53(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], block send...\n", addr); + goto _fail_; + } + if (addr > 0) + addr += nblk * block_size; + buf += nblk * block_size; + +#endif /* platform */ + +#if 0 + if (!sdio_check_bs()) + goto _fail_; +#else + /* g_sdio.os_func.os_sleep(1); */ +#endif + + } + + + if (nleft > 0) { + cmd.block_mode = 0; + cmd.increment = 1; + cmd.count = nleft; + cmd.buffer = buf; + + cmd.block_size = block_size; /* johnny : prevent it from setting unexpected value */ + + if (addr > 0) { + if (!sdio_set_func0_csa_address(addr)) + goto _fail_; + } + if (!g_sdio.sdio_cmd53(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], bytes send...\n", addr); + goto _fail_; + } + +#if 0 + if (!sdio_check_bs()) + goto _fail_; +#else + /* g_sdio.os_func.os_sleep(1); */ +#endif + } + + return 1; + +_fail_: + + return 0; +} + +static int sdio_read_reg(uint32_t addr, uint32_t *data) +{ + if ((addr >= 0xf0) && (addr <= 0xff)) { + sdio_cmd52_t cmd; + cmd.read_write = 0; + cmd.function = 0; + cmd.raw = 0; + cmd.address = addr; + if (!g_sdio.sdio_cmd52(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd 52, read reg (%08x) ...\n", addr); + goto _fail_; + } + *data = cmd.data; + } else { + sdio_cmd53_t cmd; + + if (!sdio_set_func0_csa_address(addr)) + goto _fail_; + + cmd.read_write = 0; + cmd.function = 0; + cmd.address = 0x10f; + cmd.block_mode = 0; + cmd.increment = 1; + cmd.count = 4; + cmd.buffer = (uint8_t *)data; + + cmd.block_size = g_sdio.block_size; /* johnny : prevent it from setting unexpected value */ + + if (!g_sdio.sdio_cmd53(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53, read reg (%08x)...\n", addr); + goto _fail_; + } + +#if 0 + if (!sdio_check_bs()) + goto _fail_; +#else + /* g_sdio.os_func.os_sleep(1); */ +#endif + } + +#ifdef BIG_ENDIAN + *data = BYTE_SWAP(*data); +#endif + + return 1; + +_fail_: + + return 0; +} + +static int sdio_read(uint32_t addr, uint8_t *buf, uint32_t size) +{ + uint32_t block_size = g_sdio.block_size; + sdio_cmd53_t cmd; + int nblk, nleft; + + cmd.read_write = 0; + if (addr > 0) { + /** + * has to be word aligned... + **/ + if (size & 0x3) { + size += 4; + size &= ~0x3; + } + + /** + * func 0 access + **/ + cmd.function = 0; + cmd.address = 0x10f; + } else { +#ifdef WILC1000_SINGLE_TRANSFER + /** + * has to be block aligned... + **/ + nleft = size % block_size; + if (nleft > 0) { + size += block_size; + size &= ~(block_size - 1); + } +#else + /** + * has to be word aligned... + **/ + if (size & 0x3) { + size += 4; + size &= ~0x3; + } +#endif + + /** + * func 1 access + **/ + cmd.function = 1; + cmd.address = 0; + } + + nblk = size / block_size; + nleft = size % block_size; + + if (nblk > 0) { + +#if defined(PLAT_AML8726_M3_BACKUP) /* johnny */ + + int i; + + for (i = 0; i < nblk; i++) { + cmd.block_mode = 0; /* 1; */ + cmd.increment = 1; + cmd.count = block_size; /* nblk; */ + cmd.buffer = buf; + cmd.block_size = block_size; + if (addr > 0) { + if (!sdio_set_func0_csa_address(addr)) + goto _fail_; + } + if (!g_sdio.sdio_cmd53(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], block read...\n", addr); + goto _fail_; + } + if (addr > 0) + addr += block_size; /* addr += nblk*block_size; */ + buf += block_size; /* buf += nblk*block_size; */ + } + +#elif defined(PLAT_AML8726_M3) /* johnny */ + + int i; + int rest; + int seg_cnt; + + seg_cnt = (nblk * block_size) / MAX_SEG_SIZE; + rest = (nblk * block_size) & (MAX_SEG_SIZE - 1); + + for (i = 0; i < seg_cnt; i++) { + cmd.block_mode = 1; + cmd.increment = 1; + cmd.count = MAX_SEG_SIZE / block_size; + cmd.buffer = buf; + cmd.block_size = block_size; + + + if (addr > 0) { + if (!sdio_set_func0_csa_address(addr)) + goto _fail_; + } + if (!g_sdio.sdio_cmd53(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], block read...\n", addr); + goto _fail_; + } + + if (addr > 0) + addr += MAX_SEG_SIZE; + + buf += MAX_SEG_SIZE; + + } + + + if (rest > 0) { + cmd.block_mode = 1; + cmd.increment = 1; + cmd.count = rest / block_size; + cmd.buffer = buf; + cmd.block_size = block_size; /* johnny : prevent it from setting unexpected value */ + + if (addr > 0) { + if (!sdio_set_func0_csa_address(addr)) + goto _fail_; + } + if (!g_sdio.sdio_cmd53(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], block read...\n", addr); + goto _fail_; + } + + if (addr > 0) + addr += rest; + + buf += rest; + + } + +#else + + cmd.block_mode = 1; + cmd.increment = 1; + cmd.count = nblk; + cmd.buffer = buf; + cmd.block_size = block_size; + if (addr > 0) { + if (!sdio_set_func0_csa_address(addr)) + goto _fail_; + } + if (!g_sdio.sdio_cmd53(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], block read...\n", addr); + goto _fail_; + } + if (addr > 0) + addr += nblk * block_size; + buf += nblk * block_size; + +#endif /* platform */ + +#if 0 + if (!sdio_check_bs()) + goto _fail_; +#else + /* g_sdio.os_func.os_sleep(1); */ +#endif + + } /* if (nblk > 0) */ + + if (nleft > 0) { + cmd.block_mode = 0; + cmd.increment = 1; + cmd.count = nleft; + cmd.buffer = buf; + + cmd.block_size = block_size; /* johnny : prevent it from setting unexpected value */ + + if (addr > 0) { + if (!sdio_set_func0_csa_address(addr)) + goto _fail_; + } + if (!g_sdio.sdio_cmd53(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], bytes read...\n", addr); + goto _fail_; + } + +#if 0 + if (!sdio_check_bs()) + goto _fail_; +#else + /* g_sdio.os_func.os_sleep(1); */ +#endif + } + + return 1; + +_fail_: + + return 0; +} + +/******************************************** + * + * Bus interfaces + * + ********************************************/ + +static int sdio_deinit(void *pv) +{ + return 1; +} + +static int sdio_sync(void) +{ + uint32_t reg; + + /** + * Disable power sequencer + **/ + if (!sdio_read_reg(WILC_MISC, ®)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed read misc reg...\n"); + return 0; + } + + reg &= ~(1 << 8); + if (!sdio_write_reg(WILC_MISC, reg)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed write misc reg...\n"); + return 0; + } + +#ifdef WILC_SDIO_IRQ_GPIO + { + uint32_t reg; + int ret; + + /** + * interrupt pin mux select + **/ + ret = sdio_read_reg(WILC_PIN_MUX_0, ®); + if (!ret) { + g_sdio.dPrint(N_ERR, "[wilc spi]: Failed read reg (%08x)...\n", WILC_PIN_MUX_0); + return 0; + } + reg |= (1 << 8); + ret = sdio_write_reg(WILC_PIN_MUX_0, reg); + if (!ret) { + g_sdio.dPrint(N_ERR, "[wilc spi]: Failed write reg (%08x)...\n", WILC_PIN_MUX_0); + return 0; + } + + /** + * interrupt enable + **/ + ret = sdio_read_reg(WILC_INTR_ENABLE, ®); + if (!ret) { + g_sdio.dPrint(N_ERR, "[wilc spi]: Failed read reg (%08x)...\n", WILC_INTR_ENABLE); + return 0; + } + reg |= (1 << 16); + ret = sdio_write_reg(WILC_INTR_ENABLE, reg); + if (!ret) { + g_sdio.dPrint(N_ERR, "[wilc spi]: Failed write reg (%08x)...\n", WILC_INTR_ENABLE); + return 0; + } + } +#endif + + return 1; +} + +static int sdio_init(wilc_wlan_inp_t *inp, wilc_debug_func func) +{ + sdio_cmd52_t cmd; + int loop; + uint32_t chipid; + memset(&g_sdio, 0, sizeof(wilc_sdio_t)); + + g_sdio.dPrint = func; + g_sdio.os_context = inp->os_context.os_private; + memcpy((void *)&g_sdio.os_func, (void *)&inp->os_func, sizeof(wilc_wlan_os_func_t)); + + if (inp->io_func.io_init) { + if (!inp->io_func.io_init(g_sdio.os_context)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed io init bus...\n"); + return 0; + } + } else { + return 0; + } + + g_sdio.sdio_cmd52 = inp->io_func.u.sdio.sdio_cmd52; + g_sdio.sdio_cmd53 = inp->io_func.u.sdio.sdio_cmd53; + g_sdio.sdio_set_max_speed = inp->io_func.u.sdio.sdio_set_max_speed; + g_sdio.sdio_set_default_speed = inp->io_func.u.sdio.sdio_set_default_speed; + + /** + * function 0 csa enable + **/ + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 1; + cmd.address = 0x100; + cmd.data = 0x80; + if (!g_sdio.sdio_cmd52(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Fail cmd 52, enable csa...\n"); + goto _fail_; + } + + /** + * function 0 block size + **/ + if (!sdio_set_func0_block_size(WILC_SDIO_BLOCK_SIZE)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Fail cmd 52, set func 0 block size...\n"); + goto _fail_; + } + g_sdio.block_size = WILC_SDIO_BLOCK_SIZE; + + /** + * enable func1 IO + **/ + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 1; + cmd.address = 0x2; + cmd.data = 0x2; + if (!g_sdio.sdio_cmd52(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio] Fail cmd 52, set IOE register...\n"); + goto _fail_; + } + + /** + * make sure func 1 is up + **/ + cmd.read_write = 0; + cmd.function = 0; + cmd.raw = 0; + cmd.address = 0x3; + loop = 3; + do { + cmd.data = 0; + if (!g_sdio.sdio_cmd52(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Fail cmd 52, get IOR register...\n"); + goto _fail_; + } + if (cmd.data == 0x2) + break; + } while (loop--); + + if (loop <= 0) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Fail func 1 is not ready...\n"); + goto _fail_; + } + + /** + * func 1 is ready, set func 1 block size + **/ + if (!sdio_set_func1_block_size(WILC_SDIO_BLOCK_SIZE)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Fail set func 1 block size...\n"); + goto _fail_; + } + + /** + * func 1 interrupt enable + **/ + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 1; + cmd.address = 0x4; + cmd.data = 0x3; + if (!g_sdio.sdio_cmd52(&cmd)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Fail cmd 52, set IEN register...\n"); + goto _fail_; + } + + /** + * make sure can read back chip id correctly + **/ + if (!sdio_read_reg(0x1000, &chipid)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Fail cmd read chip id...\n"); + goto _fail_; + } + g_sdio.dPrint(N_ERR, "[wilc sdio]: chipid (%08x)\n", chipid); + if ((chipid & 0xfff) > 0x2a0) { + g_sdio.has_thrpt_enh3 = 1; + } else { + g_sdio.has_thrpt_enh3 = 0; + } + g_sdio.dPrint(N_ERR, "[wilc sdio]: has_thrpt_enh3 = %d...\n", g_sdio.has_thrpt_enh3); + + + return 1; + +_fail_: + + return 0; +} + +static void sdio_set_max_speed(void) +{ + g_sdio.sdio_set_max_speed(); +} + +static void sdio_set_default_speed(void) +{ + g_sdio.sdio_set_default_speed(); +} + +static int sdio_read_size(uint32_t *size) +{ + + uint32_t tmp; + sdio_cmd52_t cmd; + + /** + * Read DMA count in words + **/ + { + cmd.read_write = 0; + cmd.function = 0; + cmd.raw = 0; + cmd.address = 0xf2; + cmd.data = 0; + g_sdio.sdio_cmd52(&cmd); + tmp = cmd.data; + + /* cmd.read_write = 0; */ + /* cmd.function = 0; */ + /* cmd.raw = 0; */ + cmd.address = 0xf3; + cmd.data = 0; + g_sdio.sdio_cmd52(&cmd); + tmp |= (cmd.data << 8); + } + + *size = tmp; + return 1; +} + +static int sdio_read_int(uint32_t *int_status) +{ + + uint32_t tmp; + sdio_cmd52_t cmd; + + sdio_read_size(&tmp); + + /** + * Read IRQ flags + **/ +#ifndef WILC_SDIO_IRQ_GPIO + /* cmd.read_write = 0; */ + cmd.function = 1; + /* cmd.raw = 0; */ + cmd.address = 0x04; + cmd.data = 0; + g_sdio.sdio_cmd52(&cmd); + + if (cmd.data & (1 << 0)) { + tmp |= INT_0; + } + if (cmd.data & (1 << 2)) { + tmp |= INT_1; + } + if (cmd.data & (1 << 3)) { + tmp |= INT_2; + } + if (cmd.data & (1 << 4)) { + tmp |= INT_3; + } + if (cmd.data & (1 << 5)) { + tmp |= INT_4; + } + if (cmd.data & (1 << 6)) { + tmp |= INT_5; + } + { + int i; + for (i = g_sdio.nint; i < MAX_NUM_INT; i++) { + if ((tmp >> (IRG_FLAGS_OFFSET + i)) & 0x1) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Unexpected interrupt (1) : tmp=%x, data=%x\n", tmp, cmd.data); + break; + } + } + } +#else + { + uint32_t irq_flags; + + cmd.read_write = 0; + cmd.function = 0; + cmd.raw = 0; + cmd.address = 0xf7; + cmd.data = 0; + g_sdio.sdio_cmd52(&cmd); + irq_flags = cmd.data & 0x1f; + tmp |= ((irq_flags >> 0) << IRG_FLAGS_OFFSET); + } + +#endif + + *int_status = tmp; + + return 1; +} + +static int sdio_clear_int_ext(uint32_t val) +{ + int ret; + + if (g_sdio.has_thrpt_enh3) { + uint32_t reg; + +#ifdef WILC_SDIO_IRQ_GPIO + { + uint32_t flags; + flags = val & ((1 << MAX_NUN_INT_THRPT_ENH2) - 1); + reg = flags; + } +#else + reg = 0; +#endif + /* select VMM table 0 */ + if ((val & SEL_VMM_TBL0) == SEL_VMM_TBL0) + reg |= (1 << 5); + /* select VMM table 1 */ + if ((val & SEL_VMM_TBL1) == SEL_VMM_TBL1) + reg |= (1 << 6); + /* enable VMM */ + if ((val & EN_VMM) == EN_VMM) + reg |= (1 << 7); + if (reg) { + sdio_cmd52_t cmd; + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 0; + cmd.address = 0xf8; + cmd.data = reg; + + ret = g_sdio.sdio_cmd52(&cmd); + if (!ret) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0xf8 data (%d) ...\n", __LINE__); + goto _fail_; + } + + } + } else { +#ifdef WILC_SDIO_IRQ_GPIO + { + /* see below. has_thrpt_enh2 uses register 0xf8 to clear interrupts. */ + /* Cannot clear multiple interrupts. Must clear each interrupt individually */ + uint32_t flags; + flags = val & ((1 << MAX_NUM_INT) - 1); + if (flags) { + int i; + + ret = 1; + for (i = 0; i < g_sdio.nint; i++) { + if (flags & 1) { + sdio_cmd52_t cmd; + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 0; + cmd.address = 0xf8; + cmd.data = (1 << i); + + ret = g_sdio.sdio_cmd52(&cmd); + if (!ret) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0xf8 data (%d) ...\n", __LINE__); + goto _fail_; + } + + } + if (!ret) + break; + flags >>= 1; + } + if (!ret) { + goto _fail_; + } + for (i = g_sdio.nint; i < MAX_NUM_INT; i++) { + if (flags & 1) + g_sdio.dPrint(N_ERR, "[wilc sdio]: Unexpected interrupt cleared %d...\n", i); + flags >>= 1; + } + } + } +#endif /* WILC_SDIO_IRQ_GPIO */ + + + { + uint32_t vmm_ctl; + + vmm_ctl = 0; + /* select VMM table 0 */ + if ((val & SEL_VMM_TBL0) == SEL_VMM_TBL0) + vmm_ctl |= (1 << 0); + /* select VMM table 1 */ + if ((val & SEL_VMM_TBL1) == SEL_VMM_TBL1) + vmm_ctl |= (1 << 1); + /* enable VMM */ + if ((val & EN_VMM) == EN_VMM) + vmm_ctl |= (1 << 2); + + if (vmm_ctl) { + sdio_cmd52_t cmd; + + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 0; + cmd.address = 0xf6; + cmd.data = vmm_ctl; + ret = g_sdio.sdio_cmd52(&cmd); + if (!ret) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0xf6 data (%d) ...\n", __LINE__); + goto _fail_; + } + } + } + } + + return 1; +_fail_: + return 0; +} + +static int sdio_sync_ext(int nint /* how mant interrupts to enable. */) +{ + uint32_t reg; + + + if (nint > MAX_NUM_INT) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Too many interupts (%d)...\n", nint); + return 0; + } + if (nint > MAX_NUN_INT_THRPT_ENH2) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Error: Cannot support more than 5 interrupts when has_thrpt_enh2=1.\n"); + return 0; + } + + + g_sdio.nint = nint; + + /** + * Disable power sequencer + **/ + if (!sdio_read_reg(WILC_MISC, ®)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed read misc reg...\n"); + return 0; + } + + reg &= ~(1 << 8); + if (!sdio_write_reg(WILC_MISC, reg)) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed write misc reg...\n"); + return 0; + } + +#ifdef WILC_SDIO_IRQ_GPIO + { + uint32_t reg; + int ret, i; + + + /** + * interrupt pin mux select + **/ + ret = sdio_read_reg(WILC_PIN_MUX_0, ®); + if (!ret) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed read reg (%08x)...\n", WILC_PIN_MUX_0); + return 0; + } + reg |= (1 << 8); + ret = sdio_write_reg(WILC_PIN_MUX_0, reg); + if (!ret) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed write reg (%08x)...\n", WILC_PIN_MUX_0); + return 0; + } + + /** + * interrupt enable + **/ + ret = sdio_read_reg(WILC_INTR_ENABLE, ®); + if (!ret) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed read reg (%08x)...\n", WILC_INTR_ENABLE); + return 0; + } + + for (i = 0; (i < 5) && (nint > 0); i++, nint--) { + reg |= (1 << (27 + i)); + } + ret = sdio_write_reg(WILC_INTR_ENABLE, reg); + if (!ret) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed write reg (%08x)...\n", WILC_INTR_ENABLE); + return 0; + } + if (nint) { + ret = sdio_read_reg(WILC_INTR2_ENABLE, ®); + if (!ret) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed read reg (%08x)...\n", WILC_INTR2_ENABLE); + return 0; + } + + for (i = 0; (i < 3) && (nint > 0); i++, nint--) { + reg |= (1 << i); + } + + ret = sdio_read_reg(WILC_INTR2_ENABLE, ®); + if (!ret) { + g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed write reg (%08x)...\n", WILC_INTR2_ENABLE); + return 0; + } + } + } +#endif /* WILC_SDIO_IRQ_GPIO */ + return 1; +} + + +/******************************************** + * + * Global sdio HIF function table + * + ********************************************/ + +wilc_hif_func_t hif_sdio = { + sdio_init, + sdio_deinit, + sdio_read_reg, + sdio_write_reg, + sdio_read, + sdio_write, + sdio_sync, + sdio_clear_int, + sdio_read_int, + sdio_clear_int_ext, + sdio_read_size, + sdio_write, + sdio_read, + sdio_sync_ext, + + sdio_set_max_speed, + sdio_set_default_speed, +}; + diff --git a/drivers/staging/wilc1000/wilc_semaphore.c b/drivers/staging/wilc1000/wilc_semaphore.c new file mode 100644 index 000000000000..637107bfb877 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_semaphore.c @@ -0,0 +1,70 @@ + +#include "wilc_oswrapper.h" +#ifdef CONFIG_WILC_SEMAPHORE_FEATURE + + +WILC_ErrNo WILC_SemaphoreCreate(WILC_SemaphoreHandle *pHandle, + tstrWILC_SemaphoreAttrs *pstrAttrs) +{ + tstrWILC_SemaphoreAttrs strDefaultAttrs; + if (pstrAttrs == WILC_NULL) { + WILC_SemaphoreFillDefault(&strDefaultAttrs); + pstrAttrs = &strDefaultAttrs; + } + + sema_init(pHandle, pstrAttrs->u32InitCount); + return WILC_SUCCESS; + +} + + +WILC_ErrNo WILC_SemaphoreDestroy(WILC_SemaphoreHandle *pHandle, + tstrWILC_SemaphoreAttrs *pstrAttrs) +{ + /* nothing to be done ! */ + + return WILC_SUCCESS; + +} + + +WILC_ErrNo WILC_SemaphoreAcquire(WILC_SemaphoreHandle *pHandle, + tstrWILC_SemaphoreAttrs *pstrAttrs) +{ + WILC_ErrNo s32RetStatus = WILC_SUCCESS; + + #ifndef CONFIG_WILC_SEMAPHORE_TIMEOUT + while (down_interruptible(pHandle)) + ; + + #else + if (pstrAttrs == WILC_NULL) { + down(pHandle); + } else { + + s32RetStatus = down_timeout(pHandle, msecs_to_jiffies(pstrAttrs->u32TimeOut)); + } + #endif + + if (s32RetStatus == 0) { + return WILC_SUCCESS; + } else if (s32RetStatus == -ETIME) { + return WILC_TIMEOUT; + } else { + return WILC_FAIL; + } + + return WILC_SUCCESS; + +} + +WILC_ErrNo WILC_SemaphoreRelease(WILC_SemaphoreHandle *pHandle, + tstrWILC_SemaphoreAttrs *pstrAttrs) +{ + + up(pHandle); + return WILC_SUCCESS; + +} + +#endif diff --git a/drivers/staging/wilc1000/wilc_semaphore.h b/drivers/staging/wilc1000/wilc_semaphore.h new file mode 100644 index 000000000000..3006f9f20c4d --- /dev/null +++ b/drivers/staging/wilc1000/wilc_semaphore.h @@ -0,0 +1,115 @@ +#ifndef __WILC_SEMAPHORE_H__ +#define __WILC_SEMAPHORE_H__ + +/*! + * @file wilc_semaphore.h + * @brief Semaphore OS Wrapper functionality + * @author syounan + * @sa wilc_oswrapper.h top level OS wrapper file + * @date 10 Aug 2010 + * @version 1.0 + */ + + +#ifndef CONFIG_WILC_SEMAPHORE_FEATURE +#error the feature WILC_OS_FEATURE_SEMAPHORE must be supported to include this file +#endif + +/*! + * @struct WILC_SemaphoreAttrs + * @brief Semaphore API options + * @author syounan + * @date 10 Aug 2010 + * @version 1.0 + */ +typedef struct { + /*!< + * Initial count when the semaphore is created. default is 1 + */ + WILC_Uint32 u32InitCount; + + #ifdef CONFIG_WILC_SEMAPHORE_TIMEOUT + /*!< + * Timeout for use with WILC_SemaphoreAcquire, 0 to return immediately and + * WILC_OS_INFINITY to wait forever. default is WILC_OS_INFINITY + */ + WILC_Uint32 u32TimeOut; + #endif + +} tstrWILC_SemaphoreAttrs; + + +/*! + * @brief Fills the WILC_SemaphoreAttrs with default parameters + * @param[out] pstrAttrs structure to be filled + * @sa WILC_SemaphoreAttrs + * @author syounan + * @date 10 Aug 2010 + * @version 1.0 + */ +static void WILC_SemaphoreFillDefault(tstrWILC_SemaphoreAttrs *pstrAttrs) +{ + pstrAttrs->u32InitCount = 1; + #ifdef CONFIG_WILC_SEMAPHORE_TIMEOUT + pstrAttrs->u32TimeOut = WILC_OS_INFINITY; + #endif +} +/*! + * @brief Creates a new Semaphore object + * @param[out] pHandle handle to the newly created semaphore + * @param[in] pstrAttrs Optional attributes, NULL for defaults + * pstrAttrs->u32InitCount controls the initial count + * @return Error code indicating success/failure + * @sa WILC_SemaphoreAttrs + * @author syounan + * @date 10 Aug 2010 + * @version 1.0 + */ +WILC_ErrNo WILC_SemaphoreCreate(WILC_SemaphoreHandle *pHandle, + tstrWILC_SemaphoreAttrs *pstrAttrs); + +/*! + * @brief Destroyes an existing Semaphore, releasing any resources + * @param[in] pHandle handle to the semaphore object + * @param[in] pstrAttrs Optional attributes, NULL for defaults + * @return Error code indicating success/failure + * @sa WILC_SemaphoreAttrs + * @todo need to define behaviour if the semaphore delayed while it is pending + * @author syounan + * @date 10 Aug 2010 + * @version 1.0 + */ +WILC_ErrNo WILC_SemaphoreDestroy(WILC_SemaphoreHandle *pHandle, + tstrWILC_SemaphoreAttrs *pstrAttrs); + +/*! + * @brief Acquire the Semaphore object + * @details This function will block until it can Acquire the given + * semaphore, if the feature WILC_OS_FEATURE_SEMAPHORE_TIMEOUT is + * eanbled a timeout value can be passed in pstrAttrs + * @param[in] pHandle handle to the semaphore object + * @param[in] pstrAttrs Optional attributes, NULL for default + * @return Error code indicating success/failure + * @sa WILC_SemaphoreAttrs + * @author syounan + * @date 10 Aug 2010 + * @version 1.0 + */ +WILC_ErrNo WILC_SemaphoreAcquire(WILC_SemaphoreHandle *pHandle, + tstrWILC_SemaphoreAttrs *pstrAttrs); + +/*! + * @brief Release the Semaphore object + * @param[in] pHandle handle to the semaphore object + * @param[in] pstrAttrs Optional attributes, NULL for default + * @return Error code indicating sucess/failure + * @sa WILC_SemaphoreAttrs + * @author syounan + * @date 10 Aug 2010 + * @version 1.0 + */ +WILC_ErrNo WILC_SemaphoreRelease(WILC_SemaphoreHandle *pHandle, + tstrWILC_SemaphoreAttrs *pstrAttrs); + + +#endif diff --git a/drivers/staging/wilc1000/wilc_sleep.c b/drivers/staging/wilc1000/wilc_sleep.c new file mode 100644 index 000000000000..368157175f40 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_sleep.c @@ -0,0 +1,36 @@ + +#include "wilc_oswrapper.h" + +#ifdef CONFIG_WILC_SLEEP_FEATURE + +/* + * @author mdaftedar + * @date 10 Aug 2010 + * @version 1.0 + */ +void WILC_Sleep(WILC_Uint32 u32TimeMilliSec) +{ + if (u32TimeMilliSec <= 4000000) { + WILC_Uint32 u32Temp = u32TimeMilliSec * 1000; +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 35) + usleep_range(u32Temp, u32Temp); +#else + udelay(u32Temp); +#endif + } else { + msleep(u32TimeMilliSec); + } + +} +#endif + +/* #ifdef CONFIG_WILC_SLEEP_HI_RES */ +void WILC_SleepMicrosec(WILC_Uint32 u32TimeMicoSec) +{ + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 35) + usleep_range(u32TimeMicoSec, u32TimeMicoSec); + #else + udelay(u32TimeMicoSec); + #endif +} +/* #endif */ diff --git a/drivers/staging/wilc1000/wilc_sleep.h b/drivers/staging/wilc1000/wilc_sleep.h new file mode 100644 index 000000000000..d640fb553aca --- /dev/null +++ b/drivers/staging/wilc1000/wilc_sleep.h @@ -0,0 +1,45 @@ +#ifndef __WILC_SLEEP_H__ +#define __WILC_SLEEP_H__ + +/*! + * @file wilc_sleep.h + * @brief Sleep OS Wrapper functionality + * @author syounan + * @sa wilc_oswrapper.h top level OS wrapper file + * @date 10 Aug 2010 + * @version 1.0 + */ + +#ifndef CONFIG_WILC_SLEEP_FEATURE +#error the feature WILC_OS_FEATURE_SLEEP must be supported to include this file +#endif + +/*! + * @brief forces the current thread to sleep until the given time has elapsed + * @param[in] u32TimeMilliSec Time to sleep in Milli seconds + * @sa WILC_SleepMicrosec + * @author syounan + * @date 10 Aug 2010 + * @version 1.0 + * @note This function offers a relatively innacurate and low resolution + * sleep, for accurate high resolution sleep use u32TimeMicoSec + */ +void WILC_Sleep(WILC_Uint32 u32TimeMilliSec); + +#ifdef CONFIG_WILC_SLEEP_HI_RES +/*! + * @brief forces the current thread to sleep until the given time has elapsed + * @param[in] u32TimeMicoSec Time to sleep in Micro seconds + * @sa WILC_Sleep + * @author syounan + * @date 10 Aug 2010 + * @version 1.0 + * @note This function offers an acurare high resolution sleep, depends on + * the feature WILC_OS_FEATURE_SLEEP_HI_RES and may not be supported + * on all Operating Systems + */ +void WILC_SleepMicrosec(WILC_Uint32 u32TimeMicoSec); +#endif + + +#endif diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c new file mode 100644 index 000000000000..2f38ddabc654 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_spi.c @@ -0,0 +1,1475 @@ +/* ////////////////////////////////////////////////////////////////////////// */ +/* */ +/* Copyright (c) Atmel Corporation. All rights reserved. */ +/* */ +/* Module Name: wilc_spi.c */ +/* */ +/* */ +/* //////////////////////////////////////////////////////////////////////////// */ + +#include "wilc_wlan_if.h" +#include "wilc_wlan.h" + +extern unsigned int int_clrd; + +/* + * #include + * #include + */ +typedef struct { + void *os_context; + int (*spi_tx)(uint8_t *, uint32_t); + int (*spi_rx)(uint8_t *, uint32_t); + int (*spi_trx)(uint8_t *, uint8_t *, uint32_t); + int (*spi_max_speed)(void); + wilc_debug_func dPrint; + int crc_off; + int nint; + int has_thrpt_enh; +} wilc_spi_t; + +static wilc_spi_t g_spi; + +static int spi_read(uint32_t, uint8_t *, uint32_t); +static int spi_write(uint32_t, uint8_t *, uint32_t); + +/******************************************** + * + * Crc7 + * + ********************************************/ + +static const uint8_t crc7_syndrome_table[256] = { + 0x00, 0x09, 0x12, 0x1b, 0x24, 0x2d, 0x36, 0x3f, + 0x48, 0x41, 0x5a, 0x53, 0x6c, 0x65, 0x7e, 0x77, + 0x19, 0x10, 0x0b, 0x02, 0x3d, 0x34, 0x2f, 0x26, + 0x51, 0x58, 0x43, 0x4a, 0x75, 0x7c, 0x67, 0x6e, + 0x32, 0x3b, 0x20, 0x29, 0x16, 0x1f, 0x04, 0x0d, + 0x7a, 0x73, 0x68, 0x61, 0x5e, 0x57, 0x4c, 0x45, + 0x2b, 0x22, 0x39, 0x30, 0x0f, 0x06, 0x1d, 0x14, + 0x63, 0x6a, 0x71, 0x78, 0x47, 0x4e, 0x55, 0x5c, + 0x64, 0x6d, 0x76, 0x7f, 0x40, 0x49, 0x52, 0x5b, + 0x2c, 0x25, 0x3e, 0x37, 0x08, 0x01, 0x1a, 0x13, + 0x7d, 0x74, 0x6f, 0x66, 0x59, 0x50, 0x4b, 0x42, + 0x35, 0x3c, 0x27, 0x2e, 0x11, 0x18, 0x03, 0x0a, + 0x56, 0x5f, 0x44, 0x4d, 0x72, 0x7b, 0x60, 0x69, + 0x1e, 0x17, 0x0c, 0x05, 0x3a, 0x33, 0x28, 0x21, + 0x4f, 0x46, 0x5d, 0x54, 0x6b, 0x62, 0x79, 0x70, + 0x07, 0x0e, 0x15, 0x1c, 0x23, 0x2a, 0x31, 0x38, + 0x41, 0x48, 0x53, 0x5a, 0x65, 0x6c, 0x77, 0x7e, + 0x09, 0x00, 0x1b, 0x12, 0x2d, 0x24, 0x3f, 0x36, + 0x58, 0x51, 0x4a, 0x43, 0x7c, 0x75, 0x6e, 0x67, + 0x10, 0x19, 0x02, 0x0b, 0x34, 0x3d, 0x26, 0x2f, + 0x73, 0x7a, 0x61, 0x68, 0x57, 0x5e, 0x45, 0x4c, + 0x3b, 0x32, 0x29, 0x20, 0x1f, 0x16, 0x0d, 0x04, + 0x6a, 0x63, 0x78, 0x71, 0x4e, 0x47, 0x5c, 0x55, + 0x22, 0x2b, 0x30, 0x39, 0x06, 0x0f, 0x14, 0x1d, + 0x25, 0x2c, 0x37, 0x3e, 0x01, 0x08, 0x13, 0x1a, + 0x6d, 0x64, 0x7f, 0x76, 0x49, 0x40, 0x5b, 0x52, + 0x3c, 0x35, 0x2e, 0x27, 0x18, 0x11, 0x0a, 0x03, + 0x74, 0x7d, 0x66, 0x6f, 0x50, 0x59, 0x42, 0x4b, + 0x17, 0x1e, 0x05, 0x0c, 0x33, 0x3a, 0x21, 0x28, + 0x5f, 0x56, 0x4d, 0x44, 0x7b, 0x72, 0x69, 0x60, + 0x0e, 0x07, 0x1c, 0x15, 0x2a, 0x23, 0x38, 0x31, + 0x46, 0x4f, 0x54, 0x5d, 0x62, 0x6b, 0x70, 0x79 +}; + +static uint8_t crc7_byte(uint8_t crc, uint8_t data) +{ + return crc7_syndrome_table[(crc << 1) ^ data]; +} + +static uint8_t crc7(uint8_t crc, const uint8_t *buffer, uint32_t len) +{ + while (len--) + crc = crc7_byte(crc, *buffer++); + return crc; +} + +/******************************************** + * + * Spi protocol Function + * + ********************************************/ + +#define CMD_DMA_WRITE 0xc1 +#define CMD_DMA_READ 0xc2 +#define CMD_INTERNAL_WRITE 0xc3 +#define CMD_INTERNAL_READ 0xc4 +#define CMD_TERMINATE 0xc5 +#define CMD_REPEAT 0xc6 +#define CMD_DMA_EXT_WRITE 0xc7 +#define CMD_DMA_EXT_READ 0xc8 +#define CMD_SINGLE_WRITE 0xc9 +#define CMD_SINGLE_READ 0xca +#define CMD_RESET 0xcf + +#define N_OK 1 +#define N_FAIL 0 +#define N_RESET -1 +#define N_RETRY -2 + +#define DATA_PKT_SZ_256 256 +#define DATA_PKT_SZ_512 512 +#define DATA_PKT_SZ_1K 1024 +#define DATA_PKT_SZ_4K (4 * 1024) +#define DATA_PKT_SZ_8K (8 * 1024) +#define DATA_PKT_SZ DATA_PKT_SZ_8K + +static int spi_cmd(uint8_t cmd, uint32_t adr, uint32_t data, uint32_t sz, uint8_t clockless) +{ + uint8_t bc[9]; + int len = 5; + int result = N_OK; + + bc[0] = cmd; + switch (cmd) { + case CMD_SINGLE_READ: /* single word (4 bytes) read */ + bc[1] = (uint8_t)(adr >> 16); + bc[2] = (uint8_t)(adr >> 8); + bc[3] = (uint8_t)adr; + len = 5; + break; + + case CMD_INTERNAL_READ: /* internal register read */ + bc[1] = (uint8_t)(adr >> 8); + if (clockless) + bc[1] |= (1 << 7); + bc[2] = (uint8_t)adr; + bc[3] = 0x00; + len = 5; + break; + + case CMD_TERMINATE: /* termination */ + bc[1] = 0x00; + bc[2] = 0x00; + bc[3] = 0x00; + len = 5; + break; + + case CMD_REPEAT: /* repeat */ + bc[1] = 0x00; + bc[2] = 0x00; + bc[3] = 0x00; + len = 5; + break; + + case CMD_RESET: /* reset */ + bc[1] = 0xff; + bc[2] = 0xff; + bc[3] = 0xff; + len = 5; + break; + + case CMD_DMA_WRITE: /* dma write */ + case CMD_DMA_READ: /* dma read */ + bc[1] = (uint8_t)(adr >> 16); + bc[2] = (uint8_t)(adr >> 8); + bc[3] = (uint8_t)adr; + bc[4] = (uint8_t)(sz >> 8); + bc[5] = (uint8_t)(sz); + len = 7; + break; + + case CMD_DMA_EXT_WRITE: /* dma extended write */ + case CMD_DMA_EXT_READ: /* dma extended read */ + bc[1] = (uint8_t)(adr >> 16); + bc[2] = (uint8_t)(adr >> 8); + bc[3] = (uint8_t)adr; + bc[4] = (uint8_t)(sz >> 16); + bc[5] = (uint8_t)(sz >> 8); + bc[6] = (uint8_t)(sz); + len = 8; + break; + + case CMD_INTERNAL_WRITE: /* internal register write */ + bc[1] = (uint8_t)(adr >> 8); + if (clockless) + bc[1] |= (1 << 7); + bc[2] = (uint8_t)(adr); + bc[3] = (uint8_t)(data >> 24); + bc[4] = (uint8_t)(data >> 16); + bc[5] = (uint8_t)(data >> 8); + bc[6] = (uint8_t)(data); + len = 8; + break; + + case CMD_SINGLE_WRITE: /* single word write */ + bc[1] = (uint8_t)(adr >> 16); + bc[2] = (uint8_t)(adr >> 8); + bc[3] = (uint8_t)(adr); + bc[4] = (uint8_t)(data >> 24); + bc[5] = (uint8_t)(data >> 16); + bc[6] = (uint8_t)(data >> 8); + bc[7] = (uint8_t)(data); + len = 9; + break; + + default: + result = N_FAIL; + break; + } + + if (result) { + if (!g_spi.crc_off) + bc[len - 1] = (crc7(0x7f, (const uint8_t *)&bc[0], len - 1)) << 1; + else + len -= 1; + + if (!g_spi.spi_tx(bc, len)) { + PRINT_ER("[wilc spi]: Failed cmd write, bus error...\n"); + result = N_FAIL; + } + } + + return result; +} + +static int spi_cmd_rsp(uint8_t cmd) +{ + uint8_t rsp; + int result = N_OK; + + /** + * Command/Control response + **/ + if ((cmd == CMD_RESET) || + (cmd == CMD_TERMINATE) || + (cmd == CMD_REPEAT)) { + if (!g_spi.spi_rx(&rsp, 1)) { + result = N_FAIL; + goto _fail_; + } + } + + if (!g_spi.spi_rx(&rsp, 1)) { + PRINT_ER("[wilc spi]: Failed cmd response read, bus error...\n"); + result = N_FAIL; + goto _fail_; + } + + if (rsp != cmd) { + PRINT_ER("[wilc spi]: Failed cmd response, cmd (%02x), resp (%02x)\n", cmd, rsp); + result = N_FAIL; + goto _fail_; + } + + /** + * State response + **/ + if (!g_spi.spi_rx(&rsp, 1)) { + PRINT_ER("[wilc spi]: Failed cmd state read, bus error...\n"); + result = N_FAIL; + goto _fail_; + } + + if (rsp != 0x00) { + PRINT_ER("[wilc spi]: Failed cmd state response state (%02x)\n", rsp); + result = N_FAIL; + } + +_fail_: + + return result; +} + +static int spi_cmd_complete(uint8_t cmd, uint32_t adr, uint8_t *b, uint32_t sz, uint8_t clockless) +{ + uint8_t wb[32], rb[32]; + uint8_t wix, rix; + uint32_t len2; + uint8_t rsp; + int len = 0; + int result = N_OK; + + wb[0] = cmd; + switch (cmd) { + case CMD_SINGLE_READ: /* single word (4 bytes) read */ + wb[1] = (uint8_t)(adr >> 16); + wb[2] = (uint8_t)(adr >> 8); + wb[3] = (uint8_t)adr; + len = 5; + break; + + case CMD_INTERNAL_READ: /* internal register read */ + wb[1] = (uint8_t)(adr >> 8); + if (clockless == 1) + wb[1] |= (1 << 7); + wb[2] = (uint8_t)adr; + wb[3] = 0x00; + len = 5; + break; + + case CMD_TERMINATE: /* termination */ + wb[1] = 0x00; + wb[2] = 0x00; + wb[3] = 0x00; + len = 5; + break; + + case CMD_REPEAT: /* repeat */ + wb[1] = 0x00; + wb[2] = 0x00; + wb[3] = 0x00; + len = 5; + break; + + case CMD_RESET: /* reset */ + wb[1] = 0xff; + wb[2] = 0xff; + wb[3] = 0xff; + len = 5; + break; + + case CMD_DMA_WRITE: /* dma write */ + case CMD_DMA_READ: /* dma read */ + wb[1] = (uint8_t)(adr >> 16); + wb[2] = (uint8_t)(adr >> 8); + wb[3] = (uint8_t)adr; + wb[4] = (uint8_t)(sz >> 8); + wb[5] = (uint8_t)(sz); + len = 7; + break; + + case CMD_DMA_EXT_WRITE: /* dma extended write */ + case CMD_DMA_EXT_READ: /* dma extended read */ + wb[1] = (uint8_t)(adr >> 16); + wb[2] = (uint8_t)(adr >> 8); + wb[3] = (uint8_t)adr; + wb[4] = (uint8_t)(sz >> 16); + wb[5] = (uint8_t)(sz >> 8); + wb[6] = (uint8_t)(sz); + len = 8; + break; + + case CMD_INTERNAL_WRITE: /* internal register write */ + wb[1] = (uint8_t)(adr >> 8); + if (clockless == 1) + wb[1] |= (1 << 7); + wb[2] = (uint8_t)(adr); + wb[3] = b[3]; + wb[4] = b[2]; + wb[5] = b[1]; + wb[6] = b[0]; + len = 8; + break; + + case CMD_SINGLE_WRITE: /* single word write */ + wb[1] = (uint8_t)(adr >> 16); + wb[2] = (uint8_t)(adr >> 8); + wb[3] = (uint8_t)(adr); + wb[4] = b[3]; + wb[5] = b[2]; + wb[6] = b[1]; + wb[7] = b[0]; + len = 9; + break; + + default: + result = N_FAIL; + break; + } + + if (result != N_OK) { + return result; + } + + if (!g_spi.crc_off) { + wb[len - 1] = (crc7(0x7f, (const uint8_t *)&wb[0], len - 1)) << 1; + } else { + len -= 1; + } + +#define NUM_SKIP_BYTES (1) +#define NUM_RSP_BYTES (2) +#define NUM_DATA_HDR_BYTES (1) +#define NUM_DATA_BYTES (4) +#define NUM_CRC_BYTES (2) +#define NUM_DUMMY_BYTES (3) + if ((cmd == CMD_RESET) || + (cmd == CMD_TERMINATE) || + (cmd == CMD_REPEAT)) { + len2 = len + (NUM_SKIP_BYTES + NUM_RSP_BYTES + NUM_DUMMY_BYTES); + } else if ((cmd == CMD_INTERNAL_READ) || (cmd == CMD_SINGLE_READ)) { + if (!g_spi.crc_off) { + len2 = len + (NUM_RSP_BYTES + NUM_DATA_HDR_BYTES + NUM_DATA_BYTES + + NUM_CRC_BYTES + NUM_DUMMY_BYTES); + } else { + len2 = len + (NUM_RSP_BYTES + NUM_DATA_HDR_BYTES + NUM_DATA_BYTES + + NUM_DUMMY_BYTES); + } + } else { + len2 = len + (NUM_RSP_BYTES + NUM_DUMMY_BYTES); + } +#undef NUM_DUMMY_BYTES + + if (len2 > (sizeof(wb) / sizeof(wb[0]))) { + PRINT_ER("[wilc spi]: spi buffer size too small (%d) (%d)\n", + len2, (sizeof(wb) / sizeof(wb[0]))); + result = N_FAIL; + return result; + } + /* zero spi write buffers. */ + for (wix = len; wix < len2; wix++) { + wb[wix] = 0; + } + rix = len; + + if (!g_spi.spi_trx(wb, rb, len2)) { + PRINT_ER("[wilc spi]: Failed cmd write, bus error...\n"); + result = N_FAIL; + return result; + } + +#if 0 + { + int jj; + PRINT_D(BUS_DBG, "--- cnd = %x, len=%d, len2=%d\n", cmd, len, len2); + for (jj = 0; jj < sizeof(wb) / sizeof(wb[0]); jj++) { + + if (jj >= len2) + break; + if (((jj + 1) % 16) != 0) { + if ((jj % 16) == 0) { + PRINT_D(BUS_DBG, "wb[%02x]: %02x ", jj, wb[jj]); + } else { + PRINT_D(BUS_DBG, "%02x ", wb[jj]); + } + } else { + PRINT_D(BUS_DBG, "%02x\n", wb[jj]); + } + } + + for (jj = 0; jj < sizeof(rb) / sizeof(rb[0]); jj++) { + + if (jj >= len2) + break; + if (((jj + 1) % 16) != 0) { + if ((jj % 16) == 0) { + PRINT_D(BUS_DBG, "rb[%02x]: %02x ", jj, rb[jj]); + } else { + PRINT_D(BUS_DBG, "%02x ", rb[jj]); + } + } else { + PRINT_D(BUS_DBG, "%02x\n", rb[jj]); + } + } + } +#endif + + /** + * Command/Control response + **/ + if ((cmd == CMD_RESET) || + (cmd == CMD_TERMINATE) || + (cmd == CMD_REPEAT)) { + rix++; /* skip 1 byte */ + } + + /* do { */ + rsp = rb[rix++]; + /* if(rsp == cmd) break; */ + /* } while(&rptr[1] <= &rb[len2]); */ + + if (rsp != cmd) { + PRINT_ER("[wilc spi]: Failed cmd response, cmd (%02x)" + ", resp (%02x)\n", cmd, rsp); + result = N_FAIL; + return result; + } + + /** + * State response + **/ + rsp = rb[rix++]; + if (rsp != 0x00) { + PRINT_ER("[wilc spi]: Failed cmd state response " + "state (%02x)\n", rsp); + result = N_FAIL; + return result; + } + + if ((cmd == CMD_INTERNAL_READ) || (cmd == CMD_SINGLE_READ) + || (cmd == CMD_DMA_READ) || (cmd == CMD_DMA_EXT_READ)) { + int retry; + /* uint16_t crc1, crc2; */ + uint8_t crc[2]; + /** + * Data Respnose header + **/ + retry = 100; + do { + /* ensure there is room in buffer later to read data and crc */ + if (rix < len2) { + rsp = rb[rix++]; + } else { + retry = 0; + break; + } + if (((rsp >> 4) & 0xf) == 0xf) + break; + } while (retry--); + + if (retry <= 0) { + PRINT_ER("[wilc spi]: Error, data read " + "response (%02x)\n", rsp); + result = N_RESET; + return result; + } + + if ((cmd == CMD_INTERNAL_READ) || (cmd == CMD_SINGLE_READ)) { + /** + * Read bytes + **/ + if ((rix + 3) < len2) { + b[0] = rb[rix++]; + b[1] = rb[rix++]; + b[2] = rb[rix++]; + b[3] = rb[rix++]; + } else { + PRINT_ER("[wilc spi]: buffer overrun when reading data.\n"); + result = N_FAIL; + return result; + } + + if (!g_spi.crc_off) { + /** + * Read Crc + **/ + if ((rix + 1) < len2) { + crc[0] = rb[rix++]; + crc[1] = rb[rix++]; + } else { + PRINT_ER("[wilc spi]: buffer overrun when reading crc.\n"); + result = N_FAIL; + return result; + } + } + } else if ((cmd == CMD_DMA_READ) || (cmd == CMD_DMA_EXT_READ)) { + int ix; + + /* some data may be read in response to dummy bytes. */ + for (ix = 0; (rix < len2) && (ix < sz); ) { + b[ix++] = rb[rix++]; + } +#if 0 + if (ix) + PRINT_D(BUS_DBG, "ttt %d %d\n", sz, ix); +#endif + sz -= ix; + + if (sz > 0) { + int nbytes; + + if (sz <= (DATA_PKT_SZ - ix)) { + nbytes = sz; + } else { + nbytes = DATA_PKT_SZ - ix; + } + + /** + * Read bytes + **/ + if (!g_spi.spi_rx(&b[ix], nbytes)) { + PRINT_ER("[wilc spi]: Failed data block read, bus error...\n"); + result = N_FAIL; + goto _error_; + } + + /** + * Read Crc + **/ + if (!g_spi.crc_off) { + if (!g_spi.spi_rx(crc, 2)) { + PRINT_ER("[wilc spi]: Failed data block crc read, bus error...\n"); + result = N_FAIL; + goto _error_; + } + } + + + ix += nbytes; + sz -= nbytes; + } + + /* if any data in left unread, then read the rest using normal DMA code.*/ + while (sz > 0) { + int nbytes; + +#if 0 + PRINT_INFO(BUS_DBG, "rrr %d %d\n", sz, ix); +#endif + if (sz <= DATA_PKT_SZ) { + nbytes = sz; + } else { + nbytes = DATA_PKT_SZ; + } + + /** + * read data response only on the next DMA cycles not + * the first DMA since data response header is already + * handled above for the first DMA. + **/ + /** + * Data Respnose header + **/ + retry = 10; + do { + if (!g_spi.spi_rx(&rsp, 1)) { + PRINT_ER("[wilc spi]: Failed data response read, bus error...\n"); + result = N_FAIL; + break; + } + if (((rsp >> 4) & 0xf) == 0xf) + break; + } while (retry--); + + if (result == N_FAIL) + break; + + + /** + * Read bytes + **/ + if (!g_spi.spi_rx(&b[ix], nbytes)) { + PRINT_ER("[wilc spi]: Failed data block read, bus error...\n"); + result = N_FAIL; + break; + } + + /** + * Read Crc + **/ + if (!g_spi.crc_off) { + if (!g_spi.spi_rx(crc, 2)) { + PRINT_ER("[wilc spi]: Failed data block crc read, bus error...\n"); + result = N_FAIL; + break; + } + } + + ix += nbytes; + sz -= nbytes; + } + } + } +_error_: + return result; +} + +static int spi_data_read(uint8_t *b, uint32_t sz) +{ + int retry, ix, nbytes; + int result = N_OK; + uint8_t crc[2]; + uint8_t rsp; + + /** + * Data + **/ + ix = 0; + do { + if (sz <= DATA_PKT_SZ) + nbytes = sz; + else + nbytes = DATA_PKT_SZ; + + /** + * Data Respnose header + **/ + retry = 10; + do { + if (!g_spi.spi_rx(&rsp, 1)) { + PRINT_ER("[wilc spi]: Failed data response read, bus error...\n"); + result = N_FAIL; + break; + } + if (((rsp >> 4) & 0xf) == 0xf) + break; + } while (retry--); + + if (result == N_FAIL) + break; + + if (retry <= 0) { + PRINT_ER("[wilc spi]: Failed data response read...(%02x)\n", rsp); + result = N_FAIL; + break; + } + + /** + * Read bytes + **/ + if (!g_spi.spi_rx(&b[ix], nbytes)) { + PRINT_ER("[wilc spi]: Failed data block read, bus error...\n"); + result = N_FAIL; + break; + } + + /** + * Read Crc + **/ + if (!g_spi.crc_off) { + if (!g_spi.spi_rx(crc, 2)) { + PRINT_ER("[wilc spi]: Failed data block crc read, bus error...\n"); + result = N_FAIL; + break; + } + } + + ix += nbytes; + sz -= nbytes; + + } while (sz); + + return result; +} + +static int spi_data_write(uint8_t *b, uint32_t sz) +{ + int ix, nbytes; + int result = 1; + uint8_t cmd, order, crc[2] = {0}; + /* uint8_t rsp; */ + + /** + * Data + **/ + ix = 0; + do { + if (sz <= DATA_PKT_SZ) + nbytes = sz; + else + nbytes = DATA_PKT_SZ; + + /** + * Write command + **/ + cmd = 0xf0; + if (ix == 0) { + if (sz <= DATA_PKT_SZ) + + order = 0x3; + else + order = 0x1; + } else { + if (sz <= DATA_PKT_SZ) + order = 0x3; + else + order = 0x2; + } + cmd |= order; + if (!g_spi.spi_tx(&cmd, 1)) { + PRINT_ER("[wilc spi]: Failed data block cmd write, bus error...\n"); + result = N_FAIL; + break; + } + + /** + * Write data + **/ + if (!g_spi.spi_tx(&b[ix], nbytes)) { + PRINT_ER("[wilc spi]: Failed data block write, bus error...\n"); + result = N_FAIL; + break; + } + + /** + * Write Crc + **/ + if (!g_spi.crc_off) { + if (!g_spi.spi_tx(crc, 2)) { + PRINT_ER("[wilc spi]: Failed data block crc write, bus error...\n"); + result = N_FAIL; + break; + } + } + + /** + * No need to wait for response + **/ +#if 0 + /** + * Respnose + **/ + if (!g_spi.spi_rx(&rsp, 1)) { + PRINT_ER("[wilc spi]: Failed data block write, response read, bus error...\n"); + result = N_FAIL; + break; + } + + if (((rsp >> 4) & 0xf) != 0xc) { + result = N_FAIL; + PRINT_ER("[wilc spi]: Failed data block write response...(%02x)\n", rsp); + break; + } + + /** + * State + **/ + if (!g_spi.spi_rx(&rsp, 1)) { + PRINT_ER("[wilc spi]: Failed data block write, read state, bus error...\n"); + result = N_FAIL; + break; + } +#endif + + ix += nbytes; + sz -= nbytes; + } while (sz); + + + return result; +} + +/******************************************** + * + * Spi Internal Read/Write Function + * + ********************************************/ + +static int spi_internal_write(uint32_t adr, uint32_t dat) +{ + int result; + +#if defined USE_OLD_SPI_SW + /** + * Command + **/ + result = spi_cmd(CMD_INTERNAL_WRITE, adr, dat, 4, 0); + if (result != N_OK) { + PRINT_ER("[wilc spi]: Failed internal write cmd...\n"); + return 0; + } + + result = spi_cmd_rsp(CMD_INTERNAL_WRITE, 0); + if (result != N_OK) { + PRINT_ER("[wilc spi]: Failed internal write cmd response...\n"); + } +#else + +#ifdef BIG_ENDIAN + dat = BYTE_SWAP(dat); +#endif + result = spi_cmd_complete(CMD_INTERNAL_WRITE, adr, (uint8_t *)&dat, 4, 0); + if (result != N_OK) { + PRINT_ER("[wilc spi]: Failed internal write cmd...\n"); + } + +#endif + return result; +} + +static int spi_internal_read(uint32_t adr, uint32_t *data) +{ + int result; + +#if defined USE_OLD_SPI_SW + result = spi_cmd(CMD_INTERNAL_READ, adr, 0, 4, 0); + if (result != N_OK) { + PRINT_ER("[wilc spi]: Failed internal read cmd...\n"); + return 0; + } + + result = spi_cmd_rsp(CMD_INTERNAL_READ, 0); + if (result != N_OK) { + PRINT_ER("[wilc spi]: Failed internal read cmd response...\n"); + return 0; + } + + /** + * Data + **/ + result = spi_data_read((uint8_t *)data, 4); + if (result != N_OK) { + PRINT_ER("[wilc spi]: Failed internal read data...\n"); + return 0; + } +#else + result = spi_cmd_complete(CMD_INTERNAL_READ, adr, (uint8_t *)data, 4, 0); + if (result != N_OK) { + PRINT_ER("[wilc spi]: Failed internal read cmd...\n"); + return 0; + } +#endif + + +#ifdef BIG_ENDIAN + *data = BYTE_SWAP(*data); +#endif + + return 1; +} + +/******************************************** + * + * Spi interfaces + * + ********************************************/ + +static int spi_write_reg(uint32_t addr, uint32_t data) +{ + int result = N_OK; + uint8_t cmd = CMD_SINGLE_WRITE; + uint8_t clockless = 0; + + +#if defined USE_OLD_SPI_SW + { + result = spi_cmd(cmd, addr, data, 4, 0); + if (result != N_OK) { + PRINT_ER("[wilc spi]: Failed cmd, write reg (%08x)...\n", addr); + return 0; + } + + result = spi_cmd_rsp(cmd, 0); + if (result != N_OK) { + PRINT_ER("[wilc spi]: Failed cmd response, write reg (%08x)...\n", addr); + return 0; + } + + return 1; + } +#else +#ifdef BIG_ENDIAN + data = BYTE_SWAP(data); +#endif + if (addr < 0x30) { + /* Clockless register*/ + cmd = CMD_INTERNAL_WRITE; + clockless = 1; + } + + result = spi_cmd_complete(cmd, addr, (uint8_t *)&data, 4, clockless); + if (result != N_OK) { + PRINT_ER("[wilc spi]: Failed cmd, write reg (%08x)...\n", addr); + } + + return result; +#endif + +} + +static int spi_write(uint32_t addr, uint8_t *buf, uint32_t size) +{ + int result; + uint8_t cmd = CMD_DMA_EXT_WRITE; + + /** + * has to be greated than 4 + **/ + if (size <= 4) + return 0; + +#if defined USE_OLD_SPI_SW + /** + * Command + **/ + result = spi_cmd(cmd, addr, 0, size, 0); + if (result != N_OK) { + PRINT_ER("[wilc spi]: Failed cmd, write block (%08x)...\n", addr); + return 0; + } + + result = spi_cmd_rsp(cmd, 0); + if (result != N_OK) { + PRINT_ER("[wilc spi ]: Failed cmd response, write block (%08x)...\n", addr); + return 0; + } +#else + result = spi_cmd_complete(cmd, addr, NULL, size, 0); + if (result != N_OK) { + PRINT_ER("[wilc spi]: Failed cmd, write block (%08x)...\n", addr); + return 0; + } +#endif + + /** + * Data + **/ + result = spi_data_write(buf, size); + if (result != N_OK) { + PRINT_ER("[wilc spi]: Failed block data write...\n"); + } + + return 1; +} + +static int spi_read_reg(uint32_t addr, uint32_t *data) +{ + int result = N_OK; + uint8_t cmd = CMD_SINGLE_READ; + uint8_t clockless = 0; + +#if defined USE_OLD_SPI_SW + result = spi_cmd(cmd, addr, 0, 4, 0); + if (result != N_OK) { + PRINT_ER("[wilc spi]: Failed cmd, read reg (%08x)...\n", addr); + return 0; + } + result = spi_cmd_rsp(cmd, 0); + if (result != N_OK) { + PRINT_ER("[wilc spi]: Failed cmd response, read reg (%08x)...\n", addr); + return 0; + } + + result = spi_data_read((uint8_t *)data, 4); + if (result != N_OK) { + PRINT_ER("[wilc spi]: Failed data read...\n"); + return 0; + } +#else + if (addr < 0x30) { + /* PRINT_ER("***** read addr %d\n\n", addr); */ + /* Clockless register*/ + cmd = CMD_INTERNAL_READ; + clockless = 1; + } + + result = spi_cmd_complete(cmd, addr, (uint8_t *)data, 4, clockless); + if (result != N_OK) { + PRINT_ER("[wilc spi]: Failed cmd, read reg (%08x)...\n", addr); + return 0; + } +#endif + + +#ifdef BIG_ENDIAN + *data = BYTE_SWAP(*data); +#endif + + return 1; +} + +static int spi_read(uint32_t addr, uint8_t *buf, uint32_t size) +{ + uint8_t cmd = CMD_DMA_EXT_READ; + int result; + + if (size <= 4) + return 0; + +#if defined USE_OLD_SPI_SW + /** + * Command + **/ + result = spi_cmd(cmd, addr, 0, size, 0); + if (result != N_OK) { + PRINT_ER("[wilc spi]: Failed cmd, read block (%08x)...\n", addr); + return 0; + } + + result = spi_cmd_rsp(cmd, 0); + if (result != N_OK) { + PRINT_ER("[wilc spi]: Failed cmd response, read block (%08x)...\n", addr); + return 0; + } + + /** + * Data + **/ + result = spi_data_read(buf, size); + if (result != N_OK) { + PRINT_ER("[wilc spi]: Failed block data read...\n"); + return 0; + } +#else + result = spi_cmd_complete(cmd, addr, buf, size, 0); + if (result != N_OK) { + PRINT_ER("[wilc spi]: Failed cmd, read block (%08x)...\n", addr); + return 0; + } +#endif + + + return 1; +} + +/******************************************** + * + * Bus interfaces + * + ********************************************/ + +static int spi_clear_int(void) +{ + uint32_t reg; + if (!spi_read_reg(WILC_HOST_RX_CTRL_0, ®)) { + PRINT_ER("[wilc spi]: Failed read reg (%08x)...\n", WILC_HOST_RX_CTRL_0); + return 0; + } + reg &= ~0x1; + spi_write_reg(WILC_HOST_RX_CTRL_0, reg); + int_clrd++; + return 1; +} + +static int spi_deinit(void *pv) +{ + /** + * TODO: + **/ + return 1; +} + +static int spi_sync(void) +{ + uint32_t reg; + int ret; + + /** + * interrupt pin mux select + **/ + ret = spi_read_reg(WILC_PIN_MUX_0, ®); + if (!ret) { + PRINT_ER("[wilc spi]: Failed read reg (%08x)...\n", WILC_PIN_MUX_0); + return 0; + } + reg |= (1 << 8); + ret = spi_write_reg(WILC_PIN_MUX_0, reg); + if (!ret) { + PRINT_ER("[wilc spi]: Failed write reg (%08x)...\n", WILC_PIN_MUX_0); + return 0; + } + + /** + * interrupt enable + **/ + ret = spi_read_reg(WILC_INTR_ENABLE, ®); + if (!ret) { + PRINT_ER("[wilc spi]: Failed read reg (%08x)...\n", WILC_INTR_ENABLE); + return 0; + } + reg |= (1 << 16); + ret = spi_write_reg(WILC_INTR_ENABLE, reg); + if (!ret) { + PRINT_ER("[wilc spi]: Failed write reg (%08x)...\n", WILC_INTR_ENABLE); + return 0; + } + + return 1; +} + +static int spi_init(wilc_wlan_inp_t *inp, wilc_debug_func func) +{ + uint32_t reg; + uint32_t chipid; + + static int isinit; + + if (isinit) { + + if (!spi_read_reg(0x1000, &chipid)) { + PRINT_ER("[wilc spi]: Fail cmd read chip id...\n"); + return 0; + } + return 1; + } + + memset(&g_spi, 0, sizeof(wilc_spi_t)); + + g_spi.dPrint = func; + g_spi.os_context = inp->os_context.os_private; + if (inp->io_func.io_init) { + if (!inp->io_func.io_init(g_spi.os_context)) { + PRINT_ER("[wilc spi]: Failed io init bus...\n"); + return 0; + } + } else { + return 0; + } + g_spi.spi_tx = inp->io_func.u.spi.spi_tx; + g_spi.spi_rx = inp->io_func.u.spi.spi_rx; + g_spi.spi_trx = inp->io_func.u.spi.spi_trx; + g_spi.spi_max_speed = inp->io_func.u.spi.spi_max_speed; + + /** + * configure protocol + **/ + g_spi.crc_off = 0; + + /* TODO: We can remove the CRC trials if there is a definite way to reset */ + /* the SPI to it's initial value. */ + if (!spi_internal_read(WILC_SPI_PROTOCOL_OFFSET, ®)) { + /* Read failed. Try with CRC off. This might happen when module + * is removed but chip isn't reset*/ + g_spi.crc_off = 1; + PRINT_ER("[wilc spi]: Failed internal read protocol with CRC on, retyring with CRC off...\n", __LINE__); + if (!spi_internal_read(WILC_SPI_PROTOCOL_OFFSET, ®)) { + /* Reaad failed with both CRC on and off, something went bad */ + PRINT_ER("[wilc spi]: Failed internal read protocol...\n", __LINE__); + return 0; + } + } + if (g_spi.crc_off == 0) { + reg &= ~0xc; /* disable crc checking */ + reg &= ~0x70; + reg |= (0x5 << 4); + if (!spi_internal_write(WILC_SPI_PROTOCOL_OFFSET, reg)) { + PRINT_ER("[wilc spi %d]: Failed internal write protocol reg...\n", __LINE__); + return 0; + } + g_spi.crc_off = 1; + } + + + /** + * make sure can read back chip id correctly + **/ + if (!spi_read_reg(0x1000, &chipid)) { + PRINT_ER("[wilc spi]: Fail cmd read chip id...\n"); + return 0; + } + /* PRINT_ER("[wilc spi]: chipid (%08x)\n", chipid); */ + + g_spi.has_thrpt_enh = 1; + + isinit = 1; + + return 1; +} + +static void spi_max_bus_speed(void) +{ + g_spi.spi_max_speed(); +} + +static void spi_default_bus_speed(void) +{ +} + +static int spi_read_size(uint32_t *size) +{ + int ret; + if (g_spi.has_thrpt_enh) { + ret = spi_internal_read(0xe840 - WILC_SPI_REG_BASE, size); + *size = *size & IRQ_DMA_WD_CNT_MASK; + } else { + uint32_t tmp; + uint32_t byte_cnt; + + ret = spi_read_reg(WILC_VMM_TO_HOST_SIZE, &byte_cnt); + if (!ret) { + PRINT_ER("[wilc spi]: Failed read WILC_VMM_TO_HOST_SIZE ...\n"); + goto _fail_; + } + tmp = (byte_cnt >> 2) & IRQ_DMA_WD_CNT_MASK; + *size = tmp; + } + + + +_fail_: + return ret; +} + + + +static int spi_read_int(uint32_t *int_status) +{ + int ret; + if (g_spi.has_thrpt_enh) { + ret = spi_internal_read(0xe840 - WILC_SPI_REG_BASE, int_status); + } else { + uint32_t tmp; + uint32_t byte_cnt; + + ret = spi_read_reg(WILC_VMM_TO_HOST_SIZE, &byte_cnt); + if (!ret) { + PRINT_ER("[wilc spi]: Failed read WILC_VMM_TO_HOST_SIZE ...\n"); + goto _fail_; + } + tmp = (byte_cnt >> 2) & IRQ_DMA_WD_CNT_MASK; + + { + int happended, j; + + j = 0; + do { + uint32_t irq_flags; + + happended = 0; + + spi_read_reg(0x1a90, &irq_flags); + tmp |= ((irq_flags >> 27) << IRG_FLAGS_OFFSET); + + if (g_spi.nint > 5) { + spi_read_reg(0x1a94, &irq_flags); + tmp |= (((irq_flags >> 0) & 0x7) << (IRG_FLAGS_OFFSET + 5)); + } + + { + uint32_t unkmown_mask; + + unkmown_mask = ~((1ul << g_spi.nint) - 1); + + if ((tmp >> IRG_FLAGS_OFFSET) & unkmown_mask) { + PRINT_ER("[wilc spi]: Unexpected interrupt (2): j=%d, tmp=%x, mask=%x\n", j, tmp, unkmown_mask); + happended = 1; + } + } + j++; + } while (happended); + } + + *int_status = tmp; + + } + +_fail_: + return ret; +} + +static int spi_clear_int_ext(uint32_t val) +{ + int ret; + + if (g_spi.has_thrpt_enh) { + ret = spi_internal_write(0xe844 - WILC_SPI_REG_BASE, val); + } else { + uint32_t flags; + flags = val & ((1 << MAX_NUM_INT) - 1); + if (flags) { + int i; + + ret = 1; + for (i = 0; i < g_spi.nint; i++) { + /* No matter what you write 1 or 0, it will clear interrupt. */ + if (flags & 1) + ret = spi_write_reg(0x10c8 + i * 4, 1); + if (!ret) + break; + flags >>= 1; + } + if (!ret) { + PRINT_ER("[wilc spi]: Failed spi_write_reg, set reg %x ...\n", 0x10c8 + i * 4); + goto _fail_; + } + for (i = g_spi.nint; i < MAX_NUM_INT; i++) { + if (flags & 1) + PRINT_ER("[wilc spi]: Unexpected interrupt cleared %d...\n", i); + flags >>= 1; + } + } + + { + uint32_t tbl_ctl; + + tbl_ctl = 0; + /* select VMM table 0 */ + if ((val & SEL_VMM_TBL0) == SEL_VMM_TBL0) + tbl_ctl |= (1 << 0); + /* select VMM table 1 */ + if ((val & SEL_VMM_TBL1) == SEL_VMM_TBL1) + tbl_ctl |= (1 << 1); + + ret = spi_write_reg(WILC_VMM_TBL_CTL, tbl_ctl); + if (!ret) { + PRINT_ER("[wilc spi]: fail write reg vmm_tbl_ctl...\n"); + goto _fail_; + } + + if ((val & EN_VMM) == EN_VMM) { + /** + * enable vmm transfer. + **/ + ret = spi_write_reg(WILC_VMM_CORE_CTL, 1); + if (!ret) { + PRINT_ER("[wilc spi]: fail write reg vmm_core_ctl...\n"); + goto _fail_; + } + } + } + } +_fail_: + return ret; +} + +static int spi_sync_ext(int nint /* how mant interrupts to enable. */) +{ + uint32_t reg; + int ret, i; + + if (nint > MAX_NUM_INT) { + PRINT_ER("[wilc spi]: Too many interupts (%d)...\n", nint); + return 0; + } + + g_spi.nint = nint; + + /** + * interrupt pin mux select + **/ + ret = spi_read_reg(WILC_PIN_MUX_0, ®); + if (!ret) { + PRINT_ER("[wilc spi]: Failed read reg (%08x)...\n", WILC_PIN_MUX_0); + return 0; + } + reg |= (1 << 8); + ret = spi_write_reg(WILC_PIN_MUX_0, reg); + if (!ret) { + PRINT_ER("[wilc spi]: Failed write reg (%08x)...\n", WILC_PIN_MUX_0); + return 0; + } + + /** + * interrupt enable + **/ + ret = spi_read_reg(WILC_INTR_ENABLE, ®); + if (!ret) { + PRINT_ER("[wilc spi]: Failed read reg (%08x)...\n", WILC_INTR_ENABLE); + return 0; + } + + for (i = 0; (i < 5) && (nint > 0); i++, nint--) { + reg |= (1 << (27 + i)); + } + ret = spi_write_reg(WILC_INTR_ENABLE, reg); + if (!ret) { + PRINT_ER("[wilc spi]: Failed write reg (%08x)...\n", WILC_INTR_ENABLE); + return 0; + } + if (nint) { + ret = spi_read_reg(WILC_INTR2_ENABLE, ®); + if (!ret) { + PRINT_ER("[wilc spi]: Failed read reg (%08x)...\n", WILC_INTR2_ENABLE); + return 0; + } + + for (i = 0; (i < 3) && (nint > 0); i++, nint--) { + reg |= (1 << i); + } + + ret = spi_read_reg(WILC_INTR2_ENABLE, ®); + if (!ret) { + PRINT_ER("[wilc spi]: Failed write reg (%08x)...\n", WILC_INTR2_ENABLE); + return 0; + } + } + + return 1; +} +/******************************************** + * + * Global spi HIF function table + * + ********************************************/ +wilc_hif_func_t hif_spi = { + spi_init, + spi_deinit, + spi_read_reg, + spi_write_reg, + spi_read, + spi_write, + spi_sync, + spi_clear_int, + spi_read_int, + spi_clear_int_ext, + spi_read_size, + spi_write, + spi_read, + spi_sync_ext, + spi_max_bus_speed, + spi_default_bus_speed, +}; + diff --git a/drivers/staging/wilc1000/wilc_strutils.c b/drivers/staging/wilc1000/wilc_strutils.c new file mode 100644 index 000000000000..9e525d56feb8 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_strutils.c @@ -0,0 +1,431 @@ + +#define _CRT_SECURE_NO_DEPRECATE + +#include "wilc_oswrapper.h" + +#ifdef CONFIG_WILC_STRING_UTILS + + +/*! + * @author syounan + * @date 18 Aug 2010 + * @version 1.0 + */ +WILC_Sint32 WILC_memcmp(const void *pvArg1, const void *pvArg2, WILC_Uint32 u32Count) +{ + return memcmp(pvArg1, pvArg2, u32Count); +} + + +/*! + * @author syounan + * @date 18 Aug 2010 + * @version 1.0 + */ +void WILC_memcpy_INTERNAL(void *pvTarget, const void *pvSource, WILC_Uint32 u32Count) +{ + memcpy(pvTarget, pvSource, u32Count); +} + +/*! + * @author syounan + * @date 18 Aug 2010 + * @version 1.0 + */ +void *WILC_memset(void *pvTarget, WILC_Uint8 u8SetValue, WILC_Uint32 u32Count) +{ + return memset(pvTarget, u8SetValue, u32Count); +} + +/*! + * @author syounan + * @date 18 Aug 2010 + * @version 1.0 + */ +WILC_Char *WILC_strncat(WILC_Char *pcTarget, const WILC_Char *pcSource, + WILC_Uint32 u32Count) +{ + return strncat(pcTarget, pcSource, u32Count); +} + +/*! + * @author syounan + * @date 18 Aug 2010 + * @version 1.0 + */ +WILC_Char *WILC_strncpy(WILC_Char *pcTarget, const WILC_Char *pcSource, + WILC_Uint32 u32Count) +{ + return strncpy(pcTarget, pcSource, u32Count); +} + +/*! + * @author syounan + * @date 18 Aug 2010 + * @version 1.0 + */ +WILC_Sint32 WILC_strcmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2) +{ + WILC_Sint32 s32Result; + + if (pcStr1 == WILC_NULL && pcStr2 == WILC_NULL) { + s32Result = 0; + } else if (pcStr1 == WILC_NULL) { + s32Result = -1; + } else if (pcStr2 == WILC_NULL) { + s32Result = 1; + } else { + s32Result = strcmp(pcStr1, pcStr2); + if (s32Result < 0) { + s32Result = -1; + } else if (s32Result > 0) { + s32Result = 1; + } + } + + return s32Result; +} + +WILC_Sint32 WILC_strncmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2, + WILC_Uint32 u32Count) +{ + WILC_Sint32 s32Result; + + if (pcStr1 == WILC_NULL && pcStr2 == WILC_NULL) { + s32Result = 0; + } else if (pcStr1 == WILC_NULL) { + s32Result = -1; + } else if (pcStr2 == WILC_NULL) { + s32Result = 1; + } else { + s32Result = strncmp(pcStr1, pcStr2, u32Count); + if (s32Result < 0) { + s32Result = -1; + } else if (s32Result > 0) { + s32Result = 1; + } + } + + return s32Result; +} + +/* + * @author syounan + * @date 1 Nov 2010 + * @version 2.0 + */ +WILC_Sint32 WILC_strcmp_IgnoreCase(const WILC_Char *pcStr1, const WILC_Char *pcStr2) +{ + WILC_Sint32 s32Result; + + if (pcStr1 == WILC_NULL && pcStr2 == WILC_NULL) { + s32Result = 0; + } else if (pcStr1 == WILC_NULL) { + s32Result = -1; + } else if (pcStr2 == WILC_NULL) { + s32Result = 1; + } else { + WILC_Char cTestedChar1, cTestedChar2; + do { + cTestedChar1 = *pcStr1; + if ((*pcStr1 >= 'a') && (*pcStr1 <= 'z')) { + /* turn a lower case character to an upper case one */ + cTestedChar1 -= 32; + } + + cTestedChar2 = *pcStr2; + if ((*pcStr2 >= 'a') && (*pcStr2 <= 'z')) { + /* turn a lower case character to an upper case one */ + cTestedChar2 -= 32; + } + + pcStr1++; + pcStr2++; + + } while ((cTestedChar1 == cTestedChar2) + && (cTestedChar1 != 0) + && (cTestedChar2 != 0)); + + if (cTestedChar1 > cTestedChar2) { + s32Result = 1; + } else if (cTestedChar1 < cTestedChar2) { + s32Result = -1; + } else { + s32Result = 0; + } + } + + return s32Result; +} + +/*! + * @author aabozaeid + * @date 8 Dec 2010 + * @version 1.0 + */ +WILC_Sint32 WILC_strncmp_IgnoreCase(const WILC_Char *pcStr1, const WILC_Char *pcStr2, + WILC_Uint32 u32Count) +{ + WILC_Sint32 s32Result; + + if (pcStr1 == WILC_NULL && pcStr2 == WILC_NULL) { + s32Result = 0; + } else if (pcStr1 == WILC_NULL) { + s32Result = -1; + } else if (pcStr2 == WILC_NULL) { + s32Result = 1; + } else { + WILC_Char cTestedChar1, cTestedChar2; + do { + cTestedChar1 = *pcStr1; + if ((*pcStr1 >= 'a') && (*pcStr1 <= 'z')) { + /* turn a lower case character to an upper case one */ + cTestedChar1 -= 32; + } + + cTestedChar2 = *pcStr2; + if ((*pcStr2 >= 'a') && (*pcStr2 <= 'z')) { + /* turn a lower case character to an upper case one */ + cTestedChar2 -= 32; + } + + pcStr1++; + pcStr2++; + u32Count--; + + } while ((u32Count > 0) + && (cTestedChar1 == cTestedChar2) + && (cTestedChar1 != 0) + && (cTestedChar2 != 0)); + + if (cTestedChar1 > cTestedChar2) { + s32Result = 1; + } else if (cTestedChar1 < cTestedChar2) { + s32Result = -1; + } else { + s32Result = 0; + } + } + + return s32Result; + +} + +/*! + * @author syounan + * @date 18 Aug 2010 + * @version 1.0 + */ +WILC_Uint32 WILC_strlen(const WILC_Char *pcStr) +{ + return (WILC_Uint32)strlen(pcStr); +} + +/*! + * @author bfahmy + * @date 28 Aug 2010 + * @version 1.0 + */ +WILC_Sint32 WILC_strtoint(const WILC_Char *pcStr) +{ + return (WILC_Sint32)(simple_strtol(pcStr, NULL, 10)); +} + +/* + * @author syounan + * @date 1 Nov 2010 + * @version 2.0 + */ +WILC_ErrNo WILC_snprintf(WILC_Char *pcTarget, WILC_Uint32 u32Size, + const WILC_Char *pcFormat, ...) +{ + va_list argptr; + va_start(argptr, pcFormat); + if (vsnprintf(pcTarget, u32Size, pcFormat, argptr) < 0) { + /* if turncation happens windows does not properly terminate strings */ + pcTarget[u32Size - 1] = 0; + } + va_end(argptr); + + /* I find no sane way of detecting errors in windows, so let it all succeed ! */ + return WILC_SUCCESS; +} + +#ifdef CONFIG_WILC_EXTENDED_STRING_OPERATIONS + +/** + * @brief + * @details Searches for the first occurrence of the character c in the first n bytes + * of the string pointed to by the argument str. + * Returns a pointer pointing to the first matching character, + * or null if no match was found. + * @param[in] + * @return + * @note + * @author remil + * @date 3 Nov 2010 + * @version 1.0 + */ +WILC_Char *WILC_memchr(const void *str, WILC_Char c, WILC_Sint32 n) +{ + return (WILC_Char *) memchr(str, c, (size_t)n); +} + +/** + * @brief + * @details Searches for the first occurrence of the character c (an unsigned char) + * in the string pointed to by the argument str. + * The terminating null character is considered to be part of the string. + * Returns a pointer pointing to the first matching character, + * or null if no match was found. + * @param[in] + * @return + * @note + * @author remil + * @date 3 Nov 2010 + * @version 1.0 + */ +WILC_Char *WILC_strchr(const WILC_Char *str, WILC_Char c) +{ + return strchr(str, c); +} + +/** + * @brief + * @details Appends the string pointed to by str2 to the end of the string pointed to by str1. + * The terminating null character of str1 is overwritten. + * Copying stops once the terminating null character of str2 is copied. If overlapping occurs, the result is undefined. + * The argument str1 is returned. + * @param[in] WILC_Char* str1, + * @param[in] WILC_Char* str2, + * @return WILC_Char* + * @note + * @author remil + * @date 3 Nov 2010 + * @version 1.0 + */ +WILC_Char *WILC_strcat(WILC_Char *str1, const WILC_Char *str2) +{ + return strcat(str1, str2); +} + +/** + * @brief + * @details Copy pcSource to pcTarget + * @param[in] WILC_Char* pcTarget + * @param[in] const WILC_Char* pcSource + * @return WILC_Char* + * @note + * @author remil + * @date 3 Nov 2010 + * @version 1.0 + */ +WILC_Char *WILC_strcpy(WILC_Char *pcTarget, const WILC_Char *pcSource) +{ + return strncpy(pcTarget, pcSource, strlen(pcSource)); +} + +/** + * @brief + * @details Finds the first sequence of characters in the string str1 that + * does not contain any character specified in str2. + * Returns the length of this first sequence of characters found that + * do not match with str2. + * @param[in] const WILC_Char *str1 + * @param[in] const WILC_Char *str2 + * @return WILC_Uint32 + * @note + * @author remil + * @date 3 Nov 2010 + * @version 1.0 + */ +WILC_Uint32 WILC_strcspn(const WILC_Char *str1, const WILC_Char *str2) +{ + return (WILC_Uint32)strcspn(str1, str2); +} +#if 0 +/** + * @brief + * @details Searches an internal array for the error number errnum and returns a pointer + * to an error message string. + * Returns a pointer to an error message string. + * @param[in] WILC_Sint32 errnum + * @return WILC_Char* + * @note + * @author remil + * @date 3 Nov 2010 + * @version 1.0 + */ +WILC_Char *WILC_strerror(WILC_Sint32 errnum) +{ + return strerror(errnum); +} +#endif + +/** + * @brief + * @details Finds the first occurrence of the entire string str2 + * (not including the terminating null character) which appears in the string str1. + * Returns a pointer to the first occurrence of str2 in str1. + * If no match was found, then a null pointer is returned. + * If str2 points to a string of zero length, then the argument str1 is returned. + * @param[in] const WILC_Char *str1 + * @param[in] const WILC_Char *str2 + * @return WILC_Char* + * @note + * @author remil + * @date 3 Nov 2010 + * @version 1.0 + */ +WILC_Char *WILC_strstr(const WILC_Char *str1, const WILC_Char *str2) +{ + return strstr(str1, str2); +} +#if 0 +/** + * @brief + * @details Parses the C string str interpreting its content as a floating point + * number and returns its value as a double. + * If endptr is not a null pointer, the function also sets the value pointed + * by endptr to point to the first character after the number. + * @param[in] const WILC_Char* str + * @param[in] WILC_Char** endptr + * @return WILC_Double + * @note + * @author remil + * @date 11 Nov 2010 + * @version 1.0 + */ +WILC_Double WILC_StringToDouble(const WILC_Char *str, WILC_Char **endptr) +{ + return strtod (str, endptr); +} +#endif + +/** + * @brief Parses the C string str interpreting its content as an unsigned integral + * number of the specified base, which is returned as an unsigned long int value. + * @details The function first discards as many whitespace characters as necessary + * until the first non-whitespace character is found. + * Then, starting from this character, takes as many characters as possible + * that are valid following a syntax that depends on the base parameter, + * and interprets them as a numerical value. + * Finally, a pointer to the first character following the integer + * representation in str is stored in the object pointed by endptr. + * @param[in] const WILC_Char *str + * @param[in] WILC_Char **endptr + * @param[in] WILC_Sint32 base + * @return WILC_Uint32 + * @note + * @author remil + * @date 11 Nov 2010 + * @version 1.0 + */ +WILC_Uint32 WILC_StringToUint32(const WILC_Char *str, WILC_Char **endptr, WILC_Sint32 base) +{ + return simple_strtoul(str, endptr, base); +} + +#endif + +#endif diff --git a/drivers/staging/wilc1000/wilc_strutils.h b/drivers/staging/wilc1000/wilc_strutils.h new file mode 100644 index 000000000000..3a973a5ec61b --- /dev/null +++ b/drivers/staging/wilc1000/wilc_strutils.h @@ -0,0 +1,412 @@ +#ifndef __WILC_STRUTILS_H__ +#define __WILC_STRUTILS_H__ + +/*! + * @file wilc_strutils.h + * @brief Basic string utilities + * @author syounan + * @sa wilc_oswrapper.h top level OS wrapper file + * @date 16 Aug 2010 + * @version 1.0 + */ + +#ifndef CONFIG_WILC_STRING_UTILS +#error the feature CONFIG_WILC_STRING_UTILS must be supported to include this file +#endif + +/*! + * @brief Compares two memory buffers + * @param[in] pvArg1 pointer to the first memory location + * @param[in] pvArg2 pointer to the second memory location + * @param[in] u32Count the size of the memory buffers + * @return 0 if the 2 buffers are equal, 1 if pvArg1 is bigger than pvArg2, + * -1 if pvArg1 smaller than pvArg2 + * @note this function repeats the functionality of standard memcmp + * @author syounan + * @date 18 Aug 2010 + * @version 1.0 + */ +WILC_Sint32 WILC_memcmp(const void *pvArg1, const void *pvArg2, WILC_Uint32 u32Count); + +/*! + * @brief Internal implementation for memory copy + * @param[in] pvTarget the target buffer to which the data is copied into + * @param[in] pvSource pointer to the second memory location + * @param[in] u32Count the size of the data to copy + * @note this function should not be used directly, use WILC_memcpy instead + * @author syounan + * @date 18 Aug 2010 + * @version 1.0 + */ +void WILC_memcpy_INTERNAL(void *pvTarget, const void *pvSource, WILC_Uint32 u32Count); + +/*! + * @brief Copies the contents of a memory buffer into another + * @param[in] pvTarget the target buffer to which the data is copied into + * @param[in] pvSource pointer to the second memory location + * @param[in] u32Count the size of the data to copy + * @return WILC_SUCCESS if copy is successfully handeled + * WILC_FAIL if copy failed + * @note this function repeats the functionality of standard memcpy, + * however memcpy is undefined if the two buffers overlap but this + * implementation will check for overlap and report error + * @author syounan + * @date 18 Aug 2010 + * @version 1.0 + */ +static WILC_ErrNo WILC_memcpy(void *pvTarget, const void *pvSource, WILC_Uint32 u32Count) +{ + if ( + (((WILC_Uint8 *)pvTarget <= (WILC_Uint8 *)pvSource) + && (((WILC_Uint8 *)pvTarget + u32Count) > (WILC_Uint8 *)pvSource)) + + || (((WILC_Uint8 *)pvSource <= (WILC_Uint8 *)pvTarget) + && (((WILC_Uint8 *)pvSource + u32Count) > (WILC_Uint8 *)pvTarget)) + ) { + /* ovelapped memory, return Error */ + return WILC_FAIL; + } else { + WILC_memcpy_INTERNAL(pvTarget, pvSource, u32Count); + return WILC_SUCCESS; + } +} + +/*! + * @brief Sets the contents of a memory buffer with the given value + * @param[in] pvTarget the target buffer which contsnts will be set + * @param[in] u8SetValue the value to be used + * @param[in] u32Count the size of the memory buffer + * @return value of pvTarget + * @note this function repeats the functionality of standard memset + * @author syounan + * @date 18 Aug 2010 + * @version 1.0 + */ +void *WILC_memset(void *pvTarget, WILC_Uint8 u8SetValue, WILC_Uint32 u32Count); + +/*! + * @brief Concatenates the contents of 2 strings up to a given count + * @param[in] pcTarget the target string, its null character will be overwritten + * and contents of pcSource will be concatentaed to it + * @param[in] pcSource the source string the will be concatentaed + * @param[in] u32Count copying will proceed until a null character in pcSource + * is encountered or u32Count of bytes copied + * @return value of pcTarget + * @note this function repeats the functionality of standard strncat + * @author syounan + * @date 18 Aug 2010 + * @version 1.0 + */ +WILC_Char *WILC_strncat(WILC_Char *pcTarget, const WILC_Char *pcSource, + WILC_Uint32 u32Count); + +/*! + * @brief copies the contents of source string into the target string + * @param[in] pcTarget the target string buffer + * @param[in] pcSource the source string the will be copied + * @param[in] u32Count copying will proceed until a null character in pcSource + * is encountered or u32Count of bytes copied + * @return value of pcTarget + * @note this function repeats the functionality of standard strncpy + * @author syounan + * @date 18 Aug 2010 + * @version 1.0 + */ +WILC_Char *WILC_strncpy(WILC_Char *pcTarget, const WILC_Char *pcSource, + WILC_Uint32 u32Count); + +/*! + * @brief Compares two strings + * @details Compares 2 strings reporting which is bigger, WILC_NULL is considered + * the smallest string, then a zero length string then all other + * strings depending on thier ascii characters order + * @param[in] pcStr1 the first string, WILC_NULL is valid and considered smaller + * than any other non-NULL string (incliding zero lenght strings) + * @param[in] pcStr2 the second string, WILC_NULL is valid and considered smaller + * than any other non-NULL string (incliding zero lenght strings) + * @return 0 if the 2 strings are equal, 1 if pcStr1 is bigger than pcStr2, + * -1 if pcStr1 smaller than pcStr2 + * @note this function repeats the functionality of standard strcmp + * @author syounan + * @date 18 Aug 2010 + * @version 1.0 + */ +WILC_Sint32 WILC_strcmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2); + +/*! + * @brief Compares two strings up to u32Count characters + * @details Compares 2 strings reporting which is bigger, WILC_NULL is considered + * the smallest string, then a zero length string then all other + * strings depending on thier ascii characters order with small case + * converted to uppder case + * @param[in] pcStr1 the first string, WILC_NULL is valid and considered smaller + * than any other non-NULL string (incliding zero lenght strings) + * @param[in] pcStr2 the second string, WILC_NULL is valid and considered smaller + * than any other non-NULL string (incliding zero lenght strings) + * @param[in] u32Count copying will proceed until a null character in pcStr1 or + * pcStr2 is encountered or u32Count of bytes copied + * @return 0 if the 2 strings are equal, 1 if pcStr1 is bigger than pcStr2, + * -1 if pcStr1 smaller than pcStr2 + * @author aabozaeid + * @date 7 Dec 2010 + * @version 1.0 + */ +WILC_Sint32 WILC_strncmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2, + WILC_Uint32 u32Count); + +/*! + * @brief Compares two strings ignoring the case of its latin letters + * @details Compares 2 strings reporting which is bigger, WILC_NULL is considered + * the smallest string, then a zero length string then all other + * strings depending on thier ascii characters order with small case + * converted to uppder case + * @param[in] pcStr1 the first string, WILC_NULL is valid and considered smaller + * than any other non-NULL string (incliding zero lenght strings) + * @param[in] pcStr2 the second string, WILC_NULL is valid and considered smaller + * than any other non-NULL string (incliding zero lenght strings) + * @return 0 if the 2 strings are equal, 1 if pcStr1 is bigger than pcStr2, + * -1 if pcStr1 smaller than pcStr2 + * @author syounan + * @date 1 Nov 2010 + * @version 2.0 + */ +WILC_Sint32 WILC_strcmp_IgnoreCase(const WILC_Char *pcStr1, const WILC_Char *pcStr2); + +/*! + * @brief Compares two strings ignoring the case of its latin letters up to + * u32Count characters + * @details Compares 2 strings reporting which is bigger, WILC_NULL is considered + * the smallest string, then a zero length string then all other + * strings depending on thier ascii characters order with small case + * converted to uppder case + * @param[in] pcStr1 the first string, WILC_NULL is valid and considered smaller + * than any other non-NULL string (incliding zero lenght strings) + * @param[in] pcStr2 the second string, WILC_NULL is valid and considered smaller + * than any other non-NULL string (incliding zero lenght strings) + * @param[in] u32Count copying will proceed until a null character in pcStr1 or + * pcStr2 is encountered or u32Count of bytes copied + * @return 0 if the 2 strings are equal, 1 if pcStr1 is bigger than pcStr2, + * -1 if pcStr1 smaller than pcStr2 + * @author aabozaeid + * @date 7 Dec 2010 + * @version 1.0 + */ +WILC_Sint32 WILC_strncmp_IgnoreCase(const WILC_Char *pcStr1, const WILC_Char *pcStr2, + WILC_Uint32 u32Count); + +/*! + * @brief gets the length of a string + * @param[in] pcStr the string + * @return the length + * @note this function repeats the functionality of standard strlen + * @author syounan + * @date 18 Aug 2010 + * @version 1.0 + */ +WILC_Uint32 WILC_strlen(const WILC_Char *pcStr); + +/*! + * @brief convert string to integer + * @param[in] pcStr the string + * @return the value of string + * @note this function repeats the functionality of the libc atoi + * @author bfahmy + * @date 28 Aug 2010 + * @version 1.0 + */ +WILC_Sint32 WILC_strtoint(const WILC_Char *pcStr); + +/*! + * @brief print a formatted string into a buffer + * @param[in] pcTarget the buffer where the resulting string is written + * @param[in] u32Size size of the output beffer including the \0 terminating + * character + * @param[in] pcFormat format of the string + * @return number of character written or would have been written if the + * string were not truncated + * @note this function repeats the functionality of standard snprintf + * @author syounan + * @date 1 Nov 2010 + * @version 2.0 + */ +WILC_Sint32 WILC_snprintf(WILC_Char *pcTarget, WILC_Uint32 u32Size, + const WILC_Char *pcFormat, ...); + + +#ifdef CONFIG_WILC_EXTENDED_STRING_OPERATIONS + + +/** + * @brief + * @details Searches for the first occurrence of the character c in the first n bytes + * of the string pointed to by the argument str. + * Returns a pointer pointing to the first matching character, + * or null if no match was found. + * @param[in] + * @return + * @note + * @author remil + * @date 3 Nov 2010 + * @version 1.0 + */ +WILC_Char *WILC_memchr(const void *str, WILC_Char c, WILC_Sint32 n); + +/** + * @brief + * @details Searches for the first occurrence of the character c (an unsigned char) + * in the string pointed to by the argument str. + * The terminating null character is considered to be part of the string. + * Returns a pointer pointing to the first matching character, + * or null if no match was found. + * @param[in] + * @return + * @note + * @author remil + * @date 3 Nov 2010 + * @version 1.0 + */ +WILC_Char *WILC_strchr(const WILC_Char *str, WILC_Char c); + +/** + * @brief + * @details Appends the string pointed to by str2 to the end of the string pointed to by str1. + * The terminating null character of str1 is overwritten. + * Copying stops once the terminating null character of str2 is copied. If overlapping occurs, the result is undefined. + * The argument str1 is returned. + * @param[in] WILC_Char* str1, + * @param[in] WILC_Char* str2, + * @return WILC_Char* + * @note + * @author remil + * @date 3 Nov 2010 + * @version 1.0 + */ +WILC_Char *WILC_strcat(WILC_Char *str1, const WILC_Char *str2); + + +/** + * @brief + * @details Copy pcSource to pcTarget + * @param[in] WILC_Char* pcTarget + * @param[in] const WILC_Char* pcSource + * @return WILC_Char* + * @note + * @author remil + * @date 3 Nov 2010 + * @version 1.0 + */ +WILC_Char *WILC_strcpy(WILC_Char *pcTarget, const WILC_Char *pcSource); + + + +/** + * @brief + * @details Finds the first sequence of characters in the string str1 that + * does not contain any character specified in str2. + * Returns the length of this first sequence of characters found that + * do not match with str2. + * @param[in] const WILC_Char *str1 + * @param[in] const WILC_Char *str2 + * @return WILC_Uint32 + * @note + * @author remil + * @date 3 Nov 2010 + * @version 1.0 + */ +WILC_Uint32 WILC_strcspn(const WILC_Char *str1, const WILC_Char *str2); + + +/** + * @brief + * @details Searches an internal array for the error number errnum and returns a pointer + * to an error message string. + * Returns a pointer to an error message string. + * @param[in] WILC_Sint32 errnum + * @return WILC_Char* + * @note + * @author remil + * @date 3 Nov 2010 + * @version 1.0 + */ +WILC_Char *WILC_strerror(WILC_Sint32 errnum); + +/** + * @brief + * @details Finds the first occurrence of the entire string str2 + * (not including the terminating null character) which appears in the string str1. + * Returns a pointer to the first occurrence of str2 in str1. + * If no match was found, then a null pointer is returned. + * If str2 points to a string of zero length, then the argument str1 is returned. + * @param[in] const WILC_Char *str1 + * @param[in] const WILC_Char *str2 + * @return WILC_Char* + * @note + * @author remil + * @date 3 Nov 2010 + * @version 1.0 + */ +WILC_Char *WILC_strstr(const WILC_Char *str1, const WILC_Char *str2); + +/** + * @brief + * @details Searches for the first occurrence of the character c (an unsigned char) + * in the string pointed to by the argument str. + * The terminating null character is considered to be part of the string. + * Returns a pointer pointing to the first matching character, + * or null if no match was found. + * @param[in] + * @return + * @note + * @author remil + * @date 3 Nov 2010 + * @version 1.0 + */ +WILC_Char *WILC_strchr(const WILC_Char *str, WILC_Char c); + + +/** + * @brief + * @details Parses the C string str interpreting its content as a floating point + * number and returns its value as a double. + * If endptr is not a null pointer, the function also sets the value pointed + * by endptr to point to the first character after the number. + * @param[in] const WILC_Char* str + * @param[in] WILC_Char** endptr + * @return WILC_Double + * @note + * @author remil + * @date 11 Nov 2010 + * @version 1.0 + */ +WILC_Double WILC_StringToDouble(const WILC_Char *str, + WILC_Char **endptr); + + +/** + * @brief Parses the C string str interpreting its content as an unsigned integral + * number of the specified base, which is returned as an unsigned long int value. + * @details The function first discards as many whitespace characters as necessary + * until the first non-whitespace character is found. + * Then, starting from this character, takes as many characters as possible + * that are valid following a syntax that depends on the base parameter, + * and interprets them as a numerical value. + * Finally, a pointer to the first character following the integer + * representation in str is stored in the object pointed by endptr. + * @param[in] const WILC_Char *str + * @param[in] WILC_Char **endptr + * @param[in] WILC_Sint32 base + * @return WILC_Uint32 + * @note + * @author remil + * @date 11 Nov 2010 + * @version 1.0 + */ +WILC_Uint32 WILC_StringToUint32(const WILC_Char *str, + WILC_Char **endptr, + WILC_Sint32 base); + + + +#endif + +#endif diff --git a/drivers/staging/wilc1000/wilc_thread.c b/drivers/staging/wilc1000/wilc_thread.c new file mode 100644 index 000000000000..5eb04e839309 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_thread.c @@ -0,0 +1,35 @@ + +#include "wilc_oswrapper.h" + +#ifdef CONFIG_WILC_THREAD_FEATURE + + + +WILC_ErrNo WILC_ThreadCreate(WILC_ThreadHandle *pHandle, tpfWILC_ThreadFunction pfEntry, + void *pvArg, tstrWILC_ThreadAttrs *pstrAttrs) +{ + + + *pHandle = kthread_run((int (*)(void *))pfEntry, pvArg, "WILC_kthread"); + + + if (IS_ERR(*pHandle)) { + return WILC_FAIL; + } else { + return WILC_SUCCESS; + } + +} + +WILC_ErrNo WILC_ThreadDestroy(WILC_ThreadHandle *pHandle, + tstrWILC_ThreadAttrs *pstrAttrs) +{ + WILC_ErrNo s32RetStatus = WILC_SUCCESS; + + kthread_stop(*pHandle); + return s32RetStatus; +} + + + +#endif diff --git a/drivers/staging/wilc1000/wilc_thread.h b/drivers/staging/wilc1000/wilc_thread.h new file mode 100644 index 000000000000..c862cd544dd4 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_thread.h @@ -0,0 +1,153 @@ +#ifndef __WILC_THREAD_H__ +#define __WILC_THREAD_H__ + +/*! + * @file wilc_thread.h + * @brief Thread OS Wrapper functionality + * @author syounan + * @sa wilc_oswrapper.h top level OS wrapper file + * @date 10 Aug 2010 + * @version 1.0 + */ + +#ifndef CONFIG_WILC_THREAD_FEATURE +#error the feature WILC_OS_FEATURE_THREAD must be supported to include this file +#endif + +typedef void (*tpfWILC_ThreadFunction)(void *); + +typedef enum { + #ifdef CONFIG_WILC_THREAD_STRICT_PRIORITY + WILC_OS_THREAD_PIORITY_0 = 0, + WILC_OS_THREAD_PIORITY_1 = 1, + WILC_OS_THREAD_PIORITY_2 = 2, + WILC_OS_THREAD_PIORITY_3 = 3, + WILC_OS_THREAD_PIORITY_4 = 4, + #endif + + WILC_OS_THREAD_PIORITY_HIGH = 0, + WILC_OS_THREAD_PIORITY_NORMAL = 2, + WILC_OS_THREAD_PIORITY_LOW = 4 +} tenuWILC_ThreadPiority; + +/*! + * @struct WILC_ThreadAttrs + * @brief Thread API options + * @author syounan + * @date 10 Aug 2010 + * @version 1.0 + */ +typedef struct { + /*!< + * stack size for use with WILC_ThreadCreate, default is WILC_OS_THREAD_DEFAULT_STACK + */ + WILC_Uint32 u32StackSize; + + /*!< + * piority for the thread, if WILC_OS_FEATURE_THREAD_STRICT_PIORITY is defined + * this value is strictly observed and can take a larger resolution + */ + tenuWILC_ThreadPiority enuPiority; + + #ifdef CONFIG_WILC_THREAD_SUSPEND_CONTROL + /*! + * if true the thread will be created suspended + */ + WILC_Bool bStartSuspended; + #endif + +} tstrWILC_ThreadAttrs; + +#define WILC_OS_THREAD_DEFAULT_STACK (10 * 1024) + +/*! + * @brief Fills the WILC_ThreadAttrs with default parameters + * @param[out] pstrAttrs structure to be filled + * @sa WILC_ThreadAttrs + * @author syounan + * @date 10 Aug 2010 + * @version 1.0 + */ + +static void WILC_ThreadFillDefault(tstrWILC_ThreadAttrs *pstrAttrs) +{ + pstrAttrs->u32StackSize = WILC_OS_THREAD_DEFAULT_STACK; + pstrAttrs->enuPiority = WILC_OS_THREAD_PIORITY_NORMAL; + + #ifdef CONFIG_WILC_THREAD_SUSPEND_CONTROL + pstrAttrs->bStartSuspended = WILC_FALSE; + #endif +} + +/*! + * @brief Creates a new thread + * @details if the feature WILC_OS_FEATURE_THREAD_SUSPEND_CONTROL is + * defined and tstrWILC_ThreadAttrs.bStartSuspended is set to true + * the new thread will be created in suspended state, otherwise + * it will start executing immeadiately + * if the feature WILC_OS_FEATURE_THREAD_STRICT_PIORITY is defined + * piorities are strictly observed, otherwise the underlaying OS + * may not observe piorities + * @param[out] pHandle handle to the newly created thread object + * @param[in] pfEntry pointer to the entry point of the new thread + * @param[in] pstrAttrs Optional attributes, NULL for default + * @return Error code indicating sucess/failure + * @sa WILC_ThreadAttrs + * @author syounan + * @date 10 Aug 2010 + * @version 1.0 + */ +WILC_ErrNo WILC_ThreadCreate(WILC_ThreadHandle *pHandle, tpfWILC_ThreadFunction pfEntry, + void *pvArg, tstrWILC_ThreadAttrs *pstrAttrs); + +/*! + * @brief Destroys the Thread object + * @details This function is used for clean up and freeing any used resources + * This function will block until the destroyed thread exits cleanely, + * so, the thread code thould handle an exit case before this calling + * this function + * @param[in] pHandle handle to the thread object + * @param[in] pstrAttrs Optional attributes, NULL for default + * @return Error code indicating sucess/failure + * @sa WILC_ThreadAttrs + * @author syounan + * @date 10 Aug 2010 + * @version 1.0 + */ +WILC_ErrNo WILC_ThreadDestroy(WILC_ThreadHandle *pHandle, + tstrWILC_ThreadAttrs *pstrAttrs); + +#ifdef CONFIG_WILC_THREAD_SUSPEND_CONTROL + +/*! + * @brief Suspends an executing Thread object + * @param[in] pHandle handle to the thread object + * @param[in] pstrAttrs Optional attributes, NULL for default + * @return Error code indicating sucess/failure + * @sa WILC_ThreadAttrs + * @note Optional part, WILC_OS_FEATURE_THREAD_SUSPEND_CONTROL must be enabled + * @author syounan + * @date 10 Aug 2010 + * @version 1.0 + */ +WILC_ErrNo WILC_ThreadSuspend(WILC_ThreadHandle *pHandle, + tstrWILC_ThreadAttrs *pstrAttrs); + +/*! + * @brief Resumes a suspened Thread object + * @param[in] pHandle handle to the thread object + * @param[in] pstrAttrs Optional attributes, NULL for default + * @return Error code indicating sucess/failure + * @sa WILC_ThreadAttrs + * @note Optional part, WILC_OS_FEATURE_THREAD_SUSPEND_CONTROL must be enabled + * @author syounan + * @date 10 Aug 2010 + * @version 1.0 + */ +WILC_ErrNo WILC_ThreadResume(WILC_ThreadHandle *pHandle, + tstrWILC_ThreadAttrs *pstrAttrs); + +#endif + + +#endif diff --git a/drivers/staging/wilc1000/wilc_time.c b/drivers/staging/wilc1000/wilc_time.c new file mode 100644 index 000000000000..27c252b462ac --- /dev/null +++ b/drivers/staging/wilc1000/wilc_time.c @@ -0,0 +1,163 @@ + +#define _CRT_SECURE_NO_DEPRECATE +#include "wilc_oswrapper.h" + +#ifdef CONFIG_WILC_TIME_FEATURE + + +WILC_Uint32 WILC_TimeMsec(void) +{ + WILC_Uint32 u32Time = 0; + struct timespec current_time; + + current_time = current_kernel_time(); + u32Time = current_time.tv_sec * 1000; + u32Time += current_time.tv_nsec / 1000000; + + + return u32Time; +} + + +#ifdef CONFIG_WILC_EXTENDED_TIME_OPERATIONS + +/** + * @brief + * @details function returns the implementation's best approximation to the + * processor time used by the process since the beginning of an + * implementation-dependent time related only to the process invocation. + * @return WILC_Uint32 + * @note + * @author remil + * @date 11 Nov 2010 + * @version 1.0 + */ +WILC_Uint32 WILC_Clock() +{ + +} + + +/** + * @brief + * @details The difftime() function computes the difference between two calendar + * times (as returned by WILC_GetTime()): time1 - time0. + * @param[in] WILC_Time time1 + * @param[in] WILC_Time time0 + * @return WILC_Double + * @note + * @author remil + * @date 11 Nov 2010 + * @version 1.0 + */ +WILC_Double WILC_DiffTime(WILC_Time time1, WILC_Time time0) +{ + +} + + + +/** + * @brief + * @details The gmtime() function converts the time in seconds since + * the Epoch pointed to by timer into a broken-down time, + * expressed as Coordinated Universal Time (UTC). + * @param[in] const WILC_Time* timer + * @return WILC_tm* + * @note + * @author remil + * @date 11 Nov 2010 + * @version 1.0 + */ +WILC_tm *WILC_GmTime(const WILC_Time *timer) +{ + +} + + +/** + * @brief + * @details The localtime() function converts the time in seconds since + * the Epoch pointed to by timer into a broken-down time, expressed + * as a local time. The function corrects for the timezone and any + * seasonal time adjustments. Local timezone information is used as + * though localtime() calls tzset(). + * @param[in] const WILC_Time* timer + * @return WILC_tm* + * @note + * @author remil + * @date 11 Nov 2010 + * @version 1.0 + */ +WILC_tm *WILC_LocalTime(const WILC_Time *timer) +{ + +} + + +/** + * @brief + * @details The mktime() function converts the broken-down time, + * expressed as local time, in the structure pointed to by timeptr, + * into a time since the Epoch value with the same encoding as that + * of the values returned by time(). The original values of the tm_wday + * and tm_yday components of the structure are ignored, and the original + * values of the other components are not restricted to the ranges described + * in the entry. + * @param[in] WILC_tm* timer + * @return WILC_Time + * @note + * @author remil + * @date 11 Nov 2010 + * @version 1.0 + */ +WILC_Time WILC_MkTime(WILC_tm *timer) +{ + +} + + +/** + * @brief + * @details The strftime() function places bytes into the array + * pointed to by s as controlled by the string pointed to by format. + * @param[in] WILC_Char* s + * @param[in] WILC_Uint32 maxSize + * @param[in] const WILC_Char* format + * @param[in] const WILC_tm* timptr + * @return WILC_Uint32 + * @note + * @author remil + * @date 11 Nov 2010 + * @version 1.0 + */ +WILC_Uint32 WILC_StringFormatTime(WILC_Char *s, + WILC_Uint32 maxSize, + const WILC_Char *format, + const WILC_tm *timptr) +{ + +} + + +/** + * @brief The WILC_GetTime() function returns the value of time in seconds since the Epoch. + * @details The tloc argument points to an area where the return value is also stored. + * If tloc is a null pointer, no value is stored. + * @param[in] WILC_Time* tloc + * @return WILC_Time + * @note + * @author remil + * @date 11 Nov 2010 + * @version 1.0 + */ +WILC_Time WILC_GetTime(WILC_Time *tloc) +{ + +} + + +#endif +#endif + + diff --git a/drivers/staging/wilc1000/wilc_time.h b/drivers/staging/wilc1000/wilc_time.h new file mode 100644 index 000000000000..787df7ded75c --- /dev/null +++ b/drivers/staging/wilc1000/wilc_time.h @@ -0,0 +1,205 @@ +#ifndef __WILC_TIME_H__ +#define __WILC_TIME_H__ + +/*! +* @file wilc_time.h +* @brief Time retrival functionality +* @author syounan +* @sa wilc_oswrapper.h top level OS wrapper file +* @date 2 Sep 2010 +* @version 1.0 +*/ + +#ifndef CONFIG_WILC_TIME_FEATURE +#error the feature CONFIG_WILC_TIME_FEATURE must be supported to include this file +#endif + +/*! +* @struct WILC_ThreadAttrs +* @brief Thread API options +* @author syounan +* @date 2 Sep 2010 +* @version 1.0 +*/ +typedef struct { + /* a dummy type to prevent compile errors on empty structure*/ + WILC_Uint8 dummy; +} tstrWILC_TimeAttrs; + +typedef struct { + /*!< current year */ + WILC_Uint16 u16Year; + /*!< current month */ + WILC_Uint8 u8Month; + /*!< current day */ + WILC_Uint8 u8Day; + + /*!< current hour (in 24H format) */ + WILC_Uint8 u8Hour; + /*!< current minute */ + WILC_Uint8 u8Miute; + /*!< current second */ + WILC_Uint8 u8Second; + +} tstrWILC_TimeCalender; + +/*! +* @brief returns the number of msec elapsed since system start up +* @return number of msec elapsed singe system start up +* @note since this returned value is 32 bit, the caller must handle + wraparounds in values every about 49 of continous operations +* @author syounan +* @date 2 Sep 2010 +* @version 1.0 +*/ +WILC_Uint32 WILC_TimeMsec(void); + + + +#ifdef CONFIG_WILC_EXTENDED_TIME_OPERATIONS +/** +* @brief +* @details function returns the implementation's best approximation to the + processor time used by the process since the beginning of an + implementation-dependent time related only to the process invocation. +* @return WILC_Uint32 +* @note +* @author remil +* @date 11 Nov 2010 +* @version 1.0 +*/ +WILC_Uint32 WILC_Clock(); + +/** +* @brief +* @details The difftime() function computes the difference between two calendar + times (as returned by WILC_GetTime()): time1 - time0. +* @param[in] WILC_Time time1 +* @param[in] WILC_Time time0 +* @return WILC_Double +* @note +* @author remil +* @date 11 Nov 2010 +* @version 1.0 +*/ +WILC_Double WILC_DiffTime(WILC_Time time1, WILC_Time time0); + +/** +* @brief +* @details The gmtime() function converts the time in seconds since + the Epoch pointed to by timer into a broken-down time, + expressed as Coordinated Universal Time (UTC). +* @param[in] const WILC_Time* timer +* @return WILC_tm* +* @note +* @author remil +* @date 11 Nov 2010 +* @version 1.0 +*/ +WILC_tm *WILC_GmTime(const WILC_Time *timer); + + +/** +* @brief +* @details The localtime() function converts the time in seconds since + the Epoch pointed to by timer into a broken-down time, expressed + as a local time. The function corrects for the timezone and any + seasonal time adjustments. Local timezone information is used as + though localtime() calls tzset(). +* @param[in] const WILC_Time* timer +* @return WILC_tm* +* @note +* @author remil +* @date 11 Nov 2010 +* @version 1.0 +*/ +WILC_tm *WILC_LocalTime(const WILC_Time *timer); + + +/** +* @brief +* @details The mktime() function converts the broken-down time, + expressed as local time, in the structure pointed to by timeptr, + into a time since the Epoch value with the same encoding as that + of the values returned by time(). The original values of the tm_wday + and tm_yday components of the structure are ignored, and the original + values of the other components are not restricted to the ranges described + in the entry. +* @param[in] WILC_tm* timer +* @return WILC_Time +* @note +* @author remil +* @date 11 Nov 2010 +* @version 1.0 +*/ +WILC_Time WILC_MkTime(WILC_tm *timer); + + +/** +* @brief +* @details The strftime() function places bytes into the array + pointed to by s as controlled by the string pointed to by format. +* @param[in] WILC_Char* s +* @param[in] WILC_Uint32 maxSize +* @param[in] const WILC_Char* format +* @param[in] const WILC_tm* timptr +* @return WILC_Uint32 +* @note +* @author remil +* @date 11 Nov 2010 +* @version 1.0 +*/ +WILC_Uint32 WILC_StringFormatTime(WILC_Char *s, + WILC_Uint32 maxSize, + const WILC_Char *format, + const WILC_tm *timptr); + + +/** +* @brief The WILC_GetTime() function returns the value of time in seconds since the Epoch. +* @details The tloc argument points to an area where the return value is also stored. + If tloc is a null pointer, no value is stored. +* @param[in] WILC_Time* tloc +* @return WILC_Time +* @note +* @author remil +* @date 11 Nov 2010 +* @version 1.0 +*/ +WILC_Time WILC_GetTime(WILC_Time *tloc); + +#endif + +#ifdef CONFIG_WILC_TIME_UTC_SINCE_1970 + +/*! +* @brief returns the number of seconds elapsed since 1970 (in UTC) +* @param[in] pstrAttrs Optional attributes, NULL for default +* @return number of seconds elapsed since 1970 (in UTC) +* @sa tstrWILC_TimeAttrs +* @author syounan +* @date 2 Sep 2010 +* @version 1.0 +*/ +WILC_Uint32 WILC_TimeUtcSince1970(tstrWILC_TimeAttrs *pstrAttrs); + +#endif + +#ifdef CONFIG_WILC_TIME_CALENDER + +/*! +* @brief gets the current calender time +* @return number of seconds elapsed since 1970 (in UTC) +* @param[out] ptstrCalender calender structure to be filled with time +* @param[in] pstrAttrs Optional attributes, NULL for default +* @sa WILC_ThreadAttrs +* @author syounan +* @date 2 Sep 2010 +* @version 1.0 +*/ +WILC_ErrNo WILC_TimeCalender(tstrWILC_TimeCalender *ptstrCalender, + tstrWILC_TimeAttrs *pstrAttrs); + +#endif + +#endif diff --git a/drivers/staging/wilc1000/wilc_timer.c b/drivers/staging/wilc1000/wilc_timer.c new file mode 100644 index 000000000000..477986dcff0a --- /dev/null +++ b/drivers/staging/wilc1000/wilc_timer.c @@ -0,0 +1,51 @@ + +#include "wilc_oswrapper.h" + +#ifdef CONFIG_WILC_TIMER_FEATURE + + + +WILC_ErrNo WILC_TimerCreate(WILC_TimerHandle *pHandle, + tpfWILC_TimerFunction pfCallback, tstrWILC_TimerAttrs *pstrAttrs) +{ + WILC_ErrNo s32RetStatus = WILC_SUCCESS; + setup_timer(pHandle, (void(*)(unsigned long))pfCallback, 0); + + return s32RetStatus; +} + +WILC_ErrNo WILC_TimerDestroy(WILC_TimerHandle *pHandle, + tstrWILC_TimerAttrs *pstrAttrs) +{ + WILC_ErrNo s32RetStatus = WILC_FAIL; + if (pHandle != NULL) { + s32RetStatus = del_timer_sync(pHandle); + pHandle = NULL; + } + + return s32RetStatus; +} + + +WILC_ErrNo WILC_TimerStart(WILC_TimerHandle *pHandle, WILC_Uint32 u32Timeout, + void *pvArg, tstrWILC_TimerAttrs *pstrAttrs) +{ + WILC_ErrNo s32RetStatus = WILC_FAIL; + if (pHandle != NULL) { + pHandle->data = (unsigned long)pvArg; + s32RetStatus = mod_timer(pHandle, (jiffies + msecs_to_jiffies(u32Timeout))); + } + return s32RetStatus; +} + +WILC_ErrNo WILC_TimerStop(WILC_TimerHandle *pHandle, + tstrWILC_TimerAttrs *pstrAttrs) +{ + WILC_ErrNo s32RetStatus = WILC_FAIL; + if (pHandle != NULL) + s32RetStatus = del_timer(pHandle); + + return s32RetStatus; +} + +#endif diff --git a/drivers/staging/wilc1000/wilc_timer.h b/drivers/staging/wilc1000/wilc_timer.h new file mode 100644 index 000000000000..1080ce24a045 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_timer.h @@ -0,0 +1,153 @@ +#ifndef __WILC_TIMER_H__ +#define __WILC_TIMER_H__ + +/*! + * @file wilc_timer.h + * @brief Timer (One Shot and Periodic) OS wrapper functionality + * @author syounan + * @sa wilc_oswrapper.h top level OS wrapper file + * @date 16 Aug 2010 + * @version 1.0 + */ + +#ifndef CONFIG_WILC_TIMER_FEATURE +#error the feature CONFIG_WILC_TIMER_FEATURE must be supported to include this file +#endif + +typedef void (*tpfWILC_TimerFunction)(void *); + +/*! + * @struct tstrWILC_TimerAttrs + * @brief Timer API options + * @author syounan + * @date 16 Aug 2010 + * @version 1.0 + */ +typedef struct { + /*!< if set to WILC_TRUE the callback function will be called + * periodically. */ + #ifdef CONFIG_WILC_TIMER_PERIODIC + WILC_Bool bPeriodicTimer; + #endif + + /* a dummy member to avoid compiler errors*/ + WILC_Uint8 dummy; +} tstrWILC_TimerAttrs; + +/*! + * @brief Fills the WILC_TimerAttrs with default parameters + * @param[out] pstrAttrs structure to be filled + * @sa WILC_TimerAttrs + * @author syounan + * @date 16 Aug 2010 + * @version 1.0 + */ + +static void WILC_TimerFillDefault(tstrWILC_TimerAttrs *pstrAttrs) +{ + #ifdef CONFIG_WILC_TIMER_PERIODIC + pstrAttrs->bPeriodicTimer = WILC_FALSE; + #endif +} + + +/*! + * @brief Creates a new timer + * @details Timers are a useful utility to execute some callback function + * in the future. + * A timer object has 3 states : IDLE, PENDING and EXECUTING + * IDLE : initial timer state after creation, no execution for the + * callback function is planned + * PENDING : a request to execute the callback function is made + * using WILC_TimerStart. + * EXECUTING : the timer has expired and its callback is now + * executing, when execution is done the timer returns to PENDING + * if the feature CONFIG_WILC_TIMER_PERIODIC is enabled and + * the flag tstrWILC_TimerAttrs.bPeriodicTimer is set. otherwise the + * timer will return to IDLE + * @param[out] pHandle handle to the newly created timer object + * @param[in] pfEntry pointer to the callback function to be called when the + * timer expires + * the underlaying OS may put many restrictions on what can be + * called inside a timer's callback, as a general rule no blocking + * operations (IO or semaphore Acquision) should be perfomred + * It is recommended that the callback will be as short as possible + * and only flags other threads to do the actual work + * also it should be noted that the underlaying OS maynot give any + * guarentees on which contect this callback will execute in + * @param[in] pstrAttrs Optional attributes, NULL for default + * @return Error code indicating sucess/failure + * @sa WILC_TimerAttrs + * @author syounan + * @date 16 Aug 2010 + * @version 1.0 + */ +WILC_ErrNo WILC_TimerCreate(WILC_TimerHandle *pHandle, + tpfWILC_TimerFunction pfCallback, tstrWILC_TimerAttrs *pstrAttrs); + + +/*! + * @brief Destroys a given timer + * @details This will destroy a given timer freeing any resources used by it + * if the timer was PENDING Then must be cancelled as well(i.e. + * goes to IDLE, same effect as calling WILC_TimerCancel first) + * if the timer was EXECUTING then the callback will be allowed to + * finish first then all resources are freed + * @param[in] pHandle handle to the timer object + * @param[in] pstrAttrs Optional attributes, NULL for default + * @return Error code indicating sucess/failure + * @sa WILC_TimerAttrs + * @author syounan + * @date 16 Aug 2010 + * @version 1.0 + */ +WILC_ErrNo WILC_TimerDestroy(WILC_TimerHandle *pHandle, + tstrWILC_TimerAttrs *pstrAttrs); + +/*! + * @brief Starts a given timer + * @details This function will move the timer to the PENDING state until the + * given time expires (in msec) then the callback function will be + * executed (timer in EXECUTING state) after execution is dene the + * timer either goes to IDLE (if bPeriodicTimer==WILC_FALSE) or + * PENDING with same timeout value (if bPeriodicTimer==WILC_TRUE) + * @param[in] pHandle handle to the timer object + * @param[in] u32Timeout timeout value in msec after witch the callback + * function will be executed. Timeout value of 0 is not allowed for + * periodic timers + * @param[in] pstrAttrs Optional attributes, NULL for default, + * set bPeriodicTimer to run this timer as a periodic timer + * @return Error code indicating sucess/failure + * @sa WILC_TimerAttrs + * @author syounan + * @date 16 Aug 2010 + * @version 1.0 + */ +WILC_ErrNo WILC_TimerStart(WILC_TimerHandle *pHandle, WILC_Uint32 u32Timeout, void *pvArg, + tstrWILC_TimerAttrs *pstrAttrs); + + +/*! + * @brief Stops a given timer + * @details This function will move the timer to the IDLE state cancelling + * any sheduled callback execution. + * if this function is called on a timer already in the IDLE state + * it will have no effect. + * if this function is called on a timer in EXECUTING state + * (callback has already started) it will wait until executing is + * done then move the timer to the IDLE state (which is trivial + * work if the timer is non periodic) + * @param[in] pHandle handle to the timer object + * @param[in] pstrAttrs Optional attributes, NULL for default, + * @return Error code indicating sucess/failure + * @sa WILC_TimerAttrs + * @author syounan + * @date 16 Aug 2010 + * @version 1.0 + */ +WILC_ErrNo WILC_TimerStop(WILC_TimerHandle *pHandle, + tstrWILC_TimerAttrs *pstrAttrs); + + + +#endif diff --git a/drivers/staging/wilc1000/wilc_type.h b/drivers/staging/wilc1000/wilc_type.h new file mode 100644 index 000000000000..5f36e7f92cd1 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_type.h @@ -0,0 +1,34 @@ +/* ////////////////////////////////////////////////////////////////////////// */ +/* */ +/* Copyright (c) Atmel Corporation. All rights reserved. */ +/* */ +/* Module Name: wilc_type.h */ +/* */ +/* */ +/* //////////////////////////////////////////////////////////////////////////// */ +#ifndef WILC_TYPE_H +#define WILC_TYPE_H + +/******************************************** + * + * Type Defines + * + ********************************************/ +#ifdef WIN32 +typedef char int8_t; +typedef short int16_t; +typedef long int32_t; +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned long uint32_t; +#else +#ifdef _linux_ +/*typedef unsigned char uint8_t; + * typedef unsigned short uint16_t; + * typedef unsigned long uint32_t;*/ +#include +#else +#include "wilc_oswrapper.h" +#endif +#endif +#endif diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c new file mode 100644 index 000000000000..648472925de0 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -0,0 +1,4592 @@ +/*! + * @file wilc_wfi_cfgopertaions.c + * @brief CFG80211 Function Implementation functionality + * @author aabouzaeid + * mabubakr + * mdaftedar + * zsalah + * @sa wilc_wfi_cfgopertaions.h top level OS wrapper file + * @date 31 Aug 2010 + * @version 1.0 + */ + +#include "wilc_wfi_cfgoperations.h" +#include "wilc_wlan.c" +#ifdef WILC_SDIO +#include "linux_wlan_sdio.h" /* tony : for set_wiphy_dev() */ +#endif + + +#define IS_MANAGMEMENT 0x100 +#define IS_MANAGMEMENT_CALLBACK 0x080 +#define IS_MGMT_STATUS_SUCCES 0x040 +#define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff) + +extern void linux_wlan_free(void *vp); +extern int linux_wlan_get_firmware(perInterface_wlan_t *p_nic); +extern void linux_wlan_unlock(void *vp); +extern WILC_Uint16 Set_machw_change_vir_if(WILC_Bool bValue); + +extern int mac_open(struct net_device *ndev); +extern int mac_close(struct net_device *ndev); + +tstrNetworkInfo astrLastScannedNtwrksShadow[MAX_NUM_SCANNED_NETWORKS_SHADOW]; +WILC_Uint32 u32LastScannedNtwrksCountShadow; +#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP +WILC_TimerHandle hDuringIpTimer; +#endif +WILC_TimerHandle hAgingTimer; +static WILC_Uint8 op_ifcs; +extern WILC_Uint8 u8ConnectedSSID[6]; + +/*BugID_5137*/ +WILC_Uint8 g_wilc_initialized = 1; +extern linux_wlan_t *g_linux_wlan; +#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP +extern WILC_Bool g_obtainingIP; +#endif + +#define CHAN2G(_channel, _freq, _flags) { \ + .band = IEEE80211_BAND_2GHZ, \ + .center_freq = (_freq), \ + .hw_value = (_channel), \ + .flags = (_flags), \ + .max_antenna_gain = 0, \ + .max_power = 30, \ +} + +/*Frequency range for channels*/ +static struct ieee80211_channel WILC_WFI_2ghz_channels[] = { + CHAN2G(1, 2412, 0), + CHAN2G(2, 2417, 0), + CHAN2G(3, 2422, 0), + CHAN2G(4, 2427, 0), + CHAN2G(5, 2432, 0), + CHAN2G(6, 2437, 0), + CHAN2G(7, 2442, 0), + CHAN2G(8, 2447, 0), + CHAN2G(9, 2452, 0), + CHAN2G(10, 2457, 0), + CHAN2G(11, 2462, 0), + CHAN2G(12, 2467, 0), + CHAN2G(13, 2472, 0), + CHAN2G(14, 2484, 0), +}; + +#define RATETAB_ENT(_rate, _hw_value, _flags) { \ + .bitrate = (_rate), \ + .hw_value = (_hw_value), \ + .flags = (_flags), \ +} + + +/* Table 6 in section 3.2.1.1 */ +static struct ieee80211_rate WILC_WFI_rates[] = { + RATETAB_ENT(10, 0, 0), + RATETAB_ENT(20, 1, 0), + RATETAB_ENT(55, 2, 0), + RATETAB_ENT(110, 3, 0), + RATETAB_ENT(60, 9, 0), + RATETAB_ENT(90, 6, 0), + RATETAB_ENT(120, 7, 0), + RATETAB_ENT(180, 8, 0), + RATETAB_ENT(240, 9, 0), + RATETAB_ENT(360, 10, 0), + RATETAB_ENT(480, 11, 0), + RATETAB_ENT(540, 12, 0), +}; + +#ifdef WILC_P2P +struct p2p_mgmt_data { + int size; + u8 *buff; +}; + +/*Global variable used to state the current connected STA channel*/ +WILC_Uint8 u8WLANChannel = INVALID_CHANNEL; + +/*BugID_5442*/ +WILC_Uint8 u8CurrChannel; + +WILC_Uint8 u8P2P_oui[] = {0x50, 0x6f, 0x9A, 0x09}; +WILC_Uint8 u8P2Plocalrandom = 0x01; +WILC_Uint8 u8P2Precvrandom = 0x00; +WILC_Uint8 u8P2P_vendorspec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03}; +WILC_Bool bWilc_ie = WILC_FALSE; +#endif + +static struct ieee80211_supported_band WILC_WFI_band_2ghz = { + .channels = WILC_WFI_2ghz_channels, + .n_channels = ARRAY_SIZE(WILC_WFI_2ghz_channels), + .bitrates = WILC_WFI_rates, + .n_bitrates = ARRAY_SIZE(WILC_WFI_rates), +}; + + +/*BugID_5137*/ +struct add_key_params { + u8 key_idx; + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) + bool pairwise; + #endif + u8 *mac_addr; +}; +struct add_key_params g_add_gtk_key_params; +struct wilc_wfi_key g_key_gtk_params; +struct add_key_params g_add_ptk_key_params; +struct wilc_wfi_key g_key_ptk_params; +struct wilc_wfi_wep_key g_key_wep_params; +WILC_Uint8 g_flushing_in_progress; +WILC_Bool g_ptk_keys_saved = WILC_FALSE; +WILC_Bool g_gtk_keys_saved = WILC_FALSE; +WILC_Bool g_wep_keys_saved = WILC_FALSE; + +#define AGING_TIME (9 * 1000) +#define duringIP_TIME 15000 + +void clear_shadow_scan(void *pUserVoid) +{ + struct WILC_WFI_priv *priv; + int i; + priv = (struct WILC_WFI_priv *)pUserVoid; + if (op_ifcs == 0) { + WILC_TimerDestroy(&hAgingTimer, WILC_NULL); + PRINT_INFO(CORECONFIG_DBG, "destroy aging timer\n"); + + for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) { + if (astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs != NULL) { + WILC_FREE(astrLastScannedNtwrksShadow[i].pu8IEs); + astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs = NULL; + } + + host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams); + astrLastScannedNtwrksShadow[i].pJoinParams = NULL; + } + u32LastScannedNtwrksCountShadow = 0; + } + +} + +uint32_t get_rssi_avg(tstrNetworkInfo *pstrNetworkInfo) +{ + uint8_t i; + int rssi_v = 0; + uint8_t num_rssi = (pstrNetworkInfo->strRssi.u8Full) ? NUM_RSSI : (pstrNetworkInfo->strRssi.u8Index); + + for (i = 0; i < num_rssi; i++) + rssi_v += pstrNetworkInfo->strRssi.as8RSSI[i]; + + rssi_v /= num_rssi; + return rssi_v; +} + +void refresh_scan(void *pUserVoid, uint8_t all, WILC_Bool bDirectScan) +{ + struct WILC_WFI_priv *priv; + struct wiphy *wiphy; + struct cfg80211_bss *bss = NULL; + int i; + int rssi = 0; + + priv = (struct WILC_WFI_priv *)pUserVoid; + wiphy = priv->dev->ieee80211_ptr->wiphy; + + for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) { + tstrNetworkInfo *pstrNetworkInfo; + pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]); + + + if ((!pstrNetworkInfo->u8Found) || all) { + WILC_Sint32 s32Freq; + struct ieee80211_channel *channel; + + if (pstrNetworkInfo != WILC_NULL) { + + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38) + s32Freq = ieee80211_channel_to_frequency((WILC_Sint32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ); + #else + s32Freq = ieee80211_channel_to_frequency((WILC_Sint32)pstrNetworkInfo->u8channel); + #endif + + channel = ieee80211_get_channel(wiphy, s32Freq); + + rssi = get_rssi_avg(pstrNetworkInfo); + if (WILC_memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7) || bDirectScan) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0) + bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo, + pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs, + (size_t)pstrNetworkInfo->u16IEsLen, (((WILC_Sint32)rssi) * 100), GFP_KERNEL); +#else + bss = cfg80211_inform_bss(wiphy, channel, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo, + pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs, + (size_t)pstrNetworkInfo->u16IEsLen, (((WILC_Sint32)rssi) * 100), GFP_KERNEL); +#endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0) + cfg80211_put_bss(wiphy, bss); +#else + cfg80211_put_bss(bss); +#endif + } + } + + } + } + +} + +void reset_shadow_found(void *pUserVoid) +{ + struct WILC_WFI_priv *priv; + int i; + priv = (struct WILC_WFI_priv *)pUserVoid; + for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) { + astrLastScannedNtwrksShadow[i].u8Found = 0; + + } +} + +void update_scan_time(void *pUserVoid) +{ + struct WILC_WFI_priv *priv; + int i; + priv = (struct WILC_WFI_priv *)pUserVoid; + for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) { + astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies; + } +} + +void remove_network_from_shadow(void *pUserVoid) +{ + struct WILC_WFI_priv *priv; + unsigned long now = jiffies; + int i, j; + + priv = (struct WILC_WFI_priv *)pUserVoid; + + for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) { + if (time_after(now, astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan + (unsigned long)(SCAN_RESULT_EXPIRE))) { + PRINT_D(CFG80211_DBG, "Network expired in ScanShadow: %s \n", astrLastScannedNtwrksShadow[i].au8ssid); + + if (astrLastScannedNtwrksShadow[i].pu8IEs != NULL) { + WILC_FREE(astrLastScannedNtwrksShadow[i].pu8IEs); + astrLastScannedNtwrksShadow[i].pu8IEs = NULL; + } + + host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams); + + for (j = i; (j < u32LastScannedNtwrksCountShadow - 1); j++) { + astrLastScannedNtwrksShadow[j] = astrLastScannedNtwrksShadow[j + 1]; + } + u32LastScannedNtwrksCountShadow--; + } + } + + PRINT_D(CFG80211_DBG, "Number of cached networks: %d\n", u32LastScannedNtwrksCountShadow); + if (u32LastScannedNtwrksCountShadow != 0) + WILC_TimerStart(&(hAgingTimer), AGING_TIME, pUserVoid, WILC_NULL); + else + PRINT_D(CFG80211_DBG, "No need to restart Aging timer\n"); +} + +#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP +void clear_duringIP(void *pUserVoid) +{ + PRINT_D(GENERIC_DBG, "GO:IP Obtained , enable scan\n"); + g_obtainingIP = WILC_FALSE; +} +#endif + +int8_t is_network_in_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid) +{ + struct WILC_WFI_priv *priv; + int8_t state = -1; + int i; + + priv = (struct WILC_WFI_priv *)pUserVoid; + if (u32LastScannedNtwrksCountShadow == 0) { + PRINT_D(CFG80211_DBG, "Starting Aging timer\n"); + WILC_TimerStart(&(hAgingTimer), AGING_TIME, pUserVoid, WILC_NULL); + state = -1; + } else { + /* Linear search for now */ + for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) { + if (WILC_memcmp(astrLastScannedNtwrksShadow[i].au8bssid, + pstrNetworkInfo->au8bssid, 6) == 0) { + state = i; + break; + } + } + } + return state; +} + +void add_network_to_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams) +{ + struct WILC_WFI_priv *priv; + int8_t ap_found = is_network_in_shadow(pstrNetworkInfo, pUserVoid); + uint32_t ap_index = 0; + uint8_t rssi_index = 0; + priv = (struct WILC_WFI_priv *)pUserVoid; + + if (u32LastScannedNtwrksCountShadow >= MAX_NUM_SCANNED_NETWORKS_SHADOW) { + PRINT_D(CFG80211_DBG, "Shadow network reached its maximum limit\n"); + return; + } + if (ap_found == -1) { + ap_index = u32LastScannedNtwrksCountShadow; + u32LastScannedNtwrksCountShadow++; + + } else { + ap_index = ap_found; + } + rssi_index = astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index; + astrLastScannedNtwrksShadow[ap_index].strRssi.as8RSSI[rssi_index++] = pstrNetworkInfo->s8rssi; + if (rssi_index == NUM_RSSI) { + rssi_index = 0; + astrLastScannedNtwrksShadow[ap_index].strRssi.u8Full = 1; + } + astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index = rssi_index; + + astrLastScannedNtwrksShadow[ap_index].s8rssi = pstrNetworkInfo->s8rssi; + astrLastScannedNtwrksShadow[ap_index].u16CapInfo = pstrNetworkInfo->u16CapInfo; + + astrLastScannedNtwrksShadow[ap_index].u8SsidLen = pstrNetworkInfo->u8SsidLen; + WILC_memcpy(astrLastScannedNtwrksShadow[ap_index].au8ssid, + pstrNetworkInfo->au8ssid, pstrNetworkInfo->u8SsidLen); + + WILC_memcpy(astrLastScannedNtwrksShadow[ap_index].au8bssid, + pstrNetworkInfo->au8bssid, ETH_ALEN); + + astrLastScannedNtwrksShadow[ap_index].u16BeaconPeriod = pstrNetworkInfo->u16BeaconPeriod; + astrLastScannedNtwrksShadow[ap_index].u8DtimPeriod = pstrNetworkInfo->u8DtimPeriod; + astrLastScannedNtwrksShadow[ap_index].u8channel = pstrNetworkInfo->u8channel; + + astrLastScannedNtwrksShadow[ap_index].u16IEsLen = pstrNetworkInfo->u16IEsLen; + astrLastScannedNtwrksShadow[ap_index].u64Tsf = pstrNetworkInfo->u64Tsf; + if (ap_found != -1) + WILC_FREE(astrLastScannedNtwrksShadow[ap_index].pu8IEs); + astrLastScannedNtwrksShadow[ap_index].pu8IEs = + (WILC_Uint8 *)WILC_MALLOC(pstrNetworkInfo->u16IEsLen); /* will be deallocated by the WILC_WFI_CfgScan() function */ + WILC_memcpy(astrLastScannedNtwrksShadow[ap_index].pu8IEs, + pstrNetworkInfo->pu8IEs, pstrNetworkInfo->u16IEsLen); + + astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScan = jiffies; + astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScanCached = jiffies; + astrLastScannedNtwrksShadow[ap_index].u8Found = 1; + if (ap_found != -1) + host_int_freeJoinParams(astrLastScannedNtwrksShadow[ap_index].pJoinParams); + astrLastScannedNtwrksShadow[ap_index].pJoinParams = pJoinParams; + +} + + +/** + * @brief CfgScanResult + * @details Callback function which returns the scan results found + * + * @param[in] tenuScanEvent enuScanEvent: enum, indicating the scan event triggered, whether that is + * SCAN_EVENT_NETWORK_FOUND or SCAN_EVENT_DONE + * tstrNetworkInfo* pstrNetworkInfo: structure holding the scan results information + * void* pUserVoid: Private structure associated with the wireless interface + * @return NONE + * @author mabubakr + * @date + * @version 1.0 + */ +static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams) +{ + struct WILC_WFI_priv *priv; + struct wiphy *wiphy; + WILC_Sint32 s32Freq; + struct ieee80211_channel *channel; + WILC_Sint32 s32Error = WILC_SUCCESS; + struct cfg80211_bss *bss = NULL; + + priv = (struct WILC_WFI_priv *)pUserVoid; + if (priv->bCfgScanning == WILC_TRUE) { + if (enuScanEvent == SCAN_EVENT_NETWORK_FOUND) { + wiphy = priv->dev->ieee80211_ptr->wiphy; + WILC_NULLCHECK(s32Error, wiphy); + if (wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC + && + ((((WILC_Sint32)pstrNetworkInfo->s8rssi) * 100) < 0 + || + (((WILC_Sint32)pstrNetworkInfo->s8rssi) * 100) > 100) + ) { + WILC_ERRORREPORT(s32Error, WILC_FAIL); + } + + if (pstrNetworkInfo != WILC_NULL) { + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38) + s32Freq = ieee80211_channel_to_frequency((WILC_Sint32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ); + #else + s32Freq = ieee80211_channel_to_frequency((WILC_Sint32)pstrNetworkInfo->u8channel); + #endif + channel = ieee80211_get_channel(wiphy, s32Freq); + + WILC_NULLCHECK(s32Error, channel); + + PRINT_INFO(CFG80211_DBG, "Network Info:: CHANNEL Frequency: %d, RSSI: %d, CapabilityInfo: %d," + "BeaconPeriod: %d \n", channel->center_freq, (((WILC_Sint32)pstrNetworkInfo->s8rssi) * 100), + pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod); + + if (pstrNetworkInfo->bNewNetwork == WILC_TRUE) { + if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */ + /* max_scan_ssids */ + PRINT_D(CFG80211_DBG, "Network %s found\n", pstrNetworkInfo->au8ssid); + + + priv->u32RcvdChCount++; + + + + if (pJoinParams == NULL) { + PRINT_INFO(CORECONFIG_DBG, ">> Something really bad happened\n"); + } + add_network_to_shadow(pstrNetworkInfo, priv, pJoinParams); + + /*P2P peers are sent to WPA supplicant and added to shadow table*/ + + if (!(WILC_memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7))) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0) + bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo, + pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs, + (size_t)pstrNetworkInfo->u16IEsLen, (((WILC_Sint32)pstrNetworkInfo->s8rssi) * 100), GFP_KERNEL); +#else + bss = cfg80211_inform_bss(wiphy, channel, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo, + pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs, + (size_t)pstrNetworkInfo->u16IEsLen, (((WILC_Sint32)pstrNetworkInfo->s8rssi) * 100), GFP_KERNEL); +#endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0) + cfg80211_put_bss(wiphy, bss); +#else + cfg80211_put_bss(bss); +#endif + } + + + } else { + PRINT_ER("Discovered networks exceeded the max limit\n"); + } + } else { + WILC_Uint32 i; + /* So this network is discovered before, we'll just update its RSSI */ + for (i = 0; i < priv->u32RcvdChCount; i++) { + if (WILC_memcmp(astrLastScannedNtwrksShadow[i].au8bssid, pstrNetworkInfo->au8bssid, 6) == 0) { + PRINT_D(CFG80211_DBG, "Update RSSI of %s \n", astrLastScannedNtwrksShadow[i].au8ssid); + + astrLastScannedNtwrksShadow[i].s8rssi = pstrNetworkInfo->s8rssi; + astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies; + break; + } + } + } + } + } else if (enuScanEvent == SCAN_EVENT_DONE) { + PRINT_D(CFG80211_DBG, "Scan Done[%p] \n", priv->dev); + PRINT_D(CFG80211_DBG, "Refreshing Scan ... \n"); + refresh_scan(priv, 1, WILC_FALSE); + + if (priv->u32RcvdChCount > 0) { + PRINT_D(CFG80211_DBG, "%d Network(s) found \n", priv->u32RcvdChCount); + } else { + PRINT_D(CFG80211_DBG, "No networks found \n"); + } + + WILC_SemaphoreAcquire(&(priv->hSemScanReq), NULL); + + if (priv->pstrScanReq != WILC_NULL) { + cfg80211_scan_done(priv->pstrScanReq, WILC_FALSE); + priv->u32RcvdChCount = 0; + priv->bCfgScanning = WILC_FALSE; + priv->pstrScanReq = WILC_NULL; + } + WILC_SemaphoreRelease(&(priv->hSemScanReq), NULL); + + } + /*Aborting any scan operation during mac close*/ + else if (enuScanEvent == SCAN_EVENT_ABORTED) { + WILC_SemaphoreAcquire(&(priv->hSemScanReq), NULL); + + PRINT_D(CFG80211_DBG, "Scan Aborted \n"); + if (priv->pstrScanReq != WILC_NULL) { + + update_scan_time(priv); + refresh_scan(priv, 1, WILC_FALSE); + + cfg80211_scan_done(priv->pstrScanReq, WILC_FALSE); + priv->bCfgScanning = WILC_FALSE; + priv->pstrScanReq = WILC_NULL; + } + WILC_SemaphoreRelease(&(priv->hSemScanReq), NULL); + } + } + + + WILC_CATCH(s32Error) + { + } +} + + +/** + * @brief WILC_WFI_Set_PMKSA + * @details Check if pmksa is cached and set it. + * @param[in] + * @return int : Return 0 on Success + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +int WILC_WFI_Set_PMKSA(WILC_Uint8 *bssid, struct WILC_WFI_priv *priv) +{ + WILC_Uint32 i; + WILC_Sint32 s32Error = WILC_SUCCESS; + + + for (i = 0; i < priv->pmkid_list.numpmkid; i++) { + + if (!WILC_memcmp(bssid, priv->pmkid_list.pmkidlist[i].bssid, + ETH_ALEN)) { + PRINT_D(CFG80211_DBG, "PMKID successful comparison"); + + /*If bssid is found, set the values*/ + s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list); + + if (s32Error != WILC_SUCCESS) + PRINT_ER("Error in pmkid\n"); + + break; + } + } + + return s32Error; + + +} +int linux_wlan_set_bssid(struct net_device *wilc_netdev, uint8_t *pBSSID); + + +/** + * @brief CfgConnectResult + * @details + * @param[in] tenuConnDisconnEvent enuConnDisconnEvent: Type of connection response either + * connection response or disconnection notification. + * tstrConnectInfo* pstrConnectInfo: COnnection information. + * WILC_Uint8 u8MacStatus: Mac Status from firmware + * tstrDisconnectNotifInfo* pstrDisconnectNotifInfo: Disconnection Notification + * void* pUserVoid: Private data associated with wireless interface + * @return NONE + * @author mabubakr + * @date 01 MAR 2012 + * @version 1.0 + */ +int connecting; + +static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent, + tstrConnectInfo *pstrConnectInfo, + WILC_Uint8 u8MacStatus, + tstrDisconnectNotifInfo *pstrDisconnectNotifInfo, + void *pUserVoid) +{ + struct WILC_WFI_priv *priv; + struct net_device *dev; + #ifdef WILC_P2P + tstrWILC_WFIDrv *pstrWFIDrv; + #endif + WILC_Uint8 NullBssid[ETH_ALEN] = {0}; + connecting = 0; + + priv = (struct WILC_WFI_priv *)pUserVoid; + dev = priv->dev; + #ifdef WILC_P2P + pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv; + #endif + + if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) { + /*Initialization*/ + WILC_Uint16 u16ConnectStatus = WLAN_STATUS_SUCCESS; + + u16ConnectStatus = pstrConnectInfo->u16ConnectStatus; + + PRINT_D(CFG80211_DBG, " Connection response received = %d\n", u8MacStatus); + + if ((u8MacStatus == MAC_DISCONNECTED) && + (pstrConnectInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE)) { + /* The case here is that our station was waiting for association response frame and has just received it containing status code + * = SUCCESSFUL_STATUSCODE, while mac status is MAC_DISCONNECTED (which means something wrong happened) */ + u16ConnectStatus = WLAN_STATUS_UNSPECIFIED_FAILURE; + linux_wlan_set_bssid(priv->dev, NullBssid); + WILC_memset(u8ConnectedSSID, 0, ETH_ALEN); + + /*BugID_5457*/ + /*Invalidate u8WLANChannel value on wlan0 disconnect*/ + #ifdef WILC_P2P + if (!pstrWFIDrv->u8P2PConnect) + u8WLANChannel = INVALID_CHANNEL; + #endif + + PRINT_ER("Unspecified failure: Connection status %d : MAC status = %d \n", u16ConnectStatus, u8MacStatus); + } + + if (u16ConnectStatus == WLAN_STATUS_SUCCESS) { + WILC_Bool bNeedScanRefresh = WILC_FALSE; + WILC_Uint32 i; + + PRINT_INFO(CFG80211_DBG, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo->au8bssid[0], + pstrConnectInfo->au8bssid[1], pstrConnectInfo->au8bssid[2], pstrConnectInfo->au8bssid[3], pstrConnectInfo->au8bssid[4], pstrConnectInfo->au8bssid[5]); + WILC_memcpy(priv->au8AssociatedBss, pstrConnectInfo->au8bssid, ETH_ALEN); + + /* set bssid in frame filter */ + /* linux_wlan_set_bssid(dev,pstrConnectInfo->au8bssid); */ + + /* BugID_4209: if this network has expired in the scan results in the above nl80211 layer, refresh them here by calling + * cfg80211_inform_bss() with the last Scan results before calling cfg80211_connect_result() to avoid + * Linux kernel warning generated at the nl80211 layer */ + + for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) { + if (WILC_memcmp(astrLastScannedNtwrksShadow[i].au8bssid, + pstrConnectInfo->au8bssid, ETH_ALEN) == 0) { + unsigned long now = jiffies; + + if (time_after(now, + astrLastScannedNtwrksShadow[i].u32TimeRcvdInScanCached + (unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ)))) { + bNeedScanRefresh = WILC_TRUE; + } + + break; + } + } + + if (bNeedScanRefresh == WILC_TRUE) { + /* RefreshScanResult(priv); */ + /*BugID_5418*/ + /*Also, refrsh DIRECT- results if */ + refresh_scan(priv, 1, WILC_TRUE); + + } + + } + + + PRINT_D(CFG80211_DBG, "Association request info elements length = %d\n", pstrConnectInfo->ReqIEsLen); + + PRINT_D(CFG80211_DBG, "Association response info elements length = %d\n", pstrConnectInfo->u16RespIEsLen); + + cfg80211_connect_result(dev, pstrConnectInfo->au8bssid, + pstrConnectInfo->pu8ReqIEs, pstrConnectInfo->ReqIEsLen, + pstrConnectInfo->pu8RespIEs, pstrConnectInfo->u16RespIEsLen, + u16ConnectStatus, GFP_KERNEL); /* TODO: mostafa: u16ConnectStatus to */ + /* be replaced by pstrConnectInfo->u16ConnectStatus */ + } else if (enuConnDisconnEvent == CONN_DISCONN_EVENT_DISCONN_NOTIF) { + #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP + g_obtainingIP = WILC_FALSE; + #endif + PRINT_ER("Received MAC_DISCONNECTED from firmware with reason %d on dev [%p]\n", + pstrDisconnectNotifInfo->u16reason, priv->dev); + u8P2Plocalrandom = 0x01; + u8P2Precvrandom = 0x00; + bWilc_ie = WILC_FALSE; + WILC_memset(priv->au8AssociatedBss, 0, ETH_ALEN); + linux_wlan_set_bssid(priv->dev, NullBssid); + WILC_memset(u8ConnectedSSID, 0, ETH_ALEN); + + /*BugID_5457*/ + /*Invalidate u8WLANChannel value on wlan0 disconnect*/ + #ifdef WILC_P2P + if (!pstrWFIDrv->u8P2PConnect) + u8WLANChannel = INVALID_CHANNEL; + #endif + /*BugID_5315*/ + /*Incase "P2P CLIENT Connected" send deauthentication reason by 3 to force the WPA_SUPPLICANT to directly change + * virtual interface to station*/ + if ((pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) { + pstrDisconnectNotifInfo->u16reason = 3; + } + /*BugID_5315*/ + /*Incase "P2P CLIENT during connection(not connected)" send deauthentication reason by 1 to force the WPA_SUPPLICANT + * to scan again and retry the connection*/ + else if ((!pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) { + pstrDisconnectNotifInfo->u16reason = 1; + } + cfg80211_disconnected(dev, pstrDisconnectNotifInfo->u16reason, pstrDisconnectNotifInfo->ie, + pstrDisconnectNotifInfo->ie_len, GFP_KERNEL); + + } + +} + + +/** + * @brief WILC_WFI_CfgSetChannel + * @details Set channel for a given wireless interface. Some devices + * may support multi-channel operation (by channel hopping) so cfg80211 + * doesn't verify much. Note, however, that the passed netdev may be + * %NULL as well if the user requested changing the channel for the + * device itself, or for a monitor interface. + * @param[in] + * @return int : Return 0 on Success + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) +/* + * struct changed from v3.8.0 + * tony, sswd, WILC-KR, 2013-10-29 + * struct cfg80211_chan_def { + * struct ieee80211_channel *chan; + * enum nl80211_chan_width width; + * u32 center_freq1; + * u32 center_freq2; + * }; + */ +static int WILC_WFI_CfgSetChannel(struct wiphy *wiphy, + struct cfg80211_chan_def *chandef) +#else +static int WILC_WFI_CfgSetChannel(struct wiphy *wiphy, + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32) + struct net_device *netdev, + #endif + struct ieee80211_channel *channel, + enum nl80211_channel_type channel_type) +#endif +{ + + WILC_Uint32 channelnum = 0; + struct WILC_WFI_priv *priv; + WILC_Sint32 s32Error = WILC_SUCCESS; + priv = wiphy_priv(wiphy); + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) /* tony for v3.8.0 support */ + channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq); + PRINT_D(CFG80211_DBG, "Setting channel %d with frequency %d\n", channelnum, chandef->chan->center_freq); +#else + channelnum = ieee80211_frequency_to_channel(channel->center_freq); + + PRINT_D(CFG80211_DBG, "Setting channel %d with frequency %d\n", channelnum, channel->center_freq); +#endif + + u8CurrChannel = channelnum; + s32Error = host_int_set_mac_chnl_num(priv->hWILCWFIDrv, channelnum); + + if (s32Error != WILC_SUCCESS) + PRINT_ER("Error in setting channel %d\n", channelnum); + + return s32Error; +} + +/** + * @brief WILC_WFI_CfgScan + * @details Request to do a scan. If returning zero, the scan request is given + * the driver, and will be valid until passed to cfg80211_scan_done(). + * For scan results, call cfg80211_inform_bss(); you can call this outside + * the scan/scan_done bracket too. + * @param[in] + * @return int : Return 0 on Success + * @author mabubakr + * @date 01 MAR 2012 + * @version 1.0 + */ + +/* + * kernel version 3.8.8 supported + * tony, sswd, WILC-KR, 2013-10-29 + */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) +static int WILC_WFI_CfgScan(struct wiphy *wiphy, struct cfg80211_scan_request *request) +#else +static int WILC_WFI_CfgScan(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_scan_request *request) +#endif +{ + struct WILC_WFI_priv *priv; + WILC_Uint32 i; + WILC_Sint32 s32Error = WILC_SUCCESS; + WILC_Uint8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS]; + tstrHiddenNetwork strHiddenNetwork; + + priv = wiphy_priv(wiphy); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0) + PRINT_D(CORECONFIG_DBG, "Scan on netdev [%p] host if [%x]\n", dev, (WILC_Uint32)priv->hWILCWFIDrv); +#endif + + /*if(connecting) + * return -EBUSY; */ + + /*BugID_4800: if in AP mode, return.*/ + /*This check is to handle the situation when user*/ + /*requests "create group" during a running scan*/ + /* host_int_set_wfi_drv_handler(priv->hWILCWFIDrv); */ +#if 0 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) /* tony for v3.8.0 support */ + if (priv->dev->ieee80211_ptr->iftype == NL80211_IFTYPE_AP) { + PRINT_D(GENERIC_DBG, "Required scan while in AP mode"); + return s32Error; + } +#else + if (dev->ieee80211_ptr->iftype == NL80211_IFTYPE_AP) { + PRINT_D(GENERIC_DBG, "Required scan while in AP mode"); + s32Error = WILC_BUSY; + return s32Error; + } +#endif +#endif /* end of if 0 */ + priv->pstrScanReq = request; + + priv->u32RcvdChCount = 0; + + host_int_set_wfi_drv_handler((WILC_Uint32)priv->hWILCWFIDrv); + + + reset_shadow_found(priv); + + priv->bCfgScanning = WILC_TRUE; + if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */ + /* max_scan_ssids */ + for (i = 0; i < request->n_channels; i++) { + au8ScanChanList[i] = (WILC_Uint8)ieee80211_frequency_to_channel(request->channels[i]->center_freq); + PRINT_INFO(CFG80211_DBG, "ScanChannel List[%d] = %d,", i, au8ScanChanList[i]); + } + + PRINT_D(CFG80211_DBG, "Requested num of scan channel %d\n", request->n_channels); + PRINT_D(CFG80211_DBG, "Scan Request IE len = %d\n", request->ie_len); + + PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids); + + if (request->n_ssids >= 1) { + + + strHiddenNetwork.pstrHiddenNetworkInfo = WILC_MALLOC(request->n_ssids * sizeof(tstrHiddenNetwork)); + strHiddenNetwork.u8ssidnum = request->n_ssids; + + + /*BugID_4156*/ + for (i = 0; i < request->n_ssids; i++) { + + if (request->ssids[i].ssid != NULL && request->ssids[i].ssid_len != 0) { + strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid = WILC_MALLOC(request->ssids[i].ssid_len); + WILC_memcpy(strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, request->ssids[i].ssid, request->ssids[i].ssid_len); + strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen = request->ssids[i].ssid_len; + } else { + PRINT_D(CFG80211_DBG, "Received one NULL SSID \n"); + strHiddenNetwork.u8ssidnum -= 1; + } + } + PRINT_D(CFG80211_DBG, "Trigger Scan Request \n"); + s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN, + au8ScanChanList, request->n_channels, + (const WILC_Uint8 *)request->ie, request->ie_len, + CfgScanResult, (void *)priv, &strHiddenNetwork); + } else { + PRINT_D(CFG80211_DBG, "Trigger Scan Request \n"); + s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN, + au8ScanChanList, request->n_channels, + (const WILC_Uint8 *)request->ie, request->ie_len, + CfgScanResult, (void *)priv, NULL); + } + + } else { + PRINT_ER("Requested num of scanned channels is greater than the max, supported" + " channels \n"); + } + + if (s32Error != WILC_SUCCESS) { + s32Error = -EBUSY; + PRINT_WRN(CFG80211_DBG, "Device is busy: Error(%d)\n", s32Error); + } + + return s32Error; +} + +/** + * @brief WILC_WFI_CfgConnect + * @details Connect to the ESS with the specified parameters. When connected, + * call cfg80211_connect_result() with status code %WLAN_STATUS_SUCCESS. + * If the connection fails for some reason, call cfg80211_connect_result() + * with the status from the AP. + * @param[in] + * @return int : Return 0 on Success + * @author mabubakr + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_CfgConnect(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_connect_params *sme) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + WILC_Uint32 i; + /* SECURITY_T tenuSecurity_t = NO_SECURITY; */ + WILC_Uint8 u8security = NO_ENCRYPT; + AUTHTYPE_T tenuAuth_type = ANY; + WILC_Char *pcgroup_encrypt_val; + WILC_Char *pccipher_group; + WILC_Char *pcwpa_version; + + struct WILC_WFI_priv *priv; + tstrWILC_WFIDrv *pstrWFIDrv; + tstrNetworkInfo *pstrNetworkInfo = NULL; + + + connecting = 1; + priv = wiphy_priv(wiphy); + pstrWFIDrv = (tstrWILC_WFIDrv *)(priv->hWILCWFIDrv); + + host_int_set_wfi_drv_handler((WILC_Uint32)priv->hWILCWFIDrv); + + /* host_int_set_wfi_drv_handler((WILC_Uint32)priv->hWILCWFIDrv); */ + PRINT_D(CFG80211_DBG, "Connecting to SSID [%s] on netdev [%p] host if [%x]\n", sme->ssid, dev, (WILC_Uint32)priv->hWILCWFIDrv); + #ifdef WILC_P2P + if (!(WILC_strncmp(sme->ssid, "DIRECT-", 7))) { + PRINT_D(CFG80211_DBG, "Connected to Direct network,OBSS disabled\n"); + pstrWFIDrv->u8P2PConnect = 1; + } else + pstrWFIDrv->u8P2PConnect = 0; + #endif + PRINT_INFO(CFG80211_DBG, "Required SSID = %s\n , AuthType = %d \n", sme->ssid, sme->auth_type); + + for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) { + if ((sme->ssid_len == astrLastScannedNtwrksShadow[i].u8SsidLen) && + WILC_memcmp(astrLastScannedNtwrksShadow[i].au8ssid, + sme->ssid, + sme->ssid_len) == 0) { + PRINT_INFO(CFG80211_DBG, "Network with required SSID is found %s\n", sme->ssid); + if (sme->bssid == NULL) { + /* BSSID is not passed from the user, so decision of matching + * is done by SSID only */ + PRINT_INFO(CFG80211_DBG, "BSSID is not passed from the user\n"); + break; + } else { + /* BSSID is also passed from the user, so decision of matching + * should consider also this passed BSSID */ + if (WILC_memcmp(astrLastScannedNtwrksShadow[i].au8bssid, + sme->bssid, + ETH_ALEN) == 0) { + PRINT_INFO(CFG80211_DBG, "BSSID is passed from the user and matched\n"); + break; + } + } + } + } + + if (i < u32LastScannedNtwrksCountShadow) { + PRINT_D(CFG80211_DBG, "Required bss is in scan results\n"); + + pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]); + + PRINT_INFO(CFG80211_DBG, "network BSSID to be associated: %x%x%x%x%x%x\n", + pstrNetworkInfo->au8bssid[0], pstrNetworkInfo->au8bssid[1], + pstrNetworkInfo->au8bssid[2], pstrNetworkInfo->au8bssid[3], + pstrNetworkInfo->au8bssid[4], pstrNetworkInfo->au8bssid[5]); + } else { + s32Error = -ENOENT; + if (u32LastScannedNtwrksCountShadow == 0) + PRINT_D(CFG80211_DBG, "No Scan results yet\n"); + else + PRINT_D(CFG80211_DBG, "Required bss not in scan results: Error(%d)\n", s32Error); + + goto done; + } + + priv->WILC_WFI_wep_default = 0; + WILC_memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key)); + WILC_memset(priv->WILC_WFI_wep_key_len, 0, sizeof(priv->WILC_WFI_wep_key_len)); + + PRINT_INFO(CFG80211_DBG, "sme->crypto.wpa_versions=%x\n", sme->crypto.wpa_versions); + PRINT_INFO(CFG80211_DBG, "sme->crypto.cipher_group=%x\n", sme->crypto.cipher_group); + + PRINT_INFO(CFG80211_DBG, "sme->crypto.n_ciphers_pairwise=%d\n", sme->crypto.n_ciphers_pairwise); + + if (INFO) { + for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) + PRINT_D(CORECONFIG_DBG, "sme->crypto.ciphers_pairwise[%d]=%x\n", i, sme->crypto.ciphers_pairwise[i]); + } + + if (sme->crypto.cipher_group != NO_ENCRYPT) { + /* To determine the u8security value, first we check the group cipher suite then {in case of WPA or WPA2} + * we will add to it the pairwise cipher suite(s) */ + pcwpa_version = "Default"; + PRINT_D(CORECONFIG_DBG, ">> sme->crypto.wpa_versions: %x\n", sme->crypto.wpa_versions); + /* case NL80211_WPA_VERSION_1: */ + if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) { + /* tenuSecurity_t = WEP_40; */ + u8security = ENCRYPT_ENABLED | WEP; + pcgroup_encrypt_val = "WEP40"; + pccipher_group = "WLAN_CIPHER_SUITE_WEP40"; + PRINT_INFO(CFG80211_DBG, "WEP Default Key Idx = %d\n", sme->key_idx); + + if (INFO) { + for (i = 0; i < sme->key_len; i++) + PRINT_D(CORECONFIG_DBG, "WEP Key Value[%d] = %d\n", i, sme->key[i]); + } + priv->WILC_WFI_wep_default = sme->key_idx; + priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len; + WILC_memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len); + + /*BugID_5137*/ + g_key_wep_params.key_len = sme->key_len; + g_key_wep_params.key = WILC_MALLOC(sme->key_len); + memcpy(g_key_wep_params.key, sme->key, sme->key_len); + g_key_wep_params.key_idx = sme->key_idx; + g_wep_keys_saved = WILC_TRUE; + + host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx); + host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx); + } else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) { + /* tenuSecurity_t = WEP_104; */ + u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED; + pcgroup_encrypt_val = "WEP104"; + pccipher_group = "WLAN_CIPHER_SUITE_WEP104"; + + priv->WILC_WFI_wep_default = sme->key_idx; + priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len; + WILC_memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len); + + /*BugID_5137*/ + g_key_wep_params.key_len = sme->key_len; + g_key_wep_params.key = WILC_MALLOC(sme->key_len); + memcpy(g_key_wep_params.key, sme->key, sme->key_len); + g_key_wep_params.key_idx = sme->key_idx; + g_wep_keys_saved = WILC_TRUE; + + host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx); + host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx); + } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) { + /* case NL80211_WPA_VERSION_2: */ + if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) { + /* tenuSecurity_t = WPA2_TKIP; */ + u8security = ENCRYPT_ENABLED | WPA2 | TKIP; + pcgroup_encrypt_val = "WPA2_TKIP"; + pccipher_group = "TKIP"; + } else { /* TODO: mostafa: here we assume that any other encryption type is AES */ + /* tenuSecurity_t = WPA2_AES; */ + u8security = ENCRYPT_ENABLED | WPA2 | AES; + pcgroup_encrypt_val = "WPA2_AES"; + pccipher_group = "AES"; + } + pcwpa_version = "WPA_VERSION_2"; + } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) { + if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) { + /* tenuSecurity_t = WPA_TKIP; */ + u8security = ENCRYPT_ENABLED | WPA | TKIP; + pcgroup_encrypt_val = "WPA_TKIP"; + pccipher_group = "TKIP"; + } else { /* TODO: mostafa: here we assume that any other encryption type is AES */ + /* tenuSecurity_t = WPA_AES; */ + u8security = ENCRYPT_ENABLED | WPA | AES; + pcgroup_encrypt_val = "WPA_AES"; + pccipher_group = "AES"; + + } + pcwpa_version = "WPA_VERSION_1"; + + /* break; */ + } else { + s32Error = -ENOTSUPP; + PRINT_ER("Not supported cipher: Error(%d)\n", s32Error); + + goto done; + } + + } + + /* After we set the u8security value from checking the group cipher suite, {in case of WPA or WPA2} we will + * add to it the pairwise cipher suite(s) */ + if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) + || (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) { + for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) { + if (sme->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP) { + u8security = u8security | TKIP; + } else { /* TODO: mostafa: here we assume that any other encryption type is AES */ + u8security = u8security | AES; + } + } + } + + PRINT_D(CFG80211_DBG, "Adding key with cipher group = %x\n", sme->crypto.cipher_group); + + PRINT_D(CFG80211_DBG, "Authentication Type = %d\n", sme->auth_type); + switch (sme->auth_type) { + case NL80211_AUTHTYPE_OPEN_SYSTEM: + PRINT_D(CFG80211_DBG, "In OPEN SYSTEM\n"); + tenuAuth_type = OPEN_SYSTEM; + break; + + case NL80211_AUTHTYPE_SHARED_KEY: + tenuAuth_type = SHARED_KEY; + PRINT_D(CFG80211_DBG, "In SHARED KEY\n"); + break; + + default: + PRINT_D(CFG80211_DBG, "Automatic Authentation type = %d\n", sme->auth_type); + } + + + /* ai: key_mgmt: enterprise case */ + if (sme->crypto.n_akm_suites) { + switch (sme->crypto.akm_suites[0]) { + case WLAN_AKM_SUITE_8021X: + tenuAuth_type = IEEE8021; + break; + + default: + break; + } + } + + + PRINT_INFO(CFG80211_DBG, "Required Channel = %d\n", pstrNetworkInfo->u8channel); + + PRINT_INFO(CFG80211_DBG, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n", + pcgroup_encrypt_val, pccipher_group, pcwpa_version); + + /*BugID_5442*/ + u8CurrChannel = pstrNetworkInfo->u8channel; + + if (!pstrWFIDrv->u8P2PConnect) { + u8WLANChannel = pstrNetworkInfo->u8channel; + } + + linux_wlan_set_bssid(dev, pstrNetworkInfo->au8bssid); + + s32Error = host_int_set_join_req(priv->hWILCWFIDrv, pstrNetworkInfo->au8bssid, sme->ssid, + sme->ssid_len, sme->ie, sme->ie_len, + CfgConnectResult, (void *)priv, u8security, + tenuAuth_type, pstrNetworkInfo->u8channel, + pstrNetworkInfo->pJoinParams); + if (s32Error != WILC_SUCCESS) { + PRINT_ER("host_int_set_join_req(): Error(%d) \n", s32Error); + s32Error = -ENOENT; + goto done; + } + +done: + + return s32Error; +} + + +/** + * @brief WILC_WFI_disconnect + * @details Disconnect from the BSS/ESS. + * @param[in] + * @return int : Return 0 on Success + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + struct WILC_WFI_priv *priv; + #ifdef WILC_P2P + tstrWILC_WFIDrv *pstrWFIDrv; + #endif + uint8_t NullBssid[ETH_ALEN] = {0}; + connecting = 0; + priv = wiphy_priv(wiphy); + + /*BugID_5457*/ + /*Invalidate u8WLANChannel value on wlan0 disconnect*/ + #ifdef WILC_P2P + pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv; + if (!pstrWFIDrv->u8P2PConnect) + u8WLANChannel = INVALID_CHANNEL; + #endif + linux_wlan_set_bssid(priv->dev, NullBssid); + + PRINT_D(CFG80211_DBG, "Disconnecting with reason code(%d)\n", reason_code); + + u8P2Plocalrandom = 0x01; + u8P2Precvrandom = 0x00; + bWilc_ie = WILC_FALSE; + #ifdef WILC_P2P + pstrWFIDrv->u64P2p_MgmtTimeout = 0; + #endif + + s32Error = host_int_disconnect(priv->hWILCWFIDrv, reason_code); + if (s32Error != WILC_SUCCESS) { + PRINT_ER("Error in disconnecting: Error(%d)\n", s32Error); + s32Error = -EINVAL; + } + + return s32Error; +} + +/** + * @brief WILC_WFI_add_key + * @details Add a key with the given parameters. @mac_addr will be %NULL + * when adding a group key. + * @param[in] key : key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key, 8-byte Rx Mic Key + * @return int : Return 0 on Success + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) + bool pairwise, + #endif + const u8 *mac_addr, struct key_params *params) + +{ + WILC_Sint32 s32Error = WILC_SUCCESS, KeyLen = params->key_len; + WILC_Uint32 i; + struct WILC_WFI_priv *priv; + WILC_Uint8 *pu8RxMic = NULL; + WILC_Uint8 *pu8TxMic = NULL; + WILC_Uint8 u8mode = NO_ENCRYPT; + #ifdef WILC_AP_EXTERNAL_MLME + WILC_Uint8 u8gmode = NO_ENCRYPT; + WILC_Uint8 u8pmode = NO_ENCRYPT; + AUTHTYPE_T tenuAuth_type = ANY; + #endif + + priv = wiphy_priv(wiphy); + + PRINT_D(CFG80211_DBG, "Adding key with cipher suite = %x\n", params->cipher); + + /*BugID_5137*/ + PRINT_D(CFG80211_DBG, "%x %x %d\n", (WILC_Uint32)wiphy, (WILC_Uint32)netdev, key_index); + + PRINT_D(CFG80211_DBG, "key %x %x %x\n", params->key[0], + params->key[1], + params->key[2]); + + + switch (params->cipher) { + case WLAN_CIPHER_SUITE_WEP40: + case WLAN_CIPHER_SUITE_WEP104: + #ifdef WILC_AP_EXTERNAL_MLME + if (priv->wdev->iftype == NL80211_IFTYPE_AP) { + + priv->WILC_WFI_wep_default = key_index; + priv->WILC_WFI_wep_key_len[key_index] = params->key_len; + WILC_memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len); + + PRINT_D(CFG80211_DBG, "Adding AP WEP Default key Idx = %d\n", key_index); + PRINT_D(CFG80211_DBG, "Adding AP WEP Key len= %d\n", params->key_len); + + for (i = 0; i < params->key_len; i++) + PRINT_D(CFG80211_DBG, "WEP AP key val[%d] = %x\n", i, params->key[i]); + + tenuAuth_type = OPEN_SYSTEM; + + if (params->cipher == WLAN_CIPHER_SUITE_WEP40) + u8mode = ENCRYPT_ENABLED | WEP; + else + u8mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED; + + host_int_add_wep_key_bss_ap(priv->hWILCWFIDrv, params->key, params->key_len, key_index, u8mode, tenuAuth_type); + break; + } + #endif + if (WILC_memcmp(params->key, priv->WILC_WFI_wep_key[key_index], params->key_len)) { + priv->WILC_WFI_wep_default = key_index; + priv->WILC_WFI_wep_key_len[key_index] = params->key_len; + WILC_memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len); + + PRINT_D(CFG80211_DBG, "Adding WEP Default key Idx = %d\n", key_index); + PRINT_D(CFG80211_DBG, "Adding WEP Key length = %d\n", params->key_len); + if (INFO) { + for (i = 0; i < params->key_len; i++) + PRINT_INFO(CFG80211_DBG, "WEP key value[%d] = %d\n", i, params->key[i]); + } + host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, params->key, params->key_len, key_index); + } + + break; + + case WLAN_CIPHER_SUITE_TKIP: + case WLAN_CIPHER_SUITE_CCMP: + #ifdef WILC_AP_EXTERNAL_MLME + if (priv->wdev->iftype == NL80211_IFTYPE_AP || priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) { + + if (priv->wilc_gtk[key_index] == NULL) { + priv->wilc_gtk[key_index] = (struct wilc_wfi_key *)WILC_MALLOC(sizeof(struct wilc_wfi_key)); + priv->wilc_gtk[key_index]->key = WILC_NULL; + priv->wilc_gtk[key_index]->seq = WILC_NULL; + + } + if (priv->wilc_ptk[key_index] == NULL) { + priv->wilc_ptk[key_index] = (struct wilc_wfi_key *)WILC_MALLOC(sizeof(struct wilc_wfi_key)); + priv->wilc_ptk[key_index]->key = WILC_NULL; + priv->wilc_ptk[key_index]->seq = WILC_NULL; + } + + + + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) + if (!pairwise) + #else + if (!mac_addr || is_broadcast_ether_addr(mac_addr)) + #endif + { + if (params->cipher == WLAN_CIPHER_SUITE_TKIP) + u8gmode = ENCRYPT_ENABLED | WPA | TKIP; + else + u8gmode = ENCRYPT_ENABLED | WPA2 | AES; + + priv->wilc_groupkey = u8gmode; + + if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { + + pu8TxMic = params->key + 24; + pu8RxMic = params->key + 16; + KeyLen = params->key_len - 16; + } + /* if there has been previous allocation for the same index through its key, free that memory and allocate again*/ + if (priv->wilc_gtk[key_index]->key) + WILC_FREE(priv->wilc_gtk[key_index]->key); + + priv->wilc_gtk[key_index]->key = (WILC_Uint8 *)WILC_MALLOC(params->key_len); + WILC_memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len); + + /* if there has been previous allocation for the same index through its seq, free that memory and allocate again*/ + if (priv->wilc_gtk[key_index]->seq) + WILC_FREE(priv->wilc_gtk[key_index]->seq); + + if ((params->seq_len) > 0) { + priv->wilc_gtk[key_index]->seq = (WILC_Uint8 *)WILC_MALLOC(params->seq_len); + WILC_memcpy(priv->wilc_gtk[key_index]->seq, params->seq, params->seq_len); + } + + priv->wilc_gtk[key_index]->cipher = params->cipher; + priv->wilc_gtk[key_index]->key_len = params->key_len; + priv->wilc_gtk[key_index]->seq_len = params->seq_len; + + if (INFO) { + for (i = 0; i < params->key_len; i++) + PRINT_INFO(CFG80211_DBG, "Adding group key value[%d] = %x\n", i, params->key[i]); + for (i = 0; i < params->seq_len; i++) + PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]); + } + + + host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen, + key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, AP_MODE, u8gmode); + + } else { + PRINT_INFO(CFG80211_DBG, "STA Address: %x%x%x%x%x\n", mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4]); + + if (params->cipher == WLAN_CIPHER_SUITE_TKIP) + u8pmode = ENCRYPT_ENABLED | WPA | TKIP; + else + u8pmode = priv->wilc_groupkey | AES; + + + if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { + + pu8TxMic = params->key + 24; + pu8RxMic = params->key + 16; + KeyLen = params->key_len - 16; + } + + if (priv->wilc_ptk[key_index]->key) + WILC_FREE(priv->wilc_ptk[key_index]->key); + + priv->wilc_ptk[key_index]->key = (WILC_Uint8 *)WILC_MALLOC(params->key_len); + + if (priv->wilc_ptk[key_index]->seq) + WILC_FREE(priv->wilc_ptk[key_index]->seq); + + if ((params->seq_len) > 0) + priv->wilc_ptk[key_index]->seq = (WILC_Uint8 *)WILC_MALLOC(params->seq_len); + + if (INFO) { + for (i = 0; i < params->key_len; i++) + PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %x\n", i, params->key[i]); + + for (i = 0; i < params->seq_len; i++) + PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]); + } + + WILC_memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len); + + if ((params->seq_len) > 0) + WILC_memcpy(priv->wilc_ptk[key_index]->seq, params->seq, params->seq_len); + + priv->wilc_ptk[key_index]->cipher = params->cipher; + priv->wilc_ptk[key_index]->key_len = params->key_len; + priv->wilc_ptk[key_index]->seq_len = params->seq_len; + + host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr, + pu8RxMic, pu8TxMic, AP_MODE, u8pmode, key_index); + } + break; + } + #endif + + { + u8mode = 0; + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) + if (!pairwise) + #else + if (!mac_addr || is_broadcast_ether_addr(mac_addr)) + #endif + { + if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { + /* swap the tx mic by rx mic */ + pu8RxMic = params->key + 24; + pu8TxMic = params->key + 16; + KeyLen = params->key_len - 16; + } + + /*BugID_5137*/ + /*save keys only on interface 0 (wifi interface)*/ + if (!g_gtk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) { + g_add_gtk_key_params.key_idx = key_index; + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) + g_add_gtk_key_params.pairwise = pairwise; + #endif + if (!mac_addr) { + g_add_gtk_key_params.mac_addr = NULL; + } else { + g_add_gtk_key_params.mac_addr = WILC_MALLOC(ETH_ALEN); + memcpy(g_add_gtk_key_params.mac_addr, mac_addr, ETH_ALEN); + } + g_key_gtk_params.key_len = params->key_len; + g_key_gtk_params.seq_len = params->seq_len; + g_key_gtk_params.key = WILC_MALLOC(params->key_len); + memcpy(g_key_gtk_params.key, params->key, params->key_len); + if (params->seq_len > 0) { + g_key_gtk_params.seq = WILC_MALLOC(params->seq_len); + memcpy(g_key_gtk_params.seq, params->seq, params->seq_len); + } + g_key_gtk_params.cipher = params->cipher; + + PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_gtk_params.key[0], + g_key_gtk_params.key[1], + g_key_gtk_params.key[2]); + g_gtk_keys_saved = WILC_TRUE; + } + + host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen, + key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, STATION_MODE, u8mode); + /* host_int_add_tx_gtk(priv->hWILCWFIDrv,params->key_len,params->key,key_index); */ + } else { + if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { + /* swap the tx mic by rx mic */ + pu8RxMic = params->key + 24; + pu8TxMic = params->key + 16; + KeyLen = params->key_len - 16; + } + + /*BugID_5137*/ + /*save keys only on interface 0 (wifi interface)*/ + if (!g_ptk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) { + g_add_ptk_key_params.key_idx = key_index; + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) + g_add_ptk_key_params.pairwise = pairwise; + #endif + if (!mac_addr) { + g_add_ptk_key_params.mac_addr = NULL; + } else { + g_add_ptk_key_params.mac_addr = WILC_MALLOC(ETH_ALEN); + memcpy(g_add_ptk_key_params.mac_addr, mac_addr, ETH_ALEN); + } + g_key_ptk_params.key_len = params->key_len; + g_key_ptk_params.seq_len = params->seq_len; + g_key_ptk_params.key = WILC_MALLOC(params->key_len); + memcpy(g_key_ptk_params.key, params->key, params->key_len); + if (params->seq_len > 0) { + g_key_ptk_params.seq = WILC_MALLOC(params->seq_len); + memcpy(g_key_ptk_params.seq, params->seq, params->seq_len); + } + g_key_ptk_params.cipher = params->cipher; + + PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_ptk_params.key[0], + g_key_ptk_params.key[1], + g_key_ptk_params.key[2]); + g_ptk_keys_saved = WILC_TRUE; + } + + host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr, + pu8RxMic, pu8TxMic, STATION_MODE, u8mode, key_index); + PRINT_D(CFG80211_DBG, "Adding pairwise key\n"); + if (INFO) { + for (i = 0; i < params->key_len; i++) + PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %d\n", i, params->key[i]); + } + } + } + break; + + default: + PRINT_ER("Not supported cipher: Error(%d)\n", s32Error); + s32Error = -ENOTSUPP; + + } + + return s32Error; +} + +/** + * @brief WILC_WFI_del_key + * @details Remove a key given the @mac_addr (%NULL for a group key) + * and @key_index, return -ENOENT if the key doesn't exist. + * @param[in] + * @return int : Return 0 on Success + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_del_key(struct wiphy *wiphy, struct net_device *netdev, + u8 key_index, + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) + bool pairwise, + #endif + const u8 *mac_addr) +{ + struct WILC_WFI_priv *priv; + WILC_Sint32 s32Error = WILC_SUCCESS; + + priv = wiphy_priv(wiphy); + + /*BugID_5137*/ + /*delete saved keys, if any*/ + if (netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) { + g_ptk_keys_saved = WILC_FALSE; + g_gtk_keys_saved = WILC_FALSE; + g_wep_keys_saved = WILC_FALSE; + + /*Delete saved WEP keys params, if any*/ + if (g_key_wep_params.key != NULL) { + WILC_FREE(g_key_wep_params.key); + g_key_wep_params.key = NULL; + } + + /*freeing memory allocated by "wilc_gtk" and "wilc_ptk" in "WILC_WIFI_ADD_KEY"*/ + + #ifdef WILC_AP_EXTERNAL_MLME + if ((priv->wilc_gtk[key_index]) != NULL) { + + if (priv->wilc_gtk[key_index]->key != NULL) { + + WILC_FREE(priv->wilc_gtk[key_index]->key); + priv->wilc_gtk[key_index]->key = NULL; + } + if (priv->wilc_gtk[key_index]->seq) { + + WILC_FREE(priv->wilc_gtk[key_index]->seq); + priv->wilc_gtk[key_index]->seq = NULL; + } + + WILC_FREE(priv->wilc_gtk[key_index]); + priv->wilc_gtk[key_index] = NULL; + + } + + if ((priv->wilc_ptk[key_index]) != NULL) { + + if (priv->wilc_ptk[key_index]->key) { + + WILC_FREE(priv->wilc_ptk[key_index]->key); + priv->wilc_ptk[key_index]->key = NULL; + } + if (priv->wilc_ptk[key_index]->seq) { + + WILC_FREE(priv->wilc_ptk[key_index]->seq); + priv->wilc_ptk[key_index]->seq = NULL; + } + WILC_FREE(priv->wilc_ptk[key_index]); + priv->wilc_ptk[key_index] = NULL; + } + #endif + + /*Delete saved PTK and GTK keys params, if any*/ + if (g_key_ptk_params.key != NULL) { + WILC_FREE(g_key_ptk_params.key); + g_key_ptk_params.key = NULL; + } + if (g_key_ptk_params.seq != NULL) { + WILC_FREE(g_key_ptk_params.seq); + g_key_ptk_params.seq = NULL; + } + + if (g_key_gtk_params.key != NULL) { + WILC_FREE(g_key_gtk_params.key); + g_key_gtk_params.key = NULL; + } + if (g_key_gtk_params.seq != NULL) { + WILC_FREE(g_key_gtk_params.seq); + g_key_gtk_params.seq = NULL; + } + + /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/ + Set_machw_change_vir_if(WILC_FALSE); + } + + if (key_index >= 0 && key_index <= 3) { + WILC_memset(priv->WILC_WFI_wep_key[key_index], 0, priv->WILC_WFI_wep_key_len[key_index]); + priv->WILC_WFI_wep_key_len[key_index] = 0; + + PRINT_D(CFG80211_DBG, "Removing WEP key with index = %d\n", key_index); + host_int_remove_wep_key(priv->hWILCWFIDrv, key_index); + } else { + PRINT_D(CFG80211_DBG, "Removing all installed keys\n"); + host_int_remove_key(priv->hWILCWFIDrv, mac_addr); + } + + return s32Error; +} + +/** + * @brief WILC_WFI_get_key + * @details Get information about the key with the given parameters. + * @mac_addr will be %NULL when requesting information for a group + * key. All pointers given to the @callback function need not be valid + * after it returns. This function should return an error if it is + * not possible to retrieve the key, -ENOENT if it doesn't exist. + * @param[in] + * @return int : Return 0 on Success + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) + bool pairwise, + #endif + const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *)) +{ + + WILC_Sint32 s32Error = WILC_SUCCESS; + + struct WILC_WFI_priv *priv; + struct key_params key_params; + WILC_Uint32 i; + priv = wiphy_priv(wiphy); + + + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) + if (!pairwise) + #else + if (!mac_addr || is_broadcast_ether_addr(mac_addr)) + #endif + { + PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index); + + key_params.key = priv->wilc_gtk[key_index]->key; + key_params.cipher = priv->wilc_gtk[key_index]->cipher; + key_params.key_len = priv->wilc_gtk[key_index]->key_len; + key_params.seq = priv->wilc_gtk[key_index]->seq; + key_params.seq_len = priv->wilc_gtk[key_index]->seq_len; + if (INFO) { + for (i = 0; i < key_params.key_len; i++) + PRINT_INFO(CFG80211_DBG, "Retrieved key value %x\n", key_params.key[i]); + } + } else { + PRINT_D(CFG80211_DBG, "Getting pairwise key\n"); + + key_params.key = priv->wilc_ptk[key_index]->key; + key_params.cipher = priv->wilc_ptk[key_index]->cipher; + key_params.key_len = priv->wilc_ptk[key_index]->key_len; + key_params.seq = priv->wilc_ptk[key_index]->seq; + key_params.seq_len = priv->wilc_ptk[key_index]->seq_len; + } + + callback(cookie, &key_params); + + return s32Error; /* priv->wilc_gtk->key_len ?0 : -ENOENT; */ +} + +/** + * @brief WILC_WFI_set_default_key + * @details Set the default management frame key on an interface + * @param[in] + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 37) + , bool unicast, bool multicast + #endif + ) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + struct WILC_WFI_priv *priv; + + + priv = wiphy_priv(wiphy); + + PRINT_D(CFG80211_DBG, "Setting default key with idx = %d \n", key_index); + + if (key_index != priv->WILC_WFI_wep_default) { + + host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, key_index); + } + + return s32Error; +} + +/** + * @brief WILC_WFI_dump_survey + * @details Get site survey information + * @param[in] + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_dump_survey(struct wiphy *wiphy, struct net_device *netdev, + int idx, struct survey_info *info) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + + + if (idx != 0) { + s32Error = -ENOENT; + PRINT_ER("Error Idx value doesn't equal zero: Error(%d)\n", s32Error); + + } + + return s32Error; +} + + +/** + * @brief WILC_WFI_get_station + * @details Get station information for the station identified by @mac + * @param[in] NONE + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ + +extern uint32_t Statisitcs_totalAcks, Statisitcs_DroppedAcks; +static int WILC_WFI_get_station(struct wiphy *wiphy, struct net_device *dev, + u8 *mac, struct station_info *sinfo) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + struct WILC_WFI_priv *priv; + perInterface_wlan_t *nic; + #ifdef WILC_AP_EXTERNAL_MLME + WILC_Uint32 i = 0; + WILC_Uint32 associatedsta = 0; + WILC_Uint32 inactive_time = 0; + #endif + priv = wiphy_priv(wiphy); + nic = netdev_priv(dev); + + #ifdef WILC_AP_EXTERNAL_MLME + if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) { + PRINT_D(HOSTAPD_DBG, "Getting station parameters\n"); + + PRINT_INFO(HOSTAPD_DBG, ": %x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4]); + + for (i = 0; i < NUM_STA_ASSOCIATED; i++) { + + if (!(memcmp(mac, priv->assoc_stainfo.au8Sta_AssociatedBss[i], ETH_ALEN))) { + associatedsta = i; + break; + } + + } + + if (associatedsta == -1) { + s32Error = -ENOENT; + PRINT_ER("Station required is not associated : Error(%d)\n", s32Error); + + return s32Error; + } + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) //0421 + sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME); +#else + sinfo->filled |= STATION_INFO_INACTIVE_TIME; +#endif + + host_int_get_inactive_time(priv->hWILCWFIDrv, mac, &(inactive_time)); + sinfo->inactive_time = 1000 * inactive_time; + PRINT_D(CFG80211_DBG, "Inactive time %d\n", sinfo->inactive_time); + + } + #endif + + if (nic->iftype == STATION_MODE) { + tstrStatistics strStatistics; + host_int_get_statistics(priv->hWILCWFIDrv, &strStatistics); + + /* + * tony: 2013-11-13 + * tx_failed introduced more than + * kernel version 3.0.0 + */ + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) //0421 + sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) | + BIT( NL80211_STA_INFO_RX_PACKETS) | + BIT(NL80211_STA_INFO_TX_PACKETS) | + BIT(NL80211_STA_INFO_TX_FAILED) | + BIT(NL80211_STA_INFO_TX_BITRATE); + #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0) + sinfo->filled |= STATION_INFO_SIGNAL | STATION_INFO_RX_PACKETS | STATION_INFO_TX_PACKETS + | STATION_INFO_TX_FAILED | STATION_INFO_TX_BITRATE; + #else + sinfo->filled |= STATION_INFO_SIGNAL | STATION_INFO_RX_PACKETS | STATION_INFO_TX_PACKETS + | STATION_INFO_TX_BITRATE; + #endif + + sinfo->signal = strStatistics.s8RSSI; + sinfo->rx_packets = strStatistics.u32RxCount; + sinfo->tx_packets = strStatistics.u32TxCount + strStatistics.u32TxFailureCount; + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0) + sinfo->tx_failed = strStatistics.u32TxFailureCount; + #endif + sinfo->txrate.legacy = strStatistics.u8LinkSpeed * 10; + +#ifdef TCP_ENHANCEMENTS + if ((strStatistics.u8LinkSpeed > TCP_ACK_FILTER_LINK_SPEED_THRESH) && (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED)) { + Enable_TCP_ACK_Filter(WILC_TRUE); + } else if (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED) { + Enable_TCP_ACK_Filter(WILC_FALSE); + } +#endif + + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0) + PRINT_D(CORECONFIG_DBG, "*** stats[%d][%d][%d][%d][%d]\n", sinfo->signal, sinfo->rx_packets, sinfo->tx_packets, + sinfo->tx_failed, sinfo->txrate.legacy); + #else + PRINT_D(CORECONFIG_DBG, "*** stats[%d][%d][%d][%d]\n", sinfo->signal, sinfo->rx_packets, sinfo->tx_packets, + sinfo->txrate.legacy); + #endif + } + return s32Error; +} + + +/** + * @brief WILC_WFI_change_bss + * @details Modify parameters for a given BSS. + * @param[in] + * -use_cts_prot: Whether to use CTS protection + * (0 = no, 1 = yes, -1 = do not change) + * -use_short_preamble: Whether the use of short preambles is allowed + * (0 = no, 1 = yes, -1 = do not change) + * -use_short_slot_time: Whether the use of short slot time is allowed + * (0 = no, 1 = yes, -1 = do not change) + * -basic_rates: basic rates in IEEE 802.11 format + * (or NULL for no change) + * -basic_rates_len: number of basic rates + * -ap_isolate: do not forward packets between connected stations + * -ht_opmode: HT Operation mode + * (u16 = opmode, -1 = do not change) + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_change_bss(struct wiphy *wiphy, struct net_device *dev, + struct bss_parameters *params) +{ + PRINT_D(CFG80211_DBG, "Changing Bss parametrs\n"); + return 0; +} + +/** + * @brief WILC_WFI_auth + * @details Request to authenticate with the specified peer + * @param[in] + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_auth(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_auth_request *req) +{ + PRINT_D(CFG80211_DBG, "In Authentication Function\n"); + return 0; +} + +/** + * @brief WILC_WFI_assoc + * @details Request to (re)associate with the specified peer + * @param[in] + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_assoc(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_assoc_request *req) +{ + PRINT_D(CFG80211_DBG, "In Association Function\n"); + return 0; +} + +/** + * @brief WILC_WFI_deauth + * @details Request to deauthenticate from the specified peer + * @param[in] + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_deauth(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_deauth_request *req, void *cookie) +{ + PRINT_D(CFG80211_DBG, "In De-authentication Function\n"); + return 0; +} + +/** + * @brief WILC_WFI_disassoc + * @details Request to disassociate from the specified peer + * @param[in] + * @return int : Return 0 on Success + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_disassoc(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_disassoc_request *req, void *cookie) +{ + PRINT_D(CFG80211_DBG, "In Disassociation Function\n"); + return 0; +} + +/** + * @brief WILC_WFI_set_wiphy_params + * @details Notify that wiphy parameters have changed; + * @param[in] Changed bitfield (see &enum wiphy_params_flags) describes which values + * have changed. + * @return int : Return 0 on Success + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_set_wiphy_params(struct wiphy *wiphy, u32 changed) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrCfgParamVal pstrCfgParamVal; + struct WILC_WFI_priv *priv; + + priv = wiphy_priv(wiphy); +/* priv = netdev_priv(priv->wdev->netdev); */ + + pstrCfgParamVal.u32SetCfgFlag = 0; + PRINT_D(CFG80211_DBG, "Setting Wiphy params \n"); + + if (changed & WIPHY_PARAM_RETRY_SHORT) { + PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_SHORT %d\n", + priv->dev->ieee80211_ptr->wiphy->retry_short); + pstrCfgParamVal.u32SetCfgFlag |= RETRY_SHORT; + pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short; + } + if (changed & WIPHY_PARAM_RETRY_LONG) { + + PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_LONG %d\n", priv->dev->ieee80211_ptr->wiphy->retry_long); + pstrCfgParamVal.u32SetCfgFlag |= RETRY_LONG; + pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long; + + } + if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { + PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->frag_threshold); + pstrCfgParamVal.u32SetCfgFlag |= FRAG_THRESHOLD; + pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold; + + } + + if (changed & WIPHY_PARAM_RTS_THRESHOLD) { + PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->rts_threshold); + + pstrCfgParamVal.u32SetCfgFlag |= RTS_THRESHOLD; + pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold; + + } + + PRINT_D(CFG80211_DBG, "Setting CFG params in the host interface\n"); + s32Error = hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal); + if (s32Error) + PRINT_ER("Error in setting WIPHY PARAMS\n"); + + + return s32Error; +} +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32) +/** + * @brief WILC_WFI_set_bitrate_mask + * @details set the bitrate mask configuration + * @param[in] + * @return int : Return 0 on Success + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_set_bitrate_mask(struct wiphy *wiphy, + struct net_device *dev, const u8 *peer, + const struct cfg80211_bitrate_mask *mask) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + /* strCfgParamVal pstrCfgParamVal; */ + /* struct WILC_WFI_priv* priv; */ + + PRINT_D(CFG80211_DBG, "Setting Bitrate mask function\n"); +#if 0 + priv = wiphy_priv(wiphy); + /* priv = netdev_priv(priv->wdev->netdev); */ + + pstrCfgParamVal.curr_tx_rate = mask->control[IEEE80211_BAND_2GHZ].legacy; + + PRINT_D(CFG80211_DBG, "Tx rate = %d\n", pstrCfgParamVal.curr_tx_rate); + s32Error = hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal); + + if (s32Error) + PRINT_ER("Error in setting bitrate\n"); +#endif + return s32Error; + +} + +/** + * @brief WILC_WFI_set_pmksa + * @details Cache a PMKID for a BSSID. This is mostly useful for fullmac + * devices running firmwares capable of generating the (re) association + * RSN IE. It allows for faster roaming between WPA2 BSSIDs. + * @param[in] + * @return int : Return 0 on Success + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_set_pmksa(struct wiphy *wiphy, struct net_device *netdev, + struct cfg80211_pmksa *pmksa) +{ + WILC_Uint32 i; + WILC_Sint32 s32Error = WILC_SUCCESS; + WILC_Uint8 flag = 0; + + struct WILC_WFI_priv *priv = wiphy_priv(wiphy); + + PRINT_D(CFG80211_DBG, "Setting PMKSA\n"); + + + for (i = 0; i < priv->pmkid_list.numpmkid; i++) { + if (!WILC_memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid, + ETH_ALEN)) { + /*If bssid already exists and pmkid value needs to reset*/ + flag = PMKID_FOUND; + PRINT_D(CFG80211_DBG, "PMKID already exists\n"); + break; + } + } + if (i < WILC_MAX_NUM_PMKIDS) { + PRINT_D(CFG80211_DBG, "Setting PMKID in private structure\n"); + WILC_memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid, + ETH_ALEN); + WILC_memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid, + PMKID_LEN); + if (!(flag == PMKID_FOUND)) + priv->pmkid_list.numpmkid++; + } else { + PRINT_ER("Invalid PMKID index\n"); + s32Error = -EINVAL; + } + + if (!s32Error) { + PRINT_D(CFG80211_DBG, "Setting pmkid in the host interface\n"); + s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list); + } + return s32Error; +} + +/** + * @brief WILC_WFI_del_pmksa + * @details Delete a cached PMKID. + * @param[in] + * @return int : Return 0 on Success + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_del_pmksa(struct wiphy *wiphy, struct net_device *netdev, + struct cfg80211_pmksa *pmksa) +{ + + WILC_Uint32 i; + WILC_Uint8 flag = 0; + WILC_Sint32 s32Error = WILC_SUCCESS; + + struct WILC_WFI_priv *priv = wiphy_priv(wiphy); + /* priv = netdev_priv(priv->wdev->netdev); */ + + PRINT_D(CFG80211_DBG, "Deleting PMKSA keys\n"); + + for (i = 0; i < priv->pmkid_list.numpmkid; i++) { + if (!WILC_memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid, + ETH_ALEN)) { + /*If bssid is found, reset the values*/ + PRINT_D(CFG80211_DBG, "Reseting PMKID values\n"); + WILC_memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(tstrHostIFpmkid)); + flag = PMKID_FOUND; + break; + } + } + + if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) { + for (; i < (priv->pmkid_list.numpmkid - 1); i++) { + WILC_memcpy(priv->pmkid_list.pmkidlist[i].bssid, + priv->pmkid_list.pmkidlist[i + 1].bssid, + ETH_ALEN); + WILC_memcpy(priv->pmkid_list.pmkidlist[i].pmkid, + priv->pmkid_list.pmkidlist[i].pmkid, + PMKID_LEN); + } + priv->pmkid_list.numpmkid--; + } else { + s32Error = -EINVAL; + } + + return s32Error; +} + +/** + * @brief WILC_WFI_flush_pmksa + * @details Flush all cached PMKIDs. + * @param[in] + * @return int : Return 0 on Success + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) +{ + struct WILC_WFI_priv *priv = wiphy_priv(wiphy); + /* priv = netdev_priv(priv->wdev->netdev); */ + + PRINT_D(CFG80211_DBG, "Flushing PMKID key values\n"); + + /*Get cashed Pmkids and set all with zeros*/ + WILC_memset(&priv->pmkid_list, 0, sizeof(tstrHostIFpmkidAttr)); + + return 0; +} +#endif + +#ifdef WILC_P2P + +/** + * @brief WILC_WFI_CfgParseRxAction + * @details Function parses the received frames and modifies the following attributes: + * -GO Intent + * -Channel list + * -Operating Channel + * + * @param[in] u8* Buffer, u32 length + * @return NONE. + * @author mdaftedar + * @date 12 DEC 2012 + * @version + */ + +void WILC_WFI_CfgParseRxAction(WILC_Uint8 *buf, WILC_Uint32 len) +{ + WILC_Uint32 index = 0; + WILC_Uint32 i = 0, j = 0; + + /*BugID_5460*/ + #ifdef USE_SUPPLICANT_GO_INTENT + WILC_Uint8 intent; + WILC_Uint8 tie_breaker; + WILC_Bool is_wilc_go = WILC_TRUE; + #endif + WILC_Uint8 op_channel_attr_index = 0; + WILC_Uint8 channel_list_attr_index = 0; + + while (index < len) { + if (buf[index] == GO_INTENT_ATTR_ID) { + #ifdef USE_SUPPLICANT_GO_INTENT + /*BugID_5460*/ + /*Case 1: If we are going to be p2p client, no need to modify channels attributes*/ + /*In negotiation frames, go intent attr value determines who will be GO*/ + intent = GET_GO_INTENT(buf[index + 3]); + tie_breaker = GET_TIE_BREAKER(buf[index + 3]); + if (intent > SUPPLICANT_GO_INTENT + || (intent == SUPPLICANT_GO_INTENT && tie_breaker == 1)) { + PRINT_D(GENERIC_DBG, "WILC will be client (intent %d tie breaker %d)\n", intent, tie_breaker); + is_wilc_go = WILC_FALSE; + } else { + PRINT_D(GENERIC_DBG, "WILC will be GO (intent %d tie breaker %d)\n", intent, tie_breaker); + is_wilc_go = WILC_TRUE; + } + + #else /* USE_SUPPLICANT_GO_INTENT */ + #ifdef FORCE_P2P_CLIENT + buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1); + #else + buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1); + #endif + #endif /* USE_SUPPLICANT_GO_INTENT */ + } + + #ifdef USE_SUPPLICANT_GO_INTENT + /*Case 2: If group bssid attribute is present, no need to modify channels attributes*/ + /*In invitation req and rsp, group bssid attr presence determines who will be GO*/ + if (buf[index] == GROUP_BSSID_ATTR_ID) { + PRINT_D(GENERIC_DBG, "Group BSSID: %2x:%2x:%2x\n", buf[index + 3] + , buf[index + 4] + , buf[index + 5]); + is_wilc_go = WILC_FALSE; + } + #endif /* USE_SUPPLICANT_GO_INTENT */ + + if (buf[index] == CHANLIST_ATTR_ID) { + channel_list_attr_index = index; + } else if (buf[index] == OPERCHAN_ATTR_ID) { + op_channel_attr_index = index; + } + index += buf[index + 1] + 3; /* ID,Length byte */ + } + + #ifdef USE_SUPPLICANT_GO_INTENT + if (u8WLANChannel != INVALID_CHANNEL && is_wilc_go) + #else + if (u8WLANChannel != INVALID_CHANNEL) + #endif + { + /*Modify channel list attribute*/ + if (channel_list_attr_index) { + PRINT_D(GENERIC_DBG, "Modify channel list attribute\n"); + for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) { + if (buf[i] == 0x51) { + for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) { + buf[j] = u8WLANChannel; + } + break; + } + } + } + /*Modify operating channel attribute*/ + if (op_channel_attr_index) { + PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n"); + buf[op_channel_attr_index + 6] = 0x51; + buf[op_channel_attr_index + 7] = u8WLANChannel; + } + } +} + +/** + * @brief WILC_WFI_CfgParseTxAction + * @details Function parses the transmitted action frames and modifies the + * GO Intent attribute + * @param[in] u8* Buffer, u32 length, bool bOperChan, u8 iftype + * @return NONE. + * @author mdaftedar + * @date 12 DEC 2012 + * @version + */ +void WILC_WFI_CfgParseTxAction(WILC_Uint8 *buf, WILC_Uint32 len, WILC_Bool bOperChan, WILC_Uint8 iftype) +{ + WILC_Uint32 index = 0; + WILC_Uint32 i = 0, j = 0; + + WILC_Uint8 op_channel_attr_index = 0; + WILC_Uint8 channel_list_attr_index = 0; + #ifdef USE_SUPPLICANT_GO_INTENT + WILC_Bool is_wilc_go = WILC_FALSE; + + /*BugID_5460*/ + /*Case 1: If we are already p2p client, no need to modify channels attributes*/ + /*This to handle the case of inviting a p2p peer to join an existing group which we are a member in*/ + if (iftype == CLIENT_MODE) + return; + #endif + + while (index < len) { + #ifdef USE_SUPPLICANT_GO_INTENT + /*Case 2: If group bssid attribute is present, no need to modify channels attributes*/ + /*In invitation req and rsp, group bssid attr presence determines who will be GO*/ + /*Note: If we are already p2p client, group bssid attr may also be present (handled in Case 1)*/ + if (buf[index] == GROUP_BSSID_ATTR_ID) { + PRINT_D(GENERIC_DBG, "Group BSSID: %2x:%2x:%2x\n", buf[index + 3] + , buf[index + 4] + , buf[index + 5]); + is_wilc_go = WILC_TRUE; + } + + #else /* USE_SUPPLICANT_GO_INTENT */ + if (buf[index] == GO_INTENT_ATTR_ID) { + #ifdef FORCE_P2P_CLIENT + buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1); + #else + buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1); + #endif + + break; + } + #endif + + if (buf[index] == CHANLIST_ATTR_ID) { + channel_list_attr_index = index; + } else if (buf[index] == OPERCHAN_ATTR_ID) { + op_channel_attr_index = index; + } + index += buf[index + 1] + 3; /* ID,Length byte */ + } + + #ifdef USE_SUPPLICANT_GO_INTENT + /*No need to check bOperChan since only transmitted invitation frames are parsed*/ + if (u8WLANChannel != INVALID_CHANNEL && is_wilc_go) + #else + if (u8WLANChannel != INVALID_CHANNEL && bOperChan) + #endif + { + /*Modify channel list attribute*/ + if (channel_list_attr_index) { + PRINT_D(GENERIC_DBG, "Modify channel list attribute\n"); + for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) { + if (buf[i] == 0x51) { + for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) { + buf[j] = u8WLANChannel; + } + break; + } + } + } + /*Modify operating channel attribute*/ + if (op_channel_attr_index) { + PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n"); + buf[op_channel_attr_index + 6] = 0x51; + buf[op_channel_attr_index + 7] = u8WLANChannel; + } + } +} + +/* @brief WILC_WFI_p2p_rx + * @details + * @param[in] + * + * @return None + * @author Mai Daftedar + * @date 2 JUN 2013 + * @version 1.0 + */ + +void WILC_WFI_p2p_rx (struct net_device *dev, uint8_t *buff, uint32_t size) +{ + + struct WILC_WFI_priv *priv; + WILC_Uint32 header, pkt_offset; + tstrWILC_WFIDrv *pstrWFIDrv; + WILC_Uint32 i = 0; + WILC_Sint32 s32Freq; + priv = wiphy_priv(dev->ieee80211_ptr->wiphy); + pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv; + + /* Get WILC header */ + WILC_memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET); + + /* The packet offset field conain info about what type of managment frame */ + /* we are dealing with and ack status */ + pkt_offset = GET_PKT_OFFSET(header); + + if (pkt_offset & IS_MANAGMEMENT_CALLBACK) { + if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) { + PRINT_D(GENERIC_DBG, "Probe response ACK\n"); + #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0)) + cfg80211_mgmt_tx_status(dev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL); + #else + cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL); + #endif + return; + } else { + if (pkt_offset & IS_MGMT_STATUS_SUCCES) { + PRINT_D(GENERIC_DBG, "Success Ack - Action frame category: %x Action Subtype: %d Dialog T: %x OR %x\n", buff[ACTION_CAT_ID], buff[ACTION_SUBTYPE_ID], + buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]); + #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0)) + cfg80211_mgmt_tx_status(dev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL); + #else + cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL); + #endif + } else { + PRINT_D(GENERIC_DBG, "Fail Ack - Action frame category: %x Action Subtype: %d Dialog T: %x OR %x\n", buff[ACTION_CAT_ID], buff[ACTION_SUBTYPE_ID], + buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]); + #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0)) + cfg80211_mgmt_tx_status(dev, priv->u64tx_cookie, buff, size, false, GFP_KERNEL); + #else + cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, false, GFP_KERNEL); + #endif + } + return; + } + } else { + + PRINT_D(GENERIC_DBG, "Rx Frame Type:%x\n", buff[FRAME_TYPE_ID]); + + /*BugID_5442*/ + /*Upper layer is informed that the frame is received on this freq*/ + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38) + s32Freq = ieee80211_channel_to_frequency(u8CurrChannel, IEEE80211_BAND_2GHZ); + #else + s32Freq = ieee80211_channel_to_frequency(u8CurrChannel); + #endif + + if (ieee80211_is_action(buff[FRAME_TYPE_ID])) { + PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]); + + if (priv->bCfgScanning == WILC_TRUE && jiffies >= pstrWFIDrv->u64P2p_MgmtTimeout) { + PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n"); + return; + } + if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) { + + switch (buff[ACTION_SUBTYPE_ID]) { + case GAS_INTIAL_REQ: + PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buff[ACTION_SUBTYPE_ID]); + break; + + case GAS_INTIAL_RSP: + PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buff[ACTION_SUBTYPE_ID]); + break; + + case PUBLIC_ACT_VENDORSPEC: + /*Now we have a public action vendor specific action frame, check if its a p2p public action frame + * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/ + if (!WILC_memcmp(u8P2P_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) { + if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) { + if (!bWilc_ie) { + for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) { + if (!WILC_memcmp(u8P2P_vendorspec, &buff[i], 6)) { + u8P2Precvrandom = buff[i + 6]; + bWilc_ie = WILC_TRUE; + PRINT_D(GENERIC_DBG, "WILC Vendor specific IE:%02x\n", u8P2Precvrandom); + break; + } + } + } + } + if (u8P2Plocalrandom > u8P2Precvrandom) { + if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP + || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) { + for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) { + if (buff[i] == P2PELEM_ATTR_ID && !(WILC_memcmp(u8P2P_oui, &buff[i + 2], 4))) { + WILC_WFI_CfgParseRxAction(&buff[i + 6], size - (i + 6)); + break; + } + } + } + } else + PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom); + } + + + if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP) && (bWilc_ie)) { + PRINT_D(GENERIC_DBG, "Sending P2P to host without extra elemnt\n"); + /* extra attribute for sig_dbm: signal strength in mBm, or 0 if unknown */ + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)) + cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0); + #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)) + cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0, GFP_ATOMIC); + #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) + cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, GFP_ATOMIC); + #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)) + cfg80211_rx_mgmt(dev, s32Freq, 0, buff, size - 7, GFP_ATOMIC); /* rachel */ + #elif (LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0)) + cfg80211_rx_mgmt(dev, s32Freq, buff, size - 7, GFP_ATOMIC); + #endif + + return; + } + break; + + default: + PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]); + break; + } + } + } + + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)) + cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0); + #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)) + cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0, GFP_ATOMIC); + #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) + cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size, GFP_ATOMIC); + #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)) + cfg80211_rx_mgmt(dev, s32Freq, 0, buff, size, GFP_ATOMIC); + #elif (LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0)) + cfg80211_rx_mgmt(dev, s32Freq, buff, size, GFP_ATOMIC); + #endif + } +} + +/** + * @brief WILC_WFI_mgmt_tx_complete + * @details Returns result of writing mgmt frame to VMM (Tx buffers are freed here) + * @param[in] priv + * transmitting status + * @return None + * @author Amr Abdelmoghny + * @date 20 MAY 2013 + * @version 1.0 + */ +static void WILC_WFI_mgmt_tx_complete(void *priv, int status) +{ + struct p2p_mgmt_data *pv_data = (struct p2p_mgmt_data *)priv; + + + kfree(pv_data->buff); + kfree(pv_data); +} + +/** + * @brief WILC_WFI_RemainOnChannelReady + * @details Callback function, called from handle_remain_on_channel on being ready on channel + * @param + * @return none + * @author Amr abdelmoghny + * @date 9 JUNE 2013 + * @version + */ + +static void WILC_WFI_RemainOnChannelReady(void *pUserVoid) +{ + struct WILC_WFI_priv *priv; + priv = (struct WILC_WFI_priv *)pUserVoid; + + PRINT_D(HOSTINF_DBG, "Remain on channel ready \n"); + + priv->bInP2PlistenState = WILC_TRUE; + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) + cfg80211_ready_on_channel(priv->wdev, + priv->strRemainOnChanParams.u64ListenCookie, + priv->strRemainOnChanParams.pstrListenChan, + priv->strRemainOnChanParams.u32ListenDuration, + GFP_KERNEL); +#else + cfg80211_ready_on_channel(priv->dev, + priv->strRemainOnChanParams.u64ListenCookie, + priv->strRemainOnChanParams.pstrListenChan, + priv->strRemainOnChanParams.tenuChannelType, + priv->strRemainOnChanParams.u32ListenDuration, + GFP_KERNEL); +#endif +} + +/** + * @brief WILC_WFI_RemainOnChannelExpired + * @details Callback function, called on expiration of remain-on-channel duration + * @param + * @return none + * @author Amr abdelmoghny + * @date 15 MAY 2013 + * @version + */ + +static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, WILC_Uint32 u32SessionID) +{ + struct WILC_WFI_priv *priv; + priv = (struct WILC_WFI_priv *)pUserVoid; + + /*BugID_5477*/ + if (u32SessionID == priv->strRemainOnChanParams.u32ListenSessionID) { + PRINT_D(GENERIC_DBG, "Remain on channel expired \n"); + + priv->bInP2PlistenState = WILC_FALSE; + + /*Inform wpas of remain-on-channel expiration*/ + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) + cfg80211_remain_on_channel_expired(priv->wdev, + priv->strRemainOnChanParams.u64ListenCookie, + priv->strRemainOnChanParams.pstrListenChan, + GFP_KERNEL); + #else + cfg80211_remain_on_channel_expired(priv->dev, + priv->strRemainOnChanParams.u64ListenCookie, + priv->strRemainOnChanParams.pstrListenChan, + priv->strRemainOnChanParams.tenuChannelType, + GFP_KERNEL); + #endif + } else { + PRINT_D(GENERIC_DBG, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID + , priv->strRemainOnChanParams.u32ListenSessionID); + } +} + + +/** + * @brief WILC_WFI_remain_on_channel + * @details Request the driver to remain awake on the specified + * channel for the specified duration to complete an off-channel + * operation (e.g., public action frame exchange). When the driver is + * ready on the requested channel, it must indicate this with an event + * notification by calling cfg80211_ready_on_channel(). + * @param[in] + * @return int : Return 0 on Success + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_remain_on_channel(struct wiphy *wiphy, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) + struct wireless_dev *wdev, +#else + struct net_device *dev, +#endif + struct ieee80211_channel *chan, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0)) + enum nl80211_channel_type channel_type, +#endif + unsigned int duration, u64 *cookie) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + struct WILC_WFI_priv *priv; + priv = wiphy_priv(wiphy); + + PRINT_D(GENERIC_DBG, "Remaining on channel %d\n", chan->hw_value); + + /*BugID_4800: if in AP mode, return.*/ + /*This check is to handle the situation when user*/ + /*requests "create group" during a running scan*/ + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) + if (wdev->iftype == NL80211_IFTYPE_AP) { + PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode"); + return s32Error; + } +#else + if (dev->ieee80211_ptr->iftype == NL80211_IFTYPE_AP) { + PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode"); + return s32Error; + } +#endif + + u8CurrChannel = chan->hw_value; + + /*Setting params needed by WILC_WFI_RemainOnChannelExpired()*/ + priv->strRemainOnChanParams.pstrListenChan = chan; + priv->strRemainOnChanParams.u64ListenCookie = *cookie; + #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0)) + priv->strRemainOnChanParams.tenuChannelType = channel_type; + #endif + priv->strRemainOnChanParams.u32ListenDuration = duration; + priv->strRemainOnChanParams.u32ListenSessionID++; + + s32Error = host_int_remain_on_channel(priv->hWILCWFIDrv + , priv->strRemainOnChanParams.u32ListenSessionID + , duration + , chan->hw_value + , WILC_WFI_RemainOnChannelExpired + , WILC_WFI_RemainOnChannelReady + , (void *)priv); + + return s32Error; +} + +/** + * @brief WILC_WFI_cancel_remain_on_channel + * @details Cancel an on-going remain-on-channel operation. + * This allows the operation to be terminated prior to timeout based on + * the duration value. + * @param[in] struct wiphy *wiphy, + * @param[in] struct net_device *dev + * @param[in] u64 cookie, + * @return int : Return 0 on Success + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_cancel_remain_on_channel(struct wiphy *wiphy, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) + struct wireless_dev *wdev, +#else + struct net_device *dev, +#endif + u64 cookie) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + struct WILC_WFI_priv *priv; + priv = wiphy_priv(wiphy); + + PRINT_D(CFG80211_DBG, "Cancel remain on channel\n"); + + s32Error = host_int_ListenStateExpired(priv->hWILCWFIDrv, priv->strRemainOnChanParams.u32ListenSessionID); + return s32Error; +} +/** + * @brief WILC_WFI_add_wilcvendorspec + * @details Adding WILC information elemet to allow two WILC devices to + * identify each other and connect + * @param[in] WILC_Uint8 * buf + * @return void + * @author mdaftedar + * @date 01 JAN 2014 + * @version 1.0 + */ +void WILC_WFI_add_wilcvendorspec(WILC_Uint8 *buff) +{ + WILC_memcpy(buff, u8P2P_vendorspec, sizeof(u8P2P_vendorspec)); +} +/** + * @brief WILC_WFI_mgmt_tx_frame + * @details + * + * @param[in] + * @return NONE. + * @author mdaftedar + * @date 01 JUL 2012 + * @version + */ +extern linux_wlan_t *g_linux_wlan; +extern WILC_Bool bEnablePS; +int WILC_WFI_mgmt_tx(struct wiphy *wiphy, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0) + struct wireless_dev *wdev, + struct cfg80211_mgmt_tx_params *params, + u64 *cookie) +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)) + struct wireless_dev *wdev, + struct ieee80211_channel *chan, + bool offchan, + unsigned int wait, + const u8 *buf, + size_t len, + bool no_cck, + bool dont_wait_for_ack, u64 *cookie) +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) + struct wireless_dev *wdev, + struct ieee80211_channel *chan, bool offchan, + enum nl80211_channel_type channel_type, + bool channel_type valid, + unsigned int wait, const u8 *buf, + size_t len, bool no_cck, + bool dont_wait_for_ack, u64 *cookie) +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)) + struct net_device *dev, + struct ieee80211_channel *chan, bool offchan, + enum nl80211_channel_type channel_type, + bool channel_type_valid, + unsigned int wait, const u8 *buf, + size_t len, bool no_cck, + bool dont_wait_for_ack, u64 *cookie) +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)) + struct net_device *dev, + struct ieee80211_channel *chan, bool offchan, + enum nl80211_channel_type channel_type, + bool channel_type_valid, + unsigned int wait, const u8 *buf, + size_t len, bool no_cck, u64 *cookie) +#else + struct net_device *dev, + struct ieee80211_channel *chan, bool offchan, + enum nl80211_channel_type channel_type, + bool channel_type_valid, + unsigned int wait, const u8 *buf, + size_t len, u64 *cookie) +#endif +{ + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0) + struct ieee80211_channel *chan = params->chan; + unsigned int wait = params->wait; + const u8 *buf = params->buf; + size_t len = params->len; + #endif + const struct ieee80211_mgmt *mgmt; + struct p2p_mgmt_data *mgmt_tx; + struct WILC_WFI_priv *priv; + WILC_Sint32 s32Error = WILC_SUCCESS; + tstrWILC_WFIDrv *pstrWFIDrv; + WILC_Uint32 i; + perInterface_wlan_t *nic; + WILC_Uint32 buf_len = len + sizeof(u8P2P_vendorspec) + sizeof(u8P2Plocalrandom); + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) + nic = netdev_priv(wdev->netdev); +#else + nic = netdev_priv(dev); +#endif + priv = wiphy_priv(wiphy); + pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv; + + *cookie = (unsigned long)buf; + priv->u64tx_cookie = *cookie; + mgmt = (const struct ieee80211_mgmt *) buf; + + if (ieee80211_is_mgmt(mgmt->frame_control)) { + + /*mgmt frame allocation*/ + mgmt_tx = (struct p2p_mgmt_data *)WILC_MALLOC(sizeof(struct p2p_mgmt_data)); + if (mgmt_tx == NULL) { + PRINT_ER("Failed to allocate memory for mgmt_tx structure\n"); + return WILC_FAIL; + } + mgmt_tx->buff = (char *)WILC_MALLOC(buf_len); + if (mgmt_tx->buff == NULL) { + PRINT_ER("Failed to allocate memory for mgmt_tx buff\n"); + return WILC_FAIL; + } + WILC_memcpy(mgmt_tx->buff, buf, len); + mgmt_tx->size = len; + + + if (ieee80211_is_probe_resp(mgmt->frame_control)) { + PRINT_D(GENERIC_DBG, "TX: Probe Response\n"); + PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value); + host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value); + /*Save the current channel after we tune to it*/ + u8CurrChannel = chan->hw_value; + } else if (ieee80211_is_action(mgmt->frame_control)) { + PRINT_D(GENERIC_DBG, "ACTION FRAME:%x\n", (WILC_Uint16)mgmt->frame_control); + + + /*BugID_4847*/ + if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) { + /*BugID_4847*/ + /*Only set the channel, if not a negotiation confirmation frame + * (If Negotiation confirmation frame, force it + * to be transmitted on the same negotiation channel)*/ + + if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC || + buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) { + PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value); + host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value); + /*Save the current channel after we tune to it*/ + u8CurrChannel = chan->hw_value; + } + switch (buf[ACTION_SUBTYPE_ID]) { + case GAS_INTIAL_REQ: + { + PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buf[ACTION_SUBTYPE_ID]); + break; + } + + case GAS_INTIAL_RSP: + { + PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buf[ACTION_SUBTYPE_ID]); + break; + } + + case PUBLIC_ACT_VENDORSPEC: + { + /*Now we have a public action vendor specific action frame, check if its a p2p public action frame + * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/ + if (!WILC_memcmp(u8P2P_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) { + /*For the connection of two WILC's connection generate a rand number to determine who will be a GO*/ + if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) { + if (u8P2Plocalrandom == 1 && u8P2Precvrandom < u8P2Plocalrandom) { + get_random_bytes(&u8P2Plocalrandom, 1); + /*Increment the number to prevent if its 0*/ + u8P2Plocalrandom++; + } + } + + if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP + || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) { + if (u8P2Plocalrandom > u8P2Precvrandom) { + PRINT_D(GENERIC_DBG, "LOCAL WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom); + + /*Search for the p2p information information element , after the Public action subtype theres a byte for teh dialog token, skip that*/ + for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) { + if (buf[i] == P2PELEM_ATTR_ID && !(WILC_memcmp(u8P2P_oui, &buf[i + 2], 4))) { + if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP) + WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), WILC_TRUE, nic->iftype); + + /*BugID_5460*/ + /*If using supplicant go intent, no need at all*/ + /*to parse transmitted negotiation frames*/ + #ifndef USE_SUPPLICANT_GO_INTENT + else + WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), WILC_FALSE, nic->iftype); + #endif + break; + } + } + + if (buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_REQ && buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_RSP) { + WILC_WFI_add_wilcvendorspec(&mgmt_tx->buff[len]); + mgmt_tx->buff[len + sizeof(u8P2P_vendorspec)] = u8P2Plocalrandom; + mgmt_tx->size = buf_len; + } + } else + PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom); + } + + } else { + PRINT_D(GENERIC_DBG, "Not a P2P public action frame\n"); + } + + break; + } + + default: + { + PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf[ACTION_SUBTYPE_ID]); + break; + } + } + + } + + PRINT_D(GENERIC_DBG, "TX: ACTION FRAME Type:%x : Chan:%d\n", buf[ACTION_SUBTYPE_ID], chan->hw_value); + pstrWFIDrv->u64P2p_MgmtTimeout = (jiffies + msecs_to_jiffies(wait)); + + PRINT_D(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n", jiffies, pstrWFIDrv->u64P2p_MgmtTimeout); + + } + + g_linux_wlan->oup.wlan_add_mgmt_to_tx_que(mgmt_tx, mgmt_tx->buff, mgmt_tx->size, WILC_WFI_mgmt_tx_complete); + } else { + PRINT_D(GENERIC_DBG, "This function transmits only management frames\n"); + } + return s32Error; +} + +int WILC_WFI_mgmt_tx_cancel_wait(struct wiphy *wiphy, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) + struct wireless_dev *wdev, +#else + struct net_device *dev, +#endif + u64 cookie) +{ + struct WILC_WFI_priv *priv; + tstrWILC_WFIDrv *pstrWFIDrv; + priv = wiphy_priv(wiphy); + pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv; + + + PRINT_D(GENERIC_DBG, "Tx Cancel wait :%lu\n", jiffies); + pstrWFIDrv->u64P2p_MgmtTimeout = jiffies; + + if (priv->bInP2PlistenState == WILC_FALSE) { + /* Bug 5504: This is just to avoid connection failure when getting stuck when the supplicant + * considers the driver falsely that it is in Listen state */ + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) + cfg80211_remain_on_channel_expired(priv->wdev, + priv->strRemainOnChanParams.u64ListenCookie, + priv->strRemainOnChanParams.pstrListenChan, + GFP_KERNEL); + #else + cfg80211_remain_on_channel_expired(priv->dev, + priv->strRemainOnChanParams.u64ListenCookie, + priv->strRemainOnChanParams.pstrListenChan, + priv->strRemainOnChanParams.tenuChannelType, + GFP_KERNEL); + #endif + + } + + return 0; +} + +/** + * @brief WILC_WFI_action + * @details Transmit an action frame + * @param[in] + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 JUL 2012 + * @version 1.0 + * */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) +int WILC_WFI_action(struct wiphy *wiphy, struct net_device *dev, + struct ieee80211_channel *chan, enum nl80211_channel_type channel_type, + const u8 *buf, size_t len, u64 *cookie) +{ + PRINT_D(HOSTAPD_DBG, "In action function\n"); + return WILC_SUCCESS; +} +#endif +#else + +/** + * @brief WILC_WFI_frame_register + * @details Notify driver that a management frame type was + * registered. Note that this callback may not sleep, and cannot run + * concurrently with itself. + * @param[in] + * @return NONE. + * @author mdaftedar + * @date 01 JUL 2012 + * @version + */ +void WILC_WFI_frame_register(struct wiphy *wiphy, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) + struct wireless_dev *wdev, +#else + struct net_device *dev, +#endif + u16 frame_type, bool reg) +{ + + struct WILC_WFI_priv *priv; + perInterface_wlan_t *nic; + + + priv = wiphy_priv(wiphy); + nic = netdev_priv(priv->wdev->netdev); + + + + /*BugID_5137*/ + if (!frame_type) + return; + + PRINT_D(GENERIC_DBG, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type, reg); + switch (frame_type) { + case PROBE_REQ: + { + nic->g_struct_frame_reg[0].frame_type = frame_type; + nic->g_struct_frame_reg[0].reg = reg; + } + break; + + case ACTION: + { + nic->g_struct_frame_reg[1].frame_type = frame_type; + nic->g_struct_frame_reg[1].reg = reg; + } + break; + + default: + { + break; + } + + } + /*If mac is closed, then return*/ + if (!g_linux_wlan->wilc1000_initialized) { + PRINT_D(GENERIC_DBG, "Return since mac is closed\n"); + return; + } + host_int_frame_register(priv->hWILCWFIDrv, frame_type, reg); + + +} +#endif +#endif /*WILC_P2P*/ + +/** + * @brief WILC_WFI_set_cqm_rssi_config + * @details Configure connection quality monitor RSSI threshold. + * @param[in] struct wiphy *wiphy: + * @param[in] struct net_device *dev: + * @param[in] s32 rssi_thold: + * @param[in] u32 rssi_hyst: + * @return int : Return 0 on Success + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_set_cqm_rssi_config(struct wiphy *wiphy, + struct net_device *dev, s32 rssi_thold, u32 rssi_hyst) +{ + PRINT_D(CFG80211_DBG, "Setting CQM RSSi Function\n"); + return 0; + +} +/** + * @brief WILC_WFI_dump_station + * @details Configure connection quality monitor RSSI threshold. + * @param[in] struct wiphy *wiphy: + * @param[in] struct net_device *dev + * @param[in] int idx + * @param[in] u8 *mac + * @param[in] struct station_info *sinfo + * @return int : Return 0 on Success + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_dump_station(struct wiphy *wiphy, struct net_device *dev, + int idx, u8 *mac, struct station_info *sinfo) +{ + struct WILC_WFI_priv *priv; + PRINT_D(CFG80211_DBG, "Dumping station information\n"); + + if (idx != 0) + return -ENOENT; + + priv = wiphy_priv(wiphy); + /* priv = netdev_priv(priv->wdev->netdev); */ + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)) //0421 + sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL); +#else + sinfo->filled |= STATION_INFO_SIGNAL; +#endif + + host_int_get_rssi(priv->hWILCWFIDrv, &(sinfo->signal)); + +#if 0 + sinfo->filled |= STATION_INFO_TX_BYTES | + STATION_INFO_TX_PACKETS | + STATION_INFO_RX_BYTES | + STATION_INFO_RX_PACKETS | STATION_INFO_SIGNAL | STATION_INFO_INACTIVE_TIME; + + WILC_SemaphoreAcquire(&SemHandleUpdateStats, NULL); + sinfo->inactive_time = priv->netstats.rx_time > priv->netstats.tx_time ? jiffies_to_msecs(jiffies - priv->netstats.tx_time) : jiffies_to_msecs(jiffies - priv->netstats.rx_time); + sinfo->rx_bytes = priv->netstats.rx_bytes; + sinfo->tx_bytes = priv->netstats.tx_bytes; + sinfo->rx_packets = priv->netstats.rx_packets; + sinfo->tx_packets = priv->netstats.tx_packets; + WILC_SemaphoreRelease(&SemHandleUpdateStats, NULL); +#endif + return 0; + +} + + +/** + * @brief WILC_WFI_set_power_mgmt + * @details + * @param[in] + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 JUL 2012 + * @version 1.0WILC_WFI_set_cqmWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_config_rssi_config + */ +int WILC_WFI_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, + bool enabled, int timeout) +{ + struct WILC_WFI_priv *priv; + PRINT_D(CFG80211_DBG, " Power save Enabled= %d , TimeOut = %d\n", enabled, timeout); + + if (wiphy == WILC_NULL) + return -ENOENT; + + priv = wiphy_priv(wiphy); + if (priv->hWILCWFIDrv == WILC_NULL) { + PRINT_ER("Driver is NULL\n"); + return -EIO; + } + + if (bEnablePS == WILC_TRUE) + host_int_set_power_mgmt(priv->hWILCWFIDrv, enabled, timeout); + + + return WILC_SUCCESS; + +} +#ifdef WILC_AP_EXTERNAL_MLME +/** + * @brief WILC_WFI_change_virt_intf + * @details Change type/configuration of virtual interface, + * keep the struct wireless_dev's iftype updated. + * @param[in] NONE + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +void wilc1000_wlan_deinit(linux_wlan_t *nic); +int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic); + +static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev, + enum nl80211_iftype type, u32 *flags, struct vif_params *params) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + struct WILC_WFI_priv *priv; + /* struct WILC_WFI_mon_priv* mon_priv; */ + perInterface_wlan_t *nic; + WILC_Uint8 interface_type; + WILC_Uint16 TID = 0; + #ifdef WILC_P2P + WILC_Uint8 i; + #endif + + nic = netdev_priv(dev); + priv = wiphy_priv(wiphy); + + PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n"); + PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name); + u8P2Plocalrandom = 0x01; + u8P2Precvrandom = 0x00; + + bWilc_ie = WILC_FALSE; + + #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP + g_obtainingIP = WILC_FALSE; + WILC_TimerStop(&hDuringIpTimer, WILC_NULL); + PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n"); + #endif + /*BugID_5137*/ + /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/ + if (g_ptk_keys_saved && g_gtk_keys_saved) { + Set_machw_change_vir_if(WILC_TRUE); + } + + switch (type) { + case NL80211_IFTYPE_STATION: + connecting = 0; + PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n"); + /* linux_wlan_set_bssid(dev,g_linux_wlan->strInterfaceInfo[0].aSrcAddress); */ + + /* send delba over wlan interface */ + + + dev->ieee80211_ptr->iftype = type; + priv->wdev->iftype = type; + nic->monitor_flag = 0; + nic->iftype = STATION_MODE; + + /*Remove the enteries of the previously connected clients*/ + memset(priv->assoc_stainfo.au8Sta_AssociatedBss, 0, MAX_NUM_STA * ETH_ALEN); + #ifndef SIMULATION + #ifdef WILC_P2P + interface_type = nic->iftype; + nic->iftype = STATION_MODE; + + if (g_linux_wlan->wilc1000_initialized) { + host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID); + /* ensure that the message Q is empty */ + host_int_wait_msg_queue_idle(); + + /*BugID_5213*/ + /*Eliminate host interface blocking state*/ + linux_wlan_unlock((void *)&g_linux_wlan->cfg_event); + + wilc1000_wlan_deinit(g_linux_wlan); + wilc1000_wlan_init(dev, nic); + g_wilc_initialized = 1; + nic->iftype = interface_type; + + /*Setting interface 1 drv handler and mac address in newly downloaded FW*/ + host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler); + host_int_set_MacAddress((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler), + g_linux_wlan->strInterfaceInfo[0].aSrcAddress); + host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE); + + /*Add saved WEP keys, if any*/ + if (g_wep_keys_saved) { + host_int_set_WEPDefaultKeyID((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler), + g_key_wep_params.key_idx); + host_int_add_wep_key_bss_sta((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler), + g_key_wep_params.key, + g_key_wep_params.key_len, + g_key_wep_params.key_idx); + } + + /*No matter the driver handler passed here, it will be overwriiten*/ + /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/ + host_int_flush_join_req(priv->hWILCWFIDrv); + + /*Add saved PTK and GTK keys, if any*/ + if (g_ptk_keys_saved && g_gtk_keys_saved) { + PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0], + g_key_ptk_params.key[1], + g_key_ptk_params.key[2]); + PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0], + g_key_gtk_params.key[1], + g_key_gtk_params.key[2]); + WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, + g_linux_wlan->strInterfaceInfo[0].wilc_netdev, + g_add_ptk_key_params.key_idx, + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) + g_add_ptk_key_params.pairwise, + #endif + g_add_ptk_key_params.mac_addr, + (struct key_params *)(&g_key_ptk_params)); + + WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, + g_linux_wlan->strInterfaceInfo[0].wilc_netdev, + g_add_gtk_key_params.key_idx, + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) + g_add_gtk_key_params.pairwise, + #endif + g_add_gtk_key_params.mac_addr, + (struct key_params *)(&g_key_gtk_params)); + } + + /*BugID_4847: registered frames in firmware are now*/ + /*lost due to mac close. So re-register those frames*/ + if (g_linux_wlan->wilc1000_initialized) { + for (i = 0; i < num_reg_frame; i++) { + PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type, + nic->g_struct_frame_reg[i].reg); + host_int_frame_register(priv->hWILCWFIDrv, + nic->g_struct_frame_reg[i].frame_type, + nic->g_struct_frame_reg[i].reg); + } + } + + bEnablePS = WILC_TRUE; + host_int_set_power_mgmt(priv->hWILCWFIDrv, 1, 0); + } + #endif + #endif + break; + + case NL80211_IFTYPE_P2P_CLIENT: + bEnablePS = WILC_FALSE; + host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0); + connecting = 0; + PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n"); + /* linux_wlan_set_bssid(dev,g_linux_wlan->strInterfaceInfo[0].aSrcAddress); */ + + host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID); + + dev->ieee80211_ptr->iftype = type; + priv->wdev->iftype = type; + nic->monitor_flag = 0; + + #ifndef SIMULATION + #ifdef WILC_P2P + + PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n"); + nic->iftype = CLIENT_MODE; + + + if (g_linux_wlan->wilc1000_initialized) { + /* ensure that the message Q is empty */ + host_int_wait_msg_queue_idle(); + + wilc1000_wlan_deinit(g_linux_wlan); + wilc1000_wlan_init(dev, nic); + g_wilc_initialized = 1; + + host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler); + host_int_set_MacAddress((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler), + g_linux_wlan->strInterfaceInfo[0].aSrcAddress); + host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE); + + /*Add saved WEP keys, if any*/ + if (g_wep_keys_saved) { + host_int_set_WEPDefaultKeyID((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler), + g_key_wep_params.key_idx); + host_int_add_wep_key_bss_sta((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler), + g_key_wep_params.key, + g_key_wep_params.key_len, + g_key_wep_params.key_idx); + } + + /*No matter the driver handler passed here, it will be overwriiten*/ + /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/ + host_int_flush_join_req(priv->hWILCWFIDrv); + + /*Add saved PTK and GTK keys, if any*/ + if (g_ptk_keys_saved && g_gtk_keys_saved) { + PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0], + g_key_ptk_params.key[1], + g_key_ptk_params.key[2]); + PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0], + g_key_gtk_params.key[1], + g_key_gtk_params.key[2]); + WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, + g_linux_wlan->strInterfaceInfo[0].wilc_netdev, + g_add_ptk_key_params.key_idx, + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) + g_add_ptk_key_params.pairwise, + #endif + g_add_ptk_key_params.mac_addr, + (struct key_params *)(&g_key_ptk_params)); + + WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, + g_linux_wlan->strInterfaceInfo[0].wilc_netdev, + g_add_gtk_key_params.key_idx, + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) + g_add_gtk_key_params.pairwise, + #endif + g_add_gtk_key_params.mac_addr, + (struct key_params *)(&g_key_gtk_params)); + } + + /*Refresh scan, to refresh the scan results to the wpa_supplicant. Set MachHw to false to enable further key installments*/ + refresh_scan(priv, 1, WILC_TRUE); + Set_machw_change_vir_if(WILC_FALSE); + + /*BugID_4847: registered frames in firmware are now lost + * due to mac close. So re-register those frames */ + if (g_linux_wlan->wilc1000_initialized) { + for (i = 0; i < num_reg_frame; i++) { + PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type, + nic->g_struct_frame_reg[i].reg); + host_int_frame_register(priv->hWILCWFIDrv, + nic->g_struct_frame_reg[i].frame_type, + nic->g_struct_frame_reg[i].reg); + } + } + } + #endif + #endif + break; + + case NL80211_IFTYPE_AP: + /* connecting = 1; */ + bEnablePS = WILC_FALSE; + PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type); + /* linux_wlan_set_bssid(dev,g_linux_wlan->strInterfaceInfo[0].aSrcAddress); */ + /* mon_priv = netdev_priv(dev); */ + /* mon_priv->real_ndev = dev; */ + dev->ieee80211_ptr->iftype = type; + priv->wdev->iftype = type; + nic->iftype = AP_MODE; + PRINT_D(CORECONFIG_DBG, "(WILC_Uint32)priv->hWILCWFIDrv[%x]\n", (WILC_Uint32)priv->hWILCWFIDrv); + + #ifndef SIMULATION + PRINT_D(HOSTAPD_DBG, "Downloading AP firmware\n"); + linux_wlan_get_firmware(nic); + #ifdef WILC_P2P + /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/ + if (g_linux_wlan->wilc1000_initialized) { + nic->iftype = AP_MODE; + g_linux_wlan->wilc1000_initialized = 1; + mac_close(dev); + mac_open(dev); + + /* wilc1000_wlan_deinit(g_linux_wlan); */ + /* wilc1000_wlan_init(dev,nic); */ + /* repeat_power_cycle(nic); */ + /* nic->iftype = STATION_MODE; */ + + /*BugID_4847: registered frames in firmware are now lost + * due to mac close. So re-register those frames */ + for (i = 0; i < num_reg_frame; i++) { + PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type, + nic->g_struct_frame_reg[i].reg); + host_int_frame_register(priv->hWILCWFIDrv, + nic->g_struct_frame_reg[i].frame_type, + nic->g_struct_frame_reg[i].reg); + } + } + #endif + #endif + break; + + case NL80211_IFTYPE_P2P_GO: + PRINT_D(GENERIC_DBG, "start duringIP timer\n"); + + #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP + g_obtainingIP = WILC_TRUE; + WILC_TimerStart(&hDuringIpTimer, duringIP_TIME, WILC_NULL, WILC_NULL); + #endif + host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0); + /*BugID_5222*/ + /*Delete block ack has to be the latest config packet*/ + /*sent before downloading new FW. This is because it blocks on*/ + /*hWaitResponse semaphore, which allows previous config*/ + /*packets to actually take action on old FW*/ + host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID); + bEnablePS = WILC_FALSE; + PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n"); + /* linux_wlan_set_bssid(dev,g_linux_wlan->strInterfaceInfo[0].aSrcAddress); */ + /* mon_priv = netdev_priv(dev); */ + /* mon_priv->real_ndev = dev; */ + dev->ieee80211_ptr->iftype = type; + priv->wdev->iftype = type; + + PRINT_D(CORECONFIG_DBG, "(WILC_Uint32)priv->hWILCWFIDrv[%x]\n", (WILC_Uint32)priv->hWILCWFIDrv); + /* host_int_set_operation_mode((WILC_Uint32)priv->hWILCWFIDrv,AP_MODE); */ + + #ifndef SIMULATION + #ifdef WILC_P2P + PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n"); + + + #if 1 + nic->iftype = GO_MODE; + + /* ensure that the message Q is empty */ + host_int_wait_msg_queue_idle(); + + /*while(!g_hif_thread_idle) + * { + * PRINT_D(GENERIC_DBG, "Wait for host IF idle\n"); + * WILC_Sleep(10); + * }*/ + wilc1000_wlan_deinit(g_linux_wlan); + /* repeat_power_cycle_partially(g_linux_wlan); */ + wilc1000_wlan_init(dev, nic); + g_wilc_initialized = 1; + + + /*Setting interface 1 drv handler and mac address in newly downloaded FW*/ + host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler); + host_int_set_MacAddress((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler), + g_linux_wlan->strInterfaceInfo[0].aSrcAddress); + host_int_set_operation_mode(priv->hWILCWFIDrv, AP_MODE); + + /*Add saved WEP keys, if any*/ + if (g_wep_keys_saved) { + host_int_set_WEPDefaultKeyID((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler), + g_key_wep_params.key_idx); + host_int_add_wep_key_bss_sta((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler), + g_key_wep_params.key, + g_key_wep_params.key_len, + g_key_wep_params.key_idx); + } + + /*No matter the driver handler passed here, it will be overwriiten*/ + /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/ + host_int_flush_join_req(priv->hWILCWFIDrv); + + /*Add saved PTK and GTK keys, if any*/ + if (g_ptk_keys_saved && g_gtk_keys_saved) { + PRINT_D(CFG80211_DBG, "ptk %x %x %x cipher %x\n", g_key_ptk_params.key[0], + g_key_ptk_params.key[1], + g_key_ptk_params.key[2], + g_key_ptk_params.cipher); + PRINT_D(CFG80211_DBG, "gtk %x %x %x cipher %x\n", g_key_gtk_params.key[0], + g_key_gtk_params.key[1], + g_key_gtk_params.key[2], + g_key_gtk_params.cipher); + #if 1 + WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, + g_linux_wlan->strInterfaceInfo[0].wilc_netdev, + g_add_ptk_key_params.key_idx, + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) + g_add_ptk_key_params.pairwise, + #endif + g_add_ptk_key_params.mac_addr, + (struct key_params *)(&g_key_ptk_params)); + + WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, + g_linux_wlan->strInterfaceInfo[0].wilc_netdev, + g_add_gtk_key_params.key_idx, + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) + g_add_gtk_key_params.pairwise, + #endif + g_add_gtk_key_params.mac_addr, + (struct key_params *)(&g_key_gtk_params)); + #endif + } + #endif + + /*BugID_4847: registered frames in firmware are now*/ + /*lost due to mac close. So re-register those frames*/ + if (g_linux_wlan->wilc1000_initialized) { + for (i = 0; i < num_reg_frame; i++) { + PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type, + nic->g_struct_frame_reg[i].reg); + host_int_frame_register(priv->hWILCWFIDrv, + nic->g_struct_frame_reg[i].frame_type, + nic->g_struct_frame_reg[i].reg); + } + } + #endif + #endif + break; + + default: + PRINT_ER("Unknown interface type= %d\n", type); + s32Error = -EINVAL; + return s32Error; + break; + } + + return s32Error; +} + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0) +/* (austin.2013-07-23) + * + * To support revised cfg80211_ops + * + * add_beacon --> start_ap + * set_beacon --> change_beacon + * del_beacon --> stop_ap + * + * beacon_parameters --> cfg80211_ap_settings + * cfg80211_beacon_data + * + * applicable for linux kernel 3.4+ + */ + +/** + * @brief WILC_WFI_start_ap + * @details Add a beacon with given parameters, @head, @interval + * and @dtim_period will be valid, @tail is optional. + * @param[in] wiphy + * @param[in] dev The net device structure + * @param[in] settings cfg80211_ap_settings parameters for the beacon to be added + * @return int : Return 0 on Success. + * @author austin + * @date 23 JUL 2013 + * @version 1.0 + */ +static int WILC_WFI_start_ap(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_ap_settings *settings) +{ + struct cfg80211_beacon_data *beacon = &(settings->beacon); + struct WILC_WFI_priv *priv; + WILC_Sint32 s32Error = WILC_SUCCESS; + + priv = wiphy_priv(wiphy); + PRINT_D(HOSTAPD_DBG, "Starting ap\n"); + + PRINT_D(HOSTAPD_DBG, "Interval = %d \n DTIM period = %d\n Head length = %d Tail length = %d\n", + settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len); + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) + s32Error = WILC_WFI_CfgSetChannel(wiphy, &settings->chandef); + + if (s32Error != WILC_SUCCESS) + PRINT_ER("Error in setting channel\n"); +#endif + + linux_wlan_set_bssid(dev, g_linux_wlan->strInterfaceInfo[0].aSrcAddress); + + #ifndef WILC_FULLY_HOSTING_AP + s32Error = host_int_add_beacon(priv->hWILCWFIDrv, + settings->beacon_interval, + settings->dtim_period, + beacon->head_len, (WILC_Uint8 *)beacon->head, + beacon->tail_len, (WILC_Uint8 *)beacon->tail); + #else + s32Error = host_add_beacon(priv->hWILCWFIDrv, + settings->beacon_interval, + settings->dtim_period, + beacon->head_len, (WILC_Uint8 *)beacon->head, + beacon->tail_len, (WILC_Uint8 *)beacon->tail); + #endif + + return s32Error; +} + +/** + * @brief WILC_WFI_change_beacon + * @details Add a beacon with given parameters, @head, @interval + * and @dtim_period will be valid, @tail is optional. + * @param[in] wiphy + * @param[in] dev The net device structure + * @param[in] beacon cfg80211_beacon_data for the beacon to be changed + * @return int : Return 0 on Success. + * @author austin + * @date 23 JUL 2013 + * @version 1.0 + */ +static int WILC_WFI_change_beacon(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_beacon_data *beacon) +{ + struct WILC_WFI_priv *priv; + WILC_Sint32 s32Error = WILC_SUCCESS; + + priv = wiphy_priv(wiphy); + PRINT_D(HOSTAPD_DBG, "Setting beacon\n"); + + +#ifndef WILC_FULLY_HOSTING_AP + s32Error = host_int_add_beacon(priv->hWILCWFIDrv, + 0, + 0, + beacon->head_len, (WILC_Uint8 *)beacon->head, + beacon->tail_len, (WILC_Uint8 *)beacon->tail); +#else + s32Error = host_add_beacon(priv->hWILCWFIDrv, + 0, + 0, + beacon->head_len, (WILC_Uint8 *)beacon->head, + beacon->tail_len, (WILC_Uint8 *)beacon->tail); +#endif + + return s32Error; +} + +/** + * @brief WILC_WFI_stop_ap + * @details Remove beacon configuration and stop sending the beacon. + * @param[in] + * @return int : Return 0 on Success. + * @author austin + * @date 23 JUL 2013 + * @version 1.0 + */ +static int WILC_WFI_stop_ap(struct wiphy *wiphy, struct net_device *dev) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + struct WILC_WFI_priv *priv; + WILC_Uint8 NullBssid[ETH_ALEN] = {0}; + + + WILC_NULLCHECK(s32Error, wiphy); + + priv = wiphy_priv(wiphy); + + PRINT_D(HOSTAPD_DBG, "Deleting beacon\n"); + + /*BugID_5188*/ + linux_wlan_set_bssid(dev, NullBssid); + + #ifndef WILC_FULLY_HOSTING_AP + s32Error = host_int_del_beacon(priv->hWILCWFIDrv); + #else + s32Error = host_del_beacon(priv->hWILCWFIDrv); + #endif + + WILC_ERRORCHECK(s32Error); + + WILC_CATCH(s32Error) + { + } + return s32Error; +} + +#else /* here belows are original for < kernel 3.3 (austin.2013-07-23) */ + +/** + * @brief WILC_WFI_add_beacon + * @details Add a beacon with given parameters, @head, @interval + * and @dtim_period will be valid, @tail is optional. + * @param[in] wiphy + * @param[in] dev The net device structure + * @param[in] info Parameters for the beacon to be added + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_add_beacon(struct wiphy *wiphy, struct net_device *dev, + struct beacon_parameters *info) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + struct WILC_WFI_priv *priv; + + + + priv = wiphy_priv(wiphy); + PRINT_D(HOSTAPD_DBG, "Adding Beacon\n"); + + PRINT_D(HOSTAPD_DBG, "Interval = %d \n DTIM period = %d\n Head length = %d Tail length = %d\n", info->interval, info->dtim_period, info->head_len, info->tail_len); + + linux_wlan_set_bssid(dev, g_linux_wlan->strInterfaceInfo[0].aSrcAddress); + + #ifndef WILC_FULLY_HOSTING_AP + s32Error = host_int_add_beacon(priv->hWILCWFIDrv, info->interval, + info->dtim_period, + info->head_len, info->head, + info->tail_len, info->tail); + + #else + s32Error = host_add_beacon(priv->hWILCWFIDrv, info->interval, + info->dtim_period, + info->head_len, info->head, + info->tail_len, info->tail); + #endif + + return s32Error; +} + +/** + * @brief WILC_WFI_set_beacon + * @details Change the beacon parameters for an access point mode + * interface. This should reject the call when no beacon has been + * configured. + * @param[in] + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_set_beacon(struct wiphy *wiphy, struct net_device *dev, + struct beacon_parameters *info) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + + + PRINT_D(HOSTAPD_DBG, "Setting beacon\n"); + + s32Error = WILC_WFI_add_beacon(wiphy, dev, info); + + return s32Error; +} + +/** + * @brief WILC_WFI_del_beacon + * @details Remove beacon configuration and stop sending the beacon. + * @param[in] + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_del_beacon(struct wiphy *wiphy, struct net_device *dev) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + struct WILC_WFI_priv *priv; + WILC_Uint8 NullBssid[ETH_ALEN] = {0}; + + + WILC_NULLCHECK(s32Error, wiphy); + + priv = wiphy_priv(wiphy); + + PRINT_D(HOSTAPD_DBG, "Deleting beacon\n"); + + /*BugID_5188*/ + linux_wlan_set_bssid(dev, NullBssid); + + #ifndef WILC_FULLY_HOSTING_AP + s32Error = host_int_del_beacon(priv->hWILCWFIDrv); + #else + s32Error = host_del_beacon(priv->hWILCWFIDrv); + #endif + + WILC_ERRORCHECK(s32Error); + + WILC_CATCH(s32Error) + { + } + return s32Error; +} + +#endif /* linux kernel 3.4+ (austin.2013-07-23) */ + +/** + * @brief WILC_WFI_add_station + * @details Add a new station. + * @param[in] + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_add_station(struct wiphy *wiphy, struct net_device *dev, + u8 *mac, struct station_parameters *params) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + struct WILC_WFI_priv *priv; + tstrWILC_AddStaParam strStaParams = {{0}}; + perInterface_wlan_t *nic; + + + WILC_NULLCHECK(s32Error, wiphy); + + priv = wiphy_priv(wiphy); + nic = netdev_priv(dev); + + if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) { + #ifndef WILC_FULLY_HOSTING_AP + + WILC_memcpy(strStaParams.au8BSSID, mac, ETH_ALEN); + WILC_memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN); + strStaParams.u16AssocID = params->aid; + strStaParams.u8NumRates = params->supported_rates_len; + strStaParams.pu8Rates = params->supported_rates; + + PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid); + + PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n", priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][0], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][1], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][2], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][3], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][4], + priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]); + PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID); + PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates); + + if (params->ht_capa == WILC_NULL) { + strStaParams.bIsHTSupported = WILC_FALSE; + } else { + strStaParams.bIsHTSupported = WILC_TRUE; + strStaParams.u16HTCapInfo = params->ht_capa->cap_info; + strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info; + WILC_memcpy(strStaParams.au8SuppMCsSet, ¶ms->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE); + strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info; + strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info; + strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info; + } + + strStaParams.u16FlagsMask = params->sta_flags_mask; + strStaParams.u16FlagsSet = params->sta_flags_set; + + PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported); + PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo); + PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams); + PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams); + PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap); + PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap); + PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask); + PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet); + + s32Error = host_int_add_station(priv->hWILCWFIDrv, &strStaParams); + WILC_ERRORCHECK(s32Error); + + #else + PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid); + WILC_memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN); + + PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n", priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][0], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][1], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][2], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][3], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][4], + priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]); + + WILC_AP_AddSta(mac, params); + WILC_ERRORCHECK(s32Error); + #endif /* WILC_FULLY_HOSTING_AP */ + + } + + WILC_CATCH(s32Error) + { + } + return s32Error; +} + +/** + * @brief WILC_WFI_del_station + * @details Remove a station; @mac may be NULL to remove all stations. + * @param[in] + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_del_station(struct wiphy *wiphy, struct net_device *dev, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) + struct station_del_parameters *params) +#else + u8 *mac) +#endif +{ + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) + u8 *mac = params->mac; + #endif + WILC_Sint32 s32Error = WILC_SUCCESS; + struct WILC_WFI_priv *priv; + perInterface_wlan_t *nic; + WILC_NULLCHECK(s32Error, wiphy); + /*BugID_4795: mac may be null pointer to indicate deleting all stations, so avoid null check*/ + /* WILC_NULLCHECK(s32Error, mac); */ + + priv = wiphy_priv(wiphy); + nic = netdev_priv(dev); + + if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) { + PRINT_D(HOSTAPD_DBG, "Deleting station\n"); + + + if (mac == WILC_NULL) { + PRINT_D(HOSTAPD_DBG, "All associated stations \n"); + s32Error = host_int_del_allstation(priv->hWILCWFIDrv, priv->assoc_stainfo.au8Sta_AssociatedBss); + } else { + PRINT_D(HOSTAPD_DBG, "With mac address: %x%x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + } + + #ifndef WILC_FULLY_HOSTING_AP + s32Error = host_int_del_station(priv->hWILCWFIDrv, mac); + #else + WILC_AP_RemoveSta(mac); + #endif /* WILC_FULLY_HOSTING_AP */ + + WILC_ERRORCHECK(s32Error); + } + WILC_CATCH(s32Error) + { + } + return s32Error; +} + +/** + * @brief WILC_WFI_change_station + * @details Modify a given station. + * @param[in] + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_change_station(struct wiphy *wiphy, struct net_device *dev, + u8 *mac, struct station_parameters *params) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + struct WILC_WFI_priv *priv; + tstrWILC_AddStaParam strStaParams = {{0}}; + perInterface_wlan_t *nic; + + + PRINT_D(HOSTAPD_DBG, "Change station paramters\n"); + + WILC_NULLCHECK(s32Error, wiphy); + + priv = wiphy_priv(wiphy); + nic = netdev_priv(dev); + + if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) { + #ifndef WILC_FULLY_HOSTING_AP + + WILC_memcpy(strStaParams.au8BSSID, mac, ETH_ALEN); + strStaParams.u16AssocID = params->aid; + strStaParams.u8NumRates = params->supported_rates_len; + strStaParams.pu8Rates = params->supported_rates; + + PRINT_D(HOSTAPD_DBG, "BSSID = %x%x%x%x%x%x\n", strStaParams.au8BSSID[0], strStaParams.au8BSSID[1], strStaParams.au8BSSID[2], strStaParams.au8BSSID[3], strStaParams.au8BSSID[4], + strStaParams.au8BSSID[5]); + PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID); + PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates); + + if (params->ht_capa == WILC_NULL) { + strStaParams.bIsHTSupported = WILC_FALSE; + } else { + strStaParams.bIsHTSupported = WILC_TRUE; + strStaParams.u16HTCapInfo = params->ht_capa->cap_info; + strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info; + WILC_memcpy(strStaParams.au8SuppMCsSet, ¶ms->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE); + strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info; + strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info; + strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info; + + } + + strStaParams.u16FlagsMask = params->sta_flags_mask; + strStaParams.u16FlagsSet = params->sta_flags_set; + + PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported); + PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo); + PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams); + PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams); + PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap); + PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap); + PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask); + PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet); + + s32Error = host_int_edit_station(priv->hWILCWFIDrv, &strStaParams); + WILC_ERRORCHECK(s32Error); + + #else + WILC_AP_EditSta(mac, params); + WILC_ERRORCHECK(s32Error); + #endif /* WILC_FULLY_HOSTING_AP */ + + } + WILC_CATCH(s32Error) + { + } + return s32Error; +} + + +/** + * @brief WILC_WFI_add_virt_intf + * @details + * @param[in] + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 JUL 2012 + * @version 1.0 + */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0) +struct wireless_dev *WILC_WFI_add_virt_intf(struct wiphy *wiphy, const char *name, + unsigned char name_assign_type, + enum nl80211_iftype type, u32 *flags, + struct vif_params *params) +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0) /* tony for v3.8 support */ +struct wireless_dev *WILC_WFI_add_virt_intf(struct wiphy *wiphy, const char *name, + enum nl80211_iftype type, u32 *flags, + struct vif_params *params) +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) /* tony for v3.6 support */ +struct wireless_dev *WILC_WFI_add_virt_intf(struct wiphy *wiphy, char *name, + enum nl80211_iftype type, u32 *flags, + struct vif_params *params) +#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) +int WILC_WFI_add_virt_intf(struct wiphy *wiphy, char *name, + enum nl80211_iftype type, u32 *flags, + struct vif_params *params) +#else +struct net_device *WILC_WFI_add_virt_intf(struct wiphy *wiphy, char *name, + enum nl80211_iftype type, u32 *flags, + struct vif_params *params) +#endif +{ + perInterface_wlan_t *nic; + struct WILC_WFI_priv *priv; + /* struct WILC_WFI_mon_priv* mon_priv; */ + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) + WILC_Sint32 s32Error = WILC_SUCCESS; + #endif + struct net_device *new_ifc = NULL; + priv = wiphy_priv(wiphy); + + + + PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", priv->wdev->netdev); + + nic = netdev_priv(priv->wdev->netdev); + + + if (type == NL80211_IFTYPE_MONITOR) { + PRINT_D(HOSTAPD_DBG, "Monitor interface mode: Initializing mon interface virtual device driver\n"); + PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", nic->wilc_netdev); + new_ifc = WILC_WFI_init_mon_interface(name, nic->wilc_netdev); + if (new_ifc != NULL) { + PRINT_D(HOSTAPD_DBG, "Setting monitor flag in private structure\n"); + #ifdef SIMULATION + priv = netdev_priv(priv->wdev->netdev); + priv->monitor_flag = 1; + #else + nic = netdev_priv(priv->wdev->netdev); + nic->monitor_flag = 1; + #endif + } else + PRINT_ER("Error in initializing monitor interface\n "); + } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) /* tony for v3.8 support */ + return priv->wdev; +#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) + return s32Error; +#else + /* return priv->wdev->netdev; */ + PRINT_D(HOSTAPD_DBG, "IFC[%p] created\n", new_ifc); + return new_ifc; +#endif + +} + +/** + * @brief WILC_WFI_del_virt_intf + * @details + * @param[in] + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 JUL 2012 + * @version 1.0 + */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) +int WILC_WFI_del_virt_intf(struct wiphy *wiphy, struct wireless_dev *wdev) /* tony for v3.8 support */ +#else +int WILC_WFI_del_virt_intf(struct wiphy *wiphy, struct net_device *dev) +#endif +{ + PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n"); + return WILC_SUCCESS; +} + + + +#endif /*WILC_AP_EXTERNAL_MLME*/ +static struct cfg80211_ops WILC_WFI_cfg80211_ops = { + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) + /* + * replaced set_channel by set_monitor_channel + * from v3.6 + * tony, 2013-10-29 + */ + .set_monitor_channel = WILC_WFI_CfgSetChannel, +#else + .set_channel = WILC_WFI_CfgSetChannel, +#endif + .scan = WILC_WFI_CfgScan, + .connect = WILC_WFI_CfgConnect, + .disconnect = WILC_WFI_disconnect, + .add_key = WILC_WFI_add_key, + .del_key = WILC_WFI_del_key, + .get_key = WILC_WFI_get_key, + .set_default_key = WILC_WFI_set_default_key, +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32) + /* .dump_survey = WILC_WFI_dump_survey, */ +#endif + #ifdef WILC_AP_EXTERNAL_MLME + .add_virtual_intf = WILC_WFI_add_virt_intf, + .del_virtual_intf = WILC_WFI_del_virt_intf, + .change_virtual_intf = WILC_WFI_change_virt_intf, + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0) + .add_beacon = WILC_WFI_add_beacon, + .set_beacon = WILC_WFI_set_beacon, + .del_beacon = WILC_WFI_del_beacon, +#else + /* supports kernel 3.4+ change. austin.2013-07-23 */ + .start_ap = WILC_WFI_start_ap, + .change_beacon = WILC_WFI_change_beacon, + .stop_ap = WILC_WFI_stop_ap, +#endif + .add_station = WILC_WFI_add_station, + .del_station = WILC_WFI_del_station, + .change_station = WILC_WFI_change_station, + #endif /* WILC_AP_EXTERNAL_MLME*/ + #ifndef WILC_FULLY_HOSTING_AP + .get_station = WILC_WFI_get_station, + #endif + .dump_station = WILC_WFI_dump_station, + .change_bss = WILC_WFI_change_bss, + /* .auth = WILC_WFI_auth, */ + /* .assoc = WILC_WFI_assoc, */ + /* .deauth = WILC_WFI_deauth, */ + /* .disassoc = WILC_WFI_disassoc, */ + .set_wiphy_params = WILC_WFI_set_wiphy_params, + +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32) + /* .set_bitrate_mask = WILC_WFI_set_bitrate_mask, */ + .set_pmksa = WILC_WFI_set_pmksa, + .del_pmksa = WILC_WFI_del_pmksa, + .flush_pmksa = WILC_WFI_flush_pmksa, +#ifdef WILC_P2P + .remain_on_channel = WILC_WFI_remain_on_channel, + .cancel_remain_on_channel = WILC_WFI_cancel_remain_on_channel, + .mgmt_tx_cancel_wait = WILC_WFI_mgmt_tx_cancel_wait, + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) + .action = WILC_WFI_action, + #endif + #else + .mgmt_tx = WILC_WFI_mgmt_tx, + .mgmt_frame_register = WILC_WFI_frame_register, + #endif +#endif + /* .mgmt_tx_cancel_wait = WILC_WFI_mgmt_tx_cancel_wait, */ + .set_power_mgmt = WILC_WFI_set_power_mgmt, + .set_cqm_rssi_config = WILC_WFI_set_cqm_rssi_config, +#endif + +}; + + + + + +/** + * @brief WILC_WFI_update_stats + * @details Modify parameters for a given BSS. + * @param[in] + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0WILC_WFI_set_cqmWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_config_rssi_config + */ +int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed) +{ + + struct WILC_WFI_priv *priv; + + priv = wiphy_priv(wiphy); + /* WILC_SemaphoreAcquire(&SemHandleUpdateStats,NULL); */ +#if 1 + switch (changed) { + + case WILC_WFI_RX_PKT: + { + /* MI_PRINTF("In Rx Receive Packet\n"); */ + priv->netstats.rx_packets++; + priv->netstats.rx_bytes += pktlen; + priv->netstats.rx_time = get_jiffies_64(); + } + break; + + case WILC_WFI_TX_PKT: + { + priv->netstats.tx_packets++; + priv->netstats.tx_bytes += pktlen; + priv->netstats.tx_time = get_jiffies_64(); + + } + break; + + default: + break; + } + /* WILC_SemaphoreRelease(&SemHandleUpdateStats,NULL); */ +#endif + return 0; +} +/** + * @brief WILC_WFI_InitPriv + * @details Initialization of the net device, private data + * @param[in] NONE + * @return NONE + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +void WILC_WFI_InitPriv(struct net_device *dev) +{ + + struct WILC_WFI_priv *priv; + priv = netdev_priv(dev); + + priv->netstats.rx_packets = 0; + priv->netstats.tx_packets = 0; + priv->netstats.rx_bytes = 0; + priv->netstats.rx_bytes = 0; + priv->netstats.rx_time = 0; + priv->netstats.tx_time = 0; + + +} +/** + * @brief WILC_WFI_CfgAlloc + * @details Allocation of the wireless device structure and assigning it + * to the cfg80211 operations structure. + * @param[in] NONE + * @return wireless_dev : Returns pointer to wireless_dev structure. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +struct wireless_dev *WILC_WFI_CfgAlloc(void) +{ + + struct wireless_dev *wdev; + + + PRINT_D(CFG80211_DBG, "Allocating wireless device\n"); + /*Allocating the wireless device structure*/ + wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL); + if (!wdev) { + PRINT_ER("Cannot allocate wireless device\n"); + goto _fail_; + } + + /*Creating a new wiphy, linking wireless structure with the wiphy structure*/ + wdev->wiphy = wiphy_new(&WILC_WFI_cfg80211_ops, sizeof(struct WILC_WFI_priv)); + if (!wdev->wiphy) { + PRINT_ER("Cannot allocate wiphy\n"); + goto _fail_mem_; + + } + + #ifdef WILC_AP_EXTERNAL_MLME + /* enable 802.11n HT */ + WILC_WFI_band_2ghz.ht_cap.ht_supported = 1; + WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT); + WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff; + WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K; + WILC_WFI_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE; + #endif + + /*wiphy bands*/ + wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &WILC_WFI_band_2ghz; + + return wdev; + +_fail_mem_: + kfree(wdev); +_fail_: + return NULL; + +} +/** + * @brief WILC_WFI_WiphyRegister + * @details Registering of the wiphy structure and interface modes + * @param[in] NONE + * @return NONE + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +struct wireless_dev *WILC_WFI_WiphyRegister(struct net_device *net) +{ + struct WILC_WFI_priv *priv; + struct wireless_dev *wdev; + WILC_Sint32 s32Error = WILC_SUCCESS; + + PRINT_D(CFG80211_DBG, "Registering wifi device\n"); + + wdev = WILC_WFI_CfgAlloc(); + if (wdev == NULL) { + PRINT_ER("CfgAlloc Failed\n"); + return NULL; + } + + + /*Return hardware description structure (wiphy)'s priv*/ + priv = wdev_priv(wdev); + WILC_SemaphoreCreate(&(priv->SemHandleUpdateStats), NULL); + + /*Link the wiphy with wireless structure*/ + priv->wdev = wdev; + + /*Maximum number of probed ssid to be added by user for the scan request*/ + wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID; + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32) + /*Maximum number of pmkids to be cashed*/ + wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS; + PRINT_INFO(CFG80211_DBG, "Max number of PMKIDs = %d\n", wdev->wiphy->max_num_pmkids); + #endif + + wdev->wiphy->max_scan_ie_len = 1000; + + /*signal strength in mBm (100*dBm) */ + wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; + + /*Set the availaible cipher suites*/ + wdev->wiphy->cipher_suites = cipher_suites; + wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37) + /*Setting default managment types: for register action frame: */ + wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types; +#endif + +#ifdef WILC_P2P + wdev->wiphy->max_remain_on_channel_duration = 500; + /*Setting the wiphy interfcae mode and type before registering the wiphy*/ + wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) | + BIT(NL80211_IFTYPE_P2P_CLIENT); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0) + + wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; +#endif +#else + wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR); +#endif + wdev->iftype = NL80211_IFTYPE_STATION; + + + + PRINT_INFO(CFG80211_DBG, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n", + wdev->wiphy->max_scan_ssids, wdev->wiphy->max_scan_ie_len, wdev->wiphy->signal_type, + wdev->wiphy->interface_modes, wdev->iftype); + + #ifdef WILC_SDIO + set_wiphy_dev(wdev->wiphy, &local_sdio_func->dev); /* tony */ + #endif + + /*Register wiphy structure*/ + s32Error = wiphy_register(wdev->wiphy); + if (s32Error) { + PRINT_ER("Cannot register wiphy device\n"); + /*should define what action to be taken in such failure*/ + } else { + PRINT_D(CFG80211_DBG, "Successful Registering\n"); + } + +#if 0 + /*wdev[i]->wiphy->interface_modes = + * BIT(NL80211_IFTYPE_AP); + * wdev[i]->iftype = NL80211_IFTYPE_AP; + */ + + /*Pointing the priv structure the netdev*/ + priv = netdev_priv(net); + + /*linking the wireless_dev structure with the netdevice*/ + priv->dev->ieee80211_ptr = wdev; + priv->dev->ml_priv = priv; + wdev->netdev = priv->dev; +#endif + priv->dev = net; +#if 0 + ret = host_int_init(&priv->hWILCWFIDrv); + if (ret) { + PRINT_ER("Error Init Driver\n"); + } +#endif + return wdev; + + +} +/** + * @brief WILC_WFI_WiphyFree + * @details Freeing allocation of the wireless device structure + * @param[in] NONE + * @return NONE + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +int WILC_WFI_InitHostInt(struct net_device *net) +{ + + WILC_Sint32 s32Error = WILC_SUCCESS; + + struct WILC_WFI_priv *priv; + + tstrWILC_SemaphoreAttrs strSemaphoreAttrs; + + PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr); + priv = wdev_priv(net->ieee80211_ptr); + if (op_ifcs == 0) { + s32Error = WILC_TimerCreate(&(hAgingTimer), remove_network_from_shadow, WILC_NULL); + #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP + s32Error = WILC_TimerCreate(&(hDuringIpTimer), clear_duringIP, WILC_NULL); + #endif + } + op_ifcs++; + if (s32Error < 0) { + PRINT_ER("Failed to creat refresh Timer\n"); + return s32Error; + } + + WILC_SemaphoreFillDefault(&strSemaphoreAttrs); + + /* /////////////////////////////////////// */ + /* strSemaphoreAttrs.u32InitCount = 0; */ + + + priv->gbAutoRateAdjusted = WILC_FALSE; + + priv->bInP2PlistenState = WILC_FALSE; + + WILC_SemaphoreCreate(&(priv->hSemScanReq), &strSemaphoreAttrs); + s32Error = host_int_init(&priv->hWILCWFIDrv); + /* s32Error = host_int_init(&priv->hWILCWFIDrv_2); */ + if (s32Error) { + PRINT_ER("Error while initializing hostinterface\n"); + } + return s32Error; +} + +/** + * @brief WILC_WFI_WiphyFree + * @details Freeing allocation of the wireless device structure + * @param[in] NONE + * @return NONE + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +int WILC_WFI_DeInitHostInt(struct net_device *net) +{ + WILC_Sint32 s32Error = WILC_SUCCESS; + + struct WILC_WFI_priv *priv; + priv = wdev_priv(net->ieee80211_ptr); + + + + + + + WILC_SemaphoreDestroy(&(priv->hSemScanReq), NULL); + + priv->gbAutoRateAdjusted = WILC_FALSE; + + priv->bInP2PlistenState = WILC_FALSE; + + op_ifcs--; + + s32Error = host_int_deinit(priv->hWILCWFIDrv); + /* s32Error = host_int_deinit(priv->hWILCWFIDrv_2); */ + + /* Clear the Shadow scan */ + clear_shadow_scan(priv); + #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP + if (op_ifcs == 0) { + PRINT_D(CORECONFIG_DBG, "destroy during ip\n"); + WILC_TimerDestroy(&hDuringIpTimer, WILC_NULL); + } + #endif + + if (s32Error) { + PRINT_ER("Error while deintializing host interface\n"); + } + return s32Error; +} + + +/** + * @brief WILC_WFI_WiphyFree + * @details Freeing allocation of the wireless device structure + * @param[in] NONE + * @return NONE + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +void WILC_WFI_WiphyFree(struct net_device *net) +{ + + PRINT_D(CFG80211_DBG, "Unregistering wiphy\n"); + + if (net == NULL) { + PRINT_D(INIT_DBG, "net_device is NULL\n"); + return; + } + + if (net->ieee80211_ptr == NULL) { + PRINT_D(INIT_DBG, "ieee80211_ptr is NULL\n"); + return; + } + + if (net->ieee80211_ptr->wiphy == NULL) { + PRINT_D(INIT_DBG, "wiphy is NULL\n"); + return; + } + + wiphy_unregister(net->ieee80211_ptr->wiphy); + + PRINT_D(INIT_DBG, "Freeing wiphy\n"); + wiphy_free(net->ieee80211_ptr->wiphy); + kfree(net->ieee80211_ptr); + +} diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h new file mode 100644 index 000000000000..9eb8f37542d0 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h @@ -0,0 +1,134 @@ +/*! + * @file wilc_wfi_cfgoperations.h + * @brief Definitions for the network module + * @author syounan + * @sa wilc_oswrapper.h top level OS wrapper file + * @date 31 Aug 2010 + * @version 1.0 + */ +#ifndef NM_WFI_CFGOPERATIONS +#define NM_WFI_CFGOPERATIONS +#include "wilc_wfi_netdevice.h" + +#ifdef WILC_FULLY_HOSTING_AP +#include "wilc_host_ap.h" +#endif + + +/* The following macros describe the bitfield map used by the firmware to determine its 11i mode */ +#define NO_ENCRYPT 0 +#define ENCRYPT_ENABLED (1 << 0) +#define WEP (1 << 1) +#define WEP_EXTENDED (1 << 2) +#define WPA (1 << 3) +#define WPA2 (1 << 4) +#define AES (1 << 5) +#define TKIP (1 << 6) + +#ifdef WILC_P2P +/* #define USE_SUPPLICANT_GO_INTENT */ + +/*Public action frame index IDs*/ +#define FRAME_TYPE_ID 0 +#define ACTION_CAT_ID 24 +#define ACTION_SUBTYPE_ID 25 +#define P2P_PUB_ACTION_SUBTYPE 30 + +/*Public action frame Attribute IDs*/ +#define ACTION_FRAME 0xd0 +#define GO_INTENT_ATTR_ID 0x04 +#define CHANLIST_ATTR_ID 0x0b +#define OPERCHAN_ATTR_ID 0x11 +#ifdef USE_SUPPLICANT_GO_INTENT +#define GROUP_BSSID_ATTR_ID 0x07 +#endif +#define PUB_ACTION_ATTR_ID 0x04 +#define P2PELEM_ATTR_ID 0xdd + +/*Public action subtype values*/ +#define GO_NEG_REQ 0x00 +#define GO_NEG_RSP 0x01 +#define GO_NEG_CONF 0x02 +#define P2P_INV_REQ 0x03 +#define P2P_INV_RSP 0x04 +#define PUBLIC_ACT_VENDORSPEC 0x09 +#define GAS_INTIAL_REQ 0x0a +#define GAS_INTIAL_RSP 0x0b + +#define INVALID_CHANNEL 0 +#ifdef USE_SUPPLICANT_GO_INTENT +#define SUPPLICANT_GO_INTENT 6 +#define GET_GO_INTENT(a) (((a) >> 1) & 0x0f) +#define GET_TIE_BREAKER(a) (((a)) & 0x01) +#else +/* #define FORCE_P2P_CLIENT */ +#endif +#endif + +#define nl80211_SCAN_RESULT_EXPIRE (3 * HZ) +#define SCAN_RESULT_EXPIRE (40 * HZ) + +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 30) +static const u32 cipher_suites[] = { + WLAN_CIPHER_SUITE_WEP40, + WLAN_CIPHER_SUITE_WEP104, + WLAN_CIPHER_SUITE_TKIP, + WLAN_CIPHER_SUITE_CCMP, + WLAN_CIPHER_SUITE_AES_CMAC, +}; +#endif + + + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37) +static const struct ieee80211_txrx_stypes + wilc_wfi_cfg80211_mgmt_types[NL80211_IFTYPE_MAX] = { + [NL80211_IFTYPE_STATION] = { + .tx = 0xffff, + .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | + BIT(IEEE80211_STYPE_PROBE_REQ >> 4) + }, + [NL80211_IFTYPE_AP] = { + .tx = 0xffff, + .rx = BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) | + BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) | + BIT(IEEE80211_STYPE_PROBE_REQ >> 4) | + BIT(IEEE80211_STYPE_DISASSOC >> 4) | + BIT(IEEE80211_STYPE_AUTH >> 4) | + BIT(IEEE80211_STYPE_DEAUTH >> 4) | + BIT(IEEE80211_STYPE_ACTION >> 4) + }, + [NL80211_IFTYPE_P2P_CLIENT] = { + .tx = 0xffff, + .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | + BIT(IEEE80211_STYPE_PROBE_REQ >> 4) | + BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) | + BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) | + BIT(IEEE80211_STYPE_PROBE_REQ >> 4) | + BIT(IEEE80211_STYPE_DISASSOC >> 4) | + BIT(IEEE80211_STYPE_AUTH >> 4) | + BIT(IEEE80211_STYPE_DEAUTH >> 4) + } +}; +#endif +/* Time to stay on the channel */ +#define WILC_WFI_DWELL_PASSIVE 100 +#define WILC_WFI_DWELL_ACTIVE 40 + +struct wireless_dev *WILC_WFI_CfgAlloc(void); +struct wireless_dev *WILC_WFI_WiphyRegister(struct net_device *net); +void WILC_WFI_WiphyFree(struct net_device *net); +int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed); +int WILC_WFI_DeInitHostInt(struct net_device *net); +int WILC_WFI_InitHostInt(struct net_device *net); +void WILC_WFI_monitor_rx(uint8_t *buff, uint32_t size); +int WILC_WFI_deinit_mon_interface(void); +struct net_device *WILC_WFI_init_mon_interface(char *name, struct net_device *real_dev); + +#ifdef TCP_ENHANCEMENTS +#define TCP_ACK_FILTER_LINK_SPEED_THRESH 54 +#define DEFAULT_LINK_SPEED 72 +extern void Enable_TCP_ACK_Filter(WILC_Bool value); +#endif + +#endif diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.c b/drivers/staging/wilc1000/wilc_wfi_netdevice.c new file mode 100644 index 000000000000..fbc4b857aa35 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.c @@ -0,0 +1,960 @@ +/*! + * @file wilc_wfi_netdevice.c + * @brief File Operations OS wrapper functionality + * @author mdaftedar + * @sa wilc_wfi_netdevice.h + * @date 01 MAR 2012 + * @version 1.0 + */ + +#ifdef SIMULATION + +#include "wilc_wfi_cfgoperations.h" +#include "host_interface.h" + + +MODULE_AUTHOR("Mai Daftedar"); +MODULE_LICENSE("Dual BSD/GPL"); + + +struct net_device *WILC_WFI_devs[2]; + +/* + * Transmitter lockup simulation, normally disabled. + */ +static int lockup; +module_param(lockup, int, 0); + +static int timeout = WILC_WFI_TIMEOUT; +module_param(timeout, int, 0); + +/* + * Do we run in NAPI mode? + */ +static int use_napi ; +module_param(use_napi, int, 0); + + +/* + * A structure representing an in-flight packet. + */ +struct WILC_WFI_packet { + struct WILC_WFI_packet *next; + struct net_device *dev; + int datalen; + u8 data[ETH_DATA_LEN]; +}; + + + +int pool_size = 8; +module_param(pool_size, int, 0); + + +static void WILC_WFI_TxTimeout(struct net_device *dev); +static void (*WILC_WFI_Interrupt)(int, void *, struct pt_regs *); + +/** + * @brief WILC_WFI_SetupPool + * @details Set up a device's packet pool. + * @param[in] struct net_device *dev : Network Device Pointer + * @return NONE + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +void WILC_WFI_SetupPool(struct net_device *dev) +{ + struct WILC_WFI_priv *priv = netdev_priv(dev); + int i; + struct WILC_WFI_packet *pkt; + + priv->ppool = NULL; + for (i = 0; i < pool_size; i++) { + pkt = kmalloc (sizeof (struct WILC_WFI_packet), GFP_KERNEL); + if (pkt == NULL) { + PRINT_D(RX_DBG, "Ran out of memory allocating packet pool\n"); + return; + } + pkt->dev = dev; + pkt->next = priv->ppool; + priv->ppool = pkt; + } +} + +/** + * @brief WILC_WFI_TearDownPool + * @details Internal cleanup function that's called after the network device + * driver is unregistered + * @param[in] struct net_device *dev : Network Device Driver + * @return NONE + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +void WILC_WFI_TearDownPool(struct net_device *dev) +{ + struct WILC_WFI_priv *priv = netdev_priv(dev); + struct WILC_WFI_packet *pkt; + + while ((pkt = priv->ppool)) { + priv->ppool = pkt->next; + kfree (pkt); + /* FIXME - in-flight packets ? */ + } +} + +/** + * @brief WILC_WFI_GetTxBuffer + * @details Buffer/pool management + * @param[in] net_device *dev : Network Device Driver Structure + * @return struct WILC_WFI_packet + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +struct WILC_WFI_packet *WILC_WFI_GetTxBuffer(struct net_device *dev) +{ + struct WILC_WFI_priv *priv = netdev_priv(dev); + unsigned long flags; + struct WILC_WFI_packet *pkt; + + spin_lock_irqsave(&priv->lock, flags); + pkt = priv->ppool; + priv->ppool = pkt->next; + if (priv->ppool == NULL) { + PRINT_INFO(RX_DBG, "Pool empty\n"); + netif_stop_queue(dev); + } + spin_unlock_irqrestore(&priv->lock, flags); + return pkt; +} +/** + * @brief WILC_WFI_ReleaseBuffer + * @details Buffer/pool management + * @param[in] WILC_WFI_packet *pkt : Structure holding in-flight packet + * @return NONE + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +void WILC_WFI_ReleaseBuffer(struct WILC_WFI_packet *pkt) +{ + unsigned long flags; + struct WILC_WFI_priv *priv = netdev_priv(pkt->dev); + + spin_lock_irqsave(&priv->lock, flags); + pkt->next = priv->ppool; + priv->ppool = pkt; + spin_unlock_irqrestore(&priv->lock, flags); + if (netif_queue_stopped(pkt->dev) && pkt->next == NULL) + netif_wake_queue(pkt->dev); +} + +/** + * @brief WILC_WFI_EnqueueBuf + * @details Enqueuing packets in an RX buffer queue + * @param[in] WILC_WFI_packet *pkt : Structure holding in-flight packet + * @param[in] net_device *dev : Network Device Driver Structure + * @return NONE + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +void WILC_WFI_EnqueueBuf(struct net_device *dev, struct WILC_WFI_packet *pkt) +{ + unsigned long flags; + struct WILC_WFI_priv *priv = netdev_priv(dev); + + spin_lock_irqsave(&priv->lock, flags); + pkt->next = priv->rx_queue; /* FIXME - misorders packets */ + priv->rx_queue = pkt; + spin_unlock_irqrestore(&priv->lock, flags); +} + +/** + * @brief WILC_WFI_DequeueBuf + * @details Dequeuing packets from the RX buffer queue + * @param[in] net_device *dev : Network Device Driver Structure + * @return WILC_WFI_packet *pkt : Structure holding in-flight pac + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +struct WILC_WFI_packet *WILC_WFI_DequeueBuf(struct net_device *dev) +{ + struct WILC_WFI_priv *priv = netdev_priv(dev); + struct WILC_WFI_packet *pkt; + unsigned long flags; + + spin_lock_irqsave(&priv->lock, flags); + pkt = priv->rx_queue; + if (pkt != NULL) + priv->rx_queue = pkt->next; + spin_unlock_irqrestore(&priv->lock, flags); + return pkt; +} +/** + * @brief WILC_WFI_RxInts + * @details Enable and disable receive interrupts. + * @param[in] net_device *dev : Network Device Driver Structure + * @param[in] enable : Enable/Disable flag + * @return NONE + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static void WILC_WFI_RxInts(struct net_device *dev, int enable) +{ + struct WILC_WFI_priv *priv = netdev_priv(dev); + priv->rx_int_enabled = enable; +} + +/** + * @brief WILC_WFI_Open + * @details Open Network Device Driver, called when the network + * interface is opened. It starts the interface's transmit queue. + * @param[in] net_device *dev : Network Device Driver Structure + * @param[in] enable : Enable/Disable flag + * @return int : Returns 0 upon success. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +int WILC_WFI_Open(struct net_device *dev) +{ + /* request_region(), request_irq(), .... (like fops->open) */ + /* + * Assign the hardware address of the board: use "\0SNULx", where + * x is 0 or 1. The first byte is '\0' to avoid being a multicast + * address (the first byte of multicast addrs is odd). + */ + memcpy(dev->dev_addr, "\0WLAN0", ETH_ALEN); + if (dev == WILC_WFI_devs[1]) + dev->dev_addr[ETH_ALEN - 1]++; /* \0SNUL1 */ + + WILC_WFI_InitHostInt(dev); + netif_start_queue(dev); + return 0; +} +/** + * @brief WILC_WFI_Release + * @details Release Network Device Driver, called when the network + * interface is stopped or brought down. This function marks + * the network driver as not being able to transmit + * @param[in] net_device *dev : Network Device Driver Structure + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +int WILC_WFI_Release(struct net_device *dev) +{ + /* release ports, irq and such -- like fops->close */ + + netif_stop_queue(dev); /* can't transmit any more */ + + return 0; +} +/** + * @brief WILC_WFI_Config + * @details Configuration changes (passed on by ifconfig) + * @param[in] net_device *dev : Network Device Driver Structure + * @param[in] struct ifmap *map : Contains the ioctl implementation for the + * network driver. + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +int WILC_WFI_Config(struct net_device *dev, struct ifmap *map) +{ + if (dev->flags & IFF_UP) /* can't act on a running interface */ + return -EBUSY; + + /* Don't allow changing the I/O address */ + if (map->base_addr != dev->base_addr) { + PRINT_D(RX_DBG, KERN_WARNING "WILC_WFI: Can't change I/O address\n"); + return -EOPNOTSUPP; + } + + /* Allow changing the IRQ */ + if (map->irq != dev->irq) { + dev->irq = map->irq; + /* request_irq() is delayed to open-time */ + } + + /* ignore other fields */ + return 0; +} +/** + * @brief WILC_WFI_Rx + * @details Receive a packet: retrieve, encapsulate and pass over to upper + * levels + * @param[in] net_device *dev : Network Device Driver Structure + * @param[in] WILC_WFI_packet : + * @return NONE + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +void WILC_WFI_Rx(struct net_device *dev, struct WILC_WFI_packet *pkt) +{ + int i; + struct sk_buff *skb; + struct WILC_WFI_priv *priv = netdev_priv(dev); + s8 rssi; + /* + * The packet has been retrieved from the transmission + * medium. Build an skb around it, so upper layers can handle it + */ + + + skb = dev_alloc_skb(pkt->datalen + 2); + if (!skb) { + if (printk_ratelimit()) + PRINT_D(RX_DBG, "WILC_WFI rx: low on mem - packet dropped\n"); + priv->stats.rx_dropped++; + goto out; + } + skb_reserve(skb, 2); /* align IP on 16B boundary */ + memcpy(skb_put(skb, pkt->datalen), pkt->data, pkt->datalen); + + if (priv->monitor_flag) { + PRINT_INFO(RX_DBG, "In monitor device name %s\n", dev->name); + priv = wiphy_priv(priv->dev->ieee80211_ptr->wiphy); + PRINT_D(RX_DBG, "VALUE PASSED IN OF HRWD %p\n", priv->hWILCWFIDrv); + /* host_int_get_rssi(priv->hWILCWFIDrv, &(rssi)); */ + if (INFO) { + for (i = 14; i < skb->len; i++) + PRINT_INFO(RX_DBG, "RXdata[%d] %02x\n", i, skb->data[i]); + } + WILC_WFI_monitor_rx(dev, skb); + return; + } +#if 0 + PRINT_D(RX_DBG, "In RX NORMAl Device name %s\n", dev->name); + /* Write metadata, and then pass to the receive level */ + skb->dev = dev; + skb->protocol = eth_type_trans(skb, dev); + skb->ip_summed = CHECKSUM_UNNECESSARY; /* don't check it */ + WILC_WFI_update_stats(priv->dev->ieee80211_ptr->wiphy, pkt->datalen, WILC_WFI_RX_PKT); + netif_rx(skb); +#endif +out: + return; +} + +/** + * @brief WILC_WFI_Poll + * @details The poll implementation + * @param[in] struct napi_struct *napi : + * @param[in] int budget : + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static int WILC_WFI_Poll(struct napi_struct *napi, int budget) +{ + int npackets = 0; + struct sk_buff *skb; + struct WILC_WFI_priv *priv = container_of(napi, struct WILC_WFI_priv, napi); + struct net_device *dev = priv->dev; + struct WILC_WFI_packet *pkt; + + while (npackets < budget && priv->rx_queue) { + pkt = WILC_WFI_DequeueBuf(dev); + skb = dev_alloc_skb(pkt->datalen + 2); + if (!skb) { + if (printk_ratelimit()) + PRINT_D(RX_DBG, "WILC_WFI: packet dropped\n"); + priv->stats.rx_dropped++; + WILC_WFI_ReleaseBuffer(pkt); + continue; + } + skb_reserve(skb, 2); /* align IP on 16B boundary */ + memcpy(skb_put(skb, pkt->datalen), pkt->data, pkt->datalen); + skb->dev = dev; + skb->protocol = eth_type_trans(skb, dev); + skb->ip_summed = CHECKSUM_UNNECESSARY; /* don't check it */ + netif_receive_skb(skb); + /* Maintain stats */ + npackets++; + WILC_WFI_update_stats(priv->dev->ieee80211_ptr->wiphy, pkt->datalen, WILC_WFI_RX_PKT); + WILC_WFI_ReleaseBuffer(pkt); + } + /* If we processed all packets, we're done; tell the kernel and re-enable ints */ + if (npackets < budget) { + napi_complete(napi); + WILC_WFI_RxInts(dev, 1); + } + return npackets; +} + +/** + * @brief WILC_WFI_Poll + * @details The typical interrupt entry point + * @param[in] struct napi_struct *napi : + * @param[in] int budget : + * @return int : Return 0 on Success. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static void WILC_WFI_RegularInterrupt(int irq, void *dev_id, struct pt_regs *regs) +{ + int statusword; + struct WILC_WFI_priv *priv; + struct WILC_WFI_packet *pkt = NULL; + /* + * As usual, check the "device" pointer to be sure it is + * really interrupting. + * Then assign "struct device *dev" + */ + struct net_device *dev = (struct net_device *)dev_id; + /* ... and check with hw if it's really ours */ + + /* paranoid */ + if (!dev) + return; + + /* Lock the device */ + priv = netdev_priv(dev); + spin_lock(&priv->lock); + + /* retrieve statusword: real netdevices use I/O instructions */ + statusword = priv->status; + priv->status = 0; + if (statusword & WILC_WFI_RX_INTR) { + /* send it to WILC_WFI_rx for handling */ + pkt = priv->rx_queue; + if (pkt) { + priv->rx_queue = pkt->next; + WILC_WFI_Rx(dev, pkt); + } + } + if (statusword & WILC_WFI_TX_INTR) { + /* a transmission is over: free the skb */ + WILC_WFI_update_stats(priv->dev->ieee80211_ptr->wiphy, priv->tx_packetlen, WILC_WFI_TX_PKT); + dev_kfree_skb(priv->skb); + } + + /* Unlock the device and we are done */ + spin_unlock(&priv->lock); + if (pkt) + WILC_WFI_ReleaseBuffer(pkt); /* Do this outside the lock! */ + return; +} +/** + * @brief WILC_WFI_NapiInterrupt + * @details A NAPI interrupt handler + * @param[in] irq: + * @param[in] dev_id: + * @param[in] pt_regs: + * @return NONE + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +static void WILC_WFI_NapiInterrupt(int irq, void *dev_id, struct pt_regs *regs) +{ + int statusword; + struct WILC_WFI_priv *priv; + + /* + * As usual, check the "device" pointer for shared handlers. + * Then assign "struct device *dev" + */ + struct net_device *dev = (struct net_device *)dev_id; + /* ... and check with hw if it's really ours */ + + /* paranoid */ + if (!dev) + return; + + /* Lock the device */ + priv = netdev_priv(dev); + spin_lock(&priv->lock); + + /* retrieve statusword: real netdevices use I/O instructions */ + statusword = priv->status; + priv->status = 0; + if (statusword & WILC_WFI_RX_INTR) { + WILC_WFI_RxInts(dev, 0); /* Disable further interrupts */ + napi_schedule(&priv->napi); + } + if (statusword & WILC_WFI_TX_INTR) { + /* a transmission is over: free the skb */ + + WILC_WFI_update_stats(priv->dev->ieee80211_ptr->wiphy, priv->tx_packetlen, WILC_WFI_TX_PKT); + dev_kfree_skb(priv->skb); + } + + /* Unlock the device and we are done */ + spin_unlock(&priv->lock); + return; +} + +/** + * @brief MI_WFI_HwTx + * @details Transmit a packet (low level interface) + * @param[in] buf: + * @param[in] len: + * @param[in] net_device *dev: + * @return NONE + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +void WILC_WFI_HwTx(char *buf, int len, struct net_device *dev) +{ + /* + * This function deals with hw details. This interface loops + * back the packet to the other WILC_WFI interface (if any). + * In other words, this function implements the WILC_WFI behaviour, + * while all other procedures are rather device-independent + */ + struct iphdr *ih; + struct net_device *dest; + struct WILC_WFI_priv *priv; + u32 *saddr, *daddr; + struct WILC_WFI_packet *tx_buffer; + + + /* I am paranoid. Ain't I? */ + if (len < sizeof(struct ethhdr) + sizeof(struct iphdr)) { + PRINT_D(RX_DBG, "WILC_WFI: Hmm... packet too short (%i octets)\n", + len); + return; + } + + if (0) { /* enable this conditional to look at the data */ + int i; + PRINT_D(RX_DBG, "len is %i", len); + for (i = 14; i < len; i++) + PRINT_D(RX_DBG, "TXdata[%d] %02x\n", i, buf[i] & 0xff); + /* PRINT_D(RX_DBG, "\n"); */ + } + /* + * Ethhdr is 14 bytes, but the kernel arranges for iphdr + * to be aligned (i.e., ethhdr is unaligned) + */ + ih = (struct iphdr *)(buf + sizeof(struct ethhdr)); + saddr = &ih->saddr; + daddr = &ih->daddr; + + ((u8 *)saddr)[2] ^= 1; /* change the third octet (class C) */ + ((u8 *)daddr)[2] ^= 1; + + ih->check = 0; /* and rebuild the checksum (ip needs it) */ + ih->check = ip_fast_csum((unsigned char *)ih, ih->ihl); + + + if (dev == WILC_WFI_devs[0]) + PRINT_D(RX_DBG, "%08x:%05i --> %08x:%05i\n", + ntohl(ih->saddr), ntohs(((struct tcphdr *)(ih + 1))->source), + ntohl(ih->daddr), ntohs(((struct tcphdr *)(ih + 1))->dest)); + else + PRINT_D(RX_DBG, "%08x:%05i <-- %08x:%05i\n", + ntohl(ih->daddr), ntohs(((struct tcphdr *)(ih + 1))->dest), + ntohl(ih->saddr), ntohs(((struct tcphdr *)(ih + 1))->source)); + + /* + * Ok, now the packet is ready for transmission: first simulate a + * receive interrupt on the twin device, then a + * transmission-done on the transmitting device + */ + dest = WILC_WFI_devs[dev == WILC_WFI_devs[0] ? 1 : 0]; + priv = netdev_priv(dest); + + tx_buffer = WILC_WFI_GetTxBuffer(dev); + tx_buffer->datalen = len; + memcpy(tx_buffer->data, buf, len); + WILC_WFI_EnqueueBuf(dest, tx_buffer); + if (priv->rx_int_enabled) { + priv->status |= WILC_WFI_RX_INTR; + WILC_WFI_Interrupt(0, dest, NULL); + } + + priv = netdev_priv(dev); + priv->tx_packetlen = len; + priv->tx_packetdata = buf; + priv->status |= WILC_WFI_TX_INTR; + if (lockup && ((priv->stats.tx_packets + 1) % lockup) == 0) { + /* Simulate a dropped transmit interrupt */ + netif_stop_queue(dev); + PRINT_D(RX_DBG, "Simulate lockup at %ld, txp %ld\n", jiffies, + (unsigned long) priv->stats.tx_packets); + } else + WILC_WFI_Interrupt(0, dev, NULL); + +} + +/** + * @brief WILC_WFI_Tx + * @details Transmit a packet (called by the kernel) + * @param[in] sk_buff *skb: + * @param[in] net_device *dev: + * @return NONE + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +int WILC_WFI_Tx(struct sk_buff *skb, struct net_device *dev) +{ + int len; + char *data, shortpkt[ETH_ZLEN]; + struct WILC_WFI_priv *priv = netdev_priv(dev); + + /* priv = wiphy_priv(priv->dev->ieee80211_ptr->wiphy); */ + + /* if(priv->monitor_flag) */ + /* mac80211_hwsim_monitor_rx(skb); */ + + + data = skb->data; + len = skb->len; + + if (len < ETH_ZLEN) { + memset(shortpkt, 0, ETH_ZLEN); + memcpy(shortpkt, skb->data, skb->len); + len = ETH_ZLEN; + data = shortpkt; + } + dev->trans_start = jiffies; /* save the timestamp */ + + /* Remember the skb, so we can free it at interrupt time */ + priv->skb = skb; + + /* actual deliver of data is device-specific, and not shown here */ + WILC_WFI_HwTx(data, len, dev); + + return 0; /* Our simple device can not fail */ +} + +/** + * @brief WILC_WFI_TxTimeout + * @details Deal with a transmit timeout. + * @param[in] net_device *dev: + * @return NONE + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +void WILC_WFI_TxTimeout(struct net_device *dev) +{ + struct WILC_WFI_priv *priv = netdev_priv(dev); + + PRINT_D(RX_DBG, "Transmit timeout at %ld, latency %ld\n", jiffies, + jiffies - dev->trans_start); + /* Simulate a transmission interrupt to get things moving */ + priv->status = WILC_WFI_TX_INTR; + WILC_WFI_Interrupt(0, dev, NULL); + priv->stats.tx_errors++; + netif_wake_queue(dev); + return; +} + +/** + * @brief WILC_WFI_Ioctl + * @details Ioctl commands + * @param[in] net_device *dev: + * @param[in] ifreq *rq + * @param[in] cmd: + * @return int : Return 0 on Success + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +int WILC_WFI_Ioctl(struct net_device *dev, struct ifreq *rq, int cmd) +{ + PRINT_D(RX_DBG, "ioctl\n"); + return 0; +} + +/** + * @brief WILC_WFI_Stat + * @details Return statistics to the caller + * @param[in] net_device *dev: + * @return WILC_WFI_Stats : Return net_device_stats stucture with the + * network device driver private data contents. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +struct net_device_stats *WILC_WFI_Stats(struct net_device *dev) +{ + struct WILC_WFI_priv *priv = netdev_priv(dev); + return &priv->stats; +} + +/** + * @brief WILC_WFI_RebuildHeader + * @details This function is called to fill up an eth header, since arp is not + * available on the interface + * @param[in] sk_buff *skb: + * @return int : Return 0 on Success + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +int WILC_WFI_RebuildHeader(struct sk_buff *skb) +{ + struct ethhdr *eth = (struct ethhdr *) skb->data; + struct net_device *dev = skb->dev; + + memcpy(eth->h_source, dev->dev_addr, dev->addr_len); + memcpy(eth->h_dest, dev->dev_addr, dev->addr_len); + eth->h_dest[ETH_ALEN - 1] ^= 0x01; /* dest is us xor 1 */ + return 0; +} +/** + * @brief WILC_WFI_RebuildHeader + * @details This function is called to fill up an eth header, since arp is not + * available on the interface + * @param[in] sk_buff *skb: + * @param[in] struct net_device *dev: + * @param[in] unsigned short type: + * @param[in] const void *saddr, + * @param[in] const void *daddr: + * @param[in] unsigned int len + * @return int : Return 0 on Success + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +int WILC_WFI_Header(struct sk_buff *skb, struct net_device *dev, + unsigned short type, const void *daddr, const void *saddr, + unsigned int len) +{ + struct ethhdr *eth = (struct ethhdr *)skb_push(skb, ETH_HLEN); + + eth->h_proto = htons(type); + memcpy(eth->h_source, saddr ? saddr : dev->dev_addr, dev->addr_len); + memcpy(eth->h_dest, daddr ? daddr : dev->dev_addr, dev->addr_len); + eth->h_dest[ETH_ALEN - 1] ^= 0x01; /* dest is us xor 1 */ + return dev->hard_header_len; +} + +/** + * @brief WILC_WFI_ChangeMtu + * @details The "change_mtu" method is usually not needed. + * If you need it, it must be like this. + * @param[in] net_device *dev : Network Device Driver Structure + * @param[in] new_mtu : + * @return int : Returns 0 on Success. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +int WILC_WFI_ChangeMtu(struct net_device *dev, int new_mtu) +{ + unsigned long flags; + struct WILC_WFI_priv *priv = netdev_priv(dev); + spinlock_t *lock = &priv->lock; + + /* check ranges */ + if ((new_mtu < 68) || (new_mtu > 1500)) + return -EINVAL; + /* + * Do anything you need, and the accept the value + */ + spin_lock_irqsave(lock, flags); + dev->mtu = new_mtu; + spin_unlock_irqrestore(lock, flags); + return 0; /* success */ +} + +static const struct header_ops WILC_WFI_header_ops = { + .create = WILC_WFI_Header, + .rebuild = WILC_WFI_RebuildHeader, + .cache = NULL, /* disable caching */ +}; + + +static const struct net_device_ops WILC_WFI_netdev_ops = { + .ndo_open = WILC_WFI_Open, + .ndo_stop = WILC_WFI_Release, + .ndo_set_config = WILC_WFI_Config, + .ndo_start_xmit = WILC_WFI_Tx, + .ndo_do_ioctl = WILC_WFI_Ioctl, + .ndo_get_stats = WILC_WFI_Stats, + .ndo_change_mtu = WILC_WFI_ChangeMtu, + .ndo_tx_timeout = WILC_WFI_TxTimeout, +}; + +/** + * @brief WILC_WFI_Init + * @details The init function (sometimes called probe). + * It is invoked by register_netdev() + * @param[in] net_device *dev: + * @return NONE + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +void WILC_WFI_Init(struct net_device *dev) +{ + struct WILC_WFI_priv *priv; + + + /* + * Then, assign other fields in dev, using ether_setup() and some + * hand assignments + */ + ether_setup(dev); /* assign some of the fields */ + /* 1- Allocate space */ + + dev->netdev_ops = &WILC_WFI_netdev_ops; + dev->header_ops = &WILC_WFI_header_ops; + dev->watchdog_timeo = timeout; + /* keep the default flags, just add NOARP */ + dev->flags |= IFF_NOARP; + dev->features |= NETIF_F_NO_CSUM; + /* + * Then, initialize the priv field. This encloses the statistics + * and a few private fields. + */ + priv = netdev_priv(dev); + memset(priv, 0, sizeof(struct WILC_WFI_priv)); + priv->dev = dev; + netif_napi_add(dev, &priv->napi, WILC_WFI_Poll, 2); + /* The last parameter above is the NAPI "weight". */ + spin_lock_init(&priv->lock); + WILC_WFI_RxInts(dev, 1); /* enable receive interrupts */ + WILC_WFI_SetupPool(dev); +} + +/** + * @brief WILC_WFI_Stat + * @details Return statistics to the caller + * @param[in] net_device *dev: + * @return WILC_WFI_Stats : Return net_device_stats stucture with the + * network device driver private data contents. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ + +void WILC_WFI_Cleanup(void) +{ + int i; + struct WILC_WFI_priv *priv[2]; + + /*if(hwsim_mon!=NULL) + * { + * PRINT_D(RX_DBG, "Freeing monitor interface\n"); + * unregister_netdev(hwsim_mon); + * free_netdev(hwsim_mon); + * }*/ + for (i = 0; i < 2; i++) { + priv[i] = netdev_priv(WILC_WFI_devs[i]); + + if (WILC_WFI_devs[i]) { + PRINT_D(RX_DBG, "Unregistering\n"); + unregister_netdev(WILC_WFI_devs[i]); + WILC_WFI_TearDownPool(WILC_WFI_devs[i]); + free_netdev(WILC_WFI_devs[i]); + PRINT_D(RX_DBG, "[NETDEV]Stopping interface\n"); + WILC_WFI_DeInitHostInt(WILC_WFI_devs[i]); + WILC_WFI_WiphyFree(WILC_WFI_devs[i]); + } + + } + /* unregister_netdev(hwsim_mon); */ + WILC_WFI_deinit_mon_interface(); + return; +} + + +void StartConfigSim(void); + + + + + + + +/** + * @brief WILC_WFI_Stat + * @details Return statistics to the caller + * @param[in] net_device *dev: + * @return WILC_WFI_Stats : Return net_device_stats stucture with the + * network device driver private data contents. + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +int WILC_WFI_InitModule(void) +{ + + int result, i, ret = -ENOMEM; + struct WILC_WFI_priv *priv[2], *netpriv; + struct wireless_dev *wdev; + WILC_WFI_Interrupt = use_napi ? WILC_WFI_NapiInterrupt : WILC_WFI_RegularInterrupt; + char buf[IFNAMSIZ]; + + for (i = 0; i < 2; i++) { + + /* Allocate the net devices */ + WILC_WFI_devs[i] = alloc_netdev(sizeof(struct WILC_WFI_priv), "wlan%d", + WILC_WFI_Init); + if (WILC_WFI_devs[i] == NULL) + goto out; + /* priv[i] = netdev_priv(WILC_WFI_devs[i]); */ + + wdev = WILC_WFI_WiphyRegister(WILC_WFI_devs[i]); + WILC_WFI_devs[i]->ieee80211_ptr = wdev; + netpriv = netdev_priv(WILC_WFI_devs[i]); + netpriv->dev->ieee80211_ptr = wdev; + netpriv->dev->ml_priv = netpriv; + wdev->netdev = netpriv->dev; + + /*Registering the net device*/ + result = register_netdev(WILC_WFI_devs[i]); + if (result) + PRINT_D(RX_DBG, "WILC_WFI: error %i registering device \"%s\"\n", + result, WILC_WFI_devs[i]->name); + else + ret = 0; + } + + + /*init atmel driver */ + priv[0] = netdev_priv(WILC_WFI_devs[0]); + priv[1] = netdev_priv(WILC_WFI_devs[1]); + + if (priv[1]->dev->ieee80211_ptr->wiphy->interface_modes && BIT(NL80211_IFTYPE_MONITOR)) { + /* snprintf(buf, IFNAMSIZ, "mon.%s", priv[1]->dev->name); */ + /* WILC_WFI_init_mon_interface(); */ + /* priv[1]->monitor_flag = 1; */ + + } + priv[0]->bCfgScanning = WILC_FALSE; + priv[0]->u32RcvdChCount = 0; + + WILC_memset(priv[0]->au8AssociatedBss, 0xFF, ETH_ALEN); + + + /* ret = host_int_init(&priv[0]->hWILCWFIDrv); */ + /*copy handle to the other driver*/ + /* priv[1]->hWILCWFIDrv = priv[0]->hWILCWFIDrv; */ + if (ret) { + PRINT_ER("Error Init Driver\n"); + } + + +out: + if (ret) + WILC_WFI_Cleanup(); + return ret; + + +} + + +module_init(WILC_WFI_InitModule); +module_exit(WILC_WFI_Cleanup); + +#endif diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h new file mode 100644 index 000000000000..aa30de932ca4 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -0,0 +1,277 @@ +/*! + * @file wilc_wfi_netdevice.h + * @brief Definitions for the network module + * @author mdaftedar + * @date 01 MAR 2012 + * @version 1.0 + */ +#ifndef WILC_WFI_NETDEVICE +#define WILC_WFI_NETDEVICE + +/* These are the flags in the statusword */ +#define WILC_WFI_RX_INTR 0x0001 +#define WILC_WFI_TX_INTR 0x0002 + +/* Default timeout period */ +#define WILC_WFI_TIMEOUT 5 /* In jiffies */ +#define WILC_MAX_NUM_PMKIDS 16 +#define PMKID_LEN 16 +#define PMKID_FOUND 1 + #define NUM_STA_ASSOCIATED 8 + +#include +#include +#include +#include +#include +#include /* kmalloc() */ +#include /* error codes */ +#include /* size_t */ +#include /* mark_bh */ +#include +#include +#include /* struct device, and other headers */ +#include /* eth_type_trans */ +#include /* struct iphdr */ +#include /* struct tcphdr */ +#include + +#include +#include + +#include +#include +#include +#include + + +#include +#include +#include "host_interface.h" +#include "wilc_wlan.h" +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 30) +#include +#else +#include /* tony, 2013-06-12 */ +#endif + + +#define FLOW_CONTROL_LOWER_THRESHOLD 128 +#define FLOW_CONTROL_UPPER_THRESHOLD 256 + +/*iftype*/ + + +enum stats_flags { + WILC_WFI_RX_PKT = 1 << 0, + WILC_WFI_TX_PKT = 1 << 1, +}; + +struct WILC_WFI_stats { + + unsigned long rx_packets; + unsigned long tx_packets; + unsigned long rx_bytes; + unsigned long tx_bytes; + u64 rx_time; + u64 tx_time; + +}; + +/* + * This structure is private to each device. It is used to pass + * packets in and out, so there is place for a packet + */ + +#define RX_BH_KTHREAD 0 +#define RX_BH_WORK_QUEUE 1 +#define RX_BH_THREADED_IRQ 2 +#define num_reg_frame 2 +/* + * If you use RX_BH_WORK_QUEUE on LPC3131: You may lose the first interrupt on + * LPC3131 which is important to get the MAC start status when you are blocked inside + * linux_wlan_firmware_download() which blocks mac_open(). + */ +#if defined (NM73131_0_BOARD) + #define RX_BH_TYPE RX_BH_KTHREAD +#elif defined (PANDA_BOARD) + #define RX_BH_TYPE RX_BH_THREADED_IRQ +#else + #define RX_BH_TYPE RX_BH_KTHREAD +#endif + +struct wilc_wfi_key { + u8 *key; + u8 *seq; + int key_len; + int seq_len; + u32 cipher; +}; +struct wilc_wfi_wep_key { + u8 *key; + u8 key_len; + u8 key_idx; +}; + +struct sta_info { + WILC_Uint8 au8Sta_AssociatedBss[MAX_NUM_STA][ETH_ALEN]; +}; + +#ifdef WILC_P2P +/*Parameters needed for host interface for remaining on channel*/ +struct wilc_wfi_p2pListenParams { + struct ieee80211_channel *pstrListenChan; + enum nl80211_channel_type tenuChannelType; + WILC_Uint32 u32ListenDuration; + WILC_Uint64 u64ListenCookie; + WILC_Uint32 u32ListenSessionID; +}; + +#endif /*WILC_P2P*/ + +struct WILC_WFI_priv { + struct wireless_dev *wdev; + struct cfg80211_scan_request *pstrScanReq; + + #ifdef WILC_P2P + struct wilc_wfi_p2pListenParams strRemainOnChanParams; + WILC_Uint64 u64tx_cookie; + + #endif + + WILC_Bool bCfgScanning; + WILC_Uint32 u32RcvdChCount; + + + + WILC_Uint8 au8AssociatedBss[ETH_ALEN]; + struct sta_info assoc_stainfo; + struct net_device_stats stats; + WILC_Uint8 monitor_flag; + int status; + struct WILC_WFI_packet *ppool; + struct WILC_WFI_packet *rx_queue; /* List of incoming packets */ + int rx_int_enabled; + int tx_packetlen; + u8 *tx_packetdata; + struct sk_buff *skb; + spinlock_t lock; + struct net_device *dev; + struct napi_struct napi; + WILC_WFIDrvHandle hWILCWFIDrv; + WILC_WFIDrvHandle hWILCWFIDrv_2; + tstrHostIFpmkidAttr pmkid_list; + struct WILC_WFI_stats netstats; + WILC_Uint8 WILC_WFI_wep_default; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31) +#define WLAN_KEY_LEN_WEP104 13 +#endif + WILC_Uint8 WILC_WFI_wep_key[4][WLAN_KEY_LEN_WEP104]; + WILC_Uint8 WILC_WFI_wep_key_len[4]; + struct net_device *real_ndev; /* The real interface that the monitor is on */ + struct wilc_wfi_key *wilc_gtk[MAX_NUM_STA]; + struct wilc_wfi_key *wilc_ptk[MAX_NUM_STA]; + WILC_Uint8 wilc_groupkey; + /* semaphores */ + WILC_SemaphoreHandle SemHandleUpdateStats; + WILC_SemaphoreHandle hSemScanReq; + /* */ + WILC_Bool gbAutoRateAdjusted; + + WILC_Bool bInP2PlistenState; + +}; + +typedef struct { + WILC_Uint16 frame_type; + WILC_Bool reg; + +} struct_frame_reg; + + +#define NUM_CONCURRENT_IFC 2 +typedef struct { + uint8_t aSrcAddress[ETH_ALEN]; + uint8_t aBSSID[ETH_ALEN]; + uint32_t drvHandler; + struct net_device *wilc_netdev; +} tstrInterfaceInfo; +typedef struct { + int mac_status; + int wilc1000_initialized; + + + #if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO) + unsigned short dev_irq_num; + #endif + wilc_wlan_oup_t oup; + int close; + uint8_t u8NoIfcs; + tstrInterfaceInfo strInterfaceInfo[NUM_CONCURRENT_IFC]; + uint8_t open_ifcs; + struct mutex txq_cs; + + /*Added by Amr - BugID_4720*/ + struct mutex txq_add_to_head_cs; + spinlock_t txq_spinlock; + + struct mutex rxq_cs; + struct mutex hif_cs; + + /* struct mutex txq_event; */ + struct semaphore rxq_event; + struct semaphore cfg_event; + struct semaphore sync_event; + + struct semaphore txq_event; + /* struct completion txq_event; */ + +#if (RX_BH_TYPE == RX_BH_WORK_QUEUE) + struct work_struct rx_work_queue; +#elif (RX_BH_TYPE == RX_BH_KTHREAD) + struct task_struct *rx_bh_thread; + struct semaphore rx_sem; +#endif + + + + struct semaphore rxq_thread_started; + struct semaphore txq_thread_started; + + struct task_struct *rxq_thread; + struct task_struct *txq_thread; + + unsigned char eth_src_address[NUM_CONCURRENT_IFC][6]; + /* unsigned char eth_dst_address[6]; */ + + const struct firmware *wilc_firmware; /* Bug 4703 */ + + struct net_device *real_ndev; +#ifdef WILC_SDIO + int already_claim; + struct sdio_func *wilc_sdio_func; +#else + struct spi_device *wilc_spidev; +#endif + +} linux_wlan_t; + +typedef struct { + uint8_t u8IfIdx; + WILC_Uint8 iftype; + int monitor_flag; + int mac_opened; + #ifdef WILC_P2P + struct_frame_reg g_struct_frame_reg[num_reg_frame]; + #endif + struct net_device *wilc_netdev; + struct net_device_stats netstats; + +} perInterface_wlan_t; + +struct WILC_WFI_mon_priv { + struct net_device *real_ndev; +}; +extern struct net_device *WILC_WFI_devs[]; + +#endif diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c new file mode 100644 index 000000000000..92ed42ad49ac --- /dev/null +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -0,0 +1,2434 @@ +/* ////////////////////////////////////////////////////////////////////////// */ +/* */ +/* Copyright (c) Atmel Corporation. All rights reserved. */ +/* */ +/* Module Name: wilc_wlan.c */ +/* */ +/* */ +/* //////////////////////////////////////////////////////////////////////////// */ + +#include "wilc_wlan_if.h" +#include "wilc_wlan.h" +#define INLINE static __inline + +/******************************************** + * + * Global + * + ********************************************/ +extern unsigned int int_clrd; +extern wilc_hif_func_t hif_sdio; +extern wilc_hif_func_t hif_spi; +extern wilc_cfg_func_t mac_cfg; +#if defined(PLAT_RK3026_TCHIP) +extern WILC_Uint8 g_wilc_initialized; /* AMR : 0422 RK3026 Crash issue */ +#endif +extern void WILC_WFI_mgmt_rx(uint8_t *buff, uint32_t size); +extern void frmw_to_linux(uint8_t *buff, uint32_t size); +int sdio_xfer_cnt(void); +uint32_t wilc_get_chipid(uint8_t update); +WILC_Uint16 Set_machw_change_vir_if(WILC_Bool bValue); + +/* static uint32_t vmm_table[WILC_VMM_TBL_SIZE]; */ +/* static uint32_t vmm_table_rbk[WILC_VMM_TBL_SIZE]; */ + +/* static uint32_t vmm_table_rbk[WILC_VMM_TBL_SIZE]; */ + + +typedef struct { + int quit; + + /** + * input interface functions + **/ + wilc_wlan_os_func_t os_func; + wilc_wlan_io_func_t io_func; + wilc_wlan_net_func_t net_func; + wilc_wlan_indicate_func_t indicate_func; + + /** + * host interface functions + **/ + wilc_hif_func_t hif_func; + void *hif_lock; + + /** + * configuration interface functions + **/ + wilc_cfg_func_t cif_func; + int cfg_frame_in_use; + wilc_cfg_frame_t cfg_frame; + uint32_t cfg_frame_offset; + int cfg_seq_no; + void *cfg_wait; + + /** + * RX buffer + **/ + #ifdef MEMORY_STATIC + uint32_t rx_buffer_size; + uint8_t *rx_buffer; + uint32_t rx_buffer_offset; + #endif + /** + * TX buffer + **/ + uint32_t tx_buffer_size; + uint8_t *tx_buffer; + uint32_t tx_buffer_offset; + + /** + * TX queue + **/ + void *txq_lock; + + /*Added by Amr - BugID_4720*/ + void *txq_add_to_head_lock; + void *txq_spinlock; + unsigned long txq_spinlock_flags; + + struct txq_entry_t *txq_head; + struct txq_entry_t *txq_tail; + int txq_entries; + void *txq_wait; + int txq_exit; + + /** + * RX queue + **/ + void *rxq_lock; + struct rxq_entry_t *rxq_head; + struct rxq_entry_t *rxq_tail; + int rxq_entries; + void *rxq_wait; + int rxq_exit; + + +} wilc_wlan_dev_t; + +static wilc_wlan_dev_t g_wlan; + +INLINE void chip_allow_sleep(void); +INLINE void chip_wakeup(void); +/******************************************** + * + * Debug + * + ********************************************/ + +static uint32_t dbgflag = N_INIT | N_ERR | N_INTR | N_TXQ | N_RXQ; + +static void wilc_debug(uint32_t flag, char *fmt, ...) +{ + char buf[256]; + va_list args; + int len; + + if (flag & dbgflag) { + va_start(args, fmt); + len = vsprintf(buf, fmt, args); + va_end(args); + + if (g_wlan.os_func.os_debug) + g_wlan.os_func.os_debug(buf); + } + + return; +} + +static CHIP_PS_STATE_T genuChipPSstate = CHIP_WAKEDUP; + +/*BugID_5213*/ +/*acquire_bus() and release_bus() are made INLINE functions*/ +/*as a temporary workaround to fix a problem of receiving*/ +/*unknown interrupt from FW*/ +INLINE void acquire_bus(BUS_ACQUIRE_T acquire) +{ + + g_wlan.os_func.os_enter_cs(g_wlan.hif_lock); + #ifndef WILC_OPTIMIZE_SLEEP_INT + if (genuChipPSstate != CHIP_WAKEDUP) + #endif + { + if (acquire == ACQUIRE_AND_WAKEUP) + chip_wakeup(); + } + +} +INLINE void release_bus(BUS_RELEASE_T release) +{ + #ifdef WILC_OPTIMIZE_SLEEP_INT + if (release == RELEASE_ALLOW_SLEEP) + chip_allow_sleep(); + #endif + g_wlan.os_func.os_leave_cs(g_wlan.hif_lock); +} +/******************************************** + * + * Queue + * + ********************************************/ + +static void wilc_wlan_txq_remove(struct txq_entry_t *tqe) +{ + + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + /* unsigned long flags; */ + /* p->os_func.os_spin_lock(p->txq_spinlock, &flags); */ + if (tqe == p->txq_head) { + + p->txq_head = tqe->next; + if (p->txq_head) + p->txq_head->prev = NULL; + + + } else if (tqe == p->txq_tail) { + p->txq_tail = (tqe->prev); + if (p->txq_tail) + p->txq_tail->next = NULL; + } else { + tqe->prev->next = tqe->next; + tqe->next->prev = tqe->prev; + } + p->txq_entries -= 1; + /* p->os_func.os_spin_unlock(p->txq_spinlock, &flags); */ + +} + +static struct txq_entry_t *wilc_wlan_txq_remove_from_head(void) +{ + struct txq_entry_t *tqe; + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + unsigned long flags; + p->os_func.os_spin_lock(p->txq_spinlock, &flags); + if (p->txq_head) { + /* p->os_func.os_enter_cs(p->txq_lock); */ + tqe = p->txq_head; + p->txq_head = tqe->next; + if (p->txq_head) { + p->txq_head->prev = NULL; + } + p->txq_entries -= 1; + + /*Added by Amr - BugID_4720*/ + + + /* p->os_func.os_leave_cs(p->txq_lock); */ + + } else { + tqe = NULL; + } + p->os_func.os_spin_unlock(p->txq_spinlock, &flags); + return tqe; +} + +static void wilc_wlan_txq_add_to_tail(struct txq_entry_t *tqe) +{ + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + unsigned long flags; + /*Added by Amr - BugID_4720*/ + p->os_func.os_spin_lock(p->txq_spinlock, &flags); + +/* p->os_func.os_enter_cs(p->txq_lock); */ + if (p->txq_head == NULL) { + tqe->next = NULL; + tqe->prev = NULL; + p->txq_head = tqe; + p->txq_tail = tqe; + /* p->os_func.os_signal(p->txq_wait); */ + } else { + tqe->next = NULL; + tqe->prev = p->txq_tail; + p->txq_tail->next = tqe; + p->txq_tail = tqe; + } + p->txq_entries += 1; + PRINT_D(TX_DBG, "Number of entries in TxQ = %d\n", p->txq_entries); +/* p->os_func.os_leave_cs(p->txq_lock); */ + + /*Added by Amr - BugID_4720*/ + p->os_func.os_spin_unlock(p->txq_spinlock, &flags); + + /** + * wake up TX queue + **/ + PRINT_D(TX_DBG, "Wake the txq_handling\n"); + + p->os_func.os_signal(p->txq_wait); + + +} + +static int wilc_wlan_txq_add_to_head(struct txq_entry_t *tqe) +{ + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + unsigned long flags; + /*Added by Amr - BugID_4720*/ + if (p->os_func.os_wait(p->txq_add_to_head_lock, CFG_PKTS_TIMEOUT)) + return -1; + + p->os_func.os_spin_lock(p->txq_spinlock, &flags); + + /* p->os_func.os_enter_cs(p->txq_lock); */ + if (p->txq_head == NULL) { + tqe->next = NULL; + tqe->prev = NULL; + p->txq_head = tqe; + p->txq_tail = tqe; + } else { + tqe->next = p->txq_head; + tqe->prev = NULL; + p->txq_head->prev = tqe; + p->txq_head = tqe; + } + p->txq_entries += 1; + PRINT_D(TX_DBG, "Number of entries in TxQ = %d\n", p->txq_entries); + /* p->os_func.os_leave_cs(p->txq_lock); */ + + /*Added by Amr - BugID_4720*/ + p->os_func.os_spin_unlock(p->txq_spinlock, &flags); + p->os_func.os_signal(p->txq_add_to_head_lock); + + + /** + * wake up TX queue + **/ + p->os_func.os_signal(p->txq_wait); + PRINT_D(TX_DBG, "Wake up the txq_handler\n"); +/* complete(p->txq_wait); */ + + /*Added by Amr - BugID_4720*/ + return 0; + +} + +uint32_t Statisitcs_totalAcks = 0, Statisitcs_DroppedAcks = 0; + +#ifdef TCP_ACK_FILTER +struct Ack_session_info; +typedef struct Ack_session_info { + uint32_t Ack_seq_num; + uint32_t Bigger_Ack_num; + uint16_t src_port; + uint16_t dst_port; + uint16_t status; + /* struct Ack_session_info * next; */ + /* struct Ack_session_info * prev; */ +} Ack_session_info_t; + +typedef struct { + uint32_t ack_num; + /* uint32_t seq_num; */ + /* uint16_t src_port; */ + /* uint16_t dst_port; */ + /* uint32_t dst_ip_addr; */ + uint32_t Session_index; + struct txq_entry_t *txqe; + /* Ack_session_info * Ack_session; */ +} Pending_Acks_info_t /*Ack_info_t*/; + + + + +struct Ack_session_info *Free_head; +struct Ack_session_info *Alloc_head; + +#define TCP_FIN_MASK (1 << 0) +#define TCP_SYN_MASK (1 << 1) +#define TCP_Ack_MASK (1 << 4) +#define NOT_TCP_ACK (-1) + +#define MAX_TCP_SESSION 25 +#define MAX_PENDING_ACKS 256 +Ack_session_info_t Acks_keep_track_info[2 * MAX_TCP_SESSION]; +Pending_Acks_info_t Pending_Acks_info[MAX_PENDING_ACKS]; + +uint32_t PendingAcks_arrBase; +uint32_t Opened_TCP_session; +uint32_t Pending_Acks; + + + +static __inline int Init_TCP_tracking(void) +{ + + /*uint32_t i; + * Free_head=&Acks_keep_track_info[0]; + * i=1; + * Acks_keep_track_info[0].next=&Acks_keep_track_info[1]; + * for(i=1<;i Acks_keep_track_info[index].Bigger_Ack_num) { + Acks_keep_track_info[index].Bigger_Ack_num = Ack; + } + return 0; + +} +static __inline int add_TCP_Pending_Ack(uint32_t Ack, uint32_t Session_index, struct txq_entry_t *txqe) +{ + Statisitcs_totalAcks++; + if (Pending_Acks < MAX_PENDING_ACKS) { + Pending_Acks_info[PendingAcks_arrBase + Pending_Acks].ack_num = Ack; + Pending_Acks_info[PendingAcks_arrBase + Pending_Acks].txqe = txqe; + Pending_Acks_info[PendingAcks_arrBase + Pending_Acks].Session_index = Session_index; + txqe->tcp_PendingAck_index = PendingAcks_arrBase + Pending_Acks; + Pending_Acks++; + + } else { + + } + return 0; +} +static __inline int remove_TCP_related(void) +{ + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + unsigned long flags; + p->os_func.os_spin_lock(p->txq_spinlock, &flags); + + p->os_func.os_spin_unlock(p->txq_spinlock, &flags); + return 0; +} + +static __inline int tcp_process(struct txq_entry_t *tqe) +{ + int ret; + uint8_t *eth_hdr_ptr; + uint8_t *buffer = tqe->buffer; + unsigned short h_proto; + int i; + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + unsigned long flags; + p->os_func.os_spin_lock(p->txq_spinlock, &flags); + + eth_hdr_ptr = &buffer[0]; + h_proto = ntohs(*((unsigned short *)ð_hdr_ptr[12])); + if (h_proto == 0x0800) { /* IP */ + uint8_t *ip_hdr_ptr; + uint8_t protocol; + + ip_hdr_ptr = &buffer[ETHERNET_HDR_LEN]; + protocol = ip_hdr_ptr[9]; + + + if (protocol == 0x06) { + uint8_t *tcp_hdr_ptr; + uint32_t IHL, Total_Length, Data_offset; + tcp_hdr_ptr = &ip_hdr_ptr[IP_HDR_LEN]; + IHL = (ip_hdr_ptr[0] & 0xf) << 2; + Total_Length = (((uint32_t)ip_hdr_ptr[2]) << 8) + ((uint32_t)ip_hdr_ptr[3]); + Data_offset = (((uint32_t)tcp_hdr_ptr[12] & 0xf0) >> 2); + if (Total_Length == (IHL + Data_offset)) { /*we want to recognize the clear Acks(packet only carry Ack infos not with data) so data size must be equal zero*/ + uint32_t seq_no, Ack_no; + seq_no = (((uint32_t)tcp_hdr_ptr[4]) << 24) + (((uint32_t)tcp_hdr_ptr[5]) << 16) + (((uint32_t)tcp_hdr_ptr[6]) << 8) + ((uint32_t)tcp_hdr_ptr[7]); + + Ack_no = (((uint32_t)tcp_hdr_ptr[8]) << 24) + (((uint32_t)tcp_hdr_ptr[9]) << 16) + (((uint32_t)tcp_hdr_ptr[10]) << 8) + ((uint32_t)tcp_hdr_ptr[11]); + + + for (i = 0; i < Opened_TCP_session; i++) { + if (Acks_keep_track_info[i].Ack_seq_num == seq_no) { + Update_TCP_track_session(i, Ack_no); + break; + } + } + if (i == Opened_TCP_session) { + add_TCP_track_session(0, 0, seq_no); + } + add_TCP_Pending_Ack(Ack_no, i, tqe); + + + } + + } else { + ret = 0; + } + } else { + ret = 0; + } + p->os_func.os_spin_unlock(p->txq_spinlock, &flags); + return ret; +} + + +static int wilc_wlan_txq_filter_dup_tcp_ack(void) +{ + + uint32_t i = 0; + uint32_t Dropped = 0; + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + + p->os_func.os_spin_lock(p->txq_spinlock, &p->txq_spinlock_flags); + for (i = PendingAcks_arrBase; i < (PendingAcks_arrBase + Pending_Acks); i++) { + if (Pending_Acks_info[i].ack_num < Acks_keep_track_info[Pending_Acks_info[i].Session_index].Bigger_Ack_num) { + struct txq_entry_t *tqe; + PRINT_D(TCP_ENH, "DROP ACK: %u \n", Pending_Acks_info[i].ack_num); + tqe = Pending_Acks_info[i].txqe; + if (tqe) { + wilc_wlan_txq_remove(tqe); + Statisitcs_DroppedAcks++; + tqe->status = 1; /* mark the packet send */ + if (tqe->tx_complete_func) + tqe->tx_complete_func(tqe->priv, tqe->status); + p->os_func.os_free(tqe); + Dropped++; + /* p->txq_entries -= 1; */ + } + } + } + Pending_Acks = 0; + Opened_TCP_session = 0; + + if (PendingAcks_arrBase == 0) { + PendingAcks_arrBase = MAX_TCP_SESSION; + } else { + PendingAcks_arrBase = 0; + } + + + p->os_func.os_spin_unlock(p->txq_spinlock, &p->txq_spinlock_flags); + + while (Dropped > 0) { + /*consume the semaphore count of the removed packet*/ + p->os_func.os_wait(p->txq_wait, 1); + Dropped--; + } + + return 1; +} +#endif + +#ifdef TCP_ENHANCEMENTS +WILC_Bool EnableTCPAckFilter = WILC_FALSE; + +void Enable_TCP_ACK_Filter(WILC_Bool value) +{ + EnableTCPAckFilter = value; +} + +WILC_Bool is_TCP_ACK_Filter_Enabled(void) +{ + return EnableTCPAckFilter; +} +#endif + +static int wilc_wlan_txq_add_cfg_pkt(uint8_t *buffer, uint32_t buffer_size) +{ + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + struct txq_entry_t *tqe; + + PRINT_D(TX_DBG, "Adding config packet ...\n"); + if (p->quit) { + PRINT_D(TX_DBG, "Return due to clear function\n"); + p->os_func.os_signal(p->cfg_wait); + return 0; + } + + tqe = (struct txq_entry_t *)p->os_func.os_malloc_atomic(sizeof(struct txq_entry_t)); + if (tqe == NULL) { + PRINT_ER("Failed to allocate memory\n"); + return 0; + } + + tqe->type = WILC_CFG_PKT; + tqe->buffer = buffer; + tqe->buffer_size = buffer_size; + tqe->tx_complete_func = NULL; + tqe->priv = NULL; +#ifdef TCP_ACK_FILTER + tqe->tcp_PendingAck_index = NOT_TCP_ACK; +#endif + /** + * Configuration packet always at the front + **/ + PRINT_D(TX_DBG, "Adding the config packet at the Queue tail\n"); + + /*Edited by Amr - BugID_4720*/ + if (wilc_wlan_txq_add_to_head(tqe)) + return 0; + /* wilc_wlan_txq_add_to_tail(tqe); */ + return 1; +} + +static int wilc_wlan_txq_add_net_pkt(void *priv, uint8_t *buffer, uint32_t buffer_size, wilc_tx_complete_func_t func) +{ + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + struct txq_entry_t *tqe; + + if (p->quit) + return 0; + + tqe = (struct txq_entry_t *)p->os_func.os_malloc_atomic(sizeof(struct txq_entry_t)); + + if (tqe == NULL) + return 0; + tqe->type = WILC_NET_PKT; + tqe->buffer = buffer; + tqe->buffer_size = buffer_size; + tqe->tx_complete_func = func; + tqe->priv = priv; + + PRINT_D(TX_DBG, "Adding mgmt packet at the Queue tail\n"); +#ifdef TCP_ACK_FILTER + tqe->tcp_PendingAck_index = NOT_TCP_ACK; +#ifdef TCP_ENHANCEMENTS + if (is_TCP_ACK_Filter_Enabled() == WILC_TRUE) +#endif + tcp_process(tqe); +#endif + wilc_wlan_txq_add_to_tail(tqe); + /*return number of itemes in the queue*/ + return p->txq_entries; +} +/*Bug3959: transmitting mgmt frames received from host*/ +#if defined(WILC_AP_EXTERNAL_MLME) || defined(WILC_P2P) +int wilc_wlan_txq_add_mgmt_pkt(void *priv, uint8_t *buffer, uint32_t buffer_size, wilc_tx_complete_func_t func) +{ + + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + struct txq_entry_t *tqe; + + if (p->quit) + return 0; + + tqe = (struct txq_entry_t *)p->os_func.os_malloc_atomic(sizeof(struct txq_entry_t)); + + if (tqe == NULL) + return 0; + tqe->type = WILC_MGMT_PKT; + tqe->buffer = buffer; + tqe->buffer_size = buffer_size; + tqe->tx_complete_func = func; + tqe->priv = priv; +#ifdef TCP_ACK_FILTER + tqe->tcp_PendingAck_index = NOT_TCP_ACK; +#endif + PRINT_D(TX_DBG, "Adding Network packet at the Queue tail\n"); + wilc_wlan_txq_add_to_tail(tqe); + return 1; +} + +#ifdef WILC_FULLY_HOSTING_AP +int wilc_FH_wlan_txq_add_net_pkt(void *priv, uint8_t *buffer, uint32_t buffer_size, wilc_tx_complete_func_t func) +{ + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + struct txq_entry_t *tqe; + + if (p->quit) + return 0; + + tqe = (struct txq_entry_t *)p->os_func.os_malloc_atomic(sizeof(struct txq_entry_t)); + + if (tqe == NULL) + return 0; + tqe->type = WILC_FH_DATA_PKT; + tqe->buffer = buffer; + tqe->buffer_size = buffer_size; + tqe->tx_complete_func = func; + tqe->priv = priv; + PRINT_D(TX_DBG, "Adding mgmt packet at the Queue tail\n"); + wilc_wlan_txq_add_to_tail(tqe); + /*return number of itemes in the queue*/ + return p->txq_entries; +} +#endif /* WILC_FULLY_HOSTING_AP*/ +#endif /*WILC_AP_EXTERNAL_MLME*/ +static struct txq_entry_t *wilc_wlan_txq_get_first(void) +{ + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + struct txq_entry_t *tqe; + unsigned long flags; + + /*Added by Amr - BugID_4720*/ + p->os_func.os_spin_lock(p->txq_spinlock, &flags); + + /* p->os_func.os_enter_cs(p->txq_lock); */ + tqe = p->txq_head; + + /*Added by Amr - BugID_4720*/ + p->os_func.os_spin_unlock(p->txq_spinlock, &flags); + + /* p->os_func.os_leave_cs(p->txq_lock); */ + + return tqe; +} + +static struct txq_entry_t *wilc_wlan_txq_get_next(struct txq_entry_t *tqe) +{ + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + unsigned long flags; + /*Added by Amr - BugID_4720*/ + p->os_func.os_spin_lock(p->txq_spinlock, &flags); + + /* p->os_func.os_enter_cs(p->txq_lock); */ + tqe = tqe->next; + + /*Added by Amr - BugID_4720*/ + p->os_func.os_spin_unlock(p->txq_spinlock, &flags); + + /* p->os_func.os_leave_cs(p->txq_lock); */ + + return tqe; +} + +static int wilc_wlan_rxq_add(struct rxq_entry_t *rqe) +{ + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + + if (p->quit) + return 0; + + p->os_func.os_enter_cs(p->rxq_lock); + if (p->rxq_head == NULL) { + PRINT_D(RX_DBG, "Add to Queue head\n"); + rqe->next = NULL; + p->rxq_head = rqe; + p->rxq_tail = rqe; + } else { + PRINT_D(RX_DBG, "Add to Queue tail\n"); + p->rxq_tail->next = rqe; + rqe->next = NULL; + p->rxq_tail = rqe; + } + p->rxq_entries += 1; + PRINT_D(RX_DBG, "Number of queue entries: %d\n", p->rxq_entries); + p->os_func.os_leave_cs(p->rxq_lock); + return p->rxq_entries; +} + +static struct rxq_entry_t *wilc_wlan_rxq_remove(void) +{ + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + + PRINT_D(RX_DBG, "Getting rxQ element\n"); + if (p->rxq_head) { + struct rxq_entry_t *rqe; + + p->os_func.os_enter_cs(p->rxq_lock); + rqe = p->rxq_head; + p->rxq_head = p->rxq_head->next; + p->rxq_entries -= 1; + PRINT_D(RX_DBG, "RXQ entries decreased\n"); + p->os_func.os_leave_cs(p->rxq_lock); + return rqe; + } + PRINT_D(RX_DBG, "Nothing to get from Q\n"); + return NULL; +} + + +/******************************************** + * + * Power Save handle functions + * + ********************************************/ + + + +#ifdef WILC_OPTIMIZE_SLEEP_INT + +INLINE void chip_allow_sleep(void) +{ + uint32_t reg = 0; + + /* Clear bit 1 */ + g_wlan.hif_func.hif_read_reg(0xf0, ®); + + g_wlan.hif_func.hif_write_reg(0xf0, reg & ~(1 << 0)); +} + +INLINE void chip_wakeup(void) +{ + uint32_t reg, clk_status_reg, trials = 0; + uint32_t sleep_time; + + if ((g_wlan.io_func.io_type & 0x1) == HIF_SPI) { + do { + g_wlan.hif_func.hif_read_reg(1, ®); + /* Set bit 1 */ + g_wlan.hif_func.hif_write_reg(1, reg | (1 << 1)); + + /* Clear bit 1*/ + g_wlan.hif_func.hif_write_reg(1, reg & ~(1 << 1)); + + do { + /* Wait for the chip to stabilize*/ + WILC_Sleep(2); + /* Make sure chip is awake. This is an extra step that can be removed */ + /* later to avoid the bus access overhead */ + if ((wilc_get_chipid(WILC_TRUE) == 0)) { + wilc_debug(N_ERR, "Couldn't read chip id. Wake up failed\n"); + } + } while ((wilc_get_chipid(WILC_TRUE) == 0) && ((++trials % 3) == 0)); + + } while (wilc_get_chipid(WILC_TRUE) == 0); + } else if ((g_wlan.io_func.io_type & 0x1) == HIF_SDIO) { + g_wlan.hif_func.hif_read_reg(0xf0, ®); + do { + /* Set bit 1 */ + g_wlan.hif_func.hif_write_reg(0xf0, reg | (1 << 0)); + + /* Check the clock status */ + g_wlan.hif_func.hif_read_reg(0xf1, &clk_status_reg); + + /* in case of clocks off, wait 2ms, and check it again. */ + /* if still off, wait for another 2ms, for a total wait of 6ms. */ + /* If still off, redo the wake up sequence */ + while (((clk_status_reg & 0x1) == 0) && (((++trials) % 3) == 0)) { + /* Wait for the chip to stabilize*/ + WILC_Sleep(2); + + /* Make sure chip is awake. This is an extra step that can be removed */ + /* later to avoid the bus access overhead */ + g_wlan.hif_func.hif_read_reg(0xf1, &clk_status_reg); + + if ((clk_status_reg & 0x1) == 0) { + wilc_debug(N_ERR, "clocks still OFF. Wake up failed\n"); + } + } + /* in case of failure, Reset the wakeup bit to introduce a new edge on the next loop */ + if ((clk_status_reg & 0x1) == 0) { + /* Reset bit 0 */ + g_wlan.hif_func.hif_write_reg(0xf0, reg & (~(1 << 0))); + } + } while ((clk_status_reg & 0x1) == 0); + } + + + if (genuChipPSstate == CHIP_SLEEPING_MANUAL) { + g_wlan.hif_func.hif_read_reg(0x1C0C, ®); + reg &= ~(1 << 0); + g_wlan.hif_func.hif_write_reg(0x1C0C, reg); + + if (wilc_get_chipid(WILC_FALSE) >= 0x1002b0) { + /* Enable PALDO back right after wakeup */ + uint32_t val32; + g_wlan.hif_func.hif_read_reg(0x1e1c, &val32); + val32 |= (1 << 6); + g_wlan.hif_func.hif_write_reg(0x1e1c, val32); + + g_wlan.hif_func.hif_read_reg(0x1e9c, &val32); + val32 |= (1 << 6); + g_wlan.hif_func.hif_write_reg(0x1e9c, val32); + } + } + genuChipPSstate = CHIP_WAKEDUP; +} +#else +INLINE void chip_wakeup(void) +{ + uint32_t reg, trials = 0; + do { + if ((g_wlan.io_func.io_type & 0x1) == HIF_SPI) { + g_wlan.hif_func.hif_read_reg(1, ®); + /* Make sure bit 1 is 0 before we start. */ + g_wlan.hif_func.hif_write_reg(1, reg & ~(1 << 1)); + /* Set bit 1 */ + g_wlan.hif_func.hif_write_reg(1, reg | (1 << 1)); + /* Clear bit 1*/ + g_wlan.hif_func.hif_write_reg(1, reg & ~(1 << 1)); + } else if ((g_wlan.io_func.io_type & 0x1) == HIF_SDIO) { + /* Make sure bit 0 is 0 before we start. */ + g_wlan.hif_func.hif_read_reg(0xf0, ®); + g_wlan.hif_func.hif_write_reg(0xf0, reg & ~(1 << 0)); + /* Set bit 1 */ + g_wlan.hif_func.hif_write_reg(0xf0, reg | (1 << 0)); + /* Clear bit 1 */ + g_wlan.hif_func.hif_write_reg(0xf0, reg & ~(1 << 0)); + } + + do { + /* Wait for the chip to stabilize*/ +/* WILC_Sleep(2); */ + mdelay(3); + + /* Make sure chip is awake. This is an extra step that can be removed */ + /* later to avoid the bus access overhead */ + if ((wilc_get_chipid(WILC_TRUE) == 0)) { + wilc_debug(N_ERR, "Couldn't read chip id. Wake up failed\n"); + } + } while ((wilc_get_chipid(WILC_TRUE) == 0) && ((++trials % 3) == 0)); + + } while (wilc_get_chipid(WILC_TRUE) == 0); + + if (genuChipPSstate == CHIP_SLEEPING_MANUAL) { + g_wlan.hif_func.hif_read_reg(0x1C0C, ®); + reg &= ~(1 << 0); + g_wlan.hif_func.hif_write_reg(0x1C0C, reg); + + if (wilc_get_chipid(WILC_FALSE) >= 0x1002b0) { + /* Enable PALDO back right after wakeup */ + uint32_t val32; + g_wlan.hif_func.hif_read_reg(0x1e1c, &val32); + val32 |= (1 << 6); + g_wlan.hif_func.hif_write_reg(0x1e1c, val32); + + g_wlan.hif_func.hif_read_reg(0x1e9c, &val32); + val32 |= (1 << 6); + g_wlan.hif_func.hif_write_reg(0x1e9c, val32); + } + } + genuChipPSstate = CHIP_WAKEDUP; +} +#endif +void chip_sleep_manually(WILC_Uint32 u32SleepTime) +{ + uint32_t val32; + + if (genuChipPSstate != CHIP_WAKEDUP) { + /* chip is already sleeping. Do nothing */ + return; + } + acquire_bus(ACQUIRE_ONLY); + +#ifdef WILC_OPTIMIZE_SLEEP_INT + chip_allow_sleep(); +#endif + + /* Trigger the manual sleep interrupt */ + g_wlan.hif_func.hif_write_reg(0x10a8, 1); + + genuChipPSstate = CHIP_SLEEPING_MANUAL; + release_bus(RELEASE_ONLY); + +} + + +/******************************************** + * + * Tx, Rx queue handle functions + * + ********************************************/ +static int wilc_wlan_handle_txq(uint32_t *pu32TxqCount) +{ + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + int i, entries = 0; + uint32_t sum; + uint32_t reg; + uint8_t *txb = p->tx_buffer; + uint32_t offset = 0; + int vmm_sz = 0; + struct txq_entry_t *tqe; + int ret = 0; + int counter; + int timeout; + uint32_t vmm_table[WILC_VMM_TBL_SIZE]; + p->txq_exit = 0; + do { + if (p->quit) + break; + + /*Added by Amr - BugID_4720*/ + p->os_func.os_wait(p->txq_add_to_head_lock, CFG_PKTS_TIMEOUT); +#ifdef TCP_ACK_FILTER + wilc_wlan_txq_filter_dup_tcp_ack(); +#endif + /** + * build the vmm list + **/ + PRINT_D(TX_DBG, "Getting the head of the TxQ\n"); + tqe = wilc_wlan_txq_get_first(); + i = 0; + sum = 0; + do { + /* if ((tqe != NULL) && (i < (8)) && */ + /* if ((tqe != NULL) && (i < (WILC_VMM_TBL_SIZE-1)) && */ + if ((tqe != NULL) && (i < (WILC_VMM_TBL_SIZE - 1)) /* reserve last entry to 0 */) { + + if (tqe->type == WILC_CFG_PKT) { + vmm_sz = ETH_CONFIG_PKT_HDR_OFFSET; + } + /*Bug3959: transmitting mgmt frames received from host*/ + /*vmm_sz will only be equal to tqe->buffer_size + 4 bytes (HOST_HDR_OFFSET)*/ + /* in other cases WILC_MGMT_PKT and WILC_DATA_PKT_MAC_HDR*/ + else if (tqe->type == WILC_NET_PKT) { + vmm_sz = ETH_ETHERNET_HDR_OFFSET; + } +#ifdef WILC_FULLY_HOSTING_AP + else if (tqe->type == WILC_FH_DATA_PKT) { + vmm_sz = FH_TX_HOST_HDR_OFFSET; + } +#endif +#ifdef WILC_AP_EXTERNAL_MLME + else { + vmm_sz = HOST_HDR_OFFSET; + } +#endif + vmm_sz += tqe->buffer_size; + PRINT_D(TX_DBG, "VMM Size before alignment = %d\n", vmm_sz); + if (vmm_sz & 0x3) { /* has to be word aligned */ + vmm_sz = (vmm_sz + 4) & ~0x3; + } + if ((sum + vmm_sz) > p->tx_buffer_size) { + break; + } + PRINT_D(TX_DBG, "VMM Size AFTER alignment = %d\n", vmm_sz); + vmm_table[i] = vmm_sz / 4; /* table take the word size */ + PRINT_D(TX_DBG, "VMMTable entry size = %d\n", vmm_table[i]); + + if (tqe->type == WILC_CFG_PKT) { + vmm_table[i] |= (1 << 10); + PRINT_D(TX_DBG, "VMMTable entry changed for CFG packet = %d\n", vmm_table[i]); + } +#ifdef BIG_ENDIAN + vmm_table[i] = BYTE_SWAP(vmm_table[i]); +#endif + /* p->hif_func.hif_write_reg(0x1160,vmm_table[0]); */ + + /* wilc_debug(N_TXQ, "[wilc txq]: vmm table[%d] = %08x\n", i, vmm_table[i]); */ + i++; + sum += vmm_sz; + PRINT_D(TX_DBG, "sum = %d\n", sum); + tqe = wilc_wlan_txq_get_next(tqe); + } else { + break; + } + } while (1); + + if (i == 0) { /* nothing in the queue */ + PRINT_D(TX_DBG, "Nothing in TX-Q\n"); + break; + } else { + PRINT_D(TX_DBG, "Mark the last entry in VMM table - number of previous entries = %d\n", i); + vmm_table[i] = 0x0; /* mark the last element to 0 */ + } + acquire_bus(ACQUIRE_AND_WAKEUP); + counter = 0; + do { + + ret = p->hif_func.hif_read_reg(WILC_HOST_TX_CTRL, ®); + if (!ret) { + wilc_debug(N_ERR, "[wilc txq]: fail can't read reg vmm_tbl_entry..\n"); + break; + } + + if ((reg & 0x1) == 0) { + /** + * write to vmm table + **/ + PRINT_D(TX_DBG, "Writing VMM table ... with Size = %d\n", ((i + 1) * 4)); + break; + } else { + counter++; + if (counter > 200) { + counter = 0; + PRINT_D(TX_DBG, "Looping in tx ctrl , forcce quit\n"); + ret = p->hif_func.hif_write_reg(WILC_HOST_TX_CTRL, 0); + break; + } + /** + * wait for vmm table is ready + **/ + PRINT_WRN(GENERIC_DBG, "[wilc txq]: warn, vmm table not clear yet, wait... \n"); + release_bus(RELEASE_ALLOW_SLEEP); + p->os_func.os_sleep(3); /* wait 3 ms */ + acquire_bus(ACQUIRE_AND_WAKEUP); + } + } while (!p->quit); + + if (!ret) { + goto _end_; + } + + timeout = 200; + do { + + /** + * write to vmm table + **/ + ret = p->hif_func.hif_block_tx(WILC_VMM_TBL_RX_SHADOW_BASE, (uint8_t *)vmm_table, ((i + 1) * 4)); /* Bug 4477 fix */ + if (!ret) { + wilc_debug(N_ERR, "ERR block TX of VMM table.\n"); + break; + } + + + /** + * interrupt firmware + **/ + ret = p->hif_func.hif_write_reg(WILC_HOST_VMM_CTL, 0x2); + if (!ret) { + wilc_debug(N_ERR, "[wilc txq]: fail can't write reg host_vmm_ctl..\n"); + break; + } + + /** + * wait for confirm... + **/ + + do { + ret = p->hif_func.hif_read_reg(WILC_HOST_VMM_CTL, ®); + if (!ret) { + wilc_debug(N_ERR, "[wilc txq]: fail can't read reg host_vmm_ctl..\n"); + break; + } + if ((reg >> 2) & 0x1) { + /** + * Get the entries + **/ + entries = ((reg >> 3) & 0x3f); + /* entries = ((reg>>3)&0x2f); */ + break; + } else { + release_bus(RELEASE_ALLOW_SLEEP); + p->os_func.os_sleep(3); /* wait 3 ms */ + acquire_bus(ACQUIRE_AND_WAKEUP); + PRINT_WRN(GENERIC_DBG, "Can't get VMM entery - reg = %2x\n", reg); + } + } while (--timeout); + if (timeout <= 0) { + ret = p->hif_func.hif_write_reg(WILC_HOST_VMM_CTL, 0x0); + break; + } + + if (!ret) { + break; + } + + if (entries == 0) { + PRINT_WRN(GENERIC_DBG, "[wilc txq]: no more buffer in the chip (reg: %08x), retry later [[ %d, %x ]] \n", reg, i, vmm_table[i - 1]); + + /* undo the transaction. */ + ret = p->hif_func.hif_read_reg(WILC_HOST_TX_CTRL, ®); + if (!ret) { + wilc_debug(N_ERR, "[wilc txq]: fail can't read reg WILC_HOST_TX_CTRL..\n"); + break; + } + reg &= ~(1ul << 0); + ret = p->hif_func.hif_write_reg(WILC_HOST_TX_CTRL, reg); + if (!ret) { + wilc_debug(N_ERR, "[wilc txq]: fail can't write reg WILC_HOST_TX_CTRL..\n"); + break; + } + break; + } else { + break; + } + } while (1); + + if (!ret) { + goto _end_; + } + if (entries == 0) { + ret = WILC_TX_ERR_NO_BUF; + goto _end_; + } + + /* since copying data into txb takes some time, then + * allow the bus lock to be released let the RX task go. */ + release_bus(RELEASE_ALLOW_SLEEP); + + /** + * Copy data to the TX buffer + **/ + offset = 0; + i = 0; + do { + tqe = wilc_wlan_txq_remove_from_head(); + if (tqe != NULL && (vmm_table[i] != 0)) { + uint32_t header, buffer_offset; + +#ifdef BIG_ENDIAN + vmm_table[i] = BYTE_SWAP(vmm_table[i]); +#endif + vmm_sz = (vmm_table[i] & 0x3ff); /* in word unit */ + vmm_sz *= 4; + header = (tqe->type << 31) | (tqe->buffer_size << 15) | vmm_sz; + /*Bug3959: transmitting mgmt frames received from host*/ + /*setting bit 30 in the host header to indicate mgmt frame*/ +#ifdef WILC_AP_EXTERNAL_MLME + if (tqe->type == WILC_MGMT_PKT) { + header |= (1 << 30); + } else { + header &= ~(1 << 30); + } +#endif + /*else if(tqe->type == WILC_DATA_PKT_MAC_HDR) + * { + * header |= (1<< 29); + * }*/ + /* wilc_debug(N_TXQ, "[wilc txq]: header (%08x), real size (%d), vmm size (%d)\n", header, tqe->buffer_size, vmm_sz); */ + +#ifdef BIG_ENDIAN + header = BYTE_SWAP(header); +#endif + memcpy(&txb[offset], &header, 4); + if (tqe->type == WILC_CFG_PKT) { + buffer_offset = ETH_CONFIG_PKT_HDR_OFFSET; + } + /*Bug3959: transmitting mgmt frames received from host*/ + /*buffer offset = HOST_HDR_OFFSET in other cases: WILC_MGMT_PKT*/ + /* and WILC_DATA_PKT_MAC_HDR*/ + else if (tqe->type == WILC_NET_PKT) { + char *pBSSID = ((struct tx_complete_data *)(tqe->priv))->pBssid; + buffer_offset = ETH_ETHERNET_HDR_OFFSET; + /* copy the bssid at the sart of the buffer */ + memcpy(&txb[offset + 4], pBSSID, 6); + } +#ifdef WILC_FULLY_HOSTING_AP + else if (tqe->type == WILC_FH_DATA_PKT) { + buffer_offset = FH_TX_HOST_HDR_OFFSET; + } +#endif + else { + buffer_offset = HOST_HDR_OFFSET; + } + + memcpy(&txb[offset + buffer_offset], tqe->buffer, tqe->buffer_size); + offset += vmm_sz; + i++; + tqe->status = 1; /* mark the packet send */ + if (tqe->tx_complete_func) + tqe->tx_complete_func(tqe->priv, tqe->status); + #ifdef TCP_ACK_FILTER + if (tqe->tcp_PendingAck_index != NOT_TCP_ACK) { + Pending_Acks_info[tqe->tcp_PendingAck_index].txqe = NULL; + } + #endif + p->os_func.os_free(tqe); + } else { + break; + } + } while (--entries); + + /** + * lock the bus + **/ + acquire_bus(ACQUIRE_AND_WAKEUP); + + ret = p->hif_func.hif_clear_int_ext(ENABLE_TX_VMM); + if (!ret) { + wilc_debug(N_ERR, "[wilc txq]: fail can't start tx VMM ...\n"); + goto _end_; + } + + /** + * transfer + **/ + ret = p->hif_func.hif_block_tx_ext(0, txb, offset); + if (!ret) { + wilc_debug(N_ERR, "[wilc txq]: fail can't block tx ext...\n"); + goto _end_; + } + +_end_: + + release_bus(RELEASE_ALLOW_SLEEP); + if (ret != 1) + break; + } while (0); + /* remove_TCP_related(); */ + /*Added by Amr - BugID_4720*/ + p->os_func.os_signal(p->txq_add_to_head_lock); + + p->txq_exit = 1; + PRINT_D(TX_DBG, "THREAD: Exiting txq\n"); + /* return tx[]q count */ + *pu32TxqCount = p->txq_entries; + return ret; +} + +static void wilc_wlan_handle_rxq(void) +{ + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + int offset = 0, size, has_packet = 0; + uint8_t *buffer; + struct rxq_entry_t *rqe; + + p->rxq_exit = 0; + + + + + do { + if (p->quit) { + PRINT_D(RX_DBG, "exit 1st do-while due to Clean_UP function \n"); + p->os_func.os_signal(p->cfg_wait); + break; + } + rqe = wilc_wlan_rxq_remove(); + if (rqe == NULL) { + PRINT_D(RX_DBG, "nothing in the queue - exit 1st do-while\n"); + break; + } + buffer = rqe->buffer; + size = rqe->buffer_size; + PRINT_D(RX_DBG, "rxQ entery Size = %d - Address = %p\n", size, buffer); + offset = 0; + + + + do { + uint32_t header; + uint32_t pkt_len, pkt_offset, tp_len; + int is_cfg_packet; + PRINT_D(RX_DBG, "In the 2nd do-while\n"); + memcpy(&header, &buffer[offset], 4); +#ifdef BIG_ENDIAN + header = BYTE_SWAP(header); +#endif + PRINT_D(RX_DBG, "Header = %04x - Offset = %d\n", header, offset); + + + + is_cfg_packet = (header >> 31) & 0x1; + pkt_offset = (header >> 22) & 0x1ff; + tp_len = (header >> 11) & 0x7ff; + pkt_len = header & 0x7ff; + + if (pkt_len == 0 || tp_len == 0) { + wilc_debug(N_RXQ, "[wilc rxq]: data corrupt, packet len or tp_len is 0 [%d][%d]\n", pkt_len, tp_len); + break; + } + +/*bug 3887: [AP] Allow Management frames to be passed to the host*/ + #if defined(WILC_AP_EXTERNAL_MLME) || defined(WILC_P2P) + #define IS_MANAGMEMENT 0x100 + #define IS_MANAGMEMENT_CALLBACK 0x080 + #define IS_MGMT_STATUS_SUCCES 0x040 + + + if (pkt_offset & IS_MANAGMEMENT) { + /* reset mgmt indicator bit, to use pkt_offeset in furthur calculations */ + pkt_offset &= ~(IS_MANAGMEMENT | IS_MANAGMEMENT_CALLBACK | IS_MGMT_STATUS_SUCCES); + +#ifdef USE_WIRELESS + WILC_WFI_mgmt_rx(&buffer[offset + HOST_HDR_OFFSET], pkt_len); + +#endif + + } + /* BUG4530 fix */ + else + #endif + { + /* wilc_debug(N_RXQ, "[wilc rxq]: packet, tp len(%d), len (%d), offset (%d), cfg (%d)\n", tp_len, pkt_len, pkt_offset, is_cfg_packet); */ + + if (!is_cfg_packet) { + + if (p->net_func.rx_indicate) { + if (pkt_len > 0) { + p->net_func.rx_indicate(&buffer[offset], pkt_len, pkt_offset); + has_packet = 1; + } + } + } else { + wilc_cfg_rsp_t rsp; + + + + p->cif_func.rx_indicate(&buffer[pkt_offset + offset], pkt_len, &rsp); + if (rsp.type == WILC_CFG_RSP) { + /** + * wake up the waiting task... + **/ + PRINT_D(RX_DBG, "p->cfg_seq_no = %d - rsp.seq_no = %d\n", p->cfg_seq_no, rsp.seq_no); + if (p->cfg_seq_no == rsp.seq_no) { + p->os_func.os_signal(p->cfg_wait); + } + /* p->os_func.os_signal(p->cfg_wait); */ + } else if (rsp.type == WILC_CFG_RSP_STATUS) { + /** + * Call back to indicate status... + **/ + if (p->indicate_func.mac_indicate) { + p->indicate_func.mac_indicate(WILC_MAC_INDICATE_STATUS); + } + + } else if (rsp.type == WILC_CFG_RSP_SCAN) { + if (p->indicate_func.mac_indicate) + p->indicate_func.mac_indicate(WILC_MAC_INDICATE_SCAN); + } + } + } + offset += tp_len; + if (offset >= size) + break; + } while (1); + + +#ifndef MEMORY_STATIC + if (buffer != NULL) + p->os_func.os_free((void *)buffer); +#endif + if (rqe != NULL) + p->os_func.os_free((void *)rqe); + + if (has_packet) { + if (p->net_func.rx_complete) + p->net_func.rx_complete(); + } + } while (1); + + p->rxq_exit = 1; + PRINT_D(RX_DBG, "THREAD: Exiting RX thread \n"); + return; +} + +/******************************************** + * + * Fast DMA Isr + * + ********************************************/ +static void wilc_unknown_isr_ext(void) +{ + g_wlan.hif_func.hif_clear_int_ext(0); +} +static void wilc_pllupdate_isr_ext(uint32_t int_stats) +{ + + int trials = 10; + + g_wlan.hif_func.hif_clear_int_ext(PLL_INT_CLR); + + /* Waiting for PLL */ + g_wlan.os_func.os_atomic_sleep(WILC_PLL_TO); + + /* poll till read a valid data */ + while (!(ISWILC1000(wilc_get_chipid(WILC_TRUE)) && --trials)) { + PRINT_D(TX_DBG, "PLL update retrying\n"); + g_wlan.os_func.os_atomic_sleep(1); + } +} + +static void wilc_sleeptimer_isr_ext(uint32_t int_stats1) +{ + g_wlan.hif_func.hif_clear_int_ext(SLEEP_INT_CLR); +#ifndef WILC_OPTIMIZE_SLEEP_INT + genuChipPSstate = CHIP_SLEEPING_AUTO; +#endif +} + +static void wilc_wlan_handle_isr_ext(uint32_t int_status) +{ + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; +#ifdef MEMORY_STATIC + uint32_t offset = p->rx_buffer_offset; +#endif + uint8_t *buffer = NULL; + uint32_t size; + uint32_t retries = 0; + int ret = 0; + struct rxq_entry_t *rqe; + + + /** + * Get the rx size + **/ + + size = ((int_status & 0x7fff) << 2); + + while (!size && retries < 10) { + uint32_t time = 0; + /*looping more secure*/ + /*zero size make a crashe because the dma will not happen and that will block the firmware*/ + wilc_debug(N_ERR, "RX Size equal zero ... Trying to read it again for %d time\n", time++); + p->hif_func.hif_read_size(&size); + size = ((size & 0x7fff) << 2); + retries++; + + } + + if (size > 0) { +#ifdef MEMORY_STATIC + if (p->rx_buffer_size - offset < size) + offset = 0; + + if (p->rx_buffer) + buffer = &p->rx_buffer[offset]; + else { + wilc_debug(N_ERR, "[wilc isr]: fail Rx Buffer is NULL...drop the packets (%d)\n", size); + goto _end_; + } + +#else + buffer = p->os_func.os_malloc(size); + if (buffer == NULL) { + wilc_debug(N_ERR, "[wilc isr]: fail alloc host memory...drop the packets (%d)\n", size); + WILC_Sleep(100); + goto _end_; + } +#endif + + /** + * clear the chip's interrupt after getting size some register getting corrupted after clear the interrupt + **/ + p->hif_func.hif_clear_int_ext(DATA_INT_CLR | ENABLE_RX_VMM); + + + /** + * start transfer + **/ + ret = p->hif_func.hif_block_rx_ext(0, buffer, size); + + if (!ret) { + wilc_debug(N_ERR, "[wilc isr]: fail block rx...\n"); + goto _end_; + } +_end_: + + + if (ret) { +#ifdef MEMORY_STATIC + offset += size; + p->rx_buffer_offset = offset; +#endif + /** + * add to rx queue + **/ + rqe = (struct rxq_entry_t *)p->os_func.os_malloc(sizeof(struct rxq_entry_t)); + if (rqe != NULL) { + rqe->buffer = buffer; + rqe->buffer_size = size; + PRINT_D(RX_DBG, "rxq entery Size= %d - Address = %p\n", rqe->buffer_size, rqe->buffer); + wilc_wlan_rxq_add(rqe); + p->os_func.os_signal(p->rxq_wait); + } + } else { +#ifndef MEMORY_STATIC + if (buffer != NULL) + p->os_func.os_free(buffer); +#endif + } + } +#ifdef TCP_ENHANCEMENTS + wilc_wlan_handle_rxq(); +#endif +} + +void wilc_handle_isr(void) +{ + uint32_t int_status; + + acquire_bus(ACQUIRE_AND_WAKEUP); + g_wlan.hif_func.hif_read_int(&int_status); + + if (int_status & PLL_INT_EXT) { + wilc_pllupdate_isr_ext(int_status); + } + if (int_status & DATA_INT_EXT) { + wilc_wlan_handle_isr_ext(int_status); + #ifndef WILC_OPTIMIZE_SLEEP_INT + /* Chip is up and talking*/ + genuChipPSstate = CHIP_WAKEDUP; + #endif + } + if (int_status & SLEEP_INT_EXT) { + wilc_sleeptimer_isr_ext(int_status); + } + + if (!(int_status & (ALL_INT_EXT))) { +#ifdef WILC_SDIO + PRINT_D(TX_DBG, ">> UNKNOWN_INTERRUPT - 0x%08x\n", int_status); +#endif + wilc_unknown_isr_ext(); + } +#if ((!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO)) + linux_wlan_enable_irq(); +#endif + release_bus(RELEASE_ALLOW_SLEEP); +} + +/******************************************** + * + * Firmware download + * + ********************************************/ +static int wilc_wlan_firmware_download(const uint8_t *buffer, uint32_t buffer_size) +{ + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + uint32_t offset; + uint32_t addr, size, size2, blksz; + uint8_t *dma_buffer; + int ret = 0; + + blksz = (1ul << 12); /* Bug 4703: 4KB Good enough size for most platforms = PAGE_SIZE. */ + /* Allocate a DMA coherent buffer. */ + +#if (defined WILC_PREALLOC_AT_BOOT) + { + extern void *get_fw_buffer(void); + dma_buffer = (uint8_t *)get_fw_buffer(); + PRINT_D(TX_DBG, "fw_buffer = 0x%x\n", dma_buffer); + } +#else + dma_buffer = (uint8_t *)g_wlan.os_func.os_malloc(blksz); +#endif + if (dma_buffer == NULL) { + /*EIO 5*/ + ret = -5; + PRINT_ER("Can't allocate buffer for firmware download IO error\n "); + goto _fail_1; + } + + PRINT_D(INIT_DBG, "Downloading firmware size = %d ...\n", buffer_size); + /** + * load the firmware + **/ + offset = 0; + do { + memcpy(&addr, &buffer[offset], 4); + memcpy(&size, &buffer[offset + 4], 4); +#ifdef BIG_ENDIAN + addr = BYTE_SWAP(addr); + size = BYTE_SWAP(size); +#endif + acquire_bus(ACQUIRE_ONLY); + offset += 8; + while (((int)size) && (offset < buffer_size)) { + if (size <= blksz) { + size2 = size; + } else { + size2 = blksz; + } + /* Copy firmware into a DMA coherent buffer */ + memcpy(dma_buffer, &buffer[offset], size2); + ret = p->hif_func.hif_block_tx(addr, dma_buffer, size2); + if (!ret) + break; + + addr += size2; + offset += size2; + size -= size2; + } + release_bus(RELEASE_ONLY); + + if (!ret) { + /*EIO 5*/ + ret = -5; + PRINT_ER("Can't download firmware IO error\n "); + goto _fail_; + } + PRINT_D(INIT_DBG, "Offset = %d\n", offset); + } while (offset < buffer_size); + +_fail_: + +#if (defined WILC_PREALLOC_AT_BOOT) + +#else + if (dma_buffer) + g_wlan.os_func.os_free(dma_buffer); +#endif + +_fail_1: + + return (ret < 0) ? ret : 0; +} + +/******************************************** + * + * Common + * + ********************************************/ +static int wilc_wlan_start(void) +{ + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + uint32_t reg = 0; + int ret; + uint32_t chipid; + + /** + * Set the host interface + **/ +#ifdef OLD_FPGA_BITFILE + acquire_bus(ACQUIRE_ONLY); + ret = p->hif_func.hif_read_reg(WILC_VMM_CORE_CTL, ®); + if (!ret) { + wilc_debug(N_ERR, "[wilc start]: fail read reg vmm_core_ctl...\n"); + release_bus(RELEASE_ALLOW_SLEEP); + return ret; + } + reg |= (p->io_func.io_type << 2); + ret = p->hif_func.hif_write_reg(WILC_VMM_CORE_CTL, reg); + if (!ret) { + wilc_debug(N_ERR, "[wilc start]: fail write reg vmm_core_ctl...\n"); + release_bus(RELEASE_ONLY); + return ret; + } +#else + if (p->io_func.io_type == HIF_SDIO) { + reg = 0; + reg |= (1 << 3); /* bug 4456 and 4557 */ + } else if (p->io_func.io_type == HIF_SPI) { + reg = 1; + } + acquire_bus(ACQUIRE_ONLY); + ret = p->hif_func.hif_write_reg(WILC_VMM_CORE_CFG, reg); + if (!ret) { + wilc_debug(N_ERR, "[wilc start]: fail write reg vmm_core_cfg...\n"); + release_bus(RELEASE_ONLY); + /* EIO 5*/ + ret = -5; + return ret; + } + reg = 0; +#ifdef WILC_SDIO_IRQ_GPIO + reg |= WILC_HAVE_SDIO_IRQ_GPIO; +#endif + +#ifdef WILC_DISABLE_PMU +#else + reg |= WILC_HAVE_USE_PMU; +#endif + +#ifdef WILC_SLEEP_CLK_SRC_XO + reg |= WILC_HAVE_SLEEP_CLK_SRC_XO; +#elif defined WILC_SLEEP_CLK_SRC_RTC + reg |= WILC_HAVE_SLEEP_CLK_SRC_RTC; +#endif + +#ifdef WILC_EXT_PA_INV_TX_RX + reg |= WILC_HAVE_EXT_PA_INV_TX_RX; +#endif + + reg |= WILC_HAVE_LEGACY_RF_SETTINGS; + + +/*BugID_5257*/ +/*Set oscillator frequency*/ +#ifdef XTAL_24 + reg |= WILC_HAVE_XTAL_24; +#endif + +/*BugID_5271*/ +/*Enable/Disable GPIO configuration for FW logs*/ +#ifdef DISABLE_WILC_UART + reg |= WILC_HAVE_DISABLE_WILC_UART; +#endif + + ret = p->hif_func.hif_write_reg(WILC_GP_REG_1, reg); + if (!ret) { + wilc_debug(N_ERR, "[wilc start]: fail write WILC_GP_REG_1 ...\n"); + release_bus(RELEASE_ONLY); + /* EIO 5*/ + ret = -5; + return ret; + } +#endif + + + /** + * Bus related + **/ + p->hif_func.hif_sync_ext(NUM_INT_EXT); + + ret = p->hif_func.hif_read_reg(0x1000, &chipid); + if (!ret) { + wilc_debug(N_ERR, "[wilc start]: fail read reg 0x1000 ...\n"); + release_bus(RELEASE_ONLY); + /* EIO 5*/ + ret = -5; + return ret; + } + + /** + * Go... + **/ + + /* p->hif_func.hif_write_reg(0x150014, reg); */ + + p->hif_func.hif_read_reg(WILC_GLB_RESET_0, ®); + if ((reg & (1ul << 10)) == (1ul << 10)) { + reg &= ~(1ul << 10); + p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg); + p->hif_func.hif_read_reg(WILC_GLB_RESET_0, ®); + } + + reg |= (1ul << 10); + ret = p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg); + p->hif_func.hif_read_reg(WILC_GLB_RESET_0, ®); + release_bus(RELEASE_ONLY); + + return (ret < 0) ? ret : 0; +} + +void wilc_wlan_global_reset(void) +{ + + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + acquire_bus(ACQUIRE_AND_WAKEUP); + p->hif_func.hif_write_reg(WILC_GLB_RESET_0, 0x0); + release_bus(RELEASE_ONLY); +} +static int wilc_wlan_stop(void) +{ + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + uint32_t reg = 0; + int ret; + uint8_t timeout = 10; + /** + * TODO: stop the firmware, need a re-download + **/ + acquire_bus(ACQUIRE_AND_WAKEUP); + + ret = p->hif_func.hif_read_reg(WILC_GLB_RESET_0, ®); + if (!ret) { + PRINT_ER("Error while reading reg\n"); + release_bus(RELEASE_ALLOW_SLEEP); + return ret; + } + + reg &= ~(1 << 10); + + + ret = p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg); + if (!ret) { + PRINT_ER("Error while writing reg\n"); + release_bus(RELEASE_ALLOW_SLEEP); + return ret; + } + + + + do { + ret = p->hif_func.hif_read_reg(WILC_GLB_RESET_0, ®); + if (!ret) { + PRINT_ER("Error while reading reg\n"); + release_bus(RELEASE_ALLOW_SLEEP); + return ret; + } + PRINT_D(GENERIC_DBG, "Read RESET Reg %x : Retry%d\n", reg, timeout); + /*Workaround to ensure that the chip is actually reset*/ + if ((reg & (1 << 10))) { + PRINT_D(GENERIC_DBG, "Bit 10 not reset : Retry %d\n", timeout); + reg &= ~(1 << 10); + ret = p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg); + timeout--; + } else { + PRINT_D(GENERIC_DBG, "Bit 10 reset after : Retry %d\n", timeout); + ret = p->hif_func.hif_read_reg(WILC_GLB_RESET_0, ®); + if (!ret) { + PRINT_ER("Error while reading reg\n"); + release_bus(RELEASE_ALLOW_SLEEP); + return ret; + } + PRINT_D(GENERIC_DBG, "Read RESET Reg %x : Retry%d\n", reg, timeout); + break; + } + + } while (timeout); +#if 1 +/******************************************************************************/ +/* This was add at Bug 4595 to reset the chip while maintaining the bus state */ +/******************************************************************************/ + reg = ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 8) | (1 << 9) | (1 << 26) | (1 << 29) | (1 << 30) | (1 << 31)); /**/ + /**/ + ret = p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg); /**/ + reg = ~(1 << 10); /**/ + /**/ + ret = p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg); /**/ +/******************************************************************************/ +#endif + + release_bus(RELEASE_ALLOW_SLEEP); + + return ret; +} + +static void wilc_wlan_cleanup(void) +{ + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + struct txq_entry_t *tqe; + struct rxq_entry_t *rqe; + uint32_t reg = 0; + int ret; + + p->quit = 1; + /** + * wait for queue end + **/ + /* p->os_func.os_signal(p->txq_wait); */ + /* p->os_func.os_signal(p->rxq_wait); */ + + /* complete(p->txq_wait); */ + /* complete(p->rxq_wait); */ + /*do { + * if (p->txq_exit && p->rxq_exit) + * break; + * } while (1);*/ + + /** + * clean up the queue + **/ + do { + tqe = wilc_wlan_txq_remove_from_head(); + if (tqe == NULL) + break; + if (tqe->tx_complete_func) + tqe->tx_complete_func(tqe->priv, 0); + p->os_func.os_free((void *)tqe); + } while (1); + + do { + rqe = wilc_wlan_rxq_remove(); + if (rqe == NULL) + break; +#ifdef MEMORY_DYNAMIC + p->os_func.os_free((void *)tqe->buffer); +#endif + p->os_func.os_free((void *)rqe); + } while (1); + + /** + * clean up buffer + **/ + +#if (defined WILC_PREALLOC_AT_BOOT) + +#else + #ifdef MEMORY_STATIC + if (p->rx_buffer) { + p->os_func.os_free(p->rx_buffer); + p->rx_buffer = WILC_NULL; + } + #endif + if (p->tx_buffer) { + p->os_func.os_free(p->tx_buffer); + p->tx_buffer = WILC_NULL; + } +#endif + + acquire_bus(ACQUIRE_AND_WAKEUP); + + + ret = p->hif_func.hif_read_reg(WILC_GP_REG_0, ®); + if (!ret) { + PRINT_ER("Error while reading reg\n"); + release_bus(RELEASE_ALLOW_SLEEP); + } + PRINT_ER("Writing ABORT reg\n"); + ret = p->hif_func.hif_write_reg(WILC_GP_REG_0, (reg | ABORT_INT)); + if (!ret) { + PRINT_ER("Error while writing reg\n"); + release_bus(RELEASE_ALLOW_SLEEP); + } + release_bus(RELEASE_ALLOW_SLEEP); + /** + * io clean up + **/ + p->hif_func.hif_deinit(NULL); + +} + +static int wilc_wlan_cfg_commit(int type, uint32_t drvHandler) +{ + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + wilc_cfg_frame_t *cfg = &p->cfg_frame; + int total_len = p->cfg_frame_offset + 4 + DRIVER_HANDLER_SIZE; + int seq_no = p->cfg_seq_no % 256; + int driver_handler = (WILC_Uint32)drvHandler; + + + /** + * Set up header + **/ + if (type == WILC_CFG_SET) { /* Set */ + cfg->wid_header[0] = 'W'; + } else { /* Query */ + cfg->wid_header[0] = 'Q'; + } + cfg->wid_header[1] = seq_no; /* sequence number */ + cfg->wid_header[2] = (uint8_t)total_len; + cfg->wid_header[3] = (uint8_t)(total_len >> 8); + cfg->wid_header[4] = (uint8_t)driver_handler; + cfg->wid_header[5] = (uint8_t)(driver_handler >> 8); + cfg->wid_header[6] = (uint8_t)(driver_handler >> 16); + cfg->wid_header[7] = (uint8_t)(driver_handler >> 24); + p->cfg_seq_no = seq_no; + + /** + * Add to TX queue + **/ + + /*Edited by Amr - BugID_4720*/ + if (!wilc_wlan_txq_add_cfg_pkt(&cfg->wid_header[0], total_len)) + return -1; + + return 0; +} + +static int wilc_wlan_cfg_set(int start, uint32_t wid, uint8_t *buffer, uint32_t buffer_size, int commit, uint32_t drvHandler) +{ + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + uint32_t offset; + int ret_size; + + + if (p->cfg_frame_in_use) + return 0; + + if (start) + p->cfg_frame_offset = 0; + + offset = p->cfg_frame_offset; + ret_size = p->cif_func.cfg_wid_set(p->cfg_frame.frame, offset, (uint16_t)wid, buffer, buffer_size); + offset += ret_size; + p->cfg_frame_offset = offset; + + if (commit) { + PRINT_D(TX_DBG, "[WILC]PACKET Commit with sequence number %d\n", p->cfg_seq_no); + PRINT_D(RX_DBG, "Processing cfg_set()\n"); + p->cfg_frame_in_use = 1; + + /*Edited by Amr - BugID_4720*/ + if (wilc_wlan_cfg_commit(WILC_CFG_SET, drvHandler)) + ret_size = 0; /* BugID_5213 */ + + if (p->os_func.os_wait(p->cfg_wait, CFG_PKTS_TIMEOUT)) { + PRINT_D(TX_DBG, "Set Timed Out\n"); + ret_size = 0; + } + p->cfg_frame_in_use = 0; + p->cfg_frame_offset = 0; + p->cfg_seq_no += 1; + + } + + return ret_size; +} +static int wilc_wlan_cfg_get(int start, uint32_t wid, int commit, uint32_t drvHandler) +{ + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + uint32_t offset; + int ret_size; + + + if (p->cfg_frame_in_use) + return 0; + + if (start) + p->cfg_frame_offset = 0; + + offset = p->cfg_frame_offset; + ret_size = p->cif_func.cfg_wid_get(p->cfg_frame.frame, offset, (uint16_t)wid); + offset += ret_size; + p->cfg_frame_offset = offset; + + if (commit) { + p->cfg_frame_in_use = 1; + + /*Edited by Amr - BugID_4720*/ + if (wilc_wlan_cfg_commit(WILC_CFG_QUERY, drvHandler)) + ret_size = 0; /* BugID_5213 */ + + + if (p->os_func.os_wait(p->cfg_wait, CFG_PKTS_TIMEOUT)) { + PRINT_D(TX_DBG, "Get Timed Out\n"); + ret_size = 0; + } + PRINT_D(GENERIC_DBG, "[WILC]Get Response received\n"); + p->cfg_frame_in_use = 0; + p->cfg_frame_offset = 0; + p->cfg_seq_no += 1; + } + + return ret_size; +} + +static int wilc_wlan_cfg_get_val(uint32_t wid, uint8_t *buffer, uint32_t buffer_size) +{ + wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; + int ret; + + ret = p->cif_func.cfg_wid_get_val((uint16_t)wid, buffer, buffer_size); + + return ret; +} + +void wilc_bus_set_max_speed(void) +{ + + /* Increase bus speed to max possible. */ + g_wlan.hif_func.hif_set_max_bus_speed(); +} + +void wilc_bus_set_default_speed(void) +{ + + /* Restore bus speed to default. */ + g_wlan.hif_func.hif_set_default_bus_speed(); +} +uint32_t init_chip(void) +{ + uint32_t chipid; + uint32_t reg, ret = 0; + +#if defined(PLAT_RK3026_TCHIP) + acquire_bus(ACQUIRE_AND_WAKEUP); /* AMR : 0422 RK3026 Crash issue */ +#else + acquire_bus(ACQUIRE_ONLY); +#endif + + chipid = wilc_get_chipid(WILC_TRUE); + + + + if ((chipid & 0xfff) != 0xa0) { + /** + * Avoid booting from boot ROM. Make sure that Drive IRQN [SDIO platform] + * or SD_DAT3 [SPI platform] to ?1? + **/ + /* Set cortus reset register to register control. */ + ret = g_wlan.hif_func.hif_read_reg(0x1118, ®); + if (!ret) { + wilc_debug(N_ERR, "[wilc start]: fail read reg 0x1118 ...\n"); + return ret; + } + reg |= (1 << 0); + ret = g_wlan.hif_func.hif_write_reg(0x1118, reg); + if (!ret) { + wilc_debug(N_ERR, "[wilc start]: fail write reg 0x1118 ...\n"); + return ret; + } + /** + * Write branch intruction to IRAM (0x71 trap) at location 0xFFFF0000 + * (Cortus map) or C0000 (AHB map). + **/ + ret = g_wlan.hif_func.hif_write_reg(0xc0000, 0x71); + if (!ret) { + wilc_debug(N_ERR, "[wilc start]: fail write reg 0xc0000 ...\n"); + return ret; + } + } + + + #if 0 + if ((chipid & 0xfff) < 0xf0) { + /* Setting MUX to probe sleep signal on pin 6 of J216*/ + g_wlan.hif_func.hif_write_reg(0x1060, 0x1); + g_wlan.hif_func.hif_write_reg(0x1180, 0x33333333); + g_wlan.hif_func.hif_write_reg(0x1184, 0x33333333); + g_wlan.hif_func.hif_read_reg(0x1408, ®); + /* set MUX for GPIO_4 (pin 4) to cortus GPIO*/ + reg &= ~((0x7 << 16)); + g_wlan.hif_func.hif_write_reg(0x1408, (reg | (0x7 << 12))); + } else { + /* Enable test bus*/ + g_wlan.hif_func.hif_write_reg(0x1060, 0x1); + /* Rotate bus signals to get sleep signal on pin 6 like it was on previous chips*/ + g_wlan.hif_func.hif_write_reg(0x1188, 0x70); + /* Set output of pin 6 to test bus 0x1*/ + /* Set output of pin 9 to test bus 0x2*/ + g_wlan.hif_func.hif_write_reg(0x1180, 0x200100); + g_wlan.hif_func.hif_read_reg(0x1408, ®); + + /* set MUX for GPIO_4 (pin 4) to cortus GPIO*/ + reg &= ~((0x7 << 16)); + /* set MUX for GPIO_3 (pin 6) to test bus*/ + reg |= (0x7 << 12) | (0x7 << 24); + g_wlan.hif_func.hif_write_reg(0x1408, reg); + } + #endif + + + + release_bus(RELEASE_ONLY); + + return ret; + +} + +uint32_t wilc_get_chipid(uint8_t update) +{ + static uint32_t chipid; + /* SDIO can't read into global variables */ + /* Use this variable as a temp, then copy to the global */ + uint32_t tempchipid = 0; + uint32_t rfrevid; + + if (chipid == 0 || update != 0) { + g_wlan.hif_func.hif_read_reg(0x1000, &tempchipid); + g_wlan.hif_func.hif_read_reg(0x13f4, &rfrevid); + if (!ISWILC1000(tempchipid)) { + chipid = 0; + goto _fail_; + } + if (tempchipid == 0x1002a0) { + if (rfrevid == 0x1) { /* 1002A0 */ + } else { /* if (rfrevid == 0x2) */ /* 1002A1 */ + tempchipid = 0x1002a1; + } + } else if (tempchipid == 0x1002b0) { + if (rfrevid == 3) { /* 1002B0 */ + } else if (rfrevid == 4) { /* 1002B1 */ + tempchipid = 0x1002b1; + } else { /* if(rfrevid == 5) */ /* 1002B2 */ + tempchipid = 0x1002b2; + } + } else { + } + + chipid = tempchipid; + } +_fail_: + return chipid; +} + +#ifdef COMPLEMENT_BOOT +uint8_t core_11b_ready(void) +{ + uint32_t reg_val; + + acquire_bus(ACQUIRE_ONLY); + g_wlan.hif_func.hif_write_reg(0x16082c, 1); + g_wlan.hif_func.hif_write_reg(0x161600, 0x90); + g_wlan.hif_func.hif_read_reg(0x161600, ®_val); + release_bus(RELEASE_ONLY); + + if (reg_val == 0x90) + return 0; + else + return 1; +} +#endif + +int wilc_wlan_init(wilc_wlan_inp_t *inp, wilc_wlan_oup_t *oup) +{ + + int ret = 0; + + PRINT_D(INIT_DBG, "Initializing WILC_Wlan ...\n"); + + memset((void *)&g_wlan, 0, sizeof(wilc_wlan_dev_t)); + + /** + * store the input + **/ + memcpy((void *)&g_wlan.os_func, (void *)&inp->os_func, sizeof(wilc_wlan_os_func_t)); + memcpy((void *)&g_wlan.io_func, (void *)&inp->io_func, sizeof(wilc_wlan_io_func_t)); + memcpy((void *)&g_wlan.net_func, (void *)&inp->net_func, sizeof(wilc_wlan_net_func_t)); + memcpy((void *)&g_wlan.indicate_func, (void *)&inp->indicate_func, sizeof(wilc_wlan_net_func_t)); + g_wlan.hif_lock = inp->os_context.hif_critical_section; + g_wlan.txq_lock = inp->os_context.txq_critical_section; + + /*Added by Amr - BugID_4720*/ + g_wlan.txq_add_to_head_lock = inp->os_context.txq_add_to_head_critical_section; + + /*Added by Amr - BugID_4720*/ + g_wlan.txq_spinlock = inp->os_context.txq_spin_lock; + + g_wlan.rxq_lock = inp->os_context.rxq_critical_section; + g_wlan.txq_wait = inp->os_context.txq_wait_event; + g_wlan.rxq_wait = inp->os_context.rxq_wait_event; + g_wlan.cfg_wait = inp->os_context.cfg_wait_event; + g_wlan.tx_buffer_size = inp->os_context.tx_buffer_size; +#if defined (MEMORY_STATIC) + g_wlan.rx_buffer_size = inp->os_context.rx_buffer_size; +#endif + /* g_wlan.os_func.os_lock(g_wlan.cfg_wait); */ + /*** + * host interface init + **/ +#if defined(PLAT_RK3026_TCHIP) /* AMR : 0422 RK3026 Crash issue */ + if (!g_wilc_initialized) { + custom_lock_bus(g_mac_open); + custom_wakeup(g_mac_open); + } +#endif + + if ((inp->io_func.io_type & 0x1) == HIF_SDIO) { + if (!hif_sdio.hif_init(inp, wilc_debug)) { + /* EIO 5 */ + ret = -5; + goto _fail_; + } + memcpy((void *)&g_wlan.hif_func, &hif_sdio, sizeof(wilc_hif_func_t)); + } else { + if ((inp->io_func.io_type & 0x1) == HIF_SPI) { + /** + * TODO: + **/ + if (!hif_spi.hif_init(inp, wilc_debug)) { + /* EIO 5 */ + ret = -5; + goto _fail_; + } + memcpy((void *)&g_wlan.hif_func, &hif_spi, sizeof(wilc_hif_func_t)); + } else { + /* EIO 5 */ + ret = -5; + goto _fail_; + } + } + + /*** + * mac interface init + **/ + if (!mac_cfg.cfg_init(wilc_debug)) { + /* ENOBUFS 105 */ + ret = -105; + goto _fail_; + } + memcpy((void *)&g_wlan.cif_func, &mac_cfg, sizeof(wilc_cfg_func_t)); + + + /** + * alloc tx, rx buffer + **/ +#if (defined WILC_PREALLOC_AT_BOOT) + extern void *get_tx_buffer(void); + extern void *get_rx_buffer(void); + + PRINT_D(TX_DBG, "malloc before, g_wlan.tx_buffer = 0x%x, g_wlan.rx_buffer = 0x%x\n", g_wlan.tx_buffer, g_wlan.rx_buffer); +#endif + + + + if (g_wlan.tx_buffer == WILC_NULL) +#if (defined WILC_PREALLOC_AT_BOOT) + g_wlan.tx_buffer = (uint8_t *)get_tx_buffer(); +#else + g_wlan.tx_buffer = (uint8_t *)g_wlan.os_func.os_malloc(g_wlan.tx_buffer_size); +#endif + PRINT_D(TX_DBG, "g_wlan.tx_buffer = 0x%x\n", g_wlan.tx_buffer); + + if (g_wlan.tx_buffer == WILC_NULL) { + /* ENOBUFS 105 */ + ret = -105; + PRINT_ER("Can't allocate Tx Buffer"); + goto _fail_; + } + +/* rx_buffer is not used unless we activate USE_MEM STATIC which is not applicable, allocating such memory is useless*/ +#if defined (MEMORY_STATIC) + if (g_wlan.rx_buffer == WILC_NULL) + #if (defined WILC_PREALLOC_AT_BOOT) + g_wlan.rx_buffer = (uint8_t *)get_rx_buffer(); + #else + g_wlan.rx_buffer = (uint8_t *)g_wlan.os_func.os_malloc(g_wlan.rx_buffer_size); + #endif + PRINT_D(TX_DBG, "g_wlan.rx_buffer =0x%x\n", g_wlan.rx_buffer); + if (g_wlan.rx_buffer == WILC_NULL) { + /* ENOBUFS 105 */ + ret = -105; + PRINT_ER("Can't allocate Rx Buffer"); + goto _fail_; + } +#endif + + /** + * export functions + **/ + oup->wlan_firmware_download = wilc_wlan_firmware_download; + oup->wlan_start = wilc_wlan_start; + oup->wlan_stop = wilc_wlan_stop; + oup->wlan_add_to_tx_que = wilc_wlan_txq_add_net_pkt; + oup->wlan_handle_tx_que = wilc_wlan_handle_txq; + oup->wlan_handle_rx_que = wilc_wlan_handle_rxq; + /* oup->wlan_handle_rx_isr = wilc_wlan_handle_isr; */ + oup->wlan_handle_rx_isr = wilc_handle_isr; + oup->wlan_cleanup = wilc_wlan_cleanup; + oup->wlan_cfg_set = wilc_wlan_cfg_set; + oup->wlan_cfg_get = wilc_wlan_cfg_get; + oup->wlan_cfg_get_value = wilc_wlan_cfg_get_val; + + /*Bug3959: transmitting mgmt frames received from host*/ + #if defined(WILC_AP_EXTERNAL_MLME) || defined(WILC_P2P) + oup->wlan_add_mgmt_to_tx_que = wilc_wlan_txq_add_mgmt_pkt; + + #ifdef WILC_FULLY_HOSTING_AP + oup->wlan_add_data_to_tx_que = wilc_FH_wlan_txq_add_net_pkt; + #endif + #endif + + if (!init_chip()) { + /* EIO 5 */ + ret = -5; + goto _fail_; + } +#ifdef TCP_ACK_FILTER + Init_TCP_tracking(); +#endif + +#if defined(PLAT_RK3026_TCHIP) /* AMR : 0422 RK3026 Crash issue */ + if (!g_wilc_initialized) + custom_unlock_bus(g_mac_open); +#endif + + return 1; + +_fail_: + +#if (defined WILC_PREALLOC_AT_BOOT) + +#else + #ifdef MEMORY_STATIC + if (g_wlan.rx_buffer) { + g_wlan.os_func.os_free(g_wlan.rx_buffer); + g_wlan.rx_buffer = WILC_NULL; + } + #endif + if (g_wlan.tx_buffer) { + g_wlan.os_func.os_free(g_wlan.tx_buffer); + g_wlan.tx_buffer = WILC_NULL; + } +#endif + +#if defined(PLAT_RK3026_TCHIP) /* AMR : 0422 RK3026 Crash issue */ + if (!g_wilc_initialized) + custom_unlock_bus(g_mac_open); +#endif + + return ret; + +} + +#define BIT31 (1 << 31) +WILC_Uint16 Set_machw_change_vir_if(WILC_Bool bValue) +{ + WILC_Uint16 ret; + WILC_Uint32 reg; + + /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/ + (&g_wlan)->os_func.os_enter_cs((&g_wlan)->hif_lock); + ret = (&g_wlan)->hif_func.hif_read_reg(WILC_CHANGING_VIR_IF, ®); + if (!ret) { + PRINT_ER("Error while Reading reg WILC_CHANGING_VIR_IF\n"); + } + + if (bValue == WILC_TRUE) { + reg |= (BIT31); + } else { + reg &= ~(BIT31); + } + + ret = (&g_wlan)->hif_func.hif_write_reg(WILC_CHANGING_VIR_IF, reg); + + if (!ret) { + PRINT_ER("Error while writing reg WILC_CHANGING_VIR_IF\n"); + } + (&g_wlan)->os_func.os_leave_cs((&g_wlan)->hif_lock); + + return ret; +} + +#ifdef WILC_FULLY_HOSTING_AP +wilc_wlan_dev_t *Get_wlan_context(WILC_Uint16 *pu16size) +{ + *pu16size = sizeof(wilc_wlan_dev_t); + return &g_wlan; +} +#endif + diff --git a/drivers/staging/wilc1000/wilc_wlan.h b/drivers/staging/wilc1000/wilc_wlan.h new file mode 100644 index 000000000000..0ba7ec69e2b4 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_wlan.h @@ -0,0 +1,321 @@ +#ifndef WILC_WLAN_H +#define WILC_WLAN_H + +#include "wilc_type.h" + + +#define ISWILC1000(id) (((id & 0xfffff000) == 0x100000) ? 1 : 0) + + +/******************************************** + * + * Mac eth header length + * + ********************************************/ +#define DRIVER_HANDLER_SIZE 4 +#define MAX_MAC_HDR_LEN 26 /* QOS_MAC_HDR_LEN */ +#define SUB_MSDU_HEADER_LENGTH 14 +#define SNAP_HDR_LEN 8 +#define ETHERNET_HDR_LEN 14 +#define WORD_ALIGNMENT_PAD 0 + +#define ETH_ETHERNET_HDR_OFFSET (MAX_MAC_HDR_LEN + SUB_MSDU_HEADER_LENGTH + \ + SNAP_HDR_LEN - ETHERNET_HDR_LEN + WORD_ALIGNMENT_PAD) + +/*Bug3959: transmitting mgmt frames received from host*/ +#define HOST_HDR_OFFSET 4 +#define ETHERNET_HDR_LEN 14 +#define IP_HDR_LEN 20 +#define IP_HDR_OFFSET ETHERNET_HDR_LEN +#define UDP_HDR_OFFSET (IP_HDR_LEN + IP_HDR_OFFSET) +#define UDP_HDR_LEN 8 +#define UDP_DATA_OFFSET (UDP_HDR_OFFSET + UDP_HDR_LEN) +#define ETH_CONFIG_PKT_HDR_LEN UDP_DATA_OFFSET + +#define ETH_CONFIG_PKT_HDR_OFFSET (ETH_ETHERNET_HDR_OFFSET + \ + ETH_CONFIG_PKT_HDR_LEN) +#define ACTION 0xD0 +#define PROBE_REQ 0x40 +#ifdef WILC_FULLY_HOSTING_AP +#define FH_TX_HOST_HDR_OFFSET 24 +#endif + +/******************************************** + * + * Endian Conversion + * + ********************************************/ + +#define BYTE_SWAP(val) ((((val) & 0x000000FF) << 24) + \ + (((val) & 0x0000FF00) << 8) + \ + (((val) & 0x00FF0000) >> 8) + \ + (((val) & 0xFF000000) >> 24)) + +/******************************************** + * + * Register Defines + * + ********************************************/ +#define WILC_PERIPH_REG_BASE 0x1000 +/*BugID_5137*/ +#define WILC_CHANGING_VIR_IF (0x108c) +#define WILC_CHIPID (WILC_PERIPH_REG_BASE) +#define WILC_GLB_RESET_0 (WILC_PERIPH_REG_BASE + 0x400) +#define WILC_PIN_MUX_0 (WILC_PERIPH_REG_BASE + 0x408) +#define WILC_HOST_TX_CTRL (WILC_PERIPH_REG_BASE + 0x6c) +#define WILC_HOST_RX_CTRL_0 (WILC_PERIPH_REG_BASE + 0x70) +#define WILC_HOST_RX_CTRL_1 (WILC_PERIPH_REG_BASE + 0x74) +#define WILC_HOST_VMM_CTL (WILC_PERIPH_REG_BASE + 0x78) +#define WILC_HOST_RX_CTRL (WILC_PERIPH_REG_BASE + 0x80) +#define WILC_HOST_RX_EXTRA_SIZE (WILC_PERIPH_REG_BASE + 0x84) +#define WILC_HOST_TX_CTRL_1 (WILC_PERIPH_REG_BASE + 0x88) +#define WILC_MISC (WILC_PERIPH_REG_BASE + 0x428) +#define WILC_INTR_REG_BASE (WILC_PERIPH_REG_BASE + 0xa00) +#define WILC_INTR_ENABLE (WILC_INTR_REG_BASE) +#define WILC_INTR2_ENABLE (WILC_INTR_REG_BASE + 4) + +#define WILC_INTR_POLARITY (WILC_INTR_REG_BASE + 0x10) +#define WILC_INTR_TYPE (WILC_INTR_REG_BASE + 0x20) +#define WILC_INTR_CLEAR (WILC_INTR_REG_BASE + 0x30) +#define WILC_INTR_STATUS (WILC_INTR_REG_BASE + 0x40) + +#define WILC_VMM_TBL_SIZE 64 +#define WILC_VMM_TX_TBL_BASE (0x150400) +#define WILC_VMM_RX_TBL_BASE (0x150500) + +#define WILC_VMM_BASE 0x150000 +#define WILC_VMM_CORE_CTL (WILC_VMM_BASE) +#define WILC_VMM_TBL_CTL (WILC_VMM_BASE + 0x4) +#define WILC_VMM_TBL_ENTRY (WILC_VMM_BASE + 0x8) +#define WILC_VMM_TBL0_SIZE (WILC_VMM_BASE + 0xc) +#define WILC_VMM_TO_HOST_SIZE (WILC_VMM_BASE + 0x10) +#define WILC_VMM_CORE_CFG (WILC_VMM_BASE + 0x14) +#define WILC_VMM_TBL_ACTIVE (WILC_VMM_BASE + 040) +#define WILC_VMM_TBL_STATUS (WILC_VMM_BASE + 0x44) + +#define WILC_SPI_REG_BASE 0xe800 +#define WILC_SPI_CTL (WILC_SPI_REG_BASE) +#define WILC_SPI_MASTER_DMA_ADDR (WILC_SPI_REG_BASE + 0x4) +#define WILC_SPI_MASTER_DMA_COUNT (WILC_SPI_REG_BASE + 0x8) +#define WILC_SPI_SLAVE_DMA_ADDR (WILC_SPI_REG_BASE + 0xc) +#define WILC_SPI_SLAVE_DMA_COUNT (WILC_SPI_REG_BASE + 0x10) +#define WILC_SPI_TX_MODE (WILC_SPI_REG_BASE + 0x20) +#define WILC_SPI_PROTOCOL_CONFIG (WILC_SPI_REG_BASE + 0x24) +#define WILC_SPI_INTR_CTL (WILC_SPI_REG_BASE + 0x2c) + +#define WILC_SPI_PROTOCOL_OFFSET (WILC_SPI_PROTOCOL_CONFIG - WILC_SPI_REG_BASE) + +#define WILC_AHB_DATA_MEM_BASE 0x30000 +#define WILC_AHB_SHARE_MEM_BASE 0xd0000 + +#define WILC_VMM_TBL_RX_SHADOW_BASE WILC_AHB_SHARE_MEM_BASE /* Bug 4477 fix */ +#define WILC_VMM_TBL_RX_SHADOW_SIZE (256) /* Bug 4477 fix */ + +#define WILC_GP_REG_0 0x149c +#define WILC_GP_REG_1 0x14a0 + +#define rHAVE_SDIO_IRQ_GPIO_BIT (0) +#define rHAVE_USE_PMU_BIT (1) +#define rHAVE_SLEEP_CLK_SRC_RTC_BIT (2) +#define rHAVE_SLEEP_CLK_SRC_XO_BIT (3) +#define rHAVE_EXT_PA_INV_TX_RX_BIT (4) +#define rHAVE_LEGACY_RF_SETTINGS_BIT (5) +#define rHAVE_XTAL_24_BIT (6) +#define rHAVE_DISABLE_WILC_UART_BIT (7) + + +#define WILC_HAVE_SDIO_IRQ_GPIO (1 << rHAVE_SDIO_IRQ_GPIO_BIT) +#define WILC_HAVE_USE_PMU (1 << rHAVE_USE_PMU_BIT) +#define WILC_HAVE_SLEEP_CLK_SRC_RTC (1 << rHAVE_SLEEP_CLK_SRC_RTC_BIT) +#define WILC_HAVE_SLEEP_CLK_SRC_XO (1 << rHAVE_SLEEP_CLK_SRC_XO_BIT) +#define WILC_HAVE_EXT_PA_INV_TX_RX (1 << rHAVE_EXT_PA_INV_TX_RX_BIT) +#define WILC_HAVE_LEGACY_RF_SETTINGS (1 << rHAVE_LEGACY_RF_SETTINGS_BIT) +#define WILC_HAVE_XTAL_24 (1 << rHAVE_XTAL_24_BIT) +#define WILC_HAVE_DISABLE_WILC_UART (1 << rHAVE_DISABLE_WILC_UART_BIT) + + +/******************************************** + * + * Wlan Defines + * + ********************************************/ +#define WILC_CFG_PKT 1 +#define WILC_NET_PKT 0 +/*Bug3959: transmitting mgmt frames received from host*/ +#ifdef WILC_AP_EXTERNAL_MLME +#define WILC_MGMT_PKT 2 + +#ifdef WILC_FULLY_HOSTING_AP +#define WILC_FH_DATA_PKT 4 +#endif + +#endif /*WILC_AP_EXTERNAL_MLME*/ +#define WILC_CFG_SET 1 +#define WILC_CFG_QUERY 0 + +#define WILC_CFG_RSP 1 +#define WILC_CFG_RSP_STATUS 2 +#define WILC_CFG_RSP_SCAN 3 + +#ifdef WILC_SDIO +#define WILC_PLL_TO 4 +#else +#define WILC_PLL_TO 2 +#endif + + +#define ABORT_INT (1 << 31) + +/*******************************************/ +/* E0 and later Interrupt flags. */ +/*******************************************/ +/*******************************************/ +/* E0 and later Interrupt flags. */ +/* IRQ Status word */ +/* 15:0 = DMA count in words. */ +/* 16: INT0 flag */ +/* 17: INT1 flag */ +/* 18: INT2 flag */ +/* 19: INT3 flag */ +/* 20: INT4 flag */ +/* 21: INT5 flag */ +/*******************************************/ +#define IRG_FLAGS_OFFSET 16 +#define IRQ_DMA_WD_CNT_MASK ((1ul << IRG_FLAGS_OFFSET) - 1) +#define INT_0 (1 << (IRG_FLAGS_OFFSET)) +#define INT_1 (1 << (IRG_FLAGS_OFFSET + 1)) +#define INT_2 (1 << (IRG_FLAGS_OFFSET + 2)) +#define INT_3 (1 << (IRG_FLAGS_OFFSET + 3)) +#define INT_4 (1 << (IRG_FLAGS_OFFSET + 4)) +#define INT_5 (1 << (IRG_FLAGS_OFFSET + 5)) +#define MAX_NUM_INT (6) + +/*******************************************/ +/* E0 and later Interrupt flags. */ +/* IRQ Clear word */ +/* 0: Clear INT0 */ +/* 1: Clear INT1 */ +/* 2: Clear INT2 */ +/* 3: Clear INT3 */ +/* 4: Clear INT4 */ +/* 5: Clear INT5 */ +/* 6: Select VMM table 1 */ +/* 7: Select VMM table 2 */ +/* 8: Enable VMM */ +/*******************************************/ +#define CLR_INT0 (1 << 0) +#define CLR_INT1 (1 << 1) +#define CLR_INT2 (1 << 2) +#define CLR_INT3 (1 << 3) +#define CLR_INT4 (1 << 4) +#define CLR_INT5 (1 << 5) +#define SEL_VMM_TBL0 (1 << 6) +#define SEL_VMM_TBL1 (1 << 7) +#define EN_VMM (1 << 8) + +#define DATA_INT_EXT INT_0 +#define PLL_INT_EXT INT_1 +#define SLEEP_INT_EXT INT_2 +#define ALL_INT_EXT (DATA_INT_EXT | PLL_INT_EXT | SLEEP_INT_EXT) +#define NUM_INT_EXT (3) + +#define DATA_INT_CLR CLR_INT0 +#define PLL_INT_CLR CLR_INT1 +#define SLEEP_INT_CLR CLR_INT2 + +#define ENABLE_RX_VMM (SEL_VMM_TBL1 | EN_VMM) +#define ENABLE_TX_VMM (SEL_VMM_TBL0 | EN_VMM) + + +/*time for expiring the semaphores of cfg packets*/ +#define CFG_PKTS_TIMEOUT 2000 +/******************************************** + * + * Debug Type + * + ********************************************/ +typedef void (*wilc_debug_func)(uint32_t, char *, ...); + +/******************************************** + * + * Tx/Rx Queue Structure + * + ********************************************/ + +struct txq_entry_t { + struct txq_entry_t *next; + struct txq_entry_t *prev; + int type; + int tcp_PendingAck_index; + uint8_t *buffer; + int buffer_size; + void *priv; + int status; + void (*tx_complete_func)(void *, int); +}; + +struct rxq_entry_t { + struct rxq_entry_t *next; + uint8_t *buffer; + int buffer_size; +}; + +/******************************************** + * + * Host IF Structure + * + ********************************************/ + +typedef struct { + int (*hif_init)(wilc_wlan_inp_t *, wilc_debug_func); + int (*hif_deinit)(void *); + int (*hif_read_reg)(uint32_t, uint32_t *); + int (*hif_write_reg)(uint32_t, uint32_t); + int (*hif_block_rx)(uint32_t, uint8_t *, uint32_t); + int (*hif_block_tx)(uint32_t, uint8_t *, uint32_t); + int (*hif_sync)(void); + int (*hif_clear_int)(void); + int (*hif_read_int)(uint32_t *); + int (*hif_clear_int_ext)(uint32_t); + int (*hif_read_size)(uint32_t *); + int (*hif_block_tx_ext)(uint32_t, uint8_t *, uint32_t); + int (*hif_block_rx_ext)(uint32_t, uint8_t *, uint32_t); + int (*hif_sync_ext)(int); + void (*hif_set_max_bus_speed)(void); + void (*hif_set_default_bus_speed)(void); +} wilc_hif_func_t; + +/******************************************** + * + * Configuration Structure + * + ********************************************/ + +#define MAX_CFG_FRAME_SIZE 1468 + +typedef struct { + uint8_t ether_header[14]; + uint8_t ip_header[20]; + uint8_t udp_header[8]; + uint8_t wid_header[8]; + uint8_t frame[MAX_CFG_FRAME_SIZE]; +} wilc_cfg_frame_t; + +typedef struct { + int (*wlan_tx)(uint8_t *, uint32_t, wilc_tx_complete_func_t); +} wilc_wlan_cfg_func_t; + +typedef struct { + int type; + uint32_t seq_no; +} wilc_cfg_rsp_t; + +typedef struct { + int (*cfg_wid_set)(uint8_t *, uint32_t, uint16_t, uint8_t *, int); + int (*cfg_wid_get)(uint8_t *, uint32_t, uint16_t); + int (*cfg_wid_get_val)(uint16_t, uint8_t *, uint32_t); + int (*rx_indicate)(uint8_t *, int, wilc_cfg_rsp_t *); + int (*cfg_init)(wilc_debug_func); +} wilc_cfg_func_t; + +#endif diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.c b/drivers/staging/wilc1000/wilc_wlan_cfg.c new file mode 100644 index 000000000000..a627c5870960 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_wlan_cfg.c @@ -0,0 +1,643 @@ +/* ////////////////////////////////////////////////////////////////////////// */ +/* */ +/* Copyright (c) Atmel Corporation. All rights reserved. */ +/* */ +/* Module Name: wilc_wlan_cfg.c */ +/* */ +/* */ +/* ///////////////////////////////////////////////////////////////////////// */ + +#include "wilc_wlan_if.h" +#include "wilc_wlan.h" +#include "wilc_wlan_cfg.h" +#include "coreconfigurator.h" + +#ifdef WILC_FULLY_HOSTING_AP +#include "wilc_host_ap.h" +void WILC_mgm_HOSTAPD_ACK(void *priv, WILC_Bool bStatus); +#endif + +/******************************************** + * + * Global Data + * + ********************************************/ + +typedef struct { + wilc_debug_func dPrint; + + int mac_status; + uint8_t mac_address[7]; + uint8_t ip_address[5]; + uint8_t bssid[7]; + uint8_t ssid[34]; + uint8_t firmware_version[129]; + uint8_t supp_rate[24]; + uint8_t wep_key[28]; + uint8_t i_psk[66]; + uint8_t hardwareProductVersion[33]; + uint8_t phyversion[17]; + uint8_t supp_username[21]; + uint8_t supp_password[64]; + uint8_t assoc_req[256]; + uint8_t assoc_rsp[256]; + uint8_t firmware_info[8]; + uint8_t scan_result[256]; + uint8_t scan_result1[256]; +} wilc_mac_cfg_t; + +static wilc_mac_cfg_t g_mac; + +static wilc_cfg_byte_t g_cfg_byte[] = { + {WID_BSS_TYPE, 0}, + {WID_CURRENT_TX_RATE, 0}, + {WID_CURRENT_CHANNEL, 0}, + {WID_PREAMBLE, 0}, + {WID_11G_OPERATING_MODE, 0}, + {WID_STATUS, 0}, + {WID_SCAN_TYPE, 0}, + {WID_KEY_ID, 0}, + {WID_QOS_ENABLE, 0}, + {WID_POWER_MANAGEMENT, 0}, + {WID_11I_MODE, 0}, + {WID_AUTH_TYPE, 0}, + {WID_SITE_SURVEY, 0}, + {WID_LISTEN_INTERVAL, 0}, + {WID_DTIM_PERIOD, 0}, + {WID_ACK_POLICY, 0}, + {WID_BCAST_SSID, 0}, + {WID_REKEY_POLICY, 0}, + {WID_SHORT_SLOT_ALLOWED, 0}, + {WID_START_SCAN_REQ, 0}, + {WID_RSSI, 0}, + {WID_LINKSPEED, 0}, + {WID_AUTO_RX_SENSITIVITY, 0}, + {WID_DATAFLOW_CONTROL, 0}, + {WID_SCAN_FILTER, 0}, + {WID_11N_PROT_MECH, 0}, + {WID_11N_ERP_PROT_TYPE, 0}, + {WID_11N_ENABLE, 0}, + {WID_11N_OPERATING_MODE, 0}, + {WID_11N_OBSS_NONHT_DETECTION, 0}, + {WID_11N_HT_PROT_TYPE, 0}, + {WID_11N_RIFS_PROT_ENABLE, 0}, + {WID_11N_SMPS_MODE, 0}, + {WID_11N_CURRENT_TX_MCS, 0}, + {WID_11N_SHORT_GI_ENABLE, 0}, + {WID_RIFS_MODE, 0}, + {WID_TX_ABORT_CONFIG, 0}, + {WID_11N_IMMEDIATE_BA_ENABLED, 0}, + {WID_11N_TXOP_PROT_DISABLE, 0}, + {WID_NIL, 0} +}; + +static wilc_cfg_hword_t g_cfg_hword[] = { + {WID_LINK_LOSS_THRESHOLD, 0}, + {WID_RTS_THRESHOLD, 0}, + {WID_FRAG_THRESHOLD, 0}, + {WID_SHORT_RETRY_LIMIT, 0}, + {WID_LONG_RETRY_LIMIT, 0}, + {WID_BEACON_INTERVAL, 0}, + {WID_RX_SENSE, 0}, + {WID_ACTIVE_SCAN_TIME, 0}, + {WID_PASSIVE_SCAN_TIME, 0}, + {WID_SITE_SURVEY_SCAN_TIME, 0}, + {WID_JOIN_START_TIMEOUT, 0}, + {WID_AUTH_TIMEOUT, 0}, + {WID_ASOC_TIMEOUT, 0}, + {WID_11I_PROTOCOL_TIMEOUT, 0}, + {WID_EAPOL_RESPONSE_TIMEOUT, 0}, + {WID_11N_SIG_QUAL_VAL, 0}, + {WID_CCA_THRESHOLD, 0}, + {WID_NIL, 0} +}; + +static wilc_cfg_word_t g_cfg_word[] = { + {WID_FAILED_COUNT, 0}, + {WID_RETRY_COUNT, 0}, + {WID_MULTIPLE_RETRY_COUNT, 0}, + {WID_FRAME_DUPLICATE_COUNT, 0}, + {WID_ACK_FAILURE_COUNT, 0}, + {WID_RECEIVED_FRAGMENT_COUNT, 0}, + {WID_MCAST_RECEIVED_FRAME_COUNT, 0}, + {WID_FCS_ERROR_COUNT, 0}, + {WID_SUCCESS_FRAME_COUNT, 0}, + {WID_TX_FRAGMENT_COUNT, 0}, + {WID_TX_MULTICAST_FRAME_COUNT, 0}, + {WID_RTS_SUCCESS_COUNT, 0}, + {WID_RTS_FAILURE_COUNT, 0}, + {WID_WEP_UNDECRYPTABLE_COUNT, 0}, + {WID_REKEY_PERIOD, 0}, + {WID_REKEY_PACKET_COUNT, 0}, + {WID_HW_RX_COUNT, 0}, + {WID_GET_INACTIVE_TIME, 0}, + {WID_NIL, 0} + +}; + +static wilc_cfg_str_t g_cfg_str[] = { + {WID_SSID, g_mac.ssid}, /* 33 + 1 bytes */ + {WID_FIRMWARE_VERSION, g_mac.firmware_version}, + {WID_OPERATIONAL_RATE_SET, g_mac.supp_rate}, + {WID_BSSID, g_mac.bssid}, /* 6 bytes */ + {WID_WEP_KEY_VALUE, g_mac.wep_key}, /* 27 bytes */ + {WID_11I_PSK, g_mac.i_psk}, /* 65 bytes */ + /* {WID_11E_P_ACTION_REQ, g_mac.action_req}, */ + {WID_HARDWARE_VERSION, g_mac.hardwareProductVersion}, + {WID_MAC_ADDR, g_mac.mac_address}, + {WID_PHY_VERSION, g_mac.phyversion}, + {WID_SUPP_USERNAME, g_mac.supp_username}, + {WID_SUPP_PASSWORD, g_mac.supp_password}, + {WID_SITE_SURVEY_RESULTS, g_mac.scan_result}, + {WID_SITE_SURVEY_RESULTS, g_mac.scan_result1}, + /* {WID_RX_POWER_LEVEL, g_mac.channel_rssi}, */ + {WID_ASSOC_REQ_INFO, g_mac.assoc_req}, + {WID_ASSOC_RES_INFO, g_mac.assoc_rsp}, + /* {WID_11N_P_ACTION_REQ, g_mac.action_req}, */ + {WID_FIRMWARE_INFO, g_mac.firmware_version}, + {WID_IP_ADDRESS, g_mac.ip_address}, + {WID_NIL, NULL} +}; + +/******************************************** + * + * Configuration Functions + * + ********************************************/ + +static int wilc_wlan_cfg_set_byte(uint8_t *frame, uint32_t offset, uint16_t id, uint8_t val8) +{ + uint8_t *buf; + + if ((offset + 4) >= MAX_CFG_FRAME_SIZE) + return 0; + + buf = &frame[offset]; + + buf[0] = (uint8_t)id; + buf[1] = (uint8_t)(id >> 8); + buf[2] = 1; + buf[3] = val8; + return 4; +} + +static int wilc_wlan_cfg_set_hword(uint8_t *frame, uint32_t offset, uint16_t id, uint16_t val16) +{ + uint8_t *buf; + + if ((offset + 5) >= MAX_CFG_FRAME_SIZE) + return 0; + + buf = &frame[offset]; + + buf[0] = (uint8_t)id; + buf[1] = (uint8_t)(id >> 8); + buf[2] = 2; + buf[3] = (uint8_t)val16; + buf[4] = (uint8_t)(val16 >> 8); + + return 5; +} + +static int wilc_wlan_cfg_set_word(uint8_t *frame, uint32_t offset, uint16_t id, uint32_t val32) +{ + uint8_t *buf; + + if ((offset + 7) >= MAX_CFG_FRAME_SIZE) + return 0; + + buf = &frame[offset]; + + buf[0] = (uint8_t)id; + buf[1] = (uint8_t)(id >> 8); + buf[2] = 4; + buf[3] = (uint8_t)val32; + buf[4] = (uint8_t)(val32 >> 8); + buf[5] = (uint8_t)(val32 >> 16); + buf[6] = (uint8_t)(val32 >> 24); + + return 7; +} + +static int wilc_wlan_cfg_set_str(uint8_t *frame, uint32_t offset, uint16_t id, uint8_t *str, uint32_t size) +{ + uint8_t *buf; + + if ((offset + size + 3) >= MAX_CFG_FRAME_SIZE) + return 0; + + buf = &frame[offset]; + + buf[0] = (uint8_t)id; + buf[1] = (uint8_t)(id >> 8); + buf[2] = (uint8_t)size; + + if ((str != NULL) && (size != 0)) + memcpy(&buf[3], str, size); + + return (size + 3); +} + +static int wilc_wlan_cfg_set_bin(uint8_t *frame, uint32_t offset, uint16_t id, uint8_t *b, uint32_t size) +{ + uint8_t *buf; + uint32_t i; + uint8_t checksum = 0; + + if ((offset + size + 5) >= MAX_CFG_FRAME_SIZE) + return 0; + + buf = &frame[offset]; + buf[0] = (uint8_t)id; + buf[1] = (uint8_t)(id >> 8); + buf[2] = (uint8_t)size; + buf[3] = (uint8_t)(size >> 8); + + if ((b != NULL) && (size != 0)) { + memcpy(&buf[4], b, size); + for (i = 0; i < size; i++) { + checksum += buf[i + 4]; + } + } + + buf[size + 4] = checksum; + + return (size + 5); +} + +/******************************************** + * + * Configuration Response Functions + * + ********************************************/ + +static void wilc_wlan_parse_response_frame(uint8_t *info, int size) +{ + uint32_t wid, len = 0, i = 0; + static int seq; + + while (size > 0) { + i = 0; + wid = info[0] | (info[1] << 8); +#ifdef BIG_ENDIAN + wid = BYTE_SWAP(wid); +#endif + PRINT_INFO(GENERIC_DBG, "Processing response for %d seq %d\n", wid, seq++); + switch ((wid >> 12) & 0x7) { + case WID_CHAR: + do { + if (g_cfg_byte[i].id == WID_NIL) + break; + + if (g_cfg_byte[i].id == wid) { + g_cfg_byte[i].val = info[3]; + break; + } + i++; + } while (1); + len = 2; + break; + + case WID_SHORT: + do { + if (g_cfg_hword[i].id == WID_NIL) + break; + + if (g_cfg_hword[i].id == wid) { +#ifdef BIG_ENDIAN + g_cfg_hword[i].val = (info[3] << 8) | (info[4]); +#else + g_cfg_hword[i].val = info[3] | (info[4] << 8); +#endif + break; + } + i++; + } while (1); + len = 3; + break; + + case WID_INT: + do { + if (g_cfg_word[i].id == WID_NIL) + break; + + if (g_cfg_word[i].id == wid) { +#ifdef BIG_ENDIAN + g_cfg_word[i].val = (info[3] << 24) | (info[4] << 16) | (info[5] << 8) | (info[6]); +#else + g_cfg_word[i].val = info[3] | (info[4] << 8) | (info[5] << 16) | (info[6] << 24); +#endif + break; + } + i++; + } while (1); + len = 5; + break; + + case WID_STR: + do { + if (g_cfg_str[i].id == WID_NIL) + break; + + if (g_cfg_str[i].id == wid) { + if (wid == WID_SITE_SURVEY_RESULTS) { + static int toggle; + PRINT_INFO(GENERIC_DBG, "Site survey results received[%d]\n", + size); + + PRINT_INFO(GENERIC_DBG, "Site survey results value[%d]toggle[%d]\n", size, toggle); + i += toggle; + toggle ^= 1; + } + memcpy(g_cfg_str[i].str, &info[2], (info[2] + 1)); + break; + } + i++; + } while (1); + len = 1 + info[2]; + break; + + default: + break; + } + size -= (2 + len); + info += (2 + len); + } + + return; +} + +static int wilc_wlan_parse_info_frame(uint8_t *info, int size) +{ + wilc_mac_cfg_t *pd = (wilc_mac_cfg_t *)&g_mac; + uint32_t wid, len; + int type = WILC_CFG_RSP_STATUS; + + wid = info[0] | (info[1] << 8); +#if 0 +#ifdef BIG_ENDIAN + wid = BYTE_SWAP(wid); +#endif +#endif + + len = info[2]; + PRINT_INFO(GENERIC_DBG, "Status Len = %d Id= %d\n", len, wid); + if ((len == 1) && (wid == WID_STATUS)) { + pd->mac_status = info[3]; + type = WILC_CFG_RSP_STATUS; + } + + return type; +} + +#if 0 +static int wilc_wlan_parse_network_frame(uint8_t *info, int size) +{ + wilc_mac_cfg_t *priv = (wilc_mac_cfg_t *)&g_mac; + uint32_t wid, len; + + wid = info[0] | (info[1] << 8); + len = info[2] | (info[3] << 8); + + /** + * Review: this message is only for AP mode. + * TBD + **/ + if (wid == WID_NETWORK_INFO) { /* not send by the firmware */ + + } + + return; +} +#endif + +/******************************************** + * + * Configuration Exported Functions + * + ********************************************/ + +static int wilc_wlan_cfg_set_wid(uint8_t *frame, uint32_t offset, uint16_t id, uint8_t *buf, int size) +{ + uint8_t type = (id >> 12) & 0xf; + int ret = 0; + + if (type == 0) { /* byte command */ + if (size >= 1) + ret = wilc_wlan_cfg_set_byte(frame, offset, id, *buf); + } else if (type == 1) { /* half word command */ + if (size >= 2) + ret = wilc_wlan_cfg_set_hword(frame, offset, id, *((uint16_t *)buf)); + } else if (type == 2) { /* word command */ + if (size >= 4) + ret = wilc_wlan_cfg_set_word(frame, offset, id, *((uint32_t *)buf)); + } else if (type == 3) { /* string command */ + ret = wilc_wlan_cfg_set_str(frame, offset, id, buf, size); + } else if (type == 4) { /* binary command */ + ret = wilc_wlan_cfg_set_bin(frame, offset, id, buf, size); + } else { + g_mac.dPrint(N_ERR, "illegal id\n"); + } + + return ret; +} + +static int wilc_wlan_cfg_get_wid(uint8_t *frame, uint32_t offset, uint16_t id) +{ + uint8_t *buf; + + if ((offset + 2) >= MAX_CFG_FRAME_SIZE) + return 0; + + buf = &frame[offset]; + + buf[0] = (uint8_t)id; + buf[1] = (uint8_t)(id >> 8); + + return 2; +} + +static int wilc_wlan_cfg_get_wid_value(uint16_t wid, uint8_t *buffer, uint32_t buffer_size) +{ + uint32_t type = (wid >> 12) & 0xf; + int i, ret = 0; + + if (wid == WID_STATUS) { + *((uint32_t *)buffer) = g_mac.mac_status; + return 4; + } + + i = 0; + if (type == 0) { /* byte command */ + do { + if (g_cfg_byte[i].id == WID_NIL) + break; + + if (g_cfg_byte[i].id == wid) { + memcpy(buffer, &g_cfg_byte[i].val, 1); + ret = 1; + break; + } + i++; + } while (1); + } else if (type == 1) { /* half word command */ + do { + if (g_cfg_hword[i].id == WID_NIL) + break; + + if (g_cfg_hword[i].id == wid) { + memcpy(buffer, &g_cfg_hword[i].val, 2); + ret = 2; + break; + } + i++; + } while (1); + } else if (type == 2) { /* word command */ + do { + if (g_cfg_word[i].id == WID_NIL) + break; + + if (g_cfg_word[i].id == wid) { + memcpy(buffer, &g_cfg_word[i].val, 4); + ret = 4; + break; + } + i++; + } while (1); + } else if (type == 3) { /* string command */ + do { + if (g_cfg_str[i].id == WID_NIL) + break; + + if (g_cfg_str[i].id == wid) { + uint32_t size = g_cfg_str[i].str[0]; + if (buffer_size >= size) { + if (g_cfg_str[i].id == WID_SITE_SURVEY_RESULTS) { + static int toggle; + PRINT_INFO(GENERIC_DBG, "Site survey results value[%d]\n", + size); + i += toggle; + toggle ^= 1; + + } + memcpy(buffer, &g_cfg_str[i].str[1], size); + ret = size; + } + break; + } + i++; + } while (1); + } else { + g_mac.dPrint(N_ERR, "[CFG]: illegal type (%08x)\n", wid); + } + + return ret; +} + +static int wilc_wlan_cfg_indicate_rx(uint8_t *frame, int size, wilc_cfg_rsp_t *rsp) +{ + int ret = 1; + uint8_t msg_type; + uint8_t msg_id; + uint16_t msg_len; + #ifdef WILC_FULLY_HOSTING_AP + WILC_Uint32 *ptru32Frame; + WILC_Bool bStatus = frame[2]; + + #ifdef BIG_ENDIAN + ptru32Frame = (frame[4] << 24) | (frame[5] << 16) | (frame[6] << 8) | frame[7]; + #else + ptru32Frame = (frame[7] << 24) | (frame[6] << 16) | (frame[5] << 8) | frame[4]; + #endif /* BIG_ENDIAN */ + + #endif /* WILC_FULLY_HOSTING_AP */ + + msg_type = frame[0]; + msg_id = frame[1]; /* seq no */ +#ifdef BIG_ENDIAN + msg_len = (frame[2] << 8) | frame[3]; +#else + msg_len = (frame[3] << 8) | frame[2]; +#endif + frame += 4; + size -= 4; + + /** + * The valid types of response messages are 'R' (Response), 'I' (Information), and 'N' (Network Information) + **/ + + switch (msg_type) { + case 'R': + wilc_wlan_parse_response_frame(frame, size); + rsp->type = WILC_CFG_RSP; + rsp->seq_no = msg_id; + break; + + case 'I': + rsp->type = wilc_wlan_parse_info_frame(frame, size); + rsp->seq_no = msg_id; + /*call host interface info parse as well*/ + PRINT_INFO(RX_DBG, "Info message received\n"); + GnrlAsyncInfoReceived(frame - 4, size + 4); + break; + + case 'L': +#ifndef SWITCH_LOG_TERMINAL + PRINT_ER("Unexpected firmware log message received \n"); +#else + PRINT_D(FIRM_DBG, "\nFIRMWARE LOGS :\n<<\n%s\n>>\n", frame); + break; + +#endif +#if 1 + case 'N': + NetworkInfoReceived(frame - 4, size + 4); + rsp->type = 0; + break; + +#endif +/*bug3819:*/ + case 'S': + PRINT_INFO(RX_DBG, "Scan Notification Received \n"); + host_int_ScanCompleteReceived(frame - 4, size + 4); + break; + +#ifdef WILC_FULLY_HOSTING_AP + case 'T': + PRINT_INFO(RX_DBG, "TBTT Notification Received \n"); + process_tbtt_isr(); + break; + + case 'A': + PRINT_INFO(RX_DBG, "HOSTAPD ACK Notification Received \n"); + WILC_mgm_HOSTAPD_ACK(ptru32Frame, bStatus); + break; +#endif + + default: + PRINT_INFO(RX_DBG, "Receive unknown message type[%d-%d-%d-%d-%d-%d-%d-%d]\n", + frame[0], frame[1], frame[2], frame[3], frame[4], + frame[5], frame[6], frame[7]); + rsp->type = 0; + rsp->seq_no = msg_id; + ret = 0; + break; + } + + return ret; +} + +static int wilc_wlan_cfg_init(wilc_debug_func func) +{ + memset((void *)&g_mac, 0, sizeof(wilc_mac_cfg_t)); + g_mac.dPrint = func; + return 1; +} + +wilc_cfg_func_t mac_cfg = { + wilc_wlan_cfg_set_wid, + wilc_wlan_cfg_get_wid, + wilc_wlan_cfg_get_wid_value, + wilc_wlan_cfg_indicate_rx, + wilc_wlan_cfg_init, +}; diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.h b/drivers/staging/wilc1000/wilc_wlan_cfg.h new file mode 100644 index 000000000000..8906611b2930 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_wlan_cfg.h @@ -0,0 +1,33 @@ +/* ////////////////////////////////////////////////////////////////////////// */ +/* */ +/* Copyright (c) Atmel Corporation. All rights reserved. */ +/* */ +/* Module Name: wilc_wlan_cfg.h */ +/* */ +/* */ +/* ///////////////////////////////////////////////////////////////////////// */ + +#ifndef WILC_WLAN_CFG_H +#define WILC_WLAN_CFG_H + +typedef struct { + uint16_t id; + uint16_t val; +} wilc_cfg_byte_t; + +typedef struct { + uint16_t id; + uint16_t val; +} wilc_cfg_hword_t; + +typedef struct { + uint32_t id; + uint32_t val; +} wilc_cfg_word_t; + +typedef struct { + uint32_t id; + uint8_t *str; +} wilc_cfg_str_t; + +#endif diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h new file mode 100644 index 000000000000..dd86ca7dd3f3 --- /dev/null +++ b/drivers/staging/wilc1000/wilc_wlan_if.h @@ -0,0 +1,991 @@ +/* ////////////////////////////////////////////////////////////////////////// */ +/* */ +/* Copyright (c) Atmel Corporation. All rights reserved. */ +/* */ +/* Module Name: wilc_wlan_if.h */ +/* */ +/* */ +/* ///////////////////////////////////////////////////////////////////////// */ + + +#ifndef WILC_WLAN_IF_H +#define WILC_WLAN_IF_H + +/*bug 3887: [AP] Allow Management frames to be passed to the host*/ +#define WILC_AP_EXTERNAL_MLME +#define WILC_P2P +#define TCP_ENHANCEMENTS +/* #define MEMORY_STATIC */ +/* #define WILC_FULLY_HOSTING_AP */ +/* #define USE_OLD_SPI_SW */ + + +#include "wilc_type.h" +#include "linux_wlan_common.h" + + +/******************************************** + * + * Debug Flags + * + ********************************************/ + +#define N_INIT 0x00000001 +#define N_ERR 0x00000002 +#define N_TXQ 0x00000004 +#define N_INTR 0x00000008 +#define N_RXQ 0x00000010 + +/******************************************** + * + * Host Interface Defines + * + ********************************************/ + +#define HIF_SDIO (0) +#define HIF_SPI (1 << 0) +#define HIF_SDIO_GPIO_IRQ (1 << 2) + + +/******************************************** + * + * Tx/Rx Buffer Size Defines + * + ********************************************/ + +#define CE_TX_BUFFER_SIZE (64 * 1024) +#define CE_RX_BUFFER_SIZE (384 * 1024) + +/******************************************** + * + * Wlan Interface Defines + * + ********************************************/ + +typedef struct { + uint32_t read_write: 1; + uint32_t function: 3; + uint32_t raw: 1; + uint32_t address: 17; + uint32_t data: 8; +} sdio_cmd52_t; + +typedef struct { + /* struct { */ + uint32_t read_write: 1; + uint32_t function: 3; + uint32_t block_mode: 1; + uint32_t increment: 1; + uint32_t address: 17; + uint32_t count: 9; + /* } bit; */ + uint8_t *buffer; + uint32_t block_size; +} sdio_cmd53_t; + +typedef struct { + void (*os_sleep)(uint32_t); + void (*os_atomic_sleep)(uint32_t); + void (*os_debug)(uint8_t *); + void *(*os_malloc)(uint32_t); + void *(*os_malloc_atomic)(uint32_t); + void (*os_free)(void *); + void (*os_lock)(void *); + void (*os_unlock)(void *); + int (*os_wait)(void *, WILC_Uint32); + void (*os_signal)(void *); + void (*os_enter_cs)(void *); + void (*os_leave_cs)(void *); + + /*Added by Amr - BugID_4720*/ + void (*os_spin_lock)(void *, unsigned long *); + void (*os_spin_unlock)(void *, unsigned long *); + +} wilc_wlan_os_func_t; + +typedef struct { + int io_type; + int (*io_init)(void *); + void (*io_deinit)(void *); + union { + struct { + int (*sdio_cmd52)(sdio_cmd52_t *); + int (*sdio_cmd53)(sdio_cmd53_t *); + int (*sdio_set_max_speed)(void); + int (*sdio_set_default_speed)(void); + } sdio; + struct { + int (*spi_max_speed)(void); + int (*spi_tx)(uint8_t *, uint32_t); + int (*spi_rx)(uint8_t *, uint32_t); + int (*spi_trx)(uint8_t *, uint8_t *, uint32_t); + } spi; + } u; +} wilc_wlan_io_func_t; + +typedef struct { + void (*rx_indicate)(uint8_t *, uint32_t, uint32_t); + void (*rx_complete)(void); +} wilc_wlan_net_func_t; + +typedef struct { + void (*mac_indicate)(int); +} wilc_wlan_indicate_func_t; +#define WILC_MAC_INDICATE_STATUS 0x1 +#define WILC_MAC_STATUS_INIT -1 +#define WILC_MAC_STATUS_READY 0 +#define WILC_MAC_STATUS_CONNECT 1 + +#define WILC_MAC_INDICATE_SCAN 0x2 + +typedef struct { + void *os_private; + + void *hif_critical_section; + + uint32_t tx_buffer_size; + void *txq_critical_section; + + /*Added by Amr - BugID_4720*/ + void *txq_add_to_head_critical_section; + void *txq_spin_lock; + + void *txq_wait_event; + +#if defined(MEMORY_STATIC) + uint32_t rx_buffer_size; +#endif + void *rxq_critical_section; + void *rxq_wait_event; + + void *cfg_wait_event; +} wilc_wlan_os_context_t; + +typedef struct { + wilc_wlan_os_context_t os_context; + wilc_wlan_os_func_t os_func; + wilc_wlan_io_func_t io_func; + wilc_wlan_net_func_t net_func; + wilc_wlan_indicate_func_t indicate_func; +} wilc_wlan_inp_t; + +#if 0 +typedef struct { + int start; + uint32_t id; + void *buffer; + uint32_t buffer_size; + int commit; +} wilc_wlan_cfg_set_t; + +typedef struct { + int start; + uint32_t id; + int commit; +} wilc_wlan_cfg_get_t; + +typedef struct { + uint32_t id; + void *buffer; + uint32_t buffer_size; +} wilc_wlan_cfg_val_t; +#endif + +struct tx_complete_data { + #ifdef WILC_FULLY_HOSTING_AP + struct tx_complete_data *next; + #endif + int size; + void *buff; + uint8_t *pBssid; + struct sk_buff *skb; +}; + + +typedef void (*wilc_tx_complete_func_t)(void *, int); + +#define WILC_TX_ERR_NO_BUF (-2) + +typedef struct { + int (*wlan_firmware_download)(const uint8_t *, uint32_t); + int (*wlan_start)(void); + int (*wlan_stop)(void); + int (*wlan_add_to_tx_que)(void *, uint8_t *, uint32_t, wilc_tx_complete_func_t); + int (*wlan_handle_tx_que)(uint32_t *); + void (*wlan_handle_rx_que)(void); + void (*wlan_handle_rx_isr)(void); + void (*wlan_cleanup)(void); + int (*wlan_cfg_set)(int, uint32_t, uint8_t *, uint32_t, int, uint32_t); + int (*wlan_cfg_get)(int, uint32_t, int, uint32_t); + int (*wlan_cfg_get_value)(uint32_t, uint8_t *, uint32_t); + /*Bug3959: transmitting mgmt frames received from host*/ + #if defined(WILC_AP_EXTERNAL_MLME) || defined(WILC_P2P) + int (*wlan_add_mgmt_to_tx_que)(void *, uint8_t *, uint32_t, wilc_tx_complete_func_t); + + #ifdef WILC_FULLY_HOSTING_AP + int (*wlan_add_data_to_tx_que)(void *, uint8_t *, uint32_t, wilc_tx_complete_func_t); + #endif + + #endif +} wilc_wlan_oup_t; + +/******************************************** + * + * Wlan Configuration ID + * + ********************************************/ + +#define MAX_SSID_LEN 33 +#define MAX_RATES_SUPPORTED 12 + +#define INFINITE_SLEEP_TIME ((WILC_Uint32)0xFFFFFFFF) + +#ifdef WILC_PARSE_SCAN_IN_HOST +typedef enum { + SUPP_RATES_IE = 1, + EXT_SUPP_RATES_IE = 50, + HT_CAPABILITY_IE = 45, + RSN_IE = 48, + WPA_IE = 221, + WMM_IE = 221, + #ifdef WILC_P2P + P2P_IE = 221, + #endif +} BEACON_IE; +#endif +typedef enum { + INFRASTRUCTURE = 0, + INDEPENDENT, + AP, +} BSSTYPE_T; + +typedef enum { + RATE_AUTO = 0, + RATE_1MB = 1, + RATE_2MB = 2, + RATE_5MB = 5, + RATE_6MB = 6, + RATE_9MB = 9, + RATE_11MB = 11, + RATE_12MB = 12, + RATE_18MB = 18, + RATE_24MB = 24, + RATE_26MB = 36, + RATE_48MB = 48, + RATE_54MB = 54 +} TX_RATE_T; + +typedef enum { + B_ONLY_MODE = 0, /* basic rate: 1, 2 Mbps, otherwise: 5, 11 Mbps */ + G_ONLY_MODE, /* basic rate: 6, 12, 24 Mbps, otherwise: 9, 18, 36, 48, 54 Mbps */ + G_MIXED_11B_1_MODE, /* basic rate: 1, 2, 5.5, 11 Mbps, otherwise: all on */ + G_MIXED_11B_2_MODE, /* basic rate: 1, 2, 5, 11, 6, 12, 24 Mbps, otherwise: all on */ +} G_OPERATING_MODE_T; + +typedef enum { + G_SHORT_PREAMBLE = 0, /* Short Preamble */ + G_LONG_PREAMBLE = 1, /* Long Preamble */ + G_AUTO_PREAMBLE = 2, /* Auto Preamble Selection */ +} G_PREAMBLE_T; + +#define MAC_CONNECTED 1 +#define MAC_DISCONNECTED 0 + +/*bug3819: */ +#define SCAN_DONE TRUE +typedef enum { + PASSIVE_SCAN = 0, + ACTIVE_SCAN = 1, +} SCANTYPE_T; + +typedef enum { + NO_POWERSAVE = 0, + MIN_FAST_PS = 1, + MAX_FAST_PS = 2, + MIN_PSPOLL_PS = 3, + MAX_PSPOLL_PS = 4 +} USER_PS_MODE_T; + +typedef enum { + CHIP_WAKEDUP = 0, + CHIP_SLEEPING_AUTO = 1, + CHIP_SLEEPING_MANUAL = 2 +} CHIP_PS_STATE_T; + +typedef enum { + ACQUIRE_ONLY = 0, + ACQUIRE_AND_WAKEUP = 1, +} BUS_ACQUIRE_T; + +typedef enum { + RELEASE_ONLY = 0, + RELEASE_ALLOW_SLEEP = 1, +} BUS_RELEASE_T; + +typedef enum { + NO_SECURITY = 0, + WEP_40 = 0x3, + WEP_104 = 0x7, + WPA_AES = 0x29, + WPA_TKIP = 0x49, + WPA_AES_TKIP = 0x69, /* Aes or Tkip */ + WPA2_AES = 0x31, + WPA2_TKIP = 0x51, + WPA2_AES_TKIP = 0x71, /* Aes or Tkip */ +} SECURITY_T; + +typedef enum { + OPEN_SYSTEM = 1, + SHARED_KEY = 2, + ANY = 3, + IEEE8021 = 5 +} AUTHTYPE_T; + +typedef enum { + SITE_SURVEY_1CH = 0, + SITE_SURVEY_ALL_CH = 1, + SITE_SURVEY_OFF = 2 +} SITE_SURVEY_T; + +typedef enum { + NORMAL_ACK = 0, + NO_ACK, +} ACK_POLICY_T; + +typedef enum { + DONT_RESET = 0, + DO_RESET = 1, + NO_REQUEST = 2, +} RESET_REQ_T; + +typedef enum { + REKEY_DISABLE = 1, + REKEY_TIME_BASE, + REKEY_PKT_BASE, + REKEY_TIME_PKT_BASE +} RSNA_REKEY_POLICY_T; + +typedef enum { + FILTER_NO = 0x00, + FILTER_AP_ONLY = 0x01, + FILTER_STA_ONLY = 0x02 +} SCAN_CLASS_FITLER_T; + +typedef enum { + PRI_HIGH_RSSI = 0x00, + PRI_LOW_RSSI = 0x04, + PRI_DETECT = 0x08 +} SCAN_PRI_T; + +typedef enum { + CH_FILTER_OFF = 0x00, + CH_FILTER_ON = 0x10 +} CH_FILTER_T; + +typedef enum { + AUTO_PROT = 0, /* Auto */ + NO_PROT, /* Do not use any protection */ + ERP_PROT, /* Protect all ERP frame exchanges */ + HT_PROT, /* Protect all HT frame exchanges */ + GF_PROT, /* Protect all GF frame exchanges */ +} N_PROTECTION_MODE_T; + +typedef enum { + G_SELF_CTS_PROT, + G_RTS_CTS_PROT, +} G_PROTECTION_MODE_T; + +typedef enum { + HT_MIXED_MODE = 1, + HT_ONLY_20MHZ_MODE, + HT_ONLY_20_40MHZ_MODE, +} N_OPERATING_MODE_T; + +typedef enum { + NO_DETECT = 0, + DETECT_ONLY = 1, + DETECT_PROTECT = 2, + DETECT_PROTECT_REPORT = 3, +} N_OBSS_DETECTION_T; + +typedef enum { + RTS_CTS_NONHT_PROT = 0, /* RTS-CTS at non-HT rate */ + FIRST_FRAME_NONHT_PROT, /* First frame at non-HT rate */ + LSIG_TXOP_PROT, /* LSIG TXOP Protection */ + FIRST_FRAME_MIXED_PROT, /* First frame at Mixed format */ +} N_PROTECTION_TYPE_T; + +typedef enum { + STATIC_MODE = 1, + DYNAMIC_MODE = 2, + MIMO_MODE = 3, /* power save disable */ +} N_SMPS_MODE_T; + +typedef enum { + DISABLE_SELF_CTS, + ENABLE_SELF_CTS, + DISABLE_TX_ABORT, + ENABLE_TX_ABORT, + HW_TRIGGER_ABORT, + SW_TRIGGER_ABORT, +} TX_ABORT_OPTION_T; + +typedef enum { + WID_CHAR = 0, + WID_SHORT = 1, + WID_INT = 2, + WID_STR = 3, + WID_BIN_DATA = 4, + WID_BIN = 5, + WID_IP = 6, + WID_ADR = 7, + WID_UNDEF = 8, + WID_TYPE_FORCE_32BIT = 0xFFFFFFFF + +} WID_TYPE_T, tenuWIDtype; + +typedef enum { + WID_NIL = 0xffff, + + + /* BSS Type */ + /* -------------------------------------------------------------- */ + /* Configuration : Infrastructure Independent Access Point */ + /* Values to set : 0 1 2 */ + /* -------------------------------------------------------------- */ + WID_BSS_TYPE = 0x0000, + + /* Transmit Rate */ + /* -------------------------------------------------------------- */ + /* Configuration : 1 2 5.5 11 6 9 12 18 24 36 48 54 */ + /* Values to set : 1 2 5 11 6 9 12 18 24 36 48 54 */ + /* -------------------------------------------------------------- */ + WID_CURRENT_TX_RATE = 0x0001, + + /* Channel */ + /* ------------------------------------------------------------------- */ + /* Configuration(g) : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */ + /* Values to set : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */ + /* -------------------------------------------------------------------- */ + WID_CURRENT_CHANNEL = 0x0002, + + /* Preamble */ + /* -------------------------------------------------------------- */ + /* Configuration : short long Auto */ + /* Values to set : 0 1 2 */ + /* -------------------------------------------------------------- */ + WID_PREAMBLE = 0x0003, + + /* 11g operating mode (ignored if 11g not present) */ + /* -------------------------------------------------------------- */ + /* Configuration : HighPerf Compat(RSet #1) Compat(RSet #2) */ + /* Values to set : 1 2 3 */ + /* -------------------------------------------------------------- */ + WID_11G_OPERATING_MODE = 0x0004, + + /* Mac status (response only) */ + /* -------------------------------------------------------------- */ + /* Configuration : disconnect connect */ + /* Values to get : 0 1 */ + /* -------------------------------------------------------------- */ + WID_STATUS = 0x0005, + + /* Scan type */ + /* -------------------------------------------------------------- */ + /* Configuration : Passive Scanning Active Scanning */ + /* Values to set : 0 1 */ + /* -------------------------------------------------------------- */ + WID_SCAN_TYPE = 0x0007, + + /* Key Id (WEP default key Id) */ + /* -------------------------------------------------------------- */ + /* Configuration : Any value between 0 to 3 */ + /* Values to set : Same value. Default is 0 */ + /* -------------------------------------------------------------- */ + WID_KEY_ID = 0x0009, + + /* QoS Enable */ + /* -------------------------------------------------------------- */ + /* Configuration : QoS Disable WMM Enable */ + /* Values to set : 0 1 */ + /* -------------------------------------------------------------- */ + WID_QOS_ENABLE = 0x000A, + + /* Power Management */ + /* ------------------------------------------------------------------ */ + /* Configuration : NO_POWERSAVE MIN_POWERSAVE MAX_POWERSAVE */ + /* Values to set : 0 1 2 */ + /* ------------------------------------------------------------------ */ + WID_POWER_MANAGEMENT = 0x000B, + + /* WEP/802 11I Configuration */ + /* ------------------------------------------------------------------ */ + /* Configuration : Disable WP40 WP104 WPA-AES WPA-TKIP RSN-AES RSN-TKIP */ + /* Values (0x) : 00 03 07 29 49 31 51 */ + /* */ + /* Configuration : WPA-AES+TKIP RSN-AES+TKIP */ + /* Values (0x) : 69 71 */ + /* ------------------------------------------------------------------ */ + WID_11I_MODE = 0x000C, + + /* WEP Configuration: Used in BSS STA mode only when WEP is enabled */ + /* ------------------------------------------------------------------ */ + /* Configuration : Open System Shared Key Any Type | 802.1x Auth */ + /* Values (0x) : 01 02 03 | BIT2 */ + /* ------------------------------------------------------------------ */ + WID_AUTH_TYPE = 0x000D, + + /* Site Survey Type */ + /* -------------------------------------------------------------- */ + /* Configuration : Values to set */ + /* Survey 1 Channel : 0 */ + /* survey all Channels : 1 */ + /* Disable Site Survey : 2 */ + /* -------------------------------------------------------------- */ + WID_SITE_SURVEY = 0x000E, + + /* Listen Interval */ + /* -------------------------------------------------------------- */ + /* Configuration : Any value between 1 to 255 */ + /* Values to set : Same value. Default is 3 */ + /* -------------------------------------------------------------- */ + WID_LISTEN_INTERVAL = 0x000F, + + /* DTIM Period */ + /* -------------------------------------------------------------- */ + /* Configuration : Any value between 1 to 255 */ + /* Values to set : Same value. Default is 3 */ + /* -------------------------------------------------------------- */ + WID_DTIM_PERIOD = 0x0010, + + /* ACK Policy */ + /* -------------------------------------------------------------- */ + /* Configuration : Normal Ack No Ack */ + /* Values to set : 0 1 */ + /* -------------------------------------------------------------- */ + WID_ACK_POLICY = 0x0011, + + /* Reset MAC (Set only) */ + /* -------------------------------------------------------------- */ + /* Configuration : Don't Reset Reset No Request */ + /* Values to set : 0 1 2 */ + /* -------------------------------------------------------------- */ + WID_RESET = 0x0012, + + /* Broadcast SSID Option: Setting this will adhere to "" SSID element */ + /* ------------------------------------------------------------------ */ + /* Configuration : Enable Disable */ + /* Values to set : 1 0 */ + /* ------------------------------------------------------------------ */ + WID_BCAST_SSID = 0x0015, + + /* Disconnect (Station) */ + /* ------------------------------------------------------------------ */ + /* Configuration : Association ID */ + /* Values to set : Association ID */ + /* ------------------------------------------------------------------ */ + WID_DISCONNECT = 0x0016, + + /* 11a Tx Power Level */ + /* -------------------------------------------------------------------- */ + /* Configuration : Sets TX Power (Higher the value greater the power) */ + /* Values to set : Any value between 0 and 63 (inclusive; Default is 48)*/ + /* -------------------------------------------------------------------- */ + WID_TX_POWER_LEVEL_11A = 0x0018, + + /* Group Key Update Policy Selection */ + /* -------------------------------------------------------------------- */ + /* Configuration : Disabled timeBased packetBased timePacketBased */ + /* Values to set : 1 2 3 4 */ + /* -------------------------------------------------------------------- */ + WID_REKEY_POLICY = 0x0019, + + /* Allow Short Slot */ + /* -------------------------------------------------------------- */ + /* Configuration : Disallow Short Slot Allow Short Slot */ + /* (Enable Only Long Slot) (Enable Short Slot if applicable)*/ + /* Values to set : 0 1 */ + /* -------------------------------------------------------------- */ + WID_SHORT_SLOT_ALLOWED = 0x001A, + + WID_PHY_ACTIVE_REG = 0x001B, + + /* 11b Tx Power Level */ + /* -------------------------------------------------------------------- */ + /* Configuration : Sets TX Power (Higher the value greater the power) */ + /* Values to set : Any value between 0 and 63 (inclusive; Default is 48)*/ + /* -------------------------------------------------------------------- */ + WID_TX_POWER_LEVEL_11B = 0x001D, + + /* Scan Request */ + /* -------------------------------------------------------------------- */ + /* Configuration : Request default scan */ + /* Values to set : 0 */ + /* -------------------------------------------------------------------- */ + WID_START_SCAN_REQ = 0x001E, + + /* Rssi (get only) */ + /* -------------------------------------------------------------------- */ + /* Configuration : */ + /* Values to get : Rssi value */ + /* -------------------------------------------------------------------- */ + WID_RSSI = 0x001F, + + /* Join Request */ + /* -------------------------------------------------------------------- */ + /* Configuration : Request to join */ + /* Values to set : index of scan result */ + /* -------------------------------------------------------------------- */ + WID_JOIN_REQ = 0x0020, + + WID_LINKSPEED = 0x0026, + + /* Enable User Control of TX Power */ + /* -------------------------------------------------------------------- */ + /* Configuration : Disable Enable */ + /* Values to set : 0 1 */ + /* -------------------------------------------------------------------- */ + WID_USER_CONTROL_ON_TX_POWER = 0x0027, + + WID_MEMORY_ACCESS_8BIT = 0x0029, + + /* Enable Auto RX Sensitivity feature */ + /* -------------------------------------------------------------------- */ + /* Configuration : Disable Enable */ + /* Values to set : 0 1 */ + /* -------------------------------------------------------------------- */ + WID_AUTO_RX_SENSITIVITY = 0x0032, + + /* Receive Buffer Based Ack */ + /* -------------------------------------------------------------------- */ + /* Configuration : Disable Enable */ + /* Values to set : 0 1 */ + /* -------------------------------------------------------------------- */ + WID_DATAFLOW_CONTROL = 0x0033, + + /* Scan Filter */ + /* -------------------------------------------------------------------- */ + /* Configuration : Class No filter AP only Station Only */ + /* Values to set : 0 1 2 */ + /* Configuration : Priority High Rssi Low Rssi Detect */ + /* Values to set : 0 0x4 0x08 */ + /* Configuration : Channel filter off filter on */ + /* Values to set : 0 0x10 */ + /* -------------------------------------------------------------------- */ + WID_SCAN_FILTER = 0x0036, + + /* Link Loss Threshold (measure in the beacon period) */ + /* -------------------------------------------------------------------- */ + /* Configuration : Any value between 10 and 254 (Set to 255 to disable it) */ + /* Values to set : Same value. Default is 10 */ + /* -------------------------------------------------------------------- */ + WID_LINK_LOSS_THRESHOLD = 0x0037, + + /*BugID_4978*/ + WID_ABORT_RUNNING_SCAN = 0x003E, + + /* NMAC Character WID list */ + WID_WPS_START = 0x0043, + + /* Protection mode for MAC */ + /* -------------------------------------------------------------- */ + /* Configuration : Auto No protection ERP HT GF */ + /* Values to set : 0 1 2 3 4 */ + /* -------------------------------------------------------------- */ + WID_11N_PROT_MECH = 0x0080, + + /* ERP Protection type for MAC */ + /* -------------------------------------------------------------- */ + /* Configuration : Self-CTS RTS-CTS */ + /* Values to set : 0 1 */ + /* -------------------------------------------------------------- */ + WID_11N_ERP_PROT_TYPE = 0x0081, + + /* HT Option Enable */ + /* -------------------------------------------------------------- */ + /* Configuration : HT Enable HT Disable */ + /* Values to set : 1 0 */ + /* -------------------------------------------------------------- */ + WID_11N_ENABLE = 0x0082, + + /* 11n Operating mode (Note that 11g operating mode will also be */ + /* used in addition to this, if this is set to HT Mixed mode) */ + /* -------------------------------------------------------------- */ + /* Configuration : HT Mixed HT Only-20MHz HT Only-20/40MHz */ + /* Values to set : 1 2 3 */ + /* -------------------------------------------------------------- */ + WID_11N_OPERATING_MODE = 0x0083, + + /* 11n OBSS non-HT STA Detection flag */ + /* -------------------------------------------------------------- */ + /* Configuration : Do not detect */ + /* Values to set : 0 */ + /* Configuration : Detect, do not protect or report */ + /* Values to set : 1 */ + /* Configuration : Detect, protect and do not report */ + /* Values to set : 2 */ + /* Configuration : Detect, protect and report to other BSS */ + /* Values to set : 3 */ + /* -------------------------------------------------------------- */ + WID_11N_OBSS_NONHT_DETECTION = 0x0084, + + /* 11n HT Protection Type */ + /* -------------------------------------------------------------- */ + /* Configuration : RTS-CTS First Frame Exchange at non-HT-rate */ + /* Values to set : 0 1 */ + /* Configuration : LSIG TXOP First Frame Exchange in Mixed Fmt */ + /* Values to set : 2 3 */ + /* -------------------------------------------------------------- */ + WID_11N_HT_PROT_TYPE = 0x0085, + + /* 11n RIFS Protection Enable Flag */ + /* -------------------------------------------------------------- */ + /* Configuration : Disable Enable */ + /* Values to set : 0 1 */ + /* -------------------------------------------------------------- */ + WID_11N_RIFS_PROT_ENABLE = 0x0086, + + /* SMPS Mode */ + /* -------------------------------------------------------------- */ + /* Configuration : Static Dynamic MIMO (Power Save Disabled) */ + /* Values to set : 1 2 3 */ + /* -------------------------------------------------------------- */ + WID_11N_SMPS_MODE = 0x0087, + + /* Current transmit MCS */ + /* -------------------------------------------------------------- */ + /* Configuration : MCS Index for data rate */ + /* Values to set : 0 to 7 */ + /* -------------------------------------------------------------- */ + WID_11N_CURRENT_TX_MCS = 0x0088, + + WID_11N_PRINT_STATS = 0x0089, + + /* 11n Short GI Enable Flag */ + /* -------------------------------------------------------------- */ + /* Configuration : Disable Enable */ + /* Values to set : 0 1 */ + /* -------------------------------------------------------------- */ + WID_11N_SHORT_GI_ENABLE = 0x008D, + + /* 11n RIFS Enable Flag */ + /* -------------------------------------------------------------- */ + /* Configuration : Disable Enable */ + /* Values to set : 0 1 */ + /* -------------------------------------------------------------- */ + WID_RIFS_MODE = 0x0094, + + /* TX Abort Feature */ + /* -------------------------------------------------------------- */ + /* Configuration : Disable Self CTS Enable Self CTS */ + /* Values to set : 0 1 */ + /* Configuration : Disable TX Abort Enable TX Abort */ + /* Values to set : 2 3 */ + /* Configuration : Enable HW TX Abort Enable SW TX Abort */ + /* Values to set : 4 5 */ + /* -------------------------------------------------------------- */ + WID_TX_ABORT_CONFIG = 0x00A1, + + WID_REG_TSSI_11B_VALUE = 0x00A6, + WID_REG_TSSI_11G_VALUE = 0x00A7, + WID_REG_TSSI_11N_VALUE = 0x00A8, + WID_TX_CALIBRATION = 0x00A9, + WID_DSCR_TSSI_11B_VALUE = 0x00AA, + WID_DSCR_TSSI_11G_VALUE = 0x00AB, + WID_DSCR_TSSI_11N_VALUE = 0x00AC, + + /* Immediate Block-Ack Support */ + /* -------------------------------------------------------------- */ + /* Configuration : Disable Enable */ + /* Values to set : 0 1 */ + /* -------------------------------------------------------------- */ + WID_11N_IMMEDIATE_BA_ENABLED = 0x00AF, + + /* TXOP Disable Flag */ + /* -------------------------------------------------------------- */ + /* Configuration : Disable Enable */ + /* Values to set : 1 0 */ + /* -------------------------------------------------------------- */ + WID_11N_TXOP_PROT_DISABLE = 0x00B0, + + + WID_TX_POWER_LEVEL_11N = 0x00B1, + + /* Custom Character WID list */ + WID_PC_TEST_MODE = 0x00C8, + /*bug3819: */ + /* SCAN Complete notification WID*/ + WID_SCAN_COMPLETE = 0x00C9, + +#ifdef WILC_AP_EXTERNAL_MLME + WID_DEL_BEACON = 0x00CA, +#endif + + WID_LOGTerminal_Switch = 0x00CD, + /* EMAC Short WID list */ + /* RTS Threshold */ + /* -------------------------------------------------------------- */ + /* Configuration : Any value between 256 to 2347 */ + /* Values to set : Same value. Default is 2347 */ + /* -------------------------------------------------------------- */ + WID_RTS_THRESHOLD = 0x1000, + + /* Fragmentation Threshold */ + /* -------------------------------------------------------------- */ + /* Configuration : Any value between 256 to 2346 */ + /* Values to set : Same value. Default is 2346 */ + /* -------------------------------------------------------------- */ + WID_FRAG_THRESHOLD = 0x1001, + + WID_SHORT_RETRY_LIMIT = 0x1002, + WID_LONG_RETRY_LIMIT = 0x1003, + WID_BEACON_INTERVAL = 0x1006, + WID_MEMORY_ACCESS_16BIT = 0x1008, + WID_RX_SENSE = 0x100B, + WID_ACTIVE_SCAN_TIME = 0x100C, + WID_PASSIVE_SCAN_TIME = 0x100D, + + WID_SITE_SURVEY_SCAN_TIME = 0x100E, + WID_JOIN_START_TIMEOUT = 0x100F, + WID_AUTH_TIMEOUT = 0x1010, + WID_ASOC_TIMEOUT = 0x1011, + WID_11I_PROTOCOL_TIMEOUT = 0x1012, + WID_EAPOL_RESPONSE_TIMEOUT = 0x1013, + + /* NMAC Short WID list */ + WID_11N_SIG_QUAL_VAL = 0x1085, + WID_CCA_THRESHOLD = 0x1087, + + /* Custom Short WID list */ + + /* EMAC Integer WID list */ + WID_FAILED_COUNT = 0x2000, + WID_RETRY_COUNT = 0x2001, + WID_MULTIPLE_RETRY_COUNT = 0x2002, + WID_FRAME_DUPLICATE_COUNT = 0x2003, + WID_ACK_FAILURE_COUNT = 0x2004, + WID_RECEIVED_FRAGMENT_COUNT = 0x2005, + WID_MCAST_RECEIVED_FRAME_COUNT = 0x2006, + WID_FCS_ERROR_COUNT = 0x2007, + WID_SUCCESS_FRAME_COUNT = 0x2008, + WID_HUT_TX_COUNT = 0x200A, + WID_TX_FRAGMENT_COUNT = 0x200B, + WID_TX_MULTICAST_FRAME_COUNT = 0x200C, + WID_RTS_SUCCESS_COUNT = 0x200D, + WID_RTS_FAILURE_COUNT = 0x200E, + WID_WEP_UNDECRYPTABLE_COUNT = 0x200F, + WID_REKEY_PERIOD = 0x2010, + WID_REKEY_PACKET_COUNT = 0x2011, + WID_1X_SERV_ADDR = 0x2012, + WID_STACK_IP_ADDR = 0x2013, + WID_STACK_NETMASK_ADDR = 0x2014, + WID_HW_RX_COUNT = 0x2015, + WID_MEMORY_ADDRESS = 0x201E, + WID_MEMORY_ACCESS_32BIT = 0x201F, + WID_RF_REG_VAL = 0x2021, + + + /* NMAC Integer WID list */ + WID_11N_PHY_ACTIVE_REG_VAL = 0x2080, + + /* Custom Integer WID list */ + WID_GET_INACTIVE_TIME = 0x2084, + WID_SET_DRV_HANDLER = 0X2085, + WID_SET_OPERATION_MODE = 0X2086, + /* EMAC String WID list */ + WID_SSID = 0x3000, + WID_FIRMWARE_VERSION = 0x3001, + WID_OPERATIONAL_RATE_SET = 0x3002, + WID_BSSID = 0x3003, + WID_WEP_KEY_VALUE = 0x3004, + WID_11I_PSK = 0x3008, + WID_11E_P_ACTION_REQ = 0x3009, + WID_1X_KEY = 0x300A, + WID_HARDWARE_VERSION = 0x300B, + WID_MAC_ADDR = 0x300C, + WID_HUT_DEST_ADDR = 0x300D, + WID_PHY_VERSION = 0x300F, + WID_SUPP_USERNAME = 0x3010, + WID_SUPP_PASSWORD = 0x3011, + WID_SITE_SURVEY_RESULTS = 0x3012, + WID_RX_POWER_LEVEL = 0x3013, + WID_DEL_ALL_RX_BA = 0x3014, + WID_SET_STA_MAC_INACTIVE_TIME = 0x3017, + WID_ADD_WEP_KEY = 0x3019, + WID_REMOVE_WEP_KEY = 0x301A, + WID_ADD_PTK = 0x301B, + WID_ADD_RX_GTK = 0x301C, + WID_ADD_TX_GTK = 0x301D, + WID_REMOVE_KEY = 0x301E, + WID_ASSOC_REQ_INFO = 0x301F, + WID_ASSOC_RES_INFO = 0x3020, + WID_MANUFACTURER = 0x3026, /*Added for CAPI tool */ + WID_MODEL_NAME = 0x3027, /*Added for CAPI tool */ + WID_MODEL_NUM = 0x3028, /*Added for CAPI tool */ + WID_DEVICE_NAME = 0x3029, /*Added for CAPI tool */ + + /* NMAC String WID list */ + WID_11N_P_ACTION_REQ = 0x3080, + WID_HUT_TEST_ID = 0x3081, + WID_PMKID_INFO = 0x3082, + WID_FIRMWARE_INFO = 0x3083, + #ifdef WILC_P2P + WID_REGISTER_FRAME = 0x3084, + #endif + WID_DEL_ALL_STA = 0x3085, + #ifdef WILC_P2P + WID_REMAIN_ON_CHAN = 0x3996, + #endif + /*BugID_4156*/ + WID_SSID_PROBE_REQ = 0x3997, + /*BugID_4124 WID to trigger modified Join Request using SSID and BSSID instead of bssListIdx (used by WID_JOIN_REQ)*/ + WID_JOIN_REQ_EXTENDED = 0x3998, + + /* BugID 4951: WID toset IP address in firmware */ + WID_IP_ADDRESS = 0x3999, + + + + /* Custom String WID list */ + + /* EMAC Binary WID list */ + WID_UAPSD_CONFIG = 0x4001, + WID_UAPSD_STATUS = 0x4002, + WID_WMM_AP_AC_PARAMS = 0x4003, + WID_WMM_STA_AC_PARAMS = 0x4004, + WID_NETWORK_INFO = 0x4005, + WID_STA_JOIN_INFO = 0x4006, + WID_CONNECTED_STA_LIST = 0x4007, + + /* NMAC Binary WID list */ + WID_11N_AUTORATE_TABLE = 0x4080, + + + /*Added here by Amr - BugID 4134*/ + WID_SCAN_CHANNEL_LIST = 0x4084, + + /*BugID_3746 WID to add IE to be added in next probe request*/ + WID_INFO_ELEMENT_PROBE = 0x4085, + /*BugID_3746 WID to add IE to be added in next associate request*/ + WID_INFO_ELEMENT_ASSOCIATE = 0x4086, + WID_ADD_STA = 0X4087, + WID_REMOVE_STA = 0X4088, + WID_EDIT_STA = 0X4089, + WID_ADD_BEACON = 0x408a, + + /* BugID 5108 */ + WID_SETUP_MULTICAST_FILTER = 0x408b, + + /* Miscellaneous WIDs */ + WID_ALL = 0x7FFE, + WID_MAX = 0xFFFF +} WID_T; + +int wilc_wlan_init(wilc_wlan_inp_t *inp, wilc_wlan_oup_t *oup); + +void wilc_bus_set_max_speed(void); +void wilc_bus_set_default_speed(void); +uint32_t wilc_get_chipid(uint8_t update); + + +#endif From a30baec189f7db458696118ae02cedd517feff43 Mon Sep 17 00:00:00 2001 From: Johnny Kim Date: Mon, 11 May 2015 14:30:57 +0900 Subject: [PATCH 0528/1163] staging: MAINTAINERS: add maintainer for wilc1000 device Add myself as maintainer for atmel wilc1000 Signed-off-by: Johnny Kim Signed-off-by: Rachel Kim Signed-off-by: Dean Lee Signed-off-by: Chris Park Acked-by: Nicolas Ferre Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index f8e0afb708b4..0c5391f437bb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9496,6 +9496,15 @@ M: Forest Bond S: Odd Fixes F: drivers/staging/vt665?/ +STAGING - WILC1000 WIFI DRIVER +M: Johnny Kim +M: Rachel Kim +M: Dean Lee +M: Chris Park +L: linux-wireless@vger.kernel.org +S: Supported +F: drivers/staging/wilc1000/ + STAGING - XGI Z7,Z9,Z11 PCI DISPLAY DRIVER M: Arnaud Patard S: Odd Fixes From f1a9983002cd9d849b37b88d44c89edef7a291ee Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Wed, 27 May 2015 13:02:16 -0700 Subject: [PATCH 0529/1163] staging: wilc1000: Include linux/gpio.h instead of asm/gpio.h Fix: drivers/staging/wilc1000/linux_wlan.c:18:22: fatal error: asm/gpio.h: No such file or directory Not every architecture has asm/gpio.h. Include linux/gpio.h instead. Signed-off-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 49b238a05a88..18f1bd00201a 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include From e3cb742c3295e7b992d7ecd402fcd5c7675e0e68 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Wed, 27 May 2015 21:32:43 -0700 Subject: [PATCH 0530/1163] staging: wilc1000: Disable for S390 The wilc1000 driver uses definitions such as DEBUG_LEVEL, DEBUG, and PRINT_INFO. This causes compile errors on S390 which has similar definitions in its core code. Disable the driver for S390 instead of giving the non-standard messaging code credit by trying to fix it. Signed-off-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/wilc1000/Kconfig b/drivers/staging/wilc1000/Kconfig index 101f908bc9ed..0b349d3c1475 100644 --- a/drivers/staging/wilc1000/Kconfig +++ b/drivers/staging/wilc1000/Kconfig @@ -1,5 +1,6 @@ config WILC1000 tristate "WILC1000 support (WiFi only)" + depends on !S390 ---help--- This module only support IEEE 802.11n WiFi. From 9535ebc5e9cce28825b1919304e04f4af991ba2c Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Thu, 28 May 2015 16:35:42 +0200 Subject: [PATCH 0531/1163] staging/wilc1000: fix Kconfig dependencies The newly added wilc1000 driver lacks several Kconfig dependencies, resulting in a multitude of randconfig build errors, e.g.: drivers/built-in.o: In function `WILC_WFI_mgmt_tx_cancel_wait': binder.c:(.text+0x12bd28): undefined reference to `cfg80211_remain_on_channel_expired' drivers/built-in.o: In function `WILC_WFI_CfgSetChannel': binder.c:(.text+0x12c9d8): undefined reference to `ieee80211_frequency_to_channel' drivers/built-in.o: In function `WILC_WFI_CfgAlloc': binder.c:(.text+0x132530): undefined reference to `wiphy_new_nm' drivers/built-in.o: In function `wilc_netdev_init': binder.c:(.text+0x1356d0): undefined reference to `register_inetaddr_notifier' drivers/built-in.o: In function `linux_spi_init': binder.c:(.text+0x210a68): undefined reference to `spi_register_driver' This change ensures that we always have at least one of SPI or MMC enabled, and are only able to pick an interface that works. It also adds all the missing dependencies for networking infrastructure (cfg80211, wext, and ipv4). In order to make it readable, I also took the liberty of re-indenting the Kconfig file to the normal conventions. Reported-by: kbuild test robot Signed-off-by: Arnd Bergmann Acked-by: Nicolas Ferre Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/Kconfig | 74 ++++++++++++++++---------------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/drivers/staging/wilc1000/Kconfig b/drivers/staging/wilc1000/Kconfig index 0b349d3c1475..c246b0d904df 100644 --- a/drivers/staging/wilc1000/Kconfig +++ b/drivers/staging/wilc1000/Kconfig @@ -1,56 +1,58 @@ config WILC1000 tristate "WILC1000 support (WiFi only)" depends on !S390 + depends on CFG80211 && WEXT_CORE && INET + depends on MMC || SPI ---help--- - This module only support IEEE 802.11n WiFi. + This module only support IEEE 802.11n WiFi. choice prompt "Memory Allocation" depends on WILC1000 default WILC1000_PREALLOCATE_AT_LOADING_DRIVER - config WILC1000_PREALLOCATE_AT_LOADING_DRIVER - bool "Preallocate memory at loading driver" - ---help--- - This choice supports static allocation of the memory - for the receive buffer. The driver will allocate the RX buffer - during initial time. The driver will also free the buffer - by calling network device stop. +config WILC1000_PREALLOCATE_AT_LOADING_DRIVER + bool "Preallocate memory at loading driver" + ---help--- + This choice supports static allocation of the memory + for the receive buffer. The driver will allocate the RX buffer + during initial time. The driver will also free the buffer + by calling network device stop. - config WILC1000_DYNAMICALLY_ALLOCATE_MEMROY - bool "Dynamically allocate memory in real time" - ---help--- - This choice supports dynamic allocation of the memory - for the receive buffer. The driver will allocate the RX buffer - when it is required. +config WILC1000_DYNAMICALLY_ALLOCATE_MEMROY + bool "Dynamically allocate memory in real time" + ---help--- + This choice supports dynamic allocation of the memory + for the receive buffer. The driver will allocate the RX buffer + when it is required. endchoice - choice - prompt "Bus Type" - depends on WILC1000 - default WILC1000_SDIO - + prompt "Bus Type" + depends on WILC1000 + default WILC1000_SDIO + config WILC1000_SDIO - bool "SDIO support" - depends on MMC - ---help--- - This module adds support for the SDIO interface of adapters using - WILC chipset. Select this if your platform is using the SDIO bus. + bool "SDIO support" + depends on MMC + ---help--- + This module adds support for the SDIO interface + of adapters using WILC chipset. Select this if + your platform is using the SDIO bus. config WILC1000_SPI - bool "SPI support" - ---help--- - This module adds support for the SPI interface of adapters using - WILC chipset. Select this if your platform is using the SPI bus. + depends on SPI + bool "SPI support" + ---help--- + This module adds support for the SPI interface + of adapters using WILC chipset. Select this if + your platform is using the SPI bus. endchoice - config WILC1000_HW_OOB_INTR - bool "Use out of band interrupt" - depends on WILC1000 && WILC1000_SDIO - default n - ---help--- - If your platform don't recognize SDIO IRQ, connect chipset external IRQ pin - and check this option. Or, Use this to get all interrupts including SDIO interrupts. - + bool "Use out of band interrupt" + depends on WILC1000 && WILC1000_SDIO + default n + ---help--- + If your platform don't recognize SDIO IRQ, connect chipset external IRQ pin + and check this option. Or, Use this to get all interrupts including SDIO interrupts. From e5af056149ab91c55199e6633b5e69d370b5226c Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 29 May 2015 22:52:12 +0200 Subject: [PATCH 0532/1163] staging: wilc1000: remove linux version checks For code that is integrated into mainline Linux, checks for the kernel version make no sense, because we know which version we are compiling against. This removes all checks and the associated dead code. Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 88 +--- drivers/staging/wilc1000/wilc_sleep.c | 8 - .../staging/wilc1000/wilc_wfi_cfgoperations.c | 486 +----------------- .../staging/wilc1000/wilc_wfi_cfgoperations.h | 7 +- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 8 - 5 files changed, 5 insertions(+), 592 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 18f1bd00201a..3f8b3c54f196 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -180,7 +180,6 @@ linux_wlan_t *g_linux_wlan; wilc_wlan_oup_t *gpstrWlanOps; WILC_Bool bEnablePS = WILC_TRUE; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) static const struct net_device_ops wilc_netdev_ops = { .ndo_init = mac_init_fn, .ndo_open = mac_open, @@ -191,37 +190,7 @@ static const struct net_device_ops wilc_netdev_ops = { .ndo_set_rx_mode = wilc_set_multicast_list, }; -#define wilc_set_netdev_ops(ndev) do { (ndev)->netdev_ops = &wilc_netdev_ops; } while (0) -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) -static const struct net_device_ops wilc_netdev_ops = { - .ndo_init = mac_init_fn, - .ndo_open = mac_open, - .ndo_stop = mac_close, - .ndo_start_xmit = mac_xmit, - .ndo_do_ioctl = mac_ioctl, - .ndo_get_stats = mac_stats, - .ndo_set_multicast_list = wilc_set_multicast_list, - -}; - -#define wilc_set_netdev_ops(ndev) do { (ndev)->netdev_ops = &wilc_netdev_ops; } while (0) - -#else - -static void wilc_set_netdev_ops(struct net_device *ndev) -{ - - ndev->init = mac_init_fn; - ndev->open = mac_open; - ndev->stop = mac_close; - ndev->hard_start_xmit = mac_xmit; - ndev->do_ioctl = mac_ioctl; - ndev->get_stats = mac_stats; - ndev->set_multicast_list = wilc_set_multicast_list, -} - -#endif #ifdef DEBUG_MODE extern volatile int timeNo; @@ -594,12 +563,7 @@ static void linux_wlan_msleep(uint32_t msc) { if (msc <= 4000000) { WILC_Uint32 u32Temp = msc * 1000; -#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 35) usleep_range(u32Temp, u32Temp); -#else - /* This is delay not sleep !!!, has to be changed*/ - msleep(msc); -#endif } else { msleep(msc); } @@ -2195,7 +2159,6 @@ struct net_device_stats *mac_stats(struct net_device *dev) } /* Setup the multicast filter */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) static void wilc_set_multicast_list(struct net_device *dev) { @@ -2251,55 +2214,6 @@ static void wilc_set_multicast_list(struct net_device *dev) } -#else - -static void wilc_set_multicast_list(struct net_device *dev) -{ - /* BIG Warning, Beware : Uncompiled, untested... */ - struct dev_mc_list *mc_ptr; - int i = 0; - - if (!dev) - return; - - PRINT_D(INIT_DBG, "Setting Multicast List. \n"); - PRINT_D(INIT_DBG, "dev->mc_count = %d\n", dev->mc_count); - - if (dev->flags & IFF_PROMISC) { - /* Normally, we should configure the chip to retrive all packets - * but we don't wanna support this right now */ - /* TODO: add promiscuous mode support */ - PRINT_D(INIT_DBG, "Set promiscuous mode ON, retrive all packets \n"); - return; - } - - /* If there's more addresses than we handle, get all multicast - * packets and sort them out in software. */ - if ((dev->flags & IFF_ALLMULTI) || (dev->mc_count > WILC_MULTICAST_TABLE_SIZE)) { - PRINT_D(INIT_DBG, "Disable multicast filter, retrive all multicast packets\n"); - host_int_setup_multicast_filter((WILC_WFIDrvHandle)gWFiDrvHandle, WILC_FALSE, 0); - return; - } - - /* No multicast? Just get our own stuff */ - if (dev->mc_count == 0) { - PRINT_D(INIT_DBG, "Enable multicast filter, retrive directed packets only.\n"); - host_int_setup_multicast_filter((WILC_WFIDrvHandle)gWFiDrvHandle, WILC_TRUE, 0); - return; - } - - /* Store all of the multicast addresses in the hardware filter */ - - for (mc_ptr = dev->mc_list; mc_ptr; mc_ptr = mc_ptr->next, i++) { - WILC_memcpy(gau8MulticastMacAddrList[i], mc_ptr->dmi_addr, ETH_ALEN) - i++; - } - - host_int_setup_multicast_filter((WILC_WFIDrvHandle)gWFiDrvHandle, WILC_TRUE, (dev->mc_count)); - -} -#endif - static void linux_wlan_tx_complete(void *priv, int status) { @@ -2765,7 +2679,7 @@ int wilc_netdev_init(void) nic->wilc_netdev = ndev; g_linux_wlan->strInterfaceInfo[g_linux_wlan->u8NoIfcs].wilc_netdev = ndev; g_linux_wlan->u8NoIfcs++; - wilc_set_netdev_ops(ndev); + ndev->netdev_ops = &wilc_netdev_ops; #ifdef USE_WIRELESS { diff --git a/drivers/staging/wilc1000/wilc_sleep.c b/drivers/staging/wilc1000/wilc_sleep.c index 368157175f40..b8f45146956b 100644 --- a/drivers/staging/wilc1000/wilc_sleep.c +++ b/drivers/staging/wilc1000/wilc_sleep.c @@ -12,11 +12,7 @@ void WILC_Sleep(WILC_Uint32 u32TimeMilliSec) { if (u32TimeMilliSec <= 4000000) { WILC_Uint32 u32Temp = u32TimeMilliSec * 1000; -#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 35) usleep_range(u32Temp, u32Temp); -#else - udelay(u32Temp); -#endif } else { msleep(u32TimeMilliSec); } @@ -27,10 +23,6 @@ void WILC_Sleep(WILC_Uint32 u32TimeMilliSec) /* #ifdef CONFIG_WILC_SLEEP_HI_RES */ void WILC_SleepMicrosec(WILC_Uint32 u32TimeMicoSec) { - #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 35) usleep_range(u32TimeMicoSec, u32TimeMicoSec); - #else - udelay(u32TimeMicoSec); - #endif } /* #endif */ diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 648472925de0..c1d511825147 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -126,9 +126,7 @@ static struct ieee80211_supported_band WILC_WFI_band_2ghz = { /*BugID_5137*/ struct add_key_params { u8 key_idx; - #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) bool pairwise; - #endif u8 *mac_addr; }; struct add_key_params g_add_gtk_key_params; @@ -202,30 +200,15 @@ void refresh_scan(void *pUserVoid, uint8_t all, WILC_Bool bDirectScan) if (pstrNetworkInfo != WILC_NULL) { - #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38) s32Freq = ieee80211_channel_to_frequency((WILC_Sint32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ); - #else - s32Freq = ieee80211_channel_to_frequency((WILC_Sint32)pstrNetworkInfo->u8channel); - #endif - channel = ieee80211_get_channel(wiphy, s32Freq); rssi = get_rssi_avg(pstrNetworkInfo); if (WILC_memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7) || bDirectScan) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0) bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs, (size_t)pstrNetworkInfo->u16IEsLen, (((WILC_Sint32)rssi) * 100), GFP_KERNEL); -#else - bss = cfg80211_inform_bss(wiphy, channel, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo, - pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs, - (size_t)pstrNetworkInfo->u16IEsLen, (((WILC_Sint32)rssi) * 100), GFP_KERNEL); -#endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0) cfg80211_put_bss(wiphy, bss); -#else - cfg80211_put_bss(bss); -#endif } } @@ -417,11 +400,7 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo } if (pstrNetworkInfo != WILC_NULL) { - #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38) s32Freq = ieee80211_channel_to_frequency((WILC_Sint32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ); - #else - s32Freq = ieee80211_channel_to_frequency((WILC_Sint32)pstrNetworkInfo->u8channel); - #endif channel = ieee80211_get_channel(wiphy, s32Freq); WILC_NULLCHECK(s32Error, channel); @@ -448,20 +427,10 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo /*P2P peers are sent to WPA supplicant and added to shadow table*/ if (!(WILC_memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7))) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0) bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs, (size_t)pstrNetworkInfo->u16IEsLen, (((WILC_Sint32)pstrNetworkInfo->s8rssi) * 100), GFP_KERNEL); -#else - bss = cfg80211_inform_bss(wiphy, channel, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo, - pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs, - (size_t)pstrNetworkInfo->u16IEsLen, (((WILC_Sint32)pstrNetworkInfo->s8rssi) * 100), GFP_KERNEL); -#endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0) cfg80211_put_bss(wiphy, bss); -#else - cfg80211_put_bss(bss); -#endif } @@ -730,27 +699,8 @@ static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent, * @date 01 MAR 2012 * @version 1.0 */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) -/* - * struct changed from v3.8.0 - * tony, sswd, WILC-KR, 2013-10-29 - * struct cfg80211_chan_def { - * struct ieee80211_channel *chan; - * enum nl80211_chan_width width; - * u32 center_freq1; - * u32 center_freq2; - * }; - */ static int WILC_WFI_CfgSetChannel(struct wiphy *wiphy, struct cfg80211_chan_def *chandef) -#else -static int WILC_WFI_CfgSetChannel(struct wiphy *wiphy, - #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32) - struct net_device *netdev, - #endif - struct ieee80211_channel *channel, - enum nl80211_channel_type channel_type) -#endif { WILC_Uint32 channelnum = 0; @@ -758,14 +708,8 @@ static int WILC_WFI_CfgSetChannel(struct wiphy *wiphy, WILC_Sint32 s32Error = WILC_SUCCESS; priv = wiphy_priv(wiphy); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) /* tony for v3.8.0 support */ channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq); PRINT_D(CFG80211_DBG, "Setting channel %d with frequency %d\n", channelnum, chandef->chan->center_freq); -#else - channelnum = ieee80211_frequency_to_channel(channel->center_freq); - - PRINT_D(CFG80211_DBG, "Setting channel %d with frequency %d\n", channelnum, channel->center_freq); -#endif u8CurrChannel = channelnum; s32Error = host_int_set_mac_chnl_num(priv->hWILCWFIDrv, channelnum); @@ -793,11 +737,7 @@ static int WILC_WFI_CfgSetChannel(struct wiphy *wiphy, * kernel version 3.8.8 supported * tony, sswd, WILC-KR, 2013-10-29 */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) static int WILC_WFI_CfgScan(struct wiphy *wiphy, struct cfg80211_scan_request *request) -#else -static int WILC_WFI_CfgScan(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_scan_request *request) -#endif { struct WILC_WFI_priv *priv; WILC_Uint32 i; @@ -807,10 +747,6 @@ static int WILC_WFI_CfgScan(struct wiphy *wiphy, struct net_device *dev, struct priv = wiphy_priv(wiphy); -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0) - PRINT_D(CORECONFIG_DBG, "Scan on netdev [%p] host if [%x]\n", dev, (WILC_Uint32)priv->hWILCWFIDrv); -#endif - /*if(connecting) * return -EBUSY; */ @@ -819,18 +755,10 @@ static int WILC_WFI_CfgScan(struct wiphy *wiphy, struct net_device *dev, struct /*requests "create group" during a running scan*/ /* host_int_set_wfi_drv_handler(priv->hWILCWFIDrv); */ #if 0 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) /* tony for v3.8.0 support */ if (priv->dev->ieee80211_ptr->iftype == NL80211_IFTYPE_AP) { PRINT_D(GENERIC_DBG, "Required scan while in AP mode"); return s32Error; } -#else - if (dev->ieee80211_ptr->iftype == NL80211_IFTYPE_AP) { - PRINT_D(GENERIC_DBG, "Required scan while in AP mode"); - s32Error = WILC_BUSY; - return s32Error; - } -#endif #endif /* end of if 0 */ priv->pstrScanReq = request; @@ -1224,9 +1152,7 @@ static int WILC_WFI_disconnect(struct wiphy *wiphy, struct net_device *dev, u16 * @version 1.0 */ static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, - #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) bool pairwise, - #endif const u8 *mac_addr, struct key_params *params) { @@ -1316,11 +1242,7 @@ static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 k - #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) if (!pairwise) - #else - if (!mac_addr || is_broadcast_ether_addr(mac_addr)) - #endif { if (params->cipher == WLAN_CIPHER_SUITE_TKIP) u8gmode = ENCRYPT_ENABLED | WPA | TKIP; @@ -1419,11 +1341,7 @@ static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 k { u8mode = 0; - #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) if (!pairwise) - #else - if (!mac_addr || is_broadcast_ether_addr(mac_addr)) - #endif { if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { /* swap the tx mic by rx mic */ @@ -1436,9 +1354,7 @@ static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 k /*save keys only on interface 0 (wifi interface)*/ if (!g_gtk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) { g_add_gtk_key_params.key_idx = key_index; - #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) g_add_gtk_key_params.pairwise = pairwise; - #endif if (!mac_addr) { g_add_gtk_key_params.mac_addr = NULL; } else { @@ -1476,9 +1392,7 @@ static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 k /*save keys only on interface 0 (wifi interface)*/ if (!g_ptk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) { g_add_ptk_key_params.key_idx = key_index; - #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) g_add_ptk_key_params.pairwise = pairwise; - #endif if (!mac_addr) { g_add_ptk_key_params.mac_addr = NULL; } else { @@ -1533,9 +1447,7 @@ static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 k */ static int WILC_WFI_del_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, - #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) bool pairwise, - #endif const u8 *mac_addr) { struct WILC_WFI_priv *priv; @@ -1645,9 +1557,7 @@ static int WILC_WFI_del_key(struct wiphy *wiphy, struct net_device *netdev, * @version 1.0 */ static int WILC_WFI_get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, - #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) bool pairwise, - #endif const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *)) { @@ -1659,11 +1569,7 @@ static int WILC_WFI_get_key(struct wiphy *wiphy, struct net_device *netdev, u8 k priv = wiphy_priv(wiphy); - #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) if (!pairwise) - #else - if (!mac_addr || is_broadcast_ether_addr(mac_addr)) - #endif { PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index); @@ -1700,11 +1606,8 @@ static int WILC_WFI_get_key(struct wiphy *wiphy, struct net_device *netdev, u8 k * @date 01 MAR 2012 * @version 1.0 */ -static int WILC_WFI_set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index - #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 37) - , bool unicast, bool multicast - #endif - ) +static int WILC_WFI_set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, + bool unicast, bool multicast) { WILC_Sint32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv; @@ -1794,11 +1697,7 @@ static int WILC_WFI_get_station(struct wiphy *wiphy, struct net_device *dev, return s32Error; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) //0421 sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME); -#else - sinfo->filled |= STATION_INFO_INACTIVE_TIME; -#endif host_int_get_inactive_time(priv->hWILCWFIDrv, mac, &(inactive_time)); sinfo->inactive_time = 1000 * inactive_time; @@ -1816,26 +1715,16 @@ static int WILC_WFI_get_station(struct wiphy *wiphy, struct net_device *dev, * tx_failed introduced more than * kernel version 3.0.0 */ - #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) //0421 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) | BIT( NL80211_STA_INFO_RX_PACKETS) | BIT(NL80211_STA_INFO_TX_PACKETS) | BIT(NL80211_STA_INFO_TX_FAILED) | BIT(NL80211_STA_INFO_TX_BITRATE); - #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0) - sinfo->filled |= STATION_INFO_SIGNAL | STATION_INFO_RX_PACKETS | STATION_INFO_TX_PACKETS - | STATION_INFO_TX_FAILED | STATION_INFO_TX_BITRATE; - #else - sinfo->filled |= STATION_INFO_SIGNAL | STATION_INFO_RX_PACKETS | STATION_INFO_TX_PACKETS - | STATION_INFO_TX_BITRATE; - #endif sinfo->signal = strStatistics.s8RSSI; sinfo->rx_packets = strStatistics.u32RxCount; sinfo->tx_packets = strStatistics.u32TxCount + strStatistics.u32TxFailureCount; - #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0) sinfo->tx_failed = strStatistics.u32TxFailureCount; - #endif sinfo->txrate.legacy = strStatistics.u8LinkSpeed * 10; #ifdef TCP_ENHANCEMENTS @@ -1846,13 +1735,8 @@ static int WILC_WFI_get_station(struct wiphy *wiphy, struct net_device *dev, } #endif - #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0) PRINT_D(CORECONFIG_DBG, "*** stats[%d][%d][%d][%d][%d]\n", sinfo->signal, sinfo->rx_packets, sinfo->tx_packets, sinfo->tx_failed, sinfo->txrate.legacy); - #else - PRINT_D(CORECONFIG_DBG, "*** stats[%d][%d][%d][%d]\n", sinfo->signal, sinfo->rx_packets, sinfo->tx_packets, - sinfo->txrate.legacy); - #endif } return s32Error; } @@ -2008,7 +1892,7 @@ static int WILC_WFI_set_wiphy_params(struct wiphy *wiphy, u32 changed) return s32Error; } -#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32) + /** * @brief WILC_WFI_set_bitrate_mask * @details set the bitrate mask configuration @@ -2166,7 +2050,6 @@ static int WILC_WFI_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) return 0; } -#endif #ifdef WILC_P2P @@ -2388,29 +2271,17 @@ void WILC_WFI_p2p_rx (struct net_device *dev, uint8_t *buff, uint32_t size) if (pkt_offset & IS_MANAGMEMENT_CALLBACK) { if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) { PRINT_D(GENERIC_DBG, "Probe response ACK\n"); - #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0)) - cfg80211_mgmt_tx_status(dev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL); - #else cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL); - #endif return; } else { if (pkt_offset & IS_MGMT_STATUS_SUCCES) { PRINT_D(GENERIC_DBG, "Success Ack - Action frame category: %x Action Subtype: %d Dialog T: %x OR %x\n", buff[ACTION_CAT_ID], buff[ACTION_SUBTYPE_ID], buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]); - #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0)) - cfg80211_mgmt_tx_status(dev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL); - #else cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL); - #endif } else { PRINT_D(GENERIC_DBG, "Fail Ack - Action frame category: %x Action Subtype: %d Dialog T: %x OR %x\n", buff[ACTION_CAT_ID], buff[ACTION_SUBTYPE_ID], buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]); - #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0)) - cfg80211_mgmt_tx_status(dev, priv->u64tx_cookie, buff, size, false, GFP_KERNEL); - #else cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, false, GFP_KERNEL); - #endif } return; } @@ -2420,11 +2291,7 @@ void WILC_WFI_p2p_rx (struct net_device *dev, uint8_t *buff, uint32_t size) /*BugID_5442*/ /*Upper layer is informed that the frame is received on this freq*/ - #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38) s32Freq = ieee80211_channel_to_frequency(u8CurrChannel, IEEE80211_BAND_2GHZ); - #else - s32Freq = ieee80211_channel_to_frequency(u8CurrChannel); - #endif if (ieee80211_is_action(buff[FRAME_TYPE_ID])) { PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]); @@ -2478,18 +2345,7 @@ void WILC_WFI_p2p_rx (struct net_device *dev, uint8_t *buff, uint32_t size) if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP) && (bWilc_ie)) { PRINT_D(GENERIC_DBG, "Sending P2P to host without extra elemnt\n"); /* extra attribute for sig_dbm: signal strength in mBm, or 0 if unknown */ - #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)) cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0); - #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)) - cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0, GFP_ATOMIC); - #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) - cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, GFP_ATOMIC); - #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)) - cfg80211_rx_mgmt(dev, s32Freq, 0, buff, size - 7, GFP_ATOMIC); /* rachel */ - #elif (LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0)) - cfg80211_rx_mgmt(dev, s32Freq, buff, size - 7, GFP_ATOMIC); - #endif - return; } break; @@ -2501,17 +2357,7 @@ void WILC_WFI_p2p_rx (struct net_device *dev, uint8_t *buff, uint32_t size) } } - #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)) cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0); - #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)) - cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0, GFP_ATOMIC); - #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) - cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size, GFP_ATOMIC); - #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)) - cfg80211_rx_mgmt(dev, s32Freq, 0, buff, size, GFP_ATOMIC); - #elif (LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0)) - cfg80211_rx_mgmt(dev, s32Freq, buff, size, GFP_ATOMIC); - #endif } } @@ -2553,20 +2399,11 @@ static void WILC_WFI_RemainOnChannelReady(void *pUserVoid) priv->bInP2PlistenState = WILC_TRUE; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) cfg80211_ready_on_channel(priv->wdev, priv->strRemainOnChanParams.u64ListenCookie, priv->strRemainOnChanParams.pstrListenChan, priv->strRemainOnChanParams.u32ListenDuration, GFP_KERNEL); -#else - cfg80211_ready_on_channel(priv->dev, - priv->strRemainOnChanParams.u64ListenCookie, - priv->strRemainOnChanParams.pstrListenChan, - priv->strRemainOnChanParams.tenuChannelType, - priv->strRemainOnChanParams.u32ListenDuration, - GFP_KERNEL); -#endif } /** @@ -2591,18 +2428,10 @@ static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, WILC_Uint32 u32Sess priv->bInP2PlistenState = WILC_FALSE; /*Inform wpas of remain-on-channel expiration*/ - #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) cfg80211_remain_on_channel_expired(priv->wdev, priv->strRemainOnChanParams.u64ListenCookie, priv->strRemainOnChanParams.pstrListenChan, GFP_KERNEL); - #else - cfg80211_remain_on_channel_expired(priv->dev, - priv->strRemainOnChanParams.u64ListenCookie, - priv->strRemainOnChanParams.pstrListenChan, - priv->strRemainOnChanParams.tenuChannelType, - GFP_KERNEL); - #endif } else { PRINT_D(GENERIC_DBG, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID , priv->strRemainOnChanParams.u32ListenSessionID); @@ -2624,15 +2453,8 @@ static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, WILC_Uint32 u32Sess * @version 1.0 */ static int WILC_WFI_remain_on_channel(struct wiphy *wiphy, -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) struct wireless_dev *wdev, -#else - struct net_device *dev, -#endif struct ieee80211_channel *chan, -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0)) - enum nl80211_channel_type channel_type, -#endif unsigned int duration, u64 *cookie) { WILC_Sint32 s32Error = WILC_SUCCESS; @@ -2645,26 +2467,16 @@ static int WILC_WFI_remain_on_channel(struct wiphy *wiphy, /*This check is to handle the situation when user*/ /*requests "create group" during a running scan*/ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) if (wdev->iftype == NL80211_IFTYPE_AP) { PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode"); return s32Error; } -#else - if (dev->ieee80211_ptr->iftype == NL80211_IFTYPE_AP) { - PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode"); - return s32Error; - } -#endif u8CurrChannel = chan->hw_value; /*Setting params needed by WILC_WFI_RemainOnChannelExpired()*/ priv->strRemainOnChanParams.pstrListenChan = chan; priv->strRemainOnChanParams.u64ListenCookie = *cookie; - #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0)) - priv->strRemainOnChanParams.tenuChannelType = channel_type; - #endif priv->strRemainOnChanParams.u32ListenDuration = duration; priv->strRemainOnChanParams.u32ListenSessionID++; @@ -2693,11 +2505,7 @@ static int WILC_WFI_remain_on_channel(struct wiphy *wiphy, * @version 1.0 */ static int WILC_WFI_cancel_remain_on_channel(struct wiphy *wiphy, -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) struct wireless_dev *wdev, -#else - struct net_device *dev, -#endif u64 cookie) { WILC_Sint32 s32Error = WILC_SUCCESS; @@ -2736,57 +2544,14 @@ void WILC_WFI_add_wilcvendorspec(WILC_Uint8 *buff) extern linux_wlan_t *g_linux_wlan; extern WILC_Bool bEnablePS; int WILC_WFI_mgmt_tx(struct wiphy *wiphy, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0) struct wireless_dev *wdev, struct cfg80211_mgmt_tx_params *params, u64 *cookie) -#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)) - struct wireless_dev *wdev, - struct ieee80211_channel *chan, - bool offchan, - unsigned int wait, - const u8 *buf, - size_t len, - bool no_cck, - bool dont_wait_for_ack, u64 *cookie) -#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) - struct wireless_dev *wdev, - struct ieee80211_channel *chan, bool offchan, - enum nl80211_channel_type channel_type, - bool channel_type valid, - unsigned int wait, const u8 *buf, - size_t len, bool no_cck, - bool dont_wait_for_ack, u64 *cookie) -#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)) - struct net_device *dev, - struct ieee80211_channel *chan, bool offchan, - enum nl80211_channel_type channel_type, - bool channel_type_valid, - unsigned int wait, const u8 *buf, - size_t len, bool no_cck, - bool dont_wait_for_ack, u64 *cookie) -#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)) - struct net_device *dev, - struct ieee80211_channel *chan, bool offchan, - enum nl80211_channel_type channel_type, - bool channel_type_valid, - unsigned int wait, const u8 *buf, - size_t len, bool no_cck, u64 *cookie) -#else - struct net_device *dev, - struct ieee80211_channel *chan, bool offchan, - enum nl80211_channel_type channel_type, - bool channel_type_valid, - unsigned int wait, const u8 *buf, - size_t len, u64 *cookie) -#endif { - #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0) struct ieee80211_channel *chan = params->chan; unsigned int wait = params->wait; const u8 *buf = params->buf; size_t len = params->len; - #endif const struct ieee80211_mgmt *mgmt; struct p2p_mgmt_data *mgmt_tx; struct WILC_WFI_priv *priv; @@ -2796,11 +2561,7 @@ int WILC_WFI_mgmt_tx(struct wiphy *wiphy, perInterface_wlan_t *nic; WILC_Uint32 buf_len = len + sizeof(u8P2P_vendorspec) + sizeof(u8P2Plocalrandom); -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) nic = netdev_priv(wdev->netdev); -#else - nic = netdev_priv(dev); -#endif priv = wiphy_priv(wiphy); pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv; @@ -2938,11 +2699,7 @@ int WILC_WFI_mgmt_tx(struct wiphy *wiphy, } int WILC_WFI_mgmt_tx_cancel_wait(struct wiphy *wiphy, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) struct wireless_dev *wdev, -#else - struct net_device *dev, -#endif u64 cookie) { struct WILC_WFI_priv *priv; @@ -2957,45 +2714,15 @@ int WILC_WFI_mgmt_tx_cancel_wait(struct wiphy *wiphy, if (priv->bInP2PlistenState == WILC_FALSE) { /* Bug 5504: This is just to avoid connection failure when getting stuck when the supplicant * considers the driver falsely that it is in Listen state */ - #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) cfg80211_remain_on_channel_expired(priv->wdev, priv->strRemainOnChanParams.u64ListenCookie, priv->strRemainOnChanParams.pstrListenChan, GFP_KERNEL); - #else - cfg80211_remain_on_channel_expired(priv->dev, - priv->strRemainOnChanParams.u64ListenCookie, - priv->strRemainOnChanParams.pstrListenChan, - priv->strRemainOnChanParams.tenuChannelType, - GFP_KERNEL); - #endif - } return 0; } -/** - * @brief WILC_WFI_action - * @details Transmit an action frame - * @param[in] - * @return int : Return 0 on Success. - * @author mdaftedar - * @date 01 JUL 2012 - * @version 1.0 - * */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) -int WILC_WFI_action(struct wiphy *wiphy, struct net_device *dev, - struct ieee80211_channel *chan, enum nl80211_channel_type channel_type, - const u8 *buf, size_t len, u64 *cookie) -{ - PRINT_D(HOSTAPD_DBG, "In action function\n"); - return WILC_SUCCESS; -} -#endif -#else - /** * @brief WILC_WFI_frame_register * @details Notify driver that a management frame type was @@ -3008,11 +2735,7 @@ int WILC_WFI_action(struct wiphy *wiphy, struct net_device *dev, * @version */ void WILC_WFI_frame_register(struct wiphy *wiphy, -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) struct wireless_dev *wdev, -#else - struct net_device *dev, -#endif u16 frame_type, bool reg) { @@ -3060,7 +2783,6 @@ void WILC_WFI_frame_register(struct wiphy *wiphy, } -#endif #endif /*WILC_P2P*/ /** @@ -3107,11 +2829,7 @@ static int WILC_WFI_dump_station(struct wiphy *wiphy, struct net_device *dev, priv = wiphy_priv(wiphy); /* priv = netdev_priv(priv->wdev->netdev); */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)) //0421 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL); -#else - sinfo->filled |= STATION_INFO_SIGNAL; -#endif host_int_get_rssi(priv->hWILCWFIDrv, &(sinfo->signal)); @@ -3279,18 +2997,14 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, g_linux_wlan->strInterfaceInfo[0].wilc_netdev, g_add_ptk_key_params.key_idx, - #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) g_add_ptk_key_params.pairwise, - #endif g_add_ptk_key_params.mac_addr, (struct key_params *)(&g_key_ptk_params)); WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, g_linux_wlan->strInterfaceInfo[0].wilc_netdev, g_add_gtk_key_params.key_idx, - #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) g_add_gtk_key_params.pairwise, - #endif g_add_gtk_key_params.mac_addr, (struct key_params *)(&g_key_gtk_params)); } @@ -3372,18 +3086,14 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, g_linux_wlan->strInterfaceInfo[0].wilc_netdev, g_add_ptk_key_params.key_idx, - #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) g_add_ptk_key_params.pairwise, - #endif g_add_ptk_key_params.mac_addr, (struct key_params *)(&g_key_ptk_params)); WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, g_linux_wlan->strInterfaceInfo[0].wilc_netdev, g_add_gtk_key_params.key_idx, - #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) g_add_gtk_key_params.pairwise, - #endif g_add_gtk_key_params.mac_addr, (struct key_params *)(&g_key_gtk_params)); } @@ -3531,18 +3241,14 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, g_linux_wlan->strInterfaceInfo[0].wilc_netdev, g_add_ptk_key_params.key_idx, - #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) g_add_ptk_key_params.pairwise, - #endif g_add_ptk_key_params.mac_addr, (struct key_params *)(&g_key_ptk_params)); WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, g_linux_wlan->strInterfaceInfo[0].wilc_netdev, g_add_gtk_key_params.key_idx, - #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) g_add_gtk_key_params.pairwise, - #endif g_add_gtk_key_params.mac_addr, (struct key_params *)(&g_key_gtk_params)); #endif @@ -3574,7 +3280,6 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev return s32Error; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0) /* (austin.2013-07-23) * * To support revised cfg80211_ops @@ -3614,12 +3319,10 @@ static int WILC_WFI_start_ap(struct wiphy *wiphy, struct net_device *dev, PRINT_D(HOSTAPD_DBG, "Interval = %d \n DTIM period = %d\n Head length = %d Tail length = %d\n", settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) s32Error = WILC_WFI_CfgSetChannel(wiphy, &settings->chandef); if (s32Error != WILC_SUCCESS) PRINT_ER("Error in setting channel\n"); -#endif linux_wlan_set_bssid(dev, g_linux_wlan->strInterfaceInfo[0].aSrcAddress); @@ -3718,116 +3421,6 @@ static int WILC_WFI_stop_ap(struct wiphy *wiphy, struct net_device *dev) return s32Error; } -#else /* here belows are original for < kernel 3.3 (austin.2013-07-23) */ - -/** - * @brief WILC_WFI_add_beacon - * @details Add a beacon with given parameters, @head, @interval - * and @dtim_period will be valid, @tail is optional. - * @param[in] wiphy - * @param[in] dev The net device structure - * @param[in] info Parameters for the beacon to be added - * @return int : Return 0 on Success. - * @author mdaftedar - * @date 01 MAR 2012 - * @version 1.0 - */ -static int WILC_WFI_add_beacon(struct wiphy *wiphy, struct net_device *dev, - struct beacon_parameters *info) -{ - WILC_Sint32 s32Error = WILC_SUCCESS; - struct WILC_WFI_priv *priv; - - - - priv = wiphy_priv(wiphy); - PRINT_D(HOSTAPD_DBG, "Adding Beacon\n"); - - PRINT_D(HOSTAPD_DBG, "Interval = %d \n DTIM period = %d\n Head length = %d Tail length = %d\n", info->interval, info->dtim_period, info->head_len, info->tail_len); - - linux_wlan_set_bssid(dev, g_linux_wlan->strInterfaceInfo[0].aSrcAddress); - - #ifndef WILC_FULLY_HOSTING_AP - s32Error = host_int_add_beacon(priv->hWILCWFIDrv, info->interval, - info->dtim_period, - info->head_len, info->head, - info->tail_len, info->tail); - - #else - s32Error = host_add_beacon(priv->hWILCWFIDrv, info->interval, - info->dtim_period, - info->head_len, info->head, - info->tail_len, info->tail); - #endif - - return s32Error; -} - -/** - * @brief WILC_WFI_set_beacon - * @details Change the beacon parameters for an access point mode - * interface. This should reject the call when no beacon has been - * configured. - * @param[in] - * @return int : Return 0 on Success. - * @author mdaftedar - * @date 01 MAR 2012 - * @version 1.0 - */ -static int WILC_WFI_set_beacon(struct wiphy *wiphy, struct net_device *dev, - struct beacon_parameters *info) -{ - WILC_Sint32 s32Error = WILC_SUCCESS; - - - PRINT_D(HOSTAPD_DBG, "Setting beacon\n"); - - s32Error = WILC_WFI_add_beacon(wiphy, dev, info); - - return s32Error; -} - -/** - * @brief WILC_WFI_del_beacon - * @details Remove beacon configuration and stop sending the beacon. - * @param[in] - * @return int : Return 0 on Success. - * @author mdaftedar - * @date 01 MAR 2012 - * @version 1.0 - */ -static int WILC_WFI_del_beacon(struct wiphy *wiphy, struct net_device *dev) -{ - WILC_Sint32 s32Error = WILC_SUCCESS; - struct WILC_WFI_priv *priv; - WILC_Uint8 NullBssid[ETH_ALEN] = {0}; - - - WILC_NULLCHECK(s32Error, wiphy); - - priv = wiphy_priv(wiphy); - - PRINT_D(HOSTAPD_DBG, "Deleting beacon\n"); - - /*BugID_5188*/ - linux_wlan_set_bssid(dev, NullBssid); - - #ifndef WILC_FULLY_HOSTING_AP - s32Error = host_int_del_beacon(priv->hWILCWFIDrv); - #else - s32Error = host_del_beacon(priv->hWILCWFIDrv); - #endif - - WILC_ERRORCHECK(s32Error); - - WILC_CATCH(s32Error) - { - } - return s32Error; -} - -#endif /* linux kernel 3.4+ (austin.2013-07-23) */ - /** * @brief WILC_WFI_add_station * @details Add a new station. @@ -3923,15 +3516,9 @@ static int WILC_WFI_add_station(struct wiphy *wiphy, struct net_device *dev, * @version 1.0 */ static int WILC_WFI_del_station(struct wiphy *wiphy, struct net_device *dev, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) struct station_del_parameters *params) -#else - u8 *mac) -#endif { - #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) u8 *mac = params->mac; - #endif WILC_Sint32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv; perInterface_wlan_t *nic; @@ -4055,35 +3642,14 @@ static int WILC_WFI_change_station(struct wiphy *wiphy, struct net_device *dev, * @date 01 JUL 2012 * @version 1.0 */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0) struct wireless_dev *WILC_WFI_add_virt_intf(struct wiphy *wiphy, const char *name, unsigned char name_assign_type, enum nl80211_iftype type, u32 *flags, struct vif_params *params) -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0) /* tony for v3.8 support */ -struct wireless_dev *WILC_WFI_add_virt_intf(struct wiphy *wiphy, const char *name, - enum nl80211_iftype type, u32 *flags, - struct vif_params *params) -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) /* tony for v3.6 support */ -struct wireless_dev *WILC_WFI_add_virt_intf(struct wiphy *wiphy, char *name, - enum nl80211_iftype type, u32 *flags, - struct vif_params *params) -#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) -int WILC_WFI_add_virt_intf(struct wiphy *wiphy, char *name, - enum nl80211_iftype type, u32 *flags, - struct vif_params *params) -#else -struct net_device *WILC_WFI_add_virt_intf(struct wiphy *wiphy, char *name, - enum nl80211_iftype type, u32 *flags, - struct vif_params *params) -#endif { perInterface_wlan_t *nic; struct WILC_WFI_priv *priv; /* struct WILC_WFI_mon_priv* mon_priv; */ - #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) - WILC_Sint32 s32Error = WILC_SUCCESS; - #endif struct net_device *new_ifc = NULL; priv = wiphy_priv(wiphy); @@ -4110,16 +3676,7 @@ struct net_device *WILC_WFI_add_virt_intf(struct wiphy *wiphy, char *name, } else PRINT_ER("Error in initializing monitor interface\n "); } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) /* tony for v3.8 support */ return priv->wdev; -#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) - return s32Error; -#else - /* return priv->wdev->netdev; */ - PRINT_D(HOSTAPD_DBG, "IFC[%p] created\n", new_ifc); - return new_ifc; -#endif - } /** @@ -4131,11 +3688,7 @@ struct net_device *WILC_WFI_add_virt_intf(struct wiphy *wiphy, char *name, * @date 01 JUL 2012 * @version 1.0 */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) int WILC_WFI_del_virt_intf(struct wiphy *wiphy, struct wireless_dev *wdev) /* tony for v3.8 support */ -#else -int WILC_WFI_del_virt_intf(struct wiphy *wiphy, struct net_device *dev) -#endif { PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n"); return WILC_SUCCESS; @@ -4146,16 +3699,7 @@ int WILC_WFI_del_virt_intf(struct wiphy *wiphy, struct net_device *dev) #endif /*WILC_AP_EXTERNAL_MLME*/ static struct cfg80211_ops WILC_WFI_cfg80211_ops = { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) - /* - * replaced set_channel by set_monitor_channel - * from v3.6 - * tony, 2013-10-29 - */ .set_monitor_channel = WILC_WFI_CfgSetChannel, -#else - .set_channel = WILC_WFI_CfgSetChannel, -#endif .scan = WILC_WFI_CfgScan, .connect = WILC_WFI_CfgConnect, .disconnect = WILC_WFI_disconnect, @@ -4163,24 +3707,15 @@ static struct cfg80211_ops WILC_WFI_cfg80211_ops = { .del_key = WILC_WFI_del_key, .get_key = WILC_WFI_get_key, .set_default_key = WILC_WFI_set_default_key, -#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32) /* .dump_survey = WILC_WFI_dump_survey, */ -#endif #ifdef WILC_AP_EXTERNAL_MLME .add_virtual_intf = WILC_WFI_add_virt_intf, .del_virtual_intf = WILC_WFI_del_virt_intf, .change_virtual_intf = WILC_WFI_change_virt_intf, -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0) - .add_beacon = WILC_WFI_add_beacon, - .set_beacon = WILC_WFI_set_beacon, - .del_beacon = WILC_WFI_del_beacon, -#else - /* supports kernel 3.4+ change. austin.2013-07-23 */ .start_ap = WILC_WFI_start_ap, .change_beacon = WILC_WFI_change_beacon, .stop_ap = WILC_WFI_stop_ap, -#endif .add_station = WILC_WFI_add_station, .del_station = WILC_WFI_del_station, .change_station = WILC_WFI_change_station, @@ -4196,7 +3731,6 @@ static struct cfg80211_ops WILC_WFI_cfg80211_ops = { /* .disassoc = WILC_WFI_disassoc, */ .set_wiphy_params = WILC_WFI_set_wiphy_params, -#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32) /* .set_bitrate_mask = WILC_WFI_set_bitrate_mask, */ .set_pmksa = WILC_WFI_set_pmksa, .del_pmksa = WILC_WFI_del_pmksa, @@ -4205,15 +3739,8 @@ static struct cfg80211_ops WILC_WFI_cfg80211_ops = { .remain_on_channel = WILC_WFI_remain_on_channel, .cancel_remain_on_channel = WILC_WFI_cancel_remain_on_channel, .mgmt_tx_cancel_wait = WILC_WFI_mgmt_tx_cancel_wait, - #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) - .action = WILC_WFI_action, - #endif - #else .mgmt_tx = WILC_WFI_mgmt_tx, .mgmt_frame_register = WILC_WFI_frame_register, - #endif -#endif /* .mgmt_tx_cancel_wait = WILC_WFI_mgmt_tx_cancel_wait, */ .set_power_mgmt = WILC_WFI_set_power_mgmt, .set_cqm_rssi_config = WILC_WFI_set_cqm_rssi_config, @@ -4378,11 +3905,9 @@ struct wireless_dev *WILC_WFI_WiphyRegister(struct net_device *net) /*Maximum number of probed ssid to be added by user for the scan request*/ wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID; - #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32) /*Maximum number of pmkids to be cashed*/ wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS; PRINT_INFO(CFG80211_DBG, "Max number of PMKIDs = %d\n", wdev->wiphy->max_num_pmkids); - #endif wdev->wiphy->max_scan_ie_len = 1000; @@ -4392,20 +3917,15 @@ struct wireless_dev *WILC_WFI_WiphyRegister(struct net_device *net) /*Set the availaible cipher suites*/ wdev->wiphy->cipher_suites = cipher_suites; wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37) /*Setting default managment types: for register action frame: */ wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types; -#endif #ifdef WILC_P2P wdev->wiphy->max_remain_on_channel_duration = 500; /*Setting the wiphy interfcae mode and type before registering the wiphy*/ wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) | BIT(NL80211_IFTYPE_P2P_CLIENT); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0) - wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; -#endif #else wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR); #endif diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h index 9eb8f37542d0..508db6a3f6dd 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h @@ -68,7 +68,6 @@ #define nl80211_SCAN_RESULT_EXPIRE (3 * HZ) #define SCAN_RESULT_EXPIRE (40 * HZ) -#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 30) static const u32 cipher_suites[] = { WLAN_CIPHER_SUITE_WEP40, WLAN_CIPHER_SUITE_WEP104, @@ -76,11 +75,7 @@ static const u32 cipher_suites[] = { WLAN_CIPHER_SUITE_CCMP, WLAN_CIPHER_SUITE_AES_CMAC, }; -#endif - - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37) static const struct ieee80211_txrx_stypes wilc_wfi_cfg80211_mgmt_types[NL80211_IFTYPE_MAX] = { [NL80211_IFTYPE_STATION] = { @@ -110,7 +105,7 @@ static const struct ieee80211_txrx_stypes BIT(IEEE80211_STYPE_DEAUTH >> 4) } }; -#endif + /* Time to stay on the channel */ #define WILC_WFI_DWELL_PASSIVE 100 #define WILC_WFI_DWELL_ACTIVE 40 diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index aa30de932ca4..0abe653acc66 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -49,12 +49,7 @@ #include #include "host_interface.h" #include "wilc_wlan.h" -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 30) -#include -#else #include /* tony, 2013-06-12 */ -#endif - #define FLOW_CONTROL_LOWER_THRESHOLD 128 #define FLOW_CONTROL_UPPER_THRESHOLD 256 @@ -163,9 +158,6 @@ struct WILC_WFI_priv { tstrHostIFpmkidAttr pmkid_list; struct WILC_WFI_stats netstats; WILC_Uint8 WILC_WFI_wep_default; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31) -#define WLAN_KEY_LEN_WEP104 13 -#endif WILC_Uint8 WILC_WFI_wep_key[4][WLAN_KEY_LEN_WEP104]; WILC_Uint8 WILC_WFI_wep_key_len[4]; struct net_device *real_ndev; /* The real interface that the monitor is on */ From 544c69dc83844f9db20af868027df0faf0cf9dd3 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 29 May 2015 22:52:13 +0200 Subject: [PATCH 0533/1163] staging: wilc1000: remove platform version checks For code that is integrated into mainline Linux, checks for the OS platform make no sense, because we know that we are on Linux. This removes all checks and the associated dead code. Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/Makefile | 3 +-- drivers/staging/wilc1000/coreconfigurator.c | 2 -- drivers/staging/wilc1000/wilc_osconfig.h | 15 --------------- drivers/staging/wilc1000/wilc_oswrapper.h | 14 -------------- 4 files changed, 1 insertion(+), 33 deletions(-) diff --git a/drivers/staging/wilc1000/Makefile b/drivers/staging/wilc1000/Makefile index 84bd975ff3be..4aa0d84ba8da 100644 --- a/drivers/staging/wilc1000/Makefile +++ b/drivers/staging/wilc1000/Makefile @@ -13,8 +13,7 @@ ccflags-y += -DSTA_FIRMWARE=\"atmel/wilc1000_fw.bin\" \ ccflags-y += -I$(src)/ -DEXPORT_SYMTAB -D__CHECK_ENDIAN__ -DWILC_ASIC_A0 \ -DPLL_WORKAROUND -DCONNECT_DIRECT -DAGING_ALG \ -DWILC_PARSE_SCAN_IN_HOST -DDISABLE_PWRSAVE_AND_SCAN_DURING_IP \ - -DWILC_PLATFORM=WILC_LINUXKERNEL -Wno-unused-function -DUSE_WIRELESS \ - -DWILC_DEBUGFS + -Wno-unused-function -DUSE_WIRELESS -DWILC_DEBUGFS #ccflags-y += -DTCP_ACK_FILTER ccflags-$(CONFIG_WILC1000_PREALLOCATE_DURING_SYSTEM_BOOT) += -DMEMORY_STATIC \ diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index 01625bdda454..d5a076ed2426 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -2123,7 +2123,6 @@ WILC_Sint32 CoreConfiguratorDeInit(void) #ifndef SIMULATION -#if WILC_PLATFORM != WILC_WIN32 /*Using the global handle of the driver*/ extern wilc_wlan_oup_t *gpstrWlanOps; /** @@ -2198,4 +2197,3 @@ WILC_Sint32 SendConfigPkt(WILC_Uint8 u8Mode, tstrWID *pstrWIDs, return ret; } #endif -#endif diff --git a/drivers/staging/wilc1000/wilc_osconfig.h b/drivers/staging/wilc1000/wilc_osconfig.h index 8e89702c79be..2e3700e2c1ad 100644 --- a/drivers/staging/wilc1000/wilc_osconfig.h +++ b/drivers/staging/wilc1000/wilc_osconfig.h @@ -1,18 +1,3 @@ -/* - * Automatically generated C config: don't edit - * Tue Aug 10 19:52:12 2010 - */ - -/* OSes supported */ -#define WILC_WIN32 0 -#define WILC_NU 1 -#define WILC_MTK 2 -#define WILC_LINUX 3 -#define WILC_LINUXKERNEL 4 -/* the current OS */ -/* #define WILC_PLATFORM WILC_LINUXKERNEL */ - - /* Logs options */ #define WILC_LOGS_NOTHING 0 #define WILC_LOGS_WARN 1 diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index e50267ec1ef4..df288c8be626 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -46,21 +46,7 @@ typedef WILC_Uint16 WILC_WideChar; /* Os Configuration File */ #include "wilc_osconfig.h" - -/* Platform specific include */ -#if WILC_PLATFORM == WILC_WIN32 #include "wilc_platform.h" -#elif WILC_PLATFORM == WILC_NU -#include "wilc_platform.h" -#elif WILC_PLATFORM == WILC_MTK -#include "wilc_platform.h" -#elif WILC_PLATFORM == WILC_LINUX -#include "wilc_platform.h" -#elif WILC_PLATFORM == WILC_LINUXKERNEL -#include "wilc_platform.h" -#else -#error "OS not supported" -#endif /* Logging Functions */ #include "wilc_log.h" From 1999bd52514f90e0dbfb9d2b8a4d7ecb115bb0a5 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 29 May 2015 22:52:14 +0200 Subject: [PATCH 0534/1163] staging: wilc1000: remove thread wrapper The wilc_thread code is a very thin wrapper around kthread, so just remove it and use kthread directly. Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/Makefile | 2 +- drivers/staging/wilc1000/host_interface.c | 16 +-- drivers/staging/wilc1000/wilc_osconfig.h | 3 - drivers/staging/wilc1000/wilc_oswrapper.h | 5 - drivers/staging/wilc1000/wilc_platform.h | 14 -- drivers/staging/wilc1000/wilc_thread.c | 35 ----- drivers/staging/wilc1000/wilc_thread.h | 153 ---------------------- 7 files changed, 8 insertions(+), 220 deletions(-) delete mode 100644 drivers/staging/wilc1000/wilc_thread.c delete mode 100644 drivers/staging/wilc1000/wilc_thread.h diff --git a/drivers/staging/wilc1000/Makefile b/drivers/staging/wilc1000/Makefile index 4aa0d84ba8da..4aa5f6764df4 100644 --- a/drivers/staging/wilc1000/Makefile +++ b/drivers/staging/wilc1000/Makefile @@ -27,7 +27,7 @@ ccflags-$(CONFIG_WILC1000_DYNAMICALLY_ALLOCATE_MEMROY) += -DWILC_NORMAL_ALLOC wilc1000-objs := wilc_wfi_netdevice.o wilc_wfi_cfgoperations.o linux_wlan.o linux_mon.o \ wilc_memory.o wilc_msgqueue.o wilc_semaphore.o wilc_sleep.o wilc_strutils.o \ - wilc_thread.o wilc_time.o wilc_timer.o coreconfigurator.o host_interface.o \ + wilc_time.o wilc_timer.o coreconfigurator.o host_interface.o \ fifo_buffer.o wilc_sdio.o wilc_spi.o wilc_wlan_cfg.o wilc_debugfs.o wilc1000-$(CONFIG_WILC1000_SDIO) += linux_wlan_sdio.o diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index fcbadd1885de..7c764a2ba573 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -543,7 +543,7 @@ tstrWILC_WFIDrv *gWFiDrvHandle = WILC_NULL; WILC_Bool g_obtainingIP = WILC_FALSE; #endif WILC_Uint8 P2P_LISTEN_STATE; -static WILC_ThreadHandle HostIFthreadHandler; +static struct task_struct *HostIFthreadHandler; static WILC_MsgQueueHandle gMsgQHostIF; static WILC_SemaphoreHandle hSemHostIFthrdEnd; @@ -4370,7 +4370,7 @@ static WILC_Sint32 Handle_DelAllRxBASessions(void *drvHandler, tstrHostIfBASessi * @date * @version 1.0 */ -static void hostIFthread(void *pvArg) +static int hostIFthread(void *pvArg) { WILC_Uint32 u32Ret; tstrHostIFmsg strHostIFmsg; @@ -4591,10 +4591,7 @@ static void hostIFthread(void *pvArg) PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n"); WILC_SemaphoreRelease(&hSemHostIFthrdEnd, WILC_NULL); - return; - /* do_exit(error); */ - /* PRINT_D(HOSTINF_DBG,"do_exit error code %d\n",error); */ - + return 0; } static void TimerCB_Scan(void *pvArg) @@ -6683,9 +6680,10 @@ WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) goto _fail_; } msgQ_created = 1; - s32Error = WILC_ThreadCreate(&HostIFthreadHandler, hostIFthread, WILC_NULL, WILC_NULL); - if (s32Error < 0) { + HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread"); + if (IS_ERR(HostIFthreadHandler)) { PRINT_ER("Failed to creat Thread\n"); + s32Error = WILC_FAIL; goto _fail_mq_; } s32Error = WILC_TimerCreate(&(g_hPeriodicRSSI), GetPeriodicRSSI, WILC_NULL); @@ -6788,7 +6786,7 @@ _fail_timer_2: _fail_timer_1: WILC_TimerDestroy(&(pstrWFIDrv->hScanTimer), WILC_NULL); _fail_thread_: - WILC_ThreadDestroy(&HostIFthreadHandler, WILC_NULL); + kthread_stop(HostIFthreadHandler); _fail_mq_: WILC_MsgQueueDestroy(&gMsgQHostIF, WILC_NULL); _fail_: diff --git a/drivers/staging/wilc1000/wilc_osconfig.h b/drivers/staging/wilc1000/wilc_osconfig.h index 2e3700e2c1ad..aa98ea5b423f 100644 --- a/drivers/staging/wilc1000/wilc_osconfig.h +++ b/drivers/staging/wilc1000/wilc_osconfig.h @@ -10,9 +10,6 @@ /* OS features supported */ -#define CONFIG_WILC_THREAD_FEATURE 1 -/* #define CONFIG_WILC_THREAD_SUSPEND_CONTROL 1 */ -/* #define CONFIG_WILC_THREAD_STRICT_PRIORITY 1 */ #define CONFIG_WILC_SEMAPHORE_FEATURE 1 /* #define CONFIG_WILC_SEMAPHORE_TIMEOUT 1 */ #define CONFIG_WILC_SLEEP_FEATURE 1 diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index df288c8be626..03a1ecf90625 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -54,11 +54,6 @@ typedef WILC_Uint16 WILC_WideChar; /* Error reporting and handling support */ #include "wilc_errorsupport.h" -/* Thread support */ -#ifdef CONFIG_WILC_THREAD_FEATURE -#include "wilc_thread.h" -#endif - /* Semaphore support */ #ifdef CONFIG_WILC_SEMAPHORE_FEATURE #include "wilc_semaphore.h" diff --git a/drivers/staging/wilc1000/wilc_platform.h b/drivers/staging/wilc1000/wilc_platform.h index 31d5034cb7fa..87e4eedcc914 100644 --- a/drivers/staging/wilc1000/wilc_platform.h +++ b/drivers/staging/wilc1000/wilc_platform.h @@ -15,18 +15,6 @@ * Feature support checks *******************************************************************/ -/* CONFIG_WILC_THREAD_FEATURE is implemented */ - -/* remove the following block when implementing its feature */ -#ifdef CONFIG_WILC_THREAD_SUSPEND_CONTROL -#error This feature is not supported by this OS -#endif - -/* remove the following block when implementing its feature */ -#ifdef CONFIG_WILC_THREAD_STRICT_PRIORITY -#error This feature is not supported by this OS -#endif - /* CONFIG_WILC_SEMAPHORE_FEATURE is implemented */ /* remove the following block when implementing its feature @@ -140,8 +128,6 @@ * OS specific types *******************************************************************/ -typedef struct task_struct *WILC_ThreadHandle; - typedef void *WILC_MemoryPoolHandle; typedef struct semaphore WILC_SemaphoreHandle; diff --git a/drivers/staging/wilc1000/wilc_thread.c b/drivers/staging/wilc1000/wilc_thread.c deleted file mode 100644 index 5eb04e839309..000000000000 --- a/drivers/staging/wilc1000/wilc_thread.c +++ /dev/null @@ -1,35 +0,0 @@ - -#include "wilc_oswrapper.h" - -#ifdef CONFIG_WILC_THREAD_FEATURE - - - -WILC_ErrNo WILC_ThreadCreate(WILC_ThreadHandle *pHandle, tpfWILC_ThreadFunction pfEntry, - void *pvArg, tstrWILC_ThreadAttrs *pstrAttrs) -{ - - - *pHandle = kthread_run((int (*)(void *))pfEntry, pvArg, "WILC_kthread"); - - - if (IS_ERR(*pHandle)) { - return WILC_FAIL; - } else { - return WILC_SUCCESS; - } - -} - -WILC_ErrNo WILC_ThreadDestroy(WILC_ThreadHandle *pHandle, - tstrWILC_ThreadAttrs *pstrAttrs) -{ - WILC_ErrNo s32RetStatus = WILC_SUCCESS; - - kthread_stop(*pHandle); - return s32RetStatus; -} - - - -#endif diff --git a/drivers/staging/wilc1000/wilc_thread.h b/drivers/staging/wilc1000/wilc_thread.h deleted file mode 100644 index c862cd544dd4..000000000000 --- a/drivers/staging/wilc1000/wilc_thread.h +++ /dev/null @@ -1,153 +0,0 @@ -#ifndef __WILC_THREAD_H__ -#define __WILC_THREAD_H__ - -/*! - * @file wilc_thread.h - * @brief Thread OS Wrapper functionality - * @author syounan - * @sa wilc_oswrapper.h top level OS wrapper file - * @date 10 Aug 2010 - * @version 1.0 - */ - -#ifndef CONFIG_WILC_THREAD_FEATURE -#error the feature WILC_OS_FEATURE_THREAD must be supported to include this file -#endif - -typedef void (*tpfWILC_ThreadFunction)(void *); - -typedef enum { - #ifdef CONFIG_WILC_THREAD_STRICT_PRIORITY - WILC_OS_THREAD_PIORITY_0 = 0, - WILC_OS_THREAD_PIORITY_1 = 1, - WILC_OS_THREAD_PIORITY_2 = 2, - WILC_OS_THREAD_PIORITY_3 = 3, - WILC_OS_THREAD_PIORITY_4 = 4, - #endif - - WILC_OS_THREAD_PIORITY_HIGH = 0, - WILC_OS_THREAD_PIORITY_NORMAL = 2, - WILC_OS_THREAD_PIORITY_LOW = 4 -} tenuWILC_ThreadPiority; - -/*! - * @struct WILC_ThreadAttrs - * @brief Thread API options - * @author syounan - * @date 10 Aug 2010 - * @version 1.0 - */ -typedef struct { - /*!< - * stack size for use with WILC_ThreadCreate, default is WILC_OS_THREAD_DEFAULT_STACK - */ - WILC_Uint32 u32StackSize; - - /*!< - * piority for the thread, if WILC_OS_FEATURE_THREAD_STRICT_PIORITY is defined - * this value is strictly observed and can take a larger resolution - */ - tenuWILC_ThreadPiority enuPiority; - - #ifdef CONFIG_WILC_THREAD_SUSPEND_CONTROL - /*! - * if true the thread will be created suspended - */ - WILC_Bool bStartSuspended; - #endif - -} tstrWILC_ThreadAttrs; - -#define WILC_OS_THREAD_DEFAULT_STACK (10 * 1024) - -/*! - * @brief Fills the WILC_ThreadAttrs with default parameters - * @param[out] pstrAttrs structure to be filled - * @sa WILC_ThreadAttrs - * @author syounan - * @date 10 Aug 2010 - * @version 1.0 - */ - -static void WILC_ThreadFillDefault(tstrWILC_ThreadAttrs *pstrAttrs) -{ - pstrAttrs->u32StackSize = WILC_OS_THREAD_DEFAULT_STACK; - pstrAttrs->enuPiority = WILC_OS_THREAD_PIORITY_NORMAL; - - #ifdef CONFIG_WILC_THREAD_SUSPEND_CONTROL - pstrAttrs->bStartSuspended = WILC_FALSE; - #endif -} - -/*! - * @brief Creates a new thread - * @details if the feature WILC_OS_FEATURE_THREAD_SUSPEND_CONTROL is - * defined and tstrWILC_ThreadAttrs.bStartSuspended is set to true - * the new thread will be created in suspended state, otherwise - * it will start executing immeadiately - * if the feature WILC_OS_FEATURE_THREAD_STRICT_PIORITY is defined - * piorities are strictly observed, otherwise the underlaying OS - * may not observe piorities - * @param[out] pHandle handle to the newly created thread object - * @param[in] pfEntry pointer to the entry point of the new thread - * @param[in] pstrAttrs Optional attributes, NULL for default - * @return Error code indicating sucess/failure - * @sa WILC_ThreadAttrs - * @author syounan - * @date 10 Aug 2010 - * @version 1.0 - */ -WILC_ErrNo WILC_ThreadCreate(WILC_ThreadHandle *pHandle, tpfWILC_ThreadFunction pfEntry, - void *pvArg, tstrWILC_ThreadAttrs *pstrAttrs); - -/*! - * @brief Destroys the Thread object - * @details This function is used for clean up and freeing any used resources - * This function will block until the destroyed thread exits cleanely, - * so, the thread code thould handle an exit case before this calling - * this function - * @param[in] pHandle handle to the thread object - * @param[in] pstrAttrs Optional attributes, NULL for default - * @return Error code indicating sucess/failure - * @sa WILC_ThreadAttrs - * @author syounan - * @date 10 Aug 2010 - * @version 1.0 - */ -WILC_ErrNo WILC_ThreadDestroy(WILC_ThreadHandle *pHandle, - tstrWILC_ThreadAttrs *pstrAttrs); - -#ifdef CONFIG_WILC_THREAD_SUSPEND_CONTROL - -/*! - * @brief Suspends an executing Thread object - * @param[in] pHandle handle to the thread object - * @param[in] pstrAttrs Optional attributes, NULL for default - * @return Error code indicating sucess/failure - * @sa WILC_ThreadAttrs - * @note Optional part, WILC_OS_FEATURE_THREAD_SUSPEND_CONTROL must be enabled - * @author syounan - * @date 10 Aug 2010 - * @version 1.0 - */ -WILC_ErrNo WILC_ThreadSuspend(WILC_ThreadHandle *pHandle, - tstrWILC_ThreadAttrs *pstrAttrs); - -/*! - * @brief Resumes a suspened Thread object - * @param[in] pHandle handle to the thread object - * @param[in] pstrAttrs Optional attributes, NULL for default - * @return Error code indicating sucess/failure - * @sa WILC_ThreadAttrs - * @note Optional part, WILC_OS_FEATURE_THREAD_SUSPEND_CONTROL must be enabled - * @author syounan - * @date 10 Aug 2010 - * @version 1.0 - */ -WILC_ErrNo WILC_ThreadResume(WILC_ThreadHandle *pHandle, - tstrWILC_ThreadAttrs *pstrAttrs); - -#endif - - -#endif From 691f1a2f035d345c5a908c5c1e2a158dde6c93fa Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 29 May 2015 22:52:15 +0200 Subject: [PATCH 0535/1163] staging: wilc1000: remove __DRIVER_VERSION__ macro The driver version is meaningless, and in particular does not have to be passed from the Makefile. This removes the macros, but leaves the behavior of printing the 10.2 version untouched for the moment. Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/Makefile | 6 ------ drivers/staging/wilc1000/linux_wlan.c | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/wilc1000/Makefile b/drivers/staging/wilc1000/Makefile index 4aa5f6764df4..13e3ed8ef31e 100644 --- a/drivers/staging/wilc1000/Makefile +++ b/drivers/staging/wilc1000/Makefile @@ -32,9 +32,3 @@ wilc1000-objs := wilc_wfi_netdevice.o wilc_wfi_cfgoperations.o linux_wlan.o linu wilc1000-$(CONFIG_WILC1000_SDIO) += linux_wlan_sdio.o wilc1000-$(CONFIG_WILC1000_SPI) += linux_wlan_spi.o - -WILC1000_SRC_VERSION = 10.0 -PATCHLEVEL = 2 -WILC1000_FW_VERSION = 0 - -ccflags-y += -D__DRIVER_VERSION__=\"$(WILC1000_SRC_VERSION).$(PATCHLEVEL)\" diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 3f8b3c54f196..2a74441af09e 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -2747,7 +2747,7 @@ static int __init init_wilc_driver(void) #endif printk("IN INIT FUNCTION\n"); - printk("*** WILC1000 driver VERSION=[%s] FW_VER=[%s] ***\n", __DRIVER_VERSION__, __DRIVER_VERSION__); + printk("*** WILC1000 driver VERSION=[10.2] FW_VER=[10.2] ***\n"); linux_wlan_device_power(1); msleep(100); From adf1b358a9c97b8d73dc91ade96f2a9f225921e1 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Thu, 28 May 2015 11:03:56 -0400 Subject: [PATCH 0536/1163] staging: wilc1000: off by one in wilc_wfi_cfg80211_mgmt_types NL80211_IFTYPE_MAX represents the largest interface type number defined, so declaring the array with that size will actually leave out the last interface. This causes invalid memory access whenever this array is used, which starts happening at boot. Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wfi_cfgoperations.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h index 508db6a3f6dd..829ba32ea210 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h @@ -77,7 +77,7 @@ static const u32 cipher_suites[] = { }; static const struct ieee80211_txrx_stypes - wilc_wfi_cfg80211_mgmt_types[NL80211_IFTYPE_MAX] = { + wilc_wfi_cfg80211_mgmt_types[NUM_NL80211_IFTYPES] = { [NL80211_IFTYPE_STATION] = { .tx = 0xffff, .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | From 24b44e0c0b16405c597a23a3f2b3f70a055e3db8 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 13 May 2015 23:25:56 +0100 Subject: [PATCH 0537/1163] lustre: kill unused macro (LOOKUP_CONTINUE) Signed-off-by: Al Viro Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_internal.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 1253b3cf50a8..bf8f1541546c 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -57,12 +57,6 @@ #define VM_FAULT_RETRY 0 #endif -/* Kernel 3.1 kills LOOKUP_CONTINUE, LOOKUP_PARENT is equivalent to it. - * seem kernel commit 49084c3bb2055c401f3493c13edae14d49128ca0 */ -#ifndef LOOKUP_CONTINUE -#define LOOKUP_CONTINUE LOOKUP_PARENT -#endif - /** Only used on client-side for indicating the tail of dir hash/offset. */ #define LL_DIR_END_OFF 0x7fffffffffffffffULL #define LL_DIR_END_OFF_32BIT 0x7fffffffUL From 907b8a0012934c95f8074f68a018aa0c120409b9 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 13 May 2015 23:25:57 +0100 Subject: [PATCH 0538/1163] lustre: kill unused helper Signed-off-by: Al Viro Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/linux/lustre_compat25.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index 3925db160650..513c81f43d6e 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -189,22 +189,7 @@ static inline int ll_quota_off(struct super_block *sb, int off, int remount) #endif - -/* - * After 3.1, kernel's nameidata.intent.open.flags is different - * with lustre's lookup_intent.it_flags, as lustre's it_flags' - * lower bits equal to FMODE_xxx while kernel doesn't transliterate - * lower bits of nameidata.intent.open.flags to FMODE_xxx. - * */ #include -static inline int ll_namei_to_lookup_intent_flag(int flag) -{ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0) - flag = (flag & ~O_ACCMODE) | OPEN_FMODE(flag); -#endif - return flag; -} - #include # define ll_umode_t umode_t From 109a1624e37fed4b11841daf8ae05395a03a5fde Mon Sep 17 00:00:00 2001 From: Ankit Garg Date: Wed, 6 May 2015 11:03:23 +0530 Subject: [PATCH 0539/1163] staging: lustre: lclient: lcommon_cl.c fixing coding style issues This patch fixes the checkpatch.pl warning: WARNING: else is not generally useful after a break or return + return result; + } else { Signed-off-by: Ankit Garg Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/lclient/lcommon_cl.c | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c index 19448fe52cfd..e0c1ccafbd63 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c +++ b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c @@ -836,25 +836,24 @@ int ccc_prep_size(const struct lu_env *env, struct cl_object *obj, *exceed = 1; } return result; - } else { - /* - * region is within kms and, hence, within real file - * size (A). We need to increase i_size to cover the - * read region so that generic_file_read() will do its - * job, but that doesn't mean the kms size is - * _correct_, it is only the _minimum_ size. If - * someone does a stat they will get the correct size - * which will always be >= the kms value here. - * b=11081 - */ - if (cl_isize_read(inode) < kms) { - cl_isize_write_nolock(inode, kms); - CDEBUG(D_VFSTRACE, - DFID" updating i_size %llu\n", - PFID(lu_object_fid(&obj->co_lu)), - (__u64)cl_isize_read(inode)); + } + /* + * region is within kms and, hence, within real file + * size (A). We need to increase i_size to cover the + * read region so that generic_file_read() will do its + * job, but that doesn't mean the kms size is + * _correct_, it is only the _minimum_ size. If + * someone does a stat they will get the correct size + * which will always be >= the kms value here. + * b=11081 + */ + if (cl_isize_read(inode) < kms) { + cl_isize_write_nolock(inode, kms); + CDEBUG(D_VFSTRACE, + DFID" updating i_size %llu\n", + PFID(lu_object_fid(&obj->co_lu)), + (__u64)cl_isize_read(inode)); - } } } ccc_object_size_unlock(obj); From 58973deb5b831eafa3eb04efe8ed85dbfe52aa18 Mon Sep 17 00:00:00 2001 From: "Gunasundar, Balamanikandan (B.)" Date: Tue, 12 May 2015 10:35:52 +0000 Subject: [PATCH 0540/1163] Staging: lustre: Replace kzalloc and memcpy by kmemdup This patch was generated by 'make coccicheck' Signed-off-by: Balamanikandan Gunasundar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 57c6ddd95f3e..c988be4fc049 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1711,13 +1711,12 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) goto destroy_new; } /* not found - create */ - buffer = kzalloc(LNET_NIDSTR_SIZE, GFP_NOFS); + buffer = kmemdup(libcfs_nid2str(*nid), LNET_NIDSTR_SIZE, GFP_NOFS); if (buffer == NULL) { rc = -ENOMEM; goto destroy_new; } - memcpy(buffer, libcfs_nid2str(*nid), LNET_NIDSTR_SIZE); new_stat->nid_proc = lprocfs_register(buffer, obd->obd_proc_exports_entry, NULL, NULL); From db562e8154035b2dec9fc8e506450bc52a9adbe1 Mon Sep 17 00:00:00 2001 From: "Gujulan Elango, Hari Prasath (H.)" Date: Wed, 13 May 2015 10:36:28 +0000 Subject: [PATCH 0541/1163] staging: lustre: check kzalloc return value check the return value of kzalloc before accessing the memory pointer Signed-off-by: Hari Prasath Gujulan Elango Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_lib.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 61acc70aaae4..e759da3a1b5e 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -284,6 +284,10 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, char *buf; buf = kzalloc(PAGE_CACHE_SIZE, GFP_KERNEL); + if (!buf) { + err = -ENOMEM; + goto out_md_fid; + } obd_connect_flags2str(buf, PAGE_CACHE_SIZE, valid ^ CLIENT_CONNECT_MDT_REQD, ","); LCONSOLE_ERROR_MSG(0x170, "Server %s does not support feature(s) needed for correct operation of this client (%s). Please upgrade server or downgrade client.\n", From e3bf98f71d25fdf7de4a82f16210e20502b71045 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Fri, 15 May 2015 21:40:18 +0300 Subject: [PATCH 0542/1163] staging/lustre: Remove __attribute__ definition from libcfs.h Linux requires a GNU C compatible compiler so drop a pointless define. Signed-off-by: Pekka Enberg Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/libcfs.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h index 947df7eeca87..244f1aaecad2 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h @@ -37,10 +37,6 @@ #ifndef __LIBCFS_LIBCFS_H__ #define __LIBCFS_LIBCFS_H__ -#if !__GNUC__ -#define __attribute__(x) -#endif - #include "linux/libcfs.h" #include From 36fc24486910d492881f279cb97ad33b69859ebd Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Fri, 15 May 2015 21:40:19 +0300 Subject: [PATCH 0543/1163] staging/lustre: Remove duplicate helpers from libcfs.h Remove bunch of duplicate helpers from libcfs.h that are guaranteed to be present. Signed-off-by: Pekka Enberg Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/libcfs/libcfs.h | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h index 244f1aaecad2..a789559b81c2 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h @@ -42,25 +42,6 @@ #include "curproc.h" -#ifndef offsetof -# define offsetof(typ, memb) ((long)(long_ptr_t)((char *)&(((typ *)0)->memb))) -#endif - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(a) ((sizeof(a)) / (sizeof((a)[0]))) -#endif - -#if !defined(swap) -#define swap(x, y) do { typeof(x) z = x; x = y; y = z; } while (0) -#endif - -#if !defined(container_of) -/* given a pointer @ptr to the field @member embedded into type (usually - * struct) @type, return pointer to the embedding instance of @type. */ -#define container_of(ptr, type, member) \ - ((type *)((char *)(ptr)-(char *)(&((type *)0)->member))) -#endif - static inline int __is_po2(unsigned long long val) { return !(val & (val - 1)); From 322489d9d551d20bfa69feef85729b82dc2edebc Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Fri, 15 May 2015 21:40:20 +0300 Subject: [PATCH 0544/1163] staging/lustre: Use roundup_pow_of_two() in LNetEQAlloc() Use roundup_pow_of_two() and drop the private cfs_power2_roundup() implementation. Signed-off-by: Pekka Enberg Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/libcfs/libcfs_private.h | 13 ------------- drivers/staging/lustre/lnet/lnet/lib-eq.c | 2 +- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h index fef882530455..d8f8543de573 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h @@ -496,19 +496,6 @@ static inline size_t cfs_round_strlen(char *fset) return (size_t)cfs_size_round((int)strlen(fset) + 1); } -/* roundup \a val to power2 */ -static inline unsigned int cfs_power2_roundup(unsigned int val) -{ - if (val != LOWEST_BIT_SET(val)) { /* not a power of 2 already */ - do { - val &= ~LOWEST_BIT_SET(val); - } while (val != LOWEST_BIT_SET(val)); - /* ...and round up */ - val <<= 1; - } - return val; -} - #define LOGL(var, len, ptr) \ do { \ if (var) \ diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c index 5470148f5b64..1221c0bad107 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c @@ -79,7 +79,7 @@ LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback, * overflow, they don't skip entries, so the queue has the same * apparent capacity at all times */ - count = cfs_power2_roundup(count); + count = roundup_pow_of_two(count); if (callback != LNET_EQ_HANDLER_NONE && count != 0) CWARN("EQ callback is guaranteed to get every event, do you still want to set eqcount %d for polling event which will have locking overhead? Please contact with developer to confirm\n", count); From 77198552a481192fe9c7ce6cfd8a54231598a71a Mon Sep 17 00:00:00 2001 From: "Gujulan Elango, Hari Prasath (H.)" Date: Tue, 12 May 2015 10:01:18 +0000 Subject: [PATCH 0545/1163] staging: rtl8723au: remove redundant initialization The variable pHalData is initialized twice in this same function with same value.So removing one of them. Signed-off-by: Hari Prasath Gujulan Elango Acked-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c index 11e1108d0c56..9733aa6ef908 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c @@ -55,7 +55,7 @@ int FillH2CCmd(struct rtw_adapter *padapter, u8 ElementID, u32 CmdLen, u8 h2c_box_num; u32 msgbox_addr; u32 msgbox_ex_addr; - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); + struct hal_data_8723a *pHalData; u32 h2c_cmd = 0; u16 h2c_cmd_ex = 0; int ret = _FAIL; From 711c9b3ce441fc0e373ab0f7487dd6ce01117d61 Mon Sep 17 00:00:00 2001 From: Juston Li Date: Fri, 22 May 2015 22:03:04 -0700 Subject: [PATCH 0546/1163] staging: rtl8723au: fix sparse warning change cast to __le16 to fix the following warning: drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:1488:20: warning: cast to restricted __le16 Signed-off-by: Juston Li 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 efe173072ad5..cb5076abda8b 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1485,7 +1485,7 @@ void Hal_EfuseParseIDCode(struct rtw_adapter *padapter, u8 *hwinfo) u16 EEPROMId; /* Checl 0x8129 again for making sure autoload status!! */ - EEPROMId = le16_to_cpu(*((u16 *) hwinfo)); + EEPROMId = le16_to_cpu(*((__le16 *) hwinfo)); if (EEPROMId != RTL_EEPROM_ID) { DBG_8723A("EEPROM ID(%#x) is invalid!!\n", EEPROMId); pEEPROM->bautoload_fail_flag = true; From b2f23a2d71dd5ed3a0eed70e37db32b99d774c69 Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Tue, 19 May 2015 11:35:20 +0200 Subject: [PATCH 0547/1163] staging: rtl8723au: remove useless return value The loadparam() function cannot fail, it's called only once and its return value is ignored there. Signed-off-by: Luca Ceresoli Cc: Greg Kroah-Hartman Cc: Larry Finger Cc: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/os_intfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 83696360c293..fab1e608fdc6 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -172,7 +172,7 @@ MODULE_PARM_DESC(debug, "Set debug level (1-9) (default 1)"); static int netdev_close(struct net_device *pnetdev); -static int loadparam(struct rtw_adapter *padapter, struct net_device *pnetdev) +static void loadparam(struct rtw_adapter *padapter, struct net_device *pnetdev) { struct registry_priv *registry_par = &padapter->registrypriv; @@ -233,7 +233,6 @@ static int loadparam(struct rtw_adapter *padapter, struct net_device *pnetdev) snprintf(registry_par->if2name, 16, "%s", if2name); registry_par->notch_filter = (u8)rtw_notch_filter; registry_par->regulatory_tid = (u8)rtw_regulatory_id; - return _SUCCESS; } static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p) From e630eb48ff320b52ea1a1237e8ed0d23e4e9e900 Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Tue, 19 May 2015 11:35:21 +0200 Subject: [PATCH 0548/1163] staging: rtl8723au: remove useless comment "step 2" does mean much as there is no "step 1" stated anywhere... Signed-off-by: Luca Ceresoli Cc: Greg Kroah-Hartman Cc: Larry Finger Cc: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/os_intfs.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index fab1e608fdc6..b8848c25beb4 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -371,7 +371,6 @@ struct net_device *rtw_init_netdev23a(struct rtw_adapter *old_padapter) pnetdev->watchdog_timeo = HZ*3; /* 3 second timeout */ - /* step 2. */ loadparam(padapter, pnetdev); return pnetdev; } From 65609bd672e4fb232f81010b96ef8892833276b7 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sat, 16 May 2015 03:38:31 -0400 Subject: [PATCH 0549/1163] staging/lustre: Only set INTERRUPTIBLE state before calling schedule In __l_wait_event the condition could be a complicated function that does allocations and other potentialy blocking activities, so it sohuld not be called in a task state other than RUNNABLE Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/include/lustre_lib.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h b/drivers/staging/lustre/lustre/include/lustre_lib.h index bf135630c39a..43ee9f0eb4d4 100644 --- a/drivers/staging/lustre/lustre/include/lustre_lib.h +++ b/drivers/staging/lustre/lustre/include/lustre_lib.h @@ -549,19 +549,13 @@ do { \ __blocked = cfs_block_sigsinv(0); \ \ for (;;) { \ - unsigned __wstate; \ - \ - __wstate = info->lwi_on_signal != NULL && \ - (__timeout == 0 || __allow_intr) ? \ - TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE; \ - \ - set_current_state(TASK_INTERRUPTIBLE); \ - \ if (condition) \ break; \ \ + set_current_state(TASK_INTERRUPTIBLE); \ + \ if (__timeout == 0) { \ - schedule(); \ + schedule(); \ } else { \ long interval = info->lwi_interval? \ min_t(long, \ @@ -582,6 +576,8 @@ do { \ } \ } \ \ + set_current_state(TASK_RUNNING); \ + \ if (condition) \ break; \ if (cfs_signal_pending()) { \ @@ -605,7 +601,6 @@ do { \ \ cfs_restore_sigs(__blocked); \ \ - set_current_state(TASK_RUNNING); \ remove_wait_queue(&wq, &__wait); \ } while (0) From 38bbb63d94cd024d76db7d39594ae0bc605dd16c Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sat, 16 May 2015 03:38:32 -0400 Subject: [PATCH 0550/1163] staging/lustre/ptlrpc: Fix wrong indenting in plain_authorize() smatch highlighted a wrongly indented bit of code that almost hides the extra assignment. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/sec_plain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c index 989cdcda27b5..65f3ab42829c 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c @@ -870,7 +870,7 @@ int plain_authorize(struct ptlrpc_request *req) lustre_msg_buf(msg, PLAIN_PACK_MSG_OFF, 0), lustre_msg_buflen(msg, PLAIN_PACK_MSG_OFF), NULL, 0, (unsigned char *)&msg->lm_cksum, &hsize); - req->rq_reply_off = 0; + req->rq_reply_off = 0; } return 0; From 3959d0cb7e6e1a00cf815278901929534709e72a Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sat, 16 May 2015 03:38:33 -0400 Subject: [PATCH 0551/1163] staging/lustre/ptlrpc: Fix potential NULL pointer dereference In lov_unpackmd() there's this strange bit of code where we first try to look inside of lmm striping pattern for it's type, and then we check if the pattern is NULL which cannot be right. Move the check under if (lmm) branch so that it's safe. Found by Coverity version 6.6.1 Signed-off-by: Sebastien Buisson Reviewed-on: http://review.whamcloud.com/7827 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4049 Reviewed-by: John L. Hammond Reviewed-by: jacques-Charles Lafoucriere Signed-off: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lov/lov_pack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c index 5356d5324176..92b9ffece4a0 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c @@ -367,9 +367,11 @@ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, if (rc) return rc; magic = le32_to_cpu(lmm->lmm_magic); + pattern = le32_to_cpu(lmm->lmm_pattern); } else { magic = LOV_MAGIC; stripe_count = lov_get_stripecnt(lov, magic, 0); + pattern = LOV_PATTERN_RAID0; } /* If we aren't passed an lsmp struct, we just want the size */ @@ -384,7 +386,6 @@ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, return 0; } - pattern = le32_to_cpu(lmm->lmm_pattern); lsm_size = lov_alloc_memmd(lsmp, stripe_count, pattern, magic); if (lsm_size < 0) return lsm_size; From a612b007280192743f52a8fb764aefbeca05f188 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sat, 16 May 2015 03:38:34 -0400 Subject: [PATCH 0552/1163] staging/lustre/llite: Fix wrong identing in ll_setxattr_common smatch has highlighted wrong indenting that results from commit 7fc1f831d83f ("staging/lustre/llite: extended attribute cache") Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/xattr.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index e0fcbe1395fd..362a87d0d0d3 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -188,11 +188,11 @@ int ll_setxattr_common(struct inode *inode, const char *name, valid |= rce_ops2valid(rce->rce_ops); } #endif - oc = ll_mdscapa_get(inode); - rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), oc, - valid, name, pv, size, 0, flags, - ll_i2suppgid(inode), &req); - capa_put(oc); + oc = ll_mdscapa_get(inode); + rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), oc, + valid, name, pv, size, 0, flags, + ll_i2suppgid(inode), &req); + capa_put(oc); #ifdef CONFIG_FS_POSIX_ACL if (new_value != NULL) lustre_posix_acl_xattr_free(new_value, size); From 4f445e634cd6af72028fd389ede325b1bde04c87 Mon Sep 17 00:00:00 2001 From: Adrian Remonda Date: Mon, 18 May 2015 20:34:50 +0200 Subject: [PATCH 0553/1163] Staging: lustre: Fixed typo In the explanation of the function the name of the function was incorrect Signed-off-by: Adrian Remonda Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/nrs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c index 63a05f4a902d..d38a1af8bfd7 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c @@ -478,7 +478,7 @@ static void nrs_resource_get_safe(struct ptlrpc_nrs *nrs, * * \param resp the resource hierarchy that is being released * - * \see ptlrpcnrs_req_hp_move() + * \see ptlrpc_nrs_req_hp_move() * \see ptlrpc_nrs_req_finalize() */ static void nrs_resource_put_safe(struct ptlrpc_nrs_resource **resp) From 7e7ab095cf44476b912a98428a2b69918f0ddeb6 Mon Sep 17 00:00:00 2001 From: Mike Shuey Date: Tue, 19 May 2015 10:14:32 -0400 Subject: [PATCH 0554/1163] staging: lustre: lnet: lnet: code cleanups - variable declarations Unify variable declarations to use a single space, and any other obvious spacing flaws. Signed-off-by: Mike Shuey Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/acceptor.c | 32 +-- drivers/staging/lustre/lnet/lnet/api-ni.c | 198 +++++++-------- drivers/staging/lustre/lnet/lnet/config.c | 234 ++++++++--------- drivers/staging/lustre/lnet/lnet/lib-eq.c | 42 ++-- drivers/staging/lustre/lnet/lnet/lib-md.c | 26 +- drivers/staging/lustre/lnet/lnet/lib-me.c | 20 +- drivers/staging/lustre/lnet/lnet/lib-move.c | 238 +++++++++--------- drivers/staging/lustre/lnet/lnet/lib-msg.c | 50 ++-- drivers/staging/lustre/lnet/lnet/lib-ptl.c | 116 ++++----- drivers/staging/lustre/lnet/lnet/lo.c | 2 +- drivers/staging/lustre/lnet/lnet/module.c | 8 +- drivers/staging/lustre/lnet/lnet/peer.c | 50 ++-- drivers/staging/lustre/lnet/lnet/router.c | 224 ++++++++--------- .../staging/lustre/lnet/lnet/router_proc.c | 210 ++++++++-------- 14 files changed, 725 insertions(+), 725 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c index 72fd1bf70ca0..69d4b193dd75 100644 --- a/drivers/staging/lustre/lnet/lnet/acceptor.c +++ b/drivers/staging/lustre/lnet/lnet/acceptor.c @@ -143,10 +143,10 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid, __u32 local_ip, __u32 peer_ip, int peer_port) { lnet_acceptor_connreq_t cr; - struct socket *sock; - int rc; - int port; - int fatal; + struct socket *sock; + int rc; + int port; + int fatal; CLASSERT(sizeof(cr) <= 16); /* not too big to be on the stack */ @@ -211,12 +211,12 @@ static int lnet_accept(struct socket *sock, __u32 magic) { lnet_acceptor_connreq_t cr; - __u32 peer_ip; - int peer_port; - int rc; - int flip; - lnet_ni_t *ni; - char *str; + __u32 peer_ip; + int peer_port; + int rc; + int flip; + lnet_ni_t *ni; + char *str; LASSERT(sizeof(cr) <= 16); /* not too big for the stack */ @@ -333,11 +333,11 @@ static int lnet_acceptor(void *arg) { struct socket *newsock; - int rc; - __u32 magic; - __u32 peer_ip; - int peer_port; - int secure = (int)((long_ptr_t)arg); + int rc; + __u32 magic; + __u32 peer_ip; + int peer_port; + int secure = (int)((long_ptr_t)arg); LASSERT(lnet_acceptor_state.pta_sock == NULL); @@ -444,7 +444,7 @@ accept2secure(const char *acc, long *sec) int lnet_acceptor_start(void) { - int rc; + int rc; long rc2; long secure; diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 4a14e5109821..6910f56703d1 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -41,7 +41,7 @@ #define D_LNI D_CONSOLE -lnet_t the_lnet; /* THE state of the network */ +lnet_t the_lnet; /* THE state of the network */ EXPORT_SYMBOL(the_lnet); @@ -70,8 +70,8 @@ lnet_get_routes(void) static char * lnet_get_networks(void) { - char *nets; - int rc; + char *nets; + int rc; if (*networks != 0 && *ip2nets != 0) { LCONSOLE_ERROR_MSG(0x101, "Please specify EITHER 'networks' or 'ip2nets' but not both at once\n"); @@ -107,8 +107,8 @@ lnet_fini_locks(void) static int lnet_create_remote_nets_table(void) { - int i; - struct list_head *hash; + int i; + struct list_head *hash; LASSERT(the_lnet.ln_remote_nets_hash == NULL); LASSERT(the_lnet.ln_remote_nets_hbits > 0); @@ -273,8 +273,8 @@ static void lnet_assert_wire_constants(void) static lnd_t * lnet_find_lnd_by_type(int type) { - lnd_t *lnd; - struct list_head *tmp; + lnd_t *lnd; + struct list_head *tmp; /* holding lnd mutex */ list_for_each(tmp, &the_lnet.ln_lnds) { @@ -325,7 +325,7 @@ void lnet_counters_get(lnet_counters_t *counters) { lnet_counters_t *ctr; - int i; + int i; memset(counters, 0, sizeof(*counters)); @@ -353,7 +353,7 @@ void lnet_counters_reset(void) { lnet_counters_t *counters; - int i; + int i; lnet_net_lock(LNET_LOCK_EX); @@ -396,8 +396,8 @@ lnet_freelist_init(lnet_freelist_t *fl, int n, int size) void lnet_freelist_fini(lnet_freelist_t *fl) { - struct list_head *el; - int count; + struct list_head *el; + int count; if (fl->fl_nobjs == 0) return; @@ -441,7 +441,7 @@ lnet_res_type2str(int type) static void lnet_res_container_cleanup(struct lnet_res_container *rec) { - int count = 0; + int count = 0; if (rec->rec_type == 0) /* not set yet, it's uninitialized */ return; @@ -486,8 +486,8 @@ static int lnet_res_container_setup(struct lnet_res_container *rec, int cpt, int type, int objnum, int objsz) { - int rc = 0; - int i; + int rc = 0; + int i; LASSERT(rec->rec_type == 0); @@ -525,8 +525,8 @@ out: static void lnet_res_containers_destroy(struct lnet_res_container **recs) { - struct lnet_res_container *rec; - int i; + struct lnet_res_container *rec; + int i; cfs_percpt_for_each(rec, i, recs) lnet_res_container_cleanup(rec); @@ -537,10 +537,10 @@ lnet_res_containers_destroy(struct lnet_res_container **recs) static struct lnet_res_container ** lnet_res_containers_create(int type, int objnum, int objsz) { - struct lnet_res_container **recs; - struct lnet_res_container *rec; - int rc; - int i; + struct lnet_res_container **recs; + struct lnet_res_container *rec; + int rc; + int i; recs = cfs_percpt_alloc(lnet_cpt_table(), sizeof(*rec)); if (recs == NULL) { @@ -564,9 +564,9 @@ lnet_libhandle_t * lnet_res_lh_lookup(struct lnet_res_container *rec, __u64 cookie) { /* ALWAYS called with lnet_res_lock held */ - struct list_head *head; - lnet_libhandle_t *lh; - unsigned int hash; + struct list_head *head; + lnet_libhandle_t *lh; + unsigned int hash; if ((cookie & LNET_COOKIE_MASK) != rec->rec_type) return NULL; @@ -586,8 +586,8 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, lnet_libhandle_t *lh) { /* ALWAYS called with lnet_res_lock held */ - unsigned int ibits = LNET_COOKIE_TYPE_BITS + LNET_CPT_BITS; - unsigned int hash; + unsigned int ibits = LNET_COOKIE_TYPE_BITS + LNET_CPT_BITS; + unsigned int hash; lh->lh_cookie = rec->rec_lh_cookie; rec->rec_lh_cookie += 1 << ibits; @@ -605,7 +605,7 @@ lnet_prepare(lnet_pid_t requested_pid) { /* Prepare to bring up the network */ struct lnet_res_container **recs; - int rc = 0; + int rc = 0; LASSERT(the_lnet.ln_refcount == 0); @@ -725,8 +725,8 @@ lnet_unprepare(void) lnet_ni_t * lnet_net2ni_locked(__u32 net, int cpt) { - struct list_head *tmp; - lnet_ni_t *ni; + struct list_head *tmp; + lnet_ni_t *ni; LASSERT(cpt != LNET_LOCK_EX); @@ -758,8 +758,8 @@ EXPORT_SYMBOL(lnet_net2ni); static unsigned int lnet_nid_cpt_hash(lnet_nid_t nid, unsigned int number) { - __u64 key = nid; - unsigned int val; + __u64 key = nid; + unsigned int val; LASSERT(number >= 1 && number <= LNET_CPT_NUMBER); @@ -801,8 +801,8 @@ lnet_cpt_of_nid_locked(lnet_nid_t nid) int lnet_cpt_of_nid(lnet_nid_t nid) { - int cpt; - int cpt2; + int cpt; + int cpt2; if (LNET_CPT_NUMBER == 1) return 0; /* the only one */ @@ -821,8 +821,8 @@ EXPORT_SYMBOL(lnet_cpt_of_nid); int lnet_islocalnet(__u32 net) { - struct lnet_ni *ni; - int cpt; + struct lnet_ni *ni; + int cpt; cpt = lnet_net_lock_current(); @@ -838,8 +838,8 @@ lnet_islocalnet(__u32 net) lnet_ni_t * lnet_nid2ni_locked(lnet_nid_t nid, int cpt) { - struct lnet_ni *ni; - struct list_head *tmp; + struct lnet_ni *ni; + struct list_head *tmp; LASSERT(cpt != LNET_LOCK_EX); @@ -858,8 +858,8 @@ lnet_nid2ni_locked(lnet_nid_t nid, int cpt) int lnet_islocalnid(lnet_nid_t nid) { - struct lnet_ni *ni; - int cpt; + struct lnet_ni *ni; + int cpt; cpt = lnet_net_lock_current(); ni = lnet_nid2ni_locked(nid, cpt); @@ -874,10 +874,10 @@ int lnet_count_acceptor_nis(void) { /* Return the # of NIs that need the acceptor. */ - int count = 0; - struct list_head *tmp; - struct lnet_ni *ni; - int cpt; + int count = 0; + struct list_head *tmp; + struct lnet_ni *ni; + int cpt; cpt = lnet_net_lock_current(); list_for_each(tmp, &the_lnet.ln_nis) { @@ -895,7 +895,7 @@ lnet_count_acceptor_nis(void) static int lnet_ni_tq_credits(lnet_ni_t *ni) { - int credits; + int credits; LASSERT(ni->ni_ncpts >= 1); @@ -912,9 +912,9 @@ lnet_ni_tq_credits(lnet_ni_t *ni) static void lnet_shutdown_lndnis(void) { - int i; - int islo; - lnet_ni_t *ni; + int i; + int islo; + lnet_ni_t *ni; /* NB called holding the global mutex */ @@ -968,8 +968,8 @@ lnet_shutdown_lndnis(void) * and shut them down in guaranteed thread context */ i = 2; while (!list_empty(&the_lnet.ln_nis_zombie)) { - int *ref; - int j; + int *ref; + int j; ni = list_entry(the_lnet.ln_nis_zombie.next, lnet_ni_t, ni_list); @@ -1029,15 +1029,15 @@ lnet_shutdown_lndnis(void) static int lnet_startup_lndnis(void) { - lnd_t *lnd; - struct lnet_ni *ni; - struct lnet_tx_queue *tq; - struct list_head nilist; - int i; - int rc = 0; - int lnd_type; - int nicount = 0; - char *nets = lnet_get_networks(); + lnd_t *lnd; + struct lnet_ni *ni; + struct lnet_tx_queue *tq; + struct list_head nilist; + int i; + int rc = 0; + int lnd_type; + int nicount = 0; + char *nets = lnet_get_networks(); INIT_LIST_HEAD(&nilist); @@ -1181,7 +1181,7 @@ lnet_startup_lndnis(void) int LNetInit(void) { - int rc; + int rc; lnet_assert_wire_constants(); LASSERT(!the_lnet.ln_init); @@ -1277,8 +1277,8 @@ EXPORT_SYMBOL(LNetFini); int LNetNIInit(lnet_pid_t requested_pid) { - int im_a_router = 0; - int rc; + int im_a_router = 0; + int rc; LNET_MUTEX_LOCK(&the_lnet.ln_api_mutex); @@ -1413,9 +1413,9 @@ int LNetCtl(unsigned int cmd, void *arg) { struct libcfs_ioctl_data *data = arg; - lnet_process_id_t id = {0}; - lnet_ni_t *ni; - int rc; + lnet_process_id_t id = {0}; + lnet_ni_t *ni; + int rc; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); @@ -1531,10 +1531,10 @@ EXPORT_SYMBOL(LNetCtl); int LNetGetId(unsigned int index, lnet_process_id_t *id) { - struct lnet_ni *ni; - struct list_head *tmp; - int cpt; - int rc = -ENOENT; + struct lnet_ni *ni; + struct list_head *tmp; + int cpt; + int rc = -ENOENT; LASSERT(the_lnet.ln_init); @@ -1575,11 +1575,11 @@ EXPORT_SYMBOL(LNetSnprintHandle); static int lnet_create_ping_info(void) { - int i; - int n; - int rc; - unsigned int infosz; - lnet_ni_t *ni; + int i; + int n; + int rc; + unsigned int infosz; + lnet_ni_t *ni; lnet_process_id_t id; lnet_ping_info_t *pinfo; @@ -1633,7 +1633,7 @@ lnet_create_ping_info(void) static void lnet_destroy_ping_info(void) { - struct lnet_ni *ni; + struct lnet_ni *ni; lnet_net_lock(0); @@ -1654,12 +1654,12 @@ lnet_destroy_ping_info(void) int lnet_ping_target_init(void) { - lnet_md_t md = { NULL }; - lnet_handle_me_t meh; + lnet_md_t md = { NULL }; + lnet_handle_me_t meh; lnet_process_id_t id; - int rc; - int rc2; - int infosz; + int rc; + int rc2; + int infosz; rc = lnet_create_ping_info(); if (rc != 0) @@ -1722,11 +1722,11 @@ lnet_ping_target_init(void) void lnet_ping_target_fini(void) { - lnet_event_t event; - int rc; - int which; - int timeout_ms = 1000; - sigset_t blocked = cfs_block_allsigs(); + lnet_event_t event; + int rc; + int which; + int timeout_ms = 1000; + sigset_t blocked = cfs_block_allsigs(); LNetMDUnlink(the_lnet.ln_ping_target_md); /* NB md could be busy; this just starts the unlink */ @@ -1759,22 +1759,22 @@ lnet_ping_target_fini(void) int lnet_ping(lnet_process_id_t id, int timeout_ms, lnet_process_id_t *ids, int n_ids) { - lnet_handle_eq_t eqh; - lnet_handle_md_t mdh; - lnet_event_t event; - lnet_md_t md = { NULL }; - int which; - int unlinked = 0; - int replied = 0; - const int a_long_time = 60000; /* mS */ - int infosz = offsetof(lnet_ping_info_t, pi_ni[n_ids]); - lnet_ping_info_t *info; - lnet_process_id_t tmpid; - int i; - int nob; - int rc; - int rc2; - sigset_t blocked; + lnet_handle_eq_t eqh; + lnet_handle_md_t mdh; + lnet_event_t event; + lnet_md_t md = { NULL }; + int which; + int unlinked = 0; + int replied = 0; + const int a_long_time = 60000; /* mS */ + int infosz = offsetof(lnet_ping_info_t, pi_ni[n_ids]); + lnet_ping_info_t *info; + lnet_process_id_t tmpid; + int i; + int nob; + int rc; + int rc2; + sigset_t blocked; if (n_ids <= 0 || id.nid == LNET_NID_ANY || diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c index 2dc4c4a1afd0..70bc8096b66b 100644 --- a/drivers/staging/lustre/lnet/lnet/config.c +++ b/drivers/staging/lustre/lnet/lnet/config.c @@ -38,9 +38,9 @@ #include "../../include/linux/lnet/lib-lnet.h" struct lnet_text_buf_t { /* tmp struct for parsing routes */ - struct list_head ltb_list; /* stash on lists */ - int ltb_size; /* allocated size */ - char ltb_text[0]; /* text buffer */ + struct list_head ltb_list; /* stash on lists */ + int ltb_size; /* allocated size */ + char ltb_text[0]; /* text buffer */ }; static int lnet_tbnob; /* track text buf allocation */ @@ -80,8 +80,8 @@ lnet_issep(char c) static int lnet_net_unique(__u32 net, struct list_head *nilist) { - struct list_head *tmp; - lnet_ni_t *ni; + struct list_head *tmp; + lnet_ni_t *ni; list_for_each(tmp, nilist) { ni = list_entry(tmp, lnet_ni_t, ni_list); @@ -111,10 +111,10 @@ lnet_ni_free(struct lnet_ni *ni) static lnet_ni_t * lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist) { - struct lnet_tx_queue *tq; - struct lnet_ni *ni; - int rc; - int i; + struct lnet_tx_queue *tq; + struct lnet_ni *ni; + int rc; + int i; if (!lnet_net_unique(net, nilist)) { LCONSOLE_ERROR_MSG(0x111, "Duplicate network specified: %s\n", @@ -178,13 +178,13 @@ int lnet_parse_networks(struct list_head *nilist, char *networks) { struct cfs_expr_list *el = NULL; - int tokensize = strlen(networks) + 1; - char *tokens; - char *str; - char *tmp; - struct lnet_ni *ni; - __u32 net; - int nnets = 0; + int tokensize = strlen(networks) + 1; + char *tokens; + char *str; + char *tmp; + struct lnet_ni *ni; + __u32 net; + int nnets = 0; if (strlen(networks) > LNET_SINGLE_TEXTBUF_NOB) { /* _WAY_ conservative */ @@ -210,12 +210,12 @@ lnet_parse_networks(struct list_head *nilist, char *networks) goto failed; while (str != NULL && *str != 0) { - char *comma = strchr(str, ','); - char *bracket = strchr(str, '('); - char *square = strchr(str, '['); - char *iface; - int niface; - int rc; + char *comma = strchr(str, ','); + char *bracket = strchr(str, '('); + char *square = strchr(str, '['); + char *iface; + int niface; + int rc; /* NB we don't check interface conflicts here; it's the LNDs * responsibility (if it cares at all) */ @@ -369,7 +369,7 @@ static struct lnet_text_buf_t * lnet_new_text_buf(int str_len) { struct lnet_text_buf_t *ltb; - int nob; + int nob; /* NB allocate space for the terminating 0 */ nob = offsetof(struct lnet_text_buf_t, ltb_text[str_len + 1]); @@ -404,7 +404,7 @@ lnet_free_text_buf(struct lnet_text_buf_t *ltb) static void lnet_free_text_bufs(struct list_head *tbs) { - struct lnet_text_buf_t *ltb; + struct lnet_text_buf_t *ltb; while (!list_empty(tbs)) { ltb = list_entry(tbs->next, struct lnet_text_buf_t, ltb_list); @@ -417,11 +417,11 @@ lnet_free_text_bufs(struct list_head *tbs) static int lnet_str2tbs_sep(struct list_head *tbs, char *str) { - struct list_head pending; - char *sep; - int nob; - int i; - struct lnet_text_buf_t *ltb; + struct list_head pending; + char *sep; + int nob; + int i; + struct lnet_text_buf_t *ltb; INIT_LIST_HEAD(&pending); @@ -477,8 +477,8 @@ lnet_expand1tb(struct list_head *list, char *str, char *sep1, char *sep2, char *item, int itemlen) { - int len1 = (int)(sep1 - str); - int len2 = strlen(sep2 + 1); + int len1 = (int)(sep1 - str); + int len2 = strlen(sep2 + 1); struct lnet_text_buf_t *ltb; LASSERT(*sep1 == '['); @@ -500,18 +500,18 @@ lnet_expand1tb(struct list_head *list, static int lnet_str2tbs_expand(struct list_head *tbs, char *str) { - char num[16]; - struct list_head pending; - char *sep; - char *sep2; - char *parsed; - char *enditem; - int lo; - int hi; - int stride; - int i; - int nob; - int scanned; + char num[16]; + struct list_head pending; + char *sep; + char *sep2; + char *parsed; + char *enditem; + int lo; + int hi; + int stride; + int i; + int nob; + int scanned; INIT_LIST_HEAD(&pending); @@ -584,8 +584,8 @@ lnet_str2tbs_expand(struct list_head *tbs, char *str) static int lnet_parse_hops(char *str, unsigned int *hops) { - int len = strlen(str); - int nob = len; + int len = strlen(str); + int nob = len; return (sscanf(str, "%u%n", hops, &nob) >= 1 && nob == len && @@ -597,9 +597,9 @@ lnet_parse_hops(char *str, unsigned int *hops) static int lnet_parse_priority(char *str, unsigned int *priority, char **token) { - int nob; + int nob; char *sep; - int len; + int len; sep = strchr(str, LNET_PRIORITY_SEPARATOR); if (sep == NULL) { @@ -628,23 +628,23 @@ static int lnet_parse_route(char *str, int *im_a_router) { /* static scratch buffer OK (single threaded) */ - static char cmd[LNET_SINGLE_TEXTBUF_NOB]; + static char cmd[LNET_SINGLE_TEXTBUF_NOB]; - struct list_head nets; - struct list_head gateways; - struct list_head *tmp1; - struct list_head *tmp2; - __u32 net; - lnet_nid_t nid; - struct lnet_text_buf_t *ltb; - int rc; - char *sep; - char *token = str; - int ntokens = 0; - int myrc = -1; - unsigned int hops; - int got_hops = 0; - unsigned int priority = 0; + struct list_head nets; + struct list_head gateways; + struct list_head *tmp1; + struct list_head *tmp2; + __u32 net; + lnet_nid_t nid; + struct lnet_text_buf_t *ltb; + int rc; + char *sep; + char *token = str; + int ntokens = 0; + int myrc = -1; + unsigned int hops; + int got_hops = 0; + unsigned int priority = 0; INIT_LIST_HEAD(&gateways); INIT_LIST_HEAD(&nets); @@ -772,7 +772,7 @@ lnet_parse_route(char *str, int *im_a_router) static int lnet_parse_route_tbs(struct list_head *tbs, int *im_a_router) { - struct lnet_text_buf_t *ltb; + struct lnet_text_buf_t *ltb; while (!list_empty(tbs)) { ltb = list_entry(tbs->next, struct lnet_text_buf_t, ltb_list); @@ -792,8 +792,8 @@ lnet_parse_route_tbs(struct list_head *tbs, int *im_a_router) int lnet_parse_routes(char *routes, int *im_a_router) { - struct list_head tbs; - int rc = 0; + struct list_head tbs; + int rc = 0; *im_a_router = 0; @@ -814,8 +814,8 @@ static int lnet_match_network_token(char *token, int len, __u32 *ipaddrs, int nip) { LIST_HEAD(list); - int rc; - int i; + int rc; + int i; rc = cfs_ip_addr_parse(token, len, &list); if (rc != 0) @@ -834,13 +834,13 @@ lnet_match_network_tokens(char *net_entry, __u32 *ipaddrs, int nip) { static char tokens[LNET_SINGLE_TEXTBUF_NOB]; - int matched = 0; - int ntokens = 0; - int len; + int matched = 0; + int ntokens = 0; + int len; char *net = NULL; char *sep; char *token; - int rc; + int rc; LASSERT(strlen(net_entry) < sizeof(tokens)); @@ -889,8 +889,8 @@ lnet_match_network_tokens(char *net_entry, __u32 *ipaddrs, int nip) static __u32 lnet_netspec2net(char *netspec) { - char *bracket = strchr(netspec, '('); - __u32 net; + char *bracket = strchr(netspec, '('); + __u32 net; if (bracket != NULL) *bracket = 0; @@ -906,15 +906,15 @@ lnet_netspec2net(char *netspec) static int lnet_splitnets(char *source, struct list_head *nets) { - int offset = 0; - int offset2; - int len; - struct lnet_text_buf_t *tb; - struct lnet_text_buf_t *tb2; - struct list_head *t; - char *sep; - char *bracket; - __u32 net; + int offset = 0; + int offset2; + int len; + struct lnet_text_buf_t *tb; + struct lnet_text_buf_t *tb2; + struct list_head *t; + char *sep; + char *bracket; + __u32 net; LASSERT(!list_empty(nets)); LASSERT(nets->next == nets->prev); /* single entry */ @@ -986,22 +986,22 @@ lnet_splitnets(char *source, struct list_head *nets) static int lnet_match_networks(char **networksp, char *ip2nets, __u32 *ipaddrs, int nip) { - static char networks[LNET_SINGLE_TEXTBUF_NOB]; - static char source[LNET_SINGLE_TEXTBUF_NOB]; + static char networks[LNET_SINGLE_TEXTBUF_NOB]; + static char source[LNET_SINGLE_TEXTBUF_NOB]; - struct list_head raw_entries; - struct list_head matched_nets; - struct list_head current_nets; - struct list_head *t; - struct list_head *t2; - struct lnet_text_buf_t *tb; - struct lnet_text_buf_t *tb2; - __u32 net1; - __u32 net2; - int len; - int count; - int dup; - int rc; + struct list_head raw_entries; + struct list_head matched_nets; + struct list_head current_nets; + struct list_head *t; + struct list_head *t2; + struct lnet_text_buf_t *tb; + struct lnet_text_buf_t *tb2; + __u32 net1; + __u32 net2; + int len; + int count; + int dup; + int rc; INIT_LIST_HEAD(&raw_entries); if (lnet_str2tbs_sep(&raw_entries, ip2nets) < 0) { @@ -1112,15 +1112,15 @@ lnet_ipaddr_free_enumeration(__u32 *ipaddrs, int nip) static int lnet_ipaddr_enumerate(__u32 **ipaddrsp) { - int up; - __u32 netmask; - __u32 *ipaddrs; - __u32 *ipaddrs2; - int nip; - char **ifnames; - int nif = libcfs_ipif_enumerate(&ifnames); - int i; - int rc; + int up; + __u32 netmask; + __u32 *ipaddrs; + __u32 *ipaddrs2; + int nip; + char **ifnames; + int nif = libcfs_ipif_enumerate(&ifnames); + int i; + int rc; if (nif <= 0) return nif; @@ -1178,9 +1178,9 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp) int lnet_parse_ip2nets(char **networksp, char *ip2nets) { - __u32 *ipaddrs = NULL; - int nip = lnet_ipaddr_enumerate(&ipaddrs); - int rc; + __u32 *ipaddrs = NULL; + int nip = lnet_ipaddr_enumerate(&ipaddrs); + int rc; if (nip < 0) { LCONSOLE_ERROR_MSG(0x117, @@ -1215,14 +1215,14 @@ lnet_parse_ip2nets(char **networksp, char *ip2nets) int lnet_set_ip_niaddr(lnet_ni_t *ni) { - __u32 net = LNET_NIDNET(ni->ni_nid); + __u32 net = LNET_NIDNET(ni->ni_nid); char **names; - int n; - __u32 ip; - __u32 netmask; - int up; - int i; - int rc; + int n; + __u32 ip; + __u32 netmask; + int up; + int i; + int rc; /* Convenience for LNDs that use the IP address of a local interface as * the local address part of their NID */ diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c index 1221c0bad107..28858fb215c3 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c @@ -70,7 +70,7 @@ int LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback, lnet_handle_eq_t *handle) { - lnet_eq_t *eq; + lnet_eq_t *eq; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); @@ -151,13 +151,13 @@ EXPORT_SYMBOL(LNetEQAlloc); int LNetEQFree(lnet_handle_eq_t eqh) { - struct lnet_eq *eq; - lnet_event_t *events = NULL; - int **refs = NULL; - int *ref; - int rc = 0; - int size = 0; - int i; + struct lnet_eq *eq; + lnet_event_t *events = NULL; + int **refs = NULL; + int *ref; + int rc = 0; + int size = 0; + int i; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); @@ -185,9 +185,9 @@ LNetEQFree(lnet_handle_eq_t eqh) } /* stash for free after lock dropped */ - events = eq->eq_events; - size = eq->eq_size; - refs = eq->eq_refs; + events = eq->eq_events; + size = eq->eq_size; + refs = eq->eq_refs; lnet_res_lh_invalidate(&eq->eq_lh); list_del(&eq->eq_list); @@ -237,9 +237,9 @@ lnet_eq_enqueue_event(lnet_eq_t *eq, lnet_event_t *ev) 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); - lnet_event_t *new_event = &eq->eq_events[new_index]; - int rc; + int new_index = eq->eq_deq_seq & (eq->eq_size - 1); + lnet_event_t *new_event = &eq->eq_events[new_index]; + int rc; /* must called with lnet_eq_wait_lock hold */ if (LNET_SEQ_GT(eq->eq_deq_seq, new_event->sequence)) @@ -323,10 +323,10 @@ static int lnet_eq_wait_locked(int *timeout_ms) __must_hold(&the_lnet.ln_eq_wait_lock) { - int tms = *timeout_ms; - int wait; - wait_queue_t wl; - unsigned long now; + int tms = *timeout_ms; + int wait; + wait_queue_t wl; + unsigned long now; if (tms == 0) return -1; /* don't want to wait and no new event */ @@ -392,9 +392,9 @@ int LNetEQPoll(lnet_handle_eq_t *eventqs, int neq, int timeout_ms, lnet_event_t *event, int *which) { - int wait = 1; - int rc; - int i; + int wait = 1; + int rc; + int i; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c index 89d660fefd48..5856c30503ea 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-md.c +++ b/drivers/staging/lustre/lnet/lnet/lib-md.c @@ -74,7 +74,7 @@ lnet_md_unlink(lnet_libmd_t *md) CDEBUG(D_NET, "Unlinking md %p\n", md); if (md->md_eq != NULL) { - int cpt = lnet_cpt_of_cookie(md->md_lh.lh_cookie); + int cpt = lnet_cpt_of_cookie(md->md_lh.lh_cookie); LASSERT(*md->md_eq->eq_refs[cpt] > 0); (*md->md_eq->eq_refs[cpt])--; @@ -88,9 +88,9 @@ lnet_md_unlink(lnet_libmd_t *md) static int lnet_md_build(lnet_libmd_t *lmd, lnet_md_t *umd, int unlink) { - int i; + int i; unsigned int niov; - int total_length = 0; + int total_length = 0; lmd->md_me = NULL; lmd->md_start = umd->start; @@ -268,10 +268,10 @@ LNetMDAttach(lnet_handle_me_t meh, lnet_md_t umd, { LIST_HEAD(matches); LIST_HEAD(drops); - struct lnet_me *me; - struct lnet_libmd *md; - int cpt; - int rc; + struct lnet_me *me; + struct lnet_libmd *md; + int cpt; + int rc; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); @@ -346,9 +346,9 @@ EXPORT_SYMBOL(LNetMDAttach); int LNetMDBind(lnet_md_t umd, lnet_unlink_t unlink, lnet_handle_md_t *handle) { - lnet_libmd_t *md; - int cpt; - int rc; + lnet_libmd_t *md; + int cpt; + int rc; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); @@ -421,9 +421,9 @@ EXPORT_SYMBOL(LNetMDBind); int LNetMDUnlink(lnet_handle_md_t mdh) { - lnet_event_t ev; - lnet_libmd_t *md; - int cpt; + lnet_event_t ev; + lnet_libmd_t *md; + int cpt; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); diff --git a/drivers/staging/lustre/lnet/lnet/lib-me.c b/drivers/staging/lustre/lnet/lnet/lib-me.c index a3f929244711..09e90087c74a 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-me.c +++ b/drivers/staging/lustre/lnet/lnet/lib-me.c @@ -80,8 +80,8 @@ LNetMEAttach(unsigned int portal, lnet_handle_me_t *handle) { struct lnet_match_table *mtable; - struct lnet_me *me; - struct list_head *head; + struct lnet_me *me; + struct list_head *head; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); @@ -151,10 +151,10 @@ LNetMEInsert(lnet_handle_me_t current_meh, lnet_unlink_t unlink, lnet_ins_pos_t pos, lnet_handle_me_t *handle) { - struct lnet_me *current_me; - struct lnet_me *new_me; - struct lnet_portal *ptl; - int cpt; + struct lnet_me *current_me; + struct lnet_me *new_me; + struct lnet_portal *ptl; + int cpt; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); @@ -228,10 +228,10 @@ EXPORT_SYMBOL(LNetMEInsert); int LNetMEUnlink(lnet_handle_me_t meh) { - lnet_me_t *me; - lnet_libmd_t *md; - lnet_event_t ev; - int cpt; + lnet_me_t *me; + lnet_libmd_t *md; + lnet_event_t ev; + int cpt; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index c2fb70e5fc4e..ba59fe70732a 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -49,10 +49,10 @@ MODULE_PARM_DESC(local_nid_dist_zero, "Reserved"); int lnet_fail_nid(lnet_nid_t nid, unsigned int threshold) { - lnet_test_peer_t *tp; - struct list_head *el; - struct list_head *next; - struct list_head cull; + lnet_test_peer_t *tp; + struct list_head *el; + struct list_head *next; + struct list_head cull; LASSERT(the_lnet.ln_init); @@ -103,10 +103,10 @@ static int fail_peer(lnet_nid_t nid, int outgoing) { lnet_test_peer_t *tp; - struct list_head *el; - struct list_head *next; - struct list_head cull; - int fail = 0; + struct list_head *el; + struct list_head *next; + struct list_head cull; + int fail = 0; INIT_LIST_HEAD(&cull); @@ -175,7 +175,7 @@ lnet_copy_iov2iov(unsigned int ndiov, struct kvec *diov, unsigned int doffset, unsigned int nob) { /* NB diov, siov are READ-ONLY */ - unsigned int this_nob; + unsigned int this_nob; if (nob == 0) return; @@ -236,8 +236,8 @@ lnet_extract_iov(int dst_niov, struct kvec *dst, /* Initialise 'dst' to the subset of 'src' starting at 'offset', * for exactly 'len' bytes, and return the number of entries. * NB not destructive to 'src' */ - unsigned int frag_len; - unsigned int niov; + unsigned int frag_len; + unsigned int niov; if (len == 0) /* no data => */ return 0; /* no frags */ @@ -279,7 +279,7 @@ EXPORT_SYMBOL(lnet_extract_iov); unsigned int lnet_kiov_nob(unsigned int niov, lnet_kiov_t *kiov) { - unsigned int nob = 0; + unsigned int nob = 0; while (niov-- > 0) nob += (kiov++)->kiov_len; @@ -294,9 +294,9 @@ lnet_copy_kiov2kiov(unsigned int ndiov, lnet_kiov_t *diov, unsigned int doffset, unsigned int nob) { /* NB diov, siov are READ-ONLY */ - unsigned int this_nob; - char *daddr = NULL; - char *saddr = NULL; + unsigned int this_nob; + char *daddr = NULL; + char *saddr = NULL; if (nob == 0) return; @@ -376,8 +376,8 @@ lnet_copy_kiov2iov(unsigned int niov, struct kvec *iov, unsigned int iovoffset, unsigned int kiovoffset, unsigned int nob) { /* NB iov, kiov are READ-ONLY */ - unsigned int this_nob; - char *addr = NULL; + unsigned int this_nob; + char *addr = NULL; if (nob == 0) return; @@ -447,8 +447,8 @@ lnet_copy_iov2kiov(unsigned int nkiov, lnet_kiov_t *kiov, unsigned int nob) { /* NB kiov, iov are READ-ONLY */ - unsigned int this_nob; - char *addr = NULL; + unsigned int this_nob; + char *addr = NULL; if (nob == 0) return; @@ -518,8 +518,8 @@ lnet_extract_kiov(int dst_niov, lnet_kiov_t *dst, /* Initialise 'dst' to the subset of 'src' starting at 'offset', * for exactly 'len' bytes, and return the number of entries. * NB not destructive to 'src' */ - unsigned int frag_len; - unsigned int niov; + unsigned int frag_len; + unsigned int niov; if (len == 0) /* no data => */ return 0; /* no frags */ @@ -565,10 +565,10 @@ static void lnet_ni_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed, unsigned int offset, unsigned int mlen, unsigned int rlen) { - unsigned int niov = 0; + unsigned int niov = 0; struct kvec *iov = NULL; - lnet_kiov_t *kiov = NULL; - int rc; + lnet_kiov_t *kiov = NULL; + int rc; LASSERT(!in_interrupt()); LASSERT(mlen == 0 || msg != NULL); @@ -642,8 +642,8 @@ lnet_prep_send(lnet_msg_t *msg, int type, lnet_process_id_t target, static void lnet_ni_send(lnet_ni_t *ni, lnet_msg_t *msg) { - void *priv = msg->msg_private; - int rc; + void *priv = msg->msg_private; + int rc; LASSERT(!in_interrupt()); LASSERT(LNET_NETTYP(LNET_NIDNET(ni->ni_nid)) == LOLND || @@ -657,7 +657,7 @@ lnet_ni_send(lnet_ni_t *ni, lnet_msg_t *msg) static int lnet_ni_eager_recv(lnet_ni_t *ni, lnet_msg_t *msg) { - int rc; + int rc; LASSERT(!msg->msg_sending); LASSERT(msg->msg_receiving); @@ -700,7 +700,7 @@ lnet_ni_query_locked(lnet_ni_t *ni, lnet_peer_t *lp) static inline int lnet_peer_is_alive(lnet_peer_t *lp, unsigned long now) { - int alive; + int alive; unsigned long deadline; LASSERT(lnet_peer_aliveness_enabled(lp)); @@ -785,10 +785,10 @@ lnet_peer_alive_locked(lnet_peer_t *lp) static int lnet_post_send_locked(lnet_msg_t *msg, int do_send) { - lnet_peer_t *lp = msg->msg_txpeer; - lnet_ni_t *ni = lp->lp_ni; - int cpt = msg->msg_tx_cpt; - struct lnet_tx_queue *tq = ni->ni_tx_queues[cpt]; + lnet_peer_t *lp = msg->msg_txpeer; + lnet_ni_t *ni = lp->lp_ni; + int cpt = msg->msg_tx_cpt; + struct lnet_tx_queue *tq = ni->ni_tx_queues[cpt]; /* non-lnet_send() callers have checked before */ LASSERT(!do_send || msg->msg_tx_delayed); @@ -871,8 +871,8 @@ lnet_post_send_locked(lnet_msg_t *msg, int do_send) static lnet_rtrbufpool_t * lnet_msg2bufpool(lnet_msg_t *msg) { - lnet_rtrbufpool_t *rbp; - int cpt; + lnet_rtrbufpool_t *rbp; + int cpt; LASSERT(msg->msg_rx_committed); @@ -894,9 +894,9 @@ lnet_post_routed_recv_locked(lnet_msg_t *msg, int do_recv) /* lnet_parse is going to lnet_net_unlock immediately after this, so it * sets do_recv FALSE and I don't do the unlock/send/lock bit. I * return EAGAIN if msg blocked and 0 if received or OK to receive */ - lnet_peer_t *lp = msg->msg_rxpeer; - lnet_rtrbufpool_t *rbp; - lnet_rtrbuf_t *rb; + lnet_peer_t *lp = msg->msg_rxpeer; + lnet_rtrbufpool_t *rbp; + lnet_rtrbuf_t *rb; LASSERT(msg->msg_iov == NULL); LASSERT(msg->msg_kiov == NULL); @@ -967,11 +967,11 @@ lnet_post_routed_recv_locked(lnet_msg_t *msg, int do_recv) void lnet_return_tx_credits_locked(lnet_msg_t *msg) { - lnet_peer_t *txpeer = msg->msg_txpeer; - lnet_msg_t *msg2; + lnet_peer_t *txpeer = msg->msg_txpeer; + lnet_msg_t *msg2; if (msg->msg_txcredit) { - struct lnet_ni *ni = txpeer->lp_ni; + struct lnet_ni *ni = txpeer->lp_ni; struct lnet_tx_queue *tq = ni->ni_tx_queues[msg->msg_tx_cpt]; /* give back NI txcredits */ @@ -1025,12 +1025,12 @@ lnet_return_tx_credits_locked(lnet_msg_t *msg) void lnet_return_rx_credits_locked(lnet_msg_t *msg) { - lnet_peer_t *rxpeer = msg->msg_rxpeer; - lnet_msg_t *msg2; + lnet_peer_t *rxpeer = msg->msg_rxpeer; + lnet_msg_t *msg2; if (msg->msg_rtrcredit) { /* give back global router credits */ - lnet_rtrbuf_t *rb; + lnet_rtrbuf_t *rb; lnet_rtrbufpool_t *rbp; /* NB If a msg ever blocks for a buffer in rbp_msgs, it stays @@ -1122,13 +1122,13 @@ lnet_compare_routes(lnet_route_t *r1, lnet_route_t *r2) static lnet_peer_t * lnet_find_route_locked(lnet_ni_t *ni, lnet_nid_t target, lnet_nid_t rtr_nid) { - lnet_remotenet_t *rnet; - lnet_route_t *rtr; - lnet_route_t *rtr_best; - lnet_route_t *rtr_last; - struct lnet_peer *lp_best; - struct lnet_peer *lp; - int rc; + lnet_remotenet_t *rnet; + lnet_route_t *rtr; + lnet_route_t *rtr_best; + lnet_route_t *rtr_last; + struct lnet_peer *lp_best; + struct lnet_peer *lp; + int rc; /* If @rtr_nid is not LNET_NID_ANY, return the gateway with * rtr_nid nid, otherwise find the best gateway I can use */ @@ -1182,13 +1182,13 @@ lnet_find_route_locked(lnet_ni_t *ni, lnet_nid_t target, lnet_nid_t rtr_nid) int lnet_send(lnet_nid_t src_nid, lnet_msg_t *msg, lnet_nid_t rtr_nid) { - lnet_nid_t dst_nid = msg->msg_target.nid; - struct lnet_ni *src_ni; - struct lnet_ni *local_ni; - struct lnet_peer *lp; - int cpt; - int cpt2; - int rc; + lnet_nid_t dst_nid = msg->msg_target.nid; + struct lnet_ni *src_ni; + struct lnet_ni *local_ni; + struct lnet_peer *lp; + int cpt; + int cpt2; + int rc; /* NB: rtr_nid is set to LNET_NID_ANY for all current use-cases, * but we might want to use pre-determined router for ACK/REPLY @@ -1364,7 +1364,7 @@ lnet_drop_message(lnet_ni_t *ni, int cpt, void *private, unsigned int nob) static void lnet_recv_put(lnet_ni_t *ni, lnet_msg_t *msg) { - lnet_hdr_t *hdr = &msg->msg_hdr; + lnet_hdr_t *hdr = &msg->msg_hdr; if (msg->msg_wanted != 0) lnet_setpayloadbuffer(msg); @@ -1383,9 +1383,9 @@ lnet_recv_put(lnet_ni_t *ni, lnet_msg_t *msg) static int lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg) { - lnet_hdr_t *hdr = &msg->msg_hdr; - struct lnet_match_info info; - int rc; + lnet_hdr_t *hdr = &msg->msg_hdr; + struct lnet_match_info info; + int rc; /* Convert put fields to host byte order */ hdr->msg.put.match_bits = le64_to_cpu(hdr->msg.put.match_bits); @@ -1433,24 +1433,24 @@ lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg) static int lnet_parse_get(lnet_ni_t *ni, lnet_msg_t *msg, int rdma_get) { - struct lnet_match_info info; - lnet_hdr_t *hdr = &msg->msg_hdr; - lnet_handle_wire_t reply_wmd; - int rc; + struct lnet_match_info info; + lnet_hdr_t *hdr = &msg->msg_hdr; + lnet_handle_wire_t reply_wmd; + int rc; /* Convert get fields to host byte order */ - hdr->msg.get.match_bits = le64_to_cpu(hdr->msg.get.match_bits); - hdr->msg.get.ptl_index = le32_to_cpu(hdr->msg.get.ptl_index); - hdr->msg.get.sink_length = le32_to_cpu(hdr->msg.get.sink_length); - hdr->msg.get.src_offset = le32_to_cpu(hdr->msg.get.src_offset); + hdr->msg.get.match_bits = le64_to_cpu(hdr->msg.get.match_bits); + hdr->msg.get.ptl_index = le32_to_cpu(hdr->msg.get.ptl_index); + hdr->msg.get.sink_length = le32_to_cpu(hdr->msg.get.sink_length); + hdr->msg.get.src_offset = le32_to_cpu(hdr->msg.get.src_offset); - info.mi_id.nid = hdr->src_nid; - info.mi_id.pid = hdr->src_pid; - info.mi_opc = LNET_MD_OP_GET; - info.mi_portal = hdr->msg.get.ptl_index; - info.mi_rlength = hdr->msg.get.sink_length; - info.mi_roffset = hdr->msg.get.src_offset; - info.mi_mbits = hdr->msg.get.match_bits; + info.mi_id.nid = hdr->src_nid; + info.mi_id.pid = hdr->src_pid; + info.mi_opc = LNET_MD_OP_GET; + info.mi_portal = hdr->msg.get.ptl_index; + info.mi_rlength = hdr->msg.get.sink_length; + info.mi_roffset = hdr->msg.get.src_offset; + info.mi_mbits = hdr->msg.get.match_bits; rc = lnet_ptl_match_md(&info, msg); if (rc == LNET_MATCHMD_DROP) { @@ -1497,13 +1497,13 @@ lnet_parse_get(lnet_ni_t *ni, lnet_msg_t *msg, int rdma_get) static int lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg) { - void *private = msg->msg_private; - lnet_hdr_t *hdr = &msg->msg_hdr; + void *private = msg->msg_private; + lnet_hdr_t *hdr = &msg->msg_hdr; lnet_process_id_t src = {0}; - lnet_libmd_t *md; - int rlength; - int mlength; - int cpt; + lnet_libmd_t *md; + int rlength; + int mlength; + int cpt; cpt = lnet_cpt_of_cookie(hdr->msg.reply.dst_wmd.wh_object_cookie); lnet_res_lock(cpt); @@ -1562,10 +1562,10 @@ lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg) static int lnet_parse_ack(lnet_ni_t *ni, lnet_msg_t *msg) { - lnet_hdr_t *hdr = &msg->msg_hdr; + lnet_hdr_t *hdr = &msg->msg_hdr; lnet_process_id_t src = {0}; - lnet_libmd_t *md; - int cpt; + lnet_libmd_t *md; + int cpt; src.nid = hdr->src_nid; src.pid = hdr->src_pid; @@ -1612,7 +1612,7 @@ lnet_parse_ack(lnet_ni_t *ni, lnet_msg_t *msg) static int lnet_parse_forward_locked(lnet_ni_t *ni, lnet_msg_t *msg) { - int rc = 0; + int rc = 0; if (msg->msg_rxpeer->lp_rtrcredits <= 0 || lnet_msg2bufpool(msg)->rbp_credits <= 0) { @@ -1713,15 +1713,15 @@ int lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid, void *private, int rdma_req) { - int rc = 0; - int cpt; - int for_me; - struct lnet_msg *msg; - lnet_pid_t dest_pid; - lnet_nid_t dest_nid; - lnet_nid_t src_nid; - __u32 payload_length; - __u32 type; + int rc = 0; + int cpt; + int for_me; + struct lnet_msg *msg; + lnet_pid_t dest_pid; + lnet_nid_t dest_nid; + lnet_nid_t src_nid; + __u32 payload_length; + __u32 type; LASSERT(!in_interrupt()); @@ -1945,8 +1945,8 @@ void lnet_drop_delayed_msg_list(struct list_head *head, char *reason) { while (!list_empty(head)) { - lnet_process_id_t id = {0}; - lnet_msg_t *msg; + lnet_process_id_t id = {0}; + lnet_msg_t *msg; msg = list_entry(head->next, lnet_msg_t, msg_list); list_del(&msg->msg_list); @@ -1986,8 +1986,8 @@ void lnet_recv_delayed_msg_list(struct list_head *head) { while (!list_empty(head)) { - lnet_msg_t *msg; - lnet_process_id_t id; + lnet_msg_t *msg; + lnet_process_id_t id; msg = list_entry(head->next, lnet_msg_t, msg_list); list_del(&msg->msg_list); @@ -2063,10 +2063,10 @@ LNetPut(lnet_nid_t self, lnet_handle_md_t mdh, lnet_ack_req_t ack, __u64 match_bits, unsigned int offset, __u64 hdr_data) { - struct lnet_msg *msg; - struct lnet_libmd *md; - int cpt; - int rc; + struct lnet_msg *msg; + struct lnet_libmd *md; + int cpt; + int rc; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); @@ -2153,10 +2153,10 @@ lnet_create_reply_msg(lnet_ni_t *ni, lnet_msg_t *getmsg) * CAVEAT EMPTOR: 'getmsg' is the original GET, which is freed when * lnet_finalize() is called on it, so the LND must call this first */ - struct lnet_msg *msg = lnet_msg_alloc(); - struct lnet_libmd *getmd = getmsg->msg_md; - lnet_process_id_t peer_id = getmsg->msg_target; - int cpt; + struct lnet_msg *msg = lnet_msg_alloc(); + struct lnet_libmd *getmd = getmsg->msg_md; + lnet_process_id_t peer_id = getmsg->msg_target; + int cpt; LASSERT(!getmsg->msg_target_is_router); LASSERT(!getmsg->msg_routing); @@ -2263,10 +2263,10 @@ LNetGet(lnet_nid_t self, lnet_handle_md_t mdh, lnet_process_id_t target, unsigned int portal, __u64 match_bits, unsigned int offset) { - struct lnet_msg *msg; - struct lnet_libmd *md; - int cpt; - int rc; + struct lnet_msg *msg; + struct lnet_libmd *md; + int cpt; + int rc; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); @@ -2353,14 +2353,14 @@ EXPORT_SYMBOL(LNetGet); int LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp) { - struct list_head *e; - struct lnet_ni *ni; - lnet_remotenet_t *rnet; - __u32 dstnet = LNET_NIDNET(dstnid); - int hops; - int cpt; - __u32 order = 2; - struct list_head *rn_list; + struct list_head *e; + struct lnet_ni *ni; + lnet_remotenet_t *rnet; + __u32 dstnet = LNET_NIDNET(dstnid); + int hops; + int cpt; + __u32 order = 2; + struct list_head *rn_list; /* if !local_nid_dist_zero, I don't return a distance of 0 ever * (when lustre sees a distance of 0, it substitutes 0@lo), so I diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c index a46ccbf6608f..65d7595d6555 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-msg.c +++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c @@ -60,8 +60,8 @@ lnet_build_unlink_event(lnet_libmd_t *md, lnet_event_t *ev) void lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type) { - lnet_hdr_t *hdr = &msg->msg_hdr; - lnet_event_t *ev = &msg->msg_ev; + lnet_hdr_t *hdr = &msg->msg_hdr; + lnet_event_t *ev = &msg->msg_ev; LASSERT(!msg->msg_routing); @@ -73,7 +73,7 @@ lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type) ev->target.pid = le32_to_cpu(hdr->dest_pid); ev->initiator.nid = LNET_NID_ANY; ev->initiator.pid = the_lnet.ln_pid; - ev->sender = LNET_NID_ANY; + ev->sender = LNET_NID_ANY; } else { /* event for passive message */ @@ -82,9 +82,9 @@ lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type) ev->initiator.pid = hdr->src_pid; ev->initiator.nid = hdr->src_nid; ev->rlength = hdr->payload_length; - ev->sender = msg->msg_from; - ev->mlength = msg->msg_wanted; - ev->offset = msg->msg_offset; + ev->sender = msg->msg_from; + ev->mlength = msg->msg_wanted; + ev->offset = msg->msg_offset; } switch (ev_type) { @@ -137,7 +137,7 @@ void lnet_msg_commit(lnet_msg_t *msg, int cpt) { struct lnet_msg_container *container = the_lnet.ln_msg_containers[cpt]; - lnet_counters_t *counters = the_lnet.ln_counters[cpt]; + lnet_counters_t *counters = the_lnet.ln_counters[cpt]; /* routed message can be committed for both receiving and sending */ LASSERT(!msg->msg_tx_committed); @@ -170,7 +170,7 @@ static void lnet_msg_decommit_tx(lnet_msg_t *msg, int status) { lnet_counters_t *counters; - lnet_event_t *ev = &msg->msg_ev; + lnet_event_t *ev = &msg->msg_ev; LASSERT(msg->msg_tx_committed); if (status != 0) @@ -219,8 +219,8 @@ lnet_msg_decommit_tx(lnet_msg_t *msg, int status) static void lnet_msg_decommit_rx(lnet_msg_t *msg, int status) { - lnet_counters_t *counters; - lnet_event_t *ev = &msg->msg_ev; + lnet_counters_t *counters; + lnet_event_t *ev = &msg->msg_ev; LASSERT(!msg->msg_tx_committed); /* decommitted or never committed */ LASSERT(msg->msg_rx_committed); @@ -273,7 +273,7 @@ lnet_msg_decommit_rx(lnet_msg_t *msg, int status) void lnet_msg_decommit(lnet_msg_t *msg, int cpt, int status) { - int cpt2 = cpt; + int cpt2 = cpt; LASSERT(msg->msg_tx_committed || msg->msg_rx_committed); LASSERT(msg->msg_onactivelist); @@ -335,8 +335,8 @@ lnet_msg_attach_md(lnet_msg_t *msg, lnet_libmd_t *md, void lnet_msg_detach_md(lnet_msg_t *msg, int status) { - lnet_libmd_t *md = msg->msg_md; - int unlink; + lnet_libmd_t *md = msg->msg_md; + int unlink; /* Now it's safe to drop my caller's ref */ md->md_refcount--; @@ -359,8 +359,8 @@ static int lnet_complete_msg_locked(lnet_msg_t *msg, int cpt) { lnet_handle_wire_t ack_wmd; - int rc; - int status = msg->msg_ev.status; + int rc; + int status = msg->msg_ev.status; LASSERT(msg->msg_onactivelist); @@ -434,11 +434,11 @@ lnet_complete_msg_locked(lnet_msg_t *msg, int cpt) void lnet_finalize(lnet_ni_t *ni, lnet_msg_t *msg, int status) { - struct lnet_msg_container *container; - int my_slot; - int cpt; - int rc; - int i; + struct lnet_msg_container *container; + int my_slot; + int cpt; + int rc; + int i; LASSERT(!in_interrupt()); @@ -534,7 +534,7 @@ EXPORT_SYMBOL(lnet_finalize); void lnet_msg_container_cleanup(struct lnet_msg_container *container) { - int count = 0; + int count = 0; if (container->msc_init == 0) return; @@ -568,7 +568,7 @@ lnet_msg_container_cleanup(struct lnet_msg_container *container) int lnet_msg_container_setup(struct lnet_msg_container *container, int cpt) { - int rc; + int rc; container->msc_init = 1; @@ -608,7 +608,7 @@ void lnet_msg_containers_destroy(void) { struct lnet_msg_container *container; - int i; + int i; if (the_lnet.ln_msg_containers == NULL) return; @@ -624,8 +624,8 @@ int lnet_msg_containers_create(void) { struct lnet_msg_container *container; - int rc; - int i; + int rc; + int i; the_lnet.ln_msg_containers = cfs_percpt_alloc(lnet_cpt_table(), sizeof(*container)); diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/drivers/staging/lustre/lnet/lnet/lib-ptl.c index 3ba0da919b41..84707c5cb464 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c +++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c @@ -39,7 +39,7 @@ #include "../../include/linux/lnet/lib-lnet.h" /* NB: add /proc interfaces in upcoming patches */ -int portal_rotor = LNET_PTL_ROTOR_HASH_RT; +int portal_rotor = LNET_PTL_ROTOR_HASH_RT; module_param(portal_rotor, int, 0644); MODULE_PARM_DESC(portal_rotor, "redirect PUTs to different cpu-partitions"); @@ -47,8 +47,8 @@ static int lnet_ptl_match_type(unsigned int index, lnet_process_id_t match_id, __u64 mbits, __u64 ignore_bits) { - struct lnet_portal *ptl = the_lnet.ln_portals[index]; - int unique; + struct lnet_portal *ptl = the_lnet.ln_portals[index]; + int unique; unique = ignore_bits == 0 && match_id.nid != LNET_NID_ANY && @@ -89,7 +89,7 @@ static void lnet_ptl_enable_mt(struct lnet_portal *ptl, int cpt) { struct lnet_match_table *mtable = ptl->ptl_mtables[cpt]; - int i; + int i; /* with hold of both lnet_res_lock(cpt) and lnet_ptl_lock */ LASSERT(lnet_ptl_is_wildcard(ptl)); @@ -114,7 +114,7 @@ static void lnet_ptl_disable_mt(struct lnet_portal *ptl, int cpt) { struct lnet_match_table *mtable = ptl->ptl_mtables[cpt]; - int i; + int i; /* with hold of both lnet_res_lock(cpt) and lnet_ptl_lock */ LASSERT(lnet_ptl_is_wildcard(ptl)); @@ -141,9 +141,9 @@ lnet_try_match_md(lnet_libmd_t *md, { /* ALWAYS called holding the lnet_res_lock, and can't lnet_res_unlock; * lnet_match_blocked_msg() relies on this to avoid races */ - unsigned int offset; - unsigned int mlength; - lnet_me_t *me = md->md_me; + unsigned int offset; + unsigned int mlength; + lnet_me_t *me = md->md_me; /* MD exhausted */ if (lnet_md_exhausted(md)) @@ -227,7 +227,7 @@ struct lnet_match_table * lnet_mt_of_attach(unsigned int index, lnet_process_id_t id, __u64 mbits, __u64 ignore_bits, lnet_ins_pos_t pos) { - struct lnet_portal *ptl; + struct lnet_portal *ptl; struct lnet_match_table *mtable; /* NB: called w/o lock */ @@ -261,11 +261,11 @@ static struct lnet_match_table * lnet_mt_of_match(struct lnet_match_info *info, struct lnet_msg *msg) { struct lnet_match_table *mtable; - struct lnet_portal *ptl; - unsigned int nmaps; - unsigned int rotor; - unsigned int cpt; - bool routed; + struct lnet_portal *ptl; + unsigned int nmaps; + unsigned int rotor; + unsigned int cpt; + bool routed; /* NB: called w/o lock */ LASSERT(info->mi_portal < the_lnet.ln_nportals); @@ -312,8 +312,8 @@ lnet_mt_of_match(struct lnet_match_info *info, struct lnet_msg *msg) static int lnet_mt_test_exhausted(struct lnet_match_table *mtable, int pos) { - __u64 *bmap; - int i; + __u64 *bmap; + int i; if (!lnet_ptl_is_wildcard(the_lnet.ln_portals[mtable->mt_portal])) return 0; @@ -337,7 +337,7 @@ lnet_mt_test_exhausted(struct lnet_match_table *mtable, int pos) static void lnet_mt_set_exhausted(struct lnet_match_table *mtable, int pos, int exhausted) { - __u64 *bmap; + __u64 *bmap; LASSERT(lnet_ptl_is_wildcard(the_lnet.ln_portals[mtable->mt_portal])); LASSERT(pos <= LNET_MT_HASH_IGNORE); @@ -373,11 +373,11 @@ int lnet_mt_match_md(struct lnet_match_table *mtable, struct lnet_match_info *info, struct lnet_msg *msg) { - struct list_head *head; - lnet_me_t *me; - lnet_me_t *tmp; - int exhausted = 0; - int rc; + struct list_head *head; + lnet_me_t *me; + lnet_me_t *tmp; + int exhausted = 0; + int rc; /* any ME with ignore bits? */ if (!list_empty(&mtable->mt_mhash[LNET_MT_HASH_IGNORE])) @@ -428,7 +428,7 @@ lnet_mt_match_md(struct lnet_match_table *mtable, static int lnet_ptl_match_early(struct lnet_portal *ptl, struct lnet_msg *msg) { - int rc; + int rc; /* message arrived before any buffer posting on this portal, * simply delay or drop this message */ @@ -461,9 +461,9 @@ static int lnet_ptl_match_delay(struct lnet_portal *ptl, struct lnet_match_info *info, struct lnet_msg *msg) { - int first = ptl->ptl_mt_maps[0]; /* read w/o lock */ - int rc = 0; - int i; + int first = ptl->ptl_mt_maps[0]; /* read w/o lock */ + int rc = 0; + int i; /* steal buffer from other CPTs, and delay it if nothing to steal, * this function is more expensive than a regular match, but we @@ -472,7 +472,7 @@ lnet_ptl_match_delay(struct lnet_portal *ptl, for (i = 0; i < LNET_CPT_NUMBER; i++) { struct lnet_match_table *mtable; - int cpt; + int cpt; cpt = (first + i) % LNET_CPT_NUMBER; mtable = ptl->ptl_mtables[cpt]; @@ -536,8 +536,8 @@ int lnet_ptl_match_md(struct lnet_match_info *info, struct lnet_msg *msg) { struct lnet_match_table *mtable; - struct lnet_portal *ptl; - int rc; + struct lnet_portal *ptl; + int rc; CDEBUG(D_NET, "Request from %s of length %d into portal %d MB=%#llx\n", libcfs_id2str(info->mi_id), info->mi_rlength, info->mi_portal, @@ -622,13 +622,13 @@ void lnet_ptl_attach_md(lnet_me_t *me, lnet_libmd_t *md, struct list_head *matches, struct list_head *drops) { - struct lnet_portal *ptl = the_lnet.ln_portals[me->me_portal]; + struct lnet_portal *ptl = the_lnet.ln_portals[me->me_portal]; struct lnet_match_table *mtable; - struct list_head *head; - lnet_msg_t *tmp; - lnet_msg_t *msg; - int exhausted = 0; - int cpt; + struct list_head *head; + lnet_msg_t *tmp; + lnet_msg_t *msg; + int exhausted = 0; + int cpt; LASSERT(md->md_refcount == 0); /* a brand new MD */ @@ -647,20 +647,20 @@ lnet_ptl_attach_md(lnet_me_t *me, lnet_libmd_t *md, head = &ptl->ptl_msg_stealing; again: list_for_each_entry_safe(msg, tmp, head, msg_list) { - struct lnet_match_info info; - lnet_hdr_t *hdr; - int rc; + struct lnet_match_info info; + lnet_hdr_t *hdr; + int rc; LASSERT(msg->msg_rx_delayed || head == &ptl->ptl_msg_stealing); - hdr = &msg->msg_hdr; - info.mi_id.nid = hdr->src_nid; - info.mi_id.pid = hdr->src_pid; - info.mi_opc = LNET_MD_OP_PUT; - info.mi_portal = hdr->msg.put.ptl_index; - info.mi_rlength = hdr->payload_length; - info.mi_roffset = hdr->msg.put.offset; - info.mi_mbits = hdr->msg.put.match_bits; + hdr = &msg->msg_hdr; + info.mi_id.nid = hdr->src_nid; + info.mi_id.pid = hdr->src_pid; + info.mi_opc = LNET_MD_OP_PUT; + info.mi_portal = hdr->msg.put.ptl_index; + info.mi_rlength = hdr->payload_length; + info.mi_roffset = hdr->msg.put.offset; + info.mi_mbits = hdr->msg.put.match_bits; rc = lnet_try_match_md(md, &info, msg); @@ -715,7 +715,7 @@ static void lnet_ptl_cleanup(struct lnet_portal *ptl) { struct lnet_match_table *mtable; - int i; + int i; if (ptl->ptl_mtables == NULL) /* uninitialized portal */ return; @@ -723,9 +723,9 @@ lnet_ptl_cleanup(struct lnet_portal *ptl) LASSERT(list_empty(&ptl->ptl_msg_delayed)); LASSERT(list_empty(&ptl->ptl_msg_stealing)); cfs_percpt_for_each(mtable, i, ptl->ptl_mtables) { - struct list_head *mhash; - lnet_me_t *me; - int j; + struct list_head *mhash; + lnet_me_t *me; + int j; if (mtable->mt_mhash == NULL) /* uninitialized match-table */ continue; @@ -753,9 +753,9 @@ static int lnet_ptl_setup(struct lnet_portal *ptl, int index) { struct lnet_match_table *mtable; - struct list_head *mhash; - int i; - int j; + struct list_head *mhash; + int i; + int j; ptl->ptl_mtables = cfs_percpt_alloc(lnet_cpt_table(), sizeof(struct lnet_match_table)); @@ -798,7 +798,7 @@ lnet_ptl_setup(struct lnet_portal *ptl, int index) void lnet_portals_destroy(void) { - int i; + int i; if (the_lnet.ln_portals == NULL) return; @@ -813,8 +813,8 @@ lnet_portals_destroy(void) int lnet_portals_create(void) { - int size; - int i; + int size; + int i; size = offsetof(struct lnet_portal, ptl_mt_maps[LNET_CPT_NUMBER]); @@ -898,8 +898,8 @@ EXPORT_SYMBOL(LNetSetLazyPortal); int LNetClearLazyPortal(int portal) { - struct lnet_portal *ptl; - LIST_HEAD (zombies); + struct lnet_portal *ptl; + LIST_HEAD(zombies); if (portal < 0 || portal >= the_lnet.ln_nportals) return -EINVAL; diff --git a/drivers/staging/lustre/lnet/lnet/lo.c b/drivers/staging/lustre/lnet/lnet/lo.c index f708c2e649d7..2a137f46800f 100644 --- a/drivers/staging/lustre/lnet/lnet/lo.c +++ b/drivers/staging/lustre/lnet/lnet/lo.c @@ -111,7 +111,7 @@ lnd_t the_lolnd = { /* .lnd_type = */ LOLND, /* .lnd_startup = */ lolnd_startup, /* .lnd_shutdown = */ lolnd_shutdown, - /* .lnt_ctl = */ NULL, + /* .lnt_ctl = */ NULL, /* .lnd_send = */ lolnd_send, /* .lnd_recv = */ lolnd_recv, /* .lnd_eager_recv = */ NULL, diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c index 72b7fbc83718..ff3f83172b14 100644 --- a/drivers/staging/lustre/lnet/lnet/module.c +++ b/drivers/staging/lustre/lnet/lnet/module.c @@ -47,7 +47,7 @@ static int lnet_configure(void *arg) { /* 'arg' only there so I can be passed to cfs_create_thread() */ - int rc = 0; + int rc = 0; LNET_MUTEX_LOCK(&lnet_config_mutex); @@ -66,7 +66,7 @@ lnet_configure(void *arg) static int lnet_unconfigure(void) { - int refcount; + int refcount; LNET_MUTEX_LOCK(&lnet_config_mutex); @@ -86,7 +86,7 @@ lnet_unconfigure(void) static int lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_data *data) { - int rc; + int rc; switch (cmd) { case IOC_LIBCFS_CONFIGURE: @@ -113,7 +113,7 @@ static DECLARE_IOCTL_HANDLER(lnet_ioctl_handler, lnet_ioctl); static int __init init_lnet(void) { - int rc; + int rc; mutex_init(&lnet_config_mutex); diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c index 45b5742f1bd2..1fceed3c8fc0 100644 --- a/drivers/staging/lustre/lnet/lnet/peer.c +++ b/drivers/staging/lustre/lnet/lnet/peer.c @@ -43,10 +43,10 @@ int lnet_peer_tables_create(void) { - struct lnet_peer_table *ptable; - struct list_head *hash; - int i; - int j; + struct lnet_peer_table *ptable; + struct list_head *hash; + int i; + int j; the_lnet.ln_peer_tables = cfs_percpt_alloc(lnet_cpt_table(), sizeof(*ptable)); @@ -77,10 +77,10 @@ lnet_peer_tables_create(void) void lnet_peer_tables_destroy(void) { - struct lnet_peer_table *ptable; - struct list_head *hash; - int i; - int j; + struct lnet_peer_table *ptable; + struct list_head *hash; + int i; + int j; if (the_lnet.ln_peer_tables == NULL) return; @@ -106,9 +106,9 @@ lnet_peer_tables_destroy(void) void lnet_peer_tables_cleanup(void) { - struct lnet_peer_table *ptable; - int i; - int j; + struct lnet_peer_table *ptable; + int i; + int j; LASSERT(the_lnet.ln_shutdown); /* i.e. no new peers */ @@ -133,7 +133,7 @@ lnet_peer_tables_cleanup(void) cfs_percpt_for_each(ptable, i, the_lnet.ln_peer_tables) { LIST_HEAD(deathrow); - lnet_peer_t *lp; + lnet_peer_t *lp; lnet_net_lock(i); @@ -186,8 +186,8 @@ lnet_destroy_peer_locked(lnet_peer_t *lp) lnet_peer_t * lnet_find_peer_locked(struct lnet_peer_table *ptable, lnet_nid_t nid) { - struct list_head *peers; - lnet_peer_t *lp; + struct list_head *peers; + lnet_peer_t *lp; LASSERT(!the_lnet.ln_shutdown); @@ -205,11 +205,11 @@ lnet_find_peer_locked(struct lnet_peer_table *ptable, lnet_nid_t nid) int lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt) { - struct lnet_peer_table *ptable; - lnet_peer_t *lp = NULL; - lnet_peer_t *lp2; - int cpt2; - int rc = 0; + struct lnet_peer_table *ptable; + lnet_peer_t *lp = NULL; + lnet_peer_t *lp2; + int cpt2; + int rc = 0; *lpp = NULL; if (the_lnet.ln_shutdown) /* it's shutting down */ @@ -287,8 +287,8 @@ lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt) goto out; } - lp->lp_txcredits = - lp->lp_mintxcredits = lp->lp_ni->ni_peertxcredits; + lp->lp_txcredits = + lp->lp_mintxcredits = lp->lp_ni->ni_peertxcredits; lp->lp_rtrcredits = lp->lp_minrtrcredits = lnet_peer_buffer_credits(lp->lp_ni); @@ -308,10 +308,10 @@ out: void lnet_debug_peer(lnet_nid_t nid) { - char *aliveness = "NA"; - lnet_peer_t *lp; - int rc; - int cpt; + char *aliveness = "NA"; + lnet_peer_t *lp; + int rc; + int cpt; cpt = lnet_cpt_of_nid(nid); lnet_net_lock(cpt); diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index 8510bae4822a..96886a2b4571 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -139,8 +139,8 @@ lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive, static void lnet_ni_notify_locked(lnet_ni_t *ni, lnet_peer_t *lp) { - int alive; - int notifylnd; + int alive; + int notifylnd; /* Notify only in 1 thread at any time to ensure ordered notification. * NB individual events can be missed; the only guarantee is that you @@ -152,7 +152,7 @@ lnet_ni_notify_locked(lnet_ni_t *ni, lnet_peer_t *lp) lp->lp_notifying = 1; while (lp->lp_notify) { - alive = lp->lp_alive; + alive = lp->lp_alive; notifylnd = lp->lp_notifylnd; lp->lp_notifylnd = 0; @@ -228,9 +228,9 @@ lnet_rtr_decref_locked(lnet_peer_t *lp) lnet_remotenet_t * lnet_find_net_locked(__u32 net) { - lnet_remotenet_t *rnet; - struct list_head *tmp; - struct list_head *rn_list; + lnet_remotenet_t *rnet; + struct list_head *tmp; + struct list_head *rn_list; LASSERT(!the_lnet.ln_shutdown); @@ -276,9 +276,9 @@ static void lnet_shuffle_seed(void) static void lnet_add_route_to_rnet(lnet_remotenet_t *rnet, lnet_route_t *route) { - unsigned int len = 0; - unsigned int offset = 0; - struct list_head *e; + unsigned int len = 0; + unsigned int offset = 0; + struct list_head *e; lnet_shuffle_seed(); @@ -304,13 +304,13 @@ int lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway, unsigned int priority) { - struct list_head *e; - lnet_remotenet_t *rnet; - lnet_remotenet_t *rnet2; - lnet_route_t *route; - lnet_ni_t *ni; - int add_route; - int rc; + struct list_head *e; + lnet_remotenet_t *rnet; + lnet_remotenet_t *rnet2; + lnet_route_t *route; + lnet_ni_t *ni; + int add_route; + int rc; CDEBUG(D_NET, "Add route: net %s hops %u priority %u gw %s\n", libcfs_net2str(net), hops, priority, libcfs_nid2str(gateway)); @@ -416,14 +416,14 @@ lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway, int lnet_check_routes(void) { - lnet_remotenet_t *rnet; - lnet_route_t *route; - lnet_route_t *route2; - struct list_head *e1; - struct list_head *e2; - int cpt; - struct list_head *rn_list; - int i; + lnet_remotenet_t *rnet; + lnet_route_t *route; + lnet_route_t *route2; + struct list_head *e1; + struct list_head *e2; + int cpt; + struct list_head *rn_list; + int i; cpt = lnet_net_lock_current(); @@ -434,9 +434,9 @@ lnet_check_routes(void) route2 = NULL; list_for_each(e2, &rnet->lrn_routes) { - lnet_nid_t nid1; - lnet_nid_t nid2; - int net; + lnet_nid_t nid1; + lnet_nid_t nid2; + int net; route = list_entry(e2, lnet_route_t, lr_list); @@ -472,14 +472,14 @@ lnet_check_routes(void) int lnet_del_route(__u32 net, lnet_nid_t gw_nid) { - struct lnet_peer *gateway; - lnet_remotenet_t *rnet; - lnet_route_t *route; - struct list_head *e1; - struct list_head *e2; - int rc = -ENOENT; - struct list_head *rn_list; - int idx = 0; + struct lnet_peer *gateway; + lnet_remotenet_t *rnet; + lnet_route_t *route; + struct list_head *e1; + struct list_head *e2; + int rc = -ENOENT; + struct list_head *rn_list; + int idx = 0; CDEBUG(D_NET, "Del route: net %s : gw %s\n", libcfs_net2str(net), libcfs_nid2str(gw_nid)); @@ -554,13 +554,13 @@ int lnet_get_route(int idx, __u32 *net, __u32 *hops, lnet_nid_t *gateway, __u32 *alive, __u32 *priority) { - struct list_head *e1; - struct list_head *e2; - lnet_remotenet_t *rnet; - lnet_route_t *route; - int cpt; - int i; - struct list_head *rn_list; + struct list_head *e1; + struct list_head *e2; + lnet_remotenet_t *rnet; + lnet_route_t *route; + int cpt; + int i; + struct list_head *rn_list; cpt = lnet_net_lock_current(); @@ -574,11 +574,11 @@ lnet_get_route(int idx, __u32 *net, __u32 *hops, lr_list); if (idx-- == 0) { - *net = rnet->lrn_net; - *hops = route->lr_hops; + *net = rnet->lrn_net; + *hops = route->lr_hops; *priority = route->lr_priority; *gateway = route->lr_gateway->lp_nid; - *alive = route->lr_gateway->lp_alive; + *alive = route->lr_gateway->lp_alive; lnet_net_unlock(cpt); return 0; } @@ -593,7 +593,7 @@ lnet_get_route(int idx, __u32 *net, __u32 *hops, void lnet_swap_pinginfo(lnet_ping_info_t *info) { - int i; + int i; lnet_ni_status_t *stat; __swab32s(&info->pi_magic); @@ -614,9 +614,9 @@ lnet_swap_pinginfo(lnet_ping_info_t *info) static void lnet_parse_rc_info(lnet_rc_data_t *rcd) { - lnet_ping_info_t *info = rcd->rcd_pinginfo; - struct lnet_peer *gw = rcd->rcd_gateway; - lnet_route_t *rtr; + lnet_ping_info_t *info = rcd->rcd_pinginfo; + struct lnet_peer *gw = rcd->rcd_gateway; + lnet_route_t *rtr; if (!gw->lp_alive) return; @@ -643,14 +643,14 @@ lnet_parse_rc_info(lnet_rc_data_t *rcd) return; /* can't carry NI status info */ list_for_each_entry(rtr, &gw->lp_routes, lr_gwlist) { - int ptl_status = LNET_NI_STATUS_INVALID; - int down = 0; - int up = 0; - int i; + int ptl_status = LNET_NI_STATUS_INVALID; + int down = 0; + int up = 0; + int i; for (i = 0; i < info->pi_nnis && i < LNET_MAX_RTR_NIS; i++) { lnet_ni_status_t *stat = &info->pi_ni[i]; - lnet_nid_t nid = stat->ns_nid; + lnet_nid_t nid = stat->ns_nid; if (nid == LNET_NID_ANY) { CDEBUG(D_NET, "%s: unexpected LNET_NID_ANY\n", @@ -699,8 +699,8 @@ lnet_parse_rc_info(lnet_rc_data_t *rcd) static void lnet_router_checker_event(lnet_event_t *event) { - lnet_rc_data_t *rcd = event->md.user_ptr; - struct lnet_peer *lp; + lnet_rc_data_t *rcd = event->md.user_ptr; + struct lnet_peer *lp; LASSERT(rcd != NULL); @@ -752,14 +752,14 @@ lnet_router_checker_event(lnet_event_t *event) static void lnet_wait_known_routerstate(void) { - lnet_peer_t *rtr; - struct list_head *entry; - int all_known; + lnet_peer_t *rtr; + struct list_head *entry; + int all_known; LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING); for (;;) { - int cpt = lnet_net_lock_current(); + int cpt = lnet_net_lock_current(); all_known = 1; list_for_each(entry, &the_lnet.ln_routers) { @@ -799,9 +799,9 @@ lnet_router_ni_update_locked(lnet_peer_t *gw, __u32 net) static void lnet_update_ni_status_locked(void) { - lnet_ni_t *ni; - long now; - int timeout; + lnet_ni_t *ni; + long now; + int timeout; LASSERT(the_lnet.ln_routing); @@ -860,10 +860,10 @@ lnet_destroy_rc_data(lnet_rc_data_t *rcd) static lnet_rc_data_t * lnet_create_rc_data_locked(lnet_peer_t *gateway) { - lnet_rc_data_t *rcd = NULL; - lnet_ping_info_t *pi; - int rc; - int i; + lnet_rc_data_t *rcd = NULL; + lnet_ping_info_t *pi; + int rc; + int i; lnet_net_unlock(gateway->lp_cpt); @@ -943,8 +943,8 @@ static void lnet_ping_router_locked(lnet_peer_t *rtr) { lnet_rc_data_t *rcd = NULL; - unsigned long now = cfs_time_current(); - int secs; + unsigned long now = cfs_time_current(); + int secs; lnet_peer_addref_locked(rtr); @@ -979,9 +979,9 @@ lnet_ping_router_locked(lnet_peer_t *rtr) if (secs != 0 && !rtr->lp_ping_notsent && cfs_time_after(now, cfs_time_add(rtr->lp_ping_timestamp, cfs_time_seconds(secs)))) { - int rc; + int rc; lnet_process_id_t id; - lnet_handle_md_t mdh; + lnet_handle_md_t mdh; id.nid = rtr->lp_nid; id.pid = LUSTRE_SRV_LNET_PID; @@ -1013,8 +1013,8 @@ lnet_ping_router_locked(lnet_peer_t *rtr) int lnet_router_checker_start(void) { - int rc; - int eqsz; + int rc; + int eqsz; LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN); @@ -1085,11 +1085,11 @@ lnet_router_checker_stop(void) static void lnet_prune_rc_data(int wait_unlink) { - lnet_rc_data_t *rcd; - lnet_rc_data_t *tmp; - lnet_peer_t *lp; - struct list_head head; - int i = 2; + lnet_rc_data_t *rcd; + lnet_rc_data_t *tmp; + lnet_peer_t *lp; + struct list_head head; + int i = 2; if (likely(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING && list_empty(&the_lnet.ln_rcd_deathrow) && @@ -1169,17 +1169,17 @@ lnet_prune_rc_data(int wait_unlink) static int lnet_router_checker(void *arg) { - lnet_peer_t *rtr; - struct list_head *entry; + lnet_peer_t *rtr; + struct list_head *entry; cfs_block_allsigs(); LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING); while (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING) { - __u64 version; - int cpt; - int cpt2; + __u64 version; + int cpt; + int cpt2; cpt = lnet_net_lock_current(); rescan: @@ -1245,11 +1245,11 @@ lnet_destroy_rtrbuf(lnet_rtrbuf_t *rb, int npages) static lnet_rtrbuf_t * lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt) { - int npages = rbp->rbp_npages; - int sz = offsetof(lnet_rtrbuf_t, rb_kiov[npages]); - struct page *page; + int npages = rbp->rbp_npages; + int sz = offsetof(lnet_rtrbuf_t, rb_kiov[npages]); + struct page *page; lnet_rtrbuf_t *rb; - int i; + int i; LIBCFS_CPT_ALLOC(rb, lnet_cpt_table(), cpt, sz); if (rb == NULL) @@ -1280,9 +1280,9 @@ lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt) static void lnet_rtrpool_free_bufs(lnet_rtrbufpool_t *rbp) { - int npages = rbp->rbp_npages; - int nbuffers = 0; - lnet_rtrbuf_t *rb; + int npages = rbp->rbp_npages; + int nbuffers = 0; + lnet_rtrbuf_t *rb; if (rbp->rbp_nbuffers == 0) /* not initialized or already freed */ return; @@ -1310,7 +1310,7 @@ static int lnet_rtrpool_alloc_bufs(lnet_rtrbufpool_t *rbp, int nbufs, int cpt) { lnet_rtrbuf_t *rb; - int i; + int i; if (rbp->rbp_nbuffers != 0) { LASSERT(rbp->rbp_nbuffers == nbufs); @@ -1355,7 +1355,7 @@ void lnet_rtrpools_free(void) { lnet_rtrbufpool_t *rtrp; - int i; + int i; if (the_lnet.ln_rtrpools == NULL) /* uninitialized or freed */ return; @@ -1373,7 +1373,7 @@ lnet_rtrpools_free(void) static int lnet_nrb_tiny_calculate(int npages) { - int nrbs = LNET_NRB_TINY; + int nrbs = LNET_NRB_TINY; if (tiny_router_buffers < 0) { LCONSOLE_ERROR_MSG(0x10c, @@ -1392,7 +1392,7 @@ lnet_nrb_tiny_calculate(int npages) static int lnet_nrb_small_calculate(int npages) { - int nrbs = LNET_NRB_SMALL; + int nrbs = LNET_NRB_SMALL; if (small_router_buffers < 0) { LCONSOLE_ERROR_MSG(0x10c, @@ -1411,7 +1411,7 @@ lnet_nrb_small_calculate(int npages) static int lnet_nrb_large_calculate(int npages) { - int nrbs = LNET_NRB_LARGE; + int nrbs = LNET_NRB_LARGE; if (large_router_buffers < 0) { LCONSOLE_ERROR_MSG(0x10c, @@ -1431,13 +1431,13 @@ int lnet_rtrpools_alloc(int im_a_router) { lnet_rtrbufpool_t *rtrp; - int large_pages; - int small_pages = 1; - int nrb_tiny; - int nrb_small; - int nrb_large; - int rc; - int i; + int large_pages; + int small_pages = 1; + int nrb_tiny; + int nrb_small; + int nrb_large; + int rc; + int i; large_pages = (LNET_MTU + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; @@ -1507,9 +1507,9 @@ lnet_rtrpools_alloc(int im_a_router) int lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when) { - struct lnet_peer *lp = NULL; - unsigned long now = cfs_time_current(); - int cpt = lnet_cpt_of_nid(nid); + struct lnet_peer *lp = NULL; + unsigned long now = cfs_time_current(); + int cpt = lnet_cpt_of_nid(nid); LASSERT(!in_interrupt ()); @@ -1591,13 +1591,13 @@ void lnet_router_checker(void) { static time_t last; - static int running; + static int running; - time_t now = get_seconds(); - int interval = now - last; - int rc; - __u64 version; - lnet_peer_t *rtr; + time_t now = get_seconds(); + int interval = now - last; + int rc; + __u64 version; + lnet_peer_t *rtr; /* It's no use to call me again within a sec - all intervals and * timeouts are measured in seconds */ @@ -1625,7 +1625,7 @@ lnet_router_checker(void) /* consume all pending events */ while (1) { - int i; + int i; lnet_event_t ev; /* NB ln_rc_eqh must be the 1st in 'eventqs' otherwise the diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c index c055afc86eb4..ee902dc43823 100644 --- a/drivers/staging/lustre/lnet/lnet/router_proc.c +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c @@ -112,11 +112,11 @@ static int proc_call_handler(void *data, int write, loff_t *ppos, static int __proc_lnet_stats(void *data, int write, loff_t pos, void __user *buffer, int nob) { - int rc; + int rc; lnet_counters_t *ctrs; - int len; - char *tmpstr; - const int tmpsiz = 256; /* 7 %u and 4 %llu */ + int len; + char *tmpstr; + const int tmpsiz = 256; /* 7 %u and 4 %llu */ if (write) { lnet_counters_reset(); @@ -167,13 +167,13 @@ static int proc_lnet_stats(struct ctl_table *table, int write, static int proc_lnet_routes(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { - const int tmpsiz = 256; - char *tmpstr; - char *s; - int rc = 0; - int len; - int ver; - int off; + const int tmpsiz = 256; + char *tmpstr; + char *s; + int rc = 0; + int len; + int ver; + int off; CLASSERT(sizeof(loff_t) >= 4); @@ -205,13 +205,13 @@ static int proc_lnet_routes(struct ctl_table *table, int write, lnet_net_unlock(0); *ppos = LNET_PROC_POS_MAKE(0, ver, 0, off); } else { - struct list_head *n; - struct list_head *r; - lnet_route_t *route = NULL; - lnet_remotenet_t *rnet = NULL; - int skip = off - 1; - struct list_head *rn_list; - int i; + struct list_head *n; + struct list_head *r; + lnet_route_t *route = NULL; + lnet_remotenet_t *rnet = NULL; + int skip = off - 1; + struct list_head *rn_list; + int i; lnet_net_lock(0); @@ -251,11 +251,11 @@ static int proc_lnet_routes(struct ctl_table *table, int write, } if (route != NULL) { - __u32 net = rnet->lrn_net; - unsigned int hops = route->lr_hops; - unsigned int priority = route->lr_priority; - lnet_nid_t nid = route->lr_gateway->lp_nid; - int alive = route->lr_gateway->lp_alive; + __u32 net = rnet->lrn_net; + unsigned int hops = route->lr_hops; + unsigned int priority = route->lr_priority; + lnet_nid_t nid = route->lr_gateway->lp_nid; + int alive = route->lr_gateway->lp_alive; s += snprintf(s, tmpstr + tmpsiz - s, "%-8s %4u %8u %7s %s\n", @@ -293,13 +293,13 @@ static int proc_lnet_routes(struct ctl_table *table, int write, static int proc_lnet_routers(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { - int rc = 0; - char *tmpstr; - char *s; - const int tmpsiz = 256; - int len; - int ver; - int off; + int rc = 0; + char *tmpstr; + char *s; + const int tmpsiz = 256; + int len; + int ver; + int off; off = LNET_PROC_HOFF_GET(*ppos); ver = LNET_PROC_VER_GET(*ppos); @@ -328,9 +328,9 @@ static int proc_lnet_routers(struct ctl_table *table, int write, lnet_net_unlock(0); *ppos = LNET_PROC_POS_MAKE(0, ver, 0, off); } else { - struct list_head *r; - struct lnet_peer *peer = NULL; - int skip = off - 1; + struct list_head *r; + struct lnet_peer *peer = NULL; + int skip = off - 1; lnet_net_lock(0); @@ -360,14 +360,14 @@ static int proc_lnet_routers(struct ctl_table *table, int write, lnet_nid_t nid = peer->lp_nid; unsigned long now = cfs_time_current(); unsigned long deadline = peer->lp_ping_deadline; - int nrefs = peer->lp_refcount; - int nrtrrefs = peer->lp_rtr_refcount; + int nrefs = peer->lp_refcount; + int nrtrrefs = peer->lp_rtr_refcount; int alive_cnt = peer->lp_alive_count; - int alive = peer->lp_alive; - int pingsent = !peer->lp_ping_notsent; + int alive = peer->lp_alive; + int pingsent = !peer->lp_ping_notsent; int last_ping = cfs_duration_sec(cfs_time_sub(now, peer->lp_ping_timestamp)); - int down_ni = 0; + int down_ni = 0; lnet_route_t *rtr; if ((peer->lp_ping_feats & @@ -428,16 +428,16 @@ static int proc_lnet_routers(struct ctl_table *table, int write, static int proc_lnet_peers(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { - const int tmpsiz = 256; - struct lnet_peer_table *ptable; - char *tmpstr; - char *s; - int cpt = LNET_PROC_CPT_GET(*ppos); - int ver = LNET_PROC_VER_GET(*ppos); - int hash = LNET_PROC_HASH_GET(*ppos); - int hoff = LNET_PROC_HOFF_GET(*ppos); - int rc = 0; - int len; + const int tmpsiz = 256; + struct lnet_peer_table *ptable; + char *tmpstr; + char *s; + int cpt = LNET_PROC_CPT_GET(*ppos); + int ver = LNET_PROC_VER_GET(*ppos); + int hash = LNET_PROC_HASH_GET(*ppos); + int hoff = LNET_PROC_HOFF_GET(*ppos); + int rc = 0; + int len; CLASSERT(LNET_PROC_HASH_BITS >= LNET_PEER_HASH_BITS); LASSERT(!write); @@ -465,9 +465,9 @@ static int proc_lnet_peers(struct ctl_table *table, int write, hoff++; } else { - struct lnet_peer *peer; - struct list_head *p; - int skip; + struct lnet_peer *peer; + struct list_head *p; + int skip; again: p = NULL; peer = NULL; @@ -521,23 +521,23 @@ static int proc_lnet_peers(struct ctl_table *table, int write, } if (peer != NULL) { - lnet_nid_t nid = peer->lp_nid; - int nrefs = peer->lp_refcount; - int lastalive = -1; - char *aliveness = "NA"; - int maxcr = peer->lp_ni->ni_peertxcredits; - int txcr = peer->lp_txcredits; - int mintxcr = peer->lp_mintxcredits; - int rtrcr = peer->lp_rtrcredits; - int minrtrcr = peer->lp_minrtrcredits; - int txqnob = peer->lp_txqnob; + lnet_nid_t nid = peer->lp_nid; + int nrefs = peer->lp_refcount; + int lastalive = -1; + char *aliveness = "NA"; + int maxcr = peer->lp_ni->ni_peertxcredits; + int txcr = peer->lp_txcredits; + int mintxcr = peer->lp_mintxcredits; + int rtrcr = peer->lp_rtrcredits; + int minrtrcr = peer->lp_minrtrcredits; + int txqnob = peer->lp_txqnob; if (lnet_isrouter(peer) || lnet_peer_aliveness_enabled(peer)) aliveness = peer->lp_alive ? "up" : "down"; if (lnet_peer_aliveness_enabled(peer)) { - unsigned long now = cfs_time_current(); + unsigned long now = cfs_time_current(); long delta; delta = cfs_time_sub(now, peer->lp_last_alive); @@ -595,13 +595,13 @@ static int proc_lnet_peers(struct ctl_table *table, int write, static int __proc_lnet_buffers(void *data, int write, loff_t pos, void __user *buffer, int nob) { - char *s; - char *tmpstr; - int tmpsiz; - int idx; - int len; - int rc; - int i; + char *s; + char *tmpstr; + int tmpsiz; + int idx; + int len; + int rc; + int i; LASSERT(!write); @@ -660,11 +660,11 @@ static int proc_lnet_buffers(struct ctl_table *table, int write, static int proc_lnet_nis(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { - int tmpsiz = 128 * LNET_CPT_NUMBER; - int rc = 0; - char *tmpstr; - char *s; - int len; + int tmpsiz = 128 * LNET_CPT_NUMBER; + int rc = 0; + char *tmpstr; + char *s; + int len; LASSERT(!write); @@ -684,9 +684,9 @@ static int proc_lnet_nis(struct ctl_table *table, int write, "rtr", "max", "tx", "min"); LASSERT(tmpstr + tmpsiz - s > 0); } else { - struct list_head *n; - lnet_ni_t *ni = NULL; - int skip = *ppos - 1; + struct list_head *n; + lnet_ni_t *ni = NULL; + int skip = *ppos - 1; lnet_net_lock(0); @@ -705,12 +705,12 @@ static int proc_lnet_nis(struct ctl_table *table, int write, } if (ni != NULL) { - struct lnet_tx_queue *tq; - char *stat; - long now = get_seconds(); - int last_alive = -1; - int i; - int j; + struct lnet_tx_queue *tq; + char *stat; + long now = get_seconds(); + int last_alive = -1; + int i; + int j; if (the_lnet.ln_routing) last_alive = now - ni->ni_last_alive; @@ -777,9 +777,9 @@ static int proc_lnet_nis(struct ctl_table *table, int write, } struct lnet_portal_rotors { - int pr_value; - const char *pr_name; - const char *pr_desc; + int pr_value; + const char *pr_name; + const char *pr_desc; }; static struct lnet_portal_rotors portal_rotors[] = { @@ -815,11 +815,11 @@ extern int portal_rotor; static int __proc_lnet_portal_rotor(void *data, int write, loff_t pos, void __user *buffer, int nob) { - const int buf_len = 128; - char *buf; - char *tmp; - int rc; - int i; + const int buf_len = 128; + char *buf; + char *tmp; + int rc; + int i; LIBCFS_ALLOC(buf, buf_len); if (buf == NULL) @@ -887,38 +887,38 @@ static struct ctl_table lnet_table[] = { * to go via /proc for portability. */ { - .procname = "stats", - .mode = 0644, + .procname = "stats", + .mode = 0644, .proc_handler = &proc_lnet_stats, }, { - .procname = "routes", - .mode = 0444, + .procname = "routes", + .mode = 0444, .proc_handler = &proc_lnet_routes, }, { - .procname = "routers", - .mode = 0444, + .procname = "routers", + .mode = 0444, .proc_handler = &proc_lnet_routers, }, { - .procname = "peers", - .mode = 0444, + .procname = "peers", + .mode = 0444, .proc_handler = &proc_lnet_peers, }, { - .procname = "buffers", - .mode = 0444, + .procname = "buffers", + .mode = 0444, .proc_handler = &proc_lnet_buffers, }, { - .procname = "nis", - .mode = 0444, + .procname = "nis", + .mode = 0444, .proc_handler = &proc_lnet_nis, }, { - .procname = "portal_rotor", - .mode = 0644, + .procname = "portal_rotor", + .mode = 0644, .proc_handler = &proc_lnet_portal_rotor, }, { From 4de4e73625aa3e067357ad6f956a4cad3255413f Mon Sep 17 00:00:00 2001 From: Mike Shuey Date: Tue, 19 May 2015 10:14:33 -0400 Subject: [PATCH 0555/1163] staging: lustre: lnet: dead code - remove lnet_fini_locks lnet_fini_locks() does nothing. Remove. Signed-off-by: Mike Shuey Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/api-ni.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 6910f56703d1..1adc481c7f48 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -98,12 +98,6 @@ lnet_init_locks(void) mutex_init(&the_lnet.ln_api_mutex); } -static void -lnet_fini_locks(void) -{ -} - - static int lnet_create_remote_nets_table(void) { @@ -153,8 +147,6 @@ lnet_destroy_locks(void) cfs_percpt_lock_free(the_lnet.ln_net_lock); the_lnet.ln_net_lock = NULL; } - - lnet_fini_locks(); } static int From 7c285a193412cffe5394ff68910cc19852d42cfc Mon Sep 17 00:00:00 2001 From: Mike Shuey Date: Tue, 19 May 2015 10:14:34 -0400 Subject: [PATCH 0556/1163] staging: lustre: lnet: dead code - remove LNetSetAsync LNetSetAsync() returns 0, and is never called. Doesn't exist in the Intel tree, either. Remove it. Signed-off-by: Mike Shuey Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/include/linux/lnet/api.h | 1 - drivers/staging/lustre/lnet/lnet/lib-move.c | 24 ------------------- 2 files changed, 25 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/api.h b/drivers/staging/lustre/include/linux/lnet/api.h index cd865175703f..c4dc1b2f605d 100644 --- a/drivers/staging/lustre/include/linux/lnet/api.h +++ b/drivers/staging/lustre/include/linux/lnet/api.h @@ -209,7 +209,6 @@ int LNetGet(lnet_nid_t self, int LNetSetLazyPortal(int portal); int LNetClearLazyPortal(int portal); int LNetCtl(unsigned int cmd, void *arg); -int LNetSetAsync(lnet_process_id_t id, int nasync); /** @} lnet_misc */ diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index ba59fe70732a..433faae9a2ff 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -2434,27 +2434,3 @@ LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp) return -EHOSTUNREACH; } EXPORT_SYMBOL(LNetDist); - -/** - * Set the number of asynchronous messages expected from a target process. - * - * This function is only meaningful for userspace callers. It's a no-op when - * called from kernel. - * - * Asynchronous messages are those that can come from a target when the - * userspace process is not waiting for IO to complete; e.g., AST callbacks - * from Lustre servers. Specifying the expected number of such messages - * allows them to be eagerly received when user process is not running in - * LNet; otherwise network errors may occur. - * - * \param id Process ID of the target process. - * \param nasync Number of asynchronous messages expected from the target. - * - * \return 0 on success, and an error code otherwise. - */ -int -LNetSetAsync(lnet_process_id_t id, int nasync) -{ - return 0; -} -EXPORT_SYMBOL(LNetSetAsync); From 92980ff946fc2cdf160db735751bdbf01e5be39e Mon Sep 17 00:00:00 2001 From: Mike Shuey Date: Tue, 19 May 2015 10:14:35 -0400 Subject: [PATCH 0557/1163] staging: lustre: lnet: lnet: Module is LNet, not Portals Fix the module version to match upstream development. Signed-off-by: Mike Shuey Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c index ff3f83172b14..f73d64468396 100644 --- a/drivers/staging/lustre/lnet/lnet/module.c +++ b/drivers/staging/lustre/lnet/lnet/module.c @@ -147,7 +147,7 @@ fini_lnet(void) } MODULE_AUTHOR("Peter J. Braam "); -MODULE_DESCRIPTION("Portals v3.1"); +MODULE_DESCRIPTION("LNet v3.1"); MODULE_LICENSE("GPL"); MODULE_VERSION("1.0.0"); From ec3d17c0ed2e8e8cf111e24aec6586190b5d9b7a Mon Sep 17 00:00:00 2001 From: Mike Shuey Date: Tue, 19 May 2015 10:14:36 -0400 Subject: [PATCH 0558/1163] staging: lustre: lnet: o2iblnd: code cleanup - align whitespace Unify variable declarations to use a single whitespace. Also line up declarations and comments in o2iblnd.h. Signed-off-by: Mike Shuey Signed-off-by: Greg Kroah-Hartman --- .../lustre/lnet/klnds/o2iblnd/o2iblnd.c | 458 ++++++------ .../lustre/lnet/klnds/o2iblnd/o2iblnd.h | 670 +++++++++--------- .../lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 484 +++++++------ .../lnet/klnds/o2iblnd/o2iblnd_modparams.c | 48 +- 4 files changed, 836 insertions(+), 824 deletions(-) diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index 3bad441de8dc..a57c5c35ee68 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -42,21 +42,21 @@ #include static lnd_t the_o2iblnd = { - .lnd_type = O2IBLND, - .lnd_startup = kiblnd_startup, - .lnd_shutdown = kiblnd_shutdown, - .lnd_ctl = kiblnd_ctl, - .lnd_query = kiblnd_query, - .lnd_send = kiblnd_send, - .lnd_recv = kiblnd_recv, + .lnd_type = O2IBLND, + .lnd_startup = kiblnd_startup, + .lnd_shutdown = kiblnd_shutdown, + .lnd_ctl = kiblnd_ctl, + .lnd_query = kiblnd_query, + .lnd_send = kiblnd_send, + .lnd_recv = kiblnd_recv, }; -kib_data_t kiblnd_data; +kib_data_t kiblnd_data; static __u32 kiblnd_cksum(void *ptr, int nob) { - char *c = ptr; - __u32 sum = 0; + char *c = ptr; + __u32 sum = 0; while (nob-- > 0) sum = ((sum << 1) | (sum >> 31)) + *c++; @@ -138,10 +138,10 @@ static int kiblnd_msgtype2size(int type) static int kiblnd_unpack_rd(kib_msg_t *msg, int flip) { - kib_rdma_desc_t *rd; - int nob; - int n; - int i; + kib_rdma_desc_t *rd; + int nob; + int n; + int i; LASSERT(msg->ibm_type == IBLND_MSG_GET_REQ || msg->ibm_type == IBLND_MSG_PUT_ACK); @@ -210,10 +210,10 @@ void kiblnd_pack_msg(lnet_ni_t *ni, kib_msg_t *msg, int version, int kiblnd_unpack_msg(kib_msg_t *msg, int nob) { const int hdr_size = offsetof(kib_msg_t, ibm_u); - __u32 msg_cksum; - __u16 version; - int msg_nob; - int flip; + __u32 msg_cksum; + __u16 version; + int msg_nob; + int flip; /* 6 bytes are enough to have received magic + version */ if (nob < 6) { @@ -320,10 +320,10 @@ int kiblnd_unpack_msg(kib_msg_t *msg, int nob) int kiblnd_create_peer(lnet_ni_t *ni, kib_peer_t **peerp, lnet_nid_t nid) { - kib_peer_t *peer; - kib_net_t *net = ni->ni_data; - int cpt = lnet_cpt_of_nid(nid); - unsigned long flags; + kib_peer_t *peer; + kib_net_t *net = ni->ni_data; + int cpt = lnet_cpt_of_nid(nid); + unsigned long flags; LASSERT(net != NULL); LASSERT(nid != LNET_NID_ANY); @@ -385,9 +385,9 @@ kib_peer_t *kiblnd_find_peer_locked(lnet_nid_t nid) { /* the caller is responsible for accounting the additional reference * that this creates */ - struct list_head *peer_list = kiblnd_nid2peerlist(nid); - struct list_head *tmp; - kib_peer_t *peer; + struct list_head *peer_list = kiblnd_nid2peerlist(nid); + struct list_head *tmp; + kib_peer_t *peer; list_for_each(tmp, peer_list) { @@ -422,10 +422,10 @@ void kiblnd_unlink_peer_locked(kib_peer_t *peer) static int kiblnd_get_peer_info(lnet_ni_t *ni, int index, lnet_nid_t *nidp, int *count) { - kib_peer_t *peer; - struct list_head *ptmp; - int i; - unsigned long flags; + kib_peer_t *peer; + struct list_head *ptmp; + int i; + unsigned long flags; read_lock_irqsave(&kiblnd_data.kib_global_lock, flags); @@ -459,9 +459,9 @@ static int kiblnd_get_peer_info(lnet_ni_t *ni, int index, static void kiblnd_del_peer_locked(kib_peer_t *peer) { - struct list_head *ctmp; - struct list_head *cnxt; - kib_conn_t *conn; + struct list_head *ctmp; + struct list_head *cnxt; + kib_conn_t *conn; if (list_empty(&peer->ibp_conns)) { kiblnd_unlink_peer_locked(peer); @@ -480,14 +480,14 @@ static void kiblnd_del_peer_locked(kib_peer_t *peer) static int kiblnd_del_peer(lnet_ni_t *ni, lnet_nid_t nid) { LIST_HEAD(zombies); - struct list_head *ptmp; - struct list_head *pnxt; - kib_peer_t *peer; - int lo; - int hi; - int i; - unsigned long flags; - int rc = -ENOENT; + struct list_head *ptmp; + struct list_head *pnxt; + kib_peer_t *peer; + int lo; + int hi; + int i; + unsigned long flags; + int rc = -ENOENT; write_lock_irqsave(&kiblnd_data.kib_global_lock, flags); @@ -532,12 +532,12 @@ static int kiblnd_del_peer(lnet_ni_t *ni, lnet_nid_t nid) static kib_conn_t *kiblnd_get_conn_by_idx(lnet_ni_t *ni, int index) { - kib_peer_t *peer; - struct list_head *ptmp; - kib_conn_t *conn; - struct list_head *ctmp; - int i; - unsigned long flags; + kib_peer_t *peer; + struct list_head *ptmp; + kib_conn_t *conn; + struct list_head *ctmp; + int i; + unsigned long flags; read_lock_irqsave(&kiblnd_data.kib_global_lock, flags); @@ -593,7 +593,7 @@ int kiblnd_translate_mtu(int value) static void kiblnd_setup_mtu_locked(struct rdma_cm_id *cmid) { - int mtu; + int mtu; /* XXX There is no path record for iWARP, set by netdev->change_mtu? */ if (cmid->route.path_rec == NULL) @@ -607,11 +607,11 @@ static void kiblnd_setup_mtu_locked(struct rdma_cm_id *cmid) static int kiblnd_get_completion_vector(kib_conn_t *conn, int cpt) { - cpumask_t *mask; - int vectors; - int off; - int i; - lnet_nid_t nid = conn->ibc_peer->ibp_nid; + cpumask_t *mask; + int vectors; + int off; + int i; + lnet_nid_t nid = conn->ibc_peer->ibp_nid; vectors = conn->ibc_cmid->device->num_comp_vectors; if (vectors <= 1) @@ -642,17 +642,17 @@ kib_conn_t *kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id *cmid, * she must dispose of 'cmid'. (Actually I'd block forever if I tried * to destroy 'cmid' here since I'm called from the CM which still has * its ref on 'cmid'). */ - rwlock_t *glock = &kiblnd_data.kib_global_lock; - kib_net_t *net = peer->ibp_ni->ni_data; - kib_dev_t *dev; + rwlock_t *glock = &kiblnd_data.kib_global_lock; + kib_net_t *net = peer->ibp_ni->ni_data; + kib_dev_t *dev; struct ib_qp_init_attr *init_qp_attr; - struct kib_sched_info *sched; - kib_conn_t *conn; - struct ib_cq *cq; - unsigned long flags; - int cpt; - int rc; - int i; + struct kib_sched_info *sched; + kib_conn_t *conn; + struct ib_cq *cq; + unsigned long flags; + int cpt; + int rc; + int i; LASSERT(net != NULL); LASSERT(!in_interrupt()); @@ -837,8 +837,8 @@ kib_conn_t *kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id *cmid, void kiblnd_destroy_conn(kib_conn_t *conn) { struct rdma_cm_id *cmid = conn->ibc_cmid; - kib_peer_t *peer = conn->ibc_peer; - int rc; + kib_peer_t *peer = conn->ibc_peer; + int rc; LASSERT(!in_interrupt()); LASSERT(atomic_read(&conn->ibc_refcount) == 0); @@ -904,10 +904,10 @@ void kiblnd_destroy_conn(kib_conn_t *conn) int kiblnd_close_peer_conns_locked(kib_peer_t *peer, int why) { - kib_conn_t *conn; - struct list_head *ctmp; - struct list_head *cnxt; - int count = 0; + kib_conn_t *conn; + struct list_head *ctmp; + struct list_head *cnxt; + int count = 0; list_for_each_safe(ctmp, cnxt, &peer->ibp_conns) { conn = list_entry(ctmp, kib_conn_t, ibc_list); @@ -926,10 +926,10 @@ int kiblnd_close_peer_conns_locked(kib_peer_t *peer, int why) int kiblnd_close_stale_conns_locked(kib_peer_t *peer, int version, __u64 incarnation) { - kib_conn_t *conn; - struct list_head *ctmp; - struct list_head *cnxt; - int count = 0; + kib_conn_t *conn; + struct list_head *ctmp; + struct list_head *cnxt; + int count = 0; list_for_each_safe(ctmp, cnxt, &peer->ibp_conns) { conn = list_entry(ctmp, kib_conn_t, ibc_list); @@ -953,14 +953,14 @@ int kiblnd_close_stale_conns_locked(kib_peer_t *peer, static int kiblnd_close_matching_conns(lnet_ni_t *ni, lnet_nid_t nid) { - kib_peer_t *peer; - struct list_head *ptmp; - struct list_head *pnxt; - int lo; - int hi; - int i; - unsigned long flags; - int count = 0; + kib_peer_t *peer; + struct list_head *ptmp; + struct list_head *pnxt; + int lo; + int hi; + int i; + unsigned long flags; + int count = 0; write_lock_irqsave(&kiblnd_data.kib_global_lock, flags); @@ -1001,17 +1001,17 @@ static int kiblnd_close_matching_conns(lnet_ni_t *ni, lnet_nid_t nid) int kiblnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg) { struct libcfs_ioctl_data *data = arg; - int rc = -EINVAL; + int rc = -EINVAL; switch (cmd) { case IOC_LIBCFS_GET_PEER: { - lnet_nid_t nid = 0; - int count = 0; + lnet_nid_t nid = 0; + int count = 0; rc = kiblnd_get_peer_info(ni, data->ioc_count, &nid, &count); - data->ioc_nid = nid; - data->ioc_count = count; + data->ioc_nid = nid; + data->ioc_count = count; break; } @@ -1053,11 +1053,11 @@ int kiblnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg) void kiblnd_query(lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when) { - unsigned long last_alive = 0; - unsigned long now = cfs_time_current(); - rwlock_t *glock = &kiblnd_data.kib_global_lock; - kib_peer_t *peer; - unsigned long flags; + unsigned long last_alive = 0; + unsigned long now = cfs_time_current(); + rwlock_t *glock = &kiblnd_data.kib_global_lock; + kib_peer_t *peer; + unsigned long flags; read_lock_irqsave(glock, flags); @@ -1086,8 +1086,8 @@ void kiblnd_query(lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when) void kiblnd_free_pages(kib_pages_t *p) { - int npages = p->ibp_npages; - int i; + int npages = p->ibp_npages; + int i; for (i = 0; i < npages; i++) { if (p->ibp_pages[i] != NULL) @@ -1099,8 +1099,8 @@ void kiblnd_free_pages(kib_pages_t *p) int kiblnd_alloc_pages(kib_pages_t **pp, int cpt, int npages) { - kib_pages_t *p; - int i; + kib_pages_t *p; + int i; LIBCFS_CPT_ALLOC(p, lnet_cpt_table(), cpt, offsetof(kib_pages_t, ibp_pages[npages])); @@ -1130,7 +1130,7 @@ int kiblnd_alloc_pages(kib_pages_t **pp, int cpt, int npages) void kiblnd_unmap_rx_descs(kib_conn_t *conn) { kib_rx_t *rx; - int i; + int i; LASSERT(conn->ibc_rxs != NULL); LASSERT(conn->ibc_hdev != NULL); @@ -1153,14 +1153,13 @@ void kiblnd_unmap_rx_descs(kib_conn_t *conn) void kiblnd_map_rx_descs(kib_conn_t *conn) { - kib_rx_t *rx; - struct page *pg; - int pg_off; - int ipg; - int i; + kib_rx_t *rx; + struct page *pg; + int pg_off; + int ipg; + int i; - for (pg_off = ipg = i = 0; - i < IBLND_RX_MSGS(conn->ibc_version); i++) { + for (pg_off = ipg = i = 0; i < IBLND_RX_MSGS(conn->ibc_version); i++) { pg = conn->ibc_rx_pages->ibp_pages[ipg]; rx = &conn->ibc_rxs[i]; @@ -1192,9 +1191,9 @@ void kiblnd_map_rx_descs(kib_conn_t *conn) static void kiblnd_unmap_tx_pool(kib_tx_pool_t *tpo) { - kib_hca_dev_t *hdev = tpo->tpo_hdev; - kib_tx_t *tx; - int i; + kib_hca_dev_t *hdev = tpo->tpo_hdev; + kib_tx_t *tx; + int i; LASSERT(tpo->tpo_pool.po_allocated == 0); @@ -1216,8 +1215,8 @@ static void kiblnd_unmap_tx_pool(kib_tx_pool_t *tpo) static kib_hca_dev_t *kiblnd_current_hdev(kib_dev_t *dev) { kib_hca_dev_t *hdev; - unsigned long flags; - int i = 0; + unsigned long flags; + int i = 0; read_lock_irqsave(&kiblnd_data.kib_global_lock, flags); while (dev->ibd_failover) { @@ -1240,15 +1239,15 @@ static kib_hca_dev_t *kiblnd_current_hdev(kib_dev_t *dev) static void kiblnd_map_tx_pool(kib_tx_pool_t *tpo) { - kib_pages_t *txpgs = tpo->tpo_tx_pages; - kib_pool_t *pool = &tpo->tpo_pool; - kib_net_t *net = pool->po_owner->ps_net; - kib_dev_t *dev; - struct page *page; - kib_tx_t *tx; - int page_offset; - int ipage; - int i; + kib_pages_t *txpgs = tpo->tpo_tx_pages; + kib_pool_t *pool = &tpo->tpo_pool; + kib_net_t *net = pool->po_owner->ps_net; + kib_dev_t *dev; + struct page *page; + kib_tx_t *tx; + int page_offset; + int ipage; + int i; LASSERT(net != NULL); @@ -1291,7 +1290,7 @@ static void kiblnd_map_tx_pool(kib_tx_pool_t *tpo) struct ib_mr *kiblnd_find_dma_mr(kib_hca_dev_t *hdev, __u64 addr, __u64 size) { - __u64 index; + __u64 index; LASSERT(hdev->ibh_mrs[0] != NULL); @@ -1311,7 +1310,7 @@ struct ib_mr *kiblnd_find_rd_dma_mr(kib_hca_dev_t *hdev, kib_rdma_desc_t *rd) { struct ib_mr *prev_mr; struct ib_mr *mr; - int i; + int i; LASSERT(hdev->ibh_mrs[0] != NULL); @@ -1382,18 +1381,18 @@ static int kiblnd_create_fmr_pool(kib_fmr_poolset_t *fps, kib_fmr_pool_t **pp_fpo) { /* FMR pool for RDMA */ - kib_dev_t *dev = fps->fps_net->ibn_dev; - kib_fmr_pool_t *fpo; + kib_dev_t *dev = fps->fps_net->ibn_dev; + kib_fmr_pool_t *fpo; struct ib_fmr_pool_param param = { .max_pages_per_fmr = LNET_MAX_PAYLOAD/PAGE_SIZE, - .page_shift = PAGE_SHIFT, - .access = (IB_ACCESS_LOCAL_WRITE | - IB_ACCESS_REMOTE_WRITE), - .pool_size = fps->fps_pool_size, + .page_shift = PAGE_SHIFT, + .access = (IB_ACCESS_LOCAL_WRITE | + IB_ACCESS_REMOTE_WRITE), + .pool_size = fps->fps_pool_size, .dirty_watermark = fps->fps_flush_trigger, .flush_function = NULL, - .flush_arg = NULL, - .cache = !!*kiblnd_tunables.kib_fmr_cache}; + .flush_arg = NULL, + .cache = !!*kiblnd_tunables.kib_fmr_cache}; int rc; LIBCFS_CPT_ALLOC(fpo, lnet_cpt_table(), fps->fps_cpt, sizeof(*fpo)); @@ -1454,7 +1453,7 @@ static int kiblnd_init_fmr_poolset(kib_fmr_poolset_t *fps, int cpt, int flush_trigger) { kib_fmr_pool_t *fpo; - int rc; + int rc; memset(fps, 0, sizeof(kib_fmr_poolset_t)); @@ -1485,11 +1484,11 @@ static int kiblnd_fmr_pool_is_idle(kib_fmr_pool_t *fpo, unsigned long now) void kiblnd_fmr_pool_unmap(kib_fmr_t *fmr, int status) { LIST_HEAD(zombies); - kib_fmr_pool_t *fpo = fmr->fmr_pool; + kib_fmr_pool_t *fpo = fmr->fmr_pool; kib_fmr_poolset_t *fps = fpo->fpo_owner; - unsigned long now = cfs_time_current(); - kib_fmr_pool_t *tmp; - int rc; + unsigned long now = cfs_time_current(); + kib_fmr_pool_t *tmp; + int rc; rc = ib_fmr_pool_unmap(fmr->fmr_pfmr); LASSERT(rc == 0); @@ -1525,9 +1524,9 @@ int kiblnd_fmr_pool_map(kib_fmr_poolset_t *fps, __u64 *pages, int npages, __u64 iov, kib_fmr_t *fmr) { struct ib_pool_fmr *pfmr; - kib_fmr_pool_t *fpo; - __u64 version; - int rc; + kib_fmr_pool_t *fpo; + __u64 version; + int rc; again: spin_lock(&fps->fps_lock); @@ -1658,13 +1657,13 @@ static int kiblnd_init_poolset(kib_poolset_t *ps, int cpt, kib_ps_node_init_t nd_init, kib_ps_node_fini_t nd_fini) { - kib_pool_t *pool; - int rc; + kib_pool_t *pool; + int rc; memset(ps, 0, sizeof(kib_poolset_t)); - ps->ps_cpt = cpt; - ps->ps_net = net; + ps->ps_cpt = cpt; + ps->ps_net = net; ps->ps_pool_create = po_create; ps->ps_pool_destroy = po_destroy; ps->ps_node_init = nd_init; @@ -1698,9 +1697,9 @@ static int kiblnd_pool_is_idle(kib_pool_t *pool, unsigned long now) void kiblnd_pool_free_node(kib_pool_t *pool, struct list_head *node) { LIST_HEAD(zombies); - kib_poolset_t *ps = pool->po_owner; - kib_pool_t *tmp; - unsigned long now = cfs_time_current(); + kib_poolset_t *ps = pool->po_owner; + kib_pool_t *tmp; + unsigned long now = cfs_time_current(); spin_lock(&ps->ps_lock); @@ -1727,9 +1726,9 @@ void kiblnd_pool_free_node(kib_pool_t *pool, struct list_head *node) struct list_head *kiblnd_pool_alloc_node(kib_poolset_t *ps) { - struct list_head *node; - kib_pool_t *pool; - int rc; + struct list_head *node; + kib_pool_t *pool; + int rc; again: spin_lock(&ps->ps_lock); @@ -1789,8 +1788,8 @@ struct list_head *kiblnd_pool_alloc_node(kib_poolset_t *ps) void kiblnd_pmr_pool_unmap(kib_phys_mr_t *pmr) { - kib_pmr_pool_t *ppo = pmr->pmr_pool; - struct ib_mr *mr = pmr->pmr_mr; + kib_pmr_pool_t *ppo = pmr->pmr_pool; + struct ib_mr *mr = pmr->pmr_mr; pmr->pmr_mr = NULL; kiblnd_pool_free_node(&ppo->ppo_pool, &pmr->pmr_list); @@ -1802,9 +1801,9 @@ int kiblnd_pmr_pool_map(kib_pmr_poolset_t *pps, kib_hca_dev_t *hdev, kib_rdma_desc_t *rd, __u64 *iova, kib_phys_mr_t **pp_pmr) { kib_phys_mr_t *pmr; - struct list_head *node; - int rc; - int i; + struct list_head *node; + int rc; + int i; node = kiblnd_pool_alloc_node(&pps->pps_poolset); if (node == NULL) { @@ -1846,7 +1845,7 @@ int kiblnd_pmr_pool_map(kib_pmr_poolset_t *pps, kib_hca_dev_t *hdev, static void kiblnd_destroy_pmr_pool(kib_pool_t *pool) { kib_pmr_pool_t *ppo = container_of(pool, kib_pmr_pool_t, ppo_pool); - kib_phys_mr_t *pmr; + kib_phys_mr_t *pmr; kib_phys_mr_t *tmp; LASSERT(pool->po_allocated == 0); @@ -1881,10 +1880,10 @@ static inline int kiblnd_pmr_pool_size(int ncpts) static int kiblnd_create_pmr_pool(kib_poolset_t *ps, int size, kib_pool_t **pp_po) { - struct kib_pmr_pool *ppo; - struct kib_pool *pool; - kib_phys_mr_t *pmr; - int i; + struct kib_pmr_pool *ppo; + struct kib_pool *pool; + kib_phys_mr_t *pmr; + int i; LIBCFS_CPT_ALLOC(ppo, lnet_cpt_table(), ps->ps_cpt, sizeof(kib_pmr_pool_t)); @@ -1923,8 +1922,8 @@ static int kiblnd_create_pmr_pool(kib_poolset_t *ps, int size, static void kiblnd_destroy_tx_pool(kib_pool_t *pool) { - kib_tx_pool_t *tpo = container_of(pool, kib_tx_pool_t, tpo_pool); - int i; + kib_tx_pool_t *tpo = container_of(pool, kib_tx_pool_t, tpo_pool); + int i; LASSERT(pool->po_allocated == 0); @@ -1979,9 +1978,9 @@ static int kiblnd_tx_pool_size(int ncpts) static int kiblnd_create_tx_pool(kib_poolset_t *ps, int size, kib_pool_t **pp_po) { - int i; - int npg; - kib_pool_t *pool; + int i; + int npg; + kib_pool_t *pool; kib_tx_pool_t *tpo; LIBCFS_CPT_ALLOC(tpo, lnet_cpt_table(), ps->ps_cpt, sizeof(*tpo)); @@ -2064,19 +2063,19 @@ static void kiblnd_tx_init(kib_pool_t *pool, struct list_head *node) { kib_tx_poolset_t *tps = container_of(pool->po_owner, kib_tx_poolset_t, tps_poolset); - kib_tx_t *tx = list_entry(node, kib_tx_t, tx_list); + kib_tx_t *tx = list_entry(node, kib_tx_t, tx_list); tx->tx_cookie = tps->tps_next_tx_cookie++; } static void kiblnd_net_fini_pools(kib_net_t *net) { - int i; + int i; cfs_cpt_for_each(i, lnet_cpt_table()) { - kib_tx_poolset_t *tps; - kib_fmr_poolset_t *fps; - kib_pmr_poolset_t *pps; + kib_tx_poolset_t *tps; + kib_fmr_poolset_t *fps; + kib_pmr_poolset_t *pps; if (net->ibn_tx_ps != NULL) { tps = net->ibn_tx_ps[i]; @@ -2112,16 +2111,15 @@ static void kiblnd_net_fini_pools(kib_net_t *net) static int kiblnd_net_init_pools(kib_net_t *net, __u32 *cpts, int ncpts) { - unsigned long flags; - int cpt; - int rc; - int i; + unsigned long flags; + int cpt; + int rc; + int i; read_lock_irqsave(&kiblnd_data.kib_global_lock, flags); if (*kiblnd_tunables.kib_map_on_demand == 0 && net->ibn_dev->ibd_hdev->ibh_nmrs == 1) { - read_unlock_irqrestore(&kiblnd_data.kib_global_lock, - flags); + read_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags); goto create_tx_pool; } @@ -2241,7 +2239,7 @@ static int kiblnd_net_init_pools(kib_net_t *net, __u32 *cpts, int ncpts) static int kiblnd_hdev_get_attr(kib_hca_dev_t *hdev) { struct ib_device_attr *attr; - int rc; + int rc; /* It's safe to assume a HCA can handle a page size * matching that of the native system */ @@ -2284,7 +2282,7 @@ static int kiblnd_hdev_get_attr(kib_hca_dev_t *hdev) static void kiblnd_hdev_cleanup_mrs(kib_hca_dev_t *hdev) { - int i; + int i; if (hdev->ibh_nmrs == 0 || hdev->ibh_mrs == NULL) return; @@ -2317,12 +2315,11 @@ void kiblnd_hdev_destroy(kib_hca_dev_t *hdev) static int kiblnd_hdev_setup_mrs(kib_hca_dev_t *hdev) { struct ib_mr *mr; - int i; - int rc; - __u64 mm_size; - __u64 mr_size; - int acflags = IB_ACCESS_LOCAL_WRITE | - IB_ACCESS_REMOTE_WRITE; + int i; + int rc; + __u64 mm_size; + __u64 mr_size; + int acflags = IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_WRITE; rc = kiblnd_hdev_get_attr(hdev); if (rc != 0) @@ -2371,11 +2368,11 @@ static int kiblnd_hdev_setup_mrs(kib_hca_dev_t *hdev) for (i = 0; i < hdev->ibh_nmrs; i++) { struct ib_phys_buf ipb; - __u64 iova; + __u64 iova; ipb.size = hdev->ibh_mr_size; ipb.addr = i * mr_size; - iova = ipb.addr; + iova = ipb.addr; mr = ib_reg_phys_mr(hdev->ibh_pd, &ipb, 1, acflags, &iova); if (IS_ERR(mr)) { @@ -2406,10 +2403,10 @@ static int kiblnd_dummy_callback(struct rdma_cm_id *cmid, static int kiblnd_dev_need_failover(kib_dev_t *dev) { - struct rdma_cm_id *cmid; - struct sockaddr_in srcaddr; - struct sockaddr_in dstaddr; - int rc; + struct rdma_cm_id *cmid; + struct sockaddr_in srcaddr; + struct sockaddr_in dstaddr; + int rc; if (dev->ibd_hdev == NULL || /* initializing */ dev->ibd_hdev->ibh_cmid == NULL || /* listener is dead */ @@ -2435,7 +2432,7 @@ static int kiblnd_dev_need_failover(kib_dev_t *dev) } memset(&srcaddr, 0, sizeof(srcaddr)); - srcaddr.sin_family = AF_INET; + srcaddr.sin_family = AF_INET; srcaddr.sin_addr.s_addr = (__force u32)htonl(dev->ibd_ifip); memset(&dstaddr, 0, sizeof(dstaddr)); @@ -2464,15 +2461,15 @@ int kiblnd_dev_failover(kib_dev_t *dev) LIST_HEAD(zombie_tpo); LIST_HEAD(zombie_ppo); LIST_HEAD(zombie_fpo); - struct rdma_cm_id *cmid = NULL; - kib_hca_dev_t *hdev = NULL; - kib_hca_dev_t *old; - struct ib_pd *pd; - kib_net_t *net; - struct sockaddr_in addr; - unsigned long flags; - int rc = 0; - int i; + struct rdma_cm_id *cmid = NULL; + kib_hca_dev_t *hdev = NULL; + kib_hca_dev_t *old; + struct ib_pd *pd; + kib_net_t *net; + struct sockaddr_in addr; + unsigned long flags; + int rc = 0; + int i; LASSERT(*kiblnd_tunables.kib_dev_failover > 1 || dev->ibd_can_failover || @@ -2614,11 +2611,11 @@ void kiblnd_destroy_dev(kib_dev_t *dev) static kib_dev_t *kiblnd_create_dev(char *ifname) { struct net_device *netdev; - kib_dev_t *dev; - __u32 netmask; - __u32 ip; - int up; - int rc; + kib_dev_t *dev; + __u32 netmask; + __u32 ip; + int up; + int rc; rc = libcfs_ipif_query(ifname, &up, &ip, &netmask); if (rc != 0) { @@ -2665,8 +2662,8 @@ static kib_dev_t *kiblnd_create_dev(char *ifname) static void kiblnd_base_shutdown(void) { - struct kib_sched_info *sched; - int i; + struct kib_sched_info *sched; + int i; LASSERT(list_empty(&kiblnd_data.kib_devs)); @@ -2732,10 +2729,10 @@ static void kiblnd_base_shutdown(void) void kiblnd_shutdown(lnet_ni_t *ni) { - kib_net_t *net = ni->ni_data; - rwlock_t *g_lock = &kiblnd_data.kib_global_lock; - int i; - unsigned long flags; + kib_net_t *net = ni->ni_data; + rwlock_t *g_lock = &kiblnd_data.kib_global_lock; + int i; + unsigned long flags; LASSERT(kiblnd_data.kib_init == IBLND_INIT_ALL); @@ -2804,9 +2801,9 @@ out: static int kiblnd_base_startup(void) { - struct kib_sched_info *sched; - int rc; - int i; + struct kib_sched_info *sched; + int rc; + int i; LASSERT(kiblnd_data.kib_init == IBLND_INIT_NOTHING); @@ -2821,8 +2818,7 @@ static int kiblnd_base_startup(void) kiblnd_data.kib_peer_hash_size = IBLND_PEER_HASH_SIZE; LIBCFS_ALLOC(kiblnd_data.kib_peers, - sizeof(struct list_head) * - kiblnd_data.kib_peer_hash_size); + sizeof(struct list_head) * kiblnd_data.kib_peer_hash_size); if (kiblnd_data.kib_peers == NULL) goto failed; for (i = 0; i < kiblnd_data.kib_peer_hash_size; i++) @@ -2840,7 +2836,7 @@ static int kiblnd_base_startup(void) goto failed; cfs_percpt_for_each(sched, i, kiblnd_data.kib_scheds) { - int nthrs; + int nthrs; spin_lock_init(&sched->ibs_lock); INIT_LIST_HEAD(&sched->ibs_conns); @@ -2893,9 +2889,9 @@ static int kiblnd_base_startup(void) static int kiblnd_start_schedulers(struct kib_sched_info *sched) { - int rc = 0; - int nthrs; - int i; + int rc = 0; + int nthrs; + int i; if (sched->ibs_nthreads == 0) { if (*kiblnd_tunables.kib_nscheds > 0) { @@ -2913,8 +2909,8 @@ static int kiblnd_start_schedulers(struct kib_sched_info *sched) } for (i = 0; i < nthrs; i++) { - long id; - char name[20]; + long id; + char name[20]; id = KIB_THREAD_ID(sched->ibs_cpt, sched->ibs_nthreads + i); snprintf(name, sizeof(name), "kiblnd_sd_%02ld_%02ld", @@ -2935,9 +2931,9 @@ static int kiblnd_start_schedulers(struct kib_sched_info *sched) static int kiblnd_dev_start_threads(kib_dev_t *dev, int newdev, __u32 *cpts, int ncpts) { - int cpt; - int rc; - int i; + int cpt; + int rc; + int i; for (i = 0; i < ncpts; i++) { struct kib_sched_info *sched; @@ -2960,10 +2956,10 @@ static int kiblnd_dev_start_threads(kib_dev_t *dev, int newdev, __u32 *cpts, static kib_dev_t *kiblnd_dev_search(char *ifname) { - kib_dev_t *alias = NULL; - kib_dev_t *dev; - char *colon; - char *colon2; + kib_dev_t *alias = NULL; + kib_dev_t *dev; + char *colon; + char *colon2; colon = strchr(ifname, ':'); list_for_each_entry(dev, &kiblnd_data.kib_devs, ibd_list) { @@ -2992,13 +2988,13 @@ static kib_dev_t *kiblnd_dev_search(char *ifname) int kiblnd_startup(lnet_ni_t *ni) { - char *ifname; - kib_dev_t *ibdev = NULL; - kib_net_t *net; - struct timeval tv; - unsigned long flags; - int rc; - int newdev; + char *ifname; + kib_dev_t *ibdev = NULL; + kib_net_t *net; + struct timeval tv; + unsigned long flags; + int rc; + int newdev; LASSERT(ni->ni_lnd == &the_o2iblnd); @@ -3091,7 +3087,7 @@ static void __exit kiblnd_module_fini(void) static int __init kiblnd_module_init(void) { - int rc; + int rc; CLASSERT(sizeof(kib_msg_t) <= IBLND_MSG_SIZE); CLASSERT(offsetof(kib_msg_t, diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h index cd664d025f41..7f52c6963427 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h @@ -80,42 +80,47 @@ #define IBLND_N_SCHED_HIGH 4 typedef struct { - int *kib_dev_failover; /* HCA failover */ - unsigned int *kib_service; /* IB service number */ - int *kib_min_reconnect_interval; /* first failed connection retry... */ - int *kib_max_reconnect_interval; /* ...exponentially increasing to this */ - int *kib_cksum; /* checksum kib_msg_t? */ - int *kib_timeout; /* comms timeout (seconds) */ - int *kib_keepalive; /* keepalive timeout (seconds) */ - int *kib_ntx; /* # tx descs */ - int *kib_credits; /* # concurrent sends */ - int *kib_peertxcredits; /* # concurrent sends to 1 peer */ - int *kib_peerrtrcredits; /* # per-peer router buffer credits */ - int *kib_peercredits_hiw; /* # when eagerly to return credits */ - int *kib_peertimeout; /* seconds to consider peer dead */ - char **kib_default_ipif; /* default IPoIB interface */ - int *kib_retry_count; - int *kib_rnr_retry_count; - int *kib_concurrent_sends; /* send work queue sizing */ - int *kib_ib_mtu; /* IB MTU */ - int *kib_map_on_demand; /* map-on-demand if RD has more fragments - * than this value, 0 disable map-on-demand */ - int *kib_pmr_pool_size; /* # physical MR in pool */ - int *kib_fmr_pool_size; /* # FMRs in pool */ - int *kib_fmr_flush_trigger; /* When to trigger FMR flush */ - int *kib_fmr_cache; /* enable FMR pool cache? */ - int *kib_require_priv_port;/* accept only privileged ports */ - int *kib_use_priv_port; /* use privileged port for active connect */ - /* # threads on each CPT */ - int *kib_nscheds; + int *kib_dev_failover; /* HCA failover */ + unsigned int *kib_service; /* IB service number */ + int *kib_min_reconnect_interval; /* first failed connection + * retry... */ + int *kib_max_reconnect_interval; /* ...exponentially increasing + * to this */ + int *kib_cksum; /* checksum kib_msg_t? */ + int *kib_timeout; /* comms timeout (seconds) */ + int *kib_keepalive; /* keepalive timeout (seconds) */ + int *kib_ntx; /* # tx descs */ + int *kib_credits; /* # concurrent sends */ + int *kib_peertxcredits; /* # concurrent sends to 1 peer */ + int *kib_peerrtrcredits; /* # per-peer router buffer + * credits */ + int *kib_peercredits_hiw; /* # when eagerly to return + * credits */ + int *kib_peertimeout; /* seconds to consider peer dead */ + char **kib_default_ipif; /* default IPoIB interface */ + int *kib_retry_count; + int *kib_rnr_retry_count; + int *kib_concurrent_sends; /* send work queue sizing */ + int *kib_ib_mtu; /* IB MTU */ + int *kib_map_on_demand; /* map-on-demand if RD has more + * fragments than this value, 0 + * disable map-on-demand */ + int *kib_pmr_pool_size; /* # physical MR in pool */ + int *kib_fmr_pool_size; /* # FMRs in pool */ + int *kib_fmr_flush_trigger; /* When to trigger FMR flush */ + int *kib_fmr_cache; /* enable FMR pool cache? */ + int *kib_require_priv_port; /* accept only privileged ports */ + int *kib_use_priv_port; /* use privileged port for active + * connect */ + int *kib_nscheds; /* # threads on each CPT */ } kib_tunables_t; extern kib_tunables_t kiblnd_tunables; -#define IBLND_MSG_QUEUE_SIZE_V1 8 /* V1 only : # messages/RDMAs in-flight */ -#define IBLND_CREDIT_HIGHWATER_V1 7 /* V1 only : when eagerly to return credits */ +#define IBLND_MSG_QUEUE_SIZE_V1 8 /* V1 only : # messages/RDMAs in-flight */ +#define IBLND_CREDIT_HIGHWATER_V1 7 /* V1 only : when eagerly to return credits */ -#define IBLND_CREDITS_DEFAULT 8 /* default # of peer credits */ +#define IBLND_CREDITS_DEFAULT 8 /* default # of peer credits */ #define IBLND_CREDITS_MAX ((typeof(((kib_msg_t*) 0)->ibm_credits)) - 1) /* Max # of peer credits */ #define IBLND_MSG_QUEUE_SIZE(v) ((v) == IBLND_MSG_VERSION_1 ? \ @@ -186,34 +191,36 @@ struct kib_hca_dev; #endif typedef struct { - struct list_head ibd_list; /* chain on kib_devs */ - struct list_head ibd_fail_list; /* chain on kib_failed_devs */ - __u32 ibd_ifip; /* IPoIB interface IP */ - /** IPoIB interface name */ - char ibd_ifname[KIB_IFNAME_SIZE]; - int ibd_nnets; /* # nets extant */ + struct list_head ibd_list; /* chain on kib_devs */ + struct list_head ibd_fail_list; /* chain on kib_failed_devs */ + __u32 ibd_ifip; /* IPoIB interface IP */ - unsigned long ibd_next_failover; - int ibd_failed_failover; /* # failover failures */ - unsigned int ibd_failover; /* failover in progress */ - unsigned int ibd_can_failover; /* IPoIB interface is a bonding master */ - struct list_head ibd_nets; - struct kib_hca_dev *ibd_hdev; + /* IPoIB interface name */ + char ibd_ifname[KIB_IFNAME_SIZE]; + int ibd_nnets; /* # nets extant */ + + unsigned long ibd_next_failover; + int ibd_failed_failover; /* # failover failures */ + unsigned int ibd_failover; /* failover in progress */ + unsigned int ibd_can_failover; /* IPoIB interface is a bonding + * master */ + struct list_head ibd_nets; + struct kib_hca_dev *ibd_hdev; } kib_dev_t; typedef struct kib_hca_dev { - struct rdma_cm_id *ibh_cmid; /* listener cmid */ - struct ib_device *ibh_ibdev; /* IB device */ - int ibh_page_shift; /* page shift of current HCA */ - int ibh_page_size; /* page size of current HCA */ - __u64 ibh_page_mask; /* page mask of current HCA */ - int ibh_mr_shift; /* bits shift of max MR size */ - __u64 ibh_mr_size; /* size of MR */ - int ibh_nmrs; /* # of global MRs */ - struct ib_mr **ibh_mrs; /* global MR */ - struct ib_pd *ibh_pd; /* PD */ - kib_dev_t *ibh_dev; /* owner */ - atomic_t ibh_ref; /* refcount */ + struct rdma_cm_id *ibh_cmid; /* listener cmid */ + struct ib_device *ibh_ibdev; /* IB device */ + int ibh_page_shift; /* page shift of current HCA */ + int ibh_page_size; /* page size of current HCA */ + __u64 ibh_page_mask; /* page mask of current HCA */ + int ibh_mr_shift; /* bits shift of max MR size */ + __u64 ibh_mr_size; /* size of MR */ + int ibh_nmrs; /* # of global MRs */ + struct ib_mr **ibh_mrs; /* global MR */ + struct ib_pd *ibh_pd; /* PD */ + kib_dev_t *ibh_dev; /* owner */ + atomic_t ibh_ref; /* refcount */ } kib_hca_dev_t; /** # of seconds to keep pool alive */ @@ -222,19 +229,19 @@ typedef struct kib_hca_dev { #define IBLND_POOL_RETRY 1 typedef struct { - int ibp_npages; /* # pages */ - struct page *ibp_pages[0]; /* page array */ + int ibp_npages; /* # pages */ + struct page *ibp_pages[0]; /* page array */ } kib_pages_t; struct kib_pmr_pool; typedef struct { - struct list_head pmr_list; /* chain node */ - struct ib_phys_buf *pmr_ipb; /* physical buffer */ - struct ib_mr *pmr_mr; /* IB MR */ - struct kib_pmr_pool *pmr_pool; /* owner of this MR */ - __u64 pmr_iova; /* Virtual I/O address */ - int pmr_refcount; /* reference count */ + struct list_head pmr_list; /* chain node */ + struct ib_phys_buf *pmr_ipb; /* physical buffer */ + struct ib_mr *pmr_mr; /* IB MR */ + struct kib_pmr_pool *pmr_pool; /* owner of this MR */ + __u64 pmr_iova; /* Virtual I/O address */ + int pmr_refcount; /* reference count */ } kib_phys_mr_t; struct kib_pool; @@ -251,97 +258,99 @@ struct kib_net; #define IBLND_POOL_NAME_LEN 32 typedef struct kib_poolset { - spinlock_t ps_lock; /* serialize */ - struct kib_net *ps_net; /* network it belongs to */ - char ps_name[IBLND_POOL_NAME_LEN]; /* pool set name */ - struct list_head ps_pool_list; /* list of pools */ - struct list_head ps_failed_pool_list; /* failed pool list */ - unsigned long ps_next_retry; /* time stamp for retry if failed to allocate */ - int ps_increasing; /* is allocating new pool */ - int ps_pool_size; /* new pool size */ - int ps_cpt; /* CPT id */ + spinlock_t ps_lock; /* serialize */ + struct kib_net *ps_net; /* network it belongs to */ + char ps_name[IBLND_POOL_NAME_LEN]; /* pool set name */ + struct list_head ps_pool_list; /* list of pools */ + struct list_head ps_failed_pool_list;/* failed pool list */ + unsigned long ps_next_retry; /* time stamp for retry if + * failed to allocate */ + int ps_increasing; /* is allocating new pool */ + int ps_pool_size; /* new pool size */ + int ps_cpt; /* CPT id */ - kib_ps_pool_create_t ps_pool_create; /* create a new pool */ - kib_ps_pool_destroy_t ps_pool_destroy; /* destroy a pool */ - kib_ps_node_init_t ps_node_init; /* initialize new allocated node */ - kib_ps_node_fini_t ps_node_fini; /* finalize node */ + kib_ps_pool_create_t ps_pool_create; /* create a new pool */ + kib_ps_pool_destroy_t ps_pool_destroy; /* destroy a pool */ + kib_ps_node_init_t ps_node_init; /* initialize new allocated + * node */ + kib_ps_node_fini_t ps_node_fini; /* finalize node */ } kib_poolset_t; typedef struct kib_pool { - struct list_head po_list; /* chain on pool list */ - struct list_head po_free_list; /* pre-allocated node */ - kib_poolset_t *po_owner; /* pool_set of this pool */ - unsigned long po_deadline; /* deadline of this pool */ - int po_allocated; /* # of elements in use */ - int po_failed; /* pool is created on failed HCA */ - int po_size; /* # of pre-allocated elements */ + struct list_head po_list; /* chain on pool list */ + struct list_head po_free_list; /* pre-allocated node */ + kib_poolset_t *po_owner; /* pool_set of this pool */ + unsigned long po_deadline; /* deadline of this pool */ + int po_allocated; /* # of elements in use */ + int po_failed; /* pool is created on failed + * HCA */ + int po_size; /* # of pre-allocated elements */ } kib_pool_t; typedef struct { - kib_poolset_t tps_poolset; /* pool-set */ - __u64 tps_next_tx_cookie; /* cookie of TX */ + kib_poolset_t tps_poolset; /* pool-set */ + __u64 tps_next_tx_cookie; /* cookie of TX */ } kib_tx_poolset_t; typedef struct { - kib_pool_t tpo_pool; /* pool */ - struct kib_hca_dev *tpo_hdev; /* device for this pool */ - struct kib_tx *tpo_tx_descs; /* all the tx descriptors */ - kib_pages_t *tpo_tx_pages; /* premapped tx msg pages */ + kib_pool_t tpo_pool; /* pool */ + struct kib_hca_dev *tpo_hdev; /* device for this pool */ + struct kib_tx *tpo_tx_descs; /* all the tx descriptors */ + kib_pages_t *tpo_tx_pages; /* premapped tx msg pages */ } kib_tx_pool_t; typedef struct { - kib_poolset_t pps_poolset; /* pool-set */ + kib_poolset_t pps_poolset; /* pool-set */ } kib_pmr_poolset_t; typedef struct kib_pmr_pool { - struct kib_hca_dev *ppo_hdev; /* device for this pool */ - kib_pool_t ppo_pool; /* pool */ + struct kib_hca_dev *ppo_hdev; /* device for this pool */ + kib_pool_t ppo_pool; /* pool */ } kib_pmr_pool_t; typedef struct { - spinlock_t fps_lock; /* serialize */ - struct kib_net *fps_net; /* IB network */ - struct list_head fps_pool_list; /* FMR pool list */ - struct list_head fps_failed_pool_list; /* FMR pool list */ - __u64 fps_version; /* validity stamp */ - int fps_cpt; /* CPT id */ - int fps_pool_size; - int fps_flush_trigger; - /* is allocating new pool */ - int fps_increasing; - /* time stamp for retry if failed to allocate */ - unsigned long fps_next_retry; + spinlock_t fps_lock; /* serialize */ + struct kib_net *fps_net; /* IB network */ + struct list_head fps_pool_list; /* FMR pool list */ + struct list_head fps_failed_pool_list;/* FMR pool list */ + __u64 fps_version; /* validity stamp */ + int fps_cpt; /* CPT id */ + int fps_pool_size; + int fps_flush_trigger; + int fps_increasing; /* is allocating new pool */ + unsigned long fps_next_retry; /* time stamp for retry if + * failed to allocate */ } kib_fmr_poolset_t; typedef struct { - struct list_head fpo_list; /* chain on pool list */ - struct kib_hca_dev *fpo_hdev; /* device for this pool */ - kib_fmr_poolset_t *fpo_owner; /* owner of this pool */ - struct ib_fmr_pool *fpo_fmr_pool; /* IB FMR pool */ - unsigned long fpo_deadline; /* deadline of this pool */ - int fpo_failed; /* fmr pool is failed */ - int fpo_map_count; /* # of mapped FMR */ + struct list_head fpo_list; /* chain on pool list */ + struct kib_hca_dev *fpo_hdev; /* device for this pool */ + kib_fmr_poolset_t *fpo_owner; /* owner of this pool */ + struct ib_fmr_pool *fpo_fmr_pool; /* IB FMR pool */ + unsigned long fpo_deadline; /* deadline of this pool */ + int fpo_failed; /* fmr pool is failed */ + int fpo_map_count; /* # of mapped FMR */ } kib_fmr_pool_t; typedef struct { - struct ib_pool_fmr *fmr_pfmr; /* IB pool fmr */ - kib_fmr_pool_t *fmr_pool; /* pool of FMR */ + struct ib_pool_fmr *fmr_pfmr; /* IB pool fmr */ + kib_fmr_pool_t *fmr_pool; /* pool of FMR */ } kib_fmr_t; typedef struct kib_net { - struct list_head ibn_list; /* chain on kib_dev_t::ibd_nets */ - __u64 ibn_incarnation; /* my epoch */ - int ibn_init; /* initialisation state */ - int ibn_shutdown; /* shutting down? */ + struct list_head ibn_list; /* chain on kib_dev_t::ibd_nets */ + __u64 ibn_incarnation;/* my epoch */ + int ibn_init; /* initialisation state */ + int ibn_shutdown; /* shutting down? */ - atomic_t ibn_npeers; /* # peers extant */ - atomic_t ibn_nconns; /* # connections extant */ + atomic_t ibn_npeers; /* # peers extant */ + atomic_t ibn_nconns; /* # connections extant */ - kib_tx_poolset_t **ibn_tx_ps; /* tx pool-set */ - kib_fmr_poolset_t **ibn_fmr_ps; /* fmr pool-set */ - kib_pmr_poolset_t **ibn_pmr_ps; /* pmr pool-set */ + kib_tx_poolset_t **ibn_tx_ps; /* tx pool-set */ + kib_fmr_poolset_t **ibn_fmr_ps; /* fmr pool-set */ + kib_pmr_poolset_t **ibn_pmr_ps; /* pmr pool-set */ - kib_dev_t *ibn_dev; /* underlying IB device */ + kib_dev_t *ibn_dev; /* underlying IB device */ } kib_net_t; #define KIB_THREAD_SHIFT 16 @@ -350,51 +359,45 @@ typedef struct kib_net { #define KIB_THREAD_TID(id) ((id) & ((1UL << KIB_THREAD_SHIFT) - 1)) struct kib_sched_info { - /* serialise */ - spinlock_t ibs_lock; - /* schedulers sleep here */ - wait_queue_head_t ibs_waitq; - /* conns to check for rx completions */ - struct list_head ibs_conns; - /* number of scheduler threads */ - int ibs_nthreads; - /* max allowed scheduler threads */ - int ibs_nthreads_max; - int ibs_cpt; /* CPT id */ + spinlock_t ibs_lock; /* serialise */ + wait_queue_head_t ibs_waitq; /* schedulers sleep here */ + struct list_head ibs_conns; /* conns to check for rx completions */ + int ibs_nthreads; /* number of scheduler threads */ + int ibs_nthreads_max; /* max allowed scheduler threads */ + int ibs_cpt; /* CPT id */ }; typedef struct { - int kib_init; /* initialisation state */ - int kib_shutdown; /* shut down? */ - struct list_head kib_devs; /* IB devices extant */ - /* list head of failed devices */ - struct list_head kib_failed_devs; - /* schedulers sleep here */ - wait_queue_head_t kib_failover_waitq; - atomic_t kib_nthreads; /* # live threads */ - /* stabilize net/dev/peer/conn ops */ - rwlock_t kib_global_lock; - /* hash table of all my known peers */ - struct list_head *kib_peers; - /* size of kib_peers */ - int kib_peer_hash_size; - /* the connd task (serialisation assertions) */ - void *kib_connd; - /* connections to setup/teardown */ - struct list_head kib_connd_conns; - /* connections with zero refcount */ - struct list_head kib_connd_zombies; - /* connection daemon sleeps here */ - wait_queue_head_t kib_connd_waitq; - spinlock_t kib_connd_lock; /* serialise */ - struct ib_qp_attr kib_error_qpa; /* QP->ERROR */ - /* percpt data for schedulers */ - struct kib_sched_info **kib_scheds; + int kib_init; /* initialisation state */ + int kib_shutdown; /* shut down? */ + struct list_head kib_devs; /* IB devices extant */ + struct list_head kib_failed_devs; /* list head of failed + * devices */ + wait_queue_head_t kib_failover_waitq; /* schedulers sleep here */ + atomic_t kib_nthreads; /* # live threads */ + rwlock_t kib_global_lock; /* stabilize net/dev/peer/conn + * ops */ + struct list_head *kib_peers; /* hash table of all my known + * peers */ + int kib_peer_hash_size; /* size of kib_peers */ + void *kib_connd; /* the connd task + * (serialisation assertions) + */ + struct list_head kib_connd_conns; /* connections to + * setup/teardown */ + struct list_head kib_connd_zombies; /* connections with zero + * refcount */ + wait_queue_head_t kib_connd_waitq; /* connection daemon sleeps + * here */ + spinlock_t kib_connd_lock; /* serialise */ + struct ib_qp_attr kib_error_qpa; /* QP->ERROR */ + struct kib_sched_info **kib_scheds; /* percpt data for schedulers + */ } kib_data_t; -#define IBLND_INIT_NOTHING 0 -#define IBLND_INIT_DATA 1 -#define IBLND_INIT_ALL 2 +#define IBLND_INIT_NOTHING 0 +#define IBLND_INIT_DATA 1 +#define IBLND_INIT_ALL 2 /************************************************************************ * IB Wire message format. @@ -402,228 +405,243 @@ typedef struct { */ typedef struct kib_connparams { - __u16 ibcp_queue_depth; - __u16 ibcp_max_frags; - __u32 ibcp_max_msg_size; + __u16 ibcp_queue_depth; + __u16 ibcp_max_frags; + __u32 ibcp_max_msg_size; } WIRE_ATTR kib_connparams_t; typedef struct { - lnet_hdr_t ibim_hdr; /* portals header */ - char ibim_payload[0]; /* piggy-backed payload */ + lnet_hdr_t ibim_hdr; /* portals header */ + char ibim_payload[0]; /* piggy-backed payload */ } WIRE_ATTR kib_immediate_msg_t; typedef struct { - __u32 rf_nob; /* # bytes this frag */ - __u64 rf_addr; /* CAVEAT EMPTOR: misaligned!! */ + __u32 rf_nob; /* # bytes this frag */ + __u64 rf_addr; /* CAVEAT EMPTOR: misaligned!! */ } WIRE_ATTR kib_rdma_frag_t; typedef struct { - __u32 rd_key; /* local/remote key */ - __u32 rd_nfrags; /* # fragments */ - kib_rdma_frag_t rd_frags[0]; /* buffer frags */ + __u32 rd_key; /* local/remote key */ + __u32 rd_nfrags; /* # fragments */ + kib_rdma_frag_t rd_frags[0]; /* buffer frags */ } WIRE_ATTR kib_rdma_desc_t; typedef struct { - lnet_hdr_t ibprm_hdr; /* portals header */ - __u64 ibprm_cookie; /* opaque completion cookie */ + lnet_hdr_t ibprm_hdr; /* portals header */ + __u64 ibprm_cookie; /* opaque completion cookie */ } WIRE_ATTR kib_putreq_msg_t; typedef struct { - __u64 ibpam_src_cookie; /* reflected completion cookie */ - __u64 ibpam_dst_cookie; /* opaque completion cookie */ - kib_rdma_desc_t ibpam_rd; /* sender's sink buffer */ + __u64 ibpam_src_cookie; /* reflected completion cookie */ + __u64 ibpam_dst_cookie; /* opaque completion cookie */ + kib_rdma_desc_t ibpam_rd; /* sender's sink buffer */ } WIRE_ATTR kib_putack_msg_t; typedef struct { - lnet_hdr_t ibgm_hdr; /* portals header */ - __u64 ibgm_cookie; /* opaque completion cookie */ - kib_rdma_desc_t ibgm_rd; /* rdma descriptor */ + lnet_hdr_t ibgm_hdr; /* portals header */ + __u64 ibgm_cookie; /* opaque completion cookie */ + kib_rdma_desc_t ibgm_rd; /* rdma descriptor */ } WIRE_ATTR kib_get_msg_t; typedef struct { - __u64 ibcm_cookie; /* opaque completion cookie */ - __s32 ibcm_status; /* < 0 failure: >= 0 length */ + __u64 ibcm_cookie; /* opaque completion cookie */ + __s32 ibcm_status; /* < 0 failure: >= 0 length */ } WIRE_ATTR kib_completion_msg_t; typedef struct { /* First 2 fields fixed FOR ALL TIME */ - __u32 ibm_magic; /* I'm an ibnal message */ - __u16 ibm_version; /* this is my version number */ + __u32 ibm_magic; /* I'm an ibnal message */ + __u16 ibm_version; /* this is my version number */ - __u8 ibm_type; /* msg type */ - __u8 ibm_credits; /* returned credits */ - __u32 ibm_nob; /* # bytes in whole message */ - __u32 ibm_cksum; /* checksum (0 == no checksum) */ - __u64 ibm_srcnid; /* sender's NID */ - __u64 ibm_srcstamp; /* sender's incarnation */ - __u64 ibm_dstnid; /* destination's NID */ - __u64 ibm_dststamp; /* destination's incarnation */ + __u8 ibm_type; /* msg type */ + __u8 ibm_credits; /* returned credits */ + __u32 ibm_nob; /* # bytes in whole message */ + __u32 ibm_cksum; /* checksum (0 == no checksum) */ + __u64 ibm_srcnid; /* sender's NID */ + __u64 ibm_srcstamp; /* sender's incarnation */ + __u64 ibm_dstnid; /* destination's NID */ + __u64 ibm_dststamp; /* destination's incarnation */ union { - kib_connparams_t connparams; - kib_immediate_msg_t immediate; - kib_putreq_msg_t putreq; - kib_putack_msg_t putack; - kib_get_msg_t get; - kib_completion_msg_t completion; + kib_connparams_t connparams; + kib_immediate_msg_t immediate; + kib_putreq_msg_t putreq; + kib_putack_msg_t putack; + kib_get_msg_t get; + kib_completion_msg_t completion; } WIRE_ATTR ibm_u; } WIRE_ATTR kib_msg_t; -#define IBLND_MSG_MAGIC LNET_PROTO_IB_MAGIC /* unique magic */ +#define IBLND_MSG_MAGIC LNET_PROTO_IB_MAGIC /* unique magic */ -#define IBLND_MSG_VERSION_1 0x11 -#define IBLND_MSG_VERSION_2 0x12 -#define IBLND_MSG_VERSION IBLND_MSG_VERSION_2 +#define IBLND_MSG_VERSION_1 0x11 +#define IBLND_MSG_VERSION_2 0x12 +#define IBLND_MSG_VERSION IBLND_MSG_VERSION_2 -#define IBLND_MSG_CONNREQ 0xc0 /* connection request */ -#define IBLND_MSG_CONNACK 0xc1 /* connection acknowledge */ -#define IBLND_MSG_NOOP 0xd0 /* nothing (just credits) */ -#define IBLND_MSG_IMMEDIATE 0xd1 /* immediate */ -#define IBLND_MSG_PUT_REQ 0xd2 /* putreq (src->sink) */ -#define IBLND_MSG_PUT_NAK 0xd3 /* completion (sink->src) */ -#define IBLND_MSG_PUT_ACK 0xd4 /* putack (sink->src) */ -#define IBLND_MSG_PUT_DONE 0xd5 /* completion (src->sink) */ -#define IBLND_MSG_GET_REQ 0xd6 /* getreq (sink->src) */ -#define IBLND_MSG_GET_DONE 0xd7 /* completion (src->sink: all OK) */ +#define IBLND_MSG_CONNREQ 0xc0 /* connection request */ +#define IBLND_MSG_CONNACK 0xc1 /* connection acknowledge */ +#define IBLND_MSG_NOOP 0xd0 /* nothing (just credits) */ +#define IBLND_MSG_IMMEDIATE 0xd1 /* immediate */ +#define IBLND_MSG_PUT_REQ 0xd2 /* putreq (src->sink) */ +#define IBLND_MSG_PUT_NAK 0xd3 /* completion (sink->src) */ +#define IBLND_MSG_PUT_ACK 0xd4 /* putack (sink->src) */ +#define IBLND_MSG_PUT_DONE 0xd5 /* completion (src->sink) */ +#define IBLND_MSG_GET_REQ 0xd6 /* getreq (sink->src) */ +#define IBLND_MSG_GET_DONE 0xd7 /* completion (src->sink: all OK) */ typedef struct { - __u32 ibr_magic; /* sender's magic */ - __u16 ibr_version; /* sender's version */ - __u8 ibr_why; /* reject reason */ - __u8 ibr_padding; /* padding */ - __u64 ibr_incarnation; /* incarnation of peer */ - kib_connparams_t ibr_cp; /* connection parameters */ + __u32 ibr_magic; /* sender's magic */ + __u16 ibr_version; /* sender's version */ + __u8 ibr_why; /* reject reason */ + __u8 ibr_padding; /* padding */ + __u64 ibr_incarnation; /* incarnation of peer */ + kib_connparams_t ibr_cp; /* connection parameters */ } WIRE_ATTR kib_rej_t; /* connection rejection reasons */ -#define IBLND_REJECT_CONN_RACE 1 /* You lost connection race */ -#define IBLND_REJECT_NO_RESOURCES 2 /* Out of memory/conns etc */ -#define IBLND_REJECT_FATAL 3 /* Anything else */ - -#define IBLND_REJECT_CONN_UNCOMPAT 4 /* incompatible version peer */ -#define IBLND_REJECT_CONN_STALE 5 /* stale peer */ - -#define IBLND_REJECT_RDMA_FRAGS 6 /* Fatal: peer's rdma frags can't match mine */ -#define IBLND_REJECT_MSG_QUEUE_SIZE 7 /* Fatal: peer's msg queue size can't match mine */ +#define IBLND_REJECT_CONN_RACE 1 /* You lost connection race */ +#define IBLND_REJECT_NO_RESOURCES 2 /* Out of memory/conns etc */ +#define IBLND_REJECT_FATAL 3 /* Anything else */ +#define IBLND_REJECT_CONN_UNCOMPAT 4 /* incompatible version peer */ +#define IBLND_REJECT_CONN_STALE 5 /* stale peer */ +#define IBLND_REJECT_RDMA_FRAGS 6 /* Fatal: peer's rdma frags can't match + * mine */ +#define IBLND_REJECT_MSG_QUEUE_SIZE 7 /* Fatal: peer's msg queue size can't + * match mine */ /***********************************************************************/ -typedef struct kib_rx /* receive message */ +typedef struct kib_rx /* receive message */ { - struct list_head rx_list; /* queue for attention */ - struct kib_conn *rx_conn; /* owning conn */ - int rx_nob; /* # bytes received (-1 while posted) */ - enum ib_wc_status rx_status; /* completion status */ - kib_msg_t *rx_msg; /* message buffer (host vaddr) */ - __u64 rx_msgaddr; /* message buffer (I/O addr) */ - DECLARE_PCI_UNMAP_ADDR (rx_msgunmap); /* for dma_unmap_single() */ - struct ib_recv_wr rx_wrq; /* receive work item... */ - struct ib_sge rx_sge; /* ...and its memory */ + struct list_head rx_list; /* queue for attention */ + struct kib_conn *rx_conn; /* owning conn */ + int rx_nob; /* # bytes received (-1 while + * posted) */ + enum ib_wc_status rx_status; /* completion status */ + kib_msg_t *rx_msg; /* message buffer (host vaddr) */ + __u64 rx_msgaddr; /* message buffer (I/O addr) */ + DECLARE_PCI_UNMAP_ADDR (rx_msgunmap); /* for dma_unmap_single() */ + struct ib_recv_wr rx_wrq; /* receive work item... */ + struct ib_sge rx_sge; /* ...and its memory */ } kib_rx_t; -#define IBLND_POSTRX_DONT_POST 0 /* don't post */ -#define IBLND_POSTRX_NO_CREDIT 1 /* post: no credits */ -#define IBLND_POSTRX_PEER_CREDIT 2 /* post: give peer back 1 credit */ -#define IBLND_POSTRX_RSRVD_CREDIT 3 /* post: give myself back 1 reserved credit */ +#define IBLND_POSTRX_DONT_POST 0 /* don't post */ +#define IBLND_POSTRX_NO_CREDIT 1 /* post: no credits */ +#define IBLND_POSTRX_PEER_CREDIT 2 /* post: give peer back 1 credit */ +#define IBLND_POSTRX_RSRVD_CREDIT 3 /* post: give myself back 1 reserved + * credit */ -typedef struct kib_tx /* transmit message */ +typedef struct kib_tx /* transmit message */ { - struct list_head tx_list; /* queue on idle_txs ibc_tx_queue etc. */ - kib_tx_pool_t *tx_pool; /* pool I'm from */ - struct kib_conn *tx_conn; /* owning conn */ - short tx_sending; /* # tx callbacks outstanding */ - short tx_queued; /* queued for sending */ - short tx_waiting; /* waiting for peer */ - int tx_status; /* LNET completion status */ - unsigned long tx_deadline; /* completion deadline */ - __u64 tx_cookie; /* completion cookie */ - lnet_msg_t *tx_lntmsg[2]; /* lnet msgs to finalize on completion */ - kib_msg_t *tx_msg; /* message buffer (host vaddr) */ - __u64 tx_msgaddr; /* message buffer (I/O addr) */ - DECLARE_PCI_UNMAP_ADDR (tx_msgunmap); /* for dma_unmap_single() */ - int tx_nwrq; /* # send work items */ - struct ib_send_wr *tx_wrq; /* send work items... */ - struct ib_sge *tx_sge; /* ...and their memory */ - kib_rdma_desc_t *tx_rd; /* rdma descriptor */ - int tx_nfrags; /* # entries in... */ - struct scatterlist *tx_frags; /* dma_map_sg descriptor */ - __u64 *tx_pages; /* rdma phys page addrs */ + struct list_head tx_list; /* queue on idle_txs ibc_tx_queue + * etc. */ + kib_tx_pool_t *tx_pool; /* pool I'm from */ + struct kib_conn *tx_conn; /* owning conn */ + short tx_sending; /* # tx callbacks outstanding */ + short tx_queued; /* queued for sending */ + short tx_waiting; /* waiting for peer */ + int tx_status; /* LNET completion status */ + unsigned long tx_deadline; /* completion deadline */ + __u64 tx_cookie; /* completion cookie */ + lnet_msg_t *tx_lntmsg[2]; /* lnet msgs to finalize on + * completion */ + kib_msg_t *tx_msg; /* message buffer (host vaddr) */ + __u64 tx_msgaddr; /* message buffer (I/O addr) */ + DECLARE_PCI_UNMAP_ADDR (tx_msgunmap); /* for dma_unmap_single() */ + int tx_nwrq; /* # send work items */ + struct ib_send_wr *tx_wrq; /* send work items... */ + struct ib_sge *tx_sge; /* ...and their memory */ + kib_rdma_desc_t *tx_rd; /* rdma descriptor */ + int tx_nfrags; /* # entries in... */ + struct scatterlist *tx_frags; /* dma_map_sg descriptor */ + __u64 *tx_pages; /* rdma phys page addrs */ union { - kib_phys_mr_t *pmr; /* MR for physical buffer */ - kib_fmr_t fmr; /* FMR */ - } tx_u; - int tx_dmadir; /* dma direction */ + kib_phys_mr_t *pmr; /* MR for physical buffer */ + kib_fmr_t fmr; /* FMR */ + } tx_u; + int tx_dmadir; /* dma direction */ } kib_tx_t; typedef struct kib_connvars { - /* connection-in-progress variables */ - kib_msg_t cv_msg; + kib_msg_t cv_msg; /* connection-in-progress variables */ } kib_connvars_t; typedef struct kib_conn { - struct kib_sched_info *ibc_sched; /* scheduler information */ - struct kib_peer *ibc_peer; /* owning peer */ - kib_hca_dev_t *ibc_hdev; /* HCA bound on */ - struct list_head ibc_list; /* stash on peer's conn list */ - struct list_head ibc_sched_list; /* schedule for attention */ - __u16 ibc_version; /* version of connection */ - __u64 ibc_incarnation; /* which instance of the peer */ - atomic_t ibc_refcount; /* # users */ - int ibc_state; /* what's happening */ - int ibc_nsends_posted; /* # uncompleted sends */ - int ibc_noops_posted; /* # uncompleted NOOPs */ - int ibc_credits; /* # credits I have */ - int ibc_outstanding_credits; /* # credits to return */ - int ibc_reserved_credits;/* # ACK/DONE msg credits */ - int ibc_comms_error; /* set on comms error */ - unsigned int ibc_nrx:16; /* receive buffers owned */ - unsigned int ibc_scheduled:1; /* scheduled for attention */ - unsigned int ibc_ready:1; /* CQ callback fired */ - /* time of last send */ - unsigned long ibc_last_send; - /** link chain for kiblnd_check_conns only */ - struct list_head ibc_connd_list; - /** rxs completed before ESTABLISHED */ - struct list_head ibc_early_rxs; - /** IBLND_MSG_NOOPs for IBLND_MSG_VERSION_1 */ - struct list_head ibc_tx_noops; - struct list_head ibc_tx_queue; /* sends that need a credit */ - struct list_head ibc_tx_queue_nocred;/* sends that don't need a credit */ - struct list_head ibc_tx_queue_rsrvd; /* sends that need to reserve an ACK/DONE msg */ - struct list_head ibc_active_txs; /* active tx awaiting completion */ - spinlock_t ibc_lock; /* serialise */ - kib_rx_t *ibc_rxs; /* the rx descs */ - kib_pages_t *ibc_rx_pages; /* premapped rx msg pages */ + struct kib_sched_info *ibc_sched; /* scheduler information */ + struct kib_peer *ibc_peer; /* owning peer */ + kib_hca_dev_t *ibc_hdev; /* HCA bound on */ + struct list_head ibc_list; /* stash on peer's conn + * list */ + struct list_head ibc_sched_list; /* schedule for attention */ + __u16 ibc_version; /* version of connection */ + __u64 ibc_incarnation; /* which instance of the + * peer */ + atomic_t ibc_refcount; /* # users */ + int ibc_state; /* what's happening */ + int ibc_nsends_posted; /* # uncompleted sends */ + int ibc_noops_posted; /* # uncompleted NOOPs */ + int ibc_credits; /* # credits I have */ + int ibc_outstanding_credits; /* # credits to return */ + int ibc_reserved_credits; /* # ACK/DONE msg credits */ + int ibc_comms_error; /* set on comms error */ + unsigned int ibc_nrx:16; /* receive buffers owned */ + unsigned int ibc_scheduled:1; /* scheduled for attention + */ + unsigned int ibc_ready:1; /* CQ callback fired */ + unsigned long ibc_last_send; /* time of last send */ + struct list_head ibc_connd_list; /* link chain for + * kiblnd_check_conns only + */ + struct list_head ibc_early_rxs; /* rxs completed before + * ESTABLISHED */ + struct list_head ibc_tx_noops; /* IBLND_MSG_NOOPs for + * IBLND_MSG_VERSION_1 */ + struct list_head ibc_tx_queue; /* sends that need a credit + */ + struct list_head ibc_tx_queue_nocred; /* sends that don't need a + * credit */ + struct list_head ibc_tx_queue_rsrvd; /* sends that need to + * reserve an ACK/DONE msg + */ + struct list_head ibc_active_txs; /* active tx awaiting + * completion */ + spinlock_t ibc_lock; /* serialise */ + kib_rx_t *ibc_rxs; /* the rx descs */ + kib_pages_t *ibc_rx_pages; /* premapped rx msg pages */ - struct rdma_cm_id *ibc_cmid; /* CM id */ - struct ib_cq *ibc_cq; /* completion queue */ + struct rdma_cm_id *ibc_cmid; /* CM id */ + struct ib_cq *ibc_cq; /* completion queue */ - kib_connvars_t *ibc_connvars; /* in-progress connection state */ + kib_connvars_t *ibc_connvars; /* in-progress connection + * state */ } kib_conn_t; -#define IBLND_CONN_INIT 0 /* being initialised */ -#define IBLND_CONN_ACTIVE_CONNECT 1 /* active sending req */ -#define IBLND_CONN_PASSIVE_WAIT 2 /* passive waiting for rtu */ -#define IBLND_CONN_ESTABLISHED 3 /* connection established */ -#define IBLND_CONN_CLOSING 4 /* being closed */ -#define IBLND_CONN_DISCONNECTED 5 /* disconnected */ +#define IBLND_CONN_INIT 0 /* being initialised */ +#define IBLND_CONN_ACTIVE_CONNECT 1 /* active sending req */ +#define IBLND_CONN_PASSIVE_WAIT 2 /* passive waiting for rtu */ +#define IBLND_CONN_ESTABLISHED 3 /* connection established */ +#define IBLND_CONN_CLOSING 4 /* being closed */ +#define IBLND_CONN_DISCONNECTED 5 /* disconnected */ typedef struct kib_peer { - struct list_head ibp_list; /* stash on global peer list */ - lnet_nid_t ibp_nid; /* who's on the other end(s) */ - lnet_ni_t *ibp_ni; /* LNet interface */ - atomic_t ibp_refcount; /* # users */ - struct list_head ibp_conns; /* all active connections */ - struct list_head ibp_tx_queue; /* msgs waiting for a conn */ - __u16 ibp_version; /* version of peer */ - __u64 ibp_incarnation; /* incarnation of peer */ - int ibp_connecting; /* current active connection attempts */ - int ibp_accepting; /* current passive connection attempts */ - int ibp_error; /* errno on closing this peer */ - unsigned long ibp_last_alive; /* when (in jiffies) I was last alive */ + struct list_head ibp_list; /* stash on global peer list */ + lnet_nid_t ibp_nid; /* who's on the other end(s) */ + lnet_ni_t *ibp_ni; /* LNet interface */ + atomic_t ibp_refcount; /* # users */ + struct list_head ibp_conns; /* all active connections */ + struct list_head ibp_tx_queue; /* msgs waiting for a conn */ + __u16 ibp_version; /* version of peer */ + __u64 ibp_incarnation; /* incarnation of peer */ + int ibp_connecting; /* current active connection attempts + */ + int ibp_accepting; /* current passive connection attempts + */ + int ibp_error; /* errno on closing this peer */ + unsigned long ibp_last_alive; /* when (in jiffies) I was last alive + */ } kib_peer_t; -extern kib_data_t kiblnd_data; +extern kib_data_t kiblnd_data; extern void kiblnd_hdev_destroy(kib_hca_dev_t *hdev); @@ -941,8 +959,8 @@ static inline unsigned int kiblnd_sg_dma_len(struct ib_device *dev, * right because OFED1.2 defines it as const, to use it we have to add * (void *) cast to overcome "const" */ -#define KIBLND_CONN_PARAM(e) ((e)->param.conn.private_data) -#define KIBLND_CONN_PARAM_LEN(e) ((e)->param.conn.private_data_len) +#define KIBLND_CONN_PARAM(e) ((e)->param.conn.private_data) +#define KIBLND_CONN_PARAM_LEN(e) ((e)->param.conn.private_data_len) struct ib_mr *kiblnd_find_rd_dma_mr(kib_hca_dev_t *hdev, diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index dbf3749831f9..477aa8b76f32 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -44,9 +44,9 @@ static void kiblnd_tx_done(lnet_ni_t *ni, kib_tx_t *tx) { lnet_msg_t *lntmsg[2]; - kib_net_t *net = ni->ni_data; - int rc; - int i; + kib_net_t *net = ni->ni_data; + int rc; + int i; LASSERT(net != NULL); LASSERT(!in_interrupt()); @@ -102,10 +102,10 @@ kiblnd_txlist_done(lnet_ni_t *ni, struct list_head *txlist, int status) 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; - struct list_head *node; - kib_tx_t *tx; - kib_tx_poolset_t *tps; + kib_net_t *net = (kib_net_t *)ni->ni_data; + struct list_head *node; + kib_tx_t *tx; + kib_tx_poolset_t *tps; tps = net->ibn_tx_ps[lnet_cpt_of_nid(target)]; node = kiblnd_pool_alloc_node(&tps->tps_poolset); @@ -130,9 +130,9 @@ kiblnd_get_idle_tx(lnet_ni_t *ni, lnet_nid_t target) static void kiblnd_drop_rx(kib_rx_t *rx) { - kib_conn_t *conn = rx->rx_conn; - struct kib_sched_info *sched = conn->ibc_sched; - unsigned long flags; + kib_conn_t *conn = rx->rx_conn; + struct kib_sched_info *sched = conn->ibc_sched; + unsigned long flags; spin_lock_irqsave(&sched->ibs_lock, flags); LASSERT(conn->ibc_nrx > 0); @@ -145,11 +145,11 @@ kiblnd_drop_rx(kib_rx_t *rx) int kiblnd_post_rx(kib_rx_t *rx, int credit) { - kib_conn_t *conn = rx->rx_conn; - kib_net_t *net = conn->ibc_peer->ibp_ni->ni_data; - struct ib_recv_wr *bad_wrq = NULL; - struct ib_mr *mr; - int rc; + kib_conn_t *conn = rx->rx_conn; + kib_net_t *net = conn->ibc_peer->ibp_ni->ni_data; + struct ib_recv_wr *bad_wrq = NULL; + struct ib_mr *mr; + int rc; LASSERT(net != NULL); LASSERT(!in_interrupt()); @@ -164,10 +164,10 @@ kiblnd_post_rx(kib_rx_t *rx, int credit) rx->rx_sge.addr = rx->rx_msgaddr; rx->rx_sge.length = IBLND_MSG_SIZE; - rx->rx_wrq.next = NULL; + rx->rx_wrq.next = NULL; rx->rx_wrq.sg_list = &rx->rx_sge; rx->rx_wrq.num_sge = 1; - rx->rx_wrq.wr_id = kiblnd_ptr2wreqid(rx, IBLND_WID_RX); + rx->rx_wrq.wr_id = kiblnd_ptr2wreqid(rx, IBLND_WID_RX); LASSERT(conn->ibc_state >= IBLND_CONN_INIT); LASSERT(rx->rx_nob >= 0); /* not posted */ @@ -212,7 +212,7 @@ kiblnd_post_rx(kib_rx_t *rx, int credit) static kib_tx_t * kiblnd_find_waiting_tx_locked(kib_conn_t *conn, int txtype, __u64 cookie) { - struct list_head *tmp; + struct list_head *tmp; list_for_each(tmp, &conn->ibc_active_txs) { kib_tx_t *tx = list_entry(tmp, kib_tx_t, tx_list); @@ -237,9 +237,9 @@ kiblnd_find_waiting_tx_locked(kib_conn_t *conn, int txtype, __u64 cookie) static void kiblnd_handle_completion(kib_conn_t *conn, int txtype, int status, __u64 cookie) { - kib_tx_t *tx; - lnet_ni_t *ni = conn->ibc_peer->ibp_ni; - int idle; + kib_tx_t *tx; + lnet_ni_t *ni = conn->ibc_peer->ibp_ni; + int idle; spin_lock(&conn->ibc_lock); @@ -276,8 +276,8 @@ kiblnd_handle_completion(kib_conn_t *conn, int txtype, int status, __u64 cookie) static void kiblnd_send_completion(kib_conn_t *conn, int type, int status, __u64 cookie) { - lnet_ni_t *ni = conn->ibc_peer->ibp_ni; - kib_tx_t *tx = kiblnd_get_idle_tx(ni, conn->ibc_peer->ibp_nid); + lnet_ni_t *ni = conn->ibc_peer->ibp_ni; + kib_tx_t *tx = kiblnd_get_idle_tx(ni, conn->ibc_peer->ibp_nid); if (tx == NULL) { CERROR("Can't get tx for completion %x for %s\n", @@ -295,14 +295,14 @@ kiblnd_send_completion(kib_conn_t *conn, int type, int status, __u64 cookie) static void kiblnd_handle_rx(kib_rx_t *rx) { - kib_msg_t *msg = rx->rx_msg; - kib_conn_t *conn = rx->rx_conn; - lnet_ni_t *ni = conn->ibc_peer->ibp_ni; - int credits = msg->ibm_credits; - kib_tx_t *tx; - int rc = 0; - int rc2; - int post_credit; + kib_msg_t *msg = rx->rx_msg; + kib_conn_t *conn = rx->rx_conn; + lnet_ni_t *ni = conn->ibc_peer->ibp_ni; + int credits = msg->ibm_credits; + kib_tx_t *tx; + int rc = 0; + int rc2; + int post_credit; LASSERT(conn->ibc_state >= IBLND_CONN_ESTABLISHED); @@ -456,12 +456,12 @@ kiblnd_handle_rx(kib_rx_t *rx) static void kiblnd_rx_complete(kib_rx_t *rx, int status, int nob) { - kib_msg_t *msg = rx->rx_msg; - kib_conn_t *conn = rx->rx_conn; - lnet_ni_t *ni = conn->ibc_peer->ibp_ni; - kib_net_t *net = ni->ni_data; - int rc; - int err = -EIO; + kib_msg_t *msg = rx->rx_msg; + kib_conn_t *conn = rx->rx_conn; + lnet_ni_t *ni = conn->ibc_peer->ibp_ni; + kib_net_t *net = ni->ni_data; + int rc; + int err = -EIO; LASSERT(net != NULL); LASSERT(rx->rx_nob < 0); /* was posted */ @@ -502,8 +502,8 @@ kiblnd_rx_complete(kib_rx_t *rx, int status, int nob) /* racing with connection establishment/teardown! */ if (conn->ibc_state < IBLND_CONN_ESTABLISHED) { - rwlock_t *g_lock = &kiblnd_data.kib_global_lock; - unsigned long flags; + rwlock_t *g_lock = &kiblnd_data.kib_global_lock; + unsigned long flags; write_lock_irqsave(g_lock, flags); /* must check holding global lock to eliminate race */ @@ -550,19 +550,19 @@ kiblnd_kvaddr_to_page(unsigned long vaddr) static int kiblnd_fmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, int nob) { - kib_hca_dev_t *hdev; - __u64 *pages = tx->tx_pages; - kib_fmr_poolset_t *fps; - int npages; - int size; - int cpt; - int rc; - int i; + kib_hca_dev_t *hdev; + __u64 *pages = tx->tx_pages; + kib_fmr_poolset_t *fps; + int npages; + int size; + int cpt; + int rc; + int i; LASSERT(tx->tx_pool != NULL); LASSERT(tx->tx_pool->tpo_pool.po_owner != NULL); - hdev = tx->tx_pool->tpo_hdev; + hdev = tx->tx_pool->tpo_hdev; for (i = 0, npages = 0; i < rd->rd_nfrags; i++) { for (size = 0; size < rd->rd_frags[i].rf_nob; @@ -586,7 +586,7 @@ kiblnd_fmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, int nob) rd->rd_key = (rd != tx->tx_rd) ? tx->tx_u.fmr.fmr_pfmr->fmr->rkey : tx->tx_u.fmr.fmr_pfmr->fmr->lkey; rd->rd_frags[0].rf_addr &= ~hdev->ibh_page_mask; - rd->rd_frags[0].rf_nob = nob; + rd->rd_frags[0].rf_nob = nob; rd->rd_nfrags = 1; return 0; @@ -595,11 +595,11 @@ kiblnd_fmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, int nob) static int kiblnd_pmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, int nob) { - kib_hca_dev_t *hdev; - kib_pmr_poolset_t *pps; - __u64 iova; - int cpt; - int rc; + kib_hca_dev_t *hdev; + kib_pmr_poolset_t *pps; + __u64 iova; + int cpt; + int rc; LASSERT(tx->tx_pool != NULL); LASSERT(tx->tx_pool->tpo_pool.po_owner != NULL); @@ -623,7 +623,7 @@ kiblnd_pmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, int nob) tx->tx_u.pmr->pmr_mr->lkey; rd->rd_nfrags = 1; rd->rd_frags[0].rf_addr = iova; - rd->rd_frags[0].rf_nob = nob; + rd->rd_frags[0].rf_nob = nob; return 0; } @@ -631,7 +631,7 @@ kiblnd_pmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, int nob) void kiblnd_unmap_tx(lnet_ni_t *ni, kib_tx_t *tx) { - kib_net_t *net = ni->ni_data; + kib_net_t *net = ni->ni_data; LASSERT(net != NULL); @@ -655,20 +655,19 @@ int kiblnd_map_tx(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd, int nfrags) { - kib_hca_dev_t *hdev = tx->tx_pool->tpo_hdev; - kib_net_t *net = ni->ni_data; - struct ib_mr *mr = NULL; - __u32 nob; - int i; + kib_hca_dev_t *hdev = tx->tx_pool->tpo_hdev; + kib_net_t *net = ni->ni_data; + struct ib_mr *mr = NULL; + __u32 nob; + int i; /* If rd is not tx_rd, it's going to get sent to a peer and I'm the * RDMA sink */ tx->tx_dmadir = (rd != tx->tx_rd) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; tx->tx_nfrags = nfrags; - rd->rd_nfrags = - kiblnd_dma_map_sg(hdev->ibh_ibdev, - tx->tx_frags, tx->tx_nfrags, tx->tx_dmadir); + rd->rd_nfrags = kiblnd_dma_map_sg(hdev->ibh_ibdev, tx->tx_frags, + tx->tx_nfrags, tx->tx_dmadir); for (i = 0, nob = 0; i < rd->rd_nfrags; i++) { rd->rd_frags[i].rf_nob = kiblnd_sg_dma_len( @@ -699,12 +698,12 @@ static int kiblnd_setup_rd_iov(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd, unsigned int niov, struct kvec *iov, int offset, int nob) { - kib_net_t *net = ni->ni_data; - struct page *page; + kib_net_t *net = ni->ni_data; + struct page *page; struct scatterlist *sg; - unsigned long vaddr; - int fragnob; - int page_offset; + unsigned long vaddr; + int fragnob; + int page_offset; LASSERT(nob > 0); LASSERT(niov > 0); @@ -752,9 +751,9 @@ 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) { - kib_net_t *net = ni->ni_data; + kib_net_t *net = ni->ni_data; struct scatterlist *sg; - int fragnob; + int fragnob; CDEBUG(D_NET, "niov %d offset %d nob %d\n", nkiov, offset, nob); @@ -793,11 +792,11 @@ 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; - int ver = conn->ibc_version; - int rc; - int done; + kib_msg_t *msg = tx->tx_msg; + kib_peer_t *peer = conn->ibc_peer; + int ver = conn->ibc_version; + int rc; + int done; struct ib_send_wr *bad_wrq; LASSERT(tx->tx_queued); @@ -878,8 +877,7 @@ kiblnd_post_tx_locked(kib_conn_t *conn, kib_tx_t *tx, int credit) /* close_conn will launch failover */ rc = -ENETDOWN; } else { - rc = ib_post_send(conn->ibc_cmid->qp, - tx->tx_wrq, &bad_wrq); + rc = ib_post_send(conn->ibc_cmid->qp, tx->tx_wrq, &bad_wrq); } conn->ibc_last_send = jiffies; @@ -925,9 +923,9 @@ kiblnd_post_tx_locked(kib_conn_t *conn, kib_tx_t *tx, int credit) void kiblnd_check_sends(kib_conn_t *conn) { - int ver = conn->ibc_version; + int ver = conn->ibc_version; lnet_ni_t *ni = conn->ibc_peer->ibp_ni; - kib_tx_t *tx; + kib_tx_t *tx; /* Don't send anything until after the connection is established */ if (conn->ibc_state < IBLND_CONN_ESTABLISHED) { @@ -997,9 +995,9 @@ kiblnd_check_sends(kib_conn_t *conn) static void kiblnd_tx_complete(kib_tx_t *tx, int status) { - int failed = (status != IB_WC_SUCCESS); - kib_conn_t *conn = tx->tx_conn; - int idle; + int failed = (status != IB_WC_SUCCESS); + kib_conn_t *conn = tx->tx_conn; + int idle; LASSERT(tx->tx_sending > 0); @@ -1051,11 +1049,11 @@ kiblnd_tx_complete(kib_tx_t *tx, int status) void kiblnd_init_tx_msg(lnet_ni_t *ni, kib_tx_t *tx, int type, int body_nob) { - kib_hca_dev_t *hdev = tx->tx_pool->tpo_hdev; - struct ib_sge *sge = &tx->tx_sge[tx->tx_nwrq]; + kib_hca_dev_t *hdev = tx->tx_pool->tpo_hdev; + struct ib_sge *sge = &tx->tx_sge[tx->tx_nwrq]; struct ib_send_wr *wrq = &tx->tx_wrq[tx->tx_nwrq]; - int nob = offsetof(kib_msg_t, ibm_u) + body_nob; - struct ib_mr *mr; + int nob = offsetof(kib_msg_t, ibm_u) + body_nob; + struct ib_mr *mr; LASSERT(tx->tx_nwrq >= 0); LASSERT(tx->tx_nwrq < IBLND_MAX_RDMA_FRAGS + 1); @@ -1086,14 +1084,14 @@ int kiblnd_init_rdma(kib_conn_t *conn, kib_tx_t *tx, int type, int resid, kib_rdma_desc_t *dstrd, __u64 dstcookie) { - kib_msg_t *ibmsg = tx->tx_msg; - kib_rdma_desc_t *srcrd = tx->tx_rd; - struct ib_sge *sge = &tx->tx_sge[0]; + kib_msg_t *ibmsg = tx->tx_msg; + kib_rdma_desc_t *srcrd = tx->tx_rd; + struct ib_sge *sge = &tx->tx_sge[0]; struct ib_send_wr *wrq = &tx->tx_wrq[0]; - int rc = resid; - int srcidx; - int dstidx; - int wrknob; + int rc = resid; + int srcidx; + int dstidx; + int wrknob; LASSERT(!in_interrupt()); LASSERT(tx->tx_nwrq == 0); @@ -1144,7 +1142,7 @@ kiblnd_init_rdma(kib_conn_t *conn, kib_tx_t *tx, int type, wrq->send_flags = 0; wrq->wr.rdma.remote_addr = kiblnd_rd_frag_addr(dstrd, dstidx); - wrq->wr.rdma.rkey = kiblnd_rd_frag_key(dstrd, dstidx); + wrq->wr.rdma.rkey = kiblnd_rd_frag_key(dstrd, dstidx); srcidx = kiblnd_rd_consume_frag(srcrd, srcidx, wrknob); dstidx = kiblnd_rd_consume_frag(dstrd, dstidx, wrknob); @@ -1170,7 +1168,7 @@ kiblnd_init_rdma(kib_conn_t *conn, kib_tx_t *tx, int type, void kiblnd_queue_tx_locked(kib_tx_t *tx, kib_conn_t *conn) { - struct list_head *q; + struct list_head *q; LASSERT(tx->tx_nwrq > 0); /* work items set up */ LASSERT(!tx->tx_queued); /* not queued for sending already */ @@ -1271,11 +1269,11 @@ static void kiblnd_connect_peer(kib_peer_t *peer) { struct rdma_cm_id *cmid; - kib_dev_t *dev; - kib_net_t *net = peer->ibp_ni->ni_data; + kib_dev_t *dev; + kib_net_t *net = peer->ibp_ni->ni_data; struct sockaddr_in srcaddr; struct sockaddr_in dstaddr; - int rc; + int rc; LASSERT(net != NULL); LASSERT(peer->ibp_connecting > 0); @@ -1335,12 +1333,12 @@ kiblnd_connect_peer(kib_peer_t *peer) void kiblnd_launch_tx(lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid) { - kib_peer_t *peer; - kib_peer_t *peer2; - kib_conn_t *conn; - rwlock_t *g_lock = &kiblnd_data.kib_global_lock; - unsigned long flags; - int rc; + kib_peer_t *peer; + kib_peer_t *peer2; + kib_conn_t *conn; + rwlock_t *g_lock = &kiblnd_data.kib_global_lock; + unsigned long flags; + int rc; /* If I get here, I've committed to send, so I complete the tx with * failure on any problems */ @@ -1456,20 +1454,20 @@ kiblnd_launch_tx(lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid) int kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) { - lnet_hdr_t *hdr = &lntmsg->msg_hdr; - int type = lntmsg->msg_type; + lnet_hdr_t *hdr = &lntmsg->msg_hdr; + int type = lntmsg->msg_type; lnet_process_id_t target = lntmsg->msg_target; - int target_is_router = lntmsg->msg_target_is_router; - int routing = lntmsg->msg_routing; - unsigned int payload_niov = lntmsg->msg_niov; - struct kvec *payload_iov = lntmsg->msg_iov; - lnet_kiov_t *payload_kiov = lntmsg->msg_kiov; - unsigned int payload_offset = lntmsg->msg_offset; - unsigned int payload_nob = lntmsg->msg_len; - kib_msg_t *ibmsg; - kib_tx_t *tx; - int nob; - int rc; + int target_is_router = lntmsg->msg_target_is_router; + int routing = lntmsg->msg_routing; + unsigned int payload_niov = lntmsg->msg_niov; + struct kvec *payload_iov = lntmsg->msg_iov; + lnet_kiov_t *payload_kiov = lntmsg->msg_kiov; + unsigned int payload_offset = lntmsg->msg_offset; + unsigned int payload_nob = lntmsg->msg_len; + kib_msg_t *ibmsg; + kib_tx_t *tx; + int nob; + int rc; /* NB 'private' is different depending on what we're sending.... */ @@ -1628,13 +1626,13 @@ static void kiblnd_reply(lnet_ni_t *ni, kib_rx_t *rx, lnet_msg_t *lntmsg) { lnet_process_id_t target = lntmsg->msg_target; - unsigned int niov = lntmsg->msg_niov; - struct kvec *iov = lntmsg->msg_iov; - lnet_kiov_t *kiov = lntmsg->msg_kiov; - unsigned int offset = lntmsg->msg_offset; - unsigned int nob = lntmsg->msg_len; - kib_tx_t *tx; - int rc; + unsigned int niov = lntmsg->msg_niov; + struct kvec *iov = lntmsg->msg_iov; + lnet_kiov_t *kiov = lntmsg->msg_kiov; + unsigned int offset = lntmsg->msg_offset; + unsigned int nob = lntmsg->msg_len; + kib_tx_t *tx; + int rc; tx = kiblnd_get_idle_tx(ni, rx->rx_conn->ibc_peer->ibp_nid); if (tx == NULL) { @@ -1691,14 +1689,14 @@ kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed, unsigned int niov, struct kvec *iov, lnet_kiov_t *kiov, unsigned int offset, unsigned int mlen, unsigned int rlen) { - kib_rx_t *rx = private; - kib_msg_t *rxmsg = rx->rx_msg; - kib_conn_t *conn = rx->rx_conn; - kib_tx_t *tx; - kib_msg_t *txmsg; - int nob; - int post_credit = IBLND_POSTRX_PEER_CREDIT; - int rc = 0; + kib_rx_t *rx = private; + kib_msg_t *rxmsg = rx->rx_msg; + kib_conn_t *conn = rx->rx_conn; + kib_tx_t *tx; + kib_msg_t *txmsg; + int nob; + int post_credit = IBLND_POSTRX_PEER_CREDIT; + int rc = 0; LASSERT(mlen <= rlen); LASSERT(!in_interrupt()); @@ -1828,8 +1826,8 @@ kiblnd_peer_alive(kib_peer_t *peer) static void kiblnd_peer_notify(kib_peer_t *peer) { - int error = 0; - unsigned long last_alive = 0; + int error = 0; + unsigned long last_alive = 0; unsigned long flags; read_lock_irqsave(&kiblnd_data.kib_global_lock, flags); @@ -1860,9 +1858,9 @@ kiblnd_close_conn_locked(kib_conn_t *conn, int error) * connection to be finished off by the connd. Otherwise the connd is * already dealing with it (either to set it up or tear it down). * Caller holds kib_global_lock exclusively in irq context */ - kib_peer_t *peer = conn->ibc_peer; - kib_dev_t *dev; - unsigned long flags; + kib_peer_t *peer = conn->ibc_peer; + kib_dev_t *dev; + unsigned long flags; LASSERT(error != 0 || conn->ibc_state >= IBLND_CONN_ESTABLISHED); @@ -1934,8 +1932,8 @@ kiblnd_close_conn(kib_conn_t *conn, int error) static void kiblnd_handle_early_rxs(kib_conn_t *conn) { - unsigned long flags; - kib_rx_t *rx; + unsigned long flags; + kib_rx_t *rx; kib_rx_t *tmp; LASSERT(!in_interrupt()); @@ -1957,9 +1955,9 @@ static void kiblnd_abort_txs(kib_conn_t *conn, struct list_head *txs) { LIST_HEAD(zombies); - struct list_head *tmp; - struct list_head *nxt; - kib_tx_t *tx; + struct list_head *tmp; + struct list_head *nxt; + kib_tx_t *tx; spin_lock(&conn->ibc_lock); @@ -2018,7 +2016,7 @@ void kiblnd_peer_connect_failed(kib_peer_t *peer, int active, int error) { LIST_HEAD(zombies); - unsigned long flags; + unsigned long flags; LASSERT(error != 0); LASSERT(!in_interrupt()); @@ -2071,12 +2069,12 @@ kiblnd_peer_connect_failed(kib_peer_t *peer, int active, int error) void kiblnd_connreq_done(kib_conn_t *conn, int status) { - kib_peer_t *peer = conn->ibc_peer; - kib_tx_t *tx; + kib_peer_t *peer = conn->ibc_peer; + kib_tx_t *tx; kib_tx_t *tmp; - struct list_head txs; - unsigned long flags; - int active; + struct list_head txs; + unsigned long flags; + int active; active = (conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT); @@ -2166,7 +2164,7 @@ kiblnd_connreq_done(kib_conn_t *conn, int status) static void kiblnd_reject(struct rdma_cm_id *cmid, kib_rej_t *rej) { - int rc; + int rc; rc = rdma_reject(cmid, rej, sizeof(*rej)); @@ -2177,22 +2175,22 @@ kiblnd_reject(struct rdma_cm_id *cmid, kib_rej_t *rej) static int kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob) { - rwlock_t *g_lock = &kiblnd_data.kib_global_lock; - kib_msg_t *reqmsg = priv; - kib_msg_t *ackmsg; - kib_dev_t *ibdev; - kib_peer_t *peer; - kib_peer_t *peer2; - kib_conn_t *conn; - lnet_ni_t *ni = NULL; - kib_net_t *net = NULL; - lnet_nid_t nid; + rwlock_t *g_lock = &kiblnd_data.kib_global_lock; + kib_msg_t *reqmsg = priv; + kib_msg_t *ackmsg; + kib_dev_t *ibdev; + kib_peer_t *peer; + kib_peer_t *peer2; + kib_conn_t *conn; + lnet_ni_t *ni = NULL; + kib_net_t *net = NULL; + lnet_nid_t nid; struct rdma_conn_param cp; - kib_rej_t rej; - int version = IBLND_MSG_VERSION; - unsigned long flags; - int rc; - struct sockaddr_in *peer_addr; + kib_rej_t rej; + int version = IBLND_MSG_VERSION; + unsigned long flags; + int rc; + struct sockaddr_in *peer_addr; LASSERT(!in_interrupt()); /* cmid inherits 'context' from the corresponding listener id */ @@ -2200,8 +2198,8 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob) LASSERT(ibdev != NULL); memset(&rej, 0, sizeof(rej)); - rej.ibr_magic = IBLND_MSG_MAGIC; - rej.ibr_why = IBLND_REJECT_FATAL; + rej.ibr_magic = IBLND_MSG_MAGIC; + rej.ibr_why = IBLND_REJECT_FATAL; rej.ibr_cp.ibcp_max_msg_size = IBLND_MSG_SIZE; peer_addr = (struct sockaddr_in *)&(cmid->route.addr.dst_addr); @@ -2243,7 +2241,7 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob) } nid = reqmsg->ibm_srcnid; - ni = lnet_net2ni(LNET_NIDNET(reqmsg->ibm_dstnid)); + ni = lnet_net2ni(LNET_NIDNET(reqmsg->ibm_dstnid)); if (ni != NULL) { net = (kib_net_t *)ni->ni_data; @@ -2394,7 +2392,7 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob) * CM callback doesn't destroy cmid. */ conn->ibc_incarnation = reqmsg->ibm_srcstamp; - conn->ibc_credits = IBLND_MSG_QUEUE_SIZE(version); + conn->ibc_credits = IBLND_MSG_QUEUE_SIZE(version); conn->ibc_reserved_credits = IBLND_MSG_QUEUE_SIZE(version); LASSERT(conn->ibc_credits + conn->ibc_reserved_credits + IBLND_OOB_MSGS(version) <= IBLND_RX_MSGS(version)); @@ -2412,12 +2410,12 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob) memset(&cp, 0, sizeof(cp)); cp.private_data = ackmsg; - cp.private_data_len = ackmsg->ibm_nob; + cp.private_data_len = ackmsg->ibm_nob; cp.responder_resources = 0; /* No atomic ops or RDMA reads */ - cp.initiator_depth = 0; + cp.initiator_depth = 0; cp.flow_control = 1; - cp.retry_count = *kiblnd_tunables.kib_retry_count; - cp.rnr_retry_count = *kiblnd_tunables.kib_rnr_retry_count; + cp.retry_count = *kiblnd_tunables.kib_retry_count; + cp.rnr_retry_count = *kiblnd_tunables.kib_rnr_retry_count; CDEBUG(D_NET, "Accept %s\n", libcfs_nid2str(nid)); @@ -2439,7 +2437,7 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob) if (ni != NULL) lnet_ni_decref(ni); - rej.ibr_version = version; + rej.ibr_version = version; rej.ibr_cp.ibcp_queue_depth = IBLND_MSG_QUEUE_SIZE(version); rej.ibr_cp.ibcp_max_frags = IBLND_RDMA_FRAGS(version); kiblnd_reject(cmid, &rej); @@ -2451,10 +2449,10 @@ static void kiblnd_reconnect(kib_conn_t *conn, int version, __u64 incarnation, int why, kib_connparams_t *cp) { - kib_peer_t *peer = conn->ibc_peer; - char *reason; - int retry = 0; - unsigned long flags; + kib_peer_t *peer = conn->ibc_peer; + char *reason; + int retry = 0; + unsigned long flags; LASSERT(conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT); LASSERT(peer->ibp_connecting > 0); /* 'conn' at least */ @@ -2513,7 +2511,7 @@ kiblnd_reconnect(kib_conn_t *conn, int version, static void kiblnd_rejected(kib_conn_t *conn, int reason, void *priv, int priv_nob) { - kib_peer_t *peer = conn->ibc_peer; + kib_peer_t *peer = conn->ibc_peer; LASSERT(!in_interrupt()); LASSERT(conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT); @@ -2532,10 +2530,10 @@ kiblnd_rejected(kib_conn_t *conn, int reason, void *priv, int priv_nob) case IB_CM_REJ_CONSUMER_DEFINED: if (priv_nob >= offsetof(kib_rej_t, ibr_padding)) { - kib_rej_t *rej = priv; - kib_connparams_t *cp = NULL; - int flip = 0; - __u64 incarnation = -1; + kib_rej_t *rej = priv; + kib_connparams_t *cp = NULL; + int flip = 0; + __u64 incarnation = -1; /* NB. default incarnation is -1 because: * a) V1 will ignore dst incarnation in connreq. @@ -2652,13 +2650,13 @@ kiblnd_rejected(kib_conn_t *conn, int reason, void *priv, int priv_nob) static void kiblnd_check_connreply(kib_conn_t *conn, void *priv, int priv_nob) { - kib_peer_t *peer = conn->ibc_peer; - lnet_ni_t *ni = peer->ibp_ni; - kib_net_t *net = ni->ni_data; - kib_msg_t *msg = priv; - int ver = conn->ibc_version; - int rc = kiblnd_unpack_msg(msg, priv_nob); - unsigned long flags; + kib_peer_t *peer = conn->ibc_peer; + lnet_ni_t *ni = peer->ibp_ni; + kib_net_t *net = ni->ni_data; + kib_msg_t *msg = priv; + int ver = conn->ibc_version; + int rc = kiblnd_unpack_msg(msg, priv_nob); + unsigned long flags; LASSERT(net != NULL); @@ -2726,8 +2724,8 @@ kiblnd_check_connreply(kib_conn_t *conn, void *priv, int priv_nob) goto failed; } - conn->ibc_incarnation = msg->ibm_srcstamp; - conn->ibc_credits = + conn->ibc_incarnation = msg->ibm_srcstamp; + conn->ibc_credits = conn->ibc_reserved_credits = IBLND_MSG_QUEUE_SIZE(ver); LASSERT(conn->ibc_credits + conn->ibc_reserved_credits + IBLND_OOB_MSGS(ver) <= IBLND_RX_MSGS(ver)); @@ -2749,20 +2747,20 @@ kiblnd_check_connreply(kib_conn_t *conn, void *priv, int priv_nob) static int kiblnd_active_connect(struct rdma_cm_id *cmid) { - kib_peer_t *peer = (kib_peer_t *)cmid->context; - kib_conn_t *conn; - kib_msg_t *msg; - struct rdma_conn_param cp; - int version; - __u64 incarnation; - unsigned long flags; - int rc; + kib_peer_t *peer = (kib_peer_t *)cmid->context; + kib_conn_t *conn; + kib_msg_t *msg; + struct rdma_conn_param cp; + int version; + __u64 incarnation; + unsigned long flags; + int rc; read_lock_irqsave(&kiblnd_data.kib_global_lock, flags); incarnation = peer->ibp_incarnation; - version = (peer->ibp_version == 0) ? IBLND_MSG_VERSION : - peer->ibp_version; + version = (peer->ibp_version == 0) ? IBLND_MSG_VERSION : + peer->ibp_version; read_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags); @@ -2793,8 +2791,8 @@ kiblnd_active_connect(struct rdma_cm_id *cmid) cp.private_data_len = msg->ibm_nob; cp.responder_resources = 0; /* No atomic ops or RDMA reads */ cp.initiator_depth = 0; - cp.flow_control = 1; - cp.retry_count = *kiblnd_tunables.kib_retry_count; + cp.flow_control = 1; + cp.retry_count = *kiblnd_tunables.kib_retry_count; cp.rnr_retry_count = *kiblnd_tunables.kib_rnr_retry_count; LASSERT(cmid->context == (void *)conn); @@ -2814,9 +2812,9 @@ kiblnd_active_connect(struct rdma_cm_id *cmid) int kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event) { - kib_peer_t *peer; - kib_conn_t *conn; - int rc; + kib_peer_t *peer; + kib_conn_t *conn; + int rc; switch (event->event) { default: @@ -2983,8 +2981,8 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event) static int kiblnd_check_txs_locked(kib_conn_t *conn, struct list_head *txs) { - kib_tx_t *tx; - struct list_head *ttmp; + kib_tx_t *tx; + struct list_head *ttmp; list_for_each(ttmp, txs) { tx = list_entry(ttmp, kib_tx_t, tx_list); @@ -3022,13 +3020,13 @@ kiblnd_check_conns(int idx) { LIST_HEAD(closes); LIST_HEAD(checksends); - struct list_head *peers = &kiblnd_data.kib_peers[idx]; - struct list_head *ptmp; - kib_peer_t *peer; - kib_conn_t *conn; + struct list_head *peers = &kiblnd_data.kib_peers[idx]; + struct list_head *ptmp; + kib_peer_t *peer; + kib_conn_t *conn; kib_conn_t *tmp; - struct list_head *ctmp; - unsigned long flags; + struct list_head *ctmp; + unsigned long flags; /* NB. We expect to have a look at all the peers and not find any * RDMAs to time out, so we just use a shared lock while we @@ -3114,14 +3112,14 @@ kiblnd_disconnect_conn(kib_conn_t *conn) int kiblnd_connd(void *arg) { - wait_queue_t wait; - unsigned long flags; - kib_conn_t *conn; - int timeout; - int i; - int dropped_lock; - int peer_index = 0; - unsigned long deadline = jiffies; + wait_queue_t wait; + unsigned long flags; + kib_conn_t *conn; + int timeout; + int i; + int dropped_lock; + int peer_index = 0; + unsigned long deadline = jiffies; cfs_block_allsigs(); @@ -3169,7 +3167,7 @@ kiblnd_connd(void *arg) if (timeout <= 0) { const int n = 4; const int p = 1; - int chunk = kiblnd_data.kib_peer_hash_size; + int chunk = kiblnd_data.kib_peer_hash_size; spin_unlock_irqrestore(&kiblnd_data.kib_connd_lock, flags); dropped_lock = 1; @@ -3273,9 +3271,9 @@ kiblnd_cq_completion(struct ib_cq *cq, void *arg) * consuming my CQ I could be called after all completions have * occurred. But in this case, ibc_nrx == 0 && ibc_nsends_posted == 0 * and this CQ is about to be destroyed so I NOOP. */ - kib_conn_t *conn = (kib_conn_t *)arg; - struct kib_sched_info *sched = conn->ibc_sched; - unsigned long flags; + kib_conn_t *conn = (kib_conn_t *)arg; + struct kib_sched_info *sched = conn->ibc_sched; + unsigned long flags; LASSERT(cq == conn->ibc_cq); @@ -3309,15 +3307,15 @@ kiblnd_cq_event(struct ib_event *event, void *arg) int kiblnd_scheduler(void *arg) { - long id = (long)arg; - struct kib_sched_info *sched; - kib_conn_t *conn; - wait_queue_t wait; - unsigned long flags; - struct ib_wc wc; - int did_something; - int busy_loops = 0; - int rc; + long id = (long)arg; + struct kib_sched_info *sched; + kib_conn_t *conn; + wait_queue_t wait; + unsigned long flags; + struct ib_wc wc; + int did_something; + int busy_loops = 0; + int rc; cfs_block_allsigs(); @@ -3432,11 +3430,11 @@ kiblnd_scheduler(void *arg) int kiblnd_failover_thread(void *arg) { - rwlock_t *glock = &kiblnd_data.kib_global_lock; - kib_dev_t *dev; - wait_queue_t wait; - unsigned long flags; - int rc; + rwlock_t *glock = &kiblnd_data.kib_global_lock; + kib_dev_t *dev; + wait_queue_t wait; + unsigned long flags; + int rc; LASSERT(*kiblnd_tunables.kib_dev_failover != 0); @@ -3446,8 +3444,8 @@ kiblnd_failover_thread(void *arg) write_lock_irqsave(glock, flags); while (!kiblnd_data.kib_shutdown) { - int do_failover = 0; - int long_sleep; + int do_failover = 0; + int long_sleep; list_for_each_entry(dev, &kiblnd_data.kib_failed_devs, ibd_fail_list) { diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c index eedf01afd57f..b0e00361cfce 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c @@ -150,30 +150,30 @@ module_param(use_privileged_port, int, 0644); MODULE_PARM_DESC(use_privileged_port, "use privileged port when initiating connection"); kib_tunables_t kiblnd_tunables = { - .kib_dev_failover = &dev_failover, - .kib_service = &service, - .kib_cksum = &cksum, - .kib_timeout = &timeout, - .kib_keepalive = &keepalive, - .kib_ntx = &ntx, - .kib_credits = &credits, - .kib_peertxcredits = &peer_credits, - .kib_peercredits_hiw = &peer_credits_hiw, - .kib_peerrtrcredits = &peer_buffer_credits, - .kib_peertimeout = &peer_timeout, - .kib_default_ipif = &ipif_name, - .kib_retry_count = &retry_count, - .kib_rnr_retry_count = &rnr_retry_count, - .kib_concurrent_sends = &concurrent_sends, - .kib_ib_mtu = &ib_mtu, - .kib_map_on_demand = &map_on_demand, - .kib_fmr_pool_size = &fmr_pool_size, - .kib_fmr_flush_trigger = &fmr_flush_trigger, - .kib_fmr_cache = &fmr_cache, - .kib_pmr_pool_size = &pmr_pool_size, - .kib_require_priv_port = &require_privileged_port, - .kib_use_priv_port = &use_privileged_port, - .kib_nscheds = &nscheds + .kib_dev_failover = &dev_failover, + .kib_service = &service, + .kib_cksum = &cksum, + .kib_timeout = &timeout, + .kib_keepalive = &keepalive, + .kib_ntx = &ntx, + .kib_credits = &credits, + .kib_peertxcredits = &peer_credits, + .kib_peercredits_hiw = &peer_credits_hiw, + .kib_peerrtrcredits = &peer_buffer_credits, + .kib_peertimeout = &peer_timeout, + .kib_default_ipif = &ipif_name, + .kib_retry_count = &retry_count, + .kib_rnr_retry_count = &rnr_retry_count, + .kib_concurrent_sends = &concurrent_sends, + .kib_ib_mtu = &ib_mtu, + .kib_map_on_demand = &map_on_demand, + .kib_fmr_pool_size = &fmr_pool_size, + .kib_fmr_flush_trigger = &fmr_flush_trigger, + .kib_fmr_cache = &fmr_cache, + .kib_pmr_pool_size = &pmr_pool_size, + .kib_require_priv_port = &require_privileged_port, + .kib_use_priv_port = &use_privileged_port, + .kib_nscheds = &nscheds }; int From 97d10d0a40dddd317f1c659ec42544b4793a140e Mon Sep 17 00:00:00 2001 From: Mike Shuey Date: Tue, 19 May 2015 10:14:37 -0400 Subject: [PATCH 0559/1163] staging: lustre: lnet: socklnd: code cleanup - align spacing Unify variable declarations to use a single space. Also include several miscellaneous whitespace cleanups, particularly in socklnd.h. Signed-off-by: Mike Shuey Signed-off-by: Greg Kroah-Hartman --- .../lustre/lnet/klnds/socklnd/socklnd.c | 468 +++++++-------- .../lustre/lnet/klnds/socklnd/socklnd.h | 548 ++++++++++-------- .../lustre/lnet/klnds/socklnd/socklnd_cb.c | 394 ++++++------- .../lnet/klnds/socklnd/socklnd_lib-linux.c | 150 ++--- .../lnet/klnds/socklnd/socklnd_modparams.c | 33 +- .../lustre/lnet/klnds/socklnd/socklnd_proto.c | 128 ++-- 6 files changed, 892 insertions(+), 829 deletions(-) diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index 7586b7e4040b..7b5d4078ba4e 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -49,8 +49,8 @@ ksock_nal_data_t ksocknal_data; static ksock_interface_t * ksocknal_ip2iface(lnet_ni_t *ni, __u32 ip) { - ksock_net_t *net = ni->ni_data; - int i; + ksock_net_t *net = ni->ni_data; + int i; ksock_interface_t *iface; for (i = 0; i < net->ksnn_ninterfaces; i++) { @@ -102,8 +102,8 @@ ksocknal_destroy_route(ksock_route_t *route) static int ksocknal_create_peer(ksock_peer_t **peerp, lnet_ni_t *ni, lnet_process_id_t id) { - ksock_net_t *net = ni->ni_data; - ksock_peer_t *peer; + ksock_net_t *net = ni->ni_data; + ksock_peer_t *peer; LASSERT(id.nid != LNET_NID_ANY); LASSERT(id.pid != LNET_PID_ANY); @@ -149,7 +149,7 @@ ksocknal_create_peer(ksock_peer_t **peerp, lnet_ni_t *ni, lnet_process_id_t id) void ksocknal_destroy_peer(ksock_peer_t *peer) { - ksock_net_t *net = peer->ksnp_ni->ni_data; + ksock_net_t *net = peer->ksnp_ni->ni_data; CDEBUG(D_NET, "peer %s %p deleted\n", libcfs_id2str(peer->ksnp_id), peer); @@ -175,9 +175,9 @@ ksocknal_destroy_peer(ksock_peer_t *peer) ksock_peer_t * ksocknal_find_peer_locked(lnet_ni_t *ni, lnet_process_id_t id) { - struct list_head *peer_list = ksocknal_nid2peerlist(id.nid); - struct list_head *tmp; - ksock_peer_t *peer; + struct list_head *peer_list = ksocknal_nid2peerlist(id.nid); + struct list_head *tmp; + ksock_peer_t *peer; list_for_each(tmp, peer_list) { @@ -203,7 +203,7 @@ ksocknal_find_peer_locked(lnet_ni_t *ni, lnet_process_id_t id) ksock_peer_t * ksocknal_find_peer(lnet_ni_t *ni, lnet_process_id_t id) { - ksock_peer_t *peer; + ksock_peer_t *peer; read_lock(&ksocknal_data.ksnd_global_lock); peer = ksocknal_find_peer_locked(ni, id); @@ -217,8 +217,8 @@ ksocknal_find_peer(lnet_ni_t *ni, lnet_process_id_t id) static void ksocknal_unlink_peer_locked(ksock_peer_t *peer) { - int i; - __u32 ip; + int i; + __u32 ip; ksock_interface_t *iface; for (i = 0; i < peer->ksnp_n_passive_ips; i++) { @@ -249,13 +249,13 @@ ksocknal_get_peer_info(lnet_ni_t *ni, int index, lnet_process_id_t *id, __u32 *myip, __u32 *peer_ip, int *port, int *conn_count, int *share_count) { - ksock_peer_t *peer; - struct list_head *ptmp; - ksock_route_t *route; - struct list_head *rtmp; - int i; - int j; - int rc = -ENOENT; + ksock_peer_t *peer; + struct list_head *ptmp; + ksock_route_t *route; + struct list_head *rtmp; + int i; + int j; + int rc = -ENOENT; read_lock(&ksocknal_data.ksnd_global_lock); @@ -322,8 +322,8 @@ ksocknal_get_peer_info(lnet_ni_t *ni, int index, static void ksocknal_associate_route_conn_locked(ksock_route_t *route, ksock_conn_t *conn) { - ksock_peer_t *peer = route->ksnr_peer; - int type = conn->ksnc_type; + ksock_peer_t *peer = route->ksnr_peer; + int type = conn->ksnc_type; ksock_interface_t *iface; conn->ksnc_route = route; @@ -366,9 +366,9 @@ ksocknal_associate_route_conn_locked(ksock_route_t *route, ksock_conn_t *conn) static void ksocknal_add_route_locked(ksock_peer_t *peer, ksock_route_t *route) { - struct list_head *tmp; - ksock_conn_t *conn; - ksock_route_t *route2; + struct list_head *tmp; + ksock_conn_t *conn; + ksock_route_t *route2; LASSERT(!peer->ksnp_closing); LASSERT(route->ksnr_peer == NULL); @@ -407,11 +407,11 @@ ksocknal_add_route_locked(ksock_peer_t *peer, ksock_route_t *route) static void ksocknal_del_route_locked(ksock_route_t *route) { - ksock_peer_t *peer = route->ksnr_peer; + ksock_peer_t *peer = route->ksnr_peer; ksock_interface_t *iface; - ksock_conn_t *conn; - struct list_head *ctmp; - struct list_head *cnxt; + ksock_conn_t *conn; + struct list_head *ctmp; + struct list_head *cnxt; LASSERT(!route->ksnr_deleted); @@ -447,12 +447,12 @@ ksocknal_del_route_locked(ksock_route_t *route) int ksocknal_add_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port) { - struct list_head *tmp; - ksock_peer_t *peer; - ksock_peer_t *peer2; - ksock_route_t *route; - ksock_route_t *route2; - int rc; + struct list_head *tmp; + ksock_peer_t *peer; + ksock_peer_t *peer2; + ksock_route_t *route; + ksock_route_t *route2; + int rc; if (id.nid == LNET_NID_ANY || id.pid == LNET_PID_ANY) @@ -509,11 +509,11 @@ ksocknal_add_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port) static void ksocknal_del_peer_locked(ksock_peer_t *peer, __u32 ip) { - ksock_conn_t *conn; - ksock_route_t *route; - struct list_head *tmp; - struct list_head *nxt; - int nshared; + ksock_conn_t *conn; + ksock_route_t *route; + struct list_head *tmp; + struct list_head *nxt; + int nshared; LASSERT(!peer->ksnp_closing); @@ -565,13 +565,13 @@ static int ksocknal_del_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ip) { LIST_HEAD(zombies); - struct list_head *ptmp; - struct list_head *pnxt; - ksock_peer_t *peer; - int lo; - int hi; - int i; - int rc = -ENOENT; + struct list_head *ptmp; + struct list_head *pnxt; + ksock_peer_t *peer; + int lo; + int hi; + int i; + int rc = -ENOENT; write_lock_bh(&ksocknal_data.ksnd_global_lock); @@ -623,11 +623,11 @@ ksocknal_del_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ip) static ksock_conn_t * ksocknal_get_conn_by_idx(lnet_ni_t *ni, int index) { - ksock_peer_t *peer; - struct list_head *ptmp; - ksock_conn_t *conn; - struct list_head *ctmp; - int i; + ksock_peer_t *peer; + struct list_head *ptmp; + ksock_conn_t *conn; + struct list_head *ctmp; + int i; read_lock(&ksocknal_data.ksnd_global_lock); @@ -661,8 +661,8 @@ static ksock_sched_t * ksocknal_choose_scheduler_locked(unsigned int cpt) { struct ksock_sched_info *info = ksocknal_data.ksnd_sched_info[cpt]; - ksock_sched_t *sched; - int i; + ksock_sched_t *sched; + int i; LASSERT(info->ksi_nthreads > 0); @@ -683,9 +683,9 @@ ksocknal_choose_scheduler_locked(unsigned int cpt) static int ksocknal_local_ipvec(lnet_ni_t *ni, __u32 *ipaddrs) { - ksock_net_t *net = ni->ni_data; - int i; - int nip; + ksock_net_t *net = ni->ni_data; + int i; + int nip; read_lock(&ksocknal_data.ksnd_global_lock); @@ -711,12 +711,12 @@ ksocknal_local_ipvec(lnet_ni_t *ni, __u32 *ipaddrs) static int ksocknal_match_peerip(ksock_interface_t *iface, __u32 *ips, int nips) { - int best_netmatch = 0; - int best_xor = 0; - int best = -1; - int this_xor; - int this_netmatch; - int i; + int best_netmatch = 0; + int best_xor = 0; + int best = -1; + int this_xor; + int this_netmatch; + int i; for (i = 0; i < nips; i++) { if (ips[i] == 0) @@ -743,19 +743,19 @@ ksocknal_match_peerip(ksock_interface_t *iface, __u32 *ips, int nips) static int ksocknal_select_ips(ksock_peer_t *peer, __u32 *peerips, int n_peerips) { - rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock; - ksock_net_t *net = peer->ksnp_ni->ni_data; - ksock_interface_t *iface; - ksock_interface_t *best_iface; - int n_ips; - int i; - int j; - int k; - __u32 ip; - __u32 xor; - int this_netmatch; - int best_netmatch; - int best_npeers; + rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock; + ksock_net_t *net = peer->ksnp_ni->ni_data; + ksock_interface_t *iface; + ksock_interface_t *best_iface; + int n_ips; + int i; + int j; + int k; + __u32 ip; + __u32 xor; + int this_netmatch; + int best_netmatch; + int best_npeers; /* CAVEAT EMPTOR: We do all our interface matching with an * exclusive hold of global lock at IRQ priority. We're only @@ -846,19 +846,19 @@ static void ksocknal_create_routes(ksock_peer_t *peer, int port, __u32 *peer_ipaddrs, int npeer_ipaddrs) { - ksock_route_t *newroute = NULL; - rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock; - lnet_ni_t *ni = peer->ksnp_ni; - ksock_net_t *net = ni->ni_data; - struct list_head *rtmp; - ksock_route_t *route; - ksock_interface_t *iface; - ksock_interface_t *best_iface; - int best_netmatch; - int this_netmatch; - int best_nroutes; - int i; - int j; + ksock_route_t *newroute = NULL; + rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock; + lnet_ni_t *ni = peer->ksnp_ni; + ksock_net_t *net = ni->ni_data; + struct list_head *rtmp; + ksock_route_t *route; + ksock_interface_t *iface; + ksock_interface_t *best_iface; + int best_netmatch; + int this_netmatch; + int best_nroutes; + int i; + int j; /* CAVEAT EMPTOR: We do all our interface matching with an * exclusive hold of global lock at IRQ priority. We're only @@ -963,10 +963,10 @@ ksocknal_create_routes(ksock_peer_t *peer, int port, int ksocknal_accept(lnet_ni_t *ni, struct socket *sock) { - ksock_connreq_t *cr; - int rc; - __u32 peer_ip; - int peer_port; + ksock_connreq_t *cr; + int rc; + __u32 peer_ip; + int peer_port; rc = libcfs_sock_getaddr(sock, 1, &peer_ip, &peer_port); LASSERT(rc == 0); /* we succeeded before */ @@ -994,7 +994,7 @@ ksocknal_accept(lnet_ni_t *ni, struct socket *sock) static int ksocknal_connecting(ksock_peer_t *peer, __u32 ipaddr) { - ksock_route_t *route; + ksock_route_t *route; list_for_each_entry(route, &peer->ksnp_routes, ksnr_list) { @@ -1008,23 +1008,23 @@ int ksocknal_create_conn(lnet_ni_t *ni, ksock_route_t *route, struct socket *sock, int type) { - rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock; + rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock; LIST_HEAD(zombies); - lnet_process_id_t peerid; - struct list_head *tmp; - __u64 incarnation; - ksock_conn_t *conn; - ksock_conn_t *conn2; - ksock_peer_t *peer = NULL; - ksock_peer_t *peer2; - ksock_sched_t *sched; + lnet_process_id_t peerid; + struct list_head *tmp; + __u64 incarnation; + ksock_conn_t *conn; + ksock_conn_t *conn2; + ksock_peer_t *peer = NULL; + ksock_peer_t *peer2; + ksock_sched_t *sched; ksock_hello_msg_t *hello; - int cpt; - ksock_tx_t *tx; - ksock_tx_t *txtmp; - int rc; - int active; - char *warn = NULL; + int cpt; + ksock_tx_t *tx; + ksock_tx_t *txtmp; + int rc; + int active; + char *warn = NULL; active = (route != NULL); @@ -1396,10 +1396,10 @@ ksocknal_close_conn_locked(ksock_conn_t *conn, int error) /* This just does the immmediate housekeeping, and queues the * connection for the reaper to terminate. * Caller holds ksnd_global_lock exclusively in irq context */ - ksock_peer_t *peer = conn->ksnc_peer; - ksock_route_t *route; - ksock_conn_t *conn2; - struct list_head *tmp; + ksock_peer_t *peer = conn->ksnc_peer; + ksock_route_t *route; + ksock_conn_t *conn2; + struct list_head *tmp; LASSERT(peer->ksnp_error == 0); LASSERT(!conn->ksnc_closing); @@ -1479,7 +1479,7 @@ ksocknal_close_conn_locked(ksock_conn_t *conn, int error) void ksocknal_peer_failed(ksock_peer_t *peer) { - int notify = 0; + int notify = 0; unsigned long last_alive = 0; /* There has been a connection failure or comms error; but I'll only @@ -1506,9 +1506,9 @@ ksocknal_peer_failed(ksock_peer_t *peer) void ksocknal_finalize_zcreq(ksock_conn_t *conn) { - ksock_peer_t *peer = conn->ksnc_peer; - ksock_tx_t *tx; - ksock_tx_t *tmp; + ksock_peer_t *peer = conn->ksnc_peer; + ksock_tx_t *tx; + ksock_tx_t *tmp; LIST_HEAD(zlist); /* NB safe to finalize TXs because closing of socket will @@ -1546,9 +1546,9 @@ ksocknal_terminate_conn(ksock_conn_t *conn) * disengage the socket from its callbacks and close it. * ksnc_refcount will eventually hit zero, and then the reaper will * destroy it. */ - ksock_peer_t *peer = conn->ksnc_peer; - ksock_sched_t *sched = conn->ksnc_scheduler; - int failed = 0; + ksock_peer_t *peer = conn->ksnc_peer; + ksock_sched_t *sched = conn->ksnc_scheduler; + int failed = 0; LASSERT(conn->ksnc_closing); @@ -1617,7 +1617,7 @@ ksocknal_queue_zombie_conn(ksock_conn_t *conn) void ksocknal_destroy_conn(ksock_conn_t *conn) { - unsigned long last_rcv; + unsigned long last_rcv; /* Final coup-de-grace of the reaper */ CDEBUG(D_NET, "connection %p\n", conn); @@ -1677,10 +1677,10 @@ ksocknal_destroy_conn(ksock_conn_t *conn) int ksocknal_close_peer_conns_locked(ksock_peer_t *peer, __u32 ipaddr, int why) { - ksock_conn_t *conn; - struct list_head *ctmp; - struct list_head *cnxt; - int count = 0; + ksock_conn_t *conn; + struct list_head *ctmp; + struct list_head *cnxt; + int count = 0; list_for_each_safe(ctmp, cnxt, &peer->ksnp_conns) { conn = list_entry(ctmp, ksock_conn_t, ksnc_list); @@ -1698,9 +1698,9 @@ ksocknal_close_peer_conns_locked(ksock_peer_t *peer, __u32 ipaddr, int why) int ksocknal_close_conn_and_siblings(ksock_conn_t *conn, int why) { - ksock_peer_t *peer = conn->ksnc_peer; - __u32 ipaddr = conn->ksnc_ipaddr; - int count; + ksock_peer_t *peer = conn->ksnc_peer; + __u32 ipaddr = conn->ksnc_ipaddr; + int count; write_lock_bh(&ksocknal_data.ksnd_global_lock); @@ -1714,13 +1714,13 @@ ksocknal_close_conn_and_siblings(ksock_conn_t *conn, int why) int ksocknal_close_matching_conns(lnet_process_id_t id, __u32 ipaddr) { - ksock_peer_t *peer; - struct list_head *ptmp; - struct list_head *pnxt; - int lo; - int hi; - int i; - int count = 0; + ksock_peer_t *peer; + struct list_head *ptmp; + struct list_head *pnxt; + int lo; + int hi; + int i; + int count = 0; write_lock_bh(&ksocknal_data.ksnd_global_lock); @@ -1762,7 +1762,7 @@ ksocknal_notify(lnet_ni_t *ni, lnet_nid_t gw_nid, int alive) { /* The router is telling me she's been notified of a change in * gateway state.... */ - lnet_process_id_t id = {0}; + lnet_process_id_t id = {0}; id.nid = gw_nid; id.pid = LNET_PID_ANY; @@ -1783,20 +1783,20 @@ ksocknal_notify(lnet_ni_t *ni, lnet_nid_t gw_nid, int alive) void ksocknal_query(lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when) { - int connect = 1; - unsigned long last_alive = 0; - unsigned long now = cfs_time_current(); - ksock_peer_t *peer = NULL; - rwlock_t *glock = &ksocknal_data.ksnd_global_lock; - lnet_process_id_t id = {.nid = nid, .pid = LUSTRE_SRV_LNET_PID}; + int connect = 1; + unsigned long last_alive = 0; + unsigned long now = cfs_time_current(); + ksock_peer_t *peer = NULL; + rwlock_t *glock = &ksocknal_data.ksnd_global_lock; + lnet_process_id_t id = {.nid = nid, .pid = LUSTRE_SRV_LNET_PID}; read_lock(glock); peer = ksocknal_find_peer_locked(ni, id); if (peer != NULL) { - struct list_head *tmp; - ksock_conn_t *conn; - int bufnob; + struct list_head *tmp; + ksock_conn_t *conn; + int bufnob; list_for_each(tmp, &peer->ksnp_conns) { conn = list_entry(tmp, ksock_conn_t, ksnc_list); @@ -1844,10 +1844,10 @@ ksocknal_query(lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when) static void ksocknal_push_peer(ksock_peer_t *peer) { - int index; - int i; - struct list_head *tmp; - ksock_conn_t *conn; + int index; + int i; + struct list_head *tmp; + ksock_conn_t *conn; for (index = 0; ; index++) { read_lock(&ksocknal_data.ksnd_global_lock); @@ -1877,12 +1877,12 @@ ksocknal_push_peer(ksock_peer_t *peer) static int ksocknal_push(lnet_ni_t *ni, lnet_process_id_t id) { - ksock_peer_t *peer; - struct list_head *tmp; - int index; - int i; - int j; - int rc = -ENOENT; + ksock_peer_t *peer; + struct list_head *tmp; + int index; + int i; + int j; + int rc = -ENOENT; for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) { for (j = 0; ; j++) { @@ -1926,15 +1926,15 @@ ksocknal_push(lnet_ni_t *ni, lnet_process_id_t id) static int ksocknal_add_interface(lnet_ni_t *ni, __u32 ipaddress, __u32 netmask) { - ksock_net_t *net = ni->ni_data; + ksock_net_t *net = ni->ni_data; ksock_interface_t *iface; - int rc; - int i; - int j; - struct list_head *ptmp; - ksock_peer_t *peer; - struct list_head *rtmp; - ksock_route_t *route; + int rc; + int i; + int j; + struct list_head *ptmp; + ksock_peer_t *peer; + struct list_head *rtmp; + ksock_route_t *route; if (ipaddress == 0 || netmask == 0) @@ -1988,12 +1988,12 @@ ksocknal_add_interface(lnet_ni_t *ni, __u32 ipaddress, __u32 netmask) static void ksocknal_peer_del_interface_locked(ksock_peer_t *peer, __u32 ipaddr) { - struct list_head *tmp; - struct list_head *nxt; - ksock_route_t *route; - ksock_conn_t *conn; - int i; - int j; + struct list_head *tmp; + struct list_head *nxt; + ksock_route_t *route; + ksock_conn_t *conn; + int i; + int j; for (i = 0; i < peer->ksnp_n_passive_ips; i++) if (peer->ksnp_passive_ips[i] == ipaddr) { @@ -2029,14 +2029,14 @@ ksocknal_peer_del_interface_locked(ksock_peer_t *peer, __u32 ipaddr) static int ksocknal_del_interface(lnet_ni_t *ni, __u32 ipaddress) { - ksock_net_t *net = ni->ni_data; - int rc = -ENOENT; - struct list_head *tmp; - struct list_head *nxt; - ksock_peer_t *peer; - __u32 this_ip; - int i; - int j; + ksock_net_t *net = ni->ni_data; + int rc = -ENOENT; + struct list_head *tmp; + struct list_head *nxt; + ksock_peer_t *peer; + __u32 this_ip; + int i; + int j; write_lock_bh(&ksocknal_data.ksnd_global_lock); @@ -2114,11 +2114,11 @@ ksocknal_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg) data->ioc_u32[0]); /* IP address */ case IOC_LIBCFS_GET_PEER: { - __u32 myip = 0; - __u32 ip = 0; - int port = 0; - int conn_count = 0; - int share_count = 0; + __u32 myip = 0; + __u32 ip = 0; + int port = 0; + int conn_count = 0; + int share_count = 0; rc = ksocknal_get_peer_info(ni, data->ioc_count, &id, &myip, &ip, &port, @@ -2150,9 +2150,9 @@ ksocknal_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg) data->ioc_u32[0]); /* IP */ case IOC_LIBCFS_GET_CONN: { - int txmem; - int rxmem; - int nagle; + int txmem; + int rxmem; + int nagle; ksock_conn_t *conn = ksocknal_get_conn_by_idx(ni, data->ioc_count); if (conn == NULL) @@ -2207,8 +2207,8 @@ ksocknal_free_buffers(void) LASSERT(atomic_read(&ksocknal_data.ksnd_nactive_txs) == 0); if (ksocknal_data.ksnd_sched_info != NULL) { - struct ksock_sched_info *info; - int i; + struct ksock_sched_info *info; + int i; cfs_percpt_for_each(info, i, ksocknal_data.ksnd_sched_info) { if (info->ksi_scheds != NULL) { @@ -2227,8 +2227,8 @@ ksocknal_free_buffers(void) spin_lock(&ksocknal_data.ksnd_tx_lock); if (!list_empty(&ksocknal_data.ksnd_idle_noop_txs)) { - struct list_head zlist; - ksock_tx_t *tx; + struct list_head zlist; + ksock_tx_t *tx; list_add(&zlist, &ksocknal_data.ksnd_idle_noop_txs); list_del_init(&ksocknal_data.ksnd_idle_noop_txs); @@ -2248,9 +2248,9 @@ static void ksocknal_base_shutdown(void) { struct ksock_sched_info *info; - ksock_sched_t *sched; - int i; - int j; + ksock_sched_t *sched; + int i; + int j; CDEBUG(D_MALLOC, "before NAL cleanup: kmem %d\n", atomic_read(&libcfs_kmemory)); @@ -2351,8 +2351,8 @@ static int ksocknal_base_startup(void) { struct ksock_sched_info *info; - int rc; - int i; + int rc; + int i; LASSERT(ksocknal_data.ksnd_init == SOCKNAL_INIT_NOTHING); LASSERT(ksocknal_data.ksnd_nnets == 0); @@ -2398,8 +2398,8 @@ ksocknal_base_startup(void) goto failed; cfs_percpt_for_each(info, i, ksocknal_data.ksnd_sched_info) { - ksock_sched_t *sched; - int nthrs; + ksock_sched_t *sched; + int nthrs; nthrs = cfs_cpt_weight(lnet_cpt_table(), i); if (*ksocknal_tunables.ksnd_nscheds > 0) { @@ -2430,9 +2430,9 @@ ksocknal_base_startup(void) } } - ksocknal_data.ksnd_connd_starting = 0; - ksocknal_data.ksnd_connd_failed_stamp = 0; - ksocknal_data.ksnd_connd_starting_stamp = get_seconds(); + ksocknal_data.ksnd_connd_starting = 0; + ksocknal_data.ksnd_connd_failed_stamp = 0; + ksocknal_data.ksnd_connd_starting_stamp = get_seconds(); /* must have at least 2 connds to remain responsive to accepts while * connecting */ if (*ksocknal_tunables.ksnd_nconnds < SOCKNAL_CONND_RESV + 1) @@ -2482,9 +2482,9 @@ ksocknal_base_startup(void) static void ksocknal_debug_peerhash(lnet_ni_t *ni) { - ksock_peer_t *peer = NULL; - struct list_head *tmp; - int i; + ksock_peer_t *peer = NULL; + struct list_head *tmp; + int i; read_lock(&ksocknal_data.ksnd_global_lock); @@ -2536,12 +2536,12 @@ ksocknal_debug_peerhash(lnet_ni_t *ni) void ksocknal_shutdown(lnet_ni_t *ni) { - ksock_net_t *net = ni->ni_data; - int i; + ksock_net_t *net = ni->ni_data; + int i; lnet_process_id_t anyid = {0}; - anyid.nid = LNET_NID_ANY; - anyid.pid = LNET_PID_ANY; + anyid.nid = LNET_NID_ANY; + anyid.pid = LNET_PID_ANY; LASSERT(ksocknal_data.ksnd_init == SOCKNAL_INIT_ALL); LASSERT(ksocknal_data.ksnd_nnets > 0); @@ -2588,11 +2588,11 @@ ksocknal_shutdown(lnet_ni_t *ni) static int ksocknal_enumerate_interfaces(ksock_net_t *net) { - char **names; - int i; - int j; - int rc; - int n; + char **names; + int i; + int j; + int rc; + int n; n = libcfs_ipif_enumerate(&names); if (n <= 0) { @@ -2601,9 +2601,9 @@ ksocknal_enumerate_interfaces(ksock_net_t *net) } for (i = j = 0; i < n; i++) { - int up; - __u32 ip; - __u32 mask; + int up; + __u32 ip; + __u32 mask; if (!strcmp(names[i], "lo")) /* skip the loopback IF */ continue; @@ -2645,15 +2645,15 @@ ksocknal_enumerate_interfaces(ksock_net_t *net) static int ksocknal_search_new_ipif(ksock_net_t *net) { - int new_ipif = 0; - int i; + int new_ipif = 0; + int i; for (i = 0; i < net->ksnn_ninterfaces; i++) { - char *ifnam = &net->ksnn_interfaces[i].ksni_name[0]; - char *colon = strchr(ifnam, ':'); - int found = 0; - ksock_net_t *tmp; - int j; + char *ifnam = &net->ksnn_interfaces[i].ksni_name[0]; + char *colon = strchr(ifnam, ':'); + int found = 0; + ksock_net_t *tmp; + int j; if (colon != NULL) /* ignore alias device */ *colon = 0; @@ -2687,9 +2687,9 @@ ksocknal_search_new_ipif(ksock_net_t *net) static int ksocknal_start_schedulers(struct ksock_sched_info *info) { - int nthrs; - int rc = 0; - int i; + int nthrs; + int rc = 0; + int i; if (info->ksi_nthreads == 0) { if (*ksocknal_tunables.ksnd_nscheds > 0) { @@ -2708,9 +2708,9 @@ ksocknal_start_schedulers(struct ksock_sched_info *info) } for (i = 0; i < nthrs; i++) { - long id; - char name[20]; - ksock_sched_t *sched; + long id; + char name[20]; + ksock_sched_t *sched; id = KSOCK_THREAD_ID(info->ksi_cpt, info->ksi_nthreads + i); sched = &info->ksi_scheds[KSOCK_THREAD_SID(id)]; snprintf(name, sizeof(name), "socknal_sd%02d_%02d", @@ -2733,14 +2733,14 @@ ksocknal_start_schedulers(struct ksock_sched_info *info) static int ksocknal_net_start_threads(ksock_net_t *net, __u32 *cpts, int ncpts) { - int newif = ksocknal_search_new_ipif(net); - int rc; - int i; + int newif = ksocknal_search_new_ipif(net); + int rc; + int i; LASSERT(ncpts > 0 && ncpts <= cfs_cpt_number(lnet_cpt_table())); for (i = 0; i < ncpts; i++) { - struct ksock_sched_info *info; + struct ksock_sched_info *info; int cpt = (cpts == NULL) ? i : cpts[i]; LASSERT(cpt < cfs_cpt_number(lnet_cpt_table())); @@ -2759,9 +2759,9 @@ ksocknal_net_start_threads(ksock_net_t *net, __u32 *cpts, int ncpts) int ksocknal_startup(lnet_ni_t *ni) { - ksock_net_t *net; - int rc; - int i; + ksock_net_t *net; + int rc; + int i; LASSERT(ni->ni_lnd == &the_ksocklnd); @@ -2791,7 +2791,7 @@ ksocknal_startup(lnet_ni_t *ni) net->ksnn_ninterfaces = 1; } else { for (i = 0; i < LNET_MAX_INTERFACES; i++) { - int up; + int up; if (ni->ni_interfaces[i] == NULL) break; @@ -2851,7 +2851,7 @@ ksocknal_module_fini(void) static int __init ksocknal_module_init(void) { - int rc; + int rc; /* check ksnr_connected/connecting field large enough */ CLASSERT(SOCKLND_CONN_NTYPES <= 4); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h index c54c9955164e..c34378c0220a 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h @@ -36,15 +36,15 @@ #include "../../../include/linux/lnet/socklnd.h" #include "../../../include/linux/lnet/lnet-sysctl.h" -#define SOCKNAL_PEER_HASH_SIZE 101 /* # peer lists */ -#define SOCKNAL_RESCHED 100 /* # scheduler loops before reschedule */ -#define SOCKNAL_INSANITY_RECONN 5000 /* connd is trying on reconn infinitely */ -#define SOCKNAL_ENOMEM_RETRY CFS_TICK /* jiffies between retries */ +#define SOCKNAL_PEER_HASH_SIZE 101 /* # peer lists */ +#define SOCKNAL_RESCHED 100 /* # scheduler loops before reschedule */ +#define SOCKNAL_INSANITY_RECONN 5000 /* connd is trying on reconn infinitely */ +#define SOCKNAL_ENOMEM_RETRY CFS_TICK /* jiffies between retries */ -#define SOCKNAL_SINGLE_FRAG_TX 0 /* disable multi-fragment sends */ -#define SOCKNAL_SINGLE_FRAG_RX 0 /* disable multi-fragment receives */ +#define SOCKNAL_SINGLE_FRAG_TX 0 /* disable multi-fragment sends */ +#define SOCKNAL_SINGLE_FRAG_RX 0 /* disable multi-fragment receives */ -#define SOCKNAL_VERSION_DEBUG 0 /* enable protocol version debugging */ +#define SOCKNAL_VERSION_DEBUG 0 /* enable protocol version debugging */ /* risk kmap deadlock on multi-frag I/O (backs off to single-frag if disabled). * no risk if we're not running on a CONFIG_HIGHMEM platform. */ @@ -58,33 +58,31 @@ struct ksock_sched_info; typedef struct /* per scheduler state */ { - spinlock_t kss_lock; /* serialise */ - struct list_head kss_rx_conns; /* conn waiting to be read */ - /* conn waiting to be written */ - struct list_head kss_tx_conns; - /* zombie noop tx list */ - struct list_head kss_zombie_noop_txs; - wait_queue_head_t kss_waitq; /* where scheduler sleeps */ - /* # connections assigned to this scheduler */ - int kss_nconns; - struct ksock_sched_info *kss_info; /* owner of it */ - struct page *kss_rx_scratch_pgs[LNET_MAX_IOV]; - struct kvec kss_scratch_iov[LNET_MAX_IOV]; + spinlock_t kss_lock; /* serialise */ + struct list_head kss_rx_conns; /* conn waiting to be read */ + struct list_head kss_tx_conns; /* conn waiting to be written */ + struct list_head kss_zombie_noop_txs; /* zombie noop tx list */ + wait_queue_head_t kss_waitq; /* where scheduler sleeps */ + int kss_nconns; /* # connections assigned to + * this scheduler */ + struct ksock_sched_info *kss_info; /* owner of it */ + struct page *kss_rx_scratch_pgs[LNET_MAX_IOV]; + struct kvec kss_scratch_iov[LNET_MAX_IOV]; } ksock_sched_t; struct ksock_sched_info { - int ksi_nthreads_max; /* max allowed threads */ - int ksi_nthreads; /* number of threads */ - int ksi_cpt; /* CPT id */ - ksock_sched_t *ksi_scheds; /* array of schedulers */ + int ksi_nthreads_max; /* max allowed threads */ + int ksi_nthreads; /* number of threads */ + int ksi_cpt; /* CPT id */ + ksock_sched_t *ksi_scheds; /* array of schedulers */ }; -#define KSOCK_CPT_SHIFT 16 -#define KSOCK_THREAD_ID(cpt, sid) (((cpt) << KSOCK_CPT_SHIFT) | (sid)) -#define KSOCK_THREAD_CPT(id) ((id) >> KSOCK_CPT_SHIFT) -#define KSOCK_THREAD_SID(id) ((id) & ((1UL << KSOCK_CPT_SHIFT) - 1)) +#define KSOCK_CPT_SHIFT 16 +#define KSOCK_THREAD_ID(cpt, sid) (((cpt) << KSOCK_CPT_SHIFT) | (sid)) +#define KSOCK_THREAD_CPT(id) ((id) >> KSOCK_CPT_SHIFT) +#define KSOCK_THREAD_SID(id) ((id) & ((1UL << KSOCK_CPT_SHIFT) - 1)) -typedef struct /* in-use interface */ +typedef struct /* in-use interface */ { __u32 ksni_ipaddr; /* interface's IP address */ __u32 ksni_netmask; /* interface's network mask */ @@ -94,35 +92,48 @@ typedef struct /* in-use interface */ } ksock_interface_t; typedef struct { - /* "stuck" socket timeout (seconds) */ - int *ksnd_timeout; - /* # scheduler threads in each pool while starting */ - int *ksnd_nscheds; - int *ksnd_nconnds; /* # connection daemons */ - int *ksnd_nconnds_max; /* max # connection daemons */ - int *ksnd_min_reconnectms; /* first connection retry after (ms)... */ - int *ksnd_max_reconnectms; /* ...exponentially increasing to this */ - int *ksnd_eager_ack; /* make TCP ack eagerly? */ - int *ksnd_typed_conns; /* drive sockets by type? */ - int *ksnd_min_bulk; /* smallest "large" message */ - int *ksnd_tx_buffer_size; /* socket tx buffer size */ - int *ksnd_rx_buffer_size; /* socket rx buffer size */ - int *ksnd_nagle; /* enable NAGLE? */ - int *ksnd_round_robin; /* round robin for multiple interfaces */ - int *ksnd_keepalive; /* # secs for sending keepalive NOOP */ - int *ksnd_keepalive_idle; /* # idle secs before 1st probe */ - int *ksnd_keepalive_count; /* # probes */ - int *ksnd_keepalive_intvl; /* time between probes */ - int *ksnd_credits; /* # concurrent sends */ - int *ksnd_peertxcredits; /* # concurrent sends to 1 peer */ - int *ksnd_peerrtrcredits; /* # per-peer router buffer credits */ - int *ksnd_peertimeout; /* seconds to consider peer dead */ - int *ksnd_enable_csum; /* enable check sum */ - int *ksnd_inject_csum_error; /* set non-zero to inject checksum error */ - int *ksnd_nonblk_zcack; /* always send zc-ack on non-blocking connection */ - unsigned int *ksnd_zc_min_payload; /* minimum zero copy payload size */ - int *ksnd_zc_recv; /* enable ZC receive (for Chelsio TOE) */ - int *ksnd_zc_recv_min_nfrags; /* minimum # of fragments to enable ZC receive */ + int *ksnd_timeout; /* "stuck" socket timeout + * (seconds) */ + int *ksnd_nscheds; /* # scheduler threads in each + * pool while starting */ + int *ksnd_nconnds; /* # connection daemons */ + int *ksnd_nconnds_max; /* max # connection daemons */ + int *ksnd_min_reconnectms; /* first connection retry after + * (ms)... */ + int *ksnd_max_reconnectms; /* ...exponentially increasing to + * this */ + int *ksnd_eager_ack; /* make TCP ack eagerly? */ + int *ksnd_typed_conns; /* drive sockets by type? */ + int *ksnd_min_bulk; /* smallest "large" message */ + int *ksnd_tx_buffer_size; /* socket tx buffer size */ + int *ksnd_rx_buffer_size; /* socket rx buffer size */ + int *ksnd_nagle; /* enable NAGLE? */ + int *ksnd_round_robin; /* round robin for multiple + * interfaces */ + int *ksnd_keepalive; /* # secs for sending keepalive + * NOOP */ + int *ksnd_keepalive_idle; /* # idle secs before 1st probe + */ + int *ksnd_keepalive_count; /* # probes */ + int *ksnd_keepalive_intvl; /* time between probes */ + int *ksnd_credits; /* # concurrent sends */ + int *ksnd_peertxcredits; /* # concurrent sends to 1 peer + */ + int *ksnd_peerrtrcredits; /* # per-peer router buffer + * credits */ + int *ksnd_peertimeout; /* seconds to consider peer dead + */ + int *ksnd_enable_csum; /* enable check sum */ + int *ksnd_inject_csum_error; /* set non-zero to inject + * checksum error */ + int *ksnd_nonblk_zcack; /* always send zc-ack on + * non-blocking connection */ + unsigned int *ksnd_zc_min_payload; /* minimum zero copy payload + * size */ + int *ksnd_zc_recv; /* enable ZC receive (for + * Chelsio TOE) */ + int *ksnd_zc_recv_min_nfrags; /* minimum # of fragments to + * enable ZC receive */ } ksock_tunables_t; typedef struct { @@ -141,55 +152,67 @@ typedef struct { #define SOCKNAL_CONND_RESV 1 typedef struct { - int ksnd_init; /* initialisation state */ - int ksnd_nnets; /* # networks set up */ - struct list_head ksnd_nets; /* list of nets */ - /* stabilize peer/conn ops */ - rwlock_t ksnd_global_lock; - /* hash table of all my known peers */ - struct list_head *ksnd_peers; - int ksnd_peer_hash_size; /* size of ksnd_peers */ + int ksnd_init; /* initialisation state + */ + int ksnd_nnets; /* # networks set up */ + struct list_head ksnd_nets; /* list of nets */ + rwlock_t ksnd_global_lock; /* stabilize peer/conn + * ops */ + struct list_head *ksnd_peers; /* hash table of all my + * known peers */ + int ksnd_peer_hash_size; /* size of ksnd_peers */ - int ksnd_nthreads; /* # live threads */ - int ksnd_shuttingdown; /* tell threads to exit */ - /* schedulers information */ - struct ksock_sched_info **ksnd_sched_info; + int ksnd_nthreads; /* # live threads */ + int ksnd_shuttingdown; /* tell threads to exit + */ + struct ksock_sched_info **ksnd_sched_info; /* schedulers info */ - atomic_t ksnd_nactive_txs; /* #active txs */ + atomic_t ksnd_nactive_txs; /* #active txs */ - struct list_head ksnd_deathrow_conns; /* conns to close: reaper_lock*/ - struct list_head ksnd_zombie_conns; /* conns to free: reaper_lock */ - struct list_head ksnd_enomem_conns; /* conns to retry: reaper_lock*/ - wait_queue_head_t ksnd_reaper_waitq; /* reaper sleeps here */ - unsigned long ksnd_reaper_waketime;/* when reaper will wake */ - spinlock_t ksnd_reaper_lock; /* serialise */ + struct list_head ksnd_deathrow_conns; /* conns to close: + * reaper_lock*/ + struct list_head ksnd_zombie_conns; /* conns to free: + * reaper_lock */ + struct list_head ksnd_enomem_conns; /* conns to retry: + * reaper_lock*/ + wait_queue_head_t ksnd_reaper_waitq; /* reaper sleeps here */ + unsigned long ksnd_reaper_waketime; /* when reaper will wake + */ + spinlock_t ksnd_reaper_lock; /* serialise */ - int ksnd_enomem_tx; /* test ENOMEM sender */ - int ksnd_stall_tx; /* test sluggish sender */ - int ksnd_stall_rx; /* test sluggish receiver */ + int ksnd_enomem_tx; /* test ENOMEM sender */ + int ksnd_stall_tx; /* test sluggish sender + */ + int ksnd_stall_rx; /* test sluggish + * receiver */ - struct list_head ksnd_connd_connreqs; /* incoming connection requests */ - struct list_head ksnd_connd_routes; /* routes waiting to be connected */ - wait_queue_head_t ksnd_connd_waitq; /* connds sleep here */ - int ksnd_connd_connecting;/* # connds connecting */ - /** time stamp of the last failed connecting attempt */ - long ksnd_connd_failed_stamp; - /** # starting connd */ - unsigned ksnd_connd_starting; - /** time stamp of the last starting connd */ - long ksnd_connd_starting_stamp; - /** # running connd */ - unsigned ksnd_connd_running; - spinlock_t ksnd_connd_lock; /* serialise */ + struct list_head ksnd_connd_connreqs; /* incoming connection + * requests */ + struct list_head ksnd_connd_routes; /* routes waiting to be + * connected */ + wait_queue_head_t ksnd_connd_waitq; /* connds sleep here */ + int ksnd_connd_connecting; /* # connds connecting + */ + long ksnd_connd_failed_stamp;/* time stamp of the + * last failed + * connecting attempt */ + unsigned ksnd_connd_starting; /* # starting connd */ + long ksnd_connd_starting_stamp;/* time stamp of the + * last starting connd + */ + unsigned ksnd_connd_running; /* # running connd */ + spinlock_t ksnd_connd_lock; /* serialise */ - struct list_head ksnd_idle_noop_txs; /* list head for freed noop tx */ - spinlock_t ksnd_tx_lock; /* serialise, g_lock unsafe */ + struct list_head ksnd_idle_noop_txs; /* list head for freed + * noop tx */ + spinlock_t ksnd_tx_lock; /* serialise, g_lock + * unsafe */ } ksock_nal_data_t; -#define SOCKNAL_INIT_NOTHING 0 -#define SOCKNAL_INIT_DATA 1 -#define SOCKNAL_INIT_ALL 2 +#define SOCKNAL_INIT_NOTHING 0 +#define SOCKNAL_INIT_DATA 1 +#define SOCKNAL_INIT_ALL 2 /* A packet just assembled for transmission is represented by 1 or more * struct iovec fragments (the first frag contains the portals header), @@ -200,43 +223,45 @@ typedef struct { * received into either struct iovec or lnet_kiov_t fragments, depending on * what the header matched or whether the message needs forwarding. */ -struct ksock_conn; /* forward ref */ -struct ksock_peer; /* forward ref */ -struct ksock_route; /* forward ref */ -struct ksock_proto; /* forward ref */ +struct ksock_conn; /* forward ref */ +struct ksock_peer; /* forward ref */ +struct ksock_route; /* forward ref */ +struct ksock_proto; /* forward ref */ -typedef struct /* transmit packet */ +typedef struct /* transmit packet */ { - struct list_head tx_list; /* queue on conn for transmission etc */ - struct list_head tx_zc_list; /* queue on peer for ZC request */ - atomic_t tx_refcount; /* tx reference count */ - int tx_nob; /* # packet bytes */ - int tx_resid; /* residual bytes */ - int tx_niov; /* # packet iovec frags */ - struct kvec *tx_iov; /* packet iovec frags */ - int tx_nkiov; /* # packet page frags */ - unsigned short tx_zc_aborted; /* aborted ZC request */ - unsigned short tx_zc_capable:1; /* payload is large enough for ZC */ - unsigned short tx_zc_checked:1; /* Have I checked if I should ZC? */ - unsigned short tx_nonblk:1; /* it's a non-blocking ACK */ - lnet_kiov_t *tx_kiov; /* packet page frags */ - struct ksock_conn *tx_conn; /* owning conn */ - lnet_msg_t *tx_lnetmsg; /* lnet message for lnet_finalize() */ - unsigned long tx_deadline; /* when (in jiffies) tx times out */ - ksock_msg_t tx_msg; /* socklnd message buffer */ - int tx_desc_size; /* size of this descriptor */ + struct list_head tx_list; /* queue on conn for transmission etc + */ + struct list_head tx_zc_list; /* queue on peer for ZC request */ + atomic_t tx_refcount; /* tx reference count */ + int tx_nob; /* # packet bytes */ + int tx_resid; /* residual bytes */ + int tx_niov; /* # packet iovec frags */ + struct kvec *tx_iov; /* packet iovec frags */ + int tx_nkiov; /* # packet page frags */ + unsigned short tx_zc_aborted; /* aborted ZC request */ + unsigned short tx_zc_capable:1; /* payload is large enough for ZC */ + unsigned short tx_zc_checked:1; /* Have I checked if I should ZC? */ + unsigned short tx_nonblk:1; /* it's a non-blocking ACK */ + lnet_kiov_t *tx_kiov; /* packet page frags */ + struct ksock_conn *tx_conn; /* owning conn */ + lnet_msg_t *tx_lnetmsg; /* lnet message for lnet_finalize() + */ + unsigned long tx_deadline; /* when (in jiffies) tx times out */ + ksock_msg_t tx_msg; /* socklnd message buffer */ + int tx_desc_size; /* size of this descriptor */ union { struct { - struct kvec iov; /* virt hdr */ - lnet_kiov_t kiov[0]; /* paged payload */ - } paged; + struct kvec iov; /* virt hdr */ + lnet_kiov_t kiov[0]; /* paged payload */ + } paged; struct { - struct kvec iov[1]; /* virt hdr + payload */ - } virt; - } tx_frags; + struct kvec iov[1]; /* virt hdr + payload */ + } virt; + } tx_frags; } ksock_tx_t; -#define KSOCK_NOOP_TX_SIZE ((int)offsetof(ksock_tx_t, tx_frags.paged.kiov[0])) +#define KSOCK_NOOP_TX_SIZE ((int)offsetof(ksock_tx_t, tx_frags.paged.kiov[0])) /* network zero copy callback descriptor embedded in ksock_tx_t */ @@ -247,148 +272,189 @@ typedef union { lnet_kiov_t kiov[LNET_MAX_IOV]; } ksock_rxiovspace_t; -#define SOCKNAL_RX_KSM_HEADER 1 /* reading ksock message header */ -#define SOCKNAL_RX_LNET_HEADER 2 /* reading lnet message header */ -#define SOCKNAL_RX_PARSE 3 /* Calling lnet_parse() */ -#define SOCKNAL_RX_PARSE_WAIT 4 /* waiting to be told to read the body */ -#define SOCKNAL_RX_LNET_PAYLOAD 5 /* reading lnet payload (to deliver here) */ -#define SOCKNAL_RX_SLOP 6 /* skipping body */ +#define SOCKNAL_RX_KSM_HEADER 1 /* reading ksock message header */ +#define SOCKNAL_RX_LNET_HEADER 2 /* reading lnet message header */ +#define SOCKNAL_RX_PARSE 3 /* Calling lnet_parse() */ +#define SOCKNAL_RX_PARSE_WAIT 4 /* waiting to be told to read the body */ +#define SOCKNAL_RX_LNET_PAYLOAD 5 /* reading lnet payload (to deliver here) */ +#define SOCKNAL_RX_SLOP 6 /* skipping body */ typedef struct ksock_conn { - struct ksock_peer *ksnc_peer; /* owning peer */ - struct ksock_route *ksnc_route; /* owning route */ - struct list_head ksnc_list; /* stash on peer's conn list */ - struct socket *ksnc_sock; /* actual socket */ - void *ksnc_saved_data_ready; /* socket's original data_ready() callback */ - void *ksnc_saved_write_space; /* socket's original write_space() callback */ - atomic_t ksnc_conn_refcount; /* conn refcount */ - atomic_t ksnc_sock_refcount; /* sock refcount */ - ksock_sched_t *ksnc_scheduler; /* who schedules this connection */ - __u32 ksnc_myipaddr; /* my IP */ - __u32 ksnc_ipaddr; /* peer's IP */ - int ksnc_port; /* peer's port */ - signed int ksnc_type:3; /* type of connection, - * should be signed value */ - unsigned int ksnc_closing:1; /* being shut down */ - unsigned int ksnc_flip:1; /* flip or not, only for V2.x */ - unsigned int ksnc_zc_capable:1; /* enable to ZC */ - struct ksock_proto *ksnc_proto; /* protocol for the connection */ + struct ksock_peer *ksnc_peer; /* owning peer */ + struct ksock_route *ksnc_route; /* owning route */ + struct list_head ksnc_list; /* stash on peer's conn list */ + struct socket *ksnc_sock; /* actual socket */ + void *ksnc_saved_data_ready; /* socket's original + * data_ready() callback */ + void *ksnc_saved_write_space; /* socket's original + * write_space() callback */ + atomic_t ksnc_conn_refcount;/* conn refcount */ + atomic_t ksnc_sock_refcount;/* sock refcount */ + ksock_sched_t *ksnc_scheduler; /* who schedules this connection + */ + __u32 ksnc_myipaddr; /* my IP */ + __u32 ksnc_ipaddr; /* peer's IP */ + int ksnc_port; /* peer's port */ + signed int ksnc_type:3; /* type of connection, should be + * signed value */ + unsigned int ksnc_closing:1; /* being shut down */ + unsigned int ksnc_flip:1; /* flip or not, only for V2.x */ + unsigned int ksnc_zc_capable:1; /* enable to ZC */ + struct ksock_proto *ksnc_proto; /* protocol for the connection */ /* reader */ - struct list_head ksnc_rx_list; /* where I enq waiting input or a forwarding descriptor */ - unsigned long ksnc_rx_deadline; /* when (in jiffies) receive times out */ - __u8 ksnc_rx_started; /* started receiving a message */ - __u8 ksnc_rx_ready; /* data ready to read */ - __u8 ksnc_rx_scheduled;/* being progressed */ - __u8 ksnc_rx_state; /* what is being read */ - int ksnc_rx_nob_left; /* # bytes to next hdr/body */ - int ksnc_rx_nob_wanted; /* bytes actually wanted */ - int ksnc_rx_niov; /* # iovec frags */ - struct kvec *ksnc_rx_iov; /* the iovec frags */ - int ksnc_rx_nkiov; /* # page frags */ - lnet_kiov_t *ksnc_rx_kiov; /* the page frags */ - ksock_rxiovspace_t ksnc_rx_iov_space;/* space for frag descriptors */ - __u32 ksnc_rx_csum; /* partial checksum for incoming data */ - void *ksnc_cookie; /* rx lnet_finalize passthru arg */ - ksock_msg_t ksnc_msg; /* incoming message buffer: - * V2.x message takes the - * whole struct - * V1.x message is a bare - * lnet_hdr_t, it's stored in - * ksnc_msg.ksm_u.lnetmsg */ + struct list_head ksnc_rx_list; /* where I enq waiting input or a + * forwarding descriptor */ + unsigned long ksnc_rx_deadline; /* when (in jiffies) receive times + * out */ + __u8 ksnc_rx_started; /* started receiving a message */ + __u8 ksnc_rx_ready; /* data ready to read */ + __u8 ksnc_rx_scheduled; /* being progressed */ + __u8 ksnc_rx_state; /* what is being read */ + int ksnc_rx_nob_left; /* # bytes to next hdr/body */ + int ksnc_rx_nob_wanted;/* bytes actually wanted */ + int ksnc_rx_niov; /* # iovec frags */ + struct kvec *ksnc_rx_iov; /* the iovec frags */ + int ksnc_rx_nkiov; /* # page frags */ + lnet_kiov_t *ksnc_rx_kiov; /* the page frags */ + ksock_rxiovspace_t ksnc_rx_iov_space; /* space for frag descriptors */ + __u32 ksnc_rx_csum; /* partial checksum for incoming + * data */ + void *ksnc_cookie; /* rx lnet_finalize passthru arg + */ + ksock_msg_t ksnc_msg; /* incoming message buffer: + * V2.x message takes the + * whole struct + * V1.x message is a bare + * lnet_hdr_t, it's stored in + * ksnc_msg.ksm_u.lnetmsg */ /* WRITER */ - struct list_head ksnc_tx_list; /* where I enq waiting for output space */ - struct list_head ksnc_tx_queue; /* packets waiting to be sent */ - ksock_tx_t *ksnc_tx_carrier; /* next TX that can carry a LNet message or ZC-ACK */ - unsigned long ksnc_tx_deadline; /* when (in jiffies) tx times out */ - int ksnc_tx_bufnob; /* send buffer marker */ - atomic_t ksnc_tx_nob; /* # bytes queued */ - int ksnc_tx_ready; /* write space */ - int ksnc_tx_scheduled; /* being progressed */ - unsigned long ksnc_tx_last_post; /* time stamp of the last posted TX */ + struct list_head ksnc_tx_list; /* where I enq waiting for output + * space */ + struct list_head ksnc_tx_queue; /* packets waiting to be sent */ + ksock_tx_t *ksnc_tx_carrier; /* next TX that can carry a LNet + * message or ZC-ACK */ + unsigned long ksnc_tx_deadline; /* when (in jiffies) tx times out + */ + int ksnc_tx_bufnob; /* send buffer marker */ + atomic_t ksnc_tx_nob; /* # bytes queued */ + int ksnc_tx_ready; /* write space */ + int ksnc_tx_scheduled; /* being progressed */ + unsigned long ksnc_tx_last_post; /* time stamp of the last posted + * TX */ } ksock_conn_t; typedef struct ksock_route { - struct list_head ksnr_list; /* chain on peer route list */ - struct list_head ksnr_connd_list; /* chain on ksnr_connd_routes */ - struct ksock_peer *ksnr_peer; /* owning peer */ - atomic_t ksnr_refcount; /* # users */ - unsigned long ksnr_timeout; /* when (in jiffies) reconnection can happen next */ - long ksnr_retry_interval; /* how long between retries */ - __u32 ksnr_myipaddr; /* my IP */ - __u32 ksnr_ipaddr; /* IP address to connect to */ - int ksnr_port; /* port to connect to */ - unsigned int ksnr_scheduled:1; /* scheduled for attention */ - unsigned int ksnr_connecting:1;/* connection establishment in progress */ - unsigned int ksnr_connected:4; /* connections established by type */ - unsigned int ksnr_deleted:1; /* been removed from peer? */ - unsigned int ksnr_share_count; /* created explicitly? */ - int ksnr_conn_count; /* # conns established by this route */ + struct list_head ksnr_list; /* chain on peer route list */ + struct list_head ksnr_connd_list; /* chain on ksnr_connd_routes */ + struct ksock_peer *ksnr_peer; /* owning peer */ + atomic_t ksnr_refcount; /* # users */ + unsigned long ksnr_timeout; /* when (in jiffies) reconnection + * can happen next */ + long ksnr_retry_interval; /* how long between retries */ + __u32 ksnr_myipaddr; /* my IP */ + __u32 ksnr_ipaddr; /* IP address to connect to */ + int ksnr_port; /* port to connect to */ + unsigned int ksnr_scheduled:1; /* scheduled for attention */ + unsigned int ksnr_connecting:1; /* connection establishment in + * progress */ + unsigned int ksnr_connected:4; /* connections established by + * type */ + unsigned int ksnr_deleted:1; /* been removed from peer? */ + unsigned int ksnr_share_count; /* created explicitly? */ + int ksnr_conn_count; /* # conns established by this + * route */ } ksock_route_t; -#define SOCKNAL_KEEPALIVE_PING 1 /* cookie for keepalive ping */ +#define SOCKNAL_KEEPALIVE_PING 1 /* cookie for keepalive ping */ typedef struct ksock_peer { - struct list_head ksnp_list; /* stash on global peer list */ - unsigned long ksnp_last_alive; /* when (in jiffies) I was last alive */ - lnet_process_id_t ksnp_id; /* who's on the other end(s) */ - atomic_t ksnp_refcount; /* # users */ - int ksnp_sharecount; /* lconf usage counter */ - int ksnp_closing; /* being closed */ - int ksnp_accepting;/* # passive connections pending */ - int ksnp_error; /* errno on closing last conn */ - __u64 ksnp_zc_next_cookie;/* ZC completion cookie */ - __u64 ksnp_incarnation; /* latest known peer incarnation */ - struct ksock_proto *ksnp_proto; /* latest known peer protocol */ - struct list_head ksnp_conns; /* all active connections */ - struct list_head ksnp_routes; /* routes */ - struct list_head ksnp_tx_queue; /* waiting packets */ - spinlock_t ksnp_lock; /* serialize, g_lock unsafe */ - struct list_head ksnp_zc_req_list; /* zero copy requests wait for ACK */ - unsigned long ksnp_send_keepalive; /* time to send keepalive */ - lnet_ni_t *ksnp_ni; /* which network */ - int ksnp_n_passive_ips; /* # of... */ - __u32 ksnp_passive_ips[LNET_MAX_INTERFACES]; /* preferred local interfaces */ + struct list_head ksnp_list; /* stash on global peer list */ + unsigned long ksnp_last_alive; /* when (in jiffies) I was last + * alive */ + lnet_process_id_t ksnp_id; /* who's on the other end(s) */ + atomic_t ksnp_refcount; /* # users */ + int ksnp_sharecount; /* lconf usage counter */ + int ksnp_closing; /* being closed */ + int ksnp_accepting; /* # passive connections pending + */ + int ksnp_error; /* errno on closing last conn */ + __u64 ksnp_zc_next_cookie; /* ZC completion cookie */ + __u64 ksnp_incarnation; /* latest known peer incarnation + */ + struct ksock_proto *ksnp_proto; /* latest known peer protocol */ + struct list_head ksnp_conns; /* all active connections */ + struct list_head ksnp_routes; /* routes */ + struct list_head ksnp_tx_queue; /* waiting packets */ + spinlock_t ksnp_lock; /* serialize, g_lock unsafe */ + struct list_head ksnp_zc_req_list; /* zero copy requests wait for + * ACK */ + unsigned long ksnp_send_keepalive; /* time to send keepalive */ + lnet_ni_t *ksnp_ni; /* which network */ + int ksnp_n_passive_ips; /* # of... */ + + /* preferred local interfaces */ + __u32 ksnp_passive_ips[LNET_MAX_INTERFACES]; } ksock_peer_t; typedef struct ksock_connreq { - struct list_head ksncr_list; /* stash on ksnd_connd_connreqs */ - lnet_ni_t *ksncr_ni; /* chosen NI */ - struct socket *ksncr_sock; /* accepted socket */ + struct list_head ksncr_list; /* stash on ksnd_connd_connreqs */ + lnet_ni_t *ksncr_ni; /* chosen NI */ + struct socket *ksncr_sock; /* accepted socket */ } ksock_connreq_t; extern ksock_nal_data_t ksocknal_data; extern ksock_tunables_t ksocknal_tunables; -#define SOCKNAL_MATCH_NO 0 /* TX can't match type of connection */ -#define SOCKNAL_MATCH_YES 1 /* TX matches type of connection */ -#define SOCKNAL_MATCH_MAY 2 /* TX can be sent on the connection, but not preferred */ +#define SOCKNAL_MATCH_NO 0 /* TX can't match type of connection */ +#define SOCKNAL_MATCH_YES 1 /* TX matches type of connection */ +#define SOCKNAL_MATCH_MAY 2 /* TX can be sent on the connection, but not + * preferred */ typedef struct ksock_proto { - int pro_version; /* version number of protocol */ - int (*pro_send_hello)(ksock_conn_t *, ksock_hello_msg_t *); /* handshake function */ - int (*pro_recv_hello)(ksock_conn_t *, ksock_hello_msg_t *, int);/* handshake function */ - void (*pro_pack)(ksock_tx_t *); /* message pack */ - void (*pro_unpack)(ksock_msg_t *); /* message unpack */ - ksock_tx_t *(*pro_queue_tx_msg)(ksock_conn_t *, ksock_tx_t *); /* queue tx on the connection */ - int (*pro_queue_tx_zcack)(ksock_conn_t *, ksock_tx_t *, __u64); /* queue ZC ack on the connection */ - int (*pro_handle_zcreq)(ksock_conn_t *, __u64, int); /* handle ZC request */ - int (*pro_handle_zcack)(ksock_conn_t *, __u64, __u64); /* handle ZC ACK */ - int (*pro_match_tx)(ksock_conn_t *, ksock_tx_t *, int); /* msg type matches the connection type: - * return value: - * return MATCH_NO : no - * return MATCH_YES : matching type - * return MATCH_MAY : can be backup */ + /* version number of protocol */ + int pro_version; + + /* handshake function */ + int (*pro_send_hello)(ksock_conn_t *, ksock_hello_msg_t *); + + /* handshake function */ + int (*pro_recv_hello)(ksock_conn_t *, ksock_hello_msg_t *, int); + + /* message pack */ + void (*pro_pack)(ksock_tx_t *); + + /* message unpack */ + void (*pro_unpack)(ksock_msg_t *); + + /* queue tx on the connection */ + ksock_tx_t *(*pro_queue_tx_msg)(ksock_conn_t *, ksock_tx_t *); + + /* queue ZC ack on the connection */ + int (*pro_queue_tx_zcack)(ksock_conn_t *, ksock_tx_t *, __u64); + + /* handle ZC request */ + int (*pro_handle_zcreq)(ksock_conn_t *, __u64, int); + + /* handle ZC ACK */ + int (*pro_handle_zcack)(ksock_conn_t *, __u64, __u64); + + /* msg type matches the connection type: + * return value: + * return MATCH_NO : no + * return MATCH_YES : matching type + * return MATCH_MAY : can be backup */ + int (*pro_match_tx)(ksock_conn_t *, ksock_tx_t *, int); } ksock_proto_t; extern ksock_proto_t ksocknal_protocol_v1x; extern ksock_proto_t ksocknal_protocol_v2x; extern ksock_proto_t ksocknal_protocol_v3x; -#define KSOCK_PROTO_V1_MAJOR LNET_PROTO_TCP_VERSION_MAJOR -#define KSOCK_PROTO_V1_MINOR LNET_PROTO_TCP_VERSION_MINOR -#define KSOCK_PROTO_V1 KSOCK_PROTO_V1_MAJOR +#define KSOCK_PROTO_V1_MAJOR LNET_PROTO_TCP_VERSION_MAJOR +#define KSOCK_PROTO_V1_MINOR LNET_PROTO_TCP_VERSION_MINOR +#define KSOCK_PROTO_V1 KSOCK_PROTO_V1_MAJOR #ifndef CPU_MASK_NONE #define CPU_MASK_NONE 0UL @@ -434,7 +500,7 @@ ksocknal_conn_decref(ksock_conn_t *conn) static inline int ksocknal_connsock_addref(ksock_conn_t *conn) { - int rc = -ESHUTDOWN; + int rc = -ESHUTDOWN; read_lock(&ksocknal_data.ksnd_global_lock); if (!conn->ksnc_closing) { diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index fa7ad883bda9..a1a4ac027fb5 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -75,13 +75,13 @@ ksocknal_alloc_tx_noop(__u64 cookie, int nonblk) return NULL; } - tx->tx_conn = NULL; - tx->tx_lnetmsg = NULL; - tx->tx_kiov = NULL; - tx->tx_nkiov = 0; - tx->tx_iov = tx->tx_frags.virt.iov; - tx->tx_niov = 1; - tx->tx_nonblk = nonblk; + tx->tx_conn = NULL; + tx->tx_lnetmsg = NULL; + tx->tx_kiov = NULL; + tx->tx_nkiov = 0; + tx->tx_iov = tx->tx_frags.virt.iov; + tx->tx_niov = 1; + tx->tx_nonblk = nonblk; socklnd_init_msg(&tx->tx_msg, KSOCK_MSG_NOOP); tx->tx_msg.ksm_zc_cookies[1] = cookie; @@ -110,11 +110,11 @@ ksocknal_free_tx (ksock_tx_t *tx) static int ksocknal_send_iov (ksock_conn_t *conn, ksock_tx_t *tx) { - struct kvec *iov = tx->tx_iov; - int nob; - int rc; + struct kvec *iov = tx->tx_iov; + int nob; + int rc; - LASSERT (tx->tx_niov > 0); + LASSERT(tx->tx_niov > 0); /* Never touch tx->tx_iov inside ksocknal_lib_send_iov() */ rc = ksocknal_lib_send_iov(conn, tx); @@ -128,7 +128,7 @@ ksocknal_send_iov (ksock_conn_t *conn, ksock_tx_t *tx) /* "consume" iov */ do { - LASSERT (tx->tx_niov > 0); + LASSERT(tx->tx_niov > 0); if (nob < (int) iov->iov_len) { iov->iov_base = (void *)((char *)iov->iov_base + nob); @@ -147,12 +147,12 @@ ksocknal_send_iov (ksock_conn_t *conn, ksock_tx_t *tx) static int ksocknal_send_kiov (ksock_conn_t *conn, ksock_tx_t *tx) { - lnet_kiov_t *kiov = tx->tx_kiov; - int nob; - int rc; + lnet_kiov_t *kiov = tx->tx_kiov; + int nob; + int rc; - LASSERT (tx->tx_niov == 0); - LASSERT (tx->tx_nkiov > 0); + LASSERT(tx->tx_niov == 0); + LASSERT(tx->tx_nkiov > 0); /* Never touch tx->tx_kiov inside ksocknal_lib_send_kiov() */ rc = ksocknal_lib_send_kiov(conn, tx); @@ -185,15 +185,15 @@ ksocknal_send_kiov (ksock_conn_t *conn, ksock_tx_t *tx) static int ksocknal_transmit (ksock_conn_t *conn, ksock_tx_t *tx) { - int rc; - int bufnob; + int rc; + int bufnob; if (ksocknal_data.ksnd_stall_tx != 0) { set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout(cfs_time_seconds(ksocknal_data.ksnd_stall_tx)); } - LASSERT (tx->tx_resid != 0); + LASSERT(tx->tx_resid != 0); rc = ksocknal_connsock_addref(conn); if (rc != 0) { @@ -252,10 +252,10 @@ static int ksocknal_recv_iov (ksock_conn_t *conn) { struct kvec *iov = conn->ksnc_rx_iov; - int nob; - int rc; + int nob; + int rc; - LASSERT (conn->ksnc_rx_niov > 0); + LASSERT(conn->ksnc_rx_niov > 0); /* Never touch conn->ksnc_rx_iov or change connection * status inside ksocknal_lib_recv_iov */ @@ -277,7 +277,7 @@ ksocknal_recv_iov (ksock_conn_t *conn) conn->ksnc_rx_nob_left -= nob; do { - LASSERT (conn->ksnc_rx_niov > 0); + LASSERT(conn->ksnc_rx_niov > 0); if (nob < (int)iov->iov_len) { iov->iov_len -= nob; @@ -296,10 +296,10 @@ ksocknal_recv_iov (ksock_conn_t *conn) static int ksocknal_recv_kiov (ksock_conn_t *conn) { - lnet_kiov_t *kiov = conn->ksnc_rx_kiov; - int nob; - int rc; - LASSERT (conn->ksnc_rx_nkiov > 0); + lnet_kiov_t *kiov = conn->ksnc_rx_kiov; + int nob; + int rc; + LASSERT(conn->ksnc_rx_nkiov > 0); /* Never touch conn->ksnc_rx_kiov or change connection * status inside ksocknal_lib_recv_iov */ @@ -321,7 +321,7 @@ ksocknal_recv_kiov (ksock_conn_t *conn) conn->ksnc_rx_nob_left -= nob; do { - LASSERT (conn->ksnc_rx_nkiov > 0); + LASSERT(conn->ksnc_rx_nkiov > 0); if (nob < (int) kiov->kiov_len) { kiov->kiov_offset += nob; @@ -343,7 +343,7 @@ ksocknal_receive (ksock_conn_t *conn) /* Return 1 on success, 0 on EOF, < 0 on error. * Caller checks ksnc_rx_nob_wanted to determine * progress/completion. */ - int rc; + int rc; if (ksocknal_data.ksnd_stall_rx != 0) { set_current_state(TASK_UNINTERRUPTIBLE); @@ -388,8 +388,8 @@ ksocknal_receive (ksock_conn_t *conn) void ksocknal_tx_done (lnet_ni_t *ni, ksock_tx_t *tx) { - lnet_msg_t *lnetmsg = tx->tx_lnetmsg; - int rc = (tx->tx_resid == 0 && !tx->tx_zc_aborted) ? 0 : -EIO; + lnet_msg_t *lnetmsg = tx->tx_lnetmsg; + int rc = (tx->tx_resid == 0 && !tx->tx_zc_aborted) ? 0 : -EIO; LASSERT(ni != NULL || tx->tx_conn != NULL); @@ -410,7 +410,7 @@ ksocknal_txlist_done (lnet_ni_t *ni, struct list_head *txlist, int error) ksock_tx_t *tx; while (!list_empty (txlist)) { - tx = list_entry (txlist->next, ksock_tx_t, tx_list); + tx = list_entry(txlist->next, ksock_tx_t, tx_list); if (error && tx->tx_lnetmsg != NULL) { CNETERR("Deleting packet type %d len %d %s->%s\n", @@ -422,18 +422,18 @@ ksocknal_txlist_done (lnet_ni_t *ni, struct list_head *txlist, int error) CNETERR("Deleting noop packet\n"); } - list_del (&tx->tx_list); + list_del(&tx->tx_list); - LASSERT (atomic_read(&tx->tx_refcount) == 1); - ksocknal_tx_done (ni, tx); + LASSERT(atomic_read(&tx->tx_refcount) == 1); + ksocknal_tx_done(ni, tx); } } static void ksocknal_check_zc_req(ksock_tx_t *tx) { - ksock_conn_t *conn = tx->tx_conn; - ksock_peer_t *peer = conn->ksnc_peer; + ksock_conn_t *conn = tx->tx_conn; + ksock_peer_t *peer = conn->ksnc_peer; /* Set tx_msg.ksm_zc_cookies[0] to a unique non-zero cookie and add tx * to ksnp_zc_req_list if some fragment of this message should be sent @@ -441,8 +441,8 @@ ksocknal_check_zc_req(ksock_tx_t *tx) * she has received this message to tell us we can signal completion. * tx_msg.ksm_zc_cookies[0] remains non-zero while tx is on * ksnp_zc_req_list. */ - LASSERT (tx->tx_msg.ksm_type != KSOCK_MSG_NOOP); - LASSERT (tx->tx_zc_capable); + LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP); + LASSERT(tx->tx_zc_capable); tx->tx_zc_checked = 1; @@ -461,7 +461,7 @@ ksocknal_check_zc_req(ksock_tx_t *tx) tx->tx_deadline = cfs_time_shift(*ksocknal_tunables.ksnd_timeout); - LASSERT (tx->tx_msg.ksm_zc_cookies[0] == 0); + LASSERT(tx->tx_msg.ksm_zc_cookies[0] == 0); tx->tx_msg.ksm_zc_cookies[0] = peer->ksnp_zc_next_cookie++; @@ -476,7 +476,7 @@ ksocknal_check_zc_req(ksock_tx_t *tx) static void ksocknal_uncheck_zc_req(ksock_tx_t *tx) { - ksock_peer_t *peer = tx->tx_conn->ksnc_peer; + ksock_peer_t *peer = tx->tx_conn->ksnc_peer; LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP); LASSERT(tx->tx_zc_capable); @@ -502,14 +502,14 @@ ksocknal_uncheck_zc_req(ksock_tx_t *tx) static int ksocknal_process_transmit (ksock_conn_t *conn, ksock_tx_t *tx) { - int rc; + int rc; if (tx->tx_zc_capable && !tx->tx_zc_checked) ksocknal_check_zc_req(tx); rc = ksocknal_transmit (conn, tx); - CDEBUG (D_NET, "send(%d) %d\n", tx->tx_resid, rc); + CDEBUG(D_NET, "send(%d) %d\n", tx->tx_resid, rc); if (tx->tx_resid == 0) { /* Sent everything OK */ @@ -546,7 +546,7 @@ ksocknal_process_transmit (ksock_conn_t *conn, ksock_tx_t *tx) } /* Actual error */ - LASSERT (rc < 0); + LASSERT(rc < 0); if (!conn->ksnc_closing) { switch (rc) { @@ -582,9 +582,9 @@ ksocknal_launch_connection_locked (ksock_route_t *route) /* called holding write lock on ksnd_global_lock */ - LASSERT (!route->ksnr_scheduled); - LASSERT (!route->ksnr_connecting); - LASSERT ((ksocknal_route_mask() & ~route->ksnr_connected) != 0); + LASSERT(!route->ksnr_scheduled); + LASSERT(!route->ksnr_connecting); + LASSERT((ksocknal_route_mask() & ~route->ksnr_connected) != 0); route->ksnr_scheduled = 1; /* scheduling conn for connd */ ksocknal_route_addref(route); /* extra ref for connd */ @@ -617,22 +617,22 @@ ksocknal_launch_all_connections_locked (ksock_peer_t *peer) ksock_conn_t * ksocknal_find_conn_locked(ksock_peer_t *peer, ksock_tx_t *tx, int nonblk) { - struct list_head *tmp; - ksock_conn_t *conn; - ksock_conn_t *typed = NULL; - ksock_conn_t *fallback = NULL; - int tnob = 0; - int fnob = 0; + struct list_head *tmp; + ksock_conn_t *conn; + ksock_conn_t *typed = NULL; + ksock_conn_t *fallback = NULL; + int tnob = 0; + int fnob = 0; list_for_each (tmp, &peer->ksnp_conns) { ksock_conn_t *c = list_entry(tmp, ksock_conn_t, ksnc_list); - int nob = atomic_read(&c->ksnc_tx_nob) + - c->ksnc_sock->sk->sk_wmem_queued; - int rc; + int nob = atomic_read(&c->ksnc_tx_nob) + + c->ksnc_sock->sk->sk_wmem_queued; + int rc; - LASSERT (!c->ksnc_closing); - LASSERT (c->ksnc_proto != NULL && - c->ksnc_proto->pro_match_tx != NULL); + LASSERT(!c->ksnc_closing); + LASSERT(c->ksnc_proto != NULL && + c->ksnc_proto->pro_match_tx != NULL); rc = c->ksnc_proto->pro_match_tx(c, tx, nonblk); @@ -656,7 +656,7 @@ ksocknal_find_conn_locked(ksock_peer_t *peer, ksock_tx_t *tx, int nonblk) (fnob == nob && *ksocknal_tunables.ksnd_round_robin && cfs_time_after(fallback->ksnc_tx_last_post, c->ksnc_tx_last_post))) { fallback = c; - fnob = nob; + fnob = nob; } break; } @@ -685,9 +685,9 @@ void ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn) { ksock_sched_t *sched = conn->ksnc_scheduler; - ksock_msg_t *msg = &tx->tx_msg; - ksock_tx_t *ztx = NULL; - int bufnob = 0; + ksock_msg_t *msg = &tx->tx_msg; + ksock_tx_t *ztx = NULL; + int bufnob = 0; /* called holding global lock (read or irq-write) and caller may * not have dropped this lock between finding conn and calling me, @@ -708,11 +708,11 @@ ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn) * * We always expect at least 1 mapped fragment containing the * complete ksocknal message header. */ - LASSERT (lnet_iov_nob (tx->tx_niov, tx->tx_iov) + - lnet_kiov_nob(tx->tx_nkiov, tx->tx_kiov) == - (unsigned int)tx->tx_nob); - LASSERT (tx->tx_niov >= 1); - LASSERT (tx->tx_resid == tx->tx_nob); + LASSERT(lnet_iov_nob (tx->tx_niov, tx->tx_iov) + + lnet_kiov_nob(tx->tx_nkiov, tx->tx_kiov) == + (unsigned int)tx->tx_nob); + LASSERT(tx->tx_niov >= 1); + LASSERT(tx->tx_resid == tx->tx_nob); CDEBUG (D_NET, "Packet %p type %d, nob %d niov %d nkiov %d\n", tx, (tx->tx_lnetmsg != NULL) ? tx->tx_lnetmsg->msg_hdr.type: @@ -739,8 +739,8 @@ ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn) if (msg->ksm_type == KSOCK_MSG_NOOP) { /* The packet is noop ZC ACK, try to piggyback the ack_cookie * on a normal packet so I don't need to send it */ - LASSERT (msg->ksm_zc_cookies[1] != 0); - LASSERT (conn->ksnc_proto->pro_queue_tx_zcack != NULL); + LASSERT(msg->ksm_zc_cookies[1] != 0); + LASSERT(conn->ksnc_proto->pro_queue_tx_zcack != NULL); if (conn->ksnc_proto->pro_queue_tx_zcack(conn, tx, 0)) ztx = tx; /* ZC ACK piggybacked on ztx release tx later */ @@ -748,8 +748,8 @@ ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn) } else { /* It's a normal packet - can it piggback a noop zc-ack that * has been queued already? */ - LASSERT (msg->ksm_zc_cookies[1] == 0); - LASSERT (conn->ksnc_proto->pro_queue_tx_msg != NULL); + LASSERT(msg->ksm_zc_cookies[1] == 0); + LASSERT(conn->ksnc_proto->pro_queue_tx_msg != NULL); ztx = conn->ksnc_proto->pro_queue_tx_msg(conn, tx); /* ztx will be released later */ @@ -777,14 +777,14 @@ ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn) ksock_route_t * ksocknal_find_connectable_route_locked (ksock_peer_t *peer) { - unsigned long now = cfs_time_current(); - struct list_head *tmp; + unsigned long now = cfs_time_current(); + struct list_head *tmp; ksock_route_t *route; list_for_each (tmp, &peer->ksnp_routes) { route = list_entry (tmp, ksock_route_t, ksnr_list); - LASSERT (!route->ksnr_connecting || route->ksnr_scheduled); + LASSERT(!route->ksnr_connecting || route->ksnr_scheduled); if (route->ksnr_scheduled) /* connections being established */ continue; @@ -813,13 +813,13 @@ ksocknal_find_connectable_route_locked (ksock_peer_t *peer) ksock_route_t * ksocknal_find_connecting_route_locked (ksock_peer_t *peer) { - struct list_head *tmp; - ksock_route_t *route; + struct list_head *tmp; + ksock_route_t *route; list_for_each (tmp, &peer->ksnp_routes) { route = list_entry (tmp, ksock_route_t, ksnr_list); - LASSERT (!route->ksnr_connecting || route->ksnr_scheduled); + LASSERT(!route->ksnr_connecting || route->ksnr_scheduled); if (route->ksnr_scheduled) return route; @@ -831,13 +831,13 @@ ksocknal_find_connecting_route_locked (ksock_peer_t *peer) int ksocknal_launch_packet (lnet_ni_t *ni, ksock_tx_t *tx, lnet_process_id_t id) { - ksock_peer_t *peer; - ksock_conn_t *conn; - rwlock_t *g_lock; - int retry; - int rc; + ksock_peer_t *peer; + ksock_conn_t *conn; + rwlock_t *g_lock; + int retry; + int rc; - LASSERT (tx->tx_conn == NULL); + LASSERT(tx->tx_conn == NULL); g_lock = &ksocknal_data.ksnd_global_lock; @@ -922,17 +922,17 @@ ksocknal_launch_packet (lnet_ni_t *ni, ksock_tx_t *tx, lnet_process_id_t id) int ksocknal_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) { - int mpflag = 1; - int type = lntmsg->msg_type; + int mpflag = 1; + int type = lntmsg->msg_type; lnet_process_id_t target = lntmsg->msg_target; - unsigned int payload_niov = lntmsg->msg_niov; - struct kvec *payload_iov = lntmsg->msg_iov; - lnet_kiov_t *payload_kiov = lntmsg->msg_kiov; - unsigned int payload_offset = lntmsg->msg_offset; - unsigned int payload_nob = lntmsg->msg_len; - ksock_tx_t *tx; - int desc_size; - int rc; + unsigned int payload_niov = lntmsg->msg_niov; + struct kvec *payload_iov = lntmsg->msg_iov; + lnet_kiov_t *payload_kiov = lntmsg->msg_kiov; + unsigned int payload_offset = lntmsg->msg_offset; + unsigned int payload_nob = lntmsg->msg_len; + ksock_tx_t *tx; + int desc_size; + int rc; /* NB 'private' is different depending on what we're sending. * Just ignore it... */ @@ -940,8 +940,8 @@ ksocknal_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) CDEBUG(D_NET, "sending %u bytes in %d frags to %s\n", payload_nob, payload_niov, libcfs_id2str(target)); - LASSERT (payload_nob == 0 || payload_niov > 0); - LASSERT (payload_niov <= LNET_MAX_IOV); + LASSERT(payload_nob == 0 || payload_niov > 0); + LASSERT(payload_niov <= LNET_MAX_IOV); /* payload is either all vaddrs or all pages */ LASSERT (!(payload_kiov != NULL && payload_iov != NULL)); LASSERT (!in_interrupt ()); @@ -1028,9 +1028,9 @@ ksocknal_new_packet (ksock_conn_t *conn, int nob_to_skip) { static char ksocknal_slop_buffer[4096]; - int nob; - unsigned int niov; - int skipped; + int nob; + unsigned int niov; + int skipped; LASSERT(conn->ksnc_proto != NULL); @@ -1063,7 +1063,7 @@ ksocknal_new_packet (ksock_conn_t *conn, int nob_to_skip) conn->ksnc_rx_iov = (struct kvec *)&conn->ksnc_rx_iov_space; conn->ksnc_rx_iov[0].iov_base = &conn->ksnc_msg.ksm_u.lnetmsg; - conn->ksnc_rx_iov[0].iov_len = sizeof (lnet_hdr_t); + conn->ksnc_rx_iov[0].iov_len = sizeof (lnet_hdr_t); break; default: @@ -1108,18 +1108,18 @@ ksocknal_new_packet (ksock_conn_t *conn, int nob_to_skip) static int ksocknal_process_receive (ksock_conn_t *conn) { - lnet_hdr_t *lhdr; + lnet_hdr_t *lhdr; lnet_process_id_t *id; - int rc; + int rc; LASSERT (atomic_read(&conn->ksnc_conn_refcount) > 0); /* NB: sched lock NOT held */ /* SOCKNAL_RX_LNET_HEADER is here for backward compatibility */ - LASSERT (conn->ksnc_rx_state == SOCKNAL_RX_KSM_HEADER || - conn->ksnc_rx_state == SOCKNAL_RX_LNET_PAYLOAD || - conn->ksnc_rx_state == SOCKNAL_RX_LNET_HEADER || - conn->ksnc_rx_state == SOCKNAL_RX_SLOP); + LASSERT(conn->ksnc_rx_state == SOCKNAL_RX_KSM_HEADER || + conn->ksnc_rx_state == SOCKNAL_RX_LNET_PAYLOAD || + conn->ksnc_rx_state == SOCKNAL_RX_LNET_HEADER || + conn->ksnc_rx_state == SOCKNAL_RX_SLOP); again: if (conn->ksnc_rx_nob_wanted != 0) { rc = ksocknal_receive(conn); @@ -1229,7 +1229,7 @@ ksocknal_process_receive (ksock_conn_t *conn) if ((conn->ksnc_peer->ksnp_id.pid & LNET_PID_USERFLAG) != 0) { /* Userspace peer */ lhdr = &conn->ksnc_msg.ksm_u.lnetmsg.ksnm_hdr; - id = &conn->ksnc_peer->ksnp_id; + id = &conn->ksnc_peer->ksnp_id; /* Substitute process ID assigned at connection time */ lhdr->src_pid = cpu_to_le32(id->pid); @@ -1277,7 +1277,7 @@ ksocknal_process_receive (ksock_conn_t *conn) LASSERT(conn->ksnc_proto != &ksocknal_protocol_v1x); lhdr = &conn->ksnc_msg.ksm_u.lnetmsg.ksnm_hdr; - id = &conn->ksnc_peer->ksnp_id; + id = &conn->ksnc_peer->ksnp_id; rc = conn->ksnc_proto->pro_handle_zcreq(conn, conn->ksnc_msg.ksm_zc_cookies[0], @@ -1305,7 +1305,7 @@ ksocknal_process_receive (ksock_conn_t *conn) } /* Not Reached */ - LBUG (); + LBUG(); return -EINVAL; /* keep gcc happy */ } @@ -1314,15 +1314,15 @@ ksocknal_recv (lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed, unsigned int niov, struct kvec *iov, lnet_kiov_t *kiov, unsigned int offset, unsigned int mlen, unsigned int rlen) { - ksock_conn_t *conn = (ksock_conn_t *)private; + ksock_conn_t *conn = (ksock_conn_t *)private; ksock_sched_t *sched = conn->ksnc_scheduler; - LASSERT (mlen <= rlen); - LASSERT (niov <= LNET_MAX_IOV); + LASSERT(mlen <= rlen); + LASSERT(niov <= LNET_MAX_IOV); conn->ksnc_cookie = msg; conn->ksnc_rx_nob_wanted = mlen; - conn->ksnc_rx_nob_left = rlen; + conn->ksnc_rx_nob_left = rlen; if (mlen == 0 || iov != NULL) { conn->ksnc_rx_nkiov = 0; @@ -1333,18 +1333,18 @@ ksocknal_recv (lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed, niov, iov, offset, mlen); } else { conn->ksnc_rx_niov = 0; - conn->ksnc_rx_iov = NULL; + conn->ksnc_rx_iov = NULL; conn->ksnc_rx_kiov = conn->ksnc_rx_iov_space.kiov; conn->ksnc_rx_nkiov = lnet_extract_kiov(LNET_MAX_IOV, conn->ksnc_rx_kiov, niov, kiov, offset, mlen); } - LASSERT (mlen == - lnet_iov_nob (conn->ksnc_rx_niov, conn->ksnc_rx_iov) + - lnet_kiov_nob (conn->ksnc_rx_nkiov, conn->ksnc_rx_kiov)); + LASSERT(mlen == + lnet_iov_nob(conn->ksnc_rx_niov, conn->ksnc_rx_iov) + + lnet_kiov_nob(conn->ksnc_rx_nkiov, conn->ksnc_rx_kiov)); - LASSERT (conn->ksnc_rx_scheduled); + LASSERT(conn->ksnc_rx_scheduled); spin_lock_bh(&sched->kss_lock); @@ -1370,7 +1370,7 @@ ksocknal_recv (lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed, static inline int ksocknal_sched_cansleep(ksock_sched_t *sched) { - int rc; + int rc; spin_lock_bh(&sched->kss_lock); @@ -1384,13 +1384,13 @@ ksocknal_sched_cansleep(ksock_sched_t *sched) int ksocknal_scheduler(void *arg) { - struct ksock_sched_info *info; - ksock_sched_t *sched; - ksock_conn_t *conn; - ksock_tx_t *tx; - int rc; - int nloops = 0; - long id = (long)arg; + struct ksock_sched_info *info; + ksock_sched_t *sched; + ksock_conn_t *conn; + ksock_tx_t *tx; + int rc; + int nloops = 0; + long id = (long)arg; info = ksocknal_data.ksnd_sched_info[KSOCK_THREAD_CPT(id)]; sched = &info->ksi_scheds[KSOCK_THREAD_SID(id)]; @@ -1455,7 +1455,7 @@ int ksocknal_scheduler(void *arg) } if (!list_empty (&sched->kss_tx_conns)) { - LIST_HEAD (zlist); + LIST_HEAD(zlist); if (!list_empty(&sched->kss_zombie_noop_txs)) { list_add(&zlist, @@ -1513,9 +1513,9 @@ int ksocknal_scheduler(void *arg) /* Do nothing; after a short timeout, this * conn will be reposted on kss_tx_conns. */ } else if (conn->ksnc_tx_ready && - !list_empty (&conn->ksnc_tx_queue)) { + !list_empty(&conn->ksnc_tx_queue)) { /* reschedule for tx */ - list_add_tail (&conn->ksnc_tx_list, + list_add_tail(&conn->ksnc_tx_list, &sched->kss_tx_conns); } else { conn->ksnc_tx_scheduled = 0; @@ -1606,7 +1606,7 @@ void ksocknal_write_callback (ksock_conn_t *conn) static ksock_proto_t * ksocknal_parse_proto_version (ksock_hello_msg_t *hello) { - __u32 version = 0; + __u32 version = 0; if (hello->kshm_magic == LNET_PROTO_MAGIC) version = hello->kshm_version; @@ -1634,8 +1634,8 @@ ksocknal_parse_proto_version (ksock_hello_msg_t *hello) if (hello->kshm_magic == le32_to_cpu(LNET_PROTO_TCP_MAGIC)) { lnet_magicversion_t *hmv = (lnet_magicversion_t *)hello; - CLASSERT (sizeof (lnet_magicversion_t) == - offsetof (ksock_hello_msg_t, kshm_src_nid)); + CLASSERT(sizeof (lnet_magicversion_t) == + offsetof (ksock_hello_msg_t, kshm_src_nid)); if (hmv->version_major == cpu_to_le16 (KSOCK_PROTO_V1_MAJOR) && hmv->version_minor == cpu_to_le16 (KSOCK_PROTO_V1_MINOR)) @@ -1650,19 +1650,19 @@ ksocknal_send_hello (lnet_ni_t *ni, ksock_conn_t *conn, lnet_nid_t peer_nid, ksock_hello_msg_t *hello) { /* CAVEAT EMPTOR: this byte flips 'ipaddrs' */ - ksock_net_t *net = (ksock_net_t *)ni->ni_data; + ksock_net_t *net = (ksock_net_t *)ni->ni_data; - LASSERT (hello->kshm_nips <= LNET_MAX_INTERFACES); + LASSERT(hello->kshm_nips <= LNET_MAX_INTERFACES); /* rely on caller to hold a ref on socket so it wouldn't disappear */ - LASSERT (conn->ksnc_proto != NULL); + LASSERT(conn->ksnc_proto != NULL); - hello->kshm_src_nid = ni->ni_nid; - hello->kshm_dst_nid = peer_nid; - hello->kshm_src_pid = the_lnet.ln_pid; + hello->kshm_src_nid = ni->ni_nid; + hello->kshm_dst_nid = peer_nid; + hello->kshm_src_pid = the_lnet.ln_pid; hello->kshm_src_incarnation = net->ksnn_incarnation; - hello->kshm_ctype = conn->ksnc_type; + hello->kshm_ctype = conn->ksnc_type; return conn->ksnc_proto->pro_send_hello(conn, hello); } @@ -1693,16 +1693,16 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, * EALREADY lost connection race * EPROTO protocol version mismatch */ - struct socket *sock = conn->ksnc_sock; - int active = (conn->ksnc_proto != NULL); - int timeout; - int proto_match; - int rc; - ksock_proto_t *proto; - lnet_process_id_t recv_id; + struct socket *sock = conn->ksnc_sock; + int active = (conn->ksnc_proto != NULL); + int timeout; + int proto_match; + int rc; + ksock_proto_t *proto; + lnet_process_id_t recv_id; /* socket type set on active connections - not set on passive */ - LASSERT (!active == !(conn->ksnc_type != SOCKLND_CONN_NONE)); + LASSERT(!active == !(conn->ksnc_type != SOCKLND_CONN_NONE)); timeout = active ? *ksocknal_tunables.ksnd_timeout : lnet_acceptor_timeout(); @@ -1731,7 +1731,7 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, if (rc != 0) { CERROR("Error %d reading HELLO from %pI4h\n", rc, &conn->ksnc_ipaddr); - LASSERT (rc < 0); + LASSERT(rc < 0); return rc; } @@ -1765,7 +1765,7 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, if (rc != 0) { CERROR("Error %d reading or checking hello from from %pI4h\n", rc, &conn->ksnc_ipaddr); - LASSERT (rc < 0); + LASSERT(rc < 0); return rc; } @@ -1830,22 +1830,22 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, static int ksocknal_connect (ksock_route_t *route) { - LIST_HEAD (zombies); - ksock_peer_t *peer = route->ksnr_peer; - int type; - int wanted; - struct socket *sock; - unsigned long deadline; - int retry_later = 0; - int rc = 0; + LIST_HEAD(zombies); + ksock_peer_t *peer = route->ksnr_peer; + int type; + int wanted; + struct socket *sock; + unsigned long deadline; + int retry_later = 0; + int rc = 0; deadline = cfs_time_add(cfs_time_current(), cfs_time_seconds(*ksocknal_tunables.ksnd_timeout)); write_lock_bh(&ksocknal_data.ksnd_global_lock); - LASSERT (route->ksnr_scheduled); - LASSERT (!route->ksnr_connecting); + LASSERT(route->ksnr_scheduled); + LASSERT(!route->ksnr_connecting); route->ksnr_connecting = 1; @@ -2101,7 +2101,7 @@ static ksock_route_t * ksocknal_connd_get_route_locked(signed long *timeout_p) { ksock_route_t *route; - unsigned long now; + unsigned long now; now = cfs_time_current(); @@ -2124,13 +2124,13 @@ ksocknal_connd_get_route_locked(signed long *timeout_p) int ksocknal_connd (void *arg) { - spinlock_t *connd_lock = &ksocknal_data.ksnd_connd_lock; - ksock_connreq_t *cr; - wait_queue_t wait; - int nloops = 0; - int cons_retry = 0; + spinlock_t *connd_lock = &ksocknal_data.ksnd_connd_lock; + ksock_connreq_t *cr; + wait_queue_t wait; + int nloops = 0; + int cons_retry = 0; - cfs_block_allsigs (); + cfs_block_allsigs(); init_waitqueue_entry(&wait, current); @@ -2144,7 +2144,7 @@ ksocknal_connd (void *arg) ksock_route_t *route = NULL; long sec = get_seconds(); long timeout = MAX_SCHEDULE_TIMEOUT; - int dropped_lock = 0; + int dropped_lock = 0; if (ksocknal_connd_check_stop(sec, &timeout)) { /* wakeup another one to check stop */ @@ -2236,15 +2236,15 @@ static ksock_conn_t * ksocknal_find_timed_out_conn (ksock_peer_t *peer) { /* We're called with a shared lock on ksnd_global_lock */ - ksock_conn_t *conn; - struct list_head *ctmp; + ksock_conn_t *conn; + struct list_head *ctmp; list_for_each (ctmp, &peer->ksnp_conns) { - int error; + int error; conn = list_entry (ctmp, ksock_conn_t, ksnc_list); /* Don't need the {get,put}connsock dance to deref ksnc_sock */ - LASSERT (!conn->ksnc_closing); + LASSERT(!conn->ksnc_closing); /* SOCK_ERROR will reset error code of socket in * some platform (like Darwin8.x) */ @@ -2313,8 +2313,8 @@ ksocknal_find_timed_out_conn (ksock_peer_t *peer) static inline void ksocknal_flush_stale_txs(ksock_peer_t *peer) { - ksock_tx_t *tx; - LIST_HEAD (stale_txs); + ksock_tx_t *tx; + LIST_HEAD(stale_txs); write_lock_bh(&ksocknal_data.ksnd_global_lock); @@ -2338,9 +2338,9 @@ ksocknal_flush_stale_txs(ksock_peer_t *peer) static int ksocknal_send_keepalive_locked(ksock_peer_t *peer) { - ksock_sched_t *sched; - ksock_conn_t *conn; - ksock_tx_t *tx; + ksock_sched_t *sched; + ksock_conn_t *conn; + ksock_tx_t *tx; if (list_empty(&peer->ksnp_conns)) /* last_alive will be updated by create_conn */ return 0; @@ -2399,10 +2399,10 @@ ksocknal_send_keepalive_locked(ksock_peer_t *peer) static void ksocknal_check_peer_timeouts (int idx) { - struct list_head *peers = &ksocknal_data.ksnd_peers[idx]; - ksock_peer_t *peer; - ksock_conn_t *conn; - ksock_tx_t *tx; + struct list_head *peers = &ksocknal_data.ksnd_peers[idx]; + ksock_peer_t *peer; + ksock_conn_t *conn; + ksock_tx_t *tx; again: /* NB. We expect to have a look at all the peers and not find any @@ -2411,9 +2411,9 @@ ksocknal_check_peer_timeouts (int idx) read_lock(&ksocknal_data.ksnd_global_lock); list_for_each_entry(peer, peers, ksnp_list) { - unsigned long deadline = 0; - int resid = 0; - int n = 0; + unsigned long deadline = 0; + int resid = 0; + int n = 0; if (ksocknal_send_keepalive_locked(peer) != 0) { read_unlock(&ksocknal_data.ksnd_global_lock); @@ -2476,8 +2476,8 @@ ksocknal_check_peer_timeouts (int idx) tx = list_entry(peer->ksnp_zc_req_list.next, ksock_tx_t, tx_zc_list); deadline = tx->tx_deadline; - resid = tx->tx_resid; - conn = tx->tx_conn; + resid = tx->tx_resid; + conn = tx->tx_conn; ksocknal_conn_addref(conn); spin_unlock(&peer->ksnp_lock); @@ -2499,17 +2499,17 @@ ksocknal_check_peer_timeouts (int idx) int ksocknal_reaper (void *arg) { - wait_queue_t wait; - ksock_conn_t *conn; - ksock_sched_t *sched; - struct list_head enomem_conns; - int nenomem_conns; - long timeout; - int i; - int peer_index = 0; - unsigned long deadline = cfs_time_current(); + wait_queue_t wait; + ksock_conn_t *conn; + ksock_sched_t *sched; + struct list_head enomem_conns; + int nenomem_conns; + long timeout; + int i; + int peer_index = 0; + unsigned long deadline = cfs_time_current(); - cfs_block_allsigs (); + cfs_block_allsigs(); INIT_LIST_HEAD(&enomem_conns); init_waitqueue_entry(&wait, current); @@ -2580,7 +2580,7 @@ ksocknal_reaper (void *arg) cfs_time_current())) <= 0) { const int n = 4; const int p = 1; - int chunk = ksocknal_data.ksnd_peer_hash_size; + int chunk = ksocknal_data.ksnd_peer_hash_size; /* Time to check for timeouts on a few more peers: I do * checks every 'p' seconds on a proportion of the peer 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 f5e8ab06070c..caeb3477da97 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c @@ -64,7 +64,7 @@ ksocknal_lib_get_conn_addrs(ksock_conn_t *conn) int ksocknal_lib_zc_capable(ksock_conn_t *conn) { - int caps = conn->ksnc_sock->sk->sk_route_caps; + int caps = conn->ksnc_sock->sk->sk_route_caps; if (conn->ksnc_proto == &ksocknal_protocol_v1x) return 0; @@ -78,8 +78,8 @@ int ksocknal_lib_send_iov(ksock_conn_t *conn, ksock_tx_t *tx) { struct socket *sock = conn->ksnc_sock; - int nob; - int rc; + int nob; + int rc; if (*ksocknal_tunables.ksnd_enable_csum && /* checksum enabled */ conn->ksnc_proto == &ksocknal_protocol_v2x && /* V2.x connection */ @@ -92,15 +92,15 @@ ksocknal_lib_send_iov(ksock_conn_t *conn, ksock_tx_t *tx) { #if SOCKNAL_SINGLE_FRAG_TX - struct kvec scratch; - struct kvec *scratchiov = &scratch; - unsigned int niov = 1; + struct kvec scratch; + struct kvec *scratchiov = &scratch; + unsigned int niov = 1; #else - struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov; - unsigned int niov = tx->tx_niov; + struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov; + unsigned int niov = tx->tx_niov; #endif struct msghdr msg = {.msg_flags = MSG_DONTWAIT}; - int i; + int i; for (nob = i = 0; i < niov; i++) { scratchiov[i] = tx->tx_iov[i]; @@ -120,9 +120,9 @@ int ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx) { struct socket *sock = conn->ksnc_sock; - lnet_kiov_t *kiov = tx->tx_kiov; - int rc; - int nob; + lnet_kiov_t *kiov = tx->tx_kiov; + int rc; + int nob; /* Not NOOP message */ LASSERT(tx->tx_lnetmsg != NULL); @@ -131,11 +131,11 @@ ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx) * or leave them alone. */ if (tx->tx_msg.ksm_zc_cookies[0] != 0) { /* Zero copy is enabled */ - struct sock *sk = sock->sk; - struct page *page = kiov->kiov_page; - int offset = kiov->kiov_offset; - int fragsize = kiov->kiov_len; - int msgflg = MSG_DONTWAIT; + struct sock *sk = sock->sk; + struct page *page = kiov->kiov_page; + int offset = kiov->kiov_offset; + int fragsize = kiov->kiov_len; + int msgflg = MSG_DONTWAIT; CDEBUG(D_NET, "page %p + offset %x for %d\n", page, offset, kiov->kiov_len); @@ -153,18 +153,18 @@ ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx) } } else { #if SOCKNAL_SINGLE_FRAG_TX || !SOCKNAL_RISK_KMAP_DEADLOCK - struct kvec scratch; + struct kvec scratch; struct kvec *scratchiov = &scratch; - unsigned int niov = 1; + unsigned int niov = 1; #else #ifdef CONFIG_HIGHMEM #warning "XXX risk of kmap deadlock on multiple frags..." #endif struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov; - unsigned int niov = tx->tx_nkiov; + unsigned int niov = tx->tx_nkiov; #endif struct msghdr msg = {.msg_flags = MSG_DONTWAIT}; - int i; + int i; for (nob = i = 0; i < niov; i++) { scratchiov[i].iov_base = kmap(kiov[i].kiov_page) + @@ -187,7 +187,7 @@ ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx) void ksocknal_lib_eager_ack(ksock_conn_t *conn) { - int opt = 1; + int opt = 1; struct socket *sock = conn->ksnc_sock; /* Remind the socket to ACK eagerly. If I don't, the socket might @@ -203,23 +203,23 @@ int ksocknal_lib_recv_iov(ksock_conn_t *conn) { #if SOCKNAL_SINGLE_FRAG_RX - struct kvec scratch; + struct kvec scratch; struct kvec *scratchiov = &scratch; - unsigned int niov = 1; + unsigned int niov = 1; #else struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov; - unsigned int niov = conn->ksnc_rx_niov; + unsigned int niov = conn->ksnc_rx_niov; #endif struct kvec *iov = conn->ksnc_rx_iov; struct msghdr msg = { - .msg_flags = 0 + .msg_flags = 0 }; - int nob; - int i; - int rc; - int fragnob; - int sum; - __u32 saved_csum; + int nob; + int i; + int rc; + int fragnob; + int sum; + __u32 saved_csum; /* NB we can't trust socket ops to either consume our iovs * or leave them alone. */ @@ -271,9 +271,9 @@ static void * ksocknal_lib_kiov_vmap(lnet_kiov_t *kiov, int niov, struct kvec *iov, struct page **pages) { - void *addr; - int nob; - int i; + void *addr; + int nob; + int i; if (!*ksocknal_tunables.ksnd_zc_recv || pages == NULL) return NULL; @@ -307,29 +307,29 @@ int ksocknal_lib_recv_kiov(ksock_conn_t *conn) { #if SOCKNAL_SINGLE_FRAG_RX || !SOCKNAL_RISK_KMAP_DEADLOCK - struct kvec scratch; - struct kvec *scratchiov = &scratch; - struct page **pages = NULL; - unsigned int niov = 1; + struct kvec scratch; + struct kvec *scratchiov = &scratch; + struct page **pages = NULL; + unsigned int niov = 1; #else #ifdef CONFIG_HIGHMEM #warning "XXX risk of kmap deadlock on multiple frags..." #endif - struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov; - struct page **pages = conn->ksnc_scheduler->kss_rx_scratch_pgs; - unsigned int niov = conn->ksnc_rx_nkiov; + struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov; + struct page **pages = conn->ksnc_scheduler->kss_rx_scratch_pgs; + unsigned int niov = conn->ksnc_rx_nkiov; #endif lnet_kiov_t *kiov = conn->ksnc_rx_kiov; struct msghdr msg = { - .msg_flags = 0 + .msg_flags = 0 }; - int nob; - int i; - int rc; - void *base; - void *addr; - int sum; - int fragnob; + int nob; + int i; + int rc; + void *base; + void *addr; + int sum; + int fragnob; int n; /* NB we can't trust socket ops to either consume our iovs @@ -357,10 +357,10 @@ ksocknal_lib_recv_kiov(ksock_conn_t *conn) for (i = 0, sum = rc; sum > 0; i++, sum -= fragnob) { LASSERT(i < niov); - /* Dang! have to kmap again because I have nowhere to stash the - * mapped address. But by doing it while the page is still - * mapped, the kernel just bumps the map count and returns me - * the address it stashed. */ + /* Dang! have to kmap again because I have nowhere to + * stash the mapped address. But by doing it while the + * page is still mapped, the kernel just bumps the map + * count and returns me the address it stashed. */ base = kmap(kiov[i].kiov_page) + kiov[i].kiov_offset; fragnob = kiov[i].kiov_len; if (fragnob > sum) @@ -386,9 +386,9 @@ ksocknal_lib_recv_kiov(ksock_conn_t *conn) void ksocknal_lib_csum_tx(ksock_tx_t *tx) { - int i; - __u32 csum; - void *base; + int i; + __u32 csum; + void *base; LASSERT(tx->tx_iov[0].iov_base == &tx->tx_msg); LASSERT(tx->tx_conn != NULL); @@ -426,8 +426,8 @@ int ksocknal_lib_get_conn_tunables(ksock_conn_t *conn, int *txmem, int *rxmem, int *nagle) { struct socket *sock = conn->ksnc_sock; - int len; - int rc; + int len; + int rc; rc = ksocknal_connsock_addref(conn); if (rc != 0) { @@ -456,13 +456,13 @@ ksocknal_lib_get_conn_tunables(ksock_conn_t *conn, int *txmem, int *rxmem, int * int ksocknal_lib_setup_sock(struct socket *sock) { - int rc; - int option; - int keep_idle; - int keep_intvl; - int keep_count; - int do_keepalive; - struct linger linger; + int rc; + int option; + int keep_idle; + int keep_intvl; + int keep_count; + int do_keepalive; + struct linger linger; sock->sk->sk_allocation = GFP_NOFS; @@ -555,11 +555,11 @@ ksocknal_lib_setup_sock(struct socket *sock) void ksocknal_lib_push_conn(ksock_conn_t *conn) { - struct sock *sk; + struct sock *sk; struct tcp_sock *tp; - int nonagle; - int val = 1; - int rc; + int nonagle; + int val = 1; + int rc; rc = ksocknal_connsock_addref(conn); if (rc != 0) /* being shut down */ @@ -592,7 +592,7 @@ extern void ksocknal_write_callback(ksock_conn_t *conn); static void ksocknal_data_ready(struct sock *sk) { - ksock_conn_t *conn; + ksock_conn_t *conn; /* interleave correctly with closing sockets... */ LASSERT(!in_irq()); @@ -611,9 +611,9 @@ ksocknal_data_ready(struct sock *sk) static void ksocknal_write_space(struct sock *sk) { - ksock_conn_t *conn; - int wspace; - int min_wpace; + ksock_conn_t *conn; + int wspace; + int min_wpace; /* interleave correctly with closing sockets... */ LASSERT(!in_irq()); @@ -689,7 +689,7 @@ ksocknal_lib_reset_callback(struct socket *sock, ksock_conn_t *conn) int ksocknal_lib_memory_pressure(ksock_conn_t *conn) { - int rc = 0; + int rc = 0; ksock_sched_t *sched; sched = conn->ksnc_scheduler; diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c index 86b88db1cf20..c3ac67698125 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c @@ -145,40 +145,37 @@ ksock_tunables_t ksocknal_tunables; int ksocknal_tunables_init(void) { - /* initialize ksocknal_tunables structure */ - ksocknal_tunables.ksnd_timeout = &sock_timeout; - ksocknal_tunables.ksnd_nscheds = &nscheds; - ksocknal_tunables.ksnd_nconnds = &nconnds; - ksocknal_tunables.ksnd_nconnds_max = &nconnds_max; + ksocknal_tunables.ksnd_timeout = &sock_timeout; + ksocknal_tunables.ksnd_nscheds = &nscheds; + ksocknal_tunables.ksnd_nconnds = &nconnds; + ksocknal_tunables.ksnd_nconnds_max = &nconnds_max; ksocknal_tunables.ksnd_min_reconnectms = &min_reconnectms; ksocknal_tunables.ksnd_max_reconnectms = &max_reconnectms; - ksocknal_tunables.ksnd_eager_ack = &eager_ack; - ksocknal_tunables.ksnd_typed_conns = &typed_conns; - ksocknal_tunables.ksnd_min_bulk = &min_bulk; + ksocknal_tunables.ksnd_eager_ack = &eager_ack; + ksocknal_tunables.ksnd_typed_conns = &typed_conns; + ksocknal_tunables.ksnd_min_bulk = &min_bulk; ksocknal_tunables.ksnd_tx_buffer_size = &tx_buffer_size; ksocknal_tunables.ksnd_rx_buffer_size = &rx_buffer_size; - ksocknal_tunables.ksnd_nagle = &nagle; - ksocknal_tunables.ksnd_round_robin = &round_robin; - ksocknal_tunables.ksnd_keepalive = &keepalive; + ksocknal_tunables.ksnd_nagle = &nagle; + ksocknal_tunables.ksnd_round_robin = &round_robin; + ksocknal_tunables.ksnd_keepalive = &keepalive; ksocknal_tunables.ksnd_keepalive_idle = &keepalive_idle; ksocknal_tunables.ksnd_keepalive_count = &keepalive_count; ksocknal_tunables.ksnd_keepalive_intvl = &keepalive_intvl; - ksocknal_tunables.ksnd_credits = &credits; + ksocknal_tunables.ksnd_credits = &credits; ksocknal_tunables.ksnd_peertxcredits = &peer_credits; ksocknal_tunables.ksnd_peerrtrcredits = &peer_buffer_credits; - ksocknal_tunables.ksnd_peertimeout = &peer_timeout; - ksocknal_tunables.ksnd_enable_csum = &enable_csum; + ksocknal_tunables.ksnd_peertimeout = &peer_timeout; + ksocknal_tunables.ksnd_enable_csum = &enable_csum; ksocknal_tunables.ksnd_inject_csum_error = &inject_csum_error; ksocknal_tunables.ksnd_nonblk_zcack = &nonblk_zcack; ksocknal_tunables.ksnd_zc_min_payload = &zc_min_payload; - ksocknal_tunables.ksnd_zc_recv = &zc_recv; + ksocknal_tunables.ksnd_zc_recv = &zc_recv; ksocknal_tunables.ksnd_zc_recv_min_nfrags = &zc_recv_min_nfrags; - - #if SOCKNAL_VERSION_DEBUG - ksocknal_tunables.ksnd_protocol = &protocol; + ksocknal_tunables.ksnd_protocol = &protocol; #endif if (*ksocknal_tunables.ksnd_zc_min_payload < (2 << 10)) diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c index 8596581f54ff..1938d6a9b3a4 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c @@ -52,7 +52,7 @@ ksocknal_queue_tx_msg_v1(ksock_conn_t *conn, ksock_tx_t *tx_msg) void ksocknal_next_tx_carrier(ksock_conn_t *conn) { - ksock_tx_t *tx = conn->ksnc_tx_carrier; + ksock_tx_t *tx = conn->ksnc_tx_carrier; /* Called holding BH lock: conn->ksnc_scheduler->kss_lock */ LASSERT(!list_empty(&conn->ksnc_tx_queue)); @@ -119,7 +119,7 @@ ksocknal_queue_tx_zcack_v2(ksock_conn_t *conn, static ksock_tx_t * ksocknal_queue_tx_msg_v2(ksock_conn_t *conn, ksock_tx_t *tx_msg) { - ksock_tx_t *tx = conn->ksnc_tx_carrier; + ksock_tx_t *tx = conn->ksnc_tx_carrier; /* * Enqueue tx_msg: @@ -361,10 +361,10 @@ ksocknal_match_tx_v3(ksock_conn_t *conn, ksock_tx_t *tx, int nonblk) static int ksocknal_handle_zcreq(ksock_conn_t *c, __u64 cookie, int remote) { - ksock_peer_t *peer = c->ksnc_peer; - ksock_conn_t *conn; - ksock_tx_t *tx; - int rc; + ksock_peer_t *peer = c->ksnc_peer; + ksock_conn_t *conn; + ksock_tx_t *tx; + int rc; read_lock(&ksocknal_data.ksnd_global_lock); @@ -405,11 +405,11 @@ ksocknal_handle_zcreq(ksock_conn_t *c, __u64 cookie, int remote) static int ksocknal_handle_zcack(ksock_conn_t *conn, __u64 cookie1, __u64 cookie2) { - ksock_peer_t *peer = conn->ksnc_peer; - ksock_tx_t *tx; - ksock_tx_t *tmp; + ksock_peer_t *peer = conn->ksnc_peer; + ksock_tx_t *tx; + ksock_tx_t *tmp; LIST_HEAD(zlist); - int count; + int count; if (cookie1 == 0) cookie1 = cookie2; @@ -452,11 +452,11 @@ ksocknal_handle_zcack(ksock_conn_t *conn, __u64 cookie1, __u64 cookie2) static int ksocknal_send_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello) { - struct socket *sock = conn->ksnc_sock; - lnet_hdr_t *hdr; + struct socket *sock = conn->ksnc_sock; + lnet_hdr_t *hdr; lnet_magicversion_t *hmv; - int rc; - int i; + int rc; + int i; CLASSERT(sizeof(lnet_magicversion_t) == offsetof(lnet_hdr_t, src_nid)); @@ -470,7 +470,7 @@ ksocknal_send_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello) /* Re-organize V2.x message header to V1.x (lnet_hdr_t) * header and send out */ - hmv->magic = cpu_to_le32 (LNET_PROTO_TCP_MAGIC); + hmv->magic = cpu_to_le32 (LNET_PROTO_TCP_MAGIC); hmv->version_major = cpu_to_le16 (KSOCK_PROTO_V1_MAJOR); hmv->version_minor = cpu_to_le16 (KSOCK_PROTO_V1_MINOR); @@ -488,9 +488,9 @@ ksocknal_send_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello) LNET_UNLOCK(); } - hdr->src_nid = cpu_to_le64 (hello->kshm_src_nid); - hdr->src_pid = cpu_to_le32 (hello->kshm_src_pid); - hdr->type = cpu_to_le32 (LNET_MSG_HELLO); + hdr->src_nid = cpu_to_le64 (hello->kshm_src_nid); + hdr->src_pid = cpu_to_le32 (hello->kshm_src_pid); + hdr->type = cpu_to_le32 (LNET_MSG_HELLO); hdr->payload_length = cpu_to_le32 (hello->kshm_nips * sizeof(__u32)); hdr->msg.hello.type = cpu_to_le32 (hello->kshm_ctype); hdr->msg.hello.incarnation = cpu_to_le64 (hello->kshm_src_incarnation); @@ -529,7 +529,7 @@ static int ksocknal_send_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello) { struct socket *sock = conn->ksnc_sock; - int rc; + int rc; hello->kshm_magic = LNET_PROTO_MAGIC; hello->kshm_version = conn->ksnc_proto->pro_version; @@ -572,10 +572,10 @@ static int ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeout) { - struct socket *sock = conn->ksnc_sock; - lnet_hdr_t *hdr; - int rc; - int i; + struct socket *sock = conn->ksnc_sock; + lnet_hdr_t *hdr; + int rc; + int i; LIBCFS_ALLOC(hdr, sizeof(*hdr)); if (hdr == NULL) { @@ -602,12 +602,12 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello, goto out; } - hello->kshm_src_nid = le64_to_cpu(hdr->src_nid); - hello->kshm_src_pid = le32_to_cpu(hdr->src_pid); + hello->kshm_src_nid = le64_to_cpu(hdr->src_nid); + hello->kshm_src_pid = le32_to_cpu(hdr->src_pid); hello->kshm_src_incarnation = le64_to_cpu(hdr->msg.hello.incarnation); - hello->kshm_ctype = le32_to_cpu(hdr->msg.hello.type); - hello->kshm_nips = le32_to_cpu(hdr->payload_length) / - sizeof(__u32); + hello->kshm_ctype = le32_to_cpu(hdr->msg.hello.type); + hello->kshm_nips = le32_to_cpu(hdr->payload_length) / + sizeof(__u32); if (hello->kshm_nips > LNET_MAX_INTERFACES) { CERROR("Bad nips %d from ip %pI4h\n", @@ -647,9 +647,9 @@ out: static int ksocknal_recv_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeout) { - struct socket *sock = conn->ksnc_sock; - int rc; - int i; + struct socket *sock = conn->ksnc_sock; + int rc; + int i; if (hello->kshm_magic == LNET_PROTO_MAGIC) conn->ksnc_flip = 0; @@ -746,9 +746,9 @@ ksocknal_pack_msg_v2(ksock_tx_t *tx) static void ksocknal_unpack_msg_v1(ksock_msg_t *msg) { - msg->ksm_csum = 0; - msg->ksm_type = KSOCK_MSG_LNET; - msg->ksm_zc_cookies[0] = msg->ksm_zc_cookies[1] = 0; + msg->ksm_csum = 0; + msg->ksm_type = KSOCK_MSG_LNET; + msg->ksm_zc_cookies[0] = msg->ksm_zc_cookies[1] = 0; } static void @@ -758,40 +758,40 @@ ksocknal_unpack_msg_v2(ksock_msg_t *msg) } ksock_proto_t ksocknal_protocol_v1x = { - .pro_version = KSOCK_PROTO_V1, - .pro_send_hello = ksocknal_send_hello_v1, - .pro_recv_hello = ksocknal_recv_hello_v1, - .pro_pack = ksocknal_pack_msg_v1, - .pro_unpack = ksocknal_unpack_msg_v1, - .pro_queue_tx_msg = ksocknal_queue_tx_msg_v1, - .pro_handle_zcreq = NULL, - .pro_handle_zcack = NULL, - .pro_queue_tx_zcack = NULL, - .pro_match_tx = ksocknal_match_tx + .pro_version = KSOCK_PROTO_V1, + .pro_send_hello = ksocknal_send_hello_v1, + .pro_recv_hello = ksocknal_recv_hello_v1, + .pro_pack = ksocknal_pack_msg_v1, + .pro_unpack = ksocknal_unpack_msg_v1, + .pro_queue_tx_msg = ksocknal_queue_tx_msg_v1, + .pro_handle_zcreq = NULL, + .pro_handle_zcack = NULL, + .pro_queue_tx_zcack = NULL, + .pro_match_tx = ksocknal_match_tx }; ksock_proto_t ksocknal_protocol_v2x = { - .pro_version = KSOCK_PROTO_V2, - .pro_send_hello = ksocknal_send_hello_v2, - .pro_recv_hello = ksocknal_recv_hello_v2, - .pro_pack = ksocknal_pack_msg_v2, - .pro_unpack = ksocknal_unpack_msg_v2, - .pro_queue_tx_msg = ksocknal_queue_tx_msg_v2, - .pro_queue_tx_zcack = ksocknal_queue_tx_zcack_v2, - .pro_handle_zcreq = ksocknal_handle_zcreq, - .pro_handle_zcack = ksocknal_handle_zcack, - .pro_match_tx = ksocknal_match_tx + .pro_version = KSOCK_PROTO_V2, + .pro_send_hello = ksocknal_send_hello_v2, + .pro_recv_hello = ksocknal_recv_hello_v2, + .pro_pack = ksocknal_pack_msg_v2, + .pro_unpack = ksocknal_unpack_msg_v2, + .pro_queue_tx_msg = ksocknal_queue_tx_msg_v2, + .pro_queue_tx_zcack = ksocknal_queue_tx_zcack_v2, + .pro_handle_zcreq = ksocknal_handle_zcreq, + .pro_handle_zcack = ksocknal_handle_zcack, + .pro_match_tx = ksocknal_match_tx }; ksock_proto_t ksocknal_protocol_v3x = { - .pro_version = KSOCK_PROTO_V3, - .pro_send_hello = ksocknal_send_hello_v2, - .pro_recv_hello = ksocknal_recv_hello_v2, - .pro_pack = ksocknal_pack_msg_v2, - .pro_unpack = ksocknal_unpack_msg_v2, - .pro_queue_tx_msg = ksocknal_queue_tx_msg_v2, - .pro_queue_tx_zcack = ksocknal_queue_tx_zcack_v3, - .pro_handle_zcreq = ksocknal_handle_zcreq, - .pro_handle_zcack = ksocknal_handle_zcack, - .pro_match_tx = ksocknal_match_tx_v3 + .pro_version = KSOCK_PROTO_V3, + .pro_send_hello = ksocknal_send_hello_v2, + .pro_recv_hello = ksocknal_recv_hello_v2, + .pro_pack = ksocknal_pack_msg_v2, + .pro_unpack = ksocknal_unpack_msg_v2, + .pro_queue_tx_msg = ksocknal_queue_tx_msg_v2, + .pro_queue_tx_zcack = ksocknal_queue_tx_zcack_v3, + .pro_handle_zcreq = ksocknal_handle_zcreq, + .pro_handle_zcack = ksocknal_handle_zcack, + .pro_match_tx = ksocknal_match_tx_v3 }; From 74d680116219380ed946bb3ad24237f2424fdb66 Mon Sep 17 00:00:00 2001 From: Mike Shuey Date: Tue, 19 May 2015 10:14:38 -0400 Subject: [PATCH 0560/1163] staging: lustre: lnet: selftest: code cleanup - variable spacing, indentation Unify spacing in variable declarations, and align indentation in headers. General whitespace cleanups. Signed-off-by: Mike Shuey Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lnet/selftest/brw_test.c | 60 ++-- drivers/staging/lustre/lnet/selftest/conctl.c | 54 +-- drivers/staging/lustre/lnet/selftest/conrpc.c | 124 +++---- drivers/staging/lustre/lnet/selftest/conrpc.h | 34 +- .../staging/lustre/lnet/selftest/console.c | 246 +++++++------- .../staging/lustre/lnet/selftest/console.h | 180 +++++----- .../staging/lustre/lnet/selftest/framework.c | 160 ++++----- drivers/staging/lustre/lnet/selftest/module.c | 10 +- .../staging/lustre/lnet/selftest/ping_test.c | 24 +- drivers/staging/lustre/lnet/selftest/rpc.c | 150 ++++----- drivers/staging/lustre/lnet/selftest/rpc.h | 141 ++++---- .../staging/lustre/lnet/selftest/selftest.h | 307 +++++++++--------- drivers/staging/lustre/lnet/selftest/timer.c | 20 +- drivers/staging/lustre/lnet/selftest/timer.h | 16 +- 14 files changed, 764 insertions(+), 762 deletions(-) diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c index 658f4584fff8..de11f1bc8be7 100644 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c @@ -91,7 +91,7 @@ brw_client_init(sfw_test_instance_t *tsi) len = npg * PAGE_CACHE_SIZE; } else { - test_bulk_req_v1_t *breq = &tsi->tsi_u.bulk_v1; + test_bulk_req_v1_t *breq = &tsi->tsi_u.bulk_v1; /* I should never get this step if it's unknown feature * because make_session will reject unknown feature */ @@ -223,7 +223,7 @@ bad_data: static void brw_fill_bulk(srpc_bulk_t *bk, int pattern, __u64 magic) { - int i; + int i; struct page *pg; for (i = 0; i < bk->bk_niov; i++) { @@ -235,7 +235,7 @@ brw_fill_bulk(srpc_bulk_t *bk, int pattern, __u64 magic) static int brw_check_bulk(srpc_bulk_t *bk, int pattern, __u64 magic) { - int i; + int i; struct page *pg; for (i = 0; i < bk->bk_niov; i++) { @@ -254,16 +254,16 @@ static int brw_client_prep_rpc(sfw_test_unit_t *tsu, lnet_process_id_t dest, srpc_client_rpc_t **rpcpp) { - srpc_bulk_t *bulk = tsu->tsu_private; + srpc_bulk_t *bulk = tsu->tsu_private; sfw_test_instance_t *tsi = tsu->tsu_instance; - sfw_session_t *sn = tsi->tsi_batch->bat_session; - srpc_client_rpc_t *rpc; - srpc_brw_reqst_t *req; - int flags; - int npg; - int len; - int opc; - int rc; + sfw_session_t *sn = tsi->tsi_batch->bat_session; + srpc_client_rpc_t *rpc; + srpc_brw_reqst_t *req; + int flags; + int npg; + int len; + int opc; + int rc; LASSERT(sn != NULL); LASSERT(bulk != NULL); @@ -277,7 +277,7 @@ brw_client_prep_rpc(sfw_test_unit_t *tsu, len = npg * PAGE_CACHE_SIZE; } else { - test_bulk_req_v1_t *breq = &tsi->tsi_u.bulk_v1; + test_bulk_req_v1_t *breq = &tsi->tsi_u.bulk_v1; /* I should never get this step if it's unknown feature * because make_session will reject unknown feature */ @@ -311,12 +311,12 @@ brw_client_prep_rpc(sfw_test_unit_t *tsu, static void brw_client_done_rpc(sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc) { - __u64 magic = BRW_MAGIC; + __u64 magic = BRW_MAGIC; sfw_test_instance_t *tsi = tsu->tsu_instance; - sfw_session_t *sn = tsi->tsi_batch->bat_session; - srpc_msg_t *msg = &rpc->crpc_replymsg; - srpc_brw_reply_t *reply = &msg->msg_body.brw_reply; - srpc_brw_reqst_t *reqst = &rpc->crpc_reqstmsg.msg_body.brw_reqst; + sfw_session_t *sn = tsi->tsi_batch->bat_session; + srpc_msg_t *msg = &rpc->crpc_replymsg; + srpc_brw_reply_t *reply = &msg->msg_body.brw_reply; + srpc_brw_reqst_t *reqst = &rpc->crpc_reqstmsg.msg_body.brw_reqst; LASSERT(sn != NULL); @@ -380,10 +380,10 @@ brw_server_rpc_done(srpc_server_rpc_t *rpc) static int brw_bulk_ready(srpc_server_rpc_t *rpc, int status) { - __u64 magic = BRW_MAGIC; + __u64 magic = BRW_MAGIC; srpc_brw_reply_t *reply = &rpc->srpc_replymsg.msg_body.brw_reply; srpc_brw_reqst_t *reqst; - srpc_msg_t *reqstmsg; + srpc_msg_t *reqstmsg; LASSERT(rpc->srpc_bulk != NULL); LASSERT(rpc->srpc_reqstbuf != NULL); @@ -416,13 +416,13 @@ brw_bulk_ready(srpc_server_rpc_t *rpc, int status) static int brw_server_handle(struct srpc_server_rpc *rpc) { - struct srpc_service *sv = rpc->srpc_scd->scd_svc; - srpc_msg_t *replymsg = &rpc->srpc_replymsg; - srpc_msg_t *reqstmsg = &rpc->srpc_reqstbuf->buf_msg; + struct srpc_service *sv = rpc->srpc_scd->scd_svc; + srpc_msg_t *replymsg = &rpc->srpc_replymsg; + srpc_msg_t *reqstmsg = &rpc->srpc_reqstbuf->buf_msg; srpc_brw_reply_t *reply = &replymsg->msg_body.brw_reply; srpc_brw_reqst_t *reqst = &reqstmsg->msg_body.brw_reqst; - int npg; - int rc; + int npg; + int rc; LASSERT(sv->sv_id == SRPC_SERVICE_BRW); @@ -490,17 +490,17 @@ brw_server_handle(struct srpc_server_rpc *rpc) sfw_test_client_ops_t brw_test_client; void brw_init_test_client(void) { - brw_test_client.tso_init = brw_client_init; - brw_test_client.tso_fini = brw_client_fini; - brw_test_client.tso_prep_rpc = brw_client_prep_rpc; - brw_test_client.tso_done_rpc = brw_client_done_rpc; + brw_test_client.tso_init = brw_client_init; + brw_test_client.tso_fini = brw_client_fini; + brw_test_client.tso_prep_rpc = brw_client_prep_rpc; + brw_test_client.tso_done_rpc = brw_client_done_rpc; }; srpc_service_t brw_test_service; void brw_init_test_service(void) { - brw_test_service.sv_id = SRPC_SERVICE_BRW; + brw_test_service.sv_id = SRPC_SERVICE_BRW; brw_test_service.sv_name = "brw_test"; brw_test_service.sv_handler = brw_server_handle; brw_test_service.sv_bulk_ready = brw_bulk_ready; diff --git a/drivers/staging/lustre/lnet/selftest/conctl.c b/drivers/staging/lustre/lnet/selftest/conctl.c index 045fe295ad54..1a7870e91f23 100644 --- a/drivers/staging/lustre/lnet/selftest/conctl.c +++ b/drivers/staging/lustre/lnet/selftest/conctl.c @@ -48,11 +48,11 @@ static int lst_session_new_ioctl(lstio_session_new_args_t *args) { - char *name; - int rc; + char *name; + int rc; if (args->lstio_ses_idp == NULL || /* address for output sid */ - args->lstio_ses_key == 0 || /* no key is specified */ + args->lstio_ses_key == 0 || /* no key is specified */ args->lstio_ses_namep == NULL || /* session name */ args->lstio_ses_nmlen <= 0 || args->lstio_ses_nmlen > LST_NAME_SIZE) @@ -96,12 +96,12 @@ lst_session_info_ioctl(lstio_session_info_args_t *args) { /* no checking of key */ - if (args->lstio_ses_idp == NULL || /* address for output sid */ - args->lstio_ses_keyp == NULL || /* address for output key */ + if (args->lstio_ses_idp == NULL || /* address for output sid */ + args->lstio_ses_keyp == NULL || /* address for output key */ args->lstio_ses_featp == NULL || /* address for output features */ args->lstio_ses_ndinfo == NULL || /* address for output ndinfo */ - args->lstio_ses_namep == NULL || /* address for output name */ - args->lstio_ses_nmlen <= 0 || + args->lstio_ses_namep == NULL || /* address for output name */ + args->lstio_ses_nmlen <= 0 || args->lstio_ses_nmlen > LST_NAME_SIZE) return -EINVAL; @@ -197,8 +197,8 @@ out: static int lst_group_add_ioctl(lstio_group_add_args_t *args) { - char *name; - int rc; + char *name; + int rc; if (args->lstio_grp_key != console_session.ses_key) return -EACCES; @@ -324,8 +324,8 @@ static int lst_nodes_add_ioctl(lstio_group_nodes_args_t *args) { unsigned feats; - int rc; - char *name; + int rc; + char *name; if (args->lstio_grp_key != console_session.ses_key) return -EACCES; @@ -385,10 +385,10 @@ lst_group_list_ioctl(lstio_group_list_args_t *args) static int lst_group_info_ioctl(lstio_group_info_args_t *args) { - char *name; - int ndent; - int index; - int rc; + char *name; + int ndent; + int index; + int rc; if (args->lstio_grp_key != console_session.ses_key) return -EACCES; @@ -449,8 +449,8 @@ lst_group_info_ioctl(lstio_group_info_args_t *args) static int lst_batch_add_ioctl(lstio_batch_add_args_t *args) { - int rc; - char *name; + int rc; + char *name; if (args->lstio_bat_key != console_session.ses_key) return -EACCES; @@ -483,8 +483,8 @@ lst_batch_add_ioctl(lstio_batch_add_args_t *args) static int lst_batch_run_ioctl(lstio_batch_run_args_t *args) { - int rc; - char *name; + int rc; + char *name; if (args->lstio_bat_key != console_session.ses_key) return -EACCES; @@ -518,8 +518,8 @@ lst_batch_run_ioctl(lstio_batch_run_args_t *args) static int lst_batch_stop_ioctl(lstio_batch_stop_args_t *args) { - int rc; - char *name; + int rc; + char *name; if (args->lstio_bat_key != console_session.ses_key) return -EACCES; @@ -613,10 +613,10 @@ lst_batch_list_ioctl(lstio_batch_list_args_t *args) static int lst_batch_info_ioctl(lstio_batch_info_args_t *args) { - char *name; - int rc; - int index; - int ndent; + char *name; + int rc; + int index; + int ndent; if (args->lstio_bat_key != console_session.ses_key) return -EACCES; @@ -678,8 +678,8 @@ lst_batch_info_ioctl(lstio_batch_info_args_t *args) static int lst_stat_query_ioctl(lstio_stat_args_t *args) { - int rc; - char *name; + int rc; + char *name; /* TODO: not finished */ if (args->lstio_sta_key != console_session.ses_key) diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c index 77f02b76128e..a1a4e08f7391 100644 --- a/drivers/staging/lustre/lnet/selftest/conrpc.c +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c @@ -117,8 +117,8 @@ static int lstcon_rpc_prep(lstcon_node_t *nd, int service, unsigned feats, int bulk_npg, int bulk_len, lstcon_rpc_t **crpcpp) { - lstcon_rpc_t *crpc = NULL; - int rc; + lstcon_rpc_t *crpc = NULL; + int rc; spin_lock(&console_session.ses_rpc_lock); @@ -151,7 +151,7 @@ void lstcon_rpc_put(lstcon_rpc_t *crpc) { srpc_bulk_t *bulk = &crpc->crp_rpc->crpc_bulk; - int i; + int i; LASSERT(list_empty(&crpc->crp_link)); @@ -336,8 +336,8 @@ lstcon_rpc_trans_check(lstcon_rpc_trans_t *trans) int lstcon_rpc_trans_postwait(lstcon_rpc_trans_t *trans, int timeout) { - lstcon_rpc_t *crpc; - int rc; + lstcon_rpc_t *crpc; + int rc; if (list_empty(&trans->tas_rpcs_list)) return 0; @@ -386,8 +386,8 @@ lstcon_rpc_trans_postwait(lstcon_rpc_trans_t *trans, int timeout) static int lstcon_rpc_get_reply(lstcon_rpc_t *crpc, srpc_msg_t **msgpp) { - lstcon_node_t *nd = crpc->crp_node; - srpc_client_rpc_t *rpc = crpc->crp_rpc; + lstcon_node_t *nd = crpc->crp_node; + srpc_client_rpc_t *rpc = crpc->crp_rpc; srpc_generic_reply_t *rep; LASSERT(nd != NULL && rpc != NULL); @@ -423,9 +423,9 @@ lstcon_rpc_get_reply(lstcon_rpc_t *crpc, srpc_msg_t **msgpp) void lstcon_rpc_trans_stat(lstcon_rpc_trans_t *trans, lstcon_trans_stat_t *stat) { - lstcon_rpc_t *crpc; - srpc_msg_t *rep; - int error; + lstcon_rpc_t *crpc; + srpc_msg_t *rep; + int error; LASSERT(stat != NULL); @@ -470,16 +470,16 @@ lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans, struct list_head *head_up, lstcon_rpc_readent_func_t readent) { - struct list_head tmp; - struct list_head *next; - lstcon_rpc_ent_t *ent; + struct list_head tmp; + struct list_head *next; + lstcon_rpc_ent_t *ent; srpc_generic_reply_t *rep; - lstcon_rpc_t *crpc; - srpc_msg_t *msg; - lstcon_node_t *nd; - long dur; - struct timeval tv; - int error; + lstcon_rpc_t *crpc; + srpc_msg_t *msg; + lstcon_node_t *nd; + long dur; + struct timeval tv; + int error; LASSERT(head_up != NULL); @@ -544,9 +544,9 @@ void lstcon_rpc_trans_destroy(lstcon_rpc_trans_t *trans) { srpc_client_rpc_t *rpc; - lstcon_rpc_t *crpc; - lstcon_rpc_t *tmp; - int count = 0; + lstcon_rpc_t *crpc; + lstcon_rpc_t *tmp; + int count = 0; list_for_each_entry_safe(crpc, tmp, &trans->tas_rpcs_list, crp_link) { @@ -601,7 +601,7 @@ lstcon_sesrpc_prep(lstcon_node_t *nd, int transop, { srpc_mksn_reqst_t *msrq; srpc_rmsn_reqst_t *rsrq; - int rc; + int rc; switch (transop) { case LST_TRANS_SESNEW: @@ -638,7 +638,7 @@ int lstcon_dbgrpc_prep(lstcon_node_t *nd, unsigned feats, lstcon_rpc_t **crpc) { srpc_debug_reqst_t *drq; - int rc; + int rc; rc = lstcon_rpc_prep(nd, SRPC_SERVICE_DEBUG, feats, 0, 0, crpc); if (rc != 0) @@ -707,7 +707,7 @@ static lnet_process_id_packed_t * lstcon_next_id(int idx, int nkiov, lnet_kiov_t *kiov) { lnet_process_id_packed_t *pid; - int i; + int i; i = idx / SFW_ID_PER_PAGE; @@ -723,11 +723,11 @@ lstcon_dstnodes_prep(lstcon_group_t *grp, int idx, int dist, int span, int nkiov, lnet_kiov_t *kiov) { lnet_process_id_packed_t *pid; - lstcon_ndlink_t *ndl; - lstcon_node_t *nd; - int start; - int end; - int i = 0; + lstcon_ndlink_t *ndl; + lstcon_node_t *nd; + int start; + int end; + int i = 0; LASSERT(dist >= 1); LASSERT(span >= 1); @@ -777,8 +777,8 @@ lstcon_pingrpc_prep(lst_test_ping_param_t *param, srpc_test_reqst_t *req) { test_ping_req_t *prq = &req->tsr_u.ping; - prq->png_size = param->png_size; - prq->png_flags = param->png_flags; + prq->png_size = param->png_size; + prq->png_flags = param->png_flags; /* TODO dest */ return 0; } @@ -788,9 +788,10 @@ lstcon_bulkrpc_v0_prep(lst_test_bulk_param_t *param, srpc_test_reqst_t *req) { test_bulk_req_t *brq = &req->tsr_u.bulk_v0; - brq->blk_opc = param->blk_opc; - brq->blk_npg = (param->blk_size + PAGE_CACHE_SIZE - 1) / PAGE_CACHE_SIZE; - brq->blk_flags = param->blk_flags; + brq->blk_opc = param->blk_opc; + brq->blk_npg = (param->blk_size + PAGE_CACHE_SIZE - 1) / + PAGE_CACHE_SIZE; + brq->blk_flags = param->blk_flags; return 0; } @@ -816,7 +817,7 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats, lstcon_group_t *dgrp = test->tes_dst_grp; srpc_test_reqst_t *trq; srpc_bulk_t *bulk; - int i; + int i; int npg = 0; int nob = 0; int rc = 0; @@ -835,8 +836,10 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats, trq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.tes_reqst; if (transop == LST_TRANS_TSBSRVADD) { - int ndist = (sgrp->grp_nnode + test->tes_dist - 1) / test->tes_dist; - int nspan = (dgrp->grp_nnode + test->tes_span - 1) / test->tes_span; + int ndist = (sgrp->grp_nnode + test->tes_dist - 1) / + test->tes_dist; + int nspan = (dgrp->grp_nnode + test->tes_span - 1) / + test->tes_span; int nmax = (ndist + nspan - 1) / nspan; trq->tsr_ndest = 0; @@ -851,7 +854,8 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats, LASSERT(nob > 0); len = (feats & LST_FEAT_BULK_LEN) == 0 ? - PAGE_CACHE_SIZE : min_t(int, nob, PAGE_CACHE_SIZE); + PAGE_CACHE_SIZE : + min_t(int, nob, PAGE_CACHE_SIZE); nob -= len; bulk->bk_iovs[i].kiov_offset = 0; @@ -883,8 +887,8 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats, trq->tsr_loop = test->tes_loop; } - trq->tsr_sid = console_session.ses_id; - trq->tsr_bid = test->tes_hdr.tsb_id; + trq->tsr_sid = console_session.ses_id; + trq->tsr_bid = test->tes_hdr.tsb_id; trq->tsr_concur = test->tes_concur; trq->tsr_is_client = (transop == LST_TRANS_TSBCLIADD) ? 1 : 0; trq->tsr_stop_onerr = !!test->tes_stop_onerr; @@ -966,7 +970,7 @@ lstcon_rpc_stat_reply(lstcon_rpc_trans_t *trans, srpc_msg_t *msg, srpc_batch_reply_t *bat_rep; srpc_test_reply_t *test_rep; srpc_stat_reply_t *stat_rep; - int rc = 0; + int rc = 0; switch (trans->tas_opc) { case LST_TRANS_SESNEW: @@ -1084,11 +1088,11 @@ lstcon_rpc_trans_ndlist(struct list_head *ndlist, lstcon_rpc_trans_t **transpp) { lstcon_rpc_trans_t *trans; - lstcon_ndlink_t *ndl; - lstcon_node_t *nd; - lstcon_rpc_t *rpc; - unsigned feats; - int rc; + lstcon_ndlink_t *ndl; + lstcon_node_t *nd; + lstcon_rpc_t *rpc; + unsigned feats; + int rc; /* Creating session RPG for list of nodes */ @@ -1165,16 +1169,16 @@ lstcon_rpc_trans_ndlist(struct list_head *ndlist, static void lstcon_rpc_pinger(void *arg) { - stt_timer_t *ptimer = (stt_timer_t *)arg; + stt_timer_t *ptimer = (stt_timer_t *)arg; lstcon_rpc_trans_t *trans; - lstcon_rpc_t *crpc; - srpc_msg_t *rep; + lstcon_rpc_t *crpc; + srpc_msg_t *rep; srpc_debug_reqst_t *drq; - lstcon_ndlink_t *ndl; - lstcon_node_t *nd; - time_t intv; - int count = 0; - int rc; + lstcon_ndlink_t *ndl; + lstcon_node_t *nd; + time_t intv; + int count = 0; + int rc; /* RPC pinger is a special case of transaction, * it's called by timer at 8 seconds interval. @@ -1283,8 +1287,8 @@ lstcon_rpc_pinger(void *arg) int lstcon_rpc_pinger_start(void) { - stt_timer_t *ptimer; - int rc; + stt_timer_t *ptimer; + int rc; LASSERT(list_empty(&console_session.ses_rpc_freelist)); LASSERT(atomic_read(&console_session.ses_rpc_counter) == 0); @@ -1324,9 +1328,9 @@ void lstcon_rpc_cleanup_wait(void) { lstcon_rpc_trans_t *trans; - lstcon_rpc_t *crpc; - struct list_head *pacer; - struct list_head zlist; + lstcon_rpc_t *crpc; + struct list_head *pacer; + struct list_head zlist; /* Called with hold of global mutex */ diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.h b/drivers/staging/lustre/lnet/selftest/conrpc.h index 2353889c6eac..7d33cf9e9d99 100644 --- a/drivers/staging/lustre/lnet/selftest/conrpc.h +++ b/drivers/staging/lustre/lnet/selftest/conrpc.h @@ -64,31 +64,29 @@ struct lstcon_test; struct lstcon_node; typedef struct lstcon_rpc { - struct list_head crp_link; /* chain on rpc transaction */ + struct list_head crp_link; /* chain on rpc transaction */ srpc_client_rpc_t *crp_rpc; /* client rpc */ - struct lstcon_node *crp_node; /* destination node */ + struct lstcon_node *crp_node; /* destination node */ struct lstcon_rpc_trans *crp_trans; /* conrpc transaction */ - unsigned int crp_posted:1; /* rpc is posted */ - unsigned int crp_finished:1; /* rpc is finished */ - unsigned int crp_unpacked:1; /* reply is unpacked */ + unsigned int crp_posted:1; /* rpc is posted */ + unsigned int crp_finished:1; /* rpc is finished */ + unsigned int crp_unpacked:1; /* reply is unpacked */ /** RPC is embedded in other structure and can't free it */ - unsigned int crp_embedded:1; - int crp_status; /* console rpc errors */ - unsigned long crp_stamp; /* replied time stamp */ + unsigned int crp_embedded:1; + int crp_status; /* console rpc errors */ + unsigned long crp_stamp; /* replied time stamp */ } lstcon_rpc_t; typedef struct lstcon_rpc_trans { - struct list_head tas_olink; /* link chain on owner list */ - struct list_head tas_link; /* link chain on global list */ - int tas_opc; /* operation code of transaction */ - /* features mask is uptodate */ - unsigned tas_feats_updated; - /* test features mask */ - unsigned tas_features; - wait_queue_head_t tas_waitq; /* wait queue head */ - atomic_t tas_remaining; /* # of un-scheduled rpcs */ - struct list_head tas_rpcs_list; /* queued requests */ + struct list_head tas_olink; /* link chain on owner list */ + struct list_head tas_link; /* link chain on global list */ + int tas_opc; /* operation code of transaction */ + unsigned tas_feats_updated; /* features mask is uptodate */ + unsigned tas_features; /* test features mask */ + wait_queue_head_t tas_waitq; /* wait queue head */ + atomic_t tas_remaining; /* # of un-scheduled rpcs */ + struct list_head tas_rpcs_list; /* queued requests */ } lstcon_rpc_trans_t; #define LST_TRANS_PRIVATE 0x1000 diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c index 2b5f53c7a730..f47c8f27f975 100644 --- a/drivers/staging/lustre/lnet/selftest/console.c +++ b/drivers/staging/lustre/lnet/selftest/console.c @@ -59,7 +59,7 @@ do { \ (p)->nle_nnode++; \ } while (0) -lstcon_session_t console_session; +lstcon_session_t console_session; static void lstcon_node_get(lstcon_node_t *nd) @@ -73,7 +73,7 @@ static int lstcon_node_find(lnet_process_id_t id, lstcon_node_t **ndpp, int create) { lstcon_ndlink_t *ndl; - unsigned int idx = LNET_NIDADDR(id.nid) % LST_GLOBAL_HASHSIZE; + unsigned int idx = LNET_NIDADDR(id.nid) % LST_GLOBAL_HASHSIZE; LASSERT(id.nid != LNET_NID_ANY); @@ -117,7 +117,7 @@ lstcon_node_find(lnet_process_id_t id, lstcon_node_t **ndpp, int create) static void lstcon_node_put(lstcon_node_t *nd) { - lstcon_ndlink_t *ndl; + lstcon_ndlink_t *ndl; LASSERT(nd->nd_ref > 0); @@ -140,10 +140,10 @@ static int lstcon_ndlink_find(struct list_head *hash, lnet_process_id_t id, lstcon_ndlink_t **ndlpp, int create) { - unsigned int idx = LNET_NIDADDR(id.nid) % LST_NODE_HASHSIZE; + unsigned int idx = LNET_NIDADDR(id.nid) % LST_NODE_HASHSIZE; lstcon_ndlink_t *ndl; - lstcon_node_t *nd; - int rc; + lstcon_node_t *nd; + int rc; if (id.nid == LNET_NID_ANY) return -EINVAL; @@ -197,7 +197,7 @@ static int lstcon_group_alloc(char *name, lstcon_group_t **grpp) { lstcon_group_t *grp; - int i; + int i; LIBCFS_ALLOC(grp, offsetof(lstcon_group_t, grp_ndl_hash[LST_NODE_HASHSIZE])); @@ -243,7 +243,7 @@ lstcon_group_drain(lstcon_group_t *grp, int keep) static void lstcon_group_decref(lstcon_group_t *grp) { - int i; + int i; if (--grp->grp_ref > 0) return; @@ -264,7 +264,7 @@ lstcon_group_decref(lstcon_group_t *grp) static int lstcon_group_find(const char *name, lstcon_group_t **grpp) { - lstcon_group_t *grp; + lstcon_group_t *grp; list_for_each_entry(grp, &console_session.ses_grp_list, grp_link) { if (strncmp(grp->grp_name, name, LST_NAME_SIZE) != 0) @@ -288,7 +288,7 @@ static int lstcon_group_ndlink_find(lstcon_group_t *grp, lnet_process_id_t id, lstcon_ndlink_t **ndlpp, int create) { - int rc; + int rc; rc = lstcon_ndlink_find(&grp->grp_ndl_hash[0], id, ndlpp, create); if (rc != 0) @@ -404,12 +404,12 @@ lstcon_group_nodes_add(lstcon_group_t *grp, int count, lnet_process_id_t *ids_up, unsigned *featp, struct list_head *result_up) { - lstcon_rpc_trans_t *trans; - lstcon_ndlink_t *ndl; - lstcon_group_t *tmp; - lnet_process_id_t id; - int i; - int rc; + lstcon_rpc_trans_t *trans; + lstcon_ndlink_t *ndl; + lstcon_group_t *tmp; + lnet_process_id_t id; + int i; + int rc; rc = lstcon_group_alloc(NULL, &tmp); if (rc != 0) { @@ -471,12 +471,12 @@ lstcon_group_nodes_remove(lstcon_group_t *grp, int count, lnet_process_id_t *ids_up, struct list_head *result_up) { - lstcon_rpc_trans_t *trans; - lstcon_ndlink_t *ndl; - lstcon_group_t *tmp; - lnet_process_id_t id; - int rc; - int i; + lstcon_rpc_trans_t *trans; + lstcon_ndlink_t *ndl; + lstcon_group_t *tmp; + lnet_process_id_t id; + int rc; + int i; /* End session and remove node from the group */ @@ -525,7 +525,7 @@ int lstcon_group_add(char *name) { lstcon_group_t *grp; - int rc; + int rc; rc = (lstcon_group_find(name, &grp) == 0)? -EEXIST: 0; if (rc != 0) { @@ -549,8 +549,8 @@ int lstcon_nodes_add(char *name, int count, lnet_process_id_t *ids_up, unsigned *featp, struct list_head *result_up) { - lstcon_group_t *grp; - int rc; + lstcon_group_t *grp; + int rc; LASSERT(count > 0); LASSERT(ids_up != NULL); @@ -580,8 +580,8 @@ int lstcon_group_del(char *name) { lstcon_rpc_trans_t *trans; - lstcon_group_t *grp; - int rc; + lstcon_group_t *grp; + int rc; rc = lstcon_group_find(name, &grp); if (rc != 0) { @@ -621,7 +621,7 @@ int lstcon_group_clean(char *name, int args) { lstcon_group_t *grp = NULL; - int rc; + int rc; rc = lstcon_group_find(name, &grp); if (rc != 0) { @@ -654,7 +654,7 @@ lstcon_nodes_remove(char *name, int count, lnet_process_id_t *ids_up, struct list_head *result_up) { lstcon_group_t *grp = NULL; - int rc; + int rc; rc = lstcon_group_find(name, &grp); if (rc != 0) { @@ -682,9 +682,9 @@ lstcon_nodes_remove(char *name, int count, int lstcon_group_refresh(char *name, struct list_head *result_up) { - lstcon_rpc_trans_t *trans; - lstcon_group_t *grp; - int rc; + lstcon_rpc_trans_t *trans; + lstcon_group_t *grp; + int rc; rc = lstcon_group_find(name, &grp); if (rc != 0) { @@ -743,10 +743,10 @@ static int lstcon_nodes_getent(struct list_head *head, int *index_p, int *count_p, lstcon_node_ent_t *dents_up) { - lstcon_ndlink_t *ndl; - lstcon_node_t *nd; - int count = 0; - int index = 0; + lstcon_ndlink_t *ndl; + lstcon_node_t *nd; + int count = 0; + int index = 0; LASSERT(index_p != NULL && count_p != NULL); LASSERT(dents_up != NULL); @@ -784,9 +784,9 @@ lstcon_group_info(char *name, lstcon_ndlist_ent_t *gents_p, int *index_p, int *count_p, lstcon_node_ent_t *dents_up) { lstcon_ndlist_ent_t *gentp; - lstcon_group_t *grp; - lstcon_ndlink_t *ndl; - int rc; + lstcon_group_t *grp; + lstcon_ndlink_t *ndl; + int rc; rc = lstcon_group_find(name, &grp); if (rc != 0) { @@ -828,7 +828,7 @@ lstcon_group_info(char *name, lstcon_ndlist_ent_t *gents_p, static int lstcon_batch_find(const char *name, lstcon_batch_t **batpp) { - lstcon_batch_t *bat; + lstcon_batch_t *bat; list_for_each_entry(bat, &console_session.ses_bat_list, bat_link) { if (strncmp(bat->bat_name, name, LST_NAME_SIZE) == 0) { @@ -843,9 +843,9 @@ lstcon_batch_find(const char *name, lstcon_batch_t **batpp) int lstcon_batch_add(char *name) { - lstcon_batch_t *bat; - int i; - int rc; + lstcon_batch_t *bat; + int i; + int rc; rc = (lstcon_batch_find(name, &bat) == 0)? -EEXIST: 0; if (rc != 0) { @@ -903,7 +903,7 @@ lstcon_batch_add(char *name) int lstcon_batch_list(int index, int len, char *name_up) { - lstcon_batch_t *bat; + lstcon_batch_t *bat; LASSERT(name_up != NULL); LASSERT(index >= 0); @@ -924,12 +924,12 @@ lstcon_batch_info(char *name, lstcon_test_batch_ent_t *ent_up, int server, lstcon_node_ent_t *dents_up) { lstcon_test_batch_ent_t *entp; - struct list_head *clilst; - struct list_head *srvlst; - lstcon_test_t *test = NULL; - lstcon_batch_t *bat; - lstcon_ndlink_t *ndl; - int rc; + struct list_head *clilst; + struct list_head *srvlst; + lstcon_test_t *test = NULL; + lstcon_batch_t *bat; + lstcon_ndlink_t *ndl; + int rc; rc = lstcon_batch_find(name, &bat); if (rc != 0) { @@ -1018,7 +1018,7 @@ lstcon_batch_op(lstcon_batch_t *bat, int transop, struct list_head *result_up) { lstcon_rpc_trans_t *trans; - int rc; + int rc; rc = lstcon_rpc_trans_ndlist(&bat->bat_cli_list, &bat->bat_trans_list, transop, @@ -1041,7 +1041,7 @@ int lstcon_batch_run(char *name, int timeout, struct list_head *result_up) { lstcon_batch_t *bat; - int rc; + int rc; if (lstcon_batch_find(name, &bat) != 0) { CDEBUG(D_NET, "Can't find batch %s\n", name); @@ -1063,7 +1063,7 @@ int lstcon_batch_stop(char *name, int force, struct list_head *result_up) { lstcon_batch_t *bat; - int rc; + int rc; if (lstcon_batch_find(name, &bat) != 0) { CDEBUG(D_NET, "Can't find batch %s\n", name); @@ -1084,9 +1084,9 @@ lstcon_batch_stop(char *name, int force, struct list_head *result_up) static void lstcon_batch_destroy(lstcon_batch_t *bat) { - lstcon_ndlink_t *ndl; - lstcon_test_t *test; - int i; + lstcon_ndlink_t *ndl; + lstcon_test_t *test; + int i; list_del(&bat->bat_link); @@ -1137,11 +1137,11 @@ lstcon_batch_destroy(lstcon_batch_t *bat) static int lstcon_testrpc_condition(int transop, lstcon_node_t *nd, void *arg) { - lstcon_test_t *test; - lstcon_batch_t *batch; - lstcon_ndlink_t *ndl; - struct list_head *hash; - struct list_head *head; + lstcon_test_t *test; + lstcon_batch_t *batch; + lstcon_ndlink_t *ndl; + struct list_head *hash; + struct list_head *head; test = (lstcon_test_t *)arg; LASSERT(test != NULL); @@ -1181,10 +1181,10 @@ lstcon_testrpc_condition(int transop, lstcon_node_t *nd, void *arg) static int lstcon_test_nodes_add(lstcon_test_t *test, struct list_head *result_up) { - lstcon_rpc_trans_t *trans; - lstcon_group_t *grp; - int transop; - int rc; + lstcon_rpc_trans_t *trans; + lstcon_group_t *grp; + int transop; + int rc; LASSERT(test->tes_src_grp != NULL); LASSERT(test->tes_dst_grp != NULL); @@ -1251,8 +1251,8 @@ lstcon_verify_batch(const char *name, lstcon_batch_t **batch) static int lstcon_verify_group(const char *name, lstcon_group_t **grp) { - int rc; - lstcon_ndlink_t *ndl; + int rc; + lstcon_ndlink_t *ndl; rc = lstcon_group_find(name, grp); if (rc != 0) { @@ -1398,13 +1398,13 @@ lstcon_test_batch_query(char *name, int testidx, int client, int timeout, struct list_head *result_up) { lstcon_rpc_trans_t *trans; - struct list_head *translist; - struct list_head *ndlist; - lstcon_tsb_hdr_t *hdr; - lstcon_batch_t *batch; - lstcon_test_t *test = NULL; - int transop; - int rc; + struct list_head *translist; + struct list_head *ndlist; + lstcon_tsb_hdr_t *hdr; + lstcon_batch_t *batch; + lstcon_test_t *test = NULL; + int transop; + int rc; rc = lstcon_batch_find(name, &batch); if (rc != 0) { @@ -1460,9 +1460,9 @@ lstcon_statrpc_readent(int transop, srpc_msg_t *msg, lstcon_rpc_ent_t *ent_up) { srpc_stat_reply_t *rep = &msg->msg_body.stat_reply; - sfw_counters_t *sfwk_stat; - srpc_counters_t *srpc_stat; - lnet_counters_t *lnet_stat; + sfw_counters_t *sfwk_stat; + srpc_counters_t *srpc_stat; + lnet_counters_t *lnet_stat; if (rep->str_status != 0) return 0; @@ -1483,9 +1483,9 @@ static int lstcon_ndlist_stat(struct list_head *ndlist, int timeout, struct list_head *result_up) { - struct list_head head; + struct list_head head; lstcon_rpc_trans_t *trans; - int rc; + int rc; INIT_LIST_HEAD(&head); @@ -1508,8 +1508,8 @@ lstcon_ndlist_stat(struct list_head *ndlist, int lstcon_group_stat(char *grp_name, int timeout, struct list_head *result_up) { - lstcon_group_t *grp; - int rc; + lstcon_group_t *grp; + int rc; rc = lstcon_group_find(grp_name, &grp); if (rc != 0) { @@ -1528,11 +1528,11 @@ int lstcon_nodes_stat(int count, lnet_process_id_t *ids_up, int timeout, struct list_head *result_up) { - lstcon_ndlink_t *ndl; - lstcon_group_t *tmp; - lnet_process_id_t id; - int i; - int rc; + lstcon_ndlink_t *ndl; + lstcon_group_t *tmp; + lnet_process_id_t id; + int i; + int rc; rc = lstcon_group_alloc(NULL, &tmp); if (rc != 0) { @@ -1604,7 +1604,7 @@ lstcon_batch_debug(int timeout, char *name, int client, struct list_head *result_up) { lstcon_batch_t *bat; - int rc; + int rc; rc = lstcon_batch_find(name, &bat); if (rc != 0) @@ -1622,7 +1622,7 @@ lstcon_group_debug(int timeout, char *name, struct list_head *result_up) { lstcon_group_t *grp; - int rc; + int rc; rc = lstcon_group_find(name, &grp); if (rc != 0) @@ -1640,11 +1640,11 @@ lstcon_nodes_debug(int timeout, int count, lnet_process_id_t *ids_up, struct list_head *result_up) { - lnet_process_id_t id; - lstcon_ndlink_t *ndl; - lstcon_group_t *grp; - int i; - int rc; + lnet_process_id_t id; + lstcon_ndlink_t *ndl; + lstcon_group_t *grp; + int i; + int rc; rc = lstcon_group_alloc(NULL, &grp); if (rc != 0) { @@ -1689,7 +1689,7 @@ lstcon_session_match(lst_sid_t sid) static void lstcon_new_session_id(lst_sid_t *sid) { - lnet_process_id_t id; + lnet_process_id_t id; LASSERT(console_session.ses_state == LST_SESSION_NONE); @@ -1704,8 +1704,8 @@ int lstcon_session_new(char *name, int key, unsigned feats, int timeout, int force, lst_sid_t *sid_up) { - int rc = 0; - int i; + int rc = 0; + int i; if (console_session.ses_state != LST_SESSION_NONE) { /* session exists */ @@ -1733,9 +1733,9 @@ lstcon_session_new(char *name, int key, unsigned feats, lstcon_new_session_id(&console_session.ses_id); - console_session.ses_key = key; - console_session.ses_state = LST_SESSION_ACTIVE; - console_session.ses_force = !!force; + console_session.ses_key = key; + console_session.ses_state = LST_SESSION_ACTIVE; + console_session.ses_force = !!force; console_session.ses_features = feats; console_session.ses_feats_updated = 0; console_session.ses_timeout = (timeout <= 0) ? @@ -1770,8 +1770,8 @@ lstcon_session_info(lst_sid_t *sid_up, int *key_up, unsigned *featp, lstcon_ndlist_ent_t *ndinfo_up, char *name_up, int len) { lstcon_ndlist_ent_t *entp; - lstcon_ndlink_t *ndl; - int rc = 0; + lstcon_ndlink_t *ndl; + int rc = 0; if (console_session.ses_state != LST_SESSION_ACTIVE) return -ESRCH; @@ -1802,9 +1802,9 @@ int lstcon_session_end(void) { lstcon_rpc_trans_t *trans; - lstcon_group_t *grp; - lstcon_batch_t *bat; - int rc = 0; + lstcon_group_t *grp; + lstcon_batch_t *bat; + int rc = 0; LASSERT(console_session.ses_state == LST_SESSION_ACTIVE); @@ -1894,13 +1894,13 @@ lstcon_session_feats_check(unsigned feats) static int lstcon_acceptor_handle(srpc_server_rpc_t *rpc) { - srpc_msg_t *rep = &rpc->srpc_replymsg; - srpc_msg_t *req = &rpc->srpc_reqstbuf->buf_msg; + srpc_msg_t *rep = &rpc->srpc_replymsg; + srpc_msg_t *req = &rpc->srpc_reqstbuf->buf_msg; srpc_join_reqst_t *jreq = &req->msg_body.join_reqst; srpc_join_reply_t *jrep = &rep->msg_body.join_reply; - lstcon_group_t *grp = NULL; - lstcon_ndlink_t *ndl; - int rc = 0; + lstcon_group_t *grp = NULL; + lstcon_ndlink_t *ndl; + int rc = 0; sfw_unpack_message(req); @@ -1978,9 +1978,9 @@ srpc_service_t lstcon_acceptor_service; static void lstcon_init_acceptor_service(void) { /* initialize selftest console acceptor service table */ - lstcon_acceptor_service.sv_name = "join session"; - lstcon_acceptor_service.sv_handler = lstcon_acceptor_handle; - lstcon_acceptor_service.sv_id = SRPC_SERVICE_JOIN; + lstcon_acceptor_service.sv_name = "join session"; + lstcon_acceptor_service.sv_handler = lstcon_acceptor_handle; + lstcon_acceptor_service.sv_id = SRPC_SERVICE_JOIN; lstcon_acceptor_service.sv_wi_total = SFW_FRWK_WI_MAX; } @@ -1992,19 +1992,19 @@ static DECLARE_IOCTL_HANDLER(lstcon_ioctl_handler, lstcon_ioctl_entry); int lstcon_console_init(void) { - int i; - int rc; + int i; + int rc; memset(&console_session, 0, sizeof(lstcon_session_t)); - console_session.ses_id = LST_INVALID_SID; - console_session.ses_state = LST_SESSION_NONE; - console_session.ses_timeout = 0; - console_session.ses_force = 0; - console_session.ses_expired = 0; - console_session.ses_feats_updated = 0; - console_session.ses_features = LST_FEATS_MASK; - console_session.ses_laststamp = get_seconds(); + console_session.ses_id = LST_INVALID_SID; + console_session.ses_state = LST_SESSION_NONE; + console_session.ses_timeout = 0; + console_session.ses_force = 0; + console_session.ses_expired = 0; + console_session.ses_feats_updated = 0; + console_session.ses_features = LST_FEATS_MASK; + console_session.ses_laststamp = get_seconds(); mutex_init(&console_session.ses_mutex); @@ -2062,7 +2062,7 @@ out: int lstcon_console_fini(void) { - int i; + int i; libcfs_deregister_ioctl(&lstcon_ioctl_handler); diff --git a/drivers/staging/lustre/lnet/selftest/console.h b/drivers/staging/lustre/lnet/selftest/console.h index e41ca89f10ba..c4cf0aed80e1 100644 --- a/drivers/staging/lustre/lnet/selftest/console.h +++ b/drivers/staging/lustre/lnet/selftest/console.h @@ -52,119 +52,121 @@ #include "conrpc.h" typedef struct lstcon_node { - lnet_process_id_t nd_id; /* id of the node */ - int nd_ref; /* reference count */ - int nd_state; /* state of the node */ - int nd_timeout; /* session timeout */ - unsigned long nd_stamp; /* timestamp of last replied RPC */ - struct lstcon_rpc nd_ping; /* ping rpc */ -} lstcon_node_t; /*** node descriptor */ + lnet_process_id_t nd_id; /* id of the node */ + int nd_ref; /* reference count */ + int nd_state; /* state of the node */ + int nd_timeout; /* session timeout */ + unsigned long nd_stamp; /* timestamp of last replied RPC */ + struct lstcon_rpc nd_ping; /* ping rpc */ +} lstcon_node_t; /* node descriptor */ typedef struct { - struct list_head ndl_link; /* chain on list */ - struct list_head ndl_hlink; /* chain on hash */ - lstcon_node_t *ndl_node; /* pointer to node */ -} lstcon_ndlink_t; /*** node link descriptor */ + struct list_head ndl_link; /* chain on list */ + struct list_head ndl_hlink; /* chain on hash */ + lstcon_node_t *ndl_node; /* pointer to node */ +} lstcon_ndlink_t; /* node link descriptor */ typedef struct { - struct list_head grp_link; /* chain on global group list */ - int grp_ref; /* reference count */ - int grp_userland; /* has userland nodes */ - int grp_nnode; /* # of nodes */ - char grp_name[LST_NAME_SIZE]; /* group name */ + struct list_head grp_link; /* chain on global group list + */ + int grp_ref; /* reference count */ + int grp_userland; /* has userland nodes */ + int grp_nnode; /* # of nodes */ + char grp_name[LST_NAME_SIZE]; /* group name */ - struct list_head grp_trans_list; /* transaction list */ - struct list_head grp_ndl_list; /* nodes list */ - struct list_head grp_ndl_hash[0];/* hash table for nodes */ -} lstcon_group_t; /*** (alias of nodes) group descriptor */ + struct list_head grp_trans_list; /* transaction list */ + struct list_head grp_ndl_list; /* nodes list */ + struct list_head grp_ndl_hash[0]; /* hash table for nodes */ +} lstcon_group_t; /* (alias of nodes) group descriptor */ -#define LST_BATCH_IDLE 0xB0 /* idle batch */ -#define LST_BATCH_RUNNING 0xB1 /* running batch */ +#define LST_BATCH_IDLE 0xB0 /* idle batch */ +#define LST_BATCH_RUNNING 0xB1 /* running batch */ typedef struct lstcon_tsb_hdr { - lst_bid_t tsb_id; /* batch ID */ - int tsb_index; /* test index */ + lst_bid_t tsb_id; /* batch ID */ + int tsb_index; /* test index */ } lstcon_tsb_hdr_t; typedef struct { - lstcon_tsb_hdr_t bat_hdr; /* test_batch header */ - struct list_head bat_link; /* chain on session's batches list */ - int bat_ntest; /* # of test */ - int bat_state; /* state of the batch */ - int bat_arg; /* parameter for run|stop, timeout for run, force for stop */ - char bat_name[LST_NAME_SIZE]; /* name of batch */ + lstcon_tsb_hdr_t bat_hdr; /* test_batch header */ + struct list_head bat_link; /* chain on session's batches list */ + int bat_ntest; /* # of test */ + int bat_state; /* state of the batch */ + int bat_arg; /* parameter for run|stop, timeout + * for run, force for stop */ + char bat_name[LST_NAME_SIZE];/* name of batch */ - struct list_head bat_test_list; /* list head of tests (lstcon_test_t) */ - struct list_head bat_trans_list; /* list head of transaction */ - struct list_head bat_cli_list; /* list head of client nodes (lstcon_node_t) */ - struct list_head *bat_cli_hash; /* hash table of client nodes */ - struct list_head bat_srv_list; /* list head of server nodes */ - struct list_head *bat_srv_hash; /* hash table of server nodes */ -} lstcon_batch_t; /*** (tests ) batch descriptor */ + struct list_head bat_test_list; /* list head of tests (lstcon_test_t) + */ + struct list_head bat_trans_list; /* list head of transaction */ + struct list_head bat_cli_list; /* list head of client nodes + * (lstcon_node_t) */ + struct list_head *bat_cli_hash; /* hash table of client nodes */ + struct list_head bat_srv_list; /* list head of server nodes */ + struct list_head *bat_srv_hash; /* hash table of server nodes */ +} lstcon_batch_t; /* (tests ) batch descriptor */ typedef struct lstcon_test { - lstcon_tsb_hdr_t tes_hdr; /* test batch header */ - struct list_head tes_link; /* chain on batch's tests list */ - lstcon_batch_t *tes_batch; /* pointer to batch */ + lstcon_tsb_hdr_t tes_hdr; /* test batch header */ + struct list_head tes_link; /* chain on batch's tests list */ + lstcon_batch_t *tes_batch; /* pointer to batch */ - int tes_type; /* type of the test, i.e: bulk, ping */ - int tes_stop_onerr; /* stop on error */ - int tes_oneside; /* one-sided test */ - int tes_concur; /* concurrency */ - int tes_loop; /* loop count */ - int tes_dist; /* nodes distribution of target group */ - int tes_span; /* nodes span of target group */ - int tes_cliidx; /* client index, used for RPC creating */ + int tes_type; /* type of the test, i.e: bulk, ping */ + int tes_stop_onerr; /* stop on error */ + int tes_oneside; /* one-sided test */ + int tes_concur; /* concurrency */ + int tes_loop; /* loop count */ + int tes_dist; /* nodes distribution of target group */ + int tes_span; /* nodes span of target group */ + int tes_cliidx; /* client index, used for RPC creating */ - struct list_head tes_trans_list; /* transaction list */ - lstcon_group_t *tes_src_grp; /* group run the test */ - lstcon_group_t *tes_dst_grp; /* target group */ + struct list_head tes_trans_list; /* transaction list */ + lstcon_group_t *tes_src_grp; /* group run the test */ + lstcon_group_t *tes_dst_grp; /* target group */ - int tes_paramlen; /* test parameter length */ - char tes_param[0]; /* test parameter */ -} lstcon_test_t; /*** a single test descriptor */ + int tes_paramlen; /* test parameter length */ + char tes_param[0]; /* test parameter */ +} lstcon_test_t; /* a single test descriptor */ -#define LST_GLOBAL_HASHSIZE 503 /* global nodes hash table size */ -#define LST_NODE_HASHSIZE 239 /* node hash table (for batch or group) */ +#define LST_GLOBAL_HASHSIZE 503 /* global nodes hash table size */ +#define LST_NODE_HASHSIZE 239 /* node hash table (for batch or group) */ -#define LST_SESSION_NONE 0x0 /* no session */ -#define LST_SESSION_ACTIVE 0x1 /* working session */ +#define LST_SESSION_NONE 0x0 /* no session */ +#define LST_SESSION_ACTIVE 0x1 /* working session */ -#define LST_CONSOLE_TIMEOUT 300 /* default console timeout */ +#define LST_CONSOLE_TIMEOUT 300 /* default console timeout */ typedef struct { - struct mutex ses_mutex; /* only 1 thread in session */ - lst_sid_t ses_id; /* global session id */ - int ses_key; /* local session key */ - int ses_state; /* state of session */ - int ses_timeout; /* timeout in seconds */ - time_t ses_laststamp; /* last operation stamp (seconds) */ - /** tests features of the session */ - unsigned ses_features; - /** features are synced with remote test nodes */ - unsigned ses_feats_updated:1; - /** force creating */ - unsigned ses_force:1; - /** session is shutting down */ - unsigned ses_shutdown:1; - /** console is timedout */ - unsigned ses_expired:1; - __u64 ses_id_cookie; /* batch id cookie */ - char ses_name[LST_NAME_SIZE]; /* session name */ - lstcon_rpc_trans_t *ses_ping; /* session pinger */ - stt_timer_t ses_ping_timer; /* timer for pinger */ - lstcon_trans_stat_t ses_trans_stat; /* transaction stats */ + struct mutex ses_mutex; /* only 1 thread in session */ + lst_sid_t ses_id; /* global session id */ + int ses_key; /* local session key */ + int ses_state; /* state of session */ + int ses_timeout; /* timeout in seconds */ + time_t ses_laststamp; /* last operation stamp (seconds) + */ + unsigned ses_features; /* tests features of the session + */ + unsigned ses_feats_updated:1; /* features are synced with + * remote test nodes */ + unsigned ses_force:1; /* force creating */ + unsigned ses_shutdown:1; /* session is shutting down */ + unsigned ses_expired:1; /* console is timedout */ + __u64 ses_id_cookie; /* batch id cookie */ + char ses_name[LST_NAME_SIZE];/* session name */ + lstcon_rpc_trans_t *ses_ping; /* session pinger */ + stt_timer_t ses_ping_timer; /* timer for pinger */ + lstcon_trans_stat_t ses_trans_stat; /* transaction stats */ - struct list_head ses_trans_list; /* global list of transaction */ - struct list_head ses_grp_list; /* global list of groups */ - struct list_head ses_bat_list; /* global list of batches */ - struct list_head ses_ndl_list; /* global list of nodes */ - struct list_head *ses_ndl_hash; /* hash table of nodes */ + struct list_head ses_trans_list; /* global list of transaction */ + struct list_head ses_grp_list; /* global list of groups */ + struct list_head ses_bat_list; /* global list of batches */ + struct list_head ses_ndl_list; /* global list of nodes */ + struct list_head *ses_ndl_hash; /* hash table of nodes */ - spinlock_t ses_rpc_lock; /* serialize */ - atomic_t ses_rpc_counter;/* # of initialized RPCs */ - struct list_head ses_rpc_freelist; /* idle console rpc */ -} lstcon_session_t; /*** session descriptor */ + spinlock_t ses_rpc_lock; /* serialize */ + atomic_t ses_rpc_counter; /* # of initialized RPCs */ + struct list_head ses_rpc_freelist; /* idle console rpc */ +} lstcon_session_t; /* session descriptor */ extern lstcon_session_t console_session; diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c index a93a90de0f85..7c5185a2a795 100644 --- a/drivers/staging/lustre/lnet/selftest/framework.c +++ b/drivers/staging/lustre/lnet/selftest/framework.c @@ -53,20 +53,20 @@ static int rpc_timeout = 64; module_param(rpc_timeout, int, 0644); MODULE_PARM_DESC(rpc_timeout, "rpc timeout in seconds (64 by default, 0 == never)"); -#define sfw_unpack_id(id) \ -do { \ +#define sfw_unpack_id(id) \ +do { \ __swab64s(&(id).nid); \ __swab32s(&(id).pid); \ } while (0) -#define sfw_unpack_sid(sid) \ -do { \ +#define sfw_unpack_sid(sid) \ +do { \ __swab64s(&(sid).ses_nid); \ __swab64s(&(sid).ses_stamp); \ } while (0) -#define sfw_unpack_fw_counters(fc) \ -do { \ +#define sfw_unpack_fw_counters(fc) \ +do { \ __swab32s(&(fc).running_ms); \ __swab32s(&(fc).active_batches); \ __swab32s(&(fc).zombie_sessions); \ @@ -75,7 +75,7 @@ do { \ } while (0) #define sfw_unpack_rpc_counters(rc) \ -do { \ +do { \ __swab32s(&(rc).errors); \ __swab32s(&(rc).rpcs_sent); \ __swab32s(&(rc).rpcs_rcvd); \ @@ -86,7 +86,7 @@ do { \ } while (0) #define sfw_unpack_lnet_counters(lc) \ -do { \ +do { \ __swab32s(&(lc).errors); \ __swab32s(&(lc).msgs_max); \ __swab32s(&(lc).msgs_alloc); \ @@ -104,14 +104,14 @@ do { \ #define sfw_batch_active(b) (atomic_read(&(b)->bat_nactive) != 0) static struct smoketest_framework { - struct list_head fw_zombie_rpcs; /* RPCs to be recycled */ - struct list_head fw_zombie_sessions; /* stopping sessions */ - struct list_head fw_tests; /* registered test cases */ - atomic_t fw_nzombies; /* # zombie sessions */ - spinlock_t fw_lock; /* serialise */ - sfw_session_t *fw_session; /* _the_ session */ - int fw_shuttingdown; /* shutdown in progress */ - srpc_server_rpc_t *fw_active_srpc; /* running RPC */ + struct list_head fw_zombie_rpcs; /* RPCs to be recycled */ + struct list_head fw_zombie_sessions; /* stopping sessions */ + struct list_head fw_tests; /* registered test cases */ + atomic_t fw_nzombies; /* # zombie sessions */ + spinlock_t fw_lock; /* serialise */ + sfw_session_t *fw_session; /* _the_ session */ + int fw_shuttingdown; /* shutdown in progress */ + srpc_server_rpc_t *fw_active_srpc; /* running RPC */ } sfw_data; /* forward ref's */ @@ -160,7 +160,7 @@ static void sfw_add_session_timer(void) { sfw_session_t *sn = sfw_data.fw_session; - stt_timer_t *timer = &sn->sn_timer; + stt_timer_t *timer = &sn->sn_timer; LASSERT(!sfw_data.fw_shuttingdown); @@ -199,8 +199,8 @@ sfw_deactivate_session(void) __must_hold(&sfw_data.fw_lock) { sfw_session_t *sn = sfw_data.fw_session; - int nactive = 0; - sfw_batch_t *tsb; + int nactive = 0; + sfw_batch_t *tsb; sfw_test_case_t *tsc; if (sn == NULL) return; @@ -273,7 +273,7 @@ sfw_init_session(sfw_session_t *sn, lst_sid_t sid, strlcpy(&sn->sn_name[0], name, sizeof(sn->sn_name)); sn->sn_timer_active = 0; - sn->sn_id = sid; + sn->sn_id = sid; sn->sn_features = features; sn->sn_timeout = session_timeout; sn->sn_started = cfs_time_current(); @@ -287,8 +287,8 @@ sfw_init_session(sfw_session_t *sn, lst_sid_t sid, static void sfw_server_rpc_done(struct srpc_server_rpc *rpc) { - struct srpc_service *sv = rpc->srpc_scd->scd_svc; - int status = rpc->srpc_status; + struct srpc_service *sv = rpc->srpc_scd->scd_svc; + int status = rpc->srpc_status; CDEBUG(D_NET, "Incoming framework RPC done: service %s, peer %s, status %s:%d\n", @@ -327,7 +327,7 @@ static sfw_batch_t * sfw_find_batch(lst_bid_t bid) { sfw_session_t *sn = sfw_data.fw_session; - sfw_batch_t *bat; + sfw_batch_t *bat; LASSERT(sn != NULL); @@ -343,7 +343,7 @@ static sfw_batch_t * sfw_bid2batch(lst_bid_t bid) { sfw_session_t *sn = sfw_data.fw_session; - sfw_batch_t *bat; + sfw_batch_t *bat; LASSERT(sn != NULL); @@ -368,10 +368,10 @@ sfw_bid2batch(lst_bid_t bid) static int sfw_get_stats(srpc_stat_reqst_t *request, srpc_stat_reply_t *reply) { - sfw_session_t *sn = sfw_data.fw_session; + sfw_session_t *sn = sfw_data.fw_session; sfw_counters_t *cnt = &reply->str_fw; - sfw_batch_t *bat; - struct timeval tv; + sfw_batch_t *bat; + struct timeval tv; reply->str_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id; @@ -412,9 +412,9 @@ int sfw_make_session(srpc_mksn_reqst_t *request, srpc_mksn_reply_t *reply) { sfw_session_t *sn = sfw_data.fw_session; - srpc_msg_t *msg = container_of(request, srpc_msg_t, + srpc_msg_t *msg = container_of(request, srpc_msg_t, msg_body.mksn_reqst); - int cplen = 0; + int cplen = 0; if (request->mksn_sid.ses_nid == LNET_NID_ANY) { reply->mksn_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id; @@ -533,7 +533,7 @@ sfw_debug_session(srpc_debug_reqst_t *request, srpc_debug_reply_t *reply) static void sfw_test_rpc_fini(srpc_client_rpc_t *rpc) { - sfw_test_unit_t *tsu = rpc->crpc_priv; + sfw_test_unit_t *tsu = rpc->crpc_priv; sfw_test_instance_t *tsi = tsu->tsu_instance; /* Called with hold of tsi->tsi_lock */ @@ -544,9 +544,9 @@ sfw_test_rpc_fini(srpc_client_rpc_t *rpc) static inline int sfw_test_buffers(sfw_test_instance_t *tsi) { - struct sfw_test_case *tsc = sfw_find_test_case(tsi->tsi_service); - struct srpc_service *svc = tsc->tsc_srv_service; - int nbuf; + struct sfw_test_case *tsc = sfw_find_test_case(tsi->tsi_service); + struct srpc_service *svc = tsc->tsc_srv_service; + int nbuf; nbuf = min(svc->sv_wi_total, tsi->tsi_loop) / svc->sv_ncpts; return max(SFW_TEST_WI_MIN, nbuf + SFW_TEST_WI_EXTRA); @@ -555,10 +555,10 @@ sfw_test_buffers(sfw_test_instance_t *tsi) static int sfw_load_test(struct sfw_test_instance *tsi) { - struct sfw_test_case *tsc; - struct srpc_service *svc; - int nbuf; - int rc; + struct sfw_test_case *tsc; + struct srpc_service *svc; + int nbuf; + int rc; LASSERT(tsi != NULL); tsc = sfw_find_test_case(tsi->tsi_service); @@ -611,7 +611,7 @@ static void sfw_destroy_test_instance(sfw_test_instance_t *tsi) { srpc_client_rpc_t *rpc; - sfw_test_unit_t *tsu; + sfw_test_unit_t *tsu; if (!tsi->tsi_is_client) goto clean; @@ -728,14 +728,14 @@ sfw_unpack_addtest_req(srpc_msg_t *msg) static int sfw_add_test_instance(sfw_batch_t *tsb, srpc_server_rpc_t *rpc) { - srpc_msg_t *msg = &rpc->srpc_reqstbuf->buf_msg; - srpc_test_reqst_t *req = &msg->msg_body.tes_reqst; - srpc_bulk_t *bk = rpc->srpc_bulk; - int ndest = req->tsr_ndest; - sfw_test_unit_t *tsu; + srpc_msg_t *msg = &rpc->srpc_reqstbuf->buf_msg; + srpc_test_reqst_t *req = &msg->msg_body.tes_reqst; + srpc_bulk_t *bk = rpc->srpc_bulk; + int ndest = req->tsr_ndest; + sfw_test_unit_t *tsu; sfw_test_instance_t *tsi; - int i; - int rc; + int i; + int rc; LIBCFS_ALLOC(tsi, sizeof(*tsi)); if (tsi == NULL) { @@ -751,9 +751,9 @@ sfw_add_test_instance(sfw_batch_t *tsb, srpc_server_rpc_t *rpc) INIT_LIST_HEAD(&tsi->tsi_active_rpcs); tsi->tsi_stopping = 0; - tsi->tsi_batch = tsb; - tsi->tsi_loop = req->tsr_loop; - tsi->tsi_concur = req->tsr_concur; + tsi->tsi_batch = tsb; + tsi->tsi_loop = req->tsr_loop; + tsi->tsi_concur = req->tsr_concur; tsi->tsi_service = req->tsr_service; tsi->tsi_is_client = !!(req->tsr_is_client); tsi->tsi_stoptsu_onerr = !!(req->tsr_stop_onerr); @@ -782,8 +782,8 @@ sfw_add_test_instance(sfw_batch_t *tsb, srpc_server_rpc_t *rpc) for (i = 0; i < ndest; i++) { lnet_process_id_packed_t *dests; - lnet_process_id_packed_t id; - int j; + lnet_process_id_packed_t id; + int j; dests = page_address(bk->bk_iovs[i / SFW_ID_PER_PAGE].kiov_page); LASSERT(dests != NULL); /* my pages are within KVM always */ @@ -824,8 +824,8 @@ static void sfw_test_unit_done(sfw_test_unit_t *tsu) { sfw_test_instance_t *tsi = tsu->tsu_instance; - sfw_batch_t *tsb = tsi->tsi_batch; - sfw_session_t *sn = tsb->bat_session; + sfw_batch_t *tsb = tsi->tsi_batch; + sfw_session_t *sn = tsb->bat_session; LASSERT(sfw_test_active(tsi)); @@ -866,9 +866,9 @@ sfw_test_unit_done(sfw_test_unit_t *tsu) static void sfw_test_rpc_done(srpc_client_rpc_t *rpc) { - sfw_test_unit_t *tsu = rpc->crpc_priv; + sfw_test_unit_t *tsu = rpc->crpc_priv; sfw_test_instance_t *tsi = tsu->tsu_instance; - int done = 0; + int done = 0; tsi->tsi_ops->tso_done_rpc(tsu, rpc); @@ -904,7 +904,7 @@ sfw_create_test_rpc(sfw_test_unit_t *tsu, lnet_process_id_t peer, unsigned features, int nblk, int blklen, srpc_client_rpc_t **rpcpp) { - srpc_client_rpc_t *rpc = NULL; + srpc_client_rpc_t *rpc = NULL; sfw_test_instance_t *tsi = tsu->tsu_instance; spin_lock(&tsi->tsi_lock); @@ -945,9 +945,9 @@ sfw_create_test_rpc(sfw_test_unit_t *tsu, lnet_process_id_t peer, static int sfw_run_test(swi_workitem_t *wi) { - sfw_test_unit_t *tsu = wi->swi_workitem.wi_data; + sfw_test_unit_t *tsu = wi->swi_workitem.wi_data; sfw_test_instance_t *tsi = tsu->tsu_instance; - srpc_client_rpc_t *rpc = NULL; + srpc_client_rpc_t *rpc = NULL; LASSERT(wi == &tsu->tsu_worker); @@ -995,8 +995,8 @@ test_done: static int sfw_run_batch(sfw_batch_t *tsb) { - swi_workitem_t *wi; - sfw_test_unit_t *tsu; + swi_workitem_t *wi; + sfw_test_unit_t *tsu; sfw_test_instance_t *tsi; if (sfw_batch_active(tsb)) { @@ -1032,7 +1032,7 @@ int sfw_stop_batch(sfw_batch_t *tsb, int force) { sfw_test_instance_t *tsi; - srpc_client_rpc_t *rpc; + srpc_client_rpc_t *rpc; if (!sfw_batch_active(tsb)) { CDEBUG(D_NET, "Batch %llu inactive\n", tsb->bat_id.bat_id); @@ -1118,11 +1118,11 @@ sfw_alloc_pages(struct srpc_server_rpc *rpc, int cpt, int npages, int len, static int sfw_add_test(srpc_server_rpc_t *rpc) { - sfw_session_t *sn = sfw_data.fw_session; + sfw_session_t *sn = sfw_data.fw_session; srpc_test_reply_t *reply = &rpc->srpc_replymsg.msg_body.tes_reply; srpc_test_reqst_t *request; - int rc; - sfw_batch_t *bat; + int rc; + sfw_batch_t *bat; request = &rpc->srpc_reqstbuf->buf_msg.msg_body.tes_reqst; reply->tsr_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id; @@ -1160,8 +1160,8 @@ sfw_add_test(srpc_server_rpc_t *rpc) if (request->tsr_is_client && rpc->srpc_bulk == NULL) { /* rpc will be resumed later in sfw_bulk_ready */ - int npg = sfw_id_pages(request->tsr_ndest); - int len; + int npg = sfw_id_pages(request->tsr_ndest); + int len; if ((sn->sn_features & LST_FEAT_BULK_LEN) == 0) { len = npg * PAGE_CACHE_SIZE; @@ -1189,8 +1189,8 @@ static int sfw_control_batch(srpc_batch_reqst_t *request, srpc_batch_reply_t *reply) { sfw_session_t *sn = sfw_data.fw_session; - int rc = 0; - sfw_batch_t *bat; + int rc = 0; + sfw_batch_t *bat; reply->bar_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id; @@ -1229,11 +1229,11 @@ sfw_control_batch(srpc_batch_reqst_t *request, srpc_batch_reply_t *reply) static int sfw_handle_server_rpc(struct srpc_server_rpc *rpc) { - struct srpc_service *sv = rpc->srpc_scd->scd_svc; - srpc_msg_t *reply = &rpc->srpc_replymsg; - srpc_msg_t *request = &rpc->srpc_reqstbuf->buf_msg; - unsigned features = LST_FEATS_MASK; - int rc = 0; + struct srpc_service *sv = rpc->srpc_scd->scd_svc; + srpc_msg_t *reply = &rpc->srpc_replymsg; + srpc_msg_t *request = &rpc->srpc_reqstbuf->buf_msg; + unsigned features = LST_FEATS_MASK; + int rc = 0; LASSERT(sfw_data.fw_active_srpc == NULL); LASSERT(sv->sv_id <= SRPC_FRAMEWORK_SERVICE_MAX_ID); @@ -1334,8 +1334,8 @@ sfw_handle_server_rpc(struct srpc_server_rpc *rpc) static int sfw_bulk_ready(struct srpc_server_rpc *rpc, int status) { - struct srpc_service *sv = rpc->srpc_scd->scd_svc; - int rc; + struct srpc_service *sv = rpc->srpc_scd->scd_svc; + int rc; LASSERT(rpc->srpc_bulk != NULL); LASSERT(sv->sv_id == SRPC_SERVICE_TEST); @@ -1640,10 +1640,10 @@ extern void brw_init_test_service(void); int sfw_startup(void) { - int i; - int rc; - int error; - srpc_service_t *sv; + int i; + int rc; + int error; + srpc_service_t *sv; sfw_test_case_t *tsc; @@ -1735,9 +1735,9 @@ sfw_startup(void) void sfw_shutdown(void) { - srpc_service_t *sv; + srpc_service_t *sv; sfw_test_case_t *tsc; - int i; + int i; spin_lock(&sfw_data.fw_lock); diff --git a/drivers/staging/lustre/lnet/selftest/module.c b/drivers/staging/lustre/lnet/selftest/module.c index 7ad62f167cea..09b8f4649796 100644 --- a/drivers/staging/lustre/lnet/selftest/module.c +++ b/drivers/staging/lustre/lnet/selftest/module.c @@ -39,7 +39,7 @@ #include "selftest.h" enum { - LST_INIT_NONE = 0, + LST_INIT_NONE = 0, LST_INIT_WI_SERIAL, LST_INIT_WI_TEST, LST_INIT_RPC, @@ -58,7 +58,7 @@ struct cfs_wi_sched **lst_sched_test; static void lnet_selftest_fini(void) { - int i; + int i; switch (lst_init_step) { case LST_INIT_CONSOLE: @@ -92,9 +92,9 @@ lnet_selftest_fini(void) static int lnet_selftest_init(void) { - int nscheds; - int rc; - int i; + int nscheds; + int rc; + int i; rc = cfs_wi_sched_create("lst_s", lnet_cpt_table(), CFS_CPT_ANY, 1, &lst_sched_serial); diff --git a/drivers/staging/lustre/lnet/selftest/ping_test.c b/drivers/staging/lustre/lnet/selftest/ping_test.c index 644069a9fe4e..1dab9984c58e 100644 --- a/drivers/staging/lustre/lnet/selftest/ping_test.c +++ b/drivers/staging/lustre/lnet/selftest/ping_test.c @@ -73,7 +73,7 @@ static void ping_client_fini(sfw_test_instance_t *tsi) { sfw_session_t *sn = tsi->tsi_batch->bat_session; - int errors; + int errors; LASSERT(sn != NULL); LASSERT(tsi->tsi_is_client); @@ -89,11 +89,11 @@ static int ping_client_prep_rpc(sfw_test_unit_t *tsu, lnet_process_id_t dest, srpc_client_rpc_t **rpc) { - srpc_ping_reqst_t *req; + srpc_ping_reqst_t *req; sfw_test_instance_t *tsi = tsu->tsu_instance; - sfw_session_t *sn = tsi->tsi_batch->bat_session; - struct timeval tv; - int rc; + sfw_session_t *sn = tsi->tsi_batch->bat_session; + struct timeval tv; + int rc; LASSERT(sn != NULL); LASSERT((sn->sn_features & ~LST_FEATS_MASK) == 0); @@ -121,10 +121,10 @@ static void ping_client_done_rpc(sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc) { sfw_test_instance_t *tsi = tsu->tsu_instance; - sfw_session_t *sn = tsi->tsi_batch->bat_session; - srpc_ping_reqst_t *reqst = &rpc->crpc_reqstmsg.msg_body.ping_reqst; - srpc_ping_reply_t *reply = &rpc->crpc_replymsg.msg_body.ping_reply; - struct timeval tv; + sfw_session_t *sn = tsi->tsi_batch->bat_session; + srpc_ping_reqst_t *reqst = &rpc->crpc_reqstmsg.msg_body.ping_reqst; + srpc_ping_reply_t *reply = &rpc->crpc_replymsg.msg_body.ping_reply; + struct timeval tv; LASSERT(sn != NULL); @@ -171,9 +171,9 @@ ping_client_done_rpc(sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc) static int ping_server_handle(struct srpc_server_rpc *rpc) { - struct srpc_service *sv = rpc->srpc_scd->scd_svc; - srpc_msg_t *reqstmsg = &rpc->srpc_reqstbuf->buf_msg; - srpc_msg_t *replymsg = &rpc->srpc_replymsg; + struct srpc_service *sv = rpc->srpc_scd->scd_svc; + srpc_msg_t *reqstmsg = &rpc->srpc_reqstbuf->buf_msg; + srpc_msg_t *replymsg = &rpc->srpc_replymsg; srpc_ping_reqst_t *req = &reqstmsg->msg_body.ping_reqst; srpc_ping_reply_t *rep = &rpc->srpc_replymsg.msg_body.ping_reply; diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c index 080788ab749e..59cf01ff4334 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.c +++ b/drivers/staging/lustre/lnet/selftest/rpc.c @@ -104,7 +104,7 @@ srpc_add_bulk_page(srpc_bulk_t *bk, struct page *pg, int i, int nob) void srpc_free_bulk(srpc_bulk_t *bk) { - int i; + int i; struct page *pg; LASSERT(bk != NULL); @@ -124,8 +124,8 @@ srpc_free_bulk(srpc_bulk_t *bk) srpc_bulk_t * srpc_alloc_bulk(int cpt, unsigned bulk_npg, unsigned bulk_len, int sink) { - srpc_bulk_t *bk; - int i; + srpc_bulk_t *bk; + int i; LASSERT(bulk_npg > 0 && bulk_npg <= LNET_MAX_IOV); @@ -143,7 +143,7 @@ srpc_alloc_bulk(int cpt, unsigned bulk_npg, unsigned bulk_len, int sink) for (i = 0; i < bulk_npg; i++) { struct page *pg; - int nob; + int nob; pg = alloc_pages_node(cfs_cpt_spread_node(lnet_cpt_table(), cpt), GFP_IOFS, 0); @@ -193,11 +193,11 @@ srpc_init_server_rpc(struct srpc_server_rpc *rpc, static void srpc_service_fini(struct srpc_service *svc) { - struct srpc_service_cd *scd; - struct srpc_server_rpc *rpc; - struct srpc_buffer *buf; - struct list_head *q; - int i; + struct srpc_service_cd *scd; + struct srpc_server_rpc *rpc; + struct srpc_buffer *buf; + struct list_head *q; + int i; if (svc->sv_cpt_data == NULL) return; @@ -249,11 +249,11 @@ int srpc_add_buffer(struct swi_workitem *wi); static int srpc_service_init(struct srpc_service *svc) { - struct srpc_service_cd *scd; - struct srpc_server_rpc *rpc; - int nrpcs; - int i; - int j; + struct srpc_service_cd *scd; + struct srpc_server_rpc *rpc; + int nrpcs; + int i; + int j; svc->sv_shuttingdown = 0; @@ -357,8 +357,8 @@ srpc_post_passive_rdma(int portal, int local, __u64 matchbits, void *buf, int len, int options, lnet_process_id_t peer, lnet_handle_md_t *mdh, srpc_event_t *ev) { - int rc; - lnet_md_t md; + int rc; + lnet_md_t md; lnet_handle_me_t meh; rc = LNetMEAttach(portal, peer, matchbits, 0, LNET_UNLINK, @@ -397,7 +397,7 @@ srpc_post_active_rdma(int portal, __u64 matchbits, void *buf, int len, int options, lnet_process_id_t peer, lnet_nid_t self, lnet_handle_md_t *mdh, srpc_event_t *ev) { - int rc; + int rc; lnet_md_t md; md.user_ptr = ev; @@ -471,9 +471,9 @@ static int srpc_service_post_buffer(struct srpc_service_cd *scd, struct srpc_buffer *buf) __must_hold(&scd->scd_lock) { - struct srpc_service *sv = scd->scd_svc; - struct srpc_msg *msg = &buf->buf_msg; - int rc; + struct srpc_service *sv = scd->scd_svc; + struct srpc_msg *msg = &buf->buf_msg; + int rc; LNetInvalidateHandle(&buf->buf_mdh); list_add(&buf->buf_list, &scd->scd_buf_posted); @@ -519,9 +519,9 @@ srpc_service_post_buffer(struct srpc_service_cd *scd, struct srpc_buffer *buf) int srpc_add_buffer(struct swi_workitem *wi) { - struct srpc_service_cd *scd = wi->swi_workitem.wi_data; - struct srpc_buffer *buf; - int rc = 0; + struct srpc_service_cd *scd = wi->swi_workitem.wi_data; + struct srpc_buffer *buf; + int rc = 0; /* it's called by workitem scheduler threads, these threads * should have been set CPT affinity, so buffers will be posted @@ -579,9 +579,9 @@ srpc_add_buffer(struct swi_workitem *wi) int srpc_service_add_buffers(struct srpc_service *sv, int nbuffer) { - struct srpc_service_cd *scd; - int rc = 0; - int i; + struct srpc_service_cd *scd; + int rc = 0; + int i; LASSERTF(nbuffer > 0, "nbuffer must be positive: %d\n", nbuffer); @@ -633,9 +633,9 @@ srpc_service_add_buffers(struct srpc_service *sv, int nbuffer) void srpc_service_remove_buffers(struct srpc_service *sv, int nbuffer) { - struct srpc_service_cd *scd; - int num; - int i; + struct srpc_service_cd *scd; + int num; + int i; LASSERT(!sv->sv_shuttingdown); @@ -653,9 +653,9 @@ srpc_service_remove_buffers(struct srpc_service *sv, int nbuffer) int srpc_finish_service(struct srpc_service *sv) { - struct srpc_service_cd *scd; - struct srpc_server_rpc *rpc; - int i; + struct srpc_service_cd *scd; + struct srpc_server_rpc *rpc; + int i; LASSERT(sv->sv_shuttingdown); /* srpc_shutdown_service called */ @@ -731,9 +731,9 @@ srpc_service_recycle_buffer(struct srpc_service_cd *scd, srpc_buffer_t *buf) void srpc_abort_service(struct srpc_service *sv) { - struct srpc_service_cd *scd; - struct srpc_server_rpc *rpc; - int i; + struct srpc_service_cd *scd; + struct srpc_server_rpc *rpc; + int i; CDEBUG(D_NET, "Aborting service: id %d, name %s\n", sv->sv_id, sv->sv_name); @@ -756,10 +756,10 @@ srpc_abort_service(struct srpc_service *sv) void srpc_shutdown_service(srpc_service_t *sv) { - struct srpc_service_cd *scd; - struct srpc_server_rpc *rpc; - srpc_buffer_t *buf; - int i; + struct srpc_service_cd *scd; + struct srpc_server_rpc *rpc; + srpc_buffer_t *buf; + int i; CDEBUG(D_NET, "Shutting down service: id %d, name %s\n", sv->sv_id, sv->sv_name); @@ -792,7 +792,7 @@ static int srpc_send_request(srpc_client_rpc_t *rpc) { srpc_event_t *ev = &rpc->crpc_reqstev; - int rc; + int rc; ev->ev_fired = 0; ev->ev_data = rpc; @@ -812,8 +812,8 @@ static int srpc_prepare_reply(srpc_client_rpc_t *rpc) { srpc_event_t *ev = &rpc->crpc_replyev; - __u64 *id = &rpc->crpc_reqstmsg.msg_body.reqst.rpyid; - int rc; + __u64 *id = &rpc->crpc_reqstmsg.msg_body.reqst.rpyid; + int rc; ev->ev_fired = 0; ev->ev_data = rpc; @@ -835,11 +835,11 @@ srpc_prepare_reply(srpc_client_rpc_t *rpc) static int srpc_prepare_bulk(srpc_client_rpc_t *rpc) { - srpc_bulk_t *bk = &rpc->crpc_bulk; + srpc_bulk_t *bk = &rpc->crpc_bulk; srpc_event_t *ev = &rpc->crpc_bulkev; __u64 *id = &rpc->crpc_reqstmsg.msg_body.reqst.bulkid; - int rc; - int opt; + int rc; + int opt; LASSERT(bk->bk_niov <= LNET_MAX_IOV); @@ -868,11 +868,11 @@ srpc_prepare_bulk(srpc_client_rpc_t *rpc) static int srpc_do_bulk(srpc_server_rpc_t *rpc) { - srpc_event_t *ev = &rpc->srpc_ev; - srpc_bulk_t *bk = rpc->srpc_bulk; - __u64 id = rpc->srpc_reqstbuf->buf_msg.msg_body.reqst.bulkid; - int rc; - int opt; + srpc_event_t *ev = &rpc->srpc_ev; + srpc_bulk_t *bk = rpc->srpc_bulk; + __u64 id = rpc->srpc_reqstbuf->buf_msg.msg_body.reqst.bulkid; + int rc; + int opt; LASSERT(bk != NULL); @@ -896,9 +896,9 @@ srpc_do_bulk(srpc_server_rpc_t *rpc) static void srpc_server_rpc_done(srpc_server_rpc_t *rpc, int status) { - struct srpc_service_cd *scd = rpc->srpc_scd; - struct srpc_service *sv = scd->scd_svc; - srpc_buffer_t *buffer; + struct srpc_service_cd *scd = rpc->srpc_scd; + struct srpc_service *sv = scd->scd_svc; + srpc_buffer_t *buffer; LASSERT(status != 0 || rpc->srpc_wi.swi_state == SWI_STATE_DONE); @@ -959,11 +959,11 @@ srpc_server_rpc_done(srpc_server_rpc_t *rpc, int status) int srpc_handle_rpc(swi_workitem_t *wi) { - struct srpc_server_rpc *rpc = wi->swi_workitem.wi_data; - struct srpc_service_cd *scd = rpc->srpc_scd; - struct srpc_service *sv = scd->scd_svc; - srpc_event_t *ev = &rpc->srpc_ev; - int rc = 0; + struct srpc_server_rpc *rpc = wi->swi_workitem.wi_data; + struct srpc_service_cd *scd = rpc->srpc_scd; + struct srpc_service *sv = scd->scd_svc; + srpc_event_t *ev = &rpc->srpc_ev; + int rc = 0; LASSERT(wi == &rpc->srpc_wi); @@ -989,7 +989,7 @@ srpc_handle_rpc(swi_workitem_t *wi) default: LBUG(); case SWI_STATE_NEWBORN: { - srpc_msg_t *msg; + srpc_msg_t *msg; srpc_generic_reply_t *reply; msg = &rpc->srpc_reqstbuf->buf_msg; @@ -1173,10 +1173,10 @@ srpc_client_rpc_done(srpc_client_rpc_t *rpc, int status) int srpc_send_rpc(swi_workitem_t *wi) { - int rc = 0; + int rc = 0; srpc_client_rpc_t *rpc; - srpc_msg_t *reply; - int do_bulk; + srpc_msg_t *reply; + int do_bulk; LASSERT(wi != NULL); @@ -1359,13 +1359,13 @@ srpc_post_rpc(srpc_client_rpc_t *rpc) int srpc_send_reply(struct srpc_server_rpc *rpc) { - srpc_event_t *ev = &rpc->srpc_ev; - struct srpc_msg *msg = &rpc->srpc_replymsg; - struct srpc_buffer *buffer = rpc->srpc_reqstbuf; - struct srpc_service_cd *scd = rpc->srpc_scd; - struct srpc_service *sv = scd->scd_svc; - __u64 rpyid; - int rc; + srpc_event_t *ev = &rpc->srpc_ev; + struct srpc_msg *msg = &rpc->srpc_replymsg; + struct srpc_buffer *buffer = rpc->srpc_reqstbuf; + struct srpc_service_cd *scd = rpc->srpc_scd; + struct srpc_service *sv = scd->scd_svc; + __u64 rpyid; + int rc; LASSERT(buffer != NULL); rpyid = buffer->buf_msg.msg_body.reqst.rpyid; @@ -1403,14 +1403,14 @@ srpc_send_reply(struct srpc_server_rpc *rpc) static void srpc_lnet_ev_handler(lnet_event_t *ev) { - struct srpc_service_cd *scd; - srpc_event_t *rpcev = ev->md.user_ptr; + struct srpc_service_cd *scd; + srpc_event_t *rpcev = ev->md.user_ptr; srpc_client_rpc_t *crpc; srpc_server_rpc_t *srpc; - srpc_buffer_t *buffer; - srpc_service_t *sv; - srpc_msg_t *msg; - srpc_msg_type_t type; + srpc_buffer_t *buffer; + srpc_service_t *sv; + srpc_msg_t *msg; + srpc_msg_type_t type; LASSERT(!in_interrupt()); diff --git a/drivers/staging/lustre/lnet/selftest/rpc.h b/drivers/staging/lustre/lnet/selftest/rpc.h index fbeb75fe5922..b7b00c6b1004 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.h +++ b/drivers/staging/lustre/lnet/selftest/rpc.h @@ -79,60 +79,61 @@ typedef struct { } WIRE_ATTR srpc_generic_reqst_t; typedef struct { - __u32 status; - lst_sid_t sid; + __u32 status; + lst_sid_t sid; } WIRE_ATTR srpc_generic_reply_t; /* FRAMEWORK RPCs */ typedef struct { - __u64 mksn_rpyid; /* reply buffer matchbits */ - lst_sid_t mksn_sid; /* session id */ - __u32 mksn_force; /* use brute force */ + __u64 mksn_rpyid; /* reply buffer matchbits */ + lst_sid_t mksn_sid; /* session id */ + __u32 mksn_force; /* use brute force */ char mksn_name[LST_NAME_SIZE]; -} WIRE_ATTR srpc_mksn_reqst_t; /* make session request */ +} WIRE_ATTR srpc_mksn_reqst_t; /* make session request */ typedef struct { - __u32 mksn_status; /* session status */ - lst_sid_t mksn_sid; /* session id */ - __u32 mksn_timeout; /* session timeout */ - char mksn_name[LST_NAME_SIZE]; + __u32 mksn_status; /* session status */ + lst_sid_t mksn_sid; /* session id */ + __u32 mksn_timeout; /* session timeout */ + char mksn_name[LST_NAME_SIZE]; } WIRE_ATTR srpc_mksn_reply_t; /* make session reply */ typedef struct { - __u64 rmsn_rpyid; /* reply buffer matchbits */ - lst_sid_t rmsn_sid; /* session id */ + __u64 rmsn_rpyid; /* reply buffer matchbits */ + lst_sid_t rmsn_sid; /* session id */ } WIRE_ATTR srpc_rmsn_reqst_t; /* remove session request */ typedef struct { - __u32 rmsn_status; - lst_sid_t rmsn_sid; /* session id */ + __u32 rmsn_status; + lst_sid_t rmsn_sid; /* session id */ } WIRE_ATTR srpc_rmsn_reply_t; /* remove session reply */ typedef struct { - __u64 join_rpyid; /* reply buffer matchbits */ - lst_sid_t join_sid; /* session id to join */ - char join_group[LST_NAME_SIZE]; /* group name */ + __u64 join_rpyid; /* reply buffer matchbits */ + lst_sid_t join_sid; /* session id to join */ + char join_group[LST_NAME_SIZE]; /* group name */ } WIRE_ATTR srpc_join_reqst_t; typedef struct { - __u32 join_status; /* returned status */ - lst_sid_t join_sid; /* session id */ - __u32 join_timeout; /* # seconds' inactivity to expire */ - char join_session[LST_NAME_SIZE]; /* session name */ + __u32 join_status; /* returned status */ + lst_sid_t join_sid; /* session id */ + __u32 join_timeout; /* # seconds' inactivity to + * expire */ + char join_session[LST_NAME_SIZE]; /* session name */ } WIRE_ATTR srpc_join_reply_t; typedef struct { - __u64 dbg_rpyid; /* reply buffer matchbits */ - lst_sid_t dbg_sid; /* session id */ - __u32 dbg_flags; /* bitmap of debug */ + __u64 dbg_rpyid; /* reply buffer matchbits */ + lst_sid_t dbg_sid; /* session id */ + __u32 dbg_flags; /* bitmap of debug */ } WIRE_ATTR srpc_debug_reqst_t; typedef struct { - __u32 dbg_status; /* returned code */ - lst_sid_t dbg_sid; /* session id */ - __u32 dbg_timeout; /* session timeout */ - __u32 dbg_nbatch; /* # of batches in the node */ - char dbg_name[LST_NAME_SIZE]; /* session name */ + __u32 dbg_status; /* returned code */ + lst_sid_t dbg_sid; /* session id */ + __u32 dbg_timeout; /* session timeout */ + __u32 dbg_nbatch; /* # of batches in the node */ + char dbg_name[LST_NAME_SIZE]; /* session name */ } WIRE_ATTR srpc_debug_reply_t; #define SRPC_BATCH_OPC_RUN 1 @@ -140,55 +141,51 @@ typedef struct { #define SRPC_BATCH_OPC_QUERY 3 typedef struct { - __u64 bar_rpyid; /* reply buffer matchbits */ - lst_sid_t bar_sid; /* session id */ - lst_bid_t bar_bid; /* batch id */ - __u32 bar_opc; /* create/start/stop batch */ - __u32 bar_testidx; /* index of test */ - __u32 bar_arg; /* parameters */ + __u64 bar_rpyid; /* reply buffer matchbits */ + lst_sid_t bar_sid; /* session id */ + lst_bid_t bar_bid; /* batch id */ + __u32 bar_opc; /* create/start/stop batch */ + __u32 bar_testidx; /* index of test */ + __u32 bar_arg; /* parameters */ } WIRE_ATTR srpc_batch_reqst_t; typedef struct { - __u32 bar_status; /* status of request */ - lst_sid_t bar_sid; /* session id */ - __u32 bar_active; /* # of active tests in batch/test */ - __u32 bar_time; /* remained time */ + __u32 bar_status; /* status of request */ + lst_sid_t bar_sid; /* session id */ + __u32 bar_active; /* # of active tests in batch/test */ + __u32 bar_time; /* remained time */ } WIRE_ATTR srpc_batch_reply_t; typedef struct { - __u64 str_rpyid; /* reply buffer matchbits */ - lst_sid_t str_sid; /* session id */ - __u32 str_type; /* type of stat */ + __u64 str_rpyid; /* reply buffer matchbits */ + lst_sid_t str_sid; /* session id */ + __u32 str_type; /* type of stat */ } WIRE_ATTR srpc_stat_reqst_t; typedef struct { - __u32 str_status; - lst_sid_t str_sid; - sfw_counters_t str_fw; - srpc_counters_t str_rpc; - lnet_counters_t str_lnet; + __u32 str_status; + lst_sid_t str_sid; + sfw_counters_t str_fw; + srpc_counters_t str_rpc; + lnet_counters_t str_lnet; } WIRE_ATTR srpc_stat_reply_t; typedef struct { - __u32 blk_opc; /* bulk operation code */ - __u32 blk_npg; /* # of pages */ - __u32 blk_flags; /* reserved flags */ + __u32 blk_opc; /* bulk operation code */ + __u32 blk_npg; /* # of pages */ + __u32 blk_flags; /* reserved flags */ } WIRE_ATTR test_bulk_req_t; typedef struct { - /** bulk operation code */ - __u16 blk_opc; - /** data check flags */ - __u16 blk_flags; - /** data length */ - __u32 blk_len; - /** reserved: offset */ - __u32 blk_offset; + __u16 blk_opc; /* bulk operation code */ + __u16 blk_flags; /* data check flags */ + __u32 blk_len; /* data length */ + __u32 blk_offset; /* reserved: offset */ } WIRE_ATTR test_bulk_req_v1_t; typedef struct { - __u32 png_size; /* size of ping message */ - __u32 png_flags; /* reserved flags */ + __u32 png_size; /* size of ping message */ + __u32 png_flags; /* reserved flags */ } WIRE_ATTR test_ping_req_t; typedef struct { @@ -197,8 +194,8 @@ typedef struct { lst_sid_t tsr_sid; /* session id */ lst_bid_t tsr_bid; /* batch id */ __u32 tsr_service; /* test type: bulk|ping|... */ - /* test client loop count or # server buffers needed */ - __u32 tsr_loop; + __u32 tsr_loop; /* test client loop count or + * # server buffers needed */ __u32 tsr_concur; /* concurrency of test */ __u8 tsr_is_client; /* is test client or not */ __u8 tsr_stop_onerr; /* stop on error */ @@ -234,8 +231,8 @@ typedef struct { typedef struct { __u64 brw_rpyid; /* reply buffer matchbits */ __u64 brw_bulkid; /* bulk buffer matchbits */ - __u32 brw_rw; /* read or write */ - __u32 brw_len; /* bulk data len */ + __u32 brw_rw; /* read or write */ + __u32 brw_len; /* bulk data len */ __u32 brw_flags; /* bulk data patterns */ } WIRE_ATTR srpc_brw_reqst_t; /* bulk r/w request */ @@ -243,20 +240,16 @@ typedef struct { __u32 brw_status; } WIRE_ATTR srpc_brw_reply_t; /* bulk r/w reply */ -#define SRPC_MSG_MAGIC 0xeeb0f00d -#define SRPC_MSG_VERSION 1 +#define SRPC_MSG_MAGIC 0xeeb0f00d +#define SRPC_MSG_VERSION 1 typedef struct srpc_msg { - /** magic number */ - __u32 msg_magic; - /** message version number */ - __u32 msg_version; - /** type of message body: srpc_msg_type_t */ - __u32 msg_type; + __u32 msg_magic; /* magic number */ + __u32 msg_version; /* message version number */ + __u32 msg_type; /* type of message body: srpc_msg_type_t */ __u32 msg_reserved0; __u32 msg_reserved1; - /** test session features */ - __u32 msg_ses_feats; + __u32 msg_ses_feats; /* test session features */ union { srpc_generic_reqst_t reqst; srpc_generic_reply_t reply; diff --git a/drivers/staging/lustre/lnet/selftest/selftest.h b/drivers/staging/lustre/lnet/selftest/selftest.h index d48701834b18..7939e4e04d90 100644 --- a/drivers/staging/lustre/lnet/selftest/selftest.h +++ b/drivers/staging/lustre/lnet/selftest/selftest.h @@ -57,14 +57,14 @@ #endif -#define SWI_STATE_NEWBORN 0 -#define SWI_STATE_REPLY_SUBMITTED 1 -#define SWI_STATE_REPLY_SENT 2 -#define SWI_STATE_REQUEST_SUBMITTED 3 -#define SWI_STATE_REQUEST_SENT 4 -#define SWI_STATE_REPLY_RECEIVED 5 -#define SWI_STATE_BULK_STARTED 6 -#define SWI_STATE_DONE 10 +#define SWI_STATE_NEWBORN 0 +#define SWI_STATE_REPLY_SUBMITTED 1 +#define SWI_STATE_REPLY_SENT 2 +#define SWI_STATE_REQUEST_SUBMITTED 3 +#define SWI_STATE_REQUEST_SENT 4 +#define SWI_STATE_REPLY_RECEIVED 5 +#define SWI_STATE_BULK_STARTED 6 +#define SWI_STATE_DONE 10 /* forward refs */ struct srpc_service; @@ -75,24 +75,24 @@ struct sfw_test_instance; /* services below SRPC_FRAMEWORK_SERVICE_MAX_ID are framework * services, e.g. create/modify session. */ -#define SRPC_SERVICE_DEBUG 0 -#define SRPC_SERVICE_MAKE_SESSION 1 -#define SRPC_SERVICE_REMOVE_SESSION 2 -#define SRPC_SERVICE_BATCH 3 -#define SRPC_SERVICE_TEST 4 -#define SRPC_SERVICE_QUERY_STAT 5 -#define SRPC_SERVICE_JOIN 6 -#define SRPC_FRAMEWORK_SERVICE_MAX_ID 10 +#define SRPC_SERVICE_DEBUG 0 +#define SRPC_SERVICE_MAKE_SESSION 1 +#define SRPC_SERVICE_REMOVE_SESSION 2 +#define SRPC_SERVICE_BATCH 3 +#define SRPC_SERVICE_TEST 4 +#define SRPC_SERVICE_QUERY_STAT 5 +#define SRPC_SERVICE_JOIN 6 +#define SRPC_FRAMEWORK_SERVICE_MAX_ID 10 /* other services start from SRPC_FRAMEWORK_SERVICE_MAX_ID+1 */ -#define SRPC_SERVICE_BRW 11 -#define SRPC_SERVICE_PING 12 -#define SRPC_SERVICE_MAX_ID 12 +#define SRPC_SERVICE_BRW 11 +#define SRPC_SERVICE_PING 12 +#define SRPC_SERVICE_MAX_ID 12 -#define SRPC_REQUEST_PORTAL 50 +#define SRPC_REQUEST_PORTAL 50 /* a lazy portal for framework RPC requests */ -#define SRPC_FRAMEWORK_REQUEST_PORTAL 51 +#define SRPC_FRAMEWORK_REQUEST_PORTAL 51 /* all reply/bulk RDMAs go to this portal */ -#define SRPC_RDMA_PORTAL 52 +#define SRPC_RDMA_PORTAL 52 static inline srpc_msg_type_t srpc_service2request (int service) @@ -136,7 +136,8 @@ srpc_service2reply (int service) } typedef enum { - SRPC_BULK_REQ_RCVD = 1, /* passive bulk request(PUT sink/GET source) received */ + SRPC_BULK_REQ_RCVD = 1, /* passive bulk request(PUT sink/GET source) + * received */ SRPC_BULK_PUT_SENT = 2, /* active bulk PUT sent (source) */ SRPC_BULK_GET_RPLD = 3, /* active bulk GET replied (sink) */ SRPC_REPLY_RCVD = 4, /* incoming reply received */ @@ -149,114 +150,114 @@ typedef enum { typedef struct { srpc_event_type_t ev_type; /* what's up */ lnet_event_kind_t ev_lnet; /* LNet event type */ - int ev_fired; /* LNet event fired? */ - int ev_status; /* LNet event status */ - void *ev_data; /* owning server/client RPC */ + int ev_fired; /* LNet event fired? */ + int ev_status; /* LNet event status */ + void *ev_data; /* owning server/client RPC */ } srpc_event_t; typedef struct { - int bk_len; /* len of bulk data */ + int bk_len; /* len of bulk data */ lnet_handle_md_t bk_mdh; - int bk_sink; /* sink/source */ - int bk_niov; /* # iov in bk_iovs */ + int bk_sink; /* sink/source */ + int bk_niov; /* # iov in bk_iovs */ lnet_kiov_t bk_iovs[0]; } srpc_bulk_t; /* bulk descriptor */ /* message buffer descriptor */ typedef struct srpc_buffer { - struct list_head buf_list; /* chain on srpc_service::*_msgq */ - srpc_msg_t buf_msg; - lnet_handle_md_t buf_mdh; - lnet_nid_t buf_self; - lnet_process_id_t buf_peer; + struct list_head buf_list; /* chain on srpc_service::*_msgq */ + srpc_msg_t buf_msg; + lnet_handle_md_t buf_mdh; + lnet_nid_t buf_self; + lnet_process_id_t buf_peer; } srpc_buffer_t; struct swi_workitem; typedef int (*swi_action_t) (struct swi_workitem *); typedef struct swi_workitem { - struct cfs_wi_sched *swi_sched; - cfs_workitem_t swi_workitem; - swi_action_t swi_action; - int swi_state; + struct cfs_wi_sched *swi_sched; + cfs_workitem_t swi_workitem; + swi_action_t swi_action; + int swi_state; } swi_workitem_t; /* server-side state of a RPC */ typedef struct srpc_server_rpc { /* chain on srpc_service::*_rpcq */ - struct list_head srpc_list; + struct list_head srpc_list; struct srpc_service_cd *srpc_scd; - swi_workitem_t srpc_wi; - srpc_event_t srpc_ev; /* bulk/reply event */ - lnet_nid_t srpc_self; - lnet_process_id_t srpc_peer; - srpc_msg_t srpc_replymsg; - lnet_handle_md_t srpc_replymdh; - srpc_buffer_t *srpc_reqstbuf; - srpc_bulk_t *srpc_bulk; + swi_workitem_t srpc_wi; + srpc_event_t srpc_ev; /* bulk/reply event */ + lnet_nid_t srpc_self; + lnet_process_id_t srpc_peer; + srpc_msg_t srpc_replymsg; + lnet_handle_md_t srpc_replymdh; + srpc_buffer_t *srpc_reqstbuf; + srpc_bulk_t *srpc_bulk; - unsigned int srpc_aborted; /* being given up */ - int srpc_status; - void (*srpc_done)(struct srpc_server_rpc *); + unsigned int srpc_aborted; /* being given up */ + int srpc_status; + void (*srpc_done)(struct srpc_server_rpc *); } srpc_server_rpc_t; /* client-side state of a RPC */ typedef struct srpc_client_rpc { - struct list_head crpc_list; /* chain on user's lists */ - spinlock_t crpc_lock; /* serialize */ - int crpc_service; - atomic_t crpc_refcount; - int crpc_timeout; /* # seconds to wait for reply */ - stt_timer_t crpc_timer; - swi_workitem_t crpc_wi; - lnet_process_id_t crpc_dest; + struct list_head crpc_list; /* chain on user's lists */ + spinlock_t crpc_lock; /* serialize */ + int crpc_service; + atomic_t crpc_refcount; + int crpc_timeout; /* # seconds to wait for reply */ + stt_timer_t crpc_timer; + swi_workitem_t crpc_wi; + lnet_process_id_t crpc_dest; - void (*crpc_done)(struct srpc_client_rpc *); - void (*crpc_fini)(struct srpc_client_rpc *); - int crpc_status; /* completion status */ - void *crpc_priv; /* caller data */ + void (*crpc_done)(struct srpc_client_rpc *); + void (*crpc_fini)(struct srpc_client_rpc *); + int crpc_status; /* completion status */ + void *crpc_priv; /* caller data */ /* state flags */ - unsigned int crpc_aborted:1; /* being given up */ - unsigned int crpc_closed:1; /* completed */ + unsigned int crpc_aborted:1; /* being given up */ + unsigned int crpc_closed:1; /* completed */ /* RPC events */ - srpc_event_t crpc_bulkev; /* bulk event */ - srpc_event_t crpc_reqstev; /* request event */ - srpc_event_t crpc_replyev; /* reply event */ + srpc_event_t crpc_bulkev; /* bulk event */ + srpc_event_t crpc_reqstev; /* request event */ + srpc_event_t crpc_replyev; /* reply event */ /* bulk, request(reqst), and reply exchanged on wire */ - srpc_msg_t crpc_reqstmsg; - srpc_msg_t crpc_replymsg; - lnet_handle_md_t crpc_reqstmdh; - lnet_handle_md_t crpc_replymdh; - srpc_bulk_t crpc_bulk; + srpc_msg_t crpc_reqstmsg; + srpc_msg_t crpc_replymsg; + lnet_handle_md_t crpc_reqstmdh; + lnet_handle_md_t crpc_replymdh; + srpc_bulk_t crpc_bulk; } srpc_client_rpc_t; -#define srpc_client_rpc_size(rpc) \ +#define srpc_client_rpc_size(rpc) \ offsetof(srpc_client_rpc_t, crpc_bulk.bk_iovs[(rpc)->crpc_bulk.bk_niov]) -#define srpc_client_rpc_addref(rpc) \ -do { \ - CDEBUG(D_NET, "RPC[%p] -> %s (%d)++\n", \ - (rpc), libcfs_id2str((rpc)->crpc_dest), \ - atomic_read(&(rpc)->crpc_refcount)); \ - LASSERT(atomic_read(&(rpc)->crpc_refcount) > 0); \ - atomic_inc(&(rpc)->crpc_refcount); \ +#define srpc_client_rpc_addref(rpc) \ +do { \ + CDEBUG(D_NET, "RPC[%p] -> %s (%d)++\n", \ + (rpc), libcfs_id2str((rpc)->crpc_dest), \ + atomic_read(&(rpc)->crpc_refcount)); \ + LASSERT(atomic_read(&(rpc)->crpc_refcount) > 0); \ + atomic_inc(&(rpc)->crpc_refcount); \ } while (0) -#define srpc_client_rpc_decref(rpc) \ -do { \ - CDEBUG(D_NET, "RPC[%p] -> %s (%d)--\n", \ - (rpc), libcfs_id2str((rpc)->crpc_dest), \ - atomic_read(&(rpc)->crpc_refcount)); \ - LASSERT(atomic_read(&(rpc)->crpc_refcount) > 0); \ - if (atomic_dec_and_test(&(rpc)->crpc_refcount)) \ - srpc_destroy_client_rpc(rpc); \ +#define srpc_client_rpc_decref(rpc) \ +do { \ + CDEBUG(D_NET, "RPC[%p] -> %s (%d)--\n", \ + (rpc), libcfs_id2str((rpc)->crpc_dest), \ + atomic_read(&(rpc)->crpc_refcount)); \ + LASSERT(atomic_read(&(rpc)->crpc_refcount) > 0); \ + if (atomic_dec_and_test(&(rpc)->crpc_refcount)) \ + srpc_destroy_client_rpc(rpc); \ } while (0) -#define srpc_event_pending(rpc) ((rpc)->crpc_bulkev.ev_fired == 0 || \ - (rpc)->crpc_reqstev.ev_fired == 0 || \ +#define srpc_event_pending(rpc) ((rpc)->crpc_bulkev.ev_fired == 0 || \ + (rpc)->crpc_reqstev.ev_fired == 0 || \ (rpc)->crpc_replyev.ev_fired == 0) /* CPU partition data of srpc service */ @@ -268,9 +269,9 @@ struct srpc_service_cd { /** event buffer */ srpc_event_t scd_ev; /** free RPC descriptors */ - struct list_head scd_rpc_free; + struct list_head scd_rpc_free; /** in-flight RPCs */ - struct list_head scd_rpc_active; + struct list_head scd_rpc_active; /** workitem for posting buffer */ swi_workitem_t scd_buf_wi; /** CPT id */ @@ -278,7 +279,7 @@ struct srpc_service_cd { /** error code for scd_buf_wi */ int scd_buf_err; /** timestamp for scd_buf_err */ - unsigned long scd_buf_err_stamp; + unsigned long scd_buf_err_stamp; /** total # request buffers */ int scd_buf_total; /** # posted request buffers */ @@ -290,9 +291,9 @@ struct srpc_service_cd { /** increase/decrease some buffers */ int scd_buf_adjust; /** posted message buffers */ - struct list_head scd_buf_posted; + struct list_head scd_buf_posted; /** blocked for RPC descriptor */ - struct list_head scd_buf_blocked; + struct list_head scd_buf_blocked; }; /* number of server workitems (mini-thread) for testing service */ @@ -318,40 +319,42 @@ typedef struct srpc_service { * - sv_handler: process incoming RPC request * - sv_bulk_ready: notify bulk data */ - int (*sv_handler) (srpc_server_rpc_t *); - int (*sv_bulk_ready) (srpc_server_rpc_t *, int); + int (*sv_handler) (srpc_server_rpc_t *); + int (*sv_bulk_ready) (srpc_server_rpc_t *, int); } srpc_service_t; typedef struct { - struct list_head sn_list; /* chain on fw_zombie_sessions */ - lst_sid_t sn_id; /* unique identifier */ - unsigned int sn_timeout; /* # seconds' inactivity to expire */ - int sn_timer_active; - unsigned int sn_features; - stt_timer_t sn_timer; - struct list_head sn_batches; /* list of batches */ - char sn_name[LST_NAME_SIZE]; - atomic_t sn_refcount; - atomic_t sn_brw_errors; - atomic_t sn_ping_errors; - unsigned long sn_started; + struct list_head sn_list; /* chain on fw_zombie_sessions */ + lst_sid_t sn_id; /* unique identifier */ + unsigned int sn_timeout; /* # seconds' inactivity to expire */ + int sn_timer_active; + unsigned int sn_features; + stt_timer_t sn_timer; + struct list_head sn_batches; /* list of batches */ + char sn_name[LST_NAME_SIZE]; + atomic_t sn_refcount; + atomic_t sn_brw_errors; + atomic_t sn_ping_errors; + unsigned long sn_started; } sfw_session_t; #define sfw_sid_equal(sid0, sid1) ((sid0).ses_nid == (sid1).ses_nid && \ (sid0).ses_stamp == (sid1).ses_stamp) typedef struct { - struct list_head bat_list; /* chain on sn_batches */ - lst_bid_t bat_id; /* batch id */ - int bat_error; /* error code of batch */ - sfw_session_t *bat_session; /* batch's session */ - atomic_t bat_nactive; /* # of active tests */ - struct list_head bat_tests; /* test instances */ + struct list_head bat_list; /* chain on sn_batches */ + lst_bid_t bat_id; /* batch id */ + int bat_error; /* error code of batch */ + sfw_session_t *bat_session; /* batch's session */ + atomic_t bat_nactive; /* # of active tests */ + struct list_head bat_tests; /* test instances */ } sfw_batch_t; typedef struct { - int (*tso_init)(struct sfw_test_instance *tsi); /* initialize test client */ - void (*tso_fini)(struct sfw_test_instance *tsi); /* finalize test client */ + int (*tso_init)(struct sfw_test_instance *tsi); /* initialize test + * client */ + void (*tso_fini)(struct sfw_test_instance *tsi); /* finalize test + * client */ int (*tso_prep_rpc)(struct sfw_test_unit *tsu, lnet_process_id_t dest, srpc_client_rpc_t **rpc); /* prep a tests rpc */ @@ -360,29 +363,31 @@ typedef struct { } sfw_test_client_ops_t; typedef struct sfw_test_instance { - struct list_head tsi_list; /* chain on batch */ - int tsi_service; /* test type */ - sfw_batch_t *tsi_batch; /* batch */ - sfw_test_client_ops_t *tsi_ops; /* test client operations */ + struct list_head tsi_list; /* chain on batch */ + int tsi_service; /* test type */ + sfw_batch_t *tsi_batch; /* batch */ + sfw_test_client_ops_t *tsi_ops; /* test client operation + */ /* public parameter for all test units */ - unsigned int tsi_is_client:1; /* is test client */ - unsigned int tsi_stoptsu_onerr:1; /* stop tsu on error */ - int tsi_concur; /* concurrency */ - int tsi_loop; /* loop count */ + unsigned int tsi_is_client:1; /* is test client */ + unsigned int tsi_stoptsu_onerr:1; /* stop tsu on error */ + int tsi_concur; /* concurrency */ + int tsi_loop; /* loop count */ /* status of test instance */ - spinlock_t tsi_lock; /* serialize */ - unsigned int tsi_stopping:1; /* test is stopping */ - atomic_t tsi_nactive; /* # of active test unit */ - struct list_head tsi_units; /* test units */ - struct list_head tsi_free_rpcs; /* free rpcs */ - struct list_head tsi_active_rpcs; /* active rpcs */ + spinlock_t tsi_lock; /* serialize */ + unsigned int tsi_stopping:1; /* test is stopping */ + atomic_t tsi_nactive; /* # of active test + * unit */ + struct list_head tsi_units; /* test units */ + struct list_head tsi_free_rpcs; /* free rpcs */ + struct list_head tsi_active_rpcs; /* active rpcs */ union { - test_ping_req_t ping; /* ping parameter */ - test_bulk_req_t bulk_v0; /* bulk parameter */ - test_bulk_req_v1_t bulk_v1; /* bulk v1 parameter */ + test_ping_req_t ping; /* ping parameter */ + test_bulk_req_t bulk_v0; /* bulk parameter */ + test_bulk_req_v1_t bulk_v1; /* bulk v1 parameter */ } tsi_u; } sfw_test_instance_t; @@ -394,18 +399,18 @@ typedef struct sfw_test_instance { #define sfw_id_pages(n) (((n) + SFW_ID_PER_PAGE - 1) / SFW_ID_PER_PAGE) typedef struct sfw_test_unit { - struct list_head tsu_list; /* chain on lst_test_instance */ - lnet_process_id_t tsu_dest; /* id of dest node */ - int tsu_loop; /* loop count of the test */ - sfw_test_instance_t *tsu_instance; /* pointer to test instance */ - void *tsu_private; /* private data */ - swi_workitem_t tsu_worker; /* workitem of the test unit */ + struct list_head tsu_list; /* chain on lst_test_instance */ + lnet_process_id_t tsu_dest; /* id of dest node */ + int tsu_loop; /* loop count of the test */ + sfw_test_instance_t *tsu_instance; /* pointer to test instance */ + void *tsu_private; /* private data */ + swi_workitem_t tsu_worker; /* workitem of the test unit */ } sfw_test_unit_t; typedef struct sfw_test_case { - struct list_head tsc_list; /* chain on fw_tests */ - srpc_service_t *tsc_srv_service; /* test service */ - sfw_test_client_ops_t *tsc_cli_ops; /* ops of test client */ + struct list_head tsc_list; /* chain on fw_tests */ + srpc_service_t *tsc_srv_service; /* test service */ + sfw_test_client_ops_t *tsc_cli_ops; /* ops of test client */ } sfw_test_case_t; srpc_client_rpc_t * @@ -501,9 +506,9 @@ void srpc_shutdown(void); static inline void srpc_destroy_client_rpc (srpc_client_rpc_t *rpc) { - LASSERT (rpc != NULL); - LASSERT (!srpc_event_pending(rpc)); - LASSERT (atomic_read(&rpc->crpc_refcount) == 0); + LASSERT(rpc != NULL); + LASSERT(!srpc_event_pending(rpc)); + LASSERT(atomic_read(&rpc->crpc_refcount) == 0); if (rpc->crpc_fini == NULL) { LIBCFS_FREE(rpc, srpc_client_rpc_size(rpc)); @@ -520,7 +525,7 @@ srpc_init_client_rpc (srpc_client_rpc_t *rpc, lnet_process_id_t peer, void (*rpc_done)(srpc_client_rpc_t *), void (*rpc_fini)(srpc_client_rpc_t *), void *priv) { - LASSERT (nbulkiov <= LNET_MAX_IOV); + LASSERT(nbulkiov <= LNET_MAX_IOV); memset(rpc, 0, offsetof(srpc_client_rpc_t, crpc_bulk.bk_iovs[nbulkiov])); @@ -531,13 +536,13 @@ srpc_init_client_rpc (srpc_client_rpc_t *rpc, lnet_process_id_t peer, spin_lock_init(&rpc->crpc_lock); atomic_set(&rpc->crpc_refcount, 1); /* 1 ref for caller */ - rpc->crpc_dest = peer; - rpc->crpc_priv = priv; + rpc->crpc_dest = peer; + rpc->crpc_priv = priv; rpc->crpc_service = service; rpc->crpc_bulk.bk_len = bulklen; rpc->crpc_bulk.bk_niov = nbulkiov; - rpc->crpc_done = rpc_done; - rpc->crpc_fini = rpc_fini; + rpc->crpc_done = rpc_done; + rpc->crpc_fini = rpc_fini; LNetInvalidateHandle(&rpc->crpc_reqstmdh); LNetInvalidateHandle(&rpc->crpc_replymdh); LNetInvalidateHandle(&rpc->crpc_bulk.bk_mdh); diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c index 441f9472a834..6133b54f4a82 100644 --- a/drivers/staging/lustre/lnet/selftest/timer.c +++ b/drivers/staging/lustre/lnet/selftest/timer.c @@ -50,7 +50,7 @@ * sorted by increasing expiry time. The number of slots is 2**7 (128), * to cover a time period of 1024 seconds into the future before wrapping. */ -#define STTIMER_MINPOLL 3 /* log2 min poll interval (8 s) */ +#define STTIMER_MINPOLL 3 /* log2 min poll interval (8 s) */ #define STTIMER_SLOTTIME (1 << STTIMER_MINPOLL) #define STTIMER_SLOTTIMEMASK (~(STTIMER_SLOTTIME - 1)) #define STTIMER_NSLOTS (1 << 7) @@ -58,13 +58,13 @@ (STTIMER_NSLOTS - 1))]) static struct st_timer_data { - spinlock_t stt_lock; - /* start time of the slot processed previously */ - unsigned long stt_prev_slot; - struct list_head stt_hash[STTIMER_NSLOTS]; - int stt_shuttingdown; - wait_queue_head_t stt_waitq; - int stt_nthreads; + spinlock_t stt_lock; + unsigned long stt_prev_slot; /* start time of the slot processed + * previously */ + struct list_head stt_hash[STTIMER_NSLOTS]; + int stt_shuttingdown; + wait_queue_head_t stt_waitq; + int stt_nthreads; } stt_data; void @@ -124,7 +124,7 @@ stt_del_timer(stt_timer_t *timer) static int stt_expire_list(struct list_head *slot, unsigned long now) { - int expired = 0; + int expired = 0; stt_timer_t *timer; while (!list_empty(slot)) { @@ -148,7 +148,7 @@ stt_expire_list(struct list_head *slot, unsigned long now) static int stt_check_timers(unsigned long *last) { - int expired = 0; + int expired = 0; unsigned long now; unsigned long this_slot; diff --git a/drivers/staging/lustre/lnet/selftest/timer.h b/drivers/staging/lustre/lnet/selftest/timer.h index d727c1e2b0ce..2a8803d89de4 100644 --- a/drivers/staging/lustre/lnet/selftest/timer.h +++ b/drivers/staging/lustre/lnet/selftest/timer.h @@ -39,15 +39,15 @@ #define __SELFTEST_TIMER_H__ typedef struct { - struct list_head stt_list; - unsigned long stt_expires; - void (*stt_func) (void *); - void *stt_data; + struct list_head stt_list; + unsigned long stt_expires; + void (*stt_func) (void *); + void *stt_data; } stt_timer_t; -void stt_add_timer (stt_timer_t *timer); -int stt_del_timer (stt_timer_t *timer); -int stt_startup (void); -void stt_shutdown (void); +void stt_add_timer(stt_timer_t *timer); +int stt_del_timer(stt_timer_t *timer); +int stt_startup(void); +void stt_shutdown(void); #endif /* __SELFTEST_TIMER_H__ */ From bdd84a6f4baf3e1d02955545cf83c6a7e6a470db Mon Sep 17 00:00:00 2001 From: Mike Shuey Date: Tue, 19 May 2015 10:14:39 -0400 Subject: [PATCH 0561/1163] staging: lustre: lnet: remove LNET_MUTEX_LOCK macro LNET_MUTEX_LOCK and LNET_MUTEX_UNLOCK are verbose wrappers to mutex_lock and mutex_unlock. Get rid of these. Signed-off-by: Mike Shuey Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/lnet/lib-lnet.h | 2 -- drivers/staging/lustre/lnet/lnet/api-ni.c | 26 +++++++++---------- drivers/staging/lustre/lnet/lnet/module.c | 12 ++++----- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 0038d29a37fe..d84aa9a4c56d 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -172,8 +172,6 @@ lnet_net_lock_current(void) #define lnet_eq_wait_unlock() spin_unlock(&the_lnet.ln_eq_wait_lock) #define lnet_ni_lock(ni) spin_lock(&(ni)->ni_lock) #define lnet_ni_unlock(ni) spin_unlock(&(ni)->ni_lock) -#define LNET_MUTEX_LOCK(m) mutex_lock(m) -#define LNET_MUTEX_UNLOCK(m) mutex_unlock(m) #define MAX_PORTALS 64 diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 1adc481c7f48..2230eb0193a1 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -282,7 +282,7 @@ lnet_find_lnd_by_type(int type) void lnet_register_lnd(lnd_t *lnd) { - LNET_MUTEX_LOCK(&the_lnet.ln_lnd_mutex); + mutex_lock(&the_lnet.ln_lnd_mutex); LASSERT(the_lnet.ln_init); LASSERT(libcfs_isknown_lnd(lnd->lnd_type)); @@ -293,14 +293,14 @@ lnet_register_lnd(lnd_t *lnd) CDEBUG(D_NET, "%s LND registered\n", libcfs_lnd2str(lnd->lnd_type)); - LNET_MUTEX_UNLOCK(&the_lnet.ln_lnd_mutex); + mutex_unlock(&the_lnet.ln_lnd_mutex); } EXPORT_SYMBOL(lnet_register_lnd); void lnet_unregister_lnd(lnd_t *lnd) { - LNET_MUTEX_LOCK(&the_lnet.ln_lnd_mutex); + mutex_lock(&the_lnet.ln_lnd_mutex); LASSERT(the_lnet.ln_init); LASSERT(lnet_find_lnd_by_type(lnd->lnd_type) == lnd); @@ -309,7 +309,7 @@ lnet_unregister_lnd(lnd_t *lnd) list_del(&lnd->lnd_list); CDEBUG(D_NET, "%s LND unregistered\n", libcfs_lnd2str(lnd->lnd_type)); - LNET_MUTEX_UNLOCK(&the_lnet.ln_lnd_mutex); + mutex_unlock(&the_lnet.ln_lnd_mutex); } EXPORT_SYMBOL(lnet_unregister_lnd); @@ -1055,18 +1055,18 @@ lnet_startup_lndnis(void) goto failed; } - LNET_MUTEX_LOCK(&the_lnet.ln_lnd_mutex); + mutex_lock(&the_lnet.ln_lnd_mutex); lnd = lnet_find_lnd_by_type(lnd_type); if (lnd == NULL) { - LNET_MUTEX_UNLOCK(&the_lnet.ln_lnd_mutex); + mutex_unlock(&the_lnet.ln_lnd_mutex); rc = request_module("%s", libcfs_lnd2modname(lnd_type)); - LNET_MUTEX_LOCK(&the_lnet.ln_lnd_mutex); + mutex_lock(&the_lnet.ln_lnd_mutex); lnd = lnet_find_lnd_by_type(lnd_type); if (lnd == NULL) { - LNET_MUTEX_UNLOCK(&the_lnet.ln_lnd_mutex); + mutex_unlock(&the_lnet.ln_lnd_mutex); CERROR("Can't load LND %s, module %s, rc=%d\n", libcfs_lnd2str(lnd_type), libcfs_lnd2modname(lnd_type), rc); @@ -1082,7 +1082,7 @@ lnet_startup_lndnis(void) rc = (lnd->lnd_startup)(ni); - LNET_MUTEX_UNLOCK(&the_lnet.ln_lnd_mutex); + mutex_unlock(&the_lnet.ln_lnd_mutex); if (rc != 0) { LCONSOLE_ERROR_MSG(0x105, "Error %d starting up LNI %s\n", @@ -1272,7 +1272,7 @@ LNetNIInit(lnet_pid_t requested_pid) int im_a_router = 0; int rc; - LNET_MUTEX_LOCK(&the_lnet.ln_api_mutex); + mutex_lock(&the_lnet.ln_api_mutex); LASSERT(the_lnet.ln_init); CDEBUG(D_OTHER, "refs %d\n", the_lnet.ln_refcount); @@ -1343,7 +1343,7 @@ LNetNIInit(lnet_pid_t requested_pid) failed0: LASSERT(rc < 0); out: - LNET_MUTEX_UNLOCK(&the_lnet.ln_api_mutex); + mutex_unlock(&the_lnet.ln_api_mutex); return rc; } EXPORT_SYMBOL(LNetNIInit); @@ -1360,7 +1360,7 @@ EXPORT_SYMBOL(LNetNIInit); int LNetNIFini(void) { - LNET_MUTEX_LOCK(&the_lnet.ln_api_mutex); + mutex_lock(&the_lnet.ln_api_mutex); LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); @@ -1383,7 +1383,7 @@ LNetNIFini(void) lnet_unprepare(); } - LNET_MUTEX_UNLOCK(&the_lnet.ln_api_mutex); + mutex_unlock(&the_lnet.ln_api_mutex); return 0; } EXPORT_SYMBOL(LNetNIFini); diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c index f73d64468396..6881b9cf32ce 100644 --- a/drivers/staging/lustre/lnet/lnet/module.c +++ b/drivers/staging/lustre/lnet/lnet/module.c @@ -49,7 +49,7 @@ lnet_configure(void *arg) /* 'arg' only there so I can be passed to cfs_create_thread() */ int rc = 0; - LNET_MUTEX_LOCK(&lnet_config_mutex); + mutex_lock(&lnet_config_mutex); if (!the_lnet.ln_niinit_self) { rc = LNetNIInit(LUSTRE_SRV_LNET_PID); @@ -59,7 +59,7 @@ lnet_configure(void *arg) } } - LNET_MUTEX_UNLOCK(&lnet_config_mutex); + mutex_unlock(&lnet_config_mutex); return rc; } @@ -68,18 +68,18 @@ lnet_unconfigure(void) { int refcount; - LNET_MUTEX_LOCK(&lnet_config_mutex); + mutex_lock(&lnet_config_mutex); if (the_lnet.ln_niinit_self) { the_lnet.ln_niinit_self = 0; LNetNIFini(); } - LNET_MUTEX_LOCK(&the_lnet.ln_api_mutex); + mutex_lock(&the_lnet.ln_api_mutex); refcount = the_lnet.ln_refcount; - LNET_MUTEX_UNLOCK(&the_lnet.ln_api_mutex); + mutex_unlock(&the_lnet.ln_api_mutex); - LNET_MUTEX_UNLOCK(&lnet_config_mutex); + mutex_unlock(&lnet_config_mutex); return (refcount == 0) ? 0 : -EBUSY; } From 7f804436fbd32c9784a2ae5324e64f9d4717c898 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Wed, 20 May 2015 00:07:27 +0200 Subject: [PATCH 0562/1163] staging: lustre: remove unused variable warning A recent patch to simplify the lustre large memory allocation causes new warnings as an unintended side-effect: lustre/lov/lov_request.c: In function 'lov_finish_set': lustre/lov/lov_request.c:78:7: warning: unused variable 'len' [-Wunused-variable] int len = set->set_oabufs * sizeof(*set->set_pga); ^ lustre/obdclass/acl.c: In function 'lustre_ext_acl_xattr_reduce_space': lustre/obdclass/acl.c:123:6: warning: unused variable 'old_size' [-Wunused-variable] int old_size = CFS_ACL_XATTR_SIZE(old_count, ext_acl_xattr); ^ The reason is that the 'size' argument to OBD_FREE_LARGE() is never needed, which was previously hidden by the extra abstractions. This avoids the warnings by adding a cast to void, to tell the compiler that the argument is intentionally unused. A better fix is probably to remove the entire set of allocation macros and open-code the normal kernel interface calls. Signed-off-by: Arnd Bergmann Fixes: 99d56ff7c1c ("staging/lustre: Always try kmalloc first for OBD_ALLOC_LARGE") Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/obd_support.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h index 379266d6bcd9..c0136ee778e3 100644 --- a/drivers/staging/lustre/lustre/include/obd_support.h +++ b/drivers/staging/lustre/lustre/include/obd_support.h @@ -688,6 +688,7 @@ do { \ #define OBD_FREE_LARGE(ptr, size) \ do { \ + (void)(size); \ kvfree(ptr); \ } while (0) From 4bff39dfb75743c44d429b84b3810a955b8192b2 Mon Sep 17 00:00:00 2001 From: "Gujulan Elango, Hari Prasath (H.)" Date: Wed, 13 May 2015 14:35:25 +0000 Subject: [PATCH 0563/1163] staging: wlan-ng: check return value of kmalloc check return value of kmalloc before accessing the memory pointer and return -ENOMEM if allocation fails. Signed-off-by: Hari Prasath Gujulan Elango Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/p80211conv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c index bd69e8cf200f..c0e6ac8a28eb 100644 --- a/drivers/staging/wlan-ng/p80211conv.c +++ b/drivers/staging/wlan-ng/p80211conv.c @@ -207,6 +207,8 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv, /* XXXX need to pick keynum other than default? */ p80211_wep->data = kmalloc(skb->len, GFP_ATOMIC); + if (!p80211_wep->data) + return -ENOMEM; foo = wep_encrypt(wlandev, skb->data, p80211_wep->data, skb->len, (wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK), From 613462e1e4d2ea64a29a06fccd3055328354bf3a Mon Sep 17 00:00:00 2001 From: chaehyun lim Date: Fri, 15 May 2015 22:13:43 +0900 Subject: [PATCH 0564/1163] staging: wlan-ng: fix checkpatch warnings clean up checkpatch.pl in prism2sta.c WARNING : line over 80 characters Signed-off-by: chaehyun lim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/prism2sta.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/staging/wlan-ng/prism2sta.c b/drivers/staging/wlan-ng/prism2sta.c index ddb294e7044f..0329c521d17c 100644 --- a/drivers/staging/wlan-ng/prism2sta.c +++ b/drivers/staging/wlan-ng/prism2sta.c @@ -428,7 +428,8 @@ u32 prism2sta_ifstate(wlandevice_t *wlandev, u32 ifstate) result = hfa384x_drvr_start(hw); if (result) { netdev_err(wlandev->netdev, - "hfa384x_drvr_start() failed,result=%d\n", (int)result); + "hfa384x_drvr_start() failed,result=%d\n", + (int)result); result = P80211ENUM_resultcode_implementation_failure; wlandev->msdstate = WLAN_MSD_HWPRESENT; @@ -471,7 +472,8 @@ u32 prism2sta_ifstate(wlandevice_t *wlandev, u32 ifstate) result = hfa384x_drvr_start(hw); if (result) { netdev_err(wlandev->netdev, - "hfa384x_drvr_start() failed,result=%d\n", (int)result); + "hfa384x_drvr_start() failed,result=%d\n", + (int)result); result = P80211ENUM_resultcode_implementation_failure; wlandev->msdstate = WLAN_MSD_HWPRESENT; @@ -481,7 +483,8 @@ u32 prism2sta_ifstate(wlandevice_t *wlandev, u32 ifstate) result = prism2sta_getcardinfo(wlandev); if (result) { netdev_err(wlandev->netdev, - "prism2sta_getcardinfo() failed,result=%d\n", (int)result); + "prism2sta_getcardinfo() failed,result=%d\n", + (int)result); result = P80211ENUM_resultcode_implementation_failure; hfa384x_drvr_stop(hw); @@ -491,7 +494,8 @@ u32 prism2sta_ifstate(wlandevice_t *wlandev, u32 ifstate) result = prism2sta_globalsetup(wlandev); if (result) { netdev_err(wlandev->netdev, - "prism2sta_globalsetup() failed,result=%d\n", (int)result); + "prism2sta_globalsetup() failed,result=%d\n", + (int)result); result = P80211ENUM_resultcode_implementation_failure; hfa384x_drvr_stop(hw); @@ -1244,9 +1248,9 @@ void prism2sta_processing_defer(struct work_struct *data) HFA384x_RID_CURRENTSSID, result); return; } - prism2mgmt_bytestr2pstr((struct hfa384x_bytestr *) &ssid, - (p80211pstrd_t *) & - wlandev->ssid); + prism2mgmt_bytestr2pstr( + (struct hfa384x_bytestr *) &ssid, + (p80211pstrd_t *) &wlandev->ssid); /* Collect the port status */ result = hfa384x_drvr_getconfig16(hw, @@ -1658,8 +1662,9 @@ static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev, if (hw->authlist.cnt >= WLAN_AUTH_MAX) { rec.status = P80211ENUM_status_ap_full; } else { - ether_addr_copy(hw->authlist.addr[hw->authlist.cnt], - rec.address); + ether_addr_copy( + hw->authlist.addr[hw->authlist.cnt], + rec.address); hw->authlist.cnt++; added = 1; } From 7e0b1b60cb0d7d3ae4c22a891e11ceccca17afee Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 22 May 2015 16:21:35 +0100 Subject: [PATCH 0565/1163] staging: comedi: 8255: fix I/O region leak on failure The Comedi "8255" driver does not clean up properly on failure. It can leave requested I/O port regions unreleased. Specifically, the Comedi "attach" handler (`dev_8255_attach()`) requests a specified I/O port region before calling `subdev_8255_init()` to set up the subdevice. If that fails, the "attach" handler returns an error and the Comedi core will call the "detach" handler (`dev_8255_detach()`) to clean up. The "detach" handler is responsible for releasing the I/O port regions successfully requested by the "attach" handler. Unfortunately, it is unable to obtain the base address of the region if the call to `subdev_8255_init()` failed. Fix the I/O region leak by releasing the region in the "attach" handler directly if the call to `subdev_8255_init()` fails. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/8255.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/staging/comedi/drivers/8255.c index ba89321df65d..0fdf8342c995 100644 --- a/drivers/staging/comedi/drivers/8255.c +++ b/drivers/staging/comedi/drivers/8255.c @@ -306,8 +306,15 @@ static int dev_8255_attach(struct comedi_device *dev, s->type = COMEDI_SUBD_UNUSED; } else { ret = subdev_8255_init(dev, s, NULL, iobase); - if (ret) + if (ret) { + /* + * Release the I/O port region here, as the + * "detach" handler cannot find it. + */ + release_region(iobase, I8255_SIZE); + s->type = COMEDI_SUBD_UNUSED; return ret; + } } } From d2c9deac56da9a5a56c32c4cb6ec3d6bad25ad84 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 22 May 2015 16:21:36 +0100 Subject: [PATCH 0566/1163] staging: comedi: 8255.h: don't include "../comedidev.h" The Comedi "8255.h" header doesn't use anything from "comedidev.h" apart from `struct comedi_device` and `struct comedi_subdevice`, which are only used to construct corresponding pointer types within the parameter lists of function prototypes. Just declare those structure types incompletely and don't bother including "comedidev.h". Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/8255.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/8255.h b/drivers/staging/comedi/drivers/8255.h index 934b940ebd3c..977cfe4da002 100644 --- a/drivers/staging/comedi/drivers/8255.h +++ b/drivers/staging/comedi/drivers/8255.h @@ -19,8 +19,6 @@ #ifndef _8255_H #define _8255_H -#include "../comedidev.h" - #define I8255_SIZE 0x04 #define I8255_DATA_A_REG 0x00 @@ -35,6 +33,9 @@ #define I8255_CTRL_A_MODE(x) ((x) << 5) #define I8255_CTRL_CW (1 << 7) +struct comedi_device; +struct comedi_subdevice; + int subdev_8255_init(struct comedi_device *, struct comedi_subdevice *, int (*io)(struct comedi_device *, int, int, int, unsigned long), From dc54ba4d88c329cfadbaf3523b2f83fcc121ae49 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 22 May 2015 16:21:37 +0100 Subject: [PATCH 0567/1163] staging: comedi: 8255: document callback parameters better Several Comedi driver modules call `subdev_8255_init()` or `subdev_8255_mm_init()` to set up a digital I/O subdevice based on the "8255" chip. One of the parameters to these functions is an optional pointer to an I/O callback function to perform the actual register accesses (an internal default callback function is used if NULL). The kerneldoc for `subdev_8255_init()` and `subdev_8255_mm_init()` describe the prototype of the optional I/O callback function incorrectly (my fault), adding a non-existent parameter of type `struct comedi_subdevice *`. Fix the kerneldoc. Also add parameter names to the callback function pointer type wherever it occurs to make the usage clearer. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/8255.c | 26 +++++++++++++------------- drivers/staging/comedi/drivers/8255.h | 12 ++++++------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/staging/comedi/drivers/8255.c index 0fdf8342c995..f87a27e540b1 100644 --- a/drivers/staging/comedi/drivers/8255.c +++ b/drivers/staging/comedi/drivers/8255.c @@ -55,7 +55,8 @@ struct subdev_8255_private { unsigned long regbase; - int (*io)(struct comedi_device *, int, int, int, unsigned long); + int (*io)(struct comedi_device *dev, int dir, int port, int data, + unsigned long regbase); }; static int subdev_8255_io(struct comedi_device *dev, @@ -160,8 +161,9 @@ static int subdev_8255_insn_config(struct comedi_device *dev, static int __subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s, - int (*io)(struct comedi_device *, - int, int, int, unsigned long), + int (*io)(struct comedi_device *dev, + int dir, int port, int data, + unsigned long regbase), unsigned long regbase, bool is_mmio) { @@ -204,11 +206,10 @@ static int __subdev_8255_init(struct comedi_device *dev, * If the optional I/O call-back function is provided, its prototype is of * the following form: * - * int my_8255_callback(struct comedi_device *dev, - * struct comedi_subdevice *s, int dir, int port, + * int my_8255_callback(struct comedi_device *dev, int dir, int port, * int data, unsigned long regbase); * - * where 'dev', 's', and 'regbase' match the values passed to this function, + * where 'dev', and 'regbase' match the values passed to this function, * 'port' is the 8255 port number 0 to 3 (including the control port), 'dir' * is the direction (0 for read, 1 for write) and 'data' is the value to be * written. It should return 0 if writing or the value read if reading. @@ -220,8 +221,8 @@ static int __subdev_8255_init(struct comedi_device *dev, * Return: -ENOMEM if failed to allocate memory, zero on success. */ int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s, - int (*io)(struct comedi_device *, - int, int, int, unsigned long), + int (*io)(struct comedi_device *dev, int dir, int port, + int data, unsigned long regbase), unsigned long regbase) { return __subdev_8255_init(dev, s, io, regbase, false); @@ -240,11 +241,10 @@ EXPORT_SYMBOL_GPL(subdev_8255_init); * If the optional I/O call-back function is provided, its prototype is of * the following form: * - * int my_8255_callback(struct comedi_device *dev, - * struct comedi_subdevice *s, int dir, int port, + * int my_8255_callback(struct comedi_device *dev, int dir, int port, * int data, unsigned long regbase); * - * where 'dev', 's', and 'regbase' match the values passed to this function, + * where 'dev', and 'regbase' match the values passed to this function, * 'port' is the 8255 port number 0 to 3 (including the control port), 'dir' * is the direction (0 for read, 1 for write) and 'data' is the value to be * written. It should return 0 if writing or the value read if reading. @@ -256,8 +256,8 @@ EXPORT_SYMBOL_GPL(subdev_8255_init); * Return: -ENOMEM if failed to allocate memory, zero on success. */ int subdev_8255_mm_init(struct comedi_device *dev, struct comedi_subdevice *s, - int (*io)(struct comedi_device *, - int, int, int, unsigned long), + int (*io)(struct comedi_device *dev, int dir, int port, + int data, unsigned long regbase), unsigned long regbase) { return __subdev_8255_init(dev, s, io, regbase, true); diff --git a/drivers/staging/comedi/drivers/8255.h b/drivers/staging/comedi/drivers/8255.h index 977cfe4da002..21856d669288 100644 --- a/drivers/staging/comedi/drivers/8255.h +++ b/drivers/staging/comedi/drivers/8255.h @@ -36,14 +36,14 @@ struct comedi_device; struct comedi_subdevice; -int subdev_8255_init(struct comedi_device *, struct comedi_subdevice *, - int (*io)(struct comedi_device *, - int, int, int, unsigned long), +int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s, + int (*io)(struct comedi_device *dev, int dir, int port, + int data, unsigned long regbase), unsigned long regbase); -int subdev_8255_mm_init(struct comedi_device *, struct comedi_subdevice *, - int (*io)(struct comedi_device *, - int, int, int, unsigned long), +int subdev_8255_mm_init(struct comedi_device *dev, struct comedi_subdevice *s, + int (*io)(struct comedi_device *dev, int dir, int port, + int data, unsigned long regbase), unsigned long regbase); #endif From 968d17786d74d2a637ab742a752e9302316f2194 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 22 May 2015 16:21:38 +0100 Subject: [PATCH 0568/1163] staging: comedi: comedi_8255: new module split from 8255 The Comedi "8255" module is both a standalone Comedi device driver module for simple devices with one or more 8255 "Programmable Peripheral Interface" chips at known I/O base addresses (configured at run-time), and a helper module to configure a 8255-based digital I/O subdevice for other Comedi drivers. Split the "8255 subdevice helper" functionality into a new module: "comedi_8255", leaving the standalone 8255 Comedi driver in the "8255" module. The Comedi "detach" routine of the standalone "8255" driver needs to retrieve the I/O base address passed to the "comedi_8255" module to set up each subdevice in order to release the I/O port regions it requested in its "attach" routine. The "comedi_8255" module stores it in a "subdevice private" data structure that is no longer known to the "8255" module, so add a new, exported function `subdev_8255_regbase()` to retrieve it. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/Kconfig | 18 +- drivers/staging/comedi/drivers/8255.c | 223 +-------------- drivers/staging/comedi/drivers/8255.h | 2 + drivers/staging/comedi/drivers/Makefile | 3 +- drivers/staging/comedi/drivers/comedi_8255.c | 285 +++++++++++++++++++ 5 files changed, 305 insertions(+), 226 deletions(-) create mode 100644 drivers/staging/comedi/drivers/comedi_8255.c diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 61c6351f55ac..7dee73dfbf88 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -1247,16 +1247,22 @@ config COMEDI_8254 tristate config COMEDI_8255 - tristate "Generic 8255 support" + tristate + +config COMEDI_8255_SA + tristate "Standalone 8255 support" + select COMEDI_8255 ---help--- - Enable generic 8255 support. + Enable support for 8255 digital I/O as a standalone driver. You should enable compilation this driver if you plan to use a board - that has an 8255 chip. For multifunction boards, the main driver will - configure the 8255 subdevice automatically. + that has an 8255 chip at a known I/O base address and there are no + other Comedi drivers for the board. - Note that most PCI based 8255 boards use the 8255_pci driver as a - wrapper around this driver. + Note that Comedi drivers for most multi-function boards incorporating + an 8255 chip use the 'comedi_8255' module. Most PCI-based 8255 + boards use the 8255_pci driver as a wrapper around the 'comedi_8255' + module. To compile this driver as a module, choose M here: the module will be called 8255. diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/staging/comedi/drivers/8255.c index f87a27e540b1..b79d3764a8a0 100644 --- a/drivers/staging/comedi/drivers/8255.c +++ b/drivers/staging/comedi/drivers/8255.c @@ -53,221 +53,6 @@ #include "8255.h" -struct subdev_8255_private { - unsigned long regbase; - int (*io)(struct comedi_device *dev, int dir, int port, int data, - unsigned long regbase); -}; - -static int subdev_8255_io(struct comedi_device *dev, - int dir, int port, int data, unsigned long regbase) -{ - if (dir) { - outb(data, dev->iobase + regbase + port); - return 0; - } - return inb(dev->iobase + regbase + port); -} - -static int subdev_8255_mmio(struct comedi_device *dev, - int dir, int port, int data, unsigned long regbase) -{ - if (dir) { - writeb(data, dev->mmio + regbase + port); - return 0; - } - return readb(dev->mmio + regbase + port); -} - -static int subdev_8255_insn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct subdev_8255_private *spriv = s->private; - unsigned long regbase = spriv->regbase; - unsigned int mask; - unsigned int v; - - mask = comedi_dio_update_state(s, data); - if (mask) { - if (mask & 0xff) - spriv->io(dev, 1, I8255_DATA_A_REG, - s->state & 0xff, regbase); - if (mask & 0xff00) - spriv->io(dev, 1, I8255_DATA_B_REG, - (s->state >> 8) & 0xff, regbase); - if (mask & 0xff0000) - spriv->io(dev, 1, I8255_DATA_C_REG, - (s->state >> 16) & 0xff, regbase); - } - - v = spriv->io(dev, 0, I8255_DATA_A_REG, 0, regbase); - v |= (spriv->io(dev, 0, I8255_DATA_B_REG, 0, regbase) << 8); - v |= (spriv->io(dev, 0, I8255_DATA_C_REG, 0, regbase) << 16); - - data[1] = v; - - return insn->n; -} - -static void subdev_8255_do_config(struct comedi_device *dev, - struct comedi_subdevice *s) -{ - struct subdev_8255_private *spriv = s->private; - unsigned long regbase = spriv->regbase; - int config; - - config = I8255_CTRL_CW; - /* 1 in io_bits indicates output, 1 in config indicates input */ - if (!(s->io_bits & 0x0000ff)) - config |= I8255_CTRL_A_IO; - if (!(s->io_bits & 0x00ff00)) - config |= I8255_CTRL_B_IO; - if (!(s->io_bits & 0x0f0000)) - config |= I8255_CTRL_C_LO_IO; - if (!(s->io_bits & 0xf00000)) - config |= I8255_CTRL_C_HI_IO; - - spriv->io(dev, 1, I8255_CTRL_REG, config, regbase); -} - -static int subdev_8255_insn_config(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int mask; - int ret; - - if (chan < 8) - mask = 0x0000ff; - else if (chan < 16) - mask = 0x00ff00; - else if (chan < 20) - mask = 0x0f0000; - else - mask = 0xf00000; - - ret = comedi_dio_insn_config(dev, s, insn, data, mask); - if (ret) - return ret; - - subdev_8255_do_config(dev, s); - - return insn->n; -} - -static int __subdev_8255_init(struct comedi_device *dev, - struct comedi_subdevice *s, - int (*io)(struct comedi_device *dev, - int dir, int port, int data, - unsigned long regbase), - unsigned long regbase, - bool is_mmio) -{ - struct subdev_8255_private *spriv; - - spriv = comedi_alloc_spriv(s, sizeof(*spriv)); - if (!spriv) - return -ENOMEM; - - if (io) - spriv->io = io; - else if (is_mmio) - spriv->io = subdev_8255_mmio; - else - spriv->io = subdev_8255_io; - spriv->regbase = regbase; - - s->type = COMEDI_SUBD_DIO; - s->subdev_flags = SDF_READABLE | SDF_WRITABLE; - s->n_chan = 24; - s->range_table = &range_digital; - s->maxdata = 1; - s->insn_bits = subdev_8255_insn; - s->insn_config = subdev_8255_insn_config; - - subdev_8255_do_config(dev, s); - - return 0; -} - -/** - * subdev_8255_init - initialize DIO subdevice for driving I/O mapped 8255 - * @dev: comedi device owning subdevice - * @s: comedi subdevice to initialize - * @io: (optional) register I/O call-back function - * @regbase: offset of 8255 registers from dev->iobase, or call-back context - * - * Initializes a comedi subdevice as a DIO subdevice driving an 8255 chip. - * - * If the optional I/O call-back function is provided, its prototype is of - * the following form: - * - * int my_8255_callback(struct comedi_device *dev, int dir, int port, - * int data, unsigned long regbase); - * - * where 'dev', and 'regbase' match the values passed to this function, - * 'port' is the 8255 port number 0 to 3 (including the control port), 'dir' - * is the direction (0 for read, 1 for write) and 'data' is the value to be - * written. It should return 0 if writing or the value read if reading. - * - * If the optional I/O call-back function is not provided, an internal - * call-back function is used which uses consecutive I/O port addresses - * starting at dev->iobase + regbase. - * - * Return: -ENOMEM if failed to allocate memory, zero on success. - */ -int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s, - int (*io)(struct comedi_device *dev, int dir, int port, - int data, unsigned long regbase), - unsigned long regbase) -{ - return __subdev_8255_init(dev, s, io, regbase, false); -} -EXPORT_SYMBOL_GPL(subdev_8255_init); - -/** - * subdev_8255_mm_init - initialize DIO subdevice for driving mmio-mapped 8255 - * @dev: comedi device owning subdevice - * @s: comedi subdevice to initialize - * @io: (optional) register I/O call-back function - * @regbase: offset of 8255 registers from dev->mmio, or call-back context - * - * Initializes a comedi subdevice as a DIO subdevice driving an 8255 chip. - * - * If the optional I/O call-back function is provided, its prototype is of - * the following form: - * - * int my_8255_callback(struct comedi_device *dev, int dir, int port, - * int data, unsigned long regbase); - * - * where 'dev', and 'regbase' match the values passed to this function, - * 'port' is the 8255 port number 0 to 3 (including the control port), 'dir' - * is the direction (0 for read, 1 for write) and 'data' is the value to be - * written. It should return 0 if writing or the value read if reading. - * - * If the optional I/O call-back function is not provided, an internal - * call-back function is used which uses consecutive MMIO virtual addresses - * starting at dev->mmio + regbase. - * - * Return: -ENOMEM if failed to allocate memory, zero on success. - */ -int subdev_8255_mm_init(struct comedi_device *dev, struct comedi_subdevice *s, - int (*io)(struct comedi_device *dev, int dir, int port, - int data, unsigned long regbase), - unsigned long regbase) -{ - return __subdev_8255_init(dev, s, io, regbase, true); -} -EXPORT_SYMBOL_GPL(subdev_8255_mm_init); - -/* - * Start of the 8255 standalone device - */ - static int dev_8255_attach(struct comedi_device *dev, struct comedi_devconfig *it) { @@ -324,14 +109,14 @@ static int dev_8255_attach(struct comedi_device *dev, static void dev_8255_detach(struct comedi_device *dev) { struct comedi_subdevice *s; - struct subdev_8255_private *spriv; int i; for (i = 0; i < dev->n_subdevices; i++) { s = &dev->subdevices[i]; if (s->type != COMEDI_SUBD_UNUSED) { - spriv = s->private; - release_region(spriv->regbase, I8255_SIZE); + unsigned long regbase = subdev_8255_regbase(s); + + release_region(regbase, I8255_SIZE); } } } @@ -345,5 +130,5 @@ static struct comedi_driver dev_8255_driver = { module_comedi_driver(dev_8255_driver); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("Comedi driver for standalone 8255 devices"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/8255.h b/drivers/staging/comedi/drivers/8255.h index 21856d669288..41823de69b77 100644 --- a/drivers/staging/comedi/drivers/8255.h +++ b/drivers/staging/comedi/drivers/8255.h @@ -46,4 +46,6 @@ int subdev_8255_mm_init(struct comedi_device *dev, struct comedi_subdevice *s, int data, unsigned long regbase), unsigned long regbase); +unsigned long subdev_8255_regbase(struct comedi_subdevice *s); + #endif diff --git a/drivers/staging/comedi/drivers/Makefile b/drivers/staging/comedi/drivers/Makefile index d6d834006015..5764dc9a6893 100644 --- a/drivers/staging/comedi/drivers/Makefile +++ b/drivers/staging/comedi/drivers/Makefile @@ -139,7 +139,8 @@ obj-$(CONFIG_COMEDI_NI_TIOCMD) += ni_tiocmd.o obj-$(CONFIG_COMEDI_NI_LABPC) += ni_labpc_common.o obj-$(CONFIG_COMEDI_NI_LABPC_ISADMA) += ni_labpc_isadma.o -obj-$(CONFIG_COMEDI_8255) += 8255.o +obj-$(CONFIG_COMEDI_8255) += comedi_8255.o +obj-$(CONFIG_COMEDI_8255_SA) += 8255.o obj-$(CONFIG_COMEDI_AMPLC_DIO200) += amplc_dio200_common.o obj-$(CONFIG_COMEDI_AMPLC_PC236) += amplc_pc236_common.o obj-$(CONFIG_COMEDI_DAS08) += das08.o diff --git a/drivers/staging/comedi/drivers/comedi_8255.c b/drivers/staging/comedi/drivers/comedi_8255.c new file mode 100644 index 000000000000..b2441efc61cc --- /dev/null +++ b/drivers/staging/comedi/drivers/comedi_8255.c @@ -0,0 +1,285 @@ +/* + * comedi_8255.c + * Generic 8255 digital I/O support + * + * Split from the Comedi "8255" driver module. + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 1998 David A. Schleef + * + * 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. + */ + +/* + * Module: comedi_8255 + * Description: Generic 8255 support + * Author: ds + * Updated: Fri, 22 May 2015 12:14:17 +0000 + * Status: works + * + * This module is not used directly by end-users. Rather, it is used by + * other drivers to provide support for an 8255 "Programmable Peripheral + * Interface" (PPI) chip. + * + * The classic in digital I/O. The 8255 appears in Comedi as a single + * digital I/O subdevice with 24 channels. The channel 0 corresponds to + * the 8255's port A, bit 0; channel 23 corresponds to port C, bit 7. + * Direction configuration is done in blocks, with channels 0-7, 8-15, + * 16-19, and 20-23 making up the 4 blocks. The only 8255 mode + * supported is mode 0. + */ + +#include +#include "../comedidev.h" + +#include "8255.h" + +struct subdev_8255_private { + unsigned long regbase; + int (*io)(struct comedi_device *dev, int dir, int port, int data, + unsigned long regbase); +}; + +static int subdev_8255_io(struct comedi_device *dev, + int dir, int port, int data, unsigned long regbase) +{ + if (dir) { + outb(data, dev->iobase + regbase + port); + return 0; + } + return inb(dev->iobase + regbase + port); +} + +static int subdev_8255_mmio(struct comedi_device *dev, + int dir, int port, int data, unsigned long regbase) +{ + if (dir) { + writeb(data, dev->mmio + regbase + port); + return 0; + } + return readb(dev->mmio + regbase + port); +} + +static int subdev_8255_insn(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct subdev_8255_private *spriv = s->private; + unsigned long regbase = spriv->regbase; + unsigned int mask; + unsigned int v; + + mask = comedi_dio_update_state(s, data); + if (mask) { + if (mask & 0xff) + spriv->io(dev, 1, I8255_DATA_A_REG, + s->state & 0xff, regbase); + if (mask & 0xff00) + spriv->io(dev, 1, I8255_DATA_B_REG, + (s->state >> 8) & 0xff, regbase); + if (mask & 0xff0000) + spriv->io(dev, 1, I8255_DATA_C_REG, + (s->state >> 16) & 0xff, regbase); + } + + v = spriv->io(dev, 0, I8255_DATA_A_REG, 0, regbase); + v |= (spriv->io(dev, 0, I8255_DATA_B_REG, 0, regbase) << 8); + v |= (spriv->io(dev, 0, I8255_DATA_C_REG, 0, regbase) << 16); + + data[1] = v; + + return insn->n; +} + +static void subdev_8255_do_config(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + struct subdev_8255_private *spriv = s->private; + unsigned long regbase = spriv->regbase; + int config; + + config = I8255_CTRL_CW; + /* 1 in io_bits indicates output, 1 in config indicates input */ + if (!(s->io_bits & 0x0000ff)) + config |= I8255_CTRL_A_IO; + if (!(s->io_bits & 0x00ff00)) + config |= I8255_CTRL_B_IO; + if (!(s->io_bits & 0x0f0000)) + config |= I8255_CTRL_C_LO_IO; + if (!(s->io_bits & 0xf00000)) + config |= I8255_CTRL_C_HI_IO; + + spriv->io(dev, 1, I8255_CTRL_REG, config, regbase); +} + +static int subdev_8255_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int mask; + int ret; + + if (chan < 8) + mask = 0x0000ff; + else if (chan < 16) + mask = 0x00ff00; + else if (chan < 20) + mask = 0x0f0000; + else + mask = 0xf00000; + + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; + + subdev_8255_do_config(dev, s); + + return insn->n; +} + +static int __subdev_8255_init(struct comedi_device *dev, + struct comedi_subdevice *s, + int (*io)(struct comedi_device *dev, + int dir, int port, int data, + unsigned long regbase), + unsigned long regbase, + bool is_mmio) +{ + struct subdev_8255_private *spriv; + + spriv = comedi_alloc_spriv(s, sizeof(*spriv)); + if (!spriv) + return -ENOMEM; + + if (io) + spriv->io = io; + else if (is_mmio) + spriv->io = subdev_8255_mmio; + else + spriv->io = subdev_8255_io; + spriv->regbase = regbase; + + s->type = COMEDI_SUBD_DIO; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE; + s->n_chan = 24; + s->range_table = &range_digital; + s->maxdata = 1; + s->insn_bits = subdev_8255_insn; + s->insn_config = subdev_8255_insn_config; + + subdev_8255_do_config(dev, s); + + return 0; +} + +/** + * subdev_8255_init - initialize DIO subdevice for driving I/O mapped 8255 + * @dev: comedi device owning subdevice + * @s: comedi subdevice to initialize + * @io: (optional) register I/O call-back function + * @regbase: offset of 8255 registers from dev->iobase, or call-back context + * + * Initializes a comedi subdevice as a DIO subdevice driving an 8255 chip. + * + * If the optional I/O call-back function is provided, its prototype is of + * the following form: + * + * int my_8255_callback(struct comedi_device *dev, int dir, int port, + * int data, unsigned long regbase); + * + * where 'dev', and 'regbase' match the values passed to this function, + * 'port' is the 8255 port number 0 to 3 (including the control port), 'dir' + * is the direction (0 for read, 1 for write) and 'data' is the value to be + * written. It should return 0 if writing or the value read if reading. + * + * If the optional I/O call-back function is not provided, an internal + * call-back function is used which uses consecutive I/O port addresses + * starting at dev->iobase + regbase. + * + * Return: -ENOMEM if failed to allocate memory, zero on success. + */ +int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s, + int (*io)(struct comedi_device *dev, int dir, int port, + int data, unsigned long regbase), + unsigned long regbase) +{ + return __subdev_8255_init(dev, s, io, regbase, false); +} +EXPORT_SYMBOL_GPL(subdev_8255_init); + +/** + * subdev_8255_mm_init - initialize DIO subdevice for driving mmio-mapped 8255 + * @dev: comedi device owning subdevice + * @s: comedi subdevice to initialize + * @io: (optional) register I/O call-back function + * @regbase: offset of 8255 registers from dev->mmio, or call-back context + * + * Initializes a comedi subdevice as a DIO subdevice driving an 8255 chip. + * + * If the optional I/O call-back function is provided, its prototype is of + * the following form: + * + * int my_8255_callback(struct comedi_device *dev, int dir, int port, + * int data, unsigned long regbase); + * + * where 'dev', and 'regbase' match the values passed to this function, + * 'port' is the 8255 port number 0 to 3 (including the control port), 'dir' + * is the direction (0 for read, 1 for write) and 'data' is the value to be + * written. It should return 0 if writing or the value read if reading. + * + * If the optional I/O call-back function is not provided, an internal + * call-back function is used which uses consecutive MMIO virtual addresses + * starting at dev->mmio + regbase. + * + * Return: -ENOMEM if failed to allocate memory, zero on success. + */ +int subdev_8255_mm_init(struct comedi_device *dev, struct comedi_subdevice *s, + int (*io)(struct comedi_device *dev, int dir, int port, + int data, unsigned long regbase), + unsigned long regbase) +{ + return __subdev_8255_init(dev, s, io, regbase, true); +} +EXPORT_SYMBOL_GPL(subdev_8255_mm_init); + +/** + * subdev_8255_regbase - get offset of 8255 registers or call-back context + * @s: comedi subdevice + * + * Returns the 'regbase' parameter that was previously passed to to + * subdev_8255_init() or subdev_8255_mm_init() to set up the subdevice. + * Only valid if the subdevice was set up successfully. + */ +unsigned long subdev_8255_regbase(struct comedi_subdevice *s) +{ + struct subdev_8255_private *spriv = s->private; + + return spriv->regbase; +} +EXPORT_SYMBOL_GPL(subdev_8255_regbase); + +static int __init comedi_8255_module_init(void) +{ + return 0; +} +module_init(comedi_8255_module_init); + +static void __exit comedi_8255_module_exit(void) +{ +} +module_exit(comedi_8255_module_exit); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi: Generic 8255 digital I/O support"); +MODULE_LICENSE("GPL"); From d94e5c635289e29d1f0f3dd536f07a84378b702c Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 22 May 2015 18:15:56 +0100 Subject: [PATCH 0569/1163] staging: comedi: amplc_dio200.h: reformat copyright comment Reformat the copyright comment at the top of the file to use the preferred block comment style. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_dio200.h | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200.h b/drivers/staging/comedi/drivers/amplc_dio200.h index d6d6a265c461..2dbeea6c9d77 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200.h +++ b/drivers/staging/comedi/drivers/amplc_dio200.h @@ -1,24 +1,24 @@ /* - comedi/drivers/amplc_dio.h - - Header for amplc_dio200.c, amplc_dio200_common.c and - amplc_dio200_pci.c. - - Copyright (C) 2005-2013 MEV Ltd. - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 1998,2000 David A. Schleef - - 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. -*/ + * comedi/drivers/amplc_dio.h + * + * Header for amplc_dio200.c, amplc_dio200_common.c and + * amplc_dio200_pci.c. + * + * Copyright (C) 2005-2013 MEV Ltd. + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 1998,2000 David A. Schleef + * + * 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. + */ #ifndef AMPLC_DIO200_H_INCLUDED #define AMPLC_DIO200_H_INCLUDED From 8ea6663284dc47c5afdd26175f0b7f6992f6b627 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 22 May 2015 18:15:57 +0100 Subject: [PATCH 0570/1163] staging: comedi: amplc_dio200.h: make self-reliant The Comedi "amplc_dio200.h" header file included by drivers for Amplicon DIO200 series cards does not compile cleanly when it is the first header included by the ".c" file. It uses `struct comedi_device *` in the parameter lists of some function prototypes, so just declare `struct comedi_device` as an incomplete type. It also uses `bool`, so include to declare it. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_dio200.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/comedi/drivers/amplc_dio200.h b/drivers/staging/comedi/drivers/amplc_dio200.h index 2dbeea6c9d77..53fb86d59fc3 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200.h +++ b/drivers/staging/comedi/drivers/amplc_dio200.h @@ -23,6 +23,10 @@ #ifndef AMPLC_DIO200_H_INCLUDED #define AMPLC_DIO200_H_INCLUDED +#include + +struct comedi_device; + /* * Subdevice types. */ From 158bb7287ea00eff8ca5c2a60a384368dcce1d7c Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 22 May 2015 18:15:58 +0100 Subject: [PATCH 0571/1163] staging: comedi: amplc_dio200.c: reformat copyright comment Reformat the copyright comment at the top of the file to use the preferred block comment style. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_dio200.c | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/staging/comedi/drivers/amplc_dio200.c index 4fe118380218..f5cfa71a90c6 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200.c +++ b/drivers/staging/comedi/drivers/amplc_dio200.c @@ -1,23 +1,24 @@ /* - comedi/drivers/amplc_dio200.c + * comedi/drivers/amplc_dio200.c + * + * Driver for Amplicon PC212E, PC214E, PC215E, PC218E, PC272E. + * + * Copyright (C) 2005-2013 MEV Ltd. + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 1998,2000 David A. Schleef + * + * 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. + */ - Driver for Amplicon PC212E, PC214E, PC215E, PC218E, PC272E. - - Copyright (C) 2005-2013 MEV Ltd. - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 1998,2000 David A. Schleef - - 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. -*/ /* * Driver: amplc_dio200 * Description: Amplicon 200 Series ISA Digital I/O From 94ef9718111f8d7687e84c2f9309cc0838e30e9e Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 22 May 2015 18:15:59 +0100 Subject: [PATCH 0572/1163] staging: comedi: amplc_dio200_common.c: reformat copyright comment Reformat the copyright comment at the top of the file to use the preferred block comment style. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/amplc_dio200_common.c | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 3a8b3f27b525..88862523fcb0 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -1,23 +1,23 @@ /* - comedi/drivers/amplc_dio200_common.c - - Common support code for "amplc_dio200" and "amplc_dio200_pci". - - Copyright (C) 2005-2013 MEV Ltd. - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 1998,2000 David A. Schleef - - 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. -*/ + * comedi/drivers/amplc_dio200_common.c + * + * Common support code for "amplc_dio200" and "amplc_dio200_pci". + * + * Copyright (C) 2005-2013 MEV Ltd. + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 1998,2000 David A. Schleef + * + * 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 From 4cb1dec981a6d55cad1c071bed9489670e31f7e2 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 22 May 2015 18:16:00 +0100 Subject: [PATCH 0573/1163] staging: comedi: amplc_dio200_common.c: fix up brace style Use braces when the single statement following an `if` (or `else`) spans more than one line (including any preceding comments). Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/amplc_dio200_common.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 88862523fcb0..d1539e798ffd 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -337,9 +337,10 @@ static int dio200_handle_read_intr(struct comedi_device *dev, * interested in (just in case there's a race * condition). */ - if (triggered & subpriv->enabled_isns) + if (triggered & subpriv->enabled_isns) { /* Collect scan data. */ dio200_read_scan_intr(dev, s, triggered); + } } } spin_unlock_irqrestore(&subpriv->spinlock, flags); @@ -576,12 +577,13 @@ static int dio200_subdev_8254_init(struct comedi_device *dev, regshift = 0; } - if (dev->mmio) + if (dev->mmio) { i8254 = comedi_8254_mm_init(dev->mmio + offset, 0, I8254_IO8, regshift); - else + } else { i8254 = comedi_8254_init(dev->iobase + offset, 0, I8254_IO8, regshift); + } if (!i8254) return -ENOMEM; @@ -641,15 +643,18 @@ static int dio200_subdev_8255_bits(struct comedi_device *dev, mask = comedi_dio_update_state(s, data); if (mask) { - if (mask & 0xff) + if (mask & 0xff) { dio200_write8(dev, subpriv->ofs + I8255_DATA_A_REG, s->state & 0xff); - if (mask & 0xff00) + } + if (mask & 0xff00) { dio200_write8(dev, subpriv->ofs + I8255_DATA_B_REG, (s->state >> 8) & 0xff); - if (mask & 0xff0000) + } + if (mask & 0xff0000) { dio200_write8(dev, subpriv->ofs + I8255_DATA_C_REG, (s->state >> 16) & 0xff); + } } val = dio200_read8(dev, subpriv->ofs + I8255_DATA_A_REG); From 7da42b5fda090b3e4128624d39bc742ceeff1104 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 22 May 2015 18:16:01 +0100 Subject: [PATCH 0574/1163] staging: comedi: amplc_dio200_pci.c: reformat copyright comment Reformat the copyright comment at the top of the file to use the preferred block comment style. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/amplc_dio200_pci.c | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200_pci.c b/drivers/staging/comedi/drivers/amplc_dio200_pci.c index d9850c917163..2598e6e7d47d 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_pci.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_pci.c @@ -1,22 +1,23 @@ /* comedi/drivers/amplc_dio200_pci.c + * + * Driver for Amplicon PCI215, PCI272, PCIe215, PCIe236, PCIe296. + * + * Copyright (C) 2005-2013 MEV Ltd. + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 1998,2000 David A. Schleef + * + * 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. + */ - Driver for Amplicon PCI215, PCI272, PCIe215, PCIe236, PCIe296. - - Copyright (C) 2005-2013 MEV Ltd. - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 1998,2000 David A. Schleef - - 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. -*/ /* * Driver: amplc_dio200_pci * Description: Amplicon 200 Series PCI Digital I/O From e57180c85a0b9b471327c69679fb81fd36578897 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 22 May 2015 17:32:03 +0100 Subject: [PATCH 0575/1163] staging: comedi: addi_watchdog.h: don't include "../comedidev.h" The Comedi "addi_watchdog.h" header doesn't use anything form "comedidev.h" apart from `struct comedi_subdevice`, which it only uses to construct a corresponding pointer type within the parameter list of a function prototype. Just declare the structure type incompletely and don't bother including the header file. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_watchdog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi_watchdog.h b/drivers/staging/comedi/drivers/addi_watchdog.h index 83b47befa4d1..3f8e7388bbca 100644 --- a/drivers/staging/comedi/drivers/addi_watchdog.h +++ b/drivers/staging/comedi/drivers/addi_watchdog.h @@ -1,7 +1,7 @@ #ifndef _ADDI_WATCHDOG_H #define _ADDI_WATCHDOG_H -#include "../comedidev.h" +struct comedi_subdevice; void addi_watchdog_reset(unsigned long iobase); int addi_watchdog_init(struct comedi_subdevice *, unsigned long iobase); From b727255f01fa519e1bfb047e3eefb9bb74512404 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 22 May 2015 18:32:31 +0100 Subject: [PATCH 0576/1163] staging: comedi: comedi_8254.h: make self-reliant The Comedi "comedi_8254.h" header file is included by various Comedi drivers with timer/counters based on the 8254 chip. The drivers do not compile cleanly if this header file is included first. It uses pointers to the `struct comedi_device`, `struct comedi_subdevice`, and `struct comedi_insn` structures in various function prototypes, so declare those as incomplete types. It use the `bool` type, so include . It also uses the `__iomem` tag, but that seems to be taken care of indirectly by including . Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_8254.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/staging/comedi/drivers/comedi_8254.h b/drivers/staging/comedi/drivers/comedi_8254.h index d89f6d94f8aa..f4610ead6172 100644 --- a/drivers/staging/comedi/drivers/comedi_8254.h +++ b/drivers/staging/comedi/drivers/comedi_8254.h @@ -20,6 +20,12 @@ #ifndef _COMEDI_8254_H #define _COMEDI_8254_H +#include + +struct comedi_device; +struct comedi_insn; +struct comedi_subdevice; + /* * Common oscillator base values in nanoseconds */ From 3a62cdb7f64f80579ce18178ecc145f01c1ad746 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 22 May 2015 18:45:25 +0100 Subject: [PATCH 0577/1163] staging: comedi: comedi_isadma.h: make self-reliant The Comedi "comedi_isadma.h" header is included by the source for the "comedi_isadma" helper module and other modules that use it. It does not compile cleanly when it is the first header file included. It uses the `dma_addr_t` type, so include to declare it. (Also, that indirectly takes care of the use of `NULL`.) It uses `struct comedi_device *` in various function prototypes, so add an incomplete declaration of `struct comedi_device`. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_isadma.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/comedi/drivers/comedi_isadma.h b/drivers/staging/comedi/drivers/comedi_isadma.h index c7c524faf595..2fb6573ba9e4 100644 --- a/drivers/staging/comedi/drivers/comedi_isadma.h +++ b/drivers/staging/comedi/drivers/comedi_isadma.h @@ -16,6 +16,10 @@ #ifndef _COMEDI_ISADMA_H #define _COMEDI_ISADMA_H +#include + +struct comedi_device; + /* * These are used to avoid issues when and the DMA_MODE_ * defines are not available. From cdfba23d77b10a4d7a235772fb91787e317a62e6 Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Mon, 25 May 2015 14:20:43 +0000 Subject: [PATCH 0578/1163] staging: comedi: fix checkpatch error Fixed an error found by checkpatch.pl. ERROR: space required after that ',' (ctx:VxV) ./drivers/ni_mio_common.c:3764 Signed-off-by: Geliang Tang Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 9dfd4e6e6ced..f01ef89d91be 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -3761,7 +3761,7 @@ static unsigned int ni_gpct_to_stc_register(struct comedi_device *dev, if (reg < ARRAY_SIZE(ni_gpct_to_stc_regmap)) { regmap = &ni_gpct_to_stc_regmap[reg]; } else { - dev_warn(dev->class_dev,"%s: unhandled register 0x%x\n", + dev_warn(dev->class_dev, "%s: unhandled register 0x%x\n", __func__, reg); return 0; } From 71f50e25c0073aa0f1d9274643cb216cfa3094be Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Mon, 25 May 2015 14:20:44 +0000 Subject: [PATCH 0579/1163] staging: comedi: keep the consistency Changed "register 0x%x" to "register=0x%x" to keep the consistency of this file. Signed-off-by: Geliang Tang Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index f01ef89d91be..6cc304a4c59b 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -3761,7 +3761,7 @@ static unsigned int ni_gpct_to_stc_register(struct comedi_device *dev, if (reg < ARRAY_SIZE(ni_gpct_to_stc_regmap)) { regmap = &ni_gpct_to_stc_regmap[reg]; } else { - dev_warn(dev->class_dev, "%s: unhandled register 0x%x\n", + dev_warn(dev->class_dev, "%s: unhandled register=0x%x\n", __func__, reg); return 0; } From 8b4e7da516aa52f2b8dcff1939073beacf63788a Mon Sep 17 00:00:00 2001 From: Matthew Needes Date: Mon, 25 May 2015 16:41:20 -0700 Subject: [PATCH 0580/1163] staging: comedi/drivers/pcl.* coding style fixes pcl812.c / pcl816.c (resend of earlier patch) Fixed indentation problems. Signed-off-by: Matthew Needes Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 2 +- drivers/staging/comedi/drivers/pcl816.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 03a3fd6cd918..7474ef99faba 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -1155,7 +1155,7 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* we need an IRQ to do DMA on channel 3 or 1 */ if (dev->irq && board->has_dma) - pcl812_alloc_dma(dev, it->options[2]); + pcl812_alloc_dma(dev, it->options[2]); /* differential analog inputs? */ switch (board->board_type) { diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 1ccb2f19f4be..781b321587dc 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -323,7 +323,7 @@ static int check_channel_list(struct comedi_device *dev, /* check whole chanlist */ for (i = 0, segpos = 0; i < chanlen; i++) { - if (chanlist[i] != chansegment[i % seglen]) { + if (chanlist[i] != chansegment[i % seglen]) { dev_dbg(dev->class_dev, "bad channel or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n", i, CR_CHAN(chansegment[i]), From d0e2f8f0bea40becbbdea3e53b7bf4ab5f64dc10 Mon Sep 17 00:00:00 2001 From: Matthew Needes Date: Mon, 25 May 2015 16:41:21 -0700 Subject: [PATCH 0581/1163] staging: comedi/drivers/pcl.* coding style fixes pcl812.c (resend of earlier patch) Fixed lines exceeding 80 columns, correcting some spelling in process Signed-off-by: Matthew Needes Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 7474ef99faba..48f6cdf440b9 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -507,11 +507,11 @@ static const struct pcl812_board boardtypes[] = { struct pcl812_private { struct comedi_isadma *dma; - unsigned char range_correction; /* =1 we must add 1 to range number */ + unsigned char range_correction; /* =1 we must add 1 to range number */ unsigned int last_ai_chanspec; - unsigned char mode_reg_int; /* there is stored INT number for some card */ - unsigned int ai_poll_ptr; /* how many sampes transfer poll */ - unsigned int max_812_ai_mode0_rangewait; /* setling time for gain */ + unsigned char mode_reg_int; /* stored INT number for some cards */ + unsigned int ai_poll_ptr; /* how many samples transfer poll */ + unsigned int max_812_ai_mode0_rangewait; /* settling time for gain */ unsigned int use_diff:1; unsigned int use_mpc508:1; unsigned int use_ext_trg:1; From b2d3977f7d983a71106bb91674a61dd1285c0441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bu=C5=A3iu=20Alexandru=20Octavian?= Date: Sun, 17 May 2015 22:31:34 +0300 Subject: [PATCH 0582/1163] Staging: dgnc: fixed coding style issue in digi.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed coding style issue "warning line over 80 characters" detected by checkpatch.pl in digi.h Signed-off-by: Buţiu Alexandru Octavian Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/digi.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/dgnc/digi.h b/drivers/staging/dgnc/digi.h index d637a7802168..cf9dcae7cc3f 100644 --- a/drivers/staging/dgnc/digi.h +++ b/drivers/staging/dgnc/digi.h @@ -130,19 +130,19 @@ struct digi_getcounter { #define BD_RUNNING 0x0 #define BD_NOFEP 0x5 -#define DIGI_SETCUSTOMBAUD _IOW('e', 106, int) /* Set integer baud rate */ -#define DIGI_GETCUSTOMBAUD _IOR('e', 107, int) /* Get integer baud 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_REALPORT_GETBUFFERS (('e'<<8) | 108) #define DIGI_REALPORT_SENDIMMEDIATE (('e'<<8) | 109) #define DIGI_REALPORT_GETCOUNTERS (('e'<<8) | 110) #define DIGI_REALPORT_GETEVENTS (('e'<<8) | 111) -#define EV_OPU 0x0001 /* ! nonintelligent From 8ad524ffb215f68d98c25641082369d2ae3cf96c Mon Sep 17 00:00:00 2001 From: Wim de With Date: Wed, 20 May 2015 14:27:39 +0200 Subject: [PATCH 0583/1163] staging: dgnc: fix line length over 80 chars in dgnc_sysfs.c This patch fixes most of the lines over 80 characters long in dgnc_sysfs.c. I couldn't find a way to break line 202-207 in a sensible way. If there is a way, let me know. Signed-off-by: Wim de With Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_sysfs.c | 110 ++++++++++++++++++++---------- 1 file changed, 74 insertions(+), 36 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_sysfs.c b/drivers/staging/dgnc/dgnc_sysfs.c index 65551d190515..44db8703eba4 100644 --- a/drivers/staging/dgnc/dgnc_sysfs.c +++ b/drivers/staging/dgnc/dgnc_sysfs.c @@ -53,7 +53,8 @@ static ssize_t dgnc_driver_pollrate_show(struct device_driver *ddp, char *buf) return snprintf(buf, PAGE_SIZE, "%dms\n", dgnc_poll_tick); } -static ssize_t dgnc_driver_pollrate_store(struct device_driver *ddp, const char *buf, size_t count) +static ssize_t dgnc_driver_pollrate_store(struct device_driver *ddp, + const char *buf, size_t count) { int ret; @@ -62,7 +63,8 @@ static ssize_t dgnc_driver_pollrate_store(struct device_driver *ddp, const char return -EINVAL; return count; } -static DRIVER_ATTR(pollrate, (S_IRUSR | S_IWUSR), dgnc_driver_pollrate_show, dgnc_driver_pollrate_store); +static DRIVER_ATTR(pollrate, (S_IRUSR | S_IWUSR), dgnc_driver_pollrate_show, + dgnc_driver_pollrate_store); void dgnc_create_driver_sysfiles(struct pci_driver *dgnc_driver) @@ -104,7 +106,8 @@ void dgnc_remove_driver_sysfiles(struct pci_driver *dgnc_driver) -static ssize_t dgnc_vpd_show(struct device *p, struct device_attribute *attr, char *buf) +static ssize_t dgnc_vpd_show(struct device *p, struct device_attribute *attr, + char *buf) { struct dgnc_board *bd; int count = 0; @@ -112,7 +115,8 @@ static ssize_t dgnc_vpd_show(struct device *p, struct device_attribute *attr, ch DGNC_VERIFY_BOARD(p, bd); - count += sprintf(buf + count, "\n 0 1 2 3 4 5 6 7 8 9 A B C D E F"); + count += sprintf(buf + count, + "\n 0 1 2 3 4 5 6 7 8 9 A B C D E F"); for (i = 0; i < 0x40 * 2; i++) { if (!(i % 16)) count += sprintf(buf + count, "\n%04X ", i * 2); @@ -124,7 +128,8 @@ static ssize_t dgnc_vpd_show(struct device *p, struct device_attribute *attr, ch } static DEVICE_ATTR(vpd, S_IRUSR, dgnc_vpd_show, NULL); -static ssize_t dgnc_serial_number_show(struct device *p, struct device_attribute *attr, char *buf) +static ssize_t dgnc_serial_number_show(struct device *p, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; int count = 0; @@ -141,7 +146,8 @@ static ssize_t dgnc_serial_number_show(struct device *p, struct device_attribute static DEVICE_ATTR(serial_number, S_IRUSR, dgnc_serial_number_show, NULL); -static ssize_t dgnc_ports_state_show(struct device *p, struct device_attribute *attr, char *buf) +static ssize_t dgnc_ports_state_show(struct device *p, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; int count = 0; @@ -159,7 +165,8 @@ static ssize_t dgnc_ports_state_show(struct device *p, struct device_attribute * static DEVICE_ATTR(ports_state, S_IRUSR, dgnc_ports_state_show, NULL); -static ssize_t dgnc_ports_baud_show(struct device *p, struct device_attribute *attr, char *buf) +static ssize_t dgnc_ports_baud_show(struct device *p, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; int count = 0; @@ -169,14 +176,17 @@ static ssize_t dgnc_ports_baud_show(struct device *p, struct device_attribute *a for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, - "%d %d\n", bd->channels[i]->ch_portnum, bd->channels[i]->ch_old_baud); + "%d %d\n", bd->channels[i]->ch_portnum, + bd->channels[i]->ch_old_baud); } return count; } static DEVICE_ATTR(ports_baud, S_IRUSR, dgnc_ports_baud_show, NULL); -static ssize_t dgnc_ports_msignals_show(struct device *p, struct device_attribute *attr, char *buf) +static ssize_t dgnc_ports_msignals_show(struct device *p, + struct device_attribute *attr, + char *buf) { struct dgnc_board *bd; int count = 0; @@ -187,7 +197,8 @@ static ssize_t dgnc_ports_msignals_show(struct device *p, struct device_attribut for (i = 0; i < bd->nasync; i++) { if (bd->channels[i]->ch_open_count) { count += snprintf(buf + count, PAGE_SIZE - count, - "%d %s %s %s %s %s %s\n", bd->channels[i]->ch_portnum, + "%d %s %s %s %s %s %s\n", + bd->channels[i]->ch_portnum, (bd->channels[i]->ch_mostat & UART_MCR_RTS) ? "RTS" : "", (bd->channels[i]->ch_mistat & UART_MSR_CTS) ? "CTS" : "", (bd->channels[i]->ch_mostat & UART_MCR_DTR) ? "DTR" : "", @@ -204,7 +215,8 @@ static ssize_t dgnc_ports_msignals_show(struct device *p, struct device_attribut static DEVICE_ATTR(ports_msignals, S_IRUSR, dgnc_ports_msignals_show, NULL); -static ssize_t dgnc_ports_iflag_show(struct device *p, struct device_attribute *attr, char *buf) +static ssize_t dgnc_ports_iflag_show(struct device *p, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; int count = 0; @@ -214,14 +226,16 @@ static ssize_t dgnc_ports_iflag_show(struct device *p, struct device_attribute * for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", - bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_iflag); + bd->channels[i]->ch_portnum, + bd->channels[i]->ch_c_iflag); } return count; } static DEVICE_ATTR(ports_iflag, S_IRUSR, dgnc_ports_iflag_show, NULL); -static ssize_t dgnc_ports_cflag_show(struct device *p, struct device_attribute *attr, char *buf) +static ssize_t dgnc_ports_cflag_show(struct device *p, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; int count = 0; @@ -231,14 +245,16 @@ static ssize_t dgnc_ports_cflag_show(struct device *p, struct device_attribute * for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", - bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_cflag); + bd->channels[i]->ch_portnum, + bd->channels[i]->ch_c_cflag); } return count; } static DEVICE_ATTR(ports_cflag, S_IRUSR, dgnc_ports_cflag_show, NULL); -static ssize_t dgnc_ports_oflag_show(struct device *p, struct device_attribute *attr, char *buf) +static ssize_t dgnc_ports_oflag_show(struct device *p, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; int count = 0; @@ -248,14 +264,16 @@ static ssize_t dgnc_ports_oflag_show(struct device *p, struct device_attribute * for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", - bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_oflag); + bd->channels[i]->ch_portnum, + bd->channels[i]->ch_c_oflag); } return count; } static DEVICE_ATTR(ports_oflag, S_IRUSR, dgnc_ports_oflag_show, NULL); -static ssize_t dgnc_ports_lflag_show(struct device *p, struct device_attribute *attr, char *buf) +static ssize_t dgnc_ports_lflag_show(struct device *p, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; int count = 0; @@ -265,14 +283,17 @@ static ssize_t dgnc_ports_lflag_show(struct device *p, struct device_attribute * for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", - bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_lflag); + bd->channels[i]->ch_portnum, + bd->channels[i]->ch_c_lflag); } return count; } static DEVICE_ATTR(ports_lflag, S_IRUSR, dgnc_ports_lflag_show, NULL); -static ssize_t dgnc_ports_digi_flag_show(struct device *p, struct device_attribute *attr, char *buf) +static ssize_t dgnc_ports_digi_flag_show(struct device *p, + struct device_attribute *attr, + char *buf) { struct dgnc_board *bd; int count = 0; @@ -282,14 +303,16 @@ static ssize_t dgnc_ports_digi_flag_show(struct device *p, struct device_attribu for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", - bd->channels[i]->ch_portnum, bd->channels[i]->ch_digi.digi_flags); + bd->channels[i]->ch_portnum, + bd->channels[i]->ch_digi.digi_flags); } return count; } static DEVICE_ATTR(ports_digi_flag, S_IRUSR, dgnc_ports_digi_flag_show, NULL); -static ssize_t dgnc_ports_rxcount_show(struct device *p, struct device_attribute *attr, char *buf) +static ssize_t dgnc_ports_rxcount_show(struct device *p, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; int count = 0; @@ -299,14 +322,16 @@ static ssize_t dgnc_ports_rxcount_show(struct device *p, struct device_attribute for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, "%d %ld\n", - bd->channels[i]->ch_portnum, bd->channels[i]->ch_rxcount); + bd->channels[i]->ch_portnum, + bd->channels[i]->ch_rxcount); } return count; } static DEVICE_ATTR(ports_rxcount, S_IRUSR, dgnc_ports_rxcount_show, NULL); -static ssize_t dgnc_ports_txcount_show(struct device *p, struct device_attribute *attr, char *buf) +static ssize_t dgnc_ports_txcount_show(struct device *p, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; int count = 0; @@ -316,7 +341,8 @@ static ssize_t dgnc_ports_txcount_show(struct device *p, struct device_attribute for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, "%d %ld\n", - bd->channels[i]->ch_portnum, bd->channels[i]->ch_txcount); + bd->channels[i]->ch_portnum, + bd->channels[i]->ch_txcount); } return count; } @@ -366,7 +392,8 @@ void dgnc_remove_ports_sysfiles(struct dgnc_board *bd) } -static ssize_t dgnc_tty_state_show(struct device *d, struct device_attribute *attr, char *buf) +static ssize_t dgnc_tty_state_show(struct device *d, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; struct channel_t *ch; @@ -386,12 +413,14 @@ static ssize_t dgnc_tty_state_show(struct device *d, struct device_attribute *at if (bd->state != BOARD_READY) return 0; - return snprintf(buf, PAGE_SIZE, "%s", un->un_open_count ? "Open" : "Closed"); + return snprintf(buf, PAGE_SIZE, "%s", + un->un_open_count ? "Open" : "Closed"); } static DEVICE_ATTR(state, S_IRUSR, dgnc_tty_state_show, NULL); -static ssize_t dgnc_tty_baud_show(struct device *d, struct device_attribute *attr, char *buf) +static ssize_t dgnc_tty_baud_show(struct device *d, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; struct channel_t *ch; @@ -416,7 +445,8 @@ static ssize_t dgnc_tty_baud_show(struct device *d, struct device_attribute *att static DEVICE_ATTR(baud, S_IRUSR, dgnc_tty_baud_show, NULL); -static ssize_t dgnc_tty_msignals_show(struct device *d, struct device_attribute *attr, char *buf) +static ssize_t dgnc_tty_msignals_show(struct device *d, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; struct channel_t *ch; @@ -450,7 +480,8 @@ static ssize_t dgnc_tty_msignals_show(struct device *d, struct device_attribute static DEVICE_ATTR(msignals, S_IRUSR, dgnc_tty_msignals_show, NULL); -static ssize_t dgnc_tty_iflag_show(struct device *d, struct device_attribute *attr, char *buf) +static ssize_t dgnc_tty_iflag_show(struct device *d, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; struct channel_t *ch; @@ -475,7 +506,8 @@ static ssize_t dgnc_tty_iflag_show(struct device *d, struct device_attribute *at static DEVICE_ATTR(iflag, S_IRUSR, dgnc_tty_iflag_show, NULL); -static ssize_t dgnc_tty_cflag_show(struct device *d, struct device_attribute *attr, char *buf) +static ssize_t dgnc_tty_cflag_show(struct device *d, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; struct channel_t *ch; @@ -500,7 +532,8 @@ static ssize_t dgnc_tty_cflag_show(struct device *d, struct device_attribute *at static DEVICE_ATTR(cflag, S_IRUSR, dgnc_tty_cflag_show, NULL); -static ssize_t dgnc_tty_oflag_show(struct device *d, struct device_attribute *attr, char *buf) +static ssize_t dgnc_tty_oflag_show(struct device *d, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; struct channel_t *ch; @@ -525,7 +558,8 @@ static ssize_t dgnc_tty_oflag_show(struct device *d, struct device_attribute *at static DEVICE_ATTR(oflag, S_IRUSR, dgnc_tty_oflag_show, NULL); -static ssize_t dgnc_tty_lflag_show(struct device *d, struct device_attribute *attr, char *buf) +static ssize_t dgnc_tty_lflag_show(struct device *d, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; struct channel_t *ch; @@ -550,7 +584,8 @@ static ssize_t dgnc_tty_lflag_show(struct device *d, struct device_attribute *at static DEVICE_ATTR(lflag, S_IRUSR, dgnc_tty_lflag_show, NULL); -static ssize_t dgnc_tty_digi_flag_show(struct device *d, struct device_attribute *attr, char *buf) +static ssize_t dgnc_tty_digi_flag_show(struct device *d, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; struct channel_t *ch; @@ -575,7 +610,8 @@ static ssize_t dgnc_tty_digi_flag_show(struct device *d, struct device_attribute static DEVICE_ATTR(digi_flag, S_IRUSR, dgnc_tty_digi_flag_show, NULL); -static ssize_t dgnc_tty_rxcount_show(struct device *d, struct device_attribute *attr, char *buf) +static ssize_t dgnc_tty_rxcount_show(struct device *d, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; struct channel_t *ch; @@ -600,7 +636,8 @@ static ssize_t dgnc_tty_rxcount_show(struct device *d, struct device_attribute * static DEVICE_ATTR(rxcount, S_IRUSR, dgnc_tty_rxcount_show, NULL); -static ssize_t dgnc_tty_txcount_show(struct device *d, struct device_attribute *attr, char *buf) +static ssize_t dgnc_tty_txcount_show(struct device *d, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; struct channel_t *ch; @@ -625,7 +662,8 @@ static ssize_t dgnc_tty_txcount_show(struct device *d, struct device_attribute * static DEVICE_ATTR(txcount, S_IRUSR, dgnc_tty_txcount_show, NULL); -static ssize_t dgnc_tty_name_show(struct device *d, struct device_attribute *attr, char *buf) +static ssize_t dgnc_tty_name_show(struct device *d, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; struct channel_t *ch; From 7960386273f12bb46e3ffde2822a1eb254b66af8 Mon Sep 17 00:00:00 2001 From: "Gujulan Elango, Hari Prasath (H.)" Date: Fri, 29 May 2015 07:17:37 +0000 Subject: [PATCH 0584/1163] staging: dgnc: delete all references to 'flipbuf' This patch deletes all references to 'flipbuf'.Memory is allocated and freed but never used anywhere in the driver.Also deleted an ununsed Macro defined in the header file. Signed-off-by: Gujulan Elango Hari Prasath Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_driver.c | 9 --------- drivers/staging/dgnc/dgnc_driver.h | 3 --- 2 files changed, 12 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c index 805dc617e3a7..7546aff65002 100644 --- a/drivers/staging/dgnc/dgnc_driver.c +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -355,7 +355,6 @@ static void dgnc_cleanup_board(struct dgnc_board *brd) } } - kfree(brd->flipbuf); dgnc_Board[brd->boardnum] = NULL; @@ -581,14 +580,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) brd->msgbuf_head = NULL; spin_unlock_irqrestore(&dgnc_global_lock, flags); - /* - * allocate flip buffer for board. - * - * Okay to malloc with GFP_KERNEL, we are not at interrupt - * context, and there are no locks held. - */ - brd->flipbuf = kzalloc(MYFLIPLEN, GFP_KERNEL); - wake_up_interruptible(&brd->state_wait); return 0; diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h index f77fed57b873..3dee9f392fb3 100644 --- a/drivers/staging/dgnc/dgnc_driver.h +++ b/drivers/staging/dgnc/dgnc_driver.h @@ -212,8 +212,6 @@ struct dgnc_board { uint TtyRefCnt; - char *flipbuf; /* Our flip buffer, alloced if board is found */ - u16 dpatype; /* The board "type", as defined by DPA */ u16 dpastatus; /* The board "status", as defined by DPA */ @@ -288,7 +286,6 @@ struct un_t { #define CH_TX_FIFO_LWM 0x0800 /* TX Fifo is below Low Water */ #define CH_BREAK_SENDING 0x1000 /* Break is being sent */ #define CH_LOOPBACK 0x2000 /* Channel is in lookback mode */ -#define CH_FLIPBUF_IN_USE 0x4000 /* Channel's flipbuf is in use */ #define CH_BAUD0 0x08000 /* Used for checking B0 transitions */ #define CH_FORCED_STOP 0x20000 /* Output is forcibly stopped */ #define CH_FORCED_STOPI 0x40000 /* Input is forcibly stopped */ From 20ba45815649cd4870f6954cf9e2593d91e27c7a Mon Sep 17 00:00:00 2001 From: Colin Cronin Date: Wed, 13 May 2015 18:05:42 -0700 Subject: [PATCH 0585/1163] Drivers: staging: skein: skein_api: Fixed spelling errors Fixed a few spelling errors in comments. Signed-off-by: Colin Cronin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/skein_api.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/skein/skein_api.h b/drivers/staging/skein/skein_api.h index 171b87549548..7da8b386a28c 100644 --- a/drivers/staging/skein/skein_api.h +++ b/drivers/staging/skein/skein_api.h @@ -121,7 +121,7 @@ struct skein_ctx { * @param size * Which Skein size to use. * @return - * SKEIN_SUCESS of SKEIN_FAIL + * SKEIN_SUCCESS of SKEIN_FAIL */ int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size); @@ -136,7 +136,7 @@ int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size); * @param hash_bit_len * Number of MAC hash bits to compute * @return - * SKEIN_SUCESS of SKEIN_FAIL + * SKEIN_SUCCESS of SKEIN_FAIL * @see skein_reset */ int skein_init(struct skein_ctx *ctx, size_t hash_bit_len); @@ -171,7 +171,7 @@ void skein_reset(struct skein_ctx *ctx); * @param hash_bit_len * Number of MAC hash bits to compute * @return - * SKEIN_SUCESS of SKEIN_FAIL + * SKEIN_SUCCESS of SKEIN_FAIL */ int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t key_len, size_t hash_bit_len); From 3786a0f2bcb2edceabf4cd62833214e96f298609 Mon Sep 17 00:00:00 2001 From: Colin Cronin Date: Wed, 13 May 2015 22:35:03 -0700 Subject: [PATCH 0586/1163] Staging: xgifb: vb_setmode: Fixed spelling error Fixed spelling error in comment. Signed-off-by: Colin Cronin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index a47395e92d20..3f7c10e4e277 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -940,7 +940,7 @@ static void XGI_SetCRT1FIFO(struct xgi_hw_device_info *HwDeviceExtension, data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); data &= 0xfe; - xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */ + xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* disable auto-threshold */ xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34); data = xgifb_reg_get(pVBInfo->P3c4, 0x09); From 64746c0c6a9a168d1e462903b66ff17705964967 Mon Sep 17 00:00:00 2001 From: Fabian Frederick Date: Mon, 18 May 2015 19:34:15 +0200 Subject: [PATCH 0587/1163] staging: xgifb: use swap() in XGI_WriteDAC() Use kernel.h macro definition. Signed-off-by: Fabian Frederick Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 3f7c10e4e277..c886dd2892a4 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -1081,24 +1081,17 @@ static void XGI_WriteDAC(unsigned short dl, unsigned short dh, struct vb_device_info *pVBInfo) { - unsigned short temp, bh, bl; + unsigned short bh, bl; bh = ah; bl = al; if (dl != 0) { - temp = bh; - bh = dh; - dh = temp; - if (dl == 1) { - temp = bl; - bl = dh; - dh = temp; - } else { - temp = bl; - bl = bh; - bh = temp; - } + swap(bh, dh); + if (dl == 1) + swap(bl, dh); + else + swap(bl, bh); } outb((unsigned short) dh, pVBInfo->P3c9); outb((unsigned short) bh, pVBInfo->P3c9); From 3fb076717277ccc37262e5669f53cbb9292920c1 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 28 May 2015 12:39:07 -0700 Subject: [PATCH 0588/1163] staging: xgifb: use arch_phys_wc_add() and ioremap_wc() The same area used for ioremap() is used for the MTRR area. Convert the driver from using the x86 specific MTRR code to the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add() will avoid MTRR if write-combining is available, in order to take advantage of that also ensure the ioremap'd area is requested as write-combining. There are a few motivations for this: a) Take advantage of PAT when available b) Help bury MTRR code away, MTRR is architecture specific and on x86 its replaced by PAT c) Help with the goal of eventually using _PAGE_CACHE_UC over _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (see commit de33c442e titled "x86 PAT: fix performance drop for glx, use UC minus for ioremap(), ioremap_nocache() and pci_mmap_page_range()") The conversion done is expressed by the following Coccinelle SmPL patch, it additionally required manual intervention to address all the #ifdery and removal of redundant things which arch_phys_wc_add() already addresses such as verbose message about when MTRR fails and doing nothing when we didn't get an MTRR. @ mtrr_found @ expression index, base, size; @@ -index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1); +index = arch_phys_wc_add(base, size); @ mtrr_rm depends on mtrr_found @ expression mtrr_found.index, mtrr_found.base, mtrr_found.size; @@ -mtrr_del(index, base, size); +arch_phys_wc_del(index); @ mtrr_rm_zero_arg depends on mtrr_found @ expression mtrr_found.index; @@ -mtrr_del(index, 0, 0); +arch_phys_wc_del(index); @ mtrr_rm_fb_info depends on mtrr_found @ struct fb_info *info; expression mtrr_found.index; @@ -mtrr_del(index, info->fix.smem_start, info->fix.smem_len); +arch_phys_wc_del(index); @ ioremap_replace_nocache depends on mtrr_found @ struct fb_info *info; expression base, size; @@ -info->screen_base = ioremap_nocache(base, size); +info->screen_base = ioremap_wc(base, size); @ ioremap_replace_default depends on mtrr_found @ struct fb_info *info; expression base, size; @@ -info->screen_base = ioremap(base, size); +info->screen_base = ioremap_wc(base, size); Generated-by: Coccinelle SmPL Cc: Arnaud Patard Cc: Greg Kroah-Hartman Cc: Aaro Koskinen Cc: Brian Vandre Cc: Thomas Gummerer Cc: Aya Mahfouz Cc: Lubomir Rintel Cc: Vitor Braga Cc: Sudip Mukherjee Cc: Suresh Siddha Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Juergen Gross Cc: Daniel Vetter Cc: Andy Lutomirski Cc: Dave Airlie Cc: Antonino Daplas Cc: Jean-Christophe Plagniol-Villard Cc: Tomi Valkeinen Cc: devel@driverdev.osuosl.org Cc: linux-fbdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Luis R. Rodriguez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 74e88200726c..943d463cf193 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -8,10 +8,7 @@ #include #include - -#ifdef CONFIG_MTRR -#include -#endif +#include #include "XGI_main.h" #include "vb_init.h" @@ -1770,7 +1767,7 @@ static int xgifb_probe(struct pci_dev *pdev, } xgifb_info->video_vbase = hw_info->pjVideoMemoryAddress = - ioremap(xgifb_info->video_base, xgifb_info->video_size); + ioremap_wc(xgifb_info->video_base, xgifb_info->video_size); xgifb_info->mmio_vbase = ioremap(xgifb_info->mmio_base, xgifb_info->mmio_size); @@ -2014,12 +2011,8 @@ static int xgifb_probe(struct pci_dev *pdev, fb_alloc_cmap(&fb_info->cmap, 256, 0); -#ifdef CONFIG_MTRR - xgifb_info->mtrr = mtrr_add(xgifb_info->video_base, - xgifb_info->video_size, MTRR_TYPE_WRCOMB, 1); - if (xgifb_info->mtrr >= 0) - dev_info(&pdev->dev, "Added MTRR\n"); -#endif + xgifb_info->mtrr = arch_phys_wc_add(xgifb_info->video_base, + xgifb_info->video_size); if (register_framebuffer(fb_info) < 0) { ret = -EINVAL; @@ -2031,11 +2024,7 @@ static int xgifb_probe(struct pci_dev *pdev, return 0; error_mtrr: -#ifdef CONFIG_MTRR - if (xgifb_info->mtrr >= 0) - mtrr_del(xgifb_info->mtrr, xgifb_info->video_base, - xgifb_info->video_size); -#endif /* CONFIG_MTRR */ + arch_phys_wc_del(xgifb_info->mtrr); error_1: iounmap(xgifb_info->mmio_vbase); iounmap(xgifb_info->video_vbase); @@ -2059,11 +2048,7 @@ static void xgifb_remove(struct pci_dev *pdev) struct fb_info *fb_info = xgifb_info->fb_info; unregister_framebuffer(fb_info); -#ifdef CONFIG_MTRR - if (xgifb_info->mtrr >= 0) - mtrr_del(xgifb_info->mtrr, xgifb_info->video_base, - xgifb_info->video_size); -#endif /* CONFIG_MTRR */ + arch_phys_wc_del(xgifb_info->mtrr); iounmap(xgifb_info->mmio_vbase); iounmap(xgifb_info->video_vbase); release_mem_region(xgifb_info->mmio_base, xgifb_info->mmio_size); From 590826061d83b327f630fd587239f269a9361a90 Mon Sep 17 00:00:00 2001 From: Colin Cronin Date: Thu, 14 May 2015 23:33:34 -0700 Subject: [PATCH 0589/1163] Staging: vt6656: device: Fixed spelling error Fixed comment spelling error. Signed-off-by: Colin Cronin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index f71d59fa3b21..635d931de409 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -364,7 +364,7 @@ struct vnt_private { /* Power save */ u16 current_aid; - /* Beacon releated */ + /* Beacon related */ u16 seq_counter; enum vnt_cmd_state command_state; From 73f11ecbcbdd86f7150482d7e10d55034480fda9 Mon Sep 17 00:00:00 2001 From: Pedro Marzo Perez Date: Thu, 21 May 2015 02:25:19 +0200 Subject: [PATCH 0590/1163] Staging: rtl8192u: Correct include indentation and openning braces at new line Opening braces should never be in a new line. Correct include indentation. Signed-off-by: Pedro Marzo Perez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c index 0a17f84bb809..26f2fb15e2a3 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c @@ -19,7 +19,7 @@ #include "ieee80211.h" #include - #include +#include #include MODULE_AUTHOR("Jouni Malinen"); @@ -142,9 +142,7 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) /* Copy rest of the WEP key (the secret part) */ memcpy(key + 3, wep->key, wep->key_len); - if (!tcb_desc->bHwSec) - { - + if (!tcb_desc->bHwSec) { /* Append little-endian CRC32 and encrypt it to produce ICV */ crc = ~crc32_le(~0, pos, len); icv = skb_put(skb, 4); @@ -201,8 +199,7 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) /* Apply RC4 to data and compute CRC32 over decrypted data */ plen = skb->len - hdr_len - 8; - if (!tcb_desc->bHwSec) - { + if (!tcb_desc->bHwSec) { crypto_blkcipher_setkey(wep->rx_tfm, key, klen); sg_init_one(&sg, pos, plen+4); From 5e66f70e963e4ba2266071343f5a153c7db4327b Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:35 -0400 Subject: [PATCH 0591/1163] staging/lustre: Generic helpers for sysfs Add generic helpers to allow displaying oof lustre-specific values in /sys/fs/lustre Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lprocfs_status.h | 21 ++++++++++++++++ .../lustre/lustre/obdclass/lprocfs_status.c | 24 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index d030847e51ba..37f00e429614 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -742,6 +742,27 @@ static struct file_operations name##_fops = { \ .release = lprocfs_single_release, \ } +struct lustre_attr { + struct attribute attr; + ssize_t (*show)(struct kobject *kobj, struct attribute *attr, + char *buf); + ssize_t (*store)(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t len); +}; + +#define LUSTRE_ATTR(name, mode, show, store) \ +static struct lustre_attr lustre_attr_##name = __ATTR(name, mode, show, store) + +#define LUSTRE_RO_ATTR(name) LUSTRE_ATTR(name, 0444, name##_show, NULL) +#define LUSTRE_RW_ATTR(name) LUSTRE_ATTR(name, 0644, name##_show, name##_store) + +ssize_t lustre_attr_show(struct kobject *kobj, struct attribute *attr, + char *buf); +ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t len); + +extern const struct sysfs_ops lustre_sysfs_ops; + /* lproc_ptlrpc.c */ struct ptlrpc_request; extern void target_print_req(void *seq_file, struct ptlrpc_request *req); diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index c988be4fc049..916d0606b2e4 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -2056,3 +2056,27 @@ int lprocfs_obd_rd_max_pages_per_rpc(struct seq_file *m, void *data) EXPORT_SYMBOL(lprocfs_obd_rd_max_pages_per_rpc); #endif + +ssize_t lustre_attr_show(struct kobject *kobj, + struct attribute *attr, char *buf) +{ + struct lustre_attr *a = container_of(attr, struct lustre_attr, attr); + + return a->show ? a->show(kobj, attr, buf) : 0; +} +EXPORT_SYMBOL_GPL(lustre_attr_show); + +ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t len) +{ + struct lustre_attr *a = container_of(attr, struct lustre_attr, attr); + + return a->store ? a->store(kobj, attr, buf, len) : len; +} +EXPORT_SYMBOL_GPL(lustre_attr_store); + +const struct sysfs_ops lustre_sysfs_ops = { + .show = lustre_attr_show, + .store = lustre_attr_store, +}; +EXPORT_SYMBOL_GPL(lustre_sysfs_ops); From 8b82844505699f10f80c7e554364e3d0618cd77d Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:36 -0400 Subject: [PATCH 0592/1163] staging/lustre: Move /proc/fs/lustre root level files to sysfs except devices, for now. Signed-off-by: Oleg Drokin Signed-off-by: Dmitry Eremin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lprocfs_status.h | 2 + .../lustre/obdclass/linux/linux-module.c | 111 ++++++++++-------- drivers/staging/lustre/sysfs-fs-lustre | 41 +++++++ 3 files changed, 108 insertions(+), 46 deletions(-) create mode 100644 drivers/staging/lustre/sysfs-fs-lustre diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 37f00e429614..b46cd54f2081 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -350,6 +350,8 @@ enum { /* class_obd.c */ extern struct proc_dir_entry *proc_lustre_root; +extern struct kobject *lustre_kobj; + struct obd_device; struct obd_histogram; diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index 06944b863d16..df3aa8fd253e 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -64,6 +64,7 @@ #include #include #include +#include #include "../../../include/linux/libcfs/libcfs.h" #include "../../../include/linux/lnet/lnetctl.h" @@ -216,29 +217,27 @@ struct miscdevice obd_psdev = { }; -#if defined (CONFIG_PROC_FS) -static int obd_proc_version_seq_show(struct seq_file *m, void *v) +static ssize_t version_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - seq_printf(m, "lustre: %s\nkernel: %s\nbuild: %s\n", - LUSTRE_VERSION_STRING, "patchless_client", BUILD_VERSION); - return 0; + return sprintf(buf, "%s\n", LUSTRE_VERSION_STRING); } -LPROC_SEQ_FOPS_RO(obd_proc_version); -int obd_proc_pinger_seq_show(struct seq_file *m, void *v) +static ssize_t pinger_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - seq_printf(m, "%s\n", "on"); - return 0; + return sprintf(buf, "%s\n", "on"); } -LPROC_SEQ_FOPS_RO(obd_proc_pinger); -static int obd_proc_health_seq_show(struct seq_file *m, void *v) +static ssize_t health_show(struct kobject *kobj, struct attribute *attr, + char *buf) { bool healthy = true; int i; + size_t len = 0; if (libcfs_catastrophe) - seq_printf(m, "LBUG\n"); + return sprintf(buf, "LBUG\n"); read_lock(&obd_dev_lock); for (i = 0; i < class_devno_max(); i++) { @@ -256,8 +255,6 @@ static int obd_proc_health_seq_show(struct seq_file *m, void *v) read_unlock(&obd_dev_lock); if (obd_health_check(NULL, obd)) { - seq_printf(m, "device %s reported unhealthy\n", - obd->obd_name); healthy = false; } class_decref(obd, __func__, current); @@ -266,32 +263,29 @@ static int obd_proc_health_seq_show(struct seq_file *m, void *v) read_unlock(&obd_dev_lock); if (healthy) - seq_puts(m, "healthy\n"); + len = sprintf(buf, "healthy\n"); else - seq_puts(m, "NOT HEALTHY\n"); + len = sprintf(buf, "NOT HEALTHY\n"); - return 0; + return len; } -LPROC_SEQ_FOPS_RO(obd_proc_health); -static int obd_proc_jobid_var_seq_show(struct seq_file *m, void *v) +static ssize_t jobid_var_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - seq_printf(m, "%s\n", obd_jobid_var); - return 0; + return snprintf(buf, PAGE_SIZE, "%s\n", obd_jobid_var); } -static ssize_t obd_proc_jobid_var_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t jobid_var_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, + size_t count) { if (!count || count > JOBSTATS_JOBID_VAR_MAX_LEN) 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; + memcpy(obd_jobid_var, buffer, count); /* Trim the trailing '\n' if any */ if (obd_jobid_var[count - 1] == '\n') @@ -299,23 +293,21 @@ static ssize_t obd_proc_jobid_var_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(obd_proc_jobid_var); -static int obd_proc_jobid_name_seq_show(struct seq_file *m, void *v) +static ssize_t jobid_name_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - seq_printf(m, "%s\n", obd_jobid_var); - return 0; + return snprintf(buf, PAGE_SIZE, "%s\n", obd_jobid_node); } -static ssize_t obd_proc_jobid_name_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t jobid_name_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, + size_t count) { if (!count || count > JOBSTATS_JOBID_SIZE) return -EINVAL; - if (copy_from_user(obd_jobid_node, buffer, count)) - return -EFAULT; + memcpy(obd_jobid_node, buffer, count); obd_jobid_node[count] = 0; @@ -325,20 +317,25 @@ static ssize_t obd_proc_jobid_name_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(obd_proc_jobid_name); +#if defined(CONFIG_PROC_FS) /* Root for /proc/fs/lustre */ struct proc_dir_entry *proc_lustre_root = NULL; EXPORT_SYMBOL(proc_lustre_root); -struct lprocfs_vars lprocfs_base[] = { - { "version", &obd_proc_version_fops }, - { "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}, - { NULL } +LUSTRE_RO_ATTR(version); +LUSTRE_RO_ATTR(pinger); +LUSTRE_RO_ATTR(health); +LUSTRE_RW_ATTR(jobid_var); +LUSTRE_RW_ATTR(jobid_name); + +static struct attribute *lustre_attrs[] = { + &lustre_attr_version.attr, + &lustre_attr_pinger.attr, + &lustre_attr_health.attr, + &lustre_attr_jobid_name.attr, + &lustre_attr_jobid_var.attr, + NULL, }; static void *obd_device_list_seq_start(struct seq_file *p, loff_t *pos) @@ -419,15 +416,34 @@ struct file_operations obd_device_list_fops = { .release = seq_release, }; +struct kobject *lustre_kobj; +EXPORT_SYMBOL_GPL(lustre_kobj); + +static struct attribute_group lustre_attr_group = { + .attrs = lustre_attrs, +}; + int class_procfs_init(void) { int rc = 0; + lustre_kobj = kobject_create_and_add("lustre", fs_kobj); + if (lustre_kobj == NULL) + goto out; + + /* Create the files associated with this kobject */ + rc = sysfs_create_group(lustre_kobj, &lustre_attr_group); + if (rc) { + kobject_put(lustre_kobj); + goto out; + } + proc_lustre_root = lprocfs_register("fs/lustre", NULL, - lprocfs_base, NULL); + NULL, NULL); if (IS_ERR(proc_lustre_root)) { rc = PTR_ERR(proc_lustre_root); proc_lustre_root = NULL; + kobject_put(lustre_kobj); goto out; } @@ -444,6 +460,9 @@ int class_procfs_clean(void) if (proc_lustre_root) { lprocfs_remove(&proc_lustre_root); } + + kobject_put(lustre_kobj); + return 0; } #endif /* CONFIG_PROC_FS */ diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre new file mode 100644 index 000000000000..df90a1b63e1a --- /dev/null +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -0,0 +1,41 @@ +What: /sys/fs/lustre/version +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Shows current running lustre version. + +What: /sys/fs/lustre/pinger +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Shows if the lustre module has pinger support. + "on" means yes and "off" means no. + +What: /sys/fs/lustre/health +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Shows whenever current system state believed to be "healthy", + "NOT HEALTHY", or "LBUG" whenever lustre has experienced + an internal assertion failure + +What: /sys/fs/lustre/jobid_name +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Currently running job "name" for this node to be transferred + to Lustre servers for purposes of QoS and statistics gathering. + Writing into this file will change the name, reading outputs + currently set value. + +What: /sys/fs/lustre/jobid_var +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Control file for lustre "jobstats" functionality, write new + value from the list below to change the mode: + disable - disable job name reporting to the servers (default) + procname_uid - form the job name as the current running + command name and pid with a dot in between + e.g. dd.1253 + nodelocal - use jobid_name value from above. From fd0d04ba85f95169106701397417360541a983b3 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:37 -0400 Subject: [PATCH 0593/1163] staging/lustre/llite: Preparation to move /proc/fs/lustre/llite to sysfs Add necessary infrastructure, add support for mountpoint registration in /proc/fs/lustre/llite Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/llite/llite_internal.h | 4 +++ .../staging/lustre/lustre/llite/llite_lib.c | 7 +++-- .../staging/lustre/lustre/llite/lproc_llite.c | 26 +++++++++++++++++++ drivers/staging/lustre/lustre/llite/super25.c | 11 +++++++- 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index bf8f1541546c..c4c758cac12a 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -518,6 +518,9 @@ struct ll_sb_info { struct rmtacl_ctl_table ll_rct; struct eacl_table ll_et; __kernel_fsid_t ll_fsid; + struct kobject ll_kobj; /* sysfs object */ + struct super_block *ll_sb; /* struct super_block (for sysfs code)*/ + struct completion ll_kobj_unregister; }; #define LL_DEFAULT_MAX_RW_CHUNK (32 * 1024 * 1024) @@ -639,6 +642,7 @@ struct lov_stripe_md; extern spinlock_t inode_lock; extern struct proc_dir_entry *proc_lustre_fs_root; +extern struct kset *llite_kset; static inline struct inode *ll_info2i(struct ll_inode_info *lli) { diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index e759da3a1b5e..2aa2335685cb 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -58,6 +58,7 @@ struct kmem_cache *ll_file_data_slab; struct proc_dir_entry *proc_lustre_fs_root; +struct kset *llite_kset; static LIST_HEAD(ll_super_blocks); static DEFINE_SPINLOCK(ll_sb_lock); @@ -66,7 +67,7 @@ static DEFINE_SPINLOCK(ll_sb_lock); #define log2(n) ffz(~(n)) #endif -static struct ll_sb_info *ll_init_sbi(void) +static struct ll_sb_info *ll_init_sbi(struct super_block *sb) { struct ll_sb_info *sbi = NULL; unsigned long pages; @@ -134,6 +135,8 @@ static struct ll_sb_info *ll_init_sbi(void) atomic_set(&sbi->ll_agl_total, 0); sbi->ll_flags |= LL_SBI_AGL_ENABLED; + sbi->ll_sb = sb; + return sbi; } @@ -919,7 +922,7 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) try_module_get(THIS_MODULE); /* client additional sb info */ - lsi->lsi_llsbi = sbi = ll_init_sbi(); + lsi->lsi_llsbi = sbi = ll_init_sbi(sb); if (!sbi) { module_put(THIS_MODULE); kfree(cfg); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 83a9b85474e1..a3ecb61e5555 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -872,6 +872,23 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { #define MAX_STRING_SIZE 128 +static struct attribute *llite_attrs[] = { + NULL, +}; + +static void llite_sb_release(struct kobject *kobj) +{ + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); + complete(&sbi->ll_kobj_unregister); +} + +static struct kobj_type llite_ktype = { + .default_attrs = llite_attrs, + .sysfs_ops = &lustre_sysfs_ops, + .release = llite_sb_release, +}; + static const struct llite_file_opcode { __u32 opcode; __u32 type; @@ -1064,6 +1081,13 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, if (err) goto out; + sbi->ll_kobj.kset = llite_kset; + init_completion(&sbi->ll_kobj_unregister); + err = kobject_init_and_add(&sbi->ll_kobj, &llite_ktype, NULL, + "%s", name); + if (err) + goto out; + /* MDC info */ obd = class_name2obd(mdc); @@ -1124,6 +1148,8 @@ void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi) { if (sbi->ll_proc_root) { lprocfs_remove(&sbi->ll_proc_root); + kobject_put(&sbi->ll_kobj); + wait_for_completion(&sbi->ll_kobj_unregister); lprocfs_free_stats(&sbi->ll_ra_stats); lprocfs_free_stats(&sbi->ll_stats); } diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index a494f6271fa0..8753560809fa 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -138,6 +138,12 @@ static int __init init_lustre_lite(void) proc_lustre_fs_root = entry; + llite_kset = kset_create_and_add("llite", NULL, lustre_kobj); + if (!llite_kset) { + rc = -ENOMEM; + goto out_proc; + } + cfs_get_random_bytes(seed, sizeof(seed)); /* Nodes with small feet have little entropy. The NID for this @@ -155,7 +161,7 @@ static int __init init_lustre_lite(void) setup_timer(&ll_capa_timer, ll_capa_timer_callback, 0); rc = ll_capa_thread_start(); if (rc != 0) - goto out_proc; + goto out_sysfs; rc = vvp_global_init(); if (rc != 0) @@ -176,6 +182,8 @@ out_vvp: out_capa: del_timer(&ll_capa_timer); ll_capa_thread_stop(); +out_sysfs: + kset_unregister(llite_kset); out_proc: lprocfs_remove(&proc_lustre_fs_root); out_cache: @@ -201,6 +209,7 @@ static void __exit exit_lustre_lite(void) lustre_register_client_process_config(NULL); lprocfs_remove(&proc_lustre_fs_root); + kset_unregister(llite_kset); ll_xattr_fini(); vvp_global_fini(); From 364bcfc8634d5625dbb41683b061bddf307a70e8 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:38 -0400 Subject: [PATCH 0594/1163] staging/lustre/llite: move /proc/fs/lustre/llite/blocksize to sysfs Move blocksize file from /proc/fs/lustre/llite/*/ to /sys/fs/lustre/llite/*/blocksize Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 15 ++++++++------- drivers/staging/lustre/sysfs-fs-lustre | 6 ++++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index a3ecb61e5555..bdf1f38d98d6 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -48,22 +48,23 @@ 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) +static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct super_block *sb = (struct super_block *)m->private; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); struct obd_statfs osfs; int rc; - LASSERT(sb != NULL); - rc = ll_statfs_internal(sb, &osfs, + rc = ll_statfs_internal(sbi->ll_sb, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) - seq_printf(m, "%u\n", osfs.os_bsize); + return sprintf(buf, "%u\n", osfs.os_bsize); return rc; } -LPROC_SEQ_FOPS_RO(ll_blksize); +LUSTRE_RO_ATTR(blocksize); static int ll_kbytestotal_seq_show(struct seq_file *m, void *v) { @@ -839,7 +840,6 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { /* { "mntpt_path", ll_rd_path, 0, 0 }, */ { "fstype", &ll_fstype_fops, NULL, 0 }, { "site", &ll_site_stats_fops, NULL, 0 }, - { "blocksize", &ll_blksize_fops, NULL, 0 }, { "kbytestotal", &ll_kbytestotal_fops, NULL, 0 }, { "kbytesfree", &ll_kbytesfree_fops, NULL, 0 }, { "kbytesavail", &ll_kbytesavail_fops, NULL, 0 }, @@ -873,6 +873,7 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { #define MAX_STRING_SIZE 128 static struct attribute *llite_attrs[] = { + &lustre_attr_blocksize.attr, NULL, }; diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index df90a1b63e1a..85b0ba72375c 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -39,3 +39,9 @@ Description: command name and pid with a dot in between e.g. dd.1253 nodelocal - use jobid_name value from above. + +What: /sys/fs/lustre/llite/-/blocksize +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Biggest blocksize on object storage server for this filesystem. From 5804b11e1487558c6740282a01a08bb4ba0c6d06 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:39 -0400 Subject: [PATCH 0595/1163] staging/lustre/llite: move /proc/fs/lustre/llite/kbytes* to sysfs Move kbytestotal, kbytesavail and kbytesfree files from /proc/fs/lustre/llite/* to /sys/fs/lustre/llite/*/ Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/llite/lproc_llite.c | 45 ++++++++++--------- drivers/staging/lustre/sysfs-fs-lustre | 20 +++++++++ 2 files changed, 44 insertions(+), 21 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index bdf1f38d98d6..0010ac296e7f 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -66,14 +66,15 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr, } LUSTRE_RO_ATTR(blocksize); -static int ll_kbytestotal_seq_show(struct seq_file *m, void *v) +static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct super_block *sb = (struct super_block *)m->private; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); struct obd_statfs osfs; int rc; - LASSERT(sb != NULL); - rc = ll_statfs_internal(sb, &osfs, + rc = ll_statfs_internal(sbi->ll_sb, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) { @@ -83,21 +84,22 @@ static int ll_kbytestotal_seq_show(struct seq_file *m, void *v) while (blk_size >>= 1) result <<= 1; - seq_printf(m, "%llu\n", result); + rc = sprintf(buf, "%llu\n", result); } return rc; } -LPROC_SEQ_FOPS_RO(ll_kbytestotal); +LUSTRE_RO_ATTR(kbytestotal); -static int ll_kbytesfree_seq_show(struct seq_file *m, void *v) +static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct super_block *sb = (struct super_block *)m->private; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); struct obd_statfs osfs; int rc; - LASSERT(sb != NULL); - rc = ll_statfs_internal(sb, &osfs, + rc = ll_statfs_internal(sbi->ll_sb, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) { @@ -107,21 +109,22 @@ static int ll_kbytesfree_seq_show(struct seq_file *m, void *v) while (blk_size >>= 1) result <<= 1; - seq_printf(m, "%llu\n", result); + rc = sprintf(buf, "%llu\n", result); } return rc; } -LPROC_SEQ_FOPS_RO(ll_kbytesfree); +LUSTRE_RO_ATTR(kbytesfree); -static int ll_kbytesavail_seq_show(struct seq_file *m, void *v) +static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct super_block *sb = (struct super_block *)m->private; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); struct obd_statfs osfs; int rc; - LASSERT(sb != NULL); - rc = ll_statfs_internal(sb, &osfs, + rc = ll_statfs_internal(sbi->ll_sb, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) { @@ -131,12 +134,12 @@ static int ll_kbytesavail_seq_show(struct seq_file *m, void *v) while (blk_size >>= 1) result <<= 1; - seq_printf(m, "%llu\n", result); + rc = sprintf(buf, "%llu\n", result); } return rc; } -LPROC_SEQ_FOPS_RO(ll_kbytesavail); +LUSTRE_RO_ATTR(kbytesavail); static int ll_filestotal_seq_show(struct seq_file *m, void *v) { @@ -840,9 +843,6 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { /* { "mntpt_path", ll_rd_path, 0, 0 }, */ { "fstype", &ll_fstype_fops, NULL, 0 }, { "site", &ll_site_stats_fops, NULL, 0 }, - { "kbytestotal", &ll_kbytestotal_fops, NULL, 0 }, - { "kbytesfree", &ll_kbytesfree_fops, NULL, 0 }, - { "kbytesavail", &ll_kbytesavail_fops, NULL, 0 }, { "filestotal", &ll_filestotal_fops, NULL, 0 }, { "filesfree", &ll_filesfree_fops, NULL, 0 }, { "client_type", &ll_client_type_fops, NULL, 0 }, @@ -874,6 +874,9 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { static struct attribute *llite_attrs[] = { &lustre_attr_blocksize.attr, + &lustre_attr_kbytestotal.attr, + &lustre_attr_kbytesfree.attr, + &lustre_attr_kbytesavail.attr, NULL, }; diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index 85b0ba72375c..889cef40a4bf 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -45,3 +45,23 @@ Date: May 2015 Contact: "Oleg Drokin" Description: Biggest blocksize on object storage server for this filesystem. + +What: /sys/fs/lustre/llite/-/kbytestotal +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Shows total number of kilobytes of space on this filesystem + +What: /sys/fs/lustre/llite/-/kbytesfree +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Shows total number of free kilobytes of space on this filesystem + +What: /sys/fs/lustre/llite/-/kbytesavail +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Shows total number of free kilobytes of space on this filesystem + actually available for use (taking into account per-client + grants and filesystem reservations). From 7267ec0d8726c214aaf24ca9e8baebb443b0da75 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:40 -0400 Subject: [PATCH 0596/1163] staging/lustre/llite: move /proc/fs/lustre/llite/files* to sysfs Move filestotal and filesfree files from /proc/fs/lustre/llite/* to /sys/fs/lustre/llite/*/ Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/llite/lproc_llite.c | 30 ++++++++++--------- drivers/staging/lustre/sysfs-fs-lustre | 12 ++++++++ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 0010ac296e7f..3dce0bacac2a 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -141,39 +141,41 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, } LUSTRE_RO_ATTR(kbytesavail); -static int ll_filestotal_seq_show(struct seq_file *m, void *v) +static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct super_block *sb = (struct super_block *)m->private; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); struct obd_statfs osfs; int rc; - LASSERT(sb != NULL); - rc = ll_statfs_internal(sb, &osfs, + rc = ll_statfs_internal(sbi->ll_sb, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) - seq_printf(m, "%llu\n", osfs.os_files); + return sprintf(buf, "%llu\n", osfs.os_files); return rc; } -LPROC_SEQ_FOPS_RO(ll_filestotal); +LUSTRE_RO_ATTR(filestotal); -static int ll_filesfree_seq_show(struct seq_file *m, void *v) +static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct super_block *sb = (struct super_block *)m->private; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); struct obd_statfs osfs; int rc; - LASSERT(sb != NULL); - rc = ll_statfs_internal(sb, &osfs, + rc = ll_statfs_internal(sbi->ll_sb, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) - seq_printf(m, "%llu\n", osfs.os_ffree); + return sprintf(buf, "%llu\n", osfs.os_ffree); return rc; } -LPROC_SEQ_FOPS_RO(ll_filesfree); +LUSTRE_RO_ATTR(filesfree); static int ll_client_type_seq_show(struct seq_file *m, void *v) { @@ -843,8 +845,6 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { /* { "mntpt_path", ll_rd_path, 0, 0 }, */ { "fstype", &ll_fstype_fops, NULL, 0 }, { "site", &ll_site_stats_fops, NULL, 0 }, - { "filestotal", &ll_filestotal_fops, NULL, 0 }, - { "filesfree", &ll_filesfree_fops, NULL, 0 }, { "client_type", &ll_client_type_fops, NULL, 0 }, /* { "filegroups", lprocfs_rd_filegroups, 0, 0 }, */ { "max_read_ahead_mb", &ll_max_readahead_mb_fops, NULL }, @@ -877,6 +877,8 @@ static struct attribute *llite_attrs[] = { &lustre_attr_kbytestotal.attr, &lustre_attr_kbytesfree.attr, &lustre_attr_kbytesavail.attr, + &lustre_attr_filestotal.attr, + &lustre_attr_filesfree.attr, NULL, }; diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index 889cef40a4bf..ecb16f0fcb14 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -65,3 +65,15 @@ Description: Shows total number of free kilobytes of space on this filesystem actually available for use (taking into account per-client grants and filesystem reservations). + +What: /sys/fs/lustre/llite/-/filestotal +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Shows total number of inodes on the filesystem. + +What: /sys/fs/lustre/llite/-/filesfree +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Shows estimated number of free inodes on the filesystem From 95e1b6b0cff09292158ecc0701f721315167b64e Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:41 -0400 Subject: [PATCH 0597/1163] staging/lustre/llite: move /proc/fs/lustre/llite/client_type to sysfs Move client_type file from /proc/fs/lustre/llite/* to /sys/fs/lustre/llite/*/ Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/llite/lproc_llite.c | 20 ++++++++----------- drivers/staging/lustre/sysfs-fs-lustre | 8 ++++++++ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 3dce0bacac2a..fba21f877f19 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -177,20 +177,16 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr, } LUSTRE_RO_ATTR(filesfree); -static int ll_client_type_seq_show(struct seq_file *m, void *v) +static ssize_t client_type_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct ll_sb_info *sbi = ll_s2sbi((struct super_block *)m->private); + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); - LASSERT(sbi != NULL); - - if (sbi->ll_flags & LL_SBI_RMT_CLIENT) - seq_puts(m, "remote client\n"); - else - seq_puts(m, "local client\n"); - - return 0; + return sprintf(buf, "%s client\n", + sbi->ll_flags & LL_SBI_RMT_CLIENT ? "remote" : "local"); } -LPROC_SEQ_FOPS_RO(ll_client_type); +LUSTRE_RO_ATTR(client_type); static int ll_fstype_seq_show(struct seq_file *m, void *v) { @@ -845,7 +841,6 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { /* { "mntpt_path", ll_rd_path, 0, 0 }, */ { "fstype", &ll_fstype_fops, NULL, 0 }, { "site", &ll_site_stats_fops, NULL, 0 }, - { "client_type", &ll_client_type_fops, NULL, 0 }, /* { "filegroups", lprocfs_rd_filegroups, 0, 0 }, */ { "max_read_ahead_mb", &ll_max_readahead_mb_fops, NULL }, { "max_read_ahead_per_file_mb", &ll_max_readahead_per_file_mb_fops, @@ -879,6 +874,7 @@ static struct attribute *llite_attrs[] = { &lustre_attr_kbytesavail.attr, &lustre_attr_filestotal.attr, &lustre_attr_filesfree.attr, + &lustre_attr_client_type.attr, NULL, }; diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index ecb16f0fcb14..213eb8681461 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -77,3 +77,11 @@ Date: May 2015 Contact: "Oleg Drokin" Description: Shows estimated number of free inodes on the filesystem + +What: /sys/fs/lustre/llite/-/client_type +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Shows whenever this filesystem considers this client to be + compute cluster-local or remote. Remote clients have + additional uid/gid convrting logic applied. From 0cee667682b55d7c389d77877adbd63360415baa Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:42 -0400 Subject: [PATCH 0598/1163] staging/lustre/llite: move /proc/fs/lustre/llite/fstype to sysfs Move fstype file from /proc/fs/lustre/llite/* to /sys/fs/lustre/llite/*/ Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 14 +++++++------- drivers/staging/lustre/sysfs-fs-lustre | 6 ++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index fba21f877f19..53671db2b6d3 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -188,15 +188,15 @@ static ssize_t client_type_show(struct kobject *kobj, struct attribute *attr, } LUSTRE_RO_ATTR(client_type); -static int ll_fstype_seq_show(struct seq_file *m, void *v) +static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct super_block *sb = (struct super_block *)m->private; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); - LASSERT(sb != NULL); - seq_printf(m, "%s\n", sb->s_type->name); - return 0; + return sprintf(buf, "%s\n", sbi->ll_sb->s_type->name); } -LPROC_SEQ_FOPS_RO(ll_fstype); +LUSTRE_RO_ATTR(fstype); static int ll_sb_uuid_seq_show(struct seq_file *m, void *v) { @@ -839,7 +839,6 @@ LPROC_SEQ_FOPS(ll_xattr_cache); static struct lprocfs_vars lprocfs_llite_obd_vars[] = { { "uuid", &ll_sb_uuid_fops, NULL, 0 }, /* { "mntpt_path", ll_rd_path, 0, 0 }, */ - { "fstype", &ll_fstype_fops, NULL, 0 }, { "site", &ll_site_stats_fops, NULL, 0 }, /* { "filegroups", lprocfs_rd_filegroups, 0, 0 }, */ { "max_read_ahead_mb", &ll_max_readahead_mb_fops, NULL }, @@ -875,6 +874,7 @@ static struct attribute *llite_attrs[] = { &lustre_attr_filestotal.attr, &lustre_attr_filesfree.attr, &lustre_attr_client_type.attr, + &lustre_attr_fstype.attr, NULL, }; diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index 213eb8681461..36c20d893a52 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -85,3 +85,9 @@ Description: Shows whenever this filesystem considers this client to be compute cluster-local or remote. Remote clients have additional uid/gid convrting logic applied. + +What: /sys/fs/lustre/llite/-/fstype +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Shows filesystem type of the filesystem From ec55a6299990efa969dfc00d95c72444ff1e3461 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:43 -0400 Subject: [PATCH 0599/1163] staging/lustre/llite: move /proc/fs/lustre/llite/uuid to sysfs Move uuid file from /proc/fs/lustre/llite/* to /sys/fs/lustre/llite/*/ Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 14 +++++++------- drivers/staging/lustre/sysfs-fs-lustre | 6 ++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 53671db2b6d3..deee702fa33c 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -198,15 +198,15 @@ static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr, } LUSTRE_RO_ATTR(fstype); -static int ll_sb_uuid_seq_show(struct seq_file *m, void *v) +static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct super_block *sb = (struct super_block *)m->private; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); - LASSERT(sb != NULL); - seq_printf(m, "%s\n", ll_s2sbi(sb)->ll_sb_uuid.uuid); - return 0; + return sprintf(buf, "%s\n", sbi->ll_sb_uuid.uuid); } -LPROC_SEQ_FOPS_RO(ll_sb_uuid); +LUSTRE_RO_ATTR(uuid); static int ll_site_stats_seq_show(struct seq_file *m, void *v) { @@ -837,7 +837,6 @@ static ssize_t ll_xattr_cache_seq_write(struct file *file, LPROC_SEQ_FOPS(ll_xattr_cache); static struct lprocfs_vars lprocfs_llite_obd_vars[] = { - { "uuid", &ll_sb_uuid_fops, NULL, 0 }, /* { "mntpt_path", ll_rd_path, 0, 0 }, */ { "site", &ll_site_stats_fops, NULL, 0 }, /* { "filegroups", lprocfs_rd_filegroups, 0, 0 }, */ @@ -875,6 +874,7 @@ static struct attribute *llite_attrs[] = { &lustre_attr_filesfree.attr, &lustre_attr_client_type.attr, &lustre_attr_fstype.attr, + &lustre_attr_uuid.attr, NULL, }; diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index 36c20d893a52..f353d129ea81 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -91,3 +91,9 @@ Date: May 2015 Contact: "Oleg Drokin" Description: Shows filesystem type of the filesystem + +What: /sys/fs/lustre/llite/-/uuid +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Shows this filesystem superblock uuid From e1a1df5e885ccf71cf2037b0c7ac4a5fd3a0e27f Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:44 -0400 Subject: [PATCH 0600/1163] staging/lustre/llite: move /proc/fs/lustre/llite/max_read_ahead_mb to sysfs Move max_read_ahead_mb file from /proc/fs/lustre/llite/* to /sys/fs/lustre/llite/*/ Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/llite/lproc_llite.c | 35 +++++++++++-------- drivers/staging/lustre/sysfs-fs-lustre | 7 ++++ 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index deee702fa33c..5baffc1c31af 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -220,10 +220,11 @@ static int ll_site_stats_seq_show(struct seq_file *m, void *v) } LPROC_SEQ_FOPS_RO(ll_site_stats); -static int ll_max_readahead_mb_seq_show(struct seq_file *m, void *v) +static ssize_t max_read_ahead_mb_show(struct kobject *kobj, + struct attribute *attr, char *buf) { - struct super_block *sb = m->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); long pages_number; int mult; @@ -232,23 +233,27 @@ static int ll_max_readahead_mb_seq_show(struct seq_file *m, void *v) spin_unlock(&sbi->ll_lock); mult = 1 << (20 - PAGE_CACHE_SHIFT); - return lprocfs_seq_read_frac_helper(m, pages_number, mult); + return lprocfs_read_frac_helper(buf, PAGE_SIZE, pages_number, mult); } -static ssize_t ll_max_readahead_mb_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t max_read_ahead_mb_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct super_block *sb = ((struct seq_file *)file->private_data)->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); - int mult, rc, pages_number; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); + int rc; + unsigned long pages_number; - mult = 1 << (20 - PAGE_CACHE_SHIFT); - rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult); + rc = kstrtoul(buffer, 10, &pages_number); if (rc) return rc; - if (pages_number < 0 || pages_number > totalram_pages / 2) { + pages_number *= 1 << (20 - PAGE_CACHE_SHIFT); /* MB -> pages */ + + if (pages_number > totalram_pages / 2) { + CERROR("can't set file readahead more than %lu MB\n", totalram_pages >> (20 - PAGE_CACHE_SHIFT + 1)); /*1/2 of RAM*/ return -ERANGE; @@ -260,7 +265,7 @@ static ssize_t ll_max_readahead_mb_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ll_max_readahead_mb); +LUSTRE_RW_ATTR(max_read_ahead_mb); static int ll_max_readahead_per_file_mb_seq_show(struct seq_file *m, void *v) { @@ -840,7 +845,6 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { /* { "mntpt_path", ll_rd_path, 0, 0 }, */ { "site", &ll_site_stats_fops, NULL, 0 }, /* { "filegroups", lprocfs_rd_filegroups, 0, 0 }, */ - { "max_read_ahead_mb", &ll_max_readahead_mb_fops, NULL }, { "max_read_ahead_per_file_mb", &ll_max_readahead_per_file_mb_fops, NULL }, { "max_read_ahead_whole_mb", &ll_max_read_ahead_whole_mb_fops, NULL }, @@ -875,6 +879,7 @@ static struct attribute *llite_attrs[] = { &lustre_attr_client_type.attr, &lustre_attr_fstype.attr, &lustre_attr_uuid.attr, + &lustre_attr_max_read_ahead_mb.attr, NULL, }; diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index f353d129ea81..fa32197f656b 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -97,3 +97,10 @@ Date: May 2015 Contact: "Oleg Drokin" Description: Shows this filesystem superblock uuid + +What: /sys/fs/lustre/llite/-/max_read_ahead_mb +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Sets maximum number of megabytes in system memory to be + given to read-ahead cache. From 0e6c5a219a6ee69c014c598f3edd04126fecea57 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:45 -0400 Subject: [PATCH 0601/1163] staging/lustre/llite: move llite/max_read_ahead_per_file_mb to sysfs Move max_read_ahead_per_file_mb file from /proc/fs/lustre/llite/* to /sys/fs/lustre/llite/*/ Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/llite/lproc_llite.c | 35 ++++++++++--------- drivers/staging/lustre/sysfs-fs-lustre | 6 ++++ 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 5baffc1c31af..8c8a0fa093b2 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -267,10 +267,12 @@ static ssize_t max_read_ahead_mb_store(struct kobject *kobj, } LUSTRE_RW_ATTR(max_read_ahead_mb); -static int ll_max_readahead_per_file_mb_seq_show(struct seq_file *m, void *v) +static ssize_t max_read_ahead_per_file_mb_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct super_block *sb = m->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); long pages_number; int mult; @@ -279,24 +281,24 @@ static int ll_max_readahead_per_file_mb_seq_show(struct seq_file *m, void *v) spin_unlock(&sbi->ll_lock); mult = 1 << (20 - PAGE_CACHE_SHIFT); - return lprocfs_seq_read_frac_helper(m, pages_number, mult); + return lprocfs_read_frac_helper(buf, PAGE_SIZE, pages_number, mult); } -static ssize_t ll_max_readahead_per_file_mb_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t max_read_ahead_per_file_mb_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct super_block *sb = ((struct seq_file *)file->private_data)->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); - int mult, rc, pages_number; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); + int rc; + unsigned long pages_number; - mult = 1 << (20 - PAGE_CACHE_SHIFT); - rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult); + rc = kstrtoul(buffer, 10, &pages_number); if (rc) return rc; - if (pages_number < 0 || - pages_number > sbi->ll_ra_info.ra_max_pages) { + if (pages_number > sbi->ll_ra_info.ra_max_pages) { CERROR("can't set file readahead more than max_read_ahead_mb %lu MB\n", sbi->ll_ra_info.ra_max_pages); return -ERANGE; @@ -308,7 +310,7 @@ static ssize_t ll_max_readahead_per_file_mb_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ll_max_readahead_per_file_mb); +LUSTRE_RW_ATTR(max_read_ahead_per_file_mb); static int ll_max_read_ahead_whole_mb_seq_show(struct seq_file *m, void *unused) { @@ -845,8 +847,6 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { /* { "mntpt_path", ll_rd_path, 0, 0 }, */ { "site", &ll_site_stats_fops, NULL, 0 }, /* { "filegroups", lprocfs_rd_filegroups, 0, 0 }, */ - { "max_read_ahead_per_file_mb", &ll_max_readahead_per_file_mb_fops, - NULL }, { "max_read_ahead_whole_mb", &ll_max_read_ahead_whole_mb_fops, NULL }, { "max_cached_mb", &ll_max_cached_mb_fops, NULL }, { "checksum_pages", &ll_checksum_fops, NULL }, @@ -880,6 +880,7 @@ static struct attribute *llite_attrs[] = { &lustre_attr_fstype.attr, &lustre_attr_uuid.attr, &lustre_attr_max_read_ahead_mb.attr, + &lustre_attr_max_read_ahead_per_file_mb.attr, NULL, }; diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index fa32197f656b..1e07cd971093 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -104,3 +104,9 @@ Contact: "Oleg Drokin" Description: Sets maximum number of megabytes in system memory to be given to read-ahead cache. + +What: /sys/fs/lustre/llite/-/max_read_ahead_per_file_mb +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Sets maximum number of megabytes to read-ahead for a single file From ec469235867c22e9bd3e244ddd357202fac20276 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:46 -0400 Subject: [PATCH 0602/1163] staging/lustre/llite: move llite/max_read_ahead_whole_mb to sysfs Move max_read_ahead_whole_mb file from /proc/fs/lustre/llite/* to /sys/fs/lustre/llite/*/ Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/llite/lproc_llite.c | 34 ++++++++++--------- drivers/staging/lustre/sysfs-fs-lustre | 7 ++++ 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 8c8a0fa093b2..81f7af39f7d3 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -312,10 +312,12 @@ static ssize_t max_read_ahead_per_file_mb_store(struct kobject *kobj, } LUSTRE_RW_ATTR(max_read_ahead_per_file_mb); -static int ll_max_read_ahead_whole_mb_seq_show(struct seq_file *m, void *unused) +static ssize_t max_read_ahead_whole_mb_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct super_block *sb = m->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); long pages_number; int mult; @@ -324,26 +326,26 @@ static int ll_max_read_ahead_whole_mb_seq_show(struct seq_file *m, void *unused) spin_unlock(&sbi->ll_lock); mult = 1 << (20 - PAGE_CACHE_SHIFT); - return lprocfs_seq_read_frac_helper(m, pages_number, mult); + return lprocfs_read_frac_helper(buf, PAGE_SIZE, pages_number, mult); } -static ssize_t ll_max_read_ahead_whole_mb_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t max_read_ahead_whole_mb_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct super_block *sb = ((struct seq_file *)file->private_data)->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); - int mult, rc, pages_number; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); + int rc; + unsigned long pages_number; - mult = 1 << (20 - PAGE_CACHE_SHIFT); - rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult); + rc = kstrtoul(buffer, 10, &pages_number); if (rc) return rc; /* Cap this at the current max readahead window size, the readahead * algorithm does this anyway so it's pointless to set it larger. */ - if (pages_number < 0 || - pages_number > sbi->ll_ra_info.ra_max_pages_per_file) { + if (pages_number > sbi->ll_ra_info.ra_max_pages_per_file) { CERROR("can't set max_read_ahead_whole_mb more than max_read_ahead_per_file_mb: %lu\n", sbi->ll_ra_info.ra_max_pages_per_file >> (20 - PAGE_CACHE_SHIFT)); return -ERANGE; @@ -355,7 +357,7 @@ static ssize_t ll_max_read_ahead_whole_mb_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ll_max_read_ahead_whole_mb); +LUSTRE_RW_ATTR(max_read_ahead_whole_mb); static int ll_max_cached_mb_seq_show(struct seq_file *m, void *v) { @@ -847,7 +849,6 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { /* { "mntpt_path", ll_rd_path, 0, 0 }, */ { "site", &ll_site_stats_fops, NULL, 0 }, /* { "filegroups", lprocfs_rd_filegroups, 0, 0 }, */ - { "max_read_ahead_whole_mb", &ll_max_read_ahead_whole_mb_fops, NULL }, { "max_cached_mb", &ll_max_cached_mb_fops, NULL }, { "checksum_pages", &ll_checksum_fops, NULL }, { "max_rw_chunk", &ll_max_rw_chunk_fops, NULL }, @@ -881,6 +882,7 @@ static struct attribute *llite_attrs[] = { &lustre_attr_uuid.attr, &lustre_attr_max_read_ahead_mb.attr, &lustre_attr_max_read_ahead_per_file_mb.attr, + &lustre_attr_max_read_ahead_whole_mb.attr, NULL, }; diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index 1e07cd971093..3151465a3e47 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -110,3 +110,10 @@ Date: May 2015 Contact: "Oleg Drokin" Description: Sets maximum number of megabytes to read-ahead for a single file + +What: /sys/fs/lustre/llite/-/max_read_ahead_whole_mb +Date: May 2015 +Contact: "Oleg Drokin" +Description: + For small reads, how many megabytes to actually request from + the server as initial read-ahead. From 40cc864a9fcd48d7f3a67421a8e578e8d4cbe308 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:47 -0400 Subject: [PATCH 0603/1163] staging/lustre/llite: move /proc/fs/lustre/llite/checksum_pages to sysfs Move checksum_pages file from /proc/fs/lustre/llite/* to /sys/fs/lustre/llite/*/ Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/llite/llite_lib.c | 2 +- .../staging/lustre/lustre/llite/lproc_llite.c | 30 ++++++++++--------- drivers/staging/lustre/sysfs-fs-lustre | 7 +++++ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 2aa2335685cb..1b42304e0bd1 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -407,7 +407,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, if (!OBD_FAIL_CHECK(OBD_FAIL_OSC_CONNECT_CKSUM)) { /* OBD_CONNECT_CKSUM should always be set, even if checksums are * disabled by default, because it can still be enabled on the - * fly via /proc. As a consequence, we still need to come to an + * fly via /sys. As a consequence, we still need to come to an * agreement on the supported algorithms at connect time */ data->ocd_connect_flags |= OBD_CONNECT_CKSUM; diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 81f7af39f7d3..99d96d7a283e 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -480,28 +480,30 @@ out: } LPROC_SEQ_FOPS(ll_max_cached_mb); -static int ll_checksum_seq_show(struct seq_file *m, void *v) +static ssize_t checksum_pages_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct super_block *sb = m->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); - seq_printf(m, "%u\n", (sbi->ll_flags & LL_SBI_CHECKSUM) ? 1 : 0); - return 0; + return sprintf(buf, "%u\n", (sbi->ll_flags & LL_SBI_CHECKSUM) ? 1 : 0); } -static ssize_t ll_checksum_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t checksum_pages_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct super_block *sb = ((struct seq_file *)file->private_data)->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); - int val, rc; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); + int rc; + unsigned long val; if (!sbi->ll_dt_exp) /* Not set up yet */ return -EAGAIN; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; if (val) @@ -516,7 +518,7 @@ static ssize_t ll_checksum_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ll_checksum); +LUSTRE_RW_ATTR(checksum_pages); static int ll_max_rw_chunk_seq_show(struct seq_file *m, void *v) { @@ -850,7 +852,6 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { { "site", &ll_site_stats_fops, NULL, 0 }, /* { "filegroups", lprocfs_rd_filegroups, 0, 0 }, */ { "max_cached_mb", &ll_max_cached_mb_fops, NULL }, - { "checksum_pages", &ll_checksum_fops, NULL }, { "max_rw_chunk", &ll_max_rw_chunk_fops, NULL }, { "stats_track_pid", &ll_track_pid_fops, NULL }, { "stats_track_ppid", &ll_track_ppid_fops, NULL }, @@ -883,6 +884,7 @@ static struct attribute *llite_attrs[] = { &lustre_attr_max_read_ahead_mb.attr, &lustre_attr_max_read_ahead_per_file_mb.attr, &lustre_attr_max_read_ahead_whole_mb.attr, + &lustre_attr_checksum_pages.attr, NULL, }; diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index 3151465a3e47..03a4dc62df1f 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -117,3 +117,10 @@ Contact: "Oleg Drokin" Description: For small reads, how many megabytes to actually request from the server as initial read-ahead. + +What: /sys/fs/lustre/llite/-/checksum_pages +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Enables or disables per-page checksum at llite layer, before + the pages are actually given to lower level for network transfer From 06ed0cd897a8d1b1c9a067b7b726b9a47a4ca7e0 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:48 -0400 Subject: [PATCH 0604/1163] staging/lustre/llite: remove unused ll_max_rw_chunk ll_max_rw_chunk seems to be unused ever since we implemented CLIO in 2.0, so remove it and all supporting infrastructure. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/llite/llite_internal.h | 5 ---- .../staging/lustre/lustre/llite/llite_lib.c | 1 - .../staging/lustre/lustre/llite/lproc_llite.c | 24 ------------------- 3 files changed, 30 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index c4c758cac12a..e180912d0e08 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -487,9 +487,6 @@ struct ll_sb_info { unsigned int ll_namelen; struct file_operations *ll_fop; - /* =0 - hold lock over whole read/write - * >0 - max. chunk to be read/written w/o lock re-acquiring */ - unsigned long ll_max_rw_chunk; unsigned int ll_md_brw_size; /* used by readdir */ struct lu_site *ll_site; @@ -523,8 +520,6 @@ struct ll_sb_info { struct completion ll_kobj_unregister; }; -#define LL_DEFAULT_MAX_RW_CHUNK (32 * 1024 * 1024) - struct ll_ra_read { pgoff_t lrr_start; pgoff_t lrr_count; diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 1b42304e0bd1..4c9fd4acedea 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -315,7 +315,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, sb->s_magic = LL_SUPER_MAGIC; sb->s_maxbytes = MAX_LFS_FILESIZE; sbi->ll_namelen = osfs->os_namelen; - sbi->ll_max_rw_chunk = LL_DEFAULT_MAX_RW_CHUNK; if ((sbi->ll_flags & LL_SBI_USER_XATTR) && !(data->ocd_connect_flags & OBD_CONNECT_XATTR)) { diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 99d96d7a283e..da08edeceda9 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -520,29 +520,6 @@ static ssize_t checksum_pages_store(struct kobject *kobj, } LUSTRE_RW_ATTR(checksum_pages); -static int ll_max_rw_chunk_seq_show(struct seq_file *m, void *v) -{ - struct super_block *sb = m->private; - - seq_printf(m, "%lu\n", ll_s2sbi(sb)->ll_max_rw_chunk); - return 0; -} - -static ssize_t ll_max_rw_chunk_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; - int rc, val; - - rc = lprocfs_write_helper(buffer, count, &val); - if (rc) - return rc; - ll_s2sbi(sb)->ll_max_rw_chunk = val; - return count; -} -LPROC_SEQ_FOPS(ll_max_rw_chunk); - static int ll_rd_track_id(struct seq_file *m, enum stats_track_type type) { struct super_block *sb = m->private; @@ -852,7 +829,6 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { { "site", &ll_site_stats_fops, NULL, 0 }, /* { "filegroups", lprocfs_rd_filegroups, 0, 0 }, */ { "max_cached_mb", &ll_max_cached_mb_fops, NULL }, - { "max_rw_chunk", &ll_max_rw_chunk_fops, NULL }, { "stats_track_pid", &ll_track_pid_fops, NULL }, { "stats_track_ppid", &ll_track_ppid_fops, NULL }, { "stats_track_gid", &ll_track_gid_fops, NULL }, From 62cf4b1315e86a1f373f77acf32a23d76428ba27 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:49 -0400 Subject: [PATCH 0605/1163] staging/lustre/llite: move /proc/fs/lustre/llite/stats_track* to sysfs Move stats_track_pid, stats_track_ppid and stats_track_gid files from /proc/fs/lustre/llite/* to /sys/fs/lustre/llite/*/ Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/llite/lproc_llite.c | 99 ++++++++++--------- drivers/staging/lustre/sysfs-fs-lustre | 21 ++++ 2 files changed, 75 insertions(+), 45 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index da08edeceda9..3f9cdd2a6a5c 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -520,79 +520,88 @@ static ssize_t checksum_pages_store(struct kobject *kobj, } LUSTRE_RW_ATTR(checksum_pages); -static int ll_rd_track_id(struct seq_file *m, enum stats_track_type type) +static ssize_t ll_rd_track_id(struct kobject *kobj, char *buf, + enum stats_track_type type) { - struct super_block *sb = m->private; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); - if (ll_s2sbi(sb)->ll_stats_track_type == type) - seq_printf(m, "%d\n", ll_s2sbi(sb)->ll_stats_track_id); - else if (ll_s2sbi(sb)->ll_stats_track_type == STATS_TRACK_ALL) - seq_puts(m, "0 (all)\n"); + if (sbi->ll_stats_track_type == type) + return sprintf(buf, "%d\n", sbi->ll_stats_track_id); + else if (sbi->ll_stats_track_type == STATS_TRACK_ALL) + return sprintf(buf, "0 (all)\n"); else - seq_puts(m, "untracked\n"); - - return 0; + return sprintf(buf, "untracked\n"); } -static int ll_wr_track_id(const char __user *buffer, unsigned long count, - void *data, enum stats_track_type type) +static ssize_t ll_wr_track_id(struct kobject *kobj, const char *buffer, + size_t count, + enum stats_track_type type) { - struct super_block *sb = data; - int rc, pid; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); + int rc; + unsigned long pid; - rc = lprocfs_write_helper(buffer, count, &pid); + rc = kstrtoul(buffer, 10, &pid); if (rc) return rc; - ll_s2sbi(sb)->ll_stats_track_id = pid; + sbi->ll_stats_track_id = pid; if (pid == 0) - ll_s2sbi(sb)->ll_stats_track_type = STATS_TRACK_ALL; + sbi->ll_stats_track_type = STATS_TRACK_ALL; else - ll_s2sbi(sb)->ll_stats_track_type = type; - lprocfs_clear_stats(ll_s2sbi(sb)->ll_stats); + sbi->ll_stats_track_type = type; + lprocfs_clear_stats(sbi->ll_stats); return count; } -static int ll_track_pid_seq_show(struct seq_file *m, void *v) +static ssize_t stats_track_pid_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - return ll_rd_track_id(m, STATS_TRACK_PID); + return ll_rd_track_id(kobj, buf, STATS_TRACK_PID); } -static ssize_t ll_track_pid_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t stats_track_pid_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct seq_file *seq = file->private_data; - return ll_wr_track_id(buffer, count, seq->private, STATS_TRACK_PID); + return ll_wr_track_id(kobj, buffer, count, STATS_TRACK_PID); } -LPROC_SEQ_FOPS(ll_track_pid); +LUSTRE_RW_ATTR(stats_track_pid); -static int ll_track_ppid_seq_show(struct seq_file *m, void *v) +static ssize_t stats_track_ppid_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - return ll_rd_track_id(m, STATS_TRACK_PPID); + return ll_rd_track_id(kobj, buf, STATS_TRACK_PPID); } -static ssize_t ll_track_ppid_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t stats_track_ppid_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct seq_file *seq = file->private_data; - return ll_wr_track_id(buffer, count, seq->private, STATS_TRACK_PPID); + return ll_wr_track_id(kobj, buffer, count, STATS_TRACK_PPID); } -LPROC_SEQ_FOPS(ll_track_ppid); +LUSTRE_RW_ATTR(stats_track_ppid); -static int ll_track_gid_seq_show(struct seq_file *m, void *v) +static ssize_t stats_track_gid_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - return ll_rd_track_id(m, STATS_TRACK_GID); + return ll_rd_track_id(kobj, buf, STATS_TRACK_GID); } -static ssize_t ll_track_gid_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t stats_track_gid_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct seq_file *seq = file->private_data; - return ll_wr_track_id(buffer, count, seq->private, STATS_TRACK_GID); + return ll_wr_track_id(kobj, buffer, count, STATS_TRACK_GID); } -LPROC_SEQ_FOPS(ll_track_gid); +LUSTRE_RW_ATTR(stats_track_gid); static int ll_statahead_max_seq_show(struct seq_file *m, void *v) { @@ -829,9 +838,6 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { { "site", &ll_site_stats_fops, NULL, 0 }, /* { "filegroups", lprocfs_rd_filegroups, 0, 0 }, */ { "max_cached_mb", &ll_max_cached_mb_fops, NULL }, - { "stats_track_pid", &ll_track_pid_fops, NULL }, - { "stats_track_ppid", &ll_track_ppid_fops, NULL }, - { "stats_track_gid", &ll_track_gid_fops, NULL }, { "statahead_max", &ll_statahead_max_fops, NULL }, { "statahead_agl", &ll_statahead_agl_fops, NULL }, { "statahead_stats", &ll_statahead_stats_fops, NULL, 0 }, @@ -861,6 +867,9 @@ static struct attribute *llite_attrs[] = { &lustre_attr_max_read_ahead_per_file_mb.attr, &lustre_attr_max_read_ahead_whole_mb.attr, &lustre_attr_checksum_pages.attr, + &lustre_attr_stats_track_pid.attr, + &lustre_attr_stats_track_ppid.attr, + &lustre_attr_stats_track_gid.attr, NULL, }; diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index 03a4dc62df1f..acf85cc57231 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -124,3 +124,24 @@ Contact: "Oleg Drokin" Description: Enables or disables per-page checksum at llite layer, before the pages are actually given to lower level for network transfer + +What: /sys/fs/lustre/llite/-/stats_track_pid +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Limit Lustre vfs operations gathering to just a single pid. + 0 to track everything. + +What: /sys/fs/lustre/llite/-/stats_track_ppid +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Limit Lustre vfs operations gathering to just a single ppid. + 0 to track everything. + +What: /sys/fs/lustre/llite/-/stats_track_gid +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Limit Lustre vfs operations gathering to just a single gid. + 0 to track everything. From 4081a3201ade8b3be715ebb0b7879a2bfe5fcc98 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:50 -0400 Subject: [PATCH 0606/1163] staging/lustre/llite: move /proc/fs/lustre/llite/statahead_{max, agl} to sysfs Move statahead_max and statahead_agl files from /proc/fs/lustre/llite/* to /sys/fs/lustre/llite/*/ Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/llite/lproc_llite.c | 66 ++++++++++--------- drivers/staging/lustre/sysfs-fs-lustre | 16 +++++ 2 files changed, 52 insertions(+), 30 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 3f9cdd2a6a5c..aa0e12b0a69b 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -603,55 +603,61 @@ static ssize_t stats_track_gid_store(struct kobject *kobj, } LUSTRE_RW_ATTR(stats_track_gid); -static int ll_statahead_max_seq_show(struct seq_file *m, void *v) +static ssize_t statahead_max_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct super_block *sb = m->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); - seq_printf(m, "%u\n", sbi->ll_sa_max); - return 0; + return sprintf(buf, "%u\n", sbi->ll_sa_max); } -static ssize_t ll_statahead_max_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t statahead_max_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct super_block *sb = ((struct seq_file *)file->private_data)->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); - int val, rc; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; - if (val >= 0 && val <= LL_SA_RPC_MAX) + if (val <= LL_SA_RPC_MAX) sbi->ll_sa_max = val; else - CERROR("Bad statahead_max value %d. Valid values are in the range [0, %d]\n", + CERROR("Bad statahead_max value %lu. Valid values are in the range [0, %d]\n", val, LL_SA_RPC_MAX); return count; } -LPROC_SEQ_FOPS(ll_statahead_max); +LUSTRE_RW_ATTR(statahead_max); -static int ll_statahead_agl_seq_show(struct seq_file *m, void *v) +static ssize_t statahead_agl_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct super_block *sb = m->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); - seq_printf(m, "%u\n", sbi->ll_flags & LL_SBI_AGL_ENABLED ? 1 : 0); - return 0; + return sprintf(buf, "%u\n", sbi->ll_flags & LL_SBI_AGL_ENABLED ? 1 : 0); } -static ssize_t ll_statahead_agl_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t statahead_agl_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct super_block *sb = ((struct seq_file *)file->private_data)->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); - int val, rc; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; @@ -662,7 +668,7 @@ static ssize_t ll_statahead_agl_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ll_statahead_agl); +LUSTRE_RW_ATTR(statahead_agl); static int ll_statahead_stats_seq_show(struct seq_file *m, void *v) { @@ -838,8 +844,6 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { { "site", &ll_site_stats_fops, NULL, 0 }, /* { "filegroups", lprocfs_rd_filegroups, 0, 0 }, */ { "max_cached_mb", &ll_max_cached_mb_fops, NULL }, - { "statahead_max", &ll_statahead_max_fops, NULL }, - { "statahead_agl", &ll_statahead_agl_fops, NULL }, { "statahead_stats", &ll_statahead_stats_fops, NULL, 0 }, { "lazystatfs", &ll_lazystatfs_fops, NULL }, { "max_easize", &ll_max_easize_fops, NULL, 0 }, @@ -870,6 +874,8 @@ static struct attribute *llite_attrs[] = { &lustre_attr_stats_track_pid.attr, &lustre_attr_stats_track_ppid.attr, &lustre_attr_stats_track_gid.attr, + &lustre_attr_statahead_max.attr, + &lustre_attr_statahead_agl.attr, NULL, }; diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index acf85cc57231..2920eadbb844 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -145,3 +145,19 @@ Contact: "Oleg Drokin" Description: Limit Lustre vfs operations gathering to just a single gid. 0 to track everything. + +What: /sys/fs/lustre/llite/-/statahead_max +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Controls maximum number of statahead requests to send when + sequential readdir+stat pattern is detected. + +What: /sys/fs/lustre/llite/-/statahead_agl +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Controls if AGL (async glimpse ahead - obtain object information + from OSTs in parallel with MDS during statahead) should be + enabled or disabled. + 0 to disable, 1 to enable. From c7fe64bdd0623f5871800ff42842741175f19562 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:51 -0400 Subject: [PATCH 0607/1163] staging/lustre/llite: move /proc/fs/lustre/llite/lazystatfs to sysfs Move lazystatfs file from /proc/fs/lustre/llite/* to /sys/fs/lustre/llite/*/ Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/llite/lproc_llite.c | 31 ++++++++++--------- drivers/staging/lustre/sysfs-fs-lustre | 8 +++++ 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index aa0e12b0a69b..03d41278c259 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -686,24 +686,27 @@ static int ll_statahead_stats_seq_show(struct seq_file *m, void *v) } LPROC_SEQ_FOPS_RO(ll_statahead_stats); -static int ll_lazystatfs_seq_show(struct seq_file *m, void *v) +static ssize_t lazystatfs_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct super_block *sb = m->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); - seq_printf(m, "%u\n", sbi->ll_flags & LL_SBI_LAZYSTATFS ? 1 : 0); - return 0; + return sprintf(buf, "%u\n", sbi->ll_flags & LL_SBI_LAZYSTATFS ? 1 : 0); } -static ssize_t ll_lazystatfs_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t lazystatfs_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct super_block *sb = ((struct seq_file *)file->private_data)->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); - int val, rc; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; @@ -714,7 +717,7 @@ static ssize_t ll_lazystatfs_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ll_lazystatfs); +LUSTRE_RW_ATTR(lazystatfs); static int ll_max_easize_seq_show(struct seq_file *m, void *v) { @@ -845,7 +848,6 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { /* { "filegroups", lprocfs_rd_filegroups, 0, 0 }, */ { "max_cached_mb", &ll_max_cached_mb_fops, NULL }, { "statahead_stats", &ll_statahead_stats_fops, NULL, 0 }, - { "lazystatfs", &ll_lazystatfs_fops, NULL }, { "max_easize", &ll_max_easize_fops, NULL, 0 }, { "default_easize", &ll_default_easize_fops, NULL, 0 }, { "max_cookiesize", &ll_max_cookiesize_fops, NULL, 0 }, @@ -876,6 +878,7 @@ static struct attribute *llite_attrs[] = { &lustre_attr_stats_track_gid.attr, &lustre_attr_statahead_max.attr, &lustre_attr_statahead_agl.attr, + &lustre_attr_lazystatfs.attr, NULL, }; diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index 2920eadbb844..184b387b787e 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -161,3 +161,11 @@ Description: from OSTs in parallel with MDS during statahead) should be enabled or disabled. 0 to disable, 1 to enable. + +What: /sys/fs/lustre/llite/-/lazystatfs +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Controls statfs(2) behaviour in the face of down servers. + If 0, always wait for all servers to come online, + if 1, ignote inactive servers. From f5501d042e5dd2b9932f1cad8ad3a71ec4777926 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:52 -0400 Subject: [PATCH 0608/1163] staging/lustre/llite: move /proc/fs/lustre/llite/*_easize to sysfs Move max_easize and default_easize files from /proc/fs/lustre/llite/* to /sys/fs/lustre/llite/*/ Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/llite/lproc_llite.c | 30 ++++++++++--------- drivers/staging/lustre/sysfs-fs-lustre | 14 +++++++++ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 03d41278c259..32a9835af36d 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -719,10 +719,12 @@ static ssize_t lazystatfs_store(struct kobject *kobj, } LUSTRE_RW_ATTR(lazystatfs); -static int ll_max_easize_seq_show(struct seq_file *m, void *v) +static ssize_t max_easize_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct super_block *sb = m->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); unsigned int ealen; int rc; @@ -730,15 +732,16 @@ static int ll_max_easize_seq_show(struct seq_file *m, void *v) if (rc) return rc; - seq_printf(m, "%u\n", ealen); - return 0; + return sprintf(buf, "%u\n", ealen); } -LPROC_SEQ_FOPS_RO(ll_max_easize); +LUSTRE_RO_ATTR(max_easize); -static int ll_default_easize_seq_show(struct seq_file *m, void *v) +static ssize_t default_easize_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct super_block *sb = m->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); unsigned int ealen; int rc; @@ -746,10 +749,9 @@ static int ll_default_easize_seq_show(struct seq_file *m, void *v) if (rc) return rc; - seq_printf(m, "%u\n", ealen); - return 0; + return sprintf(buf, "%u\n", ealen); } -LPROC_SEQ_FOPS_RO(ll_default_easize); +LUSTRE_RO_ATTR(default_easize); static int ll_max_cookiesize_seq_show(struct seq_file *m, void *v) { @@ -848,8 +850,6 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { /* { "filegroups", lprocfs_rd_filegroups, 0, 0 }, */ { "max_cached_mb", &ll_max_cached_mb_fops, NULL }, { "statahead_stats", &ll_statahead_stats_fops, NULL, 0 }, - { "max_easize", &ll_max_easize_fops, NULL, 0 }, - { "default_easize", &ll_default_easize_fops, NULL, 0 }, { "max_cookiesize", &ll_max_cookiesize_fops, NULL, 0 }, { "default_cookiesize", &ll_default_cookiesize_fops, NULL, 0 }, { "sbi_flags", &ll_sbi_flags_fops, NULL, 0 }, @@ -879,6 +879,8 @@ static struct attribute *llite_attrs[] = { &lustre_attr_statahead_max.attr, &lustre_attr_statahead_agl.attr, &lustre_attr_lazystatfs.attr, + &lustre_attr_max_easize.attr, + &lustre_attr_default_easize.attr, NULL, }; diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index 184b387b787e..bf3f82a79a11 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -169,3 +169,17 @@ Description: Controls statfs(2) behaviour in the face of down servers. If 0, always wait for all servers to come online, if 1, ignote inactive servers. + +What: /sys/fs/lustre/llite/-/max_easize +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Shows maximum number of bytes file striping data could be + in current configuration of storage. + +What: /sys/fs/lustre/llite/-/default_easize +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Shows maximum observed file striping data seen by this + filesystem client instance. From d36f2b0ba87ef5ad41a2f02e941b8f8897f6c2a5 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:53 -0400 Subject: [PATCH 0609/1163] staging/lustre/llite: remove llite/*_cookiesize proc files Since Lustre 2.5, cookiesize is unused on the clients since MDS now does final object unlink by itself, so drop these max_cookiesize and default_cookiesize files. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/llite/lproc_llite.c | 34 ------------------- 1 file changed, 34 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 32a9835af36d..ced00769ab94 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -753,38 +753,6 @@ static ssize_t default_easize_show(struct kobject *kobj, } LUSTRE_RO_ATTR(default_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; - - seq_printf(m, "%u\n", cookielen); - return 0; -} -LPROC_SEQ_FOPS_RO(ll_max_cookiesize); - -static int ll_default_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; - - seq_printf(m, "%u\n", cookielen); - return 0; -} -LPROC_SEQ_FOPS_RO(ll_default_cookiesize); - static int ll_sbi_flags_seq_show(struct seq_file *m, void *v) { const char *str[] = LL_SBI_FLAGS; @@ -850,8 +818,6 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { /* { "filegroups", lprocfs_rd_filegroups, 0, 0 }, */ { "max_cached_mb", &ll_max_cached_mb_fops, NULL }, { "statahead_stats", &ll_statahead_stats_fops, NULL, 0 }, - { "max_cookiesize", &ll_max_cookiesize_fops, NULL, 0 }, - { "default_cookiesize", &ll_default_cookiesize_fops, NULL, 0 }, { "sbi_flags", &ll_sbi_flags_fops, NULL, 0 }, { "xattr_cache", &ll_xattr_cache_fops, NULL, 0 }, { NULL } From 070c29ca79ef5a3ba753053928371b257064b15f Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:54 -0400 Subject: [PATCH 0610/1163] staging/lustre/llite: move /proc/fs/lustre/llite/xattr_cache to sysfs Move xattr_cache file from /proc/fs/lustre/llite/* to /sys/fs/lustre/llite/*/ Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/llite/lproc_llite.c | 33 ++++++++++--------- drivers/staging/lustre/sysfs-fs-lustre | 7 ++++ 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index ced00769ab94..49fbecc40cac 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -777,26 +777,27 @@ static int ll_sbi_flags_seq_show(struct seq_file *m, void *v) } LPROC_SEQ_FOPS_RO(ll_sbi_flags); -static int ll_xattr_cache_seq_show(struct seq_file *m, void *v) +static ssize_t xattr_cache_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct super_block *sb = m->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); - seq_printf(m, "%u\n", sbi->ll_xattr_cache_enabled); - - return 0; + return sprintf(buf, "%u\n", sbi->ll_xattr_cache_enabled); } -static ssize_t ll_xattr_cache_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t xattr_cache_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct seq_file *seq = file->private_data; - struct super_block *sb = seq->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); - int val, rc; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; @@ -810,7 +811,7 @@ static ssize_t ll_xattr_cache_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ll_xattr_cache); +LUSTRE_RW_ATTR(xattr_cache); static struct lprocfs_vars lprocfs_llite_obd_vars[] = { /* { "mntpt_path", ll_rd_path, 0, 0 }, */ @@ -819,7 +820,6 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { { "max_cached_mb", &ll_max_cached_mb_fops, NULL }, { "statahead_stats", &ll_statahead_stats_fops, NULL, 0 }, { "sbi_flags", &ll_sbi_flags_fops, NULL, 0 }, - { "xattr_cache", &ll_xattr_cache_fops, NULL, 0 }, { NULL } }; @@ -847,6 +847,7 @@ static struct attribute *llite_attrs[] = { &lustre_attr_lazystatfs.attr, &lustre_attr_max_easize.attr, &lustre_attr_default_easize.attr, + &lustre_attr_xattr_cache.attr, NULL, }; diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index bf3f82a79a11..ec4ae4726cdc 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -183,3 +183,10 @@ Contact: "Oleg Drokin" Description: Shows maximum observed file striping data seen by this filesystem client instance. + +What: /sys/fs/lustre/llite/-/xattr_cache +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Controls extended attributes client-side cache. + 1 to enable, 0 to disable. From 18fd8850a4c8177ecf4870ff38c208d329a21ed0 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:55 -0400 Subject: [PATCH 0611/1163] staging/lustre/ldlm: Preparation to move /proc/fs/lustre/ldlm to sysfs Add necessary infrastructure, register /sys/fs/lustre/ldlm, /sys/fs/lustre/ldlm/namespaces and /sys/fs/lustre/ldlm/services Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lustre_dlm.h | 6 +++ .../staging/lustre/lustre/ldlm/ldlm_lockd.c | 43 ++++++++++++++++- .../lustre/lustre/ldlm/ldlm_resource.c | 48 ++++++++++++++++++- 3 files changed, 95 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index bac9902b56bb..a52ff0c3ea7e 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -60,6 +60,9 @@ struct obd_ops; struct obd_device; +extern struct kset *ldlm_ns_kset; +extern struct kset *ldlm_svc_kset; + #define OBD_LDLM_DEVICENAME "ldlm" #define LDLM_DEFAULT_LRU_SIZE (100 * num_online_cpus()) @@ -501,6 +504,9 @@ struct ldlm_namespace { * recalculation of LDLM pool statistics should be skipped. */ unsigned ns_stopping:1; + + struct kobject ns_kobj; /* sysfs object */ + struct completion ns_kobj_unregister; }; /** diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 6d731d3eda0a..46f1790d06a3 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -58,6 +58,10 @@ MODULE_PARM_DESC(ldlm_cpts, "CPU partitions ldlm threads should run on"); static struct mutex ldlm_ref_mutex; static int ldlm_refcount; +struct kobject *ldlm_kobj; +struct kset *ldlm_ns_kset; +struct kset *ldlm_svc_kset; + struct ldlm_cb_async_args { struct ldlm_cb_set_arg *ca_set_arg; struct ldlm_lock *ca_lock; @@ -1002,6 +1006,15 @@ void ldlm_destroy_export(struct obd_export *exp) } EXPORT_SYMBOL(ldlm_destroy_export); +/* These are for root of /sys/fs/lustre/ldlm */ +struct attribute *ldlm_attrs[] = { + NULL, +}; + +static struct attribute_group ldlm_attr_group = { + .attrs = ldlm_attrs, +}; + static int ldlm_setup(void) { static struct ptlrpc_service_conf conf; @@ -1016,6 +1029,28 @@ static int ldlm_setup(void) if (ldlm_state == NULL) return -ENOMEM; + ldlm_kobj = kobject_create_and_add("ldlm", lustre_kobj); + if (!ldlm_kobj) { + rc = -ENOMEM; + goto out; + } + + rc = sysfs_create_group(ldlm_kobj, &ldlm_attr_group); + if (rc) + goto out; + + ldlm_ns_kset = kset_create_and_add("namespaces", NULL, ldlm_kobj); + if (!ldlm_ns_kset) { + rc = -ENOMEM; + goto out; + } + + ldlm_svc_kset = kset_create_and_add("services", NULL, ldlm_kobj); + if (!ldlm_svc_kset) { + rc = -ENOMEM; + goto out; + } + rc = ldlm_proc_setup(); if (rc != 0) goto out; @@ -1088,7 +1123,6 @@ static int ldlm_setup(void) goto out; } - rc = ldlm_pools_init(); if (rc) { CERROR("Failed to initialize LDLM pools: %d\n", rc); @@ -1135,6 +1169,13 @@ static int ldlm_cleanup(void) if (ldlm_state->ldlm_cb_service != NULL) ptlrpc_unregister_service(ldlm_state->ldlm_cb_service); + if (ldlm_ns_kset) + kset_unregister(ldlm_ns_kset); + if (ldlm_svc_kset) + kset_unregister(ldlm_svc_kset); + if (ldlm_kobj) + kobject_put(ldlm_kobj); + ldlm_proc_cleanup(); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 7149edab44f4..70d956734a87 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -307,6 +307,24 @@ static ssize_t lprocfs_elc_seq_write(struct file *file, } LPROC_SEQ_FOPS(lprocfs_elc); +/* These are for namespaces in /sys/fs/lustre/ldlm/namespaces/ */ +static struct attribute *ldlm_ns_attrs[] = { + NULL, +}; + +static void ldlm_ns_release(struct kobject *kobj) +{ + struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, + ns_kobj); + complete(&ns->ns_kobj_unregister); +} + +static struct kobj_type ldlm_ns_ktype = { + .default_attrs = ldlm_ns_attrs, + .sysfs_ops = &lustre_sysfs_ops, + .release = ldlm_ns_release, +}; + void ldlm_namespace_proc_unregister(struct ldlm_namespace *ns) { if (ns->ns_proc_dir_entry == NULL) @@ -319,6 +337,12 @@ void ldlm_namespace_proc_unregister(struct ldlm_namespace *ns) lprocfs_free_stats(&ns->ns_stats); } +void ldlm_namespace_sysfs_unregister(struct ldlm_namespace *ns) +{ + kobject_put(&ns->ns_kobj); + wait_for_completion(&ns->ns_kobj_unregister); +} + #define LDLM_NS_ADD_VAR(name, var, ops) \ do { \ snprintf(lock_name, MAX_STRING_SIZE, name); \ @@ -327,6 +351,19 @@ void ldlm_namespace_proc_unregister(struct ldlm_namespace *ns) lprocfs_add_vars(ns_pde, lock_vars, NULL); \ } while (0) + +int ldlm_namespace_sysfs_register(struct ldlm_namespace *ns) +{ + int err; + + ns->ns_kobj.kset = ldlm_ns_kset; + init_completion(&ns->ns_kobj_unregister); + err = kobject_init_and_add(&ns->ns_kobj, &ldlm_ns_ktype, NULL, + "%s", ldlm_ns_name(ns)); + + return err; +} + int ldlm_namespace_proc_register(struct ldlm_namespace *ns) { struct lprocfs_vars lock_vars[2]; @@ -636,10 +673,17 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, ns->ns_orig_connect_flags = 0; ns->ns_connect_flags = 0; ns->ns_stopping = 0; + + rc = ldlm_namespace_sysfs_register(ns); + if (rc != 0) { + CERROR("Can't initialize ns sysfs, rc %d\n", rc); + goto out_hash; + } + rc = ldlm_namespace_proc_register(ns); if (rc != 0) { CERROR("Can't initialize ns proc, rc %d\n", rc); - goto out_hash; + goto out_sysfs; } idx = ldlm_namespace_nr_read(client); @@ -653,6 +697,8 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, return ns; out_proc: ldlm_namespace_proc_unregister(ns); +out_sysfs: + ldlm_namespace_sysfs_unregister(ns); ldlm_namespace_cleanup(ns, 0); out_hash: cfs_hash_putref(ns->ns_rs_hash); From 0f53c823f9664683ce1aadab2d6a4cee950d6f62 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:56 -0400 Subject: [PATCH 0612/1163] staging/lustre/ldlm: move cancel_unused_locks_before_replay to sysfs /proc/fs/lustre/ldlm/cancel_unused_locks_before_replay is moved to /sys/fs/lustre/ldlm/cancel_unused_locks_before_replay Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/ldlm/ldlm_lockd.c | 29 ++++++++++++++++++- .../lustre/lustre/ldlm/ldlm_resource.c | 4 --- drivers/staging/lustre/sysfs-fs-lustre | 10 +++++++ 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 46f1790d06a3..151d60d45baa 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -1006,8 +1006,35 @@ void ldlm_destroy_export(struct obd_export *exp) } EXPORT_SYMBOL(ldlm_destroy_export); +extern unsigned int ldlm_cancel_unused_locks_before_replay; + +static ssize_t cancel_unused_locks_before_replay_show(struct kobject *kobj, + struct attribute *attr, + char *buf) +{ + return sprintf(buf, "%d\n", ldlm_cancel_unused_locks_before_replay); +} +static ssize_t cancel_unused_locks_before_replay_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) +{ + int rc; + unsigned long val; + + rc = kstrtoul(buffer, 10, &val); + if (rc) + return rc; + + ldlm_cancel_unused_locks_before_replay = val; + + return count; +} +LUSTRE_RW_ATTR(cancel_unused_locks_before_replay); + /* These are for root of /sys/fs/lustre/ldlm */ -struct attribute *ldlm_attrs[] = { +static struct attribute *ldlm_attrs[] = { + &lustre_attr_cancel_unused_locks_before_replay.attr, NULL, }; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 70d956734a87..ad3e0b3a5d0a 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -65,8 +65,6 @@ struct proc_dir_entry *ldlm_type_proc_dir = NULL; static struct proc_dir_entry *ldlm_ns_proc_dir = NULL; struct proc_dir_entry *ldlm_svc_proc_dir = NULL; -extern unsigned int ldlm_cancel_unused_locks_before_replay; - /* during debug dump certain amount of granted locks for one resource to avoid * DDOS. */ unsigned int ldlm_dump_granted_max = 256; @@ -91,8 +89,6 @@ int ldlm_proc_setup(void) { "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, - &ldlm_cancel_unused_locks_before_replay }, { NULL } }; LASSERT(ldlm_ns_proc_dir == NULL); diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index ec4ae4726cdc..efe3440ae1f1 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -190,3 +190,13 @@ Contact: "Oleg Drokin" Description: Controls extended attributes client-side cache. 1 to enable, 0 to disable. + +What: /sys/fs/lustre/ldlm/cancel_unused_locks_before_replay +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Controls if client should replay unused locks during recovery + If a client tends to have a lot of unused locks in LRU, + recovery times might become prolonged. + 1 - just locally cancel unused locks (default) + 0 - replay unused locks. From 61d4a2e4b061179512fd4b240024a14646bb7b09 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:57 -0400 Subject: [PATCH 0613/1163] staging/lustre/ldlm: move namespaces/resource_count to sysfs Move ldlm display of resource_count from procfs to sysfs Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 12 +++++++----- drivers/staging/lustre/sysfs-fs-lustre | 7 +++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index ad3e0b3a5d0a..f88b1896fbaa 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -150,9 +150,11 @@ void ldlm_proc_cleanup(void) ldlm_ns_proc_dir = NULL; } -static int lprocfs_ns_resources_seq_show(struct seq_file *m, void *v) +static ssize_t resource_count_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct ldlm_namespace *ns = m->private; + struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, + ns_kobj); __u64 res = 0; struct cfs_hash_bd bd; int i; @@ -160,9 +162,9 @@ static int lprocfs_ns_resources_seq_show(struct seq_file *m, void *v) /* result is not strictly consistent */ cfs_hash_for_each_bucket(ns->ns_rs_hash, &bd, i) res += cfs_hash_bd_count_get(&bd); - return lprocfs_rd_u64(m, &res); + return sprintf(buf, "%lld\n", res); } -LPROC_SEQ_FOPS_RO(lprocfs_ns_resources); +LUSTRE_RO_ATTR(resource_count); static int lprocfs_ns_locks_seq_show(struct seq_file *m, void *v) { @@ -305,6 +307,7 @@ LPROC_SEQ_FOPS(lprocfs_elc); /* These are for namespaces in /sys/fs/lustre/ldlm/namespaces/ */ static struct attribute *ldlm_ns_attrs[] = { + &lustre_attr_resource_count.attr, NULL, }; @@ -390,7 +393,6 @@ int ldlm_namespace_proc_register(struct ldlm_namespace *ns) memset(lock_vars, 0, sizeof(lock_vars)); lock_vars[0].name = lock_name; - LDLM_NS_ADD_VAR("resource_count", ns, &lprocfs_ns_resources_fops); LDLM_NS_ADD_VAR("lock_count", ns, &lprocfs_ns_locks_fops); if (ns_is_client(ns)) { diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index efe3440ae1f1..09258694447d 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -200,3 +200,10 @@ Description: recovery times might become prolonged. 1 - just locally cancel unused locks (default) 0 - replay unused locks. + +What: /sys/fs/lustre/ldlm/namespaces//resource_count +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Displays number of lock resources (objects on which individual + locks are taken) currently allocated in this namespace. From 63af1f57474fac888116d896a0c5f17aeb6a702d Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:58 -0400 Subject: [PATCH 0614/1163] staging/lustre/ldlm: move namespace/lock_count to sysfs Move ldlm display of lock_count from procfs to sysfs Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/ldlm/ldlm_resource.c | 29 ++++++++++--------- drivers/staging/lustre/sysfs-fs-lustre | 6 ++++ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index f88b1896fbaa..f47cf4987b02 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -166,16 +166,18 @@ static ssize_t resource_count_show(struct kobject *kobj, struct attribute *attr, } LUSTRE_RO_ATTR(resource_count); -static int lprocfs_ns_locks_seq_show(struct seq_file *m, void *v) +static ssize_t lock_count_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct ldlm_namespace *ns = m->private; + struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, + ns_kobj); __u64 locks; locks = lprocfs_stats_collector(ns->ns_stats, LDLM_NSS_LOCKS, LPROCFS_FIELDS_FLAGS_SUM); - return lprocfs_rd_u64(m, &locks); + return sprintf(buf, "%lld\n", locks); } -LPROC_SEQ_FOPS_RO(lprocfs_ns_locks); +LUSTRE_RO_ATTR(lock_count); static int lprocfs_lru_size_seq_show(struct seq_file *m, void *v) { @@ -308,6 +310,7 @@ LPROC_SEQ_FOPS(lprocfs_elc); /* These are for namespaces in /sys/fs/lustre/ldlm/namespaces/ */ static struct attribute *ldlm_ns_attrs[] = { &lustre_attr_resource_count.attr, + &lustre_attr_lock_count.attr, NULL, }; @@ -360,6 +363,15 @@ int ldlm_namespace_sysfs_register(struct ldlm_namespace *ns) err = kobject_init_and_add(&ns->ns_kobj, &ldlm_ns_ktype, NULL, "%s", ldlm_ns_name(ns)); + ns->ns_stats = lprocfs_alloc_stats(LDLM_NSS_LAST, 0); + if (ns->ns_stats == NULL) { + kobject_put(&ns->ns_kobj); + return -ENOMEM; + } + + lprocfs_counter_init(ns->ns_stats, LDLM_NSS_LOCKS, + LPROCFS_CNTR_AVGMINMAX, "locks", "locks"); + return err; } @@ -381,20 +393,11 @@ int ldlm_namespace_proc_register(struct ldlm_namespace *ns) ns->ns_proc_dir_entry = ns_pde; } - ns->ns_stats = lprocfs_alloc_stats(LDLM_NSS_LAST, 0); - if (ns->ns_stats == NULL) - return -ENOMEM; - - lprocfs_counter_init(ns->ns_stats, LDLM_NSS_LOCKS, - LPROCFS_CNTR_AVGMINMAX, "locks", "locks"); - lock_name[MAX_STRING_SIZE] = '\0'; memset(lock_vars, 0, sizeof(lock_vars)); lock_vars[0].name = lock_name; - LDLM_NS_ADD_VAR("lock_count", ns, &lprocfs_ns_locks_fops); - if (ns_is_client(ns)) { LDLM_NS_ADD_VAR("lock_unused_count", &ns->ns_nr_unused, &ldlm_uint_fops); diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index 09258694447d..4541b6acda05 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -207,3 +207,9 @@ Contact: "Oleg Drokin" Description: Displays number of lock resources (objects on which individual locks are taken) currently allocated in this namespace. + +What: /sys/fs/lustre/ldlm/namespaces//lock_count +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Displays number or locks allocated in this namespace. From 6784096b4818636ad512575c701e164e8e6a09d3 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:31:59 -0400 Subject: [PATCH 0615/1163] staging/lustre/ldlm: move namespaces/lru_size to sysfs Move ldlm display of lru_size from procfs to sysfs Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/ldlm/ldlm_resource.c | 31 +++++++++---------- drivers/staging/lustre/sysfs-fs-lustre | 9 ++++++ 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index f47cf4987b02..4bba67874adb 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -179,31 +179,28 @@ static ssize_t lock_count_show(struct kobject *kobj, struct attribute *attr, } LUSTRE_RO_ATTR(lock_count); -static int lprocfs_lru_size_seq_show(struct seq_file *m, void *v) +static ssize_t lru_size_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct ldlm_namespace *ns = m->private; + struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, + ns_kobj); __u32 *nr = &ns->ns_max_unused; if (ns_connect_lru_resize(ns)) nr = &ns->ns_nr_unused; - return lprocfs_rd_uint(m, nr); + return sprintf(buf, "%u", *nr); } -static ssize_t lprocfs_lru_size_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t lru_size_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) { - struct ldlm_namespace *ns = ((struct seq_file *)file->private_data)->private; - char dummy[MAX_STRING_SIZE + 1]; + struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, + ns_kobj); unsigned long tmp; int lru_resize; int err; - dummy[MAX_STRING_SIZE] = '\0'; - if (copy_from_user(dummy, buffer, MAX_STRING_SIZE)) - return -EFAULT; - - if (strncmp(dummy, "clear", 5) == 0) { + if (strncmp(buffer, "clear", 5) == 0) { CDEBUG(D_DLMTRACE, "dropping all unused locks from namespace %s\n", ldlm_ns_name(ns)); @@ -229,9 +226,9 @@ static ssize_t lprocfs_lru_size_seq_write(struct file *file, return count; } - err = kstrtoul(dummy, 10, &tmp); + err = kstrtoul(buffer, 10, &tmp); if (err != 0) { - CERROR("invalid value written\n"); + CERROR("lru_size: invalid value written\n"); return -EINVAL; } lru_resize = (tmp == 0); @@ -277,7 +274,7 @@ static ssize_t lprocfs_lru_size_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(lprocfs_lru_size); +LUSTRE_RW_ATTR(lru_size); static int lprocfs_elc_seq_show(struct seq_file *m, void *v) { @@ -311,6 +308,7 @@ LPROC_SEQ_FOPS(lprocfs_elc); static struct attribute *ldlm_ns_attrs[] = { &lustre_attr_resource_count.attr, &lustre_attr_lock_count.attr, + &lustre_attr_lru_size.attr, NULL, }; @@ -401,7 +399,6 @@ int ldlm_namespace_proc_register(struct ldlm_namespace *ns) if (ns_is_client(ns)) { LDLM_NS_ADD_VAR("lock_unused_count", &ns->ns_nr_unused, &ldlm_uint_fops); - LDLM_NS_ADD_VAR("lru_size", ns, &lprocfs_lru_size_fops); LDLM_NS_ADD_VAR("lru_max_age", &ns->ns_max_age, &ldlm_rw_uint_fops); LDLM_NS_ADD_VAR("early_lock_cancel", ns, &lprocfs_elc_fops); diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index 4541b6acda05..0d379d0a6bb7 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -213,3 +213,12 @@ Date: May 2015 Contact: "Oleg Drokin" Description: Displays number or locks allocated in this namespace. + +What: /sys/fs/lustre/ldlm/namespaces//lru_size +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Controls and displays LRU size limit for unused locks for this + namespace. + 0 - LRU size is unlimited, controlled by server resources + positive number - number of locks to allow in lock LRU list From 87d32094efc208f31e4e3b226d25e58058352208 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:32:00 -0400 Subject: [PATCH 0616/1163] staging/lustre/ldlm: move namespaces/early_lock_cancel to sysfs Move ldlm display of early_lock_cancel from procfs to sysfs Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/ldlm/ldlm_resource.c | 28 +++++++++++-------- drivers/staging/lustre/sysfs-fs-lustre | 13 +++++++++ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 4bba67874adb..667f2ca383a1 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -276,23 +276,27 @@ static ssize_t lru_size_store(struct kobject *kobj, struct attribute *attr, } LUSTRE_RW_ATTR(lru_size); -static int lprocfs_elc_seq_show(struct seq_file *m, void *v) +static ssize_t early_lock_cancel_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct ldlm_namespace *ns = m->private; - unsigned int supp = ns_connect_cancelset(ns); + struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, + ns_kobj); - return lprocfs_rd_uint(m, &supp); + return sprintf(buf, "%d\n", ns_connect_cancelset(ns)); } -static ssize_t lprocfs_elc_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t early_lock_cancel_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct ldlm_namespace *ns = ((struct seq_file *)file->private_data)->private; - unsigned int supp = -1; + struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, + ns_kobj); + unsigned long supp = -1; int rc; - rc = lprocfs_wr_uint(file, buffer, count, &supp); + rc = kstrtoul(buffer, 10, &supp); if (rc < 0) return rc; @@ -302,13 +306,14 @@ static ssize_t lprocfs_elc_seq_write(struct file *file, ns->ns_connect_flags |= OBD_CONNECT_CANCELSET; return count; } -LPROC_SEQ_FOPS(lprocfs_elc); +LUSTRE_RW_ATTR(early_lock_cancel); /* These are for namespaces in /sys/fs/lustre/ldlm/namespaces/ */ static struct attribute *ldlm_ns_attrs[] = { &lustre_attr_resource_count.attr, &lustre_attr_lock_count.attr, &lustre_attr_lru_size.attr, + &lustre_attr_early_lock_cancel.attr, NULL, }; @@ -401,7 +406,6 @@ int ldlm_namespace_proc_register(struct ldlm_namespace *ns) &ldlm_uint_fops); LDLM_NS_ADD_VAR("lru_max_age", &ns->ns_max_age, &ldlm_rw_uint_fops); - LDLM_NS_ADD_VAR("early_lock_cancel", ns, &lprocfs_elc_fops); } else { LDLM_NS_ADD_VAR("ctime_age_limit", &ns->ns_ctime_age_limit, &ldlm_rw_uint_fops); diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index 0d379d0a6bb7..e54e4857dd53 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -222,3 +222,16 @@ Description: namespace. 0 - LRU size is unlimited, controlled by server resources positive number - number of locks to allow in lock LRU list + +What: /sys/fs/lustre/ldlm/namespaces//early_lock_cancel +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Controls "early lock cancellation" feature on this namespace + if supported by the server. + When enabled, tries to preemtively cancel locks that would be + cancelled by verious operations and bundle the cancellation + requests in the same RPC as the main operation, which results + in significant speedups due to reduced lock-pingpong RPCs. + 0 - disabled + 1 - enabled (default) From 3dd4598271fc119a4e3c5589be03f88a41c31e64 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:32:01 -0400 Subject: [PATCH 0617/1163] staging/lustre/ldlm: move namespaces/lock_unused_count to sysfs Move ldlm display of lock_unused_count from procfs to sysfs Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 14 ++++++++++++-- drivers/staging/lustre/sysfs-fs-lustre | 7 +++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 667f2ca383a1..fba09e454dce 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -179,6 +179,17 @@ static ssize_t lock_count_show(struct kobject *kobj, struct attribute *attr, } LUSTRE_RO_ATTR(lock_count); +static ssize_t lock_unused_count_show(struct kobject *kobj, + struct attribute *attr, + char *buf) +{ + struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, + ns_kobj); + + return sprintf(buf, "%d\n", ns->ns_nr_unused); +} +LUSTRE_RO_ATTR(lock_unused_count); + static ssize_t lru_size_show(struct kobject *kobj, struct attribute *attr, char *buf) { @@ -312,6 +323,7 @@ LUSTRE_RW_ATTR(early_lock_cancel); static struct attribute *ldlm_ns_attrs[] = { &lustre_attr_resource_count.attr, &lustre_attr_lock_count.attr, + &lustre_attr_lock_unused_count.attr, &lustre_attr_lru_size.attr, &lustre_attr_early_lock_cancel.attr, NULL, @@ -402,8 +414,6 @@ int ldlm_namespace_proc_register(struct ldlm_namespace *ns) lock_vars[0].name = lock_name; if (ns_is_client(ns)) { - LDLM_NS_ADD_VAR("lock_unused_count", &ns->ns_nr_unused, - &ldlm_uint_fops); LDLM_NS_ADD_VAR("lru_max_age", &ns->ns_max_age, &ldlm_rw_uint_fops); } else { diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index e54e4857dd53..f92f7cf65e7e 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -223,6 +223,13 @@ Description: 0 - LRU size is unlimited, controlled by server resources positive number - number of locks to allow in lock LRU list +What: /sys/fs/lustre/ldlm/namespaces//lock_unused_count +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Display number of locks currently sitting in the LRU list + of this namespace + What: /sys/fs/lustre/ldlm/namespaces//early_lock_cancel Date: May 2015 Contact: "Oleg Drokin" From c841236dda9aa334f7e241e3c526360328f77343 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:32:02 -0400 Subject: [PATCH 0618/1163] staging/lustre/ldlm: move namespaces/lru_max_age to sysfs Move ldlm display of lru_max_age from procfs to sysfs Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/ldlm/ldlm_resource.c | 30 +++++++++++++++++-- drivers/staging/lustre/sysfs-fs-lustre | 7 +++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index fba09e454dce..9fab434572e7 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -287,6 +287,33 @@ static ssize_t lru_size_store(struct kobject *kobj, struct attribute *attr, } LUSTRE_RW_ATTR(lru_size); +static ssize_t lru_max_age_show(struct kobject *kobj, struct attribute *attr, + char *buf) +{ + struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, + ns_kobj); + + return sprintf(buf, "%u", ns->ns_max_age); +} + +static ssize_t lru_max_age_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) +{ + struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, + ns_kobj); + unsigned long tmp; + int err; + + err = kstrtoul(buffer, 10, &tmp); + if (err != 0) + return -EINVAL; + + ns->ns_max_age = tmp; + + return count; +} +LUSTRE_RW_ATTR(lru_max_age); + static ssize_t early_lock_cancel_show(struct kobject *kobj, struct attribute *attr, char *buf) @@ -325,6 +352,7 @@ static struct attribute *ldlm_ns_attrs[] = { &lustre_attr_lock_count.attr, &lustre_attr_lock_unused_count.attr, &lustre_attr_lru_size.attr, + &lustre_attr_lru_max_age.attr, &lustre_attr_early_lock_cancel.attr, NULL, }; @@ -414,8 +442,6 @@ int ldlm_namespace_proc_register(struct ldlm_namespace *ns) lock_vars[0].name = lock_name; if (ns_is_client(ns)) { - LDLM_NS_ADD_VAR("lru_max_age", &ns->ns_max_age, - &ldlm_rw_uint_fops); } else { LDLM_NS_ADD_VAR("ctime_age_limit", &ns->ns_ctime_age_limit, &ldlm_rw_uint_fops); diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index f92f7cf65e7e..3aaa5ae9e0c4 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -230,6 +230,13 @@ Description: Display number of locks currently sitting in the LRU list of this namespace +What: /sys/fs/lustre/ldlm/namespaces//lru_max_age +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Maximum number of milliseconds a lock could sit in LRU list + before client would voluntarily cancel it as unused. + What: /sys/fs/lustre/ldlm/namespaces//early_lock_cancel Date: May 2015 Contact: "Oleg Drokin" From fa0352f0c10a4ee1044de46bbffb4593dca319ba Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:32:03 -0400 Subject: [PATCH 0619/1163] staging/lustre/ldlm: remove server-side congested locks support This code only makes sense on the server, also while we are at it drop registration of server-side procfs values and as all client side values were already moved to sysfs - also drop now unused procfs helpers. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lustre_dlm.h | 42 ------------------- .../lustre/lustre/ldlm/ldlm_resource.c | 38 ----------------- 2 files changed, 80 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index a52ff0c3ea7e..301b898d79ef 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -67,7 +67,6 @@ extern struct kset *ldlm_svc_kset; #define LDLM_DEFAULT_LRU_SIZE (100 * num_online_cpus()) #define LDLM_DEFAULT_MAX_ALIVE (cfs_time_seconds(36000)) -#define LDLM_CTIME_AGE_LIMIT (10) #define LDLM_DEFAULT_PARALLEL_AST_LIMIT 1024 /** @@ -305,14 +304,6 @@ typedef enum { LDLM_NAMESPACE_MODEST = 1 << 1 } ldlm_appetite_t; -/** - * Default values for the "max_nolock_size", "contention_time" and - * "contended_locks" namespace tunables. - */ -#define NS_DEFAULT_MAX_NOLOCK_BYTES 0 -#define NS_DEFAULT_CONTENTION_SECONDS 2 -#define NS_DEFAULT_CONTENDED_LOCKS 32 - struct ldlm_ns_bucket { /** back pointer to namespace */ struct ldlm_namespace *nsb_namespace; @@ -424,18 +415,6 @@ struct ldlm_namespace { unsigned int ns_max_unused; /** Maximum allowed age (last used time) for locks in the LRU */ unsigned int ns_max_age; - /** - * Server only: number of times we evicted clients due to lack of reply - * to ASTs. - */ - unsigned int ns_timeouts; - /** - * Number of seconds since the file change time after which the - * MDT will return an UPDATE lock along with a LOOKUP lock. - * This allows the client to start caching negative dentries - * for a directory and may save an RPC for a later stat. - */ - unsigned int ns_ctime_age_limit; /** * Used to rate-limit ldlm_namespace_dump calls. @@ -469,27 +448,6 @@ struct ldlm_namespace { /** Definition of how eagerly unused locks will be released from LRU */ ldlm_appetite_t ns_appetite; - /** - * If more than \a ns_contended_locks are found, the resource is - * considered to be contended. Lock enqueues might specify that no - * contended locks should be granted - */ - unsigned ns_contended_locks; - - /** - * The resources in this namespace remember contended state during - * \a ns_contention_time, in seconds. - */ - unsigned ns_contention_time; - - /** - * Limit size of contended extent locks, in bytes. - * If extended lock is requested for more then this many bytes and - * caller instructs us not to grant contended locks, we would disregard - * such a request. - */ - unsigned ns_max_nolock_size; - /** Limit of parallel AST RPC count. */ unsigned ns_max_parallel_ast; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 9fab434572e7..1e3190fa637b 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -80,7 +80,6 @@ static ssize_t lprocfs_wr_dump_ns(struct file *file, const char __user *buffer, LPROC_SEQ_FOPS_WR_ONLY(ldlm, dump_ns); LPROC_SEQ_FOPS_RW_TYPE(ldlm_rw, uint); -LPROC_SEQ_FOPS_RO_TYPE(ldlm, uint); int ldlm_proc_setup(void) { @@ -388,15 +387,6 @@ void ldlm_namespace_sysfs_unregister(struct ldlm_namespace *ns) wait_for_completion(&ns->ns_kobj_unregister); } -#define LDLM_NS_ADD_VAR(name, var, ops) \ - do { \ - snprintf(lock_name, MAX_STRING_SIZE, name); \ - lock_vars[0].data = var; \ - lock_vars[0].fops = ops; \ - lprocfs_add_vars(ns_pde, lock_vars, NULL); \ - } while (0) - - int ldlm_namespace_sysfs_register(struct ldlm_namespace *ns) { int err; @@ -420,8 +410,6 @@ int ldlm_namespace_sysfs_register(struct ldlm_namespace *ns) int ldlm_namespace_proc_register(struct ldlm_namespace *ns) { - struct lprocfs_vars lock_vars[2]; - char lock_name[MAX_STRING_SIZE + 1]; struct proc_dir_entry *ns_pde; LASSERT(ns != NULL); @@ -436,26 +424,6 @@ int ldlm_namespace_proc_register(struct ldlm_namespace *ns) ns->ns_proc_dir_entry = ns_pde; } - lock_name[MAX_STRING_SIZE] = '\0'; - - memset(lock_vars, 0, sizeof(lock_vars)); - lock_vars[0].name = lock_name; - - if (ns_is_client(ns)) { - } else { - LDLM_NS_ADD_VAR("ctime_age_limit", &ns->ns_ctime_age_limit, - &ldlm_rw_uint_fops); - LDLM_NS_ADD_VAR("lock_timeouts", &ns->ns_timeouts, - &ldlm_uint_fops); - LDLM_NS_ADD_VAR("max_nolock_bytes", &ns->ns_max_nolock_size, - &ldlm_rw_uint_fops); - LDLM_NS_ADD_VAR("contention_seconds", &ns->ns_contention_time, - &ldlm_rw_uint_fops); - LDLM_NS_ADD_VAR("contended_locks", &ns->ns_contended_locks, - &ldlm_rw_uint_fops); - LDLM_NS_ADD_VAR("max_parallel_ast", &ns->ns_max_parallel_ast, - &ldlm_rw_uint_fops); - } return 0; } #undef MAX_STRING_SIZE @@ -698,16 +666,10 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, atomic_set(&ns->ns_bref, 0); init_waitqueue_head(&ns->ns_waitq); - ns->ns_max_nolock_size = NS_DEFAULT_MAX_NOLOCK_BYTES; - ns->ns_contention_time = NS_DEFAULT_CONTENTION_SECONDS; - ns->ns_contended_locks = NS_DEFAULT_CONTENDED_LOCKS; - ns->ns_max_parallel_ast = LDLM_DEFAULT_PARALLEL_AST_LIMIT; ns->ns_nr_unused = 0; ns->ns_max_unused = LDLM_DEFAULT_LRU_SIZE; ns->ns_max_age = LDLM_DEFAULT_MAX_ALIVE; - ns->ns_ctime_age_limit = LDLM_CTIME_AGE_LIMIT; - ns->ns_timeouts = 0; ns->ns_orig_connect_flags = 0; ns->ns_connect_flags = 0; ns->ns_stopping = 0; From f2825e039e1a6b58411087e1e17638f872d00a93 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:32:04 -0400 Subject: [PATCH 0620/1163] staging/lustre/ldlm: Add infrastructure to move ldlm pool controls to sysfs This adds registration of /sys/fs/lustre/ldlm/namespaces/.../pool dir. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lustre_dlm.h | 4 ++ .../staging/lustre/lustre/ldlm/ldlm_pool.c | 45 ++++++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index 301b898d79ef..b1e7d55ba674 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -265,6 +265,10 @@ struct ldlm_pool { int pl_grant_plan; /** Pool statistics. */ struct lprocfs_stats *pl_stats; + + /* sysfs object */ + struct kobject pl_kobj; + struct completion pl_kobj_unregister; }; typedef int (*ldlm_res_policy)(struct ldlm_namespace *, struct ldlm_lock **, diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 53e1377873cd..0968868a8bb1 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -90,10 +90,10 @@ * pl_server_lock_volume - Current server lock volume (calculated); * * As it may be seen from list above, we have few possible tunables which may - * affect behavior much. They all may be modified via proc. However, they also + * affect behavior much. They all may be modified via sysfs. However, they also * give a possibility for constructing few pre-defined behavior policies. If * none of predefines is suitable for a working pattern being used, new one may - * be "constructed" via proc tunables. + * be "constructed" via sysfs tunables. */ #define DEBUG_SUBSYSTEM S_LDLM @@ -738,6 +738,36 @@ LPROC_SEQ_FOPS_RO(lprocfs_grant_speed); lprocfs_add_vars(pl->pl_proc_dir, pool_vars, NULL);\ } while (0) +/* These are for pools in /sys/fs/lustre/ldlm/namespaces/.../pool */ +static struct attribute *ldlm_pl_attrs[] = { + NULL, +}; + +static void ldlm_pl_release(struct kobject *kobj) +{ + struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool, + pl_kobj); + complete(&pl->pl_kobj_unregister); +} + +static struct kobj_type ldlm_pl_ktype = { + .default_attrs = ldlm_pl_attrs, + .sysfs_ops = &lustre_sysfs_ops, + .release = ldlm_pl_release, +}; + +static int ldlm_pool_sysfs_init(struct ldlm_pool *pl) +{ + struct ldlm_namespace *ns = ldlm_pl2ns(pl); + int err; + + init_completion(&pl->pl_kobj_unregister); + err = kobject_init_and_add(&pl->pl_kobj, &ldlm_pl_ktype, &ns->ns_kobj, + "pool"); + + return err; +} + static int ldlm_pool_proc_init(struct ldlm_pool *pl) { struct ldlm_namespace *ns = ldlm_pl2ns(pl); @@ -832,6 +862,12 @@ out_free_name: return rc; } +static void ldlm_pool_sysfs_fini(struct ldlm_pool *pl) +{ + kobject_put(&pl->pl_kobj); + wait_for_completion(&pl->pl_kobj_unregister); +} + static void ldlm_pool_proc_fini(struct ldlm_pool *pl) { if (pl->pl_stats != NULL) { @@ -885,6 +921,10 @@ int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns, if (rc) return rc; + rc = ldlm_pool_sysfs_init(pl); + if (rc) + return rc; + CDEBUG(D_DLMTRACE, "Lock pool %s is initialized\n", pl->pl_name); return rc; @@ -893,6 +933,7 @@ EXPORT_SYMBOL(ldlm_pool_init); void ldlm_pool_fini(struct ldlm_pool *pl) { + ldlm_pool_sysfs_fini(pl); ldlm_pool_proc_fini(pl); /* From 24b8c88a7122df35ce6a413cd76e9581411eab8f Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:32:05 -0400 Subject: [PATCH 0621/1163] staging/lustre/ldlm: move procfs ldlm pool stats to sysfs Suitable contents of /proc/fs/lustre/ldlm/namespaces/.../pools/ is moved to /sys/fs/lustre/ldlm/namespaces/.../pools/: cancel_rate grant_plan grant_speed lock_volume_factor server_lock_volume granted grant_rate limit recalc_period Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/ldlm/ldlm_internal.h | 73 +++++++++++++++---- .../staging/lustre/lustre/ldlm/ldlm_pool.c | 70 ++++++++++-------- drivers/staging/lustre/sysfs-fs-lustre | 62 ++++++++++++++++ 3 files changed, 159 insertions(+), 46 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index 70b909f55861..636451d29ef9 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h @@ -238,40 +238,85 @@ enum ldlm_policy_res { typedef enum ldlm_policy_res ldlm_policy_res_t; -#define LDLM_POOL_PROC_READER_SEQ_SHOW(var, type) \ - static int lprocfs_##var##_seq_show(struct seq_file *m, void *v) \ +#define LDLM_POOL_SYSFS_PRINT_int(v) sprintf(buf, "%d\n", v) +#define LDLM_POOL_SYSFS_SET_int(a, b) { a = b; } +#define LDLM_POOL_SYSFS_PRINT_u64(v) sprintf(buf, "%lld\n", v) +#define LDLM_POOL_SYSFS_SET_u64(a, b) { a = b; } +#define LDLM_POOL_SYSFS_PRINT_atomic(v) sprintf(buf, "%d\n", atomic_read(&v)) +#define LDLM_POOL_SYSFS_SET_atomic(a, b) atomic_set(&a, b) + +#define LDLM_POOL_SYSFS_READER_SHOW(var, type) \ + static ssize_t var##_show(struct kobject *kobj, \ + struct attribute *attr, \ + char *buf) \ { \ - struct ldlm_pool *pl = m->private; \ + struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool, \ + pl_kobj); \ type tmp; \ \ spin_lock(&pl->pl_lock); \ tmp = pl->pl_##var; \ spin_unlock(&pl->pl_lock); \ \ - return lprocfs_rd_uint(m, &tmp); \ + return LDLM_POOL_SYSFS_PRINT_##type(tmp); \ } \ struct __##var##__dummy_read {; } /* semicolon catcher */ -#define LDLM_POOL_PROC_WRITER(var, type) \ - static int lprocfs_wr_##var(struct file *file, \ - const char __user *buffer, \ - unsigned long count, void *data) \ +#define LDLM_POOL_SYSFS_WRITER_STORE(var, type) \ + static ssize_t var##_store(struct kobject *kobj, \ + struct attribute *attr, \ + const char *buffer, \ + unsigned long count) \ { \ - struct ldlm_pool *pl = data; \ - type tmp; \ + struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool, \ + pl_kobj); \ + unsigned long tmp; \ int rc; \ \ - rc = lprocfs_wr_uint(file, buffer, count, &tmp); \ + rc = kstrtoul(buffer, 10, &tmp); \ if (rc < 0) { \ - CERROR("Can't parse user input, rc = %d\n", rc); \ return rc; \ } \ \ spin_lock(&pl->pl_lock); \ - pl->pl_##var = tmp; \ + LDLM_POOL_SYSFS_SET_##type(pl->pl_##var, tmp); \ spin_unlock(&pl->pl_lock); \ \ - return rc; \ + return count; \ + } \ + struct __##var##__dummy_write {; } /* semicolon catcher */ + +#define LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(var, type) \ + static ssize_t var##_show(struct kobject *kobj, \ + struct attribute *attr, \ + char *buf) \ + { \ + struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool, \ + pl_kobj); \ + \ + return LDLM_POOL_SYSFS_PRINT_##type(pl->pl_##var); \ + } \ + struct __##var##__dummy_read {; } /* semicolon catcher */ + +#define LDLM_POOL_SYSFS_WRITER_NOLOCK_STORE(var, type) \ + static ssize_t var##_store(struct kobject *kobj, \ + struct attribute *attr, \ + const char *buffer, \ + unsigned long count) \ + { \ + struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool, \ + pl_kobj); \ + unsigned long tmp; \ + int rc; \ + \ + rc = kstrtoul(buffer, 10, &tmp); \ + if (rc < 0) { \ + return rc; \ + } \ + \ + LDLM_POOL_SYSFS_SET_##type(pl->pl_##var, tmp); \ + \ + return count; \ } \ struct __##var##__dummy_write {; } /* semicolon catcher */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 0968868a8bb1..ed7473594a60 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -696,9 +696,12 @@ static int lprocfs_pool_state_seq_show(struct seq_file *m, void *unused) } LPROC_SEQ_FOPS_RO(lprocfs_pool_state); -static int lprocfs_grant_speed_seq_show(struct seq_file *m, void *unused) +static ssize_t grant_speed_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct ldlm_pool *pl = m->private; + struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool, + pl_kobj); + int grant_speed; spin_lock(&pl->pl_lock); @@ -706,29 +709,36 @@ static int lprocfs_grant_speed_seq_show(struct seq_file *m, void *unused) grant_speed = atomic_read(&pl->pl_grant_rate) - atomic_read(&pl->pl_cancel_rate); spin_unlock(&pl->pl_lock); - return lprocfs_rd_uint(m, &grant_speed); + return sprintf(buf, "%d\n", grant_speed); } +LUSTRE_RO_ATTR(grant_speed); -LDLM_POOL_PROC_READER_SEQ_SHOW(grant_plan, int); -LPROC_SEQ_FOPS_RO(lprocfs_grant_plan); +LDLM_POOL_SYSFS_READER_SHOW(grant_plan, int); +LUSTRE_RO_ATTR(grant_plan); -LDLM_POOL_PROC_READER_SEQ_SHOW(recalc_period, int); -LDLM_POOL_PROC_WRITER(recalc_period, int); -static ssize_t lprocfs_recalc_period_seq_write(struct file *file, - const char __user *buf, - size_t len, loff_t *off) -{ - struct seq_file *seq = file->private_data; +LDLM_POOL_SYSFS_READER_SHOW(recalc_period, int); +LDLM_POOL_SYSFS_WRITER_STORE(recalc_period, int); +LUSTRE_RW_ATTR(recalc_period); - return lprocfs_wr_recalc_period(file, buf, len, seq->private); -} -LPROC_SEQ_FOPS(lprocfs_recalc_period); +LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(server_lock_volume, u64); +LUSTRE_RO_ATTR(server_lock_volume); -LPROC_SEQ_FOPS_RO_TYPE(ldlm_pool, u64); -LPROC_SEQ_FOPS_RO_TYPE(ldlm_pool, atomic); -LPROC_SEQ_FOPS_RW_TYPE(ldlm_pool_rw, atomic); +LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(limit, atomic); +LDLM_POOL_SYSFS_WRITER_NOLOCK_STORE(limit, atomic); +LUSTRE_RW_ATTR(limit); -LPROC_SEQ_FOPS_RO(lprocfs_grant_speed); +LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(granted, atomic); +LUSTRE_RO_ATTR(granted); + +LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(cancel_rate, atomic); +LUSTRE_RO_ATTR(cancel_rate); + +LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(grant_rate, atomic); +LUSTRE_RO_ATTR(grant_rate); + +LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(lock_volume_factor, atomic); +LDLM_POOL_SYSFS_WRITER_NOLOCK_STORE(lock_volume_factor, atomic); +LUSTRE_RW_ATTR(lock_volume_factor); #define LDLM_POOL_ADD_VAR(name, var, ops) \ do { \ @@ -740,6 +750,15 @@ LPROC_SEQ_FOPS_RO(lprocfs_grant_speed); /* These are for pools in /sys/fs/lustre/ldlm/namespaces/.../pool */ static struct attribute *ldlm_pl_attrs[] = { + &lustre_attr_grant_speed.attr, + &lustre_attr_grant_plan.attr, + &lustre_attr_recalc_period.attr, + &lustre_attr_server_lock_volume.attr, + &lustre_attr_limit.attr, + &lustre_attr_granted.attr, + &lustre_attr_cancel_rate.attr, + &lustre_attr_grant_rate.attr, + &lustre_attr_lock_volume_factor.attr, NULL, }; @@ -800,19 +819,6 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl) memset(pool_vars, 0, sizeof(pool_vars)); pool_vars[0].name = var_name; - LDLM_POOL_ADD_VAR("server_lock_volume", &pl->pl_server_lock_volume, - &ldlm_pool_u64_fops); - LDLM_POOL_ADD_VAR("limit", &pl->pl_limit, &ldlm_pool_rw_atomic_fops); - LDLM_POOL_ADD_VAR("granted", &pl->pl_granted, &ldlm_pool_atomic_fops); - LDLM_POOL_ADD_VAR("grant_speed", pl, &lprocfs_grant_speed_fops); - LDLM_POOL_ADD_VAR("cancel_rate", &pl->pl_cancel_rate, - &ldlm_pool_atomic_fops); - LDLM_POOL_ADD_VAR("grant_rate", &pl->pl_grant_rate, - &ldlm_pool_atomic_fops); - LDLM_POOL_ADD_VAR("grant_plan", pl, &lprocfs_grant_plan_fops); - LDLM_POOL_ADD_VAR("recalc_period", pl, &lprocfs_recalc_period_fops); - LDLM_POOL_ADD_VAR("lock_volume_factor", &pl->pl_lock_volume_factor, - &ldlm_pool_rw_atomic_fops); LDLM_POOL_ADD_VAR("state", pl, &lprocfs_pool_state_fops); pl->pl_stats = lprocfs_alloc_stats(LDLM_POOL_LAST_STAT - diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index 3aaa5ae9e0c4..39295e84c8fd 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -249,3 +249,65 @@ Description: in significant speedups due to reduced lock-pingpong RPCs. 0 - disabled 1 - enabled (default) + +What: /sys/fs/lustre/ldlm/namespaces//pool/granted +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Displays number of granted locks in this namespace + +What: /sys/fs/lustre/ldlm/namespaces//pool/grant_rate +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Number of granted locks in this namespace during last + time interval + +What: /sys/fs/lustre/ldlm/namespaces//pool/cancel_rate +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Number of lock cancellations in this namespace during + last time interval + +What: /sys/fs/lustre/ldlm/namespaces//pool/grant_speed +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Calculated speed of lock granting (grant_rate - cancel_rate) + in this namespace + +What: /sys/fs/lustre/ldlm/namespaces//pool/grant_plan +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Estimated number of locks to be granted in the next time + interval in this namespace + +What: /sys/fs/lustre/ldlm/namespaces//pool/limit +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Controls number of allowed locks in this pool. + When lru_size is 0, this is the actual limit then. + +What: /sys/fs/lustre/ldlm/namespaces//pool/lock_volume_factor +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Multiplier for all lock volume calculations above. + Default is 1. Increase to make the client to more agressively + clean it's lock LRU list for this namespace. + +What: /sys/fs/lustre/ldlm/namespaces//pool/server_lock_volume +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Calculated server lock volume. + +What: /sys/fs/lustre/ldlm/namespaces//pool/recalc_period +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Controls length of time between recalculation of above + values (in seconds). From 5c8c82f63a11c07a0687d2c71411166017012689 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:32:06 -0400 Subject: [PATCH 0622/1163] staging/lustre: Add debugfs root This is just plumbing for migrating remaining procfs to debugfs support Signed-off-by: Dmitry Eremin Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lprocfs_status.h | 25 ++++- .../lustre/obdclass/linux/linux-module.c | 32 +++++- .../lustre/lustre/obdclass/lprocfs_status.c | 103 +++++++++++++++++- 3 files changed, 153 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index b46cd54f2081..313f39436d09 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -43,6 +43,7 @@ #define _LPROCFS_SNMP_H #include +#include #include #include #include @@ -349,7 +350,7 @@ enum { #define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE /* class_obd.c */ extern struct proc_dir_entry *proc_lustre_root; - +extern struct dentry *debugfs_lustre_root; extern struct kobject *lustre_kobj; struct obd_device; @@ -577,19 +578,30 @@ lprocfs_nid_stats_clear_write(struct file *file, const char *buffer, unsigned long count, void *data); extern int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data); +extern int ldebugfs_register_stats(struct dentry *parent, + const char *name, + struct lprocfs_stats *stats); extern int lprocfs_register_stats(struct proc_dir_entry *root, const char *name, struct lprocfs_stats *stats); /* lprocfs_status.c */ +extern int ldebugfs_add_vars(struct dentry *parent, + struct lprocfs_vars *var, + void *data); extern int lprocfs_add_vars(struct proc_dir_entry *root, struct lprocfs_vars *var, void *data); +extern struct dentry *ldebugfs_register(const char *name, + struct dentry *parent, + struct lprocfs_vars *list, + void *data); extern struct proc_dir_entry *lprocfs_register(const char *name, struct proc_dir_entry *parent, struct lprocfs_vars *list, void *data); +extern void ldebugfs_remove(struct dentry **entryp); extern void lprocfs_remove(struct proc_dir_entry **root); extern void lprocfs_remove_proc_entry(const char *name, struct proc_dir_entry *parent); @@ -597,6 +609,11 @@ extern void lprocfs_remove_proc_entry(const char *name, extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list); extern int lprocfs_obd_cleanup(struct obd_device *obd); +extern int ldebugfs_seq_create(struct dentry *parent, + const char *name, + umode_t mode, + const struct file_operations *seq_fops, + void *data); extern int lprocfs_seq_create(struct proc_dir_entry *parent, const char *name, umode_t mode, const struct file_operations *seq_fops, @@ -691,7 +708,8 @@ extern int lprocfs_seq_release(struct inode *, struct file *); #define __LPROC_SEQ_FOPS(name, custom_seq_write) \ static int name##_single_open(struct inode *inode, struct file *file) \ { \ - return single_open(file, name##_seq_show, PDE_DATA(inode)); \ + return single_open(file, name##_seq_show, \ + inode->i_private ?: PDE_DATA(inode)); \ } \ static struct file_operations name##_fops = { \ .owner = THIS_MODULE, \ @@ -736,7 +754,8 @@ static struct file_operations name##_fops = { \ } \ static int name##_##type##_open(struct inode *inode, struct file *file) \ { \ - return single_open(file, NULL, PDE_DATA(inode)); \ + return single_open(file, NULL, \ + inode->i_private ?: PDE_DATA(inode));\ } \ static struct file_operations name##_##type##_fops = { \ .open = name##_##type##_open, \ diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index df3aa8fd253e..72113a915298 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -318,6 +318,10 @@ static ssize_t jobid_name_store(struct kobject *kobj, struct attribute *attr, return count; } +/* Root for /sys/kernel/debug/lustre */ +struct dentry *debugfs_lustre_root; +EXPORT_SYMBOL_GPL(debugfs_lustre_root); + #if defined(CONFIG_PROC_FS) /* Root for /proc/fs/lustre */ struct proc_dir_entry *proc_lustre_root = NULL; @@ -426,6 +430,7 @@ static struct attribute_group lustre_attr_group = { int class_procfs_init(void) { int rc = 0; + struct dentry *file; lustre_kobj = kobject_create_and_add("lustre", fs_kobj); if (lustre_kobj == NULL) @@ -438,8 +443,24 @@ int class_procfs_init(void) goto out; } - proc_lustre_root = lprocfs_register("fs/lustre", NULL, - NULL, NULL); + debugfs_lustre_root = debugfs_create_dir("lustre", NULL); + if (IS_ERR_OR_NULL(debugfs_lustre_root)) { + rc = debugfs_lustre_root ? PTR_ERR(debugfs_lustre_root) + : -ENOMEM; + debugfs_lustre_root = NULL; + kobject_put(lustre_kobj); + goto out; + } + + file = debugfs_create_file("devices", 0444, debugfs_lustre_root, NULL, + &obd_device_list_fops); + if (IS_ERR_OR_NULL(file)) { + rc = file ? PTR_ERR(file) : -ENOMEM; + kobject_put(lustre_kobj); + goto out; + } + + proc_lustre_root = lprocfs_register("fs/lustre", NULL, NULL, NULL); if (IS_ERR(proc_lustre_root)) { rc = PTR_ERR(proc_lustre_root); proc_lustre_root = NULL; @@ -452,11 +473,16 @@ int class_procfs_init(void) out: if (rc) CERROR("error adding /proc/fs/lustre/devices file\n"); - return 0; + return rc; } int class_procfs_clean(void) { + if (debugfs_lustre_root != NULL) + debugfs_remove_recursive(debugfs_lustre_root); + + debugfs_lustre_root = NULL; + if (proc_lustre_root) { lprocfs_remove(&proc_lustre_root); } diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 916d0606b2e4..000e8748da4a 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -296,6 +296,37 @@ EXPORT_SYMBOL(lprocfs_add_symlink); static struct file_operations lprocfs_generic_fops = { }; +int ldebugfs_add_vars(struct dentry *parent, + struct lprocfs_vars *list, + void *data) +{ + if (IS_ERR_OR_NULL(parent) || IS_ERR_OR_NULL(list)) + return -EINVAL; + + while (list->name != NULL) { + struct dentry *entry; + umode_t mode = 0; + + if (list->proc_mode != 0000) { + mode = list->proc_mode; + } else if (list->fops) { + if (list->fops->read) + mode = 0444; + if (list->fops->write) + mode |= 0200; + } + entry = debugfs_create_file(list->name, mode, parent, + list->data ?: data, + list->fops ?: &lprocfs_generic_fops + ); + if (IS_ERR_OR_NULL(entry)) + return entry ? PTR_ERR(entry) : -ENOMEM; + list++; + } + return 0; +} +EXPORT_SYMBOL(ldebugfs_add_vars); + /** * Add /proc entries. * @@ -336,6 +367,13 @@ int lprocfs_add_vars(struct proc_dir_entry *root, struct lprocfs_vars *list, } EXPORT_SYMBOL(lprocfs_add_vars); +void ldebugfs_remove(struct dentry **entryp) +{ + debugfs_remove(*entryp); + *entryp = NULL; +} +EXPORT_SYMBOL(ldebugfs_remove); + void lprocfs_remove(struct proc_dir_entry **rooth) { proc_remove(*rooth); @@ -350,6 +388,32 @@ void lprocfs_remove_proc_entry(const char *name, struct proc_dir_entry *parent) } EXPORT_SYMBOL(lprocfs_remove_proc_entry); +struct dentry *ldebugfs_register(const char *name, + struct dentry *parent, + struct lprocfs_vars *list, void *data) +{ + struct dentry *entry; + + entry = debugfs_create_dir(name, parent); + if (IS_ERR_OR_NULL(entry)) { + entry = entry ?: ERR_PTR(-ENOMEM); + goto out; + } + + if (!IS_ERR_OR_NULL(list)) { + int rc; + + rc = ldebugfs_add_vars(entry, list, data); + if (rc != 0) { + debugfs_remove(entry); + entry = ERR_PTR(rc); + } + } +out: + return entry; +} +EXPORT_SYMBOL(ldebugfs_register); + struct proc_dir_entry *lprocfs_register(const char *name, struct proc_dir_entry *parent, struct lprocfs_vars *list, void *data) @@ -1257,8 +1321,10 @@ static int lprocfs_stats_seq_open(struct inode *inode, struct file *file) rc = seq_open(file, &lprocfs_stats_seq_sops); if (rc) return rc; + seq = file->private_data; - seq->private = PDE_DATA(inode); + seq->private = inode->i_private ?: PDE_DATA(inode); + return 0; } @@ -1271,6 +1337,22 @@ struct file_operations lprocfs_stats_seq_fops = { .release = lprocfs_seq_release, }; +int ldebugfs_register_stats(struct dentry *parent, const char *name, + struct lprocfs_stats *stats) +{ + struct dentry *entry; + + LASSERT(!IS_ERR_OR_NULL(parent)); + + entry = debugfs_create_file(name, 0644, parent, stats, + &lprocfs_stats_seq_fops); + if (IS_ERR_OR_NULL(entry)) + return entry ? PTR_ERR(entry) : -ENOMEM; + + return 0; +} +EXPORT_SYMBOL(ldebugfs_register_stats); + int lprocfs_register_stats(struct proc_dir_entry *root, const char *name, struct lprocfs_stats *stats) { @@ -1971,6 +2053,25 @@ char *lprocfs_find_named_value(const char *buffer, const char *name, } EXPORT_SYMBOL(lprocfs_find_named_value); +int ldebugfs_seq_create(struct dentry *parent, + const char *name, + umode_t mode, + const struct file_operations *seq_fops, + void *data) +{ + struct dentry *entry; + + /* Disallow secretly (un)writable entries. */ + LASSERT((seq_fops->write == NULL) == ((mode & 0222) == 0)); + + entry = debugfs_create_file(name, mode, parent, data, seq_fops); + if (IS_ERR_OR_NULL(entry)) + return entry ? PTR_ERR(entry) : -ENOMEM; + + return 0; +} +EXPORT_SYMBOL(ldebugfs_seq_create); + int lprocfs_seq_create(struct proc_dir_entry *parent, const char *name, umode_t mode, From 4361a048743f900bb0710bd7cb36a650d7bef93a Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:32:07 -0400 Subject: [PATCH 0623/1163] staging/lustre: move /proc/fs/lustre/devices to debugfs the devices file prints out status information about all obd devices in the system in human readable form. Signed-off-by: Dmitry Eremin Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/obdclass/linux/linux-module.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index 72113a915298..03a982a9309f 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -407,7 +407,7 @@ static int obd_device_list_open(struct inode *inode, struct file *file) return rc; seq = file->private_data; - seq->private = PDE_DATA(inode); + seq->private = inode->i_private; return 0; } @@ -467,12 +467,7 @@ int class_procfs_init(void) kobject_put(lustre_kobj); goto out; } - - rc = lprocfs_seq_create(proc_lustre_root, "devices", 0444, - &obd_device_list_fops, NULL); out: - if (rc) - CERROR("error adding /proc/fs/lustre/devices file\n"); return rc; } From 328676f823b49741675f8ae47643669a31c79558 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:32:08 -0400 Subject: [PATCH 0624/1163] staging/lustre/ptlrpc: Add infrastructure for sysfs migration Added necessary plumbing for ptlrpc sysfs integration for registered services, sysfs directory registration. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lustre_net.h | 5 +++ .../staging/lustre/lustre/ldlm/ldlm_lockd.c | 3 +- .../lustre/lustre/ptlrpc/lproc_ptlrpc.c | 40 +++++++++++++++++++ .../lustre/lustre/ptlrpc/ptlrpc_internal.h | 4 ++ .../staging/lustre/lustre/ptlrpc/service.c | 8 ++++ 5 files changed, 59 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index e2805bd1acf1..4fc987d4bdb4 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -2016,6 +2016,10 @@ struct ptlrpc_service { int srv_cpt_bits; /** CPT table this service is running over */ struct cfs_cpt_table *srv_cptable; + + /* sysfs object */ + struct kobject srv_kobj; + struct completion srv_kobj_unregister; /** * partition data for ptlrpc service */ @@ -2525,6 +2529,7 @@ void ptlrpc_schedule_difficult_reply(struct ptlrpc_reply_state *rs); int ptlrpc_hpreq_handler(struct ptlrpc_request *req); struct ptlrpc_service *ptlrpc_register_service( struct ptlrpc_service_conf *conf, + struct kset *parent, struct proc_dir_entry *proc_entry); void ptlrpc_stop_all_threads(struct ptlrpc_service *svc); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 151d60d45baa..4287edbeff32 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -1112,7 +1112,8 @@ static int ldlm_setup(void) }, }; ldlm_state->ldlm_cb_service = - ptlrpc_register_service(&conf, ldlm_svc_proc_dir); + ptlrpc_register_service(&conf, ldlm_svc_kset, + ldlm_svc_proc_dir); if (IS_ERR(ldlm_state->ldlm_cb_service)) { CERROR("failed to start service\n"); rc = PTR_ERR(ldlm_state->ldlm_cb_service); diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index aeceef5152ac..255798d2c7f4 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -1049,6 +1049,46 @@ static ssize_t ptlrpc_lprocfs_hp_ratio_seq_write(struct file *file, } LPROC_SEQ_FOPS(ptlrpc_lprocfs_hp_ratio); +static struct attribute *ptlrpc_svc_attrs[] = { + NULL, +}; + +static void ptlrpc_sysfs_svc_release(struct kobject *kobj) +{ + struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service, + srv_kobj); + + complete(&svc->srv_kobj_unregister); +} + +static struct kobj_type ptlrpc_svc_ktype = { + .default_attrs = ptlrpc_svc_attrs, + .sysfs_ops = &lustre_sysfs_ops, + .release = ptlrpc_sysfs_svc_release, +}; + +void ptlrpc_sysfs_unregister_service(struct ptlrpc_service *svc) +{ + /* Let's see if we had a chance at initialization first */ + if (svc->srv_kobj.kset) { + kobject_put(&svc->srv_kobj); + wait_for_completion(&svc->srv_kobj_unregister); + } +} + +int ptlrpc_sysfs_register_service(struct kset *parent, + struct ptlrpc_service *svc) +{ + int rc; + + svc->srv_kobj.kset = parent; + init_completion(&svc->srv_kobj_unregister); + rc = kobject_init_and_add(&svc->srv_kobj, &ptlrpc_svc_ktype, NULL, + "%s", svc->srv_name); + + return rc; +} + void ptlrpc_lprocfs_register_service(struct proc_dir_entry *entry, struct ptlrpc_service *svc) { diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h index a66dc3c6da41..8ea8221caef8 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h @@ -76,6 +76,10 @@ void ptlrpc_initiate_recovery(struct obd_import *imp); int lustre_unpack_req_ptlrpc_body(struct ptlrpc_request *req, int offset); int lustre_unpack_rep_ptlrpc_body(struct ptlrpc_request *req, int offset); +int ptlrpc_sysfs_register_service(struct kset *parent, + struct ptlrpc_service *svc); +void ptlrpc_sysfs_unregister_service(struct ptlrpc_service *svc); + #if defined(CONFIG_PROC_FS) void ptlrpc_lprocfs_register_service(struct proc_dir_entry *proc_entry, struct ptlrpc_service *svc); diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 3fa52f117424..d6927e13c17a 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -680,6 +680,7 @@ free_reqs_array: */ struct ptlrpc_service * ptlrpc_register_service(struct ptlrpc_service_conf *conf, + struct kset *parent, struct proc_dir_entry *proc_entry) { struct ptlrpc_service_cpt_conf *cconf = &conf->psc_cpt; @@ -798,6 +799,12 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, list_add(&service->srv_list, &ptlrpc_all_services); mutex_unlock(&ptlrpc_all_services_mutex); + if (parent) { + rc = ptlrpc_sysfs_register_service(parent, service); + if (rc) + goto failed; + } + if (proc_entry != NULL) ptlrpc_lprocfs_register_service(proc_entry, service); @@ -3033,6 +3040,7 @@ int ptlrpc_unregister_service(struct ptlrpc_service *service) ptlrpc_service_nrs_cleanup(service); ptlrpc_lprocfs_unregister_service(service); + ptlrpc_sysfs_unregister_service(service); ptlrpc_service_free(service); From 673a6796f290fe8079af6a688f20c87e7416bba5 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:32:09 -0400 Subject: [PATCH 0625/1163] staging/lustre/ptlrpc: move procfs threads* files to sysfs Move ptlrpc service threads_min, threads_max and threads_running entries from procfs to sysfs. Currently in use only by ldlm callback service only in /sys/fs/lustre/ldlm/services/ldlm_cbd/ Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/ptlrpc/lproc_ptlrpc.c | 82 +++++++++---------- drivers/staging/lustre/sysfs-fs-lustre | 18 ++++ 2 files changed, 56 insertions(+), 44 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 255798d2c7f4..ae1645042897 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -324,23 +324,23 @@ ptlrpc_lprocfs_req_history_max_seq_write(struct file *file, } LPROC_SEQ_FOPS(ptlrpc_lprocfs_req_history_max); -static int -ptlrpc_lprocfs_threads_min_seq_show(struct seq_file *m, void *n) -{ - struct ptlrpc_service *svc = m->private; - seq_printf(m, "%d\n", svc->srv_nthrs_cpt_init * svc->srv_ncpts); - return 0; +static ssize_t threads_min_show(struct kobject *kobj, struct attribute *attr, + char *buf) +{ + struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service, + srv_kobj); + + return sprintf(buf, "%d\n", svc->srv_nthrs_cpt_init * svc->srv_ncpts); } -static ssize_t -ptlrpc_lprocfs_threads_min_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t threads_min_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) { - struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private; - int val; - int rc = lprocfs_write_helper(buffer, count, &val); + struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service, + srv_kobj); + unsigned long val; + int rc = kstrtoul(buffer, 10, &val); if (rc < 0) return rc; @@ -360,41 +360,41 @@ ptlrpc_lprocfs_threads_min_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ptlrpc_lprocfs_threads_min); +LUSTRE_RW_ATTR(threads_min); -static int -ptlrpc_lprocfs_threads_started_seq_show(struct seq_file *m, void *n) +static ssize_t threads_started_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct ptlrpc_service *svc = m->private; + struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service, + srv_kobj); struct ptlrpc_service_part *svcpt; - int total = 0; - int i; + int total = 0; + int i; ptlrpc_service_for_each_part(svcpt, i, svc) total += svcpt->scp_nthrs_running; - seq_printf(m, "%d\n", total); - return 0; + return sprintf(buf, "%d\n", total); } -LPROC_SEQ_FOPS_RO(ptlrpc_lprocfs_threads_started); +LUSTRE_RO_ATTR(threads_started); -static int -ptlrpc_lprocfs_threads_max_seq_show(struct seq_file *m, void *n) +static ssize_t threads_max_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct ptlrpc_service *svc = m->private; + struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service, + srv_kobj); - seq_printf(m, "%d\n", svc->srv_nthrs_cpt_limit * svc->srv_ncpts); - return 0; + return sprintf(buf, "%d\n", svc->srv_nthrs_cpt_limit * svc->srv_ncpts); } -static ssize_t -ptlrpc_lprocfs_threads_max_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t threads_max_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) { - struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private; - int val; - int rc = lprocfs_write_helper(buffer, count, &val); + struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service, + srv_kobj); + unsigned long val; + int rc = kstrtoul(buffer, 10, &val); if (rc < 0) return rc; @@ -414,7 +414,7 @@ ptlrpc_lprocfs_threads_max_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ptlrpc_lprocfs_threads_max); +LUSTRE_RW_ATTR(threads_max); /** * \addtogoup nrs @@ -1050,6 +1050,9 @@ static ssize_t ptlrpc_lprocfs_hp_ratio_seq_write(struct file *file, LPROC_SEQ_FOPS(ptlrpc_lprocfs_hp_ratio); static struct attribute *ptlrpc_svc_attrs[] = { + &lustre_attr_threads_min.attr, + &lustre_attr_threads_started.attr, + &lustre_attr_threads_max.attr, NULL, }; @@ -1102,15 +1105,6 @@ void ptlrpc_lprocfs_register_service(struct proc_dir_entry *entry, {.name = "req_buffer_history_max", .fops = &ptlrpc_lprocfs_req_history_max_fops, .data = svc}, - {.name = "threads_min", - .fops = &ptlrpc_lprocfs_threads_min_fops, - .data = svc}, - {.name = "threads_max", - .fops = &ptlrpc_lprocfs_threads_max_fops, - .data = svc}, - {.name = "threads_started", - .fops = &ptlrpc_lprocfs_threads_started_fops, - .data = svc}, {.name = "timeouts", .fops = &ptlrpc_lprocfs_timeouts_fops, .data = svc}, diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index 39295e84c8fd..ed09a1182399 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -311,3 +311,21 @@ Contact: "Oleg Drokin" Description: Controls length of time between recalculation of above values (in seconds). + +What: /sys/fs/lustre/ldlm/services/ldlm_cbd/threads_min +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Controls minimum number of ldlm callback threads to start. + +What: /sys/fs/lustre/ldlm/services/ldlm_cbd/threads_max +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Controls maximum number of ldlm callback threads to start. + +What: /sys/fs/lustre/ldlm/services/ldlm_cbd/threads_started +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Shows actual number of ldlm callback threads running. From b40881e579588360242bd3f8f79f978d2a871e0e Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:32:10 -0400 Subject: [PATCH 0626/1163] staging/lustre/ptlrpc: move procfs high_priority_ratio file to sysfs Move ptlrpc service high_priority_ratio entry from procfs to sysfs. Currently in use only by ldlm callback service only in /sys/fs/lustre/ldlm/services/ldlm_cbd/ Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/ptlrpc/lproc_ptlrpc.c | 33 ++++++++++--------- drivers/staging/lustre/sysfs-fs-lustre | 7 ++++ 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index ae1645042897..92d1ce93dce6 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -1018,23 +1018,26 @@ static int ptlrpc_lprocfs_timeouts_seq_show(struct seq_file *m, void *n) } LPROC_SEQ_FOPS_RO(ptlrpc_lprocfs_timeouts); -static int ptlrpc_lprocfs_hp_ratio_seq_show(struct seq_file *m, void *v) +static ssize_t high_priority_ratio_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct ptlrpc_service *svc = m->private; - seq_printf(m, "%d", svc->srv_hpreq_ratio); - return 0; + struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service, + srv_kobj); + return sprintf(buf, "%d\n", svc->srv_hpreq_ratio); } -static ssize_t ptlrpc_lprocfs_hp_ratio_seq_write(struct file *file, - const char __user *buffer, - size_t count, - loff_t *off) +static ssize_t high_priority_ratio_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private; - int rc; - int val; + struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service, + srv_kobj); + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc < 0) return rc; @@ -1047,12 +1050,13 @@ static ssize_t ptlrpc_lprocfs_hp_ratio_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ptlrpc_lprocfs_hp_ratio); +LUSTRE_RW_ATTR(high_priority_ratio); static struct attribute *ptlrpc_svc_attrs[] = { &lustre_attr_threads_min.attr, &lustre_attr_threads_started.attr, &lustre_attr_threads_max.attr, + &lustre_attr_high_priority_ratio.attr, NULL, }; @@ -1096,9 +1100,6 @@ void ptlrpc_lprocfs_register_service(struct proc_dir_entry *entry, struct ptlrpc_service *svc) { struct lprocfs_vars lproc_vars[] = { - {.name = "high_priority_ratio", - .fops = &ptlrpc_lprocfs_hp_ratio_fops, - .data = svc}, {.name = "req_buffer_history_len", .fops = &ptlrpc_lprocfs_req_history_len_fops, .data = svc}, diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index ed09a1182399..9817cb37020a 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -329,3 +329,10 @@ Date: May 2015 Contact: "Oleg Drokin" Description: Shows actual number of ldlm callback threads running. + +What: /sys/fs/lustre/ldlm/services/ldlm_cbd/high_priority_ratio +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Controls what percentage of ldlm callback threads is dedicated + to "high priority" incoming requests. From 700815d47f9da0477229f009b6fa235f20da1e21 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Thu, 21 May 2015 15:32:11 -0400 Subject: [PATCH 0627/1163] staging/lustre/ldlm: move all remaining files from procfs to debugfs Move all files except stats. It will be moved later after change type of obddev->obd_proc_entry member. Signed-off-by: Dmitry Eremin Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lustre_dlm.h | 17 +-- .../lustre/lustre/include/lustre_net.h | 6 +- .../lustre/lustre/ldlm/ldlm_internal.h | 3 +- .../staging/lustre/lustre/ldlm/ldlm_lockd.c | 7 +- .../staging/lustre/lustre/ldlm/ldlm_pool.c | 50 +++---- .../staging/lustre/lustre/ldlm/ldlm_request.c | 4 +- .../lustre/lustre/ldlm/ldlm_resource.c | 126 +++++++++--------- .../lustre/lustre/ptlrpc/lproc_ptlrpc.c | 65 ++++----- .../lustre/lustre/ptlrpc/ptlrpc_internal.h | 5 +- .../staging/lustre/lustre/ptlrpc/service.c | 6 +- 10 files changed, 135 insertions(+), 154 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index b1e7d55ba674..f6f4c037fb30 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -234,8 +234,8 @@ struct ldlm_pool_ops { * This feature is commonly referred to as lru_resize. */ struct ldlm_pool { - /** Pool proc directory. */ - struct proc_dir_entry *pl_proc_dir; + /** Pool debugfs directory. */ + struct dentry *pl_debugfs_entry; /** Pool name, must be long enough to hold compound proc entry name. */ char pl_name[100]; /** Lock for protecting SLV/CLV updates. */ @@ -388,8 +388,8 @@ struct ldlm_namespace { /** Client side original connect flags supported by server. */ __u64 ns_orig_connect_flags; - /* namespace proc dir entry */ - struct proc_dir_entry *ns_proc_dir_entry; + /* namespace debugfs dir entry */ + struct dentry *ns_debugfs_entry; /** * Position in global namespace list linking all namespaces on @@ -1251,13 +1251,8 @@ void ldlm_namespace_register(struct ldlm_namespace *ns, ldlm_side_t client); void ldlm_namespace_unregister(struct ldlm_namespace *ns, ldlm_side_t client); void ldlm_namespace_get(struct ldlm_namespace *ns); void ldlm_namespace_put(struct ldlm_namespace *ns); -#if defined (CONFIG_PROC_FS) -int ldlm_proc_setup(void); -void ldlm_proc_cleanup(void); -#else -static inline int ldlm_proc_setup(void) { return 0; } -static inline void ldlm_proc_cleanup(void) {} -#endif +int ldlm_debugfs_setup(void); +void ldlm_debugfs_cleanup(void); /* resource.c - internal */ struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns, diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index 4fc987d4bdb4..e65e7d8af666 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -1978,8 +1978,8 @@ struct ptlrpc_service { int srv_nthrs_cpt_init; /** limit of threads number for each partition */ int srv_nthrs_cpt_limit; - /** Root of /proc dir tree for this service */ - struct proc_dir_entry *srv_procroot; + /** Root of debugfs dir tree for this service */ + struct dentry *srv_debugfs_entry; /** Pointer to statistic data for this service */ struct lprocfs_stats *srv_stats; /** # hp per lp reqs to handle */ @@ -2530,7 +2530,7 @@ int ptlrpc_hpreq_handler(struct ptlrpc_request *req); struct ptlrpc_service *ptlrpc_register_service( struct ptlrpc_service_conf *conf, struct kset *parent, - struct proc_dir_entry *proc_entry); + struct dentry *debugfs_entry); void ptlrpc_stop_all_threads(struct ptlrpc_service *svc); int ptlrpc_start_threads(struct ptlrpc_service *svc); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index 636451d29ef9..cf81bdbd57cb 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h @@ -197,8 +197,7 @@ void ldlm_destroy_flock_export(struct obd_export *exp); void l_check_ns_lock(struct ldlm_namespace *ns); void l_check_no_ns_lock(struct ldlm_namespace *ns); -extern struct proc_dir_entry *ldlm_svc_proc_dir; -extern struct proc_dir_entry *ldlm_type_proc_dir; +extern struct dentry *ldlm_svc_debugfs_dir; struct ldlm_state { struct ptlrpc_service *ldlm_cb_service; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 4287edbeff32..b7b6ca1196b7 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -1078,7 +1078,7 @@ static int ldlm_setup(void) goto out; } - rc = ldlm_proc_setup(); + rc = ldlm_debugfs_setup(); if (rc != 0) goto out; @@ -1113,7 +1113,7 @@ static int ldlm_setup(void) }; ldlm_state->ldlm_cb_service = ptlrpc_register_service(&conf, ldlm_svc_kset, - ldlm_svc_proc_dir); + ldlm_svc_debugfs_dir); if (IS_ERR(ldlm_state->ldlm_cb_service)) { CERROR("failed to start service\n"); rc = PTR_ERR(ldlm_state->ldlm_cb_service); @@ -1204,8 +1204,7 @@ static int ldlm_cleanup(void) if (ldlm_kobj) kobject_put(ldlm_kobj); - ldlm_proc_cleanup(); - + ldlm_debugfs_cleanup(); kfree(ldlm_state); ldlm_state = NULL; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index ed7473594a60..310cc60252fa 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -654,7 +654,6 @@ int ldlm_pool_setup(struct ldlm_pool *pl, int limit) } EXPORT_SYMBOL(ldlm_pool_setup); -#if defined(CONFIG_PROC_FS) static int lprocfs_pool_state_seq_show(struct seq_file *m, void *unused) { int granted, grant_rate, cancel_rate, grant_step; @@ -745,7 +744,7 @@ LUSTRE_RW_ATTR(lock_volume_factor); 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, NULL);\ + ldebugfs_add_vars(pl->pl_debugfs_entry, pool_vars, NULL);\ } while (0) /* These are for pools in /sys/fs/lustre/ldlm/namespaces/.../pool */ @@ -787,10 +786,10 @@ static int ldlm_pool_sysfs_init(struct ldlm_pool *pl) return err; } -static int ldlm_pool_proc_init(struct ldlm_pool *pl) +static int ldlm_pool_debugfs_init(struct ldlm_pool *pl) { struct ldlm_namespace *ns = ldlm_pl2ns(pl); - struct proc_dir_entry *parent_ns_proc; + struct dentry *debugfs_ns_parent; struct lprocfs_vars pool_vars[2]; char *var_name = NULL; int rc = 0; @@ -799,19 +798,19 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl) if (!var_name) return -ENOMEM; - parent_ns_proc = ns->ns_proc_dir_entry; - if (parent_ns_proc == NULL) { - CERROR("%s: proc entry is not initialized\n", + debugfs_ns_parent = ns->ns_debugfs_entry; + if (IS_ERR_OR_NULL(debugfs_ns_parent)) { + CERROR("%s: debugfs entry is not initialized\n", ldlm_ns_name(ns)); rc = -EINVAL; goto out_free_name; } - pl->pl_proc_dir = lprocfs_register("pool", parent_ns_proc, - NULL, NULL); - if (IS_ERR(pl->pl_proc_dir)) { - CERROR("LProcFS failed in ldlm-pool-init\n"); - rc = PTR_ERR(pl->pl_proc_dir); - pl->pl_proc_dir = NULL; + pl->pl_debugfs_entry = ldebugfs_register("pool", debugfs_ns_parent, + NULL, NULL); + if (IS_ERR(pl->pl_debugfs_entry)) { + CERROR("LdebugFS failed in ldlm-pool-init\n"); + rc = PTR_ERR(pl->pl_debugfs_entry); + pl->pl_debugfs_entry = NULL; goto out_free_name; } @@ -819,7 +818,7 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl) memset(pool_vars, 0, sizeof(pool_vars)); pool_vars[0].name = var_name; - LDLM_POOL_ADD_VAR("state", pl, &lprocfs_pool_state_fops); + LDLM_POOL_ADD_VAR(state, pl, &lprocfs_pool_state_fops); pl->pl_stats = lprocfs_alloc_stats(LDLM_POOL_LAST_STAT - LDLM_POOL_FIRST_STAT, 0); @@ -861,7 +860,8 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl) lprocfs_counter_init(pl->pl_stats, LDLM_POOL_TIMING_STAT, LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV, "recalc_timing", "sec"); - rc = lprocfs_register_stats(pl->pl_proc_dir, "stats", pl->pl_stats); + rc = ldebugfs_register_stats(pl->pl_debugfs_entry, "stats", + pl->pl_stats); out_free_name: kfree(var_name); @@ -874,25 +874,17 @@ static void ldlm_pool_sysfs_fini(struct ldlm_pool *pl) wait_for_completion(&pl->pl_kobj_unregister); } -static void ldlm_pool_proc_fini(struct ldlm_pool *pl) +static void ldlm_pool_debugfs_fini(struct ldlm_pool *pl) { if (pl->pl_stats != NULL) { lprocfs_free_stats(&pl->pl_stats); pl->pl_stats = NULL; } - if (pl->pl_proc_dir != NULL) { - lprocfs_remove(&pl->pl_proc_dir); - pl->pl_proc_dir = NULL; + if (pl->pl_debugfs_entry != NULL) { + ldebugfs_remove(&pl->pl_debugfs_entry); + pl->pl_debugfs_entry = NULL; } } -#else /* !CONFIG_PROC_FS */ -static int ldlm_pool_proc_init(struct ldlm_pool *pl) -{ - return 0; -} - -static void ldlm_pool_proc_fini(struct ldlm_pool *pl) {} -#endif /* CONFIG_PROC_FS */ int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns, int idx, ldlm_side_t client) @@ -923,7 +915,7 @@ int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns, pl->pl_recalc_period = LDLM_POOL_CLI_DEF_RECALC_PERIOD; } pl->pl_client_lock_volume = 0; - rc = ldlm_pool_proc_init(pl); + rc = ldlm_pool_debugfs_init(pl); if (rc) return rc; @@ -940,7 +932,7 @@ EXPORT_SYMBOL(ldlm_pool_init); void ldlm_pool_fini(struct ldlm_pool *pl) { ldlm_pool_sysfs_fini(pl); - ldlm_pool_proc_fini(pl); + ldlm_pool_debugfs_fini(pl); /* * Pool should not be used after this point. We can't free it here as diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index 4f713183145b..6245a2c36a0f 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -1462,7 +1462,7 @@ static ldlm_policy_res_t ldlm_cancel_lrur_policy(struct ldlm_namespace *ns, lock->l_last_used)); lv = lvf * la * unused; - /* Inform pool about current CLV to see it via proc. */ + /* Inform pool about current CLV to see it via debugfs. */ ldlm_pool_set_clv(pl, lv); /* Stop when SLV is not yet come from server or lv is smaller than @@ -1472,7 +1472,7 @@ static ldlm_policy_res_t ldlm_cancel_lrur_policy(struct ldlm_namespace *ns, } /** - * Callback function for proc used policy. Makes decision whether to keep + * Callback function for debugfs used policy. Makes decision whether to keep * \a lock in LRU for current \a LRU size \a unused, added in current scan \a * added and number of locks to be preferably canceled \a count. * diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 1e3190fa637b..50e049b01a62 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -61,17 +61,17 @@ LIST_HEAD(ldlm_cli_active_namespace_list); /* Client namespaces that don't have any locks in them */ LIST_HEAD(ldlm_cli_inactive_namespace_list); -struct proc_dir_entry *ldlm_type_proc_dir = NULL; -static struct proc_dir_entry *ldlm_ns_proc_dir = NULL; -struct proc_dir_entry *ldlm_svc_proc_dir = NULL; +static struct dentry *ldlm_debugfs_dir; +static struct dentry *ldlm_ns_debugfs_dir; +struct dentry *ldlm_svc_debugfs_dir; /* during debug dump certain amount of granted locks for one resource to avoid * DDOS. */ unsigned int ldlm_dump_granted_max = 256; -#if defined(CONFIG_PROC_FS) -static ssize_t lprocfs_wr_dump_ns(struct file *file, const char __user *buffer, - size_t count, loff_t *off) +static ssize_t +lprocfs_wr_dump_ns(struct file *file, const char __user *buffer, + size_t count, loff_t *off) { ldlm_dump_all_namespaces(LDLM_NAMESPACE_SERVER, D_DLMTRACE); ldlm_dump_all_namespaces(LDLM_NAMESPACE_CLIENT, D_DLMTRACE); @@ -81,72 +81,74 @@ LPROC_SEQ_FOPS_WR_ONLY(ldlm, dump_ns); LPROC_SEQ_FOPS_RW_TYPE(ldlm_rw, uint); -int ldlm_proc_setup(void) +static struct lprocfs_vars ldlm_debugfs_list[] = { + { "dump_namespaces", &ldlm_dump_ns_fops, NULL, 0222 }, + { "dump_granted_max", &ldlm_rw_uint_fops, &ldlm_dump_granted_max }, + { NULL } +}; + +int ldlm_debugfs_setup(void) { int rc; - struct lprocfs_vars list[] = { - { "dump_namespaces", &ldlm_dump_ns_fops, NULL, 0222 }, - { "dump_granted_max", &ldlm_rw_uint_fops, - &ldlm_dump_granted_max }, - { NULL } }; - LASSERT(ldlm_ns_proc_dir == NULL); - ldlm_type_proc_dir = lprocfs_register(OBD_LDLM_DEVICENAME, - proc_lustre_root, - NULL, NULL); - if (IS_ERR(ldlm_type_proc_dir)) { + ldlm_debugfs_dir = ldebugfs_register(OBD_LDLM_DEVICENAME, + debugfs_lustre_root, + NULL, NULL); + if (IS_ERR_OR_NULL(ldlm_debugfs_dir)) { CERROR("LProcFS failed in ldlm-init\n"); - rc = PTR_ERR(ldlm_type_proc_dir); + rc = ldlm_debugfs_dir ? PTR_ERR(ldlm_debugfs_dir) : -ENOMEM; goto err; } - ldlm_ns_proc_dir = lprocfs_register("namespaces", - ldlm_type_proc_dir, - NULL, NULL); - if (IS_ERR(ldlm_ns_proc_dir)) { + ldlm_ns_debugfs_dir = ldebugfs_register("namespaces", + ldlm_debugfs_dir, + NULL, NULL); + if (IS_ERR_OR_NULL(ldlm_ns_debugfs_dir)) { CERROR("LProcFS failed in ldlm-init\n"); - rc = PTR_ERR(ldlm_ns_proc_dir); + rc = ldlm_ns_debugfs_dir ? PTR_ERR(ldlm_ns_debugfs_dir) + : -ENOMEM; goto err_type; } - ldlm_svc_proc_dir = lprocfs_register("services", - ldlm_type_proc_dir, - NULL, NULL); - if (IS_ERR(ldlm_svc_proc_dir)) { + ldlm_svc_debugfs_dir = ldebugfs_register("services", + ldlm_debugfs_dir, + NULL, NULL); + if (IS_ERR_OR_NULL(ldlm_svc_debugfs_dir)) { CERROR("LProcFS failed in ldlm-init\n"); - rc = PTR_ERR(ldlm_svc_proc_dir); + rc = ldlm_svc_debugfs_dir ? PTR_ERR(ldlm_svc_debugfs_dir) + : -ENOMEM; goto err_ns; } - rc = lprocfs_add_vars(ldlm_type_proc_dir, list, NULL); + rc = ldebugfs_add_vars(ldlm_debugfs_dir, ldlm_debugfs_list, NULL); return 0; err_ns: - lprocfs_remove(&ldlm_ns_proc_dir); + ldebugfs_remove(&ldlm_ns_debugfs_dir); err_type: - lprocfs_remove(&ldlm_type_proc_dir); + ldebugfs_remove(&ldlm_debugfs_dir); err: - ldlm_svc_proc_dir = NULL; - ldlm_type_proc_dir = NULL; - ldlm_ns_proc_dir = NULL; + ldlm_svc_debugfs_dir = NULL; + ldlm_ns_debugfs_dir = NULL; + ldlm_debugfs_dir = NULL; return rc; } -void ldlm_proc_cleanup(void) +void ldlm_debugfs_cleanup(void) { - if (ldlm_svc_proc_dir) - lprocfs_remove(&ldlm_svc_proc_dir); + if (!IS_ERR_OR_NULL(ldlm_svc_debugfs_dir)) + ldebugfs_remove(&ldlm_svc_debugfs_dir); - if (ldlm_ns_proc_dir) - lprocfs_remove(&ldlm_ns_proc_dir); + if (!IS_ERR_OR_NULL(ldlm_ns_debugfs_dir)) + ldebugfs_remove(&ldlm_ns_debugfs_dir); - if (ldlm_type_proc_dir) - lprocfs_remove(&ldlm_type_proc_dir); + if (!IS_ERR_OR_NULL(ldlm_debugfs_dir)) + ldebugfs_remove(&ldlm_debugfs_dir); - ldlm_svc_proc_dir = NULL; - ldlm_type_proc_dir = NULL; - ldlm_ns_proc_dir = NULL; + ldlm_svc_debugfs_dir = NULL; + ldlm_ns_debugfs_dir = NULL; + ldlm_debugfs_dir = NULL; } static ssize_t resource_count_show(struct kobject *kobj, struct attribute *attr, @@ -369,13 +371,13 @@ static struct kobj_type ldlm_ns_ktype = { .release = ldlm_ns_release, }; -void ldlm_namespace_proc_unregister(struct ldlm_namespace *ns) +static void ldlm_namespace_debugfs_unregister(struct ldlm_namespace *ns) { - if (ns->ns_proc_dir_entry == NULL) + if (IS_ERR_OR_NULL(ns->ns_debugfs_entry)) CERROR("dlm namespace %s has no procfs dir?\n", ldlm_ns_name(ns)); else - lprocfs_remove(&ns->ns_proc_dir_entry); + ldebugfs_remove(&ns->ns_debugfs_entry); if (ns->ns_stats != NULL) lprocfs_free_stats(&ns->ns_stats); @@ -408,31 +410,23 @@ int ldlm_namespace_sysfs_register(struct ldlm_namespace *ns) return err; } -int ldlm_namespace_proc_register(struct ldlm_namespace *ns) +static int ldlm_namespace_debugfs_register(struct ldlm_namespace *ns) { - struct proc_dir_entry *ns_pde; + struct dentry *ns_entry; - LASSERT(ns != NULL); - LASSERT(ns->ns_rs_hash != NULL); - - if (ns->ns_proc_dir_entry != NULL) { - ns_pde = ns->ns_proc_dir_entry; + if (!IS_ERR_OR_NULL(ns->ns_debugfs_entry)) { + ns_entry = ns->ns_debugfs_entry; } else { - ns_pde = proc_mkdir(ldlm_ns_name(ns), ldlm_ns_proc_dir); - if (ns_pde == NULL) + ns_entry = debugfs_create_dir(ldlm_ns_name(ns), + ldlm_ns_debugfs_dir); + if (ns_entry == NULL) return -ENOMEM; - ns->ns_proc_dir_entry = ns_pde; + ns->ns_debugfs_entry = ns_entry; } return 0; } #undef MAX_STRING_SIZE -#else /* CONFIG_PROC_FS */ - -#define ldlm_namespace_proc_unregister(ns) ({; }) -#define ldlm_namespace_proc_register(ns) ({0; }) - -#endif /* CONFIG_PROC_FS */ static unsigned ldlm_res_hop_hash(struct cfs_hash *hs, const void *key, unsigned mask) @@ -680,7 +674,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, goto out_hash; } - rc = ldlm_namespace_proc_register(ns); + rc = ldlm_namespace_debugfs_register(ns); if (rc != 0) { CERROR("Can't initialize ns proc, rc %d\n", rc); goto out_sysfs; @@ -696,7 +690,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, ldlm_namespace_register(ns, client); return ns; out_proc: - ldlm_namespace_proc_unregister(ns); + ldlm_namespace_debugfs_unregister(ns); out_sysfs: ldlm_namespace_sysfs_unregister(ns); ldlm_namespace_cleanup(ns, 0); @@ -944,7 +938,7 @@ void ldlm_namespace_free_post(struct ldlm_namespace *ns) * Removing it after @dir may cause oops. */ ldlm_pool_fini(&ns->ns_pool); - ldlm_namespace_proc_unregister(ns); + ldlm_namespace_debugfs_unregister(ns); cfs_hash_putref(ns->ns_rs_hash); /* Namespace \a ns should be not on list at this time, otherwise * this will cause issues related to using freed \a ns in poold diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 92d1ce93dce6..8c0c9954fe99 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -181,19 +181,19 @@ static const char *ll_eopcode2str(__u32 opcode) return ll_eopcode_table[opcode].opname; } -#if defined(CONFIG_PROC_FS) -static void ptlrpc_lprocfs_register(struct proc_dir_entry *root, char *dir, - char *name, - struct proc_dir_entry **procroot_ret, - struct lprocfs_stats **stats_ret) +static void +ptlrpc_ldebugfs_register(struct dentry *root, char *dir, + char *name, + struct dentry **debugfs_root_ret, + struct lprocfs_stats **stats_ret) { - struct proc_dir_entry *svc_procroot; + struct dentry *svc_debugfs_entry; struct lprocfs_stats *svc_stats; int i, rc; unsigned int svc_counter_config = LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV; - LASSERT(*procroot_ret == NULL); + LASSERT(*debugfs_root_ret == NULL); LASSERT(*stats_ret == NULL); svc_stats = lprocfs_alloc_stats(EXTRA_MAX_OPCODES+LUSTRE_MAX_OPCODES, @@ -201,14 +201,14 @@ static void ptlrpc_lprocfs_register(struct proc_dir_entry *root, char *dir, if (svc_stats == NULL) return; - if (dir) { - svc_procroot = lprocfs_register(dir, root, NULL, NULL); - if (IS_ERR(svc_procroot)) { + if (dir != NULL) { + svc_debugfs_entry = ldebugfs_register(dir, root, NULL, NULL); + if (IS_ERR(svc_debugfs_entry)) { lprocfs_free_stats(&svc_stats); return; } } else { - svc_procroot = root; + svc_debugfs_entry = root; } lprocfs_counter_init(svc_stats, PTLRPC_REQWAIT_CNTR, @@ -244,18 +244,19 @@ static void ptlrpc_lprocfs_register(struct proc_dir_entry *root, char *dir, ll_opcode2str(opcode), "usec"); } - rc = lprocfs_register_stats(svc_procroot, name, svc_stats); + rc = ldebugfs_register_stats(svc_debugfs_entry, name, svc_stats); if (rc < 0) { - if (dir) - lprocfs_remove(&svc_procroot); + if (dir != NULL) + ldebugfs_remove(&svc_debugfs_entry); lprocfs_free_stats(&svc_stats); } else { - if (dir) - *procroot_ret = svc_procroot; + if (dir != NULL) + *debugfs_root_ret = svc_debugfs_entry; *stats_ret = svc_stats; } } +#if defined(CONFIG_PROC_FS) static int ptlrpc_lprocfs_req_history_len_seq_show(struct seq_file *m, void *v) { @@ -980,7 +981,7 @@ ptlrpc_lprocfs_svc_req_history_open(struct inode *inode, struct file *file) return rc; seqf = file->private_data; - seqf->private = PDE_DATA(inode); + seqf->private = inode->i_private; return 0; } @@ -1096,8 +1097,8 @@ int ptlrpc_sysfs_register_service(struct kset *parent, return rc; } -void ptlrpc_lprocfs_register_service(struct proc_dir_entry *entry, - struct ptlrpc_service *svc) +void ptlrpc_ldebugfs_register_service(struct dentry *entry, + struct ptlrpc_service *svc) { struct lprocfs_vars lproc_vars[] = { {.name = "req_buffer_history_len", @@ -1124,26 +1125,28 @@ void ptlrpc_lprocfs_register_service(struct proc_dir_entry *entry, int rc; - ptlrpc_lprocfs_register(entry, svc->srv_name, - "stats", &svc->srv_procroot, - &svc->srv_stats); + ptlrpc_ldebugfs_register(entry, svc->srv_name, + "stats", &svc->srv_debugfs_entry, + &svc->srv_stats); - if (svc->srv_procroot == NULL) + if (svc->srv_debugfs_entry == NULL) return; - lprocfs_add_vars(svc->srv_procroot, lproc_vars, NULL); + ldebugfs_add_vars(svc->srv_debugfs_entry, lproc_vars, NULL); - rc = lprocfs_seq_create(svc->srv_procroot, "req_history", - 0400, &req_history_fops, svc); + rc = ldebugfs_seq_create(svc->srv_debugfs_entry, "req_history", + 0400, &req_history_fops, svc); if (rc) CWARN("Error adding the req_history file\n"); } void ptlrpc_lprocfs_register_obd(struct obd_device *obddev) { - ptlrpc_lprocfs_register(obddev->obd_proc_entry, NULL, "stats", - &obddev->obd_svc_procroot, - &obddev->obd_svc_stats); +/* TODO: enable after change type of obddev->obd_proc_entry + * ptlrpc_ldebugfs_register(obddev->obd_proc_entry, NULL, "stats", + * &obddev->obd_svc_procroot, + * &obddev->obd_svc_stats); + */ } EXPORT_SYMBOL(ptlrpc_lprocfs_register_obd); @@ -1191,8 +1194,8 @@ EXPORT_SYMBOL(ptlrpc_lprocfs_brw); void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc) { - if (svc->srv_procroot != NULL) - lprocfs_remove(&svc->srv_procroot); + if (svc->srv_debugfs_entry != NULL) + ldebugfs_remove(&svc->srv_debugfs_entry); if (svc->srv_stats) lprocfs_free_stats(&svc->srv_stats); diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h index 8ea8221caef8..9f9ef9a24b63 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h @@ -80,15 +80,14 @@ int ptlrpc_sysfs_register_service(struct kset *parent, struct ptlrpc_service *svc); void ptlrpc_sysfs_unregister_service(struct ptlrpc_service *svc); +void ptlrpc_ldebugfs_register_service(struct dentry *debugfs_entry, + struct ptlrpc_service *svc); #if defined(CONFIG_PROC_FS) -void ptlrpc_lprocfs_register_service(struct proc_dir_entry *proc_entry, - struct ptlrpc_service *svc); void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc); void ptlrpc_lprocfs_rpc_sent(struct ptlrpc_request *req, long amount); void ptlrpc_lprocfs_do_request_stat(struct ptlrpc_request *req, long q_usec, long work_usec); #else -#define ptlrpc_lprocfs_register_service(params...) do {} while (0) #define ptlrpc_lprocfs_unregister_service(params...) do {} while (0) #define ptlrpc_lprocfs_rpc_sent(params...) do {} while (0) #define ptlrpc_lprocfs_do_request_stat(params...) do {} while (0) diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index d6927e13c17a..454d1a8640a5 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -681,7 +681,7 @@ free_reqs_array: struct ptlrpc_service * ptlrpc_register_service(struct ptlrpc_service_conf *conf, struct kset *parent, - struct proc_dir_entry *proc_entry) + struct dentry *debugfs_entry) { struct ptlrpc_service_cpt_conf *cconf = &conf->psc_cpt; struct ptlrpc_service *service; @@ -805,8 +805,8 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, goto failed; } - if (proc_entry != NULL) - ptlrpc_lprocfs_register_service(proc_entry, service); + if (!IS_ERR_OR_NULL(debugfs_entry)) + ptlrpc_ldebugfs_register_service(debugfs_entry, service); rc = ptlrpc_service_nrs_setup(service); if (rc != 0) From 77386b3c0b4470db1ed546de858b31cac66fc943 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Thu, 21 May 2015 15:32:12 -0400 Subject: [PATCH 0628/1163] staging/lustre/ptlrpc: move sptlrpc procfs entry to debugfs We might want eventuall split it into a bunch of single-value sysfs entries, I imagine, but there is no urgent need now. Signed-off-by: Dmitry Eremin Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lustre_sec.h | 8 ------ .../staging/lustre/lustre/ptlrpc/sec_lproc.c | 27 +++++++++---------- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_sec.h b/drivers/staging/lustre/lustre/include/lustre_sec.h index dff70a5b9bc4..707ff69717c6 100644 --- a/drivers/staging/lustre/lustre/include/lustre_sec.h +++ b/drivers/staging/lustre/lustre/include/lustre_sec.h @@ -1061,15 +1061,7 @@ const char *sec2target_str(struct ptlrpc_sec *sec); /* * lprocfs */ -#if defined (CONFIG_PROC_FS) -struct proc_dir_entry; -extern struct proc_dir_entry *sptlrpc_proc_root; int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev); -#else -#define sptlrpc_proc_root NULL -static inline int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev) -{ return 0; } -#endif /* * server side diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c index 0d08145a6c7e..549515dd165e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c @@ -51,10 +51,6 @@ #include "ptlrpc_internal.h" - -struct proc_dir_entry *sptlrpc_proc_root = NULL; -EXPORT_SYMBOL(sptlrpc_proc_root); - static char *sec_flags2str(unsigned long flags, char *buf, int bufsize) { buf[0] = '\0'; @@ -174,17 +170,20 @@ static struct lprocfs_vars sptlrpc_lprocfs_vars[] = { { NULL } }; +static struct dentry *sptlrpc_debugfs_dir; + int sptlrpc_lproc_init(void) { - int rc; + int rc; - LASSERT(sptlrpc_proc_root == NULL); + LASSERT(sptlrpc_debugfs_dir == NULL); - sptlrpc_proc_root = lprocfs_register("sptlrpc", proc_lustre_root, - sptlrpc_lprocfs_vars, NULL); - if (IS_ERR(sptlrpc_proc_root)) { - rc = PTR_ERR(sptlrpc_proc_root); - sptlrpc_proc_root = NULL; + sptlrpc_debugfs_dir = ldebugfs_register("sptlrpc", debugfs_lustre_root, + sptlrpc_lprocfs_vars, NULL); + if (IS_ERR_OR_NULL(sptlrpc_debugfs_dir)) { + rc = sptlrpc_debugfs_dir ? PTR_ERR(sptlrpc_debugfs_dir) + : -ENOMEM; + sptlrpc_debugfs_dir = NULL; return rc; } return 0; @@ -192,8 +191,6 @@ int sptlrpc_lproc_init(void) void sptlrpc_lproc_fini(void) { - if (sptlrpc_proc_root) { - lprocfs_remove(&sptlrpc_proc_root); - sptlrpc_proc_root = NULL; - } + if (!IS_ERR_OR_NULL(sptlrpc_debugfs_dir)) + ldebugfs_remove(&sptlrpc_debugfs_dir); } From 2962b440dfe0357405a46e2afe1b6ff33de58465 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:32:13 -0400 Subject: [PATCH 0629/1163] staging/lustre: Remove useless num_refs procfs variable Every obd type registers it, but it's not really needed by anybody. Remove all the supporting infrastructure too. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lprocfs_status.h | 2 -- drivers/staging/lustre/lustre/include/obd_class.h | 3 +-- drivers/staging/lustre/lustre/llite/lproc_llite.c | 1 - drivers/staging/lustre/lustre/lmv/lmv_obd.c | 2 +- drivers/staging/lustre/lustre/lmv/lproc_lmv.c | 8 -------- drivers/staging/lustre/lustre/lov/lov_obd.c | 2 +- drivers/staging/lustre/lustre/lov/lproc_lov.c | 8 -------- drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 8 -------- drivers/staging/lustre/lustre/mdc/mdc_request.c | 2 +- drivers/staging/lustre/lustre/mgc/lproc_mgc.c | 7 ------- drivers/staging/lustre/lustre/mgc/mgc_request.c | 2 +- drivers/staging/lustre/lustre/obdclass/genops.c | 4 ++-- .../staging/lustre/lustre/obdclass/lprocfs_status.c | 10 ---------- drivers/staging/lustre/lustre/obdecho/echo_client.c | 1 - drivers/staging/lustre/lustre/obdecho/lproc_echo.c | 7 ------- drivers/staging/lustre/lustre/osc/lproc_osc.c | 7 ------- drivers/staging/lustre/lustre/osc/osc_request.c | 2 +- 17 files changed, 8 insertions(+), 68 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 313f39436d09..48a0d565b0cc 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -61,7 +61,6 @@ struct lprocfs_vars { }; struct lprocfs_static_vars { - struct lprocfs_vars *module_vars; struct lprocfs_vars *obd_vars; }; @@ -640,7 +639,6 @@ extern int lprocfs_rd_import(struct seq_file *m, void *data); extern int lprocfs_rd_state(struct seq_file *m, void *data); extern int lprocfs_rd_connect_flags(struct seq_file *m, void *data); extern int lprocfs_rd_num_exports(struct seq_file *m, void *data); -extern int lprocfs_rd_numrefs(struct seq_file *m, void *data); struct adaptive_timeout; extern int lprocfs_at_hist_helper(struct seq_file *m, diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 34b5fa3f081c..98b397e139a8 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -75,8 +75,7 @@ struct lu_device_type; extern struct list_head obd_types; struct obd_export *class_conn2export(struct lustre_handle *); int class_register_type(struct obd_ops *, struct md_ops *, - struct lprocfs_vars *, const char *nm, - struct lu_device_type *ldt); + const char *nm, struct lu_device_type *ldt); int class_unregister_type(const char *nm); struct obd_device *class_newdev(const char *type_name, const char *name); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 49fbecc40cac..e1fc62084bb1 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1532,6 +1532,5 @@ LPROC_SEQ_FOPS(ll_rw_offset_stats); void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars) { - lvars->module_vars = NULL; lvars->obd_vars = lprocfs_llite_obd_vars; } diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 8e05852ea712..0b2d35f26fc5 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -2873,7 +2873,7 @@ static int __init lmv_init(void) lprocfs_lmv_init_vars(&lvars); rc = class_register_type(&lmv_obd_ops, &lmv_md_ops, - lvars.module_vars, LUSTRE_LMV_NAME, NULL); + LUSTRE_LMV_NAME, NULL); return rc; } diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index 22e5c315faa4..76b32d56eb08 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -215,13 +215,6 @@ static struct lprocfs_vars lprocfs_lmv_obd_vars[] = { { NULL } }; -LPROC_SEQ_FOPS_RO_TYPE(lmv, numrefs); - -static struct lprocfs_vars lprocfs_lmv_module_vars[] = { - { "num_refs", &lmv_numrefs_fops, NULL, 0 }, - { NULL } -}; - struct file_operations lmv_proc_target_fops = { .owner = THIS_MODULE, .open = lmv_target_seq_open, @@ -232,6 +225,5 @@ struct file_operations lmv_proc_target_fops = { void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars) { - lvars->module_vars = lprocfs_lmv_module_vars; lvars->obd_vars = lprocfs_lmv_obd_vars; } diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 054ca32099c8..d4e8d9c30ed3 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -2365,7 +2365,7 @@ static int __init lov_init(void) } lprocfs_lov_init_vars(&lvars); - rc = class_register_type(&lov_obd_ops, NULL, lvars.module_vars, + rc = class_register_type(&lov_obd_ops, NULL, LUSTRE_LOV_NAME, &lov_device_type); if (rc) { diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index 174cbf5c138f..18fdd7ec75c4 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c @@ -289,16 +289,8 @@ static struct lprocfs_vars lprocfs_lov_obd_vars[] = { { NULL } }; -LPROC_SEQ_FOPS_RO_TYPE(lov, numrefs); - -static struct lprocfs_vars lprocfs_lov_module_vars[] = { - { "num_refs", &lov_numrefs_fops, NULL, 0 }, - { NULL } -}; - void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars) { - lvars->module_vars = lprocfs_lov_module_vars; lvars->obd_vars = lprocfs_lov_obd_vars; } diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index 23d22a4a606e..5c38cd7c22e7 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -206,15 +206,7 @@ static struct lprocfs_vars lprocfs_mdc_obd_vars[] = { { NULL } }; -LPROC_SEQ_FOPS_RO_TYPE(mdc, numrefs); - -static struct lprocfs_vars lprocfs_mdc_module_vars[] = { - { "num_refs", &mdc_numrefs_fops, NULL, 0 }, - { NULL } -}; - void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars) { - lvars->module_vars = lprocfs_mdc_module_vars; lvars->obd_vars = lprocfs_mdc_obd_vars; } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index cbbdfceb9b2a..b24ec3f848f3 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -2713,7 +2713,7 @@ static int __init mdc_init(void) lprocfs_mdc_init_vars(&lvars); - return class_register_type(&mdc_obd_ops, &mdc_md_ops, lvars.module_vars, + return class_register_type(&mdc_obd_ops, &mdc_md_ops, LUSTRE_MDC_NAME, NULL); } diff --git a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c index c4ea38e5f077..ad889e71bd6c 100644 --- a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c +++ b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c @@ -67,14 +67,7 @@ static struct lprocfs_vars lprocfs_mgc_obd_vars[] = { { NULL } }; -LPROC_SEQ_FOPS_RO_TYPE(mgc, numrefs); -static struct lprocfs_vars lprocfs_mgc_module_vars[] = { - { "num_refs", &mgc_numrefs_fops, NULL, 0 }, - { NULL } -}; - void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars) { - lvars->module_vars = lprocfs_mgc_module_vars; lvars->obd_vars = lprocfs_mgc_obd_vars; } diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index f152e5ceb941..5fff272f7b9f 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -1745,7 +1745,7 @@ struct obd_ops mgc_obd_ops = { static int __init mgc_init(void) { - return class_register_type(&mgc_obd_ops, NULL, NULL, + return class_register_type(&mgc_obd_ops, NULL, LUSTRE_MGC_NAME, NULL); } diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 37d6aefde534..eab4130d6c49 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -156,7 +156,7 @@ EXPORT_SYMBOL(class_put_type); #define CLASS_MAX_NAME 1024 int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, - struct lprocfs_vars *vars, const char *name, + const char *name, struct lu_device_type *ldt) { struct obd_type *type; @@ -192,7 +192,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, spin_lock_init(&type->obd_type_lock); type->typ_procroot = lprocfs_register(type->typ_name, proc_lustre_root, - vars, type); + NULL, type); if (IS_ERR(type->typ_procroot)) { rc = PTR_ERR(type->typ_procroot); type->typ_procroot = NULL; diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 000e8748da4a..a91894d93d4d 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1004,16 +1004,6 @@ int lprocfs_rd_num_exports(struct seq_file *m, void *data) } EXPORT_SYMBOL(lprocfs_rd_num_exports); -int lprocfs_rd_numrefs(struct seq_file *m, void *data) -{ - struct obd_type *class = (struct obd_type *) data; - - LASSERT(class != NULL); - seq_printf(m, "%d\n", class->typ_refcnt); - return 0; -} -EXPORT_SYMBOL(lprocfs_rd_numrefs); - int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list) { int rc = 0; diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 53761787a56f..f9cfba17995f 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -2149,7 +2149,6 @@ int echo_client_init(void) rc = lu_kmem_init(echo_caches); if (rc == 0) { rc = class_register_type(&echo_client_obd_ops, NULL, - lvars.module_vars, LUSTRE_ECHO_CLIENT_NAME, &echo_device_type); if (rc) diff --git a/drivers/staging/lustre/lustre/obdecho/lproc_echo.c b/drivers/staging/lustre/lustre/obdecho/lproc_echo.c index 0beb97db7c7d..2eb702e48c57 100644 --- a/drivers/staging/lustre/lustre/obdecho/lproc_echo.c +++ b/drivers/staging/lustre/lustre/obdecho/lproc_echo.c @@ -43,15 +43,8 @@ static struct lprocfs_vars lprocfs_echo_obd_vars[] = { { NULL } }; -LPROC_SEQ_FOPS_RO_TYPE(echo, numrefs); -static struct lprocfs_vars lprocfs_echo_module_vars[] = { - { "num_refs", &echo_numrefs_fops, NULL, 0 }, - { NULL } -}; - void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars) { - lvars->module_vars = lprocfs_echo_module_vars; lvars->obd_vars = lprocfs_echo_obd_vars; } #endif /* CONFIG_PROC_FS */ diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 15a66209831c..93ad272fe46d 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -573,12 +573,6 @@ static struct lprocfs_vars lprocfs_osc_obd_vars[] = { { NULL } }; -LPROC_SEQ_FOPS_RO_TYPE(osc, numrefs); -static struct lprocfs_vars lprocfs_osc_module_vars[] = { - { "num_refs", &osc_numrefs_fops, NULL, 0 }, - { NULL } -}; - #define pct(a, b) (b ? a * 100 / b : 0) static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v) @@ -746,6 +740,5 @@ int lproc_osc_attach_seqstat(struct obd_device *dev) void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars) { - lvars->module_vars = lprocfs_osc_module_vars; lvars->obd_vars = lprocfs_osc_obd_vars; } diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index ded184edb50f..5924f9f1b5b1 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -3351,7 +3351,7 @@ static int __init osc_init(void) lprocfs_osc_init_vars(&lvars); - rc = class_register_type(&osc_obd_ops, NULL, lvars.module_vars, + rc = class_register_type(&osc_obd_ops, NULL, LUSTRE_OSC_NAME, &osc_device_type); if (rc) { lu_kmem_fini(osc_caches); From cc551d5da62dc03f4343e879105f77eb3ca402ca Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:32:14 -0400 Subject: [PATCH 0630/1163] stagng/lustre/obdclass: Remove unused function lprocfs_rd_num_exports This function is unused in client code. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lprocfs_status.h | 1 - .../staging/lustre/lustre/obdclass/lprocfs_status.c | 10 ---------- 2 files changed, 11 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 48a0d565b0cc..1bbc93017ce7 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -638,7 +638,6 @@ extern int lprocfs_rd_conn_uuid(struct seq_file *m, void *data); extern int lprocfs_rd_import(struct seq_file *m, void *data); extern int lprocfs_rd_state(struct seq_file *m, void *data); extern int lprocfs_rd_connect_flags(struct seq_file *m, void *data); -extern int lprocfs_rd_num_exports(struct seq_file *m, void *data); struct adaptive_timeout; extern int lprocfs_at_hist_helper(struct seq_file *m, diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index a91894d93d4d..695b3e0dcfcf 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -994,16 +994,6 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data) } EXPORT_SYMBOL(lprocfs_rd_connect_flags); -int lprocfs_rd_num_exports(struct seq_file *m, void *data) -{ - struct obd_device *obd = data; - - LASSERT(obd != NULL); - seq_printf(m, "%u\n", obd->obd_num_exports); - return 0; -} -EXPORT_SYMBOL(lprocfs_rd_num_exports); - int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list) { int rc = 0; From b8c7ceda74e31aa8511e7b334e14e1c6169e8bee Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:32:15 -0400 Subject: [PATCH 0631/1163] staging/lustre/obdecho: Remove procfs registration obdecho client seems to be only registering useless proc values that are of no use to anybody. Remove them. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/obdecho/Makefile | 2 +- .../lustre/lustre/obdecho/echo_client.c | 8 --- .../lustre/lustre/obdecho/lproc_echo.c | 50 ------------------- 3 files changed, 1 insertion(+), 59 deletions(-) delete mode 100644 drivers/staging/lustre/lustre/obdecho/lproc_echo.c diff --git a/drivers/staging/lustre/lustre/obdecho/Makefile b/drivers/staging/lustre/lustre/obdecho/Makefile index 672028fc7f6e..a659a37a7e93 100644 --- a/drivers/staging/lustre/lustre/obdecho/Makefile +++ b/drivers/staging/lustre/lustre/obdecho/Makefile @@ -1,2 +1,2 @@ obj-$(CONFIG_LUSTRE_FS) += obdecho.o -obdecho-y := echo_client.o lproc_echo.o +obdecho-y := echo_client.o diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index f9cfba17995f..0222fd2e4757 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -2141,11 +2141,8 @@ static struct obd_ops echo_client_obd_ops = { int echo_client_init(void) { - struct lprocfs_static_vars lvars = { NULL }; int rc; - lprocfs_echo_init_vars(&lvars); - rc = lu_kmem_init(echo_caches); if (rc == 0) { rc = class_register_type(&echo_client_obd_ops, NULL, @@ -2165,15 +2162,10 @@ void echo_client_exit(void) static int __init obdecho_init(void) { - struct lprocfs_static_vars lvars; - LCONSOLE_INFO("Echo OBD driver; http://www.lustre.org/\n"); LASSERT(PAGE_CACHE_SIZE % OBD_ECHO_BLOCK_SIZE == 0); - lprocfs_echo_init_vars(&lvars); - - return echo_client_init(); } diff --git a/drivers/staging/lustre/lustre/obdecho/lproc_echo.c b/drivers/staging/lustre/lustre/obdecho/lproc_echo.c deleted file mode 100644 index 2eb702e48c57..000000000000 --- a/drivers/staging/lustre/lustre/obdecho/lproc_echo.c +++ /dev/null @@ -1,50 +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. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ -#define DEBUG_SUBSYSTEM S_ECHO - -#include "../include/lprocfs_status.h" -#include "../include/obd_class.h" - -#if defined(CONFIG_PROC_FS) -LPROC_SEQ_FOPS_RO_TYPE(echo, uuid); -static struct lprocfs_vars lprocfs_echo_obd_vars[] = { - { "uuid", &echo_uuid_fops, NULL, 0 }, - { NULL } -}; - -void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars) -{ - lvars->obd_vars = lprocfs_echo_obd_vars; -} -#endif /* CONFIG_PROC_FS */ From 9b8013023cb62360b56c04313687e93a1c2bf3d6 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:32:16 -0400 Subject: [PATCH 0632/1163] staging/lustre/obdclass: Prepare for procfs to sysfs migration Add necessary plumbing to register obd types and instances under /sys/fs/lustre Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lprocfs_status.h | 4 +- drivers/staging/lustre/lustre/include/obd.h | 4 ++ drivers/staging/lustre/lustre/lmv/lmv_obd.c | 4 +- drivers/staging/lustre/lustre/lov/lov_obd.c | 2 +- .../staging/lustre/lustre/mdc/mdc_request.c | 2 +- .../staging/lustre/lustre/mgc/mgc_request.c | 4 +- .../staging/lustre/lustre/obdclass/genops.c | 11 +++++ .../lustre/lustre/obdclass/lprocfs_status.c | 40 ++++++++++++++++++- .../staging/lustre/lustre/osc/osc_request.c | 2 +- 9 files changed, 64 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 1bbc93017ce7..3225e3c20992 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -62,6 +62,7 @@ struct lprocfs_vars { struct lprocfs_static_vars { struct lprocfs_vars *obd_vars; + struct attribute_group *sysfs_vars; }; /* if we find more consumers this could be generalized */ @@ -605,7 +606,8 @@ extern void lprocfs_remove(struct proc_dir_entry **root); extern void lprocfs_remove_proc_entry(const char *name, struct proc_dir_entry *parent); -extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list); +extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list, + struct attribute_group *attrs); extern int lprocfs_obd_cleanup(struct obd_device *obd); extern int ldebugfs_seq_create(struct dentry *parent, diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 2a88b806fca5..7bba91260e31 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -249,6 +249,7 @@ struct obd_type { int typ_refcnt; struct lu_device_type *typ_lu; spinlock_t obd_type_lock; + struct kobject *typ_kobj; }; struct brw_page { @@ -936,6 +937,9 @@ struct obd_device { struct lu_ref obd_reference; int obd_conn_inprogress; + + struct kobject obd_kobj; /* sysfs object */ + struct completion obd_kobj_unregister; }; #define OBD_LLOG_FL_SENDNOW 0x0001 diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 0b2d35f26fc5..14764ee96a93 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -1309,7 +1309,7 @@ int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid, static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { struct lmv_obd *lmv = &obd->u.lmv; - struct lprocfs_static_vars lvars; + struct lprocfs_static_vars lvars = { NULL }; struct lmv_desc *desc; int rc; @@ -1343,7 +1343,7 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) lprocfs_lmv_init_vars(&lvars); - lprocfs_obd_setup(obd, lvars.obd_vars); + lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars); #if defined (CONFIG_PROC_FS) { rc = lprocfs_seq_create(obd->obd_proc_entry, "target_obd", diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index d4e8d9c30ed3..44739eae0108 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -821,7 +821,7 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) goto out; lprocfs_lov_init_vars(&lvars); - lprocfs_obd_setup(obd, lvars.obd_vars); + lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars); #if defined (CONFIG_PROC_FS) { int rc1; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index b24ec3f848f3..9f34d67b8f4e 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -2447,7 +2447,7 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) if (rc) goto err_close_lock; lprocfs_mdc_init_vars(&lvars); - lprocfs_obd_setup(obd, lvars.obd_vars); + lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars); sptlrpc_lprocfs_cliobd_attach(obd); ptlrpc_lprocfs_register_obd(obd); diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 5fff272f7b9f..517b8ce1a44a 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -722,7 +722,7 @@ static int mgc_cleanup(struct obd_device *obd) static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { - struct lprocfs_static_vars lvars; + struct lprocfs_static_vars lvars = { NULL }; int rc; ptlrpcd_addref(); @@ -738,7 +738,7 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) } lprocfs_mgc_init_vars(&lvars); - lprocfs_obd_setup(obd, lvars.obd_vars); + lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars); sptlrpc_lprocfs_cliobd_attach(obd); if (atomic_inc_return(&mgc_count) == 1) { diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index eab4130d6c49..8e3dfafcf62d 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -199,6 +199,12 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, goto failed; } + type->typ_kobj = kobject_create_and_add(type->typ_name, lustre_kobj); + if (!type->typ_kobj) { + rc = -ENOMEM; + goto failed; + } + if (ldt != NULL) { type->typ_lu = ldt; rc = lu_device_type_init(ldt); @@ -213,6 +219,8 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, return 0; failed: + if (type->typ_kobj) + kobject_put(type->typ_kobj); kfree(type->typ_name); kfree(type->typ_md_ops); kfree(type->typ_dt_ops); @@ -239,6 +247,9 @@ int class_unregister_type(const char *name) return -EBUSY; } + if (type->typ_kobj) + kobject_put(type->typ_kobj); + if (type->typ_procroot) { lprocfs_remove(&type->typ_procroot); } diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 695b3e0dcfcf..e6f0d11205c9 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -994,7 +994,26 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data) } EXPORT_SYMBOL(lprocfs_rd_connect_flags); -int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list) +static struct attribute *obd_def_attrs[] = { + NULL, +}; + +static void obd_sysfs_release(struct kobject *kobj) +{ + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); + + complete(&obd->obd_kobj_unregister); +} + +static struct kobj_type obd_ktype = { + .default_attrs = obd_def_attrs, + .sysfs_ops = &lustre_sysfs_ops, + .release = obd_sysfs_release, +}; + +int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list, + struct attribute_group *attrs) { int rc = 0; @@ -1002,15 +1021,32 @@ int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list) LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC); LASSERT(obd->obd_type->typ_procroot != NULL); + init_completion(&obd->obd_kobj_unregister); + rc = kobject_init_and_add(&obd->obd_kobj, &obd_ktype, + obd->obd_type->typ_kobj, + "%s", obd->obd_name); + if (rc) + return rc; + + if (attrs) { + rc = sysfs_create_group(&obd->obd_kobj, attrs); + if (rc) { + kobject_put(&obd->obd_kobj); + return rc; + } + } + obd->obd_proc_entry = lprocfs_register(obd->obd_name, obd->obd_type->typ_procroot, list, obd); if (IS_ERR(obd->obd_proc_entry)) { + kobject_put(&obd->obd_kobj); rc = PTR_ERR(obd->obd_proc_entry); CERROR("error %d setting up lprocfs for %s\n", rc, obd->obd_name); obd->obd_proc_entry = NULL; } + return rc; } EXPORT_SYMBOL(lprocfs_obd_setup); @@ -1028,6 +1064,8 @@ int lprocfs_obd_cleanup(struct obd_device *obd) lprocfs_remove(&obd->obd_proc_entry); obd->obd_proc_entry = NULL; } + kobject_put(&obd->obd_kobj); + wait_for_completion(&obd->obd_kobj_unregister); return 0; } EXPORT_SYMBOL(lprocfs_obd_cleanup); diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 5924f9f1b5b1..6b6851ad3990 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -3184,7 +3184,7 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) cli->cl_grant_shrink_interval = GRANT_SHRINK_INTERVAL; lprocfs_osc_init_vars(&lvars); - if (lprocfs_obd_setup(obd, lvars.obd_vars) == 0) { + if (lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars) == 0) { lproc_osc_attach_seqstat(obd); sptlrpc_lprocfs_cliobd_attach(obd); ptlrpc_lprocfs_register_obd(obd); From 0bc36cb06e4bc5e936f2f442535daf557c7a4200 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:32:17 -0400 Subject: [PATCH 0633/1163] staging/lustre/obdclass: Move common obd proc files to sysfs This moves uuid display and also underlying fs statistics. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lprocfs_status.h | 7 -- drivers/staging/lustre/lustre/lmv/lproc_lmv.c | 3 - drivers/staging/lustre/lustre/lov/lproc_lov.c | 15 ---- drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 14 ---- drivers/staging/lustre/lustre/mgc/lproc_mgc.c | 2 - .../lustre/lustre/obdclass/lprocfs_status.c | 79 ++++++++++++------- drivers/staging/lustre/lustre/osc/lproc_osc.c | 14 ---- drivers/staging/lustre/sysfs-fs-lustre | 48 +++++++++++ 8 files changed, 97 insertions(+), 85 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 3225e3c20992..bbacda6ebd91 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -633,7 +633,6 @@ extern int lprocfs_wr_atomic(struct file *file, const char __user *buffer, extern int lprocfs_rd_uint(struct seq_file *m, void *data); extern int lprocfs_wr_uint(struct file *file, const char __user *buffer, unsigned long count, void *data); -extern int lprocfs_rd_uuid(struct seq_file *m, void *data); extern int lprocfs_rd_name(struct seq_file *m, void *data); extern int lprocfs_rd_server_uuid(struct seq_file *m, void *data); extern int lprocfs_rd_conn_uuid(struct seq_file *m, void *data); @@ -658,12 +657,6 @@ extern int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer, size_t count, loff_t *off); /* Statfs helpers */ -extern int lprocfs_rd_blksize(struct seq_file *m, void *data); -extern int lprocfs_rd_kbytestotal(struct seq_file *m, void *data); -extern int lprocfs_rd_kbytesfree(struct seq_file *m, void *data); -extern int lprocfs_rd_kbytesavail(struct seq_file *m, void *data); -extern int lprocfs_rd_filestotal(struct seq_file *m, void *data); -extern int lprocfs_rd_filesfree(struct seq_file *m, void *data); extern int lprocfs_write_helper(const char __user *buffer, unsigned long count, int *val); diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index 76b32d56eb08..debd8972f99f 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -204,13 +204,10 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file) return 0; } -LPROC_SEQ_FOPS_RO_TYPE(lmv, uuid); - static struct lprocfs_vars lprocfs_lmv_obd_vars[] = { { "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 } }; diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index 18fdd7ec75c4..92489daa5f32 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c @@ -262,29 +262,14 @@ static int lov_target_seq_open(struct inode *inode, struct file *file) return 0; } -LPROC_SEQ_FOPS_RO_TYPE(lov, uuid); -LPROC_SEQ_FOPS_RO_TYPE(lov, filestotal); -LPROC_SEQ_FOPS_RO_TYPE(lov, filesfree); -LPROC_SEQ_FOPS_RO_TYPE(lov, blksize); -LPROC_SEQ_FOPS_RO_TYPE(lov, kbytestotal); -LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesfree); -LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesavail); - static struct lprocfs_vars lprocfs_lov_obd_vars[] = { - { "uuid", &lov_uuid_fops, NULL, 0 }, { "stripesize", &lov_stripesize_fops, NULL }, { "stripeoffset", &lov_stripeoffset_fops, NULL }, { "stripecount", &lov_stripecount_fops, NULL }, { "stripetype", &lov_stripetype_fops, NULL }, { "numobd", &lov_numobd_fops, NULL, 0 }, { "activeobd", &lov_activeobd_fops, NULL, 0 }, - { "filestotal", &lov_filestotal_fops, NULL, 0 }, - { "filesfree", &lov_filesfree_fops, NULL, 0 }, /*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/ - { "blocksize", &lov_blksize_fops, NULL, 0 }, - { "kbytestotal", &lov_kbytestotal_fops, NULL, 0 }, - { "kbytesfree", &lov_kbytesfree_fops, NULL, 0 }, - { "kbytesavail", &lov_kbytesavail_fops, NULL, 0 }, { "desc_uuid", &lov_desc_uuid_fops, NULL, 0 }, { NULL } }; diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index 5c38cd7c22e7..b1ef178b6f2f 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -155,14 +155,7 @@ static struct file_operations mdc_kuc_fops = { LPROC_SEQ_FOPS_WR_ONLY(mdc, ping); -LPROC_SEQ_FOPS_RO_TYPE(mdc, uuid); LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags); -LPROC_SEQ_FOPS_RO_TYPE(mdc, blksize); -LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytestotal); -LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytesfree); -LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytesavail); -LPROC_SEQ_FOPS_RO_TYPE(mdc, filestotal); -LPROC_SEQ_FOPS_RO_TYPE(mdc, filesfree); LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid); LPROC_SEQ_FOPS_RO_TYPE(mdc, conn_uuid); LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts); @@ -178,15 +171,8 @@ LPROC_SEQ_FOPS_RW_TYPE(mdc, import); LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov); static struct lprocfs_vars lprocfs_mdc_obd_vars[] = { - { "uuid", &mdc_uuid_fops, NULL, 0 }, { "ping", &mdc_ping_fops, NULL, 0222 }, { "connect_flags", &mdc_connect_flags_fops, NULL, 0 }, - { "blocksize", &mdc_blksize_fops, NULL, 0 }, - { "kbytestotal", &mdc_kbytestotal_fops, NULL, 0 }, - { "kbytesfree", &mdc_kbytesfree_fops, NULL, 0 }, - { "kbytesavail", &mdc_kbytesavail_fops, NULL, 0 }, - { "filestotal", &mdc_filestotal_fops, NULL, 0 }, - { "filesfree", &mdc_filesfree_fops, NULL, 0 }, /*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/ { "mds_server_uuid", &mdc_server_uuid_fops, NULL, 0 }, { "mds_conn_uuid", &mdc_conn_uuid_fops, NULL, 0 }, diff --git a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c index ad889e71bd6c..34a9317d6d63 100644 --- a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c +++ b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c @@ -40,7 +40,6 @@ #include "../include/lprocfs_status.h" #include "mgc_internal.h" -LPROC_SEQ_FOPS_RO_TYPE(mgc, uuid); LPROC_SEQ_FOPS_RO_TYPE(mgc, connect_flags); LPROC_SEQ_FOPS_RO_TYPE(mgc, server_uuid); LPROC_SEQ_FOPS_RO_TYPE(mgc, conn_uuid); @@ -56,7 +55,6 @@ 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, 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 }, diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index e6f0d11205c9..5b1b59a6187b 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -501,15 +501,15 @@ int lprocfs_wr_atomic(struct file *file, const char __user *buffer, } EXPORT_SYMBOL(lprocfs_wr_atomic); -int lprocfs_rd_uuid(struct seq_file *m, void *data) +static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *obd = data; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); - LASSERT(obd != NULL); - seq_printf(m, "%s\n", obd->obd_uuid.uuid); - return 0; + return sprintf(buf, "%s\n", obd->obd_uuid.uuid); } -EXPORT_SYMBOL(lprocfs_rd_uuid); +LUSTRE_RO_ATTR(uuid); int lprocfs_rd_name(struct seq_file *m, void *data) { @@ -521,23 +521,27 @@ int lprocfs_rd_name(struct seq_file *m, void *data) } EXPORT_SYMBOL(lprocfs_rd_name); -int lprocfs_rd_blksize(struct seq_file *m, void *data) +static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *obd = data; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) - seq_printf(m, "%u\n", osfs.os_bsize); + return sprintf(buf, "%u\n", osfs.os_bsize); return rc; } -EXPORT_SYMBOL(lprocfs_rd_blksize); +LUSTRE_RO_ATTR(blocksize); -int lprocfs_rd_kbytestotal(struct seq_file *m, void *data) +static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *obd = data; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), @@ -549,16 +553,18 @@ int lprocfs_rd_kbytestotal(struct seq_file *m, void *data) while (blk_size >>= 1) result <<= 1; - seq_printf(m, "%llu\n", result); + return sprintf(buf, "%llu\n", result); } return rc; } -EXPORT_SYMBOL(lprocfs_rd_kbytestotal); +LUSTRE_RO_ATTR(kbytestotal); -int lprocfs_rd_kbytesfree(struct seq_file *m, void *data) +static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *obd = data; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), @@ -570,16 +576,18 @@ int lprocfs_rd_kbytesfree(struct seq_file *m, void *data) while (blk_size >>= 1) result <<= 1; - seq_printf(m, "%llu\n", result); + return sprintf(buf, "%llu\n", result); } return rc; } -EXPORT_SYMBOL(lprocfs_rd_kbytesfree); +LUSTRE_RO_ATTR(kbytesfree); -int lprocfs_rd_kbytesavail(struct seq_file *m, void *data) +static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *obd = data; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), @@ -591,40 +599,44 @@ int lprocfs_rd_kbytesavail(struct seq_file *m, void *data) while (blk_size >>= 1) result <<= 1; - seq_printf(m, "%llu\n", result); + return sprintf(buf, "%llu\n", result); } return rc; } -EXPORT_SYMBOL(lprocfs_rd_kbytesavail); +LUSTRE_RO_ATTR(kbytesavail); -int lprocfs_rd_filestotal(struct seq_file *m, void *data) +static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *obd = data; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) - seq_printf(m, "%llu\n", osfs.os_files); + return sprintf(buf, "%llu\n", osfs.os_files); return rc; } -EXPORT_SYMBOL(lprocfs_rd_filestotal); +LUSTRE_RO_ATTR(filestotal); -int lprocfs_rd_filesfree(struct seq_file *m, void *data) +static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *obd = data; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) - seq_printf(m, "%llu\n", osfs.os_ffree); + return sprintf(buf, "%llu\n", osfs.os_ffree); return rc; } -EXPORT_SYMBOL(lprocfs_rd_filesfree); +LUSTRE_RO_ATTR(filesfree); int lprocfs_rd_server_uuid(struct seq_file *m, void *data) { @@ -995,6 +1007,13 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data) EXPORT_SYMBOL(lprocfs_rd_connect_flags); static struct attribute *obd_def_attrs[] = { + &lustre_attr_blocksize.attr, + &lustre_attr_kbytestotal.attr, + &lustre_attr_kbytesfree.attr, + &lustre_attr_kbytesavail.attr, + &lustre_attr_filestotal.attr, + &lustre_attr_filesfree.attr, + &lustre_attr_uuid.attr, NULL, }; diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 93ad272fe46d..199913d7dddf 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -520,14 +520,7 @@ static ssize_t osc_obd_max_pages_per_rpc_seq_write(struct file *file, } LPROC_SEQ_FOPS(osc_obd_max_pages_per_rpc); -LPROC_SEQ_FOPS_RO_TYPE(osc, uuid); LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags); -LPROC_SEQ_FOPS_RO_TYPE(osc, blksize); -LPROC_SEQ_FOPS_RO_TYPE(osc, kbytestotal); -LPROC_SEQ_FOPS_RO_TYPE(osc, kbytesfree); -LPROC_SEQ_FOPS_RO_TYPE(osc, kbytesavail); -LPROC_SEQ_FOPS_RO_TYPE(osc, filestotal); -LPROC_SEQ_FOPS_RO_TYPE(osc, filesfree); LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid); LPROC_SEQ_FOPS_RO_TYPE(osc, conn_uuid); LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts); @@ -539,15 +532,8 @@ 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, 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 }, diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index 9817cb37020a..61101f272a39 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -336,3 +336,51 @@ Contact: "Oleg Drokin" Description: Controls what percentage of ldlm callback threads is dedicated to "high priority" incoming requests. + +What: /sys/fs/lustre/{obdtype}/{connection_name}/blocksize +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Blocksize on backend filesystem for service behind this obd + device (or biggest blocksize for compound devices like lov + and lmv) + +What: /sys/fs/lustre/{obdtype}/{connection_name}/kbytestotal +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Total number of kilobytes of space on backend filesystem + for service behind this obd (or total amount for compound + devices like lov lmv) + +What: /sys/fs/lustre/{obdtype}/{connection_name}/kbytesfree +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Number of free kilobytes on backend filesystem for service + behind this obd (or total amount for compound devices + like lov lmv) + +What: /sys/fs/lustre/{obdtype}/{connection_name}/kbytesavail +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Number of kilobytes of free space on backend filesystem + for service behind this obd (or total amount for compound + devices like lov lmv) that is actually available for use + (taking into account per-client and filesystem reservations). + +What: /sys/fs/lustre/{obdtype}/{connection_name}/filestotal +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Number of inodes on backend filesystem for service behind this + obd. + +What: /sys/fs/lustre/{obdtype}/{connection_name}/filesfree +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Number of free inodes on backend filesystem for service + behind this obd. + From d8ede3f1d5d94618442a61067c6b98a2afbb0962 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:32:18 -0400 Subject: [PATCH 0634/1163] staging/lustre/llite: make llite/lov and lmv symlinks old proc code had /proc/sys/fs/lustre/llite/.../lov and lmv dirs that contained name of the dir in lustre/lov and lustre/lmv to better be able to find correct obd device there, but I imagien a better solution would be to just create a symlink with the same name. The name is then pointless and the target dir would have uuid file just as if it was the old-style dir. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/llite/lproc_llite.c | 49 ++----------------- 1 file changed, 4 insertions(+), 45 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index e1fc62084bb1..2c84bed3f6ce 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -950,24 +950,17 @@ static const char *ra_stat_string[] = { [RA_STAT_WRONG_GRAB_PAGE] = "wrong page from grab_cache_page", }; -LPROC_SEQ_FOPS_RO_TYPE(llite, name); -LPROC_SEQ_FOPS_RO_TYPE(llite, uuid); - int lprocfs_register_mountpoint(struct proc_dir_entry *parent, struct super_block *sb, char *osc, char *mdc) { - struct lprocfs_vars lvars[2]; struct lustre_sb_info *lsi = s2lsi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); struct obd_device *obd; - struct proc_dir_entry *dir; char name[MAX_STRING_SIZE + 1], *ptr; int err, id, len, rc; - memset(lvars, 0, sizeof(lvars)); name[MAX_STRING_SIZE] = '\0'; - lvars[0].name = name; LASSERT(sbi != NULL); LASSERT(mdc != NULL); @@ -1066,50 +1059,16 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, /* MDC info */ obd = class_name2obd(mdc); - LASSERT(obd != NULL); - LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC); - LASSERT(obd->obd_type->typ_name != NULL); - - dir = proc_mkdir(obd->obd_type->typ_name, sbi->ll_proc_root); - if (dir == NULL) { - err = -ENOMEM; - goto out; - } - - snprintf(name, MAX_STRING_SIZE, "common_name"); - lvars[0].fops = &llite_name_fops; - err = lprocfs_add_vars(dir, lvars, obd); - if (err) - goto out; - - snprintf(name, MAX_STRING_SIZE, "uuid"); - lvars[0].fops = &llite_uuid_fops; - err = lprocfs_add_vars(dir, lvars, obd); + err = sysfs_create_link(&sbi->ll_kobj, &obd->obd_kobj, + obd->obd_type->typ_name); if (err) goto out; /* OSC */ obd = class_name2obd(osc); - LASSERT(obd != NULL); - LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC); - LASSERT(obd->obd_type->typ_name != NULL); - - dir = proc_mkdir(obd->obd_type->typ_name, sbi->ll_proc_root); - if (dir == NULL) { - err = -ENOMEM; - goto out; - } - - snprintf(name, MAX_STRING_SIZE, "common_name"); - lvars[0].fops = &llite_name_fops; - err = lprocfs_add_vars(dir, lvars, obd); - if (err) - goto out; - - snprintf(name, MAX_STRING_SIZE, "uuid"); - lvars[0].fops = &llite_uuid_fops; - err = lprocfs_add_vars(dir, lvars, obd); + err = sysfs_create_link(&sbi->ll_kobj, &obd->obd_kobj, + obd->obd_type->typ_name); out: if (err) { lprocfs_remove(&sbi->ll_proc_root); From 2ee26222d497cf75eb9a02f324dee8b6b16e1e67 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:32:20 -0400 Subject: [PATCH 0635/1163] staging/lustre/mdc: move mdc-specific procfs files to sysfs This moves max_rpcs_in_flight and max_pages_per_rpc to /proc/fs/lustre/mdc/.../ Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 68 ++++++++++++------- drivers/staging/lustre/sysfs-fs-lustre | 16 +++++ 2 files changed, 60 insertions(+), 24 deletions(-) diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index b1ef178b6f2f..2121ca761a26 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -40,29 +40,34 @@ #include "../include/lprocfs_status.h" #include "mdc_internal.h" -static int mdc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v) +static ssize_t max_rpcs_in_flight_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; + int len; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; client_obd_list_lock(&cli->cl_loi_list_lock); - seq_printf(m, "%u\n", cli->cl_max_rpcs_in_flight); + len = sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight); client_obd_list_unlock(&cli->cl_loi_list_lock); - return 0; + return len; } -static ssize_t mdc_max_rpcs_in_flight_seq_write(struct file *file, - const char __user *buffer, - size_t count, - loff_t *off) +static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *dev = - ((struct seq_file *)file->private_data)->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; - int val, rc; + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; @@ -75,7 +80,7 @@ static ssize_t mdc_max_rpcs_in_flight_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(mdc_max_rpcs_in_flight); +LUSTRE_RW_ATTR(max_rpcs_in_flight); static int mdc_kuc_open(struct inode *inode, struct file *file) { @@ -161,11 +166,23 @@ LPROC_SEQ_FOPS_RO_TYPE(mdc, conn_uuid); LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts); LPROC_SEQ_FOPS_RO_TYPE(mdc, state); -static int mdc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v) +/* + * Note: below sysfs entry is provided, but not currently in use, instead + * sbi->sb_md_brw_size is used, the per obd variable should be used + * when DNE is enabled, and dir pages are managed in MDC layer. + * Don't forget to enable sysfs store function then. + */ +static ssize_t max_pages_per_rpc_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - return lprocfs_obd_rd_max_pages_per_rpc(m, m->private); + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); + struct client_obd *cli = &dev->u.cli; + + return sprintf(buf, "%d\n", cli->cl_max_pages_per_rpc); } -LPROC_SEQ_FOPS_RO(mdc_obd_max_pages_per_rpc); +LUSTRE_RO_ATTR(max_pages_per_rpc); LPROC_SEQ_FOPS_RW_TYPE(mdc, import); LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov); @@ -176,14 +193,6 @@ static struct lprocfs_vars lprocfs_mdc_obd_vars[] = { /*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/ { "mds_server_uuid", &mdc_server_uuid_fops, NULL, 0 }, { "mds_conn_uuid", &mdc_conn_uuid_fops, NULL, 0 }, - /* - * FIXME: below proc entry is provided, but not in used, instead - * sbi->sb_md_brw_size is used, the per obd variable should be used - * when CMD is enabled, and dir pages are managed in MDC layer. - * Remember to enable proc write function. - */ - { "max_pages_per_rpc", &mdc_obd_max_pages_per_rpc_fops, NULL, 0 }, - { "max_rpcs_in_flight", &mdc_max_rpcs_in_flight_fops, NULL, 0 }, { "timeouts", &mdc_timeouts_fops, NULL, 0 }, { "import", &mdc_import_fops, NULL, 0 }, { "state", &mdc_state_fops, NULL, 0 }, @@ -192,7 +201,18 @@ static struct lprocfs_vars lprocfs_mdc_obd_vars[] = { { NULL } }; +static struct attribute *mdc_attrs[] = { + &lustre_attr_max_rpcs_in_flight.attr, + &lustre_attr_max_pages_per_rpc.attr, + NULL, +}; + +static struct attribute_group mdc_attr_group = { + .attrs = mdc_attrs, +}; + void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars) { + lvars->sysfs_vars = &mdc_attr_group; lvars->obd_vars = lprocfs_mdc_obd_vars; } diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index 61101f272a39..a99078c25d6a 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -384,3 +384,19 @@ Description: Number of free inodes on backend filesystem for service behind this obd. +What: /sys/fs/lustre/mdc/{connection_name}/max_pages_per_rpc +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Maximum number of readdir pages to fit into a single readdir + RPC. + +What: /sys/fs/lustre/mdc/{connection_name}/max_rpcs_in_flight +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Maximum number of parallel RPCs on the wire to allow on + this connection. Increasing this number would help on higher + latency links, but has a chance of overloading a server + if you have too many clients like this. + Default: 8 From aab38b00ac19347bf982cf42c71aab14a9301dee Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:32:21 -0400 Subject: [PATCH 0636/1163] staging/lustre/osc: move suitable values from procfs to sysfs All single-value controls are moved from /proc/fs/lustre/osc/.../ to /sys/fs/lustre/osc/.../ Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/osc/lproc_osc.c | 371 ++++++++++-------- drivers/staging/lustre/sysfs-fs-lustre | 107 ++++- 2 files changed, 314 insertions(+), 164 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 199913d7dddf..2f07ea5a736b 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -42,25 +42,25 @@ #include #include "osc_internal.h" -static int osc_active_seq_show(struct seq_file *m, void *v) +static ssize_t active_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); - LPROCFS_CLIMP_CHECK(dev); - seq_printf(m, "%d\n", !dev->u.cli.cl_import->imp_deactive); - LPROCFS_CLIMP_EXIT(dev); - - return 0; + return sprintf(buf, "%d\n", !dev->u.cli.cl_import->imp_deactive); } -static ssize_t osc_active_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t active_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - int val, rc; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; if (val < 0 || val > 1) @@ -70,41 +70,43 @@ static ssize_t osc_active_seq_write(struct file *file, if (dev->u.cli.cl_import->imp_deactive == val) rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val); else - CDEBUG(D_CONFIG, "activate %d: ignoring repeat request\n", val); + CDEBUG(D_CONFIG, "activate %ld: ignoring repeat request\n", + val); return count; } -LPROC_SEQ_FOPS(osc_active); +LUSTRE_RW_ATTR(active); -static int osc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v) +static ssize_t max_rpcs_in_flight_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; - client_obd_list_lock(&cli->cl_loi_list_lock); - seq_printf(m, "%u\n", cli->cl_max_rpcs_in_flight); - client_obd_list_unlock(&cli->cl_loi_list_lock); - - return 0; + return sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight); } -static ssize_t osc_max_rpcs_in_flight_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; struct ptlrpc_request_pool *pool = cli->cl_import->imp_rq_pool; - int val, rc; + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; if (val < 1 || val > OSC_MAX_RIF_MAX) return -ERANGE; - LPROCFS_CLIMP_CHECK(dev); if (pool && val > cli->cl_max_rpcs_in_flight) pool->prp_populate(pool, val-cli->cl_max_rpcs_in_flight); @@ -112,14 +114,16 @@ static ssize_t osc_max_rpcs_in_flight_seq_write(struct file *file, cli->cl_max_rpcs_in_flight = val; client_obd_list_unlock(&cli->cl_loi_list_lock); - LPROCFS_CLIMP_EXIT(dev); return count; } -LPROC_SEQ_FOPS(osc_max_rpcs_in_flight); +LUSTRE_RW_ATTR(max_rpcs_in_flight); -static int osc_max_dirty_mb_seq_show(struct seq_file *m, void *v) +static ssize_t max_dirty_mb_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; long val; int mult; @@ -129,22 +133,26 @@ static int osc_max_dirty_mb_seq_show(struct seq_file *m, void *v) client_obd_list_unlock(&cli->cl_loi_list_lock); mult = 1 << 20; - return lprocfs_seq_read_frac_helper(m, val, mult); + return lprocfs_read_frac_helper(buf, PAGE_SIZE, val, mult); } -static ssize_t osc_max_dirty_mb_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t max_dirty_mb_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; - int pages_number, mult, rc; + int rc; + unsigned long pages_number; - mult = 1 << (20 - PAGE_CACHE_SHIFT); - rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult); + rc = kstrtoul(buffer, 10, &pages_number); if (rc) return rc; + pages_number *= 1 << (20 - PAGE_CACHE_SHIFT); /* MB -> pages */ + if (pages_number <= 0 || pages_number > OSC_MAX_DIRTY_MB_MAX << (20 - PAGE_CACHE_SHIFT) || pages_number > totalram_pages / 4) /* 1/4 of RAM */ @@ -157,7 +165,7 @@ static ssize_t osc_max_dirty_mb_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(osc_max_dirty_mb); +LUSTRE_RW_ATTR(max_dirty_mb); static int osc_cached_mb_seq_show(struct seq_file *m, void *v) { @@ -210,44 +218,51 @@ static ssize_t osc_cached_mb_seq_write(struct file *file, } LPROC_SEQ_FOPS(osc_cached_mb); -static int osc_cur_dirty_bytes_seq_show(struct seq_file *m, void *v) +static ssize_t cur_dirty_bytes_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; + int len; client_obd_list_lock(&cli->cl_loi_list_lock); - seq_printf(m, "%lu\n", cli->cl_dirty); + len = sprintf(buf, "%lu\n", cli->cl_dirty); client_obd_list_unlock(&cli->cl_loi_list_lock); - return 0; + return len; } -LPROC_SEQ_FOPS_RO(osc_cur_dirty_bytes); +LUSTRE_RO_ATTR(cur_dirty_bytes); -static int osc_cur_grant_bytes_seq_show(struct seq_file *m, void *v) +static ssize_t cur_grant_bytes_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; + int len; client_obd_list_lock(&cli->cl_loi_list_lock); - seq_printf(m, "%lu\n", cli->cl_avail_grant); + len = sprintf(buf, "%lu\n", cli->cl_avail_grant); client_obd_list_unlock(&cli->cl_loi_list_lock); - return 0; + return len; } -static ssize_t osc_cur_grant_bytes_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t cur_grant_bytes_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &obd->u.cli; - int rc; - __u64 val; + int rc; + unsigned long long val; - if (obd == NULL) - return 0; - - rc = lprocfs_write_u64_helper(buffer, count, &val); + rc = kstrtoull(buffer, 10, &val); if (rc) return rc; @@ -255,54 +270,56 @@ static ssize_t osc_cur_grant_bytes_seq_write(struct file *file, client_obd_list_lock(&cli->cl_loi_list_lock); if (val >= cli->cl_avail_grant) { client_obd_list_unlock(&cli->cl_loi_list_lock); - return 0; + return -EINVAL; } client_obd_list_unlock(&cli->cl_loi_list_lock); - LPROCFS_CLIMP_CHECK(obd); if (cli->cl_import->imp_state == LUSTRE_IMP_FULL) rc = osc_shrink_grant_to_target(cli, val); - LPROCFS_CLIMP_EXIT(obd); if (rc) return rc; return count; } -LPROC_SEQ_FOPS(osc_cur_grant_bytes); +LUSTRE_RW_ATTR(cur_grant_bytes); -static int osc_cur_lost_grant_bytes_seq_show(struct seq_file *m, void *v) +static ssize_t cur_lost_grant_bytes_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; + int len; client_obd_list_lock(&cli->cl_loi_list_lock); - seq_printf(m, "%lu\n", cli->cl_lost_grant); + len = sprintf(buf, "%lu\n", cli->cl_lost_grant); client_obd_list_unlock(&cli->cl_loi_list_lock); - return 0; + return len; } -LPROC_SEQ_FOPS_RO(osc_cur_lost_grant_bytes); +LUSTRE_RO_ATTR(cur_lost_grant_bytes); -static int osc_grant_shrink_interval_seq_show(struct seq_file *m, void *v) +static ssize_t grant_shrink_interval_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *obd = m->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); - if (obd == NULL) - return 0; - seq_printf(m, "%d\n", obd->u.cli.cl_grant_shrink_interval); - return 0; + return sprintf(buf, "%d\n", obd->u.cli.cl_grant_shrink_interval); } -static ssize_t osc_grant_shrink_interval_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t grant_shrink_interval_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - int val, rc; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); + int rc; + unsigned long val; - if (obd == NULL) - return 0; - - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; @@ -313,30 +330,29 @@ static ssize_t osc_grant_shrink_interval_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(osc_grant_shrink_interval); +LUSTRE_RW_ATTR(grant_shrink_interval); -static int osc_checksum_seq_show(struct seq_file *m, void *v) +static ssize_t checksums_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *obd = m->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); - if (obd == NULL) - return 0; - - seq_printf(m, "%d\n", obd->u.cli.cl_checksum ? 1 : 0); - return 0; + return sprintf(buf, "%d\n", obd->u.cli.cl_checksum ? 1 : 0); } -static ssize_t osc_checksum_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t checksums_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - int val, rc; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); + int rc; + unsigned long val; - if (obd == NULL) - return 0; - - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; @@ -344,7 +360,7 @@ static ssize_t osc_checksum_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(osc_checksum); +LUSTRE_RW_ATTR(checksums); static int osc_checksum_type_seq_show(struct seq_file *m, void *v) { @@ -400,22 +416,27 @@ static ssize_t osc_checksum_type_seq_write(struct file *file, } LPROC_SEQ_FOPS(osc_checksum_type); -static int osc_resend_count_seq_show(struct seq_file *m, void *v) +static ssize_t resend_count_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *obd = m->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); - seq_printf(m, "%u\n", atomic_read(&obd->u.cli.cl_resends)); - return 0; + return sprintf(buf, "%u\n", atomic_read(&obd->u.cli.cl_resends)); } -static ssize_t osc_resend_count_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t resend_count_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - int val, rc; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; @@ -426,75 +447,94 @@ static ssize_t osc_resend_count_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(osc_resend_count); +LUSTRE_RW_ATTR(resend_count); -static int osc_contention_seconds_seq_show(struct seq_file *m, void *v) +static ssize_t contention_seconds_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *obd = m->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct osc_device *od = obd2osc_dev(obd); - seq_printf(m, "%u\n", od->od_contention_time); - return 0; + return sprintf(buf, "%u\n", od->od_contention_time); } -static ssize_t osc_contention_seconds_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t contention_seconds_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct osc_device *od = obd2osc_dev(obd); return lprocfs_write_helper(buffer, count, &od->od_contention_time) ?: count; } -LPROC_SEQ_FOPS(osc_contention_seconds); +LUSTRE_RW_ATTR(contention_seconds); -static int osc_lockless_truncate_seq_show(struct seq_file *m, void *v) +static ssize_t lockless_truncate_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *obd = m->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct osc_device *od = obd2osc_dev(obd); - seq_printf(m, "%u\n", od->od_lockless_truncate); - return 0; + return sprintf(buf, "%u\n", od->od_lockless_truncate); } -static ssize_t osc_lockless_truncate_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t lockless_truncate_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct osc_device *od = obd2osc_dev(obd); return lprocfs_write_helper(buffer, count, &od->od_lockless_truncate) ?: count; } -LPROC_SEQ_FOPS(osc_lockless_truncate); +LUSTRE_RW_ATTR(lockless_truncate); -static int osc_destroys_in_flight_seq_show(struct seq_file *m, void *v) +static ssize_t destroys_in_flight_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *obd = m->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); - seq_printf(m, "%u\n", atomic_read(&obd->u.cli.cl_destroy_in_flight)); - return 0; + return sprintf(buf, "%u\n", + atomic_read(&obd->u.cli.cl_destroy_in_flight)); } -LPROC_SEQ_FOPS_RO(osc_destroys_in_flight); +LUSTRE_RO_ATTR(destroys_in_flight); -static int osc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v) +static ssize_t max_pages_per_rpc_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - return lprocfs_obd_rd_max_pages_per_rpc(m, m->private); + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); + struct client_obd *cli = &dev->u.cli; + + return sprintf(buf, "%d\n", cli->cl_max_pages_per_rpc); } -static ssize_t osc_obd_max_pages_per_rpc_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t max_pages_per_rpc_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; struct obd_connect_data *ocd = &cli->cl_import->imp_connect_data; int chunk_mask, rc; - __u64 val; + unsigned long long val; - rc = lprocfs_write_u64_helper(buffer, count, &val); + rc = kstrtoull(buffer, 10, &val); if (rc) return rc; @@ -502,23 +542,19 @@ static ssize_t osc_obd_max_pages_per_rpc_seq_write(struct file *file, if (val >= ONE_MB_BRW_SIZE) val >>= PAGE_CACHE_SHIFT; - LPROCFS_CLIMP_CHECK(dev); - chunk_mask = ~((1 << (cli->cl_chunkbits - PAGE_CACHE_SHIFT)) - 1); /* max_pages_per_rpc must be chunk aligned */ val = (val + ~chunk_mask) & chunk_mask; if (val == 0 || val > ocd->ocd_brw_size >> PAGE_CACHE_SHIFT) { - LPROCFS_CLIMP_EXIT(dev); return -ERANGE; } client_obd_list_lock(&cli->cl_loi_list_lock); cli->cl_max_pages_per_rpc = val; client_obd_list_unlock(&cli->cl_loi_list_lock); - LPROCFS_CLIMP_EXIT(dev); return count; } -LPROC_SEQ_FOPS(osc_obd_max_pages_per_rpc); +LUSTRE_RW_ATTR(max_pages_per_rpc); LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags); LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid); @@ -537,22 +573,9 @@ static struct lprocfs_vars lprocfs_osc_obd_vars[] = { /*{ "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 }, @@ -724,7 +747,29 @@ int lproc_osc_attach_seqstat(struct obd_device *dev) return rc; } +static struct attribute *osc_attrs[] = { + &lustre_attr_active.attr, + &lustre_attr_checksums.attr, + &lustre_attr_contention_seconds.attr, + &lustre_attr_cur_dirty_bytes.attr, + &lustre_attr_cur_grant_bytes.attr, + &lustre_attr_cur_lost_grant_bytes.attr, + &lustre_attr_destroys_in_flight.attr, + &lustre_attr_grant_shrink_interval.attr, + &lustre_attr_lockless_truncate.attr, + &lustre_attr_max_dirty_mb.attr, + &lustre_attr_max_pages_per_rpc.attr, + &lustre_attr_max_rpcs_in_flight.attr, + &lustre_attr_resend_count.attr, + NULL, +}; + +static struct attribute_group osc_attr_group = { + .attrs = osc_attrs, +}; + void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars) { + lvars->sysfs_vars = &osc_attr_group; lvars->obd_vars = lprocfs_osc_obd_vars; } diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index a99078c25d6a..5e2d55b5b173 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -391,7 +391,7 @@ Description: Maximum number of readdir pages to fit into a single readdir RPC. -What: /sys/fs/lustre/mdc/{connection_name}/max_rpcs_in_flight +What: /sys/fs/lustre/{mdc,osc}/{connection_name}/max_rpcs_in_flight Date: May 2015 Contact: "Oleg Drokin" Description: @@ -400,3 +400,108 @@ Description: latency links, but has a chance of overloading a server if you have too many clients like this. Default: 8 + +What: /sys/fs/lustre/osc/{connection_name}/max_pages_per_rpc +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Maximum number of pages to fit into a single RPC. + Typically bigger RPCs allow for better performance. + Default: however many pages to form 1M of data (256 pages + for 4K page sized platforms) + +What: /sys/fs/lustre/osc/{connection_name}/active +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Controls accessibility of this connection. If set to 0, + fail all accesses immediately. + +What: /sys/fs/lustre/osc/{connection_name}/checksums +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Controls whenever to checksum bulk RPC data over the wire + to this target. + 1: enable (default) ; 0: disable + +What: /sys/fs/lustre/osc/{connection_name}/contention_seconds +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Controls for how long to consider a file contended once + indicated as such by the server. + When a file is considered contended, all operations switch to + synchronous lockless mode to avoid cache and lock pingpong. + +What: /sys/fs/lustre/osc/{connection_name}/cur_dirty_bytes +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Displays how many dirty bytes is presently in the cache for this + target. + +What: /sys/fs/lustre/osc/{connection_name}/cur_grant_bytes +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Shows how many bytes we have as a "dirty cache" grant from the + server. Writing a value smaller than shown allows to release + some grant back to the server. + Dirty cache grant is a way Lustre ensures that cached successful + writes on client do not end up discarded by the server due to + lack of space later on. + +What: /sys/fs/lustre/osc/{connection_name}/cur_lost_grant_bytes +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Shows how many granted bytes were released to the server due + to lack of write activity on this client. + +What: /sys/fs/lustre/osc/{connection_name}/grant_shrink_interval +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Number of seconds with no write activity for this target + to start releasing dirty grant back to the server. + +What: /sys/fs/lustre/osc/{connection_name}/destroys_in_flight +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Number of DESTROY RPCs currently in flight to this target. + +What: /sys/fs/lustre/osc/{connection_name}/lockless_truncate +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Controls whether lockless truncate RPCs are allowed to this + target. + Lockless truncate causes server to perform the locking which + is beneficial if the truncate is not followed by a write + immediately. + 1: enable ; 0: disable (default) + +What: /sys/fs/lustre/osc/{connection_name}/max_dirty_mb +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Controls how much dirty data this client can accumulate + for this target. This is orthogonal to dirty grant and is + a hard limit even if the server would allow a bigger dirty + cache. + While allowing higher dirty cache is beneficial for write + performance, flushing write cache takes longer and as such + the node might be more prone to OOMs. + Having this value set too low might result in not being able + to sent too many parallel WRITE RPCs. + Default: 32 + +What: /sys/fs/lustre/osc/{connection_name}/resend_count +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Controls how many times to try and resend RPCs to this target + that failed with "recoverable" status, such as EAGAIN, + ENOMEM. From cb1debff6d8b254536ec6ff642a2bdd22c86cb85 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:32:22 -0400 Subject: [PATCH 0637/1163] staging/lustre/lov: Move suitable variables from procfs to sysfs Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/obd.h | 2 + drivers/staging/lustre/lustre/lov/lov_obd.c | 44 +++++++------------ drivers/staging/lustre/lustre/lov/lproc_lov.c | 39 +++++++++------- drivers/staging/lustre/sysfs-fs-lustre | 13 ++++++ 4 files changed, 55 insertions(+), 43 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 7bba91260e31..d67464691702 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -573,6 +573,8 @@ struct lov_obd { void *lov_cache; struct rw_semaphore lov_notify_lock; + + struct kobject *lov_tgts_kobj; }; struct lmv_tgt_desc { diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 44739eae0108..caf1aff2a0a5 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -127,7 +127,6 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, struct obd_device *tgt_obd; static struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" }; struct obd_import *imp; - struct proc_dir_entry *lov_proc_dir; int rc; if (!lov->lov_tgts[index]) @@ -186,28 +185,10 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, CDEBUG(D_CONFIG, "Connected tgt idx %d %s (%s) %sactive\n", index, obd_uuid2str(tgt_uuid), tgt_obd->obd_name, activate ? "":"in"); - lov_proc_dir = obd->obd_proc_private; - if (lov_proc_dir) { - struct obd_device *osc_obd = lov->lov_tgts[index]->ltd_exp->exp_obd; - struct proc_dir_entry *osc_symlink; - - LASSERT(osc_obd != NULL); - LASSERT(osc_obd->obd_magic == OBD_DEVICE_MAGIC); - LASSERT(osc_obd->obd_type->typ_name != NULL); - - osc_symlink = lprocfs_add_symlink(osc_obd->obd_name, - lov_proc_dir, - "../../../%s/%s", - osc_obd->obd_type->typ_name, - osc_obd->obd_name); - if (osc_symlink == NULL) { - CERROR("could not register LOV target /proc/fs/lustre/%s/%s/target_obds/%s.", - obd->obd_type->typ_name, obd->obd_name, - osc_obd->obd_name); - lprocfs_remove(&lov_proc_dir); - obd->obd_proc_private = NULL; - } - } + if (lov->lov_tgts_kobj) + /* Even if we failed, that's ok */ + rc = sysfs_create_link(lov->lov_tgts_kobj, &tgt_obd->obd_kobj, + tgt_obd->obd_name); return 0; } @@ -239,6 +220,10 @@ static int lov_connect(const struct lu_env *env, lov->lov_ocd = *data; obd_getref(obd); + + lov->lov_tgts_kobj = kobject_create_and_add("target_obds", + &obd->obd_kobj); + for (i = 0; i < lov->desc.ld_tgt_count; i++) { tgt = lov->lov_tgts[i]; if (!tgt || obd_uuid_empty(&tgt->ltd_uuid)) @@ -268,7 +253,6 @@ static int lov_connect(const struct lu_env *env, static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) { - struct proc_dir_entry *lov_proc_dir; struct lov_obd *lov = &obd->u.lov; struct obd_device *osc_obd; int rc; @@ -284,10 +268,10 @@ static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) } 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); - } + if (lov->lov_tgts_kobj) + sysfs_remove_link(lov->lov_tgts_kobj, + osc_obd->obd_name); + /* 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. @@ -337,6 +321,10 @@ static int lov_disconnect(struct obd_export *exp) lov_del_target(obd, i, NULL, lov->lov_tgts[i]->ltd_gen); } } + + if (lov->lov_tgts_kobj) + kobject_put(lov->lov_tgts_kobj); + obd_putref(obd); out: diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index 92489daa5f32..41bb5b585a61 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c @@ -166,29 +166,29 @@ static ssize_t lov_stripecount_seq_write(struct file *file, } LPROC_SEQ_FOPS(lov_stripecount); -static int lov_numobd_seq_show(struct seq_file *m, void *v) +static ssize_t numobd_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = (struct obd_device *)m->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct lov_desc *desc; - LASSERT(dev != NULL); desc = &dev->u.lov.desc; - seq_printf(m, "%u\n", desc->ld_tgt_count); - return 0; + return sprintf(buf, "%u\n", desc->ld_tgt_count); } -LPROC_SEQ_FOPS_RO(lov_numobd); +LUSTRE_RO_ATTR(numobd); -static int lov_activeobd_seq_show(struct seq_file *m, void *v) +static ssize_t activeobd_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = (struct obd_device *)m->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct lov_desc *desc; - LASSERT(dev != NULL); desc = &dev->u.lov.desc; - seq_printf(m, "%u\n", desc->ld_active_tgt_count); - return 0; + return sprintf(buf, "%u\n", desc->ld_active_tgt_count); } -LPROC_SEQ_FOPS_RO(lov_activeobd); +LUSTRE_RO_ATTR(activeobd); static int lov_desc_uuid_seq_show(struct seq_file *m, void *v) { @@ -267,16 +267,25 @@ static struct lprocfs_vars lprocfs_lov_obd_vars[] = { { "stripeoffset", &lov_stripeoffset_fops, NULL }, { "stripecount", &lov_stripecount_fops, NULL }, { "stripetype", &lov_stripetype_fops, NULL }, - { "numobd", &lov_numobd_fops, NULL, 0 }, - { "activeobd", &lov_activeobd_fops, NULL, 0 }, /*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/ { "desc_uuid", &lov_desc_uuid_fops, NULL, 0 }, { NULL } }; +static struct attribute *lov_attrs[] = { + &lustre_attr_activeobd.attr, + &lustre_attr_numobd.attr, + NULL, +}; + +static struct attribute_group lov_attr_group = { + .attrs = lov_attrs, +}; + void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars) { - lvars->obd_vars = lprocfs_lov_obd_vars; + lvars->sysfs_vars = &lov_attr_group; + lvars->obd_vars = lprocfs_lov_obd_vars; } const struct file_operations lov_proc_target_fops = { diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index 5e2d55b5b173..c7fe14cbbb2d 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -505,3 +505,16 @@ Description: Controls how many times to try and resend RPCs to this target that failed with "recoverable" status, such as EAGAIN, ENOMEM. + +What: /sys/fs/lustre/lov/{connection_name}/numobd +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Number of OSC targets managed by this LOV instance. + +What: /sys/fs/lustre/lov/{connection_name}/activeobd +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Number of OSC targets managed by this LOV instance that are + actually active. From b5fa70d76fb1c532dd4468b8083e2945c9df9ddb Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:32:23 -0400 Subject: [PATCH 0638/1163] staging/lustre/lmv: Move suitable entries from procfs to sysfs Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/obd.h | 2 +- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 60 +++--------- drivers/staging/lustre/lustre/lmv/lproc_lmv.c | 92 ++++++++++--------- drivers/staging/lustre/sysfs-fs-lustre | 23 +++++ 4 files changed, 85 insertions(+), 92 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index d67464691702..c24fb1c51b62 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -613,6 +613,7 @@ struct lmv_obd { struct lmv_tgt_desc **tgts; struct obd_connect_data conn_data; + struct kobject *lmv_tgts_kobj; }; struct niobuf_local { @@ -917,7 +918,6 @@ struct obd_device { struct lprocfs_stats *md_stats; struct proc_dir_entry *obd_proc_entry; - void *obd_proc_private; /* type private PDEs */ struct proc_dir_entry *obd_proc_exports_entry; struct proc_dir_entry *obd_svc_procroot; struct lprocfs_stats *obd_svc_stats; diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 14764ee96a93..695a4ed9e627 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -199,7 +199,6 @@ static int lmv_connect(const struct lu_env *env, struct obd_uuid *cluuid, struct obd_connect_data *data, void *localdata) { - struct proc_dir_entry *lmv_proc_dir; struct lmv_obd *lmv = &obd->u.lmv; struct lustre_handle conn = { 0 }; int rc = 0; @@ -230,19 +229,8 @@ static int lmv_connect(const struct lu_env *env, if (data) lmv->conn_data = *data; - if (obd->obd_proc_private != NULL) { - lmv_proc_dir = obd->obd_proc_private; - } else { - lmv_proc_dir = lprocfs_register("target_obds", obd->obd_proc_entry, - NULL, NULL); - if (IS_ERR(lmv_proc_dir)) { - CERROR("could not register /proc/fs/lustre/%s/%s/target_obds.", - obd->obd_type->typ_name, obd->obd_name); - lmv_proc_dir = NULL; - } - obd->obd_proc_private = lmv_proc_dir; - } - + lmv->lmv_tgts_kobj = kobject_create_and_add("target_obds", + &obd->obd_kobj); /* * All real clients should perform actual connection right away, because * it is possible, that LMV will not have opportunity to connect targets @@ -252,10 +240,8 @@ static int lmv_connect(const struct lu_env *env, if (data->ocd_connect_flags & OBD_CONNECT_REAL) rc = lmv_check_connect(obd); - if (rc && lmv_proc_dir) { - lprocfs_remove(&lmv_proc_dir); - obd->obd_proc_private = NULL; - } + if (rc && lmv->lmv_tgts_kobj) + kobject_put(lmv->lmv_tgts_kobj); return rc; } @@ -337,7 +323,6 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize, static int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) { - struct proc_dir_entry *lmv_proc_dir; struct lmv_obd *lmv = &obd->u.lmv; struct obd_uuid *cluuid = &lmv->cluuid; struct obd_uuid lmv_mdc_uuid = { "LMV_MDC_UUID" }; @@ -415,25 +400,10 @@ static int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) mdc_obd->obd_name, mdc_obd->obd_uuid.uuid, atomic_read(&obd->obd_refcount)); - lmv_proc_dir = obd->obd_proc_private; - if (lmv_proc_dir) { - struct proc_dir_entry *mdc_symlink; - - LASSERT(mdc_obd->obd_type != NULL); - LASSERT(mdc_obd->obd_type->typ_name != NULL); - mdc_symlink = lprocfs_add_symlink(mdc_obd->obd_name, - lmv_proc_dir, - "../../../%s/%s", - mdc_obd->obd_type->typ_name, - mdc_obd->obd_name); - if (mdc_symlink == NULL) { - CERROR("Could not register LMV target /proc/fs/lustre/%s/%s/target_obds/%s.", - obd->obd_type->typ_name, obd->obd_name, - mdc_obd->obd_name); - lprocfs_remove(&lmv_proc_dir); - obd->obd_proc_private = NULL; - } - } + if (lmv->lmv_tgts_kobj) + /* Even if we failed to create the link, that's fine */ + rc = sysfs_create_link(lmv->lmv_tgts_kobj, &mdc_obd->obd_kobj, + mdc_obd->obd_name); return 0; } @@ -610,7 +580,6 @@ int lmv_check_connect(struct obd_device *obd) static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) { - struct proc_dir_entry *lmv_proc_dir; struct lmv_obd *lmv = &obd->u.lmv; struct obd_device *mdc_obd; int rc; @@ -626,9 +595,9 @@ static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) mdc_obd->obd_no_recov = obd->obd_no_recov; } - lmv_proc_dir = obd->obd_proc_private; - if (lmv_proc_dir) - lprocfs_remove_proc_entry(mdc_obd->obd_name, lmv_proc_dir); + if (lmv->lmv_tgts_kobj) + sysfs_remove_link(lmv->lmv_tgts_kobj, + mdc_obd->obd_name); rc = obd_fid_fini(tgt->ltd_exp->exp_obd); if (rc) @@ -676,11 +645,8 @@ static int lmv_disconnect(struct obd_export *exp) lmv_disconnect_mdc(obd, lmv->tgts[i]); } - if (obd->obd_proc_private) - lprocfs_remove((struct proc_dir_entry **)&obd->obd_proc_private); - else - CERROR("/proc/fs/lustre/%s/%s/target_obds missing\n", - obd->obd_type->typ_name, obd->obd_name); + if (lmv->lmv_tgts_kobj) + kobject_put(lmv->lmv_tgts_kobj); out_local: /* diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index debd8972f99f..b113e5aa0103 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -42,17 +42,17 @@ #include "../include/obd_class.h" #include "lmv_internal.h" -static int lmv_numobd_seq_show(struct seq_file *m, void *v) +static ssize_t numobd_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = (struct obd_device *)m->private; - struct lmv_desc *desc; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); + struct lmv_desc *desc; - LASSERT(dev != NULL); desc = &dev->u.lmv.desc; - seq_printf(m, "%u\n", desc->ld_tgt_count); - return 0; + return sprintf(buf, "%u\n", desc->ld_tgt_count); } -LPROC_SEQ_FOPS_RO(lmv_numobd); +LUSTRE_RO_ATTR(numobd); static const char *placement_name[] = { [PLACEMENT_CHAR_POLICY] = "CHAR", @@ -77,66 +77,61 @@ static const char *placement_policy2name(enum placement_policy placement) return placement_name[placement]; } -static int lmv_placement_seq_show(struct seq_file *m, void *v) +static ssize_t placement_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = (struct obd_device *)m->private; - struct lmv_obd *lmv; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); + struct lmv_obd *lmv; - LASSERT(dev != NULL); lmv = &dev->u.lmv; - seq_printf(m, "%s\n", placement_policy2name(lmv->lmv_placement)); - return 0; + return sprintf(buf, "%s\n", placement_policy2name(lmv->lmv_placement)); } #define MAX_POLICY_STRING_SIZE 64 -static ssize_t lmv_placement_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t placement_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - char dummy[MAX_POLICY_STRING_SIZE + 1]; - int len = count; - enum placement_policy policy; - struct lmv_obd *lmv; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); + char dummy[MAX_POLICY_STRING_SIZE + 1]; + enum placement_policy policy; + struct lmv_obd *lmv = &dev->u.lmv; - if (copy_from_user(dummy, buffer, MAX_POLICY_STRING_SIZE)) - return -EFAULT; + memcpy(dummy, buffer, MAX_POLICY_STRING_SIZE); - LASSERT(dev != NULL); - lmv = &dev->u.lmv; + if (count > MAX_POLICY_STRING_SIZE) + count = MAX_POLICY_STRING_SIZE; - if (len > MAX_POLICY_STRING_SIZE) - len = MAX_POLICY_STRING_SIZE; + if (dummy[count - 1] == '\n') + count--; + dummy[count] = '\0'; - if (dummy[len - 1] == '\n') - len--; - dummy[len] = '\0'; - - policy = placement_name2policy(dummy, len); + policy = placement_name2policy(dummy, count); if (policy != PLACEMENT_INVAL_POLICY) { spin_lock(&lmv->lmv_lock); lmv->lmv_placement = policy; spin_unlock(&lmv->lmv_lock); } else { - CERROR("Invalid placement policy \"%s\"!\n", dummy); return -EINVAL; } return count; } -LPROC_SEQ_FOPS(lmv_placement); +LUSTRE_RW_ATTR(placement); -static int lmv_activeobd_seq_show(struct seq_file *m, void *v) +static ssize_t activeobd_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = (struct obd_device *)m->private; - struct lmv_desc *desc; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); + struct lmv_desc *desc; - LASSERT(dev != NULL); desc = &dev->u.lmv.desc; - seq_printf(m, "%u\n", desc->ld_active_tgt_count); - return 0; + return sprintf(buf, "%u\n", desc->ld_active_tgt_count); } -LPROC_SEQ_FOPS_RO(lmv_activeobd); +LUSTRE_RO_ATTR(activeobd); static int lmv_desc_uuid_seq_show(struct seq_file *m, void *v) { @@ -205,9 +200,6 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file) } static struct lprocfs_vars lprocfs_lmv_obd_vars[] = { - { "numobd", &lmv_numobd_fops, NULL, 0 }, - { "placement", &lmv_placement_fops, NULL, 0 }, - { "activeobd", &lmv_activeobd_fops, NULL, 0 }, { "desc_uuid", &lmv_desc_uuid_fops, NULL, 0 }, { NULL } }; @@ -220,7 +212,19 @@ struct file_operations lmv_proc_target_fops = { .release = seq_release, }; +static struct attribute *lmv_attrs[] = { + &lustre_attr_activeobd.attr, + &lustre_attr_numobd.attr, + &lustre_attr_placement.attr, + NULL, +}; + +static struct attribute_group lmv_attr_group = { + .attrs = lmv_attrs, +}; + void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars) { + lvars->sysfs_vars = &lmv_attr_group; lvars->obd_vars = lprocfs_lmv_obd_vars; } diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index c7fe14cbbb2d..1e302e8516ce 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -518,3 +518,26 @@ Contact: "Oleg Drokin" Description: Number of OSC targets managed by this LOV instance that are actually active. + +What: /sys/fs/lustre/lmv/{connection_name}/numobd +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Number of MDC targets managed by this LMV instance. + +What: /sys/fs/lustre/lmv/{connection_name}/activeobd +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Number of MDC targets managed by this LMV instance that are + actually active. + +What: /sys/fs/lustre/lmv/{connection_name}/placement +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Determines policy of inode placement in case of multiple + metadata servers: + CHAR - based on a hash of the file name used at creation time + (Default) + NID - based on a hash of creating client network id. From 4ed8ddb09b2b11f115845961e280ee9d796ff262 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Thu, 21 May 2015 15:32:24 -0400 Subject: [PATCH 0639/1163] staging/lustre/obdclass: remove unused sysctl enum definition Since we are removing lustre sysctls, this enum is no longer needed. Signed-off-by: Dmitry Eremin Signed-off-by: Greg Kroah-Hartman --- .../lustre/obdclass/linux/linux-sysctl.c | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c index 4b62d25764ad..8927e24a599f 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c @@ -55,30 +55,6 @@ static struct ctl_table_header *obd_table_header; #endif - -#define OBD_SYSCTL 300 - -enum { - OBD_TIMEOUT = 3, /* RPC timeout before recovery/intr */ - OBD_DUMP_ON_TIMEOUT, /* dump kernel debug log upon eviction */ - OBD_MEMUSED, /* bytes currently OBD_ALLOCated */ - OBD_PAGESUSED, /* pages currently OBD_PAGE_ALLOCated */ - OBD_MAXMEMUSED, /* maximum bytes OBD_ALLOCated concurrently */ - OBD_MAXPAGESUSED, /* maximum pages OBD_PAGE_ALLOCated concurrently */ - OBD_SYNCFILTER, /* XXX temporary, as we play with sync osts.. */ - OBD_LDLM_TIMEOUT, /* LDLM timeout for ASTs before client eviction */ - OBD_DUMP_ON_EVICTION, /* dump kernel debug log upon eviction */ - OBD_DEBUG_PEER_ON_TIMEOUT, /* dump peer debug when RPC times out */ - OBD_ALLOC_FAIL_RATE, /* memory allocation random failure rate */ - OBD_MAX_DIRTY_PAGES, /* maximum dirty pages */ - OBD_AT_MIN, /* Adaptive timeouts params */ - OBD_AT_MAX, - OBD_AT_EXTRA, - OBD_AT_EARLY_MARGIN, - OBD_AT_HISTORY, -}; - - #ifdef CONFIG_SYSCTL static int proc_set_timeout(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) From f3aa79fbef7942971825fb2084a88e9527c6b04c Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Thu, 21 May 2015 15:32:25 -0400 Subject: [PATCH 0640/1163] staging/lustre/fid: move all files from procfs to debugfs Signed-off-by: Dmitry Eremin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/fid/fid_internal.h | 6 +- .../staging/lustre/lustre/fid/fid_request.c | 63 ++++++++----------- drivers/staging/lustre/lustre/fid/lproc_fid.c | 49 ++++++++------- .../lustre/lustre/include/lustre_fid.h | 2 +- 4 files changed, 54 insertions(+), 66 deletions(-) diff --git a/drivers/staging/lustre/lustre/fid/fid_internal.h b/drivers/staging/lustre/lustre/fid/fid_internal.h index b5e8da8956f2..84daee1154dc 100644 --- a/drivers/staging/lustre/lustre/fid/fid_internal.h +++ b/drivers/staging/lustre/lustre/fid/fid_internal.h @@ -47,10 +47,6 @@ int seq_client_alloc_super(struct lu_client_seq *seq, const struct lu_env *env); -#if defined(CONFIG_PROC_FS) -extern struct lprocfs_vars seq_client_proc_list[]; -#endif - -extern struct proc_dir_entry *seq_type_proc_dir; +extern struct lprocfs_vars seq_client_debugfs_list[]; #endif /* __FID_INTERNAL_H */ diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c index 7aee3935d31c..7b4e3c6782c3 100644 --- a/drivers/staging/lustre/lustre/fid/fid_request.c +++ b/drivers/staging/lustre/lustre/fid/fid_request.c @@ -53,6 +53,8 @@ #include "../include/lustre_mdc.h" #include "fid_internal.h" +static struct dentry *seq_debugfs_dir; + static int seq_client_rpc(struct lu_client_seq *seq, struct lu_seq_range *output, __u32 opc, const char *opcname) @@ -400,37 +402,32 @@ void seq_client_flush(struct lu_client_seq *seq) } EXPORT_SYMBOL(seq_client_flush); -static void seq_client_proc_fini(struct lu_client_seq *seq) +static void seq_client_debugfs_fini(struct lu_client_seq *seq) { -#if defined(CONFIG_PROC_FS) - if (seq->lcs_proc_dir) { - if (!IS_ERR(seq->lcs_proc_dir)) - lprocfs_remove(&seq->lcs_proc_dir); - seq->lcs_proc_dir = NULL; - } -#endif /* CONFIG_PROC_FS */ + if (!IS_ERR_OR_NULL(seq->lcs_debugfs_entry)) + ldebugfs_remove(&seq->lcs_debugfs_entry); } -static int seq_client_proc_init(struct lu_client_seq *seq) +static int seq_client_debugfs_init(struct lu_client_seq *seq) { -#if defined(CONFIG_PROC_FS) int rc; - seq->lcs_proc_dir = lprocfs_register(seq->lcs_name, - seq_type_proc_dir, - NULL, NULL); + seq->lcs_debugfs_entry = ldebugfs_register(seq->lcs_name, + seq_debugfs_dir, + NULL, NULL); - if (IS_ERR(seq->lcs_proc_dir)) { - CERROR("%s: LProcFS failed in seq-init\n", - seq->lcs_name); - rc = PTR_ERR(seq->lcs_proc_dir); + if (IS_ERR_OR_NULL(seq->lcs_debugfs_entry)) { + CERROR("%s: LdebugFS failed in seq-init\n", seq->lcs_name); + rc = seq->lcs_debugfs_entry ? PTR_ERR(seq->lcs_debugfs_entry) + : -ENOMEM; + seq->lcs_debugfs_entry = NULL; return rc; } - rc = lprocfs_add_vars(seq->lcs_proc_dir, - seq_client_proc_list, seq); + rc = ldebugfs_add_vars(seq->lcs_debugfs_entry, + seq_client_debugfs_list, seq); if (rc) { - CERROR("%s: Can't init sequence manager proc, rc %d\n", + CERROR("%s: Can't init sequence manager debugfs, rc %d\n", seq->lcs_name, rc); goto out_cleanup; } @@ -438,12 +435,8 @@ static int seq_client_proc_init(struct lu_client_seq *seq) return 0; out_cleanup: - seq_client_proc_fini(seq); + seq_client_debugfs_fini(seq); return rc; - -#else /* CONFIG_PROC_FS */ - return 0; -#endif } int seq_client_init(struct lu_client_seq *seq, @@ -478,7 +471,7 @@ int seq_client_init(struct lu_client_seq *seq, snprintf(seq->lcs_name, sizeof(seq->lcs_name), "cli-%s", prefix); - rc = seq_client_proc_init(seq); + rc = seq_client_debugfs_init(seq); if (rc) seq_client_fini(seq); return rc; @@ -487,7 +480,7 @@ EXPORT_SYMBOL(seq_client_init); void seq_client_fini(struct lu_client_seq *seq) { - seq_client_proc_fini(seq); + seq_client_debugfs_fini(seq); if (seq->lcs_exp != NULL) { class_export_put(seq->lcs_exp); @@ -545,22 +538,18 @@ int client_fid_fini(struct obd_device *obd) } EXPORT_SYMBOL(client_fid_fini); -struct proc_dir_entry *seq_type_proc_dir; - static int __init fid_mod_init(void) { - seq_type_proc_dir = lprocfs_register(LUSTRE_SEQ_NAME, - proc_lustre_root, - NULL, NULL); - return PTR_ERR_OR_ZERO(seq_type_proc_dir); + seq_debugfs_dir = ldebugfs_register(LUSTRE_SEQ_NAME, + debugfs_lustre_root, + NULL, NULL); + return PTR_ERR_OR_ZERO(seq_debugfs_dir); } static void __exit fid_mod_exit(void) { - if (seq_type_proc_dir != NULL && !IS_ERR(seq_type_proc_dir)) { - lprocfs_remove(&seq_type_proc_dir); - seq_type_proc_dir = NULL; - } + if (!IS_ERR_OR_NULL(seq_debugfs_dir)) + ldebugfs_remove(&seq_debugfs_dir); } MODULE_AUTHOR("Sun Microsystems, Inc. "); diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c b/drivers/staging/lustre/lustre/fid/lproc_fid.c index 783939dbd4db..41ab2eeaf18c 100644 --- a/drivers/staging/lustre/lustre/fid/lproc_fid.c +++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c @@ -59,8 +59,9 @@ * Note: this function is only used for testing, it is no safe for production * use. */ -static int lprocfs_fid_write_common(const char __user *buffer, size_t count, - struct lu_seq_range *range) +static int +ldebugfs_fid_write_common(const char __user *buffer, size_t count, + struct lu_seq_range *range) { struct lu_seq_range tmp; int rc; @@ -92,10 +93,11 @@ static int lprocfs_fid_write_common(const char __user *buffer, size_t count, return count; } -/* Client side procfs stuff */ -static ssize_t lprocfs_fid_space_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +/* Client side debugfs stuff */ +static ssize_t +ldebugfs_fid_space_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct lu_client_seq *seq; int rc; @@ -104,7 +106,7 @@ static ssize_t lprocfs_fid_space_seq_write(struct file *file, LASSERT(seq != NULL); mutex_lock(&seq->lcs_mutex); - rc = lprocfs_fid_write_common(buffer, count, &seq->lcs_space); + rc = ldebugfs_fid_write_common(buffer, count, &seq->lcs_space); if (rc == 0) { CDEBUG(D_INFO, "%s: Space: "DRANGE"\n", @@ -117,7 +119,7 @@ static ssize_t lprocfs_fid_space_seq_write(struct file *file, } static int -lprocfs_fid_space_seq_show(struct seq_file *m, void *unused) +ldebugfs_fid_space_seq_show(struct seq_file *m, void *unused) { struct lu_client_seq *seq = (struct lu_client_seq *)m->private; @@ -130,9 +132,10 @@ lprocfs_fid_space_seq_show(struct seq_file *m, void *unused) return 0; } -static ssize_t lprocfs_fid_width_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t +ldebugfs_fid_width_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct lu_client_seq *seq; __u64 max; @@ -166,7 +169,7 @@ static ssize_t lprocfs_fid_width_seq_write(struct file *file, } static int -lprocfs_fid_width_seq_show(struct seq_file *m, void *unused) +ldebugfs_fid_width_seq_show(struct seq_file *m, void *unused) { struct lu_client_seq *seq = (struct lu_client_seq *)m->private; @@ -180,7 +183,7 @@ lprocfs_fid_width_seq_show(struct seq_file *m, void *unused) } static int -lprocfs_fid_fid_seq_show(struct seq_file *m, void *unused) +ldebugfs_fid_fid_seq_show(struct seq_file *m, void *unused) { struct lu_client_seq *seq = (struct lu_client_seq *)m->private; @@ -194,7 +197,7 @@ lprocfs_fid_fid_seq_show(struct seq_file *m, void *unused) } static int -lprocfs_fid_server_seq_show(struct seq_file *m, void *unused) +ldebugfs_fid_server_seq_show(struct seq_file *m, void *unused) { struct lu_client_seq *seq = (struct lu_client_seq *)m->private; struct client_obd *cli; @@ -211,15 +214,15 @@ lprocfs_fid_server_seq_show(struct seq_file *m, void *unused) return 0; } -LPROC_SEQ_FOPS(lprocfs_fid_space); -LPROC_SEQ_FOPS(lprocfs_fid_width); -LPROC_SEQ_FOPS_RO(lprocfs_fid_server); -LPROC_SEQ_FOPS_RO(lprocfs_fid_fid); +LPROC_SEQ_FOPS(ldebugfs_fid_space); +LPROC_SEQ_FOPS(ldebugfs_fid_width); +LPROC_SEQ_FOPS_RO(ldebugfs_fid_server); +LPROC_SEQ_FOPS_RO(ldebugfs_fid_fid); -struct lprocfs_vars seq_client_proc_list[] = { - { "space", &lprocfs_fid_space_fops }, - { "width", &lprocfs_fid_width_fops }, - { "server", &lprocfs_fid_server_fops }, - { "fid", &lprocfs_fid_fid_fops }, +struct lprocfs_vars seq_client_debugfs_list[] = { + { "space", &ldebugfs_fid_space_fops }, + { "width", &ldebugfs_fid_width_fops }, + { "server", &ldebugfs_fid_server_fops }, + { "fid", &ldebugfs_fid_fid_fops }, { NULL } }; diff --git a/drivers/staging/lustre/lustre/include/lustre_fid.h b/drivers/staging/lustre/lustre/include/lustre_fid.h index 0a0929fd9023..0592f2bca008 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fid.h +++ b/drivers/staging/lustre/lustre/include/lustre_fid.h @@ -346,7 +346,7 @@ struct lu_client_seq { struct lu_seq_range lcs_space; /* Seq related proc */ - struct proc_dir_entry *lcs_proc_dir; + struct dentry *lcs_debugfs_entry; /* This holds last allocated fid in last obtained seq */ struct lu_fid lcs_fid; From 827650494fbe9390052502d0498c8b90b2e329ec Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Thu, 21 May 2015 15:32:26 -0400 Subject: [PATCH 0641/1163] staging/lustre/fld: move all files from procfs to debugfs Signed-off-by: Dmitry Eremin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/fld/fld_internal.h | 5 +- .../staging/lustre/lustre/fld/fld_request.c | 66 +++++++------------ drivers/staging/lustre/lustre/fld/lproc_fld.c | 42 ++++++------ .../lustre/lustre/include/lustre_fld.h | 12 ++-- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 2 +- 5 files changed, 55 insertions(+), 72 deletions(-) diff --git a/drivers/staging/lustre/lustre/fld/fld_internal.h b/drivers/staging/lustre/lustre/fld/fld_internal.h index 68bec7658463..844576b9bc6f 100644 --- a/drivers/staging/lustre/lustre/fld/fld_internal.h +++ b/drivers/staging/lustre/lustre/fld/fld_internal.h @@ -142,10 +142,7 @@ extern struct lu_fld_hash fld_hash[]; int fld_client_rpc(struct obd_export *exp, struct lu_seq_range *range, __u32 fld_op); -#if defined(CONFIG_PROC_FS) -extern struct lprocfs_vars fld_client_proc_list[]; -#endif - +extern struct lprocfs_vars fld_client_debugfs_list[]; struct fld_cache *fld_cache_init(const char *name, int cache_size, int cache_threshold); diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c index 075eb5ceedb6..c3b47f2346df 100644 --- a/drivers/staging/lustre/lustre/fld/fld_request.c +++ b/drivers/staging/lustre/lustre/fld/fld_request.c @@ -277,58 +277,44 @@ int fld_client_del_target(struct lu_client_fld *fld, __u64 idx) } EXPORT_SYMBOL(fld_client_del_target); -static struct proc_dir_entry *fld_type_proc_dir; +static struct dentry *fld_debugfs_dir; -#if defined(CONFIG_PROC_FS) -static int fld_client_proc_init(struct lu_client_fld *fld) +static int fld_client_debugfs_init(struct lu_client_fld *fld) { int rc; - fld->lcf_proc_dir = lprocfs_register(fld->lcf_name, - fld_type_proc_dir, - NULL, NULL); + fld->lcf_debugfs_entry = ldebugfs_register(fld->lcf_name, + fld_debugfs_dir, + NULL, NULL); - if (IS_ERR(fld->lcf_proc_dir)) { - CERROR("%s: LProcFS failed in fld-init\n", - fld->lcf_name); - rc = PTR_ERR(fld->lcf_proc_dir); + if (IS_ERR_OR_NULL(fld->lcf_debugfs_entry)) { + CERROR("%s: LdebugFS failed in fld-init\n", fld->lcf_name); + rc = fld->lcf_debugfs_entry ? PTR_ERR(fld->lcf_debugfs_entry) + : -ENOMEM; + fld->lcf_debugfs_entry = NULL; return rc; } - rc = lprocfs_add_vars(fld->lcf_proc_dir, - fld_client_proc_list, fld); + rc = ldebugfs_add_vars(fld->lcf_debugfs_entry, + fld_client_debugfs_list, fld); if (rc) { - CERROR("%s: Can't init FLD proc, rc %d\n", - fld->lcf_name, rc); + CERROR("%s: Can't init FLD debufs, rc %d\n", fld->lcf_name, rc); goto out_cleanup; } return 0; out_cleanup: - fld_client_proc_fini(fld); + fld_client_debugfs_fini(fld); return rc; } -void fld_client_proc_fini(struct lu_client_fld *fld) +void fld_client_debugfs_fini(struct lu_client_fld *fld) { - if (fld->lcf_proc_dir) { - if (!IS_ERR(fld->lcf_proc_dir)) - lprocfs_remove(&fld->lcf_proc_dir); - fld->lcf_proc_dir = NULL; - } + if (!IS_ERR_OR_NULL(fld->lcf_debugfs_entry)) + ldebugfs_remove(&fld->lcf_debugfs_entry); } -#else -static int fld_client_proc_init(struct lu_client_fld *fld) -{ - return 0; -} - -void fld_client_proc_fini(struct lu_client_fld *fld) -{ -} -#endif -EXPORT_SYMBOL(fld_client_proc_fini); +EXPORT_SYMBOL(fld_client_debugfs_fini); static inline int hash_is_sane(int hash) { @@ -372,7 +358,7 @@ int fld_client_init(struct lu_client_fld *fld, goto out; } - rc = fld_client_proc_init(fld); + rc = fld_client_debugfs_init(fld); if (rc) goto out; out: @@ -504,18 +490,16 @@ EXPORT_SYMBOL(fld_client_flush); static int __init fld_mod_init(void) { - fld_type_proc_dir = lprocfs_register(LUSTRE_FLD_NAME, - proc_lustre_root, - NULL, NULL); - return PTR_ERR_OR_ZERO(fld_type_proc_dir); + fld_debugfs_dir = ldebugfs_register(LUSTRE_FLD_NAME, + debugfs_lustre_root, + NULL, NULL); + return PTR_ERR_OR_ZERO(fld_debugfs_dir); } static void __exit fld_mod_exit(void) { - if (fld_type_proc_dir != NULL && !IS_ERR(fld_type_proc_dir)) { - lprocfs_remove(&fld_type_proc_dir); - fld_type_proc_dir = NULL; - } + if (!IS_ERR_OR_NULL(fld_debugfs_dir)) + ldebugfs_remove(&fld_debugfs_dir); } MODULE_AUTHOR("Sun Microsystems, Inc. "); diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c index f53fdcfae34e..b35ff288dbd5 100644 --- a/drivers/staging/lustre/lustre/fld/lproc_fld.c +++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c @@ -56,7 +56,7 @@ #include "fld_internal.h" static int -fld_proc_targets_seq_show(struct seq_file *m, void *unused) +fld_debugfs_targets_seq_show(struct seq_file *m, void *unused) { struct lu_client_fld *fld = (struct lu_client_fld *)m->private; struct lu_fld_target *target; @@ -73,7 +73,7 @@ fld_proc_targets_seq_show(struct seq_file *m, void *unused) } static int -fld_proc_hash_seq_show(struct seq_file *m, void *unused) +fld_debugfs_hash_seq_show(struct seq_file *m, void *unused) { struct lu_client_fld *fld = (struct lu_client_fld *)m->private; @@ -87,9 +87,9 @@ fld_proc_hash_seq_show(struct seq_file *m, void *unused) } static ssize_t -fld_proc_hash_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +fld_debugfs_hash_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct lu_client_fld *fld; struct lu_fld_hash *hash = NULL; @@ -128,8 +128,8 @@ fld_proc_hash_seq_write(struct file *file, } static ssize_t -fld_proc_cache_flush_write(struct file *file, const char __user *buffer, - size_t count, loff_t *pos) +fld_debugfs_cache_flush_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) { struct lu_client_fld *fld = file->private_data; @@ -142,31 +142,33 @@ fld_proc_cache_flush_write(struct file *file, const char __user *buffer, return count; } -static int fld_proc_cache_flush_open(struct inode *inode, struct file *file) +static int +fld_debugfs_cache_flush_open(struct inode *inode, struct file *file) { - file->private_data = PDE_DATA(inode); + file->private_data = inode->i_private; return 0; } -static int fld_proc_cache_flush_release(struct inode *inode, struct file *file) +static int +fld_debugfs_cache_flush_release(struct inode *inode, struct file *file) { file->private_data = NULL; return 0; } -static struct file_operations fld_proc_cache_flush_fops = { +static struct file_operations fld_debugfs_cache_flush_fops = { .owner = THIS_MODULE, - .open = fld_proc_cache_flush_open, - .write = fld_proc_cache_flush_write, - .release = fld_proc_cache_flush_release, + .open = fld_debugfs_cache_flush_open, + .write = fld_debugfs_cache_flush_write, + .release = fld_debugfs_cache_flush_release, }; -LPROC_SEQ_FOPS_RO(fld_proc_targets); -LPROC_SEQ_FOPS(fld_proc_hash); +LPROC_SEQ_FOPS_RO(fld_debugfs_targets); +LPROC_SEQ_FOPS(fld_debugfs_hash); -struct lprocfs_vars fld_client_proc_list[] = { - { "targets", &fld_proc_targets_fops }, - { "hash", &fld_proc_hash_fops }, - { "cache_flush", &fld_proc_cache_flush_fops }, +struct lprocfs_vars fld_client_debugfs_list[] = { + { "targets", &fld_debugfs_targets_fops }, + { "hash", &fld_debugfs_hash_fops }, + { "cache_flush", &fld_debugfs_cache_flush_fops }, { NULL } }; diff --git a/drivers/staging/lustre/lustre/include/lustre_fld.h b/drivers/staging/lustre/lustre/include/lustre_fld.h index 5ee4b1ed0995..588cdd5a291c 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fld.h +++ b/drivers/staging/lustre/lustre/include/lustre_fld.h @@ -99,8 +99,8 @@ struct lu_server_fld { struct lu_client_fld { /** - * Client side proc entry. */ - struct proc_dir_entry *lcf_proc_dir; + * Client side debugfs entry. */ + struct dentry *lcf_debugfs_entry; /** * List of exports client FLD knows about. */ @@ -123,10 +123,10 @@ struct lu_client_fld { struct fld_cache *lcf_cache; /** - * Client fld proc entry name. */ - char lcf_name[LUSTRE_MDT_MAXNAMELEN]; + * Client fld debugfs entry name. */ + char lcf_name[LUSTRE_MDT_MAXNAMELEN]; - int lcf_flags; + int lcf_flags; }; /* Client methods */ @@ -153,7 +153,7 @@ int fld_client_add_target(struct lu_client_fld *fld, int fld_client_del_target(struct lu_client_fld *fld, __u64 idx); -void fld_client_proc_fini(struct lu_client_fld *fld); +void fld_client_debugfs_fini(struct lu_client_fld *fld); /** @} fld */ diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 695a4ed9e627..65c01383725c 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -2277,7 +2277,7 @@ static int lmv_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) * stack. */ break; case OBD_CLEANUP_EXPORTS: - fld_client_proc_fini(&lmv->lmv_fld); + fld_client_debugfs_fini(&lmv->lmv_fld); lprocfs_obd_cleanup(obd); break; default: From 61e87ab0f8b24300f10ea345ebf382d9f93c5bc2 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Thu, 21 May 2015 15:32:27 -0400 Subject: [PATCH 0642/1163] staging/lustre/obd: move status files from procfs to debugfs change type of * obd->obd_proc_entry * obd->obd_svc_procroot * lov->lov_pool_proc_entry * obd_type->typ_procroot * pool_desc->pool_proc_entry Signed-off-by: Dmitry Eremin Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lprocfs_status.h | 4 ++ drivers/staging/lustre/lustre/include/obd.h | 10 +-- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 14 ++--- drivers/staging/lustre/lustre/lmv/lproc_lmv.c | 2 +- drivers/staging/lustre/lustre/lov/lov_obd.c | 19 +++--- drivers/staging/lustre/lustre/lov/lov_pool.c | 31 ++++----- drivers/staging/lustre/lustre/lov/lproc_lov.c | 2 +- drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 2 +- .../staging/lustre/lustre/obdclass/genops.c | 17 ++--- .../lustre/lustre/obdclass/lprocfs_status.c | 63 ++++++++++++------- drivers/staging/lustre/lustre/osc/lproc_osc.c | 4 +- .../lustre/lustre/ptlrpc/lproc_ptlrpc.c | 12 ++-- 12 files changed, 98 insertions(+), 82 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index bbacda6ebd91..721efd6cc698 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -565,6 +565,10 @@ extern int lprocfs_add_clear_entry(struct obd_device *obd, extern int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *peer_nid, int *newnid); extern int lprocfs_exp_cleanup(struct obd_export *exp); +extern struct dentry *ldebugfs_add_simple(struct dentry *root, + char *name, + void *data, + struct file_operations *fops); extern struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root, char *name, void *data, diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index c24fb1c51b62..cb994e1d6bba 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -244,7 +244,7 @@ struct obd_type { struct list_head typ_chain; struct obd_ops *typ_dt_ops; struct md_ops *typ_md_ops; - struct proc_dir_entry *typ_procroot; + struct dentry *typ_debugfs_entry; char *typ_name; int typ_refcnt; struct lu_device_type *typ_lu; @@ -545,7 +545,7 @@ struct pool_desc { struct lov_qos_rr pool_rr; /* round robin qos */ struct hlist_node pool_hash; /* access by poolname */ struct list_head pool_list; /* serial access */ - struct proc_dir_entry *pool_proc_entry; /* file in /proc */ + struct dentry *pool_debugfs_entry; /* file in /proc */ struct obd_device *pool_lobd; /* obd of the lov/lod to which * this pool belongs */ }; @@ -566,7 +566,7 @@ struct lov_obd { int lov_pool_count; struct cfs_hash *lov_pools_hash_body; /* used for key access */ struct list_head lov_pool_list; /* used for sequential access */ - struct proc_dir_entry *lov_pool_proc_entry; + struct dentry *lov_pool_debugfs_entry; enum lustre_sec_part lov_sp_me; /* Cached LRU pages from upper layer */ @@ -917,9 +917,9 @@ struct obd_device { unsigned int md_cntr_base; struct lprocfs_stats *md_stats; - struct proc_dir_entry *obd_proc_entry; + struct dentry *obd_debugfs_entry; struct proc_dir_entry *obd_proc_exports_entry; - struct proc_dir_entry *obd_svc_procroot; + struct dentry *obd_svc_debugfs_entry; struct lprocfs_stats *obd_svc_stats; atomic_t obd_evict_inprogress; wait_queue_head_t obd_evict_inprogress_waitq; diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 65c01383725c..aca686a2ca10 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -1310,15 +1310,11 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) lprocfs_lmv_init_vars(&lvars); lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars); -#if defined (CONFIG_PROC_FS) - { - rc = lprocfs_seq_create(obd->obd_proc_entry, "target_obd", - 0444, &lmv_proc_target_fops, obd); - if (rc) - CWARN("%s: error adding LMV target_obd file: rc = %d\n", - obd->obd_name, rc); - } -#endif + rc = ldebugfs_seq_create(obd->obd_debugfs_entry, "target_obd", + 0444, &lmv_proc_target_fops, obd); + if (rc) + CWARN("%s: error adding LMV target_obd file: rc = %d\n", + obd->obd_name, rc); rc = fld_client_init(&lmv->lmv_fld, obd->obd_name, LUSTRE_CLI_FLD_HASH_DHT); if (rc) { diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index b113e5aa0103..8583fe229cdd 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -194,7 +194,7 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file) return rc; seq = file->private_data; - seq->private = PDE_DATA(inode); + seq->private = inode->i_private; return 0; } diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index caf1aff2a0a5..b5dc9e138d30 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -810,20 +810,15 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) lprocfs_lov_init_vars(&lvars); lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars); -#if defined (CONFIG_PROC_FS) - { - int rc1; - rc1 = lprocfs_seq_create(obd->obd_proc_entry, "target_obd", - 0444, &lov_proc_target_fops, obd); - if (rc1) - CWARN("Error adding the target_obd file\n"); - } -#endif - lov->lov_pool_proc_entry = lprocfs_register("pools", - obd->obd_proc_entry, - NULL, NULL); + rc = ldebugfs_seq_create(obd->obd_debugfs_entry, "target_obd", + 0444, &lov_proc_target_fops, obd); + if (rc) + CWARN("Error adding the target_obd file\n"); + lov->lov_pool_debugfs_entry = ldebugfs_register("pools", + obd->obd_debugfs_entry, + NULL, NULL); return 0; out: diff --git a/drivers/staging/lustre/lustre/lov/lov_pool.c b/drivers/staging/lustre/lustre/lov/lov_pool.c index 75301fa066a0..30a29fd86e8e 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pool.c +++ b/drivers/staging/lustre/lustre/lov/lov_pool.c @@ -64,7 +64,7 @@ void lov_pool_putref(struct pool_desc *pool) if (atomic_dec_and_test(&pool->pool_refcount)) { LASSERT(hlist_unhashed(&pool->pool_hash)); LASSERT(list_empty(&pool->pool_list)); - LASSERT(pool->pool_proc_entry == NULL); + LASSERT(pool->pool_debugfs_entry == NULL); lov_ost_pool_free(&(pool->pool_rr.lqr_pool)); lov_ost_pool_free(&(pool->pool_obds)); kfree(pool); @@ -283,7 +283,7 @@ static int pool_proc_open(struct inode *inode, struct file *file) rc = seq_open(file, &pool_proc_ops); if (!rc) { struct seq_file *s = file->private_data; - s->private = PDE_DATA(inode); + s->private = inode->i_private; } return rc; } @@ -454,20 +454,21 @@ int lov_pool_new(struct obd_device *obd, char *poolname) INIT_HLIST_NODE(&new_pool->pool_hash); -#if defined (CONFIG_PROC_FS) /* we need this assert seq_file is not implemented for liblustre */ /* get ref for /proc file */ lov_pool_getref(new_pool); - new_pool->pool_proc_entry = lprocfs_add_simple(lov->lov_pool_proc_entry, - poolname, new_pool, - &pool_proc_operations); - if (IS_ERR(new_pool->pool_proc_entry)) { - CWARN("Cannot add proc pool entry "LOV_POOLNAMEF"\n", poolname); - new_pool->pool_proc_entry = NULL; + new_pool->pool_debugfs_entry = ldebugfs_add_simple( + lov->lov_pool_debugfs_entry, + poolname, new_pool, + &pool_proc_operations); + if (IS_ERR_OR_NULL(new_pool->pool_debugfs_entry)) { + CWARN("Cannot add debugfs pool entry "LOV_POOLNAMEF"\n", + poolname); + new_pool->pool_debugfs_entry = NULL; lov_pool_putref(new_pool); } - CDEBUG(D_INFO, "pool %p - proc %p\n", new_pool, new_pool->pool_proc_entry); -#endif + CDEBUG(D_INFO, "pool %p - proc %p\n", + new_pool, new_pool->pool_debugfs_entry); spin_lock(&obd->obd_dev_lock); list_add_tail(&new_pool->pool_list, &lov->lov_pool_list); @@ -493,7 +494,7 @@ out_err: lov->lov_pool_count--; spin_unlock(&obd->obd_dev_lock); - lprocfs_remove(&new_pool->pool_proc_entry); + ldebugfs_remove(&new_pool->pool_debugfs_entry); lov_ost_pool_free(&new_pool->pool_rr.lqr_pool); out_free_pool_obds: @@ -514,9 +515,9 @@ int lov_pool_del(struct obd_device *obd, char *poolname) if (pool == NULL) return -ENOENT; - if (pool->pool_proc_entry != NULL) { - CDEBUG(D_INFO, "proc entry %p\n", pool->pool_proc_entry); - lprocfs_remove(&pool->pool_proc_entry); + if (!IS_ERR_OR_NULL(pool->pool_debugfs_entry)) { + CDEBUG(D_INFO, "proc entry %p\n", pool->pool_debugfs_entry); + ldebugfs_remove(&pool->pool_debugfs_entry); lov_pool_putref(pool); } diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index 41bb5b585a61..380b8271bf24 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c @@ -258,7 +258,7 @@ static int lov_target_seq_open(struct inode *inode, struct file *file) return rc; seq = file->private_data; - seq->private = PDE_DATA(inode); + seq->private = inode->i_private; return 0; } diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index 2121ca761a26..858d568a896f 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -84,7 +84,7 @@ LUSTRE_RW_ATTR(max_rpcs_in_flight); static int mdc_kuc_open(struct inode *inode, struct file *file) { - return single_open(file, NULL, PDE_DATA(inode)); + return single_open(file, NULL, inode->i_private ?: PDE_DATA(inode)); } /* temporary for testing */ diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 8e3dfafcf62d..978c3c5c460a 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -191,11 +191,13 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, strcpy(type->typ_name, name); spin_lock_init(&type->obd_type_lock); - type->typ_procroot = lprocfs_register(type->typ_name, proc_lustre_root, - NULL, type); - if (IS_ERR(type->typ_procroot)) { - rc = PTR_ERR(type->typ_procroot); - type->typ_procroot = NULL; + type->typ_debugfs_entry = ldebugfs_register(type->typ_name, + debugfs_lustre_root, + NULL, type); + if (IS_ERR_OR_NULL(type->typ_debugfs_entry)) { + rc = type->typ_debugfs_entry ? PTR_ERR(type->typ_debugfs_entry) + : -ENOMEM; + type->typ_debugfs_entry = NULL; goto failed; } @@ -250,9 +252,8 @@ int class_unregister_type(const char *name) if (type->typ_kobj) kobject_put(type->typ_kobj); - if (type->typ_procroot) { - lprocfs_remove(&type->typ_procroot); - } + if (!IS_ERR_OR_NULL(type->typ_debugfs_entry)) + ldebugfs_remove(&type->typ_debugfs_entry); if (type->typ_lu) lu_device_type_fini(type->typ_lu); diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 5b1b59a6187b..51865ddde0b6 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -243,6 +243,29 @@ EXPORT_SYMBOL(lprocfs_seq_release); /* lprocfs API calls */ +struct dentry *ldebugfs_add_simple(struct dentry *root, + char *name, void *data, + struct file_operations *fops) +{ + struct dentry *entry; + umode_t mode = 0; + + if (root == NULL || name == NULL || fops == NULL) + return ERR_PTR(-EINVAL); + + if (fops->read) + mode = 0444; + if (fops->write) + mode |= 0200; + entry = debugfs_create_file(name, mode, root, data, fops); + if (IS_ERR_OR_NULL(entry)) { + CERROR("LprocFS: No memory to create entry %s", name); + return entry ?: ERR_PTR(-ENOMEM); + } + return entry; +} +EXPORT_SYMBOL(ldebugfs_add_simple); + struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root, char *name, void *data, struct file_operations *fops) @@ -1036,10 +1059,6 @@ int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list, { int rc = 0; - LASSERT(obd != NULL); - LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC); - LASSERT(obd->obd_type->typ_procroot != NULL); - init_completion(&obd->obd_kobj_unregister); rc = kobject_init_and_add(&obd->obd_kobj, &obd_ktype, obd->obd_type->typ_kobj, @@ -1055,15 +1074,15 @@ int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list, } } - obd->obd_proc_entry = lprocfs_register(obd->obd_name, - obd->obd_type->typ_procroot, - list, obd); - if (IS_ERR(obd->obd_proc_entry)) { - kobject_put(&obd->obd_kobj); - rc = PTR_ERR(obd->obd_proc_entry); + obd->obd_debugfs_entry = ldebugfs_register(obd->obd_name, + obd->obd_type->typ_debugfs_entry, + list, obd); + if (IS_ERR_OR_NULL(obd->obd_debugfs_entry)) { + rc = obd->obd_debugfs_entry ? PTR_ERR(obd->obd_debugfs_entry) + : -ENOMEM; CERROR("error %d setting up lprocfs for %s\n", rc, obd->obd_name); - obd->obd_proc_entry = NULL; + obd->obd_debugfs_entry = NULL; } return rc; @@ -1074,17 +1093,19 @@ int lprocfs_obd_cleanup(struct obd_device *obd) { if (!obd) return -EINVAL; + if (obd->obd_proc_exports_entry) { /* Should be no exports left */ lprocfs_remove(&obd->obd_proc_exports_entry); obd->obd_proc_exports_entry = NULL; } - if (obd->obd_proc_entry) { - lprocfs_remove(&obd->obd_proc_entry); - obd->obd_proc_entry = NULL; - } + + if (!IS_ERR_OR_NULL(obd->obd_debugfs_entry)) + ldebugfs_remove(&obd->obd_debugfs_entry); + kobject_put(&obd->obd_kobj); wait_for_completion(&obd->obd_kobj_unregister); + return 0; } EXPORT_SYMBOL(lprocfs_obd_cleanup); @@ -1507,7 +1528,7 @@ int lprocfs_alloc_obd_stats(struct obd_device *obd, unsigned num_private_stats) int rc, i; LASSERT(obd->obd_stats == NULL); - LASSERT(obd->obd_proc_entry != NULL); + LASSERT(obd->obd_debugfs_entry != NULL); LASSERT(obd->obd_cntr_base == 0); num_stats = ((int)sizeof(*obd->obd_type->typ_dt_ops) / sizeof(void *)) + @@ -1528,7 +1549,7 @@ int lprocfs_alloc_obd_stats(struct obd_device *obd, unsigned num_private_stats) "Missing obd_stat initializer obd_op operation at offset %d.\n", i - num_private_stats); } - rc = lprocfs_register_stats(obd->obd_proc_entry, "stats", stats); + rc = ldebugfs_register_stats(obd->obd_debugfs_entry, "stats", stats); if (rc < 0) { lprocfs_free_stats(&stats); } else { @@ -1598,7 +1619,7 @@ int lprocfs_alloc_md_stats(struct obd_device *obd, int rc, i; LASSERT(obd->md_stats == NULL); - LASSERT(obd->obd_proc_entry != NULL); + LASSERT(obd->obd_debugfs_entry != NULL); LASSERT(obd->md_cntr_base == 0); num_stats = 1 + MD_COUNTER_OFFSET(revalidate_lock) + @@ -1616,7 +1637,7 @@ int lprocfs_alloc_md_stats(struct obd_device *obd, LBUG(); } } - rc = lprocfs_register_stats(obd->obd_proc_entry, "md_stats", stats); + rc = ldebugfs_register_stats(obd->obd_debugfs_entry, "md_stats", stats); if (rc < 0) { lprocfs_free_stats(&stats); } else { @@ -2134,8 +2155,8 @@ int lprocfs_obd_seq_create(struct obd_device *dev, const struct file_operations *seq_fops, void *data) { - return lprocfs_seq_create(dev->obd_proc_entry, name, - mode, seq_fops, data); + return ldebugfs_seq_create(dev->obd_debugfs_entry, name, + mode, seq_fops, data); } EXPORT_SYMBOL(lprocfs_obd_seq_create); diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 2f07ea5a736b..0ba2c36ace44 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -738,8 +738,8 @@ int lproc_osc_attach_seqstat(struct obd_device *dev) { int rc; - rc = lprocfs_seq_create(dev->obd_proc_entry, "osc_stats", 0644, - &osc_stats_fops, dev); + rc = ldebugfs_seq_create(dev->obd_debugfs_entry, "osc_stats", 0644, + &osc_stats_fops, dev); if (rc == 0) rc = lprocfs_obd_seq_create(dev, "rpc_stats", 0644, &osc_rpc_stats_fops, dev); diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 8c0c9954fe99..cf5196a25fd8 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -1142,11 +1142,9 @@ void ptlrpc_ldebugfs_register_service(struct dentry *entry, void ptlrpc_lprocfs_register_obd(struct obd_device *obddev) { -/* TODO: enable after change type of obddev->obd_proc_entry - * ptlrpc_ldebugfs_register(obddev->obd_proc_entry, NULL, "stats", - * &obddev->obd_svc_procroot, - * &obddev->obd_svc_stats); - */ + ptlrpc_ldebugfs_register(obddev->obd_debugfs_entry, NULL, "stats", + &obddev->obd_svc_debugfs_entry, + &obddev->obd_svc_stats); } EXPORT_SYMBOL(ptlrpc_lprocfs_register_obd); @@ -1203,8 +1201,8 @@ void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc) void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd) { - if (obd->obd_svc_procroot) - lprocfs_remove(&obd->obd_svc_procroot); + if (!IS_ERR_OR_NULL(obd->obd_svc_debugfs_entry)) + ldebugfs_remove(&obd->obd_svc_debugfs_entry); if (obd->obd_svc_stats) lprocfs_free_stats(&obd->obd_svc_stats); From f9aaa43eeea07adb3bf8354d1b36622b9c349c5a Mon Sep 17 00:00:00 2001 From: Marcus Folkesson Date: Thu, 28 May 2015 11:21:19 +0200 Subject: [PATCH 0643/1163] staging: lustre: fix non-static symbol warnings reported by sparse Warnings reported by sparse: drivers/staging/lustre/lustre/ptlrpc/pinger.c:94:5: warning: symbol 'ptlrpc_ping' was not declared. Should it be static? drivers/staging/lustre/lustre/ptlrpc/pinger.c:113:6: warning: symbol 'ptlrpc_update_next_ping' was not declared. Should it be static drivers/staging/lustre/lustre/ptlrpc/pinger.c:144:6: warning: symbol 'pinger_check_timeout' was not declared. Should it be static? drivers/staging/lustre/lustre/ptlrpc/pinger.c:425:21: warning: symbol 'ptlrpc_new_timeout' was not declared. Should it be static? drivers/staging/lustre/lustre/ptlrpc/pinger.c:551:1: warning: symbol 'pet_list' was not declared. Should it be static? Signed-off-by: Marcus Folkesson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/pinger.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index 5abb91cc87ff..9fc815676eb8 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -91,7 +91,7 @@ int ptlrpc_obd_ping(struct obd_device *obd) } EXPORT_SYMBOL(ptlrpc_obd_ping); -int ptlrpc_ping(struct obd_import *imp) +static int ptlrpc_ping(struct obd_import *imp) { struct ptlrpc_request *req; @@ -110,7 +110,7 @@ int ptlrpc_ping(struct obd_import *imp) return 0; } -void ptlrpc_update_next_ping(struct obd_import *imp, int soon) +static void ptlrpc_update_next_ping(struct obd_import *imp, int soon) { int time = soon ? PING_INTERVAL_SHORT : PING_INTERVAL; if (imp->imp_state == LUSTRE_IMP_DISCON) { @@ -141,7 +141,7 @@ static inline int ptlrpc_next_reconnect(struct obd_import *imp) return cfs_time_shift(obd_timeout); } -long pinger_check_timeout(unsigned long time) +static long pinger_check_timeout(unsigned long time) { struct timeout_item *item; unsigned long timeout = PING_INTERVAL; @@ -422,8 +422,8 @@ EXPORT_SYMBOL(ptlrpc_pinger_del_import); * Register a timeout callback to the pinger list, and the callback will * be called when timeout happens. */ -struct timeout_item *ptlrpc_new_timeout(int time, enum timeout_event event, - timeout_cb_t cb, void *data) +static struct timeout_item *ptlrpc_new_timeout(int time, + enum timeout_event event, timeout_cb_t cb, void *data) { struct timeout_item *ti; @@ -548,7 +548,7 @@ void ptlrpc_pinger_wake_up(void) static int pet_refcount; static int pet_state; static wait_queue_head_t pet_waitq; -LIST_HEAD(pet_list); +static LIST_HEAD(pet_list); static DEFINE_SPINLOCK(pet_lock); int ping_evictor_wake(struct obd_export *exp) From c3faa4a192f1e7affec94531d0748e5dc60b8504 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Thu, 28 May 2015 23:02:23 +0200 Subject: [PATCH 0644/1163] staging/lustre/mdc: drop unneeded goto Delete jump to a label on the next line, when that label is not used elsewhere. A simplified version of the semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @r@ identifier l; @@ -if (...) goto l; -l: // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/mdc/mdc_request.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 9f34d67b8f4e..c9639413b105 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -1818,10 +1818,7 @@ static int mdc_ioc_swap_layouts(struct obd_export *exp, ptlrpc_request_set_replen(req); rc = ptlrpc_queue_wait(req); - if (rc) - goto out; -out: ptlrpc_req_finished(req); return rc; } From 758ed62b0ee818fc814e85c9680f3f8236e812fe Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Fri, 29 May 2015 18:27:47 -0400 Subject: [PATCH 0645/1163] staging/lustre: Update header license for lustre_dlm_flags.h lustre_dlm_flags.h was autogenerated with a wrong script that mistakenly stated it is GPLv3 when in fact it should be GPLv2. Also since we are no longer autogenerating this header, drop all such mentionings. Reported by: George G. Davis Signed-off-by: Oleg Drokin Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6599 Reviewed-on: http://review.whamcloud.com/14797 Reviewed-by: Andreas Dilger CC: George G. Davis Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lustre_dlm_flags.h | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h b/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h index 16dcdbfae689..d4cc09635271 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h @@ -1,17 +1,10 @@ /* -*- buffer-read-only: t -*- vi: set ro: * - * DO NOT EDIT THIS FILE (lustre_dlm_flags.h) + * 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. * - * It has been AutoGen-ed - * From the definitions lustre_dlm_flags.def - * and the template file lustre_dlm_flags.tpl - * - * lustre 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 3 of the License, or - * (at your option) any later version. - * - * lustre is distributed in the hope that it will be useful, but + * Lustre 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. @@ -22,8 +15,6 @@ /** * \file lustre_dlm_flags.h * The flags and collections of flags (masks) for \see struct ldlm_lock. - * This file is derived from flag definitions in lustre_dlm_flags.def. - * The format is defined in the lustre_dlm_flags.tpl template file. * * \addtogroup LDLM Lustre Distributed Lock Manager * @{ From 7257f9d1ac2e06a10f753d65ce819de70cf678fa Mon Sep 17 00:00:00 2001 From: Simon Guo Date: Sat, 30 May 2015 16:10:46 +0800 Subject: [PATCH 0646/1163] STAGING: Declare request_cache as static for drivers/staging/lustre/lustre/ptlrpc/client.c Declare request_cache variable as static. It is only used by drivers/staging/lustre/lustre/ptlrpc/client.c, and its naming is common which will lead to namespace pollution. Signed-off-by: Simon Guo Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 45b7af77c37e..347110e6e822 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -390,7 +390,7 @@ static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req) return rc; } -struct kmem_cache *request_cache; +static struct kmem_cache *request_cache; int ptlrpc_request_cache_init(void) { From 469caabe52aaa051f4a18a14055af459db2dcb01 Mon Sep 17 00:00:00 2001 From: Colin Cronin Date: Fri, 15 May 2015 13:02:40 -0700 Subject: [PATCH 0647/1163] Staging: dgap: dgap: Fixed spelling errors Fixed comment spelling errors Signed-off-by: Colin Cronin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 2 +- drivers/staging/dgap/dgap.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 92ae8da9b7a3..26b0446d943a 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -2645,7 +2645,7 @@ static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds) * dgap_wmove - Write data to FEP buffer. * * ch - Pointer to channel structure. - * buf - Poiter to characters to be moved. + * buf - Pointer to characters to be moved. * cnt - Number of characters to move. * *=======================================================================*/ diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index a2e5b26c673a..e707ed5fe949 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -172,7 +172,7 @@ /* * Define a local default termios struct. All ports will be created * with this termios initially. This is the same structure that is defined - * as the default in tty_io.c with the same settings overriden as in serial.c + * as the default in tty_io.c with the same settings overridden as in serial.c * * In short, this should match the internal serial ports' defaults. */ From e97bc8b220c41cab2e84d7410ece70166bba9fe9 Mon Sep 17 00:00:00 2001 From: Alex Dowad Date: Sun, 17 May 2015 19:19:37 +0200 Subject: [PATCH 0648/1163] staging: ft1000: Remove empty branch from conditional This fixes a checkpatch style warning in ft1000_ioctl. Signed-off-by: Alex Dowad Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_debug.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c index 2d758fb26eac..2593413412a3 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c @@ -588,8 +588,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command, /* Check message qtype type which is the lower byte within qos_class */ qtype = ntohs(dpram_data->pseudohdr.qos_class) & 0xff; /* pr_debug("qtype = %d\n", qtype); */ - if (qtype) { - } else { + if (!qtype) { /* Put message into Slow Queue */ /* Only put a message into the DPRAM if msg doorbell is available */ status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); From 07d783fd830a49008f3b2764ae7b6033ee1bf329 Mon Sep 17 00:00:00 2001 From: Peter Senna Tschudin Date: Tue, 19 May 2015 11:44:46 +0200 Subject: [PATCH 0649/1163] staging: goldfish: Fix pointer cast for 32 bits As the first argument of gf_write64() was of type unsigned long, and as some calls to gf_write64() were casting the first argument from void * to u64 the compiler and/or sparse were printing warnings for casts of wrong sizes when compiling for i386. This patch changes the type of the first argument of gf_write64() to const void *, and update calls to the function. This change fixed the warnings and allowed to remove casts from 3 calls to gf_write64(). In addition gf_write64() was renamed to gf_write_ptr() as the name was misleading because it only writes 32 bits on 32 bit systems. gf_write_dma_addr() was added to handle dma_addr_t values which is used at drivers/staging/goldfish/goldfish_audio.c. Signed-off-by: Dan Carpenter Signed-off-by: Peter Senna Tschudin Signed-off-by: Greg Kroah-Hartman --- drivers/platform/goldfish/goldfish_pipe.c | 18 +++++++++--------- drivers/staging/goldfish/goldfish_audio.c | 2 +- drivers/staging/goldfish/goldfish_nand.c | 2 +- drivers/tty/goldfish.c | 4 ++-- include/linux/goldfish.h | 19 +++++++++++++++---- 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c index d9a09d9637d9..aad16bc9e630 100644 --- a/drivers/platform/goldfish/goldfish_pipe.c +++ b/drivers/platform/goldfish/goldfish_pipe.c @@ -158,8 +158,8 @@ 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)(unsigned long)pipe, dev->base + PIPE_REG_CHANNEL, - dev->base + PIPE_REG_CHANNEL_HIGH); + gf_write_ptr(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,8 +172,8 @@ 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)(unsigned long)pipe, dev->base + PIPE_REG_CHANNEL, - dev->base + PIPE_REG_CHANNEL_HIGH); + gf_write_ptr(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,12 +327,12 @@ 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)(unsigned long)pipe, - dev->base + PIPE_REG_CHANNEL, - dev->base + PIPE_REG_CHANNEL_HIGH); + gf_write_ptr(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); + gf_write_ptr((void *)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); diff --git a/drivers/staging/goldfish/goldfish_audio.c b/drivers/staging/goldfish/goldfish_audio.c index 702ae04df912..b0927e49d0a8 100644 --- a/drivers/staging/goldfish/goldfish_audio.c +++ b/drivers/staging/goldfish/goldfish_audio.c @@ -63,7 +63,7 @@ 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)) + (gf_write_dma_addr((x), data->reg_base + addr, data->reg_base+addr2)) /* * temporary variable used between goldfish_audio_probe() and diff --git a/drivers/staging/goldfish/goldfish_nand.c b/drivers/staging/goldfish/goldfish_nand.c index 213877a2c430..66ae48fcc2b2 100644 --- a/drivers/staging/goldfish/goldfish_nand.c +++ b/drivers/staging/goldfish/goldfish_nand.c @@ -87,7 +87,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); - gf_write64((u64)ptr, base + NAND_DATA, base + NAND_DATA_HIGH); + gf_write_ptr(ptr, base + NAND_DATA, base + NAND_DATA_HIGH); writel(cmd, base + NAND_COMMAND); rv = readl(base + NAND_RESULT); } diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c index 0655fecf8240..0f82c0b146f6 100644 --- a/drivers/tty/goldfish.c +++ b/drivers/tty/goldfish.c @@ -59,7 +59,7 @@ 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); - gf_write64((u64)buf, base + GOLDFISH_TTY_DATA_PTR, + gf_write_ptr(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); @@ -81,7 +81,7 @@ 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); - gf_write64((u64)buf, base + GOLDFISH_TTY_DATA_PTR, + gf_write_ptr(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); diff --git a/include/linux/goldfish.h b/include/linux/goldfish.h index 569236e6b2bc..93e080b39cf6 100644 --- a/include/linux/goldfish.h +++ b/include/linux/goldfish.h @@ -3,13 +3,24 @@ /* Helpers for Goldfish virtual platform */ -static inline void gf_write64(unsigned long data, - void __iomem *portl, void __iomem *porth) +static inline void gf_write_ptr(const void *ptr, void __iomem *portl, + void __iomem *porth) { - writel((u32)data, portl); + writel((u32)(unsigned long)ptr, portl); #ifdef CONFIG_64BIT - writel(data>>32, porth); + writel((unsigned long)ptr >> 32, porth); #endif } +static inline void gf_write_dma_addr(const dma_addr_t addr, + void __iomem *portl, + void __iomem *porth) +{ + writel((u32)addr, portl); +#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT + writel(addr >> 32, porth); +#endif +} + + #endif /* __LINUX_GOLDFISH_H */ From 8ee0df0d0695f87075a77b0dc9f5f594b7ec423f Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Sat, 16 May 2015 16:17:51 +0900 Subject: [PATCH 0650/1163] staging: rts5208: fix transfer length 0 for 6-byte r/w commands For 6-byte r/w commands, transfer length 0 means 256 blocks of data, not 0 block. Signed-off-by: Akinobu Mita Cc: Micky Ching Cc: Greg Kroah-Hartman Cc: linux-scsi@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_scsi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rts5208/rtsx_scsi.c b/drivers/staging/rts5208/rtsx_scsi.c index 8a5d6a8e780f..60871f3022b1 100644 --- a/drivers/staging/rts5208/rtsx_scsi.c +++ b/drivers/staging/rts5208/rtsx_scsi.c @@ -915,6 +915,8 @@ static int read_write(struct scsi_cmnd *srb, struct rtsx_chip *chip) start_sec = ((u32)(srb->cmnd[1] & 0x1F) << 16) | ((u32)srb->cmnd[2] << 8) | ((u32)srb->cmnd[3]); sec_cnt = srb->cmnd[4]; + if (sec_cnt == 0) + sec_cnt = 256; } else if ((srb->cmnd[0] == VENDOR_CMND) && (srb->cmnd[1] == SCSI_APP_CMD) && ((srb->cmnd[2] == PP_READ10) || (srb->cmnd[2] == PP_WRITE10))) { @@ -2904,9 +2906,11 @@ void led_shine(struct scsi_cmnd *srb, struct rtsx_chip *chip) if ((srb->cmnd[0] == READ_10) || (srb->cmnd[0] == WRITE_10)) sec_cnt = ((u16)(srb->cmnd[7]) << 8) | srb->cmnd[8]; - else if ((srb->cmnd[0] == READ_6) || (srb->cmnd[0] == WRITE_6)) + else if ((srb->cmnd[0] == READ_6) || (srb->cmnd[0] == WRITE_6)) { sec_cnt = srb->cmnd[4]; - else + if (sec_cnt == 0) + sec_cnt = 256; + } else return; if (chip->rw_cap[lun] >= GPIO_TOGGLE_THRESHOLD) { From 3f8ded9d9c353cffe36e7d36c2a4bbdcb26bc5c1 Mon Sep 17 00:00:00 2001 From: Nicholas Mc Guire Date: Wed, 27 May 2015 18:02:38 +0200 Subject: [PATCH 0651/1163] staging: rts5208: pass timeout as HZ independent value schedule_timeout takes a timeout in jiffies but the code currently is passing in a constant POLLING_INTERVAL which makes this timeout HZ dependent, so pass it through msecs_to_jiffies() to fix this up. patch was compile tested for x86_64_defconfig + CONFIG_STAGING=y, CONFIG_RTS5208=m Patch is against 4.0-rc5 (localversion-next is -next-20150527) Signed-off-by: Nicholas Mc Guire 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 d64b6ed9c0c9..1bcadba07fd0 100644 --- a/drivers/staging/rts5208/rtsx.c +++ b/drivers/staging/rts5208/rtsx.c @@ -537,7 +537,7 @@ static int rtsx_polling_thread(void *__dev) for (;;) { set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(POLLING_INTERVAL); + schedule_timeout(msecs_to_jiffies(POLLING_INTERVAL)); /* lock the device pointers */ mutex_lock(&(dev->dev_mutex)); From 77e8a50149a2e0970db42da27753f7e2244f9fe3 Mon Sep 17 00:00:00 2001 From: Jaime Arrocha Date: Tue, 26 May 2015 13:14:05 -0500 Subject: [PATCH 0652/1163] staging: gdm724x: Remove test for host endian gdm_endian.c: small changes were done to remove testing for host endianness and in-driver conversion for byte-ordering. The linux/kernel.h functions are used now. gdm_endian.h: removal of code no longer needed with changes in gdm_endian.c. Signed-off-by: Jaime Arrocha Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_endian.c | 46 ++++++++++------------------ drivers/staging/gdm724x/gdm_endian.h | 11 ------- 2 files changed, 17 insertions(+), 40 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_endian.c b/drivers/staging/gdm724x/gdm_endian.c index f6cc90ae9ba6..d7144e7afa32 100644 --- a/drivers/staging/gdm724x/gdm_endian.c +++ b/drivers/staging/gdm724x/gdm_endian.c @@ -11,57 +11,45 @@ * GNU General Public License for more details. */ -#include +#include #include "gdm_endian.h" void gdm_set_endian(struct gdm_endian *ed, u8 dev_endian) { - u8 a[2] = {0x12, 0x34}; - u8 b[2] = {0, }; - u16 c = 0x1234; - if (dev_endian == ENDIANNESS_BIG) ed->dev_ed = ENDIANNESS_BIG; else ed->dev_ed = ENDIANNESS_LITTLE; - - memcpy(b, &c, 2); - - if (a[0] != b[0]) - ed->host_ed = ENDIANNESS_LITTLE; - else - ed->host_ed = ENDIANNESS_BIG; - } u16 gdm_cpu_to_dev16(struct gdm_endian *ed, u16 x) { - if (ed->dev_ed == ed->host_ed) - return x; - - return Endian16_Swap(x); + if (ed->dev_ed == ENDIANNESS_LITTLE) + return cpu_to_le16(x); + else + return cpu_to_be16(x); } u16 gdm_dev16_to_cpu(struct gdm_endian *ed, u16 x) { - if (ed->dev_ed == ed->host_ed) - return x; - - return Endian16_Swap(x); + if (ed->dev_ed == ENDIANNESS_LITTLE) + return le16_to_cpu(x); + else + return be16_to_cpu(x); } u32 gdm_cpu_to_dev32(struct gdm_endian *ed, u32 x) { - if (ed->dev_ed == ed->host_ed) - return x; - - return Endian32_Swap(x); + if (ed->dev_ed == ENDIANNESS_LITTLE) + return cpu_to_le32(x); + else + return cpu_to_be32(x); } u32 gdm_dev32_to_cpu(struct gdm_endian *ed, u32 x) { - if (ed->dev_ed == ed->host_ed) - return x; - - return Endian32_Swap(x); + if (ed->dev_ed == ENDIANNESS_LITTLE) + return le32_to_cpu(x); + else + return be32_to_cpu(x); } diff --git a/drivers/staging/gdm724x/gdm_endian.h b/drivers/staging/gdm724x/gdm_endian.h index 9b2531ff908e..6177870830e5 100644 --- a/drivers/staging/gdm724x/gdm_endian.h +++ b/drivers/staging/gdm724x/gdm_endian.h @@ -16,16 +16,6 @@ #include -#define Endian16_Swap(value) \ - ((((u16)((value) & 0x00FF)) << 8) | \ - (((u16)((value) & 0xFF00)) >> 8)) - -#define Endian32_Swap(value) \ - ((((u32)((value) & 0x000000FF)) << 24) | \ - (((u32)((value) & 0x0000FF00)) << 8) | \ - (((u32)((value) & 0x00FF0000)) >> 8) | \ - (((u32)((value) & 0xFF000000)) >> 24)) - enum { ENDIANNESS_MIN = 0, ENDIANNESS_UNKNOWN, @@ -37,7 +27,6 @@ enum { struct gdm_endian { u8 dev_ed; - u8 host_ed; }; void gdm_set_endian(struct gdm_endian *ed, u8 dev_endian); From 24768169c7929e706150ab34731394e42b5215f3 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Wed, 27 May 2015 23:51:51 +0900 Subject: [PATCH 0653/1163] staging: gdm72xx: Fix typos in printk This patch fix 2 spelling typos in printk within gdm72xx. Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm72xx/gdm_wimax.c | 2 +- drivers/staging/gdm72xx/netlink_k.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c index 61d168e82011..08290d901b0c 100644 --- a/drivers/staging/gdm72xx/gdm_wimax.c +++ b/drivers/staging/gdm72xx/gdm_wimax.c @@ -584,7 +584,7 @@ static int gdm_wimax_get_prepared_info(struct net_device *dev, char *buf, if (T == TLV_T(T_MAC_ADDRESS)) { if (L != dev->addr_len) { netdev_err(dev, - "%s Invalid inofrmation result T/L [%x/%d]\n", + "%s Invalid information result T/L [%x/%d]\n", __func__, T, L); return -1; } diff --git a/drivers/staging/gdm72xx/netlink_k.c b/drivers/staging/gdm72xx/netlink_k.c index 9d78bfcdb2c3..f3cdaa6c468c 100644 --- a/drivers/staging/gdm72xx/netlink_k.c +++ b/drivers/staging/gdm72xx/netlink_k.c @@ -121,7 +121,7 @@ int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len) int ret = 0; if (group > ND_MAX_GROUP) { - pr_err("Group %d is invalied.\n", group); + pr_err("Group %d is invalid.\n", group); pr_err("Valid group is 0 ~ %d.\n", ND_MAX_GROUP); return -EINVAL; } From 46d74c38eba22bee848c205e8a98fc4b6b53a081 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 19 May 2015 15:25:24 +0300 Subject: [PATCH 0654/1163] staging: slicoss: restore IRQs correctly after slic_cmdq_reset() We can't save two different values in "flags" so it means that IRQs are not enabled properly at the end of this function. This isn't a problem in the current code because it's always called with IRQs disabled so we don't want to enable them at the end. This bug is old but it's thanks to David Matlack's recent cleanups that Smatch can detect it. Signed-off-by: Dan Carpenter Reviewed-by: David Matlack Signed-off-by: Greg Kroah-Hartman --- drivers/staging/slicoss/slicoss.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index 5f34ebbf7b31..a609f3e67256 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -1392,7 +1392,7 @@ static void slic_cmdq_reset(struct adapter *adapter) unsigned long flags; spin_lock_irqsave(&adapter->cmdq_free.lock, flags); - spin_lock_irqsave(&adapter->cmdq_done.lock, flags); + spin_lock(&adapter->cmdq_done.lock); outstanding = adapter->cmdq_all.count - adapter->cmdq_done.count; outstanding -= adapter->cmdq_free.count; hcmd = adapter->cmdq_all.head; @@ -1423,7 +1423,7 @@ static void slic_cmdq_reset(struct adapter *adapter) "free_count %d != all count %d\n", adapter->cmdq_free.count, adapter->cmdq_all.count); } - spin_unlock_irqrestore(&adapter->cmdq_done.lock, flags); + spin_unlock(&adapter->cmdq_done.lock); spin_unlock_irqrestore(&adapter->cmdq_free.lock, flags); } From ae33b51453b30b0586c07210ad0715a3dd9378ab Mon Sep 17 00:00:00 2001 From: "Sai.Jiang" Date: Wed, 20 May 2015 16:37:50 +0800 Subject: [PATCH 0655/1163] Staging: rtl8188eu: fix coding style Remove two warnings of missing-blank-line-after-declaration. Signed-off-by: Sai.Jiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/hal_intf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/rtl8188eu/hal/hal_intf.c b/drivers/staging/rtl8188eu/hal/hal_intf.c index 4bdbed28774e..5edb5c41c8e7 100644 --- a/drivers/staging/rtl8188eu/hal/hal_intf.c +++ b/drivers/staging/rtl8188eu/hal/hal_intf.c @@ -202,6 +202,7 @@ s32 rtw_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe) s32 rtw_hal_mgnt_xmit(struct adapter *adapt, struct xmit_frame *pmgntframe) { s32 ret = _FAIL; + if (adapt->HalFunc.mgnt_xmit) ret = adapt->HalFunc.mgnt_xmit(adapt, pmgntframe); return ret; @@ -236,6 +237,7 @@ void rtw_hal_update_ra_mask(struct adapter *adapt, u32 mac_id, u8 rssi_level) #ifdef CONFIG_88EU_AP_MODE struct sta_info *psta = NULL; struct sta_priv *pstapriv = &adapt->stapriv; + if ((mac_id-1) > 0) psta = pstapriv->sta_aid[(mac_id-1) - 1]; if (psta) From 0a36d5fbd9e1a2dac7ba65e12cb4e31161c4b37f Mon Sep 17 00:00:00 2001 From: Jagan Teki Date: Mon, 18 May 2015 22:34:22 +0530 Subject: [PATCH 0656/1163] staging: rtl8188eu: core: Fix line over 80 characters This patch fixes line over 80 characters warninings while running checkpatch.pl - "WARNING: line over 80 characters" Signed-off-by: Jagan Teki Cc: Greg Kroah-Hartman Cc: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 52 +++++++++++++++++-------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index 1d3f72800492..2b09972d4cb5 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -83,12 +83,14 @@ static void update_BCNTIM(struct adapter *padapter) u8 *pbackup_remainder_ie = NULL; uint offset, tmp_len, tim_ielen, tim_ie_offset, remainder_ielen; - p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, _TIM_IE_, &tim_ielen, pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, _TIM_IE_, &tim_ielen, + pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_); if (p != NULL && tim_ielen > 0) { tim_ielen += 2; premainder_ie = p+tim_ielen; tim_ie_offset = (int)(p - pie); - remainder_ielen = pnetwork_mlmeext->IELength - tim_ie_offset - tim_ielen; + remainder_ielen = pnetwork_mlmeext->IELength - + tim_ie_offset - tim_ielen; /* append TIM IE from dst_ie offset */ dst_ie = p; } else { @@ -99,7 +101,10 @@ static void update_BCNTIM(struct adapter *padapter) offset += pnetwork_mlmeext->Ssid.SsidLength + 2; /* get supported rates len */ - p = rtw_get_ie(pie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_)); + p = rtw_get_ie(pie + _BEACON_IE_OFFSET_, + _SUPPORTEDRATES_IE_, &tmp_len, + (pnetwork_mlmeext->IELength - + _BEACON_IE_OFFSET_)); if (p != NULL) offset += tmp_len+2; @@ -108,7 +113,8 @@ static void update_BCNTIM(struct adapter *padapter) premainder_ie = pie + offset; - remainder_ielen = pnetwork_mlmeext->IELength - offset - tim_ielen; + remainder_ielen = pnetwork_mlmeext->IELength - + offset - tim_ielen; /* append TIM IE from offset */ dst_ie = pie + offset; @@ -117,11 +123,13 @@ static void update_BCNTIM(struct adapter *padapter) if (remainder_ielen > 0) { pbackup_remainder_ie = rtw_malloc(remainder_ielen); if (pbackup_remainder_ie && premainder_ie) - memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); + memcpy(pbackup_remainder_ie, + premainder_ie, remainder_ielen); } *dst_ie++ = _TIM_IE_; - if ((pstapriv->tim_bitmap&0xff00) && (pstapriv->tim_bitmap&0x00fc)) + if ((pstapriv->tim_bitmap&0xff00) && + (pstapriv->tim_bitmap&0x00fc)) tim_ielen = 5; else tim_ielen = 4; @@ -156,7 +164,8 @@ static void update_BCNTIM(struct adapter *padapter) set_tx_beacon_cmd(padapter); } -void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8 index, u8 *data, u8 len) +void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, + u8 index, u8 *data, u8 len) { struct ndis_802_11_var_ie *pIE; u8 bmatch = false; @@ -170,7 +179,8 @@ void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8 if (pIE->ElementID > index) { break; - } else if (pIE->ElementID == index) { /* already exist the same IE */ + /* already exist the same IE */ + } else if (pIE->ElementID == index) { p = (u8 *)pIE; ielen = pIE->Length; bmatch = true; @@ -199,7 +209,8 @@ void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8 if (remainder_ielen > 0) { pbackup_remainder_ie = rtw_malloc(remainder_ielen); if (pbackup_remainder_ie && premainder_ie) - memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); + memcpy(pbackup_remainder_ie, + premainder_ie, remainder_ielen); } *dst_ie++ = index; @@ -219,7 +230,8 @@ void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8 pnetwork->IELength = offset + remainder_ielen; } -void rtw_remove_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8 index) +void rtw_remove_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, + u8 index) { u8 *p, *dst_ie = NULL, *premainder_ie = NULL; u8 *pbackup_remainder_ie = NULL; @@ -243,7 +255,8 @@ void rtw_remove_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, if (remainder_ielen > 0) { pbackup_remainder_ie = rtw_malloc(remainder_ielen); if (pbackup_remainder_ie && premainder_ie) - memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); + memcpy(pbackup_remainder_ie, + premainder_ie, remainder_ielen); } /* copy remainder IE */ @@ -261,8 +274,10 @@ static u8 chk_sta_is_alive(struct sta_info *psta) { u8 ret = false; - if ((psta->sta_stats.last_rx_data_pkts + psta->sta_stats.last_rx_ctrl_pkts) == - (psta->sta_stats.rx_data_pkts + psta->sta_stats.rx_ctrl_pkts)) + if ((psta->sta_stats.last_rx_data_pkts + + psta->sta_stats.last_rx_ctrl_pkts) == + (psta->sta_stats.rx_data_pkts + + psta->sta_stats.rx_ctrl_pkts)) ; else ret = true; @@ -344,13 +359,18 @@ void expire_timeout_chk(struct adapter *padapter) if (psta->state & WIFI_SLEEP_STATE) { if (!(psta->state & WIFI_STA_ALIVE_CHK_STATE)) { - /* to check if alive by another methods if station is at ps mode. */ + /* to check if alive by another methods + * if station is at ps mode. + */ psta->expire_to = pstapriv->expire_to; psta->state |= WIFI_STA_ALIVE_CHK_STATE; - /* to update bcn with tim_bitmap for this station */ + /* to update bcn with tim_bitmap + * for this station + */ pstapriv->tim_bitmap |= BIT(psta->aid); - update_beacon(padapter, _TIM_IE_, NULL, false); + update_beacon(padapter, _TIM_IE_, + NULL, false); if (!pmlmeext->active_keep_alive_check) continue; From 71d667b800c53f840f516eb7d332186ffee3e84a Mon Sep 17 00:00:00 2001 From: Jagan Teki Date: Mon, 18 May 2015 22:02:45 +0530 Subject: [PATCH 0657/1163] staging: rtl8712: Use ether_addr_copy() instead of memcpy() Fixes Warning encounter this by applying checkpatch.pl against this file: Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2) pahole output for respective structures: - addr->sa_data struct sockaddr { sa_family_t sa_family; /* 0 2 */ char sa_data[14]; /* 2 14 */ /* size: 16, cachelines: 1, members: 2 */ /* last cacheline: 16 bytes */ }; - pnetdev->dev_addr dev_addr is interface address infor from generic net_device structure which is properly aligned and have some patches with this change as well. "staging: rtl8712: fix Prefer ether_addr_copy() over memcpy()" (sha1: 36e4d8826b317080e283e4edd08bf8d5ac706f38) Signed-off-by: Jagan Teki Cc: Greg Kroah-Hartman Cc: Larry Finger Cc: Florian Schilhabel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/os_intfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c index 6e776e5433f6..d5f4c4d26a9c 100644 --- a/drivers/staging/rtl8712/os_intfs.c +++ b/drivers/staging/rtl8712/os_intfs.c @@ -181,7 +181,7 @@ static int r871x_net_set_mac_address(struct net_device *pnetdev, void *p) struct sockaddr *addr = p; if (padapter->bup == false) - memcpy(pnetdev->dev_addr, addr->sa_data, ETH_ALEN); + ether_addr_copy(pnetdev->dev_addr, addr->sa_data); return 0; } From 904998bf542309735f944387c158ceed84f6abc6 Mon Sep 17 00:00:00 2001 From: Vladimirs Ambrosovs Date: Mon, 25 May 2015 23:22:44 +0300 Subject: [PATCH 0658/1163] staging: fwserial: fix resource leak This patch fixes the leak, which was present in fwserial driver in the init function. In case the tty driver allocation failed the function returned error, leaving debugfs entry in the filesystem. To fix the issue additional error label was added, so that the code will jump to it in case of allocation failure, and free debugfs entries. Signed-off-by: Vladimirs Ambrosovs Reviewed-by: Peter Hurley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fwserial/fwserial.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c index fdb2418c5f88..b3ea4bb54e2c 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c @@ -2815,13 +2815,14 @@ static int __init fwserial_init(void) /* num_ttys/num_ports must not be set above the static alloc avail */ if (num_ttys + num_loops > MAX_CARD_PORTS) num_ttys = MAX_CARD_PORTS - num_loops; + num_ports = num_ttys + num_loops; fwtty_driver = tty_alloc_driver(MAX_TOTAL_PORTS, TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV); if (IS_ERR(fwtty_driver)) { err = PTR_ERR(fwtty_driver); - return err; + goto remove_debugfs; } fwtty_driver->driver_name = KBUILD_MODNAME; @@ -2923,7 +2924,9 @@ unregister_driver: tty_unregister_driver(fwtty_driver); put_tty: put_tty_driver(fwtty_driver); +remove_debugfs: debugfs_remove_recursive(fwserial_debugfs); + return err; } From a1471eb9da4a79650ca30c6038425f90da3b1054 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Fri, 15 May 2015 14:49:39 +0530 Subject: [PATCH 0659/1163] staging: rtl8712: fix stack dump del_timer_sync() is not to be called in the interrupt context unless the timer is irqsafe. but most of the functions where commits 6501c8e7d86cca5f and 382d020f4459cd77 touched were called in interrupt context. And as a result the WARN_ON was getting triggered. Changed to del_timer() in places which were called from interrupt. Fixes: 382d020f4459cd77 ("Staging: rtl8712: Eliminate use of _cancel_timer" Fixes: 6501c8e7d86cca5f ("Staging: rtl8712: Eliminate use of _cancel_timer_ex") Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=97711 Reported-by: Arek Rusniak Tested-by: Arek Rusniak Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_led.c | 144 +++++++++++----------- drivers/staging/rtl8712/rtl871x_cmd.c | 2 +- drivers/staging/rtl8712/rtl871x_mlme.c | 6 +- drivers/staging/rtl8712/rtl871x_pwrctrl.c | 2 +- drivers/staging/rtl8712/rtl871x_sta_mgt.c | 2 +- 5 files changed, 78 insertions(+), 78 deletions(-) diff --git a/drivers/staging/rtl8712/rtl8712_led.c b/drivers/staging/rtl8712/rtl8712_led.c index f1d47a0676c3..ada8d5dafd49 100644 --- a/drivers/staging/rtl8712/rtl8712_led.c +++ b/drivers/staging/rtl8712/rtl8712_led.c @@ -898,11 +898,11 @@ static void SwLedControlMode1(struct _adapter *padapter, IS_LED_WPS_BLINKING(pLed)) return; if (pLed->bLedLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } pLed->bLedNoLinkBlinkInProgress = true; @@ -921,11 +921,11 @@ static void SwLedControlMode1(struct _adapter *padapter, IS_LED_WPS_BLINKING(pLed)) return; if (pLed->bLedNoLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } pLed->bLedLinkBlinkInProgress = true; @@ -946,15 +946,15 @@ static void SwLedControlMode1(struct _adapter *padapter, if (IS_LED_WPS_BLINKING(pLed)) return; if (pLed->bLedNoLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } pLed->bLedScanBlinkInProgress = true; @@ -975,11 +975,11 @@ static void SwLedControlMode1(struct _adapter *padapter, IS_LED_WPS_BLINKING(pLed)) return; if (pLed->bLedNoLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedLinkBlinkInProgress = false; } pLed->bLedBlinkInProgress = true; @@ -998,19 +998,19 @@ static void SwLedControlMode1(struct _adapter *padapter, case LED_CTL_START_WPS_BOTTON: if (pLed->bLedWPSBlinkInProgress == false) { if (pLed->bLedNoLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } pLed->bLedWPSBlinkInProgress = true; @@ -1025,23 +1025,23 @@ static void SwLedControlMode1(struct _adapter *padapter, break; case LED_CTL_STOP_WPS: if (pLed->bLedNoLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } if (pLed->bLedWPSBlinkInProgress) - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); else pLed->bLedWPSBlinkInProgress = true; pLed->CurrLedState = LED_BLINK_WPS_STOP; @@ -1057,7 +1057,7 @@ static void SwLedControlMode1(struct _adapter *padapter, break; case LED_CTL_STOP_WPS_FAIL: if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; } pLed->bLedNoLinkBlinkInProgress = true; @@ -1073,23 +1073,23 @@ static void SwLedControlMode1(struct _adapter *padapter, pLed->CurrLedState = LED_OFF; pLed->BlinkingLedState = LED_OFF; if (pLed->bLedNoLinkBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedLinkBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } mod_timer(&pLed->BlinkTimer, @@ -1116,7 +1116,7 @@ static void SwLedControlMode2(struct _adapter *padapter, return; if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } pLed->bLedScanBlinkInProgress = true; @@ -1154,11 +1154,11 @@ static void SwLedControlMode2(struct _adapter *padapter, pLed->CurrLedState = LED_ON; pLed->BlinkingLedState = LED_ON; if (pLed->bLedBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } @@ -1170,11 +1170,11 @@ static void SwLedControlMode2(struct _adapter *padapter, case LED_CTL_START_WPS_BOTTON: if (pLed->bLedWPSBlinkInProgress == false) { if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } pLed->bLedWPSBlinkInProgress = true; @@ -1214,15 +1214,15 @@ static void SwLedControlMode2(struct _adapter *padapter, pLed->CurrLedState = LED_OFF; pLed->BlinkingLedState = LED_OFF; if (pLed->bLedBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; } mod_timer(&pLed->BlinkTimer, @@ -1248,7 +1248,7 @@ static void SwLedControlMode3(struct _adapter *padapter, if (IS_LED_WPS_BLINKING(pLed)) return; if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } pLed->bLedScanBlinkInProgress = true; @@ -1286,11 +1286,11 @@ static void SwLedControlMode3(struct _adapter *padapter, pLed->CurrLedState = LED_ON; pLed->BlinkingLedState = LED_ON; if (pLed->bLedBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } mod_timer(&pLed->BlinkTimer, @@ -1300,11 +1300,11 @@ static void SwLedControlMode3(struct _adapter *padapter, case LED_CTL_START_WPS_BOTTON: if (pLed->bLedWPSBlinkInProgress == false) { if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } pLed->bLedWPSBlinkInProgress = true; @@ -1319,7 +1319,7 @@ static void SwLedControlMode3(struct _adapter *padapter, break; case LED_CTL_STOP_WPS: if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&(pLed->BlinkTimer)); + del_timer(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; } else pLed->bLedWPSBlinkInProgress = true; @@ -1336,7 +1336,7 @@ static void SwLedControlMode3(struct _adapter *padapter, break; case LED_CTL_STOP_WPS_FAIL: if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; } pLed->CurrLedState = LED_OFF; @@ -1357,15 +1357,15 @@ static void SwLedControlMode3(struct _adapter *padapter, pLed->CurrLedState = LED_OFF; pLed->BlinkingLedState = LED_OFF; if (pLed->bLedBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; } mod_timer(&pLed->BlinkTimer, @@ -1388,7 +1388,7 @@ static void SwLedControlMode4(struct _adapter *padapter, case LED_CTL_START_TO_LINK: if (pLed1->bLedWPSBlinkInProgress) { pLed1->bLedWPSBlinkInProgress = false; - del_timer_sync(&pLed1->BlinkTimer); + del_timer(&pLed1->BlinkTimer); pLed1->BlinkingLedState = LED_OFF; pLed1->CurrLedState = LED_OFF; if (pLed1->bLedOn) @@ -1400,11 +1400,11 @@ static void SwLedControlMode4(struct _adapter *padapter, IS_LED_WPS_BLINKING(pLed)) return; if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedNoLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } pLed->bLedStartToLinkBlinkInProgress = true; @@ -1426,7 +1426,7 @@ static void SwLedControlMode4(struct _adapter *padapter, if (LedAction == LED_CTL_LINK) { if (pLed1->bLedWPSBlinkInProgress) { pLed1->bLedWPSBlinkInProgress = false; - del_timer_sync(&pLed1->BlinkTimer); + del_timer(&pLed1->BlinkTimer); pLed1->BlinkingLedState = LED_OFF; pLed1->CurrLedState = LED_OFF; if (pLed1->bLedOn) @@ -1439,7 +1439,7 @@ static void SwLedControlMode4(struct _adapter *padapter, IS_LED_WPS_BLINKING(pLed)) return; if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } pLed->bLedNoLinkBlinkInProgress = true; @@ -1460,11 +1460,11 @@ static void SwLedControlMode4(struct _adapter *padapter, if (IS_LED_WPS_BLINKING(pLed)) return; if (pLed->bLedNoLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } pLed->bLedScanBlinkInProgress = true; @@ -1485,7 +1485,7 @@ static void SwLedControlMode4(struct _adapter *padapter, IS_LED_WPS_BLINKING(pLed)) return; if (pLed->bLedNoLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } pLed->bLedBlinkInProgress = true; @@ -1503,7 +1503,7 @@ static void SwLedControlMode4(struct _adapter *padapter, case LED_CTL_START_WPS_BOTTON: if (pLed1->bLedWPSBlinkInProgress) { pLed1->bLedWPSBlinkInProgress = false; - del_timer_sync(&(pLed1->BlinkTimer)); + del_timer(&pLed1->BlinkTimer); pLed1->BlinkingLedState = LED_OFF; pLed1->CurrLedState = LED_OFF; if (pLed1->bLedOn) @@ -1512,15 +1512,15 @@ static void SwLedControlMode4(struct _adapter *padapter, } if (pLed->bLedWPSBlinkInProgress == false) { if (pLed->bLedNoLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } pLed->bLedWPSBlinkInProgress = true; @@ -1538,7 +1538,7 @@ static void SwLedControlMode4(struct _adapter *padapter, break; case LED_CTL_STOP_WPS: /*WPS connect success*/ if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; } pLed->bLedNoLinkBlinkInProgress = true; @@ -1552,7 +1552,7 @@ static void SwLedControlMode4(struct _adapter *padapter, break; case LED_CTL_STOP_WPS_FAIL: /*WPS authentication fail*/ if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; } pLed->bLedNoLinkBlinkInProgress = true; @@ -1565,7 +1565,7 @@ static void SwLedControlMode4(struct _adapter *padapter, msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA)); /*LED1 settings*/ if (pLed1->bLedWPSBlinkInProgress) - del_timer_sync(&pLed1->BlinkTimer); + del_timer(&pLed1->BlinkTimer); else pLed1->bLedWPSBlinkInProgress = true; pLed1->CurrLedState = LED_BLINK_WPS_STOP; @@ -1578,7 +1578,7 @@ static void SwLedControlMode4(struct _adapter *padapter, break; case LED_CTL_STOP_WPS_FAIL_OVERLAP: /*WPS session overlap*/ if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; } pLed->bLedNoLinkBlinkInProgress = true; @@ -1591,7 +1591,7 @@ static void SwLedControlMode4(struct _adapter *padapter, msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA)); /*LED1 settings*/ if (pLed1->bLedWPSBlinkInProgress) - del_timer_sync(&pLed1->BlinkTimer); + del_timer(&pLed1->BlinkTimer); else pLed1->bLedWPSBlinkInProgress = true; pLed1->CurrLedState = LED_BLINK_WPS_STOP_OVERLAP; @@ -1607,31 +1607,31 @@ static void SwLedControlMode4(struct _adapter *padapter, pLed->CurrLedState = LED_OFF; pLed->BlinkingLedState = LED_OFF; if (pLed->bLedNoLinkBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedLinkBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } if (pLed->bLedStartToLinkBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedStartToLinkBlinkInProgress = false; } if (pLed1->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed1->BlinkTimer); + del_timer(&pLed1->BlinkTimer); pLed1->bLedWPSBlinkInProgress = false; } pLed1->BlinkingLedState = LED_UNKNOWN; @@ -1671,7 +1671,7 @@ static void SwLedControlMode5(struct _adapter *padapter, ; /* dummy branch */ else if (pLed->bLedScanBlinkInProgress == false) { if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } pLed->bLedScanBlinkInProgress = true; @@ -1705,7 +1705,7 @@ static void SwLedControlMode5(struct _adapter *padapter, pLed->CurrLedState = LED_OFF; pLed->BlinkingLedState = LED_OFF; if (pLed->bLedBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } SwLedOff(padapter, pLed); @@ -1756,7 +1756,7 @@ static void SwLedControlMode6(struct _adapter *padapter, case LED_CTL_START_WPS_BOTTON: if (pLed->bLedWPSBlinkInProgress == false) { if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } pLed->bLedWPSBlinkInProgress = true; @@ -1772,7 +1772,7 @@ static void SwLedControlMode6(struct _adapter *padapter, case LED_CTL_STOP_WPS_FAIL: case LED_CTL_STOP_WPS: if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; } pLed->CurrLedState = LED_ON; @@ -1784,11 +1784,11 @@ static void SwLedControlMode6(struct _adapter *padapter, pLed->CurrLedState = LED_OFF; pLed->BlinkingLedState = LED_OFF; if (pLed->bLedBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); + del_timer(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; } SwLedOff(padapter, pLed); diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 1a1c38f885d6..e35854d28f90 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -910,7 +910,7 @@ void r8712_createbss_cmd_callback(struct _adapter *padapter, if (pcmd->res != H2C_SUCCESS) mod_timer(&pmlmepriv->assoc_timer, jiffies + msecs_to_jiffies(1)); - del_timer_sync(&pmlmepriv->assoc_timer); + del_timer(&pmlmepriv->assoc_timer); #ifdef __BIG_ENDIAN /* endian_convert */ pnetwork->Length = le32_to_cpu(pnetwork->Length); diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c index fb2b195b90af..c044b0e55ba9 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.c +++ b/drivers/staging/rtl8712/rtl871x_mlme.c @@ -582,7 +582,7 @@ void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf) spin_lock_irqsave(&pmlmepriv->lock, irqL); if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) { - del_timer_sync(&pmlmepriv->scan_to_timer); + del_timer(&pmlmepriv->scan_to_timer); _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); } @@ -696,7 +696,7 @@ void r8712_ind_disconnect(struct _adapter *padapter) } if (padapter->pwrctrlpriv.pwr_mode != padapter->registrypriv.power_mgnt) { - del_timer_sync(&pmlmepriv->dhcp_timer); + del_timer(&pmlmepriv->dhcp_timer); r8712_set_ps_mode(padapter, padapter->registrypriv.power_mgnt, padapter->registrypriv.smart_ps); } @@ -910,7 +910,7 @@ void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf) if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) r8712_indicate_connect(adapter); - del_timer_sync(&pmlmepriv->assoc_timer); + del_timer(&pmlmepriv->assoc_timer); } else goto ignore_joinbss_callback; } else { diff --git a/drivers/staging/rtl8712/rtl871x_pwrctrl.c b/drivers/staging/rtl8712/rtl871x_pwrctrl.c index aaa584435c87..9bc04f474d18 100644 --- a/drivers/staging/rtl8712/rtl871x_pwrctrl.c +++ b/drivers/staging/rtl8712/rtl871x_pwrctrl.c @@ -103,7 +103,7 @@ void r8712_cpwm_int_hdl(struct _adapter *padapter, if (pwrpriv->cpwm_tog == ((preportpwrstate->state) & 0x80)) return; - del_timer_sync(&padapter->pwrctrlpriv.rpwm_check_timer); + del_timer(&padapter->pwrctrlpriv.rpwm_check_timer); _enter_pwrlock(&pwrpriv->lock); pwrpriv->cpwm = (preportpwrstate->state) & 0xf; if (pwrpriv->cpwm >= PS_STATE_S2) { diff --git a/drivers/staging/rtl8712/rtl871x_sta_mgt.c b/drivers/staging/rtl8712/rtl871x_sta_mgt.c index 7bb96c47f188..a9b93d0f6f56 100644 --- a/drivers/staging/rtl8712/rtl871x_sta_mgt.c +++ b/drivers/staging/rtl8712/rtl871x_sta_mgt.c @@ -198,7 +198,7 @@ void r8712_free_stainfo(struct _adapter *padapter, struct sta_info *psta) * cancel reordering_ctrl_timer */ for (i = 0; i < 16; i++) { preorder_ctrl = &psta->recvreorder_ctrl[i]; - del_timer_sync(&preorder_ctrl->reordering_ctrl_timer); + del_timer(&preorder_ctrl->reordering_ctrl_timer); } spin_lock(&(pfree_sta_queue->lock)); /* insert into free_sta_queue; 20061114 */ From cab462140f8a183e3cca0b51c8b59ef715cb6148 Mon Sep 17 00:00:00 2001 From: Haggai Eran Date: Sat, 23 May 2015 23:13:51 +0300 Subject: [PATCH 0660/1163] staging: rtl8712: prevent buffer overrun in recvbuf2recvframe With an RTL8191SU USB adaptor, sometimes the hints for a fragmented packet are set, but the packet length is too large. Allocate enough space to prevent memory corruption and a resulting kernel panic [1]. [1] http://www.spinics.net/lists/linux-wireless/msg136546.html Cc: Signed-off-by: Haggai Eran ACKed-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_recv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c index 50227b598e0c..fcb8c61b2884 100644 --- a/drivers/staging/rtl8712/rtl8712_recv.c +++ b/drivers/staging/rtl8712/rtl8712_recv.c @@ -1056,7 +1056,8 @@ static int recvbuf2recvframe(struct _adapter *padapter, struct sk_buff *pskb) /* for first fragment packet, driver need allocate 1536 + * drvinfo_sz + RXDESC_SIZE to defrag packet. */ if ((mf == 1) && (frag == 0)) - alloc_sz = 1658;/*1658+6=1664, 1664 is 128 alignment.*/ + /*1658+6=1664, 1664 is 128 alignment.*/ + alloc_sz = max_t(u16, tmp_len, 1658); else alloc_sz = tmp_len; /* 2 is for IP header 4 bytes alignment in QoS packet case. From 2ede90f99650cc08ec1807ce07300cc5a4f0402f Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Tue, 19 May 2015 11:35:17 +0200 Subject: [PATCH 0661/1163] staging: rtl8712: remove useless comment "step 2" does mean much as there is no "step 1" stated anywhere... Signed-off-by: Luca Ceresoli Cc: Greg Kroah-Hartman Cc: Larry Finger Cc: Florian Schilhabel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/os_intfs.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c index d5f4c4d26a9c..ad11311be072 100644 --- a/drivers/staging/rtl8712/os_intfs.c +++ b/drivers/staging/rtl8712/os_intfs.c @@ -228,7 +228,6 @@ struct net_device *r8712_init_netdev(void) pnetdev->watchdog_timeo = HZ; /* 1 second timeout */ pnetdev->wireless_handlers = (struct iw_handler_def *) &r871x_handlers_def; - /*step 2.*/ loadparam(padapter, pnetdev); netif_carrier_off(pnetdev); padapter->pid = 0; /* Initial the PID value used for HW PBC.*/ From a0825db8d1c196d1699770206c70f021564869bb Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Tue, 19 May 2015 11:35:18 +0200 Subject: [PATCH 0662/1163] staging: rtl8712: remove unneeded forward declaration Signed-off-by: Luca Ceresoli Cc: Greg Kroah-Hartman Cc: Larry Finger Cc: Florian Schilhabel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/os_intfs.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c index ad11311be072..c86cc55e3981 100644 --- a/drivers/staging/rtl8712/os_intfs.c +++ b/drivers/staging/rtl8712/os_intfs.c @@ -122,7 +122,6 @@ module_param(low_power, int, 0644); MODULE_PARM_DESC(ifname, " Net interface name, wlan%d=default"); MODULE_PARM_DESC(initmac, "MAC-Address, default: use FUSE"); -static uint loadparam(struct _adapter *padapter, struct net_device *pnetdev); static int netdev_open(struct net_device *pnetdev); static int netdev_close(struct net_device *pnetdev); From 73b4276365a11a5e67ede758b6e876570d247202 Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Tue, 19 May 2015 11:35:19 +0200 Subject: [PATCH 0663/1163] staging: rtl8712: remove useless return value The loadparam() function cannot fail, it's called only once and its return value is ignored there. Signed-off-by: Luca Ceresoli Cc: Greg Kroah-Hartman Cc: Larry Finger Cc: Florian Schilhabel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/os_intfs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c index c86cc55e3981..5d551a1ba3dc 100644 --- a/drivers/staging/rtl8712/os_intfs.c +++ b/drivers/staging/rtl8712/os_intfs.c @@ -125,9 +125,8 @@ MODULE_PARM_DESC(initmac, "MAC-Address, default: use FUSE"); static int netdev_open(struct net_device *pnetdev); static int netdev_close(struct net_device *pnetdev); -static uint loadparam(struct _adapter *padapter, struct net_device *pnetdev) +static void loadparam(struct _adapter *padapter, struct net_device *pnetdev) { - uint status = _SUCCESS; struct registry_priv *registry_par = &padapter->registrypriv; registry_par->chip_version = (u8)chip_version; @@ -171,7 +170,6 @@ static uint loadparam(struct _adapter *padapter, struct net_device *pnetdev) registry_par->low_power = (u8)low_power; registry_par->wifi_test = (u8) wifi_test; r8712_initmac = initmac; - return status; } static int r871x_net_set_mac_address(struct net_device *pnetdev, void *p) From fd90ae2c1ff0863d0295da99aa651d20c4f5b836 Mon Sep 17 00:00:00 2001 From: Shailendra Verma Date: Wed, 27 May 2015 07:00:54 +0530 Subject: [PATCH 0664/1163] staging:nvec: fix typo in comment Fix spelling error in comment in function tegra_nvec_remove. Signed-off-by: Shailendra Verma Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index 1bdc8d001e65..164634d61ac5 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -916,7 +916,7 @@ static int tegra_nvec_remove(struct platform_device *pdev) nvec_unregister_notifier(nvec, &nvec->nvec_status_notifier); cancel_work_sync(&nvec->rx_work); cancel_work_sync(&nvec->tx_work); - /* FIXME: needs check wether nvec is responsible for power off */ + /* FIXME: needs check whether nvec is responsible for power off */ pm_power_off = NULL; return 0; From 79ef68c83b40bb5ec212888806bc909cc62d596e Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Tue, 19 May 2015 11:35:22 +0200 Subject: [PATCH 0665/1163] staging: rtl8188eu: cosmetic: remove useless spaces Even though these are not reported by checkpatch, they are coding style issues. Signed-off-by: Luca Ceresoli Cc: Greg Kroah-Hartman Cc: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index 78b5ad0528f0..9e80e97ea172 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -531,11 +531,10 @@ void rtw_proc_remove_one(struct net_device *dev) } #endif -static uint loadparam(struct adapter *padapter, struct net_device *pnetdev) +static uint loadparam(struct adapter *padapter, struct net_device *pnetdev) { struct registry_priv *registry_par = &padapter->registrypriv; - GlobalDebugLevel = rtw_debug; registry_par->chip_version = (u8)rtw_chip_version; registry_par->rfintfs = (u8)rtw_rfintfs; From ede000f37563adf5a7906d61d19bdb99cddf4d2e Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Tue, 19 May 2015 11:35:23 +0200 Subject: [PATCH 0666/1163] staging: rtl8188eu: add missing blank lines after declarations Fixes checkpatch warnings: WARNING: Missing a blank line after declarations Signed-off-by: Luca Ceresoli Cc: Greg Kroah-Hartman Cc: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index 9e80e97ea172..d396d595bd09 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -1059,6 +1059,7 @@ int netdev_open(struct net_device *pnetdev) static int ips_netdrv_open(struct adapter *padapter) { int status = _SUCCESS; + padapter->net_closed = false; DBG_88E("===> %s.........\n", __func__); @@ -1091,6 +1092,7 @@ int rtw_ips_pwr_up(struct adapter *padapter) { int result; u32 start_time = jiffies; + DBG_88E("===> rtw_ips_pwr_up..............\n"); rtw_reset_drv_sw(padapter); @@ -1105,6 +1107,7 @@ int rtw_ips_pwr_up(struct adapter *padapter) void rtw_ips_pwr_down(struct adapter *padapter) { u32 start_time = jiffies; + DBG_88E("===> rtw_ips_pwr_down...................\n"); padapter->net_closed = true; From cfaf917e6bb7e0eefa3cfdbba067221f87fdebce Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Tue, 19 May 2015 11:35:24 +0200 Subject: [PATCH 0667/1163] staging: rtl8188eu: remove useless return value The loadparam() function cannot fail, it's called only once and its return value is ignored there. Signed-off-by: Luca Ceresoli Cc: Greg Kroah-Hartman Cc: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index d396d595bd09..8828ef01499f 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -531,7 +531,7 @@ void rtw_proc_remove_one(struct net_device *dev) } #endif -static uint loadparam(struct adapter *padapter, struct net_device *pnetdev) +static void loadparam(struct adapter *padapter, struct net_device *pnetdev) { struct registry_priv *registry_par = &padapter->registrypriv; @@ -601,7 +601,6 @@ static uint loadparam(struct adapter *padapter, struct net_device *pnetdev) snprintf(registry_par->ifname, 16, "%s", ifname); snprintf(registry_par->if2name, 16, "%s", if2name); registry_par->notch_filter = (u8)rtw_notch_filter; - return _SUCCESS; } static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p) From 8b9ffb43ac1deabc80c2622a293a12d5f1a8d0ac Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Tue, 19 May 2015 11:35:25 +0200 Subject: [PATCH 0668/1163] staging: rtl8188eu: declare internal symbols as static Also remove them from .h files. Signed-off-by: Luca Ceresoli Cc: Greg Kroah-Hartman Cc: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/osdep_intf.h | 2 -- drivers/staging/rtl8188eu/include/recv_osdep.h | 3 --- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 15 +++++++++------ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/osdep_intf.h b/drivers/staging/rtl8188eu/include/osdep_intf.h index efa786887962..1521744d626c 100644 --- a/drivers/staging/rtl8188eu/include/osdep_intf.h +++ b/drivers/staging/rtl8188eu/include/osdep_intf.h @@ -31,7 +31,6 @@ u8 rtw_init_drv_sw(struct adapter *padapter); u8 rtw_free_drv_sw(struct adapter *padapter); u8 rtw_reset_drv_sw(struct adapter *padapter); -u32 rtw_start_drv_threads(struct adapter *padapter); void rtw_stop_drv_threads (struct adapter *padapter); void rtw_cancel_all_timer(struct adapter *padapter); @@ -40,7 +39,6 @@ int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); int rtw_init_netdev_name(struct net_device *pnetdev, const char *ifname); struct net_device *rtw_init_netdev(struct adapter *padapter); u16 rtw_recv_select_queue(struct sk_buff *skb); -void rtw_proc_init_one(struct net_device *dev); void rtw_proc_remove_one(struct net_device *dev); int pm_netdev_open(struct net_device *pnetdev, u8 bnormal); diff --git a/drivers/staging/rtl8188eu/include/recv_osdep.h b/drivers/staging/rtl8188eu/include/recv_osdep.h index 5aabd3984e58..0809963ce6aa 100644 --- a/drivers/staging/rtl8188eu/include/recv_osdep.h +++ b/drivers/staging/rtl8188eu/include/recv_osdep.h @@ -44,8 +44,5 @@ int rtw_os_recv_resource_alloc(struct adapter *adapt, int rtw_os_recvbuf_resource_alloc(struct adapter *adapt, struct recv_buf *buf); void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl); -int _netdev_open(struct net_device *pnetdev); -int netdev_open(struct net_device *pnetdev); -int netdev_close(struct net_device *pnetdev); #endif /* */ diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index 8828ef01499f..d411e18f592e 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -185,17 +185,20 @@ MODULE_PARM_DESC(rtw_notch_filter, "0:Disable, 1:Enable, 2:Enable only for P2P") module_param_named(debug, rtw_debug, int, 0444); MODULE_PARM_DESC(debug, "Set debug level (1-9) (default 1)"); +static int netdev_open(struct net_device *pnetdev); +static int netdev_close(struct net_device *pnetdev); + /* dummy routines */ void rtw_proc_remove_one(struct net_device *dev) { } -void rtw_proc_init_one(struct net_device *dev) +static void rtw_proc_init_one(struct net_device *dev) { } #if 0 /* TODO: Convert these to /sys */ -void rtw_proc_init_one(struct net_device *dev) +static void rtw_proc_init_one(struct net_device *dev) { struct proc_dir_entry *dir_dev = NULL; struct proc_dir_entry *entry = NULL; @@ -749,7 +752,7 @@ struct net_device *rtw_init_netdev(struct adapter *old_padapter) return pnetdev; } -u32 rtw_start_drv_threads(struct adapter *padapter) +static u32 rtw_start_drv_threads(struct adapter *padapter) { u32 _status = _SUCCESS; @@ -973,7 +976,7 @@ u8 rtw_free_drv_sw(struct adapter *padapter) return _SUCCESS; } -int _netdev_open(struct net_device *pnetdev) +static int _netdev_open(struct net_device *pnetdev) { uint status; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); @@ -1044,7 +1047,7 @@ netdev_open_error: return -1; } -int netdev_open(struct net_device *pnetdev) +static int netdev_open(struct net_device *pnetdev) { int ret; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); @@ -1142,7 +1145,7 @@ int pm_netdev_open(struct net_device *pnetdev, u8 bnormal) return status; } -int netdev_close(struct net_device *pnetdev) +static int netdev_close(struct net_device *pnetdev) { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); struct hal_data_8188e *rtlhal = GET_HAL_DATA(padapter); From 7fc0406f4875a414e4243706f98967064a4fa962 Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Tue, 19 May 2015 11:35:26 +0200 Subject: [PATCH 0669/1163] staging: rtl8188eu: return an error code, not a boolean "If the name of a function is an action or an imperative command, the function should return an error-code integer." (Documentation/CodingStyle) Several action-like functions in this driver return a boolean: _SUCCESS = 1 on success, _FAIL = 0 on error, defined in drivers/staging/rtl8188eu/include/osdep_service.h. Change rtw_start_drv_threads() to return a proper 0-or-error value. Signed-off-by: Luca Ceresoli Cc: Greg Kroah-Hartman Cc: Larry Finger Cc: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index d411e18f592e..2e96234cd253 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -752,21 +752,21 @@ struct net_device *rtw_init_netdev(struct adapter *old_padapter) return pnetdev; } -static u32 rtw_start_drv_threads(struct adapter *padapter) +static int rtw_start_drv_threads(struct adapter *padapter) { - u32 _status = _SUCCESS; + int err = 0; RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_start_drv_threads\n")); padapter->cmdThread = kthread_run(rtw_cmd_thread, padapter, "RTW_CMD_THREAD"); if (IS_ERR(padapter->cmdThread)) - _status = _FAIL; + err = PTR_ERR(padapter->cmdThread); else /* wait for cmd_thread to run */ _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema); - return _status; + return err; } void rtw_stop_drv_threads(struct adapter *padapter) @@ -979,6 +979,7 @@ u8 rtw_free_drv_sw(struct adapter *padapter) static int _netdev_open(struct net_device *pnetdev) { uint status; + int err; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; @@ -1002,8 +1003,8 @@ static int _netdev_open(struct net_device *pnetdev) pr_info("MAC Address = %pM\n", pnetdev->dev_addr); - status = rtw_start_drv_threads(padapter); - if (status == _FAIL) { + err = rtw_start_drv_threads(padapter); + if (err) { pr_info("Initialize driver software resource Failed!\n"); goto netdev_open_error; } From 44af49b63ee6fa2a2beb911b6333e4fdaa1db234 Mon Sep 17 00:00:00 2001 From: Jakub Sitnicki Date: Fri, 22 May 2015 07:06:12 +0200 Subject: [PATCH 0670/1163] staging: rtl8188eu: Remove redundant CONFIG_88EU_AP_MODE tests Remove #ifdef's enclosed by an #ifdef test for the same macro to improve readability. No code changes: md5, CONFIG_88EU_AP_MODE=y: b819a33f65133607ebc33b8999ee3a79 r8188eu.o.before b819a33f65133607ebc33b8999ee3a79 r8188eu.o.after md5, CONFIG_88EU_AP_MODE=n: 94c84035d59285408b866a57b442276d r8188eu.o.before 94c84035d59285408b866a57b442276d r8188eu.o.after Signed-off-by: Jakub Sitnicki Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 14 +------------- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 2 -- drivers/staging/rtl8188eu/include/rtw_ap.h | 2 -- 3 files changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 2da2e97647d6..0169a7d3e4c2 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -794,9 +794,7 @@ unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame) /* Now, we are going to issue_auth... */ pstat->auth_seq = seq + 1; -#ifdef CONFIG_88EU_AP_MODE issue_auth(padapter, pstat, (unsigned short)(_STATS_SUCCESSFUL_)); -#endif if (pstat->state & WIFI_FW_AUTH_SUCCESS) pstat->auth_seq = 0; @@ -813,11 +811,9 @@ auth_fail: pstat->auth_seq = 2; memcpy(pstat->hwaddr, sa, 6); -#ifdef CONFIG_88EU_AP_MODE issue_auth(padapter, pstat, (unsigned short)status); -#endif -#endif +#endif /* CONFIG_88EU_AP_MODE */ return _FAIL; } @@ -1295,7 +1291,6 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame /* now the station is qualified to join our BSS... */ if (pstat && (pstat->state & WIFI_FW_ASSOC_SUCCESS) && (_STATS_SUCCESSFUL_ == status)) { -#ifdef CONFIG_88EU_AP_MODE /* 1 bss_cap_update & sta_info_update */ bss_cap_update_on_sta_join(padapter, pstat); sta_info_update(padapter, pstat); @@ -1312,30 +1307,23 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame /* 3-(1) report sta add event */ report_add_sta_event(padapter, pstat->hwaddr, pstat->aid); -#endif } return _SUCCESS; asoc_class2_error: -#ifdef CONFIG_88EU_AP_MODE issue_deauth(padapter, (void *)GetAddr2Ptr(pframe), status); -#endif return _FAIL; OnAssocReqFail: - -#ifdef CONFIG_88EU_AP_MODE pstat->aid = 0; if (frame_type == WIFI_ASSOCREQ) issue_asocrsp(padapter, status, pstat, WIFI_ASSOCRSP); else issue_asocrsp(padapter, status, pstat, WIFI_REASSOCRSP); -#endif - #endif /* CONFIG_88EU_AP_MODE */ diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index dc9d0ddf6b3a..0b1cb03ab7b2 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -54,14 +54,12 @@ static void _rtw_init_stainfo(struct sta_info *psta) psta->bpairwise_key_installed = false; -#ifdef CONFIG_88EU_AP_MODE psta->nonerp_set = 0; psta->no_short_slot_time_set = 0; psta->no_short_preamble_set = 0; psta->no_ht_gf_set = 0; psta->no_ht_set = 0; psta->ht_20mhz_set = 0; -#endif psta->under_exist_checking = 0; diff --git a/drivers/staging/rtl8188eu/include/rtw_ap.h b/drivers/staging/rtl8188eu/include/rtw_ap.h index 923340159798..6128ccce91ba 100644 --- a/drivers/staging/rtl8188eu/include/rtw_ap.h +++ b/drivers/staging/rtl8188eu/include/rtw_ap.h @@ -47,7 +47,6 @@ void rtw_set_macaddr_acl(struct adapter *padapter, int mode); int rtw_acl_add_sta(struct adapter *padapter, u8 *addr); int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr); -#ifdef CONFIG_88EU_AP_MODE void associated_clients_update(struct adapter *padapter, u8 updated); void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta); u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta); @@ -59,7 +58,6 @@ int rtw_sta_flush(struct adapter *padapter); int rtw_ap_inform_ch_switch(struct adapter *padapter, u8 new_ch, u8 ch_offset); void start_ap_mode(struct adapter *padapter); void stop_ap_mode(struct adapter *padapter); -#endif #endif /* end of CONFIG_88EU_AP_MODE */ #endif From 63de0eb0bc7c00336f4293724d0d9d1bc10e9228 Mon Sep 17 00:00:00 2001 From: Isaac Assegai Date: Sun, 24 May 2015 22:48:42 -0700 Subject: [PATCH 0671/1163] Staging: sm750fb: Replace spaces with tabs at the start of lines Replace spaces at the start of lines with tabs to rectify the following warning: WARNING: please, no spaces at the start of a line Signed-off-by: Isaac Assegai Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/ddk750_chip.c | 2 +- drivers/staging/sm750fb/ddk750_chip.h | 69 ++++++++++++++------------- 2 files changed, 38 insertions(+), 33 deletions(-) diff --git a/drivers/staging/sm750fb/ddk750_chip.c b/drivers/staging/sm750fb/ddk750_chip.c index 3cb860ce60cc..8b47c1bfc401 100644 --- a/drivers/staging/sm750fb/ddk750_chip.c +++ b/drivers/staging/sm750fb/ddk750_chip.c @@ -616,7 +616,7 @@ unsigned int formatPllReg(pll_value_t *pPLL) | FIELD_VALUE(0, PANEL_PLL_CTRL, N, pPLL->N) | FIELD_VALUE(0, PANEL_PLL_CTRL, M, pPLL->M); - return ulPllReg; + return ulPllReg; } diff --git a/drivers/staging/sm750fb/ddk750_chip.h b/drivers/staging/sm750fb/ddk750_chip.h index 04cb0d559245..83821de68f40 100644 --- a/drivers/staging/sm750fb/ddk750_chip.h +++ b/drivers/staging/sm750fb/ddk750_chip.h @@ -10,10 +10,10 @@ /* This is all the chips recognized by this library */ typedef enum _logical_chip_type_t { - SM_UNKNOWN, - SM718, - SM750, - SM750LE, + SM_UNKNOWN, + SM718, + SM750, + SM750LE, } logical_chip_type_t; @@ -30,42 +30,47 @@ clock_type_t; typedef struct _pll_value_t { - clock_type_t clockType; - unsigned long inputFreq; /* Input clock frequency to the PLL */ + clock_type_t clockType; + unsigned long inputFreq; /* Input clock frequency to the PLL */ - /* Use this when clockType = PANEL_PLL */ - unsigned long M; - unsigned long N; - unsigned long OD; - unsigned long POD; + /* Use this when clockType = PANEL_PLL */ + unsigned long M; + unsigned long N; + unsigned long OD; + unsigned long POD; } pll_value_t; /* input struct to initChipParam() function */ typedef struct _initchip_param_t { - unsigned short powerMode; /* Use power mode 0 or 1 */ - unsigned short chipClock; /* Speed of main chip clock in MHz unit - 0 = keep the current clock setting - Others = the new main chip clock - */ - unsigned short memClock; /* Speed of memory clock in MHz unit - 0 = keep the current clock setting - Others = the new memory clock - */ - unsigned short masterClock; /* Speed of master clock in MHz unit - 0 = keep the current clock setting - Others = the new master clock - */ - unsigned short setAllEngOff; /* 0 = leave all engine state untouched. - 1 = make sure they are off: 2D, Overlay, - video alpha, alpha, hardware cursors - */ - unsigned char resetMemory; /* 0 = Do not reset the memory controller - 1 = Reset the memory controller - */ + unsigned short powerMode; /* Use power mode 0 or 1 */ + unsigned short chipClock; /** + * Speed of main chip clock in MHz unit + * 0 = keep the current clock setting + * Others = the new main chip clock + */ + unsigned short memClock; /** + * Speed of memory clock in MHz unit + * 0 = keep the current clock setting + * Others = the new memory clock + */ + unsigned short masterClock; /** + * Speed of master clock in MHz unit + * 0 = keep the current clock setting + * Others = the new master clock + */ + unsigned short setAllEngOff; /** + * 0 = leave all engine state untouched. + * 1 = make sure they are off: 2D, Overlay, + * video alpha, alpha, hardware cursors + */ + unsigned char resetMemory; /** + * 0 = Do not reset the memory controller + * 1 = Reset the memory controller + */ - /* More initialization parameter can be added if needed */ + /* More initialization parameter can be added if needed */ } initchip_param_t; From c4eacdad9d9a563c0b324123fa5d5e7e07cda33c Mon Sep 17 00:00:00 2001 From: Michel von Czettritz Date: Tue, 26 May 2015 17:22:39 +0200 Subject: [PATCH 0672/1163] staging: sm750fb: remove duplicate from fb_videomode As suggested by Sudip this patch removes the redundant 1360x768@60 option from the fb_videomode struct array. The removed option and the option one it differ in a typo and a flag. Signed-off-by: Michel von Czettritz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c index 69b18f399b90..d90b4634b954 100644 --- a/drivers/staging/sm750fb/sm750.c +++ b/drivers/staging/sm750fb/sm750.c @@ -88,9 +88,6 @@ static const struct fb_videomode lynx750_ext[] = { FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED}, - {NULL, 60, 1360, 768, 11804, 208, 64, 23, 1, 144, 3, - FB_SYNC_HOR_HIGH_ACT|FB_VMODE_NONINTERLACED}, - /* 1360 x 768 [1.77083:1] */ {NULL, 60, 1360, 768, 11804, 208, 64, 23, 1, 144, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, From 008272072d61a8ce9f9f1e7cf2807a59b2e67b64 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Thu, 28 May 2015 08:41:16 +0900 Subject: [PATCH 0673/1163] staging: sm750fb: Fix typo in sm750.c This patch fix a spelling typo in printk within sm750.c Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c index d90b4634b954..6b642d75b9b5 100644 --- a/drivers/staging/sm750fb/sm750.c +++ b/drivers/staging/sm750fb/sm750.c @@ -974,7 +974,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index) ret = fb_alloc_cmap(&info->cmap, 256, 0); if (ret < 0) { - pr_err("Could not allcate memory for cmap.\n"); + pr_err("Could not allocate memory for cmap.\n"); goto exit; } From 60c77d1adbff06e6ca568fbd874407f1ae23badc Mon Sep 17 00:00:00 2001 From: Nicholas Mc Guire Date: Fri, 29 May 2015 17:58:18 +0200 Subject: [PATCH 0674/1163] staging: me_daq: use schedule_timeout_interruptible() API consolidation with coccinelle found: ./drivers/staging/comedi/drivers/me_daq.c:177:1-17: consolidation with schedule_timeout_*() recommended This is a 1:1 conversion of the current calls to an available helper only - so only an API consolidation to improve readability. Signed-off-by: Nicholas Mc Guire Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/me_daq.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c index d78e9195fbce..9ea1ba4b1b6f 100644 --- a/drivers/staging/comedi/drivers/me_daq.c +++ b/drivers/staging/comedi/drivers/me_daq.c @@ -173,8 +173,7 @@ struct me_private_data { static inline void sleep(unsigned sec) { - __set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(sec * HZ); + schedule_timeout_interruptible(sec * HZ); } static int me_dio_insn_config(struct comedi_device *dev, From 895875a3d85596e3e2e46aeb382bf14f1419de82 Mon Sep 17 00:00:00 2001 From: Nicholas Mc Guire Date: Fri, 29 May 2015 19:02:32 +0200 Subject: [PATCH 0675/1163] staging: panel: use schedule_timeout_interruptible() API consolidation with coccinelle found: ./drivers/staging/panel/panel.c:782:2-18: consolidation with schedule_timeout_*() recommended This is a 1:1 conversion with respect to schedule_timeout() to the schedule_timeout_interruptible() helper only - so only an API consolidation to improve readability. The timeout was being passed as (ms * HZ + 999) / 1000 but that simply looks wrong - rather than "manual" converting to jiffies, msecs_to_jiffies which handles all corner-cases correctly, was used. Patch was compile tested with x86_64_defconfig + CONFIG_STAGING=y, CONFIG_PARPORT=m, CONFIG_PANEL=m Signed-off-by: Nicholas Mc Guire Acked-by: Willy Tarreau Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index 0046ee0af8b9..d67049455253 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -775,12 +775,10 @@ 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 { - __set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout((ms * HZ + 999) / 1000); - } + else + schedule_timeout_interruptible(msecs_to_jiffies(ms)); } /* send a serial byte to the LCD panel. The caller is responsible for locking From ae7c0f4833a65b7648cceaf1a60503a89e057f0f Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sat, 30 May 2015 23:27:00 -0400 Subject: [PATCH 0676/1163] staging/lustre/llite: Move all remaining procfs entries to debugfs This moves all remaining procfs handling in llite layer to debugfs. Signed-off-by: Dmitry Eremin Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/llite/llite_internal.h | 27 ++++++----- .../staging/lustre/lustre/llite/llite_lib.c | 13 +++-- .../staging/lustre/lustre/llite/lproc_llite.c | 48 +++++++++++-------- drivers/staging/lustre/lustre/llite/super25.c | 20 ++++---- drivers/staging/lustre/lustre/llite/vvp_dev.c | 21 ++++---- 5 files changed, 68 insertions(+), 61 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index e180912d0e08..b30eb85a53c9 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -465,7 +465,7 @@ struct ll_sb_info { struct obd_uuid ll_sb_uuid; struct obd_export *ll_md_exp; struct obd_export *ll_dt_exp; - struct proc_dir_entry* ll_proc_root; + struct dentry *ll_debugfs_entry; struct lu_fid ll_root_fid; /* root object fid */ int ll_flags; @@ -636,7 +636,7 @@ struct lov_stripe_md; extern spinlock_t inode_lock; -extern struct proc_dir_entry *proc_lustre_fs_root; +extern struct dentry *llite_root; extern struct kset *llite_kset; static inline struct inode *ll_info2i(struct ll_inode_info *lli) @@ -664,20 +664,25 @@ struct ll_ra_read *ll_ra_read_get(struct file *f); /* llite/lproc_llite.c */ #if defined (CONFIG_PROC_FS) -int lprocfs_register_mountpoint(struct proc_dir_entry *parent, - struct super_block *sb, char *osc, char *mdc); -void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi); +int ldebugfs_register_mountpoint(struct dentry *parent, + struct super_block *sb, char *osc, char *mdc); +void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi); void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count); void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars); void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, struct ll_file_data *file, loff_t pos, size_t count, int rw); -#else -static inline int lprocfs_register_mountpoint(struct proc_dir_entry *parent, - struct super_block *sb, char *osc, char *mdc){return 0;} -static inline void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi) {} +#else /* CONFIG_PROC_FS */ static inline -void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) {} +int ldebugfs_register_mountpoint(struct dentry *parent, + struct super_block *sb, char *osc, char *mdc) +{ return 0; } +static inline +void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi) +{} +static inline +void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) +{} static inline void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars) { memset(lvars, 0, sizeof(*lvars)); @@ -685,7 +690,7 @@ static inline void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars) static inline void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, struct ll_file_data *file, loff_t pos, size_t count, int rw) {} -#endif +#endif /* CONFIG_PROC_FS */ /* llite/dir.c */ diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 4c9fd4acedea..25139885b5a7 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -57,7 +57,7 @@ #include "llite_internal.h" struct kmem_cache *ll_file_data_slab; -struct proc_dir_entry *proc_lustre_fs_root; +struct dentry *llite_root; struct kset *llite_kset; static LIST_HEAD(ll_super_blocks); @@ -184,11 +184,10 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, return -ENOMEM; } - if (proc_lustre_fs_root) { - err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb, - dt, md); + if (llite_root != NULL) { + err = ldebugfs_register_mountpoint(llite_root, sb, dt, md); if (err < 0) - CERROR("could not register mount in /proc/fs/lustre\n"); + CERROR("could not register mount in /lustre/llite\n"); } /* indicate the features supported by this client */ @@ -601,7 +600,7 @@ out_md: out: kfree(data); kfree(osfs); - lprocfs_unregister_mountpoint(sbi); + ldebugfs_unregister_mountpoint(sbi); return err; } @@ -682,7 +681,7 @@ static void client_common_put_super(struct super_block *sb) * see LU-2543. */ obd_zombie_barrier(); - lprocfs_unregister_mountpoint(sbi); + ldebugfs_unregister_mountpoint(sbi); obd_fid_fini(sbi->ll_md_exp->exp_obd); obd_disconnect(sbi->ll_md_exp); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 2c84bed3f6ce..486dca6077de 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -950,12 +950,13 @@ static const char *ra_stat_string[] = { [RA_STAT_WRONG_GRAB_PAGE] = "wrong page from grab_cache_page", }; -int lprocfs_register_mountpoint(struct proc_dir_entry *parent, - struct super_block *sb, char *osc, char *mdc) +int ldebugfs_register_mountpoint(struct dentry *parent, + struct super_block *sb, char *osc, char *mdc) { struct lustre_sb_info *lsi = s2lsi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); struct obd_device *obd; + struct dentry *dir; char name[MAX_STRING_SIZE + 1], *ptr; int err, id, len, rc; @@ -976,30 +977,32 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, snprintf(name, MAX_STRING_SIZE, "%.*s-%p", len, lsi->lsi_lmd->lmd_profile, sb); - sbi->ll_proc_root = lprocfs_register(name, parent, NULL, NULL); - if (IS_ERR(sbi->ll_proc_root)) { - err = PTR_ERR(sbi->ll_proc_root); - sbi->ll_proc_root = NULL; + dir = ldebugfs_register(name, parent, NULL, NULL); + if (IS_ERR_OR_NULL(dir)) { + err = dir ? PTR_ERR(dir) : -ENOMEM; + sbi->ll_debugfs_entry = NULL; return err; } + sbi->ll_debugfs_entry = dir; - rc = lprocfs_seq_create(sbi->ll_proc_root, "dump_page_cache", 0444, - &vvp_dump_pgcache_file_ops, sbi); + rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, "dump_page_cache", 0444, + &vvp_dump_pgcache_file_ops, sbi); if (rc) CWARN("Error adding the dump_page_cache file\n"); - rc = lprocfs_seq_create(sbi->ll_proc_root, "extents_stats", 0644, - &ll_rw_extents_stats_fops, sbi); + rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, "extents_stats", 0644, + &ll_rw_extents_stats_fops, sbi); if (rc) CWARN("Error adding the extent_stats file\n"); - rc = lprocfs_seq_create(sbi->ll_proc_root, "extents_stats_per_process", - 0644, &ll_rw_extents_stats_pp_fops, sbi); + rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, + "extents_stats_per_process", + 0644, &ll_rw_extents_stats_pp_fops, sbi); if (rc) CWARN("Error adding the extents_stats_per_process file\n"); - rc = lprocfs_seq_create(sbi->ll_proc_root, "offset_stats", 0644, - &ll_rw_offset_stats_fops, sbi); + rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, "offset_stats", 0644, + &ll_rw_offset_stats_fops, sbi); if (rc) CWARN("Error adding the offset_stats file\n"); @@ -1025,7 +1028,8 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, (type & LPROCFS_CNTR_AVGMINMAX), llite_opcode_table[id].opname, ptr); } - err = lprocfs_register_stats(sbi->ll_proc_root, "stats", sbi->ll_stats); + err = ldebugfs_register_stats(sbi->ll_debugfs_entry, "stats", + sbi->ll_stats); if (err) goto out; @@ -1039,13 +1043,15 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, for (id = 0; id < ARRAY_SIZE(ra_stat_string); id++) lprocfs_counter_init(sbi->ll_ra_stats, id, 0, ra_stat_string[id], "pages"); - err = lprocfs_register_stats(sbi->ll_proc_root, "read_ahead_stats", + + err = ldebugfs_register_stats(sbi->ll_debugfs_entry, "read_ahead_stats", sbi->ll_ra_stats); if (err) goto out; - err = lprocfs_add_vars(sbi->ll_proc_root, lprocfs_llite_obd_vars, sb); + err = ldebugfs_add_vars(sbi->ll_debugfs_entry, + lprocfs_llite_obd_vars, sb); if (err) goto out; @@ -1071,17 +1077,17 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, obd->obd_type->typ_name); out: if (err) { - lprocfs_remove(&sbi->ll_proc_root); + ldebugfs_remove(&sbi->ll_debugfs_entry); lprocfs_free_stats(&sbi->ll_ra_stats); lprocfs_free_stats(&sbi->ll_stats); } return err; } -void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi) +void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi) { - if (sbi->ll_proc_root) { - lprocfs_remove(&sbi->ll_proc_root); + if (sbi->ll_debugfs_entry) { + ldebugfs_remove(&sbi->ll_debugfs_entry); kobject_put(&sbi->ll_kobj); wait_for_completion(&sbi->ll_kobj_unregister); lprocfs_free_stats(&sbi->ll_ra_stats); diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index 8753560809fa..e4020ce8cb7b 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -89,7 +89,6 @@ void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg)); static int __init init_lustre_lite(void) { - struct proc_dir_entry *entry; lnet_process_id_t lnet_id; struct timeval tv; int i, rc, seed[2]; @@ -128,20 +127,17 @@ static int __init init_lustre_lite(void) if (ll_rmtperm_hash_cachep == NULL) goto out_cache; - entry = lprocfs_register("llite", proc_lustre_root, NULL, NULL); - if (IS_ERR(entry)) { - rc = PTR_ERR(entry); - CERROR("cannot register '/proc/fs/lustre/llite': rc = %d\n", - rc); + llite_root = debugfs_create_dir("llite", debugfs_lustre_root); + if (IS_ERR_OR_NULL(llite_root)) { + rc = llite_root ? PTR_ERR(llite_root) : -ENOMEM; + llite_root = NULL; goto out_cache; } - proc_lustre_fs_root = entry; - llite_kset = kset_create_and_add("llite", NULL, lustre_kobj); if (!llite_kset) { rc = -ENOMEM; - goto out_proc; + goto out_debugfs; } cfs_get_random_bytes(seed, sizeof(seed)); @@ -184,8 +180,8 @@ out_capa: ll_capa_thread_stop(); out_sysfs: kset_unregister(llite_kset); -out_proc: - lprocfs_remove(&proc_lustre_fs_root); +out_debugfs: + debugfs_remove(llite_root); out_cache: if (ll_inode_cachep != NULL) kmem_cache_destroy(ll_inode_cachep); @@ -208,7 +204,7 @@ static void __exit exit_lustre_lite(void) lustre_register_kill_super_cb(NULL); lustre_register_client_process_config(NULL); - lprocfs_remove(&proc_lustre_fs_root); + debugfs_remove(llite_root); kset_unregister(llite_kset); ll_xattr_fini(); diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index fde41d7c5e3d..6d9622acb44f 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c @@ -253,7 +253,7 @@ int cl_sb_fini(struct super_block *sb) /**************************************************************************** * - * /proc/fs/lustre/llite/$MNT/dump_page_cache + * debugfs/lustre/llite/$MNT/dump_page_cache * ****************************************************************************/ @@ -526,16 +526,17 @@ static struct seq_operations vvp_pgcache_ops = { static int vvp_dump_pgcache_seq_open(struct inode *inode, struct file *filp) { - struct ll_sb_info *sbi = PDE_DATA(inode); - struct seq_file *seq; - int result; + struct seq_file *seq; + int rc; - result = seq_open(filp, &vvp_pgcache_ops); - if (result == 0) { - seq = filp->private_data; - seq->private = sbi; - } - return result; + rc = seq_open(filp, &vvp_pgcache_ops); + if (rc) + return rc; + + seq = filp->private_data; + seq->private = inode->i_private ?: PDE_DATA(inode); + + return 0; } const struct file_operations vvp_dump_pgcache_file_ops = { From 617219c9233402cf340783a41ac6a3ca1c420db5 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Sat, 30 May 2015 23:27:01 -0400 Subject: [PATCH 0677/1163] staging/lustre/obd: remove unused proc_lustre_root Signed-off-by: Dmitry Eremin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lprocfs_status.h | 3 --- .../lustre/obdclass/linux/linux-module.c | 18 ------------------ 2 files changed, 21 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 721efd6cc698..19ab9e8b7eee 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -349,7 +349,6 @@ enum { #define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE /* class_obd.c */ -extern struct proc_dir_entry *proc_lustre_root; extern struct dentry *debugfs_lustre_root; extern struct kobject *lustre_kobj; @@ -851,8 +850,6 @@ extern int lprocfs_quota_wr_qs_factor(struct file *file, #else /* CONFIG_PROC_FS is not defined */ -#define proc_lustre_root NULL - static inline void lprocfs_counter_add(struct lprocfs_stats *stats, int index, long amount) { return; } diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index 03a982a9309f..50c3d1de24cb 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -322,11 +322,6 @@ static ssize_t jobid_name_store(struct kobject *kobj, struct attribute *attr, struct dentry *debugfs_lustre_root; EXPORT_SYMBOL_GPL(debugfs_lustre_root); -#if defined(CONFIG_PROC_FS) -/* Root for /proc/fs/lustre */ -struct proc_dir_entry *proc_lustre_root = NULL; -EXPORT_SYMBOL(proc_lustre_root); - LUSTRE_RO_ATTR(version); LUSTRE_RO_ATTR(pinger); LUSTRE_RO_ATTR(health); @@ -459,14 +454,6 @@ int class_procfs_init(void) kobject_put(lustre_kobj); goto out; } - - proc_lustre_root = lprocfs_register("fs/lustre", NULL, NULL, NULL); - if (IS_ERR(proc_lustre_root)) { - rc = PTR_ERR(proc_lustre_root); - proc_lustre_root = NULL; - kobject_put(lustre_kobj); - goto out; - } out: return rc; } @@ -478,12 +465,7 @@ int class_procfs_clean(void) debugfs_lustre_root = NULL; - if (proc_lustre_root) { - lprocfs_remove(&proc_lustre_root); - } - kobject_put(lustre_kobj); return 0; } -#endif /* CONFIG_PROC_FS */ From 8c36242b58bb38bf6da5a5cfa207e9d9fdb8c345 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sat, 30 May 2015 23:27:02 -0400 Subject: [PATCH 0678/1163] staging/lustre/obd: Rename lprocfs_add_symlink to ldebugfs_add_symlink Signed-off-by: Dmitry Eremin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lprocfs_status.h | 12 ++---------- .../lustre/lustre/obdclass/lprocfs_status.c | 16 +++++++++------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 19ab9e8b7eee..328cd07b4bfe 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -572,8 +572,8 @@ extern struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root, char *name, void *data, struct file_operations *fops); -extern struct proc_dir_entry * -lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent, +extern struct dentry * +ldebugfs_add_symlink(const char *name, struct dentry *parent, const char *format, ...); extern void lprocfs_free_per_client_stats(struct obd_device *obd); extern int @@ -905,20 +905,12 @@ static inline void lprocfs_free_md_stats(struct obd_device *obddev) struct obd_export; static inline int lprocfs_add_clear_entry(struct obd_export *exp) { return 0; } -static inline int lprocfs_exp_setup(struct obd_export *exp, - lnet_nid_t *peer_nid, - int *newnid) -{ return 0; } static inline int lprocfs_exp_cleanup(struct obd_export *exp) { return 0; } static inline struct proc_dir_entry * lprocfs_add_simple(struct proc_dir_entry *root, char *name, void *data, struct file_operations *fops) {return 0; } -static inline struct proc_dir_entry * -lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent, - const char *format, ...) -{return NULL; } static inline void lprocfs_free_per_client_stats(struct obd_device *obd) { return; } static inline diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 51865ddde0b6..79ff72c90c8c 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -289,10 +289,10 @@ struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root, } EXPORT_SYMBOL(lprocfs_add_simple); -struct proc_dir_entry *lprocfs_add_symlink(const char *name, - struct proc_dir_entry *parent, const char *format, ...) +struct dentry *ldebugfs_add_symlink(const char *name, struct dentry *parent, + const char *format, ...) { - struct proc_dir_entry *entry; + struct dentry *entry; char *dest; va_list ap; @@ -307,15 +307,17 @@ struct proc_dir_entry *lprocfs_add_symlink(const char *name, vsnprintf(dest, MAX_STRING_SIZE, format, ap); va_end(ap); - entry = proc_symlink(name, parent, dest); - if (entry == NULL) - CERROR("LprocFS: Could not create symbolic link from %s to %s", + entry = debugfs_create_symlink(name, parent, dest); + if (IS_ERR_OR_NULL(entry)) { + CERROR("LdebugFS: Could not create symbolic link from %s to %s", name, dest); + entry = NULL; + } kfree(dest); return entry; } -EXPORT_SYMBOL(lprocfs_add_symlink); +EXPORT_SYMBOL(ldebugfs_add_symlink); static struct file_operations lprocfs_generic_fops = { }; From ade9fb1e7f3bacaeba6942255ea60de170b63686 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sat, 30 May 2015 23:27:03 -0400 Subject: [PATCH 0679/1163] staging/lustre/obd: remove unused lprocfs_exp_setup() and related functions This code only made sense on servers. Signed-off-by: Dmitry Eremin Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lprocfs_status.h | 2 - drivers/staging/lustre/lustre/include/obd.h | 1 - .../lustre/lustre/obdclass/lprocfs_status.c | 182 ------------------ 3 files changed, 185 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 328cd07b4bfe..4b8c265d8fe1 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -561,8 +561,6 @@ struct obd_export; struct nid_stat; extern int lprocfs_add_clear_entry(struct obd_device *obd, struct proc_dir_entry *entry); -extern int lprocfs_exp_setup(struct obd_export *exp, - lnet_nid_t *peer_nid, int *newnid); extern int lprocfs_exp_cleanup(struct obd_export *exp); extern struct dentry *ldebugfs_add_simple(struct dentry *root, char *name, diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index cb994e1d6bba..708a4cfb4659 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -918,7 +918,6 @@ struct obd_device { struct lprocfs_stats *md_stats; struct dentry *obd_debugfs_entry; - struct proc_dir_entry *obd_proc_exports_entry; struct dentry *obd_svc_debugfs_entry; struct lprocfs_stats *obd_svc_stats; atomic_t obd_evict_inprogress; diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 79ff72c90c8c..3ef5474fcd34 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1096,12 +1096,6 @@ int lprocfs_obd_cleanup(struct obd_device *obd) if (!obd) return -EINVAL; - if (obd->obd_proc_exports_entry) { - /* Should be no exports left */ - lprocfs_remove(&obd->obd_proc_exports_entry); - obd->obd_proc_exports_entry = NULL; - } - if (!IS_ERR_OR_NULL(obd->obd_debugfs_entry)) ldebugfs_remove(&obd->obd_debugfs_entry); @@ -1685,72 +1679,6 @@ void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats) } EXPORT_SYMBOL(lprocfs_init_ldlm_stats); -int lprocfs_exp_print_uuid(struct cfs_hash *hs, struct cfs_hash_bd *bd, - struct hlist_node *hnode, void *data) - -{ - struct obd_export *exp = cfs_hash_object(hs, hnode); - struct seq_file *m = (struct seq_file *)data; - - if (exp->exp_nid_stats) - seq_printf(m, "%s\n", obd_uuid2str(&exp->exp_client_uuid)); - - return 0; -} - -static int -lproc_exp_uuid_seq_show(struct seq_file *m, void *unused) -{ - struct nid_stat *stats = (struct nid_stat *)m->private; - struct obd_device *obd = stats->nid_obd; - - cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid, - lprocfs_exp_print_uuid, m); - return 0; -} - -LPROC_SEQ_FOPS_RO(lproc_exp_uuid); - -struct exp_hash_cb_data { - struct seq_file *m; - bool first; -}; - -int lprocfs_exp_print_hash(struct cfs_hash *hs, struct cfs_hash_bd *bd, - struct hlist_node *hnode, void *cb_data) - -{ - struct exp_hash_cb_data *data = (struct exp_hash_cb_data *)cb_data; - struct obd_export *exp = cfs_hash_object(hs, hnode); - - if (exp->exp_lock_hash != NULL) { - if (data->first) { - cfs_hash_debug_header(data->m); - data->first = false; - } - cfs_hash_debug_str(hs, data->m); - } - - return 0; -} - -static int -lproc_exp_hash_seq_show(struct seq_file *m, void *unused) -{ - struct nid_stat *stats = (struct nid_stat *)m->private; - struct obd_device *obd = stats->nid_obd; - struct exp_hash_cb_data cb_data = { - .m = m, - .first = true - }; - - cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid, - lprocfs_exp_print_hash, &cb_data); - return 0; -} - -LPROC_SEQ_FOPS_RO(lproc_exp_hash); - int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data) { seq_printf(m, "%s\n", @@ -1799,116 +1727,6 @@ int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer, } EXPORT_SYMBOL(lprocfs_nid_stats_clear_write); -int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) -{ - struct nid_stat *new_stat, *old_stat; - struct obd_device *obd = NULL; - struct proc_dir_entry *entry; - char *buffer = NULL; - int rc = 0; - - *newnid = 0; - - if (!exp || !exp->exp_obd || !exp->exp_obd->obd_proc_exports_entry || - !exp->exp_obd->obd_nid_stats_hash) - return -EINVAL; - - /* not test against zero because eric say: - * You may only test nid against another nid, or LNET_NID_ANY. - * Anything else is nonsense.*/ - if (!nid || *nid == LNET_NID_ANY) - return 0; - - obd = exp->exp_obd; - - CDEBUG(D_CONFIG, "using hash %p\n", obd->obd_nid_stats_hash); - - new_stat = kzalloc(sizeof(*new_stat), GFP_NOFS); - if (new_stat == NULL) - return -ENOMEM; - - new_stat->nid = *nid; - new_stat->nid_obd = exp->exp_obd; - /* we need set default refcount to 1 to balance obd_disconnect */ - atomic_set(&new_stat->nid_exp_ref_count, 1); - - old_stat = cfs_hash_findadd_unique(obd->obd_nid_stats_hash, - nid, &new_stat->nid_hash); - CDEBUG(D_INFO, "Found stats %p for nid %s - ref %d\n", - old_stat, libcfs_nid2str(*nid), - atomic_read(&new_stat->nid_exp_ref_count)); - - /* We need to release old stats because lprocfs_exp_cleanup() hasn't - * been and will never be called. */ - if (exp->exp_nid_stats) { - nidstat_putref(exp->exp_nid_stats); - exp->exp_nid_stats = NULL; - } - - /* Return -EALREADY here so that we know that the /proc - * entry already has been created */ - if (old_stat != new_stat) { - exp->exp_nid_stats = old_stat; - rc = -EALREADY; - goto destroy_new; - } - /* not found - create */ - buffer = kmemdup(libcfs_nid2str(*nid), LNET_NIDSTR_SIZE, GFP_NOFS); - if (buffer == NULL) { - rc = -ENOMEM; - goto destroy_new; - } - - new_stat->nid_proc = lprocfs_register(buffer, - obd->obd_proc_exports_entry, - NULL, NULL); - kfree(buffer); - - if (IS_ERR(new_stat->nid_proc)) { - CERROR("Error making export directory for nid %s\n", - libcfs_nid2str(*nid)); - rc = PTR_ERR(new_stat->nid_proc); - new_stat->nid_proc = NULL; - goto destroy_new_ns; - } - - entry = lprocfs_add_simple(new_stat->nid_proc, "uuid", - new_stat, &lproc_exp_uuid_fops); - if (IS_ERR(entry)) { - CWARN("Error adding the NID stats file\n"); - rc = PTR_ERR(entry); - goto destroy_new_ns; - } - - entry = lprocfs_add_simple(new_stat->nid_proc, "hash", - new_stat, &lproc_exp_hash_fops); - if (IS_ERR(entry)) { - CWARN("Error adding the hash file\n"); - rc = PTR_ERR(entry); - goto destroy_new_ns; - } - - exp->exp_nid_stats = new_stat; - *newnid = 1; - /* protect competitive add to list, not need locking on destroy */ - spin_lock(&obd->obd_nid_lock); - list_add(&new_stat->nid_list, &obd->obd_nid_stats); - spin_unlock(&obd->obd_nid_lock); - - return rc; - -destroy_new_ns: - if (new_stat->nid_proc != NULL) - lprocfs_remove(&new_stat->nid_proc); - cfs_hash_del(obd->obd_nid_stats_hash, nid, &new_stat->nid_hash); - -destroy_new: - nidstat_putref(new_stat); - kfree(new_stat); - return rc; -} -EXPORT_SYMBOL(lprocfs_exp_setup); - int lprocfs_exp_cleanup(struct obd_export *exp) { struct nid_stat *stat = exp->exp_nid_stats; From d9528a30a8361a1af1f436129e2eb9165a3cbc5b Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sat, 30 May 2015 23:27:04 -0400 Subject: [PATCH 0680/1163] staging/lustre/obd: Remove nid_stats tracking This nid_stats tracking only makes sense on the server side, on the client there are no other clients to keep track of anyway. Signed-off-by: Dmitry Eremin Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/include/dt_object.h | 1 - .../lustre/lustre/include/lprocfs_status.h | 15 --- .../staging/lustre/lustre/include/lu_object.h | 2 - .../lustre/lustre/include/lustre_export.h | 29 ------ drivers/staging/lustre/lustre/include/obd.h | 3 - .../staging/lustre/lustre/include/obd_class.h | 18 ---- .../lustre/lustre/obdclass/lprocfs_status.c | 96 ------------------- .../lustre/lustre/obdclass/obd_config.c | 80 ---------------- 8 files changed, 244 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/dt_object.h b/drivers/staging/lustre/lustre/include/dt_object.h index be4c7d95e788..866d04b2814b 100644 --- a/drivers/staging/lustre/lustre/include/dt_object.h +++ b/drivers/staging/lustre/lustre/include/dt_object.h @@ -58,7 +58,6 @@ #include "../../include/linux/libcfs/libcfs.h" struct seq_file; -struct proc_dir_entry; struct lustre_cfg; struct thandle; diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 4b8c265d8fe1..6a77ea8ec62e 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -558,7 +558,6 @@ extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index, extern void lprocfs_free_obd_stats(struct obd_device *obddev); extern void lprocfs_free_md_stats(struct obd_device *obddev); struct obd_export; -struct nid_stat; extern int lprocfs_add_clear_entry(struct obd_device *obd, struct proc_dir_entry *entry); extern int lprocfs_exp_cleanup(struct obd_export *exp); @@ -573,11 +572,6 @@ extern struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root, extern struct dentry * ldebugfs_add_symlink(const char *name, struct dentry *parent, const char *format, ...); -extern void lprocfs_free_per_client_stats(struct obd_device *obd); -extern int -lprocfs_nid_stats_clear_write(struct file *file, const char *buffer, - unsigned long count, void *data); -extern int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data); extern int ldebugfs_register_stats(struct dentry *parent, const char *name, @@ -909,15 +903,6 @@ static inline struct proc_dir_entry * lprocfs_add_simple(struct proc_dir_entry *root, char *name, void *data, struct file_operations *fops) {return 0; } -static inline void lprocfs_free_per_client_stats(struct obd_device *obd) -{ return; } -static inline -int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer, - unsigned long count, void *data) -{return count;} -static inline -int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data) -{ return 0; } static inline struct proc_dir_entry * lprocfs_register(const char *name, struct proc_dir_entry *parent, diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index c8cc48f00026..e1d72a7a5c2d 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -43,7 +43,6 @@ #include "lu_ref.h" struct seq_file; -struct proc_dir_entry; struct lustre_cfg; struct lprocfs_stats; @@ -277,7 +276,6 @@ struct lu_device { * Stack this device belongs to. */ struct lu_site *ld_site; - struct proc_dir_entry *ld_proc_entry; /** \todo XXX: temporary back pointer into obd. */ struct obd_device *ld_obd; diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h index 9c06a49f12a4..3b992b42fd91 100644 --- a/drivers/staging/lustre/lustre/include/lustre_export.h +++ b/drivers/staging/lustre/lustre/include/lustre_export.h @@ -106,34 +106,6 @@ struct mgs_export_data { spinlock_t med_lock; /* protect med_clients */ }; -/** - * per-NID statistics structure. - * It tracks access patterns to this export on a per-client-NID basis - */ -struct nid_stat { - lnet_nid_t nid; - struct hlist_node nid_hash; - struct list_head nid_list; - struct obd_device *nid_obd; - struct proc_dir_entry *nid_proc; - struct lprocfs_stats *nid_stats; - struct lprocfs_stats *nid_ldlm_stats; - atomic_t nid_exp_ref_count; /* for obd_nid_stats_hash - exp_nid_stats */ -}; - -#define nidstat_getref(nidstat) \ -do { \ - atomic_inc(&(nidstat)->nid_exp_ref_count); \ -} while (0) - -#define nidstat_putref(nidstat) \ -do { \ - atomic_dec(&(nidstat)->nid_exp_ref_count); \ - LASSERTF(atomic_read(&(nidstat)->nid_exp_ref_count) >= 0, \ - "stat %p nid_exp_ref_count < 0\n", nidstat); \ -} while (0) - enum obd_option { OBD_OPT_FORCE = 0x0001, OBD_OPT_FAILOVER = 0x0002, @@ -190,7 +162,6 @@ struct obd_export { * exp_lock protect its change */ struct obd_import *exp_imp_reverse; - struct nid_stat *exp_nid_stats; struct lprocfs_stats *exp_md_stats; /** Active connection */ struct ptlrpc_connection *exp_connection; diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 708a4cfb4659..55452e562bd4 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -845,9 +845,6 @@ struct obd_device { struct cfs_hash *obd_uuid_hash; /* nid-export hash body */ struct cfs_hash *obd_nid_hash; - /* nid stats body */ - struct cfs_hash *obd_nid_stats_hash; - struct list_head obd_nid_stats; atomic_t obd_refcount; wait_queue_head_t obd_refcount_waitq; struct list_head obd_exports; diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 98b397e139a8..63f5224ecb97 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -378,10 +378,6 @@ static inline int obd_check_dev_active(struct obd_device *obd) OBD_COUNTER_OFFSET(op); \ LASSERT(coffset < (export)->exp_obd->obd_stats->ls_num); \ lprocfs_counter_incr((export)->exp_obd->obd_stats, coffset); \ - if ((export)->exp_nid_stats != NULL && \ - (export)->exp_nid_stats->nid_stats != NULL) \ - lprocfs_counter_incr( \ - (export)->exp_nid_stats->nid_stats, coffset);\ } #define MD_COUNTER_OFFSET(op) \ @@ -418,20 +414,6 @@ static inline int obd_check_dev_active(struct obd_device *obd) #define EXP_MD_COUNTER_INCREMENT(exp, op) #endif -static inline int lprocfs_nid_ldlm_stats_init(struct nid_stat *tmp) -{ - /* Always add in ldlm_stats */ - tmp->nid_ldlm_stats = lprocfs_alloc_stats(LDLM_LAST_OPC - LDLM_FIRST_OPC - ,LPROCFS_STATS_FLAG_NOPERCPU); - if (tmp->nid_ldlm_stats == NULL) - return -ENOMEM; - - lprocfs_init_ldlm_stats(tmp->nid_ldlm_stats); - - return lprocfs_register_stats(tmp->nid_proc, "ldlm_stats", - tmp->nid_ldlm_stats); -} - #define OBD_CHECK_MD_OP(obd, op, err) \ do { \ if (!OBT(obd) || !MDP((obd), op)) { \ diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 3ef5474fcd34..f44c74611d3b 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1106,46 +1106,6 @@ int lprocfs_obd_cleanup(struct obd_device *obd) } EXPORT_SYMBOL(lprocfs_obd_cleanup); -static void lprocfs_free_client_stats(struct nid_stat *client_stat) -{ - CDEBUG(D_CONFIG, "stat %p - data %p/%p\n", client_stat, - client_stat->nid_proc, client_stat->nid_stats); - - LASSERTF(atomic_read(&client_stat->nid_exp_ref_count) == 0, - "nid %s:count %d\n", libcfs_nid2str(client_stat->nid), - atomic_read(&client_stat->nid_exp_ref_count)); - - if (client_stat->nid_proc) - lprocfs_remove(&client_stat->nid_proc); - - if (client_stat->nid_stats) - lprocfs_free_stats(&client_stat->nid_stats); - - if (client_stat->nid_ldlm_stats) - lprocfs_free_stats(&client_stat->nid_ldlm_stats); - - kfree(client_stat); - return; - -} - -void lprocfs_free_per_client_stats(struct obd_device *obd) -{ - struct cfs_hash *hash = obd->obd_nid_stats_hash; - struct nid_stat *stat; - - /* we need extra list - because hash_exit called to early */ - /* not need locking because all clients is died */ - while (!list_empty(&obd->obd_nid_stats)) { - stat = list_entry(obd->obd_nid_stats.next, - struct nid_stat, nid_list); - list_del_init(&stat->nid_list); - cfs_hash_del(hash, &stat->nid, &stat->nid_hash); - lprocfs_free_client_stats(stat); - } -} -EXPORT_SYMBOL(lprocfs_free_per_client_stats); - int lprocfs_stats_alloc_one(struct lprocfs_stats *stats, unsigned int cpuid) { struct lprocfs_counter *cntr; @@ -1679,64 +1639,8 @@ void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats) } EXPORT_SYMBOL(lprocfs_init_ldlm_stats); -int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data) -{ - seq_printf(m, "%s\n", - "Write into this file to clear all nid stats and stale nid entries"); - return 0; -} -EXPORT_SYMBOL(lprocfs_nid_stats_clear_read); - -static int lprocfs_nid_stats_clear_write_cb(void *obj, void *data) -{ - struct nid_stat *stat = obj; - - CDEBUG(D_INFO, "refcnt %d\n", atomic_read(&stat->nid_exp_ref_count)); - if (atomic_read(&stat->nid_exp_ref_count) == 1) { - /* object has only hash references. */ - spin_lock(&stat->nid_obd->obd_nid_lock); - list_move(&stat->nid_list, data); - spin_unlock(&stat->nid_obd->obd_nid_lock); - return 1; - } - /* we has reference to object - only clear data*/ - if (stat->nid_stats) - lprocfs_clear_stats(stat->nid_stats); - - return 0; -} - -int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - struct nid_stat *client_stat; - LIST_HEAD(free_list); - - cfs_hash_cond_del(obd->obd_nid_stats_hash, - lprocfs_nid_stats_clear_write_cb, &free_list); - - while (!list_empty(&free_list)) { - client_stat = list_entry(free_list.next, struct nid_stat, - nid_list); - list_del_init(&client_stat->nid_list); - lprocfs_free_client_stats(client_stat); - } - - return count; -} -EXPORT_SYMBOL(lprocfs_nid_stats_clear_write); - int lprocfs_exp_cleanup(struct obd_export *exp) { - struct nid_stat *stat = exp->exp_nid_stats; - - if (!stat || !exp->exp_obd) - return 0; - - nidstat_putref(exp->exp_nid_stats); - exp->exp_nid_stats = NULL; - return 0; } EXPORT_SYMBOL(lprocfs_exp_cleanup); diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 0bda9c56f148..19d4eb045b1b 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -49,7 +49,6 @@ static cfs_hash_ops_t uuid_hash_ops; static cfs_hash_ops_t nid_hash_ops; -static cfs_hash_ops_t nid_stat_hash_ops; /*********** string parsing utils *********/ @@ -383,7 +382,6 @@ int class_attach(struct lustre_cfg *lcfg) INIT_LIST_HEAD(&obd->obd_unlinked_exports); INIT_LIST_HEAD(&obd->obd_delayed_exports); INIT_LIST_HEAD(&obd->obd_exports_timed); - INIT_LIST_HEAD(&obd->obd_nid_stats); spin_lock_init(&obd->obd_nid_lock); spin_lock_init(&obd->obd_dev_lock); mutex_init(&obd->obd_dev_mutex); @@ -486,7 +484,6 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) obd->obd_starting = 1; obd->obd_uuid_hash = NULL; obd->obd_nid_hash = NULL; - obd->obd_nid_stats_hash = NULL; spin_unlock(&obd->obd_dev_lock); /* create an uuid-export lustre hash */ @@ -515,19 +512,6 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) goto err_hash; } - /* create a nid-stats lustre hash */ - obd->obd_nid_stats_hash = cfs_hash_create("NID_STATS", - HASH_NID_STATS_CUR_BITS, - HASH_NID_STATS_MAX_BITS, - HASH_NID_STATS_BKT_BITS, 0, - CFS_HASH_MIN_THETA, - CFS_HASH_MAX_THETA, - &nid_stat_hash_ops, CFS_HASH_DEFAULT); - if (!obd->obd_nid_stats_hash) { - err = -ENOMEM; - goto err_hash; - } - exp = class_new_export(obd, &obd->obd_uuid); if (IS_ERR(exp)) { err = PTR_ERR(exp); @@ -567,10 +551,6 @@ err_hash: cfs_hash_putref(obd->obd_nid_hash); obd->obd_nid_hash = NULL; } - if (obd->obd_nid_stats_hash) { - cfs_hash_putref(obd->obd_nid_stats_hash); - obd->obd_nid_stats_hash = NULL; - } obd->obd_starting = 0; CERROR("setup %s failed (%d)\n", obd->obd_name, err); return err; @@ -694,12 +674,6 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg) obd->obd_nid_hash = NULL; } - /* destroy a nid-stats hash body */ - if (obd->obd_nid_stats_hash) { - cfs_hash_putref(obd->obd_nid_stats_hash); - obd->obd_nid_stats_hash = NULL; - } - class_decref(obd, "setup", obd); obd->obd_set_up = 0; @@ -1893,57 +1867,3 @@ static cfs_hash_ops_t nid_hash_ops = { .hs_get = nid_export_get, .hs_put_locked = nid_export_put_locked, }; - - -/* - * nid<->nidstats hash operations - */ - -static void * -nidstats_key(struct hlist_node *hnode) -{ - struct nid_stat *ns; - - ns = hlist_entry(hnode, struct nid_stat, nid_hash); - - return &ns->nid; -} - -static int -nidstats_keycmp(const void *key, struct hlist_node *hnode) -{ - return *(lnet_nid_t *)nidstats_key(hnode) == *(lnet_nid_t *)key; -} - -static void * -nidstats_object(struct hlist_node *hnode) -{ - return hlist_entry(hnode, struct nid_stat, nid_hash); -} - -static void -nidstats_get(struct cfs_hash *hs, struct hlist_node *hnode) -{ - struct nid_stat *ns; - - ns = hlist_entry(hnode, struct nid_stat, nid_hash); - nidstat_getref(ns); -} - -static void -nidstats_put_locked(struct cfs_hash *hs, struct hlist_node *hnode) -{ - struct nid_stat *ns; - - ns = hlist_entry(hnode, struct nid_stat, nid_hash); - nidstat_putref(ns); -} - -static cfs_hash_ops_t nid_stat_hash_ops = { - .hs_hash = nid_hash, - .hs_key = nidstats_key, - .hs_keycmp = nidstats_keycmp, - .hs_object = nidstats_object, - .hs_get = nidstats_get, - .hs_put_locked = nidstats_put_locked, -}; From e4ba525e8f5f78d5e40ced1f80c50b05aaa01ecb Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Sat, 30 May 2015 23:27:05 -0400 Subject: [PATCH 0681/1163] staging/lustre/obd: final removal of procfs stuff Signed-off-by: Dmitry Eremin Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../include/linux/libcfs/linux/libcfs.h | 1 - drivers/staging/lustre/lustre/fid/Makefile | 3 +- drivers/staging/lustre/lustre/fld/Makefile | 3 +- .../staging/lustre/lustre/include/dt_object.h | 2 - .../lustre/lustre/include/linux/lustre_lite.h | 1 - .../staging/lustre/lustre/include/linux/obd.h | 10 +- .../lustre/lustre/include/lprocfs_status.h | 225 +--------------- .../lustre/lustre/include/lustre_fid.h | 3 - .../lustre/lustre/include/lustre_fld.h | 4 - .../lustre/lustre/include/lustre_net.h | 6 - .../lustre/lustre/include/lustre_quota.h | 241 ------------------ .../staging/lustre/lustre/include/obd_class.h | 15 -- .../lustre/lustre/include/obd_support.h | 41 --- .../lustre/lustre/ldlm/ldlm_resource.c | 2 +- drivers/staging/lustre/lustre/libcfs/module.c | 1 - drivers/staging/lustre/lustre/llite/Makefile | 3 +- .../lustre/lustre/llite/llite_internal.h | 21 -- drivers/staging/lustre/lustre/llite/vvp_dev.c | 2 +- drivers/staging/lustre/lustre/lmv/Makefile | 3 +- .../staging/lustre/lustre/lmv/lmv_internal.h | 8 +- drivers/staging/lustre/lustre/lov/Makefile | 3 +- .../staging/lustre/lustre/lov/lov_internal.h | 7 - drivers/staging/lustre/lustre/lov/lov_pool.c | 2 - drivers/staging/lustre/lustre/mdc/Makefile | 3 +- drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 2 +- .../staging/lustre/lustre/mdc/mdc_internal.h | 7 - drivers/staging/lustre/lustre/mgc/Makefile | 3 +- .../staging/lustre/lustre/mgc/mgc_internal.h | 11 - .../staging/lustre/lustre/mgc/mgc_request.c | 2 - .../staging/lustre/lustre/obdclass/Makefile | 4 +- .../lustre/lustre/obdclass/class_obd.c | 37 +-- .../lustre/lustre/obdclass/dt_object.c | 6 - .../lustre/obdclass/linux/linux-module.c | 1 - .../lustre/obdclass/linux/linux-sysctl.c | 1 - .../lustre/lustre/obdclass/lprocfs_status.c | 153 +---------- .../lustre/lustre/obdclass/lu_object.c | 4 - drivers/staging/lustre/lustre/osc/Makefile | 3 +- drivers/staging/lustre/lustre/osc/lproc_osc.c | 4 +- .../staging/lustre/lustre/osc/osc_internal.h | 8 - drivers/staging/lustre/lustre/ptlrpc/Makefile | 3 +- .../lustre/lustre/ptlrpc/lproc_ptlrpc.c | 5 +- .../lustre/lustre/ptlrpc/ptlrpc_internal.h | 12 - .../staging/lustre/lustre/ptlrpc/sec_lproc.c | 8 +- 43 files changed, 54 insertions(+), 830 deletions(-) delete mode 100644 drivers/staging/lustre/lustre/include/lustre_quota.h diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h index 4fe50841e8e3..3e2502a69bbd 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h @@ -61,7 +61,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/staging/lustre/lustre/fid/Makefile b/drivers/staging/lustre/lustre/fid/Makefile index 5513ce416a35..b7ef314b4b84 100644 --- a/drivers/staging/lustre/lustre/fid/Makefile +++ b/drivers/staging/lustre/lustre/fid/Makefile @@ -1,3 +1,2 @@ obj-$(CONFIG_LUSTRE_FS) += fid.o -fid-y := fid_request.o fid_lib.o -fid-$(CONFIG_PROC_FS) += lproc_fid.o +fid-y := fid_request.o fid_lib.o lproc_fid.o diff --git a/drivers/staging/lustre/lustre/fld/Makefile b/drivers/staging/lustre/lustre/fld/Makefile index 2bbf08433dca..646e315d1aa8 100644 --- a/drivers/staging/lustre/lustre/fld/Makefile +++ b/drivers/staging/lustre/lustre/fld/Makefile @@ -1,3 +1,2 @@ obj-$(CONFIG_LUSTRE_FS) += fld.o -fld-y := fld_request.o fld_cache.o -fld-$(CONFIG_PROC_FS) += lproc_fld.o +fld-y := fld_request.o fld_cache.o lproc_fld.o diff --git a/drivers/staging/lustre/lustre/include/dt_object.h b/drivers/staging/lustre/lustre/include/dt_object.h index 866d04b2814b..abae31b41e74 100644 --- a/drivers/staging/lustre/lustre/include/dt_object.h +++ b/drivers/staging/lustre/lustre/include/dt_object.h @@ -1480,7 +1480,6 @@ static inline struct dt_thread_info *dt_info(const struct lu_env *env) int dt_global_init(void); void dt_global_fini(void); -#if defined (CONFIG_PROC_FS) int lprocfs_dt_rd_blksize(char *page, char **start, off_t off, int count, int *eof, void *data); int lprocfs_dt_rd_kbytestotal(char *page, char **start, off_t off, @@ -1493,6 +1492,5 @@ int lprocfs_dt_rd_filestotal(char *page, char **start, off_t off, int count, int *eof, void *data); int lprocfs_dt_rd_filesfree(char *page, char **start, off_t off, int count, int *eof, void *data); -#endif /* CONFIG_PROC_FS */ #endif /* __LUSTRE_DT_OBJECT_H */ diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_lite.h b/drivers/staging/lustre/lustre/include/linux/lustre_lite.h index a7658a99a08d..45651caf42cc 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_lite.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_lite.h @@ -44,7 +44,6 @@ #include #include -#include #include "../obd_class.h" #include "../lustre_net.h" diff --git a/drivers/staging/lustre/lustre/include/linux/obd.h b/drivers/staging/lustre/lustre/include/linux/obd.h index 9cd8683573ce..2817e88e014a 100644 --- a/drivers/staging/lustre/lustre/include/linux/obd.h +++ b/drivers/staging/lustre/lustre/include/linux/obd.h @@ -43,11 +43,11 @@ #include "../obd_support.h" -# include -# include -# include /* for struct task_struct, for current.h */ -# include -# include +#include +#include +#include /* for struct task_struct, for current.h */ +#include + #include "../lustre_intent.h" struct ll_iattr { diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 6a77ea8ec62e..3292fd3c588a 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -42,7 +42,6 @@ #ifndef _LPROCFS_SNMP_H #define _LPROCFS_SNMP_H -#include #include #include #include @@ -380,8 +379,6 @@ extern int lprocfs_write_frac_helper(const char __user *buffer, unsigned long count, int *val, int mult); extern int lprocfs_read_frac_helper(char *buffer, unsigned long count, long val, int mult); -#if defined (CONFIG_PROC_FS) - extern int lprocfs_stats_alloc_one(struct lprocfs_stats *stats, unsigned int cpuid); /* @@ -558,17 +555,11 @@ extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index, extern void lprocfs_free_obd_stats(struct obd_device *obddev); extern void lprocfs_free_md_stats(struct obd_device *obddev); struct obd_export; -extern int lprocfs_add_clear_entry(struct obd_device *obd, - struct proc_dir_entry *entry); extern int lprocfs_exp_cleanup(struct obd_export *exp); extern struct dentry *ldebugfs_add_simple(struct dentry *root, char *name, void *data, struct file_operations *fops); -extern struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root, - char *name, - void *data, - struct file_operations *fops); extern struct dentry * ldebugfs_add_symlink(const char *name, struct dentry *parent, const char *format, ...); @@ -576,30 +567,18 @@ ldebugfs_add_symlink(const char *name, struct dentry *parent, extern int ldebugfs_register_stats(struct dentry *parent, const char *name, struct lprocfs_stats *stats); -extern int lprocfs_register_stats(struct proc_dir_entry *root, const char *name, - struct lprocfs_stats *stats); /* lprocfs_status.c */ extern int ldebugfs_add_vars(struct dentry *parent, struct lprocfs_vars *var, void *data); -extern int lprocfs_add_vars(struct proc_dir_entry *root, - struct lprocfs_vars *var, - void *data); extern struct dentry *ldebugfs_register(const char *name, struct dentry *parent, struct lprocfs_vars *list, void *data); -extern struct proc_dir_entry *lprocfs_register(const char *name, - struct proc_dir_entry *parent, - struct lprocfs_vars *list, - void *data); extern void ldebugfs_remove(struct dentry **entryp); -extern void lprocfs_remove(struct proc_dir_entry **root); -extern void lprocfs_remove_proc_entry(const char *name, - struct proc_dir_entry *parent); extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list, struct attribute_group *attrs); @@ -610,14 +589,11 @@ extern int ldebugfs_seq_create(struct dentry *parent, umode_t mode, const struct file_operations *seq_fops, void *data); -extern int lprocfs_seq_create(struct proc_dir_entry *parent, const char *name, - umode_t mode, - const struct file_operations *seq_fops, - void *data); -extern int lprocfs_obd_seq_create(struct obd_device *dev, const char *name, - umode_t mode, - const struct file_operations *seq_fops, - void *data); +extern int ldebugfs_obd_seq_create(struct obd_device *dev, + const char *name, + umode_t mode, + const struct file_operations *seq_fops, + void *data); /* Generic callbacks */ @@ -691,12 +667,11 @@ extern int lprocfs_seq_release(struct inode *, struct file *); /* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only proc entries; otherwise, you will define name##_seq_write function also for a read-write proc entry, and then call LPROC_SEQ_SEQ instead. Finally, - call lprocfs_obd_seq_create(obd, filename, 0444, &name#_fops, data); */ + call ldebugfs_obd_seq_create(obd, filename, 0444, &name#_fops, data); */ #define __LPROC_SEQ_FOPS(name, custom_seq_write) \ static int name##_single_open(struct inode *inode, struct file *file) \ { \ - return single_open(file, name##_seq_show, \ - inode->i_private ?: PDE_DATA(inode)); \ + return single_open(file, name##_seq_show, inode->i_private); \ } \ static struct file_operations name##_fops = { \ .owner = THIS_MODULE, \ @@ -741,8 +716,7 @@ static struct file_operations name##_fops = { \ } \ static int name##_##type##_open(struct inode *inode, struct file *file) \ { \ - return single_open(file, NULL, \ - inode->i_private ?: PDE_DATA(inode));\ + return single_open(file, NULL, inode->i_private); \ } \ static struct file_operations name##_##type##_fops = { \ .open = name##_##type##_open, \ @@ -839,187 +813,4 @@ extern int lprocfs_quota_rd_qs_factor(char *page, char **start, loff_t off, extern int lprocfs_quota_wr_qs_factor(struct file *file, const char *buffer, unsigned long count, void *data); -#else -/* CONFIG_PROC_FS is not defined */ - -static inline void lprocfs_counter_add(struct lprocfs_stats *stats, - int index, long amount) -{ return; } -static inline void lprocfs_counter_incr(struct lprocfs_stats *stats, - int index) -{ return; } -static inline void lprocfs_counter_sub(struct lprocfs_stats *stats, - int index, long amount) -{ return; } -static inline void lprocfs_counter_decr(struct lprocfs_stats *stats, - int index) -{ return; } -static inline void lprocfs_counter_init(struct lprocfs_stats *stats, - int index, unsigned conf, - const char *name, const char *units) -{ return; } - -static inline __u64 lc_read_helper(struct lprocfs_counter *lc, - enum lprocfs_fields_flags field) -{ return 0; } - -/* NB: we return !NULL to satisfy error checker */ -static inline struct lprocfs_stats * -lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags) -{ return (struct lprocfs_stats *)1; } -static inline void lprocfs_clear_stats(struct lprocfs_stats *stats) -{ return; } -static inline void lprocfs_free_stats(struct lprocfs_stats **stats) -{ return; } -static inline int lprocfs_register_stats(struct proc_dir_entry *root, - const char *name, - struct lprocfs_stats *stats) -{ return 0; } -static inline void lprocfs_init_ops_stats(int num_private_stats, - struct lprocfs_stats *stats) -{ return; } -static inline void lprocfs_init_mps_stats(int num_private_stats, - struct lprocfs_stats *stats) -{ return; } -static inline void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats) -{ return; } -static inline int lprocfs_alloc_obd_stats(struct obd_device *obddev, - unsigned int num_private_stats) -{ return 0; } -static inline int lprocfs_alloc_md_stats(struct obd_device *obddev, - unsigned int num_private_stats) -{ return 0; } -static inline void lprocfs_free_obd_stats(struct obd_device *obddev) -{ return; } -static inline void lprocfs_free_md_stats(struct obd_device *obddev) -{ return; } - -struct obd_export; -static inline int lprocfs_add_clear_entry(struct obd_export *exp) -{ return 0; } -static inline int lprocfs_exp_cleanup(struct obd_export *exp) -{ return 0; } -static inline struct proc_dir_entry * -lprocfs_add_simple(struct proc_dir_entry *root, char *name, - void *data, struct file_operations *fops) -{return 0; } - -static inline struct proc_dir_entry * -lprocfs_register(const char *name, struct proc_dir_entry *parent, - struct lprocfs_vars *list, void *data) -{ return NULL; } -static inline int lprocfs_add_vars(struct proc_dir_entry *root, - struct lprocfs_vars *var, - void *data) -{ return 0; } -static inline void lprocfs_remove(struct proc_dir_entry **root) -{ return; } -static inline void lprocfs_remove_proc_entry(const char *name, - struct proc_dir_entry *parent) -{ return; } -static inline int lprocfs_obd_setup(struct obd_device *dev, - struct lprocfs_vars *list) -{ return 0; } -static inline int lprocfs_obd_cleanup(struct obd_device *dev) -{ return 0; } -static inline int lprocfs_rd_u64(struct seq_file *m, void *data) -{ return 0; } -static inline int lprocfs_rd_uuid(struct seq_file *m, void *data) -{ return 0; } -static inline int lprocfs_rd_name(struct seq_file *m, void *data) -{ return 0; } -static inline int lprocfs_rd_server_uuid(struct seq_file *m, void *data) -{ return 0; } -static inline int lprocfs_rd_conn_uuid(struct seq_file *m, void *data) -{ return 0; } -static inline int lprocfs_rd_import(struct seq_file *m, void *data) -{ return 0; } -static inline int lprocfs_rd_pinger_recov(struct seq_file *m, void *n) -{ return 0; } -static inline int lprocfs_rd_state(struct seq_file *m, void *data) -{ return 0; } -static inline int lprocfs_rd_connect_flags(struct seq_file *m, void *data) -{ return 0; } -static inline int lprocfs_rd_num_exports(struct seq_file *m, void *data) -{ return 0; } -extern inline int lprocfs_rd_numrefs(struct seq_file *m, void *data) -{ return 0; } -struct adaptive_timeout; -static inline int lprocfs_at_hist_helper(struct seq_file *m, - struct adaptive_timeout *at) -{ return 0; } -static inline int lprocfs_rd_timeouts(struct seq_file *m, void *data) -{ return 0; } -static inline int lprocfs_wr_timeouts(struct file *file, - const char __user *buffer, - unsigned long count, void *data) -{ return 0; } -static inline int lprocfs_wr_evict_client(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) -{ return 0; } -static inline int lprocfs_wr_ping(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) -{ return 0; } -static inline int lprocfs_wr_import(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) -{ return 0; } -static inline int lprocfs_wr_pinger_recov(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) -{ return 0; } - -/* Statfs helpers */ -static inline -int lprocfs_rd_blksize(struct seq_file *m, void *data) -{ return 0; } -static inline -int lprocfs_rd_kbytestotal(struct seq_file *m, void *data) -{ return 0; } -static inline -int lprocfs_rd_kbytesfree(struct seq_file *m, void *data) -{ return 0; } -static inline -int lprocfs_rd_kbytesavail(struct seq_file *m, void *data) -{ return 0; } -static inline -int lprocfs_rd_filestotal(struct seq_file *m, void *data) -{ return 0; } -static inline -int lprocfs_rd_filesfree(struct seq_file *m, void *data) -{ return 0; } -static inline -void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value) -{ return; } -static inline -void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value) -{ return; } -static inline -void lprocfs_oh_clear(struct obd_histogram *oh) -{ return; } -static inline -unsigned long lprocfs_oh_sum(struct obd_histogram *oh) -{ return 0; } -static inline -void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx, - struct lprocfs_counter *cnt) -{ return; } -static inline -__u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx, - enum lprocfs_fields_flags field) -{ return (__u64)0; } - -#define LPROC_SEQ_FOPS_RO(name) -#define LPROC_SEQ_FOPS(name) -#define LPROC_SEQ_FOPS_RO_TYPE(name, type) -#define LPROC_SEQ_FOPS_RW_TYPE(name, type) -#define LPROC_SEQ_FOPS_WR_ONLY(name, type) - -/* lproc_ptlrpc.c */ -#define target_print_req NULL - -#endif /* CONFIG_PROC_FS */ - #endif /* LPROCFS_SNMP_H */ diff --git a/drivers/staging/lustre/lustre/include/lustre_fid.h b/drivers/staging/lustre/lustre/include/lustre_fid.h index 0592f2bca008..c7c8fe4cdbcc 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fid.h +++ b/drivers/staging/lustre/lustre/include/lustre_fid.h @@ -392,9 +392,6 @@ struct lu_server_seq { /* /seq file object device */ struct dt_object *lss_obj; - /* Seq related proc */ - struct proc_dir_entry *lss_proc_dir; - /* LUSTRE_SEQ_SERVER or LUSTRE_SEQ_CONTROLLER */ enum lu_mgr_type lss_type; diff --git a/drivers/staging/lustre/lustre/include/lustre_fld.h b/drivers/staging/lustre/lustre/include/lustre_fld.h index 588cdd5a291c..c1f08dee3bd6 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fld.h +++ b/drivers/staging/lustre/lustre/include/lustre_fld.h @@ -70,10 +70,6 @@ struct lu_fld_target { }; struct lu_server_fld { - /** - * Fld dir proc entry. */ - struct proc_dir_entry *lsf_proc_dir; - /** * /fld file object device */ struct dt_object *lsf_obj; diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index e65e7d8af666..998dcd94c1b2 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -2952,15 +2952,9 @@ void ptlrpcd_decref(void); * @{ */ const char *ll_opcode2str(__u32 opcode); -#if defined (CONFIG_PROC_FS) void ptlrpc_lprocfs_register_obd(struct obd_device *obd); void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd); void ptlrpc_lprocfs_brw(struct ptlrpc_request *req, int bytes); -#else -static inline void ptlrpc_lprocfs_register_obd(struct obd_device *obd) {} -static inline void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd) {} -static inline void ptlrpc_lprocfs_brw(struct ptlrpc_request *req, int bytes) {} -#endif /** @} */ /* ptlrpc/llog_client.c */ diff --git a/drivers/staging/lustre/lustre/include/lustre_quota.h b/drivers/staging/lustre/lustre/include/lustre_quota.h deleted file mode 100644 index 2643f28070a2..000000000000 --- a/drivers/staging/lustre/lustre/include/lustre_quota.h +++ /dev/null @@ -1,241 +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, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA - * - * GPL HEADER END - */ -/* - * Copyright (c) 2011, 2012, Intel Corporation. - * Use is subject to license terms. - */ - -#ifndef _LUSTRE_QUOTA_H -#define _LUSTRE_QUOTA_H - -/** \defgroup quota quota - * - */ - -#include -#include -#include - -#include "dt_object.h" -#include "lustre_fid.h" -#include "lustre_dlm.h" - -#ifndef MAX_IQ_TIME -#define MAX_IQ_TIME 604800 /* (7*24*60*60) 1 week */ -#endif - -#ifndef MAX_DQ_TIME -#define MAX_DQ_TIME 604800 /* (7*24*60*60) 1 week */ -#endif - -struct lquota_id_info; -struct lquota_trans; - -/* Gather all quota record type in an union that can be used to read any records - * from disk. All fields of these records must be 64-bit aligned, otherwise the - * OSD layer may swab them incorrectly. */ -union lquota_rec { - struct lquota_glb_rec lqr_glb_rec; - struct lquota_slv_rec lqr_slv_rec; - struct lquota_acct_rec lqr_acct_rec; -}; - -/* Index features supported by the global index objects - * Only used for migration purpose and should be removed once on-disk migration - * is no longer needed */ -extern struct dt_index_features dt_quota_iusr_features; -extern struct dt_index_features dt_quota_busr_features; -extern struct dt_index_features dt_quota_igrp_features; -extern struct dt_index_features dt_quota_bgrp_features; - -/* Name used in the configuration logs to identify the default metadata pool - * (composed of all the MDTs, with pool ID 0) and the default data pool (all - * the OSTs, with pool ID 0 too). */ -#define QUOTA_METAPOOL_NAME "mdt=" -#define QUOTA_DATAPOOL_NAME "ost=" - -/* - * Quota Master Target support - */ - -/* Request handlers for quota master operations. - * This is used by the MDT to pass quota/lock requests to the quota master - * target. This won't be needed any more once the QMT is a real target and - * does not rely any more on the MDT service threads and namespace. */ -struct qmt_handlers { - /* Handle quotactl request from client. */ - int (*qmth_quotactl)(const struct lu_env *, struct lu_device *, - struct obd_quotactl *); - - /* Handle dqacq/dqrel request from slave. */ - int (*qmth_dqacq)(const struct lu_env *, struct lu_device *, - struct ptlrpc_request *); - - /* LDLM intent policy associated with quota locks */ - int (*qmth_intent_policy)(const struct lu_env *, struct lu_device *, - struct ptlrpc_request *, struct ldlm_lock **, - int); - - /* Initialize LVB of ldlm resource associated with quota objects */ - int (*qmth_lvbo_init)(struct lu_device *, struct ldlm_resource *); - - /* Update LVB of ldlm resource associated with quota objects */ - int (*qmth_lvbo_update)(struct lu_device *, struct ldlm_resource *, - struct ptlrpc_request *, int); - - /* Return size of LVB to be packed in ldlm message */ - int (*qmth_lvbo_size)(struct lu_device *, struct ldlm_lock *); - - /* Fill request buffer with lvb */ - int (*qmth_lvbo_fill)(struct lu_device *, struct ldlm_lock *, void *, - int); - - /* Free lvb associated with ldlm resource */ - int (*qmth_lvbo_free)(struct lu_device *, struct ldlm_resource *); -}; - -/* actual handlers are defined in lustre/quota/qmt_handler.c */ -extern struct qmt_handlers qmt_hdls; - -/* - * Quota enforcement support on slaves - */ - -struct qsd_instance; - -/* The quota slave feature is implemented under the form of a library. - * The API is the following: - * - * - qsd_init(): the user (mostly the OSD layer) should first allocate a qsd - * instance via qsd_init(). This creates all required structures - * to manage quota enforcement for this target and performs all - * low-level initialization which does not involve any lustre - * object. qsd_init() should typically be called when the OSD - * is being set up. - * - * - qsd_prepare(): This sets up on-disk objects associated with the quota slave - * feature and initiates the quota reintegration procedure if - * needed. qsd_prepare() should typically be called when - * ->ldo_prepare is invoked. - * - * - qsd_start(): a qsd instance should be started once recovery is completed - * (i.e. when ->ldo_recovery_complete is called). This is used - * to notify the qsd layer that quota should now be enforced - * again via the qsd_op_begin/end functions. The last step of the - * reintegration procedure (namely usage reconciliation) will be - * completed during start. - * - * - qsd_fini(): is used to release a qsd_instance structure allocated with - * qsd_init(). This releases all quota slave objects and frees the - * structures associated with the qsd_instance. - * - * - qsd_op_begin(): is used to enforce quota, it must be called in the - * declaration of each operation. qsd_op_end() should then be - * invoked later once all operations have been completed in - * order to release/adjust the quota space. - * Running qsd_op_begin() before qsd_start() isn't fatal and - * will return success. - * Once qsd_start() has been run, qsd_op_begin() will block - * until the reintegration procedure is completed. - * - * - qsd_op_end(): performs the post operation quota processing. This must be - * called after the operation transaction stopped. - * While qsd_op_begin() must be invoked each time a new - * operation is declared, qsd_op_end() should be called only - * once for the whole transaction. - * - * - qsd_op_adjust(): triggers pre-acquire/release if necessary. - * - * Below are the function prototypes to be used by OSD layer to manage quota - * enforcement. Arguments are documented where each function is defined. */ - -struct qsd_instance *qsd_init(const struct lu_env *, char *, struct dt_device *, - struct proc_dir_entry *); -int qsd_prepare(const struct lu_env *, struct qsd_instance *); -int qsd_start(const struct lu_env *, struct qsd_instance *); -void qsd_fini(const struct lu_env *, struct qsd_instance *); -int qsd_op_begin(const struct lu_env *, struct qsd_instance *, - struct lquota_trans *, struct lquota_id_info *, int *); -void qsd_op_end(const struct lu_env *, struct qsd_instance *, - struct lquota_trans *); -void qsd_op_adjust(const struct lu_env *, struct qsd_instance *, - union lquota_id *, int); -/* This is exported for the ldiskfs quota migration only, - * see convert_quota_file() */ -int lquota_disk_write_glb(const struct lu_env *, struct dt_object *, - __u64, struct lquota_glb_rec *); - -/* - * Quota information attached to a transaction - */ - -struct lquota_entry; - -struct lquota_id_info { - /* quota identifier */ - union lquota_id lqi_id; - - /* USRQUOTA or GRPQUOTA for now, could be expanded for - * directory quota or other types later. */ - int lqi_type; - - /* inodes or kbytes to be consumed or released, it could - * be negative when releasing space. */ - long long lqi_space; - - /* quota slave entry structure associated with this ID */ - struct lquota_entry *lqi_qentry; - - /* whether we are reporting blocks or inodes */ - bool lqi_is_blk; -}; - -/* Since we enforce only inode quota in meta pool (MDTs), and block quota in - * data pool (OSTs), there are at most 4 quota ids being enforced in a single - * transaction, which is chown transaction: - * original uid and gid, new uid and gid. - * - * This value might need to be revised when directory quota is added. */ -#define QUOTA_MAX_TRANSIDS 4 - -/* all qids involved in a single transaction */ -struct lquota_trans { - unsigned short lqt_id_cnt; - struct lquota_id_info lqt_ids[QUOTA_MAX_TRANSIDS]; -}; - -/* flags for quota local enforcement */ -#define QUOTA_FL_OVER_USRQUOTA 0x01 -#define QUOTA_FL_OVER_GRPQUOTA 0x02 -#define QUOTA_FL_SYNC 0x04 - -#define IS_LQUOTA_RES(res) \ - (res->lr_name.name[LUSTRE_RES_ID_SEQ_OFF] == FID_SEQ_QUOTA || \ - res->lr_name.name[LUSTRE_RES_ID_SEQ_OFF] == FID_SEQ_QUOTA_GLB) - -/* helper function used by MDT & OFD to retrieve quota accounting information - * on slave */ -int lquotactl_slv(const struct lu_env *, struct dt_device *, - struct obd_quotactl *); -/** @} quota */ -#endif /* _LUSTRE_QUOTA_H */ diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 63f5224ecb97..36ed78127830 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -139,14 +139,7 @@ int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg); int class_add_uuid(const char *uuid, __u64 nid); /*obdecho*/ -#if defined (CONFIG_PROC_FS) extern void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars); -#else -static inline void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars) -{ - memset(lvars, 0, sizeof(*lvars)); -} -#endif #define CFG_F_START 0x01 /* Set when we start updating from a log */ #define CFG_F_MARKER 0x02 /* We are within a maker */ @@ -356,7 +349,6 @@ static inline int obd_check_dev_active(struct obd_device *obd) return rc; } -#if defined (CONFIG_PROC_FS) #define OBD_COUNTER_OFFSET(op) \ ((offsetof(struct obd_ops, o_ ## op) - \ offsetof(struct obd_ops, o_iocontrol)) \ @@ -406,13 +398,6 @@ static inline int obd_check_dev_active(struct obd_device *obd) (export)->exp_md_stats, coffset); \ } -#else -#define OBD_COUNTER_OFFSET(op) -#define OBD_COUNTER_INCREMENT(obd, op) -#define EXP_COUNTER_INCREMENT(exp, op) -#define MD_COUNTER_INCREMENT(obd, op) -#define EXP_MD_COUNTER_INCREMENT(exp, op) -#endif #define OBD_CHECK_MD_OP(obd, op, err) \ do { \ diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h index c0136ee778e3..73e2d4880b9b 100644 --- a/drivers/staging/lustre/lustre/include/obd_support.h +++ b/drivers/staging/lustre/lustre/include/obd_support.h @@ -509,7 +509,6 @@ extern atomic_t libcfs_kmemory; extern void obd_update_maxusage(void); -#if defined (CONFIG_PROC_FS) #define obd_memory_add(size) \ lprocfs_counter_add(obd_memory, OBD_MEMORY_STAT, (long)(size)) #define obd_memory_sub(size) \ @@ -530,46 +529,6 @@ extern void obd_update_maxusage(void); extern __u64 obd_memory_max(void); extern __u64 obd_pages_max(void); -#else - -extern __u64 obd_alloc; -extern __u64 obd_pages; - -extern __u64 obd_max_alloc; -extern __u64 obd_max_pages; - -static inline void obd_memory_add(long size) -{ - obd_alloc += size; - if (obd_alloc > obd_max_alloc) - obd_max_alloc = obd_alloc; -} - -static inline void obd_memory_sub(long size) -{ - obd_alloc -= size; -} - -static inline void obd_pages_add(int order) -{ - obd_pages += 1<< order; - if (obd_pages > obd_max_pages) - obd_max_pages = obd_pages; -} - -static inline void obd_pages_sub(int order) -{ - obd_pages -= 1<< order; -} - -#define obd_memory_sum() (obd_alloc) -#define obd_pages_sum() (obd_pages) - -#define obd_memory_max() (obd_max_alloc) -#define obd_pages_max() (obd_max_pages) - -#endif - #define OBD_DEBUG_MEMUSAGE (1) #if OBD_DEBUG_MEMUSAGE diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 50e049b01a62..cdb63665a113 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -955,7 +955,7 @@ void ldlm_namespace_free_post(struct ldlm_namespace *ns) * proc1: destroy import * class_disconnect_export(grab cl_sem) -> * -> ldlm_namespace_free -> - * -> lprocfs_remove(grab _lprocfs_lock). + * -> ldebugfs_remove(grab _lprocfs_lock). * proc2: read proc info * lprocfs_fops_read(grab _lprocfs_lock) -> * -> osc_rd_active, etc(grab cl_sem). diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c index f0ee76abfd5a..83b1a708b1e3 100644 --- a/drivers/staging/lustre/lustre/libcfs/module.c +++ b/drivers/staging/lustre/lustre/libcfs/module.c @@ -49,7 +49,6 @@ #include #include -#include #include # define DEBUG_SUBSYSTEM S_LNET diff --git a/drivers/staging/lustre/lustre/llite/Makefile b/drivers/staging/lustre/lustre/llite/Makefile index 7d70115d5bc7..2cbc46838fdd 100644 --- a/drivers/staging/lustre/lustre/llite/Makefile +++ b/drivers/staging/lustre/lustre/llite/Makefile @@ -5,7 +5,6 @@ lustre-y := dcache.o dir.o file.o llite_close.o llite_lib.o llite_nfs.o \ xattr.o xattr_cache.o remote_perm.o llite_rmtacl.o llite_capa.o \ rw26.o super25.o statahead.o \ ../lclient/glimpse.o ../lclient/lcommon_cl.o ../lclient/lcommon_misc.o \ - vvp_dev.o vvp_page.o vvp_lock.o vvp_io.o vvp_object.o + vvp_dev.o vvp_page.o vvp_lock.o vvp_io.o vvp_object.o lproc_llite.o -lustre-$(CONFIG_PROC_FS) += lproc_llite.o llite_lloop-y := lloop.o diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index b30eb85a53c9..f097d4d167d5 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -663,7 +663,6 @@ void ll_ra_read_ex(struct file *f, struct ll_ra_read *rar); struct ll_ra_read *ll_ra_read_get(struct file *f); /* llite/lproc_llite.c */ -#if defined (CONFIG_PROC_FS) int ldebugfs_register_mountpoint(struct dentry *parent, struct super_block *sb, char *osc, char *mdc); void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi); @@ -672,26 +671,6 @@ void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars); void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, struct ll_file_data *file, loff_t pos, size_t count, int rw); -#else /* CONFIG_PROC_FS */ -static inline -int ldebugfs_register_mountpoint(struct dentry *parent, - struct super_block *sb, char *osc, char *mdc) -{ return 0; } -static inline -void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi) -{} -static inline -void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) -{} -static inline void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars) -{ - memset(lvars, 0, sizeof(*lvars)); -} -static inline void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, - struct ll_file_data *file, loff_t pos, - size_t count, int rw) {} -#endif /* CONFIG_PROC_FS */ - /* llite/dir.c */ void ll_release_page(struct page *page, int remove); diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index 6d9622acb44f..2aae5f5fa8ea 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c @@ -534,7 +534,7 @@ static int vvp_dump_pgcache_seq_open(struct inode *inode, struct file *filp) return rc; seq = filp->private_data; - seq->private = inode->i_private ?: PDE_DATA(inode); + seq->private = inode->i_private; return 0; } diff --git a/drivers/staging/lustre/lustre/lmv/Makefile b/drivers/staging/lustre/lustre/lmv/Makefile index a7a15369af15..1a24299791d7 100644 --- a/drivers/staging/lustre/lustre/lmv/Makefile +++ b/drivers/staging/lustre/lustre/lmv/Makefile @@ -1,3 +1,2 @@ obj-$(CONFIG_LUSTRE_FS) += lmv.o -lmv-y := lmv_obd.o lmv_intent.o lmv_fld.o -lmv-$(CONFIG_PROC_FS) += lproc_lmv.o +lmv-y := lmv_obd.o lmv_intent.o lmv_fld.o lproc_lmv.o diff --git a/drivers/staging/lustre/lustre/lmv/lmv_internal.h b/drivers/staging/lustre/lustre/lmv/lmv_internal.h index 852d78721ca9..b808728daee7 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_internal.h +++ b/drivers/staging/lustre/lustre/lmv/lmv_internal.h @@ -144,14 +144,8 @@ struct lmv_tgt_desc *lmv_locate_mds(struct lmv_obd *lmv, struct md_op_data *op_data, struct lu_fid *fid); /* lproc_lmv.c */ -#if defined(CONFIG_PROC_FS) void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars); -#else -static inline void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars) -{ - memset(lvars, 0, sizeof(*lvars)); -} -#endif + extern struct file_operations lmv_proc_target_fops; #endif diff --git a/drivers/staging/lustre/lustre/lov/Makefile b/drivers/staging/lustre/lustre/lov/Makefile index 6fe56a24b165..e4cc0db21014 100644 --- a/drivers/staging/lustre/lustre/lov/Makefile +++ b/drivers/staging/lustre/lustre/lov/Makefile @@ -2,5 +2,4 @@ obj-$(CONFIG_LUSTRE_FS) += lov.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 -lov-$(CONFIG_PROC_FS) += lproc_lov.o + lovsub_lock.o lovsub_io.o lov_pool.o lproc_lov.o diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h index b644acc9b034..5e8bcc6ba01a 100644 --- a/drivers/staging/lustre/lustre/lov/lov_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h @@ -265,15 +265,8 @@ void lsm_free_plain(struct lov_stripe_md *lsm); void dump_lsm(unsigned int level, const struct lov_stripe_md *lsm); /* lproc_lov.c */ -#if defined (CONFIG_PROC_FS) extern const struct file_operations lov_proc_target_fops; void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars); -#else -static inline void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars) -{ - memset(lvars, 0, sizeof(*lvars)); -} -#endif /* lov_cl.c */ extern struct lu_device_type lov_device_type; diff --git a/drivers/staging/lustre/lustre/lov/lov_pool.c b/drivers/staging/lustre/lustre/lov/lov_pool.c index 30a29fd86e8e..3c46c368cf13 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pool.c +++ b/drivers/staging/lustre/lustre/lov/lov_pool.c @@ -152,7 +152,6 @@ cfs_hash_ops_t pool_hash_operations = { }; -#if defined (CONFIG_PROC_FS) /* ifdef needed for liblustre support */ /* * pool /proc seq_file methods @@ -294,7 +293,6 @@ static struct file_operations pool_proc_operations = { .llseek = seq_lseek, .release = seq_release, }; -#endif /* CONFIG_PROC_FS */ void lov_dump_pool(int level, struct pool_desc *pool) { diff --git a/drivers/staging/lustre/lustre/mdc/Makefile b/drivers/staging/lustre/lustre/mdc/Makefile index 2516551a6dc3..99ba9ff0d83a 100644 --- a/drivers/staging/lustre/lustre/mdc/Makefile +++ b/drivers/staging/lustre/lustre/mdc/Makefile @@ -1,3 +1,2 @@ obj-$(CONFIG_LUSTRE_FS) += mdc.o -mdc-y := mdc_request.o mdc_reint.o mdc_lib.o mdc_locks.o -mdc-$(CONFIG_PROC_FS) += lproc_mdc.o +mdc-y := mdc_request.o mdc_reint.o mdc_lib.o mdc_locks.o lproc_mdc.o diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index 858d568a896f..1c95f87a0e2a 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -84,7 +84,7 @@ LUSTRE_RW_ATTR(max_rpcs_in_flight); static int mdc_kuc_open(struct inode *inode, struct file *file) { - return single_open(file, NULL, inode->i_private ?: PDE_DATA(inode)); + return single_open(file, NULL, inode->i_private); } /* temporary for testing */ diff --git a/drivers/staging/lustre/lustre/mdc/mdc_internal.h b/drivers/staging/lustre/lustre/mdc/mdc_internal.h index 81780c943a08..4d149435e949 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_internal.h +++ b/drivers/staging/lustre/lustre/mdc/mdc_internal.h @@ -40,14 +40,7 @@ #include "../include/lustre_mdc.h" #include "../include/lustre_mds.h" -#if defined CONFIG_PROC_FS void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars); -#else -static inline void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars) -{ - memset(lvars, 0, sizeof(*lvars)); -} -#endif void mdc_pack_body(struct ptlrpc_request *req, const struct lu_fid *fid, struct obd_capa *oc, __u64 valid, int ea_size, diff --git a/drivers/staging/lustre/lustre/mgc/Makefile b/drivers/staging/lustre/lustre/mgc/Makefile index cc6e9f51a8e8..8ea29a89cf50 100644 --- a/drivers/staging/lustre/lustre/mgc/Makefile +++ b/drivers/staging/lustre/lustre/mgc/Makefile @@ -1,3 +1,2 @@ obj-$(CONFIG_LUSTRE_FS) += mgc.o -mgc-y := mgc_request.o -mgc-$(CONFIG_PROC_FS) += lproc_mgc.o +mgc-y := mgc_request.o lproc_mgc.o diff --git a/drivers/staging/lustre/lustre/mgc/mgc_internal.h b/drivers/staging/lustre/lustre/mgc/mgc_internal.h index a6f8b3ced2e7..82fb8f46e037 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_internal.h +++ b/drivers/staging/lustre/lustre/mgc/mgc_internal.h @@ -44,19 +44,8 @@ #include "../include/lustre_log.h" #include "../include/lustre_export.h" -#if defined (CONFIG_PROC_FS) void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars); int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data); -#else -static inline void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars) -{ - memset(lvars, 0, sizeof(*lvars)); -} -static inline int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data) -{ - return 0; -} -#endif /* CONFIG_PROC_FS */ int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld); diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 517b8ce1a44a..174dfc32876b 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -448,7 +448,6 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg) return rc; } -#if defined (CONFIG_PROC_FS) int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data) { struct obd_device *obd = data; @@ -477,7 +476,6 @@ int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data) LPROCFS_CLIMP_EXIT(obd); return 0; } -#endif /* reenqueue any lost locks */ #define RQ_RUNNING 0x1 diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile index e894681797c2..d0f70b41acf6 100644 --- a/drivers/staging/lustre/lustre/obdclass/Makefile +++ b/drivers/staging/lustre/lustre/obdclass/Makefile @@ -6,6 +6,4 @@ obdclass-y := linux/linux-module.o linux/linux-obdo.o linux/linux-sysctl.o \ lustre_handles.o lustre_peer.o \ statfs_pack.o obdo.o obd_config.o obd_mount.o \ lu_object.o dt_object.o capa.o cl_object.o \ - cl_page.o cl_lock.o cl_io.o lu_ref.o acl.o - -obdclass-$(CONFIG_PROC_FS) += lprocfs_counters.o + cl_page.o cl_lock.o cl_io.o lu_ref.o acl.o lprocfs_counters.o diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index 6e967af2f6b4..1bc37566b3a5 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -506,15 +506,8 @@ int obd_init_checks(void) return ret; } -#if defined (CONFIG_PROC_FS) extern int class_procfs_init(void); extern int class_procfs_clean(void); -#else -static inline int class_procfs_init(void) -{ return 0; } -static inline int class_procfs_clean(void) -{ return 0; } -#endif static int __init init_obdclass(void) { @@ -529,24 +522,22 @@ static int __init init_obdclass(void) spin_lock_init(&obd_types_lock); obd_zombie_impexp_init(); - if (IS_ENABLED(CONFIG_PROC_FS)) { - obd_memory = lprocfs_alloc_stats(OBD_STATS_NUM, - LPROCFS_STATS_FLAG_NONE | - LPROCFS_STATS_FLAG_IRQ_SAFE); + obd_memory = lprocfs_alloc_stats(OBD_STATS_NUM, + LPROCFS_STATS_FLAG_NONE | + LPROCFS_STATS_FLAG_IRQ_SAFE); - if (obd_memory == NULL) { - CERROR("kmalloc of 'obd_memory' failed\n"); - return -ENOMEM; - } - - lprocfs_counter_init(obd_memory, OBD_MEMORY_STAT, - LPROCFS_CNTR_AVGMINMAX, - "memused", "bytes"); - lprocfs_counter_init(obd_memory, OBD_MEMORY_PAGES_STAT, - LPROCFS_CNTR_AVGMINMAX, - "pagesused", "pages"); + if (obd_memory == NULL) { + CERROR("kmalloc of 'obd_memory' failed\n"); + return -ENOMEM; } + lprocfs_counter_init(obd_memory, OBD_MEMORY_STAT, + LPROCFS_CNTR_AVGMINMAX, + "memused", "bytes"); + lprocfs_counter_init(obd_memory, OBD_MEMORY_PAGES_STAT, + LPROCFS_CNTR_AVGMINMAX, + "pagesused", "pages"); + err = obd_init_checks(); if (err == -EOVERFLOW) return err; @@ -620,7 +611,6 @@ void obd_update_maxusage(void) } EXPORT_SYMBOL(obd_update_maxusage); -#if defined (CONFIG_PROC_FS) __u64 obd_memory_max(void) { __u64 ret; @@ -644,7 +634,6 @@ __u64 obd_pages_max(void) return ret; } EXPORT_SYMBOL(obd_pages_max); -#endif /* liblustre doesn't call cleanup_obdclass, apparently. we carry on in this * ifdef to the end of the file to cover module and versioning goo.*/ diff --git a/drivers/staging/lustre/lustre/obdclass/dt_object.c b/drivers/staging/lustre/lustre/obdclass/dt_object.c index b1eee0a6dc9a..6ce407ff8318 100644 --- a/drivers/staging/lustre/lustre/obdclass/dt_object.c +++ b/drivers/staging/lustre/lustre/obdclass/dt_object.c @@ -49,8 +49,6 @@ /* fid_be_to_cpu() */ #include "../include/lustre_fid.h" -#include "../include/lustre_quota.h" - /* context key constructor/destructor: dt_global_key_init, dt_global_key_fini */ LU_KEY_INIT(dt_global, struct dt_thread_info); LU_KEY_FINI(dt_global, struct dt_thread_info); @@ -939,8 +937,6 @@ out: } EXPORT_SYMBOL(dt_index_read); -#if defined (CONFIG_PROC_FS) - int lprocfs_dt_rd_blksize(char *page, char **start, off_t off, int count, int *eof, void *data) { @@ -1055,5 +1051,3 @@ int lprocfs_dt_rd_filesfree(char *page, char **start, off_t off, return rc; } EXPORT_SYMBOL(lprocfs_dt_rd_filesfree); - -#endif /* CONFIG_PROC_FS */ diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index 50c3d1de24cb..e3c6dcb42cff 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -53,7 +53,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c index 8927e24a599f..54f0a81f7b51 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index f44c74611d3b..17e7c1807863 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -221,8 +221,6 @@ int lprocfs_write_frac_helper(const char __user *buffer, unsigned long count, } EXPORT_SYMBOL(lprocfs_write_frac_helper); -#if defined (CONFIG_PROC_FS) - static int lprocfs_no_percpu_stats; module_param(lprocfs_no_percpu_stats, int, 0644); MODULE_PARM_DESC(lprocfs_no_percpu_stats, "Do not alloc percpu data for lprocfs stats"); @@ -266,29 +264,6 @@ struct dentry *ldebugfs_add_simple(struct dentry *root, } EXPORT_SYMBOL(ldebugfs_add_simple); -struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root, - char *name, void *data, - struct file_operations *fops) -{ - struct proc_dir_entry *proc; - umode_t mode = 0; - - if (root == NULL || name == NULL || fops == NULL) - return ERR_PTR(-EINVAL); - - if (fops->read) - mode = 0444; - if (fops->write) - mode |= 0200; - proc = proc_create_data(name, mode, root, fops, data); - if (!proc) { - CERROR("LprocFS: No memory to create /proc entry %s", name); - return ERR_PTR(-ENOMEM); - } - return proc; -} -EXPORT_SYMBOL(lprocfs_add_simple); - struct dentry *ldebugfs_add_symlink(const char *name, struct dentry *parent, const char *format, ...) { @@ -352,46 +327,6 @@ int ldebugfs_add_vars(struct dentry *parent, } EXPORT_SYMBOL(ldebugfs_add_vars); -/** - * Add /proc entries. - * - * \param root [in] The parent proc entry on which new entry will be added. - * \param list [in] Array of proc entries to be added. - * \param data [in] The argument to be passed when entries read/write routines - * are called through /proc file. - * - * \retval 0 on success - * < 0 on error - */ -int lprocfs_add_vars(struct proc_dir_entry *root, struct lprocfs_vars *list, - void *data) -{ - if (root == NULL || list == NULL) - return -EINVAL; - - while (list->name != NULL) { - struct proc_dir_entry *proc; - umode_t mode = 0; - - if (list->proc_mode != 0000) { - mode = list->proc_mode; - } else if (list->fops) { - if (list->fops->read) - mode = 0444; - if (list->fops->write) - mode |= 0200; - } - proc = proc_create_data(list->name, mode, root, - list->fops ?: &lprocfs_generic_fops, - list->data ?: data); - if (proc == NULL) - return -ENOMEM; - list++; - } - return 0; -} -EXPORT_SYMBOL(lprocfs_add_vars); - void ldebugfs_remove(struct dentry **entryp) { debugfs_remove(*entryp); @@ -399,20 +334,6 @@ void ldebugfs_remove(struct dentry **entryp) } EXPORT_SYMBOL(ldebugfs_remove); -void lprocfs_remove(struct proc_dir_entry **rooth) -{ - proc_remove(*rooth); - *rooth = NULL; -} -EXPORT_SYMBOL(lprocfs_remove); - -void lprocfs_remove_proc_entry(const char *name, struct proc_dir_entry *parent) -{ - LASSERT(parent != NULL); - remove_proc_entry(name, parent); -} -EXPORT_SYMBOL(lprocfs_remove_proc_entry); - struct dentry *ldebugfs_register(const char *name, struct dentry *parent, struct lprocfs_vars *list, void *data) @@ -439,30 +360,6 @@ out: } EXPORT_SYMBOL(ldebugfs_register); -struct proc_dir_entry *lprocfs_register(const char *name, - struct proc_dir_entry *parent, - struct lprocfs_vars *list, void *data) -{ - struct proc_dir_entry *entry; - - entry = proc_mkdir(name, parent); - if (entry == NULL) { - entry = ERR_PTR(-ENOMEM); - goto out; - } - - if (list != NULL) { - int rc = lprocfs_add_vars(entry, list, data); - if (rc != 0) { - lprocfs_remove(&entry); - entry = ERR_PTR(rc); - } - } -out: - return entry; -} -EXPORT_SYMBOL(lprocfs_register); - /* Generic callbacks */ int lprocfs_rd_uint(struct seq_file *m, void *data) { @@ -1337,7 +1234,7 @@ static int lprocfs_stats_seq_open(struct inode *inode, struct file *file) return rc; seq = file->private_data; - seq->private = inode->i_private ?: PDE_DATA(inode); + seq->private = inode->i_private; return 0; } @@ -1367,21 +1264,6 @@ int ldebugfs_register_stats(struct dentry *parent, const char *name, } EXPORT_SYMBOL(ldebugfs_register_stats); -int lprocfs_register_stats(struct proc_dir_entry *root, const char *name, - struct lprocfs_stats *stats) -{ - struct proc_dir_entry *entry; - LASSERT(root != NULL); - - entry = proc_create_data(name, 0644, root, - &lprocfs_stats_seq_fops, stats); - if (entry == NULL) - return -ENOMEM; - - return 0; -} -EXPORT_SYMBOL(lprocfs_register_stats); - void lprocfs_counter_init(struct lprocfs_stats *stats, int index, unsigned conf, const char *name, const char *units) { @@ -1854,35 +1736,16 @@ int ldebugfs_seq_create(struct dentry *parent, } EXPORT_SYMBOL(ldebugfs_seq_create); -int lprocfs_seq_create(struct proc_dir_entry *parent, - const char *name, - umode_t mode, - const struct file_operations *seq_fops, - void *data) -{ - struct proc_dir_entry *entry; - - /* Disallow secretly (un)writable entries. */ - LASSERT((seq_fops->write == NULL) == ((mode & 0222) == 0)); - entry = proc_create_data(name, mode, parent, seq_fops, data); - - if (entry == NULL) - return -ENOMEM; - - return 0; -} -EXPORT_SYMBOL(lprocfs_seq_create); - -int lprocfs_obd_seq_create(struct obd_device *dev, - const char *name, - umode_t mode, - const struct file_operations *seq_fops, - void *data) +int ldebugfs_obd_seq_create(struct obd_device *dev, + const char *name, + umode_t mode, + const struct file_operations *seq_fops, + void *data) { return ldebugfs_seq_create(dev->obd_debugfs_entry, name, mode, seq_fops, data); } -EXPORT_SYMBOL(lprocfs_obd_seq_create); +EXPORT_SYMBOL(ldebugfs_obd_seq_create); void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value) { @@ -1938,8 +1801,6 @@ int lprocfs_obd_rd_max_pages_per_rpc(struct seq_file *m, void *data) } EXPORT_SYMBOL(lprocfs_obd_rd_max_pages_per_rpc); -#endif - ssize_t lustre_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) { diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index 4458faad1b1a..eae660660358 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -1989,14 +1989,10 @@ void lu_global_fini(void) static __u32 ls_stats_read(struct lprocfs_stats *stats, int idx) { -#if defined (CONFIG_PROC_FS) struct lprocfs_counter ret; lprocfs_stats_collect(stats, idx, &ret); return (__u32)ret.lc_count; -#else - return 0; -#endif } /** diff --git a/drivers/staging/lustre/lustre/osc/Makefile b/drivers/staging/lustre/lustre/osc/Makefile index 54927fba4eb4..37cdeea9ac49 100644 --- a/drivers/staging/lustre/lustre/osc/Makefile +++ b/drivers/staging/lustre/lustre/osc/Makefile @@ -1,4 +1,3 @@ obj-$(CONFIG_LUSTRE_FS) += osc.o osc-y := osc_request.o osc_dev.o osc_object.o \ - osc_page.o osc_lock.o osc_io.o osc_quota.o osc_cache.o -osc-$(CONFIG_PROC_FS) += lproc_osc.o + osc_page.o osc_lock.o osc_io.o osc_quota.o osc_cache.o lproc_osc.o diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 0ba2c36ace44..9dc84ba7aa55 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -741,8 +741,8 @@ int lproc_osc_attach_seqstat(struct obd_device *dev) rc = ldebugfs_seq_create(dev->obd_debugfs_entry, "osc_stats", 0644, &osc_stats_fops, dev); if (rc == 0) - rc = lprocfs_obd_seq_create(dev, "rpc_stats", 0644, - &osc_rpc_stats_fops, dev); + rc = ldebugfs_obd_seq_create(dev, "rpc_stats", 0644, + &osc_rpc_stats_fops, dev); return rc; } diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index af96c7bc7764..470698b0dd75 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -136,16 +136,8 @@ extern spinlock_t osc_ast_guard; int osc_cleanup(struct obd_device *obd); int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg); -#if defined (CONFIG_PROC_FS) int lproc_osc_attach_seqstat(struct obd_device *dev); void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars); -#else -static inline int lproc_osc_attach_seqstat(struct obd_device *dev) {return 0;} -static inline void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars) -{ - memset(lvars, 0, sizeof(*lvars)); -} -#endif extern struct lu_device_type osc_device_type; diff --git a/drivers/staging/lustre/lustre/ptlrpc/Makefile b/drivers/staging/lustre/lustre/ptlrpc/Makefile index fb50cd4c65b6..24bbac19ddd1 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/Makefile +++ b/drivers/staging/lustre/lustre/ptlrpc/Makefile @@ -15,6 +15,5 @@ ptlrpc_objs += pers.o lproc_ptlrpc.o wiretest.o layout.o ptlrpc_objs += sec.o sec_bulk.o sec_gc.o sec_config.o ptlrpc_objs += sec_null.o sec_plain.o nrs.o nrs_fifo.o -ptlrpc-y := $(ldlm_objs) $(ptlrpc_objs) -ptlrpc-$(CONFIG_PROC_FS) += sec_lproc.o +ptlrpc-y := $(ldlm_objs) $(ptlrpc_objs) sec_lproc.o ptlrpc-$(CONFIG_LUSTRE_TRANSLATE_ERRNOS) += errno.o diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index cf5196a25fd8..1362160983a9 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -256,7 +256,6 @@ ptlrpc_ldebugfs_register(struct dentry *root, char *dir, } } -#if defined(CONFIG_PROC_FS) static int ptlrpc_lprocfs_req_history_len_seq_show(struct seq_file *m, void *v) { @@ -1237,7 +1236,7 @@ int lprocfs_wr_evict_client(struct file *file, const char __user *buffer, /* Kludge code(deadlock situation): the lprocfs lock has been held * since the client is evicted by writing client's * uuid/nid to procfs "evict_client" entry. However, - * obd_export_evict_by_uuid() will call lprocfs_remove() to destroy + * obd_export_evict_by_uuid() will call ldebugfs_remove() to destroy * the proc entries under the being destroyed export{}, so I have * to drop the lock at first here. * - jay, jxiong@clusterfs.com */ @@ -1390,5 +1389,3 @@ int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer, } EXPORT_SYMBOL(lprocfs_wr_pinger_recov); - -#endif /* CONFIG_PROC_FS */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h index 9f9ef9a24b63..6dc3998dcd24 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h @@ -82,16 +82,10 @@ void ptlrpc_sysfs_unregister_service(struct ptlrpc_service *svc); void ptlrpc_ldebugfs_register_service(struct dentry *debugfs_entry, struct ptlrpc_service *svc); -#if defined(CONFIG_PROC_FS) void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc); void ptlrpc_lprocfs_rpc_sent(struct ptlrpc_request *req, long amount); void ptlrpc_lprocfs_do_request_stat(struct ptlrpc_request *req, long q_usec, long work_usec); -#else -#define ptlrpc_lprocfs_unregister_service(params...) do {} while (0) -#define ptlrpc_lprocfs_rpc_sent(params...) do {} while (0) -#define ptlrpc_lprocfs_do_request_stat(params...) do {} while (0) -#endif /* CONFIG_PROC_FS */ /* NRS */ @@ -266,14 +260,8 @@ void sptlrpc_enc_pool_fini(void); int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v); /* sec_lproc.c */ -#if defined(CONFIG_PROC_FS) int sptlrpc_lproc_init(void); void sptlrpc_lproc_fini(void); -#else -static inline int sptlrpc_lproc_init(void) -{ return 0; } -static inline void sptlrpc_lproc_fini(void) {} -#endif /* sec_gc.c */ int sptlrpc_gc_init(void); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c index 549515dd165e..982512febf05 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c @@ -144,16 +144,16 @@ int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev) return -EINVAL; } - rc = lprocfs_obd_seq_create(dev, "srpc_info", 0444, - &sptlrpc_info_lprocfs_fops, dev); + rc = ldebugfs_obd_seq_create(dev, "srpc_info", 0444, + &sptlrpc_info_lprocfs_fops, dev); if (rc) { CERROR("create proc entry srpc_info for %s: %d\n", dev->obd_name, rc); return rc; } - rc = lprocfs_obd_seq_create(dev, "srpc_contexts", 0444, - &sptlrpc_ctxs_lprocfs_fops, dev); + rc = ldebugfs_obd_seq_create(dev, "srpc_contexts", 0444, + &sptlrpc_ctxs_lprocfs_fops, dev); if (rc) { CERROR("create proc entry srpc_contexts for %s: %d\n", dev->obd_name, rc); From f8d199f246f06cec2568e5a5f3d6dc10850a4dfd Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 31 May 2015 15:30:15 +0900 Subject: [PATCH 0682/1163] staging: lustre/obdclass/acl: remove unused variable lustre_ext_acl_xattr_reduce_space() declares old_size, but never uses it and gcc 5.x likes to complain about this, so remove it as it's not used at all. Cc: Oleg Drokin Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/acl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/obdclass/acl.c b/drivers/staging/lustre/lustre/obdclass/acl.c index 194c48a29205..bc3fc4780cb9 100644 --- a/drivers/staging/lustre/lustre/obdclass/acl.c +++ b/drivers/staging/lustre/lustre/obdclass/acl.c @@ -120,7 +120,6 @@ static int lustre_ext_acl_xattr_reduce_space(ext_acl_xattr_header **header, { int ext_count = le32_to_cpu((*header)->a_count); int ext_size = CFS_ACL_XATTR_SIZE(ext_count, ext_acl_xattr); - int old_size = CFS_ACL_XATTR_SIZE(old_count, ext_acl_xattr); ext_acl_xattr_header *new; if (unlikely(old_count <= ext_count)) From d5be8e1d559a76c22c49bd6770fd340558b21b81 Mon Sep 17 00:00:00 2001 From: Niranjan Dighe Date: Sun, 31 May 2015 05:39:07 +0000 Subject: [PATCH 0683/1163] Staging: lustre: Replace kzalloc followed by memcpy with kmemdup Replace kzalloc followed by memcpy by kmemdup. This patch was generated by 'make coccicheck' Signed-off-by: Niranjan Dighe Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/obd_config.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 19d4eb045b1b..fbdb748a36b9 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -840,29 +840,26 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, INIT_LIST_HEAD(&lprof->lp_list); LASSERT(proflen == (strlen(prof) + 1)); - lprof->lp_profile = kzalloc(proflen, GFP_NOFS); + lprof->lp_profile = kmemdup(prof, proflen, GFP_NOFS); if (lprof->lp_profile == NULL) { err = -ENOMEM; goto free_lprof; } - memcpy(lprof->lp_profile, prof, proflen); LASSERT(osclen == (strlen(osc) + 1)); - lprof->lp_dt = kzalloc(osclen, GFP_NOFS); + lprof->lp_dt = kmemdup(osc, osclen, GFP_NOFS); if (lprof->lp_dt == NULL) { err = -ENOMEM; goto free_lp_profile; } - memcpy(lprof->lp_dt, osc, osclen); if (mdclen > 0) { LASSERT(mdclen == (strlen(mdc) + 1)); - lprof->lp_md = kzalloc(mdclen, GFP_NOFS); + lprof->lp_md = kmemdup(mdc, mdclen, GFP_NOFS); if (lprof->lp_md == NULL) { err = -ENOMEM; goto free_lp_dt; } - memcpy(lprof->lp_md, mdc, mdclen); } list_add(&lprof->lp_list, &lustre_profile_list); From a71bfb4a6aabfe5e6f145883020153103c7fdfba Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:39:41 +0200 Subject: [PATCH 0684/1163] tools:iio:generic_buffer: fix order of freeing data data gets allocated before buffer_access, so it should be freed in reverse order. Otherwise, if allocating buffer_access fails, an attempt to free it would be taken, which should not happen. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/generic_buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c index f805493be3eb..15f2a40c9bf7 100644 --- a/tools/iio/generic_buffer.c +++ b/tools/iio/generic_buffer.c @@ -345,10 +345,10 @@ int main(int argc, char **argv) error_close_buffer_access: close(fp); -error_free_data: - free(data); error_free_buffer_access: free(buffer_access); +error_free_data: + free(data); error_free_buf_dir_name: free(buf_dir_name); error_free_triggername: From d3ccfc41f971105404694e8478b5e60625e46967 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:39:42 +0200 Subject: [PATCH 0685/1163] tools:iio:generic_buffer: free dev_dir_name on exit Make sure to free dev_dir_name in case of an error or regular exit. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/generic_buffer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c index 15f2a40c9bf7..7859ee9a46b2 100644 --- a/tools/iio/generic_buffer.c +++ b/tools/iio/generic_buffer.c @@ -220,7 +220,7 @@ int main(int argc, char **argv) "%s-dev%d", device_name, dev_num); if (ret < 0) { ret = -ENOMEM; - goto error_ret; + goto error_free_dev_dir_name; } } @@ -354,6 +354,8 @@ error_free_buf_dir_name: error_free_triggername: if (datardytrigger) free(trigger_name); +error_free_dev_dir_name: + free(dev_dir_name); error_ret: return ret; } From 66dd08fde06e5ad6f0f86c7a780d60973e9d9cf0 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:39:43 +0200 Subject: [PATCH 0686/1163] tools:iio:iio_utils: free scan_el_dir on exit In the error path, the string scan_el_dir got freed, while it was missing when build_channel_array() finished without errors. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/iio_utils.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c index 6f6452167b67..f879ad7b88bc 100644 --- a/tools/iio/iio_utils.c +++ b/tools/iio/iio_utils.c @@ -403,6 +403,7 @@ int build_channel_array(const char *device_dir, } closedir(dp); + free(scan_el_dir); /* reorder so that the array is in index order */ bsort_channel_array_by_index(ci_array, *counter); From 63f05c855f3825b89b92cd21df0415e6e32af3dd Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:39:44 +0200 Subject: [PATCH 0687/1163] tools:iio: free channel-array completely In iio_utils.c build_channel_array() dynamically allocates the string generic_name in the current iio_channel_info, which doesn't got freed in case of an error. This dynamically allocated channel-array is used by generic_buffer, and needs to be freed on the error/exit path. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/generic_buffer.c | 8 +++++++- tools/iio/iio_utils.c | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c index 7859ee9a46b2..0410948e23c2 100644 --- a/tools/iio/generic_buffer.c +++ b/tools/iio/generic_buffer.c @@ -255,7 +255,7 @@ int main(int argc, char **argv) "%siio:device%d/buffer", iio_dir, dev_num); if (ret < 0) { ret = -ENOMEM; - goto error_free_triggername; + goto error_free_channels; } if (!notrigger) { @@ -351,6 +351,12 @@ error_free_data: free(data); error_free_buf_dir_name: free(buf_dir_name); +error_free_channels: + for (i = num_channels - 1; i >= 0; i--) { + free(channels[i].name); + free(channels[i].generic_name); + } + free(channels); error_free_triggername: if (datardytrigger) free(trigger_name); diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c index f879ad7b88bc..6daf98fdde1a 100644 --- a/tools/iio/iio_utils.c +++ b/tools/iio/iio_utils.c @@ -410,8 +410,10 @@ int build_channel_array(const char *device_dir, return 0; error_cleanup_array: - for (i = count - 1; i >= 0; i--) + for (i = count - 1; i >= 0; i--) { free((*ci_array)[i].name); + free((*ci_array)[i].generic_name); + } free(*ci_array); error_close_dir: closedir(dp); From 121b5e505fe86ea52603c946865d658a5fe8130b Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:39:45 +0200 Subject: [PATCH 0688/1163] tools:iio:iio_utils: fix allocation handling In build_channel_array(), count needs to be decreased in more places since current->name and current->generic_name would be freed on the error path, although they have not been allocated, yet. This also requires to free current->name, when it is allocated, but current->generic_name is not yet allocated. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/iio_utils.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c index 6daf98fdde1a..1c0ca2f89e18 100644 --- a/tools/iio/iio_utils.c +++ b/tools/iio/iio_utils.c @@ -334,6 +334,7 @@ int build_channel_array(const char *device_dir, if (sysfsfp == NULL) { free(filename); ret = -errno; + count--; goto error_cleanup_array; } fscanf(sysfsfp, "%i", ¤t_enabled); @@ -353,6 +354,7 @@ int build_channel_array(const char *device_dir, if (current->name == NULL) { free(filename); ret = -ENOMEM; + count--; goto error_cleanup_array; } /* Get the generic and specific name elements */ @@ -360,6 +362,8 @@ int build_channel_array(const char *device_dir, ¤t->generic_name); if (ret) { free(filename); + free(current->name); + count--; goto error_cleanup_array; } ret = asprintf(&filename, From f96d055e4b38c64123f211f0521f834d649cd01c Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:39:47 +0200 Subject: [PATCH 0689/1163] tools:iio:lsiio: add closedir before exit In dump_channels() the DIR *dp was left open on exit. Close it and check for errors. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/lsiio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/iio/lsiio.c b/tools/iio/lsiio.c index c585440f864e..65a2385e2a78 100644 --- a/tools/iio/lsiio.c +++ b/tools/iio/lsiio.c @@ -56,7 +56,7 @@ static int dump_channels(const char *dev_dir_name) printf(" %-10s\n", ent->d_name); } - return 0; + return (closedir(dp) == -1) ? -errno : 0; } static int dump_one_device(const char *dev_dir_name) From 2b6a6e67af6f8f644a48f75efc1f44544c0d74f6 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:39:48 +0200 Subject: [PATCH 0690/1163] tools:iio: save errno first The man-page of errno states, that errno should be saved before doing any library call, as that call may have changed the value of errno. So, when encountering any error, save errno first. This patch affects generic_buffer.c, iio_event_monitor.c and iio_utils.c. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/generic_buffer.c | 2 +- tools/iio/iio_event_monitor.c | 6 +++--- tools/iio/iio_utils.c | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c index 0410948e23c2..7635aeb93dc8 100644 --- a/tools/iio/generic_buffer.c +++ b/tools/iio/generic_buffer.c @@ -296,8 +296,8 @@ int main(int argc, char **argv) /* Attempt to open non blocking the access dev */ fp = open(buffer_access, O_RDONLY | O_NONBLOCK); if (fp == -1) { /* If it isn't there make the node */ - printf("Failed to open %s\n", buffer_access); ret = -errno; + printf("Failed to open %s\n", buffer_access); goto error_free_buffer_access; } diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c index 427c271ac0d6..f6fdab48d340 100644 --- a/tools/iio/iio_event_monitor.c +++ b/tools/iio/iio_event_monitor.c @@ -269,8 +269,8 @@ int main(int argc, char **argv) fd = open(chrdev_name, 0); if (fd == -1) { - fprintf(stdout, "Failed to open %s\n", chrdev_name); ret = -errno; + fprintf(stdout, "Failed to open %s\n", chrdev_name); goto error_free_chrdev_name; } @@ -279,8 +279,8 @@ int main(int argc, char **argv) close(fd); if (ret == -1 || event_fd == -1) { - fprintf(stdout, "Failed to retrieve event fd\n"); ret = -errno; + fprintf(stdout, "Failed to retrieve event fd\n"); goto error_free_chrdev_name; } @@ -291,8 +291,8 @@ int main(int argc, char **argv) printf("nothing available\n"); continue; } else { - perror("Failed to read event from device"); ret = -errno; + perror("Failed to read event from device"); break; } } diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c index 1c0ca2f89e18..f12bc2e81c80 100644 --- a/tools/iio/iio_utils.c +++ b/tools/iio/iio_utils.c @@ -129,8 +129,8 @@ int iioutils_get_type(unsigned *is_signed, } sysfsfp = fopen(filename, "r"); if (sysfsfp == NULL) { - printf("failed to open %s\n", filename); ret = -errno; + printf("failed to open %s\n", filename); goto error_free_filename; } @@ -141,8 +141,8 @@ int iioutils_get_type(unsigned *is_signed, bits_used, &padint, shift); if (ret < 0) { - printf("failed to pass scan type description\n"); ret = -errno; + printf("failed to pass scan type description\n"); goto error_close_sysfsfp; } *be = (endianchar == 'b'); @@ -332,8 +332,8 @@ int build_channel_array(const char *device_dir, } sysfsfp = fopen(filename, "r"); if (sysfsfp == NULL) { - free(filename); ret = -errno; + free(filename); count--; goto error_cleanup_array; } @@ -505,8 +505,8 @@ int _write_sysfs_int(char *filename, char *basedir, int val, int verify) sprintf(temp, "%s/%s", basedir, filename); sysfsfp = fopen(temp, "w"); if (sysfsfp == NULL) { - printf("failed to open %s\n", temp); ret = -errno; + printf("failed to open %s\n", temp); goto error_free; } fprintf(sysfsfp, "%d", val); @@ -514,8 +514,8 @@ int _write_sysfs_int(char *filename, char *basedir, int val, int verify) if (verify) { sysfsfp = fopen(temp, "r"); if (sysfsfp == NULL) { - printf("failed to open %s\n", temp); ret = -errno; + printf("failed to open %s\n", temp); goto error_free; } fscanf(sysfsfp, "%d", &test); @@ -556,8 +556,8 @@ int _write_sysfs_string(char *filename, char *basedir, char *val, int verify) sprintf(temp, "%s/%s", basedir, filename); sysfsfp = fopen(temp, "w"); if (sysfsfp == NULL) { - printf("Could not open %s\n", temp); ret = -errno; + printf("Could not open %s\n", temp); goto error_free; } fprintf(sysfsfp, "%s", val); @@ -565,8 +565,8 @@ int _write_sysfs_string(char *filename, char *basedir, char *val, int verify) if (verify) { sysfsfp = fopen(temp, "r"); if (sysfsfp == NULL) { - printf("could not open file to verify\n"); ret = -errno; + printf("could not open file to verify\n"); goto error_free; } fscanf(sysfsfp, "%s", temp); From 5fdb8c6127c3c594360fb5f2959a724809c0032e Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:39:49 +0200 Subject: [PATCH 0691/1163] tools:iio:iio_event_monitor: save right errno Move up error handling code to preserve the errno coming from ioctl(), before it may be changed by close(). Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/iio_event_monitor.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c index f6fdab48d340..578390db1bec 100644 --- a/tools/iio/iio_event_monitor.c +++ b/tools/iio/iio_event_monitor.c @@ -275,15 +275,17 @@ int main(int argc, char **argv) } ret = ioctl(fd, IIO_GET_EVENT_FD_IOCTL, &event_fd); - - close(fd); - if (ret == -1 || event_fd == -1) { ret = -errno; fprintf(stdout, "Failed to retrieve event fd\n"); + if (close(fd) == -1) + perror("Failed to close character device file"); + goto error_free_chrdev_name; } + close(fd); + while (true) { ret = read(event_fd, &event, sizeof(event)); if (ret == -1) { From 8749948a1bc0aff24e493f89de40e2ff95a83baf Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:39:56 +0200 Subject: [PATCH 0692/1163] tools:iio:generic_buffer: fix check of errno Since errno contains the value of any of the defined error names, a negation will not lead to the desired match. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/generic_buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c index 7635aeb93dc8..e01c80ec5a88 100644 --- a/tools/iio/generic_buffer.c +++ b/tools/iio/generic_buffer.c @@ -321,7 +321,7 @@ int main(int argc, char **argv) data, toread*scan_size); if (read_size < 0) { - if (errno == -EAGAIN) { + if (errno == EAGAIN) { printf("nothing available\n"); continue; } else From e83a47cf6a5bdbd3d5677db13ae4df22f5e24b08 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:39:57 +0200 Subject: [PATCH 0693/1163] tools:iio:generic_buffer: pass up right error code find_type_by_name() returns a valid error code in case of an error. Pass this code up instead of an artificial one. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/generic_buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c index e01c80ec5a88..419e22736c3a 100644 --- a/tools/iio/generic_buffer.c +++ b/tools/iio/generic_buffer.c @@ -202,7 +202,7 @@ int main(int argc, char **argv) dev_num = find_type_by_name(device_name, "iio:device"); if (dev_num < 0) { printf("Failed to find the %s\n", device_name); - ret = -ENODEV; + ret = dev_num; goto error_ret; } printf("iio device number being used is %d\n", dev_num); @@ -228,7 +228,7 @@ int main(int argc, char **argv) trig_num = find_type_by_name(trigger_name, "trigger"); if (trig_num < 0) { printf("Failed to find the trigger %s\n", trigger_name); - ret = -ENODEV; + ret = trig_num; goto error_free_triggername; } printf("iio trigger number being used is %d\n", trig_num); From 8e926134ef15267f65ddfc7389c8078234610295 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:39:58 +0200 Subject: [PATCH 0694/1163] tools:iio:generic_buffer: sign-extend and shift data Refactor process_scan() to handle signed and unsigned data, respect shifts and the data mask for 2, 4 and 8 byte sized scan elements. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/generic_buffer.c | 101 +++++++++++++++++++++++-------------- 1 file changed, 64 insertions(+), 37 deletions(-) diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c index 419e22736c3a..4cd246426b57 100644 --- a/tools/iio/generic_buffer.c +++ b/tools/iio/generic_buffer.c @@ -59,33 +59,80 @@ int size_from_channelarray(struct iio_channel_info *channels, int num_channels) return bytes; } -void print2byte(int input, struct iio_channel_info *info) +void print2byte(uint16_t input, struct iio_channel_info *info) { /* First swap if incorrect endian */ if (info->be) - input = be16toh((uint16_t)input); + input = be16toh(input); else - input = le16toh((uint16_t)input); + input = le16toh(input); /* * Shift before conversion to avoid sign extension * of left aligned data */ input >>= info->shift; + input &= info->mask; if (info->is_signed) { - int16_t val = input; - - val &= (1 << info->bits_used) - 1; - val = (int16_t)(val << (16 - info->bits_used)) >> - (16 - info->bits_used); - printf("%05f ", ((float)val + info->offset)*info->scale); + int16_t val = (int16_t)(input << (16 - info->bits_used)) >> + (16 - info->bits_used); + printf("%05f ", ((float)val + info->offset) * info->scale); } else { - uint16_t val = input; - - val &= (1 << info->bits_used) - 1; - printf("%05f ", ((float)val + info->offset)*info->scale); + printf("%05f ", ((float)input + info->offset) * info->scale); } } + +void print4byte(uint32_t input, struct iio_channel_info *info) +{ + /* First swap if incorrect endian */ + if (info->be) + input = be32toh(input); + else + input = le32toh(input); + + /* + * Shift before conversion to avoid sign extension + * of left aligned data + */ + input >>= info->shift; + input &= info->mask; + if (info->is_signed) { + int32_t val = (int32_t)(input << (32 - info->bits_used)) >> + (32 - info->bits_used); + printf("%05f ", ((float)val + info->offset) * info->scale); + } else { + printf("%05f ", ((float)input + info->offset) * info->scale); + } +} + +void print8byte(uint64_t input, struct iio_channel_info *info) +{ + /* First swap if incorrect endian */ + if (info->be) + input = be64toh(input); + else + input = le64toh(input); + + /* + * Shift before conversion to avoid sign extension + * of left aligned data + */ + input >>= info->shift; + input &= info->mask; + if (info->is_signed) { + int64_t val = (int64_t)(input << (64 - info->bits_used)) >> + (64 - info->bits_used); + /* special case for timestamp */ + if (info->scale == 1.0f && info->offset == 0.0f) + printf("%" PRId64 " ", val); + else + printf("%05f ", + ((float)val + info->offset) * info->scale); + } else { + printf("%05f ", ((float)input + info->offset) * info->scale); + } +} + /** * process_scan() - print out the values in SI units * @data: pointer to the start of the scan @@ -108,32 +155,12 @@ void process_scan(char *data, &channels[k]); break; case 4: - if (!channels[k].is_signed) { - uint32_t val = *(uint32_t *) - (data + channels[k].location); - printf("%05f ", ((float)val + - channels[k].offset)* - channels[k].scale); - - } + print4byte(*(uint32_t *)(data + channels[k].location), + &channels[k]); break; case 8: - if (channels[k].is_signed) { - int64_t val = *(int64_t *) - (data + - channels[k].location); - if ((val >> channels[k].bits_used) & 1) - val = (val & channels[k].mask) | - ~channels[k].mask; - /* special case for timestamp */ - if (channels[k].scale == 1.0f && - channels[k].offset == 0.0f) - printf("%" PRId64 " ", val); - else - printf("%05f ", ((float)val + - channels[k].offset)* - channels[k].scale); - } + print8byte(*(uint64_t *)(data + channels[k].location), + &channels[k]); break; default: break; From dc8b5d6e633f8e54f70594d0be87aaf401ea0559 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:39:59 +0200 Subject: [PATCH 0695/1163] tools:iio:iio_utils: check amount of matches fscanf() usually returns the number of input items successfully matched and assigned, which can be fewer than provided (or even zero). Add a check in iioutils_get_type() to make sure all items are matched. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/iio_utils.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c index f12bc2e81c80..c5b4136e648a 100644 --- a/tools/iio/iio_utils.c +++ b/tools/iio/iio_utils.c @@ -144,6 +144,10 @@ int iioutils_get_type(unsigned *is_signed, ret = -errno; printf("failed to pass scan type description\n"); goto error_close_sysfsfp; + } else if (ret != 5) { + ret = -EIO; + printf("scan type description didn't match\n"); + goto error_close_sysfsfp; } *be = (endianchar == 'b'); *bytes = padint / 8; From 096f9b862e605fe08bb30e4f7a381684a8ff82ed Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:40:00 +0200 Subject: [PATCH 0696/1163] tools:iio:iio_utils: implement digit calculation Previously, the return value of sscanf() was treated as an indication of the digits it would have read. Yet, sscanf() only returns the amount of valid matches. Therefore, introduce a function to calculate the decimal digits of the read number and use this one to commence a colon search, as originally intended. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/iio_utils.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c index c5b4136e648a..60e5ec4165b7 100644 --- a/tools/iio/iio_utils.c +++ b/tools/iio/iio_utils.c @@ -431,6 +431,18 @@ error_ret: return ret; } +int calc_digits(int num) +{ + int count = 0; + + while (num != 0) { + num /= 10; + count++; + } + + return count; +} + /** * find_type_by_name() - function to match top level types by name * @name: top level type instance name @@ -441,7 +453,7 @@ error_ret: int find_type_by_name(const char *name, const char *type) { const struct dirent *ent; - int number, numstrlen; + int number, numstrlen, ret; FILE *nameFile; DIR *dp; @@ -459,9 +471,19 @@ int find_type_by_name(const char *name, const char *type) strcmp(ent->d_name, "..") != 0 && strlen(ent->d_name) > strlen(type) && strncmp(ent->d_name, type, strlen(type)) == 0) { - numstrlen = sscanf(ent->d_name + strlen(type), - "%d", - &number); + errno = 0; + ret = sscanf(ent->d_name + strlen(type), "%d", &number); + if (ret < 0) { + ret = -errno; + printf("failed to read element number\n"); + goto error_close_dir; + } else if (ret != 1) { + ret = -EIO; + printf("failed to match element number\n"); + goto error_close_dir; + } + + numstrlen = calc_digits(number); /* verify the next character is not a colon */ if (strncmp(ent->d_name + strlen(type) + numstrlen, ":", @@ -495,6 +517,11 @@ int find_type_by_name(const char *name, const char *type) } closedir(dp); return -ENODEV; + +error_close_dir: + if (closedir(dp) == -1) + perror("find_type_by_name(): Failed to close directory"); + return ret; } int _write_sysfs_int(char *filename, char *basedir, int val, int verify) From 2156b179993e3d5b422976181ba17d91153313e1 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:40:01 +0200 Subject: [PATCH 0697/1163] tools:iio:iio_utils: mark private function static Functions _write_sysfs_int() and _write_sysfs_string() are supposed to be called only by public wrappers, so make them static. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/iio_utils.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c index 60e5ec4165b7..812153ff18c3 100644 --- a/tools/iio/iio_utils.c +++ b/tools/iio/iio_utils.c @@ -524,7 +524,7 @@ error_close_dir: return ret; } -int _write_sysfs_int(char *filename, char *basedir, int val, int verify) +static int _write_sysfs_int(char *filename, char *basedir, int val, int verify) { int ret = 0; FILE *sysfsfp; @@ -574,7 +574,8 @@ int write_sysfs_int_and_verify(char *filename, char *basedir, int val) return _write_sysfs_int(filename, basedir, val, 1); } -int _write_sysfs_string(char *filename, char *basedir, char *val, int verify) +static int _write_sysfs_string(char *filename, char *basedir, char *val, + int verify) { int ret = 0; FILE *sysfsfp; From e9e45b43b8f06273d9b78f187042dff0bf5be0a5 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:40:02 +0200 Subject: [PATCH 0698/1163] tools:iio: catch errors in string allocation This patch catches errors in string allocation in generic_buffer.c, iio_event_monitor.c, iio_utils.c and lsiio.c. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/generic_buffer.c | 4 +++- tools/iio/iio_event_monitor.c | 2 ++ tools/iio/iio_utils.c | 9 ++++++--- tools/iio/lsiio.c | 15 +++++++++++++-- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c index 4cd246426b57..eb89bc2ca5d0 100644 --- a/tools/iio/generic_buffer.c +++ b/tools/iio/generic_buffer.c @@ -234,7 +234,9 @@ int main(int argc, char **argv) } printf("iio device number being used is %d\n", dev_num); - asprintf(&dev_dir_name, "%siio:device%d", iio_dir, dev_num); + ret = asprintf(&dev_dir_name, "%siio:device%d", iio_dir, dev_num); + if (ret < 0) + return -ENOMEM; if (!notrigger) { if (trigger_name == NULL) { diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c index 578390db1bec..1374374208ee 100644 --- a/tools/iio/iio_event_monitor.c +++ b/tools/iio/iio_event_monitor.c @@ -265,6 +265,8 @@ int main(int argc, char **argv) /* If we can't find a IIO device by name assume device_name is a IIO chrdev */ chrdev_name = strdup(device_name); + if (!chrdev_name) + return -ENOMEM; } fd = open(chrdev_name, 0); diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c index 812153ff18c3..f0896f46847f 100644 --- a/tools/iio/iio_utils.c +++ b/tools/iio/iio_utils.c @@ -36,7 +36,7 @@ int iioutils_break_up_name(const char *full_name, char *current; char *w, *r; char *working, *prefix = ""; - int i; + int i, ret; for (i = 0; i < sizeof(iio_direction) / sizeof(iio_direction[0]); i++) if (!strncmp(full_name, iio_direction[i], @@ -46,6 +46,9 @@ int iioutils_break_up_name(const char *full_name, } current = strdup(full_name + strlen(prefix) + 1); + if (!current) + return -ENOMEM; + working = strtok(current, "_\0"); w = working; @@ -59,10 +62,10 @@ int iioutils_break_up_name(const char *full_name, r++; } *w = '\0'; - asprintf(generic_name, "%s_%s", prefix, working); + ret = asprintf(generic_name, "%s_%s", prefix, working); free(current); - return 0; + return (ret == -1) ? -ENOMEM : 0; } /** diff --git a/tools/iio/lsiio.c b/tools/iio/lsiio.c index 65a2385e2a78..daa6c5312d66 100644 --- a/tools/iio/lsiio.c +++ b/tools/iio/lsiio.c @@ -107,7 +107,12 @@ static void dump_devices(void) if (check_prefix(ent->d_name, type_device)) { char *dev_dir_name; - asprintf(&dev_dir_name, "%s%s", iio_dir, ent->d_name); + if (asprintf(&dev_dir_name, "%s%s", iio_dir, + ent->d_name) < 0) { + printf("Memory allocation failed\n"); + goto error_close_dir; + } + dump_one_device(dev_dir_name); free(dev_dir_name); if (verblevel >= VERBLEVEL_SENSORS) @@ -119,11 +124,17 @@ static void dump_devices(void) if (check_prefix(ent->d_name, type_trigger)) { char *dev_dir_name; - asprintf(&dev_dir_name, "%s%s", iio_dir, ent->d_name); + if (asprintf(&dev_dir_name, "%s%s", iio_dir, + ent->d_name) < 0) { + printf("Memory allocation failed\n"); + goto error_close_dir; + } + dump_one_trigger(dev_dir_name); free(dev_dir_name); } } +error_close_dir: closedir(dp); } From c8ce9903cba202936999c2c9463fbb370ee145ba Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:40:03 +0200 Subject: [PATCH 0699/1163] tools:iio:generic_buffer: catch errors for arguments conversion Add handler to catch errors on conversion of numerical arguments. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/generic_buffer.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c index eb89bc2ca5d0..93ac93f74549 100644 --- a/tools/iio/generic_buffer.c +++ b/tools/iio/generic_buffer.c @@ -206,13 +206,22 @@ int main(int argc, char **argv) noevents = 1; break; case 'c': + errno = 0; num_loops = strtoul(optarg, &dummy, 10); + if (errno) + return -errno; break; case 'w': + errno = 0; timedelay = strtoul(optarg, &dummy, 10); + if (errno) + return -errno; break; case 'l': + errno = 0; buf_len = strtoul(optarg, &dummy, 10); + if (errno) + return -errno; break; case 'g': notrigger = 1; From 6bb7cac8551e2d60edbd25a6d046cc45932c4c3e Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:40:04 +0200 Subject: [PATCH 0700/1163] tools:iio:generic_buffer: add error handling Add error handling to calls which can indicate a major problem by returning an error code. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/generic_buffer.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c index 93ac93f74549..cf9a4120204f 100644 --- a/tools/iio/generic_buffer.c +++ b/tools/iio/generic_buffer.c @@ -347,7 +347,14 @@ int main(int argc, char **argv) .events = POLLIN, }; - poll(&pfd, 1, -1); + ret = poll(&pfd, 1, -1); + if (ret < 0) { + ret = -errno; + goto error_close_buffer_access; + } else if (ret == 0) { + continue; + } + toread = buf_len; } else { @@ -378,11 +385,14 @@ int main(int argc, char **argv) if (!notrigger) /* Disconnect the trigger - just write a dummy name. */ - write_sysfs_string("trigger/current_trigger", - dev_dir_name, "NULL"); + ret = write_sysfs_string("trigger/current_trigger", + dev_dir_name, "NULL"); + if (ret < 0) + printf("Failed to write to %s\n", dev_dir_name); error_close_buffer_access: - close(fp); + if (close(fp) == -1) + perror("Failed to close buffer"); error_free_buffer_access: free(buffer_access); error_free_data: From 963f54cef23b7e8c91bbe60b978b5f4a3e990f2c Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:40:05 +0200 Subject: [PATCH 0701/1163] tools:iio:iio_event_monitor: add error handling Add error handling to calls which can indicate a major problem by returning an error code. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/iio_event_monitor.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c index 1374374208ee..1316527f3c3c 100644 --- a/tools/iio/iio_event_monitor.c +++ b/tools/iio/iio_event_monitor.c @@ -286,7 +286,10 @@ int main(int argc, char **argv) goto error_free_chrdev_name; } - close(fd); + if (close(fd) == -1) { + ret = -errno; + goto error_free_chrdev_name; + } while (true) { ret = read(event_fd, &event, sizeof(event)); @@ -304,7 +307,9 @@ int main(int argc, char **argv) print_event(&event); } - close(event_fd); + if (close(event_fd) == -1) + perror("Failed to close event file"); + error_free_chrdev_name: free(chrdev_name); error_ret: From 53118557b6a9c263e4a80825da367b2116529541 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:40:14 +0200 Subject: [PATCH 0702/1163] tools:iio:iio_utils: add error handling Add error handling to calls which can indicate a major problem by returning an error code. This also sets ret to -ENOENT in iioutils_get_type() and iioutils_get_param_float() to indicate if no matching directory entry was found. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/iio_utils.c | 265 +++++++++++++++++++++++++++++++++++------- 1 file changed, 223 insertions(+), 42 deletions(-) diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c index f0896f46847f..e1828d0d8a38 100644 --- a/tools/iio/iio_utils.c +++ b/tools/iio/iio_utils.c @@ -50,6 +50,10 @@ int iioutils_break_up_name(const char *full_name, return -ENOMEM; working = strtok(current, "_\0"); + if (!working) { + free(current); + return -EINVAL; + } w = working; r = working; @@ -117,6 +121,7 @@ int iioutils_get_type(unsigned *is_signed, ret = -errno; goto error_free_builtname_generic; } + ret = -ENOENT; while (ent = readdir(dp), ent != NULL) /* * Do we allow devices to override a generic name with @@ -162,7 +167,12 @@ int iioutils_get_type(unsigned *is_signed, *is_signed = 1; else *is_signed = 0; - fclose(sysfsfp); + if (fclose(sysfsfp)) { + ret = -errno; + printf("Failed to close %s\n", filename); + goto error_free_filename; + } + free(filename); filename = 0; @@ -170,12 +180,16 @@ int iioutils_get_type(unsigned *is_signed, } error_close_sysfsfp: if (sysfsfp) - fclose(sysfsfp); + if (fclose(sysfsfp)) + perror("iioutils_get_type(): Failed to close file"); + error_free_filename: if (filename) free(filename); error_closedir: - closedir(dp); + if (closedir(dp) == -1) + perror("iioutils_get_type(): Failed to close directory"); + error_free_builtname_generic: free(builtname_generic); error_free_builtname: @@ -215,6 +229,7 @@ int iioutils_get_param_float(float *output, ret = -errno; goto error_free_builtname_generic; } + ret = -ENOENT; while (ent = readdir(dp), ent != NULL) if ((strcmp(builtname, ent->d_name) == 0) || (strcmp(builtname_generic, ent->d_name) == 0)) { @@ -229,14 +244,19 @@ int iioutils_get_param_float(float *output, ret = -errno; goto error_free_filename; } - fscanf(sysfsfp, "%f", output); + errno = 0; + if (fscanf(sysfsfp, "%f", output) != 1) + ret = errno ? -errno : -ENODATA; + break; } error_free_filename: if (filename) free(filename); error_closedir: - closedir(dp); + if (closedir(dp) == -1) + perror("iioutils_get_param_float(): Failed to close directory"); + error_free_builtname_generic: free(builtname_generic); error_free_builtname: @@ -310,10 +330,24 @@ int build_channel_array(const char *device_dir, free(filename); goto error_close_dir; } - fscanf(sysfsfp, "%i", &ret); + errno = 0; + if (fscanf(sysfsfp, "%i", &ret) != 1) { + ret = errno ? -errno : -ENODATA; + if (fclose(sysfsfp)) + perror("build_channel_array(): Failed to close file"); + + free(filename); + goto error_close_dir; + } + if (ret == 1) (*counter)++; - fclose(sysfsfp); + if (fclose(sysfsfp)) { + ret = -errno; + free(filename); + goto error_close_dir; + } + free(filename); } *ci_array = malloc(sizeof(**ci_array) * (*counter)); @@ -344,8 +378,20 @@ int build_channel_array(const char *device_dir, count--; goto error_cleanup_array; } - fscanf(sysfsfp, "%i", ¤t_enabled); - fclose(sysfsfp); + errno = 0; + if (fscanf(sysfsfp, "%i", ¤t_enabled) != 1) { + ret = errno ? -errno : -ENODATA; + free(filename); + count--; + goto error_cleanup_array; + } + + if (fclose(sysfsfp)) { + ret = -errno; + free(filename); + count--; + goto error_cleanup_array; + } if (!current_enabled) { free(filename); @@ -383,8 +429,29 @@ int build_channel_array(const char *device_dir, goto error_cleanup_array; } sysfsfp = fopen(filename, "r"); - fscanf(sysfsfp, "%u", ¤t->index); - fclose(sysfsfp); + if (sysfsfp == NULL) { + ret = -errno; + printf("failed to open %s\n", filename); + free(filename); + goto error_cleanup_array; + } + + errno = 0; + if (fscanf(sysfsfp, "%u", ¤t->index) != 1) { + ret = errno ? -errno : -ENODATA; + if (fclose(sysfsfp)) + perror("build_channel_array(): Failed to close file"); + + free(filename); + goto error_cleanup_array; + } + + if (fclose(sysfsfp)) { + ret = -errno; + free(filename); + goto error_cleanup_array; + } + free(filename); /* Find the scale */ ret = iioutils_get_param_float(¤t->scale, @@ -410,10 +477,16 @@ int build_channel_array(const char *device_dir, device_dir, current->name, current->generic_name); + if (ret < 0) + goto error_cleanup_array; } } - closedir(dp); + if (closedir(dp) == -1) { + ret = -errno; + goto error_cleanup_array; + } + free(scan_el_dir); /* reorder so that the array is in index order */ bsort_channel_array_by_index(ci_array, *counter); @@ -427,7 +500,10 @@ error_cleanup_array: } free(*ci_array); error_close_dir: - closedir(dp); + if (dp) + if (closedir(dp) == -1) + perror("build_channel_array(): Failed to close dir"); + error_free_name: free(scan_el_dir); error_ret: @@ -496,29 +572,45 @@ int find_type_by_name(const char *name, const char *type) + numstrlen + 6); if (filename == NULL) { - closedir(dp); - return -ENOMEM; + ret = -ENOMEM; + goto error_close_dir; } - sprintf(filename, "%s%s%d/name", - iio_dir, - type, - number); + + ret = sprintf(filename, "%s%s%d/name", iio_dir, + type, number); + if (ret < 0) { + free(filename); + goto error_close_dir; + } + nameFile = fopen(filename, "r"); if (!nameFile) { free(filename); continue; } free(filename); - fscanf(nameFile, "%s", thisname); - fclose(nameFile); + errno = 0; + if (fscanf(nameFile, "%s", thisname) != 1) { + ret = errno ? -errno : -ENODATA; + goto error_close_dir; + } + + if (fclose(nameFile)) { + ret = -errno; + goto error_close_dir; + } + if (strcmp(name, thisname) == 0) { - closedir(dp); + if (closedir(dp) == -1) + return -errno; return number; } } } } - closedir(dp); + if (closedir(dp) == -1) + return -errno; + return -ENODEV; error_close_dir: @@ -536,15 +628,29 @@ static int _write_sysfs_int(char *filename, char *basedir, int val, int verify) if (temp == NULL) return -ENOMEM; - sprintf(temp, "%s/%s", basedir, filename); + ret = sprintf(temp, "%s/%s", basedir, filename); + if (ret < 0) + goto error_free; + sysfsfp = fopen(temp, "w"); if (sysfsfp == NULL) { ret = -errno; printf("failed to open %s\n", temp); goto error_free; } - fprintf(sysfsfp, "%d", val); - fclose(sysfsfp); + ret = fprintf(sysfsfp, "%d", val); + if (ret < 0) { + if (fclose(sysfsfp)) + perror("_write_sysfs_int(): Failed to close dir"); + + goto error_free; + } + + if (fclose(sysfsfp)) { + ret = -errno; + goto error_free; + } + if (verify) { sysfsfp = fopen(temp, "r"); if (sysfsfp == NULL) { @@ -552,8 +658,19 @@ static int _write_sysfs_int(char *filename, char *basedir, int val, int verify) printf("failed to open %s\n", temp); goto error_free; } - fscanf(sysfsfp, "%d", &test); - fclose(sysfsfp); + if (fscanf(sysfsfp, "%d", &test) != 1) { + ret = errno ? -errno : -ENODATA; + if (fclose(sysfsfp)) + perror("_write_sysfs_int(): Failed to close dir"); + + goto error_free; + } + + if (fclose(sysfsfp)) { + ret = -errno; + goto error_free; + } + if (test != val) { printf("Possible failure in int write %d to %s%s\n", val, @@ -588,15 +705,29 @@ static int _write_sysfs_string(char *filename, char *basedir, char *val, printf("Memory allocation failed\n"); return -ENOMEM; } - sprintf(temp, "%s/%s", basedir, filename); + ret = sprintf(temp, "%s/%s", basedir, filename); + if (ret < 0) + goto error_free; + sysfsfp = fopen(temp, "w"); if (sysfsfp == NULL) { ret = -errno; printf("Could not open %s\n", temp); goto error_free; } - fprintf(sysfsfp, "%s", val); - fclose(sysfsfp); + ret = fprintf(sysfsfp, "%s", val); + if (ret < 0) { + if (fclose(sysfsfp)) + perror("_write_sysfs_string(): Failed to close dir"); + + goto error_free; + } + + if (fclose(sysfsfp)) { + ret = -errno; + goto error_free; + } + if (verify) { sysfsfp = fopen(temp, "r"); if (sysfsfp == NULL) { @@ -604,8 +735,19 @@ static int _write_sysfs_string(char *filename, char *basedir, char *val, printf("could not open file to verify\n"); goto error_free; } - fscanf(sysfsfp, "%s", temp); - fclose(sysfsfp); + if (fscanf(sysfsfp, "%s", temp) != 1) { + ret = errno ? -errno : -ENODATA; + if (fclose(sysfsfp)) + perror("_write_sysfs_string(): Failed to close dir"); + + goto error_free; + } + + if (fclose(sysfsfp)) { + ret = -errno; + goto error_free; + } + if (strcmp(temp, val) != 0) { printf("Possible failure in string write of %s " "Should be %s " @@ -649,14 +791,27 @@ int read_sysfs_posint(char *filename, char *basedir) printf("Memory allocation failed"); return -ENOMEM; } - sprintf(temp, "%s/%s", basedir, filename); + ret = sprintf(temp, "%s/%s", basedir, filename); + if (ret < 0) + goto error_free; + sysfsfp = fopen(temp, "r"); if (sysfsfp == NULL) { ret = -errno; goto error_free; } - fscanf(sysfsfp, "%d\n", &ret); - fclose(sysfsfp); + errno = 0; + if (fscanf(sysfsfp, "%d\n", &ret) != 1) { + ret = errno ? -errno : -ENODATA; + if (fclose(sysfsfp)) + perror("read_sysfs_posint(): Failed to close dir"); + + goto error_free; + } + + if (fclose(sysfsfp)) + ret = -errno; + error_free: free(temp); return ret; @@ -672,14 +827,27 @@ int read_sysfs_float(char *filename, char *basedir, float *val) printf("Memory allocation failed"); return -ENOMEM; } - sprintf(temp, "%s/%s", basedir, filename); + ret = sprintf(temp, "%s/%s", basedir, filename); + if (ret < 0) + goto error_free; + sysfsfp = fopen(temp, "r"); if (sysfsfp == NULL) { ret = -errno; goto error_free; } - fscanf(sysfsfp, "%f\n", val); - fclose(sysfsfp); + errno = 0; + if (fscanf(sysfsfp, "%f\n", val) != 1) { + ret = errno ? -errno : -ENODATA; + if (fclose(sysfsfp)) + perror("read_sysfs_float(): Failed to close dir"); + + goto error_free; + } + + if (fclose(sysfsfp)) + ret = -errno; + error_free: free(temp); return ret; @@ -695,14 +863,27 @@ int read_sysfs_string(const char *filename, const char *basedir, char *str) printf("Memory allocation failed"); return -ENOMEM; } - sprintf(temp, "%s/%s", basedir, filename); + ret = sprintf(temp, "%s/%s", basedir, filename); + if (ret < 0) + goto error_free; + sysfsfp = fopen(temp, "r"); if (sysfsfp == NULL) { ret = -errno; goto error_free; } - fscanf(sysfsfp, "%s\n", str); - fclose(sysfsfp); + errno = 0; + if (fscanf(sysfsfp, "%s\n", str) != 1) { + ret = errno ? -errno : -ENODATA; + if (fclose(sysfsfp)) + perror("read_sysfs_string(): Failed to close dir"); + + goto error_free; + } + + if (fclose(sysfsfp)) + ret = -errno; + error_free: free(temp); return ret; From acf50b3586f8d8a7530b905e111dda41876d38f4 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:40:15 +0200 Subject: [PATCH 0703/1163] tools:iio:lsiio: add error handling Add error handling to calls which can indicate a major problem by returning an error code. This also involves to change the type of dump_devices() from void to int. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/lsiio.c | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/tools/iio/lsiio.c b/tools/iio/lsiio.c index daa6c5312d66..b1089adb7d3a 100644 --- a/tools/iio/lsiio.c +++ b/tools/iio/lsiio.c @@ -69,7 +69,10 @@ static int dump_one_device(const char *dev_dir_name) "%i", &dev_idx); if (retval != 1) return -EINVAL; - read_sysfs_string("name", dev_dir_name, name); + retval = read_sysfs_string("name", dev_dir_name, name); + if (retval) + return retval; + printf("Device %03d: %s\n", dev_idx, name); if (verblevel >= VERBLEVEL_SENSORS) @@ -87,20 +90,24 @@ static int dump_one_trigger(const char *dev_dir_name) "%i", &dev_idx); if (retval != 1) return -EINVAL; - read_sysfs_string("name", dev_dir_name, name); + retval = read_sysfs_string("name", dev_dir_name, name); + if (retval) + return retval; + printf("Trigger %03d: %s\n", dev_idx, name); return 0; } -static void dump_devices(void) +static int dump_devices(void) { const struct dirent *ent; + int ret; DIR *dp; dp = opendir(iio_dir); if (dp == NULL) { printf("No industrial I/O devices available\n"); - return; + return -ENODEV; } while (ent = readdir(dp), ent != NULL) { @@ -109,11 +116,16 @@ static void dump_devices(void) if (asprintf(&dev_dir_name, "%s%s", iio_dir, ent->d_name) < 0) { - printf("Memory allocation failed\n"); + ret = -ENOMEM; + goto error_close_dir; + } + + ret = dump_one_device(dev_dir_name); + if (ret) { + free(dev_dir_name); goto error_close_dir; } - dump_one_device(dev_dir_name); free(dev_dir_name); if (verblevel >= VERBLEVEL_SENSORS) printf("\n"); @@ -126,16 +138,26 @@ static void dump_devices(void) if (asprintf(&dev_dir_name, "%s%s", iio_dir, ent->d_name) < 0) { - printf("Memory allocation failed\n"); + ret = -ENOMEM; + goto error_close_dir; + } + + ret = dump_one_trigger(dev_dir_name); + if (ret) { + free(dev_dir_name); goto error_close_dir; } - dump_one_trigger(dev_dir_name); free(dev_dir_name); } } + return (closedir(dp) == -1) ? -errno : 0; + error_close_dir: - closedir(dp); + if (closedir(dp) == -1) + perror("dump_devices(): Failed to close directory"); + + return ret; } int main(int argc, char **argv) @@ -163,7 +185,5 @@ int main(int argc, char **argv) exit(1); } - dump_devices(); - - return 0; + return dump_devices(); } From 700f6c02582ee43b09ea2ae9d619d652ca87a219 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sun, 31 May 2015 10:35:20 +0100 Subject: [PATCH 0704/1163] staging: vt6655: implement ieee80211_low_level_stats Collect low level stats from mib counter for mac80211 call. Replacing the unused function STAvUpdate802_11Counter. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 2 ++ drivers/staging/vt6655/device_main.c | 24 +++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 440537e47121..a49c6c624c5e 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -410,6 +410,8 @@ struct vnt_private { unsigned char abyEEPROM[EEP_MAX_CONTEXT_SIZE]; /* unsigned long alignment */ unsigned short wBeaconInterval; + + struct ieee80211_low_level_stats low_stats; }; static inline PDEVICE_RD_INFO alloc_rd_info(void) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 8f96cc93820a..c27f5ef7f0a2 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1056,8 +1056,9 @@ static void vnt_check_bb_vga(struct vnt_private *priv) static irqreturn_t device_intr(int irq, void *dev_instance) { struct vnt_private *pDevice = dev_instance; + struct ieee80211_low_level_stats *low_stats = &pDevice->low_stats; int max_count = 0; - unsigned long dwMIBCounter = 0; + u32 mib_counter; unsigned char byOrgPageSel = 0; int handled = 0; unsigned long flags; @@ -1084,14 +1085,20 @@ static irqreturn_t device_intr(int irq, void *dev_instance) else byOrgPageSel = 0; - MACvReadMIBCounter(pDevice->PortOffset, &dwMIBCounter); + /* Read low level stats */ + MACvReadMIBCounter(pDevice->PortOffset, &mib_counter); + + low_stats->dot11RTSSuccessCount += mib_counter & 0xff; + low_stats->dot11RTSFailureCount += (mib_counter >> 8) & 0xff; + low_stats->dot11ACKFailureCount += (mib_counter >> 16) & 0xff; + low_stats->dot11FCSErrorCount += (mib_counter >> 24) & 0xff; + /* * TBD.... * Must do this after doing rx/tx, cause ISR bit is slow * than RD/TD write back * update ISR counter */ - STAvUpdate802_11Counter(&pDevice->s802_11Counter, &pDevice->scStatistic, dwMIBCounter); while (pDevice->dwIsr && pDevice->vif) { STAvUpdateIsrStatCounter(&pDevice->scStatistic, pDevice->dwIsr); MACvWriteISR(pDevice->PortOffset, pDevice->dwIsr); @@ -1604,6 +1611,16 @@ static int vnt_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, return 0; } +static int vnt_get_stats(struct ieee80211_hw *hw, + struct ieee80211_low_level_stats *stats) +{ + struct vnt_private *priv = hw->priv; + + memcpy(stats, &priv->low_stats, sizeof(*stats)); + + return 0; +} + static u64 vnt_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { struct vnt_private *priv = hw->priv; @@ -1641,6 +1658,7 @@ static const struct ieee80211_ops vnt_mac_ops = { .prepare_multicast = vnt_prepare_multicast, .configure_filter = vnt_configure, .set_key = vnt_set_key, + .get_stats = vnt_get_stats, .get_tsf = vnt_get_tsf, .set_tsf = vnt_set_tsf, .reset_tsf = vnt_reset_tsf, From 19327367de63e9b6f9f5a68246ab84bd7b31ebdb Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sun, 31 May 2015 10:35:21 +0100 Subject: [PATCH 0705/1163] staging: vt6655: dead code remove STAvUpdate802_11Counter This function is nolonger of any future use. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/mib.c | 27 --------------------------- drivers/staging/vt6655/mib.h | 6 ------ 2 files changed, 33 deletions(-) diff --git a/drivers/staging/vt6655/mib.c b/drivers/staging/vt6655/mib.c index d55c762027ed..e9d23a742e6a 100644 --- a/drivers/staging/vt6655/mib.c +++ b/drivers/staging/vt6655/mib.c @@ -110,30 +110,3 @@ void STAvUpdateIsrStatCounter(PSStatCounter pStatistic, unsigned long dwIsr) if (dwIsr & ISR_SOFTTIMER1) /* ISR, bit21 */ pStatistic->ISRStat.dwIsrSTIMER1Int++; } - -/* - * Description: Update 802.11 mib counter - * - * Parameters: - * In: - * p802_11Counter - Pointer to 802.11 mib counter - * pStatistic - Pointer to Statistic Counter Data Structure - * dwCounter - hardware counter for 802.11 mib - * Out: - * none - * - * Return Value: none - * - */ -void -STAvUpdate802_11Counter( - PSDot11Counters p802_11Counter, - PSStatCounter pStatistic, - unsigned long dwCounter -) -{ - 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); -} diff --git a/drivers/staging/vt6655/mib.h b/drivers/staging/vt6655/mib.h index 5cb59b8a1c7c..64ca360d3140 100644 --- a/drivers/staging/vt6655/mib.h +++ b/drivers/staging/vt6655/mib.h @@ -73,10 +73,4 @@ typedef struct tagSStatCounter { void STAvUpdateIsrStatCounter(PSStatCounter pStatistic, unsigned long dwIsr); -void STAvUpdate802_11Counter( - PSDot11Counters p802_11Counter, - PSStatCounter pStatistic, - unsigned long dwCounter -); - #endif // __MIB_H__ From 7e4786d1ab5835e7a132dfe1d0589ffe1a575bc9 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sun, 31 May 2015 10:35:22 +0100 Subject: [PATCH 0706/1163] staging: vt6655: Remove call to STAvUpdateIsrStatCounter. This function does not provide any data to users. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 2 -- drivers/staging/vt6655/device_main.c | 1 - 2 files changed, 3 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index a49c6c624c5e..62e07f525913 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -286,8 +286,6 @@ struct vnt_private { unsigned char abyCurrentNetAddr[ETH_ALEN]; __aligned(2) bool bLinkPass; /* link status: OK or fail */ - /* Adapter statistics */ - SStatCounter scStatistic; /* 802.11 counter */ SDot11Counters s802_11Counter; diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index c27f5ef7f0a2..31f4ec7b8f47 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1100,7 +1100,6 @@ static irqreturn_t device_intr(int irq, void *dev_instance) * update ISR counter */ while (pDevice->dwIsr && pDevice->vif) { - STAvUpdateIsrStatCounter(&pDevice->scStatistic, pDevice->dwIsr); MACvWriteISR(pDevice->PortOffset, pDevice->dwIsr); if (pDevice->dwIsr & ISR_FETALERR) { From da74dbac164863685016c3a4ee06cb9db89a6f28 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sun, 31 May 2015 10:35:23 +0100 Subject: [PATCH 0707/1163] staging: vt6655: remove mib.c/h dead code. Remove from makefile and dead variables Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/Makefile | 1 - drivers/staging/vt6655/device.h | 4 -- drivers/staging/vt6655/mib.c | 112 -------------------------------- drivers/staging/vt6655/mib.h | 76 ---------------------- 4 files changed, 193 deletions(-) delete mode 100644 drivers/staging/vt6655/mib.c delete mode 100644 drivers/staging/vt6655/mib.h diff --git a/drivers/staging/vt6655/Makefile b/drivers/staging/vt6655/Makefile index 115b951bf0d9..d55c3baade53 100644 --- a/drivers/staging/vt6655/Makefile +++ b/drivers/staging/vt6655/Makefile @@ -11,7 +11,6 @@ vt6655_stage-y += device_main.o \ dpc.o \ power.o \ srom.o \ - mib.o \ key.o \ rf.o diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 62e07f525913..e9c4bf31a85a 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -68,7 +68,6 @@ #include "device_cfg.h" #include "card.h" -#include "mib.h" #include "srom.h" #include "desc.h" #include "key.h" @@ -286,9 +285,6 @@ struct vnt_private { unsigned char abyCurrentNetAddr[ETH_ALEN]; __aligned(2) bool bLinkPass; /* link status: OK or fail */ - /* 802.11 counter */ - SDot11Counters s802_11Counter; - unsigned int uCurrRSSI; unsigned char byCurrSQ; diff --git a/drivers/staging/vt6655/mib.c b/drivers/staging/vt6655/mib.c deleted file mode 100644 index e9d23a742e6a..000000000000 --- a/drivers/staging/vt6655/mib.c +++ /dev/null @@ -1,112 +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: mib.c - * - * Purpose: Implement MIB Data Structure - * - * Author: Tevin Chen - * - * Date: May 21, 1996 - * - * Functions: - * STAvUpdateIstStatCounter - Update ISR statistic counter - * STAvUpdate802_11Counter - Update 802.11 mib counter - * - * Revision History: - * - */ - -#include "mac.h" -#include "mib.h" - -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Variables --------------------------*/ - -/*--------------------- Static Functions --------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - -/* - * Description: Update Isr Statistic Counter - * - * Parameters: - * In: - * pStatistic - Pointer to Statistic Counter Data Structure - * wisr - Interrupt status - * Out: - * none - * - * Return Value: none - * - */ -void STAvUpdateIsrStatCounter(PSStatCounter pStatistic, unsigned long dwIsr) -{ - /**********************/ - /* ABNORMAL interrupt */ - /**********************/ - /* not any IMR bit invoke irq */ - - if (dwIsr == 0) { - pStatistic->ISRStat.dwIsrUnknown++; - return; - } - -/* Added by Kyle */ - if (dwIsr & ISR_TXDMA0) /* ISR, bit0 */ - pStatistic->ISRStat.dwIsrTx0OK++; /* TXDMA0 successful */ - - if (dwIsr & ISR_AC0DMA) /* ISR, bit1 */ - pStatistic->ISRStat.dwIsrAC0TxOK++; /* AC0DMA successful */ - - if (dwIsr & ISR_BNTX) /* ISR, bit2 */ - pStatistic->ISRStat.dwIsrBeaconTxOK++; /* BeaconTx successful */ - - if (dwIsr & ISR_RXDMA0) /* ISR, bit3 */ - pStatistic->ISRStat.dwIsrRx0OK++; /* Rx0 successful */ - - if (dwIsr & ISR_TBTT) /* ISR, bit4 */ - pStatistic->ISRStat.dwIsrTBTTInt++; /* TBTT successful */ - - if (dwIsr & ISR_SOFTTIMER) /* ISR, bit6 */ - pStatistic->ISRStat.dwIsrSTIMERInt++; - - if (dwIsr & ISR_WATCHDOG) /* ISR, bit7 */ - pStatistic->ISRStat.dwIsrWatchDog++; - - if (dwIsr & ISR_FETALERR) /* ISR, bit8 */ - pStatistic->ISRStat.dwIsrUnrecoverableError++; - - if (dwIsr & ISR_SOFTINT) /* ISR, bit9 */ - pStatistic->ISRStat.dwIsrSoftInterrupt++; /* software interrupt */ - - if (dwIsr & ISR_MIBNEARFULL) /* ISR, bit10 */ - pStatistic->ISRStat.dwIsrMIBNearfull++; - - if (dwIsr & ISR_RXNOBUF) /* ISR, bit11 */ - pStatistic->ISRStat.dwIsrRxNoBuf++; /* Rx No Buff */ - - if (dwIsr & ISR_RXDMA1) /* ISR, bit12 */ - pStatistic->ISRStat.dwIsrRx1OK++; /* Rx1 successful */ - - if (dwIsr & ISR_SOFTTIMER1) /* ISR, bit21 */ - pStatistic->ISRStat.dwIsrSTIMER1Int++; -} diff --git a/drivers/staging/vt6655/mib.h b/drivers/staging/vt6655/mib.h deleted file mode 100644 index 64ca360d3140..000000000000 --- a/drivers/staging/vt6655/mib.h +++ /dev/null @@ -1,76 +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: mib.h - * - * Purpose: Implement MIB Data Structure - * - * Author: Tevin Chen - * - * Date: May 21, 1996 - * - */ - -#ifndef __MIB_H__ -#define __MIB_H__ - -#include "desc.h" - -// -// 802.11 counter -// - -typedef struct tagSDot11Counters { - unsigned long long RTSSuccessCount; - unsigned long long RTSFailureCount; - unsigned long long ACKFailureCount; - unsigned long long FCSErrorCount; -} SDot11Counters, *PSDot11Counters; - -// -// Custom counter -// -typedef struct tagSISRCounters { - unsigned long dwIsrTx0OK; - unsigned long dwIsrAC0TxOK; - unsigned long dwIsrBeaconTxOK; - unsigned long dwIsrRx0OK; - unsigned long dwIsrTBTTInt; - unsigned long dwIsrSTIMERInt; - unsigned long dwIsrWatchDog; - unsigned long dwIsrUnrecoverableError; - unsigned long dwIsrSoftInterrupt; - unsigned long dwIsrMIBNearfull; - unsigned long dwIsrRxNoBuf; - - unsigned long dwIsrUnknown; - - unsigned long dwIsrRx1OK; - unsigned long dwIsrSTIMER1Int; -} SISRCounters, *PSISRCounters; - -// -// statistic counter -// -typedef struct tagSStatCounter { - SISRCounters ISRStat; -} SStatCounter, *PSStatCounter; - -void STAvUpdateIsrStatCounter(PSStatCounter pStatistic, unsigned long dwIsr); - -#endif // __MIB_H__ From ff1ce1a81e6eec82c224e33d3d23ab3f0002547e Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sun, 31 May 2015 10:35:24 +0100 Subject: [PATCH 0708/1163] staging: vt6655: use workqueue for interrupt handling Introduce vnt_interrupt to handle interrupt and use workqueue to queue and queue on vif. Convert device_intr to void call vnt_interrupt_process from vnt_interrupt_work providing vif is valid. This removes troublesome heavy code from the interupt handler and allows to remove atomic from other areas of driver. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 2 ++ drivers/staging/vt6655/device_main.c | 36 ++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index e9c4bf31a85a..b928c2a42e75 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -405,6 +405,8 @@ struct vnt_private { unsigned short wBeaconInterval; + struct work_struct interrupt_work; + struct ieee80211_low_level_stats low_stats; }; diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 31f4ec7b8f47..d5f090f8fa28 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -32,7 +32,6 @@ * device_free_info - device structure resource free function * device_get_pci_info - get allocated pci io/mem resource * device_print_info - print out resource - * device_intr - interrupt handle function * device_rx_srv - rx service function * device_alloc_rx_buf - rx buffer pre-allocated function * device_free_tx_buf - free tx buffer function @@ -148,7 +147,6 @@ static void vt6655_init_info(struct pci_dev *pcid, static void device_free_info(struct vnt_private *pDevice); static bool device_get_pci_info(struct vnt_private *, struct pci_dev *pcid); static void device_print_info(struct vnt_private *pDevice); -static irqreturn_t device_intr(int irq, void *dev_instance); #ifdef CONFIG_PM static int device_notify_reboot(struct notifier_block *, unsigned long event, void *ptr); @@ -1053,27 +1051,24 @@ static void vnt_check_bb_vga(struct vnt_private *priv) } } -static irqreturn_t device_intr(int irq, void *dev_instance) +static void vnt_interrupt_process(struct vnt_private *pDevice) { - struct vnt_private *pDevice = dev_instance; struct ieee80211_low_level_stats *low_stats = &pDevice->low_stats; int max_count = 0; u32 mib_counter; unsigned char byOrgPageSel = 0; - int handled = 0; unsigned long flags; MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr); if (pDevice->dwIsr == 0) - return IRQ_RETVAL(handled); + return; if (pDevice->dwIsr == 0xffffffff) { pr_debug("dwIsr = 0xffff\n"); - return IRQ_RETVAL(handled); + return; } - handled = 1; MACvIntDisable(pDevice->PortOffset); spin_lock_irqsave(&pDevice->lock, flags); @@ -1175,8 +1170,25 @@ static irqreturn_t device_intr(int irq, void *dev_instance) spin_unlock_irqrestore(&pDevice->lock, flags); MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); +} - return IRQ_RETVAL(handled); +static void vnt_interrupt_work(struct work_struct *work) +{ + struct vnt_private *priv = + container_of(work, struct vnt_private, interrupt_work); + + if (priv->vif) + vnt_interrupt_process(priv); +} + +static irqreturn_t vnt_interrupt(int irq, void *arg) +{ + struct vnt_private *priv = arg; + + if (priv->vif) + schedule_work(&priv->interrupt_work); + + return IRQ_HANDLED; } static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb) @@ -1268,7 +1280,7 @@ static int vnt_start(struct ieee80211_hw *hw) if (!device_init_rings(priv)) return -ENOMEM; - ret = request_irq(priv->pcid->irq, &device_intr, + ret = request_irq(priv->pcid->irq, &vnt_interrupt, IRQF_SHARED, "vt6655", priv); if (ret) { dev_dbg(&priv->pcid->dev, "failed to start irq\n"); @@ -1297,6 +1309,8 @@ static void vnt_stop(struct ieee80211_hw *hw) ieee80211_stop_queues(hw); + cancel_work_sync(&priv->interrupt_work); + MACbShutdown(priv->PortOffset); MACbSoftwareReset(priv->PortOffset); CARDbRadioPowerOff(priv); @@ -1783,6 +1797,8 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) return -ENODEV; } + INIT_WORK(&priv->interrupt_work, vnt_interrupt_work); + /* do reset */ if (!MACbSoftwareReset(priv->PortOffset)) { dev_err(&pcid->dev, ": Failed to access MAC hardware..\n"); From f33d8d63fc8e2e2f98abe78db85ace6d28209e3e Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sun, 31 May 2015 10:35:25 +0100 Subject: [PATCH 0709/1163] staging: vt6655: vnt_interrupt_process remove page 0 select Page 1 is fully proctected by lock there is no need to check for it. Page 0 is selected at other times. Remove byOrgPageSel and its calls from function. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index d5f090f8fa28..2262a61ccbfd 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1056,7 +1056,6 @@ static void vnt_interrupt_process(struct vnt_private *pDevice) struct ieee80211_low_level_stats *low_stats = &pDevice->low_stats; int max_count = 0; u32 mib_counter; - unsigned char byOrgPageSel = 0; unsigned long flags; MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr); @@ -1073,13 +1072,6 @@ static void vnt_interrupt_process(struct vnt_private *pDevice) spin_lock_irqsave(&pDevice->lock, flags); - /* Make sure current page is 0 */ - VNSvInPortB(pDevice->PortOffset + MAC_REG_PAGE1SEL, &byOrgPageSel); - if (byOrgPageSel == 1) - MACvSelectPage0(pDevice->PortOffset); - else - byOrgPageSel = 0; - /* Read low level stats */ MACvReadMIBCounter(pDevice->PortOffset, &mib_counter); @@ -1164,9 +1156,6 @@ static void vnt_interrupt_process(struct vnt_private *pDevice) break; } - if (byOrgPageSel == 1) - MACvSelectPage1(pDevice->PortOffset); - spin_unlock_irqrestore(&pDevice->lock, flags); MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); From 2995dfe68a0df4e6b4d27b02a600e9a928ce8175 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sun, 31 May 2015 10:35:26 +0100 Subject: [PATCH 0710/1163] staging: vt6655: vnt_interrupt_process remove camel case. pDevice -> priv Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 103 ++++++++++++++------------- 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 2262a61ccbfd..575ba87af75f 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1051,29 +1051,29 @@ static void vnt_check_bb_vga(struct vnt_private *priv) } } -static void vnt_interrupt_process(struct vnt_private *pDevice) +static void vnt_interrupt_process(struct vnt_private *priv) { - struct ieee80211_low_level_stats *low_stats = &pDevice->low_stats; + struct ieee80211_low_level_stats *low_stats = &priv->low_stats; int max_count = 0; u32 mib_counter; unsigned long flags; - MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr); + MACvReadISR(priv->PortOffset, &priv->dwIsr); - if (pDevice->dwIsr == 0) + if (priv->dwIsr == 0) return; - if (pDevice->dwIsr == 0xffffffff) { + if (priv->dwIsr == 0xffffffff) { pr_debug("dwIsr = 0xffff\n"); return; } - MACvIntDisable(pDevice->PortOffset); + MACvIntDisable(priv->PortOffset); - spin_lock_irqsave(&pDevice->lock, flags); + spin_lock_irqsave(&priv->lock, flags); /* Read low level stats */ - MACvReadMIBCounter(pDevice->PortOffset, &mib_counter); + MACvReadMIBCounter(priv->PortOffset, &mib_counter); low_stats->dot11RTSSuccessCount += mib_counter & 0xff; low_stats->dot11RTSFailureCount += (mib_counter >> 8) & 0xff; @@ -1086,79 +1086,80 @@ static void vnt_interrupt_process(struct vnt_private *pDevice) * than RD/TD write back * update ISR counter */ - while (pDevice->dwIsr && pDevice->vif) { - MACvWriteISR(pDevice->PortOffset, pDevice->dwIsr); + while (priv->dwIsr && priv->vif) { + MACvWriteISR(priv->PortOffset, priv->dwIsr); - if (pDevice->dwIsr & ISR_FETALERR) { + if (priv->dwIsr & ISR_FETALERR) { pr_debug(" ISR_FETALERR\n"); - VNSvOutPortB(pDevice->PortOffset + MAC_REG_SOFTPWRCTL, 0); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPECTI); - device_error(pDevice, pDevice->dwIsr); + VNSvOutPortB(priv->PortOffset + MAC_REG_SOFTPWRCTL, 0); + VNSvOutPortW(priv->PortOffset + + MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPECTI); + device_error(priv, priv->dwIsr); } - if (pDevice->dwIsr & ISR_TBTT) { - if (pDevice->op_mode != NL80211_IFTYPE_ADHOC) - vnt_check_bb_vga(pDevice); + if (priv->dwIsr & ISR_TBTT) { + if (priv->op_mode != NL80211_IFTYPE_ADHOC) + vnt_check_bb_vga(priv); - pDevice->bBeaconSent = false; - if (pDevice->bEnablePSMode) - PSbIsNextTBTTWakeUp((void *)pDevice); + priv->bBeaconSent = false; + if (priv->bEnablePSMode) + PSbIsNextTBTTWakeUp((void *)priv); - if ((pDevice->op_mode == NL80211_IFTYPE_AP || - pDevice->op_mode == NL80211_IFTYPE_ADHOC) && - pDevice->vif->bss_conf.enable_beacon) { - MACvOneShotTimer1MicroSec(pDevice->PortOffset, - (pDevice->vif->bss_conf.beacon_int - MAKE_BEACON_RESERVED) << 10); + if ((priv->op_mode == NL80211_IFTYPE_AP || + priv->op_mode == NL80211_IFTYPE_ADHOC) && + priv->vif->bss_conf.enable_beacon) { + MACvOneShotTimer1MicroSec(priv->PortOffset, + (priv->vif->bss_conf.beacon_int - MAKE_BEACON_RESERVED) << 10); } /* TODO: adhoc PS mode */ } - if (pDevice->dwIsr & ISR_BNTX) { - if (pDevice->op_mode == NL80211_IFTYPE_ADHOC) { - pDevice->bIsBeaconBufReadySet = false; - pDevice->cbBeaconBufReadySetCnt = 0; + if (priv->dwIsr & ISR_BNTX) { + if (priv->op_mode == NL80211_IFTYPE_ADHOC) { + priv->bIsBeaconBufReadySet = false; + priv->cbBeaconBufReadySetCnt = 0; } - pDevice->bBeaconSent = true; + priv->bBeaconSent = true; } - if (pDevice->dwIsr & ISR_RXDMA0) - max_count += device_rx_srv(pDevice, TYPE_RXDMA0); + if (priv->dwIsr & ISR_RXDMA0) + max_count += device_rx_srv(priv, TYPE_RXDMA0); - if (pDevice->dwIsr & ISR_RXDMA1) - max_count += device_rx_srv(pDevice, TYPE_RXDMA1); + if (priv->dwIsr & ISR_RXDMA1) + max_count += device_rx_srv(priv, TYPE_RXDMA1); - if (pDevice->dwIsr & ISR_TXDMA0) - max_count += device_tx_srv(pDevice, TYPE_TXDMA0); + if (priv->dwIsr & ISR_TXDMA0) + max_count += device_tx_srv(priv, TYPE_TXDMA0); - if (pDevice->dwIsr & ISR_AC0DMA) - max_count += device_tx_srv(pDevice, TYPE_AC0DMA); + if (priv->dwIsr & ISR_AC0DMA) + max_count += device_tx_srv(priv, TYPE_AC0DMA); - if (pDevice->dwIsr & ISR_SOFTTIMER1) { - if (pDevice->vif->bss_conf.enable_beacon) - vnt_beacon_make(pDevice, pDevice->vif); + if (priv->dwIsr & ISR_SOFTTIMER1) { + if (priv->vif->bss_conf.enable_beacon) + vnt_beacon_make(priv, priv->vif); } /* If both buffers available wake the queue */ - if (AVAIL_TD(pDevice, TYPE_TXDMA0) && - AVAIL_TD(pDevice, TYPE_AC0DMA) && - ieee80211_queue_stopped(pDevice->hw, 0)) - ieee80211_wake_queues(pDevice->hw); + if (AVAIL_TD(priv, TYPE_TXDMA0) && + AVAIL_TD(priv, TYPE_AC0DMA) && + ieee80211_queue_stopped(priv->hw, 0)) + ieee80211_wake_queues(priv->hw); - MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr); + MACvReadISR(priv->PortOffset, &priv->dwIsr); - MACvReceive0(pDevice->PortOffset); - MACvReceive1(pDevice->PortOffset); + MACvReceive0(priv->PortOffset); + MACvReceive1(priv->PortOffset); - if (max_count > pDevice->sOpts.int_works) + if (max_count > priv->sOpts.int_works) break; } - spin_unlock_irqrestore(&pDevice->lock, flags); + spin_unlock_irqrestore(&priv->lock, flags); - MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); + MACvIntEnable(priv->PortOffset, IMR_MASK_VALUE); } static void vnt_interrupt_work(struct work_struct *work) From 41b9e5e5164da54c4dd77492d2e3909c38de4fc9 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sun, 31 May 2015 10:35:27 +0100 Subject: [PATCH 0711/1163] staging: vt6655: replace and resize dwIsr dwIsr is not used outside vnt_interrupt_process and should be u32. Move to function and resize to u32. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 1 - drivers/staging/vt6655/device_main.c | 33 ++++++++++++++-------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index b928c2a42e75..5cf1b337cba7 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -238,7 +238,6 @@ struct vnt_private { CHIP_TYPE chip_id; void __iomem *PortOffset; - unsigned long dwIsr; u32 memaddr; u32 ioaddr; u32 io_size; diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 575ba87af75f..aec3ccec2231 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1056,15 +1056,16 @@ static void vnt_interrupt_process(struct vnt_private *priv) struct ieee80211_low_level_stats *low_stats = &priv->low_stats; int max_count = 0; u32 mib_counter; + u32 isr; unsigned long flags; - MACvReadISR(priv->PortOffset, &priv->dwIsr); + MACvReadISR(priv->PortOffset, &isr); - if (priv->dwIsr == 0) + if (isr == 0) return; - if (priv->dwIsr == 0xffffffff) { - pr_debug("dwIsr = 0xffff\n"); + if (isr == 0xffffffff) { + pr_debug("isr = 0xffff\n"); return; } @@ -1086,18 +1087,18 @@ static void vnt_interrupt_process(struct vnt_private *priv) * than RD/TD write back * update ISR counter */ - while (priv->dwIsr && priv->vif) { - MACvWriteISR(priv->PortOffset, priv->dwIsr); + while (isr && priv->vif) { + MACvWriteISR(priv->PortOffset, isr); - if (priv->dwIsr & ISR_FETALERR) { + if (isr & ISR_FETALERR) { pr_debug(" ISR_FETALERR\n"); VNSvOutPortB(priv->PortOffset + MAC_REG_SOFTPWRCTL, 0); VNSvOutPortW(priv->PortOffset + MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPECTI); - device_error(priv, priv->dwIsr); + device_error(priv, isr); } - if (priv->dwIsr & ISR_TBTT) { + if (isr & ISR_TBTT) { if (priv->op_mode != NL80211_IFTYPE_ADHOC) vnt_check_bb_vga(priv); @@ -1116,7 +1117,7 @@ static void vnt_interrupt_process(struct vnt_private *priv) } - if (priv->dwIsr & ISR_BNTX) { + if (isr & ISR_BNTX) { if (priv->op_mode == NL80211_IFTYPE_ADHOC) { priv->bIsBeaconBufReadySet = false; priv->cbBeaconBufReadySetCnt = 0; @@ -1125,19 +1126,19 @@ static void vnt_interrupt_process(struct vnt_private *priv) priv->bBeaconSent = true; } - if (priv->dwIsr & ISR_RXDMA0) + if (isr & ISR_RXDMA0) max_count += device_rx_srv(priv, TYPE_RXDMA0); - if (priv->dwIsr & ISR_RXDMA1) + if (isr & ISR_RXDMA1) max_count += device_rx_srv(priv, TYPE_RXDMA1); - if (priv->dwIsr & ISR_TXDMA0) + if (isr & ISR_TXDMA0) max_count += device_tx_srv(priv, TYPE_TXDMA0); - if (priv->dwIsr & ISR_AC0DMA) + if (isr & ISR_AC0DMA) max_count += device_tx_srv(priv, TYPE_AC0DMA); - if (priv->dwIsr & ISR_SOFTTIMER1) { + if (isr & ISR_SOFTTIMER1) { if (priv->vif->bss_conf.enable_beacon) vnt_beacon_make(priv, priv->vif); } @@ -1148,7 +1149,7 @@ static void vnt_interrupt_process(struct vnt_private *priv) ieee80211_queue_stopped(priv->hw, 0)) ieee80211_wake_queues(priv->hw); - MACvReadISR(priv->PortOffset, &priv->dwIsr); + MACvReadISR(priv->PortOffset, &isr); MACvReceive0(priv->PortOffset); MACvReceive1(priv->PortOffset); From b5eeed8cb6097c8ea660b6598d36fdbb94065a22 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sun, 31 May 2015 10:35:28 +0100 Subject: [PATCH 0712/1163] staging: vt6655: device_rx_srv check sk_buff is NULL There is a small chance that pRD->pRDInfo->skb could go NULL while the interrupt is processing. Put NULL check on loop to break out. Signed-off-by: Malcolm Priestley Cc: Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index aec3ccec2231..8dbde24eb154 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -805,6 +805,10 @@ static int device_rx_srv(struct vnt_private *pDevice, unsigned int uIdx) pRD = pRD->next) { if (works++ > 15) break; + + if (!pRD->pRDInfo->skb) + break; + if (vnt_receive_frame(pDevice, pRD)) { if (!device_alloc_rx_buf(pDevice, pRD)) { dev_err(&pDevice->pcid->dev, From 5df5910b13e423c54930c4e9f662fd94da856d4f Mon Sep 17 00:00:00 2001 From: Jakub Sitnicki Date: Sun, 31 May 2015 15:04:14 +0200 Subject: [PATCH 0713/1163] staging: rtl8188eu: Kill dead calls to kill_pid() There is no interface to register PIDs of processes the driver should send a signal to. Remove it. Signed-off-by: Jakub Sitnicki Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/drv_types.h | 1 - drivers/staging/rtl8188eu/include/osdep_service.h | 2 -- drivers/staging/rtl8188eu/include/rtw_ioctl.h | 2 -- drivers/staging/rtl8188eu/os_dep/mlme_linux.c | 2 -- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 12 ------------ 5 files changed, 19 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/drv_types.h b/drivers/staging/rtl8188eu/include/drv_types.h index c81317906adc..bcc74dcd8207 100644 --- a/drivers/staging/rtl8188eu/include/drv_types.h +++ b/drivers/staging/rtl8188eu/include/drv_types.h @@ -175,7 +175,6 @@ static inline struct device *dvobj_to_dev(struct dvobj_priv *dvobj) }; struct adapter { - int pid[3];/* process id from UI, 0:wps, 1:hostapd, 2:dhcpcd */ u16 chip_type; struct dvobj_priv *dvobj; diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h index 515e949629e2..00472e0c00a0 100644 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ b/drivers/staging/rtl8188eu/include/osdep_service.h @@ -157,8 +157,6 @@ void rtw_free_netdev(struct net_device *netdev); #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_modular64(u64 x, u64 y); /* Macros for handling unaligned memory accesses */ diff --git a/drivers/staging/rtl8188eu/include/rtw_ioctl.h b/drivers/staging/rtl8188eu/include/rtw_ioctl.h index f3aa924f2029..ee2cb54a7552 100644 --- a/drivers/staging/rtl8188eu/include/rtw_ioctl.h +++ b/drivers/staging/rtl8188eu/include/rtw_ioctl.h @@ -117,6 +117,4 @@ int drv_set_info(struct net_device *MiniportAdapterContext, u32 informationbufferlength, u32 *bytesread, u32 *bytesneeded); -extern int ui_pid[3]; - #endif /* #ifndef __INC_CEINFO_ */ diff --git a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c index 64c99f2e9077..218adaa574b5 100644 --- a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c @@ -41,8 +41,6 @@ void rtw_os_indicate_connect(struct adapter *adapter) { rtw_indicate_wx_assoc_event(adapter); netif_carrier_on(adapter->pnetdev); - if (adapter->pid[2] != 0) - rtw_signal_process(adapter->pid[2], SIGALRM); } void rtw_os_indicate_scan_done(struct adapter *padapter, bool aborted) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index ef3c73e38172..d0d4335b444c 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -32,8 +32,6 @@ #include #include -int ui_pid[3] = {0, 0, 0}; - #define USB_VENDER_ID_REALTEK 0x0bda /* DID_USB_v916_20130116 */ @@ -330,11 +328,6 @@ static int rtw_resume_process(struct adapter *padapter) _exit_pwrlock(&pwrpriv->lock); - if (padapter->pid[1] != 0) { - DBG_88E("pid[1]:%d\n", padapter->pid[1]); - rtw_signal_process(padapter->pid[1], SIGUSR2); - } - rtw_roaming(padapter, NULL); ret = 0; @@ -511,11 +504,6 @@ static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device goto free_dvobj; } - if (ui_pid[1] != 0) { - DBG_88E("ui_pid[1]:%d\n", ui_pid[1]); - rtw_signal_process(ui_pid[1], SIGUSR2); - } - RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-871x_drv - drv_init, success!\n")); status = _SUCCESS; From 9cd491e8c390d403bdf881808ef409d83266f4b2 Mon Sep 17 00:00:00 2001 From: Heiner Kallweit Date: Sun, 31 May 2015 14:44:54 +0200 Subject: [PATCH 0714/1163] staging: fbtft: Add support for Himax HX8357D controller The Himax HX8357D is used e.g. by the Adafruit PITFT Plus 3.5". Adafruit added HX8357D support to an own fork of fbtft and support Raspbian only (https://github.com/adafruit/adafruit-rpi-fbtft/). They don't intend to push it upstream but gave me the ok to do so. Original author: Sean Cross I just applied small changes to the driver to align it with the other fbtft drivers. - add "compatible" argument to FBTFT_REGISTER_DRIVER call - add missing MODULE_ALIAS declarations Tested successfully with this display on an RPI2 under Arch Linux ARM (kernel 3.18.13). Signed-off-by: Heiner Kallweit Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/Kconfig | 6 + drivers/staging/fbtft/Makefile | 1 + drivers/staging/fbtft/fb_hx8357d.c | 222 +++++++++++++++++++++++++++++ drivers/staging/fbtft/fb_hx8357d.h | 102 +++++++++++++ 4 files changed, 331 insertions(+) create mode 100644 drivers/staging/fbtft/fb_hx8357d.c create mode 100644 drivers/staging/fbtft/fb_hx8357d.h diff --git a/drivers/staging/fbtft/Kconfig b/drivers/staging/fbtft/Kconfig index 346f189d871a..d4018780ce58 100644 --- a/drivers/staging/fbtft/Kconfig +++ b/drivers/staging/fbtft/Kconfig @@ -38,6 +38,12 @@ config FB_TFT_HX8353D help Generic Framebuffer support for HX8353D +config FB_TFT_HX8357D + tristate "FB driver for the HX8357D LCD Controller" + depends on FB_TFT + help + Generic Framebuffer support for HX8357D + config FB_TFT_ILI9163 tristate "FB driver for the ILI9163 LCD Controller" depends on FB_TFT diff --git a/drivers/staging/fbtft/Makefile b/drivers/staging/fbtft/Makefile index 9e73beee23f4..554b5260b0ee 100644 --- a/drivers/staging/fbtft/Makefile +++ b/drivers/staging/fbtft/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_FB_TFT_BD663474) += fb_bd663474.o obj-$(CONFIG_FB_TFT_HX8340BN) += fb_hx8340bn.o obj-$(CONFIG_FB_TFT_HX8347D) += fb_hx8347d.o obj-$(CONFIG_FB_TFT_HX8353D) += fb_hx8353d.o +obj-$(CONFIG_FB_TFT_HX8357D) += fb_hx8357d.o obj-$(CONFIG_FB_TFT_ILI9163) += fb_ili9163.o obj-$(CONFIG_FB_TFT_ILI9320) += fb_ili9320.o obj-$(CONFIG_FB_TFT_ILI9325) += fb_ili9325.o diff --git a/drivers/staging/fbtft/fb_hx8357d.c b/drivers/staging/fbtft/fb_hx8357d.c new file mode 100644 index 000000000000..8c7bb3ac8030 --- /dev/null +++ b/drivers/staging/fbtft/fb_hx8357d.c @@ -0,0 +1,222 @@ +/* + * FB driver for the HX8357D LCD Controller + * Copyright (C) 2015 Adafruit Industries + * + * Based on the HX8347D FB driver + * Copyright (C) 2013 Christian Vogelgsang + * + * Based on driver code found here: https://github.com/watterott/r61505u-Adapter + * + * 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, see . + */ + +#include +#include +#include +#include + +#include "fbtft.h" +#include "fb_hx8357d.h" + +#define DRVNAME "fb_hx8357d" +#define WIDTH 320 +#define HEIGHT 480 + + +static int init_display(struct fbtft_par *par) +{ + fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__); + + par->fbtftops.reset(par); + + /* Reset things like Gamma */ + write_reg(par, HX8357B_SWRESET); + usleep_range(5000, 7000); + + /* setextc */ + write_reg(par, HX8357D_SETC, 0xFF, 0x83, 0x57); + msleep(150); + + /* setRGB which also enables SDO */ + write_reg(par, HX8357_SETRGB, 0x00, 0x00, 0x06, 0x06); + + /* -1.52V */ + write_reg(par, HX8357D_SETCOM, 0x25); + + /* Normal mode 70Hz, Idle mode 55 Hz */ + write_reg(par, HX8357_SETOSC, 0x68); + + /* Set Panel - BGR, Gate direction swapped */ + write_reg(par, HX8357_SETPANEL, 0x05); + + write_reg(par, HX8357_SETPWR1, + 0x00, /* Not deep standby */ + 0x15, /* BT */ + 0x1C, /* VSPR */ + 0x1C, /* VSNR */ + 0x83, /* AP */ + 0xAA); /* FS */ + + write_reg(par, HX8357D_SETSTBA, + 0x50, /* OPON normal */ + 0x50, /* OPON idle */ + 0x01, /* STBA */ + 0x3C, /* STBA */ + 0x1E, /* STBA */ + 0x08); /* GEN */ + + write_reg(par, HX8357D_SETCYC, + 0x02, /* NW 0x02 */ + 0x40, /* RTN */ + 0x00, /* DIV */ + 0x2A, /* DUM */ + 0x2A, /* DUM */ + 0x0D, /* GDON */ + 0x78); /* GDOFF */ + + write_reg(par, HX8357D_SETGAMMA, + 0x02, + 0x0A, + 0x11, + 0x1d, + 0x23, + 0x35, + 0x41, + 0x4b, + 0x4b, + 0x42, + 0x3A, + 0x27, + 0x1B, + 0x08, + 0x09, + 0x03, + 0x02, + 0x0A, + 0x11, + 0x1d, + 0x23, + 0x35, + 0x41, + 0x4b, + 0x4b, + 0x42, + 0x3A, + 0x27, + 0x1B, + 0x08, + 0x09, + 0x03, + 0x00, + 0x01); + + /* 16 bit */ + write_reg(par, HX8357_COLMOD, 0x55); + + write_reg(par, HX8357_MADCTL, 0xC0); + + /* TE off */ + write_reg(par, HX8357_TEON, 0x00); + + /* tear line */ + write_reg(par, HX8357_TEARLINE, 0x00, 0x02); + + /* Exit Sleep */ + write_reg(par, HX8357_SLPOUT); + msleep(150); + + /* display on */ + write_reg(par, HX8357_DISPON); + usleep_range(5000, 7000); + + return 0; +} + +static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye) +{ + fbtft_par_dbg(DEBUG_SET_ADDR_WIN, par, + "%s(xs=%d, ys=%d, xe=%d, ye=%d)\n", __func__, xs, ys, xe, ye); + + /* Column addr set */ + write_reg(par, HX8357_CASET, + xs >> 8, xs & 0xff, /* XSTART */ + xe >> 8, xe & 0xff); /* XEND */ + + /* Row addr set */ + write_reg(par, HX8357_PASET, + ys >> 8, ys & 0xff, /* YSTART */ + ye >> 8, ye & 0xff); /* YEND */ + + /* write to RAM */ + write_reg(par, HX8357_RAMWR); +} + +#define HX8357D_MADCTL_MY 0x80 +#define HX8357D_MADCTL_MX 0x40 +#define HX8357D_MADCTL_MV 0x20 +#define HX8357D_MADCTL_ML 0x10 +#define HX8357D_MADCTL_RGB 0x00 +#define HX8357D_MADCTL_BGR 0x08 +#define HX8357D_MADCTL_MH 0x04 +static int set_var(struct fbtft_par *par) +{ + u8 val; + + fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__); + + switch (par->info->var.rotate) { + case 270: + val = HX8357D_MADCTL_MV | HX8357D_MADCTL_MX; + break; + case 180: + val = 0; + break; + case 90: + val = HX8357D_MADCTL_MV | HX8357D_MADCTL_MY; + break; + default: + val = HX8357D_MADCTL_MX | HX8357D_MADCTL_MY; + break; + } + + val |= (par->bgr ? HX8357D_MADCTL_RGB : HX8357D_MADCTL_BGR); + + /* Memory Access Control */ + write_reg(par, HX8357_MADCTL, val); + + return 0; +} + +static struct fbtft_display display = { + .regwidth = 8, + .width = WIDTH, + .height = HEIGHT, + .gamma_num = 2, + .gamma_len = 14, + .fbtftops = { + .init_display = init_display, + .set_addr_win = set_addr_win, + .set_var = set_var, + }, +}; +FBTFT_REGISTER_DRIVER(DRVNAME, "himax,hx8357d", &display); + +MODULE_ALIAS("spi:" DRVNAME); +MODULE_ALIAS("platform:" DRVNAME); +MODULE_ALIAS("spi:hx8357d"); +MODULE_ALIAS("platform:hx8357d"); + +MODULE_DESCRIPTION("FB driver for the HX8357D LCD Controller"); +MODULE_AUTHOR("Sean Cross "); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/fbtft/fb_hx8357d.h b/drivers/staging/fbtft/fb_hx8357d.h new file mode 100644 index 000000000000..de05e8cdf04c --- /dev/null +++ b/drivers/staging/fbtft/fb_hx8357d.h @@ -0,0 +1,102 @@ +/*************************************************** + This is our library for the Adafruit ILI9341 Breakout and Shield + ----> http://www.adafruit.com/products/1651 + + Check out the links above for our tutorials and wiring diagrams + These displays use SPI to communicate, 4 or 5 pins are required to + interface (RST is optional) + Adafruit invests time and resources providing this open source code, + please support Adafruit and open-source hardware by purchasing + products from Adafruit! + + Written by Limor Fried/Ladyada for Adafruit Industries. + MIT license, all text above must be included in any redistribution + ****************************************************/ + +#ifndef __HX8357_H__ +#define __HX8357_H__ + +#define HX8357D 0xD +#define HX8357B 0xB + +#define HX8357_TFTWIDTH 320 +#define HX8357_TFTHEIGHT 480 + +#define HX8357B_NOP 0x00 +#define HX8357B_SWRESET 0x01 +#define HX8357B_RDDID 0x04 +#define HX8357B_RDDST 0x09 + +#define HX8357B_RDPOWMODE 0x0A +#define HX8357B_RDMADCTL 0x0B +#define HX8357B_RDCOLMOD 0x0C +#define HX8357B_RDDIM 0x0D +#define HX8357B_RDDSDR 0x0F + +#define HX8357_SLPIN 0x10 +#define HX8357_SLPOUT 0x11 +#define HX8357B_PTLON 0x12 +#define HX8357B_NORON 0x13 + +#define HX8357_INVOFF 0x20 +#define HX8357_INVON 0x21 +#define HX8357_DISPOFF 0x28 +#define HX8357_DISPON 0x29 + +#define HX8357_CASET 0x2A +#define HX8357_PASET 0x2B +#define HX8357_RAMWR 0x2C +#define HX8357_RAMRD 0x2E + +#define HX8357B_PTLAR 0x30 +#define HX8357_TEON 0x35 +#define HX8357_TEARLINE 0x44 +#define HX8357_MADCTL 0x36 +#define HX8357_COLMOD 0x3A + +#define HX8357_SETOSC 0xB0 +#define HX8357_SETPWR1 0xB1 +#define HX8357B_SETDISPLAY 0xB2 +#define HX8357_SETRGB 0xB3 +#define HX8357D_SETCOM 0xB6 + +#define HX8357B_SETDISPMODE 0xB4 +#define HX8357D_SETCYC 0xB4 +#define HX8357B_SETOTP 0xB7 +#define HX8357D_SETC 0xB9 + +#define HX8357B_SET_PANEL_DRIVING 0xC0 +#define HX8357D_SETSTBA 0xC0 +#define HX8357B_SETDGC 0xC1 +#define HX8357B_SETID 0xC3 +#define HX8357B_SETDDB 0xC4 +#define HX8357B_SETDISPLAYFRAME 0xC5 +#define HX8357B_GAMMASET 0xC8 +#define HX8357B_SETCABC 0xC9 +#define HX8357_SETPANEL 0xCC + +#define HX8357B_SETPOWER 0xD0 +#define HX8357B_SETVCOM 0xD1 +#define HX8357B_SETPWRNORMAL 0xD2 + +#define HX8357B_RDID1 0xDA +#define HX8357B_RDID2 0xDB +#define HX8357B_RDID3 0xDC +#define HX8357B_RDID4 0xDD + +#define HX8357D_SETGAMMA 0xE0 + +#define HX8357B_SETGAMMA 0xC8 +#define HX8357B_SETPANELRELATED 0xE9 + +/* Color definitions */ +#define HX8357_BLACK 0x0000 +#define HX8357_BLUE 0x001F +#define HX8357_RED 0xF800 +#define HX8357_GREEN 0x07E0 +#define HX8357_CYAN 0x07FF +#define HX8357_MAGENTA 0xF81F +#define HX8357_YELLOW 0xFFE0 +#define HX8357_WHITE 0xFFFF + +#endif /* __HX8357_H__ */ From c7ddc288ebf2aee890828cec26b4fb889a246330 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:20 +0200 Subject: [PATCH 0715/1163] staging: rtl8192e: accept const MAC address Make set_swcam, setKey and rtllib_probe_resp parameter (MAC address) const. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_cam.c | 4 ++-- drivers/staging/rtl8192e/rtl8192e/rtl_cam.h | 4 ++-- drivers/staging/rtl8192e/rtllib_softmac.c | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c index 41b025e250fe..0ffade4f42bd 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c @@ -81,7 +81,7 @@ void EnableHWSecurityConfig8192(struct net_device *dev) } void set_swcam(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, - u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh) + const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh) { struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; @@ -100,7 +100,7 @@ void set_swcam(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, } void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, - u8 *MacAddr, u8 DefaultKey, u32 *KeyContent) + const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent) { u32 TargetCommand = 0; u32 TargetContent = 0; diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h index 3c4c0e61c181..864a7f607bca 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h @@ -31,9 +31,9 @@ struct net_device; void CamResetAllEntry(struct net_device *dev); void EnableHWSecurityConfig8192(struct net_device *dev); void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, - u8 *MacAddr, u8 DefaultKey, u32 *KeyContent); + const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent); void set_swcam(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, - u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh); + const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh); void CamPrintDbgReg(struct net_device *dev); u32 read_cam(struct net_device *dev, u8 addr); diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 98afd3b557c7..cd758feac88c 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -832,7 +832,8 @@ inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon, return skb; } -static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) +static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee, + const u8 *dest) { u8 *tag; int beacon_size; From 06c111072892d3f5fed9d73d1becb59d3f33410b Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:21 +0200 Subject: [PATCH 0716/1163] staging: rtl8192e: Make ethernet addresses properly aligned Reorder ethernet addresses allocated on stack or in non-packed structures to keep them aligned(2). Use ETH_ALEN as array length in places where it was hardcoded to 6. Alignment verified using pahole where possible and target-tested with BUG_ON() trap in ether_addr_copy. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 3 +-- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 6 ++---- drivers/staging/rtl8192e/rtl8192e/rtl_wx.c | 4 ++-- drivers/staging/rtl8192e/rtl819x_Qos.h | 4 ++-- drivers/staging/rtl8192e/rtl819x_TS.h | 2 +- drivers/staging/rtl8192e/rtllib.h | 10 +++++----- drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 3 ++- drivers/staging/rtl8192e/rtllib_rx.c | 6 +++++- drivers/staging/rtl8192e/rtllib_softmac.c | 4 ++-- drivers/staging/rtl8192e/rtllib_tx.c | 3 ++- 10 files changed, 24 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c index aad5cc95c341..926fca790895 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c @@ -316,12 +316,11 @@ void rtl8192e_SetHwReg(struct net_device *dev, u8 variable, u8 *val) static void rtl8192_read_eeprom_info(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - + const u8 bMac_Tmp_Addr[ETH_ALEN] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01}; u8 tempval; u8 ICVer8192, ICVer8256; u16 i, usValue, IC_Version; u16 EEPROMId; - u8 bMac_Tmp_Addr[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01}; RT_TRACE(COMP_INIT, "====> rtl8192_read_eeprom_info\n"); diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 6d60ac47c8c5..6f339cd7ae3e 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -2573,8 +2573,7 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) int ret = -1; struct rtllib_device *ieee = priv->rtllib; u32 key[4]; - u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - u8 zero_addr[6] = {0}; + const u8 broadcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; struct iw_point *p = &wrq->u.data; struct ieee_param *ipw = NULL; @@ -2611,8 +2610,7 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) } if (ieee->pairwise_key_type) { - if (memcmp(ieee->ap_mac_addr, zero_addr, - 6) == 0) + if (is_zero_ether_addr(ieee->ap_mac_addr)) ieee->iw_mode = IW_MODE_ADHOC; memcpy((u8 *)key, ipw->u.crypt.key, 16); EnableHWSecurityConfig8192(dev); diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c index 8d6a109e023b..43702df399de 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c @@ -987,8 +987,8 @@ static int r8192_wx_set_enc_ext(struct net_device *dev, ret = rtllib_wx_set_encode_ext(ieee, info, wrqu, extra); { - u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - u8 zero[6] = {0}; + const u8 broadcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + const u8 zero[ETH_ALEN] = {0}; u32 key[4] = {0}; struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; struct iw_point *encoding = &wrqu->encoding; diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index 55ef7ec33f65..b3e7dae982a7 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -255,8 +255,8 @@ union qos_tclas { u8 Priority; u8 ClassifierType; u8 Mask; - u8 SrcAddr[6]; - u8 DstAddr[6]; + u8 SrcAddr[ETH_ALEN]; + u8 DstAddr[ETH_ALEN]; u16 Type; } TYPE0_ETH; diff --git a/drivers/staging/rtl8192e/rtl819x_TS.h b/drivers/staging/rtl8192e/rtl819x_TS.h index 8601b1ad217d..b3e721bf975c 100644 --- a/drivers/staging/rtl8192e/rtl819x_TS.h +++ b/drivers/staging/rtl8192e/rtl819x_TS.h @@ -35,7 +35,7 @@ struct ts_common_info { struct list_head List; struct timer_list SetupTimer; struct timer_list InactTimer; - u8 Addr[6]; + u8 Addr[ETH_ALEN]; union tspec_body TSpec; union qos_tclas TClass[TCLAS_NUM]; u8 TClasProc; diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index bfec4fde01d1..411363c5eb9a 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1531,7 +1531,7 @@ struct rtllib_network { u16 CcxRmState[2]; bool bMBssidValid; u8 MBssidMask; - u8 MBssid[6]; + u8 MBssid[ETH_ALEN]; bool bWithCcxVerNum; u8 BssCcxVerNumber; /* These are network statistics */ @@ -1866,7 +1866,7 @@ struct rt_link_detect { struct sw_cam_table { - u8 macaddr[6]; + u8 macaddr[ETH_ALEN]; bool bused; u8 key_buf[16]; u16 key_type; @@ -1912,10 +1912,10 @@ enum ratr_table_mode_8192s { #define NUM_PMKID_CACHE 16 struct rt_pmkid_list { - u8 bUsed; - u8 Bssid[6]; + u8 Bssid[ETH_ALEN]; u8 PMKID[16]; u8 SsidBuf[33]; + u8 bUsed; u8 *ssid_octet; u16 ssid_length; }; @@ -2083,7 +2083,7 @@ struct rtllib_device { u8 *wpa_ie; size_t wps_ie_len; u8 *wps_ie; - u8 ap_mac_addr[6]; + u8 ap_mac_addr[ETH_ALEN]; u16 pairwise_key_type; u16 group_key_type; diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c index 656b4b359c50..cdad066538bf 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c @@ -52,7 +52,8 @@ struct rtllib_tkip_data { struct crypto_blkcipher *tx_tfm_arc4; struct crypto_hash *tx_tfm_michael; /* scratch buffers for virt_to_page() (crypto API) */ - u8 rx_hdr[16], tx_hdr[16]; + u8 rx_hdr[16]; + u8 tx_hdr[16]; }; static void *rtllib_tkip_init(int key_idx) diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index bb789cc9208d..3228bfd1a5f6 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1258,7 +1258,11 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, struct rx_ts_record *pTS = NULL; u16 fc, sc, SeqNum = 0; u8 type, stype, multicast = 0, unicast = 0, nr_subframes = 0, TID = 0; - u8 dst[ETH_ALEN], src[ETH_ALEN], bssid[ETH_ALEN] = {0}, *payload; + u8 *payload; + u8 dst[ETH_ALEN]; + u8 src[ETH_ALEN]; + u8 bssid[ETH_ALEN] = {0}; + size_t hdrlen = 0; bool bToOtherSTA = false; int ret = 0, i = 0; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index cd758feac88c..051105d77a21 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1957,9 +1957,9 @@ static inline void rtllib_rx_auth_rq(struct rtllib_device *ieee, static inline void rtllib_rx_assoc_rq(struct rtllib_device *ieee, struct sk_buff *skb) { - u8 dest[ETH_ALEN]; + ieee->softmac_stats.rx_ass_rq++; if (assoc_rq_parse(skb, dest) != -1) rtllib_resp_to_assoc_rq(ieee, dest); @@ -2912,7 +2912,7 @@ exit: struct sk_buff *rtllib_get_beacon_(struct rtllib_device *ieee) { - u8 broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + const u8 broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; struct sk_buff *skb; struct rtllib_probe_response *b; diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index 3b159638bba2..b177d7b32198 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -579,8 +579,9 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) .seq_ctl = 0, .qos_ctl = 0 }; - u8 dest[ETH_ALEN], src[ETH_ALEN]; int qos_actived = ieee->current_network.qos_data.active; + u8 dest[ETH_ALEN]; + u8 src[ETH_ALEN]; struct lib80211_crypt_data *crypt = NULL; struct cb_desc *tcb_desc; u8 bIsMulticast = false; From b57ceb19aba7d40403ca985ec565db8db20f4331 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:22 +0200 Subject: [PATCH 0717/1163] staging: rtl8192e: Fix PREFER_ETHER_ADDR_COPY warnings Replace memcpy() with ether_addr_copy() where possible to make checkpatch.pl happy. Change was target tested (download 1Mb file over WPA2 network) with BUG trap for unaligned addresses in ether_addr_copy() Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192e/rtl8192e/r8192E_dev.c | 2 +- drivers/staging/rtl8192e/rtl819x_BAProc.c | 13 ++-- drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 19 +++--- drivers/staging/rtl8192e/rtllib_rx.c | 46 +++++++------ drivers/staging/rtl8192e/rtllib_softmac.c | 64 +++++++++---------- drivers/staging/rtl8192e/rtllib_softmac_wx.c | 4 +- drivers/staging/rtl8192e/rtllib_tx.c | 24 +++---- 7 files changed, 89 insertions(+), 83 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c index 926fca790895..f9c61530cf8a 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c @@ -382,7 +382,7 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) *(u16 *)(&dev->dev_addr[i]) = usValue; } } else { - memcpy(dev->dev_addr, bMac_Tmp_Addr, 6); + ether_addr_copy(dev->dev_addr, bMac_Tmp_Addr); } RT_TRACE(COMP_INIT, "Permanent Address = %pM\n", diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 26258ea8de4a..5b72bceb690b 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -18,6 +18,7 @@ ******************************************************************************/ #include #include +#include #include "rtllib.h" #include "rtl819x_BA.h" @@ -103,10 +104,10 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst, BAReq = (struct rtllib_hdr_3addr *)skb_put(skb, sizeof(struct rtllib_hdr_3addr)); - memcpy(BAReq->addr1, Dst, ETH_ALEN); - memcpy(BAReq->addr2, ieee->dev->dev_addr, ETH_ALEN); + ether_addr_copy(BAReq->addr1, Dst); + ether_addr_copy(BAReq->addr2, ieee->dev->dev_addr); - memcpy(BAReq->addr3, ieee->current_network.bssid, ETH_ALEN); + ether_addr_copy(BAReq->addr3, ieee->current_network.bssid); BAReq->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT); tag = (u8 *)skb_put(skb, 9); @@ -167,9 +168,9 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst, Delba = (struct rtllib_hdr_3addr *) skb_put(skb, sizeof(struct rtllib_hdr_3addr)); - memcpy(Delba->addr1, dst, ETH_ALEN); - memcpy(Delba->addr2, ieee->dev->dev_addr, ETH_ALEN); - memcpy(Delba->addr3, ieee->current_network.bssid, ETH_ALEN); + ether_addr_copy(Delba->addr1, dst); + ether_addr_copy(Delba->addr2, ieee->dev->dev_addr); + ether_addr_copy(Delba->addr3, ieee->current_network.bssid); Delba->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT); tag = (u8 *)skb_put(skb, 6); diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c index cdad066538bf..6b2047924777 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "rtllib.h" @@ -533,20 +534,20 @@ static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) switch (le16_to_cpu(hdr11->frame_ctl) & (RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS)) { case RTLLIB_FCTL_TODS: - memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */ - memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */ + ether_addr_copy(hdr, hdr11->addr3); /* DA */ + ether_addr_copy(hdr + ETH_ALEN, hdr11->addr2); /* SA */ break; case RTLLIB_FCTL_FROMDS: - memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */ - memcpy(hdr + ETH_ALEN, hdr11->addr3, ETH_ALEN); /* SA */ + ether_addr_copy(hdr, hdr11->addr1); /* DA */ + ether_addr_copy(hdr + ETH_ALEN, hdr11->addr3); /* SA */ break; case RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS: - memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */ - memcpy(hdr + ETH_ALEN, hdr11->addr4, ETH_ALEN); /* SA */ + ether_addr_copy(hdr, hdr11->addr3); /* DA */ + ether_addr_copy(hdr + ETH_ALEN, hdr11->addr4); /* SA */ break; case 0: - memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */ - memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */ + ether_addr_copy(hdr, hdr11->addr1); /* DA */ + ether_addr_copy(hdr + ETH_ALEN, hdr11->addr2); /* SA */ break; } @@ -599,7 +600,7 @@ static void rtllib_michael_mic_failure(struct net_device *dev, else ev.flags |= IW_MICFAILURE_PAIRWISE; ev.src_addr.sa_family = ARPHRD_ETHER; - memcpy(ev.src_addr.sa_data, hdr->addr2, ETH_ALEN); + ether_addr_copy(ev.src_addr.sa_data, hdr->addr2); memset(&wrqu, 0, sizeof(wrqu)); wrqu.data.length = sizeof(ev); wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev); diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 3228bfd1a5f6..bde80c8fa8d5 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -139,8 +139,8 @@ rtllib_frag_cache_get(struct rtllib_device *ieee, entry->seq = seq; entry->last_frag = frag; entry->skb = skb; - memcpy(entry->src_addr, hdr->addr2, ETH_ALEN); - memcpy(entry->dst_addr, hdr->addr1, ETH_ALEN); + ether_addr_copy(entry->src_addr, hdr->addr2); + ether_addr_copy(entry->dst_addr, hdr->addr1); } else { /* received a fragment of a frame for which the head fragment * should have already been received @@ -400,7 +400,7 @@ static int is_duplicate_packet(struct rtllib_device *ieee, if (!entry) return 0; - memcpy(entry->mac, mac, ETH_ALEN); + ether_addr_copy(entry->mac, mac); entry->seq_num[tid] = seq; entry->frag_num[tid] = frag; entry->packet_time[tid] = jiffies; @@ -927,24 +927,24 @@ static void rtllib_rx_extract_addr(struct rtllib_device *ieee, switch (fc & (RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS)) { case RTLLIB_FCTL_FROMDS: - memcpy(dst, hdr->addr1, ETH_ALEN); - memcpy(src, hdr->addr3, ETH_ALEN); - memcpy(bssid, hdr->addr2, ETH_ALEN); + ether_addr_copy(dst, hdr->addr1); + ether_addr_copy(src, hdr->addr3); + ether_addr_copy(bssid, hdr->addr2); break; case RTLLIB_FCTL_TODS: - memcpy(dst, hdr->addr3, ETH_ALEN); - memcpy(src, hdr->addr2, ETH_ALEN); - memcpy(bssid, hdr->addr1, ETH_ALEN); + ether_addr_copy(dst, hdr->addr3); + ether_addr_copy(src, hdr->addr2); + ether_addr_copy(bssid, hdr->addr1); break; case RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS: - memcpy(dst, hdr->addr3, ETH_ALEN); - memcpy(src, hdr->addr4, ETH_ALEN); - memcpy(bssid, ieee->current_network.bssid, ETH_ALEN); + ether_addr_copy(dst, hdr->addr3); + ether_addr_copy(src, hdr->addr4); + ether_addr_copy(bssid, ieee->current_network.bssid); break; case 0: - memcpy(dst, hdr->addr1, ETH_ALEN); - memcpy(src, hdr->addr2, ETH_ALEN); - memcpy(bssid, hdr->addr3, ETH_ALEN); + ether_addr_copy(dst, hdr->addr1); + ether_addr_copy(src, hdr->addr2); + ether_addr_copy(bssid, hdr->addr3); break; } } @@ -1218,15 +1218,19 @@ static void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee, * replace EtherType */ skb_pull(sub_skb, SNAP_SIZE); - memcpy(skb_push(sub_skb, ETH_ALEN), src, ETH_ALEN); - memcpy(skb_push(sub_skb, ETH_ALEN), dst, ETH_ALEN); + ether_addr_copy(skb_push(sub_skb, ETH_ALEN), + src); + ether_addr_copy(skb_push(sub_skb, ETH_ALEN), + dst); } else { u16 len; /* Leave Ethernet header part of hdr and full payload */ len = sub_skb->len; memcpy(skb_push(sub_skb, 2), &len, 2); - memcpy(skb_push(sub_skb, ETH_ALEN), src, ETH_ALEN); - memcpy(skb_push(sub_skb, ETH_ALEN), dst, ETH_ALEN); + ether_addr_copy(skb_push(sub_skb, ETH_ALEN), + src); + ether_addr_copy(skb_push(sub_skb, ETH_ALEN), + dst); } ieee->stats.rx_packets++; @@ -2050,7 +2054,7 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, if (network->MBssidMask != 0) { network->bMBssidValid = true; network->MBssidMask = 0xff << (network->MBssidMask); - memcpy(network->MBssid, network->bssid, ETH_ALEN); + ether_addr_copy(network->MBssid, network->bssid); network->MBssid[5] &= network->MBssidMask; } else { network->bMBssidValid = false; @@ -2210,7 +2214,7 @@ static inline int rtllib_network_init( memset(&network->qos_data, 0, sizeof(struct rtllib_qos_data)); /* Pull out fixed field data */ - memcpy(network->bssid, beacon->header.addr3, ETH_ALEN); + ether_addr_copy(network->bssid, beacon->header.addr3); network->capability = le16_to_cpu(beacon->capability); network->last_scanned = jiffies; network->time_stamp[0] = beacon->time_stamp[0]; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 051105d77a21..2f562de10071 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -372,7 +372,7 @@ static inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee) req->header.duration_id = 0; memset(req->header.addr1, 0xff, ETH_ALEN); - memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN); + ether_addr_copy(req->header.addr2, ieee->dev->dev_addr); memset(req->header.addr3, 0xff, ETH_ALEN); tag = (u8 *) skb_put(skb, len + 2 + rate_len); @@ -815,9 +815,9 @@ inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon, auth->header.frame_ctl |= cpu_to_le16(RTLLIB_FCTL_WEP); auth->header.duration_id = cpu_to_le16(0x013a); - memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); - memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN); + ether_addr_copy(auth->header.addr1, beacon->bssid); + ether_addr_copy(auth->header.addr2, ieee->dev->dev_addr); + ether_addr_copy(auth->header.addr3, beacon->bssid); if (ieee->auth_mode == 0) auth->algorithm = WLAN_AUTH_OPEN; else if (ieee->auth_mode == 1) @@ -909,9 +909,9 @@ static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee, beacon_buf = (struct rtllib_probe_response *) skb_put(skb, (beacon_size - ieee->tx_headroom)); - memcpy(beacon_buf->header.addr1, dest, ETH_ALEN); - memcpy(beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - memcpy(beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); + ether_addr_copy(beacon_buf->header.addr1, dest); + ether_addr_copy(beacon_buf->header.addr2, ieee->dev->dev_addr); + ether_addr_copy(beacon_buf->header.addr3, ieee->current_network.bssid); beacon_buf->header.duration_id = 0; beacon_buf->beacon_interval = @@ -1006,9 +1006,9 @@ static struct sk_buff *rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) skb_put(skb, sizeof(struct rtllib_assoc_response_frame)); assoc->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_ASSOC_RESP); - memcpy(assoc->header.addr1, dest, ETH_ALEN); - memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN); - memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN); + ether_addr_copy(assoc->header.addr1, dest); + ether_addr_copy(assoc->header.addr3, ieee->dev->dev_addr); + ether_addr_copy(assoc->header.addr2, ieee->dev->dev_addr); assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? WLAN_CAPABILITY_ESS : WLAN_CAPABILITY_IBSS); @@ -1063,9 +1063,9 @@ static struct sk_buff *rtllib_auth_resp(struct rtllib_device *ieee, int status, auth->transaction = cpu_to_le16(2); auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN); - memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN); - memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - memcpy(auth->header.addr1, dest, ETH_ALEN); + ether_addr_copy(auth->header.addr3, ieee->dev->dev_addr); + ether_addr_copy(auth->header.addr2, ieee->dev->dev_addr); + ether_addr_copy(auth->header.addr1, dest); auth->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_AUTH); return skb; @@ -1086,9 +1086,9 @@ static struct sk_buff *rtllib_null_func(struct rtllib_device *ieee, short pwr) hdr = (struct rtllib_hdr_3addr *)skb_put(skb, sizeof(struct rtllib_hdr_3addr)); - memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN); - memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN); - memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN); + ether_addr_copy(hdr->addr1, ieee->current_network.bssid); + ether_addr_copy(hdr->addr2, ieee->dev->dev_addr); + ether_addr_copy(hdr->addr3, ieee->current_network.bssid); hdr->frame_ctl = cpu_to_le16(RTLLIB_FTYPE_DATA | RTLLIB_STYPE_NULLFUNC | RTLLIB_FCTL_TODS | @@ -1113,8 +1113,8 @@ static struct sk_buff *rtllib_pspoll_func(struct rtllib_device *ieee) hdr = (struct rtllib_pspoll_hdr *)skb_put(skb, sizeof(struct rtllib_pspoll_hdr)); - memcpy(hdr->bssid, ieee->current_network.bssid, ETH_ALEN); - memcpy(hdr->ta, ieee->dev->dev_addr, ETH_ALEN); + ether_addr_copy(hdr->bssid, ieee->current_network.bssid); + ether_addr_copy(hdr->ta, ieee->dev->dev_addr); hdr->aid = cpu_to_le16(ieee->assoc_id | 0xc000); hdr->frame_ctl = cpu_to_le16(RTLLIB_FTYPE_CTL | RTLLIB_STYPE_PSPOLL | @@ -1266,11 +1266,11 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon, hdr->header.frame_ctl = RTLLIB_STYPE_ASSOC_REQ; hdr->header.duration_id = cpu_to_le16(37); - memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN); - memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN); + ether_addr_copy(hdr->header.addr1, beacon->bssid); + ether_addr_copy(hdr->header.addr2, ieee->dev->dev_addr); + ether_addr_copy(hdr->header.addr3, beacon->bssid); - memcpy(ieee->ap_mac_addr, beacon->bssid, ETH_ALEN); + ether_addr_copy(ieee->ap_mac_addr, beacon->bssid); hdr->capability = cpu_to_le16(WLAN_CAPABILITY_ESS); if (beacon->capability & WLAN_CAPABILITY_PRIVACY) @@ -1830,7 +1830,7 @@ static int auth_rq_parse(struct sk_buff *skb, u8 *dest) } a = (struct rtllib_authentication *) skb->data; - memcpy(dest, a->header.addr2, ETH_ALEN); + ether_addr_copy(dest, a->header.addr2); if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; @@ -1858,7 +1858,7 @@ static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb, if (bssid_match) return -1; - memcpy(src, header->addr2, ETH_ALEN); + ether_addr_copy(src, header->addr2); skbend = (u8 *)skb->data + skb->len; @@ -1897,7 +1897,7 @@ static int assoc_rq_parse(struct sk_buff *skb, u8 *dest) a = (struct rtllib_assoc_request_frame *) skb->data; - memcpy(dest, a->header.addr2, ETH_ALEN); + ether_addr_copy(dest, a->header.addr2); return 0; } @@ -2652,7 +2652,7 @@ void rtllib_start_master_bss(struct rtllib_device *ieee) ieee->ssid_set = 1; } - memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN); + ether_addr_copy(ieee->current_network.bssid, ieee->dev->dev_addr); ieee->set_chan(ieee->dev, ieee->current_network.channel); ieee->state = RTLLIB_LINKED; @@ -3519,9 +3519,9 @@ inline struct sk_buff *rtllib_disauth_skb(struct rtllib_network *beacon, disauth->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_DEAUTH); disauth->header.duration_id = 0; - memcpy(disauth->header.addr1, beacon->bssid, ETH_ALEN); - memcpy(disauth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - memcpy(disauth->header.addr3, beacon->bssid, ETH_ALEN); + ether_addr_copy(disauth->header.addr1, beacon->bssid); + ether_addr_copy(disauth->header.addr2, ieee->dev->dev_addr); + ether_addr_copy(disauth->header.addr3, beacon->bssid); disauth->reason = cpu_to_le16(asRsn); return skb; @@ -3546,9 +3546,9 @@ inline struct sk_buff *rtllib_disassociate_skb(struct rtllib_network *beacon, disass->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_DISASSOC); disass->header.duration_id = 0; - memcpy(disass->header.addr1, beacon->bssid, ETH_ALEN); - memcpy(disass->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - memcpy(disass->header.addr3, beacon->bssid, ETH_ALEN); + ether_addr_copy(disass->header.addr1, beacon->bssid); + ether_addr_copy(disass->header.addr2, ieee->dev->dev_addr); + ether_addr_copy(disass->header.addr3, beacon->bssid); disass->reason = cpu_to_le16(asRsn); return skb; diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c index 9715a793fd37..90c7bde38c8a 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c @@ -160,7 +160,7 @@ int rtllib_wx_set_wap(struct rtllib_device *ieee, if (is_zero_ether_addr(temp->sa_data)) { spin_lock_irqsave(&ieee->lock, flags); - memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); + ether_addr_copy(ieee->current_network.bssid, temp->sa_data); ieee->wap_set = 0; spin_unlock_irqrestore(&ieee->lock, flags); ret = -1; @@ -177,7 +177,7 @@ int rtllib_wx_set_wap(struct rtllib_device *ieee, spin_lock_irqsave(&ieee->lock, flags); ieee->cannot_notify = false; - memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); + ether_addr_copy(ieee->current_network.bssid, temp->sa_data); ieee->wap_set = !is_zero_ether_addr(temp->sa_data); spin_unlock_irqrestore(&ieee->lock, flags); diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index b177d7b32198..b09d5d00c27c 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -609,8 +609,8 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) goto success; } /* Save source and destination addresses */ - memcpy(dest, skb->data, ETH_ALEN); - memcpy(src, skb->data+ETH_ALEN, ETH_ALEN); + ether_addr_copy(dest, skb->data); + ether_addr_copy(src, skb->data + ETH_ALEN); memset(skb->cb, 0, sizeof(skb->cb)); ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto); @@ -695,22 +695,22 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) /* To DS: Addr1 = BSSID, Addr2 = SA, * Addr3 = DA */ - memcpy(&header.addr1, ieee->current_network.bssid, - ETH_ALEN); - memcpy(&header.addr2, &src, ETH_ALEN); + ether_addr_copy(header.addr1, + ieee->current_network.bssid); + ether_addr_copy(header.addr2, src); if (IsAmsdu) - memcpy(&header.addr3, - ieee->current_network.bssid, ETH_ALEN); + ether_addr_copy(header.addr3, + ieee->current_network.bssid); else - memcpy(&header.addr3, &dest, ETH_ALEN); + ether_addr_copy(header.addr3, dest); } else if (ieee->iw_mode == IW_MODE_ADHOC) { /* not From/To DS: Addr1 = DA, Addr2 = SA, * Addr3 = BSSID */ - memcpy(&header.addr1, dest, ETH_ALEN); - memcpy(&header.addr2, src, ETH_ALEN); - memcpy(&header.addr3, ieee->current_network.bssid, - ETH_ALEN); + ether_addr_copy(header.addr1, dest); + ether_addr_copy(header.addr2, src); + ether_addr_copy(header.addr3, + ieee->current_network.bssid); } bIsMulticast = is_multicast_ether_addr(header.addr1); From 80d2579d8608f5f7642776d8dc5c050a087f9d69 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:23 +0200 Subject: [PATCH 0718/1163] staging: rtl8192e: Fix DEEP_INDENTATION warning in rtllib_parse_info_param() Move MFIE_TYPE_GENERIC handler to rtllib_parse_mife_generic() function. Code was not altered significantly, therefore in some places it generates LONG_LINE checkpatch.pl warnings. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_rx.c | 397 ++++++++++++++------------- 1 file changed, 210 insertions(+), 187 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index bde80c8fa8d5..f8f192041d98 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1739,6 +1739,213 @@ static inline void rtllib_extract_country_ie( } +static void rtllib_parse_mife_generic(struct rtllib_device *ieee, + struct rtllib_info_element *info_element, + struct rtllib_network *network, + u16 *tmp_htcap_len, + u16 *tmp_htinfo_len) +{ + u16 ht_realtek_agg_len = 0; + u8 ht_realtek_agg_buf[MAX_IE_LEN]; + + if (!rtllib_parse_qos_info_param_IE(info_element, network)) + return; + if (info_element->len >= 4 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x50 && + info_element->data[2] == 0xf2 && + info_element->data[3] == 0x01) { + network->wpa_ie_len = min(info_element->len + 2, + MAX_WPA_IE_LEN); + memcpy(network->wpa_ie, info_element, network->wpa_ie_len); + return; + } + if (info_element->len == 7 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0xe0 && + info_element->data[2] == 0x4c && + info_element->data[3] == 0x01 && + info_element->data[4] == 0x02) + network->Turbo_Enable = 1; + + if (*tmp_htcap_len == 0) { + if (info_element->len >= 4 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x90 && + info_element->data[2] == 0x4c && + info_element->data[3] == 0x033) { + + *tmp_htcap_len = min_t(u8, info_element->len, + MAX_IE_LEN); + if (*tmp_htcap_len != 0) { + network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; + network->bssht.bdHTCapLen = min_t(u16, *tmp_htcap_len, sizeof(network->bssht.bdHTCapBuf)); + memcpy(network->bssht.bdHTCapBuf, + info_element->data, + network->bssht.bdHTCapLen); + } + } + if (*tmp_htcap_len != 0) { + network->bssht.bdSupportHT = true; + network->bssht.bdHT1R = ((((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->MCS[1]) == 0); + } else { + network->bssht.bdSupportHT = false; + network->bssht.bdHT1R = false; + } + } + + + if (*tmp_htinfo_len == 0) { + if (info_element->len >= 4 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x90 && + info_element->data[2] == 0x4c && + info_element->data[3] == 0x034) { + *tmp_htinfo_len = min_t(u8, info_element->len, + MAX_IE_LEN); + if (*tmp_htinfo_len != 0) { + network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; + network->bssht.bdHTInfoLen = min_t(u16, *tmp_htinfo_len, sizeof(network->bssht.bdHTInfoBuf)); + memcpy(network->bssht.bdHTInfoBuf, + info_element->data, + network->bssht.bdHTInfoLen); + } + + } + } + + if (ieee->aggregation) { + if (network->bssht.bdSupportHT) { + if (info_element->len >= 4 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0xe0 && + info_element->data[2] == 0x4c && + info_element->data[3] == 0x02) { + ht_realtek_agg_len = min_t(u8, + info_element->len, + MAX_IE_LEN); + memcpy(ht_realtek_agg_buf, + info_element->data, + info_element->len); + } + if (ht_realtek_agg_len >= 5) { + network->realtek_cap_exit = true; + network->bssht.bdRT2RTAggregation = true; + + if ((ht_realtek_agg_buf[4] == 1) && + (ht_realtek_agg_buf[5] & 0x02)) + network->bssht.bdRT2RTLongSlotTime = true; + + if ((ht_realtek_agg_buf[4] == 1) && + (ht_realtek_agg_buf[5] & RT_HT_CAP_USE_92SE)) + network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE; + } + } + if (ht_realtek_agg_len >= 5) { + if ((ht_realtek_agg_buf[5] & RT_HT_CAP_USE_SOFTAP)) + network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_SOFTAP; + } + } + + if ((info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x05 && + info_element->data[2] == 0xb5) || + (info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x0a && + info_element->data[2] == 0xf7) || + (info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x10 && + info_element->data[2] == 0x18)) { + network->broadcom_cap_exist = true; + } + if (info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x0c && + info_element->data[2] == 0x43) + network->ralink_cap_exist = true; + if ((info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x03 && + info_element->data[2] == 0x7f) || + (info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x13 && + info_element->data[2] == 0x74)) + network->atheros_cap_exist = true; + + if ((info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x50 && + info_element->data[2] == 0x43)) + network->marvell_cap_exist = true; + if (info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x40 && + info_element->data[2] == 0x96) + network->cisco_cap_exist = true; + + + if (info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x0a && + info_element->data[2] == 0xf5) + network->airgo_cap_exist = true; + + if (info_element->len > 4 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x40 && + info_element->data[2] == 0x96 && + info_element->data[3] == 0x01) { + if (info_element->len == 6) { + memcpy(network->CcxRmState, &info_element[4], 2); + if (network->CcxRmState[0] != 0) + network->bCcxRmEnable = true; + else + network->bCcxRmEnable = false; + network->MBssidMask = network->CcxRmState[1] & 0x07; + if (network->MBssidMask != 0) { + network->bMBssidValid = true; + network->MBssidMask = 0xff << (network->MBssidMask); + ether_addr_copy(network->MBssid, + network->bssid); + network->MBssid[5] &= network->MBssidMask; + } else { + network->bMBssidValid = false; + } + } else { + network->bCcxRmEnable = false; + } + } + if (info_element->len > 4 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x40 && + info_element->data[2] == 0x96 && + info_element->data[3] == 0x03) { + if (info_element->len == 5) { + network->bWithCcxVerNum = true; + network->BssCcxVerNumber = info_element->data[4]; + } else { + network->bWithCcxVerNum = false; + network->BssCcxVerNumber = 0; + } + } + if (info_element->len > 4 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x50 && + info_element->data[2] == 0xf2 && + info_element->data[3] == 0x04) { + RTLLIB_DEBUG_MGMT("MFIE_TYPE_WZC: %d bytes\n", + info_element->len); + network->wzc_ie_len = min(info_element->len+2, + MAX_WZC_IE_LEN); + memcpy(network->wzc_ie, info_element, + network->wzc_ie_len); + } +} + int rtllib_parse_info_param(struct rtllib_device *ieee, struct rtllib_info_element *info_element, u16 length, @@ -1749,8 +1956,6 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, short offset; u16 tmp_htcap_len = 0; u16 tmp_htinfo_len = 0; - u16 ht_realtek_agg_len = 0; - u8 ht_realtek_agg_buf[MAX_IE_LEN]; char rates_str[64]; char *p; @@ -1903,191 +2108,9 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, case MFIE_TYPE_GENERIC: RTLLIB_DEBUG_MGMT("MFIE_TYPE_GENERIC: %d bytes\n", info_element->len); - if (!rtllib_parse_qos_info_param_IE(info_element, - network)) - break; - if (info_element->len >= 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x50 && - info_element->data[2] == 0xf2 && - info_element->data[3] == 0x01) { - network->wpa_ie_len = min(info_element->len + 2, - MAX_WPA_IE_LEN); - memcpy(network->wpa_ie, info_element, - network->wpa_ie_len); - break; - } - if (info_element->len == 7 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0xe0 && - info_element->data[2] == 0x4c && - info_element->data[3] == 0x01 && - info_element->data[4] == 0x02) - network->Turbo_Enable = 1; - - if (tmp_htcap_len == 0) { - if (info_element->len >= 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x90 && - info_element->data[2] == 0x4c && - info_element->data[3] == 0x033) { - - tmp_htcap_len = min_t(u8, info_element->len, MAX_IE_LEN); - if (tmp_htcap_len != 0) { - network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; - network->bssht.bdHTCapLen = min_t(u16, tmp_htcap_len, sizeof(network->bssht.bdHTCapBuf)); - memcpy(network->bssht.bdHTCapBuf, info_element->data, network->bssht.bdHTCapLen); - } - } - if (tmp_htcap_len != 0) { - network->bssht.bdSupportHT = true; - network->bssht.bdHT1R = ((((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->MCS[1]) == 0); - } else { - network->bssht.bdSupportHT = false; - network->bssht.bdHT1R = false; - } - } - - - if (tmp_htinfo_len == 0) { - if (info_element->len >= 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x90 && - info_element->data[2] == 0x4c && - info_element->data[3] == 0x034) { - tmp_htinfo_len = min_t(u8, info_element->len, MAX_IE_LEN); - if (tmp_htinfo_len != 0) { - network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; - network->bssht.bdHTInfoLen = min_t(u16, tmp_htinfo_len, sizeof(network->bssht.bdHTInfoBuf)); - memcpy(network->bssht.bdHTInfoBuf, info_element->data, network->bssht.bdHTInfoLen); - } - - } - } - - if (ieee->aggregation) { - if (network->bssht.bdSupportHT) { - if (info_element->len >= 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0xe0 && - info_element->data[2] == 0x4c && - info_element->data[3] == 0x02) { - ht_realtek_agg_len = min_t(u8, info_element->len, MAX_IE_LEN); - memcpy(ht_realtek_agg_buf, info_element->data, info_element->len); - } - if (ht_realtek_agg_len >= 5) { - network->realtek_cap_exit = true; - network->bssht.bdRT2RTAggregation = true; - - if ((ht_realtek_agg_buf[4] == 1) && (ht_realtek_agg_buf[5] & 0x02)) - network->bssht.bdRT2RTLongSlotTime = true; - - if ((ht_realtek_agg_buf[4] == 1) && (ht_realtek_agg_buf[5] & RT_HT_CAP_USE_92SE)) - network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE; - } - } - if (ht_realtek_agg_len >= 5) { - if ((ht_realtek_agg_buf[5] & RT_HT_CAP_USE_SOFTAP)) - network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_SOFTAP; - } - } - - if ((info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x05 && - info_element->data[2] == 0xb5) || - (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x0a && - info_element->data[2] == 0xf7) || - (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x10 && - info_element->data[2] == 0x18)) { - network->broadcom_cap_exist = true; - } - if (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x0c && - info_element->data[2] == 0x43) - network->ralink_cap_exist = true; - if ((info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x03 && - info_element->data[2] == 0x7f) || - (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x13 && - info_element->data[2] == 0x74)) - network->atheros_cap_exist = true; - - if ((info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x50 && - info_element->data[2] == 0x43)) - network->marvell_cap_exist = true; - if (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x40 && - info_element->data[2] == 0x96) - network->cisco_cap_exist = true; - - - if (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x0a && - info_element->data[2] == 0xf5) - network->airgo_cap_exist = true; - - if (info_element->len > 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x40 && - info_element->data[2] == 0x96 && - info_element->data[3] == 0x01) { - if (info_element->len == 6) { - memcpy(network->CcxRmState, &info_element[4], 2); - if (network->CcxRmState[0] != 0) - network->bCcxRmEnable = true; - else - network->bCcxRmEnable = false; - network->MBssidMask = network->CcxRmState[1] & 0x07; - if (network->MBssidMask != 0) { - network->bMBssidValid = true; - network->MBssidMask = 0xff << (network->MBssidMask); - ether_addr_copy(network->MBssid, network->bssid); - network->MBssid[5] &= network->MBssidMask; - } else { - network->bMBssidValid = false; - } - } else { - network->bCcxRmEnable = false; - } - } - if (info_element->len > 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x40 && - info_element->data[2] == 0x96 && - info_element->data[3] == 0x03) { - if (info_element->len == 5) { - network->bWithCcxVerNum = true; - network->BssCcxVerNumber = info_element->data[4]; - } else { - network->bWithCcxVerNum = false; - network->BssCcxVerNumber = 0; - } - } - if (info_element->len > 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x50 && - info_element->data[2] == 0xf2 && - info_element->data[3] == 0x04) { - RTLLIB_DEBUG_MGMT("MFIE_TYPE_WZC: %d bytes\n", - info_element->len); - network->wzc_ie_len = min(info_element->len+2, - MAX_WZC_IE_LEN); - memcpy(network->wzc_ie, info_element, - network->wzc_ie_len); - } + rtllib_parse_mife_generic(ieee, info_element, network, + &tmp_htcap_len, + &tmp_htinfo_len); break; case MFIE_TYPE_RSN: From c2f8b4ab8c05398a08ec91c2958f62ebc55296f4 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:24 +0200 Subject: [PATCH 0719/1163] staging: rtl8192e: Replace memcmp() with ether_addr_equal() Use dedicated macro to compare ethernet addresses in probe_rq_parse(). Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_softmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 2f562de10071..5d69f98bf355 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1853,7 +1853,7 @@ static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb, return -1; /* corrupted */ bssid_match = - (memcmp(header->addr3, ieee->current_network.bssid, ETH_ALEN) != 0) && + (!ether_addr_equal(header->addr3, ieee->current_network.bssid)) && (!is_broadcast_ether_addr(header->addr3)); if (bssid_match) return -1; From 1af35de29f253f4421d779d55a441697f80e35fe Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:25 +0200 Subject: [PATCH 0720/1163] staging: rtl8192e: Remove rtllib_crypt.[ch] It is neither compiled nor used in rtl8192e. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_crypt.c | 254 ------------------------ drivers/staging/rtl8192e/rtllib_crypt.h | 34 ---- 2 files changed, 288 deletions(-) delete mode 100644 drivers/staging/rtl8192e/rtllib_crypt.c delete mode 100644 drivers/staging/rtl8192e/rtllib_crypt.h diff --git a/drivers/staging/rtl8192e/rtllib_crypt.c b/drivers/staging/rtl8192e/rtllib_crypt.c deleted file mode 100644 index 1e6ae9bead23..000000000000 --- a/drivers/staging/rtl8192e/rtllib_crypt.c +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Host AP crypto routines - * - * Copyright (c) 2002-2003, Jouni Malinen - * Portions Copyright (C) 2004, Intel Corporation - * - * 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. See README and COPYING for - * more details. - * - */ - -#include -#include -#include -#include -#include - -#include "rtllib.h" - -struct rtllib_crypto_alg { - struct list_head list; - struct lib80211_crypto_ops *ops; -}; - - -struct rtllib_crypto { - struct list_head algs; - spinlock_t lock; -}; - -static struct rtllib_crypto *hcrypt; - -void rtllib_crypt_deinit_entries(struct lib80211_crypt_info *info, - int force) -{ - struct list_head *ptr, *n; - struct lib80211_crypt_data *entry; - - for (ptr = info->crypt_deinit_list.next, n = ptr->next; - ptr != &info->crypt_deinit_list; ptr = n, n = ptr->next) { - entry = list_entry(ptr, struct lib80211_crypt_data, list); - - if (atomic_read(&entry->refcnt) != 0 && !force) - continue; - - list_del(ptr); - - if (entry->ops) - entry->ops->deinit(entry->priv); - kfree(entry); - } -} -EXPORT_SYMBOL(rtllib_crypt_deinit_entries); - -void rtllib_crypt_deinit_handler(unsigned long data) -{ - struct lib80211_crypt_info *info = (struct lib80211_crypt_info *)data; - unsigned long flags; - - spin_lock_irqsave(info->lock, flags); - rtllib_crypt_deinit_entries(info, 0); - if (!list_empty(&info->crypt_deinit_list)) { - printk(KERN_DEBUG - "%s: entries remaining in delayed crypt deletion list\n", - info->name); - info->crypt_deinit_timer.expires = jiffies + HZ; - add_timer(&info->crypt_deinit_timer); - } - spin_unlock_irqrestore(info->lock, flags); - -} -EXPORT_SYMBOL(rtllib_crypt_deinit_handler); - -void rtllib_crypt_delayed_deinit(struct lib80211_crypt_info *info, - struct lib80211_crypt_data **crypt) -{ - struct lib80211_crypt_data *tmp; - unsigned long flags; - - if (*crypt == NULL) - return; - - tmp = *crypt; - *crypt = NULL; - - /* must not run ops->deinit() while there may be pending encrypt or - * decrypt operations. Use a list of delayed deinits to avoid needing - * locking. - */ - - spin_lock_irqsave(info->lock, flags); - list_add(&tmp->list, &info->crypt_deinit_list); - if (!timer_pending(&info->crypt_deinit_timer)) { - info->crypt_deinit_timer.expires = jiffies + HZ; - add_timer(&info->crypt_deinit_timer); - } - spin_unlock_irqrestore(info->lock, flags); -} -EXPORT_SYMBOL(rtllib_crypt_delayed_deinit); - -int rtllib_register_crypto_ops(struct lib80211_crypto_ops *ops) -{ - unsigned long flags; - struct rtllib_crypto_alg *alg; - - if (hcrypt == NULL) - return -1; - - alg = kzalloc(sizeof(*alg), GFP_KERNEL); - if (alg == NULL) - return -ENOMEM; - - alg->ops = ops; - - spin_lock_irqsave(&hcrypt->lock, flags); - list_add(&alg->list, &hcrypt->algs); - spin_unlock_irqrestore(&hcrypt->lock, flags); - - printk(KERN_DEBUG "rtllib_crypt: registered algorithm '%s'\n", - ops->name); - - return 0; -} -EXPORT_SYMBOL(rtllib_register_crypto_ops); - -int rtllib_unregister_crypto_ops(struct lib80211_crypto_ops *ops) -{ - unsigned long flags; - struct list_head *ptr; - struct rtllib_crypto_alg *del_alg = NULL; - - if (hcrypt == NULL) - return -1; - - spin_lock_irqsave(&hcrypt->lock, flags); - for (ptr = hcrypt->algs.next; ptr != &hcrypt->algs; ptr = ptr->next) { - struct rtllib_crypto_alg *alg = - (struct rtllib_crypto_alg *) ptr; - if (alg->ops == ops) { - list_del(&alg->list); - del_alg = alg; - break; - } - } - spin_unlock_irqrestore(&hcrypt->lock, flags); - - if (del_alg) { - printk(KERN_DEBUG "rtllib_crypt: unregistered algorithm '%s'\n", - ops->name); - kfree(del_alg); - } - - return del_alg ? 0 : -1; -} -EXPORT_SYMBOL(rtllib_unregister_crypto_ops); - - -struct lib80211_crypto_ops *rtllib_get_crypto_ops(const char *name) -{ - unsigned long flags; - struct list_head *ptr; - struct rtllib_crypto_alg *found_alg = NULL; - - if (hcrypt == NULL) - return NULL; - - spin_lock_irqsave(&hcrypt->lock, flags); - for (ptr = hcrypt->algs.next; ptr != &hcrypt->algs; ptr = ptr->next) { - struct rtllib_crypto_alg *alg = - (struct rtllib_crypto_alg *) ptr; - if (strcmp(alg->ops->name, name) == 0) { - found_alg = alg; - break; - } - } - spin_unlock_irqrestore(&hcrypt->lock, flags); - - if (found_alg) - return found_alg->ops; - else - return NULL; -} -EXPORT_SYMBOL(rtllib_get_crypto_ops); - - -static void *rtllib_crypt_null_init(int keyidx) { return (void *) 1; } -static void rtllib_crypt_null_deinit(void *priv) {} - -static struct lib80211_crypto_ops rtllib_crypt_null = { - .name = "NULL", - .init = rtllib_crypt_null_init, - .deinit = rtllib_crypt_null_deinit, - .encrypt_mpdu = NULL, - .decrypt_mpdu = NULL, - .encrypt_msdu = NULL, - .decrypt_msdu = NULL, - .set_key = NULL, - .get_key = NULL, - .extra_mpdu_prefix_len = 0, - .extra_mpdu_postfix_len = 0, - .extra_msdu_prefix_len = 0, - .extra_msdu_postfix_len = 0, - .owner = THIS_MODULE, -}; - - -int __init rtllib_crypto_init(void) -{ - int ret = -ENOMEM; - - hcrypt = kzalloc(sizeof(*hcrypt), GFP_KERNEL); - if (!hcrypt) - goto out; - - INIT_LIST_HEAD(&hcrypt->algs); - spin_lock_init(&hcrypt->lock); - - ret = lib80211_register_crypto_ops(&rtllib_crypt_null); - if (ret < 0) { - kfree(hcrypt); - hcrypt = NULL; - } -out: - return ret; -} - - -void __exit rtllib_crypto_deinit(void) -{ - struct list_head *ptr, *n; - - if (hcrypt == NULL) - return; - - for (ptr = hcrypt->algs.next, n = ptr->next; ptr != &hcrypt->algs; - ptr = n, n = ptr->next) { - struct rtllib_crypto_alg *alg = - (struct rtllib_crypto_alg *) ptr; - list_del(ptr); - printk(KERN_DEBUG - "rtllib_crypt: unregistered algorithm '%s' (deinit)\n", - alg->ops->name); - kfree(alg); - } - - kfree(hcrypt); -} - -module_init(rtllib_crypto_init); -module_exit(rtllib_crypto_deinit); - -MODULE_LICENSE("GPL"); diff --git a/drivers/staging/rtl8192e/rtllib_crypt.h b/drivers/staging/rtl8192e/rtllib_crypt.h deleted file mode 100644 index b8cf59f39a60..000000000000 --- a/drivers/staging/rtl8192e/rtllib_crypt.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Original code based on Host AP (software wireless LAN access point) driver - * for Intersil Prism2/2.5/3. - * - * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen - * - * Copyright (c) 2002-2003, Jouni Malinen - * - * Adaption to a generic IEEE 802.11 stack by James Ketrenos - * - * - * Copyright (c) 2004, Intel Corporation - * - * 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. See README and COPYING for - * more details. - */ - -/* This file defines the interface to the rtllib crypto module. - */ -#ifndef RTLLIB_CRYPT_H -#define RTLLIB_CRYPT_H - -#include - -int rtllib_register_crypto_ops(struct lib80211_crypto_ops *ops); -int rtllib_unregister_crypto_ops(struct lib80211_crypto_ops *ops); -struct lib80211_crypto_ops *rtllib_get_crypto_ops(const char *name); -void rtllib_crypt_deinit_entries(struct lib80211_crypt_info *info, int force); -void rtllib_crypt_deinit_handler(unsigned long data); -void rtllib_crypt_delayed_deinit(struct lib80211_crypt_info *info, - struct lib80211_crypt_data **crypt); -#endif From 11e672c3e2d2a10189a6292678f5174597927076 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:26 +0200 Subject: [PATCH 0721/1163] staging: rtl8192e: Replace RTLLIB_DEBUG(DL_ERR) with netdev_*() Replace all RTLLIB_DEBUG(RTLLIB_DL_ERR, *) calls with netdev_err() for errors that really should be reported to user. Use netdev_warn() for the rest. Rephrase some of the messages to make them more readable/compact. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 79 ++++++++++---------- drivers/staging/rtl8192e/rtl819x_HTProc.c | 23 +++--- drivers/staging/rtl8192e/rtl819x_TSProc.c | 19 +++-- drivers/staging/rtl8192e/rtllib_rx.c | 15 +++- drivers/staging/rtl8192e/rtllib_softmac.c | 6 +- drivers/staging/rtl8192e/rtllib_softmac_wx.c | 6 +- 6 files changed, 75 insertions(+), 73 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 5b72bceb690b..7d72c19005f6 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -88,12 +88,12 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst, "========>%s(), frame(%d) sentd to: %pM, ieee->dev:%p\n", __func__, type, Dst, ieee->dev); if (pBA == NULL) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "pBA is NULL\n"); + netdev_warn(ieee->dev, "pBA is NULL\n"); return NULL; } skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr)); if (skb == NULL) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc skb for ADDBA_REQ\n"); + netdev_err(ieee->dev, "Can't alloc skb for ADDBA_REQ\n"); return NULL; } @@ -159,7 +159,7 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst, skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr)); if (skb == NULL) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc skb for ADDBA_REQ\n"); + netdev_err(ieee->dev, "Can't alloc skb for DELBA_REQ\n"); return NULL; } @@ -247,10 +247,9 @@ int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb) struct rx_ts_record *pTS = NULL; if (skb->len < sizeof(struct rtllib_hdr_3addr) + 9) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, - " Invalid skb len in BAREQ(%d / %d)\n", - (int)skb->len, - (int)(sizeof(struct rtllib_hdr_3addr) + 9)); + netdev_warn(ieee->dev, "Invalid skb len in BAREQ(%d / %d)\n", + (int)skb->len, + (int)(sizeof(struct rtllib_hdr_3addr) + 9)); return -1; } @@ -270,24 +269,24 @@ int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb) (ieee->pHTInfo->bCurrentHTSupport == false) || (ieee->pHTInfo->IOTAction & HT_IOT_ACT_REJECT_ADDBA_REQ)) { rc = ADDBA_STATUS_REFUSED; - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "Failed to reply on ADDBA_REQ as some capability is not ready(%d, %d)\n", - ieee->current_network.qos_data.active, - ieee->pHTInfo->bCurrentHTSupport); + netdev_warn(ieee->dev, + "Failed to reply on ADDBA_REQ as some capability is not ready(%d, %d)\n", + ieee->current_network.qos_data.active, + ieee->pHTInfo->bCurrentHTSupport); goto OnADDBAReq_Fail; } if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst, (u8)(pBaParamSet->field.TID), RX_DIR, true)) { rc = ADDBA_STATUS_REFUSED; - RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS in %s()\n", __func__); + netdev_warn(ieee->dev, "%s(): can't get TS\n", __func__); goto OnADDBAReq_Fail; } pBA = &pTS->RxAdmittedBARecord; if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) { rc = ADDBA_STATUS_INVALID_PARAM; - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "BA Policy is not correct in %s()\n", __func__); + netdev_warn(ieee->dev, "%s(): BA Policy is not correct\n", + __func__); goto OnADDBAReq_Fail; } @@ -334,10 +333,9 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb) u16 ReasonCode; if (skb->len < sizeof(struct rtllib_hdr_3addr) + 9) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "Invalid skb len in BARSP(%d / %d)\n", - (int)skb->len, - (int)(sizeof(struct rtllib_hdr_3addr) + 9)); + netdev_warn(ieee->dev, "Invalid skb len in BARSP(%d / %d)\n", + (int)skb->len, + (int)(sizeof(struct rtllib_hdr_3addr) + 9)); return -1; } rsp = (struct rtllib_hdr_3addr *)skb->data; @@ -353,11 +351,11 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb) if (ieee->current_network.qos_data.active == 0 || ieee->pHTInfo->bCurrentHTSupport == false || ieee->pHTInfo->bCurrentAMPDUEnable == false) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "reject to ADDBA_RSP as some capability is not ready(%d, %d, %d)\n", - ieee->current_network.qos_data.active, - ieee->pHTInfo->bCurrentHTSupport, - ieee->pHTInfo->bCurrentAMPDUEnable); + netdev_warn(ieee->dev, + "reject to ADDBA_RSP as some capability is not ready(%d, %d, %d)\n", + ieee->current_network.qos_data.active, + ieee->pHTInfo->bCurrentHTSupport, + ieee->pHTInfo->bCurrentAMPDUEnable); ReasonCode = DELBA_REASON_UNKNOWN_BA; goto OnADDBARsp_Reject; } @@ -365,7 +363,7 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb) if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst, (u8)(pBaParamSet->field.TID), TX_DIR, false)) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS in %s()\n", __func__); + netdev_warn(ieee->dev, "%s(): can't get TS\n", __func__); ReasonCode = DELBA_REASON_UNKNOWN_BA; goto OnADDBARsp_Reject; } @@ -381,8 +379,9 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb) return -1; } else if ((pPendingBA->bValid == false) || (*pDialogToken != pPendingBA->DialogToken)) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "OnADDBARsp(): Recv ADDBA Rsp. BA invalid, DELBA!\n"); + netdev_warn(ieee->dev, + "%s(): Recv ADDBA Rsp. BA invalid, DELBA!\n", + __func__); ReasonCode = DELBA_REASON_UNKNOWN_BA; goto OnADDBARsp_Reject; } else { @@ -435,19 +434,18 @@ int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb) u8 *dst = NULL; if (skb->len < sizeof(struct rtllib_hdr_3addr) + 6) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "Invalid skb len in DELBA(%d / %d)\n", - (int)skb->len, - (int)(sizeof(struct rtllib_hdr_3addr) + 6)); + netdev_warn(ieee->dev, "Invalid skb len in DELBA(%d / %d)\n", + (int)skb->len, + (int)(sizeof(struct rtllib_hdr_3addr) + 6)); return -1; } if (ieee->current_network.qos_data.active == 0 || ieee->pHTInfo->bCurrentHTSupport == false) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "received DELBA while QOS or HT is not supported(%d, %d)\n", - ieee->current_network. qos_data.active, - ieee->pHTInfo->bCurrentHTSupport); + netdev_warn(ieee->dev, + "received DELBA while QOS or HT is not supported(%d, %d)\n", + ieee->current_network. qos_data.active, + ieee->pHTInfo->bCurrentHTSupport); return -1; } @@ -463,10 +461,10 @@ int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb) if (!GetTs(ieee, (struct ts_common_info **)&pRxTs, dst, (u8)pDelBaParamSet->field.TID, RX_DIR, false)) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "can't get TS for RXTS in %s().dst: %pM TID:%d\n", - __func__, dst, - (u8)pDelBaParamSet->field.TID); + netdev_warn(ieee->dev, + "%s(): can't get TS for RXTS. dst:%pM TID:%d\n", + __func__, dst, + (u8)pDelBaParamSet->field.TID); return -1; } @@ -476,9 +474,8 @@ int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb) if (!GetTs(ieee, (struct ts_common_info **)&pTxTs, dst, (u8)pDelBaParamSet->field.TID, TX_DIR, false)) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "can't get TS for TXTS in %s()\n", - __func__); + netdev_warn(ieee->dev, "%s(): can't get TS for TXTS\n", + __func__); return -1; } diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index 7f103114d5d2..2c365d334573 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -291,8 +291,8 @@ void HTConstructCapabilityElement(struct rtllib_device *ieee, u8 *posHTCap, struct ht_capab_ele *pCapELE = NULL; if ((posHTCap == NULL) || (pHT == NULL)) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "posHTCap or pHTInfo can't be null in HTConstructCapabilityElement()\n"); + netdev_warn(ieee->dev, + "%s(): posHTCap and pHTInfo are null\n", __func__); return; } memset(posHTCap, 0, *len); @@ -373,8 +373,9 @@ void HTConstructInfoElement(struct rtllib_device *ieee, u8 *posHTInfo, struct ht_info_ele *pHTInfoEle = (struct ht_info_ele *)posHTInfo; if ((posHTInfo == NULL) || (pHTInfoEle == NULL)) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "posHTInfo or pHTInfoEle can't be null in HTConstructInfoElement()\n"); + netdev_warn(ieee->dev, + "%s(): posHTInfo and pHTInfoEle are null\n", + __func__); return; } @@ -413,8 +414,7 @@ void HTConstructRT2RTAggElement(struct rtllib_device *ieee, u8 *posRT2RTAgg, u8 *len) { if (posRT2RTAgg == NULL) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "posRT2RTAgg can't be null in HTConstructRT2RTAggElement()\n"); + netdev_warn(ieee->dev, "%s(): posRT2RTAgg is null\n", __func__); return; } memset(posRT2RTAgg, 0, *len); @@ -437,8 +437,7 @@ static u8 HT_PickMCSRate(struct rtllib_device *ieee, u8 *pOperateMCS) u8 i; if (pOperateMCS == NULL) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "pOperateMCS can't be null in HT_PickMCSRate()\n"); + netdev_warn(ieee->dev, "%s(): pOperateMCS is null\n", __func__); return false; } @@ -472,8 +471,9 @@ u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet, u8 availableMcsRate[16]; if (pMCSRateSet == NULL || pMCSFilter == NULL) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "pMCSRateSet or pMCSFilter can't be null in HTGetHighestMCSRate()\n"); + netdev_warn(ieee->dev, + "%s(): pMCSRateSet and pMCSFilter are null\n", + __func__); return false; } for (i = 0; i < 16; i++) @@ -538,8 +538,7 @@ void HTOnAssocRsp(struct rtllib_device *ieee) static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; if (pHTInfo->bCurrentHTSupport == false) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "<=== HTOnAssocRsp(): HT_DISABLE\n"); + netdev_warn(ieee->dev, "%s(): HT_DISABLE\n", __func__); return; } RTLLIB_DEBUG(RTLLIB_DL_HT, "===> HTOnAssocRsp_wq(): HT_ENABLE\n"); diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 7d77d056228d..974f03e02c26 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -78,8 +78,9 @@ static void RxPktPendingTimeout(unsigned long data) pRxTs->RxTimeoutIndicateSeq = 0xffff; if (index > REORDER_WIN_SIZE) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "RxReorderIndicatePacket(): Rx Reorder struct buffer full!!\n"); + netdev_warn(ieee->dev, + "%s(): Rx Reorder struct buffer full\n", + __func__); spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); return; @@ -318,17 +319,15 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, enum direction_value Dir; if (is_multicast_ether_addr(Addr)) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "ERR! get TS for Broadcast or Multicast\n"); + netdev_warn(ieee->dev, "Get TS for Broadcast or Multicast\n"); return false; } if (ieee->current_network.qos_data.supported == 0) { UP = 0; } else { if (!IsACValid(TID)) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "ERR! in %s(), TID(%d) is not valid\n", - __func__, TID); + netdev_warn(ieee->dev, "%s(): TID(%d) is not valid\n", + __func__, TID); return false; } @@ -413,9 +412,9 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, return true; } - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "ERR!!in function %s() There is not enough dir=%d(0=up down=1) TS record to be used!!", - __func__, Dir); + netdev_warn(ieee->dev, + "There is not enough dir=%d(0=up down=1) TS record to be used!", + Dir); return false; } diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index f8f192041d98..3dc05831d3ec 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -654,7 +654,9 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, * indicate all the packets in struct buffer and get * reorder entries. */ - RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): There is no reorder entry!! Packet is dropped!!\n"); + netdev_err(ieee->dev, + "%s(): There is no reorder entry! Packet is dropped!\n", + __func__); { int i; @@ -676,7 +678,9 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) { /* This protect struct buffer from overflow. */ if (index >= REORDER_WIN_SIZE) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Buffer overflow!!\n"); + netdev_err(ieee->dev, + "%s(): Buffer overflow!\n", + __func__); bPktInBuf = true; break; } @@ -707,7 +711,9 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, pTS->RxTimeoutIndicateSeq = 0xffff; if (index > REORDER_WIN_SIZE) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Rx Reorder struct buffer full!!\n"); + netdev_err(ieee->dev, + "%s(): Rx Reorder struct buffer full!\n", + __func__); spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); return; @@ -911,7 +917,8 @@ static int rtllib_rx_check_duplicate(struct rtllib_device *ieee, pRxTS->RxLastFragNum = frag; pRxTS->RxLastSeqNum = WLAN_GET_SEQ_SEQ(sc); } else { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR!!%s(): No TS!! Skip the check!!\n", __func__); + netdev_warn(ieee->dev, "%s(): No TS! Skip the check!\n", + __func__); return -1; } } diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 5d69f98bf355..4ce35259d5d6 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -2200,8 +2200,8 @@ static void rtllib_process_action(struct rtllib_device *ieee, struct sk_buff *sk u8 category = 0; if (act == NULL) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "error to get payload of action frame\n"); + netdev_warn(ieee->dev, + "Error getting payload of action frame\n"); return; } @@ -3074,7 +3074,7 @@ void rtllib_softmac_init(struct rtllib_device *ieee) ieee->seq_ctrl[i] = 0; ieee->pDot11dInfo = kzalloc(sizeof(struct rt_dot11d_info), GFP_ATOMIC); if (!ieee->pDot11dInfo) - RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc memory for DOT11D\n"); + netdev_err(ieee->dev, "Can't alloc memory for DOT11D\n"); ieee->LinkDetectInfo.SlotIndex = 0; ieee->LinkDetectInfo.SlotNum = 2; ieee->LinkDetectInfo.NumRecvBcnInPeriod = 0; diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c index 90c7bde38c8a..d5e13a57ab7a 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c @@ -575,9 +575,9 @@ int rtllib_wx_set_power(struct rtllib_device *ieee, if ((!ieee->sta_wake_up) || (!ieee->enter_sleep_state) || (!ieee->ps_is_queue_empty)) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "%s(): PS mode is tried to be use but driver missed a callback\n\n", - __func__); + netdev_warn(ieee->dev, + "%s(): PS mode is tried to be use but driver missed a callback\n", + __func__); return -1; } From f0dddb1d0240038b87d32578c3a12ff17e5d8adb Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:27 +0200 Subject: [PATCH 0722/1163] staging: rtl8192e: Remove RTLLIB_ERROR() and RTLLIB_WARNING() Use pr_* where needed (rtllib init code). Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 2 -- drivers/staging/rtl8192e/rtllib_module.c | 8 +++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 411363c5eb9a..42c37f83d968 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -701,8 +701,6 @@ do { \ #define RTLLIB_DL_TRACE (1<<29) #define RTLLIB_DL_DATA (1<<30) #define RTLLIB_DL_ERR (1<<31) -#define RTLLIB_ERROR(f, a...) pr_err("rtllib: " f, ## a) -#define RTLLIB_WARNING(f, a...) pr_warn("rtllib: " f, ## a) #define RTLLIB_DEBUG_INFO(f, a...) RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a) #define RTLLIB_DEBUG_WX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_WX, f, ## a) diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c index 32cc8df9d3a7..b8c7df501db7 100644 --- a/drivers/staging/rtl8192e/rtllib_module.c +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -107,7 +107,7 @@ struct net_device *alloc_rtllib(int sizeof_priv) dev = alloc_etherdev(sizeof(struct rtllib_device) + sizeof_priv); if (!dev) { - RTLLIB_ERROR("Unable to network device.\n"); + pr_err("Unable to allocate net_device.\n"); return NULL; } ieee = (struct rtllib_device *)netdev_priv_rsl(dev); @@ -116,8 +116,7 @@ struct net_device *alloc_rtllib(int sizeof_priv) err = rtllib_networks_allocate(ieee); if (err) { - RTLLIB_ERROR("Unable to allocate beacon storage: %d\n", - err); + pr_err("Unable to allocate beacon storage: %d\n", err); goto failed; } rtllib_networks_initialize(ieee); @@ -240,8 +239,7 @@ static int __init rtllib_init(void) rtllib_debug_level = debug; rtllib_proc = proc_mkdir(DRV_NAME, init_net.proc_net); if (rtllib_proc == NULL) { - RTLLIB_ERROR("Unable to create " DRV_NAME - " proc directory\n"); + pr_err("Unable to create " DRV_NAME " proc directory\n"); return -EIO; } e = proc_create("debug_level", S_IRUGO | S_IWUSR, rtllib_proc, &fops); From c6a91aba25eee95cdf371c6bd807ef559172f1d9 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:28 +0200 Subject: [PATCH 0723/1163] staging: rtl8192e: Remove RTLLIB_DEBUG_WX() Use netdev_dbg() instead of RTLLIB_DEBUG_WX(). Rewrite some messages to be more readable. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 1 - drivers/staging/rtl8192e/rtllib_wx.c | 33 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 42c37f83d968..392bcd516c51 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -703,7 +703,6 @@ do { \ #define RTLLIB_DL_ERR (1<<31) #define RTLLIB_DEBUG_INFO(f, a...) RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a) -#define RTLLIB_DEBUG_WX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_WX, f, ## a) #define RTLLIB_DEBUG_SCAN(f, a...) RTLLIB_DEBUG(RTLLIB_DL_SCAN, f, ## a) #define RTLLIB_DEBUG_STATE(f, a...) RTLLIB_DEBUG(RTLLIB_DL_STATE, f, ## a) #define RTLLIB_DEBUG_MGMT(f, a...) RTLLIB_DEBUG(RTLLIB_DL_MGMT, f, ## a) diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c index 6234aae5b069..c2c5f0d58811 100644 --- a/drivers/staging/rtl8192e/rtllib_wx.c +++ b/drivers/staging/rtl8192e/rtllib_wx.c @@ -266,7 +266,7 @@ int rtllib_wx_get_scan(struct rtllib_device *ieee, int i = 0; int err = 0; - RTLLIB_DEBUG_WX("Getting scan\n"); + netdev_dbg(ieee->dev, "Getting scan\n"); down(&ieee->wx_sem); spin_lock_irqsave(&ieee->lock, flags); @@ -293,7 +293,7 @@ int rtllib_wx_get_scan(struct rtllib_device *ieee, wrqu->data.length = ev - extra; wrqu->data.flags = 0; - RTLLIB_DEBUG_WX("exit: %d networks returned.\n", i); + netdev_dbg(ieee->dev, "%s(): %d networks returned.\n", __func__, i); return err; } @@ -311,7 +311,7 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee, int i, key, key_provided, len; struct lib80211_crypt_data **crypt; - RTLLIB_DEBUG_WX("SET_ENCODE\n"); + netdev_dbg(ieee->dev, "%s()\n", __func__); key = erq->flags & IW_ENCODE_INDEX; if (key) { @@ -324,16 +324,16 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee, key = ieee->crypt_info.tx_keyidx; } - RTLLIB_DEBUG_WX("Key: %d [%s]\n", key, key_provided ? + netdev_dbg(ieee->dev, "Key: %d [%s]\n", key, key_provided ? "provided" : "default"); crypt = &ieee->crypt_info.crypt[key]; if (erq->flags & IW_ENCODE_DISABLED) { if (key_provided && *crypt) { - RTLLIB_DEBUG_WX("Disabling encryption on key %d.\n", - key); + netdev_dbg(ieee->dev, + "Disabling encryption on key %d.\n", key); lib80211_crypt_delayed_deinit(&ieee->crypt_info, crypt); } else - RTLLIB_DEBUG_WX("Disabling encryption.\n"); + netdev_dbg(ieee->dev, "Disabling encryption.\n"); /* Check all the keys to see if any are still configured, * and if no key index was provided, de-init them all @@ -405,9 +405,9 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee, if (len > erq->length) memset(sec.keys[key] + erq->length, 0, len - erq->length); - RTLLIB_DEBUG_WX("Setting key %d to '%s' (%d:%d bytes)\n", - key, escape_essid(sec.keys[key], len), - erq->length, len); + netdev_dbg(ieee->dev, "Setting key %d to '%s' (%d:%d bytes)\n", + key, escape_essid(sec.keys[key], len), erq->length, + len); sec.key_sizes[key] = len; (*crypt)->ops->set_key(sec.keys[key], len, NULL, (*crypt)->priv); @@ -436,8 +436,8 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee, /* No key data - just set the default TX key index */ if (key_provided) { - RTLLIB_DEBUG_WX("Setting key %d to default Tx key.\n", - key); + netdev_dbg(ieee->dev, + "Setting key %d as default Tx key.\n", key); ieee->crypt_info.tx_keyidx = key; sec.active_key = key; sec.flags |= SEC_ACTIVE_KEY; @@ -449,7 +449,7 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee, WLAN_AUTH_SHARED_KEY; sec.auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; sec.flags |= SEC_AUTH_MODE; - RTLLIB_DEBUG_WX("Auth: %s\n", sec.auth_mode == WLAN_AUTH_OPEN ? + netdev_dbg(ieee->dev, "Auth: %s\n", sec.auth_mode == WLAN_AUTH_OPEN ? "OPEN" : "SHARED KEY"); /* For now we just support WEP, so only set that security level... @@ -485,7 +485,7 @@ int rtllib_wx_get_encode(struct rtllib_device *ieee, int len, key; struct lib80211_crypt_data *crypt; - RTLLIB_DEBUG_WX("GET_ENCODE\n"); + netdev_dbg(ieee->dev, "%s()\n", __func__); if (ieee->iw_mode == IW_MODE_MONITOR) return -1; @@ -592,8 +592,7 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, module = "rtllib_crypt_ccmp"; break; default: - RTLLIB_DEBUG_WX("%s: unknown crypto alg %d\n", - dev->name, ext->alg); + netdev_dbg(ieee->dev, "Unknown crypto alg %d\n", ext->alg); ret = -EINVAL; goto done; } @@ -673,7 +672,7 @@ done: if (ieee->reset_on_keychange && ieee->iw_mode != IW_MODE_INFRA && ieee->reset_port && ieee->reset_port(dev)) { - RTLLIB_DEBUG_WX("%s: reset_port failed\n", dev->name); + netdev_dbg(ieee->dev, "Port reset failed\n"); return -EINVAL; } return ret; From ad5c8e0586bfda28b086472e3336903ca1e4d3d2 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:29 +0200 Subject: [PATCH 0724/1163] staging: rtl8192e: Simplify rtllib_process_probe_response() - Extract frame_ctl once and use it as variable. - Drop endian conversion in is_beacon() function (used in simplified function only) - Simplify debug messages - Invert STYPE checks in debug messages - it is valid as only BEACON and PROBE_RESP are allowed Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_rx.c | 37 +++++++++++----------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 3dc05831d3ec..304404d3474d 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -2457,9 +2457,9 @@ static inline void update_network(struct rtllib_network *dst, dst->BssCcxVerNumber = src->BssCcxVerNumber; } -static inline int is_beacon(__le16 fc) +static inline int is_beacon(u16 fc) { - return (WLAN_FC_GET_STYPE(le16_to_cpu(fc)) == RTLLIB_STYPE_BEACON); + return (WLAN_FC_GET_STYPE(fc) == RTLLIB_STYPE_BEACON); } static int IsPassiveChannel(struct rtllib_device *rtllib, u8 channel) @@ -2500,6 +2500,7 @@ static inline void rtllib_process_probe_response( short renew; struct rtllib_network *network = kzalloc(sizeof(struct rtllib_network), GFP_ATOMIC); + u16 frame_ctl = le16_to_cpu(beacon->header.frame_ctl); if (!network) return; @@ -2528,12 +2529,9 @@ static inline void rtllib_process_probe_response( if (rtllib_network_init(ieee, beacon, network, stats)) { RTLLIB_DEBUG_SCAN("Dropped '%s' ( %pM) via %s.\n", escape_essid(info_element->data, - info_element->len), - beacon->header.addr3, - WLAN_FC_GET_STYPE( - le16_to_cpu(beacon->header.frame_ctl)) == - RTLLIB_STYPE_PROBE_RESP ? - "PROBE RESPONSE" : "BEACON"); + info_element->len), beacon->header.addr3, + is_beacon(frame_ctl) ? "BEACON" : + "PROBE RESPONSE"); goto free_network; } @@ -2541,8 +2539,7 @@ static inline void rtllib_process_probe_response( if (!rtllib_legal_channel(ieee, network->channel)) goto free_network; - if (WLAN_FC_GET_STYPE(le16_to_cpu(beacon->header.frame_ctl)) == - RTLLIB_STYPE_PROBE_RESP) { + if (WLAN_FC_GET_STYPE(frame_ctl) == RTLLIB_STYPE_PROBE_RESP) { if (IsPassiveChannel(ieee, network->channel)) { netdev_info(ieee->dev, "GetScanInfo(): For Global Domain, filter probe response at channel(%d).\n", @@ -2575,7 +2572,7 @@ static inline void rtllib_process_probe_response( else ieee->current_network.buseprotection = false; } - if (is_beacon(beacon->header.frame_ctl)) { + if (is_beacon(frame_ctl)) { if (ieee->state >= RTLLIB_LINKED) ieee->LinkDetectInfo.NumRecvBcnInPeriod++; } @@ -2612,22 +2609,18 @@ static inline void rtllib_process_probe_response( RTLLIB_DEBUG_SCAN("Adding '%s' ( %pM) via %s.\n", escape_essid(network->ssid, network->ssid_len), network->bssid, - WLAN_FC_GET_STYPE( - le16_to_cpu(beacon->header.frame_ctl)) == - RTLLIB_STYPE_PROBE_RESP ? - "PROBE RESPONSE" : "BEACON"); + is_beacon(frame_ctl) ? "BEACON" : + "PROBE RESPONSE"); memcpy(target, network, sizeof(*target)); list_add_tail(&target->list, &ieee->network_list); if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) rtllib_softmac_new_net(ieee, network); } else { RTLLIB_DEBUG_SCAN("Updating '%s' ( %pM) via %s.\n", - escape_essid(target->ssid, - target->ssid_len), target->bssid, - WLAN_FC_GET_STYPE( - le16_to_cpu(beacon->header.frame_ctl)) == - RTLLIB_STYPE_PROBE_RESP ? - "PROBE RESPONSE" : "BEACON"); + escape_essid(target->ssid, target->ssid_len), + target->bssid, + is_beacon(frame_ctl) ? "BEACON" : + "PROBE RESPONSE"); /* we have an entry and we are going to update it. But this * entry may be already expired. In this case we do the same @@ -2648,7 +2641,7 @@ static inline void rtllib_process_probe_response( } spin_unlock_irqrestore(&ieee->lock, flags); - if (is_beacon(beacon->header.frame_ctl) && + if (is_beacon(frame_ctl) && is_same_network(&ieee->current_network, network, (network->ssid_len ? 1 : 0)) && (ieee->state == RTLLIB_LINKED)) { From 521a9cbdb27142d7b9a166810807af010dcf6181 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:30 +0200 Subject: [PATCH 0725/1163] staging: rtl8192e: Remove RTLLIB_DEBUG_SCAN() Use netdev_dbg() instead, remove duplicated logs. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 1 - drivers/staging/rtl8192e/rtllib_rx.c | 101 +++++++++++++-------------- drivers/staging/rtl8192e/rtllib_wx.c | 12 ++-- 3 files changed, 54 insertions(+), 60 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 392bcd516c51..6481919b334e 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -703,7 +703,6 @@ do { \ #define RTLLIB_DL_ERR (1<<31) #define RTLLIB_DEBUG_INFO(f, a...) RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a) -#define RTLLIB_DEBUG_SCAN(f, a...) RTLLIB_DEBUG(RTLLIB_DL_SCAN, f, ## a) #define RTLLIB_DEBUG_STATE(f, a...) RTLLIB_DEBUG(RTLLIB_DL_STATE, f, ## a) #define RTLLIB_DEBUG_MGMT(f, a...) RTLLIB_DEBUG(RTLLIB_DL_MGMT, f, ## a) #define RTLLIB_DEBUG_FRAG(f, a...) RTLLIB_DEBUG(RTLLIB_DL_FRAG, f, ## a) diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 304404d3474d..a6dde350fc9b 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -2130,8 +2130,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, break; case MFIE_TYPE_HT_CAP: - RTLLIB_DEBUG_SCAN("MFIE_TYPE_HT_CAP: %d bytes\n", - info_element->len); + netdev_dbg(ieee->dev, "MFIE_TYPE_HT_CAP: %d bytes\n", + info_element->len); tmp_htcap_len = min_t(u8, info_element->len, MAX_IE_LEN); if (tmp_htcap_len != 0) { network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; @@ -2157,8 +2157,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, case MFIE_TYPE_HT_INFO: - RTLLIB_DEBUG_SCAN("MFIE_TYPE_HT_INFO: %d bytes\n", - info_element->len); + netdev_dbg(ieee->dev, "MFIE_TYPE_HT_INFO: %d bytes\n", + info_element->len); tmp_htinfo_len = min_t(u8, info_element->len, MAX_IE_LEN); if (tmp_htinfo_len) { network->bssht.bdHTSpecVer = HT_SPEC_VER_IEEE; @@ -2173,8 +2173,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, break; case MFIE_TYPE_AIRONET: - RTLLIB_DEBUG_SCAN("MFIE_TYPE_AIRONET: %d bytes\n", - info_element->len); + netdev_dbg(ieee->dev, "MFIE_TYPE_AIRONET: %d bytes\n", + info_element->len); if (info_element->len > IE_CISCO_FLAG_POSITION) { network->bWithAironetIE = true; @@ -2196,8 +2196,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, break; case MFIE_TYPE_COUNTRY: - RTLLIB_DEBUG_SCAN("MFIE_TYPE_COUNTRY: %d bytes\n", - info_element->len); + netdev_dbg(ieee->dev, "MFIE_TYPE_COUNTRY: %d bytes\n", + info_element->len); rtllib_extract_country_ie(ieee, info_element, network, network->bssid); break; @@ -2304,10 +2304,9 @@ static inline int rtllib_network_init( } if (network->mode == 0) { - RTLLIB_DEBUG_SCAN("Filtered out '%s (%pM)' network.\n", - escape_essid(network->ssid, - network->ssid_len), - network->bssid); + netdev_dbg(ieee->dev, "Filtered out '%s (%pM)' network.\n", + escape_essid(network->ssid, network->ssid_len), + network->bssid); return 1; } @@ -2505,33 +2504,32 @@ static inline void rtllib_process_probe_response( if (!network) return; - RTLLIB_DEBUG_SCAN( - "'%s' ( %pM ): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n", - escape_essid(info_element->data, info_element->len), - beacon->header.addr3, - (le16_to_cpu(beacon->capability) & (1<<0xf)) ? '1' : '0', - (le16_to_cpu(beacon->capability) & (1<<0xe)) ? '1' : '0', - (le16_to_cpu(beacon->capability) & (1<<0xd)) ? '1' : '0', - (le16_to_cpu(beacon->capability) & (1<<0xc)) ? '1' : '0', - (le16_to_cpu(beacon->capability) & (1<<0xb)) ? '1' : '0', - (le16_to_cpu(beacon->capability) & (1<<0xa)) ? '1' : '0', - (le16_to_cpu(beacon->capability) & (1<<0x9)) ? '1' : '0', - (le16_to_cpu(beacon->capability) & (1<<0x8)) ? '1' : '0', - (le16_to_cpu(beacon->capability) & (1<<0x7)) ? '1' : '0', - (le16_to_cpu(beacon->capability) & (1<<0x6)) ? '1' : '0', - (le16_to_cpu(beacon->capability) & (1<<0x5)) ? '1' : '0', - (le16_to_cpu(beacon->capability) & (1<<0x4)) ? '1' : '0', - (le16_to_cpu(beacon->capability) & (1<<0x3)) ? '1' : '0', - (le16_to_cpu(beacon->capability) & (1<<0x2)) ? '1' : '0', - (le16_to_cpu(beacon->capability) & (1<<0x1)) ? '1' : '0', - (le16_to_cpu(beacon->capability) & (1<<0x0)) ? '1' : '0'); + netdev_dbg(ieee->dev, + "'%s' ( %pM ): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n", + escape_essid(info_element->data, info_element->len), + beacon->header.addr3, + (le16_to_cpu(beacon->capability) & (1<<0xf)) ? '1' : '0', + (le16_to_cpu(beacon->capability) & (1<<0xe)) ? '1' : '0', + (le16_to_cpu(beacon->capability) & (1<<0xd)) ? '1' : '0', + (le16_to_cpu(beacon->capability) & (1<<0xc)) ? '1' : '0', + (le16_to_cpu(beacon->capability) & (1<<0xb)) ? '1' : '0', + (le16_to_cpu(beacon->capability) & (1<<0xa)) ? '1' : '0', + (le16_to_cpu(beacon->capability) & (1<<0x9)) ? '1' : '0', + (le16_to_cpu(beacon->capability) & (1<<0x8)) ? '1' : '0', + (le16_to_cpu(beacon->capability) & (1<<0x7)) ? '1' : '0', + (le16_to_cpu(beacon->capability) & (1<<0x6)) ? '1' : '0', + (le16_to_cpu(beacon->capability) & (1<<0x5)) ? '1' : '0', + (le16_to_cpu(beacon->capability) & (1<<0x4)) ? '1' : '0', + (le16_to_cpu(beacon->capability) & (1<<0x3)) ? '1' : '0', + (le16_to_cpu(beacon->capability) & (1<<0x2)) ? '1' : '0', + (le16_to_cpu(beacon->capability) & (1<<0x1)) ? '1' : '0', + (le16_to_cpu(beacon->capability) & (1<<0x0)) ? '1' : '0'); if (rtllib_network_init(ieee, beacon, network, stats)) { - RTLLIB_DEBUG_SCAN("Dropped '%s' ( %pM) via %s.\n", - escape_essid(info_element->data, - info_element->len), beacon->header.addr3, - is_beacon(frame_ctl) ? "BEACON" : - "PROBE RESPONSE"); + netdev_dbg(ieee->dev, "Dropped '%s' ( %pM) via %s.\n", + escape_essid(info_element->data, info_element->len), + beacon->header.addr3, + is_beacon(frame_ctl) ? "BEACON" : "PROBE RESPONSE"); goto free_network; } @@ -2594,10 +2592,10 @@ static inline void rtllib_process_probe_response( /* If there are no more slots, expire the oldest */ list_del(&oldest->list); target = oldest; - RTLLIB_DEBUG_SCAN("Expired '%s' ( %pM) from network list.\n", - escape_essid(target->ssid, - target->ssid_len), - target->bssid); + netdev_dbg(ieee->dev, + "Expired '%s' ( %pM) from network list.\n", + escape_essid(target->ssid, target->ssid_len), + target->bssid); } else { /* Otherwise just pull from the free list */ target = list_entry(ieee->network_free_list.next, @@ -2605,22 +2603,20 @@ static inline void rtllib_process_probe_response( list_del(ieee->network_free_list.next); } + netdev_dbg(ieee->dev, "Adding '%s' ( %pM) via %s.\n", + escape_essid(network->ssid, network->ssid_len), + network->bssid, + is_beacon(frame_ctl) ? "BEACON" : "PROBE RESPONSE"); - RTLLIB_DEBUG_SCAN("Adding '%s' ( %pM) via %s.\n", - escape_essid(network->ssid, - network->ssid_len), network->bssid, - is_beacon(frame_ctl) ? "BEACON" : - "PROBE RESPONSE"); memcpy(target, network, sizeof(*target)); list_add_tail(&target->list, &ieee->network_list); if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) rtllib_softmac_new_net(ieee, network); } else { - RTLLIB_DEBUG_SCAN("Updating '%s' ( %pM) via %s.\n", - escape_essid(target->ssid, target->ssid_len), - target->bssid, - is_beacon(frame_ctl) ? "BEACON" : - "PROBE RESPONSE"); + netdev_dbg(ieee->dev, "Updating '%s' ( %pM) via %s.\n", + escape_essid(target->ssid, target->ssid_len), + target->bssid, + is_beacon(frame_ctl) ? "BEACON" : "PROBE RESPONSE"); /* we have an entry and we are going to update it. But this * entry may be already expired. In this case we do the same @@ -2670,7 +2666,6 @@ void rtllib_rx_mgt(struct rtllib_device *ieee, case RTLLIB_STYPE_BEACON: RTLLIB_DEBUG_MGMT("received BEACON (%d)\n", WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl))); - RTLLIB_DEBUG_SCAN("Beacon\n"); rtllib_process_probe_response( ieee, (struct rtllib_probe_response *)header, stats); @@ -2685,7 +2680,6 @@ void rtllib_rx_mgt(struct rtllib_device *ieee, case RTLLIB_STYPE_PROBE_RESP: RTLLIB_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl))); - RTLLIB_DEBUG_SCAN("Probe response\n"); rtllib_process_probe_response(ieee, (struct rtllib_probe_response *)header, stats); break; @@ -2693,7 +2687,6 @@ void rtllib_rx_mgt(struct rtllib_device *ieee, RTLLIB_DEBUG_MGMT("received PROBE RESQUEST (%d)\n", WLAN_FC_GET_STYPE( le16_to_cpu(header->frame_ctl))); - RTLLIB_DEBUG_SCAN("Probe request\n"); if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && ((ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) && diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c index c2c5f0d58811..2812a777d0f1 100644 --- a/drivers/staging/rtl8192e/rtllib_wx.c +++ b/drivers/staging/rtl8192e/rtllib_wx.c @@ -281,11 +281,13 @@ int rtllib_wx_get_scan(struct rtllib_device *ieee, ev = rtl819x_translate_scan(ieee, ev, stop, network, info); else - RTLLIB_DEBUG_SCAN("Not showing network '%s ( %pM)' due to age (%lums).\n", - escape_essid(network->ssid, - network->ssid_len), - network->bssid, - (jiffies - network->last_scanned) / (HZ / 100)); + netdev_dbg(ieee->dev, + "Network '%s ( %pM)' hidden due to age (%lums).\n", + escape_essid(network->ssid, + network->ssid_len), + network->bssid, + (jiffies - network->last_scanned) / + (HZ / 100)); } spin_unlock_irqrestore(&ieee->lock, flags); From e77c752f3917c4d3cec864e3354c0a64fdeba03e Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:31 +0200 Subject: [PATCH 0726/1163] staging: rtl8192e: Remove RTLLIB_DEBUG_(FRAG|EAP|DROP|STATE|TX|RX)() Use netdev_dbg() instead. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 6 --- drivers/staging/rtl8192e/rtllib_rx.c | 58 +++++++++++++++------------- drivers/staging/rtl8192e/rtllib_tx.c | 5 ++- 3 files changed, 35 insertions(+), 34 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 6481919b334e..b20090d39770 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -703,13 +703,7 @@ do { \ #define RTLLIB_DL_ERR (1<<31) #define RTLLIB_DEBUG_INFO(f, a...) RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a) -#define RTLLIB_DEBUG_STATE(f, a...) RTLLIB_DEBUG(RTLLIB_DL_STATE, f, ## a) #define RTLLIB_DEBUG_MGMT(f, a...) RTLLIB_DEBUG(RTLLIB_DL_MGMT, f, ## a) -#define RTLLIB_DEBUG_FRAG(f, a...) RTLLIB_DEBUG(RTLLIB_DL_FRAG, f, ## a) -#define RTLLIB_DEBUG_EAP(f, a...) RTLLIB_DEBUG(RTLLIB_DL_EAP, f, ## a) -#define RTLLIB_DEBUG_DROP(f, a...) RTLLIB_DEBUG(RTLLIB_DL_DROP, f, ## a) -#define RTLLIB_DEBUG_TX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_TX, f, ## a) -#define RTLLIB_DEBUG_RX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_RX, f, ## a) #define RTLLIB_DEBUG_QOS(f, a...) RTLLIB_DEBUG(RTLLIB_DL_QOS, f, ## a) #ifndef ETH_P_PAE diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index a6dde350fc9b..8ea3e2fa5042 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -69,9 +69,9 @@ rtllib_frag_cache_find(struct rtllib_device *ieee, unsigned int seq, entry = &ieee->frag_cache[tid][i]; if (entry->skb != NULL && time_after(jiffies, entry->first_frag_time + 2 * HZ)) { - RTLLIB_DEBUG_FRAG( - "expiring fragment cache entry seq=%u last_frag=%u\n", - entry->seq, entry->last_frag); + netdev_dbg(ieee->dev, + "expiring fragment cache entry seq=%u last_frag=%u\n", + entry->seq, entry->last_frag); dev_kfree_skb_any(entry->skb); entry->skb = NULL; } @@ -187,8 +187,9 @@ static int rtllib_frag_cache_invalidate(struct rtllib_device *ieee, hdr->addr1); if (entry == NULL) { - RTLLIB_DEBUG_FRAG( - "could not invalidate fragment cache entry (seq=%u)\n", seq); + netdev_dbg(ieee->dev, + "Couldn't invalidate fragment cache entry (seq=%u)\n", + seq); return -1; } @@ -305,11 +306,12 @@ rtllib_rx_frame_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv); atomic_dec(&crypt->refcnt); if (res < 0) { - RTLLIB_DEBUG_DROP( - "decryption failed (SA= %pM) res=%d\n", hdr->addr2, res); + netdev_dbg(ieee->dev, "decryption failed (SA= %pM) res=%d\n", + hdr->addr2, res); if (res == -2) - RTLLIB_DEBUG_DROP("Decryption failed ICV mismatch (key %d)\n", - skb->data[hdrlen + 3] >> 6); + netdev_dbg(ieee->dev, + "Decryption failed ICV mismatch (key %d)\n", + skb->data[hdrlen + 3] >> 6); ieee->ieee_stats.rx_discards_undecryptable++; return -1; } @@ -840,7 +842,8 @@ static u8 parse_subframe(struct rtllib_device *ieee, struct sk_buff *skb, sub_skb->dev = ieee->dev; rxb->subframes[rxb->nr_subframes++] = sub_skb; if (rxb->nr_subframes >= MAX_SUBFRAME_COUNT) { - RTLLIB_DEBUG_RX("ParseSubframe(): Too many Subframes! Packets dropped!\n"); + netdev_dbg(ieee->dev, + "ParseSubframe(): Too many Subframes! Packets dropped!\n"); break; } skb_pull(skb, nSubframe_Length); @@ -991,9 +994,9 @@ static int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, stype != RTLLIB_STYPE_DATA_CFACKPOLL && stype != RTLLIB_STYPE_QOS_DATA) { if (stype != RTLLIB_STYPE_NULLFUNC) - RTLLIB_DEBUG_DROP( - "RX: dropped data frame with no data (type=0x%02x, subtype=0x%02x)\n", - type, stype); + netdev_dbg(ieee->dev, + "RX: dropped data frame with no data (type=0x%02x, subtype=0x%02x)\n", + type, stype); return -1; } } @@ -1037,8 +1040,9 @@ static int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb, * frames silently instead of filling system log with * these reports. */ - RTLLIB_DEBUG_DROP("Decryption failed (not set) (SA= %pM)\n", - hdr->addr2); + netdev_dbg(ieee->dev, + "Decryption failed (not set) (SA= %pM)\n", + hdr->addr2); ieee->ieee_stats.rx_discards_undecryptable++; return -1; } @@ -1077,7 +1081,7 @@ static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, int flen; struct sk_buff *frag_skb = rtllib_frag_cache_get(ieee, hdr); - RTLLIB_DEBUG_FRAG("Rx Fragment received (%u)\n", frag); + netdev_dbg(ieee->dev, "Rx Fragment received (%u)\n", frag); if (!frag_skb) { RTLLIB_DEBUG(RTLLIB_DL_RX | RTLLIB_DL_FRAG, @@ -1148,12 +1152,13 @@ static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, */ struct eapol *eap = (struct eapol *)(skb->data + 24); - RTLLIB_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n", - eap_get_type(eap->type)); + netdev_dbg(ieee->dev, + "RX: IEEE 802.1X EAPOL frame: %s\n", + eap_get_type(eap->type)); } else { - RTLLIB_DEBUG_DROP( - "encryption configured, but RX frame not encrypted (SA= %pM)\n", - hdr->addr2); + netdev_dbg(ieee->dev, + "encryption configured, but RX frame not encrypted (SA= %pM)\n", + hdr->addr2); return -1; } } @@ -1162,15 +1167,16 @@ static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, rtllib_is_eapol_frame(ieee, skb, hdrlen)) { struct eapol *eap = (struct eapol *)(skb->data + 24); - RTLLIB_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n", - eap_get_type(eap->type)); + netdev_dbg(ieee->dev, + "RX: IEEE 802.1X EAPOL frame: %s\n", + eap_get_type(eap->type)); } if (crypt && !(fc & RTLLIB_FCTL_WEP) && !ieee->open_wep && !rtllib_is_eapol_frame(ieee, skb, hdrlen)) { - RTLLIB_DEBUG_DROP( - "dropped unencrypted RX data frame from %pM (drop_unencrypted=1)\n", - hdr->addr2); + netdev_dbg(ieee->dev, + "dropped unencrypted RX data frame from %pM (drop_unencrypted=1)\n", + hdr->addr2); return -1; } diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index b09d5d00c27c..8ef820d52c72 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -670,8 +670,9 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) struct eapol *eap = (struct eapol *)(skb->data + sizeof(struct ethhdr) - SNAP_SIZE - sizeof(u16)); - RTLLIB_DEBUG_EAP("TX: IEEE 802.11 EAPOL frame: %s\n", - eap_get_type(eap->type)); + netdev_dbg(ieee->dev, + "TX: IEEE 802.11 EAPOL frame: %s\n", + eap_get_type(eap->type)); } /* Advance the SKB to the start of the payload */ From 8f90dfbf649b53152654562b89074b11c8f4fe7d Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:32 +0200 Subject: [PATCH 0727/1163] staging: rtl8192e: Remove RTLLIB_DEBUG_QOS() - Pass extra argument (rtllib_device) to rtllib_parse_qos_info_param_IE() and update_network() - Replace RTLLIB_DEBUG_QOS() with netdev_dbg() - Remove RTLLIB_DEBUG_QOS() Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 1 - drivers/staging/rtl8192e/rtllib_rx.c | 26 ++++++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index b20090d39770..c7afb3edaa8f 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -704,7 +704,6 @@ do { \ #define RTLLIB_DEBUG_INFO(f, a...) RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a) #define RTLLIB_DEBUG_MGMT(f, a...) RTLLIB_DEBUG(RTLLIB_DL_MGMT, f, ## a) -#define RTLLIB_DEBUG_QOS(f, a...) RTLLIB_DEBUG(RTLLIB_DL_QOS, f, ## a) #ifndef ETH_P_PAE #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 8ea3e2fa5042..5a3593ba0ae7 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1657,9 +1657,10 @@ static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info * parameters element. check the information element length to decide * which type to read */ -static int rtllib_parse_qos_info_param_IE(struct rtllib_info_element +static int rtllib_parse_qos_info_param_IE(struct rtllib_device *ieee, + struct rtllib_info_element *info_element, - struct rtllib_network *network) + struct rtllib_network *network) { int rc = 0; struct rtllib_qos_information_element qos_info_element; @@ -1684,7 +1685,7 @@ static int rtllib_parse_qos_info_param_IE(struct rtllib_info_element } if (rc == 0) { - RTLLIB_DEBUG_QOS("QoS is supported\n"); + netdev_dbg(ieee->dev, "QoS is supported\n"); network->qos_data.supported = 1; } return rc; @@ -1761,7 +1762,7 @@ static void rtllib_parse_mife_generic(struct rtllib_device *ieee, u16 ht_realtek_agg_len = 0; u8 ht_realtek_agg_buf[MAX_IE_LEN]; - if (!rtllib_parse_qos_info_param_IE(info_element, network)) + if (!rtllib_parse_qos_info_param_IE(ieee, info_element, network)) return; if (info_element->len >= 4 && info_element->data[0] == 0x00 && @@ -2352,7 +2353,8 @@ static inline int is_same_network(struct rtllib_network *src, } -static inline void update_network(struct rtllib_network *dst, +static inline void update_network(struct rtllib_device *ieee, + struct rtllib_network *dst, struct rtllib_network *src) { int qos_active; @@ -2426,12 +2428,12 @@ static inline void update_network(struct rtllib_network *dst, sizeof(struct rtllib_qos_data)); if (dst->qos_data.supported == 1) { if (dst->ssid_len) - RTLLIB_DEBUG_QOS - ("QoS the network %s is QoS supported\n", - dst->ssid); + netdev_dbg(ieee->dev, + "QoS the network %s is QoS supported\n", + dst->ssid); else - RTLLIB_DEBUG_QOS - ("QoS the network is QoS supported\n"); + netdev_dbg(ieee->dev, + "QoS the network is QoS supported\n"); } dst->qos_data.active = qos_active; dst->qos_data.old_param_count = old_param; @@ -2567,7 +2569,7 @@ static inline void rtllib_process_probe_response( spin_lock_irqsave(&ieee->lock, flags); if (is_same_network(&ieee->current_network, network, (network->ssid_len ? 1 : 0))) { - update_network(&ieee->current_network, network); + update_network(ieee, &ieee->current_network, network); if ((ieee->current_network.mode == IEEE_N_24G || ieee->current_network.mode == IEEE_G) && ieee->current_network.berp_info_valid) { @@ -2637,7 +2639,7 @@ static inline void rtllib_process_probe_response( network->ssid_len) == 0) && (ieee->state == RTLLIB_NOLINK)))) renew = 1; - update_network(target, network); + update_network(ieee, target, network); if (renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)) rtllib_softmac_new_net(ieee, network); } From e9fea2ecb018e5ca4dad80ac36b34ba9c320415a Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:33 +0200 Subject: [PATCH 0728/1163] staging: rtl8192e: Remove RTLLIB_DEBUG_MGMT() - Use netdev_dbg() instead of RTLLIB_DEBUG_MGMT() - Remove RTLLIB_DEBUG_MGMT() - Pass net_device to auth_parse(), auth_rq_parse() and assoc_rq_parse() - Remove duplicated messages Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 2 - drivers/staging/rtl8192e/rtllib_rx.c | 78 +++++++++++------------ drivers/staging/rtl8192e/rtllib_softmac.c | 50 +++++++-------- 3 files changed, 61 insertions(+), 69 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index c7afb3edaa8f..82f4fd96e650 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -703,8 +703,6 @@ do { \ #define RTLLIB_DL_ERR (1<<31) #define RTLLIB_DEBUG_INFO(f, a...) RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a) -#define RTLLIB_DEBUG_MGMT(f, a...) RTLLIB_DEBUG(RTLLIB_DL_MGMT, f, ## a) - #ifndef ETH_P_PAE #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ #define ETH_P_IP 0x0800 /* Internet Protocol packet */ diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 5a3593ba0ae7..f9863c40fd7f 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1951,12 +1951,10 @@ static void rtllib_parse_mife_generic(struct rtllib_device *ieee, info_element->data[1] == 0x50 && info_element->data[2] == 0xf2 && info_element->data[3] == 0x04) { - RTLLIB_DEBUG_MGMT("MFIE_TYPE_WZC: %d bytes\n", - info_element->len); - network->wzc_ie_len = min(info_element->len+2, - MAX_WZC_IE_LEN); - memcpy(network->wzc_ie, info_element, - network->wzc_ie_len); + netdev_dbg(ieee->dev, "MFIE_TYPE_WZC: %d bytes\n", + info_element->len); + network->wzc_ie_len = min(info_element->len+2, MAX_WZC_IE_LEN); + memcpy(network->wzc_ie, info_element, network->wzc_ie_len); } } @@ -1975,10 +1973,10 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, while (length >= sizeof(*info_element)) { if (sizeof(*info_element) + info_element->len > length) { - RTLLIB_DEBUG_MGMT("Info elem: parse failed: info_element->len + 2 > left : info_element->len+2=%zd left=%d, id=%d.\n", - info_element->len + - sizeof(*info_element), - length, info_element->id); + netdev_dbg(ieee->dev, + "Info elem: parse failed: info_element->len + 2 > left : info_element->len+2=%zd left=%d, id=%d.\n", + info_element->len + sizeof(*info_element), + length, info_element->id); /* We stop processing but don't return an error here * because some misbehaviour APs break this rule. ie. * Orinoco AP1000. @@ -2001,8 +1999,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, memset(network->ssid + network->ssid_len, 0, IW_ESSID_MAX_SIZE - network->ssid_len); - RTLLIB_DEBUG_MGMT("MFIE_TYPE_SSID: '%s' len=%d.\n", - network->ssid, network->ssid_len); + netdev_dbg(ieee->dev, "MFIE_TYPE_SSID: '%s' len=%d.\n", + network->ssid, network->ssid_len); break; case MFIE_TYPE_RATES: @@ -2029,8 +2027,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, } } - RTLLIB_DEBUG_MGMT("MFIE_TYPE_RATES: '%s' (%d)\n", - rates_str, network->rates_len); + netdev_dbg(ieee->dev, "MFIE_TYPE_RATES: '%s' (%d)\n", + rates_str, network->rates_len); break; case MFIE_TYPE_RATES_EX: @@ -2052,22 +2050,22 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, } } - RTLLIB_DEBUG_MGMT("MFIE_TYPE_RATES_EX: '%s' (%d)\n", - rates_str, network->rates_ex_len); + netdev_dbg(ieee->dev, "MFIE_TYPE_RATES_EX: '%s' (%d)\n", + rates_str, network->rates_ex_len); break; case MFIE_TYPE_DS_SET: - RTLLIB_DEBUG_MGMT("MFIE_TYPE_DS_SET: %d\n", - info_element->data[0]); + netdev_dbg(ieee->dev, "MFIE_TYPE_DS_SET: %d\n", + info_element->data[0]); network->channel = info_element->data[0]; break; case MFIE_TYPE_FH_SET: - RTLLIB_DEBUG_MGMT("MFIE_TYPE_FH_SET: ignored\n"); + netdev_dbg(ieee->dev, "MFIE_TYPE_FH_SET: ignored\n"); break; case MFIE_TYPE_CF_SET: - RTLLIB_DEBUG_MGMT("MFIE_TYPE_CF_SET: ignored\n"); + netdev_dbg(ieee->dev, "MFIE_TYPE_CF_SET: ignored\n"); break; case MFIE_TYPE_TIM: @@ -2106,30 +2104,31 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, case MFIE_TYPE_ERP: network->erp_value = info_element->data[0]; network->flags |= NETWORK_HAS_ERP_VALUE; - RTLLIB_DEBUG_MGMT("MFIE_TYPE_ERP_SET: %d\n", - network->erp_value); + netdev_dbg(ieee->dev, "MFIE_TYPE_ERP_SET: %d\n", + network->erp_value); break; case MFIE_TYPE_IBSS_SET: network->atim_window = info_element->data[0]; - RTLLIB_DEBUG_MGMT("MFIE_TYPE_IBSS_SET: %d\n", - network->atim_window); + netdev_dbg(ieee->dev, "MFIE_TYPE_IBSS_SET: %d\n", + network->atim_window); break; case MFIE_TYPE_CHALLENGE: - RTLLIB_DEBUG_MGMT("MFIE_TYPE_CHALLENGE: ignored\n"); + netdev_dbg(ieee->dev, "MFIE_TYPE_CHALLENGE: ignored\n"); break; case MFIE_TYPE_GENERIC: - RTLLIB_DEBUG_MGMT("MFIE_TYPE_GENERIC: %d bytes\n", - info_element->len); + netdev_dbg(ieee->dev, "MFIE_TYPE_GENERIC: %d bytes\n", + info_element->len); + rtllib_parse_mife_generic(ieee, info_element, network, &tmp_htcap_len, &tmp_htinfo_len); break; case MFIE_TYPE_RSN: - RTLLIB_DEBUG_MGMT("MFIE_TYPE_RSN: %d bytes\n", - info_element->len); + netdev_dbg(ieee->dev, "MFIE_TYPE_RSN: %d bytes\n", + info_element->len); network->rsn_ie_len = min(info_element->len + 2, MAX_WPA_IE_LEN); memcpy(network->rsn_ie, info_element, @@ -2210,10 +2209,10 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, break; /* TODO */ default: - RTLLIB_DEBUG_MGMT - ("Unsupported info element: %s (%d)\n", - get_info_element_string(info_element->id), - info_element->id); + netdev_dbg(ieee->dev, + "Unsupported info element: %s (%d)\n", + get_info_element_string(info_element->id), + info_element->id); break; } @@ -2672,8 +2671,8 @@ void rtllib_rx_mgt(struct rtllib_device *ieee, switch (WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl))) { case RTLLIB_STYPE_BEACON: - RTLLIB_DEBUG_MGMT("received BEACON (%d)\n", - WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl))); + netdev_dbg(ieee->dev, "received BEACON (%d)\n", + WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl))); rtllib_process_probe_response( ieee, (struct rtllib_probe_response *)header, stats); @@ -2686,15 +2685,14 @@ void rtllib_rx_mgt(struct rtllib_device *ieee, break; case RTLLIB_STYPE_PROBE_RESP: - RTLLIB_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", - WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl))); + netdev_dbg(ieee->dev, "received PROBE RESPONSE (%d)\n", + WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl))); rtllib_process_probe_response(ieee, (struct rtllib_probe_response *)header, stats); break; case RTLLIB_STYPE_PROBE_REQ: - RTLLIB_DEBUG_MGMT("received PROBE RESQUEST (%d)\n", - WLAN_FC_GET_STYPE( - le16_to_cpu(header->frame_ctl))); + netdev_dbg(ieee->dev, "received PROBE RESQUEST (%d)\n", + WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl))); if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && ((ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) && diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 4ce35259d5d6..9c83e3b14a39 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1439,10 +1439,10 @@ void rtllib_associate_abort(struct rtllib_device *ieee) * with, so we retry or just get back to NO_LINK and scanning */ if (ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATING) { - RTLLIB_DEBUG_MGMT("Authentication failed\n"); + netdev_dbg(ieee->dev, "Authentication failed\n"); ieee->softmac_stats.no_auth_rs++; } else { - RTLLIB_DEBUG_MGMT("Association failed\n"); + netdev_dbg(ieee->dev, "Association failed\n"); ieee->softmac_stats.no_ass_rs++; } @@ -1464,7 +1464,7 @@ static void rtllib_associate_step1(struct rtllib_device *ieee, u8 *daddr) struct rtllib_network *beacon = &ieee->current_network; struct sk_buff *skb; - RTLLIB_DEBUG_MGMT("Stopping scan\n"); + netdev_dbg(ieee->dev, "Stopping scan\n"); ieee->softmac_stats.tx_auth_rq++; @@ -1474,7 +1474,7 @@ static void rtllib_associate_step1(struct rtllib_device *ieee, u8 *daddr) rtllib_associate_abort(ieee); else { ieee->state = RTLLIB_ASSOCIATING_AUTHENTICATING; - RTLLIB_DEBUG_MGMT("Sending authentication request\n"); + netdev_dbg(ieee->dev, "Sending authentication request\n"); softmac_mgmt_xmit(skb, ieee); if (!timer_pending(&ieee->associate_timer)) { ieee->associate_timer.expires = jiffies + (HZ / 2); @@ -1502,7 +1502,8 @@ static void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int *(c++) = chlen; memcpy(c, challenge, chlen); - RTLLIB_DEBUG_MGMT("Sending authentication challenge response\n"); + netdev_dbg(ieee->dev, + "Sending authentication challenge response\n"); rtllib_encrypt_fragment(ieee, skb, sizeof(struct rtllib_hdr_3addr)); @@ -1520,7 +1521,7 @@ static void rtllib_associate_step2(struct rtllib_device *ieee) del_timer_sync(&ieee->associate_timer); - RTLLIB_DEBUG_MGMT("Sending association request\n"); + netdev_dbg(ieee->dev, "Sending association request\n"); ieee->softmac_stats.tx_ass_rq++; skb = rtllib_association_req(beacon, ieee); @@ -1793,14 +1794,15 @@ void rtllib_softmac_check_all_nets(struct rtllib_device *ieee) spin_unlock_irqrestore(&ieee->lock, flags); } -static inline u16 auth_parse(struct sk_buff *skb, u8 **challenge, int *chlen) +static inline u16 auth_parse(struct net_device *dev, struct sk_buff *skb, + u8 **challenge, int *chlen) { struct rtllib_authentication *a; u8 *t; if (skb->len < (sizeof(struct rtllib_authentication) - sizeof(struct rtllib_info_element))) { - RTLLIB_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); + netdev_dbg(dev, "invalid len in auth resp: %d\n", skb->len); return 0xcafe; } *challenge = NULL; @@ -1818,14 +1820,13 @@ static inline u16 auth_parse(struct sk_buff *skb, u8 **challenge, int *chlen) return le16_to_cpu(a->status); } -static int auth_rq_parse(struct sk_buff *skb, u8 *dest) +static int auth_rq_parse(struct net_device *dev, struct sk_buff *skb, u8 *dest) { struct rtllib_authentication *a; if (skb->len < (sizeof(struct rtllib_authentication) - sizeof(struct rtllib_info_element))) { - RTLLIB_DEBUG_MGMT("invalid len in auth request: %d\n", - skb->len); + netdev_dbg(dev, "invalid len in auth request: %d\n", skb->len); return -1; } a = (struct rtllib_authentication *) skb->data; @@ -1884,14 +1885,13 @@ static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb, return !strncmp(ssid, ieee->current_network.ssid, ssidlen); } -static int assoc_rq_parse(struct sk_buff *skb, u8 *dest) +static int assoc_rq_parse(struct net_device *dev, struct sk_buff *skb, u8 *dest) { struct rtllib_assoc_request_frame *a; if (skb->len < (sizeof(struct rtllib_assoc_request_frame) - sizeof(struct rtllib_info_element))) { - - RTLLIB_DEBUG_MGMT("invalid len in auth request:%d\n", skb->len); + netdev_dbg(dev, "invalid len in auth request:%d\n", skb->len); return -1; } @@ -1909,7 +1909,8 @@ static inline u16 assoc_parse(struct rtllib_device *ieee, struct sk_buff *skb, u16 status_code; if (skb->len < sizeof(struct rtllib_assoc_response_frame)) { - RTLLIB_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); + netdev_dbg(ieee->dev, "Invalid len in auth resp: %d\n", + skb->len); return 0xcafe; } @@ -1949,7 +1950,7 @@ static inline void rtllib_rx_auth_rq(struct rtllib_device *ieee, ieee->softmac_stats.rx_auth_rq++; - status = auth_rq_parse(skb, dest); + status = auth_rq_parse(ieee->dev, skb, dest); if (status != -1) rtllib_resp_to_auth(ieee, status, dest); } @@ -1961,7 +1962,7 @@ static inline void rtllib_rx_assoc_rq(struct rtllib_device *ieee, ieee->softmac_stats.rx_ass_rq++; - if (assoc_rq_parse(skb, dest) != -1) + if (assoc_rq_parse(ieee->dev, skb, dest) != -1) rtllib_resp_to_assoc_rq(ieee, dest); netdev_info(ieee->dev, "New client associated: %pM\n", dest); @@ -2235,8 +2236,8 @@ inline int rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_assoc_response_frame *assoc_resp; struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; - RTLLIB_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", - WLAN_FC_GET_STYPE(header->frame_ctl)); + netdev_dbg(ieee->dev, "received [RE]ASSOCIATION RESPONSE (%d)\n", + WLAN_FC_GET_STYPE(header->frame_ctl)); if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATED && @@ -2297,9 +2298,6 @@ inline int rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb, netdev_info(ieee->dev, "Association response status code 0x%x\n", errcode); - RTLLIB_DEBUG_MGMT( - "Association response status code 0x%x\n", - errcode); if (ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 0); @@ -2317,13 +2315,10 @@ static void rtllib_rx_auth_resp(struct rtllib_device *ieee, struct sk_buff *skb) int chlen = 0; bool bSupportNmode = true, bHalfSupportNmode = false; - errcode = auth_parse(skb, &challenge, &chlen); + errcode = auth_parse(ieee->dev, skb, &challenge, &chlen); if (errcode) { ieee->softmac_stats.rx_auth_rs_err++; - RTLLIB_DEBUG_MGMT("Authentication respose status code 0x%x", - errcode); - netdev_info(ieee->dev, "Authentication respose status code 0x%x", errcode); rtllib_associate_abort(ieee); @@ -2373,7 +2368,8 @@ inline int rtllib_rx_auth(struct rtllib_device *ieee, struct sk_buff *skb, if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) { if (ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATING && (ieee->iw_mode == IW_MODE_INFRA)) { - RTLLIB_DEBUG_MGMT("Received authentication response"); + netdev_dbg(ieee->dev, + "Received authentication response"); rtllib_rx_auth_resp(ieee, skb); } else if (ieee->iw_mode == IW_MODE_MASTER) { rtllib_rx_auth_rq(ieee, skb); From def16d2ee94eccf305214cc4bf1c889462b3734e Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:34 +0200 Subject: [PATCH 0729/1163] staging: rtl8192e: Remove RTLLIB_DEBUG_INFO() Use pr_debug() instead. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 1 - drivers/staging/rtl8192e/rtllib_module.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 82f4fd96e650..655f5faf13ba 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -701,7 +701,6 @@ do { \ #define RTLLIB_DL_TRACE (1<<29) #define RTLLIB_DL_DATA (1<<30) #define RTLLIB_DL_ERR (1<<31) -#define RTLLIB_DEBUG_INFO(f, a...) RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a) #ifndef ETH_P_PAE #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c index b8c7df501db7..b61035b618cf 100644 --- a/drivers/staging/rtl8192e/rtllib_module.c +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -103,7 +103,7 @@ struct net_device *alloc_rtllib(int sizeof_priv) struct net_device *dev; int i, err; - RTLLIB_DEBUG_INFO("Initializing...\n"); + pr_debug("rtllib: Initializing...\n"); dev = alloc_etherdev(sizeof(struct rtllib_device) + sizeof_priv); if (!dev) { From b94436b5d527d06403120be23570343a02b2283b Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:35 +0200 Subject: [PATCH 0730/1163] staging: rtl8192e: Remove RTLLIB_DEBUG() - Use netdev_dbg or netdev_vdbg instead of RTLLIB_DEBUG() - Reformat some messages for better readability - Remove RTLLIB_DEBUG messages that make no sense Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 35 ++++++--------- drivers/staging/rtl8192e/rtl819x_HTProc.c | 21 +++++---- drivers/staging/rtl8192e/rtl819x_TSProc.c | 35 ++++++--------- drivers/staging/rtl8192e/rtllib.h | 5 --- drivers/staging/rtl8192e/rtllib_rx.c | 52 +++++++++++++---------- 5 files changed, 67 insertions(+), 81 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 7d72c19005f6..39d28e30aeb5 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -84,9 +84,9 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst, u8 *tag = NULL; u16 len = ieee->tx_headroom + 9; - RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, - "========>%s(), frame(%d) sentd to: %pM, ieee->dev:%p\n", - __func__, type, Dst, ieee->dev); + netdev_dbg(ieee->dev, "%s(): frame(%d) sentd to: %pM, ieee->dev:%p\n", + __func__, type, Dst, ieee->dev); + if (pBA == NULL) { netdev_warn(ieee->dev, "pBA is NULL\n"); return NULL; @@ -148,9 +148,8 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst, u16 len = 6 + ieee->tx_headroom; if (net_ratelimit()) - RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, - "========>%s(), ReasonCode(%d) sentd to: %pM\n", - __func__, ReasonCode, dst); + netdev_dbg(ieee->dev, "%s(): ReasonCode(%d) sentd to: %pM\n", + __func__, ReasonCode, dst); memset(&DelbaParamSet, 0, 2); @@ -186,9 +185,6 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst, tag += 2; RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len); - if (net_ratelimit()) - RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "<=====%s()\n", - __func__); return skb; } @@ -203,8 +199,7 @@ static void rtllib_send_ADDBAReq(struct rtllib_device *ieee, u8 *dst, RT_TRACE(COMP_DBG, "====>to send ADDBAREQ!!!!!\n"); softmac_mgmt_xmit(skb, ieee); } else { - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "alloc skb error in function %s()\n", __func__); + netdev_dbg(ieee->dev, "Failed to generate ADDBAReq packet.\n"); } } @@ -217,8 +212,7 @@ static void rtllib_send_ADDBARsp(struct rtllib_device *ieee, u8 *dst, if (skb) softmac_mgmt_xmit(skb, ieee); else - RTLLIB_DEBUG(RTLLIB_DL_ERR, - "alloc skb error in function %s()\n", __func__); + netdev_dbg(ieee->dev, "Failed to generate ADDBARsp packet.\n"); } static void rtllib_send_DELBA(struct rtllib_device *ieee, u8 *dst, @@ -231,8 +225,7 @@ 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 function %s()\n", __func__); + netdev_dbg(ieee->dev, "Failed to generate DELBA packet.\n"); } int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb) @@ -374,20 +367,20 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb) if (pAdmittedBA->bValid == true) { - RTLLIB_DEBUG(RTLLIB_DL_BA, - "OnADDBARsp(): Recv ADDBA Rsp. Drop because already admit it!\n"); + netdev_dbg(ieee->dev, "%s(): ADDBA response already admitted\n", + __func__); return -1; } else if ((pPendingBA->bValid == false) || (*pDialogToken != pPendingBA->DialogToken)) { netdev_warn(ieee->dev, - "%s(): Recv ADDBA Rsp. BA invalid, DELBA!\n", + "%s(): ADDBA Rsp. BA invalid, DELBA!\n", __func__); ReasonCode = DELBA_REASON_UNKNOWN_BA; goto OnADDBARsp_Reject; } else { - RTLLIB_DEBUG(RTLLIB_DL_BA, - "OnADDBARsp(): Recv ADDBA Rsp. BA is admitted! Status code:%X\n", - *pStatusCode); + netdev_dbg(ieee->dev, + "%s(): Recv ADDBA Rsp. BA is admitted! Status code:%X\n", + __func__, *pStatusCode); DeActivateBAEntry(ieee, pPendingBA); } diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index 2c365d334573..584f7a9af89a 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -217,8 +217,7 @@ static void HTIOTPeerDetermine(struct rtllib_device *ieee) else pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN; - RTLLIB_DEBUG(RTLLIB_DL_IOT, "Joseph debug!! IOTPEER: %x\n", - pHTInfo->IOTPeer); + netdev_dbg(ieee->dev, "IOTPEER: %x\n", pHTInfo->IOTPeer); } static u8 HTIOTActIsDisableMCS14(struct rtllib_device *ieee, u8 *PeerMacAddr) @@ -328,9 +327,9 @@ void HTConstructCapabilityElement(struct rtllib_device *ieee, u8 *posHTCap, pCapELE->LSigTxopProtect = 0; - RTLLIB_DEBUG(RTLLIB_DL_HT, - "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n", - pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk); + netdev_dbg(ieee->dev, + "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n", + pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk); if (IsEncrypt) { pCapELE->MPDUDensity = 7; @@ -541,7 +540,7 @@ void HTOnAssocRsp(struct rtllib_device *ieee) netdev_warn(ieee->dev, "%s(): HT_DISABLE\n", __func__); return; } - RTLLIB_DEBUG(RTLLIB_DL_HT, "===> HTOnAssocRsp_wq(): HT_ENABLE\n"); + netdev_dbg(ieee->dev, "%s(): HT_ENABLE\n", __func__); if (!memcmp(pHTInfo->PeerHTCapBuf, EWC11NHTCap, sizeof(EWC11NHTCap))) pPeerHTCap = (struct ht_capab_ele *)(&pHTInfo->PeerHTCapBuf[4]); @@ -646,7 +645,7 @@ void HTInitializeHTInfo(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - RTLLIB_DEBUG(RTLLIB_DL_HT, "===========>%s()\n", __func__); + netdev_vdbg(ieee->dev, "%s()\n", __func__); pHTInfo->bCurrentHTSupport = false; pHTInfo->bCurBW40MHz = false; @@ -716,7 +715,7 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee, struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; u8 bIOTAction = 0; - RTLLIB_DEBUG(RTLLIB_DL_HT, "==============>%s()\n", __func__); + netdev_vdbg(ieee->dev, "%s()\n", __func__); /* unmark bEnableHT flag here is the same reason why unmarked in * function rtllib_softmac_new_net. WB 2008.09.10 */ @@ -840,8 +839,7 @@ u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame) { if (ieee->pHTInfo->bCurrentHTSupport) { if ((IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1) { - RTLLIB_DEBUG(RTLLIB_DL_HT, - "HT CONTROL FILED EXIST!!\n"); + netdev_dbg(ieee->dev, "HT CONTROL FILED EXIST!!\n"); return true; } } @@ -852,7 +850,8 @@ static void HTSetConnectBwModeCallback(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - RTLLIB_DEBUG(RTLLIB_DL_HT, "======>%s()\n", __func__); + netdev_vdbg(ieee->dev, "%s()\n", __func__); + if (pHTInfo->bCurBW40MHz) { if (pHTInfo->CurSTAExtChnlOffset == HT_EXTCHNL_OFFSET_UPPER) ieee->set_chan(ieee->dev, diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 974f03e02c26..dea86ea9066d 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -58,9 +58,9 @@ static void RxPktPendingTimeout(unsigned long data) pRxTs->RxIndicateSeq = (pRxTs->RxIndicateSeq + 1) % 4096; - RTLLIB_DEBUG(RTLLIB_DL_REORDER, - "%s(): Indicate SeqNum: %d\n", - __func__, pReorderEntry->SeqNum); + netdev_dbg(ieee->dev, + "%s(): Indicate SeqNum: %d\n", + __func__, pReorderEntry->SeqNum); ieee->stats_IndicateArray[index] = pReorderEntry->prxb; index++; @@ -105,8 +105,7 @@ static void TsAddBaProcess(unsigned long data) TxTsRecord[num]); TsInitAddBA(ieee, pTxTs, BA_POLICY_IMMEDIATE, false); - RTLLIB_DEBUG(RTLLIB_DL_BA, - "TsAddBaProcess(): ADDBA Req is started!!\n"); + netdev_dbg(ieee->dev, "%s(): ADDBA Req is started\n", __func__); } static void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) @@ -145,7 +144,7 @@ void TSInitialize(struct rtllib_device *ieee) struct rx_reorder_entry *pRxReorderEntry = ieee->RxReorderEntry; u8 count = 0; - RTLLIB_DEBUG(RTLLIB_DL_TS, "==========>%s()\n", __func__); + netdev_vdbg(ieee->dev, "%s()\n", __func__); INIT_LIST_HEAD(&ieee->Tx_TS_Admit_List); INIT_LIST_HEAD(&ieee->Tx_TS_Pending_List); INIT_LIST_HEAD(&ieee->Tx_TS_Unused_List); @@ -356,8 +355,7 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, return true; if (!bAddNewTs) { - RTLLIB_DEBUG(RTLLIB_DL_TS, - "add new TS failed(tid:%d)\n", UP); + netdev_dbg(ieee->dev, "add new TS failed(tid:%d)\n", UP); return false; } @@ -373,7 +371,6 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, ((TxRxSelect == TX_DIR) ? DIR_DOWN : DIR_UP) : ((TxRxSelect == TX_DIR) ? DIR_UP : DIR_DOWN); - RTLLIB_DEBUG(RTLLIB_DL_TS, "to add Ts\n"); if (!list_empty(pUnusedList)) { (*ppTS) = list_entry(pUnusedList->next, struct ts_common_info, List); @@ -392,9 +389,9 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, ResetRxTsEntry(tmp); } - RTLLIB_DEBUG(RTLLIB_DL_TS, - "to init current TS, UP:%d, Dir:%d, addr: %pM ppTs=%p\n", - UP, Dir, Addr, *ppTS); + netdev_dbg(ieee->dev, + "to init current TS, UP:%d, Dir:%d, addr: %pM ppTs=%p\n", + UP, Dir, Addr, *ppTS); pTSInfo->field.ucTrafficType = 0; pTSInfo->field.ucTSID = UP; pTSInfo->field.ucDirection = Dir; @@ -436,9 +433,8 @@ static void RemoveTsEntry(struct rtllib_device *ieee, struct ts_common_info *pTs pRxReorderEntry = (struct rx_reorder_entry *) list_entry(pRxTS->RxPendingPktList.prev, struct rx_reorder_entry, List); - RTLLIB_DEBUG(RTLLIB_DL_REORDER, - "%s(): Delete SeqNum %d!\n", __func__, - pRxReorderEntry->SeqNum); + netdev_dbg(ieee->dev, "%s(): Delete SeqNum %d!\n", + __func__, pRxReorderEntry->SeqNum); list_del_init(&pRxReorderEntry->List); { int i = 0; @@ -538,16 +534,13 @@ void TsStartAddBaProcess(struct rtllib_device *ieee, struct tx_ts_record *pTxTS) pTxTS->bAddBaReqInProgress = true; if (pTxTS->bAddBaReqDelayed) { - RTLLIB_DEBUG(RTLLIB_DL_BA, - "TsStartAddBaProcess(): Delayed Start ADDBA after 60 sec!!\n"); + netdev_dbg(ieee->dev, "Start ADDBA after 60 sec!!\n"); mod_timer(&pTxTS->TsAddBaTimer, jiffies + msecs_to_jiffies(TS_ADDBA_DELAY)); } else { - RTLLIB_DEBUG(RTLLIB_DL_BA, - "TsStartAddBaProcess(): Immediately Start ADDBA now!!\n"); + netdev_dbg(ieee->dev, "Immediately Start ADDBA\n"); mod_timer(&pTxTS->TsAddBaTimer, jiffies+10); } } else - RTLLIB_DEBUG(RTLLIB_DL_BA, "%s()==>BA timer is already added\n", - __func__); + netdev_dbg(ieee->dev, "BA timer is already added\n"); } diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 655f5faf13ba..da179a566b17 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -643,11 +643,6 @@ enum wireless_network_type { /* debug macros */ extern u32 rtllib_debug_level; -#define RTLLIB_DEBUG(level, fmt, args...) \ -do { \ - if (rtllib_debug_level & (level)) \ - printk(KERN_DEBUG "rtllib: " fmt, ## args); \ -} while (0) #define RTLLIB_DEBUG_DATA(level, data, datalen) \ do { \ diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index f9863c40fd7f..58c9cf281959 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -536,7 +536,8 @@ void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record } pRxReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev, struct rx_reorder_entry, List); - RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Indicate SeqNum %d!\n", __func__, pRxReorderEntry->SeqNum); + netdev_dbg(ieee->dev, "%s(): Indicate SeqNum %d!\n", __func__, + pRxReorderEntry->SeqNum); list_del_init(&pRxReorderEntry->List); ieee->RfdArray[RfdCnt] = pRxReorderEntry->prxb; @@ -561,8 +562,9 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, bool bMatchWinStart = false, bPktInBuf = false; unsigned long flags; - RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Seq is %d, pTS->RxIndicateSeq is %d, WinSize is %d\n", __func__, SeqNum, - pTS->RxIndicateSeq, WinSize); + netdev_dbg(ieee->dev, + "%s(): Seq is %d, pTS->RxIndicateSeq is %d, WinSize is %d\n", + __func__, SeqNum, pTS->RxIndicateSeq, WinSize); spin_lock_irqsave(&(ieee->reorder_spinlock), flags); @@ -573,8 +575,9 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, /* Drop out the packet which SeqNum is smaller than WinStart */ if (SN_LESS(SeqNum, pTS->RxIndicateSeq)) { - RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Packet Drop! IndicateSeq: %d, NewSeq: %d\n", - pTS->RxIndicateSeq, SeqNum); + netdev_dbg(ieee->dev, + "Packet Drop! IndicateSeq: %d, NewSeq: %d\n", + pTS->RxIndicateSeq, SeqNum); pHTInfo->RxReorderDropCounter++; { int i; @@ -600,7 +603,9 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, pTS->RxIndicateSeq = SeqNum + 1 - WinSize; else pTS->RxIndicateSeq = 4095 - (WinSize - (SeqNum + 1)) + 1; - RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Window Shift! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, SeqNum); + netdev_dbg(ieee->dev, + "Window Shift! IndicateSeq: %d, NewSeq: %d\n", + pTS->RxIndicateSeq, SeqNum); } /* Indication process. @@ -615,8 +620,8 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, */ if (bMatchWinStart) { /* Current packet is going to be indicated.*/ - RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Packets indication!! IndicateSeq: %d, NewSeq: %d\n", - pTS->RxIndicateSeq, SeqNum); + netdev_dbg(ieee->dev, "Packets indication! IndicateSeq: %d, NewSeq: %d\n", + pTS->RxIndicateSeq, SeqNum); ieee->prxbIndicateArray[0] = prxb; index = 1; } else { @@ -632,10 +637,10 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, pReorderEntry->prxb = prxb; if (!AddReorderEntry(pTS, pReorderEntry)) { - RTLLIB_DEBUG(RTLLIB_DL_REORDER, - "%s(): Duplicate packet is dropped!! IndicateSeq: %d, NewSeq: %d\n", - __func__, pTS->RxIndicateSeq, - SeqNum); + netdev_dbg(ieee->dev, + "%s(): Duplicate packet is dropped. IndicateSeq: %d, NewSeq: %d\n", + __func__, pTS->RxIndicateSeq, + SeqNum); list_add_tail(&pReorderEntry->List, &ieee->RxReorder_Unused_List); { int i; @@ -646,9 +651,9 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, prxb = NULL; } } else { - RTLLIB_DEBUG(RTLLIB_DL_REORDER, - "Pkt insert into struct buffer!! IndicateSeq: %d, NewSeq: %d\n", - pTS->RxIndicateSeq, SeqNum); + netdev_dbg(ieee->dev, + "Pkt insert into struct buffer. IndicateSeq: %d, NewSeq: %d\n", + pTS->RxIndicateSeq, SeqNum); } } else { /* Packets are dropped if there are not enough reorder @@ -672,7 +677,8 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, /* Check if there is any packet need indicate.*/ while (!list_empty(&pTS->RxPendingPktList)) { - RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): start RREORDER indicate\n", __func__); + netdev_dbg(ieee->dev, "%s(): start RREORDER indicate\n", + __func__); pReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev, struct rx_reorder_entry, List); @@ -693,7 +699,8 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096; ieee->prxbIndicateArray[index] = pReorderEntry->prxb; - RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Indicate SeqNum %d!\n", __func__, pReorderEntry->SeqNum); + netdev_dbg(ieee->dev, "%s(): Indicate SeqNum %d!\n", + __func__, pReorderEntry->SeqNum); index++; list_add_tail(&pReorderEntry->List, @@ -725,8 +732,7 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, } if (bPktInBuf && pTS->RxTimeoutIndicateSeq == 0xffff) { - RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): SET rx timeout timer\n", - __func__); + netdev_dbg(ieee->dev, "%s(): SET rx timeout timer\n", __func__); pTS->RxTimeoutIndicateSeq = pTS->RxIndicateSeq; mod_timer(&pTS->RxPktPendingTimer, jiffies + msecs_to_jiffies(pHTInfo->RxReorderPendingTime)); @@ -1084,10 +1090,10 @@ static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, netdev_dbg(ieee->dev, "Rx Fragment received (%u)\n", frag); if (!frag_skb) { - RTLLIB_DEBUG(RTLLIB_DL_RX | RTLLIB_DL_FRAG, - "Rx cannot get skb from fragment cache (morefrag=%d seq=%u frag=%u)\n", - (fc & RTLLIB_FCTL_MOREFRAGS) != 0, - WLAN_GET_SEQ_SEQ(sc), frag); + netdev_dbg(ieee->dev, + "Rx cannot get skb from fragment cache (morefrag=%d seq=%u frag=%u)\n", + (fc & RTLLIB_FCTL_MOREFRAGS) != 0, + WLAN_GET_SEQ_SEQ(sc), frag); return -1; } flen = skb->len; From 7232141526e8c3702984bc5239e283b50c5f3d09 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:36 +0200 Subject: [PATCH 0731/1163] staging: rtl8192e: Remove RTLLIB_DEBUG_DATA() Use print_hex_dump_bytes() if VERBOSE_DEBUG is enabled. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 20 ++++++++++++++++---- drivers/staging/rtl8192e/rtl819x_HTProc.c | 7 +++++-- drivers/staging/rtl8192e/rtllib.h | 11 ----------- drivers/staging/rtl8192e/rtllib_tx.c | 5 ++++- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 39d28e30aeb5..25765b8b8bc4 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -133,7 +133,10 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst, tag += 2; } - RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len); +#ifdef VERBOSE_DEBUG + print_hex_dump_bytes("rtllib_ADDBA(): ", DUMP_PREFIX_NONE, skb->data, + skb->len); +#endif return skb; } @@ -184,7 +187,10 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst, put_unaligned_le16(ReasonCode, tag); tag += 2; - RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len); +#ifdef VERBOSE_DEBUG + print_hex_dump_bytes("rtllib_DELBA(): ", DUMP_PREFIX_NONE, skb->data, + skb->len); +#endif return skb; } @@ -246,7 +252,10 @@ int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb) return -1; } - RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len); +#ifdef VERBOSE_DEBUG + print_hex_dump_bytes("rtllib_rx_ADDBAReq(): ", DUMP_PREFIX_NONE, + skb->data, skb->len); +#endif req = (struct rtllib_hdr_3addr *) skb->data; tag = (u8 *)req; @@ -442,7 +451,10 @@ int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb) return -1; } - RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len); +#ifdef VERBOSE_DEBUG + print_hex_dump_bytes("rtllib_rx_DELBA(): ", DUMP_PREFIX_NONE, skb->data, + skb->len); +#endif delba = (struct rtllib_hdr_3addr *)skb->data; dst = (u8 *)(&delba->addr2[0]); delba += sizeof(struct rtllib_hdr_3addr); diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index 584f7a9af89a..3edd5d1a05fb 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -553,8 +553,11 @@ void HTOnAssocRsp(struct rtllib_device *ieee) else pPeerHTInfo = (struct ht_info_ele *)(pHTInfo->PeerHTInfoBuf); - RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA | RTLLIB_DL_HT, pPeerHTCap, - sizeof(struct ht_capab_ele)); + +#ifdef VERBOSE_DEBUG + print_hex_dump_bytes("HTOnAssocRsp(): ", DUMP_PREFIX_NONE, + pPeerHTCap, sizeof(struct ht_capab_ele)); +#endif HTSetConnectBwMode(ieee, (enum ht_channel_width)(pPeerHTCap->ChlWidth), (enum ht_extchnl_offset)(pPeerHTInfo->ExtChlOffset)); pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1) ? diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index da179a566b17..e26a23611315 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -642,17 +642,6 @@ enum wireless_network_type { #define OUI_SUBTYPE_QOS_CAPABI 5 /* debug macros */ -extern u32 rtllib_debug_level; - -#define RTLLIB_DEBUG_DATA(level, data, datalen) \ - do { \ - if ((rtllib_debug_level & (level)) == (level)) { \ - printk(KERN_DEBUG "rtllib: %s()\n", __func__); \ - print_hex_dump_bytes(KERN_DEBUG, DUMP_PREFIX_NONE, \ - data, datalen); \ - } \ - } while (0) - /* To use the debug system; * * If you are defining a new debug classification, simply add it to the #define diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index 8ef820d52c72..7047d2c61c23 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -260,7 +260,10 @@ static int rtllib_classify(struct sk_buff *skb, u8 bIsAmsdu) if (eth->h_proto != htons(ETH_P_IP)) return 0; - RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA, skb->data, skb->len); +#ifdef VERBOSE_DEBUG + print_hex_dump_bytes("rtllib_classify(): ", DUMP_PREFIX_NONE, skb->data, + skb->len); +#endif ip = ip_hdr(skb); switch (ip->tos & 0xfc) { case 0x20: From db65e4aaf5a050b2c3a91039986e66a18ac97d8d Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:37 +0200 Subject: [PATCH 0732/1163] staging: rtl8192e: Remove remains of RTLLIB_*_DEBUG() (including proc entry) Remove rest of rtllib "debug" system - it is no longer used - proper netdev_* functions are used in most cases. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 45 ------------------- drivers/staging/rtl8192e/rtllib_module.c | 55 ------------------------ 2 files changed, 100 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index e26a23611315..d5b5592c18fa 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -641,51 +641,6 @@ enum wireless_network_type { #define OUI_SUBTYPE_WMM_PARAM 1 #define OUI_SUBTYPE_QOS_CAPABI 5 -/* debug macros */ -/* To use the debug system; - * - * If you are defining a new debug classification, simply add it to the #define - * list here in the form of: - * - * #define RTLLIB_DL_xxxx VALUE - * - * shifting value to the left one bit from the previous entry. xxxx should be - * the name of the classification (for example, WEP) - * - * You then need to either add a RTLLIB_xxxx_DEBUG() macro definition for your - * classification, or use RTLLIB_DEBUG(RTLLIB_DL_xxxx, ...) whenever you want - * to send output to that classification. - * - * To add your debug level to the list of levels seen when you perform - * - * % cat /proc/net/ipw/debug_level - * - * you simply need to add your entry to the ipw_debug_levels array. - */ - -#define RTLLIB_DL_INFO (1<<0) -#define RTLLIB_DL_WX (1<<1) -#define RTLLIB_DL_SCAN (1<<2) -#define RTLLIB_DL_STATE (1<<3) -#define RTLLIB_DL_MGMT (1<<4) -#define RTLLIB_DL_FRAG (1<<5) -#define RTLLIB_DL_EAP (1<<6) -#define RTLLIB_DL_DROP (1<<7) - -#define RTLLIB_DL_TX (1<<8) -#define RTLLIB_DL_RX (1<<9) - -#define RTLLIB_DL_HT (1<<10) -#define RTLLIB_DL_BA (1<<11) -#define RTLLIB_DL_TS (1<<12) -#define RTLLIB_DL_QOS (1<<13) -#define RTLLIB_DL_REORDER (1<<14) -#define RTLLIB_DL_IOT (1<<15) -#define RTLLIB_DL_IPS (1<<16) -#define RTLLIB_DL_TRACE (1<<29) -#define RTLLIB_DL_DATA (1<<30) -#define RTLLIB_DL_ERR (1<<31) - #ifndef ETH_P_PAE #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ #define ETH_P_IP 0x0800 /* Internet Protocol packet */ diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c index b61035b618cf..845d9b8a4aa2 100644 --- a/drivers/staging/rtl8192e/rtllib_module.c +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -196,68 +196,13 @@ void free_rtllib(struct net_device *dev) } EXPORT_SYMBOL(free_rtllib); -u32 rtllib_debug_level; -static int debug = RTLLIB_DL_ERR; -static struct proc_dir_entry *rtllib_proc; - -static int show_debug_level(struct seq_file *m, void *v) -{ - seq_printf(m, "0x%08X\n", rtllib_debug_level); - - return 0; -} - -static ssize_t write_debug_level(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) -{ - unsigned long val; - int err = kstrtoul_from_user(buffer, count, 0, &val); - - if (err) - return err; - rtllib_debug_level = val; - return count; -} - -static int open_debug_level(struct inode *inode, struct file *file) -{ - return single_open(file, show_debug_level, NULL); -} - -static const struct file_operations fops = { - .open = open_debug_level, - .read = seq_read, - .llseek = seq_lseek, - .write = write_debug_level, - .release = single_release, -}; - static int __init rtllib_init(void) { - struct proc_dir_entry *e; - - rtllib_debug_level = debug; - rtllib_proc = proc_mkdir(DRV_NAME, init_net.proc_net); - if (rtllib_proc == NULL) { - pr_err("Unable to create " DRV_NAME " proc directory\n"); - return -EIO; - } - e = proc_create("debug_level", S_IRUGO | S_IWUSR, rtllib_proc, &fops); - if (!e) { - remove_proc_entry(DRV_NAME, init_net.proc_net); - rtllib_proc = NULL; - return -EIO; - } return 0; } static void __exit rtllib_exit(void) { - if (rtllib_proc) { - remove_proc_entry("debug_level", rtllib_proc); - remove_proc_entry(DRV_NAME, init_net.proc_net); - rtllib_proc = NULL; - } } module_init(rtllib_init); From ca93dcba3a924214e4c0132ef1564ba52f907d94 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:38 +0200 Subject: [PATCH 0733/1163] staging: rtl8192e: Remove assert() macro Assert macro printed warning message (and was used once). Remove it, and add netdev_warn() in place where it was called. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 5 +++-- drivers/staging/rtl8192e/rtllib_debug.h | 8 -------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 6f339cd7ae3e..9a4f09dceabe 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -1885,8 +1885,9 @@ void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, return; } - assert(queue_index != TXCMD_QUEUE); - + if (queue_index != TXCMD_QUEUE) + netdev_warn(dev, "%s(): queue index != TXCMD_QUEUE\n", + __func__); memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); skb_push(skb, priv->rtllib->tx_headroom); diff --git a/drivers/staging/rtl8192e/rtllib_debug.h b/drivers/staging/rtl8192e/rtllib_debug.h index 6df8df134367..42e88d69ae63 100644 --- a/drivers/staging/rtl8192e/rtllib_debug.h +++ b/drivers/staging/rtl8192e/rtllib_debug.h @@ -76,12 +76,4 @@ do { \ printk(KERN_DEBUG DRV_NAME ":" x "\n", ##args);\ } while (0) -#define assert(expr) \ -do { \ - if (!(expr)) { \ - pr_info("Assertion failed! %s,%s,%s,line=%d\n", \ - #expr, __FILE__, __func__, __LINE__); \ - } \ -} while (0) - #endif From 7bdfaa0abfdf4d3189b499585c09de6e941e93a3 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:39 +0200 Subject: [PATCH 0734/1163] staging: rtl8192e: Fix PREFER_PR_LEVEL warnings Fix most of remaining PREFER_PR_LEVEL warnings in rtllib. Replace printk() with netdev_* if possible, pr_* in other cases. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 2 +- drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 67 +++++++++----------- drivers/staging/rtl8192e/rtllib_rx.c | 5 +- 3 files changed, 35 insertions(+), 39 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c index 7d486e8887f8..496de4f6a7bc 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c @@ -69,7 +69,7 @@ static void *rtllib_ccmp_init(int key_idx) priv->tfm = (void *)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(priv->tfm)) { - pr_debug("rtllib_crypt_ccmp: could not allocate crypto API aes\n"); + pr_debug("Could not allocate crypto API aes\n"); priv->tfm = NULL; goto fail; } diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c index 6b2047924777..2096d78913bd 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c @@ -68,8 +68,7 @@ static void *rtllib_tkip_init(int key_idx) priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(priv->tx_tfm_arc4)) { - printk(KERN_DEBUG - "rtllib_crypt_tkip: could not allocate crypto API arc4\n"); + pr_debug("Could not allocate crypto API arc4\n"); priv->tx_tfm_arc4 = NULL; goto fail; } @@ -77,8 +76,7 @@ static void *rtllib_tkip_init(int key_idx) priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(priv->tx_tfm_michael)) { - printk(KERN_DEBUG - "rtllib_crypt_tkip: could not allocate crypto API michael_mic\n"); + pr_debug("Could not allocate crypto API michael_mic\n"); priv->tx_tfm_michael = NULL; goto fail; } @@ -86,8 +84,7 @@ static void *rtllib_tkip_init(int key_idx) priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(priv->rx_tfm_arc4)) { - printk(KERN_DEBUG - "rtllib_crypt_tkip: could not allocate crypto API arc4\n"); + pr_debug("Could not allocate crypto API arc4\n"); priv->rx_tfm_arc4 = NULL; goto fail; } @@ -95,8 +92,7 @@ static void *rtllib_tkip_init(int key_idx) priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(priv->rx_tfm_michael)) { - printk(KERN_DEBUG - "rtllib_crypt_tkip: could not allocate crypto API michael_mic\n"); + pr_debug("Could not allocate crypto API michael_mic\n"); priv->rx_tfm_michael = NULL; goto fail; } @@ -403,24 +399,24 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) keyidx = pos[3]; if (!(keyidx & (1 << 5))) { if (net_ratelimit()) { - printk(KERN_DEBUG - "TKIP: received packet without ExtIV flag from %pM\n", - hdr->addr2); + netdev_dbg(skb->dev, + "Received packet without ExtIV flag from %pM\n", + hdr->addr2); } return -2; } keyidx >>= 6; if (tkey->key_idx != keyidx) { - printk(KERN_DEBUG - "TKIP: RX tkey->key_idx=%d frame keyidx=%d priv=%p\n", - tkey->key_idx, keyidx, priv); + netdev_dbg(skb->dev, + "RX tkey->key_idx=%d frame keyidx=%d priv=%p\n", + tkey->key_idx, keyidx, priv); return -6; } if (!tkey->key_set) { if (net_ratelimit()) { - printk(KERN_DEBUG - "TKIP: received packet from %pM with keyid=%d that does not have a configured key\n", - hdr->addr2, keyidx); + netdev_dbg(skb->dev, + "Received packet from %pM with keyid=%d that does not have a configured key\n", + hdr->addr2, keyidx); } return -3; } @@ -433,10 +429,10 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) (iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) && tkey->initialized) { if (net_ratelimit()) { - printk(KERN_DEBUG - "TKIP: replay detected: STA= %pM previous TSC %08x%04x received TSC %08x%04x\n", - hdr->addr2, tkey->rx_iv32, tkey->rx_iv16, - iv32, iv16); + netdev_dbg(skb->dev, + "Replay detected: STA= %pM previous TSC %08x%04x received TSC %08x%04x\n", + hdr->addr2, tkey->rx_iv32, + tkey->rx_iv16, iv32, iv16); } tkey->dot11RSNAStatsTKIPReplays++; return -4; @@ -457,9 +453,9 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) { if (net_ratelimit()) { - printk(KERN_DEBUG - ": TKIP: failed to decrypt received packet from %pM\n", - hdr->addr2); + netdev_dbg(skb->dev, + "Failed to decrypt received packet from %pM\n", + hdr->addr2); } return -7; } @@ -479,9 +475,9 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) tkey->rx_phase1_done = 0; } if (net_ratelimit()) { - printk(KERN_DEBUG - "TKIP: ICV error detected: STA= %pM\n", - hdr->addr2); + netdev_dbg(skb->dev, + "ICV error detected: STA= %pM\n", + hdr->addr2); } tkey->dot11RSNAStatsTKIPICVErrors++; return -5; @@ -566,9 +562,9 @@ static int rtllib_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) hdr = (struct rtllib_hdr_4addr *) skb->data; if (skb_tailroom(skb) < 8 || skb->len < hdr_len) { - printk(KERN_DEBUG - "Invalid packet for Michael MIC add (tailroom=%d hdr_len=%d skb->len=%d)\n", - skb_tailroom(skb), hdr_len, skb->len); + netdev_dbg(skb->dev, + "Invalid packet for Michael MIC add (tailroom=%d hdr_len=%d skb->len=%d)\n", + skb_tailroom(skb), hdr_len, skb->len); return -1; } @@ -630,12 +626,11 @@ static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx, struct rtllib_hdr_4addr *hdr; hdr = (struct rtllib_hdr_4addr *) skb->data; - printk(KERN_DEBUG - "%s: Michael MIC verification failed for MSDU from %pM keyidx=%d\n", - skb->dev ? skb->dev->name : "N/A", hdr->addr2, - keyidx); - printk(KERN_DEBUG "%d\n", - memcmp(mic, skb->data + skb->len - 8, 8) != 0); + netdev_dbg(skb->dev, + "Michael MIC verification failed for MSDU from %pM keyidx=%d\n", + hdr->addr2, keyidx); + netdev_dbg(skb->dev, "%d\n", + memcmp(mic, skb->data + skb->len - 8, 8) != 0); if (skb->dev) { pr_info("skb->dev != NULL\n"); rtllib_michael_mic_failure(skb->dev, hdr, keyidx); diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 58c9cf281959..11c6013d133e 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -346,8 +346,9 @@ rtllib_rx_frame_decrypt_msdu(struct rtllib_device *ieee, struct sk_buff *skb, res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv); atomic_dec(&crypt->refcnt); if (res < 0) { - printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed (SA= %pM keyidx=%d)\n", - ieee->dev->name, hdr->addr2, keyidx); + netdev_dbg(ieee->dev, + "MSDU decryption/MIC verification failed (SA= %pM keyidx=%d)\n", + hdr->addr2, keyidx); return -1; } From 35e33b0468ab3b3f5b610bfa4fc9367a3b7c09a8 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:40 +0200 Subject: [PATCH 0735/1163] staging: rtl8192e: Fix LONG_LINE warnings Fix most of simple LONG_LINE warnings. None of the changes should affect behaviour of code, so several modifications are included in this patch: - Code is reindented where needed - Local variable names are compacted (priv -> p) - Unnecessary casts are removed - Nested ifs are replaced with logical and - a = b = c = d expressions are split - Replace if/then series with clamp_t() - Removed unneeded scopes Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/dot11d.h | 4 +- .../staging/rtl8192e/rtl8192e/r8192E_dev.c | 22 +- .../rtl8192e/rtl8192e/r8192E_firmware.c | 29 ++- .../staging/rtl8192e/rtl8192e/r8192E_phy.c | 4 +- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 3 +- drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 191 +++++++++++------- drivers/staging/rtl8192e/rtl8192e/rtl_wx.c | 3 +- drivers/staging/rtl8192e/rtl819x_HTProc.c | 3 +- drivers/staging/rtl8192e/rtl819x_TSProc.c | 21 +- drivers/staging/rtl8192e/rtllib_rx.c | 171 ++++++++++------ drivers/staging/rtl8192e/rtllib_softmac.c | 36 ++-- drivers/staging/rtl8192e/rtllib_tx.c | 41 ++-- 12 files changed, 314 insertions(+), 214 deletions(-) diff --git a/drivers/staging/rtl8192e/dot11d.h b/drivers/staging/rtl8192e/dot11d.h index aad3394392fe..69e0f8f7e3f8 100644 --- a/drivers/staging/rtl8192e/dot11d.h +++ b/drivers/staging/rtl8192e/dot11d.h @@ -74,8 +74,8 @@ static inline void cpMacAddr(unsigned char *des, unsigned char *src) (GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen > 0) #define IS_EQUAL_CIE_SRC(__pIeeeDev, __pTa) \ - ether_addr_equal_unaligned(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, \ - __pTa) + ether_addr_equal_unaligned( \ + GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa) #define UPDATE_CIE_SRC(__pIeeeDev, __pTa) \ cpMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa) diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c index f9c61530cf8a..e023c706a21d 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c @@ -30,7 +30,8 @@ #include "rtl_dm.h" #include "rtl_wx.h" -static int WDCAPARA_ADD[] = {EDCAPARA_BE, EDCAPARA_BK, EDCAPARA_VI, EDCAPARA_VO}; +static int WDCAPARA_ADD[] = {EDCAPARA_BE, EDCAPARA_BK, EDCAPARA_VI, + EDCAPARA_VO}; void rtl8192e_start_beacon(struct net_device *dev) { @@ -187,22 +188,21 @@ void rtl8192e_SetHwReg(struct net_device *dev, u8 variable, u8 *val) u8 u1bAIFS; u32 u4bAcParam; u8 mode = priv->rtllib->mode; - struct rtllib_qos_parameters *qos_parameters = + struct rtllib_qos_parameters *qop = &priv->rtllib->current_network.qos_data.parameters; - u1bAIFS = qos_parameters->aifs[pAcParam] * + u1bAIFS = qop->aifs[pAcParam] * ((mode&(IEEE_G|IEEE_N_24G)) ? 9 : 20) + aSifsTime; dm_init_edca_turbo(dev); - u4bAcParam = (((le16_to_cpu( - qos_parameters->tx_op_limit[pAcParam])) << - AC_PARAM_TXOP_LIMIT_OFFSET) | - ((le16_to_cpu(qos_parameters->cw_max[pAcParam])) << - AC_PARAM_ECW_MAX_OFFSET) | - ((le16_to_cpu(qos_parameters->cw_min[pAcParam])) << - AC_PARAM_ECW_MIN_OFFSET) | - (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET)); + u4bAcParam = (le16_to_cpu(qop->tx_op_limit[pAcParam]) << + AC_PARAM_TXOP_LIMIT_OFFSET) | + ((le16_to_cpu(qop->cw_max[pAcParam])) << + AC_PARAM_ECW_MAX_OFFSET) | + ((le16_to_cpu(qop->cw_min[pAcParam])) << + AC_PARAM_ECW_MIN_OFFSET) | + (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET); RT_TRACE(COMP_DBG, "%s():HW_VAR_AC_PARAM eACI:%x:%x\n", __func__, eACI, u4bAcParam); diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c index c465f8749acd..02c5b0a21b6a 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c @@ -230,7 +230,7 @@ bool init_firmware(struct net_device *dev) u32 file_length = 0; u8 *mapped_file = NULL; - u8 init_step = 0; + u8 i = 0; enum opt_rst_type rst_opt = OPT_SYSTEM_RESET; enum firmware_init_step starting_state = FW_INIT_STEP0_BOOT; @@ -250,10 +250,9 @@ bool init_firmware(struct net_device *dev) "PlatformInitFirmware: undefined firmware state\n"); } - for (init_step = starting_state; init_step <= FW_INIT_STEP2_DATA; - init_step++) { + for (i = starting_state; i <= FW_INIT_STEP2_DATA; i++) { if (rst_opt == OPT_SYSTEM_RESET) { - if (pfirmware->firmware_buf_size[init_step] == 0) { + if (pfirmware->firmware_buf_size[i] == 0) { const char *fw_name[3] = { RTL8192E_BOOT_IMG_FW, RTL8192E_MAIN_IMG_FW, @@ -263,7 +262,7 @@ bool init_firmware(struct net_device *dev) int rc; rc = request_firmware(&fw_entry, - fw_name[init_step], + fw_name[i], &priv->pdev->dev); if (rc < 0) { RT_TRACE(COMP_FIRMWARE, @@ -271,24 +270,24 @@ bool init_firmware(struct net_device *dev) goto download_firmware_fail; } if (fw_entry->size > - sizeof(pfirmware->firmware_buf[init_step])) { + sizeof(pfirmware->firmware_buf[i])) { RT_TRACE(COMP_FIRMWARE, "img file size exceed the container struct buffer fail!\n"); goto download_firmware_fail; } - if (init_step != FW_INIT_STEP1_MAIN) { - memcpy(pfirmware->firmware_buf[init_step], + if (i != FW_INIT_STEP1_MAIN) { + memcpy(pfirmware->firmware_buf[i], fw_entry->data, fw_entry->size); - pfirmware->firmware_buf_size[init_step] = + pfirmware->firmware_buf_size[i] = fw_entry->size; } else { - memset(pfirmware->firmware_buf[init_step], + memset(pfirmware->firmware_buf[i], 0, 128); - memcpy(&pfirmware->firmware_buf[init_step][128], + memcpy(&pfirmware->firmware_buf[i][128], fw_entry->data, fw_entry->size); - pfirmware->firmware_buf_size[init_step] = + pfirmware->firmware_buf_size[i] = fw_entry->size + 128; } @@ -297,14 +296,14 @@ bool init_firmware(struct net_device *dev) } } - mapped_file = pfirmware->firmware_buf[init_step]; - file_length = pfirmware->firmware_buf_size[init_step]; + mapped_file = pfirmware->firmware_buf[i]; + file_length = pfirmware->firmware_buf_size[i]; rt_status = fw_download_code(dev, mapped_file, file_length); if (!rt_status) goto download_firmware_fail; - if (!firmware_check_ready(dev, init_step)) + if (!firmware_check_ready(dev, i)) goto download_firmware_fail; } diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c index eea2e39ff594..0765c97e06a8 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c @@ -628,8 +628,8 @@ void rtl8192_phy_getTxPower(struct net_device *dev) priv->DefaultInitialGain[3] = read_nic_byte(dev, rOFDM0_XDAGCCore1); RT_TRACE(COMP_INIT, "Default initial gain (c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x)\n", - priv->DefaultInitialGain[0], priv->DefaultInitialGain[1], - priv->DefaultInitialGain[2], priv->DefaultInitialGain[3]); + priv->DefaultInitialGain[0], priv->DefaultInitialGain[1], + priv->DefaultInitialGain[2], priv->DefaultInitialGain[3]); priv->framesync = read_nic_byte(dev, rOFDM0_RxDetector3); priv->framesyncC34 = read_nic_dword(dev, rOFDM0_RxDetector2); diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 9a4f09dceabe..d73dd573a5b7 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -2068,8 +2068,7 @@ static short rtl8192_alloc_rx_desc_ring(struct net_device *dev) int i, rx_queue_idx; for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx++) { - priv->rx_ring[rx_queue_idx] = - pci_zalloc_consistent(priv->pdev, + priv->rx_ring[rx_queue_idx] = pci_zalloc_consistent(priv->pdev, sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount, &priv->rx_ring_dma[rx_queue_idx]); if (!priv->rx_ring[rx_queue_idx] || diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c index ba69157a86b4..a9218579d80f 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c @@ -248,7 +248,8 @@ void init_hal_dm(struct net_device *dev) if (IS_HARDWARE_TYPE_8192SE(dev)) dm_Init_WA_Broadcom_IOT(dev); - INIT_DELAYED_WORK_RSL(&priv->gpio_change_rf_wq, (void *)dm_CheckRfCtrlGPIO, dev); + INIT_DELAYED_WORK_RSL(&priv->gpio_change_rf_wq, + (void *)dm_CheckRfCtrlGPIO, dev); } void deinit_hal_dm(struct net_device *dev) @@ -288,8 +289,8 @@ void hal_dm_watchdog(struct net_device *dev) static void dm_check_ac_dc_power(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - static char *ac_dc_check_script_path = "/etc/acpi/wireless-rtl-ac-dc-power.sh"; - char *argv[] = {ac_dc_check_script_path, DRV_NAME, NULL}; + static char *ac_dc_script = "/etc/acpi/wireless-rtl-ac-dc-power.sh"; + char *argv[] = {ac_dc_script, DRV_NAME, NULL}; static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", @@ -303,7 +304,7 @@ static void dm_check_ac_dc_power(struct net_device *dev) if (priv->rtllib->state != RTLLIB_LINKED) return; - call_usermodehelper(ac_dc_check_script_path, argv, envp, UMH_WAIT_PROC); + call_usermodehelper(ac_dc_script, argv, envp, UMH_WAIT_PROC); return; }; @@ -313,7 +314,7 @@ void init_rate_adaptive(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rate_adaptive *pra = (struct rate_adaptive *)&priv->rate_adaptive; + struct rate_adaptive *pra = &priv->rate_adaptive; pra->ratr_state = DM_RATR_STA_MAX; pra->high2low_rssi_thresh_for_ra = RateAdaptiveTH_High; @@ -354,14 +355,15 @@ static void dm_check_rate_adaptive(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_hi_throughput *pHTInfo = priv->rtllib->pHTInfo; - struct rate_adaptive *pra = (struct rate_adaptive *)&priv->rate_adaptive; + struct rate_adaptive *pra = &priv->rate_adaptive; u32 currentRATR, targetRATR = 0; u32 LowRSSIThreshForRA = 0, HighRSSIThreshForRA = 0; bool bshort_gi_enabled = false; static u8 ping_rssi_state; if (!priv->up) { - RT_TRACE(COMP_RATE, "<---- dm_check_rate_adaptive(): driver is going to unload\n"); + RT_TRACE(COMP_RATE, + "<---- dm_check_rate_adaptive(): driver is going to unload\n"); return; } @@ -374,25 +376,31 @@ static void dm_check_rate_adaptive(struct net_device *dev) if (priv->rtllib->state == RTLLIB_LINKED) { - bshort_gi_enabled = (pHTInfo->bCurTxBW40MHz && pHTInfo->bCurShortGI40MHz) || - (!pHTInfo->bCurTxBW40MHz && pHTInfo->bCurShortGI20MHz); - + bshort_gi_enabled = (pHTInfo->bCurTxBW40MHz && + pHTInfo->bCurShortGI40MHz) || + (!pHTInfo->bCurTxBW40MHz && + pHTInfo->bCurShortGI20MHz); pra->upper_rssi_threshold_ratr = - (pra->upper_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0); + (pra->upper_rssi_threshold_ratr & (~BIT31)) | + ((bshort_gi_enabled) ? BIT31 : 0); pra->middle_rssi_threshold_ratr = - (pra->middle_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0); + (pra->middle_rssi_threshold_ratr & (~BIT31)) | + ((bshort_gi_enabled) ? BIT31 : 0); if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) { pra->low_rssi_threshold_ratr = - (pra->low_rssi_threshold_ratr_40M & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0); + (pra->low_rssi_threshold_ratr_40M & (~BIT31)) | + ((bshort_gi_enabled) ? BIT31 : 0); } else { pra->low_rssi_threshold_ratr = - (pra->low_rssi_threshold_ratr_20M & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0); + (pra->low_rssi_threshold_ratr_20M & (~BIT31)) | + ((bshort_gi_enabled) ? BIT31 : 0); } pra->ping_rssi_ratr = - (pra->ping_rssi_ratr & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0); + (pra->ping_rssi_ratr & (~BIT31)) | + ((bshort_gi_enabled) ? BIT31 : 0); if (pra->ratr_state == DM_RATR_STA_HIGH) { HighRSSIThreshForRA = pra->high2low_rssi_thresh_for_ra; @@ -408,10 +416,12 @@ static void dm_check_rate_adaptive(struct net_device *dev) (pra->low_rssi_thresh_for_ra40M) : (pra->low_rssi_thresh_for_ra20M); } - if (priv->undecorated_smoothed_pwdb >= (long)HighRSSIThreshForRA) { + if (priv->undecorated_smoothed_pwdb >= + (long)HighRSSIThreshForRA) { pra->ratr_state = DM_RATR_STA_HIGH; targetRATR = pra->upper_rssi_threshold_ratr; - } else if (priv->undecorated_smoothed_pwdb >= (long)LowRSSIThreshForRA) { + } else if (priv->undecorated_smoothed_pwdb >= + (long)LowRSSIThreshForRA) { pra->ratr_state = DM_RATR_STA_MIDDLE; targetRATR = pra->middle_rssi_threshold_ratr; } else { @@ -420,8 +430,10 @@ static void dm_check_rate_adaptive(struct net_device *dev) } if (pra->ping_rssi_enable) { - if (priv->undecorated_smoothed_pwdb < (long)(pra->ping_rssi_thresh_for_ra+5)) { - if ((priv->undecorated_smoothed_pwdb < (long)pra->ping_rssi_thresh_for_ra) || + if (priv->undecorated_smoothed_pwdb < + (long)(pra->ping_rssi_thresh_for_ra+5)) { + if ((priv->undecorated_smoothed_pwdb < + (long)pra->ping_rssi_thresh_for_ra) || ping_rssi_state) { pra->ratr_state = DM_RATR_STA_LOW; targetRATR = pra->ping_rssi_ratr; @@ -722,7 +734,8 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev) if (viviflag) { write_nic_byte(dev, Pw_Track_Flag, 0); viviflag = false; - RT_TRACE(COMP_POWER_TRACKING, "we filted this data\n"); + RT_TRACE(COMP_POWER_TRACKING, + "we filted this data\n"); for (k = 0; k < 5; k++) tmp_report[k] = 0; break; @@ -731,7 +744,7 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev) for (k = 0; k < 5; k++) Avg_TSSI_Meas_from_driver += tmp_report[k]; - Avg_TSSI_Meas_from_driver = Avg_TSSI_Meas_from_driver*100/5; + Avg_TSSI_Meas_from_driver *= 100 / 5; RT_TRACE(COMP_POWER_TRACKING, "Avg_TSSI_Meas_from_driver = %d\n", Avg_TSSI_Meas_from_driver); @@ -844,12 +857,15 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device *dev) int i = 0, CCKSwingNeedUpdate = 0; if (!priv->btxpower_trackingInit) { - tmpRegA = rtl8192_QueryBBReg(dev, rOFDM0_XATxIQImbalance, bMaskDWord); + tmpRegA = rtl8192_QueryBBReg(dev, rOFDM0_XATxIQImbalance, + bMaskDWord); for (i = 0; i < OFDM_Table_Length; i++) { if (tmpRegA == OFDMSwingTable[i]) { priv->OFDM_index[0] = (u8)i; - RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x = 0x%x, OFDM_index = 0x%x\n", - rOFDM0_XATxIQImbalance, tmpRegA, priv->OFDM_index[0]); + RT_TRACE(COMP_POWER_TRACKING, + "Initial reg0x%x = 0x%x, OFDM_index = 0x%x\n", + rOFDM0_XATxIQImbalance, tmpRegA, + priv->OFDM_index[0]); } } @@ -997,7 +1013,8 @@ static void dm_CheckTXPowerTracking_TSSI(struct net_device *dev) if (tx_power_track_counter >= 180) { - queue_delayed_work_rsl(priv->priv_wq, &priv->txpower_tracking_wq, 0); + queue_delayed_work_rsl(priv->priv_wq, + &priv->txpower_tracking_wq, 0); tx_power_track_counter = 0; } @@ -1084,53 +1101,57 @@ static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool bInCH14) } } -static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH14) +static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, + bool bInCH14) { u32 TempVal; struct r8192_priv *priv = rtllib_priv(dev); TempVal = 0; if (!bInCH14) { - TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][0] + - (CCKSwingTable_Ch1_Ch13[priv->CCK_index][1]<<8); + TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][0] + + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][1] << 8); rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); - RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n", - rCCK0_TxFilter1, TempVal); - TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][2] + - (CCKSwingTable_Ch1_Ch13[priv->CCK_index][3]<<8) + - (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4]<<16)+ - (CCKSwingTable_Ch1_Ch13[priv->CCK_index][5]<<24); + RT_TRACE(COMP_POWER_TRACKING, + "CCK not chnl 14, reg 0x%x = 0x%x\n", rCCK0_TxFilter1, + TempVal); + TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][2] + + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][3] << 8) + + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4] << 16)+ + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][5] << 24); rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); - RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n", - rCCK0_TxFilter2, TempVal); - TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][6] + - (CCKSwingTable_Ch1_Ch13[priv->CCK_index][7]<<8); + RT_TRACE(COMP_POWER_TRACKING, + "CCK not chnl 14, reg 0x%x = 0x%x\n", rCCK0_TxFilter2, + TempVal); + TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][6] + + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][7] << 8); rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); - RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n", - rCCK0_DebugPort, TempVal); + RT_TRACE(COMP_POWER_TRACKING, + "CCK not chnl 14, reg 0x%x = 0x%x\n", rCCK0_DebugPort, + TempVal); } else { - TempVal = CCKSwingTable_Ch14[priv->CCK_index][0] + - (CCKSwingTable_Ch14[priv->CCK_index][1]<<8); + TempVal = CCKSwingTable_Ch14[priv->CCK_index][0] + + (CCKSwingTable_Ch14[priv->CCK_index][1] << 8); rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n", rCCK0_TxFilter1, TempVal); - TempVal = CCKSwingTable_Ch14[priv->CCK_index][2] + - (CCKSwingTable_Ch14[priv->CCK_index][3]<<8) + - (CCKSwingTable_Ch14[priv->CCK_index][4]<<16)+ - (CCKSwingTable_Ch14[priv->CCK_index][5]<<24); + TempVal = CCKSwingTable_Ch14[priv->CCK_index][2] + + (CCKSwingTable_Ch14[priv->CCK_index][3] << 8) + + (CCKSwingTable_Ch14[priv->CCK_index][4] << 16)+ + (CCKSwingTable_Ch14[priv->CCK_index][5] << 24); rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n", rCCK0_TxFilter2, TempVal); - TempVal = CCKSwingTable_Ch14[priv->CCK_index][6] + - (CCKSwingTable_Ch14[priv->CCK_index][7]<<8); + TempVal = CCKSwingTable_Ch14[priv->CCK_index][6] + + (CCKSwingTable_Ch14[priv->CCK_index][7]<<8); rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n", rCCK0_DebugPort, TempVal); } - } +} void dm_cck_txpower_adjust(struct net_device *dev, bool binch14) { @@ -1181,7 +1202,8 @@ void dm_restore_dynamic_mechanism_state(struct net_device *dev) u32 ratr_value; if (!priv->up) { - RT_TRACE(COMP_RATE, "<---- dm_restore_dynamic_mechanism_state(): driver is going to unload\n"); + RT_TRACE(COMP_RATE, + "<---- dm_restore_dynamic_mechanism_state(): driver is going to unload\n"); return; } @@ -1325,8 +1347,10 @@ static void dm_dig_init(struct net_device *dev) dm_digtable.dig_state = DM_STA_DIG_MAX; dm_digtable.dig_highpwr_state = DM_STA_DIG_MAX; - dm_digtable.CurSTAConnectState = dm_digtable.PreSTAConnectState = DIG_STA_DISCONNECT; - dm_digtable.CurAPConnectState = dm_digtable.PreAPConnectState = DIG_AP_DISCONNECT; + dm_digtable.CurSTAConnectState = DIG_STA_DISCONNECT; + dm_digtable.PreSTAConnectState = DIG_STA_DISCONNECT; + dm_digtable.CurAPConnectState = DIG_AP_DISCONNECT; + dm_digtable.PreAPConnectState = DIG_AP_DISCONNECT; dm_digtable.initialgain_lowerbound_state = false; dm_digtable.rssi_low_thresh = DM_DIG_THRESH_LOW; @@ -1512,11 +1536,14 @@ static void dm_ctrl_initgain_byrssi_highpwr(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); static u32 reset_cnt_highpwr; - if ((priv->undecorated_smoothed_pwdb > dm_digtable.rssi_high_power_lowthresh) && - (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_power_highthresh)) + if ((priv->undecorated_smoothed_pwdb > + dm_digtable.rssi_high_power_lowthresh) && + (priv->undecorated_smoothed_pwdb < + dm_digtable.rssi_high_power_highthresh)) return; - if (priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_power_highthresh) { + if (priv->undecorated_smoothed_pwdb >= + dm_digtable.rssi_high_power_highthresh) { if (dm_digtable.dig_highpwr_state == DM_STA_DIG_ON && (priv->reset_count == reset_cnt_highpwr)) return; @@ -1532,8 +1559,10 @@ static void dm_ctrl_initgain_byrssi_highpwr(struct net_device *dev) return; dm_digtable.dig_highpwr_state = DM_STA_DIG_OFF; - if (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_power_lowthresh && - priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh) { + if ((priv->undecorated_smoothed_pwdb < + dm_digtable.rssi_high_power_lowthresh) && + (priv->undecorated_smoothed_pwdb >= + dm_digtable.rssi_high_thresh)) { if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); else @@ -1562,12 +1591,12 @@ static void dm_initial_gain(struct net_device *dev) if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) { if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) { - if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) > dm_digtable.rx_gain_range_max) - dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max; - else if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) < dm_digtable.rx_gain_range_min) - dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_min; - else - dm_digtable.cur_ig_value = dm_digtable.rssi_val+10-dm_digtable.backoff_val; + long gain_range = dm_digtable.rssi_val + 10 - + dm_digtable.backoff_val; + gain_range = clamp_t(long, gain_range, + dm_digtable.rx_gain_range_min, + dm_digtable.rx_gain_range_max); + dm_digtable.cur_ig_value = gain_range; } else { if (dm_digtable.cur_ig_value == 0) dm_digtable.cur_ig_value = priv->DefaultInitialGain[0]; @@ -1613,15 +1642,23 @@ static void dm_pd_th(struct net_device *dev) if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) { if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) { - if (dm_digtable.rssi_val >= dm_digtable.rssi_high_power_highthresh) - dm_digtable.curpd_thstate = DIG_PD_AT_HIGH_POWER; - else if (dm_digtable.rssi_val <= dm_digtable.rssi_low_thresh) - dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER; - else if ((dm_digtable.rssi_val >= dm_digtable.rssi_high_thresh) && - (dm_digtable.rssi_val < dm_digtable.rssi_high_power_lowthresh)) - dm_digtable.curpd_thstate = DIG_PD_AT_NORMAL_POWER; + if (dm_digtable.rssi_val >= + dm_digtable.rssi_high_power_highthresh) + dm_digtable.curpd_thstate = + DIG_PD_AT_HIGH_POWER; + else if (dm_digtable.rssi_val <= + dm_digtable.rssi_low_thresh) + dm_digtable.curpd_thstate = + DIG_PD_AT_LOW_POWER; + else if ((dm_digtable.rssi_val >= + dm_digtable.rssi_high_thresh) && + (dm_digtable.rssi_val < + dm_digtable.rssi_high_power_lowthresh)) + dm_digtable.curpd_thstate = + DIG_PD_AT_NORMAL_POWER; else - dm_digtable.curpd_thstate = dm_digtable.prepd_thstate; + dm_digtable.curpd_thstate = + dm_digtable.prepd_thstate; } else { dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER; } @@ -1641,7 +1678,8 @@ static void dm_pd_th(struct net_device *dev) write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00); else write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); - } else if (dm_digtable.curpd_thstate == DIG_PD_AT_NORMAL_POWER) { + } else if (dm_digtable.curpd_thstate == + DIG_PD_AT_NORMAL_POWER) { if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); else @@ -1796,7 +1834,8 @@ static void dm_check_edca_turbo(struct net_device *dev) if (priv->bcurrent_turbo_EDCA) { u8 tmp = AC0_BE; - priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8 *)(&tmp)); + priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, + (u8 *)(&tmp)); priv->bcurrent_turbo_EDCA = false; } } @@ -1866,7 +1905,8 @@ void dm_CheckRfCtrlGPIO(void *data) bool bActuallySet = false; char *argv[3]; static char *RadioPowerPath = "/etc/acpi/events/RadioPower.sh"; - static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", NULL}; + static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", + NULL}; bActuallySet = false; @@ -1897,7 +1937,8 @@ void dm_CheckRfCtrlGPIO(void *data) if (bActuallySet) { mdelay(1000); priv->bHwRfOffAction = 1; - MgntActSet_RF_State(dev, eRfPowerStateToSet, RF_CHANGE_BY_HW, true); + MgntActSet_RF_State(dev, eRfPowerStateToSet, RF_CHANGE_BY_HW, + true); if (priv->bHwRadioOff) argv[1] = "RFOFF"; else diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c index 43702df399de..2e6c4fab60fe 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c @@ -613,7 +613,8 @@ static int r8192_wx_set_nick(struct net_device *dev, if (wrqu->data.length > IW_ESSID_MAX_SIZE) return -E2BIG; down(&priv->wx_sem); - wrqu->data.length = min_t(size_t, wrqu->data.length, sizeof(priv->nick)); + wrqu->data.length = min_t(size_t, wrqu->data.length, + sizeof(priv->nick)); memset(priv->nick, 0, sizeof(priv->nick)); memcpy(priv->nick, extra, wrqu->data.length); up(&priv->wx_sem); diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index 3edd5d1a05fb..dcf8db1a7d29 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -236,7 +236,8 @@ static bool HTIOTActIsDisableMCSTwoSpatialStream(struct rtllib_device *ieee) return false; } -static u8 HTIOTActIsDisableEDCATurbo(struct rtllib_device *ieee, u8 *PeerMacAddr) +static u8 HTIOTActIsDisableEDCATurbo(struct rtllib_device *ieee, + u8 *PeerMacAddr) { return false; } diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index dea86ea9066d..8a5dd6ef8074 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -49,8 +49,10 @@ static void RxPktPendingTimeout(unsigned long data) if (index == 0) pRxTs->RxIndicateSeq = pReorderEntry->SeqNum; - if (SN_LESS(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) || - SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq)) { + if (SN_LESS(pReorderEntry->SeqNum, + pRxTs->RxIndicateSeq) || + SN_EQUAL(pReorderEntry->SeqNum, + pRxTs->RxIndicateSeq)) { list_del_init(&pReorderEntry->List); if (SN_EQUAL(pReorderEntry->SeqNum, @@ -92,7 +94,8 @@ static void RxPktPendingTimeout(unsigned long data) if (bPktInBuf && (pRxTs->RxTimeoutIndicateSeq == 0xffff)) { pRxTs->RxTimeoutIndicateSeq = pRxTs->RxIndicateSeq; mod_timer(&pRxTs->RxPktPendingTimer, jiffies + - msecs_to_jiffies(ieee->pHTInfo->RxReorderPendingTime)); + msecs_to_jiffies(ieee->pHTInfo->RxReorderPendingTime) + ); } spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); } @@ -269,10 +272,10 @@ static struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, if (!search_dir[dir]) continue; list_for_each_entry(pRet, psearch_list, List) { - if (memcmp(pRet->Addr, Addr, 6) == 0) - if (pRet->TSpec.f.TSInfo.field.ucTSID == TID) - if (pRet->TSpec.f.TSInfo.field.ucDirection == dir) - break; + if (memcmp(pRet->Addr, Addr, 6) == 0 && + pRet->TSpec.f.TSInfo.field.ucTSID == TID && + pRet->TSpec.f.TSInfo.field.ucDirection == dir) + break; } if (&pRet->List != psearch_list) @@ -415,8 +418,8 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, return false; } -static void RemoveTsEntry(struct rtllib_device *ieee, struct ts_common_info *pTs, - enum tr_select TxRxSelect) +static void RemoveTsEntry(struct rtllib_device *ieee, + struct ts_common_info *pTs, enum tr_select TxRxSelect) { del_timer_sync(&pTs->SetupTimer); del_timer_sync(&pTs->InactTimer); diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 11c6013d133e..8e3aabf6e796 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -45,8 +45,9 @@ #include "dot11d.h" static inline void rtllib_monitor_rx(struct rtllib_device *ieee, - struct sk_buff *skb, struct rtllib_rx_stats *rx_status, - size_t hdr_length) + struct sk_buff *skb, + struct rtllib_rx_stats *rx_status, + size_t hdr_length) { skb->dev = ieee->dev; skb_reset_mac_header(skb); @@ -101,7 +102,8 @@ rtllib_frag_cache_get(struct rtllib_device *ieee, struct rtllib_hdr_4addrqos *hdr_4addrqos; u8 tid; - if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && RTLLIB_QOS_HAS_SEQ(fc)) { + if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && + RTLLIB_QOS_HAS_SEQ(fc)) { hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr; tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; tid = UP2AC(tid); @@ -123,7 +125,8 @@ rtllib_frag_cache_get(struct rtllib_device *ieee, 2 /* alignment */ + 8 /* WEP */ + ETH_ALEN /* WDS */ + - (RTLLIB_QOS_HAS_SEQ(fc) ? 2 : 0) /* QOS Control */); + /* QOS Control */ + (RTLLIB_QOS_HAS_SEQ(fc) ? 2 : 0)); if (skb == NULL) return NULL; @@ -169,7 +172,8 @@ static int rtllib_frag_cache_invalidate(struct rtllib_device *ieee, struct rtllib_hdr_4addrqos *hdr_4addrqos; u8 tid; - if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && RTLLIB_QOS_HAS_SEQ(fc)) { + if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && + RTLLIB_QOS_HAS_SEQ(fc)) { hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr; tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; tid = UP2AC(tid); @@ -291,7 +295,8 @@ rtllib_rx_frame_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, return 0; if (ieee->hwsec_active) { - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *) + (skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->bHwSec = 1; @@ -331,7 +336,8 @@ rtllib_rx_frame_decrypt_msdu(struct rtllib_device *ieee, struct sk_buff *skb, if (crypt == NULL || crypt->ops->decrypt_msdu == NULL) return 0; if (ieee->hwsec_active) { - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *) + (skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->bHwSec = 1; @@ -371,7 +377,8 @@ static int is_duplicate_packet(struct rtllib_device *ieee, struct rtllib_hdr_4addrqos *hdr_4addrqos; u8 tid; - if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && RTLLIB_QOS_HAS_SEQ(fc)) { + if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && + RTLLIB_QOS_HAS_SEQ(fc)) { hdr_4addrqos = (struct rtllib_hdr_4addrqos *)header; tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; tid = UP2AC(tid); @@ -399,7 +406,8 @@ static int is_duplicate_packet(struct rtllib_device *ieee, break; } if (p == &ieee->ibss_mac_hash[index]) { - entry = kmalloc(sizeof(struct ieee_ibss_seq), GFP_ATOMIC); + entry = kmalloc(sizeof(struct ieee_ibss_seq), + GFP_ATOMIC); if (!entry) return 0; @@ -469,7 +477,8 @@ static bool AddReorderEntry(struct rx_ts_record *pTS, return true; } -void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb **prxbIndicateArray, u8 index) +void rtllib_indicate_packets(struct rtllib_device *ieee, + struct rtllib_rxb **prxbIndicateArray, u8 index) { struct net_device_stats *stats = &ieee->stats; u8 i = 0, j = 0; @@ -484,9 +493,12 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb **prx /* convert hdr + possible LLC headers into Ethernet header */ ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7]; if (sub_skb->len >= 8 && - ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 && - ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || - memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) { + ((memcmp(sub_skb->data, rfc1042_header, + SNAP_SIZE) == 0 && + ethertype != ETH_P_AARP && + ethertype != ETH_P_IPX) || + memcmp(sub_skb->data, bridge_tunnel_header, + SNAP_SIZE) == 0)) { /* remove RFC1042 or Bridge-Tunnel encapsulation * and replace EtherType */ @@ -508,11 +520,13 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb **prx stats->rx_bytes += sub_skb->len; memset(sub_skb->cb, 0, sizeof(sub_skb->cb)); - sub_skb->protocol = eth_type_trans(sub_skb, ieee->dev); + sub_skb->protocol = eth_type_trans(sub_skb, + ieee->dev); sub_skb->dev = ieee->dev; sub_skb->dev->stats.rx_packets++; sub_skb->dev->stats.rx_bytes += sub_skb->len; - sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */ + /* 802.11 crc not sufficient */ + sub_skb->ip_summed = CHECKSUM_NONE; ieee->last_rx_ps_time = jiffies; netif_rx(sub_skb); } @@ -522,7 +536,8 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb **prx } } -void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record *pTS) +void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, + struct rx_ts_record *pTS) { struct rx_reorder_entry *pRxReorderEntry; u8 RfdCnt = 0; @@ -536,7 +551,9 @@ void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record break; } - pRxReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev, struct rx_reorder_entry, List); + pRxReorderEntry = (struct rx_reorder_entry *) + list_entry(pTS->RxPendingPktList.prev, + struct rx_reorder_entry, List); netdev_dbg(ieee->dev, "%s(): Indicate SeqNum %d!\n", __func__, pRxReorderEntry->SeqNum); list_del_init(&pRxReorderEntry->List); @@ -544,7 +561,8 @@ void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record ieee->RfdArray[RfdCnt] = pRxReorderEntry->prxb; RfdCnt = RfdCnt + 1; - list_add_tail(&pRxReorderEntry->List, &ieee->RxReorder_Unused_List); + list_add_tail(&pRxReorderEntry->List, + &ieee->RxReorder_Unused_List); } rtllib_indicate_packets(ieee, ieee->RfdArray, RfdCnt); @@ -603,10 +621,11 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, if (SeqNum >= (WinSize - 1)) pTS->RxIndicateSeq = SeqNum + 1 - WinSize; else - pTS->RxIndicateSeq = 4095 - (WinSize - (SeqNum + 1)) + 1; - netdev_dbg(ieee->dev, - "Window Shift! IndicateSeq: %d, NewSeq: %d\n", - pTS->RxIndicateSeq, SeqNum); + pTS->RxIndicateSeq = 4095 - + (WinSize - (SeqNum + 1)) + 1; + netdev_dbg(ieee->dev, + "Window Shift! IndicateSeq: %d, NewSeq: %d\n", + pTS->RxIndicateSeq, SeqNum); } /* Indication process. @@ -621,7 +640,8 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, */ if (bMatchWinStart) { /* Current packet is going to be indicated.*/ - netdev_dbg(ieee->dev, "Packets indication! IndicateSeq: %d, NewSeq: %d\n", + netdev_dbg(ieee->dev, + "Packets indication! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, SeqNum); ieee->prxbIndicateArray[0] = prxb; index = 1; @@ -633,24 +653,26 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, struct rx_reorder_entry, List); list_del_init(&pReorderEntry->List); - /* Make a reorder entry and insert into a the packet list.*/ + /* Make a reorder entry and insert + * into a the packet list. + */ pReorderEntry->SeqNum = SeqNum; pReorderEntry->prxb = prxb; if (!AddReorderEntry(pTS, pReorderEntry)) { + int i; + netdev_dbg(ieee->dev, "%s(): Duplicate packet is dropped. IndicateSeq: %d, NewSeq: %d\n", __func__, pTS->RxIndicateSeq, SeqNum); list_add_tail(&pReorderEntry->List, - &ieee->RxReorder_Unused_List); { - int i; + &ieee->RxReorder_Unused_List); - for (i = 0; i < prxb->nr_subframes; i++) - dev_kfree_skb(prxb->subframes[i]); - kfree(prxb); - prxb = NULL; - } + for (i = 0; i < prxb->nr_subframes; i++) + dev_kfree_skb(prxb->subframes[i]); + kfree(prxb); + prxb = NULL; } else { netdev_dbg(ieee->dev, "Pkt insert into struct buffer. IndicateSeq: %d, NewSeq: %d\n", @@ -681,10 +703,12 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, netdev_dbg(ieee->dev, "%s(): start RREORDER indicate\n", __func__); - pReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev, - struct rx_reorder_entry, List); + pReorderEntry = (struct rx_reorder_entry *) + list_entry(pTS->RxPendingPktList.prev, + struct rx_reorder_entry, + List); if (SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) || - SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) { + SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) { /* This protect struct buffer from overflow. */ if (index >= REORDER_WIN_SIZE) { netdev_err(ieee->dev, @@ -697,7 +721,8 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, list_del_init(&pReorderEntry->List); if (SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) - pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096; + pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % + 4096; ieee->prxbIndicateArray[index] = pReorderEntry->prxb; netdev_dbg(ieee->dev, "%s(): Indicate SeqNum %d!\n", @@ -912,7 +937,8 @@ static int rtllib_rx_check_duplicate(struct rtllib_device *ieee, !ieee->current_network.qos_data.active || !IsDataFrame(skb->data) || IsLegacyDataFrame(skb->data)) { - if (!((type == RTLLIB_FTYPE_MGMT) && (stype == RTLLIB_STYPE_BEACON))) { + if (!((type == RTLLIB_FTYPE_MGMT) && + (stype == RTLLIB_STYPE_BEACON))) { if (is_duplicate_packet(ieee, hdr)) return -1; } @@ -1015,7 +1041,8 @@ static int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, /* {broad,multi}cast packets to our BSS go through */ if (is_multicast_ether_addr(dst)) { - if (memcmp(bssid, ieee->current_network.bssid, ETH_ALEN)) + if (memcmp(bssid, ieee->current_network.bssid, + ETH_ALEN)) return -1; } } @@ -1193,7 +1220,8 @@ static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, return 0; } -static void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_subframes) +static void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, + u8 nr_subframes) { if (unicast) { @@ -1310,7 +1338,8 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, /*Filter pkt has too small length */ hdrlen = rtllib_rx_get_hdrlen(ieee, skb, rx_stats); if (skb->len < hdrlen) { - netdev_info(dev, "%s():ERR!!! skb->len is smaller than hdrlen\n", + netdev_info(dev, + "%s():ERR!!! skb->len is smaller than hdrlen\n", __func__); goto rx_dropped; } @@ -1355,10 +1384,13 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, goto rx_dropped; /* Send pspoll based on moredata */ - if ((ieee->iw_mode == IW_MODE_INFRA) && (ieee->sta_sleep == LPS_IS_SLEEP) - && (ieee->polling) && (!bToOtherSTA)) { + if ((ieee->iw_mode == IW_MODE_INFRA) && + (ieee->sta_sleep == LPS_IS_SLEEP) && + (ieee->polling) && (!bToOtherSTA)) { if (WLAN_FC_MORE_DATA(fc)) { - /* more data bit is set, let's request a new frame from the AP */ + /* more data bit is set, let's request a new frame + * from the AP + */ rtllib_sta_ps_send_pspoll_frame(ieee); } else { ieee->polling = false; @@ -1384,7 +1416,8 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, && (!bToOtherSTA)) { TID = Frame_QoSTID(skb->data); SeqNum = WLAN_GET_SEQ_SEQ(sc); - GetTs(ieee, (struct ts_common_info **) &pTS, hdr->addr2, TID, RX_DIR, true); + GetTs(ieee, (struct ts_common_info **) &pTS, hdr->addr2, TID, + RX_DIR, true); if (TID != 0 && TID != 3) ieee->bis_any_nonbepkts = true; } @@ -1399,7 +1432,9 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, /* to parse amsdu packets */ /* qos data packets & reserved bit is 1 */ if (parse_subframe(ieee, skb, rx_stats, rxb, src, dst) == 0) { - /* only to free rxb, and not submit the packets to upper layer */ + /* only to free rxb, and not submit the packets + * to upper layer + */ for (i = 0; i < rxb->nr_subframes; i++) dev_kfree_skb(rxb->subframes[i]); kfree(rxb); @@ -1421,7 +1456,8 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, } /* Indicate packets to upper layer or Rx Reorder */ - if (ieee->pHTInfo->bCurRxReorderEnable == false || pTS == NULL || bToOtherSTA) + if (ieee->pHTInfo->bCurRxReorderEnable == false || pTS == NULL || + bToOtherSTA) rtllib_rx_indicate_pkt_legacy(ieee, rx_stats, rxb, dst, src); else RxReorderIndicatePacket(ieee, rxb, pTS, SeqNum); @@ -1550,8 +1586,9 @@ static int rtllib_verify_qos_info(struct rtllib_qos_information_element /* Parse a QoS parameter element */ static int rtllib_read_qos_param_element(struct rtllib_qos_parameter_info - *element_param, struct rtllib_info_element - *info_element) + *element_param, + struct rtllib_info_element + *info_element) { int ret = 0; u16 size = sizeof(struct rtllib_qos_parameter_info) - 2; @@ -1573,10 +1610,10 @@ static int rtllib_read_qos_param_element(struct rtllib_qos_parameter_info } /* Parse a QoS information element */ -static int rtllib_read_qos_info_element(struct - rtllib_qos_information_element - *element_info, struct rtllib_info_element - *info_element) +static int rtllib_read_qos_info_element(struct rtllib_qos_information_element + *element_info, + struct rtllib_info_element + *info_element) { int ret = 0; u16 size = sizeof(struct rtllib_qos_information_element) - 2; @@ -1586,7 +1623,8 @@ static int rtllib_read_qos_info_element(struct if (info_element == NULL) return -1; - if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) { + if ((info_element->id == QOS_ELEMENT_ID) && + (info_element->len == size)) { memcpy(element_info->qui, info_element->data, info_element->len); element_info->elementID = info_element->id; @@ -1596,14 +1634,14 @@ static int rtllib_read_qos_info_element(struct if (ret == 0) ret = rtllib_verify_qos_info(element_info, - QOS_OUI_INFO_SUB_TYPE); + QOS_OUI_INFO_SUB_TYPE); return ret; } /* Write QoS parameters from the ac parameters. */ static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info *param_elm, - struct rtllib_qos_data *qos_data) + struct rtllib_qos_data *qos_data) { struct rtllib_qos_ac_parameter *ac_params; struct rtllib_qos_parameters *qos_param = &(qos_data->parameters); @@ -1649,9 +1687,11 @@ static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info /* WMM spec P.11: The minimum value for AIFSN shall be 2 */ qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2 : qos_param->aifs[aci]; - qos_param->cw_min[aci] = cpu_to_le16(ac_params->ecw_min_max & 0x0F); + qos_param->cw_min[aci] = cpu_to_le16(ac_params->ecw_min_max & + 0x0F); - qos_param->cw_max[aci] = cpu_to_le16((ac_params->ecw_min_max & 0xF0) >> 4); + qos_param->cw_max[aci] = cpu_to_le16((ac_params->ecw_min_max & + 0xF0) >> 4); qos_param->flag[aci] = (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00; @@ -1742,15 +1782,19 @@ static inline void rtllib_extract_country_ie( { if (IS_DOT11D_ENABLE(ieee)) { if (info_element->len != 0) { - memcpy(network->CountryIeBuf, info_element->data, info_element->len); + memcpy(network->CountryIeBuf, info_element->data, + info_element->len); network->CountryIeLen = info_element->len; if (!IS_COUNTRY_IE_VALID(ieee)) { - if (rtllib_act_scanning(ieee, false) && ieee->FirstIe_InScan) + if (rtllib_act_scanning(ieee, false) && + ieee->FirstIe_InScan) netdev_info(ieee->dev, "Received beacon ContryIE, SSID: <%s>\n", network->ssid); - Dot11d_UpdateCountryIe(ieee, addr2, info_element->len, info_element->data); + Dot11d_UpdateCountryIe(ieee, addr2, + info_element->len, + info_element->data); } } @@ -1929,7 +1973,8 @@ static void rtllib_parse_mife_generic(struct rtllib_device *ieee, network->MBssidMask = network->CcxRmState[1] & 0x07; if (network->MBssidMask != 0) { network->bMBssidValid = true; - network->MBssidMask = 0xff << (network->MBssidMask); + network->MBssidMask = 0xff << + (network->MBssidMask); ether_addr_copy(network->MBssid, network->bssid); network->MBssid[5] &= network->MBssidMask; @@ -2001,7 +2046,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, network->ssid_len = min(info_element->len, (u8) IW_ESSID_MAX_SIZE); - memcpy(network->ssid, info_element->data, network->ssid_len); + memcpy(network->ssid, info_element->data, + network->ssid_len); if (network->ssid_len < IW_ESSID_MAX_SIZE) memset(network->ssid + network->ssid_len, 0, IW_ESSID_MAX_SIZE - network->ssid_len); @@ -2172,7 +2218,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, case MFIE_TYPE_HT_INFO: netdev_dbg(ieee->dev, "MFIE_TYPE_HT_INFO: %d bytes\n", info_element->len); - tmp_htinfo_len = min_t(u8, info_element->len, MAX_IE_LEN); + tmp_htinfo_len = min_t(u8, info_element->len, + MAX_IE_LEN); if (tmp_htinfo_len) { network->bssht.bdHTSpecVer = HT_SPEC_VER_IEEE; network->bssht.bdHTInfoLen = tmp_htinfo_len > diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 9c83e3b14a39..9dce121d660e 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -272,9 +272,10 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee) ieee->seq_ctrl[0]++; /* check whether the managed packet queued greater than 5 */ - if (!ieee->check_nic_enough_desc(ieee->dev, tcb_desc->queue_index) || - (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0) || - (ieee->queue_stop)) { + if (!ieee->check_nic_enough_desc(ieee->dev, + tcb_desc->queue_index) || + skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) || + ieee->queue_stop) { /* insert the skb packet to the management queue * * as for the completion function, it does not need @@ -1483,7 +1484,8 @@ static void rtllib_associate_step1(struct rtllib_device *ieee, u8 *daddr) } } -static void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int chlen) +static void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, + int chlen) { u8 *c; struct sk_buff *skb; @@ -1740,7 +1742,7 @@ inline void rtllib_softmac_new_net(struct rtllib_device *ieee, /* Join the network for the first time */ ieee->AsocRetryCount = 0; if ((ieee->current_network.qos_data.supported == 1) && - ieee->current_network.bssht.bdSupportHT) + ieee->current_network.bssht.bdSupportHT) HTResetSelfAndSavePeerSetting(ieee, &(ieee->current_network)); else @@ -1755,14 +1757,19 @@ inline void rtllib_softmac_new_net(struct rtllib_device *ieee, &ieee->associate_procedure_wq, 0); } else { if (rtllib_is_54g(&ieee->current_network) && - (ieee->modulation & RTLLIB_OFDM_MODULATION)) { + (ieee->modulation & + RTLLIB_OFDM_MODULATION)) { ieee->rate = 108; - ieee->SetWirelessMode(ieee->dev, IEEE_G); - netdev_info(ieee->dev, "Using G rates\n"); + ieee->SetWirelessMode(ieee->dev, + IEEE_G); + netdev_info(ieee->dev, + "Using G rates\n"); } else { ieee->rate = 22; - ieee->SetWirelessMode(ieee->dev, IEEE_B); - netdev_info(ieee->dev, "Using B rates\n"); + ieee->SetWirelessMode(ieee->dev, + IEEE_B); + netdev_info(ieee->dev, + "Using B rates\n"); } memset(ieee->dot11HTOperationalRateSet, 0, 16); ieee->state = RTLLIB_LINKED; @@ -2023,7 +2030,7 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) if (ieee->bAwakePktSent) { pPSC->LPSAwakeIntvl = 1; } else { - u8 MaxPeriod = 1; + u8 MaxPeriod = 1; if (pPSC->LPSAwakeIntvl == 0) pPSC->LPSAwakeIntvl = 1; @@ -2194,7 +2201,8 @@ void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success) } EXPORT_SYMBOL(rtllib_ps_tx_ack); -static void rtllib_process_action(struct rtllib_device *ieee, struct sk_buff *skb) +static void rtllib_process_action(struct rtllib_device *ieee, + struct sk_buff *skb) { struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; u8 *act = rtllib_get_payload((struct rtllib_hdr *)header); @@ -3674,8 +3682,8 @@ static void rtllib_MgntDisconnectIBSS(struct rtllib_device *rtllib) } -static void rtllib_MlmeDisassociateRequest(struct rtllib_device *rtllib, u8 *asSta, - u8 asRsn) +static void rtllib_MlmeDisassociateRequest(struct rtllib_device *rtllib, + u8 *asSta, u8 asRsn) { u8 i; u8 OpMode; diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index 7047d2c61c23..e99ea5e67ef9 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -57,18 +57,19 @@ * * * 802.11 frame_control for data frames - 2 bytes - * ,-----------------------------------------------------------------------------------------. - * bits | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c | d | e | - * |----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|------| - * val | 0 | 0 | 0 | 1 | x | 0 | 0 | 0 | 1 | 0 | x | x | x | x | x | - * |----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|------| - * desc | ^-ver-^ | ^type-^ | ^-----subtype-----^ | to |from |more |retry| pwr |more |wep | - * | | | x=0 data,x=1 data+ack | DS | DS |frag | | mgm |data | | - * '-----------------------------------------------------------------------------------------' - * /\ - * | - * 802.11 Data Frame | - * ,--------- 'ctrl' expands to >-----------' + * ,--------------------------------------------------------------------. + * bits | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c | d | e | + * |---|---|---|---|---|---|---|---|---|----|----|-----|-----|-----|----| + * val | 0 | 0 | 0 | 1 | x | 0 | 0 | 0 | 1 | 0 | x | x | x | x | x | + * |---|---|---|---|---|---|---|---|---|----|----|-----|-----|-----|----| + * desc | ver | type | ^-subtype-^ |to |from|more|retry| pwr |more |wep | + * | | | x=0 data |DS | DS |frag| | mgm |data | | + * | | | x=1 data+ack | | | | | | | | + * '--------------------------------------------------------------------' + * /\ + * | + * 802.11 Data Frame | + * ,--------- 'ctrl' expands to >---' * | * ,--'---,-------------------------------------------------------------. * Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | @@ -112,15 +113,15 @@ * `-----------------------------------------' * Total: 18 non-data bytes * - * In the event that fragmentation is required, the incoming payload is split into - * N parts of size ieee->fts. The first fragment contains the SNAP header and the - * remaining packets are just data. + * In the event that fragmentation is required, the incoming payload is split + * into N parts of size ieee->fts. The first fragment contains the SNAP header + * and the remaining packets are just data. * - * If encryption is enabled, each fragment payload size is reduced by enough space - * to add the prefix and postfix (IV and ICV totalling 8 bytes in the case of WEP) - * So if you have 1500 bytes of payload with ieee->fts set to 500 without - * encryption it will take 3 frames. With WEP it will take 4 frames as the - * payload of each frame is reduced to 492 bytes. + * If encryption is enabled, each fragment payload size is reduced by enough + * space to add the prefix and postfix (IV and ICV totalling 8 bytes in + * the case of WEP) So if you have 1500 bytes of payload with ieee->fts set to + * 500 without encryption it will take 3 frames. With WEP it will take 4 frames + * as the payload of each frame is reduced to 492 bytes. * * SKB visualization * From 310852327ab3b5182dd9c1b8b7f44831eaa2454a Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:41 +0200 Subject: [PATCH 0736/1163] staging: rtl8192e: Fix LONG_LING in rtllib_parse_info_param() Take out MIFE_TYPE_HT_CAP processing into separate function - rtllib_parse_mfie_ht_cap() Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_rx.c | 49 ++++++++++++++++------------ 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 8e3aabf6e796..588c6d7cf2f9 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -2010,6 +2010,33 @@ static void rtllib_parse_mife_generic(struct rtllib_device *ieee, } } +static void rtllib_parse_mfie_ht_cap(struct rtllib_info_element *info_element, + struct rtllib_network *network, + u16 *tmp_htcap_len) +{ + struct bss_ht *ht = &network->bssht; + + *tmp_htcap_len = min_t(u8, info_element->len, MAX_IE_LEN); + if (*tmp_htcap_len != 0) { + ht->bdHTSpecVer = HT_SPEC_VER_EWC; + ht->bdHTCapLen = min_t(u16, *tmp_htcap_len, + sizeof(ht->bdHTCapBuf)); + memcpy(ht->bdHTCapBuf, info_element->data, ht->bdHTCapLen); + + ht->bdSupportHT = true; + ht->bdHT1R = ((((struct ht_capab_ele *) + ht->bdHTCapBuf))->MCS[1]) == 0; + + ht->bdBandWidth = (enum ht_channel_width) + (((struct ht_capab_ele *) + (ht->bdHTCapBuf))->ChlWidth); + } else { + ht->bdSupportHT = false; + ht->bdHT1R = false; + ht->bdBandWidth = HT_CHANNEL_WIDTH_20; + } +} + int rtllib_parse_info_param(struct rtllib_device *ieee, struct rtllib_info_element *info_element, u16 length, @@ -2191,27 +2218,9 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, case MFIE_TYPE_HT_CAP: netdev_dbg(ieee->dev, "MFIE_TYPE_HT_CAP: %d bytes\n", info_element->len); - tmp_htcap_len = min_t(u8, info_element->len, MAX_IE_LEN); - if (tmp_htcap_len != 0) { - network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; - network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf) ? - sizeof(network->bssht.bdHTCapBuf) : tmp_htcap_len; - memcpy(network->bssht.bdHTCapBuf, - info_element->data, - network->bssht.bdHTCapLen); - network->bssht.bdSupportHT = true; - network->bssht.bdHT1R = ((((struct ht_capab_ele *) - network->bssht.bdHTCapBuf))->MCS[1]) == 0; - - network->bssht.bdBandWidth = (enum ht_channel_width) - (((struct ht_capab_ele *) - (network->bssht.bdHTCapBuf))->ChlWidth); - } else { - network->bssht.bdSupportHT = false; - network->bssht.bdHT1R = false; - network->bssht.bdBandWidth = HT_CHANNEL_WIDTH_20; - } + rtllib_parse_mfie_ht_cap(info_element, network, + &tmp_htcap_len); break; From 0beee3ba610694d98fb96e9bc22469c5e1fa8206 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:42 +0200 Subject: [PATCH 0737/1163] staging: rtl8192e: Remove unimplemented iwpriv handlers Remove the following private variables: - force_mic_error - changes force_mic_error that is not used - radio - changes sw_radio_on that is not used - adhoc_peer_list - unimplemented - firm_ver - unimplemented Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 1 - drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 1 - drivers/staging/rtl8192e/rtl8192e/rtl_wx.c | 86 +------------------- drivers/staging/rtl8192e/rtllib.h | 1 - 4 files changed, 4 insertions(+), 85 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index d73dd573a5b7..abce472d3814 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -1118,7 +1118,6 @@ static void rtl8192_init_priv_variable(struct net_device *dev) priv->bDriverIsGoingToUnload = false; priv->being_init_adapter = false; priv->initialized_at_probe = false; - priv->sw_radio_on = true; priv->bdisable_nic = false; priv->bfirst_init = false; priv->txringcount = 64; diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h index 0640e76f2a7a..6127e92d8b93 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h @@ -626,7 +626,6 @@ struct r8192_priv { u8 RegCWinMin; u8 keepAliveLevel; - bool sw_radio_on; bool bHwRadioOff; bool pwrdown; bool blinked_ingpio; diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c index 2e6c4fab60fe..26c2ad03126b 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c @@ -175,48 +175,6 @@ static int r8192_wx_force_reset(struct net_device *dev, } -static int r8192_wx_force_mic_error(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device *ieee = priv->rtllib; - - down(&priv->wx_sem); - - RT_TRACE(COMP_DBG, "%s(): force mic error !\n", __func__); - ieee->force_mic_error = true; - up(&priv->wx_sem); - return 0; - -} - -#define MAX_ADHOC_PEER_NUM 64 -struct adhoc_peer_entry { - unsigned char MacAddr[ETH_ALEN]; - unsigned char WirelessMode; - unsigned char bCurTxBW40MHz; -}; -struct adhoc_peers_info { - struct adhoc_peer_entry Entry[MAX_ADHOC_PEER_NUM]; - unsigned char num; -}; - -static int r8192_wx_get_adhoc_peers(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - return 0; -} - - -static int r8191se_wx_get_firm_version(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrqu, char *extra) -{ - return 0; -} - static int r8192_wx_adapter_power_status(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -247,28 +205,6 @@ static int r8192_wx_adapter_power_status(struct net_device *dev, return 0; } -static int r8192se_wx_set_radio(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct r8192_priv *priv = rtllib_priv(dev); - - down(&priv->wx_sem); - - netdev_info(dev, "%s(): set radio ! extra is %d\n", __func__, *extra); - if ((*extra != 0) && (*extra != 1)) { - RT_TRACE(COMP_ERR, - "%s(): set radio an err value,must 0(radio off) or 1(radio on)\n", - __func__); - up(&priv->wx_sem); - return -1; - } - priv->sw_radio_on = *extra; - up(&priv->wx_sem); - return 0; - -} - static int r8192se_wx_set_lps_awake_interval(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -1239,21 +1175,10 @@ static const struct iw_priv_args r8192_private_args[] = { }, { SIOCIWFIRSTPRIV + 0x3, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "forcereset" - }, { - SIOCIWFIRSTPRIV + 0x4, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "force_mic_error" - }, { - SIOCIWFIRSTPRIV + 0x5, - IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT|IW_PRIV_SIZE_FIXED|1, - "firm_ver" }, { SIOCIWFIRSTPRIV + 0x6, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE, "set_power" - }, { - SIOCIWFIRSTPRIV + 0x9, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE, - "radio" }, { SIOCIWFIRSTPRIV + 0xa, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE, @@ -1262,9 +1187,6 @@ static const struct iw_priv_args r8192_private_args[] = { SIOCIWFIRSTPRIV + 0xb, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE, "lps_force" - }, { - SIOCIWFIRSTPRIV + 0xc, - 0, IW_PRIV_TYPE_CHAR|2047, "adhoc_peer_list" }, { SIOCIWFIRSTPRIV + 0x16, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "setpromisc" @@ -1280,15 +1202,15 @@ static iw_handler r8192_private_handler[] = { (iw_handler)r8192_wx_set_scan_type, (iw_handler)r8192_wx_set_rawtx, (iw_handler)r8192_wx_force_reset, - (iw_handler)r8192_wx_force_mic_error, - (iw_handler)r8191se_wx_get_firm_version, + (iw_handler)NULL, + (iw_handler)NULL, (iw_handler)r8192_wx_adapter_power_status, (iw_handler)NULL, (iw_handler)NULL, - (iw_handler)r8192se_wx_set_radio, + (iw_handler)NULL, (iw_handler)r8192se_wx_set_lps_awake_interval, (iw_handler)r8192se_wx_set_force_lps, - (iw_handler)r8192_wx_get_adhoc_peers, + (iw_handler)NULL, (iw_handler)NULL, (iw_handler)NULL, (iw_handler)NULL, diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index d5b5592c18fa..5c3a9793171b 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1904,7 +1904,6 @@ struct rtllib_device { u8 hwsec_active; bool is_silent_reset; - bool force_mic_error; bool is_roaming; bool ieee_up; bool cannot_notify; From 7c3d2579160659da732a14cf7e8608be85a39e6f Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:43 +0200 Subject: [PATCH 0738/1163] staging: rtl8192e: Fix OOM_MESSAGE warnings Remove alloc failed messages where not needed to make checkpatch.pl happy. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 25765b8b8bc4..60f536c295ab 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -92,10 +92,8 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst, return NULL; } skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr)); - if (skb == NULL) { - netdev_err(ieee->dev, "Can't alloc skb for ADDBA_REQ\n"); + if (skb == NULL) return NULL; - } memset(skb->data, 0, sizeof(struct rtllib_hdr_3addr)); @@ -160,10 +158,8 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst, DelbaParamSet.field.TID = pBA->BaParamSet.field.TID; skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr)); - if (skb == NULL) { - netdev_err(ieee->dev, "Can't alloc skb for DELBA_REQ\n"); + if (skb == NULL) return NULL; - } skb_reserve(skb, ieee->tx_headroom); From 2b2215af34c7bcf737b90d0459560e3716944429 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:44 +0200 Subject: [PATCH 0739/1163] staging: rtl8192e: Remove unused rtl_crypto.h This header is not used - remove it to make driver code smaller. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192e/rtl8192e/rtl_crypto.h | 382 ------------------ 1 file changed, 382 deletions(-) delete mode 100644 drivers/staging/rtl8192e/rtl8192e/rtl_crypto.h diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_crypto.h b/drivers/staging/rtl8192e/rtl8192e/rtl_crypto.h deleted file mode 100644 index ee57c0f4fa69..000000000000 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_crypto.h +++ /dev/null @@ -1,382 +0,0 @@ -/* - * Scatterlist Cryptographic API. - * - * Copyright (c) 2002 James Morris - * Copyright (c) 2002 David S. Miller (davem@redhat.com) - * - * Portions derived from Cryptoapi, by Alexander Kjeldaas - * and Nettle, by Niels M鰈ler. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - */ -#ifndef _LINUX_CRYPTO_H -#define _LINUX_CRYPTO_H - -#include -#include -#include -#include -#include -#include -#include - -#define crypto_register_alg crypto_register_alg_rsl -#define crypto_unregister_alg crypto_unregister_alg_rsl -#define crypto_alloc_tfm crypto_alloc_tfm_rsl -#define crypto_free_tfm crypto_free_tfm_rsl -#define crypto_alg_available crypto_alg_available_rsl - -/* - * Algorithm masks and types. - */ -#define CRYPTO_ALG_TYPE_MASK 0x000000ff -#define CRYPTO_ALG_TYPE_CIPHER 0x00000001 -#define CRYPTO_ALG_TYPE_DIGEST 0x00000002 -#define CRYPTO_ALG_TYPE_COMPRESS 0x00000004 - -/* - * Transform masks and values (for crt_flags). - */ -#define CRYPTO_TFM_MODE_MASK 0x000000ff -#define CRYPTO_TFM_REQ_MASK 0x000fff00 -#define CRYPTO_TFM_RES_MASK 0xfff00000 - -#define CRYPTO_TFM_MODE_ECB 0x00000001 -#define CRYPTO_TFM_MODE_CBC 0x00000002 -#define CRYPTO_TFM_MODE_CFB 0x00000004 -#define CRYPTO_TFM_MODE_CTR 0x00000008 - -#define CRYPTO_TFM_REQ_WEAK_KEY 0x00000100 -#define CRYPTO_TFM_RES_WEAK_KEY 0x00100000 -#define CRYPTO_TFM_RES_BAD_KEY_LEN 0x00200000 -#define CRYPTO_TFM_RES_BAD_KEY_SCHED 0x00400000 -#define CRYPTO_TFM_RES_BAD_BLOCK_LEN 0x00800000 -#define CRYPTO_TFM_RES_BAD_FLAGS 0x01000000 - -/* - * Miscellaneous stuff. - */ -#define CRYPTO_UNSPEC 0 -#define CRYPTO_MAX_ALG_NAME 64 - -struct scatterlist; - -/* - * Algorithms: modular crypto algorithm implementations, managed - * via crypto_register_alg() and crypto_unregister_alg(). - */ -struct cipher_alg { - unsigned int cia_min_keysize; - unsigned int cia_max_keysize; - int (*cia_setkey)(void *ctx, const u8 *key, - unsigned int keylen, u32 *flags); - void (*cia_encrypt)(void *ctx, u8 *dst, const u8 *src); - void (*cia_decrypt)(void *ctx, u8 *dst, const u8 *src); -}; - -struct digest_alg { - unsigned int dia_digestsize; - void (*dia_init)(void *ctx); - void (*dia_update)(void *ctx, const u8 *data, unsigned int len); - void (*dia_final)(void *ctx, u8 *out); - int (*dia_setkey)(void *ctx, const u8 *key, - unsigned int keylen, u32 *flags); -}; - -struct compress_alg { - int (*coa_init)(void *ctx); - void (*coa_exit)(void *ctx); - int (*coa_compress)(void *ctx, const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen); - int (*coa_decompress)(void *ctx, const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen); -}; - -#define cra_cipher cra_u.cipher -#define cra_digest cra_u.digest -#define cra_compress cra_u.compress - -struct crypto_alg { - struct list_head cra_list; - u32 cra_flags; - unsigned int cra_blocksize; - unsigned int cra_ctxsize; - const char cra_name[CRYPTO_MAX_ALG_NAME]; - - union { - struct cipher_alg cipher; - struct digest_alg digest; - struct compress_alg compress; - } cra_u; - - struct module *cra_module; -}; - -/* - * Algorithm registration interface. - */ -int crypto_register_alg(struct crypto_alg *alg); -int crypto_unregister_alg(struct crypto_alg *alg); - -/* - * Algorithm query interface. - */ -int crypto_alg_available(const char *name, u32 flags); - -/* - * Transforms: user-instantiated objects which encapsulate algorithms - * and core processing logic. Managed via crypto_alloc_tfm() and - * crypto_free_tfm(), as well as the various helpers below. - */ -struct crypto_tfm; - -struct cipher_tfm { - void *cit_iv; - unsigned int cit_ivsize; - u32 cit_mode; - int (*cit_setkey)(struct crypto_tfm *tfm, - const u8 *key, unsigned int keylen); - int (*cit_encrypt)(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes); - int (*cit_encrypt_iv)(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes, u8 *iv); - int (*cit_decrypt)(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes); - int (*cit_decrypt_iv)(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes, u8 *iv); - void (*cit_xor_block)(u8 *dst, const u8 *src); -}; - -struct digest_tfm { - void (*dit_init)(struct crypto_tfm *tfm); - void (*dit_update)(struct crypto_tfm *tfm, - struct scatterlist *sg, unsigned int nsg); - void (*dit_final)(struct crypto_tfm *tfm, u8 *out); - void (*dit_digest)(struct crypto_tfm *tfm, struct scatterlist *sg, - unsigned int nsg, u8 *out); - int (*dit_setkey)(struct crypto_tfm *tfm, - const u8 *key, unsigned int keylen); -}; - -struct compress_tfm { - int (*cot_compress)(struct crypto_tfm *tfm, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen); - int (*cot_decompress)(struct crypto_tfm *tfm, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen); -}; - -#define crt_cipher crt_u.cipher -#define crt_digest crt_u.digest -#define crt_compress crt_u.compress - -struct crypto_tfm { - - u32 crt_flags; - - union { - struct cipher_tfm cipher; - struct digest_tfm digest; - struct compress_tfm compress; - } crt_u; - - struct crypto_alg *__crt_alg; -}; - -/* - * Transform user interface. - */ - -/* - * crypto_alloc_tfm() will first attempt to locate an already loaded algorithm. - * If that fails and the kernel supports dynamically loadable modules, it - * will then attempt to load a module of the same name or alias. A refcount - * is grabbed on the algorithm which is then associated with the new transform. - * - * crypto_free_tfm() frees up the transform and any associated resources, - * then drops the refcount on the associated algorithm. - */ -struct crypto_tfm *crypto_alloc_tfm(const char *alg_name, u32 tfm_flags); -void crypto_free_tfm(struct crypto_tfm *tfm); - -/* - * Transform helpers which query the underlying algorithm. - */ -static inline const char *crypto_tfm_alg_name(struct crypto_tfm *tfm) -{ - return tfm->__crt_alg->cra_name; -} - -static inline const char *crypto_tfm_alg_modname(struct crypto_tfm *tfm) -{ - struct crypto_alg *alg = tfm->__crt_alg; - - if (alg->cra_module) - return alg->cra_module->name; - else - return NULL; -} - -static inline u32 crypto_tfm_alg_type(struct crypto_tfm *tfm) -{ - return tfm->__crt_alg->cra_flags & CRYPTO_ALG_TYPE_MASK; -} - -static inline unsigned int crypto_tfm_alg_min_keysize(struct crypto_tfm *tfm) -{ - BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); - return tfm->__crt_alg->cra_cipher.cia_min_keysize; -} - -static inline unsigned int crypto_tfm_alg_max_keysize(struct crypto_tfm *tfm) -{ - BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); - return tfm->__crt_alg->cra_cipher.cia_max_keysize; -} - -static inline unsigned int crypto_tfm_alg_ivsize(struct crypto_tfm *tfm) -{ - BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); - return tfm->crt_cipher.cit_ivsize; -} - -static inline unsigned int crypto_tfm_alg_blocksize(struct crypto_tfm *tfm) -{ - return tfm->__crt_alg->cra_blocksize; -} - -static inline unsigned int crypto_tfm_alg_digestsize(struct crypto_tfm *tfm) -{ - BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST); - return tfm->__crt_alg->cra_digest.dia_digestsize; -} - -/* - * API wrappers. - */ -static inline void crypto_digest_init(struct crypto_tfm *tfm) -{ - BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST); - tfm->crt_digest.dit_init(tfm); -} - -static inline void crypto_digest_update(struct crypto_tfm *tfm, - struct scatterlist *sg, - unsigned int nsg) -{ - BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST); - tfm->crt_digest.dit_update(tfm, sg, nsg); -} - -static inline void crypto_digest_final(struct crypto_tfm *tfm, u8 *out) -{ - BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST); - tfm->crt_digest.dit_final(tfm, out); -} - -static inline void crypto_digest_digest(struct crypto_tfm *tfm, - struct scatterlist *sg, - unsigned int nsg, u8 *out) -{ - BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST); - tfm->crt_digest.dit_digest(tfm, sg, nsg, out); -} - -static inline int crypto_digest_setkey(struct crypto_tfm *tfm, - const u8 *key, unsigned int keylen) -{ - BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST); - if (tfm->crt_digest.dit_setkey == NULL) - return -ENOSYS; - return tfm->crt_digest.dit_setkey(tfm, key, keylen); -} - -static inline int crypto_cipher_setkey(struct crypto_tfm *tfm, - const u8 *key, unsigned int keylen) -{ - BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); - return tfm->crt_cipher.cit_setkey(tfm, key, keylen); -} - -static inline int crypto_cipher_encrypt(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes) -{ - BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); - return tfm->crt_cipher.cit_encrypt(tfm, dst, src, nbytes); -} - -static inline int crypto_cipher_encrypt_iv(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes, u8 *iv) -{ - BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); - BUG_ON(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB); - return tfm->crt_cipher.cit_encrypt_iv(tfm, dst, src, nbytes, iv); -} - -static inline int crypto_cipher_decrypt(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes) -{ - BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); - return tfm->crt_cipher.cit_decrypt(tfm, dst, src, nbytes); -} - -static inline int crypto_cipher_decrypt_iv(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes, u8 *iv) -{ - BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); - BUG_ON(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB); - return tfm->crt_cipher.cit_decrypt_iv(tfm, dst, src, nbytes, iv); -} - -static inline void crypto_cipher_set_iv(struct crypto_tfm *tfm, - const u8 *src, unsigned int len) -{ - BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); - memcpy(tfm->crt_cipher.cit_iv, src, len); -} - -static inline void crypto_cipher_get_iv(struct crypto_tfm *tfm, - u8 *dst, unsigned int len) -{ - BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); - memcpy(dst, tfm->crt_cipher.cit_iv, len); -} - -static inline int crypto_comp_compress(struct crypto_tfm *tfm, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen) -{ - BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS); - return tfm->crt_compress.cot_compress(tfm, src, slen, dst, dlen); -} - -static inline int crypto_comp_decompress(struct crypto_tfm *tfm, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen) -{ - BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS); - return tfm->crt_compress.cot_decompress(tfm, src, slen, dst, dlen); -} - -#endif /* _LINUX_CRYPTO_H */ From a94aa9adb6fe79ddb9181bddd34ade3e8718c582 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:45 +0200 Subject: [PATCH 0740/1163] staging: rtl8192e: Replace ?: with max_t Improve readability and make checkpatch happy. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 588c6d7cf2f9..2280d1809ffe 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1685,7 +1685,7 @@ static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info qos_param->aifs[aci] = (ac_params->aci_aifsn) & 0x0f; /* WMM spec P.11: The minimum value for AIFSN shall be 2 */ - qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2 : qos_param->aifs[aci]; + qos_param->aifs[aci] = max_t(u8, qos_param->aifs[aci], 2); qos_param->cw_min[aci] = cpu_to_le16(ac_params->ecw_min_max & 0x0F); From a5c06ad83bf444dc3219460820bdcd4707dc4c9a Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:46 +0200 Subject: [PATCH 0741/1163] staging: rtl8192e: Replace ?: with min_t Replace :? with min_t for readability. Remove check that is always false. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_softmac_wx.c | 8 +------- drivers/staging/rtl8192e/rtllib_wx.c | 3 +-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c index d5e13a57ab7a..86f52ac7d33e 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c @@ -454,13 +454,7 @@ int rtllib_wx_set_essid(struct rtllib_device *ieee, proto_started = ieee->proto_started; - len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length : - IW_ESSID_MAX_SIZE; - - if (len > IW_ESSID_MAX_SIZE) { - ret = -E2BIG; - goto out; - } + len = min_t(__u16, wrqu->essid.length, IW_ESSID_MAX_SIZE); if (ieee->iw_mode == IW_MODE_MONITOR) { ret = -1; diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c index 2812a777d0f1..2ac161786796 100644 --- a/drivers/staging/rtl8192e/rtllib_wx.c +++ b/drivers/staging/rtl8192e/rtllib_wx.c @@ -851,8 +851,7 @@ int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len) if ((eid == MFIE_TYPE_GENERIC) && (!memcmp(&ie[2], wps_oui, 4))) { - ieee->wps_ie_len = (len < MAX_WZC_IE_LEN) ? (len) : - (MAX_WZC_IE_LEN); + ieee->wps_ie_len = min_t(size_t, len, MAX_WZC_IE_LEN); buf = kmemdup(ie, ieee->wps_ie_len, GFP_KERNEL); if (buf == NULL) return -ENOMEM; From 622fd4942dc301cb9fcd38243c92218cfa5bd7f5 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:47 +0200 Subject: [PATCH 0742/1163] staging: rtl8192e: Replace ?: with max All get_key implementations return either -1 or small buffers, so cast int->u16 is not a problem. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_wx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c index 2ac161786796..f31d864df6cc 100644 --- a/drivers/staging/rtl8192e/rtllib_wx.c +++ b/drivers/staging/rtl8192e/rtllib_wx.c @@ -510,7 +510,8 @@ int rtllib_wx_get_encode(struct rtllib_device *ieee, return 0; } len = crypt->ops->get_key(keybuf, SCM_KEY_LEN, NULL, crypt->priv); - erq->length = (len >= 0 ? len : 0); + + erq->length = max(len, 0); erq->flags |= IW_ENCODE_ENABLED; From fe1bbfc9b8e478cc13e73e0d7c13026b9ab8ba9c Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:48 +0200 Subject: [PATCH 0743/1163] staging: rtl8192e: Remove unneeded RT_TRACE(COMP_ERR,...) This messages are not needed, as failure is reported earlier in code. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c | 1 - drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c index 01d2201afc94..f080a913709f 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c @@ -239,7 +239,6 @@ bool phy_RF8256_Config_ParaFile(struct net_device *dev) return true; phy_RF8256_Config_ParaFile_Fail: - RT_TRACE(COMP_ERR, "PHY Initialization failed\n"); return false; } diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c index 02c5b0a21b6a..54e430eeb8eb 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c @@ -171,7 +171,6 @@ static bool CPUcheck_firmware_ready(struct net_device *dev) return rt_status; CPUCheckFirmwareReady_Fail: - RT_TRACE(COMP_ERR, "ERR in %s()\n", __func__); rt_status = false; return rt_status; From 156b80db36bb64e8c6cbc06dd34b4aafa3276b7a Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:49 +0200 Subject: [PATCH 0744/1163] staging: rtl8192e: rtl8192_phy_checkBBAndRF(): Don't check MAC This function never supported checking of MAC block. Instead of printing several warnings - print it once and exit. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c index 0765c97e06a8..6c4832c8009b 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c @@ -504,13 +504,15 @@ bool rtl8192_phy_checkBBAndRF(struct net_device *dev, WriteAddr[HW90_BLOCK_RF] = 0x3; RT_TRACE(COMP_PHY, "=======>%s(), CheckBlock:%d\n", __func__, CheckBlock); + + if (CheckBlock == HW90_BLOCK_MAC) { + netdev_warn(dev, "%s(): No checks available for MAC block.\n", + __func__); + return ret; + } + for (i = 0; i < CheckTimes; i++) { switch (CheckBlock) { - case HW90_BLOCK_MAC: - RT_TRACE(COMP_ERR, - "PHY_CheckBBRFOK(): Never Write 0x100 here!"); - break; - case HW90_BLOCK_PHY0: case HW90_BLOCK_PHY1: write_nic_dword(dev, WriteAddr[CheckBlock], From 3b4140afd9fa3b684572a1d5a7496d5830e8b8d0 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:50 +0200 Subject: [PATCH 0745/1163] staging: rtl8192e: Replace RT_TRACE(COMP_ERR, ...) with netdev_* - Use netdev_* with log level depending on how serious error is - Rework some messages to be more readable - Pass net_device where needed for pretty prints Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- .../rtl8192e/rtl8192e/r8190P_rtl8256.c | 24 ++--- .../staging/rtl8192e/rtl8192e/r8192E_dev.c | 31 +++--- .../rtl8192e/rtl8192e/r8192E_firmware.c | 13 +-- .../staging/rtl8192e/rtl8192e/r8192E_phy.c | 100 +++++++++--------- drivers/staging/rtl8192e/rtl8192e/rtl_cam.c | 18 ++-- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 65 +++++------- drivers/staging/rtl8192e/rtl8192e/rtl_ps.c | 4 +- drivers/staging/rtl8192e/rtl8192e/rtl_wx.c | 14 ++- 8 files changed, 127 insertions(+), 142 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c index f080a913709f..facc6f1f302b 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c @@ -47,8 +47,8 @@ void PHY_SetRF8256Bandwidth(struct net_device *dev, 0x0e, bMask12Bits, 0x021); } else { - RT_TRACE(COMP_ERR, - "PHY_SetRF8256Bandwidth(): unknown hardware version\n"); + netdev_warn(dev, "%s(): Unknown HW version.\n", + __func__); } break; @@ -66,16 +66,15 @@ void PHY_SetRF8256Bandwidth(struct net_device *dev, 0x0e, bMask12Bits, 0x0e1); } else { - RT_TRACE(COMP_ERR, - "PHY_SetRF8256Bandwidth(): unknown hardware version\n"); + netdev_warn(dev, "%s(): Unknown HW version.\n", + __func__); } break; default: - RT_TRACE(COMP_ERR, - "PHY_SetRF8256Bandwidth(): unknown Bandwidth: %#X\n", - Bandwidth); + netdev_err(dev, "%s(): Unknown bandwidth: %#X\n", + __func__, Bandwidth); break; } @@ -139,9 +138,8 @@ bool phy_RF8256_Config_ParaFile(struct net_device *dev) rtStatus = rtl8192_phy_checkBBAndRF(dev, HW90_BLOCK_RF, (enum rf90_radio_path)eRFPath); if (!rtStatus) { - RT_TRACE(COMP_ERR, - "PHY_RF8256_Config():Check Radio[%d] Fail!!\n", - eRFPath); + netdev_err(dev, "%s(): Failed to check RF Path %d.\n", + __func__, eRFPath); goto phy_RF8256_Config_ParaFile_Fail; } @@ -227,9 +225,9 @@ bool phy_RF8256_Config_ParaFile(struct net_device *dev) } if (ret) { - RT_TRACE(COMP_ERR, - "phy_RF8256_Config_ParaFile():Radio[%d] Fail!!", - eRFPath); + netdev_err(dev, + "%s(): Failed to initialize RF Path %d.\n", + __func__, eRFPath); goto phy_RF8256_Config_ParaFile_Fail; } diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c index e023c706a21d..b5e4d35ee6d4 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c @@ -326,8 +326,8 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) EEPROMId = eprom_read(dev, 0); if (EEPROMId != RTL8190_EEPROM_ID) { - RT_TRACE(COMP_ERR, "EEPROM ID is invalid:%x, %x\n", - EEPROMId, RTL8190_EEPROM_ID); + netdev_err(dev, "%s(): Invalid EEPROM ID: %x\n", __func__, + EEPROMId); priv->AutoloadFailFlag = true; } else { priv->AutoloadFailFlag = false; @@ -736,9 +736,8 @@ start: else if (priv->pFirmware->firmware_status == FW_STATUS_5_READY) ulRegRead |= CPU_GEN_FIRMWARE_RESET; else - RT_TRACE(COMP_ERR, - "ERROR in %s(): undefined firmware state(%d)\n", - __func__, priv->pFirmware->firmware_status); + netdev_err(dev, "%s(): undefined firmware state: %d.\n", + __func__, priv->pFirmware->firmware_status); write_nic_dword(dev, CPU_GEN, ulRegRead); @@ -754,7 +753,7 @@ start: RT_TRACE(COMP_INIT, "BB Config Start!\n"); rtStatus = rtl8192_BBConfig(dev); if (!rtStatus) { - RT_TRACE(COMP_ERR, "BB Config failed\n"); + netdev_warn(dev, "%s(): Failed to configure BB\n", __func__); return rtStatus; } RT_TRACE(COMP_INIT, "BB Config Finished!\n"); @@ -768,8 +767,8 @@ start: else if (priv->LoopbackMode == RTL819X_MAC_LOOPBACK) ulRegRead |= CPU_CCK_LOOPBACK; else - RT_TRACE(COMP_ERR, - "Serious error: wrong loopback mode setting\n"); + netdev_err(dev, "%s: Invalid loopback mode setting.\n", + __func__); write_nic_dword(dev, CPU_GEN, ulRegRead); @@ -867,7 +866,7 @@ start: RT_TRACE(COMP_INIT, "RF Config Started!\n"); rtStatus = rtl8192_phy_RFConfig(dev); if (!rtStatus) { - RT_TRACE(COMP_ERR, "RF Config failed\n"); + netdev_info(dev, "RF Config failed\n"); return rtStatus; } RT_TRACE(COMP_INIT, "RF Config Finished!\n"); @@ -1137,7 +1136,8 @@ static u8 MRateToHwRate8190Pci(u8 rate) return ret; } -static u8 rtl8192_MapHwQueueToFirmwareQueue(u8 QueueID, u8 priority) +static u8 rtl8192_MapHwQueueToFirmwareQueue(struct net_device *dev, u8 QueueID, + u8 priority) { u8 QueueSelect = 0x0; @@ -1170,9 +1170,8 @@ static u8 rtl8192_MapHwQueueToFirmwareQueue(u8 QueueID, u8 priority) QueueSelect = QSLT_HIGH; break; default: - RT_TRACE(COMP_ERR, - "TransmitTCB(): Impossible Queue Selection: %d\n", - QueueID); + netdev_warn(dev, "%s(): Impossible Queue Selection: %d\n", + __func__, QueueID); break; } return QueueSelect; @@ -1196,7 +1195,7 @@ void rtl8192_tx_fill_desc(struct net_device *dev, struct tx_desc *pdesc, cb_desc); if (pci_dma_mapping_error(priv->pdev, mapping)) - RT_TRACE(COMP_ERR, "DMA Mapping error\n"); + netdev_err(dev, "%s(): DMA Mapping error\n", __func__); if (cb_desc->bAMPDUEnable) { pTxFwInfo->AllowAggregation = 1; pTxFwInfo->RxMF = cb_desc->ampdu_factor; @@ -1272,7 +1271,7 @@ void rtl8192_tx_fill_desc(struct net_device *dev, struct tx_desc *pdesc, pdesc->PktId = 0x0; - pdesc->QueueSelect = rtl8192_MapHwQueueToFirmwareQueue( + pdesc->QueueSelect = rtl8192_MapHwQueueToFirmwareQueue(dev, cb_desc->queue_index, cb_desc->priority); pdesc->TxFWInfoSize = sizeof(struct tx_fwinfo_8190pci); @@ -1296,7 +1295,7 @@ void rtl8192_tx_fill_cmd_desc(struct net_device *dev, PCI_DMA_TODEVICE); if (pci_dma_mapping_error(priv->pdev, mapping)) - RT_TRACE(COMP_ERR, "DMA Mapping error\n"); + netdev_err(dev, "%s(): DMA Mapping error\n", __func__); memset(entry, 0, 12); entry->LINIP = cb_desc->bLastIniPkt; entry->FirstSeg = 1; diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c index 54e430eeb8eb..17d2a1540cc8 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c @@ -116,7 +116,7 @@ static bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev) } if (!(CPU_status&CPU_GEN_PUT_CODE_OK)) { - RT_TRACE(COMP_ERR, "Download Firmware: Put code fail!\n"); + netdev_err(dev, "Firmware download failed.\n"); goto CPUCheckMainCodeOKAndTurnOnCPU_Fail; } else { RT_TRACE(COMP_FIRMWARE, "Download Firmware: Put code ok!\n"); @@ -135,15 +135,16 @@ static bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev) mdelay(2); } - if (!(CPU_status&CPU_GEN_BOOT_RDY)) + if (!(CPU_status&CPU_GEN_BOOT_RDY)) { + netdev_err(dev, "Firmware boot failed.\n"); goto CPUCheckMainCodeOKAndTurnOnCPU_Fail; - else - RT_TRACE(COMP_FIRMWARE, "Download Firmware: Boot ready!\n"); + } + + RT_TRACE(COMP_FIRMWARE, "Download Firmware: Boot ready!\n"); return rt_status; CPUCheckMainCodeOKAndTurnOnCPU_Fail: - RT_TRACE(COMP_ERR, "ERR in %s()\n", __func__); rt_status = false; return rt_status; } @@ -310,7 +311,7 @@ bool init_firmware(struct net_device *dev) return rt_status; download_firmware_fail: - RT_TRACE(COMP_ERR, "ERR in %s()\n", __func__); + netdev_err(dev, "%s: Failed to initialize firmware.\n", __func__); rt_status = false; return rt_status; diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c index 6c4832c8009b..fba7654160e8 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c @@ -539,9 +539,7 @@ bool rtl8192_phy_checkBBAndRF(struct net_device *dev, if (dwRegRead != WriteData[i]) { - RT_TRACE(COMP_ERR, - "====>error=====dwRegRead: %x, WriteData: %x\n", - dwRegRead, WriteData[i]); + netdev_warn(dev, "%s(): Check failed.\n", __func__); ret = false; break; } @@ -687,8 +685,7 @@ void rtl8192_phy_setTxPower(struct net_device *dev, u8 channel) case RF_8258: break; default: - RT_TRACE(COMP_ERR, "unknown rf chip in function %s()\n", - __func__); + netdev_err(dev, "Invalid RF Chip ID.\n"); break; } } @@ -711,7 +708,7 @@ bool rtl8192_phy_RFConfig(struct net_device *dev) break; default: - RT_TRACE(COMP_ERR, "error chip id\n"); + netdev_err(dev, "Invalid RF Chip ID.\n"); break; } return rtStatus; @@ -804,13 +801,13 @@ static void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel) case RF_8258: break; default: - RT_TRACE(COMP_ERR, - "unknown rf chip ID in rtl8192_SetTxPowerLevel()\n"); + netdev_warn(dev, "%s(): Invalid RF Chip ID\n", __func__); break; } } -static u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable, +static u8 rtl8192_phy_SetSwChnlCmdArray(struct net_device *dev, + struct sw_chnl_cmd *CmdTable, u32 CmdTableIdx, u32 CmdTableSz, enum sw_chnl_cmd_id CmdID, u32 Para1, u32 Para2, u32 msDelay) @@ -818,14 +815,11 @@ static u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable, struct sw_chnl_cmd *pCmd; if (CmdTable == NULL) { - RT_TRACE(COMP_ERR, - "phy_SetSwChnlCmdArray(): CmdTable cannot be NULL.\n"); + netdev_err(dev, "%s(): CmdTable cannot be NULL.\n", __func__); return false; } if (CmdTableIdx >= CmdTableSz) { - RT_TRACE(COMP_ERR, - "phy_SetSwChnlCmdArray(): Access invalid index, please check size of the table, CmdTableIdx:%d, CmdTableSz:%d\n", - CmdTableIdx, CmdTableSz); + netdev_err(dev, "%s(): Invalid index requested.\n", __func__); return false; } @@ -853,24 +847,23 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, __func__, *stage, *step, channel); if (!rtllib_legal_channel(priv->rtllib, channel)) { - RT_TRACE(COMP_ERR, "=============>set to illegal channel:%d\n", - channel); + netdev_err(dev, "Invalid channel requested: %d\n", channel); return true; } { PreCommonCmdCnt = 0; - rtl8192_phy_SetSwChnlCmdArray(ieee->PreCommonCmd, + rtl8192_phy_SetSwChnlCmdArray(dev, ieee->PreCommonCmd, PreCommonCmdCnt++, MAX_PRECMD_CNT, CmdID_SetTxPowerLevel, 0, 0, 0); - rtl8192_phy_SetSwChnlCmdArray(ieee->PreCommonCmd, + rtl8192_phy_SetSwChnlCmdArray(dev, ieee->PreCommonCmd, PreCommonCmdCnt++, MAX_PRECMD_CNT, CmdID_End, 0, 0, 0); PostCommonCmdCnt = 0; - rtl8192_phy_SetSwChnlCmdArray(ieee->PostCommonCmd, + rtl8192_phy_SetSwChnlCmdArray(dev, ieee->PostCommonCmd, PostCommonCmdCnt++, MAX_POSTCMD_CNT, CmdID_End, 0, 0, 0); @@ -878,32 +871,32 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, switch (priv->rf_chip) { case RF_8225: if (!(channel >= 1 && channel <= 14)) { - RT_TRACE(COMP_ERR, - "illegal channel for Zebra 8225: %d\n", - channel); + netdev_err(dev, + "Invalid channel requested for 8225: %d\n", + channel); return false; } - rtl8192_phy_SetSwChnlCmdArray(ieee->RfDependCmd, + rtl8192_phy_SetSwChnlCmdArray(dev, ieee->RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, CmdID_RF_WriteReg, rZebra1_Channel, RF_CHANNEL_TABLE_ZEBRA[channel], 10); - rtl8192_phy_SetSwChnlCmdArray(ieee->RfDependCmd, + rtl8192_phy_SetSwChnlCmdArray(dev, ieee->RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, CmdID_End, 0, 0, 0); break; case RF_8256: if (!(channel >= 1 && channel <= 14)) { - RT_TRACE(COMP_ERR, - "illegal channel for Zebra 8256: %d\n", - channel); + netdev_err(dev, + "Invalid channel requested for 8256: %d\n", + channel); return false; } - rtl8192_phy_SetSwChnlCmdArray(ieee->RfDependCmd, + rtl8192_phy_SetSwChnlCmdArray(dev, ieee->RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, CmdID_RF_WriteReg, rZebra1_Channel, channel, 10); - rtl8192_phy_SetSwChnlCmdArray(ieee->RfDependCmd, + rtl8192_phy_SetSwChnlCmdArray(dev, ieee->RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, @@ -914,8 +907,7 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, break; default: - RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n", - priv->rf_chip); + netdev_warn(dev, "Unknown RF Chip ID\n"); return false; } @@ -1015,7 +1007,7 @@ u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel) RT_TRACE(COMP_PHY, "=====>%s()\n", __func__); if (!priv->up) { - RT_TRACE(COMP_ERR, "%s(): ERR !! driver is not up\n", __func__); + netdev_err(dev, "%s(): Driver is not initialized\n", __func__); return false; } if (priv->SwChnlInProgress) @@ -1026,20 +1018,26 @@ u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel) case WIRELESS_MODE_A: case WIRELESS_MODE_N_5G: if (channel <= 14) { - RT_TRACE(COMP_ERR, "WIRELESS_MODE_A but channel<=14"); + netdev_warn(dev, + "Channel %d not available in 802.11a.\n", + channel); return false; } break; case WIRELESS_MODE_B: if (channel > 14) { - RT_TRACE(COMP_ERR, "WIRELESS_MODE_B but channel>14"); + netdev_warn(dev, + "Channel %d not available in 802.11b.\n", + channel); return false; } break; case WIRELESS_MODE_G: case WIRELESS_MODE_N_24G: if (channel > 14) { - RT_TRACE(COMP_ERR, "WIRELESS_MODE_G but channel>14"); + netdev_warn(dev, + "Channel %d not available in 802.11g.\n", + channel); return false; } break; @@ -1182,7 +1180,7 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev) return; } if (!priv->up) { - RT_TRACE(COMP_ERR, "%s(): ERR!! driver is not up\n", __func__); + netdev_err(dev, "%s(): Driver is not initialized\n", __func__); return; } regBwOpMode = read_nic_byte(dev, BW_OPMODE); @@ -1199,9 +1197,8 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev) break; default: - RT_TRACE(COMP_ERR, - "SetChannelBandwidth819xUsb(): unknown Bandwidth: %#X\n", - priv->CurrentChannelBW); + netdev_err(dev, "%s(): unknown Bandwidth: %#X\n", __func__, + priv->CurrentChannelBW); break; } @@ -1241,9 +1238,8 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev) rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 0); break; default: - RT_TRACE(COMP_ERR, - "SetChannelBandwidth819xUsb(): unknown Bandwidth: %#X\n", - priv->CurrentChannelBW); + netdev_err(dev, "%s(): unknown Bandwidth: %#X\n", __func__, + priv->CurrentChannelBW); break; } @@ -1263,7 +1259,8 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev) break; default: - RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n", priv->rf_chip); + netdev_info(dev, "%s(): Unknown RFChipID: %d\n", __func__, + priv->rf_chip); break; } @@ -1454,9 +1451,9 @@ static bool SetRFPowerState8190(struct net_device *dev, } while (!rtstatus && (InitilizeCount > 0)); if (!rtstatus) { - RT_TRACE(COMP_ERR, - "%s():Initialize Adapter fail,return\n", - __func__); + netdev_err(dev, + "%s(): Failed to initialize Adapter.\n", + __func__); priv->SetRFPowerStateInProgress = false; return false; } @@ -1557,16 +1554,16 @@ static bool SetRFPowerState8190(struct net_device *dev, default: bResult = false; - RT_TRACE(COMP_ERR, - "SetRFPowerState8190(): unknown state to set: 0x%X!!!\n", - eRFPowerState); + netdev_warn(dev, + "%s(): Unknown state requested: 0x%X.\n", + __func__, eRFPowerState); break; } break; default: - RT_TRACE(COMP_ERR, "SetRFPowerState8190(): Unknown RF type\n"); + netdev_warn(dev, "%s(): Unknown RF type\n", __func__); break; } @@ -1578,8 +1575,7 @@ static bool SetRFPowerState8190(struct net_device *dev, break; default: - RT_TRACE(COMP_ERR, - "SetRFPowerState8190(): Unknown RF type\n"); + netdev_warn(dev, "%s(): Unknown RF type\n", __func__); break; } } diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c index 0ffade4f42bd..89c3d3318e51 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c @@ -113,8 +113,8 @@ void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, if (priv->rtllib->PowerSaveControl.bInactivePs) { if (rtState == eRfOff) { if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) { - RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n", - __func__); + netdev_warn(dev, "%s(): RF is OFF.\n", + __func__); return; } down(&priv->rtllib->ips_sem); @@ -124,7 +124,7 @@ void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, } priv->rtllib->is_set_key = true; if (EntryNo >= TOTAL_CAM_ENTRY) - RT_TRACE(COMP_ERR, "cam entry exceeds in setKey()\n"); + netdev_info(dev, "%s(): Invalid CAM entry\n", __func__); RT_TRACE(COMP_SEC, "====>to setKey(), dev:%p, EntryNo:%d, KeyIndex:%d,KeyType:%d, MacAddr %pM\n", @@ -243,9 +243,9 @@ void CamRestoreAllEntry(struct net_device *dev) (u32 *)(&priv->rtllib->swcamtable[0].key_buf[0]) ); } else { - RT_TRACE(COMP_ERR, - "===>%s():ERR!! ADHOC TKIP ,but 0 entry is have no data\n", - __func__); + netdev_warn(dev, + "%s(): ADHOC TKIP: missing key entry.\n", + __func__); return; } } @@ -267,9 +267,9 @@ void CamRestoreAllEntry(struct net_device *dev) CAM_CONST_ADDR[0], 0, (u32 *)(&priv->rtllib->swcamtable[0].key_buf[0])); } else { - RT_TRACE(COMP_ERR, - "===>%s():ERR!! ADHOC CCMP ,but 0 entry is have no data\n", - __func__); + netdev_warn(dev, + "%s(): ADHOC CCMP: missing key entry.\n", + __func__); return; } } diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index abce472d3814..fcc9188a209f 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -343,8 +343,9 @@ bool MgntActSet_RF_State(struct net_device *dev, mdelay(1); if (RFWaitCounter > 100) { - RT_TRACE(COMP_ERR, - "MgntActSet_RF_State(): Wait too logn to set RF\n"); + netdev_warn(dev, + "%s(): Timeout waiting for RF change.\n", + __func__); return false; } } @@ -897,9 +898,9 @@ void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode) } else if ((bSupportMode & WIRELESS_MODE_B)) { wireless_mode = WIRELESS_MODE_B; } else { - RT_TRACE(COMP_ERR, - "%s(), No valid wireless mode supported (%x)!!!\n", - __func__, bSupportMode); + netdev_info(dev, + "%s(): Unsupported mode requested. Fallback to 802.11b\n", + __func__); wireless_mode = WIRELESS_MODE_B; } } @@ -946,8 +947,7 @@ static int _rtl8192_sta_up(struct net_device *dev, bool is_silent_reset) priv->bfirst_init = true; init_status = priv->ops->initialize_adapter(dev); if (!init_status) { - RT_TRACE(COMP_ERR, "ERR!!! %s(): initialization is failed!\n", - __func__); + netdev_err(dev, "%s(): Initialization failed!\n", __func__); priv->bfirst_init = false; return -1; } @@ -1267,9 +1267,8 @@ static short rtl8192_get_channel_map(struct net_device *dev) if ((priv->rf_chip != RF_8225) && (priv->rf_chip != RF_8256) && (priv->rf_chip != RF_6052)) { - RT_TRACE(COMP_ERR, - "%s: unknown rf chip, can't set channel map\n", - __func__); + netdev_err(dev, "%s: unknown rf chip, can't set channel map\n", + __func__); return -1; } @@ -1498,9 +1497,8 @@ RESET_START: LeisurePSLeave(dev); if (priv->up) { - RT_TRACE(COMP_ERR, - "%s():the driver is not up! return\n", - __func__); + netdev_info(dev, "%s():the driver is not up.\n", + __func__); up(&priv->wx_sem); return; } @@ -1554,9 +1552,8 @@ RESET_START: reset_times++; goto RESET_START; } else { - RT_TRACE(COMP_ERR, - " ERR!!! %s(): Reset Failed!!\n", - __func__); + netdev_warn(dev, "%s(): Reset Failed\n", + __func__); } } @@ -1729,7 +1726,7 @@ void rtl819x_watchdog_wqcallback(void *data) if (priv->check_roaming_cnt > 0) { if (ieee->eRFPowerState == eRfOff) - RT_TRACE(COMP_ERR, "========>%s()\n", __func__); + netdev_info(dev, "%s(): RF is off\n", __func__); netdev_info(dev, "===>%s(): AP is power off, chan:%d, connect another one\n", @@ -1999,9 +1996,8 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) u32 fwinfo_size = 0; if (priv->bdisable_nic) { - RT_TRACE(COMP_ERR, - "%s: ERR!! Nic is disabled! Can't tx packet len=%d qidx=%d!!!\n", - __func__, skb->len, tcb_desc->queue_index); + netdev_warn(dev, "%s: Nic is disabled! Can't tx packet.\n", + __func__); return skb->len; } @@ -2038,10 +2034,10 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) pdesc = &ring->desc[idx]; if ((pdesc->OWN == 1) && (tcb_desc->queue_index != BEACON_QUEUE)) { - RT_TRACE(COMP_ERR, - "No more TX desc@%d, ring->idx = %d, idx = %d, skblen = 0x%x queuelen=%d", - tcb_desc->queue_index, ring->idx, idx, skb->len, - skb_queue_len(&ring->queue)); + netdev_warn(dev, + "No more TX desc@%d, ring->idx = %d, idx = %d, skblen = 0x%x queuelen=%d", + tcb_desc->queue_index, ring->idx, idx, skb->len, + skb_queue_len(&ring->queue)); spin_unlock_irqrestore(&priv->irq_th_lock, flags); return skb->len; } @@ -2072,7 +2068,7 @@ static short rtl8192_alloc_rx_desc_ring(struct net_device *dev) &priv->rx_ring_dma[rx_queue_idx]); if (!priv->rx_ring[rx_queue_idx] || (unsigned long)priv->rx_ring[rx_queue_idx] & 0xFF) { - RT_TRACE(COMP_ERR, "Cannot allocate RX ring\n"); + netdev_warn(dev, "Cannot allocate RX ring\n"); return -ENOMEM; } @@ -2118,8 +2114,7 @@ static int rtl8192_alloc_tx_desc_ring(struct net_device *dev, ring = pci_zalloc_consistent(priv->pdev, sizeof(*ring) * entries, &dma); if (!ring || (unsigned long)ring & 0xFF) { - RT_TRACE(COMP_ERR, "Cannot allocate TX ring (prio = %d)\n", - prio); + netdev_warn(dev, "Cannot allocate TX ring (prio = %d)\n", prio); return -ENOMEM; } @@ -2848,7 +2843,7 @@ static int rtl8192_pci_probe(struct pci_dev *pdev, RT_TRACE(COMP_INIT, "Configuring chip resources"); if (pci_enable_device(pdev)) { - RT_TRACE(COMP_ERR, "Failed to enable PCI device"); + dev_err(&pdev->dev, "Failed to enable PCI device"); return -EIO; } @@ -2886,21 +2881,21 @@ static int rtl8192_pci_probe(struct pci_dev *pdev, pmem_flags = pci_resource_flags(pdev, 1); if (!(pmem_flags & IORESOURCE_MEM)) { - RT_TRACE(COMP_ERR, "region #1 not a MMIO resource, aborting"); + netdev_err(dev, "region #1 not a MMIO resource, aborting"); goto err_rel_rtllib; } dev_info(&pdev->dev, "Memory mapped space start: 0x%08lx\n", pmem_start); if (!request_mem_region(pmem_start, pmem_len, DRV_NAME)) { - RT_TRACE(COMP_ERR, "request_mem_region failed!"); + netdev_err(dev, "request_mem_region failed!"); goto err_rel_rtllib; } ioaddr = (unsigned long)ioremap_nocache(pmem_start, pmem_len); if (ioaddr == (unsigned long)NULL) { - RT_TRACE(COMP_ERR, "ioremap failed!"); + netdev_err(dev, "ioremap failed!"); goto err_rel_mem; } @@ -2936,7 +2931,7 @@ static int rtl8192_pci_probe(struct pci_dev *pdev, RT_TRACE(COMP_INIT, "Driver probe completed1\n"); if (rtl8192_init(dev) != 0) { - RT_TRACE(COMP_ERR, "Initialization failed"); + netdev_warn(dev, "Initialization failed"); goto err_free_irq; } @@ -3022,8 +3017,7 @@ bool NicIFEnableNIC(struct net_device *dev) (&(priv->rtllib->PowerSaveControl)); if (!priv->up) { - RT_TRACE(COMP_ERR, "ERR!!! %s(): Driver is already down!\n", - __func__); + netdev_warn(dev, "%s(): Driver is already down!\n", __func__); priv->bdisable_nic = false; return false; } @@ -3032,8 +3026,7 @@ bool NicIFEnableNIC(struct net_device *dev) priv->bfirst_init = true; init_status = priv->ops->initialize_adapter(dev); if (!init_status) { - RT_TRACE(COMP_ERR, "ERR!!! %s(): initialization is failed!\n", - __func__); + netdev_warn(dev, "%s(): Initialization failed!\n", __func__); priv->bdisable_nic = false; return false; } diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c index 386ae0c5f253..f6eb989d62d0 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c @@ -202,8 +202,8 @@ void rtllib_ips_leave_wq(struct net_device *dev) if (priv->rtllib->PowerSaveControl.bInactivePs) { if (rtState == eRfOff) { if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) { - RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n", - __func__); + netdev_warn(dev, "%s(): RF is OFF.\n", + __func__); return; } netdev_info(dev, "=========>%s(): IPSLeave\n", diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c index 26c2ad03126b..f5e4961677d2 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c @@ -116,9 +116,8 @@ static int r8192_wx_set_power(struct net_device *dev, struct r8192_priv *priv = rtllib_priv(dev); if (priv->bHwRadioOff) { - RT_TRACE(COMP_ERR, - "%s():Hw is Radio Off, we can't set Power,return\n", - __func__); + netdev_warn(dev, "%s(): Can't set Power: Radio is Off.\n", + __func__); return 0; } down(&priv->wx_sem); @@ -278,8 +277,8 @@ static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a, if (rtState == eRfOff) { if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) { - RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n", - __func__); + netdev_warn(dev, "%s(): RF is OFF.\n", + __func__); up(&priv->wx_sem); return -1; } @@ -438,9 +437,8 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, if (rtState == eRfOff) { if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) { - RT_TRACE(COMP_ERR, - "%s(): RF is OFF.\n", - __func__); + netdev_warn(dev, "%s(): RF is OFF.\n", + __func__); up(&priv->wx_sem); return -1; } From d9c1fff59ac0ea84410a8ae39f81cd176368ec6e Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:51 +0200 Subject: [PATCH 0746/1163] staging: rtl8192e: Fix trivial LONG_LINE errors Reindent lines to make checkpatch happy. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 81 ++++++++++++++-------- drivers/staging/rtl8192e/rtllib_rx.c | 24 ++++--- 2 files changed, 66 insertions(+), 39 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c index a9218579d80f..d480229394a5 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c @@ -403,16 +403,16 @@ static void dm_check_rate_adaptive(struct net_device *dev) ((bshort_gi_enabled) ? BIT31 : 0); if (pra->ratr_state == DM_RATR_STA_HIGH) { - HighRSSIThreshForRA = pra->high2low_rssi_thresh_for_ra; - LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ? + HighRSSIThreshForRA = pra->high2low_rssi_thresh_for_ra; + LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ? (pra->low_rssi_thresh_for_ra40M) : (pra->low_rssi_thresh_for_ra20M); } else if (pra->ratr_state == DM_RATR_STA_LOW) { - HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra; - LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ? + HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra; + LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ? (pra->low2high_rssi_thresh_for_ra40M) : (pra->low2high_rssi_thresh_for_ra20M); } else { - HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra; - LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ? + HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra; + LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ? (pra->low_rssi_thresh_for_ra40M) : (pra->low_rssi_thresh_for_ra20M); } @@ -749,7 +749,8 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev) "Avg_TSSI_Meas_from_driver = %d\n", Avg_TSSI_Meas_from_driver); TSSI_13dBm = priv->TSSI_13dBm; - RT_TRACE(COMP_POWER_TRACKING, "TSSI_13dBm = %d\n", TSSI_13dBm); + RT_TRACE(COMP_POWER_TRACKING, "TSSI_13dBm = %d\n", + TSSI_13dBm); if (Avg_TSSI_Meas_from_driver > TSSI_13dBm) delta = Avg_TSSI_Meas_from_driver - TSSI_13dBm; @@ -828,11 +829,13 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev) "priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); - if (priv->CCKPresentAttentuation_difference <= -12 || priv->CCKPresentAttentuation_difference >= 24) { + if (priv->CCKPresentAttentuation_difference <= -12 || + priv->CCKPresentAttentuation_difference >= 24) { priv->rtllib->bdynamic_txpower_enable = true; write_nic_byte(dev, Pw_Track_Flag, 0); write_nic_byte(dev, FW_Busy_Flag, 0); - RT_TRACE(COMP_POWER_TRACKING, "tx power track--->limited\n"); + RT_TRACE(COMP_POWER_TRACKING, + "tx power track--->limited\n"); return; } @@ -1233,18 +1236,28 @@ static void dm_bb_initialgain_restore(struct net_device *dev) return; rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); - rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bit_mask, (u32)priv->initgain_backup.xaagccore1); - rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bit_mask, (u32)priv->initgain_backup.xbagccore1); - rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, bit_mask, (u32)priv->initgain_backup.xcagccore1); - rtl8192_setBBreg(dev, rOFDM0_XDAGCCore1, bit_mask, (u32)priv->initgain_backup.xdagccore1); + rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bit_mask, + (u32)priv->initgain_backup.xaagccore1); + rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bit_mask, + (u32)priv->initgain_backup.xbagccore1); + rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, bit_mask, + (u32)priv->initgain_backup.xcagccore1); + rtl8192_setBBreg(dev, rOFDM0_XDAGCCore1, bit_mask, + (u32)priv->initgain_backup.xdagccore1); bit_mask = bMaskByte2; - rtl8192_setBBreg(dev, rCCK0_CCA, bit_mask, (u32)priv->initgain_backup.cca); + rtl8192_setBBreg(dev, rCCK0_CCA, bit_mask, + (u32)priv->initgain_backup.cca); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc50 is %x\n", priv->initgain_backup.xaagccore1); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc58 is %x\n", priv->initgain_backup.xbagccore1); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc60 is %x\n", priv->initgain_backup.xcagccore1); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc68 is %x\n", priv->initgain_backup.xdagccore1); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xa0a is %x\n", priv->initgain_backup.cca); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc50 is %x\n", + priv->initgain_backup.xaagccore1); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc58 is %x\n", + priv->initgain_backup.xbagccore1); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc60 is %x\n", + priv->initgain_backup.xcagccore1); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc68 is %x\n", + priv->initgain_backup.xdagccore1); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xa0a is %x\n", + priv->initgain_backup.cca); rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); } @@ -1277,11 +1290,16 @@ static void dm_bb_initialgain_backup(struct net_device *dev) bit_mask = bMaskByte2; priv->initgain_backup.cca = (u8)rtl8192_QueryBBReg(dev, rCCK0_CCA, bit_mask); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc50 is %x\n", priv->initgain_backup.xaagccore1); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc58 is %x\n", priv->initgain_backup.xbagccore1); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc60 is %x\n", priv->initgain_backup.xcagccore1); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc68 is %x\n", priv->initgain_backup.xdagccore1); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xa0a is %x\n", priv->initgain_backup.cca); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc50 is %x\n", + priv->initgain_backup.xaagccore1); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc58 is %x\n", + priv->initgain_backup.xbagccore1); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc60 is %x\n", + priv->initgain_backup.xcagccore1); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc68 is %x\n", + priv->initgain_backup.xdagccore1); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xa0a is %x\n", + priv->initgain_backup.cca); } @@ -1798,10 +1816,12 @@ static void dm_check_edca_turbo(struct net_device *dev) if (!priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) { if (priv->rtllib->mode == WIRELESS_MODE_G) - write_nic_dword(dev, EDCAPARA_BE, + write_nic_dword(dev, + EDCAPARA_BE, edca_setting_DL_GMode[pHTInfo->IOTPeer]); else - write_nic_dword(dev, EDCAPARA_BE, + write_nic_dword(dev, + EDCAPARA_BE, edca_setting_DL[pHTInfo->IOTPeer]); priv->bis_cur_rdlstate = true; } @@ -1809,12 +1829,15 @@ static void dm_check_edca_turbo(struct net_device *dev) priv->bcurrent_turbo_EDCA = true; } else { if (curRxOkCnt > 4*curTxOkCnt) { - if (!priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) { + if (!priv->bis_cur_rdlstate || + !priv->bcurrent_turbo_EDCA) { if (priv->rtllib->mode == WIRELESS_MODE_G) - write_nic_dword(dev, EDCAPARA_BE, + write_nic_dword(dev, + EDCAPARA_BE, edca_setting_DL_GMode[pHTInfo->IOTPeer]); else - write_nic_dword(dev, EDCAPARA_BE, + write_nic_dword(dev, + EDCAPARA_BE, edca_setting_DL[pHTInfo->IOTPeer]); priv->bis_cur_rdlstate = true; } diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 2280d1809ffe..6977f04ccd4d 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1256,14 +1256,16 @@ static void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee, struct sk_buff *sub_skb = rxb->subframes[i]; if (sub_skb) { - /* convert hdr + possible LLC headers into Ethernet header */ + /* convert hdr + possible LLC headers + * into Ethernet header + */ ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7]; if (sub_skb->len >= 8 && ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 && ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) { - /* remove RFC1042 or Bridge-Tunnel encapsulation and - * replace EtherType + /* remove RFC1042 or Bridge-Tunnel encapsulation + * and replace EtherType */ skb_pull(sub_skb, SNAP_SIZE); ether_addr_copy(skb_push(sub_skb, ETH_ALEN), @@ -1272,7 +1274,9 @@ static void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee, dst); } else { u16 len; - /* Leave Ethernet header part of hdr and full payload */ + /* Leave Ethernet header part of hdr + * and full payload + */ len = sub_skb->len; memcpy(skb_push(sub_skb, 2), &len, 2); ether_addr_copy(skb_push(sub_skb, ETH_ALEN), @@ -1293,7 +1297,8 @@ static void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee, sub_skb->dev = dev; sub_skb->dev->stats.rx_packets++; sub_skb->dev->stats.rx_bytes += sub_skb->len; - sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */ + /* 802.11 crc not sufficient */ + sub_skb->ip_summed = CHECKSUM_NONE; netif_rx(sub_skb); } } @@ -1835,11 +1840,10 @@ static void rtllib_parse_mife_generic(struct rtllib_device *ieee, if (*tmp_htcap_len == 0) { if (info_element->len >= 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x90 && - info_element->data[2] == 0x4c && - info_element->data[3] == 0x033) { - + info_element->data[0] == 0x00 && + info_element->data[1] == 0x90 && + info_element->data[2] == 0x4c && + info_element->data[3] == 0x033) { *tmp_htcap_len = min_t(u8, info_element->len, MAX_IE_LEN); if (*tmp_htcap_len != 0) { From f0e5bb2b29e87ab8fc7652fc48c3ca7b594795a1 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:52 +0200 Subject: [PATCH 0747/1163] staging: rtl8192e: rtl8192E_suspend(): Fix WOL reporting WOL capability was reported in an awkward way - print it nicely. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_pm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c index ca6ecfc8299e..e4908672421c 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c @@ -57,10 +57,8 @@ int rtl8192E_suspend(struct pci_dev *pdev, pm_message_t state) write_nic_byte(dev, MacBlkCtrl, 0xa); } out_pci_suspend: - netdev_info(dev, "r8192E support WOL call??????????????????????\n"); - if (priv->rtllib->bSupportRemoteWakeUp) - RT_TRACE(COMP_POWER, - "r8192E support WOL call!!!!!!!!!!!!!!!!!!.\n"); + netdev_info(dev, "WOL is %s\n", priv->rtllib->bSupportRemoteWakeUp ? + "Supported" : "Not supported"); pci_save_state(pdev); pci_disable_device(pdev); pci_enable_wake(pdev, pci_choose_state(pdev, state), From 512e90312308c5838e36716c28699b340ef75764 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Sun, 31 May 2015 20:19:53 +0200 Subject: [PATCH 0748/1163] staging: rtl8192e: Fix SPACING error Fix SPACING error in rtl8192_hw_to_sleep(). Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_ps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c index f6eb989d62d0..404cb83153d9 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c @@ -101,7 +101,7 @@ void rtl8192_hw_to_sleep(struct net_device *dev, u64 time) time -= msecs_to_jiffies(8 + 16 + 7); timeout = jiffies + msecs_to_jiffies(MIN_SLEEP_TIME); - if (time_before((unsigned long)time,timeout)) { + if (time_before((unsigned long)time, timeout)) { spin_unlock_irqrestore(&priv->ps_lock, flags); netdev_info(dev, "too short to sleep::%lld < %ld\n", time - jiffies, msecs_to_jiffies(MIN_SLEEP_TIME)); From f6758e7961e9158c55028f25cfa0c387bb8fe81b Mon Sep 17 00:00:00 2001 From: Drew Fustini Date: Thu, 28 May 2015 21:04:23 -0500 Subject: [PATCH 0749/1163] staging: unisys: visorbus: add static declarations Add static declarations to statisfy sparse warnings in: drivers/staging/unisys/visorbus/visorbus_main.c warning: symbol 'visorbus_debug' was not declared warning: symbol 'visorbus_forcematch' was not declared warning: symbol 'visorbus_forcenomatch' was not declared warning: symbol 'visorbus_devicetest' was not declared warning: symbol 'visorbus_debugref' was not declared warning: symbol 'visorbus_bus_groups' was not declared warning: symbol 'devmajorminor_create_file' was not declared warning: symbol 'devmajorminor_remove_file' was not declared warning: symbol 'devmajorminor_remove_all_files' was not declared warning: symbol 'unregister_devmajorminor_attributes' was not declared Signed-off-by: Drew Fustini Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorbus_main.c | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index a89889607e71..00f9a146806c 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -28,12 +28,12 @@ #define MYDRVNAME "visorbus" /* module parameters */ -int visorbus_debug; -int visorbus_forcematch; -int visorbus_forcenomatch; +static int visorbus_debug; +static int visorbus_forcematch; +static int visorbus_forcenomatch; #define MAXDEVICETEST 4 -int visorbus_devicetest; -int visorbus_debugref; +static int visorbus_devicetest; +static int visorbus_debugref; #define SERIALLOOPBACKCHANADDR (100 * 1024 * 1024) /** This is the private data that we store for each bus device instance. @@ -79,7 +79,7 @@ static const struct attribute_group visorbus_bus_group = { .attrs = visorbus_bus_attrs, }; -const struct attribute_group *visorbus_bus_groups[] = { +static const struct attribute_group *visorbus_bus_groups[] = { &visorbus_bus_group, NULL, }; @@ -282,7 +282,7 @@ devmajorminor_attr_store(struct kobject *kobj, static int register_devmajorminor_attributes(struct visor_device *dev); -int +static int devmajorminor_create_file(struct visor_device *dev, const char *name, int major, int minor) { @@ -327,7 +327,7 @@ away: return rc; } -void +static void devmajorminor_remove_file(struct visor_device *dev, int slot) { int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]); @@ -344,7 +344,7 @@ devmajorminor_remove_file(struct visor_device *dev, int slot) kfree(myattr); } -void +static void devmajorminor_remove_all_files(struct visor_device *dev) { int i = 0; @@ -384,7 +384,7 @@ away: return rc; } -void +static void unregister_devmajorminor_attributes(struct visor_device *dev) { if (!dev->kobjdevmajorminor.parent) @@ -1797,26 +1797,21 @@ visorbus_exit(void) module_param_named(debug, visorbus_debug, int, S_IRUGO); MODULE_PARM_DESC(visorbus_debug, "1 to debug"); -int visorbus_debug = 0; module_param_named(forcematch, visorbus_forcematch, int, S_IRUGO); MODULE_PARM_DESC(visorbus_forcematch, "1 to force a successful dev <--> drv match"); -int visorbus_forcematch = 0; module_param_named(forcenomatch, visorbus_forcenomatch, int, S_IRUGO); MODULE_PARM_DESC(visorbus_forcenomatch, "1 to force an UNsuccessful dev <--> drv match"); -int visorbus_forcenomatch = 0; module_param_named(devicetest, visorbus_devicetest, int, S_IRUGO); MODULE_PARM_DESC(visorbus_devicetest, "non-0 to just test device creation and destruction"); -int visorbus_devicetest = 0; module_param_named(debugref, visorbus_debugref, int, S_IRUGO); MODULE_PARM_DESC(visorbus_debugref, "1 to debug reference counting"); -int visorbus_debugref = 0; MODULE_AUTHOR("Unisys"); MODULE_LICENSE("GPL"); From 1185aaf55c20a1dfea8b7362e954da55e0e84fa7 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sun, 31 May 2015 02:47:22 -0400 Subject: [PATCH 0750/1163] staging/lustre/ldlm: Fix up LDLM_POOL_SYSFS_WRITER*_STORE define The store method defined by LDLM_POOL_SYSFS_WRITER_STORE and LDLM_POOL_SYSFS_WRITER_NOLOCK_STORE defines should use size_t count, not unsigned long. This produced a warning on i386 (and other 32bit architectures too, I guess) where unsigned long is not 32 bit. Reported by kbuild test bot. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index cf81bdbd57cb..6601e6b12c32 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h @@ -265,7 +265,7 @@ typedef enum ldlm_policy_res ldlm_policy_res_t; static ssize_t var##_store(struct kobject *kobj, \ struct attribute *attr, \ const char *buffer, \ - unsigned long count) \ + size_t count) \ { \ struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool, \ pl_kobj); \ @@ -301,7 +301,7 @@ typedef enum ldlm_policy_res ldlm_policy_res_t; static ssize_t var##_store(struct kobject *kobj, \ struct attribute *attr, \ const char *buffer, \ - unsigned long count) \ + size_t count) \ { \ struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool, \ pl_kobj); \ From 5dc65d791ddafc9f6d944391e379708b6056fc48 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:40:16 +0200 Subject: [PATCH 0751/1163] tools:iio:iio_utils: add missing documentation Fully document public functions and elements. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/iio_utils.c | 85 ++++++++++++++++++++++++++++++++++++++++--- tools/iio/iio_utils.h | 5 ++- 2 files changed, 83 insertions(+), 7 deletions(-) diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c index e1828d0d8a38..5d5831d7dfd0 100644 --- a/tools/iio/iio_utils.c +++ b/tools/iio/iio_utils.c @@ -29,6 +29,8 @@ static char * const iio_direction[] = { * iioutils_break_up_name() - extract generic name from full channel name * @full_name: the full channel name * @generic_name: the output generic channel name + * + * Returns 0 on success, or a negative error code if string extraction failed. **/ int iioutils_break_up_name(const char *full_name, char **generic_name) @@ -76,11 +78,15 @@ int iioutils_break_up_name(const char *full_name, * iioutils_get_type() - find and process _type attribute data * @is_signed: output whether channel is signed * @bytes: output how many bytes the channel storage occupies + * @bits_used: output number of valid bits of data + * @shift: output amount of bits to shift right data before applying bit mask * @mask: output a bit mask for the raw data - * @be: big endian - * @device_dir: the iio device directory + * @be: output if data in big endian + * @device_dir: the IIO device directory * @name: the channel name * @generic_name: the channel type name + * + * Returns a value >= 0 on success, otherwise a negative error code. **/ int iioutils_get_type(unsigned *is_signed, unsigned *bytes, @@ -200,6 +206,16 @@ error_ret: return ret; } +/** + * iioutils_get_param_float() - read a float value from a channel parameter + * @output: output the float value + * @param_name: the parameter name to read + * @device_dir: the IIO device directory in sysfs + * @name: the channel name + * @generic_name: the channel type name + * + * Returns a value >= 0 on success, otherwise a negative error code. + **/ int iioutils_get_param_float(float *output, const char *param_name, const char *device_dir, @@ -266,8 +282,9 @@ error_ret: } /** - * bsort_channel_array_by_index() - reorder so that the array is in index order - * + * bsort_channel_array_by_index() - sort the array in index order + * @ci_array: the iio_channel_info array to be sorted + * @cnt: the amount of array elements **/ void bsort_channel_array_by_index(struct iio_channel_info **ci_array, @@ -289,7 +306,10 @@ void bsort_channel_array_by_index(struct iio_channel_info **ci_array, /** * build_channel_array() - function to figure out what channels are present * @device_dir: the IIO device directory in sysfs - * @ + * @ci_array: output the resulting array of iio_channel_info + * @counter: output the amount of array elements + * + * Returns 0 on success, otherwise a negative error code. **/ int build_channel_array(const char *device_dir, struct iio_channel_info **ci_array, @@ -525,8 +545,10 @@ int calc_digits(int num) /** * find_type_by_name() - function to match top level types by name * @name: top level type instance name - * @type: the type of top level instance being sort + * @type: the type of top level instance being searched * + * Returns the device number of a matched IIO device on success, otherwise a + * negative error code. * Typical types this is used for are device and trigger. **/ int find_type_by_name(const char *name, const char *type) @@ -684,11 +706,28 @@ error_free: return ret; } +/** + * write_sysfs_int() - write an integer value to a sysfs file + * @filename: name of the file to write to + * @basedir: the sysfs directory in which the file is to be found + * @val: integer value to write to file + * + * Returns a value >= 0 on success, otherwise a negative error code. + **/ int write_sysfs_int(char *filename, char *basedir, int val) { return _write_sysfs_int(filename, basedir, val, 0); } +/** + * write_sysfs_int_and_verify() - write an integer value to a sysfs file + * and verify + * @filename: name of the file to write to + * @basedir: the sysfs directory in which the file is to be found + * @val: integer value to write to file + * + * Returns a value >= 0 on success, otherwise a negative error code. + **/ int write_sysfs_int_and_verify(char *filename, char *basedir, int val) { return _write_sysfs_int(filename, basedir, val, 1); @@ -770,17 +809,35 @@ error_free: * @filename: name of file to write to * @basedir: the sysfs directory in which the file is to be found * @val: the string to write + * + * Returns a value >= 0 on success, otherwise a negative error code. **/ int write_sysfs_string_and_verify(char *filename, char *basedir, char *val) { return _write_sysfs_string(filename, basedir, val, 1); } +/** + * write_sysfs_string() - write string to a sysfs file + * @filename: name of file to write to + * @basedir: the sysfs directory in which the file is to be found + * @val: the string to write + * + * Returns a value >= 0 on success, otherwise a negative error code. + **/ int write_sysfs_string(char *filename, char *basedir, char *val) { return _write_sysfs_string(filename, basedir, val, 0); } +/** + * read_sysfs_posint() - read an integer value from file + * @filename: name of file to read from + * @basedir: the sysfs directory in which the file is to be found + * + * Returns the read integer value >= 0 on success, otherwise a negative error + * code. + **/ int read_sysfs_posint(char *filename, char *basedir) { int ret; @@ -817,6 +874,14 @@ error_free: return ret; } +/** + * read_sysfs_float() - read a float value from file + * @filename: name of file to read from + * @basedir: the sysfs directory in which the file is to be found + * @val: output the read float value + * + * Returns a value >= 0 on success, otherwise a negative error code. + **/ int read_sysfs_float(char *filename, char *basedir, float *val) { int ret = 0; @@ -853,6 +918,14 @@ error_free: return ret; } +/** + * read_sysfs_string() - read a string from file + * @filename: name of file to read from + * @basedir: the sysfs directory in which the file is to be found + * @str: output the read string + * + * Returns a value >= 0 on success, otherwise a negative error code. + **/ int read_sysfs_string(const char *filename, const char *basedir, char *str) { int ret = 0; diff --git a/tools/iio/iio_utils.h b/tools/iio/iio_utils.h index 1bc837b2d769..e5eb46ade0a3 100644 --- a/tools/iio/iio_utils.h +++ b/tools/iio/iio_utils.h @@ -28,9 +28,12 @@ extern const char *iio_dir; * @offset: offset to be applied for conversion to si units * @index: the channel index in the buffer output * @bytes: number of bytes occupied in buffer output + * @bits_used: number of valid bits of data + * @shift: amount of bits to shift right data before applying bit mask * @mask: a bit mask for the raw output + * @be: flag if data is big endian * @is_signed: is the raw value stored signed - * @enabled: is this channel enabled + * @location: data offset for this channel inside the buffer (in bytes) **/ struct iio_channel_info { char *name; From 0e799878175aa7d08f5882b6a391de4724c52e9e Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:40:17 +0200 Subject: [PATCH 0752/1163] tools:iio: return values directly Return directly, if no common cleanup is required. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/generic_buffer.c | 5 ++--- tools/iio/iio_event_monitor.c | 5 ++--- tools/iio/iio_utils.c | 27 ++++++++++++--------------- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c index cf9a4120204f..62ec398922a0 100644 --- a/tools/iio/generic_buffer.c +++ b/tools/iio/generic_buffer.c @@ -238,8 +238,7 @@ int main(int argc, char **argv) dev_num = find_type_by_name(device_name, "iio:device"); if (dev_num < 0) { printf("Failed to find the %s\n", device_name); - ret = dev_num; - goto error_ret; + return dev_num; } printf("iio device number being used is %d\n", dev_num); @@ -410,6 +409,6 @@ error_free_triggername: free(trigger_name); error_free_dev_dir_name: free(dev_dir_name); -error_ret: + return ret; } diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c index 1316527f3c3c..7f56238b1d66 100644 --- a/tools/iio/iio_event_monitor.c +++ b/tools/iio/iio_event_monitor.c @@ -258,8 +258,7 @@ int main(int argc, char **argv) device_name, dev_num); ret = asprintf(&chrdev_name, "/dev/iio:device%d", dev_num); if (ret < 0) { - ret = -ENOMEM; - goto error_ret; + return -ENOMEM; } } else { /* If we can't find a IIO device by name assume device_name is a @@ -312,6 +311,6 @@ int main(int argc, char **argv) error_free_chrdev_name: free(chrdev_name); -error_ret: + return ret; } diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c index 5d5831d7dfd0..0524725279bb 100644 --- a/tools/iio/iio_utils.c +++ b/tools/iio/iio_utils.c @@ -107,10 +107,9 @@ int iioutils_get_type(unsigned *is_signed, const struct dirent *ent; ret = asprintf(&scan_el_dir, FORMAT_SCAN_ELEMENTS_DIR, device_dir); - if (ret < 0) { - ret = -ENOMEM; - goto error_ret; - } + if (ret < 0) + return -ENOMEM; + ret = asprintf(&builtname, FORMAT_TYPE_FILE, name); if (ret < 0) { ret = -ENOMEM; @@ -202,7 +201,7 @@ error_free_builtname: free(builtname); error_free_scan_el_dir: free(scan_el_dir); -error_ret: + return ret; } @@ -230,10 +229,9 @@ int iioutils_get_param_float(float *output, const struct dirent *ent; ret = asprintf(&builtname, "%s_%s", name, param_name); - if (ret < 0) { - ret = -ENOMEM; - goto error_ret; - } + if (ret < 0) + return -ENOMEM; + ret = asprintf(&builtname_generic, "%s_%s", generic_name, param_name); if (ret < 0) { @@ -277,7 +275,7 @@ error_free_builtname_generic: free(builtname_generic); error_free_builtname: free(builtname); -error_ret: + return ret; } @@ -326,10 +324,9 @@ int build_channel_array(const char *device_dir, *counter = 0; ret = asprintf(&scan_el_dir, FORMAT_SCAN_ELEMENTS_DIR, device_dir); - if (ret < 0) { - ret = -ENOMEM; - goto error_ret; - } + if (ret < 0) + return -ENOMEM; + dp = opendir(scan_el_dir); if (dp == NULL) { ret = -errno; @@ -526,7 +523,7 @@ error_close_dir: error_free_name: free(scan_el_dir); -error_ret: + return ret; } From 916e89e4b7272e1eda9eba057cf25197129bcf79 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:40:18 +0200 Subject: [PATCH 0753/1163] tools:iio:iio_event_monitor: refactor events output Refactor the code in print_event() to reduce code duplication and better reflect that the type is output unconditionally, as well as cascade the dependency of the diff-channel. Saves a few lines of code, as well. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/iio_event_monitor.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c index 7f56238b1d66..016760e769c0 100644 --- a/tools/iio/iio_event_monitor.c +++ b/tools/iio/iio_event_monitor.c @@ -213,23 +213,19 @@ static void print_event(struct iio_event_data *event) return; } - printf("Event: time: %lld, ", event->timestamp); + printf("Event: time: %lld, type: %s", event->timestamp, + iio_chan_type_name_spec[type]); - if (mod != IIO_NO_MOD) { - printf("type: %s(%s), ", - iio_chan_type_name_spec[type], - iio_modifier_names[mod]); - } else { - printf("type: %s, ", - iio_chan_type_name_spec[type]); + if (mod != IIO_NO_MOD) + printf("(%s)", iio_modifier_names[mod]); + + if (chan >= 0) { + printf(", channel: %d", chan); + if (diff && chan2 >= 0) + printf("-%d", chan2); } - if (diff && chan >= 0 && chan2 >= 0) - printf("channel: %d-%d, ", chan, chan2); - else if (chan >= 0) - printf("channel: %d, ", chan); - - printf("evtype: %s", iio_ev_type_text[ev_type]); + printf(", evtype: %s", iio_ev_type_text[ev_type]); if (dir != IIO_EV_DIR_NONE) printf(", direction: %s", iio_ev_dir_text[dir]); From 33ebcb21a67f257faf1128f08a6d7c0299cb0da2 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:40:19 +0200 Subject: [PATCH 0754/1163] tools:iio:iio_utils: refactor assignment of is_signed Change the assignment of *is_signed in iioutils_get_type() to a one-liner, as already done with *be. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/iio_utils.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c index 0524725279bb..c83f4dfe71d6 100644 --- a/tools/iio/iio_utils.c +++ b/tools/iio/iio_utils.c @@ -168,10 +168,7 @@ int iioutils_get_type(unsigned *is_signed, *mask = ~0; else *mask = (1 << *bits_used) - 1; - if (signchar == 's') - *is_signed = 1; - else - *is_signed = 0; + *is_signed = (signchar == 's'); if (fclose(sysfsfp)) { ret = -errno; printf("Failed to close %s\n", filename); From ace76e42bcd5d67e5be303997a4dc325d44366ce Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:40:20 +0200 Subject: [PATCH 0755/1163] tools:iio:iio_utils: move up reset of sysfsfp In iioutils_get_type() it is logically better fitting to have sysfsfp assigned zero right after closing it. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/iio_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c index c83f4dfe71d6..7c0abb306f5a 100644 --- a/tools/iio/iio_utils.c +++ b/tools/iio/iio_utils.c @@ -175,10 +175,10 @@ int iioutils_get_type(unsigned *is_signed, goto error_free_filename; } + sysfsfp = 0; free(filename); filename = 0; - sysfsfp = 0; } error_close_sysfsfp: if (sysfsfp) From 1e7c34788de3c0e5b18b6f27c42c191da5811c74 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:40:21 +0200 Subject: [PATCH 0756/1163] tools:iio:iio_utils: initialize count during declaration In build_channel_array(), count can be initialized already during variable declaration. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/iio_utils.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c index 7c0abb306f5a..dfee1a3f3f63 100644 --- a/tools/iio/iio_utils.c +++ b/tools/iio/iio_utils.c @@ -312,7 +312,7 @@ int build_channel_array(const char *device_dir, { DIR *dp; FILE *sysfsfp; - int count, i; + int count = 0, i; struct iio_channel_info *current; int ret; const struct dirent *ent; @@ -370,7 +370,6 @@ int build_channel_array(const char *device_dir, goto error_close_dir; } seekdir(dp, 0); - count = 0; while (ent = readdir(dp), ent != NULL) { if (strcmp(ent->d_name + strlen(ent->d_name) - strlen("_en"), "_en") == 0) { From e06e3d7112f2ec5494d2d934a8641a53885003ee Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:40:22 +0200 Subject: [PATCH 0757/1163] tools:iio: rework program parameters In generic_buffer.c: sort program parameters alphabetically and provide usage information In lsiio.c: drop unused parameters Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/generic_buffer.c | 55 +++++++++++++++++++++++++------------- tools/iio/lsiio.c | 6 ++--- 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c index 62ec398922a0..4eebb6616e5c 100644 --- a/tools/iio/generic_buffer.c +++ b/tools/iio/generic_buffer.c @@ -168,6 +168,19 @@ void process_scan(char *data, printf("\n"); } +void print_usage(void) +{ + printf("Usage: generic_buffer [options]...\n" + "Capture, convert and output data from IIO device buffer\n" + " -c Do n conversions\n" + " -e Disable wait for event (new data)\n" + " -g Use trigger-less mode\n" + " -l Set buffer length to n samples\n" + " -n Set device name (mandatory)\n" + " -t Set trigger name\n" + " -w Set delay between reads in us (event-less mode)\n"); +} + int main(int argc, char **argv) { unsigned long num_loops = 2; @@ -193,29 +206,19 @@ int main(int argc, char **argv) struct iio_channel_info *channels; - while ((c = getopt(argc, argv, "l:w:c:et:n:g")) != -1) { + while ((c = getopt(argc, argv, "c:egl:n:t:w:")) != -1) { switch (c) { - case 'n': - device_name = optarg; - break; - case 't': - trigger_name = optarg; - datardytrigger = 0; - break; - case 'e': - noevents = 1; - break; case 'c': errno = 0; num_loops = strtoul(optarg, &dummy, 10); if (errno) return -errno; break; - case 'w': - errno = 0; - timedelay = strtoul(optarg, &dummy, 10); - if (errno) - return -errno; + case 'e': + noevents = 1; + break; + case 'g': + notrigger = 1; break; case 'l': errno = 0; @@ -223,16 +226,30 @@ int main(int argc, char **argv) if (errno) return -errno; break; - case 'g': - notrigger = 1; + case 'n': + device_name = optarg; + break; + case 't': + trigger_name = optarg; + datardytrigger = 0; + break; + case 'w': + errno = 0; + timedelay = strtoul(optarg, &dummy, 10); + if (errno) + return -errno; break; case '?': + print_usage(); return -1; } } - if (device_name == NULL) + if (device_name == NULL) { + printf("Device name not set\n"); + print_usage(); return -1; + } /* Find the device requested */ dev_num = find_type_by_name(device_name, "iio:device"); diff --git a/tools/iio/lsiio.c b/tools/iio/lsiio.c index b1089adb7d3a..b59ee1733924 100644 --- a/tools/iio/lsiio.c +++ b/tools/iio/lsiio.c @@ -164,7 +164,7 @@ int main(int argc, char **argv) { int c, err = 0; - while ((c = getopt(argc, argv, "d:D:v")) != EOF) { + while ((c = getopt(argc, argv, "v")) != EOF) { switch (c) { case 'v': verblevel++; @@ -179,9 +179,7 @@ int main(int argc, char **argv) if (err || argc > optind) { fprintf(stderr, "Usage: lsiio [options]...\n" "List industrial I/O devices\n" - " -v, --verbose\n" - " Increase verbosity (may be given multiple times)\n" - ); + " -v Increase verbosity (may be given multiple times)\n"); exit(1); } From 9d4752544d17a10a40be5fc5ef68edcae5363599 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:40:36 +0200 Subject: [PATCH 0758/1163] tools:iio:iio_utils: pass strings as const Mark strings, which are not supposed to be changed (basedir, filename, value), as const in function parameters. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/iio_utils.c | 22 +++++++++++++--------- tools/iio/iio_utils.h | 15 +++++++++------ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c index dfee1a3f3f63..ec9ab7f9ae4c 100644 --- a/tools/iio/iio_utils.c +++ b/tools/iio/iio_utils.c @@ -634,7 +634,8 @@ error_close_dir: return ret; } -static int _write_sysfs_int(char *filename, char *basedir, int val, int verify) +static int _write_sysfs_int(const char *filename, const char *basedir, int val, + int verify) { int ret = 0; FILE *sysfsfp; @@ -707,7 +708,7 @@ error_free: * * Returns a value >= 0 on success, otherwise a negative error code. **/ -int write_sysfs_int(char *filename, char *basedir, int val) +int write_sysfs_int(const char *filename, const char *basedir, int val) { return _write_sysfs_int(filename, basedir, val, 0); } @@ -721,13 +722,14 @@ int write_sysfs_int(char *filename, char *basedir, int val) * * Returns a value >= 0 on success, otherwise a negative error code. **/ -int write_sysfs_int_and_verify(char *filename, char *basedir, int val) +int write_sysfs_int_and_verify(const char *filename, const char *basedir, + int val) { return _write_sysfs_int(filename, basedir, val, 1); } -static int _write_sysfs_string(char *filename, char *basedir, char *val, - int verify) +static int _write_sysfs_string(const char *filename, const char *basedir, + const char *val, int verify) { int ret = 0; FILE *sysfsfp; @@ -805,7 +807,8 @@ error_free: * * Returns a value >= 0 on success, otherwise a negative error code. **/ -int write_sysfs_string_and_verify(char *filename, char *basedir, char *val) +int write_sysfs_string_and_verify(const char *filename, const char *basedir, + const char *val) { return _write_sysfs_string(filename, basedir, val, 1); } @@ -818,7 +821,8 @@ int write_sysfs_string_and_verify(char *filename, char *basedir, char *val) * * Returns a value >= 0 on success, otherwise a negative error code. **/ -int write_sysfs_string(char *filename, char *basedir, char *val) +int write_sysfs_string(const char *filename, const char *basedir, + const char *val) { return _write_sysfs_string(filename, basedir, val, 0); } @@ -831,7 +835,7 @@ int write_sysfs_string(char *filename, char *basedir, char *val) * Returns the read integer value >= 0 on success, otherwise a negative error * code. **/ -int read_sysfs_posint(char *filename, char *basedir) +int read_sysfs_posint(const char *filename, const char *basedir) { int ret; FILE *sysfsfp; @@ -875,7 +879,7 @@ error_free: * * Returns a value >= 0 on success, otherwise a negative error code. **/ -int read_sysfs_float(char *filename, char *basedir, float *val) +int read_sysfs_float(const char *filename, const char *basedir, float *val) { int ret = 0; FILE *sysfsfp; diff --git a/tools/iio/iio_utils.h b/tools/iio/iio_utils.h index e5eb46ade0a3..379eed9deaea 100644 --- a/tools/iio/iio_utils.h +++ b/tools/iio/iio_utils.h @@ -63,12 +63,15 @@ void bsort_channel_array_by_index(struct iio_channel_info **ci_array, int cnt); int build_channel_array(const char *device_dir, struct iio_channel_info **ci_array, int *counter); int find_type_by_name(const char *name, const char *type); -int write_sysfs_int(char *filename, char *basedir, int val); -int write_sysfs_int_and_verify(char *filename, char *basedir, int val); -int write_sysfs_string_and_verify(char *filename, char *basedir, char *val); -int write_sysfs_string(char *filename, char *basedir, char *val); -int read_sysfs_posint(char *filename, char *basedir); -int read_sysfs_float(char *filename, char *basedir, float *val); +int write_sysfs_int(const char *filename, const char *basedir, int val); +int write_sysfs_int_and_verify(const char *filename, const char *basedir, + int val); +int write_sysfs_string_and_verify(const char *filename, const char *basedir, + const char *val); +int write_sysfs_string(const char *filename, const char *basedir, + const char *val); +int read_sysfs_posint(const char *filename, const char *basedir); +int read_sysfs_float(const char *filename, const char *basedir, float *val); int read_sysfs_string(const char *filename, const char *basedir, char *str); #endif /* _IIO_UTILS_H_ */ From ff7d4f5981a8a139ead70adef3c1d0ed574bca01 Mon Sep 17 00:00:00 2001 From: Laurent Navet Date: Sat, 30 May 2015 22:35:36 +0200 Subject: [PATCH 0759/1163] iio: buffer: remove unneeded test The same code is executed regardless ret value, so this test can be removed. Also fix coverity scan CID 1268786. Signed-off-by: Laurent Navet Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-buffer.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 11291259b7b9..dad61ab9b36f 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -888,8 +888,6 @@ static ssize_t iio_buffer_store_enable(struct device *dev, ret = __iio_update_buffers(indio_dev, NULL, indio_dev->buffer); - if (ret < 0) - goto done; done: mutex_unlock(&indio_dev->mlock); return (ret < 0) ? ret : len; From b3f6af36e52e1e61cf7571c77dba0e905c38297a Mon Sep 17 00:00:00 2001 From: Vladimirs Ambrosovs Date: Sat, 30 May 2015 11:20:15 +0300 Subject: [PATCH 0760/1163] staging: iio_simple_dummy: fix init function This patch fixes the init function for the iio_simple_dummy driver. The main issues were absence of kfree for the allocated array, and no devices being removed in case the probe function fails, running in a loop. Signed-off-by: Vladimirs Ambrosovs Signed-off-by: Jonathan Cameron --- drivers/staging/iio/iio_simple_dummy.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/iio_simple_dummy.c b/drivers/staging/iio/iio_simple_dummy.c index b47bf9fb64be..d0a99637007c 100644 --- a/drivers/staging/iio/iio_simple_dummy.c +++ b/drivers/staging/iio/iio_simple_dummy.c @@ -722,9 +722,16 @@ static __init int iio_dummy_init(void) for (i = 0; i < instances; i++) { ret = iio_dummy_probe(i); if (ret < 0) - return ret; + goto error_remove_devs; } return 0; + +error_remove_devs: + while (i--) + iio_dummy_remove(i); + + kfree(iio_dummy_devs); + return ret; } module_init(iio_dummy_init); From 62a90da69df1255ba43d3b6595e71e639efd80a8 Mon Sep 17 00:00:00 2001 From: Vladimirs Ambrosovs Date: Sat, 30 May 2015 11:20:16 +0300 Subject: [PATCH 0761/1163] staging: iio_simple_dummy: fix return types The functions iio_dummy_remove(), iio_simple_dummy_events_unregister() and iio_dummy_evgen_release_irq() were changed to return void instead of int. Signed-off-by: Vladimirs Ambrosovs Signed-off-by: Jonathan Cameron --- drivers/staging/iio/iio_dummy_evgen.c | 4 +--- drivers/staging/iio/iio_dummy_evgen.h | 2 +- drivers/staging/iio/iio_simple_dummy.c | 10 ++-------- drivers/staging/iio/iio_simple_dummy.h | 8 +++----- drivers/staging/iio/iio_simple_dummy_events.c | 4 +--- 5 files changed, 8 insertions(+), 20 deletions(-) diff --git a/drivers/staging/iio/iio_dummy_evgen.c b/drivers/staging/iio/iio_dummy_evgen.c index 0c9c86d7b509..c54d5b5443a6 100644 --- a/drivers/staging/iio/iio_dummy_evgen.c +++ b/drivers/staging/iio/iio_dummy_evgen.c @@ -128,13 +128,11 @@ EXPORT_SYMBOL_GPL(iio_dummy_evgen_get_irq); * * Used by client driver instances to give the irqs back when they disconnect */ -int iio_dummy_evgen_release_irq(int irq) +void iio_dummy_evgen_release_irq(int irq) { mutex_lock(&iio_evgen->lock); iio_evgen->inuse[irq - iio_evgen->base] = false; mutex_unlock(&iio_evgen->lock); - - return 0; } EXPORT_SYMBOL_GPL(iio_dummy_evgen_release_irq); diff --git a/drivers/staging/iio/iio_dummy_evgen.h b/drivers/staging/iio/iio_dummy_evgen.h index 2ac293ab7c8f..d044b946e74a 100644 --- a/drivers/staging/iio/iio_dummy_evgen.h +++ b/drivers/staging/iio/iio_dummy_evgen.h @@ -8,6 +8,6 @@ struct iio_dummy_regs { struct iio_dummy_regs *iio_dummy_evgen_get_regs(int irq); int iio_dummy_evgen_get_irq(void); -int iio_dummy_evgen_release_irq(int irq); +void iio_dummy_evgen_release_irq(int irq); #endif /* _IIO_DUMMY_EVGEN_H_ */ diff --git a/drivers/staging/iio/iio_simple_dummy.c b/drivers/staging/iio/iio_simple_dummy.c index d0a99637007c..dc9482c7569c 100644 --- a/drivers/staging/iio/iio_simple_dummy.c +++ b/drivers/staging/iio/iio_simple_dummy.c @@ -665,9 +665,8 @@ error_ret: * * Parameters follow those of iio_dummy_probe for buses. */ -static int iio_dummy_remove(int index) +static void iio_dummy_remove(int index) { - int ret; /* * Get a pointer to the device instance iio_dev structure * from the bus subsystem. E.g. @@ -685,15 +684,10 @@ static int iio_dummy_remove(int index) /* Buffered capture related cleanup */ iio_simple_dummy_unconfigure_buffer(indio_dev); - ret = iio_simple_dummy_events_unregister(indio_dev); - if (ret) - goto error_ret; + iio_simple_dummy_events_unregister(indio_dev); /* Free all structures */ iio_device_free(indio_dev); - -error_ret: - return ret; } /** diff --git a/drivers/staging/iio/iio_simple_dummy.h b/drivers/staging/iio/iio_simple_dummy.h index d86ccb76eb6d..e877a99540ab 100644 --- a/drivers/staging/iio/iio_simple_dummy.h +++ b/drivers/staging/iio/iio_simple_dummy.h @@ -79,7 +79,7 @@ int iio_simple_dummy_write_event_value(struct iio_dev *indio_dev, int val2); int iio_simple_dummy_events_register(struct iio_dev *indio_dev); -int iio_simple_dummy_events_unregister(struct iio_dev *indio_dev); +void iio_simple_dummy_events_unregister(struct iio_dev *indio_dev); #else /* Stubs for when events are disabled at compile time */ @@ -89,11 +89,9 @@ iio_simple_dummy_events_register(struct iio_dev *indio_dev) return 0; }; -static inline int +static inline void iio_simple_dummy_events_unregister(struct iio_dev *indio_dev) -{ - return 0; -}; +{ }; #endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS*/ diff --git a/drivers/staging/iio/iio_simple_dummy_events.c b/drivers/staging/iio/iio_simple_dummy_events.c index c32ef78d8e5f..ecc563cb6cb9 100644 --- a/drivers/staging/iio/iio_simple_dummy_events.c +++ b/drivers/staging/iio/iio_simple_dummy_events.c @@ -257,13 +257,11 @@ error_ret: * iio_simple_dummy_events_unregister() - tidy up interrupt handling on remove * @indio_dev: device instance data */ -int iio_simple_dummy_events_unregister(struct iio_dev *indio_dev) +void iio_simple_dummy_events_unregister(struct iio_dev *indio_dev) { struct iio_dummy_state *st = iio_priv(indio_dev); free_irq(st->event_irq, indio_dev); /* Not part of normal driver */ iio_dummy_evgen_release_irq(st->event_irq); - - return 0; } From 4dcaa5f75473271ea83545eb5a95db8d7a152362 Mon Sep 17 00:00:00 2001 From: Vladimirs Ambrosovs Date: Sat, 30 May 2015 11:20:17 +0300 Subject: [PATCH 0762/1163] staging: iio_simple_dummy: fix module_param type Fix the module_param "instances" type to uint, since the variable type holding the value is unsigned. Signed-off-by: Vladimirs Ambrosovs Signed-off-by: Jonathan Cameron --- drivers/staging/iio/iio_simple_dummy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/iio_simple_dummy.c b/drivers/staging/iio/iio_simple_dummy.c index dc9482c7569c..1629a8a6bf26 100644 --- a/drivers/staging/iio/iio_simple_dummy.c +++ b/drivers/staging/iio/iio_simple_dummy.c @@ -30,7 +30,7 @@ * dummy devices are registered. */ static unsigned instances = 1; -module_param(instances, int, 0); +module_param(instances, uint, 0); /* Pointer array used to fake bus elements */ static struct iio_dev **iio_dummy_devs; From 629bc02331f7aae6ef775fb4c15e6d8aa58722f1 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 29 May 2015 18:14:20 +0200 Subject: [PATCH 0763/1163] iio: Always compute masklength Even if no userspace consumer buffer is attached to the IIO device at registration we still need to compute the masklength, since it is possible that a in-kernel consumer buffer is going to get attached to the device at a later point. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-buffer.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index dad61ab9b36f..209c7ad793c5 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -966,6 +966,15 @@ int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev) int ret, i, attrn, attrcount, attrcount_orig = 0; const struct iio_chan_spec *channels; + channels = indio_dev->channels; + if (channels) { + int ml = indio_dev->masklength; + + for (i = 0; i < indio_dev->num_channels; i++) + ml = max(ml, channels[i].scan_index + 1); + indio_dev->masklength = ml; + } + if (!buffer) return 0; @@ -1009,12 +1018,6 @@ int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev) if (channels[i].scan_index < 0) continue; - /* Establish necessary mask length */ - if (channels[i].scan_index > - (int)indio_dev->masklength - 1) - indio_dev->masklength - = channels[i].scan_index + 1; - ret = iio_buffer_add_channel_sysfs(indio_dev, &channels[i]); if (ret < 0) From 225d59adf1c899176cce0fc80e42b1d1c12f109f Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 29 May 2015 18:14:21 +0200 Subject: [PATCH 0764/1163] iio: Specify supported modes for buffers For each buffer type specify the supported device modes for this buffer. This allows us for devices which support multiple different operating modes to pick the correct operating mode based on the modes supported by the attached buffers. It also prevents that buffers with conflicting modes are attached to a device at the same time or that a buffer with a non-supported mode is attached to a device (e.g. in-kernel callback buffer to a device only supporting hardware mode). Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/buffer_cb.c | 2 ++ drivers/iio/industrialio-buffer.c | 18 +++++++++++++++--- drivers/iio/kfifo_buf.c | 2 ++ drivers/staging/iio/accel/sca3000_ring.c | 2 ++ include/linux/iio/buffer.h | 3 +++ 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/iio/buffer_cb.c b/drivers/iio/buffer_cb.c index eb46e728aa2e..1648e6e5a848 100644 --- a/drivers/iio/buffer_cb.c +++ b/drivers/iio/buffer_cb.c @@ -33,6 +33,8 @@ static void iio_buffer_cb_release(struct iio_buffer *buffer) static const struct iio_buffer_access_funcs iio_cb_access = { .store_to = &iio_buffer_cb_store_to, .release = &iio_buffer_cb_release, + + .modes = INDIO_BUFFER_SOFTWARE | INDIO_BUFFER_TRIGGERED, }; struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev, diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 209c7ad793c5..0a14bd825fe0 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -604,6 +604,7 @@ static int iio_verify_update(struct iio_dev *indio_dev, const unsigned long *scan_mask; struct iio_buffer *buffer; bool scan_timestamp; + unsigned int modes; memset(config, 0, sizeof(*config)); @@ -615,12 +616,23 @@ static int iio_verify_update(struct iio_dev *indio_dev, list_is_singular(&indio_dev->buffer_list)) return 0; + modes = indio_dev->modes; + + list_for_each_entry(buffer, &indio_dev->buffer_list, buffer_list) { + if (buffer == remove_buffer) + continue; + modes &= buffer->access->modes; + } + + if (insert_buffer) + modes &= insert_buffer->access->modes; + /* Definitely possible for devices to support both of these. */ - if ((indio_dev->modes & INDIO_BUFFER_TRIGGERED) && indio_dev->trig) { + if ((modes & INDIO_BUFFER_TRIGGERED) && indio_dev->trig) { config->mode = INDIO_BUFFER_TRIGGERED; - } else if (indio_dev->modes & INDIO_BUFFER_HARDWARE) { + } else if (modes & INDIO_BUFFER_HARDWARE) { config->mode = INDIO_BUFFER_HARDWARE; - } else if (indio_dev->modes & INDIO_BUFFER_SOFTWARE) { + } else if (modes & INDIO_BUFFER_SOFTWARE) { config->mode = INDIO_BUFFER_SOFTWARE; } else { /* Can only occur on first buffer */ diff --git a/drivers/iio/kfifo_buf.c b/drivers/iio/kfifo_buf.c index 847ca561afe0..db15684a4731 100644 --- a/drivers/iio/kfifo_buf.c +++ b/drivers/iio/kfifo_buf.c @@ -135,6 +135,8 @@ static const struct iio_buffer_access_funcs kfifo_access_funcs = { .set_bytes_per_datum = &iio_set_bytes_per_datum_kfifo, .set_length = &iio_set_length_kfifo, .release = &iio_kfifo_buffer_release, + + .modes = INDIO_BUFFER_SOFTWARE | INDIO_BUFFER_TRIGGERED, }; struct iio_buffer *iio_kfifo_allocate(void) diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c index 8589eade1057..23685e74917e 100644 --- a/drivers/staging/iio/accel/sca3000_ring.c +++ b/drivers/staging/iio/accel/sca3000_ring.c @@ -258,6 +258,8 @@ static const struct iio_buffer_access_funcs sca3000_ring_access_funcs = { .read_first_n = &sca3000_read_first_n_hw_rb, .data_available = sca3000_ring_buf_data_available, .release = sca3000_ring_release, + + .modes = INDIO_BUFFER_HARDWARE, }; int sca3000_configure_ring(struct iio_dev *indio_dev) diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h index eb8622b78ec9..1600c55828e0 100644 --- a/include/linux/iio/buffer.h +++ b/include/linux/iio/buffer.h @@ -29,6 +29,7 @@ struct iio_buffer; * @set_length: set number of datums in buffer * @release: called when the last reference to the buffer is dropped, * should free all resources allocated by the buffer. + * @modes: Supported operating modes by this buffer type * * The purpose of this structure is to make the buffer element * modular as event for a given driver, different usecases may require @@ -51,6 +52,8 @@ struct iio_buffer_access_funcs { int (*set_length)(struct iio_buffer *buffer, int length); void (*release)(struct iio_buffer *buffer); + + unsigned int modes; }; /** From 1e1ec2861e0d4307267096c3f74c17298c1cde98 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 29 May 2015 18:14:22 +0200 Subject: [PATCH 0765/1163] iio: Require strict scan mask matching in hardware mode In hardware mode we can not use the software demuxer, this means that the selected scan mask needs to match one of the available scan masks exactly. It also means that all attached buffers need to use the same scan mask. Given that when operating in hardware mode there is typically only a single buffer attached to the device this not an issue. Add a sanity check to make sure that only a single buffer is attached in hardware mode nevertheless. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-buffer.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 0a14bd825fe0..6eee1b044c60 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -239,13 +239,19 @@ static ssize_t iio_scan_el_show(struct device *dev, /* Note NULL used as error indicator as it doesn't make sense. */ static const unsigned long *iio_scan_mask_match(const unsigned long *av_masks, unsigned int masklength, - const unsigned long *mask) + const unsigned long *mask, + bool strict) { if (bitmap_empty(mask, masklength)) return NULL; while (*av_masks) { - if (bitmap_subset(mask, av_masks, masklength)) - return av_masks; + if (strict) { + if (bitmap_equal(mask, av_masks, masklength)) + return av_masks; + } else { + if (bitmap_subset(mask, av_masks, masklength)) + return av_masks; + } av_masks += BITS_TO_LONGS(masklength); } return NULL; @@ -295,7 +301,7 @@ static int iio_scan_mask_set(struct iio_dev *indio_dev, if (indio_dev->available_scan_masks) { mask = iio_scan_mask_match(indio_dev->available_scan_masks, indio_dev->masklength, - trialmask); + trialmask, false); if (!mask) goto err_invalid_mask; } @@ -602,6 +608,7 @@ static int iio_verify_update(struct iio_dev *indio_dev, { unsigned long *compound_mask; const unsigned long *scan_mask; + bool strict_scanmask = false; struct iio_buffer *buffer; bool scan_timestamp; unsigned int modes; @@ -631,7 +638,14 @@ static int iio_verify_update(struct iio_dev *indio_dev, if ((modes & INDIO_BUFFER_TRIGGERED) && indio_dev->trig) { config->mode = INDIO_BUFFER_TRIGGERED; } else if (modes & INDIO_BUFFER_HARDWARE) { + /* + * Keep things simple for now and only allow a single buffer to + * be connected in hardware mode. + */ + if (insert_buffer && !list_empty(&indio_dev->buffer_list)) + return -EINVAL; config->mode = INDIO_BUFFER_HARDWARE; + strict_scanmask = true; } else if (modes & INDIO_BUFFER_SOFTWARE) { config->mode = INDIO_BUFFER_SOFTWARE; } else { @@ -666,7 +680,8 @@ static int iio_verify_update(struct iio_dev *indio_dev, if (indio_dev->available_scan_masks) { scan_mask = iio_scan_mask_match(indio_dev->available_scan_masks, indio_dev->masklength, - compound_mask); + compound_mask, + strict_scanmask); kfree(compound_mask); if (scan_mask == NULL) return -EINVAL; From 5517547bf44731621338c1a4047196a49c790719 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 27 May 2015 11:20:52 +0300 Subject: [PATCH 0766/1163] iio: magnetometer: correct a harmless off by one check The line before limits i to 0-3 so the existing code works fine but the check is still off by one and >= is intended instead of >. Signed-off-by: Dan Carpenter Reviewed-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/mmc35240.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c index aa6e25d3bfc3..c71392cf1370 100644 --- a/drivers/iio/magnetometer/mmc35240.c +++ b/drivers/iio/magnetometer/mmc35240.c @@ -308,7 +308,7 @@ static int mmc35240_read_raw(struct iio_dev *indio_dev, return ret; i = (reg & MMC35240_CTRL1_BW_MASK) >> MMC35240_CTRL1_BW_SHIFT; - if (i < 0 || i > ARRAY_SIZE(mmc35240_samp_freq)) + if (i < 0 || i >= ARRAY_SIZE(mmc35240_samp_freq)) return -EINVAL; *val = mmc35240_samp_freq[i]; From ed6e75c7dc5627c7251002936577052ae73ac2db Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 27 May 2015 11:24:25 +0300 Subject: [PATCH 0767/1163] iio: light: signedness bug in stk3310_write_raw() "index" needs to be signed for the error handling to work. Fixes: be9e6229d676 ('iio: light: Add support for Sensortek STK3310') Signed-off-by: Dan Carpenter Signed-off-by: Jonathan Cameron --- drivers/iio/light/stk3310.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c index e79b9d89b024..fee4297d7c8f 100644 --- a/drivers/iio/light/stk3310.c +++ b/drivers/iio/light/stk3310.c @@ -370,7 +370,7 @@ static int stk3310_write_raw(struct iio_dev *indio_dev, int val, int val2, long mask) { int ret; - unsigned int index; + int index; struct stk3310_data *data = iio_priv(indio_dev); switch (mask) { From f155bcf8deb4e93ea63aeb62b504fa6c0b007065 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 1 Jun 2015 21:06:34 +0200 Subject: [PATCH 0768/1163] staging: wilc1000: remove time wrapper The abstraction for time in this driver is completely unused, so remove it. Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/Makefile | 2 +- drivers/staging/wilc1000/wilc_osconfig.h | 1 - drivers/staging/wilc1000/wilc_oswrapper.h | 5 - drivers/staging/wilc1000/wilc_platform.h | 12 -- drivers/staging/wilc1000/wilc_time.c | 163 ----------------- drivers/staging/wilc1000/wilc_time.h | 205 ---------------------- 6 files changed, 1 insertion(+), 387 deletions(-) delete mode 100644 drivers/staging/wilc1000/wilc_time.c delete mode 100644 drivers/staging/wilc1000/wilc_time.h diff --git a/drivers/staging/wilc1000/Makefile b/drivers/staging/wilc1000/Makefile index 13e3ed8ef31e..44551ee3c697 100644 --- a/drivers/staging/wilc1000/Makefile +++ b/drivers/staging/wilc1000/Makefile @@ -27,7 +27,7 @@ ccflags-$(CONFIG_WILC1000_DYNAMICALLY_ALLOCATE_MEMROY) += -DWILC_NORMAL_ALLOC wilc1000-objs := wilc_wfi_netdevice.o wilc_wfi_cfgoperations.o linux_wlan.o linux_mon.o \ wilc_memory.o wilc_msgqueue.o wilc_semaphore.o wilc_sleep.o wilc_strutils.o \ - wilc_time.o wilc_timer.o coreconfigurator.o host_interface.o \ + wilc_timer.o coreconfigurator.o host_interface.o \ fifo_buffer.o wilc_sdio.o wilc_spi.o wilc_wlan_cfg.o wilc_debugfs.o wilc1000-$(CONFIG_WILC1000_SDIO) += linux_wlan_sdio.o diff --git a/drivers/staging/wilc1000/wilc_osconfig.h b/drivers/staging/wilc1000/wilc_osconfig.h index aa98ea5b423f..f3d3108de876 100644 --- a/drivers/staging/wilc1000/wilc_osconfig.h +++ b/drivers/staging/wilc1000/wilc_osconfig.h @@ -27,7 +27,6 @@ /* #define CONFIG_WILC_FILE_OPERATIONS_FEATURE */ /* #define CONFIG_WILC_FILE_OPERATIONS_STRING_API */ /* #define CONFIG_WILC_FILE_OPERATIONS_PATH_API */ -#define CONFIG_WILC_TIME_FEATURE /* #define CONFIG_WILC_EVENT_FEATURE */ /* #define CONFIG_WILC_EVENT_TIMEOUT */ /* #define CONFIG_WILC_SOCKET_FEATURE */ diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index 03a1ecf90625..728ce7cac85a 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -89,11 +89,6 @@ typedef WILC_Uint16 WILC_WideChar; #include "wilc_fileops.h" #endif -/* Time operations */ -#ifdef CONFIG_WILC_TIME_FEATURE -#include "wilc_time.h" -#endif - /* Event support */ #ifdef CONFIG_WILC_EVENT_FEATURE #include "wilc_event.h" diff --git a/drivers/staging/wilc1000/wilc_platform.h b/drivers/staging/wilc1000/wilc_platform.h index 87e4eedcc914..35d9f8a917ce 100644 --- a/drivers/staging/wilc1000/wilc_platform.h +++ b/drivers/staging/wilc1000/wilc_platform.h @@ -73,18 +73,6 @@ #error This feature is not supported by this OS #endif -/* CONFIG_WILC_TIME_FEATURE is implemented */ - -/* remove the following block when implementing its feature */ -#ifdef CONFIG_WILC_TIME_UTC_SINCE_1970 -#error This feature is not supported by this OS -#endif - -/* remove the following block when implementing its feature */ -#ifdef CONFIG_WILC_TIME_CALENDER -#error This feature is not supported by this OS -#endif - /* remove the following block when implementing its feature */ #ifdef CONFIG_WILC_EVENT_FEATURE #error This feature is not supported by this OS diff --git a/drivers/staging/wilc1000/wilc_time.c b/drivers/staging/wilc1000/wilc_time.c deleted file mode 100644 index 27c252b462ac..000000000000 --- a/drivers/staging/wilc1000/wilc_time.c +++ /dev/null @@ -1,163 +0,0 @@ - -#define _CRT_SECURE_NO_DEPRECATE -#include "wilc_oswrapper.h" - -#ifdef CONFIG_WILC_TIME_FEATURE - - -WILC_Uint32 WILC_TimeMsec(void) -{ - WILC_Uint32 u32Time = 0; - struct timespec current_time; - - current_time = current_kernel_time(); - u32Time = current_time.tv_sec * 1000; - u32Time += current_time.tv_nsec / 1000000; - - - return u32Time; -} - - -#ifdef CONFIG_WILC_EXTENDED_TIME_OPERATIONS - -/** - * @brief - * @details function returns the implementation's best approximation to the - * processor time used by the process since the beginning of an - * implementation-dependent time related only to the process invocation. - * @return WILC_Uint32 - * @note - * @author remil - * @date 11 Nov 2010 - * @version 1.0 - */ -WILC_Uint32 WILC_Clock() -{ - -} - - -/** - * @brief - * @details The difftime() function computes the difference between two calendar - * times (as returned by WILC_GetTime()): time1 - time0. - * @param[in] WILC_Time time1 - * @param[in] WILC_Time time0 - * @return WILC_Double - * @note - * @author remil - * @date 11 Nov 2010 - * @version 1.0 - */ -WILC_Double WILC_DiffTime(WILC_Time time1, WILC_Time time0) -{ - -} - - - -/** - * @brief - * @details The gmtime() function converts the time in seconds since - * the Epoch pointed to by timer into a broken-down time, - * expressed as Coordinated Universal Time (UTC). - * @param[in] const WILC_Time* timer - * @return WILC_tm* - * @note - * @author remil - * @date 11 Nov 2010 - * @version 1.0 - */ -WILC_tm *WILC_GmTime(const WILC_Time *timer) -{ - -} - - -/** - * @brief - * @details The localtime() function converts the time in seconds since - * the Epoch pointed to by timer into a broken-down time, expressed - * as a local time. The function corrects for the timezone and any - * seasonal time adjustments. Local timezone information is used as - * though localtime() calls tzset(). - * @param[in] const WILC_Time* timer - * @return WILC_tm* - * @note - * @author remil - * @date 11 Nov 2010 - * @version 1.0 - */ -WILC_tm *WILC_LocalTime(const WILC_Time *timer) -{ - -} - - -/** - * @brief - * @details The mktime() function converts the broken-down time, - * expressed as local time, in the structure pointed to by timeptr, - * into a time since the Epoch value with the same encoding as that - * of the values returned by time(). The original values of the tm_wday - * and tm_yday components of the structure are ignored, and the original - * values of the other components are not restricted to the ranges described - * in the entry. - * @param[in] WILC_tm* timer - * @return WILC_Time - * @note - * @author remil - * @date 11 Nov 2010 - * @version 1.0 - */ -WILC_Time WILC_MkTime(WILC_tm *timer) -{ - -} - - -/** - * @brief - * @details The strftime() function places bytes into the array - * pointed to by s as controlled by the string pointed to by format. - * @param[in] WILC_Char* s - * @param[in] WILC_Uint32 maxSize - * @param[in] const WILC_Char* format - * @param[in] const WILC_tm* timptr - * @return WILC_Uint32 - * @note - * @author remil - * @date 11 Nov 2010 - * @version 1.0 - */ -WILC_Uint32 WILC_StringFormatTime(WILC_Char *s, - WILC_Uint32 maxSize, - const WILC_Char *format, - const WILC_tm *timptr) -{ - -} - - -/** - * @brief The WILC_GetTime() function returns the value of time in seconds since the Epoch. - * @details The tloc argument points to an area where the return value is also stored. - * If tloc is a null pointer, no value is stored. - * @param[in] WILC_Time* tloc - * @return WILC_Time - * @note - * @author remil - * @date 11 Nov 2010 - * @version 1.0 - */ -WILC_Time WILC_GetTime(WILC_Time *tloc) -{ - -} - - -#endif -#endif - - diff --git a/drivers/staging/wilc1000/wilc_time.h b/drivers/staging/wilc1000/wilc_time.h deleted file mode 100644 index 787df7ded75c..000000000000 --- a/drivers/staging/wilc1000/wilc_time.h +++ /dev/null @@ -1,205 +0,0 @@ -#ifndef __WILC_TIME_H__ -#define __WILC_TIME_H__ - -/*! -* @file wilc_time.h -* @brief Time retrival functionality -* @author syounan -* @sa wilc_oswrapper.h top level OS wrapper file -* @date 2 Sep 2010 -* @version 1.0 -*/ - -#ifndef CONFIG_WILC_TIME_FEATURE -#error the feature CONFIG_WILC_TIME_FEATURE must be supported to include this file -#endif - -/*! -* @struct WILC_ThreadAttrs -* @brief Thread API options -* @author syounan -* @date 2 Sep 2010 -* @version 1.0 -*/ -typedef struct { - /* a dummy type to prevent compile errors on empty structure*/ - WILC_Uint8 dummy; -} tstrWILC_TimeAttrs; - -typedef struct { - /*!< current year */ - WILC_Uint16 u16Year; - /*!< current month */ - WILC_Uint8 u8Month; - /*!< current day */ - WILC_Uint8 u8Day; - - /*!< current hour (in 24H format) */ - WILC_Uint8 u8Hour; - /*!< current minute */ - WILC_Uint8 u8Miute; - /*!< current second */ - WILC_Uint8 u8Second; - -} tstrWILC_TimeCalender; - -/*! -* @brief returns the number of msec elapsed since system start up -* @return number of msec elapsed singe system start up -* @note since this returned value is 32 bit, the caller must handle - wraparounds in values every about 49 of continous operations -* @author syounan -* @date 2 Sep 2010 -* @version 1.0 -*/ -WILC_Uint32 WILC_TimeMsec(void); - - - -#ifdef CONFIG_WILC_EXTENDED_TIME_OPERATIONS -/** -* @brief -* @details function returns the implementation's best approximation to the - processor time used by the process since the beginning of an - implementation-dependent time related only to the process invocation. -* @return WILC_Uint32 -* @note -* @author remil -* @date 11 Nov 2010 -* @version 1.0 -*/ -WILC_Uint32 WILC_Clock(); - -/** -* @brief -* @details The difftime() function computes the difference between two calendar - times (as returned by WILC_GetTime()): time1 - time0. -* @param[in] WILC_Time time1 -* @param[in] WILC_Time time0 -* @return WILC_Double -* @note -* @author remil -* @date 11 Nov 2010 -* @version 1.0 -*/ -WILC_Double WILC_DiffTime(WILC_Time time1, WILC_Time time0); - -/** -* @brief -* @details The gmtime() function converts the time in seconds since - the Epoch pointed to by timer into a broken-down time, - expressed as Coordinated Universal Time (UTC). -* @param[in] const WILC_Time* timer -* @return WILC_tm* -* @note -* @author remil -* @date 11 Nov 2010 -* @version 1.0 -*/ -WILC_tm *WILC_GmTime(const WILC_Time *timer); - - -/** -* @brief -* @details The localtime() function converts the time in seconds since - the Epoch pointed to by timer into a broken-down time, expressed - as a local time. The function corrects for the timezone and any - seasonal time adjustments. Local timezone information is used as - though localtime() calls tzset(). -* @param[in] const WILC_Time* timer -* @return WILC_tm* -* @note -* @author remil -* @date 11 Nov 2010 -* @version 1.0 -*/ -WILC_tm *WILC_LocalTime(const WILC_Time *timer); - - -/** -* @brief -* @details The mktime() function converts the broken-down time, - expressed as local time, in the structure pointed to by timeptr, - into a time since the Epoch value with the same encoding as that - of the values returned by time(). The original values of the tm_wday - and tm_yday components of the structure are ignored, and the original - values of the other components are not restricted to the ranges described - in the entry. -* @param[in] WILC_tm* timer -* @return WILC_Time -* @note -* @author remil -* @date 11 Nov 2010 -* @version 1.0 -*/ -WILC_Time WILC_MkTime(WILC_tm *timer); - - -/** -* @brief -* @details The strftime() function places bytes into the array - pointed to by s as controlled by the string pointed to by format. -* @param[in] WILC_Char* s -* @param[in] WILC_Uint32 maxSize -* @param[in] const WILC_Char* format -* @param[in] const WILC_tm* timptr -* @return WILC_Uint32 -* @note -* @author remil -* @date 11 Nov 2010 -* @version 1.0 -*/ -WILC_Uint32 WILC_StringFormatTime(WILC_Char *s, - WILC_Uint32 maxSize, - const WILC_Char *format, - const WILC_tm *timptr); - - -/** -* @brief The WILC_GetTime() function returns the value of time in seconds since the Epoch. -* @details The tloc argument points to an area where the return value is also stored. - If tloc is a null pointer, no value is stored. -* @param[in] WILC_Time* tloc -* @return WILC_Time -* @note -* @author remil -* @date 11 Nov 2010 -* @version 1.0 -*/ -WILC_Time WILC_GetTime(WILC_Time *tloc); - -#endif - -#ifdef CONFIG_WILC_TIME_UTC_SINCE_1970 - -/*! -* @brief returns the number of seconds elapsed since 1970 (in UTC) -* @param[in] pstrAttrs Optional attributes, NULL for default -* @return number of seconds elapsed since 1970 (in UTC) -* @sa tstrWILC_TimeAttrs -* @author syounan -* @date 2 Sep 2010 -* @version 1.0 -*/ -WILC_Uint32 WILC_TimeUtcSince1970(tstrWILC_TimeAttrs *pstrAttrs); - -#endif - -#ifdef CONFIG_WILC_TIME_CALENDER - -/*! -* @brief gets the current calender time -* @return number of seconds elapsed since 1970 (in UTC) -* @param[out] ptstrCalender calender structure to be filled with time -* @param[in] pstrAttrs Optional attributes, NULL for default -* @sa WILC_ThreadAttrs -* @author syounan -* @date 2 Sep 2010 -* @version 1.0 -*/ -WILC_ErrNo WILC_TimeCalender(tstrWILC_TimeCalender *ptstrCalender, - tstrWILC_TimeAttrs *pstrAttrs); - -#endif - -#endif From 4ec5d4a4f67771d19ab6a97c2591cbfc3aaba7cc Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 1 Jun 2015 21:06:35 +0200 Subject: [PATCH 0769/1163] staging: wilc1000: remove unused string functions The driver provides wrappers for a lot of string operations. Some of them are unused, while others should be replaced with normal kernel functions. This replaces the unused ones for now, and leaves the other ones for a later cleanup. Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_osconfig.h | 2 - drivers/staging/wilc1000/wilc_oswrapper.h | 2 - drivers/staging/wilc1000/wilc_platform.h | 4 - drivers/staging/wilc1000/wilc_strutils.c | 351 ---------------------- drivers/staging/wilc1000/wilc_strutils.h | 282 ----------------- 5 files changed, 641 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_osconfig.h b/drivers/staging/wilc1000/wilc_osconfig.h index f3d3108de876..f18615e09400 100644 --- a/drivers/staging/wilc1000/wilc_osconfig.h +++ b/drivers/staging/wilc1000/wilc_osconfig.h @@ -20,7 +20,6 @@ /* #define CONFIG_WILC_MEMORY_POOLS 1 */ /* #define CONFIG_WILC_MEMORY_DEBUG 1 */ /* #define CONFIG_WILC_ASSERTION_SUPPORT 1 */ -#define CONFIG_WILC_STRING_UTILS 1 #define CONFIG_WILC_MSG_QUEUE_FEATURE /* #define CONFIG_WILC_MSG_QUEUE_IPC_NAME */ /* #define CONFIG_WILC_MSG_QUEUE_TIMEOUT */ @@ -32,5 +31,4 @@ /* #define CONFIG_WILC_SOCKET_FEATURE */ /* #define CONFIG_WILC_MATH_OPERATIONS_FEATURE */ /* #define CONFIG_WILC_EXTENDED_FILE_OPERATIONS */ -/* #define CONFIG_WILC_EXTENDED_STRING_OPERATIONS */ /* #define CONFIG_WILC_EXTENDED_TIME_OPERATIONS */ diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index 728ce7cac85a..c4e97ae03ae0 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -75,9 +75,7 @@ typedef WILC_Uint16 WILC_WideChar; #endif /* String Utilities */ -#ifdef CONFIG_WILC_STRING_UTILS #include "wilc_strutils.h" -#endif /* Message Queue */ #ifdef CONFIG_WILC_MSG_QUEUE_FEATURE diff --git a/drivers/staging/wilc1000/wilc_platform.h b/drivers/staging/wilc1000/wilc_platform.h index 35d9f8a917ce..b20bbb839e5a 100644 --- a/drivers/staging/wilc1000/wilc_platform.h +++ b/drivers/staging/wilc1000/wilc_platform.h @@ -50,8 +50,6 @@ #error This feature is not supported by this OS #endif -/* CONFIG_WILC_STRING_UTILS is implemented */ - /* CONFIG_WILC_MSG_QUEUE_FEATURE is implemented */ /* remove the following block when implementing its feature */ @@ -87,8 +85,6 @@ /* CONFIG_WILC_EXTENDED_FILE_OPERATIONS is implemented */ -/* CONFIG_WILC_EXTENDED_STRING_OPERATIONS is implemented */ - /* CONFIG_WILC_EXTENDED_TIME_OPERATIONS is implemented */ /* remove the following block when implementing its feature */ diff --git a/drivers/staging/wilc1000/wilc_strutils.c b/drivers/staging/wilc1000/wilc_strutils.c index 9e525d56feb8..f452fc57f71d 100644 --- a/drivers/staging/wilc1000/wilc_strutils.c +++ b/drivers/staging/wilc1000/wilc_strutils.c @@ -3,8 +3,6 @@ #include "wilc_oswrapper.h" -#ifdef CONFIG_WILC_STRING_UTILS - /*! * @author syounan @@ -37,17 +35,6 @@ void *WILC_memset(void *pvTarget, WILC_Uint8 u8SetValue, WILC_Uint32 u32Count) return memset(pvTarget, u8SetValue, u32Count); } -/*! - * @author syounan - * @date 18 Aug 2010 - * @version 1.0 - */ -WILC_Char *WILC_strncat(WILC_Char *pcTarget, const WILC_Char *pcSource, - WILC_Uint32 u32Count) -{ - return strncat(pcTarget, pcSource, u32Count); -} - /*! * @author syounan * @date 18 Aug 2010 @@ -59,33 +46,6 @@ WILC_Char *WILC_strncpy(WILC_Char *pcTarget, const WILC_Char *pcSource, return strncpy(pcTarget, pcSource, u32Count); } -/*! - * @author syounan - * @date 18 Aug 2010 - * @version 1.0 - */ -WILC_Sint32 WILC_strcmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2) -{ - WILC_Sint32 s32Result; - - if (pcStr1 == WILC_NULL && pcStr2 == WILC_NULL) { - s32Result = 0; - } else if (pcStr1 == WILC_NULL) { - s32Result = -1; - } else if (pcStr2 == WILC_NULL) { - s32Result = 1; - } else { - s32Result = strcmp(pcStr1, pcStr2); - if (s32Result < 0) { - s32Result = -1; - } else if (s32Result > 0) { - s32Result = 1; - } - } - - return s32Result; -} - WILC_Sint32 WILC_strncmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2, WILC_Uint32 u32Count) { @@ -109,108 +69,6 @@ WILC_Sint32 WILC_strncmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2, return s32Result; } -/* - * @author syounan - * @date 1 Nov 2010 - * @version 2.0 - */ -WILC_Sint32 WILC_strcmp_IgnoreCase(const WILC_Char *pcStr1, const WILC_Char *pcStr2) -{ - WILC_Sint32 s32Result; - - if (pcStr1 == WILC_NULL && pcStr2 == WILC_NULL) { - s32Result = 0; - } else if (pcStr1 == WILC_NULL) { - s32Result = -1; - } else if (pcStr2 == WILC_NULL) { - s32Result = 1; - } else { - WILC_Char cTestedChar1, cTestedChar2; - do { - cTestedChar1 = *pcStr1; - if ((*pcStr1 >= 'a') && (*pcStr1 <= 'z')) { - /* turn a lower case character to an upper case one */ - cTestedChar1 -= 32; - } - - cTestedChar2 = *pcStr2; - if ((*pcStr2 >= 'a') && (*pcStr2 <= 'z')) { - /* turn a lower case character to an upper case one */ - cTestedChar2 -= 32; - } - - pcStr1++; - pcStr2++; - - } while ((cTestedChar1 == cTestedChar2) - && (cTestedChar1 != 0) - && (cTestedChar2 != 0)); - - if (cTestedChar1 > cTestedChar2) { - s32Result = 1; - } else if (cTestedChar1 < cTestedChar2) { - s32Result = -1; - } else { - s32Result = 0; - } - } - - return s32Result; -} - -/*! - * @author aabozaeid - * @date 8 Dec 2010 - * @version 1.0 - */ -WILC_Sint32 WILC_strncmp_IgnoreCase(const WILC_Char *pcStr1, const WILC_Char *pcStr2, - WILC_Uint32 u32Count) -{ - WILC_Sint32 s32Result; - - if (pcStr1 == WILC_NULL && pcStr2 == WILC_NULL) { - s32Result = 0; - } else if (pcStr1 == WILC_NULL) { - s32Result = -1; - } else if (pcStr2 == WILC_NULL) { - s32Result = 1; - } else { - WILC_Char cTestedChar1, cTestedChar2; - do { - cTestedChar1 = *pcStr1; - if ((*pcStr1 >= 'a') && (*pcStr1 <= 'z')) { - /* turn a lower case character to an upper case one */ - cTestedChar1 -= 32; - } - - cTestedChar2 = *pcStr2; - if ((*pcStr2 >= 'a') && (*pcStr2 <= 'z')) { - /* turn a lower case character to an upper case one */ - cTestedChar2 -= 32; - } - - pcStr1++; - pcStr2++; - u32Count--; - - } while ((u32Count > 0) - && (cTestedChar1 == cTestedChar2) - && (cTestedChar1 != 0) - && (cTestedChar2 != 0)); - - if (cTestedChar1 > cTestedChar2) { - s32Result = 1; - } else if (cTestedChar1 < cTestedChar2) { - s32Result = -1; - } else { - s32Result = 0; - } - } - - return s32Result; - -} - /*! * @author syounan * @date 18 Aug 2010 @@ -220,212 +78,3 @@ WILC_Uint32 WILC_strlen(const WILC_Char *pcStr) { return (WILC_Uint32)strlen(pcStr); } - -/*! - * @author bfahmy - * @date 28 Aug 2010 - * @version 1.0 - */ -WILC_Sint32 WILC_strtoint(const WILC_Char *pcStr) -{ - return (WILC_Sint32)(simple_strtol(pcStr, NULL, 10)); -} - -/* - * @author syounan - * @date 1 Nov 2010 - * @version 2.0 - */ -WILC_ErrNo WILC_snprintf(WILC_Char *pcTarget, WILC_Uint32 u32Size, - const WILC_Char *pcFormat, ...) -{ - va_list argptr; - va_start(argptr, pcFormat); - if (vsnprintf(pcTarget, u32Size, pcFormat, argptr) < 0) { - /* if turncation happens windows does not properly terminate strings */ - pcTarget[u32Size - 1] = 0; - } - va_end(argptr); - - /* I find no sane way of detecting errors in windows, so let it all succeed ! */ - return WILC_SUCCESS; -} - -#ifdef CONFIG_WILC_EXTENDED_STRING_OPERATIONS - -/** - * @brief - * @details Searches for the first occurrence of the character c in the first n bytes - * of the string pointed to by the argument str. - * Returns a pointer pointing to the first matching character, - * or null if no match was found. - * @param[in] - * @return - * @note - * @author remil - * @date 3 Nov 2010 - * @version 1.0 - */ -WILC_Char *WILC_memchr(const void *str, WILC_Char c, WILC_Sint32 n) -{ - return (WILC_Char *) memchr(str, c, (size_t)n); -} - -/** - * @brief - * @details Searches for the first occurrence of the character c (an unsigned char) - * in the string pointed to by the argument str. - * The terminating null character is considered to be part of the string. - * Returns a pointer pointing to the first matching character, - * or null if no match was found. - * @param[in] - * @return - * @note - * @author remil - * @date 3 Nov 2010 - * @version 1.0 - */ -WILC_Char *WILC_strchr(const WILC_Char *str, WILC_Char c) -{ - return strchr(str, c); -} - -/** - * @brief - * @details Appends the string pointed to by str2 to the end of the string pointed to by str1. - * The terminating null character of str1 is overwritten. - * Copying stops once the terminating null character of str2 is copied. If overlapping occurs, the result is undefined. - * The argument str1 is returned. - * @param[in] WILC_Char* str1, - * @param[in] WILC_Char* str2, - * @return WILC_Char* - * @note - * @author remil - * @date 3 Nov 2010 - * @version 1.0 - */ -WILC_Char *WILC_strcat(WILC_Char *str1, const WILC_Char *str2) -{ - return strcat(str1, str2); -} - -/** - * @brief - * @details Copy pcSource to pcTarget - * @param[in] WILC_Char* pcTarget - * @param[in] const WILC_Char* pcSource - * @return WILC_Char* - * @note - * @author remil - * @date 3 Nov 2010 - * @version 1.0 - */ -WILC_Char *WILC_strcpy(WILC_Char *pcTarget, const WILC_Char *pcSource) -{ - return strncpy(pcTarget, pcSource, strlen(pcSource)); -} - -/** - * @brief - * @details Finds the first sequence of characters in the string str1 that - * does not contain any character specified in str2. - * Returns the length of this first sequence of characters found that - * do not match with str2. - * @param[in] const WILC_Char *str1 - * @param[in] const WILC_Char *str2 - * @return WILC_Uint32 - * @note - * @author remil - * @date 3 Nov 2010 - * @version 1.0 - */ -WILC_Uint32 WILC_strcspn(const WILC_Char *str1, const WILC_Char *str2) -{ - return (WILC_Uint32)strcspn(str1, str2); -} -#if 0 -/** - * @brief - * @details Searches an internal array for the error number errnum and returns a pointer - * to an error message string. - * Returns a pointer to an error message string. - * @param[in] WILC_Sint32 errnum - * @return WILC_Char* - * @note - * @author remil - * @date 3 Nov 2010 - * @version 1.0 - */ -WILC_Char *WILC_strerror(WILC_Sint32 errnum) -{ - return strerror(errnum); -} -#endif - -/** - * @brief - * @details Finds the first occurrence of the entire string str2 - * (not including the terminating null character) which appears in the string str1. - * Returns a pointer to the first occurrence of str2 in str1. - * If no match was found, then a null pointer is returned. - * If str2 points to a string of zero length, then the argument str1 is returned. - * @param[in] const WILC_Char *str1 - * @param[in] const WILC_Char *str2 - * @return WILC_Char* - * @note - * @author remil - * @date 3 Nov 2010 - * @version 1.0 - */ -WILC_Char *WILC_strstr(const WILC_Char *str1, const WILC_Char *str2) -{ - return strstr(str1, str2); -} -#if 0 -/** - * @brief - * @details Parses the C string str interpreting its content as a floating point - * number and returns its value as a double. - * If endptr is not a null pointer, the function also sets the value pointed - * by endptr to point to the first character after the number. - * @param[in] const WILC_Char* str - * @param[in] WILC_Char** endptr - * @return WILC_Double - * @note - * @author remil - * @date 11 Nov 2010 - * @version 1.0 - */ -WILC_Double WILC_StringToDouble(const WILC_Char *str, WILC_Char **endptr) -{ - return strtod (str, endptr); -} -#endif - -/** - * @brief Parses the C string str interpreting its content as an unsigned integral - * number of the specified base, which is returned as an unsigned long int value. - * @details The function first discards as many whitespace characters as necessary - * until the first non-whitespace character is found. - * Then, starting from this character, takes as many characters as possible - * that are valid following a syntax that depends on the base parameter, - * and interprets them as a numerical value. - * Finally, a pointer to the first character following the integer - * representation in str is stored in the object pointed by endptr. - * @param[in] const WILC_Char *str - * @param[in] WILC_Char **endptr - * @param[in] WILC_Sint32 base - * @return WILC_Uint32 - * @note - * @author remil - * @date 11 Nov 2010 - * @version 1.0 - */ -WILC_Uint32 WILC_StringToUint32(const WILC_Char *str, WILC_Char **endptr, WILC_Sint32 base) -{ - return simple_strtoul(str, endptr, base); -} - -#endif - -#endif diff --git a/drivers/staging/wilc1000/wilc_strutils.h b/drivers/staging/wilc1000/wilc_strutils.h index 3a973a5ec61b..62bd1af9e039 100644 --- a/drivers/staging/wilc1000/wilc_strutils.h +++ b/drivers/staging/wilc1000/wilc_strutils.h @@ -10,10 +10,6 @@ * @version 1.0 */ -#ifndef CONFIG_WILC_STRING_UTILS -#error the feature CONFIG_WILC_STRING_UTILS must be supported to include this file -#endif - /*! * @brief Compares two memory buffers * @param[in] pvArg1 pointer to the first memory location @@ -84,22 +80,6 @@ static WILC_ErrNo WILC_memcpy(void *pvTarget, const void *pvSource, WILC_Uint32 */ void *WILC_memset(void *pvTarget, WILC_Uint8 u8SetValue, WILC_Uint32 u32Count); -/*! - * @brief Concatenates the contents of 2 strings up to a given count - * @param[in] pcTarget the target string, its null character will be overwritten - * and contents of pcSource will be concatentaed to it - * @param[in] pcSource the source string the will be concatentaed - * @param[in] u32Count copying will proceed until a null character in pcSource - * is encountered or u32Count of bytes copied - * @return value of pcTarget - * @note this function repeats the functionality of standard strncat - * @author syounan - * @date 18 Aug 2010 - * @version 1.0 - */ -WILC_Char *WILC_strncat(WILC_Char *pcTarget, const WILC_Char *pcSource, - WILC_Uint32 u32Count); - /*! * @brief copies the contents of source string into the target string * @param[in] pcTarget the target string buffer @@ -115,24 +95,6 @@ WILC_Char *WILC_strncat(WILC_Char *pcTarget, const WILC_Char *pcSource, WILC_Char *WILC_strncpy(WILC_Char *pcTarget, const WILC_Char *pcSource, WILC_Uint32 u32Count); -/*! - * @brief Compares two strings - * @details Compares 2 strings reporting which is bigger, WILC_NULL is considered - * the smallest string, then a zero length string then all other - * strings depending on thier ascii characters order - * @param[in] pcStr1 the first string, WILC_NULL is valid and considered smaller - * than any other non-NULL string (incliding zero lenght strings) - * @param[in] pcStr2 the second string, WILC_NULL is valid and considered smaller - * than any other non-NULL string (incliding zero lenght strings) - * @return 0 if the 2 strings are equal, 1 if pcStr1 is bigger than pcStr2, - * -1 if pcStr1 smaller than pcStr2 - * @note this function repeats the functionality of standard strcmp - * @author syounan - * @date 18 Aug 2010 - * @version 1.0 - */ -WILC_Sint32 WILC_strcmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2); - /*! * @brief Compares two strings up to u32Count characters * @details Compares 2 strings reporting which is bigger, WILC_NULL is considered @@ -154,46 +116,6 @@ WILC_Sint32 WILC_strcmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2); WILC_Sint32 WILC_strncmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2, WILC_Uint32 u32Count); -/*! - * @brief Compares two strings ignoring the case of its latin letters - * @details Compares 2 strings reporting which is bigger, WILC_NULL is considered - * the smallest string, then a zero length string then all other - * strings depending on thier ascii characters order with small case - * converted to uppder case - * @param[in] pcStr1 the first string, WILC_NULL is valid and considered smaller - * than any other non-NULL string (incliding zero lenght strings) - * @param[in] pcStr2 the second string, WILC_NULL is valid and considered smaller - * than any other non-NULL string (incliding zero lenght strings) - * @return 0 if the 2 strings are equal, 1 if pcStr1 is bigger than pcStr2, - * -1 if pcStr1 smaller than pcStr2 - * @author syounan - * @date 1 Nov 2010 - * @version 2.0 - */ -WILC_Sint32 WILC_strcmp_IgnoreCase(const WILC_Char *pcStr1, const WILC_Char *pcStr2); - -/*! - * @brief Compares two strings ignoring the case of its latin letters up to - * u32Count characters - * @details Compares 2 strings reporting which is bigger, WILC_NULL is considered - * the smallest string, then a zero length string then all other - * strings depending on thier ascii characters order with small case - * converted to uppder case - * @param[in] pcStr1 the first string, WILC_NULL is valid and considered smaller - * than any other non-NULL string (incliding zero lenght strings) - * @param[in] pcStr2 the second string, WILC_NULL is valid and considered smaller - * than any other non-NULL string (incliding zero lenght strings) - * @param[in] u32Count copying will proceed until a null character in pcStr1 or - * pcStr2 is encountered or u32Count of bytes copied - * @return 0 if the 2 strings are equal, 1 if pcStr1 is bigger than pcStr2, - * -1 if pcStr1 smaller than pcStr2 - * @author aabozaeid - * @date 7 Dec 2010 - * @version 1.0 - */ -WILC_Sint32 WILC_strncmp_IgnoreCase(const WILC_Char *pcStr1, const WILC_Char *pcStr2, - WILC_Uint32 u32Count); - /*! * @brief gets the length of a string * @param[in] pcStr the string @@ -205,208 +127,4 @@ WILC_Sint32 WILC_strncmp_IgnoreCase(const WILC_Char *pcStr1, const WILC_Char *pc */ WILC_Uint32 WILC_strlen(const WILC_Char *pcStr); -/*! - * @brief convert string to integer - * @param[in] pcStr the string - * @return the value of string - * @note this function repeats the functionality of the libc atoi - * @author bfahmy - * @date 28 Aug 2010 - * @version 1.0 - */ -WILC_Sint32 WILC_strtoint(const WILC_Char *pcStr); - -/*! - * @brief print a formatted string into a buffer - * @param[in] pcTarget the buffer where the resulting string is written - * @param[in] u32Size size of the output beffer including the \0 terminating - * character - * @param[in] pcFormat format of the string - * @return number of character written or would have been written if the - * string were not truncated - * @note this function repeats the functionality of standard snprintf - * @author syounan - * @date 1 Nov 2010 - * @version 2.0 - */ -WILC_Sint32 WILC_snprintf(WILC_Char *pcTarget, WILC_Uint32 u32Size, - const WILC_Char *pcFormat, ...); - - -#ifdef CONFIG_WILC_EXTENDED_STRING_OPERATIONS - - -/** - * @brief - * @details Searches for the first occurrence of the character c in the first n bytes - * of the string pointed to by the argument str. - * Returns a pointer pointing to the first matching character, - * or null if no match was found. - * @param[in] - * @return - * @note - * @author remil - * @date 3 Nov 2010 - * @version 1.0 - */ -WILC_Char *WILC_memchr(const void *str, WILC_Char c, WILC_Sint32 n); - -/** - * @brief - * @details Searches for the first occurrence of the character c (an unsigned char) - * in the string pointed to by the argument str. - * The terminating null character is considered to be part of the string. - * Returns a pointer pointing to the first matching character, - * or null if no match was found. - * @param[in] - * @return - * @note - * @author remil - * @date 3 Nov 2010 - * @version 1.0 - */ -WILC_Char *WILC_strchr(const WILC_Char *str, WILC_Char c); - -/** - * @brief - * @details Appends the string pointed to by str2 to the end of the string pointed to by str1. - * The terminating null character of str1 is overwritten. - * Copying stops once the terminating null character of str2 is copied. If overlapping occurs, the result is undefined. - * The argument str1 is returned. - * @param[in] WILC_Char* str1, - * @param[in] WILC_Char* str2, - * @return WILC_Char* - * @note - * @author remil - * @date 3 Nov 2010 - * @version 1.0 - */ -WILC_Char *WILC_strcat(WILC_Char *str1, const WILC_Char *str2); - - -/** - * @brief - * @details Copy pcSource to pcTarget - * @param[in] WILC_Char* pcTarget - * @param[in] const WILC_Char* pcSource - * @return WILC_Char* - * @note - * @author remil - * @date 3 Nov 2010 - * @version 1.0 - */ -WILC_Char *WILC_strcpy(WILC_Char *pcTarget, const WILC_Char *pcSource); - - - -/** - * @brief - * @details Finds the first sequence of characters in the string str1 that - * does not contain any character specified in str2. - * Returns the length of this first sequence of characters found that - * do not match with str2. - * @param[in] const WILC_Char *str1 - * @param[in] const WILC_Char *str2 - * @return WILC_Uint32 - * @note - * @author remil - * @date 3 Nov 2010 - * @version 1.0 - */ -WILC_Uint32 WILC_strcspn(const WILC_Char *str1, const WILC_Char *str2); - - -/** - * @brief - * @details Searches an internal array for the error number errnum and returns a pointer - * to an error message string. - * Returns a pointer to an error message string. - * @param[in] WILC_Sint32 errnum - * @return WILC_Char* - * @note - * @author remil - * @date 3 Nov 2010 - * @version 1.0 - */ -WILC_Char *WILC_strerror(WILC_Sint32 errnum); - -/** - * @brief - * @details Finds the first occurrence of the entire string str2 - * (not including the terminating null character) which appears in the string str1. - * Returns a pointer to the first occurrence of str2 in str1. - * If no match was found, then a null pointer is returned. - * If str2 points to a string of zero length, then the argument str1 is returned. - * @param[in] const WILC_Char *str1 - * @param[in] const WILC_Char *str2 - * @return WILC_Char* - * @note - * @author remil - * @date 3 Nov 2010 - * @version 1.0 - */ -WILC_Char *WILC_strstr(const WILC_Char *str1, const WILC_Char *str2); - -/** - * @brief - * @details Searches for the first occurrence of the character c (an unsigned char) - * in the string pointed to by the argument str. - * The terminating null character is considered to be part of the string. - * Returns a pointer pointing to the first matching character, - * or null if no match was found. - * @param[in] - * @return - * @note - * @author remil - * @date 3 Nov 2010 - * @version 1.0 - */ -WILC_Char *WILC_strchr(const WILC_Char *str, WILC_Char c); - - -/** - * @brief - * @details Parses the C string str interpreting its content as a floating point - * number and returns its value as a double. - * If endptr is not a null pointer, the function also sets the value pointed - * by endptr to point to the first character after the number. - * @param[in] const WILC_Char* str - * @param[in] WILC_Char** endptr - * @return WILC_Double - * @note - * @author remil - * @date 11 Nov 2010 - * @version 1.0 - */ -WILC_Double WILC_StringToDouble(const WILC_Char *str, - WILC_Char **endptr); - - -/** - * @brief Parses the C string str interpreting its content as an unsigned integral - * number of the specified base, which is returned as an unsigned long int value. - * @details The function first discards as many whitespace characters as necessary - * until the first non-whitespace character is found. - * Then, starting from this character, takes as many characters as possible - * that are valid following a syntax that depends on the base parameter, - * and interprets them as a numerical value. - * Finally, a pointer to the first character following the integer - * representation in str is stored in the object pointed by endptr. - * @param[in] const WILC_Char *str - * @param[in] WILC_Char **endptr - * @param[in] WILC_Sint32 base - * @return WILC_Uint32 - * @note - * @author remil - * @date 11 Nov 2010 - * @version 1.0 - */ -WILC_Uint32 WILC_StringToUint32(const WILC_Char *str, - WILC_Char **endptr, - WILC_Sint32 base); - - - -#endif - #endif From 2ed3dc1d3ca0fcbf94ad087187e3d34e337ecf4d Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 1 Jun 2015 21:06:36 +0200 Subject: [PATCH 0770/1163] staging: wilc1000: simplify msgqueue code The driver contains an abstraction for message queues, with optional unused features, while the driver requires the main feature. This makes the msgqueue code unconditional as it's required but removes the unused parts. A later cleanup should remove the entire msgqueue code and replace it with some normal kernel API. Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_msgqueue.c | 9 ------- drivers/staging/wilc1000/wilc_msgqueue.h | 30 ----------------------- drivers/staging/wilc1000/wilc_osconfig.h | 3 --- drivers/staging/wilc1000/wilc_oswrapper.h | 2 -- drivers/staging/wilc1000/wilc_platform.h | 12 --------- 5 files changed, 56 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c b/drivers/staging/wilc1000/wilc_msgqueue.c index c1d0dabed479..1113092398d1 100644 --- a/drivers/staging/wilc1000/wilc_msgqueue.c +++ b/drivers/staging/wilc1000/wilc_msgqueue.c @@ -1,8 +1,6 @@ #include "wilc_oswrapper.h" #include -#ifdef CONFIG_WILC_MSG_QUEUE_FEATURE - /*! * @author syounan @@ -154,11 +152,6 @@ WILC_ErrNo WILC_MsgQueueRecv(WILC_MsgQueueHandle *pHandle, spin_unlock_irqrestore(&pHandle->strCriticalSection, flags); WILC_SemaphoreFillDefault(&strSemAttrs); - #ifdef CONFIG_WILC_MSG_QUEUE_TIMEOUT - if (pstrAttrs != WILC_NULL) { - strSemAttrs.u32TimeOut = pstrAttrs->u32Timeout; - } - #endif s32RetStatus = WILC_SemaphoreAcquire(&(pHandle->hSem), &strSemAttrs); if (s32RetStatus == WILC_TIMEOUT) { /* timed out, just exit without consumeing the message */ @@ -207,5 +200,3 @@ WILC_ErrNo WILC_MsgQueueRecv(WILC_MsgQueueHandle *pHandle, return s32RetStatus; } - -#endif diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h b/drivers/staging/wilc1000/wilc_msgqueue.h index a48be533aad9..84157368335d 100644 --- a/drivers/staging/wilc1000/wilc_msgqueue.h +++ b/drivers/staging/wilc1000/wilc_msgqueue.h @@ -10,10 +10,6 @@ * @version 1.0 */ -#ifndef CONFIG_WILC_MSG_QUEUE_FEATURE -#error the feature CONFIG_WILC_MSG_QUEUE_FEATURE must be supported to include this file -#endif - /*! * @struct tstrWILC_MsgQueueAttrs * @brief Message Queue API options @@ -22,37 +18,11 @@ * @version 1.0 */ typedef struct { - #ifdef CONFIG_WILC_MSG_QUEUE_IPC_NAME - WILC_Char *pcName; - #endif - - #ifdef CONFIG_WILC_MSG_QUEUE_TIMEOUT - WILC_Uint32 u32Timeout; - #endif - /* a dummy member to avoid compiler errors*/ WILC_Uint8 dummy; } tstrWILC_MsgQueueAttrs; -/*! - * @brief Fills the MsgQueueAttrs with default parameters - * @param[out] pstrAttrs structure to be filled - * @sa WILC_TimerAttrs - * @author syounan - * @date 30 Aug 2010 - * @version 1.0 - */ -static void WILC_MsgQueueFillDefault(tstrWILC_MsgQueueAttrs *pstrAttrs) -{ - #ifdef CONFIG_WILC_MSG_QUEUE_IPC_NAME - pstrAttrs->pcName = WILC_NULL; - #endif - - #ifdef CONFIG_WILC_MSG_QUEUE_TIMEOUT - pstrAttrs->u32Timeout = WILC_OS_INFINITY; - #endif -} /*! * @brief Creates a new Message queue * @details Creates a new Message queue, if the feature diff --git a/drivers/staging/wilc1000/wilc_osconfig.h b/drivers/staging/wilc1000/wilc_osconfig.h index f18615e09400..d89864c7697c 100644 --- a/drivers/staging/wilc1000/wilc_osconfig.h +++ b/drivers/staging/wilc1000/wilc_osconfig.h @@ -20,9 +20,6 @@ /* #define CONFIG_WILC_MEMORY_POOLS 1 */ /* #define CONFIG_WILC_MEMORY_DEBUG 1 */ /* #define CONFIG_WILC_ASSERTION_SUPPORT 1 */ -#define CONFIG_WILC_MSG_QUEUE_FEATURE -/* #define CONFIG_WILC_MSG_QUEUE_IPC_NAME */ -/* #define CONFIG_WILC_MSG_QUEUE_TIMEOUT */ /* #define CONFIG_WILC_FILE_OPERATIONS_FEATURE */ /* #define CONFIG_WILC_FILE_OPERATIONS_STRING_API */ /* #define CONFIG_WILC_FILE_OPERATIONS_PATH_API */ diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index c4e97ae03ae0..8b4c3dced981 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -78,9 +78,7 @@ typedef WILC_Uint16 WILC_WideChar; #include "wilc_strutils.h" /* Message Queue */ -#ifdef CONFIG_WILC_MSG_QUEUE_FEATURE #include "wilc_msgqueue.h" -#endif /* File operations */ #ifdef CONFIG_WILC_FILE_OPERATIONS_FEATURE diff --git a/drivers/staging/wilc1000/wilc_platform.h b/drivers/staging/wilc1000/wilc_platform.h index b20bbb839e5a..2f6484989565 100644 --- a/drivers/staging/wilc1000/wilc_platform.h +++ b/drivers/staging/wilc1000/wilc_platform.h @@ -50,18 +50,6 @@ #error This feature is not supported by this OS #endif -/* CONFIG_WILC_MSG_QUEUE_FEATURE is implemented */ - -/* remove the following block when implementing its feature */ -#ifdef CONFIG_WILC_MSG_QUEUE_IPC_NAME -#error This feature is not supported by this OS -#endif - -/* remove the following block when implementing its feature */ -/*#ifdef CONFIG_WILC_MSG_QUEUE_TIMEOUT - * #error This feature is not supported by this OS - #endif*/ - /* CONFIG_WILC_FILE_OPERATIONS_FEATURE is implemented */ /* CONFIG_WILC_FILE_OPERATIONS_STRING_API is implemented */ From 71b13e5990a32e990e41d3478ec6205b94153556 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 1 Jun 2015 21:06:37 +0200 Subject: [PATCH 0771/1163] staging: wilc1000: remove unused memory handling code The driver contains its own abstraction for memory allocation, most of it unused. This removes the unused parts, but the rest should also be removed later. Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_memory.c | 5 -- drivers/staging/wilc1000/wilc_memory.h | 93 ----------------------- drivers/staging/wilc1000/wilc_osconfig.h | 3 - drivers/staging/wilc1000/wilc_oswrapper.h | 2 - drivers/staging/wilc1000/wilc_platform.h | 13 ---- 5 files changed, 116 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_memory.c b/drivers/staging/wilc1000/wilc_memory.c index cf0976b443b8..fbba38da19bc 100644 --- a/drivers/staging/wilc1000/wilc_memory.c +++ b/drivers/staging/wilc1000/wilc_memory.c @@ -1,9 +1,6 @@ #include "wilc_oswrapper.h" -#ifdef CONFIG_WILC_MEMORY_FEATURE - - /*! * @author syounan * @date 18 Aug 2010 @@ -59,5 +56,3 @@ void WILC_MemoryFree(void *pvBlock, tstrWILC_MemoryAttrs *strAttrs, { kfree(pvBlock); } - -#endif diff --git a/drivers/staging/wilc1000/wilc_memory.h b/drivers/staging/wilc1000/wilc_memory.h index 1e45641af454..012f03cae0c8 100644 --- a/drivers/staging/wilc1000/wilc_memory.h +++ b/drivers/staging/wilc1000/wilc_memory.h @@ -10,10 +10,6 @@ * @version 1.0 */ -#ifndef CONFIG_WILC_MEMORY_FEATURE -#error the feature CONFIG_WILC_MEMORY_FEATURE must be supported to include this file -#endif - /*! * @struct tstrWILC_MemoryAttrs * @brief Memory API options @@ -22,32 +18,8 @@ * @version 1.0 */ typedef struct { - #ifdef CONFIG_WILC_MEMORY_POOLS - /*!< the allocation pool to use for this memory, NULL for system - * allocation. Default is NULL - */ - WILC_MemoryPoolHandle *pAllocationPool; - #endif - - /* a dummy member to avoid compiler errors*/ - WILC_Uint8 dummy; } tstrWILC_MemoryAttrs; -/*! - * @brief Fills the tstrWILC_MemoryAttrs with default parameters - * @param[out] pstrAttrs structure to be filled - * @sa tstrWILC_MemoryAttrs - * @author syounan - * @date 16 Aug 2010 - * @version 1.0 - */ -static void WILC_MemoryFillDefault(tstrWILC_MemoryAttrs *pstrAttrs) -{ - #ifdef CONFIG_WILC_MEMORY_POOLS - pstrAttrs->pAllocationPool = WILC_NULL; - #endif -} - /*! * @brief Allocates a given size of bytes * @param[in] u32Size size of memory in bytes to be allocated @@ -144,69 +116,6 @@ void *WILC_MemoryRealloc(void *pvOldBlock, WILC_Uint32 u32NewSize, void WILC_MemoryFree(void *pvBlock, tstrWILC_MemoryAttrs *strAttrs, WILC_Char *pcFileName, WILC_Uint32 u32LineNo); -/*! - * @brief Creates a new memory pool - * @param[out] pHandle the handle to the new Pool - * @param[in] u32PoolSize The pool size in bytes - * @param[in] strAttrs Optional attributes, NULL for default - * @return Error code indicating sucess/failure - * @sa sttrWILC_MemoryAttrs - * @author syounan - * @date 16 Aug 2010 - * @version 1.0 - */ -WILC_ErrNo WILC_MemoryNewPool(WILC_MemoryPoolHandle *pHandle, WILC_Uint32 u32PoolSize, - tstrWILC_MemoryAttrs *strAttrs); - -/*! - * @brief Deletes a memory pool, freeing all memory allocated from it as well - * @param[in] pHandle the handle to the deleted Pool - * @param[in] strAttrs Optional attributes, NULL for default - * @return Error code indicating sucess/failure - * @sa sttrWILC_MemoryAttrs - * @author syounan - * @date 16 Aug 2010 - * @version 1.0 - */ -WILC_ErrNo WILC_MemoryDelPool(WILC_MemoryPoolHandle *pHandle, tstrWILC_MemoryAttrs *strAttrs); - - -#ifdef CONFIG_WILC_MEMORY_DEBUG - -/*! - * @brief standrad malloc wrapper with custom attributes - */ - #define WILC_MALLOC_EX(__size__, __attrs__) \ - (WILC_MemoryAlloc( \ - (__size__), __attrs__, \ - (WILC_Char *)__WILC_FILE__, (WILC_Uint32)__WILC_LINE__)) - -/*! - * @brief standrad calloc wrapper with custom attributes - */ - #define WILC_CALLOC_EX(__size__, __attrs__) \ - (WILC_MemoryCalloc( \ - (__size__), __attrs__, \ - (WILC_Char *)__WILC_FILE__, (WILC_Uint32)__WILC_LINE__)) - -/*! - * @brief standrad realloc wrapper with custom attributes - */ - #define WILC_REALLOC_EX(__ptr__, __new_size__, __attrs__) \ - (WILC_MemoryRealloc( \ - (__ptr__), (__new_size__), __attrs__, \ - (WILC_Char *)__WILC_FILE__, (WILC_Uint32)__WILC_LINE__)) - -/*! - * @brief standrad free wrapper with custom attributes - */ - #define WILC_FREE_EX(__ptr__, __attrs__) \ - (WILC_MemoryFree( \ - (__ptr__), __attrs__, \ - (WILC_Char *)__WILC_FILE__, (WILC_Uint32)__WILC_LINE__)) - -#else - /*! * @brief standrad malloc wrapper with custom attributes */ @@ -234,8 +143,6 @@ WILC_ErrNo WILC_MemoryDelPool(WILC_MemoryPoolHandle *pHandle, tstrWILC_MemoryAtt (WILC_MemoryFree( \ (__ptr__), __attrs__, WILC_NULL, 0)) -#endif - /*! * @brief Allocates a block (with custom attributes) of given type and number of * elements diff --git a/drivers/staging/wilc1000/wilc_osconfig.h b/drivers/staging/wilc1000/wilc_osconfig.h index d89864c7697c..eec93b351f14 100644 --- a/drivers/staging/wilc1000/wilc_osconfig.h +++ b/drivers/staging/wilc1000/wilc_osconfig.h @@ -16,9 +16,6 @@ #define CONFIG_WILC_SLEEP_HI_RES 1 #define CONFIG_WILC_TIMER_FEATURE 1 /* #define CONFIG_WILC_TIMER_PERIODIC 1 */ -#define CONFIG_WILC_MEMORY_FEATURE 1 -/* #define CONFIG_WILC_MEMORY_POOLS 1 */ -/* #define CONFIG_WILC_MEMORY_DEBUG 1 */ /* #define CONFIG_WILC_ASSERTION_SUPPORT 1 */ /* #define CONFIG_WILC_FILE_OPERATIONS_FEATURE */ /* #define CONFIG_WILC_FILE_OPERATIONS_STRING_API */ diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index 8b4c3dced981..fd5dd3c6316e 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -70,9 +70,7 @@ typedef WILC_Uint16 WILC_WideChar; #endif /* Memory support */ -#ifdef CONFIG_WILC_MEMORY_FEATURE #include "wilc_memory.h" -#endif /* String Utilities */ #include "wilc_strutils.h" diff --git a/drivers/staging/wilc1000/wilc_platform.h b/drivers/staging/wilc1000/wilc_platform.h index 2f6484989565..36e2e707354b 100644 --- a/drivers/staging/wilc1000/wilc_platform.h +++ b/drivers/staging/wilc1000/wilc_platform.h @@ -33,18 +33,6 @@ /* CONFIG_WILC_TIMER_PERIODIC is implemented */ -/* CONFIG_WILC_MEMORY_FEATURE is implemented */ - -/* remove the following block when implementing its feature */ -#ifdef CONFIG_WILC_MEMORY_POOLS -#error This feature is not supported by this OS -#endif - -/* remove the following block when implementing its feature */ -#ifdef CONFIG_WILC_MEMORY_DEBUG -#error This feature is not supported by this OS -#endif - /* remove the following block when implementing its feature */ #ifdef CONFIG_WILC_ASSERTION_SUPPORT #error This feature is not supported by this OS @@ -100,7 +88,6 @@ * OS specific types *******************************************************************/ -typedef void *WILC_MemoryPoolHandle; typedef struct semaphore WILC_SemaphoreHandle; typedef struct timer_list WILC_TimerHandle; From 5f928b956760bc34ff314e9c8962066c230a05b9 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 1 Jun 2015 21:06:38 +0200 Subject: [PATCH 0772/1163] staging: wilc1000: simplify semaphore wrapper The driver has its own API for semaphores. This should be replaced with mutexes and completions, but for the moment we can start by removing the obviously unused parts. Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_osconfig.h | 1 - drivers/staging/wilc1000/wilc_oswrapper.h | 2 -- drivers/staging/wilc1000/wilc_semaphore.c | 14 -------------- drivers/staging/wilc1000/wilc_semaphore.h | 18 +----------------- 4 files changed, 1 insertion(+), 34 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_osconfig.h b/drivers/staging/wilc1000/wilc_osconfig.h index eec93b351f14..d0bf08f89906 100644 --- a/drivers/staging/wilc1000/wilc_osconfig.h +++ b/drivers/staging/wilc1000/wilc_osconfig.h @@ -10,7 +10,6 @@ /* OS features supported */ -#define CONFIG_WILC_SEMAPHORE_FEATURE 1 /* #define CONFIG_WILC_SEMAPHORE_TIMEOUT 1 */ #define CONFIG_WILC_SLEEP_FEATURE 1 #define CONFIG_WILC_SLEEP_HI_RES 1 diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index fd5dd3c6316e..32fe48a6034b 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -55,9 +55,7 @@ typedef WILC_Uint16 WILC_WideChar; #include "wilc_errorsupport.h" /* Semaphore support */ -#ifdef CONFIG_WILC_SEMAPHORE_FEATURE #include "wilc_semaphore.h" -#endif /* Sleep support */ #ifdef CONFIG_WILC_SLEEP_FEATURE diff --git a/drivers/staging/wilc1000/wilc_semaphore.c b/drivers/staging/wilc1000/wilc_semaphore.c index 637107bfb877..f09a88ca6ae4 100644 --- a/drivers/staging/wilc1000/wilc_semaphore.c +++ b/drivers/staging/wilc1000/wilc_semaphore.c @@ -1,7 +1,5 @@ #include "wilc_oswrapper.h" -#ifdef CONFIG_WILC_SEMAPHORE_FEATURE - WILC_ErrNo WILC_SemaphoreCreate(WILC_SemaphoreHandle *pHandle, tstrWILC_SemaphoreAttrs *pstrAttrs) @@ -33,19 +31,9 @@ WILC_ErrNo WILC_SemaphoreAcquire(WILC_SemaphoreHandle *pHandle, { WILC_ErrNo s32RetStatus = WILC_SUCCESS; - #ifndef CONFIG_WILC_SEMAPHORE_TIMEOUT while (down_interruptible(pHandle)) ; - #else - if (pstrAttrs == WILC_NULL) { - down(pHandle); - } else { - - s32RetStatus = down_timeout(pHandle, msecs_to_jiffies(pstrAttrs->u32TimeOut)); - } - #endif - if (s32RetStatus == 0) { return WILC_SUCCESS; } else if (s32RetStatus == -ETIME) { @@ -66,5 +54,3 @@ WILC_ErrNo WILC_SemaphoreRelease(WILC_SemaphoreHandle *pHandle, return WILC_SUCCESS; } - -#endif diff --git a/drivers/staging/wilc1000/wilc_semaphore.h b/drivers/staging/wilc1000/wilc_semaphore.h index 3006f9f20c4d..3c0ecc326fb3 100644 --- a/drivers/staging/wilc1000/wilc_semaphore.h +++ b/drivers/staging/wilc1000/wilc_semaphore.h @@ -10,11 +10,6 @@ * @version 1.0 */ - -#ifndef CONFIG_WILC_SEMAPHORE_FEATURE -#error the feature WILC_OS_FEATURE_SEMAPHORE must be supported to include this file -#endif - /*! * @struct WILC_SemaphoreAttrs * @brief Semaphore API options @@ -28,14 +23,6 @@ typedef struct { */ WILC_Uint32 u32InitCount; - #ifdef CONFIG_WILC_SEMAPHORE_TIMEOUT - /*!< - * Timeout for use with WILC_SemaphoreAcquire, 0 to return immediately and - * WILC_OS_INFINITY to wait forever. default is WILC_OS_INFINITY - */ - WILC_Uint32 u32TimeOut; - #endif - } tstrWILC_SemaphoreAttrs; @@ -47,12 +34,9 @@ typedef struct { * @date 10 Aug 2010 * @version 1.0 */ -static void WILC_SemaphoreFillDefault(tstrWILC_SemaphoreAttrs *pstrAttrs) +static inline void WILC_SemaphoreFillDefault(tstrWILC_SemaphoreAttrs *pstrAttrs) { pstrAttrs->u32InitCount = 1; - #ifdef CONFIG_WILC_SEMAPHORE_TIMEOUT - pstrAttrs->u32TimeOut = WILC_OS_INFINITY; - #endif } /*! * @brief Creates a new Semaphore object From b96ff76a073a4502dd2fb6298d2582823eebc0f7 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 1 Jun 2015 21:06:39 +0200 Subject: [PATCH 0773/1163] staging: wilc1000: clean up sleep wrapper The driver has a simple wrapper around msleep, as well as a more advanced sleep function that is unused. This removes the unused code and the options to turn the feature on or off. A follow-up should rework the code to use msleep directly. Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_osconfig.h | 2 -- drivers/staging/wilc1000/wilc_oswrapper.h | 2 -- drivers/staging/wilc1000/wilc_platform.h | 6 ----- drivers/staging/wilc1000/wilc_sleep.c | 10 -------- drivers/staging/wilc1000/wilc_sleep.h | 30 +---------------------- 5 files changed, 1 insertion(+), 49 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_osconfig.h b/drivers/staging/wilc1000/wilc_osconfig.h index d0bf08f89906..6da42c837928 100644 --- a/drivers/staging/wilc1000/wilc_osconfig.h +++ b/drivers/staging/wilc1000/wilc_osconfig.h @@ -11,8 +11,6 @@ /* OS features supported */ /* #define CONFIG_WILC_SEMAPHORE_TIMEOUT 1 */ -#define CONFIG_WILC_SLEEP_FEATURE 1 -#define CONFIG_WILC_SLEEP_HI_RES 1 #define CONFIG_WILC_TIMER_FEATURE 1 /* #define CONFIG_WILC_TIMER_PERIODIC 1 */ /* #define CONFIG_WILC_ASSERTION_SUPPORT 1 */ diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index 32fe48a6034b..2af32fff84aa 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -58,9 +58,7 @@ typedef WILC_Uint16 WILC_WideChar; #include "wilc_semaphore.h" /* Sleep support */ -#ifdef CONFIG_WILC_SLEEP_FEATURE #include "wilc_sleep.h" -#endif /* Timer support */ #ifdef CONFIG_WILC_TIMER_FEATURE diff --git a/drivers/staging/wilc1000/wilc_platform.h b/drivers/staging/wilc1000/wilc_platform.h index 36e2e707354b..2c66c3f3a2c5 100644 --- a/drivers/staging/wilc1000/wilc_platform.h +++ b/drivers/staging/wilc1000/wilc_platform.h @@ -22,12 +22,6 @@ * #error This feature is not supported by this OS #endif*/ -/* CONFIG_WILC_SLEEP_FEATURE is implemented */ - -/* remove the following block when implementing its feature */ -/* #ifdef CONFIG_WILC_SLEEP_HI_RES */ -/* #error This feature is not supported by this OS */ -/* #endif */ /* CONFIG_WILC_TIMER_FEATURE is implemented */ diff --git a/drivers/staging/wilc1000/wilc_sleep.c b/drivers/staging/wilc1000/wilc_sleep.c index b8f45146956b..98a079f3d6c9 100644 --- a/drivers/staging/wilc1000/wilc_sleep.c +++ b/drivers/staging/wilc1000/wilc_sleep.c @@ -1,8 +1,6 @@ #include "wilc_oswrapper.h" -#ifdef CONFIG_WILC_SLEEP_FEATURE - /* * @author mdaftedar * @date 10 Aug 2010 @@ -18,11 +16,3 @@ void WILC_Sleep(WILC_Uint32 u32TimeMilliSec) } } -#endif - -/* #ifdef CONFIG_WILC_SLEEP_HI_RES */ -void WILC_SleepMicrosec(WILC_Uint32 u32TimeMicoSec) -{ - usleep_range(u32TimeMicoSec, u32TimeMicoSec); -} -/* #endif */ diff --git a/drivers/staging/wilc1000/wilc_sleep.h b/drivers/staging/wilc1000/wilc_sleep.h index d640fb553aca..2865c8e44346 100644 --- a/drivers/staging/wilc1000/wilc_sleep.h +++ b/drivers/staging/wilc1000/wilc_sleep.h @@ -1,19 +1,6 @@ #ifndef __WILC_SLEEP_H__ #define __WILC_SLEEP_H__ -/*! - * @file wilc_sleep.h - * @brief Sleep OS Wrapper functionality - * @author syounan - * @sa wilc_oswrapper.h top level OS wrapper file - * @date 10 Aug 2010 - * @version 1.0 - */ - -#ifndef CONFIG_WILC_SLEEP_FEATURE -#error the feature WILC_OS_FEATURE_SLEEP must be supported to include this file -#endif - /*! * @brief forces the current thread to sleep until the given time has elapsed * @param[in] u32TimeMilliSec Time to sleep in Milli seconds @@ -24,22 +11,7 @@ * @note This function offers a relatively innacurate and low resolution * sleep, for accurate high resolution sleep use u32TimeMicoSec */ +/* TODO: remove and open-code in callers */ void WILC_Sleep(WILC_Uint32 u32TimeMilliSec); -#ifdef CONFIG_WILC_SLEEP_HI_RES -/*! - * @brief forces the current thread to sleep until the given time has elapsed - * @param[in] u32TimeMicoSec Time to sleep in Micro seconds - * @sa WILC_Sleep - * @author syounan - * @date 10 Aug 2010 - * @version 1.0 - * @note This function offers an acurare high resolution sleep, depends on - * the feature WILC_OS_FEATURE_SLEEP_HI_RES and may not be supported - * on all Operating Systems - */ -void WILC_SleepMicrosec(WILC_Uint32 u32TimeMicoSec); -#endif - - #endif From 042f19c9359400f6d31e568416aa484a94513346 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 1 Jun 2015 21:06:40 +0200 Subject: [PATCH 0774/1163] staging: wilc1000: clean up timer feature The driver has a simple wrapper around timer_list, and an optional but unused feature to make the timer periodic. This removes support for the periodic timer and simplifies the code around timers. A follow-up should replace the remaining wrapper with open-coded timers. Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_osconfig.h | 2 -- drivers/staging/wilc1000/wilc_oswrapper.h | 2 -- drivers/staging/wilc1000/wilc_platform.h | 4 ---- drivers/staging/wilc1000/wilc_timer.c | 6 ----- drivers/staging/wilc1000/wilc_timer.h | 27 ----------------------- 5 files changed, 41 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_osconfig.h b/drivers/staging/wilc1000/wilc_osconfig.h index 6da42c837928..639160d1fa4e 100644 --- a/drivers/staging/wilc1000/wilc_osconfig.h +++ b/drivers/staging/wilc1000/wilc_osconfig.h @@ -11,8 +11,6 @@ /* OS features supported */ /* #define CONFIG_WILC_SEMAPHORE_TIMEOUT 1 */ -#define CONFIG_WILC_TIMER_FEATURE 1 -/* #define CONFIG_WILC_TIMER_PERIODIC 1 */ /* #define CONFIG_WILC_ASSERTION_SUPPORT 1 */ /* #define CONFIG_WILC_FILE_OPERATIONS_FEATURE */ /* #define CONFIG_WILC_FILE_OPERATIONS_STRING_API */ diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index 2af32fff84aa..be6393cba8c2 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -61,9 +61,7 @@ typedef WILC_Uint16 WILC_WideChar; #include "wilc_sleep.h" /* Timer support */ -#ifdef CONFIG_WILC_TIMER_FEATURE #include "wilc_timer.h" -#endif /* Memory support */ #include "wilc_memory.h" diff --git a/drivers/staging/wilc1000/wilc_platform.h b/drivers/staging/wilc1000/wilc_platform.h index 2c66c3f3a2c5..d3f8fc6f2971 100644 --- a/drivers/staging/wilc1000/wilc_platform.h +++ b/drivers/staging/wilc1000/wilc_platform.h @@ -23,10 +23,6 @@ #endif*/ -/* CONFIG_WILC_TIMER_FEATURE is implemented */ - -/* CONFIG_WILC_TIMER_PERIODIC is implemented */ - /* remove the following block when implementing its feature */ #ifdef CONFIG_WILC_ASSERTION_SUPPORT #error This feature is not supported by this OS diff --git a/drivers/staging/wilc1000/wilc_timer.c b/drivers/staging/wilc1000/wilc_timer.c index 477986dcff0a..7d2e6f19c00b 100644 --- a/drivers/staging/wilc1000/wilc_timer.c +++ b/drivers/staging/wilc1000/wilc_timer.c @@ -1,10 +1,6 @@ #include "wilc_oswrapper.h" -#ifdef CONFIG_WILC_TIMER_FEATURE - - - WILC_ErrNo WILC_TimerCreate(WILC_TimerHandle *pHandle, tpfWILC_TimerFunction pfCallback, tstrWILC_TimerAttrs *pstrAttrs) { @@ -47,5 +43,3 @@ WILC_ErrNo WILC_TimerStop(WILC_TimerHandle *pHandle, return s32RetStatus; } - -#endif diff --git a/drivers/staging/wilc1000/wilc_timer.h b/drivers/staging/wilc1000/wilc_timer.h index 1080ce24a045..41c6784ab8e1 100644 --- a/drivers/staging/wilc1000/wilc_timer.h +++ b/drivers/staging/wilc1000/wilc_timer.h @@ -10,10 +10,6 @@ * @version 1.0 */ -#ifndef CONFIG_WILC_TIMER_FEATURE -#error the feature CONFIG_WILC_TIMER_FEATURE must be supported to include this file -#endif - typedef void (*tpfWILC_TimerFunction)(void *); /*! @@ -24,33 +20,10 @@ typedef void (*tpfWILC_TimerFunction)(void *); * @version 1.0 */ typedef struct { - /*!< if set to WILC_TRUE the callback function will be called - * periodically. */ - #ifdef CONFIG_WILC_TIMER_PERIODIC - WILC_Bool bPeriodicTimer; - #endif - /* a dummy member to avoid compiler errors*/ WILC_Uint8 dummy; } tstrWILC_TimerAttrs; -/*! - * @brief Fills the WILC_TimerAttrs with default parameters - * @param[out] pstrAttrs structure to be filled - * @sa WILC_TimerAttrs - * @author syounan - * @date 16 Aug 2010 - * @version 1.0 - */ - -static void WILC_TimerFillDefault(tstrWILC_TimerAttrs *pstrAttrs) -{ - #ifdef CONFIG_WILC_TIMER_PERIODIC - pstrAttrs->bPeriodicTimer = WILC_FALSE; - #endif -} - - /*! * @brief Creates a new timer * @details Timers are a useful utility to execute some callback function From d074f293907c3b53f266a337e1bdf7506a4991c0 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 1 Jun 2015 21:06:41 +0200 Subject: [PATCH 0775/1163] staging: wilc1000: remove unused OS abstraction features All the remaining features from the OS abstraction layer are not used at all in the driver, so we can just remove the remaining references to them. Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_errorsupport.h | 17 --- drivers/staging/wilc1000/wilc_event.h | 123 ------------------- drivers/staging/wilc1000/wilc_osconfig.h | 14 --- drivers/staging/wilc1000/wilc_oswrapper.h | 22 ---- drivers/staging/wilc1000/wilc_platform.h | 62 ---------- 5 files changed, 238 deletions(-) delete mode 100644 drivers/staging/wilc1000/wilc_event.h diff --git a/drivers/staging/wilc1000/wilc_errorsupport.h b/drivers/staging/wilc1000/wilc_errorsupport.h index 6405ef8ad431..4da657d17020 100644 --- a/drivers/staging/wilc1000/wilc_errorsupport.h +++ b/drivers/staging/wilc1000/wilc_errorsupport.h @@ -64,21 +64,4 @@ typedef WILC_Sint32 WILC_ErrNo; ERRORHANDLER: \ if (WILC_IS_ERR(__status__)) \ -#ifdef CONFIG_WILC_ASSERTION_SUPPORT - -/** - * @brief prints a diagnostic message and aborts the program - * @param[in] pcExpression The expression that triggered the assertion - * @param[in] pcFileName The name of the current source file. - * @param[in] u32LineNumber The line number in the current source file. - * @warning DO NOT CALL DIRECTLY. USE EQUIVALENT MACRO FUNCTION INSTEAD. - */ -void WILC_assert_INTERNAL(WILC_Char *pcExpression, WILC_Char *pcFileName, WILC_Uint32 u32LineNumber); - -#define WILC_assert(__expression__) (void)(!!(__expression__) || (WILC_assert_INTERNAL((# __expression__), __WILC_FILE__, __WILC_LINE__), 0)) - -#else -#define WILC_assert(__expression__) ((void)0) -#endif - #endif diff --git a/drivers/staging/wilc1000/wilc_event.h b/drivers/staging/wilc1000/wilc_event.h deleted file mode 100644 index 94e0f7c0bed5..000000000000 --- a/drivers/staging/wilc1000/wilc_event.h +++ /dev/null @@ -1,123 +0,0 @@ -#ifndef __WILC_EVENT_H__ -#define __WILC_EVENT_H__ - -/*! - * @file wilc_event.h - * @brief Event OS wrapper functionality - * @author syounan - * @sa wilc_oswrapper.h top level OS wrapper file - * @date 10 Oct 2010 - * @version 1.0 - */ - -#ifndef CONFIG_WILC_EVENT_FEATURE -#error the feature CONFIG_WILC_EVENT_FEATURE must be supported to include this file -#endif - - -/*! - * @struct tstrWILC_TimerAttrs - * @brief Timer API options - * @author syounan - * @date 10 Oct 2010 - * @version 1.0 - */ -typedef struct { - /* a dummy member to avoid compiler errors*/ - WILC_Uint8 dummy; - - #ifdef CONFIG_WILC_EVENT_TIMEOUT - /*!< - * Timeout for use with WILC_EventWait, 0 to return immediately and - * WILC_OS_INFINITY to wait forever. default is WILC_OS_INFINITY - */ - WILC_Uint32 u32TimeOut; - #endif - -} tstrWILC_EventAttrs; - -/*! - * @brief Fills the WILC_TimerAttrs with default parameters - * @param[out] pstrAttrs structure to be filled - * @sa WILC_TimerAttrs - * @author syounan - * @date 10 Oct 2010 - * @version 1.0 - */ -static void WILC_EventFillDefault(tstrWILC_EventAttrs *pstrAttrs) -{ - #ifdef CONFIG_WILC_EVENT_TIMEOUT - pstrAttrs->u32TimeOut = WILC_OS_INFINITY; - #endif -} - -/*! - * @brief Creates a new Event - * @details the Event is an object that allows a thread to wait until an external - * event occuers, Event objects have 2 states, either TRIGGERED or - * UNTRIGGERED - * @param[out] pHandle handle to the newly created event object - * @param[in] pstrAttrs Optional attributes, NULL for default - * @return Error code indicating sucess/failure - * @sa tstrWILC_EventAttrs - * @author syounan - * @date 10 Oct 2010 - * @version 1.0 - */ -WILC_ErrNo WILC_EventCreate(WILC_EventHandle *pHandle, tstrWILC_EventAttrs *pstrAttrs); - - -/*! - * @brief Destroys a given event - * @details This will destroy a given event freeing any resources used by it - * if there are any thread blocked by the WILC_EventWait call the the - * behaviour is undefined - * @param[in] pHandle handle to the event object - * @param[in] pstrAttrs Optional attributes, NULL for default - * @return Error code indicating sucess/failure - * @sa tstrWILC_EventAttrs - * @author syounan - * @date 10 Oct 2010 - * @version 1.0 - */ -WILC_ErrNo WILC_EventDestroy(WILC_EventHandle *pHandle, - tstrWILC_EventAttrs *pstrAttrs); - -/*! - * @brief Triggers a given event - * @details This function will set the given event into the TRIGGERED state, - * if the event is already in TRIGGERED, this function will have no - * effect - * @param[in] pHandle handle to the event object - * @param[in] pstrAttrs Optional attributes, NULL for default - * @return Error code indicating sucess/failure - * @sa tstrWILC_EventAttrs - * @author syounan - * @date 10 Oct 2010 - * @version 1.0 - */ -WILC_ErrNo WILC_EventTrigger(WILC_EventHandle *pHandle, - tstrWILC_EventAttrs *pstrAttrs); - - -/*! - * @brief waits until a given event is triggered - * @details This function will block the calling thread until the event becomes - * in the TRIGGERED state. the call will retun the event into the - * UNTRIGGERED state upon completion - * if multible threads are waiting on the same event at the same time, - * behaviour is undefined - * @param[in] pHandle handle to the event object - * @param[in] pstrAttrs Optional attributes, NULL for default - * @return Error code indicating sucess/failure - * @sa tstrWILC_EventAttrs - * @author syounan - * @date 10 Oct 2010 - * @version 1.0 - */ -WILC_ErrNo WILC_EventWait(WILC_EventHandle *pHandle, - tstrWILC_EventAttrs *pstrAttrs); - - - -#endif \ No newline at end of file diff --git a/drivers/staging/wilc1000/wilc_osconfig.h b/drivers/staging/wilc1000/wilc_osconfig.h index 639160d1fa4e..f9c25140393e 100644 --- a/drivers/staging/wilc1000/wilc_osconfig.h +++ b/drivers/staging/wilc1000/wilc_osconfig.h @@ -7,17 +7,3 @@ #define WILC_LOGS_ALL 5 #define WILC_LOG_VERBOSITY_LEVEL WILC_LOGS_ALL - -/* OS features supported */ - -/* #define CONFIG_WILC_SEMAPHORE_TIMEOUT 1 */ -/* #define CONFIG_WILC_ASSERTION_SUPPORT 1 */ -/* #define CONFIG_WILC_FILE_OPERATIONS_FEATURE */ -/* #define CONFIG_WILC_FILE_OPERATIONS_STRING_API */ -/* #define CONFIG_WILC_FILE_OPERATIONS_PATH_API */ -/* #define CONFIG_WILC_EVENT_FEATURE */ -/* #define CONFIG_WILC_EVENT_TIMEOUT */ -/* #define CONFIG_WILC_SOCKET_FEATURE */ -/* #define CONFIG_WILC_MATH_OPERATIONS_FEATURE */ -/* #define CONFIG_WILC_EXTENDED_FILE_OPERATIONS */ -/* #define CONFIG_WILC_EXTENDED_TIME_OPERATIONS */ diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index be6393cba8c2..1999970635aa 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -72,26 +72,4 @@ typedef WILC_Uint16 WILC_WideChar; /* Message Queue */ #include "wilc_msgqueue.h" -/* File operations */ -#ifdef CONFIG_WILC_FILE_OPERATIONS_FEATURE -#include "wilc_fileops.h" -#endif - -/* Event support */ -#ifdef CONFIG_WILC_EVENT_FEATURE -#include "wilc_event.h" -#endif - -/* Socket operations */ -#ifdef CONFIG_WILC_SOCKET_FEATURE -#include "wilc_socket.h" -#endif - -/* Math operations */ -#ifdef CONFIG_WILC_MATH_OPERATIONS_FEATURE -#include "wilc_math.h" -#endif - - - #endif diff --git a/drivers/staging/wilc1000/wilc_platform.h b/drivers/staging/wilc1000/wilc_platform.h index d3f8fc6f2971..2e0f41735df0 100644 --- a/drivers/staging/wilc1000/wilc_platform.h +++ b/drivers/staging/wilc1000/wilc_platform.h @@ -1,68 +1,6 @@ #ifndef __WILC_platfrom_H__ #define __WILC_platfrom_H__ -/*! - * @file wilc_platform.h - * @brief platform specific file for Linux port - * @author syounan - * @sa wilc_oswrapper.h top level OS wrapper file - * @date 15 Dec 2010 - * @version 1.0 - */ - - -/****************************************************************** - * Feature support checks - *******************************************************************/ - -/* CONFIG_WILC_SEMAPHORE_FEATURE is implemented */ - -/* remove the following block when implementing its feature - * #ifdef CONFIG_WILC_SEMAPHORE_TIMEOUT - * #error This feature is not supported by this OS - #endif*/ - - -/* remove the following block when implementing its feature */ -#ifdef CONFIG_WILC_ASSERTION_SUPPORT -#error This feature is not supported by this OS -#endif - -/* CONFIG_WILC_FILE_OPERATIONS_FEATURE is implemented */ - -/* CONFIG_WILC_FILE_OPERATIONS_STRING_API is implemented */ - -/* remove the following block when implementing its feature */ -#ifdef CONFIG_WILC_FILE_OPERATIONS_PATH_API -#error This feature is not supported by this OS -#endif - -/* remove the following block when implementing its feature */ -#ifdef CONFIG_WILC_EVENT_FEATURE -#error This feature is not supported by this OS -#endif - -/* remove the following block when implementing its feature */ -#ifdef CONFIG_WILC_EVENT_TIMEOUT -#error This feature is not supported by this OS -#endif - -/* CONFIG_WILC_MATH_OPERATIONS_FEATURE is implemented */ - -/* CONFIG_WILC_EXTENDED_FILE_OPERATIONS is implemented */ - -/* CONFIG_WILC_EXTENDED_TIME_OPERATIONS is implemented */ - -/* remove the following block when implementing its feature */ -#ifdef CONFIG_WILC_SOCKET_FEATURE -#error This feature is not supported by this OS -#endif - -/****************************************************************** - * OS specific includes - *******************************************************************/ -#define _XOPEN_SOURCE 600 - #include #include #include From e14af67d8fb20128927b65d824b389698dd5c663 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 1 Jun 2015 21:06:42 +0200 Subject: [PATCH 0776/1163] staging: wilc1000: remove EXPORT_SYMTAB The EXPORT_SYMTAB symbol has not been used in Linux for a very long time, the driver does not need to set it. Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wilc1000/Makefile b/drivers/staging/wilc1000/Makefile index 44551ee3c697..d8d8395cc4a6 100644 --- a/drivers/staging/wilc1000/Makefile +++ b/drivers/staging/wilc1000/Makefile @@ -10,7 +10,7 @@ ccflags-y += -DSTA_FIRMWARE=\"atmel/wilc1000_fw.bin\" \ -DAP_FIRMWARE=\"atmel/wilc1000_ap_fw.bin\" \ -DP2P_CONCURRENCY_FIRMWARE=\"atmel/wilc1000_p2p_fw.bin\" -ccflags-y += -I$(src)/ -DEXPORT_SYMTAB -D__CHECK_ENDIAN__ -DWILC_ASIC_A0 \ +ccflags-y += -I$(src)/ -D__CHECK_ENDIAN__ -DWILC_ASIC_A0 \ -DPLL_WORKAROUND -DCONNECT_DIRECT -DAGING_ALG \ -DWILC_PARSE_SCAN_IN_HOST -DDISABLE_PWRSAVE_AND_SCAN_DURING_IP \ -Wno-unused-function -DUSE_WIRELESS -DWILC_DEBUGFS From 83383ea33c63a622619acf2b979037ee775500dd Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 1 Jun 2015 21:06:43 +0200 Subject: [PATCH 0777/1163] staging: wilc1000: remove semaphore wrapper The various semaphore functions all directly translate into sema_init(), down() and up(), so we can just remove the API. This is a mostly automated conversion using simple sed scripts, plus some manual changes to account for down() returning no error. As a positive side-effect, down() no longer hangs after receiving a signal, as the original code did by looping around down_interruptible. The semaphores still need to be turned into mutexes as a follow-up step. Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/Makefile | 2 +- drivers/staging/wilc1000/coreconfigurator.c | 29 +-- drivers/staging/wilc1000/fifo_buffer.c | 108 ++++++----- drivers/staging/wilc1000/fifo_buffer.h | 2 +- drivers/staging/wilc1000/host_interface.c | 167 +++++++----------- drivers/staging/wilc1000/host_interface.h | 14 +- drivers/staging/wilc1000/wilc_msgqueue.c | 32 ++-- drivers/staging/wilc1000/wilc_oswrapper.h | 3 - drivers/staging/wilc1000/wilc_platform.h | 4 +- drivers/staging/wilc1000/wilc_semaphore.c | 56 ------ drivers/staging/wilc1000/wilc_semaphore.h | 99 ----------- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 35 ++-- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 4 +- 13 files changed, 158 insertions(+), 397 deletions(-) delete mode 100644 drivers/staging/wilc1000/wilc_semaphore.c delete mode 100644 drivers/staging/wilc1000/wilc_semaphore.h diff --git a/drivers/staging/wilc1000/Makefile b/drivers/staging/wilc1000/Makefile index d8d8395cc4a6..a78c4d529a58 100644 --- a/drivers/staging/wilc1000/Makefile +++ b/drivers/staging/wilc1000/Makefile @@ -26,7 +26,7 @@ ccflags-$(CONFIG_WILC1000_DYNAMICALLY_ALLOCATE_MEMROY) += -DWILC_NORMAL_ALLOC wilc1000-objs := wilc_wfi_netdevice.o wilc_wfi_cfgoperations.o linux_wlan.o linux_mon.o \ - wilc_memory.o wilc_msgqueue.o wilc_semaphore.o wilc_sleep.o wilc_strutils.o \ + wilc_memory.o wilc_msgqueue.o wilc_sleep.o wilc_strutils.o \ wilc_timer.o coreconfigurator.o host_interface.o \ fifo_buffer.o wilc_sdio.o wilc_spi.o wilc_wlan_cfg.o wilc_debugfs.o diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index d5a076ed2426..bf444825711f 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -164,8 +164,8 @@ extern void host_int_ScanCompleteReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32 /*****************************************************************************/ /* Global Variables */ /*****************************************************************************/ -static WILC_SemaphoreHandle SemHandleSendPkt; -static WILC_SemaphoreHandle SemHandlePktResp; +static struct semaphore SemHandleSendPkt; +static struct semaphore SemHandlePktResp; static WILC_Sint8 *gps8ConfigPacket; @@ -672,18 +672,10 @@ INLINE WILC_Uint16 get_asoc_id(WILC_Uint8 *data) WILC_Sint32 CoreConfiguratorInit(void) { WILC_Sint32 s32Error = WILC_SUCCESS; - tstrWILC_SemaphoreAttrs strSemSendPktAttrs; - tstrWILC_SemaphoreAttrs strSemPktRespAttrs; - PRINT_D(CORECONFIG_DBG, "CoreConfiguratorInit() \n"); - WILC_SemaphoreFillDefault(&strSemSendPktAttrs); - strSemSendPktAttrs.u32InitCount = 1; - WILC_SemaphoreCreate(&SemHandleSendPkt, &strSemSendPktAttrs); - - WILC_SemaphoreFillDefault(&strSemPktRespAttrs); - strSemPktRespAttrs.u32InitCount = 0; - WILC_SemaphoreCreate(&SemHandlePktResp, &strSemPktRespAttrs); + sema_init(&SemHandleSendPkt, 1); + sema_init(&SemHandlePktResp, 0); gps8ConfigPacket = (WILC_Sint8 *)WILC_MALLOC(MAX_PACKET_BUFF_SIZE); if (gps8ConfigPacket == NULL) { @@ -1931,7 +1923,7 @@ WILC_Sint32 ConfigWaitResponse(WILC_Char *pcRespBuffer, WILC_Sint32 s32MaxRespBu if (gstrConfigPktInfo.bRespRequired == WILC_TRUE) { - WILC_SemaphoreAcquire(&SemHandlePktResp, WILC_NULL); + down(&SemHandlePktResp); *ps32BytesRead = gstrConfigPktInfo.s32BytesRead; } @@ -1964,7 +1956,7 @@ WILC_Sint32 SendConfigPkt(WILC_Uint8 u8Mode, tstrWID *pstrWIDs, WILC_Sint32 s32ConfigPacketLen = 0; WILC_Sint32 s32RcvdRespLen = 0; - WILC_SemaphoreAcquire(&SemHandleSendPkt, WILC_NULL); + down(&SemHandleSendPkt); /*set the packet mode*/ g_oper_mode = u8Mode; @@ -2019,7 +2011,7 @@ WILC_Sint32 SendConfigPkt(WILC_Uint8 u8Mode, tstrWID *pstrWIDs, End_ConfigPkt: - WILC_SemaphoreRelease(&SemHandleSendPkt, WILC_NULL); + up(&SemHandleSendPkt); return s32Error; } @@ -2038,7 +2030,7 @@ WILC_Sint32 ConfigProvideResponse(WILC_Char *pcRespBuffer, WILC_Sint32 s32RespLe PRINT_ER("BusProvideResponse() Response greater than the prepared Buffer Size \n"); } - WILC_SemaphoreRelease(&SemHandlePktResp, WILC_NULL); + up(&SemHandlePktResp); } return s32Error; @@ -2107,11 +2099,6 @@ WILC_Sint32 CoreConfiguratorDeInit(void) PRINT_D(CORECONFIG_DBG, "CoreConfiguratorDeInit() \n"); - - WILC_SemaphoreDestroy(&SemHandleSendPkt, WILC_NULL); - WILC_SemaphoreDestroy(&SemHandlePktResp, WILC_NULL); - - if (gps8ConfigPacket != NULL) { WILC_FREE(gps8ConfigPacket); diff --git a/drivers/staging/wilc1000/fifo_buffer.c b/drivers/staging/wilc1000/fifo_buffer.c index 733d81f2eeca..e23d11130728 100644 --- a/drivers/staging/wilc1000/fifo_buffer.c +++ b/drivers/staging/wilc1000/fifo_buffer.c @@ -13,13 +13,10 @@ WILC_Uint32 FIFO_InitBuffer(tHANDLE *hBuffer, WILC_Uint32 u32BufferLength) WILC_memset (pstrFifoHandler, 0, sizeof (tstrFifoHandler)); pstrFifoHandler->pu8Buffer = WILC_MALLOC (u32BufferLength); if (pstrFifoHandler->pu8Buffer) { - tstrWILC_SemaphoreAttrs strSemBufferAttrs; pstrFifoHandler->u32BufferLength = u32BufferLength; WILC_memset (pstrFifoHandler->pu8Buffer, 0, u32BufferLength); /* create semaphore */ - WILC_SemaphoreFillDefault (&strSemBufferAttrs); - strSemBufferAttrs.u32InitCount = 1; - WILC_SemaphoreCreate(&pstrFifoHandler->SemBuffer, &strSemBufferAttrs); + sema_init(&pstrFifoHandler->SemBuffer, 1); *hBuffer = pstrFifoHandler; } else { *hBuffer = NULL; @@ -41,8 +38,6 @@ WILC_Uint32 FIFO_DeInit(tHANDLE hFifo) u32Error = 1; } - WILC_SemaphoreDestroy (&pstrFifoHandler->SemBuffer, WILC_NULL); - WILC_FREE (pstrFifoHandler); } else { u32Error = 1; @@ -56,34 +51,32 @@ WILC_Uint32 FIFO_ReadBytes(tHANDLE hFifo, WILC_Uint8 *pu8Buffer, WILC_Uint32 u32 tstrFifoHandler *pstrFifoHandler = (tstrFifoHandler *) hFifo; if (pstrFifoHandler && pu32BytesRead) { if (pstrFifoHandler->u32TotalBytes) { - if (WILC_SemaphoreAcquire(&pstrFifoHandler->SemBuffer, WILC_NULL) == WILC_SUCCESS) { - if (u32BytesToRead > pstrFifoHandler->u32TotalBytes) { - *pu32BytesRead = pstrFifoHandler->u32TotalBytes; - } else { - *pu32BytesRead = u32BytesToRead; - } - if ((pstrFifoHandler->u32ReadOffset + u32BytesToRead) <= pstrFifoHandler->u32BufferLength) { - WILC_memcpy(pu8Buffer, pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32ReadOffset, - *pu32BytesRead); - /* update read offset and total bytes */ - pstrFifoHandler->u32ReadOffset += u32BytesToRead; - pstrFifoHandler->u32TotalBytes -= u32BytesToRead; + down(&pstrFifoHandler->SemBuffer); - } else { - WILC_Uint32 u32FirstPart = - pstrFifoHandler->u32BufferLength - pstrFifoHandler->u32ReadOffset; - WILC_memcpy(pu8Buffer, pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32ReadOffset, - u32FirstPart); - WILC_memcpy(pu8Buffer + u32FirstPart, pstrFifoHandler->pu8Buffer, - u32BytesToRead - u32FirstPart); - /* update read offset and total bytes */ - pstrFifoHandler->u32ReadOffset = u32BytesToRead - u32FirstPart; - pstrFifoHandler->u32TotalBytes -= u32BytesToRead; - } - WILC_SemaphoreRelease (&pstrFifoHandler->SemBuffer, WILC_NULL); + if (u32BytesToRead > pstrFifoHandler->u32TotalBytes) { + *pu32BytesRead = pstrFifoHandler->u32TotalBytes; } else { - u32Error = 1; + *pu32BytesRead = u32BytesToRead; } + if ((pstrFifoHandler->u32ReadOffset + u32BytesToRead) <= pstrFifoHandler->u32BufferLength) { + WILC_memcpy(pu8Buffer, pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32ReadOffset, + *pu32BytesRead); + /* update read offset and total bytes */ + pstrFifoHandler->u32ReadOffset += u32BytesToRead; + pstrFifoHandler->u32TotalBytes -= u32BytesToRead; + + } else { + WILC_Uint32 u32FirstPart = + pstrFifoHandler->u32BufferLength - pstrFifoHandler->u32ReadOffset; + WILC_memcpy(pu8Buffer, pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32ReadOffset, + u32FirstPart); + WILC_memcpy(pu8Buffer + u32FirstPart, pstrFifoHandler->pu8Buffer, + u32BytesToRead - u32FirstPart); + /* update read offset and total bytes */ + pstrFifoHandler->u32ReadOffset = u32BytesToRead - u32FirstPart; + pstrFifoHandler->u32TotalBytes -= u32BytesToRead; + } + up(&pstrFifoHandler->SemBuffer); } else { u32Error = 1; } @@ -101,34 +94,33 @@ WILC_Uint32 FIFO_WriteBytes(tHANDLE hFifo, WILC_Uint8 *pu8Buffer, WILC_Uint32 u3 if (u32BytesToWrite < pstrFifoHandler->u32BufferLength) { if ((pstrFifoHandler->u32TotalBytes + u32BytesToWrite) <= pstrFifoHandler->u32BufferLength || bForceOverWrite) { - if (WILC_SemaphoreAcquire(&pstrFifoHandler->SemBuffer, WILC_NULL) == WILC_SUCCESS) { - if ((pstrFifoHandler->u32WriteOffset + u32BytesToWrite) <= pstrFifoHandler->u32BufferLength) { - WILC_memcpy(pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32WriteOffset, pu8Buffer, - u32BytesToWrite); - /* update read offset and total bytes */ - pstrFifoHandler->u32WriteOffset += u32BytesToWrite; - pstrFifoHandler->u32TotalBytes += u32BytesToWrite; + down(&pstrFifoHandler->SemBuffer); + if ((pstrFifoHandler->u32WriteOffset + u32BytesToWrite) <= pstrFifoHandler->u32BufferLength) { + WILC_memcpy(pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32WriteOffset, pu8Buffer, + u32BytesToWrite); + /* update read offset and total bytes */ + pstrFifoHandler->u32WriteOffset += u32BytesToWrite; + pstrFifoHandler->u32TotalBytes += u32BytesToWrite; - } else { - WILC_Uint32 u32FirstPart = - pstrFifoHandler->u32BufferLength - pstrFifoHandler->u32WriteOffset; - WILC_memcpy(pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32WriteOffset, pu8Buffer, - u32FirstPart); - WILC_memcpy(pstrFifoHandler->pu8Buffer, pu8Buffer + u32FirstPart, - u32BytesToWrite - u32FirstPart); - /* update read offset and total bytes */ - pstrFifoHandler->u32WriteOffset = u32BytesToWrite - u32FirstPart; - pstrFifoHandler->u32TotalBytes += u32BytesToWrite; - } - /* if data overwriten */ - if (pstrFifoHandler->u32TotalBytes > pstrFifoHandler->u32BufferLength) { - /* adjust read offset to the oldest data available */ - pstrFifoHandler->u32ReadOffset = pstrFifoHandler->u32WriteOffset; - /* data availabe is the buffer length */ - pstrFifoHandler->u32TotalBytes = pstrFifoHandler->u32BufferLength; - } - WILC_SemaphoreRelease(&pstrFifoHandler->SemBuffer, WILC_NULL); + } else { + WILC_Uint32 u32FirstPart = + pstrFifoHandler->u32BufferLength - pstrFifoHandler->u32WriteOffset; + WILC_memcpy(pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32WriteOffset, pu8Buffer, + u32FirstPart); + WILC_memcpy(pstrFifoHandler->pu8Buffer, pu8Buffer + u32FirstPart, + u32BytesToWrite - u32FirstPart); + /* update read offset and total bytes */ + pstrFifoHandler->u32WriteOffset = u32BytesToWrite - u32FirstPart; + pstrFifoHandler->u32TotalBytes += u32BytesToWrite; } + /* if data overwriten */ + if (pstrFifoHandler->u32TotalBytes > pstrFifoHandler->u32BufferLength) { + /* adjust read offset to the oldest data available */ + pstrFifoHandler->u32ReadOffset = pstrFifoHandler->u32WriteOffset; + /* data availabe is the buffer length */ + pstrFifoHandler->u32TotalBytes = pstrFifoHandler->u32BufferLength; + } + up(&pstrFifoHandler->SemBuffer); } else { u32Error = 1; } @@ -139,4 +131,4 @@ WILC_Uint32 FIFO_WriteBytes(tHANDLE hFifo, WILC_Uint8 *pu8Buffer, WILC_Uint32 u3 u32Error = 1; } return u32Error; -} \ No newline at end of file +} diff --git a/drivers/staging/wilc1000/fifo_buffer.h b/drivers/staging/wilc1000/fifo_buffer.h index 0700e7929c00..c7e140be8fab 100644 --- a/drivers/staging/wilc1000/fifo_buffer.h +++ b/drivers/staging/wilc1000/fifo_buffer.h @@ -10,7 +10,7 @@ typedef struct { WILC_Uint32 u32WriteOffset; WILC_Uint32 u32ReadOffset; WILC_Uint32 u32TotalBytes; - WILC_SemaphoreHandle SemBuffer; + struct semaphore SemBuffer; } tstrFifoHandler; diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 7c764a2ba573..8f7adc760500 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -545,11 +545,11 @@ WILC_Bool g_obtainingIP = WILC_FALSE; WILC_Uint8 P2P_LISTEN_STATE; static struct task_struct *HostIFthreadHandler; static WILC_MsgQueueHandle gMsgQHostIF; -static WILC_SemaphoreHandle hSemHostIFthrdEnd; +static struct semaphore hSemHostIFthrdEnd; -WILC_SemaphoreHandle hSemDeinitDrvHandle; -static WILC_SemaphoreHandle hWaitResponse; -WILC_SemaphoreHandle hSemHostIntDeinit; +struct semaphore hSemDeinitDrvHandle; +static struct semaphore hWaitResponse; +struct semaphore hSemHostIntDeinit; WILC_TimerHandle g_hPeriodicRSSI; @@ -663,7 +663,7 @@ static WILC_Sint32 Handle_SetWfiDrvHandler(tstrHostIfSetDrvHandler *pstrHostIfSe if ((pstrHostIfSetDrvHandler->u32Address) == (WILC_Uint32)NULL) { - WILC_SemaphoreRelease(&hSemDeinitDrvHandle, WILC_NULL); + up(&hSemDeinitDrvHandle); } @@ -709,7 +709,7 @@ static WILC_Sint32 Handle_SetOperationMode(void *drvHandler, tstrHostIfSetOperat if ((pstrHostIfSetOperationMode->u32Mode) == (WILC_Uint32)NULL) { - WILC_SemaphoreRelease(&hSemDeinitDrvHandle, WILC_NULL); + up(&hSemDeinitDrvHandle); } @@ -906,7 +906,7 @@ static WILC_Sint32 Handle_GetMacAddress(void *drvHandler, tstrHostIfGetMacAddres { } - WILC_SemaphoreRelease(&hWaitResponse, NULL); + up(&hWaitResponse); return s32Error; } @@ -929,7 +929,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; - WILC_SemaphoreAcquire(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + down(&(pstrWFIDrv->gtOsCfgValuesSem)); PRINT_D(HOSTINF_DBG, "Setting CFG params\n"); @@ -1214,7 +1214,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str WILC_CATCH(s32Error) { } - WILC_SemaphoreRelease(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + up(&(pstrWFIDrv->gtOsCfgValuesSem)); return s32Error; } @@ -1232,7 +1232,7 @@ static WILC_Sint32 Handle_wait_msg_q_empty(void) { WILC_Sint32 s32Error = WILC_SUCCESS; g_wilc_initialized = 0; - WILC_SemaphoreRelease(&hWaitResponse, NULL); + up(&hWaitResponse); return s32Error; } @@ -2818,7 +2818,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); } - WILC_SemaphoreRelease(&(pstrWFIDrv->hSemTestKeyBlock), WILC_NULL); + up(&(pstrWFIDrv->hSemTestKeyBlock)); break; case WPARxGtk: @@ -2867,7 +2867,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) WILC_FREE(pu8keybuf); /* ////////////////////////// */ - WILC_SemaphoreRelease(&(pstrWFIDrv->hSemTestKeyBlock), WILC_NULL); + up(&(pstrWFIDrv->hSemTestKeyBlock)); /* ///////////////////////// */ } @@ -2914,7 +2914,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) WILC_FREE(pu8keybuf); /* ////////////////////////// */ - WILC_SemaphoreRelease(&(pstrWFIDrv->hSemTestKeyBlock), WILC_NULL); + up(&(pstrWFIDrv->hSemTestKeyBlock)); /* ///////////////////////// */ } _WPARxGtk_end_case_: @@ -2970,7 +2970,7 @@ _WPARxGtk_end_case_: WILC_FREE(pu8keybuf); /* ////////////////////////// */ - WILC_SemaphoreRelease(&(pstrWFIDrv->hSemTestKeyBlock), WILC_NULL); + up(&(pstrWFIDrv->hSemTestKeyBlock)); /* ///////////////////////// */ } #endif @@ -3011,7 +3011,7 @@ _WPARxGtk_end_case_: WILC_FREE(pu8keybuf); /* ////////////////////////// */ - WILC_SemaphoreRelease(&(pstrWFIDrv->hSemTestKeyBlock), WILC_NULL); + up(&(pstrWFIDrv->hSemTestKeyBlock)); /* ///////////////////////// */ } @@ -3176,7 +3176,7 @@ static void Handle_Disconnect(void *drvHandler) } /* ////////////////////////// */ - WILC_SemaphoreRelease(&(pstrWFIDrv->hSemTestDisconnectBlock), WILC_NULL); + up(&(pstrWFIDrv->hSemTestDisconnectBlock)); /* ///////////////////////// */ } @@ -3264,7 +3264,7 @@ static WILC_Sint32 Handle_GetChnl(void *drvHandler) { } - WILC_SemaphoreRelease(&(pstrWFIDrv->hSemGetCHNL), WILC_NULL); + up(&(pstrWFIDrv->hSemGetCHNL)); return s32Error; @@ -3306,7 +3306,7 @@ static void Handle_GetRssi(void *drvHandler) { } - WILC_SemaphoreRelease(&(pstrWFIDrv->hSemGetRSSI), WILC_NULL); + up(&(pstrWFIDrv->hSemGetRSSI)); } @@ -3337,7 +3337,7 @@ static void Handle_GetLinkspeed(void *drvHandler) { } - WILC_SemaphoreRelease(&(pstrWFIDrv->hSemGetLINKSPEED), WILC_NULL); + up(&(pstrWFIDrv->hSemGetLINKSPEED)); } @@ -3383,7 +3383,7 @@ WILC_Sint32 Handle_GetStatistics(void *drvHandler, tstrStatistics *pstrStatistic PRINT_ER("Failed to send scan paramters config packet\n"); /* WILC_ERRORREPORT(s32Error, s32Error); */ } - WILC_SemaphoreRelease(&hWaitResponse, NULL); + up(&hWaitResponse); return 0; } @@ -3449,7 +3449,7 @@ static WILC_Sint32 Handle_Get_InActiveTime(void *drvHandler, tstrHostIfStaInacti PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime); - WILC_SemaphoreRelease(&(pstrWFIDrv->hSemInactiveTime), WILC_NULL); + up(&(pstrWFIDrv->hSemInactiveTime)); WILC_CATCH(s32Error) { @@ -3730,7 +3730,7 @@ static void Handle_DelAllSta(void *drvHandler, tstrHostIFDelAllSta *pstrDelAllSt } WILC_FREE_IF_TRUE(strWID.ps8WidVal); - WILC_SemaphoreRelease(&hWaitResponse, NULL); + up(&hWaitResponse); } @@ -4301,7 +4301,7 @@ static WILC_Sint32 Handle_DelBASession(void *drvHandler, tstrHostIfBASessionInfo WILC_FREE(strWID.ps8WidVal); /*BugID_5222*/ - WILC_SemaphoreRelease(&hWaitResponse, NULL); + up(&hWaitResponse); return s32Error; @@ -4355,7 +4355,7 @@ static WILC_Sint32 Handle_DelAllRxBASessions(void *drvHandler, tstrHostIfBASessi WILC_FREE(strWID.ps8WidVal); /*BugID_5222*/ - WILC_SemaphoreRelease(&hWaitResponse, NULL); + up(&hWaitResponse); return s32Error; @@ -4590,7 +4590,7 @@ static int hostIFthread(void *pvArg) } PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n"); - WILC_SemaphoreRelease(&hSemHostIFthrdEnd, WILC_NULL); + up(&hSemHostIFthrdEnd); return 0; } @@ -4692,7 +4692,7 @@ WILC_Sint32 host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8keyI s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); if (s32Error) PRINT_ER("Error in sending message queue : Request to remove WEP key \n"); - WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemTestKeyBlock), NULL); + down(&(pstrWFIDrv->hSemTestKeyBlock)); WILC_CATCH(s32Error) { @@ -4741,7 +4741,7 @@ WILC_Sint32 host_int_set_WEPDefaultKeyID(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); if (s32Error) PRINT_ER("Error in sending message queue : Default key index\n"); - WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemTestKeyBlock), NULL); + down(&(pstrWFIDrv->hSemTestKeyBlock)); WILC_CATCH(s32Error) { @@ -4809,7 +4809,7 @@ WILC_Sint32 host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv, const WILC_U s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); if (s32Error) PRINT_ER("Error in sending message queue :WEP Key\n"); - WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemTestKeyBlock), NULL); + down(&(pstrWFIDrv->hSemTestKeyBlock)); WILC_CATCH(s32Error) { @@ -4886,7 +4886,7 @@ WILC_Sint32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const WILC_Ui if (s32Error) PRINT_ER("Error in sending message queue :WEP Key\n"); - WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemTestKeyBlock), NULL); + down(&(pstrWFIDrv->hSemTestKeyBlock)); WILC_CATCH(s32Error) { @@ -4989,7 +4989,7 @@ WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8Ptk, WILC PRINT_ER("Error in sending message queue: PTK Key\n"); /* ////////////// */ - WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemTestKeyBlock), NULL); + down(&(pstrWFIDrv->hSemTestKeyBlock)); /* WILC_Sleep(100); */ /* /////// */ @@ -5093,7 +5093,7 @@ WILC_Sint32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8RxGtk, if (s32Error) PRINT_ER("Error in sending message queue: RX GTK\n"); /* ////////////// */ - WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemTestKeyBlock), NULL); + down(&(pstrWFIDrv->hSemTestKeyBlock)); /* WILC_Sleep(100); */ /* /////// */ @@ -5151,7 +5151,7 @@ WILC_Sint32 host_int_add_tx_gtk(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8KeyLen, PRINT_ER("Error in sending message queue: TX GTK\n"); /* ////////////// */ - WILC_SemaphoreAcquire(&hSemTestKeyBlock, NULL); + down(&hSemTestKeyBlock); WILC_Sleep(100); /* /////// */ @@ -5322,7 +5322,7 @@ WILC_Sint32 host_int_get_MacAddress(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8Ma return WILC_FAIL; } - WILC_SemaphoreAcquire(&hWaitResponse, NULL); + down(&hWaitResponse); return s32Error; } @@ -5703,7 +5703,7 @@ WILC_Sint32 host_int_disconnect(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16Reason if (s32Error) PRINT_ER("Failed to send message queue: disconnect\n"); /* ////////////// */ - WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemTestDisconnectBlock), NULL); + down(&(pstrWFIDrv->hSemTestDisconnectBlock)); /* /////// */ WILC_CATCH(s32Error) @@ -5922,7 +5922,7 @@ WILC_Sint32 host_int_wait_msg_queue_idle(void) } /* wait untill MSG Q is empty */ - WILC_SemaphoreAcquire(&hWaitResponse, NULL); + down(&hWaitResponse); return s32Error; @@ -6018,7 +6018,7 @@ WILC_Sint32 host_int_get_host_chnl_num(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); if (s32Error) PRINT_ER("Failed to send get host channel param's message queue "); - WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemGetCHNL), NULL); + down(&(pstrWFIDrv->hSemGetCHNL)); /* gu8Chnl = 11; */ *pu8ChNo = gu8Chnl; @@ -6115,7 +6115,7 @@ WILC_Sint32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *ma if (s32Error) PRINT_ER("Failed to send get host channel param's message queue "); - WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemInactiveTime), NULL); + down(&(pstrWFIDrv->hSemInactiveTime)); *pu32InactiveTime = gu32InactiveTime; @@ -6205,7 +6205,7 @@ WILC_Sint32 host_int_get_rssi(WILC_WFIDrvHandle hWFIDrv, WILC_Sint8 *ps8Rssi) return WILC_FAIL; } - WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemGetRSSI), NULL); + down(&(pstrWFIDrv->hSemGetRSSI)); if (ps8Rssi == NULL) { @@ -6242,7 +6242,7 @@ WILC_Sint32 host_int_get_link_speed(WILC_WFIDrvHandle hWFIDrv, WILC_Sint8 *ps8ln return WILC_FAIL; } - WILC_SemaphoreAcquire(&(pstrWFIDrv->hSemGetLINKSPEED), NULL); + down(&(pstrWFIDrv->hSemGetLINKSPEED)); if (ps8lnkspd == NULL) { @@ -6276,7 +6276,7 @@ WILC_Sint32 host_int_get_statistics(WILC_WFIDrvHandle hWFIDrv, tstrStatistics *p return WILC_FAIL; } - WILC_SemaphoreAcquire(&hWaitResponse, NULL); + down(&hWaitResponse); return s32Error; } @@ -6418,7 +6418,7 @@ WILC_Sint32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16WID, WILC_Uint WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; - WILC_SemaphoreAcquire(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + down(&(pstrWFIDrv->gtOsCfgValuesSem)); if (pstrWFIDrv == WILC_NULL) { PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n"); @@ -6503,7 +6503,7 @@ WILC_Sint32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16WID, WILC_Uint break; } - WILC_SemaphoreRelease(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + up(&(pstrWFIDrv->gtOsCfgValuesSem)); WILC_CATCH(s32Error) { @@ -6598,8 +6598,6 @@ WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv; - tstrWILC_SemaphoreAttrs strSemaphoreAttrs; - /*if(u32Intialized == 1) * { @@ -6611,11 +6609,7 @@ WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) gbScanWhileConnected = WILC_FALSE; - WILC_SemaphoreFillDefault(&strSemaphoreAttrs); - - - strSemaphoreAttrs.u32InitCount = 0; - WILC_SemaphoreCreate(&hWaitResponse, &strSemaphoreAttrs); + sema_init(&hWaitResponse, 0); @@ -6640,29 +6634,18 @@ WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) PRINT_D(HOSTINF_DBG, "Global handle pointer value=%x\n", (WILC_Uint32)pstrWFIDrv); /* /////////////////////////////////////// */ if (clients_count == 0) { - strSemaphoreAttrs.u32InitCount = 0; - WILC_SemaphoreCreate(&hSemHostIFthrdEnd, &strSemaphoreAttrs); - - strSemaphoreAttrs.u32InitCount = 0; - WILC_SemaphoreCreate(&hSemDeinitDrvHandle, &strSemaphoreAttrs); - + sema_init(&hSemHostIFthrdEnd, 0); + sema_init(&hSemDeinitDrvHandle, 0); /*BugID_5348*/ - strSemaphoreAttrs.u32InitCount = 1; - WILC_SemaphoreCreate(&hSemHostIntDeinit, &strSemaphoreAttrs); + sema_init(&hSemHostIntDeinit, 1); } - strSemaphoreAttrs.u32InitCount = 0; - WILC_SemaphoreCreate(&(pstrWFIDrv->hSemTestKeyBlock), &strSemaphoreAttrs); - strSemaphoreAttrs.u32InitCount = 0; - WILC_SemaphoreCreate(&(pstrWFIDrv->hSemTestDisconnectBlock), &strSemaphoreAttrs); - strSemaphoreAttrs.u32InitCount = 0; - WILC_SemaphoreCreate(&(pstrWFIDrv->hSemGetRSSI), &strSemaphoreAttrs); - strSemaphoreAttrs.u32InitCount = 0; - WILC_SemaphoreCreate(&(pstrWFIDrv->hSemGetLINKSPEED), &strSemaphoreAttrs); - strSemaphoreAttrs.u32InitCount = 0; - WILC_SemaphoreCreate(&(pstrWFIDrv->hSemGetCHNL), &strSemaphoreAttrs); - strSemaphoreAttrs.u32InitCount = 0; - WILC_SemaphoreCreate(&(pstrWFIDrv->hSemInactiveTime), &strSemaphoreAttrs); + sema_init(&(pstrWFIDrv->hSemTestKeyBlock), 0); + sema_init(&(pstrWFIDrv->hSemTestDisconnectBlock), 0); + sema_init(&(pstrWFIDrv->hSemGetRSSI), 0); + sema_init(&(pstrWFIDrv->hSemGetLINKSPEED), 0); + sema_init(&(pstrWFIDrv->hSemGetCHNL), 0); + sema_init(&(pstrWFIDrv->hSemInactiveTime), 0); /* /////////////////////////////////////// */ @@ -6718,8 +6701,8 @@ WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) } #endif - WILC_SemaphoreCreate(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); - WILC_SemaphoreAcquire(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + sema_init(&(pstrWFIDrv->gtOsCfgValuesSem), 1); + down(&(pstrWFIDrv->gtOsCfgValuesSem)); @@ -6752,7 +6735,7 @@ WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) pstrWFIDrv->strCfgValues.curr_tx_rate); - WILC_SemaphoreRelease(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + up(&(pstrWFIDrv->gtOsCfgValuesSem)); /*TODO Code to setup simulation to be removed later*/ /*Intialize configurator module*/ @@ -6781,7 +6764,7 @@ _fail_timer_3: WILC_TimerDestroy(&(pstrWFIDrv->hRemainOnChannel), WILC_NULL); #endif _fail_timer_2: - WILC_SemaphoreRelease(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + up(&(pstrWFIDrv->gtOsCfgValuesSem)); WILC_TimerDestroy(&(pstrWFIDrv->hConnectTimer), WILC_NULL); _fail_timer_1: WILC_TimerDestroy(&(pstrWFIDrv->hScanTimer), WILC_NULL); @@ -6825,7 +6808,7 @@ WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv) return 0; } - WILC_SemaphoreAcquire(&hSemHostIntDeinit, NULL); + down(&hSemHostIntDeinit); terminated_handle = pstrWFIDrv; PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count); @@ -6855,7 +6838,7 @@ WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv) #endif host_int_set_wfi_drv_handler((WILC_Uint32)WILC_NULL); - WILC_SemaphoreAcquire(&hSemDeinitDrvHandle, NULL); + down(&hSemDeinitDrvHandle); /*Calling the CFG80211 scan done function with the abort flag set to true*/ @@ -6894,29 +6877,15 @@ WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv) PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error); } - WILC_SemaphoreAcquire(&hSemHostIFthrdEnd, NULL); + down(&hSemHostIFthrdEnd); WILC_MsgQueueDestroy(&gMsgQHostIF, WILC_NULL); msgQ_created = 0; - - - WILC_SemaphoreDestroy(&hSemHostIFthrdEnd, NULL); - WILC_SemaphoreDestroy(&hSemDeinitDrvHandle, NULL); - } - WILC_SemaphoreDestroy(&(pstrWFIDrv->hSemTestKeyBlock), NULL); - WILC_SemaphoreDestroy(&(pstrWFIDrv->hSemTestDisconnectBlock), NULL); - WILC_SemaphoreDestroy(&(pstrWFIDrv->hSemGetRSSI), NULL); - WILC_SemaphoreDestroy(&(pstrWFIDrv->hSemGetLINKSPEED), NULL); - WILC_SemaphoreDestroy(&(pstrWFIDrv->hSemGetCHNL), NULL); - WILC_SemaphoreDestroy(&(pstrWFIDrv->hSemInactiveTime), NULL); - WILC_SemaphoreDestroy(&hWaitResponse, NULL); - - WILC_SemaphoreAcquire(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); - WILC_SemaphoreDestroy(&(pstrWFIDrv->gtOsCfgValuesSem), NULL); + down(&(pstrWFIDrv->gtOsCfgValuesSem)); /*Setting the gloabl driver handler with NULL*/ u32Intialized = 0; @@ -6929,7 +6898,7 @@ WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv) clients_count--; /* Decrease number of created entities */ terminated_handle = WILC_NULL; - WILC_SemaphoreRelease(&hSemHostIntDeinit, NULL); + up(&hSemHostIntDeinit); return s32Error; } @@ -7003,7 +6972,7 @@ void GnrlAsyncInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) tstrWILC_WFIDrv *pstrWFIDrv = WILC_NULL; /*BugID_5348*/ - WILC_SemaphoreAcquire(&hSemHostIntDeinit, NULL); + down(&hSemHostIntDeinit); drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24)); pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -7013,7 +6982,7 @@ void GnrlAsyncInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) { PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n"); /*BugID_5348*/ - WILC_SemaphoreRelease(&hSemHostIntDeinit, NULL); + up(&hSemHostIntDeinit); return; } @@ -7021,7 +6990,7 @@ void GnrlAsyncInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) /* received mac status is not needed when there is no current Connect Request */ PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n"); /*BugID_5348*/ - WILC_SemaphoreRelease(&hSemHostIntDeinit, NULL); + up(&hSemHostIntDeinit); return; } @@ -7045,7 +7014,7 @@ void GnrlAsyncInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) } /*BugID_5348*/ - WILC_SemaphoreRelease(&hSemHostIntDeinit, NULL); + up(&hSemHostIntDeinit); return; } @@ -7517,7 +7486,7 @@ WILC_Sint32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 pu8Mac { } - WILC_SemaphoreAcquire(&hWaitResponse, NULL); + down(&hWaitResponse); return s32Error; @@ -7945,7 +7914,7 @@ WILC_Sint32 host_int_delBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char } /*BugID_5222*/ - WILC_SemaphoreAcquire(&hWaitResponse, NULL); + down(&hWaitResponse); return s32Error; } @@ -7980,7 +7949,7 @@ WILC_Sint32 host_int_del_All_Rx_BASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSI } /*BugID_5222*/ - WILC_SemaphoreAcquire(&hWaitResponse, NULL); + down(&hWaitResponse); return s32Error; } diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index f2a348506a8b..9c06db12b7ea 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -422,14 +422,14 @@ typedef struct { WILC_Uint8 au8AssociatedBSSID[ETH_ALEN]; tstrCfgParamVal strCfgValues; /* semaphores */ - WILC_SemaphoreHandle gtOsCfgValuesSem; - WILC_SemaphoreHandle hSemTestKeyBlock; + struct semaphore gtOsCfgValuesSem; + struct semaphore hSemTestKeyBlock; - WILC_SemaphoreHandle hSemTestDisconnectBlock; - WILC_SemaphoreHandle hSemGetRSSI; - WILC_SemaphoreHandle hSemGetLINKSPEED; - WILC_SemaphoreHandle hSemGetCHNL; - WILC_SemaphoreHandle hSemInactiveTime; + struct semaphore hSemTestDisconnectBlock; + struct semaphore hSemGetRSSI; + struct semaphore hSemGetLINKSPEED; + struct semaphore hSemGetCHNL; + struct semaphore hSemInactiveTime; /* timer handlers */ WILC_TimerHandle hScanTimer; WILC_TimerHandle hConnectTimer; diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c b/drivers/staging/wilc1000/wilc_msgqueue.c index 1113092398d1..ebbba8b24de0 100644 --- a/drivers/staging/wilc1000/wilc_msgqueue.c +++ b/drivers/staging/wilc1000/wilc_msgqueue.c @@ -11,21 +11,12 @@ WILC_ErrNo WILC_MsgQueueCreate(WILC_MsgQueueHandle *pHandle, tstrWILC_MsgQueueAttrs *pstrAttrs) { - tstrWILC_SemaphoreAttrs strSemAttrs; - WILC_SemaphoreFillDefault(&strSemAttrs); - strSemAttrs.u32InitCount = 0; - spin_lock_init(&pHandle->strCriticalSection); - if ((WILC_SemaphoreCreate(&pHandle->hSem, &strSemAttrs) == WILC_SUCCESS)) { - - pHandle->pstrMessageList = NULL; - pHandle->u32ReceiversCount = 0; - pHandle->bExiting = WILC_FALSE; - - return WILC_SUCCESS; - } else { - return WILC_FAIL; - } + sema_init(&pHandle->hSem, 0); + pHandle->pstrMessageList = NULL; + pHandle->u32ReceiversCount = 0; + pHandle->bExiting = WILC_FALSE; + return WILC_SUCCESS; } /*! @@ -42,12 +33,10 @@ WILC_ErrNo WILC_MsgQueueDestroy(WILC_MsgQueueHandle *pHandle, /* Release any waiting receiver thread. */ while (pHandle->u32ReceiversCount > 0) { - WILC_SemaphoreRelease(&(pHandle->hSem), WILC_NULL); + up(&(pHandle->hSem)); pHandle->u32ReceiversCount--; } - WILC_SemaphoreDestroy(&pHandle->hSem, WILC_NULL); - while (pHandle->pstrMessageList != NULL) { Message *pstrMessge = pHandle->pstrMessageList->pstrNext; WILC_FREE(pHandle->pstrMessageList); @@ -104,7 +93,7 @@ WILC_ErrNo WILC_MsgQueueSend(WILC_MsgQueueHandle *pHandle, spin_unlock_irqrestore(&pHandle->strCriticalSection, flags); - WILC_SemaphoreRelease(&pHandle->hSem, WILC_NULL); + up(&pHandle->hSem); WILC_CATCH(s32RetStatus) { @@ -136,7 +125,6 @@ WILC_ErrNo WILC_MsgQueueRecv(WILC_MsgQueueHandle *pHandle, Message *pstrMessage; WILC_ErrNo s32RetStatus = WILC_SUCCESS; - tstrWILC_SemaphoreAttrs strSemAttrs; unsigned long flags; if ((pHandle == NULL) || (u32RecvBufferSize == 0) || (pvRecvBuffer == NULL) || (pu32ReceivedLength == NULL)) { @@ -151,8 +139,8 @@ WILC_ErrNo WILC_MsgQueueRecv(WILC_MsgQueueHandle *pHandle, pHandle->u32ReceiversCount++; spin_unlock_irqrestore(&pHandle->strCriticalSection, flags); - WILC_SemaphoreFillDefault(&strSemAttrs); - s32RetStatus = WILC_SemaphoreAcquire(&(pHandle->hSem), &strSemAttrs); + down(&(pHandle->hSem)); + if (s32RetStatus == WILC_TIMEOUT) { /* timed out, just exit without consumeing the message */ spin_lock_irqsave(&pHandle->strCriticalSection, flags); @@ -176,7 +164,7 @@ WILC_ErrNo WILC_MsgQueueRecv(WILC_MsgQueueHandle *pHandle, /* check buffer size */ if (u32RecvBufferSize < pstrMessage->u32Length) { spin_unlock_irqrestore(&pHandle->strCriticalSection, flags); - WILC_SemaphoreRelease(&pHandle->hSem, WILC_NULL); + up(&pHandle->hSem); WILC_ERRORREPORT(s32RetStatus, WILC_BUFFER_OVERFLOW); } diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index 1999970635aa..7375ec44cc42 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -54,9 +54,6 @@ typedef WILC_Uint16 WILC_WideChar; /* Error reporting and handling support */ #include "wilc_errorsupport.h" -/* Semaphore support */ -#include "wilc_semaphore.h" - /* Sleep support */ #include "wilc_sleep.h" diff --git a/drivers/staging/wilc1000/wilc_platform.h b/drivers/staging/wilc1000/wilc_platform.h index 2e0f41735df0..ae42bbcbd5eb 100644 --- a/drivers/staging/wilc1000/wilc_platform.h +++ b/drivers/staging/wilc1000/wilc_platform.h @@ -16,8 +16,6 @@ * OS specific types *******************************************************************/ -typedef struct semaphore WILC_SemaphoreHandle; - typedef struct timer_list WILC_TimerHandle; @@ -30,7 +28,7 @@ typedef struct __Message_struct { } Message; typedef struct __MessageQueue_struct { - WILC_SemaphoreHandle hSem; + struct semaphore hSem; spinlock_t strCriticalSection; WILC_Bool bExiting; WILC_Uint32 u32ReceiversCount; diff --git a/drivers/staging/wilc1000/wilc_semaphore.c b/drivers/staging/wilc1000/wilc_semaphore.c deleted file mode 100644 index f09a88ca6ae4..000000000000 --- a/drivers/staging/wilc1000/wilc_semaphore.c +++ /dev/null @@ -1,56 +0,0 @@ - -#include "wilc_oswrapper.h" - -WILC_ErrNo WILC_SemaphoreCreate(WILC_SemaphoreHandle *pHandle, - tstrWILC_SemaphoreAttrs *pstrAttrs) -{ - tstrWILC_SemaphoreAttrs strDefaultAttrs; - if (pstrAttrs == WILC_NULL) { - WILC_SemaphoreFillDefault(&strDefaultAttrs); - pstrAttrs = &strDefaultAttrs; - } - - sema_init(pHandle, pstrAttrs->u32InitCount); - return WILC_SUCCESS; - -} - - -WILC_ErrNo WILC_SemaphoreDestroy(WILC_SemaphoreHandle *pHandle, - tstrWILC_SemaphoreAttrs *pstrAttrs) -{ - /* nothing to be done ! */ - - return WILC_SUCCESS; - -} - - -WILC_ErrNo WILC_SemaphoreAcquire(WILC_SemaphoreHandle *pHandle, - tstrWILC_SemaphoreAttrs *pstrAttrs) -{ - WILC_ErrNo s32RetStatus = WILC_SUCCESS; - - while (down_interruptible(pHandle)) - ; - - if (s32RetStatus == 0) { - return WILC_SUCCESS; - } else if (s32RetStatus == -ETIME) { - return WILC_TIMEOUT; - } else { - return WILC_FAIL; - } - - return WILC_SUCCESS; - -} - -WILC_ErrNo WILC_SemaphoreRelease(WILC_SemaphoreHandle *pHandle, - tstrWILC_SemaphoreAttrs *pstrAttrs) -{ - - up(pHandle); - return WILC_SUCCESS; - -} diff --git a/drivers/staging/wilc1000/wilc_semaphore.h b/drivers/staging/wilc1000/wilc_semaphore.h deleted file mode 100644 index 3c0ecc326fb3..000000000000 --- a/drivers/staging/wilc1000/wilc_semaphore.h +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef __WILC_SEMAPHORE_H__ -#define __WILC_SEMAPHORE_H__ - -/*! - * @file wilc_semaphore.h - * @brief Semaphore OS Wrapper functionality - * @author syounan - * @sa wilc_oswrapper.h top level OS wrapper file - * @date 10 Aug 2010 - * @version 1.0 - */ - -/*! - * @struct WILC_SemaphoreAttrs - * @brief Semaphore API options - * @author syounan - * @date 10 Aug 2010 - * @version 1.0 - */ -typedef struct { - /*!< - * Initial count when the semaphore is created. default is 1 - */ - WILC_Uint32 u32InitCount; - -} tstrWILC_SemaphoreAttrs; - - -/*! - * @brief Fills the WILC_SemaphoreAttrs with default parameters - * @param[out] pstrAttrs structure to be filled - * @sa WILC_SemaphoreAttrs - * @author syounan - * @date 10 Aug 2010 - * @version 1.0 - */ -static inline void WILC_SemaphoreFillDefault(tstrWILC_SemaphoreAttrs *pstrAttrs) -{ - pstrAttrs->u32InitCount = 1; -} -/*! - * @brief Creates a new Semaphore object - * @param[out] pHandle handle to the newly created semaphore - * @param[in] pstrAttrs Optional attributes, NULL for defaults - * pstrAttrs->u32InitCount controls the initial count - * @return Error code indicating success/failure - * @sa WILC_SemaphoreAttrs - * @author syounan - * @date 10 Aug 2010 - * @version 1.0 - */ -WILC_ErrNo WILC_SemaphoreCreate(WILC_SemaphoreHandle *pHandle, - tstrWILC_SemaphoreAttrs *pstrAttrs); - -/*! - * @brief Destroyes an existing Semaphore, releasing any resources - * @param[in] pHandle handle to the semaphore object - * @param[in] pstrAttrs Optional attributes, NULL for defaults - * @return Error code indicating success/failure - * @sa WILC_SemaphoreAttrs - * @todo need to define behaviour if the semaphore delayed while it is pending - * @author syounan - * @date 10 Aug 2010 - * @version 1.0 - */ -WILC_ErrNo WILC_SemaphoreDestroy(WILC_SemaphoreHandle *pHandle, - tstrWILC_SemaphoreAttrs *pstrAttrs); - -/*! - * @brief Acquire the Semaphore object - * @details This function will block until it can Acquire the given - * semaphore, if the feature WILC_OS_FEATURE_SEMAPHORE_TIMEOUT is - * eanbled a timeout value can be passed in pstrAttrs - * @param[in] pHandle handle to the semaphore object - * @param[in] pstrAttrs Optional attributes, NULL for default - * @return Error code indicating success/failure - * @sa WILC_SemaphoreAttrs - * @author syounan - * @date 10 Aug 2010 - * @version 1.0 - */ -WILC_ErrNo WILC_SemaphoreAcquire(WILC_SemaphoreHandle *pHandle, - tstrWILC_SemaphoreAttrs *pstrAttrs); - -/*! - * @brief Release the Semaphore object - * @param[in] pHandle handle to the semaphore object - * @param[in] pstrAttrs Optional attributes, NULL for default - * @return Error code indicating sucess/failure - * @sa WILC_SemaphoreAttrs - * @author syounan - * @date 10 Aug 2010 - * @version 1.0 - */ -WILC_ErrNo WILC_SemaphoreRelease(WILC_SemaphoreHandle *pHandle, - tstrWILC_SemaphoreAttrs *pstrAttrs); - - -#endif diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index c1d511825147..d8ca75cf73f6 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -462,7 +462,7 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo PRINT_D(CFG80211_DBG, "No networks found \n"); } - WILC_SemaphoreAcquire(&(priv->hSemScanReq), NULL); + down(&(priv->hSemScanReq)); if (priv->pstrScanReq != WILC_NULL) { cfg80211_scan_done(priv->pstrScanReq, WILC_FALSE); @@ -470,12 +470,12 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo priv->bCfgScanning = WILC_FALSE; priv->pstrScanReq = WILC_NULL; } - WILC_SemaphoreRelease(&(priv->hSemScanReq), NULL); + up(&(priv->hSemScanReq)); } /*Aborting any scan operation during mac close*/ else if (enuScanEvent == SCAN_EVENT_ABORTED) { - WILC_SemaphoreAcquire(&(priv->hSemScanReq), NULL); + down(&(priv->hSemScanReq)); PRINT_D(CFG80211_DBG, "Scan Aborted \n"); if (priv->pstrScanReq != WILC_NULL) { @@ -487,7 +487,7 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo priv->bCfgScanning = WILC_FALSE; priv->pstrScanReq = WILC_NULL; } - WILC_SemaphoreRelease(&(priv->hSemScanReq), NULL); + up(&(priv->hSemScanReq)); } } @@ -2839,13 +2839,13 @@ static int WILC_WFI_dump_station(struct wiphy *wiphy, struct net_device *dev, STATION_INFO_RX_BYTES | STATION_INFO_RX_PACKETS | STATION_INFO_SIGNAL | STATION_INFO_INACTIVE_TIME; - WILC_SemaphoreAcquire(&SemHandleUpdateStats, NULL); + down(&SemHandleUpdateStats); sinfo->inactive_time = priv->netstats.rx_time > priv->netstats.tx_time ? jiffies_to_msecs(jiffies - priv->netstats.tx_time) : jiffies_to_msecs(jiffies - priv->netstats.rx_time); sinfo->rx_bytes = priv->netstats.rx_bytes; sinfo->tx_bytes = priv->netstats.tx_bytes; sinfo->rx_packets = priv->netstats.rx_packets; sinfo->tx_packets = priv->netstats.tx_packets; - WILC_SemaphoreRelease(&SemHandleUpdateStats, NULL); + up(&SemHandleUpdateStats); #endif return 0; @@ -3767,7 +3767,7 @@ int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed) struct WILC_WFI_priv *priv; priv = wiphy_priv(wiphy); - /* WILC_SemaphoreAcquire(&SemHandleUpdateStats,NULL); */ + /* down(&SemHandleUpdateStats); */ #if 1 switch (changed) { @@ -3792,7 +3792,7 @@ int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed) default: break; } - /* WILC_SemaphoreRelease(&SemHandleUpdateStats,NULL); */ + /* down(&SemHandleUpdateStats); */ #endif return 0; } @@ -3898,7 +3898,7 @@ struct wireless_dev *WILC_WFI_WiphyRegister(struct net_device *net) /*Return hardware description structure (wiphy)'s priv*/ priv = wdev_priv(wdev); - WILC_SemaphoreCreate(&(priv->SemHandleUpdateStats), NULL); + sema_init(&(priv->SemHandleUpdateStats), 1); /*Link the wiphy with wireless structure*/ priv->wdev = wdev; @@ -3991,8 +3991,6 @@ int WILC_WFI_InitHostInt(struct net_device *net) struct WILC_WFI_priv *priv; - tstrWILC_SemaphoreAttrs strSemaphoreAttrs; - PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr); priv = wdev_priv(net->ieee80211_ptr); if (op_ifcs == 0) { @@ -4007,17 +4005,11 @@ int WILC_WFI_InitHostInt(struct net_device *net) return s32Error; } - WILC_SemaphoreFillDefault(&strSemaphoreAttrs); - - /* /////////////////////////////////////// */ - /* strSemaphoreAttrs.u32InitCount = 0; */ - - priv->gbAutoRateAdjusted = WILC_FALSE; priv->bInP2PlistenState = WILC_FALSE; - WILC_SemaphoreCreate(&(priv->hSemScanReq), &strSemaphoreAttrs); + sema_init(&(priv->hSemScanReq), 1); s32Error = host_int_init(&priv->hWILCWFIDrv); /* s32Error = host_int_init(&priv->hWILCWFIDrv_2); */ if (s32Error) { @@ -4042,13 +4034,6 @@ int WILC_WFI_DeInitHostInt(struct net_device *net) struct WILC_WFI_priv *priv; priv = wdev_priv(net->ieee80211_ptr); - - - - - - WILC_SemaphoreDestroy(&(priv->hSemScanReq), NULL); - priv->gbAutoRateAdjusted = WILC_FALSE; priv->bInP2PlistenState = WILC_FALSE; diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 0abe653acc66..0fc383b272aa 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -165,8 +165,8 @@ struct WILC_WFI_priv { struct wilc_wfi_key *wilc_ptk[MAX_NUM_STA]; WILC_Uint8 wilc_groupkey; /* semaphores */ - WILC_SemaphoreHandle SemHandleUpdateStats; - WILC_SemaphoreHandle hSemScanReq; + struct semaphore SemHandleUpdateStats; + struct semaphore hSemScanReq; /* */ WILC_Bool gbAutoRateAdjusted; From 057d1e979392141727397bc7e7eac309124a2fab Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 1 Jun 2015 21:06:44 +0200 Subject: [PATCH 0778/1163] staging: wilc1000: fix const cast warnings The wilc1000 driver produces a lot of warnings about invalid casts between const and non-const variables. This reworks the code to avoid all those warnings, by marking variables and function arguments const. A lot of the types use WILC_Uint8, I change them to const u8 for style reasons, as I'm touching them anyway. Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 32 ++++++++++--------- drivers/staging/wilc1000/host_interface.h | 24 +++++++------- drivers/staging/wilc1000/linux_mon.c | 2 +- drivers/staging/wilc1000/wilc_memory.c | 2 +- drivers/staging/wilc1000/wilc_memory.h | 2 +- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 12 +++---- .../staging/wilc1000/wilc_wfi_cfgoperations.h | 2 +- 7 files changed, 39 insertions(+), 37 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 8f7adc760500..6d9bd4983e90 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -4912,8 +4912,8 @@ WILC_Sint32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const WILC_Ui * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8Ptk, WILC_Uint8 u8PtkKeylen, - const WILC_Uint8 *mac_addr, WILC_Uint8 *pu8RxMic, WILC_Uint8 *pu8TxMic, WILC_Uint8 mode, WILC_Uint8 u8Ciphermode, WILC_Uint8 u8Idx) +WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8Ptk, WILC_Uint8 u8PtkKeylen, + const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, WILC_Uint8 mode, WILC_Uint8 u8Ciphermode, WILC_Uint8 u8Idx) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -5014,9 +5014,9 @@ WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8Ptk, WILC * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8RxGtk, WILC_Uint8 u8GtkKeylen, - WILC_Uint8 u8KeyIdx, WILC_Uint32 u32KeyRSClen, WILC_Uint8 *KeyRSC, - WILC_Uint8 *pu8RxMic, WILC_Uint8 *pu8TxMic, WILC_Uint8 mode, WILC_Uint8 u8Ciphermode) +WILC_Sint32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8RxGtk, WILC_Uint8 u8GtkKeylen, + WILC_Uint8 u8KeyIdx, WILC_Uint32 u32KeyRSClen, const u8 *KeyRSC, + const u8 *pu8RxMic, const u8 *pu8TxMic, WILC_Uint8 mode, WILC_Uint8 u8Ciphermode) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -5531,7 +5531,7 @@ WILC_Sint32 host_int_get_start_scan_req(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *p * @version 1.0 */ WILC_Sint32 host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8bssid, - WILC_Uint8 *pu8ssid, size_t ssidLen, + const u8 *pu8ssid, size_t ssidLen, const WILC_Uint8 *pu8IEs, size_t IEsLen, tWILCpfConnectResult pfConnectResult, void *pvUserArg, WILC_Uint8 u8security, AUTHTYPE_T tenuAuth_type, @@ -6090,7 +6090,7 @@ WILC_Sint32 host_int_test_set_int_wid(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32 * @date * @version 1.0 */ -WILC_Sint32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *mac, WILC_Uint32 *pu32InactiveTime) +WILC_Sint32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, const u8 *mac, WILC_Uint32 *pu32InactiveTime) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -7364,10 +7364,11 @@ WILC_Sint32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam WILC_memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam)); if (pstrAddStationMsg->u8NumRates > 0) { - pstrAddStationMsg->pu8Rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates); - WILC_NULLCHECK(s32Error, pstrAddStationMsg->pu8Rates); + u8 *rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates); + WILC_NULLCHECK(s32Error, rates); - WILC_memcpy(pstrAddStationMsg->pu8Rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates); + WILC_memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates); + pstrAddStationMsg->pu8Rates = rates; } @@ -7391,7 +7392,7 @@ WILC_Sint32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam * @date * @version 1.0 */ -WILC_Sint32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8MacAddr) +WILC_Sint32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8MacAddr) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -7437,7 +7438,7 @@ WILC_Sint32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8MacAd * @date * @version 1.0 */ -WILC_Sint32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 pu8MacAddr[][ETH_ALEN]) +WILC_Sint32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -7523,9 +7524,10 @@ WILC_Sint32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaPara WILC_memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam)); if (pstrAddStationMsg->u8NumRates > 0) { - pstrAddStationMsg->pu8Rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates); - WILC_memcpy(pstrAddStationMsg->pu8Rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates); - WILC_NULLCHECK(s32Error, pstrAddStationMsg->pu8Rates); + u8 *rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates); + WILC_NULLCHECK(s32Error, rates); + WILC_memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates); + pstrAddStationMsg->pu8Rates = rates; } s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 9c06db12b7ea..5c17076d10f6 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -464,7 +464,7 @@ typedef struct { WILC_Uint8 au8BSSID[ETH_ALEN]; WILC_Uint16 u16AssocID; WILC_Uint8 u8NumRates; - WILC_Uint8 *pu8Rates; + const u8 *pu8Rates; WILC_Bool bIsHTSupported; WILC_Uint16 u16HTCapInfo; WILC_Uint8 u8AmpduParams; @@ -578,8 +578,8 @@ WILC_Sint32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const WILC_Ui * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8Ptk, WILC_Uint8 u8PtkKeylen, - const WILC_Uint8 *mac_addr, WILC_Uint8 *pu8RxMic, WILC_Uint8 *pu8TxMic, WILC_Uint8 mode, WILC_Uint8 u8Ciphermode, WILC_Uint8 u8Idx); +WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8Ptk, WILC_Uint8 u8PtkKeylen, + const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, WILC_Uint8 mode, WILC_Uint8 u8Ciphermode, WILC_Uint8 u8Idx); /** * @brief host_int_get_inactive_time @@ -593,7 +593,7 @@ WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8Ptk, WILC * @date 15 April 2013 * @version 1.0 */ -WILC_Sint32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *mac, WILC_Uint32 *pu32InactiveTime); +WILC_Sint32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, const u8 *mac, WILC_Uint32 *pu32InactiveTime); /** * @brief adds Rx GTk Key @@ -611,9 +611,9 @@ WILC_Sint32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *ma * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8RxGtk, WILC_Uint8 u8GtkKeylen, - WILC_Uint8 u8KeyIdx, WILC_Uint32 u32KeyRSClen, WILC_Uint8 *KeyRSC, - WILC_Uint8 *pu8RxMic, WILC_Uint8 *pu8TxMic, WILC_Uint8 mode, WILC_Uint8 u8Ciphermode); +WILC_Sint32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8RxGtk, WILC_Uint8 u8GtkKeylen, + WILC_Uint8 u8KeyIdx, WILC_Uint32 u32KeyRSClen, const u8 *KeyRSC, + const u8 *pu8RxMic, const u8 *pu8TxMic, WILC_Uint8 mode, WILC_Uint8 u8Ciphermode); /** @@ -836,7 +836,7 @@ WILC_Sint32 host_int_get_start_scan_req(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *p */ WILC_Sint32 host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8bssid, - WILC_Uint8 *pu8ssid, size_t ssidLen, + const u8 *pu8ssid, size_t ssidLen, const WILC_Uint8 *pu8IEs, size_t IEsLen, tWILCpfConnectResult pfConnectResult, void *pvUserArg, WILC_Uint8 u8security, AUTHTYPE_T tenuAuth_type, @@ -1157,7 +1157,7 @@ WILC_Sint32 host_int_del_beacon(WILC_WFIDrvHandle hWFIDrv); WILC_Sint32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrStaParams); /*! - * @fn WILC_Sint32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8* pu8MacAddr) + * @fn WILC_Sint32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, const u8* pu8MacAddr) * @brief Deauthenticates clients when group is terminating * @details * @param[in,out] hWFIDrv handle to the wifi driver @@ -1169,10 +1169,10 @@ WILC_Sint32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam * @date 09 April 2014 * @version 1.0 Description */ -WILC_Sint32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 pu8MacAddr[][ETH_ALEN]); +WILC_Sint32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]); /*! - * @fn WILC_Sint32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8* pu8MacAddr) + * @fn WILC_Sint32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr) * @brief Notifies the firmware with a new deleted station * @details * @param[in,out] hWFIDrv handle to the wifi driver @@ -1184,7 +1184,7 @@ WILC_Sint32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 pu8Mac * @date 15 July 2012 * @version 1.0 Description */ -WILC_Sint32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8MacAddr); +WILC_Sint32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8MacAddr); /*! * @fn WILC_Sint32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam strStaParams) diff --git a/drivers/staging/wilc1000/linux_mon.c b/drivers/staging/wilc1000/linux_mon.c index a19be45b5897..f0a20a98774d 100644 --- a/drivers/staging/wilc1000/linux_mon.c +++ b/drivers/staging/wilc1000/linux_mon.c @@ -522,7 +522,7 @@ static void WILC_WFI_mon_setup(struct net_device *dev) * @date 12 JUL 2012 * @version 1.0 */ -struct net_device *WILC_WFI_init_mon_interface(char *name, struct net_device *real_dev) +struct net_device *WILC_WFI_init_mon_interface(const char *name, struct net_device *real_dev) { diff --git a/drivers/staging/wilc1000/wilc_memory.c b/drivers/staging/wilc1000/wilc_memory.c index fbba38da19bc..f5f4b7acc993 100644 --- a/drivers/staging/wilc1000/wilc_memory.c +++ b/drivers/staging/wilc1000/wilc_memory.c @@ -51,7 +51,7 @@ void *WILC_MemoryRealloc(void *pvOldBlock, WILC_Uint32 u32NewSize, * @date 18 Aug 2010 * @version 1.0 */ -void WILC_MemoryFree(void *pvBlock, tstrWILC_MemoryAttrs *strAttrs, +void WILC_MemoryFree(const void *pvBlock, tstrWILC_MemoryAttrs *strAttrs, WILC_Char *pcFileName, WILC_Uint32 u32LineNo) { kfree(pvBlock); diff --git a/drivers/staging/wilc1000/wilc_memory.h b/drivers/staging/wilc1000/wilc_memory.h index 012f03cae0c8..4038e1f3e30b 100644 --- a/drivers/staging/wilc1000/wilc_memory.h +++ b/drivers/staging/wilc1000/wilc_memory.h @@ -113,7 +113,7 @@ void *WILC_MemoryRealloc(void *pvOldBlock, WILC_Uint32 u32NewSize, * @date 16 Aug 2010 * @version 1.0 */ -void WILC_MemoryFree(void *pvBlock, tstrWILC_MemoryAttrs *strAttrs, +void WILC_MemoryFree(const void *pvBlock, tstrWILC_MemoryAttrs *strAttrs, WILC_Char *pcFileName, WILC_Uint32 u32LineNo); /*! diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index d8ca75cf73f6..e9ab2cb35381 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1159,8 +1159,8 @@ static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 k WILC_Sint32 s32Error = WILC_SUCCESS, KeyLen = params->key_len; WILC_Uint32 i; struct WILC_WFI_priv *priv; - WILC_Uint8 *pu8RxMic = NULL; - WILC_Uint8 *pu8TxMic = NULL; + const u8 *pu8RxMic = NULL; + const u8 *pu8TxMic = NULL; WILC_Uint8 u8mode = NO_ENCRYPT; #ifdef WILC_AP_EXTERNAL_MLME WILC_Uint8 u8gmode = NO_ENCRYPT; @@ -1662,7 +1662,7 @@ static int WILC_WFI_dump_survey(struct wiphy *wiphy, struct net_device *netdev, extern uint32_t Statisitcs_totalAcks, Statisitcs_DroppedAcks; static int WILC_WFI_get_station(struct wiphy *wiphy, struct net_device *dev, - u8 *mac, struct station_info *sinfo) + const u8 *mac, struct station_info *sinfo) { WILC_Sint32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv; @@ -3431,7 +3431,7 @@ static int WILC_WFI_stop_ap(struct wiphy *wiphy, struct net_device *dev) * @version 1.0 */ static int WILC_WFI_add_station(struct wiphy *wiphy, struct net_device *dev, - u8 *mac, struct station_parameters *params) + const u8 *mac, struct station_parameters *params) { WILC_Sint32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv; @@ -3518,7 +3518,7 @@ static int WILC_WFI_add_station(struct wiphy *wiphy, struct net_device *dev, static int WILC_WFI_del_station(struct wiphy *wiphy, struct net_device *dev, struct station_del_parameters *params) { - u8 *mac = params->mac; + const u8 *mac = params->mac; WILC_Sint32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv; perInterface_wlan_t *nic; @@ -3564,7 +3564,7 @@ static int WILC_WFI_del_station(struct wiphy *wiphy, struct net_device *dev, * @version 1.0 */ static int WILC_WFI_change_station(struct wiphy *wiphy, struct net_device *dev, - u8 *mac, struct station_parameters *params) + const u8 *mac, struct station_parameters *params) { WILC_Sint32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv; diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h index 829ba32ea210..f45a15f4650f 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h @@ -118,7 +118,7 @@ int WILC_WFI_DeInitHostInt(struct net_device *net); int WILC_WFI_InitHostInt(struct net_device *net); void WILC_WFI_monitor_rx(uint8_t *buff, uint32_t size); int WILC_WFI_deinit_mon_interface(void); -struct net_device *WILC_WFI_init_mon_interface(char *name, struct net_device *real_dev); +struct net_device *WILC_WFI_init_mon_interface(const char *name, struct net_device *real_dev); #ifdef TCP_ENHANCEMENTS #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54 From 7a8fd84175d245c8ade80404c53f7ed83e03b256 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 1 Jun 2015 21:06:45 +0200 Subject: [PATCH 0779/1163] staging: wilc1000: fix compiler warnings This avoids the remaining warnings that one gets on a normal build: unused variables, unused labels, and invalid printk format strings. Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 8 ++++++-- drivers/staging/wilc1000/linux_wlan_spi.c | 3 --- drivers/staging/wilc1000/wilc_spi.c | 4 ++-- drivers/staging/wilc1000/wilc_wlan.c | 6 ++---- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 2a74441af09e..46c7e4f3471d 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -1025,7 +1025,6 @@ int repeat_power_cycle(perInterface_wlan_t *nic); static int linux_wlan_start_firmware(perInterface_wlan_t *nic) { - static int timeout = 5; int ret = 0; /* start firmware */ PRINT_D(INIT_DBG, "Starting Firmware ...\n"); @@ -1040,6 +1039,7 @@ static int linux_wlan_start_firmware(perInterface_wlan_t *nic) ret = linux_wlan_lock_timeout(&g_linux_wlan->sync_event, 5000); if (ret) { #ifdef COMPLEMENT_BOOT + static int timeout = 5; if (timeout--) { PRINT_D(INIT_DBG, "repeat power cycle[%d]", timeout); @@ -1675,7 +1675,9 @@ _fail_2: linux_wlan_unlock(&g_linux_wlan->rxq_event); kthread_stop(g_linux_wlan->rxq_thread); +#ifndef TCP_ENHANCEMENTS _fail_1: +#endif #if (RX_BH_TYPE == RX_BH_KTHREAD) /*De-Initialize 1st thread*/ g_linux_wlan->close = 1; @@ -1999,8 +2001,8 @@ _fail_fw_start_: _fail_irq_enable_: #if (defined WILC_SDIO) && (!defined WILC_SDIO_IRQ_GPIO) disable_sdio_interrupt(); -#endif _fail_irq_init_: +#endif #if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO) deinit_irq(g_linux_wlan); @@ -2522,8 +2524,10 @@ void frmw_to_linux(uint8_t *buff, uint32_t size, uint32_t pkt_offset) int stats; unsigned char *buff_to_send = NULL; struct sk_buff *skb; +#ifndef TCP_ENHANCEMENTS char *pu8UdpBuffer; struct iphdr *ih; +#endif struct net_device *wilc_netdev; perInterface_wlan_t *nic; diff --git a/drivers/staging/wilc1000/linux_wlan_spi.c b/drivers/staging/wilc1000/linux_wlan_spi.c index 0c30bbb5fa65..e5d794590f00 100644 --- a/drivers/staging/wilc1000/linux_wlan_spi.c +++ b/drivers/staging/wilc1000/linux_wlan_spi.c @@ -102,9 +102,6 @@ int linux_spi_init(void *vp) if (called == 0) { called++; - if (&wilc_bus == NULL) { - PRINT_ER("wilc_bus address is NULL\n"); - } ret = spi_register_driver(&wilc_bus); } diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c index 2f38ddabc654..d0e761080ca5 100644 --- a/drivers/staging/wilc1000/wilc_spi.c +++ b/drivers/staging/wilc1000/wilc_spi.c @@ -1194,10 +1194,10 @@ static int spi_init(wilc_wlan_inp_t *inp, wilc_debug_func func) /* Read failed. Try with CRC off. This might happen when module * is removed but chip isn't reset*/ g_spi.crc_off = 1; - PRINT_ER("[wilc spi]: Failed internal read protocol with CRC on, retyring with CRC off...\n", __LINE__); + PRINT_ER("[wilc spi]: Failed internal read protocol with CRC on, retyring with CRC off...\n"); if (!spi_internal_read(WILC_SPI_PROTOCOL_OFFSET, ®)) { /* Reaad failed with both CRC on and off, something went bad */ - PRINT_ER("[wilc spi]: Failed internal read protocol...\n", __LINE__); + PRINT_ER("[wilc spi]: Failed internal read protocol...\n"); return 0; } } diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index 92ed42ad49ac..badc8743dd1a 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -894,8 +894,6 @@ INLINE void chip_wakeup(void) #endif void chip_sleep_manually(WILC_Uint32 u32SleepTime) { - uint32_t val32; - if (genuChipPSstate != CHIP_WAKEDUP) { /* chip is already sleeping. Do nothing */ return; @@ -2302,7 +2300,7 @@ int wilc_wlan_init(wilc_wlan_inp_t *inp, wilc_wlan_oup_t *oup) #else g_wlan.tx_buffer = (uint8_t *)g_wlan.os_func.os_malloc(g_wlan.tx_buffer_size); #endif - PRINT_D(TX_DBG, "g_wlan.tx_buffer = 0x%x\n", g_wlan.tx_buffer); + PRINT_D(TX_DBG, "g_wlan.tx_buffer = %p\n", g_wlan.tx_buffer); if (g_wlan.tx_buffer == WILC_NULL) { /* ENOBUFS 105 */ @@ -2319,7 +2317,7 @@ int wilc_wlan_init(wilc_wlan_inp_t *inp, wilc_wlan_oup_t *oup) #else g_wlan.rx_buffer = (uint8_t *)g_wlan.os_func.os_malloc(g_wlan.rx_buffer_size); #endif - PRINT_D(TX_DBG, "g_wlan.rx_buffer =0x%x\n", g_wlan.rx_buffer); + PRINT_D(TX_DBG, "g_wlan.rx_buffer =%p\n", g_wlan.rx_buffer); if (g_wlan.rx_buffer == WILC_NULL) { /* ENOBUFS 105 */ ret = -105; From 0b85618f3a02994b721975508ec86c185d61a736 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 1 Jun 2015 21:20:11 +0200 Subject: [PATCH 0780/1163] staging: wilc1000: update TODO list I have crossed off one item on the list, but found a few others that should not get lost, so here is an update of the wilc1000 list Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/TODO | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/staging/wilc1000/TODO b/drivers/staging/wilc1000/TODO index 5dfeb3eda599..95199d80a3e4 100644 --- a/drivers/staging/wilc1000/TODO +++ b/drivers/staging/wilc1000/TODO @@ -3,6 +3,12 @@ TODO: - remove OS wrapper functions - remove custom debug and tracing functions - rework comments and function headers(also coding style) -- remove build warnings +- replace all semaphores with mutexes or completions +- make spi and sdio components coexist in one build +- turn compile-time platform configuration (BEAGLE_BOARD, + PANDA_BOARD, PLAT_WMS8304, PLAT_RKXXXX, CUSTOMER_PLATFORM, ...) + into run-time options that are read from DT - support soft-ap and p2p mode - support resume/suspend function +- replace SIOCDEVPRIVATE commands with generic API functions +- use wext-core handling instead of private SIOCSIWPRIV implementation From 8e1d4e5cf25c2901e8d3f322f1eab17ba193c094 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 2 Jun 2015 14:03:03 +0900 Subject: [PATCH 0781/1163] staging: wilc1000: remove unused data types There's some "custom" data types defined that are never used in the driver, so remove them before we work on converting the rest to be "standard" data types. Cc: Johnny Kim Cc: Rachel Kim Cc: Dean Lee Cc: Chris Park Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_oswrapper.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index 7375ec44cc42..a2ccf43a4a96 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -23,10 +23,6 @@ typedef signed short WILC_Sint16; typedef signed int WILC_Sint32; typedef signed long long WILC_Sint64; -/* Floating types */ -typedef float WILC_Float; -typedef double WILC_Double; - /* Boolean type */ typedef enum { WILC_FALSE = 0, @@ -35,15 +31,9 @@ typedef enum { /* Character types */ typedef char WILC_Char; -typedef WILC_Uint16 WILC_WideChar; -#define WILC_OS_INFINITY (~((WILC_Uint32)0)) #define WILC_NULL ((void *)0) -/* standard min and max macros */ -#define WILC_MIN(a, b) (((a) < (b)) ? (a) : (b)) -#define WILC_MAX(a, b) (((a) > (b)) ? (a) : (b)) - /* Os Configuration File */ #include "wilc_osconfig.h" #include "wilc_platform.h" From b1413b6084faa677bc122549aba50e38e11343d3 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 2 Jun 2015 14:11:12 +0900 Subject: [PATCH 0782/1163] staging: wilc100: remove WILC_NULL usage Use the "real" NULL value, don't try to be cute and define your own value for something that the compiler obviously supports. Cc: Johnny Kim Cc: Rachel Kim Cc: Dean Lee Cc: Chris Park Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 22 +- drivers/staging/wilc1000/host_interface.c | 298 +++++++++--------- drivers/staging/wilc1000/linux_wlan.c | 2 +- drivers/staging/wilc1000/wilc_errorsupport.h | 2 +- drivers/staging/wilc1000/wilc_memory.c | 6 +- drivers/staging/wilc1000/wilc_memory.h | 30 +- drivers/staging/wilc1000/wilc_oswrapper.h | 2 - drivers/staging/wilc1000/wilc_strutils.c | 6 +- drivers/staging/wilc1000/wilc_strutils.h | 6 +- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 46 +-- drivers/staging/wilc1000/wilc_wlan.c | 16 +- 11 files changed, 217 insertions(+), 219 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index bf444825711f..832230a51b02 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -771,7 +771,7 @@ WILC_Uint8 get_current_channel(WILC_Uint8 *pu8msa, WILC_Uint16 u16RxLen) WILC_Sint32 ParseNetworkInfo(WILC_Uint8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo) { WILC_Sint32 s32Error = WILC_SUCCESS; - tstrNetworkInfo *pstrNetworkInfo = WILC_NULL; + tstrNetworkInfo *pstrNetworkInfo = NULL; WILC_Uint8 u8MsgType = 0; WILC_Uint8 u8MsgID = 0; WILC_Uint16 u16MsgLen = 0; @@ -894,16 +894,16 @@ WILC_Sint32 DeallocateNetworkInfo(tstrNetworkInfo *pstrNetworkInfo) { WILC_Sint32 s32Error = WILC_SUCCESS; - if (pstrNetworkInfo != WILC_NULL) { - if (pstrNetworkInfo->pu8IEs != WILC_NULL) { + if (pstrNetworkInfo != NULL) { + if (pstrNetworkInfo->pu8IEs != NULL) { WILC_FREE(pstrNetworkInfo->pu8IEs); - pstrNetworkInfo->pu8IEs = WILC_NULL; + pstrNetworkInfo->pu8IEs = NULL; } else { s32Error = WILC_FAIL; } WILC_FREE(pstrNetworkInfo); - pstrNetworkInfo = WILC_NULL; + pstrNetworkInfo = NULL; } else { s32Error = WILC_FAIL; @@ -927,7 +927,7 @@ WILC_Sint32 ParseAssocRespInfo(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32BufferLen, tstrConnectRespInfo **ppstrConnectRespInfo) { WILC_Sint32 s32Error = WILC_SUCCESS; - tstrConnectRespInfo *pstrConnectRespInfo = WILC_NULL; + tstrConnectRespInfo *pstrConnectRespInfo = NULL; WILC_Uint16 u16AssocRespLen = 0; WILC_Uint8 *pu8IEs = 0; WILC_Uint16 u16IEsLen = 0; @@ -979,16 +979,16 @@ WILC_Sint32 DeallocateAssocRespInfo(tstrConnectRespInfo *pstrConnectRespInfo) { WILC_Sint32 s32Error = WILC_SUCCESS; - if (pstrConnectRespInfo != WILC_NULL) { - if (pstrConnectRespInfo->pu8RespIEs != WILC_NULL) { + if (pstrConnectRespInfo != NULL) { + if (pstrConnectRespInfo->pu8RespIEs != NULL) { WILC_FREE(pstrConnectRespInfo->pu8RespIEs); - pstrConnectRespInfo->pu8RespIEs = WILC_NULL; + pstrConnectRespInfo->pu8RespIEs = NULL; } else { s32Error = WILC_FAIL; } WILC_FREE(pstrConnectRespInfo); - pstrConnectRespInfo = WILC_NULL; + pstrConnectRespInfo = NULL; } else { s32Error = WILC_FAIL; @@ -1060,7 +1060,7 @@ WILC_Sint32 DeallocateSurveyResults(wid_site_survey_reslts_s *pstrSurveyResults) { WILC_Sint32 s32Error = WILC_SUCCESS; - if (pstrSurveyResults != WILC_NULL) { + if (pstrSurveyResults != NULL) { WILC_FREE(pstrSurveyResults); } diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 6d9bd4983e90..462bb10e930b 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -537,8 +537,8 @@ typedef enum { /*****************************************************************************/ -tstrWILC_WFIDrv *terminated_handle = WILC_NULL; -tstrWILC_WFIDrv *gWFiDrvHandle = WILC_NULL; +tstrWILC_WFIDrv *terminated_handle = NULL; +tstrWILC_WFIDrv *gWFiDrvHandle = NULL; #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP WILC_Bool g_obtainingIP = WILC_FALSE; #endif @@ -1299,7 +1299,7 @@ static WILC_Sint32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFs } pu8HdnNtwrksWidVal = WILC_MALLOC(valuesize + 1); strWIDList[u32WidsCount].ps8WidVal = pu8HdnNtwrksWidVal; - if (strWIDList[u32WidsCount].ps8WidVal != WILC_NULL) { + if (strWIDList[u32WidsCount].ps8WidVal != NULL) { pu8Buffer = strWIDList[u32WidsCount].ps8WidVal; *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; @@ -1383,7 +1383,7 @@ static WILC_Sint32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFs WILC_CATCH(s32Error) { - WILC_TimerStop(&(pstrWFIDrv->hScanTimer), WILC_NULL); + WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL); /*if there is an ongoing scan request*/ Handle_ScanDone(drvHandler, SCAN_EVENT_ABORTED); } @@ -1467,7 +1467,7 @@ static WILC_Sint32 Handle_ScanDone(void *drvHandler, tenuScanEvent enuEvent) /*if there is an ongoing scan request*/ if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) { - pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, WILC_NULL, + pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL, pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL); /*delete current scan request*/ pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL; @@ -1497,9 +1497,9 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH WILC_Sint32 s32Err = WILC_SUCCESS; WILC_Uint32 i; WILC_Uint8 u8bssDscListIndex; - wid_site_survey_reslts_s *pstrSurveyResults = WILC_NULL; + wid_site_survey_reslts_s *pstrSurveyResults = NULL; #else - WILC_Uint8 *pu8CurrByte = WILC_NULL; + WILC_Uint8 *pu8CurrByte = NULL; /*Bug4218: Parsing Join Param*/ #ifdef WILC_PARSE_SCAN_IN_HOST tstrJoinBssParam *ptstrJoinBssParam; @@ -1799,7 +1799,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH strWIDList[u32WidsCount].s32ValueSize = MAX_SSID_LEN + 7; strWIDList[u32WidsCount].ps8WidVal = WILC_MALLOC(strWIDList[u32WidsCount].s32ValueSize); - if (strWIDList[u32WidsCount].ps8WidVal == WILC_NULL) { + if (strWIDList[u32WidsCount].ps8WidVal == NULL) { WILC_ERRORREPORT(s32Error, WILC_NO_MEM); } @@ -1838,7 +1838,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH gu32FlushedJoinReqSize = strWIDList[u32WidsCount].s32ValueSize; gu8FlushedJoinReq = WILC_MALLOC(gu32FlushedJoinReqSize); } - if (strWIDList[u32WidsCount].ps8WidVal == WILC_NULL) { + if (strWIDList[u32WidsCount].ps8WidVal == NULL) { WILC_ERRORREPORT(s32Error, WILC_NO_MEM); } @@ -2004,7 +2004,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH { tstrConnectInfo strConnectInfo; - WILC_TimerStop(&(pstrWFIDrv->hConnectTimer), WILC_NULL); + WILC_TimerStop(&(pstrWFIDrv->hConnectTimer), NULL); PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n"); @@ -2060,7 +2060,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH pstrHostIFconnectAttr->pu8IEs = NULL; } - if (pu8CurrByte != WILC_NULL) { + if (pu8CurrByte != NULL) { WILC_FREE(pu8CurrByte); } return s32Error; @@ -2082,7 +2082,7 @@ static WILC_Sint32 Handle_FlushConnect(void *drvHandler) WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWIDList[5]; WILC_Uint32 u32WidsCount = 0; - WILC_Uint8 *pu8CurrByte = WILC_NULL; + WILC_Uint8 *pu8CurrByte = NULL; /* IEs to be inserted in Association Request */ @@ -2276,7 +2276,7 @@ static WILC_Sint32 Handle_RcvdNtwrkInfo(void *drvHandler, tstrRcvdNetworkInfo *p PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n"); ParseNetworkInfo(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo); if ((pstrNetworkInfo == NULL) - || (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult == WILC_NULL)) { + || (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult == NULL)) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -2358,9 +2358,9 @@ done: } /*free structure allocated*/ - if (pstrNetworkInfo != WILC_NULL) { + if (pstrNetworkInfo != NULL) { DeallocateNetworkInfo(pstrNetworkInfo); - pstrNetworkInfo = WILC_NULL; + pstrNetworkInfo = NULL; } return s32Error; @@ -2402,7 +2402,7 @@ static WILC_Sint32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncI (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) || pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) { if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) || - (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == WILC_NULL)) { + (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -2518,7 +2518,7 @@ static WILC_Sint32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncI } - WILC_TimerStop(&(pstrWFIDrv->hConnectTimer), WILC_NULL); + WILC_TimerStop(&(pstrWFIDrv->hConnectTimer), NULL); pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP, &strConnectInfo, u8MacStatus, @@ -2542,7 +2542,7 @@ static WILC_Sint32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncI #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n"); g_obtainingIP = WILC_TRUE; - WILC_TimerStart(&hDuringIpTimer, 10000, WILC_NULL, WILC_NULL); + WILC_TimerStart(&hDuringIpTimer, 10000, NULL, NULL); #endif #ifdef WILC_PARSE_SCAN_IN_HOST @@ -2597,7 +2597,7 @@ static WILC_Sint32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncI if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) { PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >> \n\n"); - WILC_TimerStop(&(pstrWFIDrv->hScanTimer), WILC_NULL); + WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL); Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED); } @@ -2674,7 +2674,7 @@ static WILC_Sint32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncI PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n"); PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >> \n\n"); /*Abort the running scan*/ - WILC_TimerStop(&(pstrWFIDrv->hScanTimer), WILC_NULL); + WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL); if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) { Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED); @@ -3110,11 +3110,11 @@ static void Handle_Disconnect(void *drvHandler) strDisconnectNotifInfo.ie_len = 0; if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) { - WILC_TimerStop(&(pstrWFIDrv->hScanTimer), WILC_NULL); - pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, WILC_NULL, + WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL); + pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL, pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL); - pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = WILC_NULL; + pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL; } if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) { @@ -3123,7 +3123,7 @@ static void Handle_Disconnect(void *drvHandler) /*Stop connect timer, if connection in progress*/ if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) { PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n"); - WILC_TimerStop(&(pstrWFIDrv->hConnectTimer), WILC_NULL); + WILC_TimerStop(&(pstrWFIDrv->hConnectTimer), NULL); } pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL, @@ -3187,7 +3187,7 @@ void resolve_disconnect_aberration(void *drvHandler) tstrWILC_WFIDrv *pstrWFIDrv; pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; - if (pstrWFIDrv == WILC_NULL) + if (pstrWFIDrv == NULL) return; if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTING)) { PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n"); @@ -3879,7 +3879,7 @@ static int Handle_RemainOnChan(void *drvHandler, tstrHostIfRemainOnChan *pstrHos strWID.s32ValueSize = 2; strWID.ps8WidVal = (WILC_Sint8 *)WILC_MALLOC(strWID.s32ValueSize); - if (strWID.ps8WidVal == WILC_NULL) { + if (strWID.ps8WidVal == NULL) { WILC_ERRORREPORT(s32Error, WILC_NO_MEM); } @@ -3895,7 +3895,7 @@ static int Handle_RemainOnChan(void *drvHandler, tstrHostIfRemainOnChan *pstrHos WILC_CATCH(-1) { P2P_LISTEN_STATE = 1; - WILC_TimerStart(&(pstrWFIDrv->hRemainOnChannel), pstrHostIfRemainOnChan->u32duration, (void *)pstrWFIDrv, WILC_NULL); + WILC_TimerStart(&(pstrWFIDrv->hRemainOnChannel), pstrHostIfRemainOnChan->u32duration, (void *)pstrWFIDrv, NULL); /*Calling CFG ready_on_channel*/ if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady) { @@ -3989,7 +3989,7 @@ static WILC_Uint32 Handle_ListenStateExpired(void *drvHandler, tstrHostIfRemainO strWID.s32ValueSize = 2; strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize); - if (strWID.ps8WidVal == WILC_NULL) { + if (strWID.ps8WidVal == NULL) { PRINT_ER("Failed to allocate memory\n"); } @@ -4033,7 +4033,7 @@ static void ListenTimerCB(void *pvArg) tstrHostIFmsg strHostIFmsg; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)pvArg; /*Stopping remain-on-channel timer*/ - WILC_TimerStop(&(pstrWFIDrv->hRemainOnChannel), WILC_NULL); + WILC_TimerStop(&(pstrWFIDrv->hRemainOnChannel), NULL); /* prepare the Timer Callback message */ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); @@ -4042,7 +4042,7 @@ static void ListenTimerCB(void *pvArg) strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID; /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { WILC_ERRORREPORT(s32Error, s32Error); } @@ -4379,7 +4379,7 @@ static int hostIFthread(void *pvArg) WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); while (1) { - WILC_MsgQueueRecv(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), &u32Ret, WILC_NULL); + WILC_MsgQueueRecv(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), &u32Ret, NULL); pstrWFIDrv = (tstrWILC_WFIDrv *)strHostIFmsg.drvHandler; if (strHostIFmsg.u16MsgId == HOST_IF_MSG_EXIT) { PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n"); @@ -4391,13 +4391,13 @@ static int hostIFthread(void *pvArg) if ((!g_wilc_initialized)) { PRINT_D(GENERIC_DBG, "--WAIT--"); WILC_Sleep(200); - WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); continue; } if (strHostIFmsg.u16MsgId == HOST_IF_MSG_CONNECT && pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) { PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n"); - WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); WILC_Sleep(2); continue; } @@ -4446,7 +4446,7 @@ static int hostIFthread(void *pvArg) break; case HOST_IF_MSG_RCVD_SCAN_COMPLETE: - WILC_TimerStop(&(pstrWFIDrv->hScanTimer), WILC_NULL); + WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL); PRINT_D(HOSTINF_DBG, "scan completed successfully\n"); /*BugID_5213*/ @@ -4604,7 +4604,7 @@ static void TimerCB_Scan(void *pvArg) strHostIFmsg.u16MsgId = HOST_IF_MSG_SCAN_TIMER_FIRED; /* send the message */ - WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); } static void TimerCB_Connect(void *pvArg) @@ -4617,7 +4617,7 @@ static void TimerCB_Connect(void *pvArg) strHostIFmsg.u16MsgId = HOST_IF_MSG_CONNECT_TIMER_FIRED; /* send the message */ - WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); } @@ -4670,7 +4670,7 @@ WILC_Sint32 host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8keyI tstrHostIFmsg strHostIFmsg; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -4689,7 +4689,7 @@ WILC_Sint32 host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8keyI uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8keyIdx; /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) PRINT_ER("Error in sending message queue : Request to remove WEP key \n"); down(&(pstrWFIDrv->hSemTestKeyBlock)); @@ -4720,7 +4720,7 @@ WILC_Sint32 host_int_set_WEPDefaultKeyID(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u tstrHostIFmsg strHostIFmsg; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -4738,7 +4738,7 @@ WILC_Sint32 host_int_set_WEPDefaultKeyID(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Index; /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) PRINT_ER("Error in sending message queue : Default key index\n"); down(&(pstrWFIDrv->hSemTestKeyBlock)); @@ -4777,7 +4777,7 @@ WILC_Sint32 host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv, const WILC_U tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -4806,7 +4806,7 @@ WILC_Sint32 host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv, const WILC_U uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx; /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) PRINT_ER("Error in sending message queue :WEP Key\n"); down(&(pstrWFIDrv->hSemTestKeyBlock)); @@ -4844,7 +4844,7 @@ WILC_Sint32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const WILC_Ui tstrHostIFmsg strHostIFmsg; WILC_Uint8 i; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -4882,7 +4882,7 @@ WILC_Sint32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const WILC_Ui strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type = tenuAuth_type; /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) PRINT_ER("Error in sending message queue :WEP Key\n"); @@ -4920,7 +4920,7 @@ WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8Ptk, WILC_U tstrHostIFmsg strHostIFmsg; WILC_Uint8 u8KeyLen = u8PtkKeylen; WILC_Uint32 i; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } if (pu8RxMic != NULL) { @@ -4983,7 +4983,7 @@ WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8Ptk, WILC_U strHostIFmsg.drvHandler = hWFIDrv; /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) PRINT_ER("Error in sending message queue: PTK Key\n"); @@ -5023,7 +5023,7 @@ WILC_Sint32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8RxGtk, W tstrHostIFmsg strHostIFmsg; WILC_Uint8 u8KeyLen = u8GtkKeylen; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } /* prepare the Key Message */ @@ -5089,7 +5089,7 @@ WILC_Sint32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8RxGtk, W /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) PRINT_ER("Error in sending message queue: RX GTK\n"); /* ////////////// */ @@ -5126,7 +5126,7 @@ WILC_Sint32 host_int_add_tx_gtk(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8KeyLen, tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -5146,7 +5146,7 @@ WILC_Sint32 host_int_add_tx_gtk(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8KeyLen, strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen; /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) PRINT_ER("Error in sending message queue: TX GTK\n"); @@ -5190,7 +5190,7 @@ WILC_Sint32 host_int_set_pmkid_info(WILC_WFIDrvHandle hWFIDrv, tstrHostIFpmkidAt WILC_Uint32 i; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -5212,7 +5212,7 @@ WILC_Sint32 host_int_set_pmkid_info(WILC_WFIDrvHandle hWFIDrv, tstrHostIFpmkidAt } /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) PRINT_ER(" Error in sending messagequeue: PMKID Info\n"); @@ -5316,7 +5316,7 @@ WILC_Sint32 host_int_get_MacAddress(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8Ma strHostIFmsg.uniHostIFmsgBody.strHostIfGetMacAddress.u8MacAddress = pu8MacAddress; strHostIFmsg.drvHandler = hWFIDrv; /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { PRINT_ER("Failed to send get mac address\n"); return WILC_FAIL; @@ -5350,7 +5350,7 @@ WILC_Sint32 host_int_set_MacAddress(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8Ma WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIfSetMacAddress.u8MacAddress, pu8MacAddress, ETH_ALEN); strHostIFmsg.drvHandler = hWFIDrv; - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { PRINT_ER("Failed to send message queue: Set mac address\n"); WILC_ERRORREPORT(s32Error, s32Error); @@ -5543,7 +5543,7 @@ WILC_Sint32 host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8bssi tstrHostIFmsg strHostIFmsg; tenuScanConnTimer enuScanConnTimer; - if (pstrWFIDrv == WILC_NULL || pfConnectResult == WILC_NULL) { + if (pstrWFIDrv == NULL || pfConnectResult == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -5603,14 +5603,14 @@ WILC_Sint32 host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8bssi PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv->enuHostIFstate); /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { PRINT_ER("Failed to send message queue: Set join request\n"); WILC_ERRORREPORT(s32Error, WILC_FAIL); } enuScanConnTimer = CONNECT_TIMER; - WILC_TimerStart(&(pstrWFIDrv->hConnectTimer), HOST_IF_CONNECT_TIMEOUT, (void *) hWFIDrv, WILC_NULL); + WILC_TimerStart(&(pstrWFIDrv->hConnectTimer), HOST_IF_CONNECT_TIMEOUT, (void *) hWFIDrv, NULL); WILC_CATCH(s32Error) { @@ -5643,7 +5643,7 @@ WILC_Sint32 host_int_flush_join_req(WILC_WFIDrvHandle hWFIDrv) } - if (hWFIDrv == WILC_NULL) { + if (hWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -5652,7 +5652,7 @@ WILC_Sint32 host_int_flush_join_req(WILC_WFIDrvHandle hWFIDrv) strHostIFmsg.drvHandler = hWFIDrv; /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { PRINT_ER("Failed to send message queue: Flush join request\n"); WILC_ERRORREPORT(s32Error, WILC_FAIL); @@ -5682,7 +5682,7 @@ WILC_Sint32 host_int_disconnect(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16Reason tstrHostIFmsg strHostIFmsg; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n"); WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -5699,7 +5699,7 @@ WILC_Sint32 host_int_disconnect(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16Reason strHostIFmsg.drvHandler = hWFIDrv; /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) PRINT_ER("Failed to send message queue: disconnect\n"); /* ////////////// */ @@ -5799,7 +5799,7 @@ WILC_Sint32 host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *p tstrWID strWID; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n"); WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -5879,7 +5879,7 @@ WILC_Sint32 host_int_set_mac_chnl_num(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8Ch tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -5889,7 +5889,7 @@ WILC_Sint32 host_int_set_mac_chnl_num(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8Ch strHostIFmsg.uniHostIFmsgBody.strHostIFSetChan.u8SetChan = u8ChNum; strHostIFmsg.drvHandler = hWFIDrv; - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { WILC_ERRORREPORT(s32Error, s32Error); } @@ -5912,7 +5912,7 @@ WILC_Sint32 host_int_wait_msg_queue_idle(void) WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); strHostIFmsg.u16MsgId = HOST_IF_MSG_Q_IDLE; - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { WILC_ERRORREPORT(s32Error, s32Error); } @@ -5942,7 +5942,7 @@ WILC_Sint32 host_int_set_wfi_drv_handler(WILC_Uint32 u32address) strHostIFmsg.uniHostIFmsgBody.strHostIfSetDrvHandler.u32Address = u32address; /* strHostIFmsg.drvHandler=hWFIDrv; */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { WILC_ERRORREPORT(s32Error, s32Error); } @@ -5970,7 +5970,7 @@ WILC_Sint32 host_int_set_operation_mode(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u strHostIFmsg.uniHostIFmsgBody.strHostIfSetOperationMode.u32Mode = u32mode; strHostIFmsg.drvHandler = hWFIDrv; - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { WILC_ERRORREPORT(s32Error, s32Error); } @@ -6003,7 +6003,7 @@ WILC_Sint32 host_int_get_host_chnl_num(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n"); WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -6015,7 +6015,7 @@ WILC_Sint32 host_int_get_host_chnl_num(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu strHostIFmsg.drvHandler = hWFIDrv; /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) PRINT_ER("Failed to send get host channel param's message queue "); down(&(pstrWFIDrv->hSemGetCHNL)); @@ -6050,7 +6050,7 @@ WILC_Sint32 host_int_test_set_int_wid(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n"); WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -6096,7 +6096,7 @@ WILC_Sint32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, const u8 *mac, tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n"); WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -6111,7 +6111,7 @@ WILC_Sint32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, const u8 *mac, strHostIFmsg.drvHandler = hWFIDrv; /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) PRINT_ER("Failed to send get host channel param's message queue "); @@ -6144,7 +6144,7 @@ WILC_Sint32 host_int_test_get_int_wid(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 *pu tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n"); WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -6199,7 +6199,7 @@ WILC_Sint32 host_int_get_rssi(WILC_WFIDrvHandle hWFIDrv, WILC_Sint8 *ps8Rssi) strHostIFmsg.drvHandler = hWFIDrv; /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { PRINT_ER("Failed to send get host channel param's message queue "); return WILC_FAIL; @@ -6236,7 +6236,7 @@ WILC_Sint32 host_int_get_link_speed(WILC_WFIDrvHandle hWFIDrv, WILC_Sint8 *ps8ln strHostIFmsg.drvHandler = hWFIDrv; /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { PRINT_ER("Failed to send GET_LINKSPEED to message queue "); return WILC_FAIL; @@ -6270,7 +6270,7 @@ WILC_Sint32 host_int_get_statistics(WILC_WFIDrvHandle hWFIDrv, tstrStatistics *p strHostIFmsg.uniHostIFmsgBody.pUserData = (WILC_Char *)pstrStatistics; strHostIFmsg.drvHandler = hWFIDrv; /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { PRINT_ER("Failed to send get host channel param's message queue "); return WILC_FAIL; @@ -6308,7 +6308,7 @@ WILC_Sint32 host_int_scan(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8ScanSource, tstrHostIFmsg strHostIFmsg; tenuScanConnTimer enuScanConnTimer; - if (pstrWFIDrv == WILC_NULL || ScanResult == WILC_NULL) { + if (pstrWFIDrv == NULL || ScanResult == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -6342,7 +6342,7 @@ WILC_Sint32 host_int_scan(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8ScanSource, pu8IEs, IEsLen); /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { PRINT_ER("Error in sending message queue scanning parameters: Error(%d)\n", s32Error); WILC_ERRORREPORT(s32Error, WILC_FAIL); @@ -6350,7 +6350,7 @@ WILC_Sint32 host_int_scan(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8ScanSource, enuScanConnTimer = SCAN_TIMER; PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n"); - WILC_TimerStart(&(pstrWFIDrv->hScanTimer), HOST_IF_SCAN_TIMEOUT, (void *) hWFIDrv, WILC_NULL); + WILC_TimerStart(&(pstrWFIDrv->hScanTimer), HOST_IF_SCAN_TIMEOUT, (void *) hWFIDrv, NULL); WILC_CATCH(s32Error) @@ -6380,7 +6380,7 @@ WILC_Sint32 hif_set_cfg(WILC_WFIDrvHandle hWFIDrv, tstrCfgParamVal *pstrCfgParam tstrHostIFmsg strHostIFmsg; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } /* prepare the WiphyParams Message */ @@ -6389,7 +6389,7 @@ WILC_Sint32 hif_set_cfg(WILC_WFIDrvHandle hWFIDrv, tstrCfgParamVal *pstrCfgParam strHostIFmsg.uniHostIFmsgBody.strHostIFCfgParamAttr.pstrCfgParamVal = *pstrCfgParamVal; strHostIFmsg.drvHandler = hWFIDrv; - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); WILC_CATCH(s32Error) { @@ -6420,7 +6420,7 @@ WILC_Sint32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16WID, WILC_Uint down(&(pstrWFIDrv->gtOsCfgValuesSem)); - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n"); WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -6567,7 +6567,7 @@ void GetPeriodicRSSI(void *pvArg) strHostIFmsg.drvHandler = pstrWFIDrv; /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { PRINT_ER("Failed to send get host channel param's message queue "); return; @@ -6615,7 +6615,7 @@ WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) /*Allocate host interface private structure*/ pstrWFIDrv = (tstrWILC_WFIDrv *)WILC_MALLOC(sizeof(tstrWILC_WFIDrv)); - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { /* WILC_ERRORREPORT(s32Error,WILC_NO_MEM); */ s32Error = WILC_NO_MEM; PRINT_ER("Failed to allocate memory\n"); @@ -6655,7 +6655,7 @@ WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) if (clients_count == 0) { - s32Error = WILC_MsgQueueCreate(&gMsgQHostIF, WILC_NULL); + s32Error = WILC_MsgQueueCreate(&gMsgQHostIF, NULL); if (s32Error < 0) { @@ -6669,7 +6669,7 @@ WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) s32Error = WILC_FAIL; goto _fail_mq_; } - s32Error = WILC_TimerCreate(&(g_hPeriodicRSSI), GetPeriodicRSSI, WILC_NULL); + s32Error = WILC_TimerCreate(&(g_hPeriodicRSSI), GetPeriodicRSSI, NULL); if (s32Error < 0) { PRINT_ER("Failed to creat Timer\n"); goto _fail_timer_1; @@ -6679,13 +6679,13 @@ WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) } - s32Error = WILC_TimerCreate(&(pstrWFIDrv->hScanTimer), TimerCB_Scan, WILC_NULL); + s32Error = WILC_TimerCreate(&(pstrWFIDrv->hScanTimer), TimerCB_Scan, NULL); if (s32Error < 0) { PRINT_ER("Failed to creat Timer\n"); goto _fail_thread_; } - s32Error = WILC_TimerCreate(&(pstrWFIDrv->hConnectTimer), TimerCB_Connect, WILC_NULL); + s32Error = WILC_TimerCreate(&(pstrWFIDrv->hConnectTimer), TimerCB_Connect, NULL); if (s32Error < 0) { PRINT_ER("Failed to creat Timer\n"); goto _fail_timer_1; @@ -6694,7 +6694,7 @@ WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) #ifdef WILC_P2P /*Remain on channel timer*/ - s32Error = WILC_TimerCreate(&(pstrWFIDrv->hRemainOnChannel), ListenTimerCB, WILC_NULL); + s32Error = WILC_TimerCreate(&(pstrWFIDrv->hRemainOnChannel), ListenTimerCB, NULL); if (s32Error < 0) { PRINT_ER("Failed to creat Remain-on-channel Timer\n"); goto _fail_timer_3; @@ -6757,21 +6757,21 @@ WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) _fail_mem_: - if (pstrWFIDrv != WILC_NULL) + if (pstrWFIDrv != NULL) WILC_FREE(pstrWFIDrv); #ifdef WILC_P2P _fail_timer_3: - WILC_TimerDestroy(&(pstrWFIDrv->hRemainOnChannel), WILC_NULL); + WILC_TimerDestroy(&(pstrWFIDrv->hRemainOnChannel), NULL); #endif _fail_timer_2: up(&(pstrWFIDrv->gtOsCfgValuesSem)); - WILC_TimerDestroy(&(pstrWFIDrv->hConnectTimer), WILC_NULL); + WILC_TimerDestroy(&(pstrWFIDrv->hConnectTimer), NULL); _fail_timer_1: - WILC_TimerDestroy(&(pstrWFIDrv->hScanTimer), WILC_NULL); + WILC_TimerDestroy(&(pstrWFIDrv->hScanTimer), NULL); _fail_thread_: kthread_stop(HostIFthreadHandler); _fail_mq_: - WILC_MsgQueueDestroy(&gMsgQHostIF, WILC_NULL); + WILC_MsgQueueDestroy(&gMsgQHostIF, NULL); _fail_: return s32Error; @@ -6816,37 +6816,37 @@ WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv) /*BugID_5348*/ /*Destroy all timers before acquiring hSemDeinitDrvHandle*/ /*to guarantee handling all messages befor proceeding*/ - if (WILC_TimerDestroy(&(pstrWFIDrv->hScanTimer), WILC_NULL)) { + if (WILC_TimerDestroy(&(pstrWFIDrv->hScanTimer), NULL)) { PRINT_D(HOSTINF_DBG, ">> Scan timer is active \n"); /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */ } - if (WILC_TimerDestroy(&(pstrWFIDrv->hConnectTimer), WILC_NULL)) { + if (WILC_TimerDestroy(&(pstrWFIDrv->hConnectTimer), NULL)) { PRINT_D(HOSTINF_DBG, ">> Connect timer is active \n"); /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */ } - if (WILC_TimerDestroy(&(g_hPeriodicRSSI), WILC_NULL)) { + if (WILC_TimerDestroy(&(g_hPeriodicRSSI), NULL)) { PRINT_D(HOSTINF_DBG, ">> Connect timer is active \n"); /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */ } #ifdef WILC_P2P /*Destroy Remain-onchannel Timer*/ - WILC_TimerDestroy(&(pstrWFIDrv->hRemainOnChannel), WILC_NULL); + WILC_TimerDestroy(&(pstrWFIDrv->hRemainOnChannel), NULL); #endif - host_int_set_wfi_drv_handler((WILC_Uint32)WILC_NULL); + host_int_set_wfi_drv_handler((WILC_Uint32)NULL); down(&hSemDeinitDrvHandle); /*Calling the CFG80211 scan done function with the abort flag set to true*/ if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) { - pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, WILC_NULL, + pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL, pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL); - pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = WILC_NULL; + pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL; } /*deinit configurator and simulator*/ #ifdef SIMULATION @@ -6864,7 +6864,7 @@ WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv) WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); if (clients_count == 1) { - if (WILC_TimerDestroy(&g_hPeriodicRSSI, WILC_NULL)) { + if (WILC_TimerDestroy(&g_hPeriodicRSSI, NULL)) { PRINT_D(HOSTINF_DBG, ">> Connect timer is active \n"); /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */ } @@ -6872,7 +6872,7 @@ WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv) strHostIFmsg.drvHandler = hWFIDrv; - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error != WILC_SUCCESS) { PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error); } @@ -6881,7 +6881,7 @@ WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv) - WILC_MsgQueueDestroy(&gMsgQHostIF, WILC_NULL); + WILC_MsgQueueDestroy(&gMsgQHostIF, NULL); msgQ_created = 0; } @@ -6890,14 +6890,14 @@ WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv) /*Setting the gloabl driver handler with NULL*/ u32Intialized = 0; /* gWFiDrvHandle = NULL; */ - if (pstrWFIDrv != WILC_NULL) { + if (pstrWFIDrv != NULL) { WILC_FREE(pstrWFIDrv); - /* pstrWFIDrv=WILC_NULL; */ + /* pstrWFIDrv=NULL; */ } clients_count--; /* Decrease number of created entities */ - terminated_handle = WILC_NULL; + terminated_handle = NULL; up(&hSemHostIntDeinit); return s32Error; } @@ -6919,7 +6919,7 @@ void NetworkInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) WILC_Sint32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; WILC_Uint32 drvHandler; - tstrWILC_WFIDrv *pstrWFIDrv = WILC_NULL; + tstrWILC_WFIDrv *pstrWFIDrv = NULL; drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24)); pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -6927,7 +6927,7 @@ void NetworkInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) - if (pstrWFIDrv == WILC_NULL || pstrWFIDrv == terminated_handle) { + if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) { PRINT_ER("NetworkInfo received but driver not init[%x]\n", (WILC_Uint32)pstrWFIDrv); return; } @@ -6944,7 +6944,7 @@ void NetworkInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) pu8Buffer, u32Length); /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error); } @@ -6969,7 +6969,7 @@ void GnrlAsyncInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) WILC_Sint32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; WILC_Uint32 drvHandler; - tstrWILC_WFIDrv *pstrWFIDrv = WILC_NULL; + tstrWILC_WFIDrv *pstrWFIDrv = NULL; /*BugID_5348*/ down(&hSemHostIntDeinit); @@ -6986,7 +6986,7 @@ void GnrlAsyncInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) return; } - if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == WILC_NULL) { + if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL) { /* received mac status is not needed when there is no current Connect Request */ PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n"); /*BugID_5348*/ @@ -7008,7 +7008,7 @@ void GnrlAsyncInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) pu8Buffer, u32Length); /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error); } @@ -7032,7 +7032,7 @@ void host_int_ScanCompleteReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) WILC_Sint32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; WILC_Uint32 drvHandler; - tstrWILC_WFIDrv *pstrWFIDrv = WILC_NULL; + tstrWILC_WFIDrv *pstrWFIDrv = NULL; drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24)); pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -7061,7 +7061,7 @@ void host_int_ScanCompleteReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) * pu8Buffer, u32Length); */ /* send the message */ - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error); } @@ -7093,7 +7093,7 @@ WILC_Sint32 host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u3 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -7110,7 +7110,7 @@ WILC_Sint32 host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u3 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID; strHostIFmsg.drvHandler = hWFIDrv; - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { WILC_ERRORREPORT(s32Error, s32Error); } @@ -7142,12 +7142,12 @@ WILC_Sint32 host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } /*Stopping remain-on-channel timer*/ - WILC_TimerStop(&(pstrWFIDrv->hRemainOnChannel), WILC_NULL); + WILC_TimerStop(&(pstrWFIDrv->hRemainOnChannel), NULL); /* prepare the timer fire Message */ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); @@ -7155,7 +7155,7 @@ WILC_Sint32 host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u strHostIFmsg.drvHandler = hWFIDrv; strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID; - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { WILC_ERRORREPORT(s32Error, s32Error); } @@ -7180,7 +7180,7 @@ WILC_Sint32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16Fr tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -7207,7 +7207,7 @@ WILC_Sint32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16Fr strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.bReg = bReg; strHostIFmsg.drvHandler = hWFIDrv; - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { WILC_ERRORREPORT(s32Error, s32Error); } @@ -7244,7 +7244,7 @@ WILC_Sint32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32Interv tstrHostIFmsg strHostIFmsg; tstrHostIFSetBeacon *pstrSetBeaconParam = &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -7277,7 +7277,7 @@ WILC_Sint32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32Interv pstrSetBeaconParam->pu8Tail = NULL; } - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { WILC_ERRORREPORT(s32Error, s32Error); } @@ -7313,7 +7313,7 @@ WILC_Sint32 host_int_del_beacon(WILC_WFIDrvHandle hWFIDrv) tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -7322,7 +7322,7 @@ WILC_Sint32 host_int_del_beacon(WILC_WFIDrvHandle hWFIDrv) strHostIFmsg.drvHandler = hWFIDrv; PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n"); - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); WILC_ERRORCHECK(s32Error); WILC_CATCH(s32Error) @@ -7349,7 +7349,7 @@ WILC_Sint32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -7372,7 +7372,7 @@ WILC_Sint32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam } - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { WILC_ERRORREPORT(s32Error, s32Error); } @@ -7399,7 +7399,7 @@ WILC_Sint32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8MacAddr tstrHostIFmsg strHostIFmsg; tstrHostIFDelSta *pstrDelStationMsg = &strHostIFmsg.uniHostIFmsgBody.strDelStaParam; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -7414,12 +7414,12 @@ WILC_Sint32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8MacAddr strHostIFmsg.drvHandler = hWFIDrv; /*BugID_4795: Handling situation of deleting all stations*/ - if (pu8MacAddr == WILC_NULL) + if (pu8MacAddr == NULL) WILC_memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN); else WILC_memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN); - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { WILC_ERRORREPORT(s32Error, s32Error); } @@ -7449,7 +7449,7 @@ WILC_Sint32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][E WILC_Uint8 u8AssocNumb = 0; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -7476,7 +7476,7 @@ WILC_Sint32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][E } pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb; - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { @@ -7509,7 +7509,7 @@ WILC_Sint32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaPara tstrHostIFmsg strHostIFmsg; tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -7530,7 +7530,7 @@ WILC_Sint32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaPara pstrAddStationMsg->pu8Rates = rates; } - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { WILC_ERRORREPORT(s32Error, s32Error); } @@ -7551,7 +7551,7 @@ WILC_Sint32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnab PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d << \n\n", bIsEnabled); - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -7568,7 +7568,7 @@ WILC_Sint32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnab pstrPowerMgmtParam->u32Timeout = u32Timeout; - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { WILC_ERRORREPORT(s32Error, s32Error); } @@ -7587,7 +7587,7 @@ WILC_Sint32 host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv, WILC_Bool tstrHostIFSetMulti *pstrMulticastFilterParam = &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMulti; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -7603,7 +7603,7 @@ WILC_Sint32 host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv, WILC_Bool pstrMulticastFilterParam->bIsEnabled = bIsEnabled; pstrMulticastFilterParam->u32count = u32count; - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { WILC_ERRORREPORT(s32Error, s32Error); } @@ -7858,7 +7858,7 @@ static int host_int_addBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char T tstrHostIFmsg strHostIFmsg; tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -7873,7 +7873,7 @@ static int host_int_addBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char T pBASessionInfo->u16SessionTimeout = SessionTimeout; strHostIFmsg.drvHandler = hWFIDrv; - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { WILC_ERRORREPORT(s32Error, s32Error); } @@ -7893,7 +7893,7 @@ WILC_Sint32 host_int_delBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char tstrHostIFmsg strHostIFmsg; tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -7906,7 +7906,7 @@ WILC_Sint32 host_int_delBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char pBASessionInfo->u8Ted = TID; strHostIFmsg.drvHandler = hWFIDrv; - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { WILC_ERRORREPORT(s32Error, s32Error); } @@ -7928,7 +7928,7 @@ WILC_Sint32 host_int_del_All_Rx_BASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSI tstrHostIFmsg strHostIFmsg; tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -7941,7 +7941,7 @@ WILC_Sint32 host_int_del_All_Rx_BASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSI pBASessionInfo->u8Ted = TID; strHostIFmsg.drvHandler = hWFIDrv; - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { WILC_ERRORREPORT(s32Error, s32Error); } @@ -7973,7 +7973,7 @@ WILC_Sint32 host_int_setup_ipaddress(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *u16i /* TODO: Enable This feature on softap firmware */ return 0; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -7986,7 +7986,7 @@ WILC_Sint32 host_int_setup_ipaddress(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *u16i strHostIFmsg.drvHandler = hWFIDrv; strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx = idx; - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { WILC_ERRORREPORT(s32Error, s32Error); } @@ -8014,7 +8014,7 @@ WILC_Sint32 host_int_get_ipaddress(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *u16ipa tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; - if (pstrWFIDrv == WILC_NULL) { + if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -8027,7 +8027,7 @@ WILC_Sint32 host_int_get_ipaddress(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *u16ipa strHostIFmsg.drvHandler=hWFIDrv; strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx= idx; - s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), WILC_NULL); + s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); if (s32Error) { WILC_ERRORREPORT(s32Error, s32Error); } diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 46c7e4f3471d..b92626ed02e1 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -304,7 +304,7 @@ static int dev_state_ev_handler(struct notifier_block *this, unsigned long event if (nic->iftype == STATION_MODE || nic->iftype == CLIENT_MODE) { pstrWFIDrv->IFC_UP = 1; g_obtainingIP = WILC_FALSE; - WILC_TimerStop(&hDuringIpTimer, WILC_NULL); + WILC_TimerStop(&hDuringIpTimer, NULL); PRINT_D(GENERIC_DBG, "IP obtained , enable scan\n"); } diff --git a/drivers/staging/wilc1000/wilc_errorsupport.h b/drivers/staging/wilc1000/wilc_errorsupport.h index 4da657d17020..dd8affabc80d 100644 --- a/drivers/staging/wilc1000/wilc_errorsupport.h +++ b/drivers/staging/wilc1000/wilc_errorsupport.h @@ -55,7 +55,7 @@ typedef WILC_Sint32 WILC_ErrNo; } while (0) #define WILC_NULLCHECK(__status__, __ptr__) do { \ - if (__ptr__ == WILC_NULL) { \ + if (__ptr__ == NULL) { \ WILC_ERRORREPORT(__status__, WILC_NULL_PTR); \ } \ } while (0) diff --git a/drivers/staging/wilc1000/wilc_memory.c b/drivers/staging/wilc1000/wilc_memory.c index f5f4b7acc993..f44827528667 100644 --- a/drivers/staging/wilc1000/wilc_memory.c +++ b/drivers/staging/wilc1000/wilc_memory.c @@ -12,7 +12,7 @@ void *WILC_MemoryAlloc(WILC_Uint32 u32Size, tstrWILC_MemoryAttrs *strAttrs, if (u32Size > 0) { return kmalloc(u32Size, GFP_ATOMIC); } else { - return WILC_NULL; + return NULL; } } @@ -37,8 +37,8 @@ void *WILC_MemoryRealloc(void *pvOldBlock, WILC_Uint32 u32NewSize, { if (u32NewSize == 0) { kfree(pvOldBlock); - return WILC_NULL; - } else if (pvOldBlock == WILC_NULL) { + return NULL; + } else if (pvOldBlock == NULL) { return kmalloc(u32NewSize, GFP_KERNEL); } else { return krealloc(pvOldBlock, u32NewSize, GFP_KERNEL); diff --git a/drivers/staging/wilc1000/wilc_memory.h b/drivers/staging/wilc1000/wilc_memory.h index 4038e1f3e30b..6f404ac272a1 100644 --- a/drivers/staging/wilc1000/wilc_memory.h +++ b/drivers/staging/wilc1000/wilc_memory.h @@ -121,27 +121,27 @@ void WILC_MemoryFree(const void *pvBlock, tstrWILC_MemoryAttrs *strAttrs, */ #define WILC_MALLOC_EX(__size__, __attrs__) \ (WILC_MemoryAlloc( \ - (__size__), __attrs__, WILC_NULL, 0)) + (__size__), __attrs__, NULL, 0)) /*! * @brief standrad calloc wrapper with custom attributes */ #define WILC_CALLOC_EX(__size__, __attrs__) \ (WILC_MemoryCalloc( \ - (__size__), __attrs__, WILC_NULL, 0)) + (__size__), __attrs__, NULL, 0)) /*! * @brief standrad realloc wrapper with custom attributes */ #define WILC_REALLOC_EX(__ptr__, __new_size__, __attrs__) \ (WILC_MemoryRealloc( \ - (__ptr__), (__new_size__), __attrs__, WILC_NULL, 0)) + (__ptr__), (__new_size__), __attrs__, NULL, 0)) /*! * @brief standrad free wrapper with custom attributes */ #define WILC_FREE_EX(__ptr__, __attrs__) \ (WILC_MemoryFree( \ - (__ptr__), __attrs__, WILC_NULL, 0)) + (__ptr__), __attrs__, NULL, 0)) /*! * @brief Allocates a block (with custom attributes) of given type and number of @@ -164,9 +164,9 @@ void WILC_MemoryFree(const void *pvBlock, tstrWILC_MemoryAttrs *strAttrs, * to NULL */ #define WILC_FREE_SET_NULL_EX(__ptr__, __attrs__) do { \ - if (__ptr__ != WILC_NULL) { \ + if (__ptr__ != NULL) { \ WILC_FREE_EX(__ptr__, __attrs__); \ - __ptr__ = WILC_NULL; \ + __ptr__ = NULL; \ } \ } while (0) @@ -175,7 +175,7 @@ void WILC_MemoryFree(const void *pvBlock, tstrWILC_MemoryAttrs *strAttrs, * to true */ #define WILC_FREE_IF_TRUE_EX(__ptr__, __attrs__) do { \ - if (__ptr__ != WILC_NULL) { \ + if (__ptr__ != NULL) { \ WILC_FREE_EX(__ptr__, __attrs__); \ } \ } while (0) @@ -184,53 +184,53 @@ void WILC_MemoryFree(const void *pvBlock, tstrWILC_MemoryAttrs *strAttrs, * @brief standrad malloc wrapper with default attributes */ #define WILC_MALLOC(__size__) \ - WILC_MALLOC_EX(__size__, WILC_NULL) + WILC_MALLOC_EX(__size__, NULL) /*! * @brief standrad calloc wrapper with default attributes */ #define WILC_CALLOC(__size__) \ - WILC_CALLOC_EX(__size__, WILC_NULL) + WILC_CALLOC_EX(__size__, NULL) /*! * @brief standrad realloc wrapper with default attributes */ #define WILC_REALLOC(__ptr__, __new_size__) \ - WILC_REALLOC_EX(__ptr__, __new_size__, WILC_NULL) + WILC_REALLOC_EX(__ptr__, __new_size__, NULL) /*! * @brief standrad free wrapper with default attributes */ #define WILC_FREE(__ptr__) \ - WILC_FREE_EX(__ptr__, WILC_NULL) + WILC_FREE_EX(__ptr__, NULL) /*! * @brief Allocates a block (with default attributes) of given type and number of * elements */ #define WILC_NEW(__struct_type__, __n_structs__) \ - WILC_NEW_EX(__struct_type__, __n_structs__, WILC_NULL) + WILC_NEW_EX(__struct_type__, __n_structs__, NULL) /*! * @brief Allocates a block (with default attributes) of given type and number of * elements and Zero-fills it */ #define WILC_NEW_0(__struct_type__, __n_structs__) \ - WILC_NEW_O_EX(__struct_type__, __n_structs__, WILC_NULL) + WILC_NEW_O_EX(__struct_type__, __n_structs__, NULL) /*! * @brief Frees a block (with default attributes), also setting the original pointer * to NULL */ #define WILC_FREE_SET_NULL(__ptr__) \ - WILC_FREE_SET_NULL_EX(__ptr__, WILC_NULL) + WILC_FREE_SET_NULL_EX(__ptr__, NULL) /*! * @brief Frees a block (with default attributes) if the pointer expression evaluates * to true */ #define WILC_FREE_IF_TRUE(__ptr__) \ - WILC_FREE_IF_TRUE_EX(__ptr__, WILC_NULL) + WILC_FREE_IF_TRUE_EX(__ptr__, NULL) #endif diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index a2ccf43a4a96..3cdc05305109 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -32,8 +32,6 @@ typedef enum { /* Character types */ typedef char WILC_Char; -#define WILC_NULL ((void *)0) - /* Os Configuration File */ #include "wilc_osconfig.h" #include "wilc_platform.h" diff --git a/drivers/staging/wilc1000/wilc_strutils.c b/drivers/staging/wilc1000/wilc_strutils.c index f452fc57f71d..d349eaa2b51f 100644 --- a/drivers/staging/wilc1000/wilc_strutils.c +++ b/drivers/staging/wilc1000/wilc_strutils.c @@ -51,11 +51,11 @@ WILC_Sint32 WILC_strncmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2, { WILC_Sint32 s32Result; - if (pcStr1 == WILC_NULL && pcStr2 == WILC_NULL) { + if (pcStr1 == NULL && pcStr2 == NULL) { s32Result = 0; - } else if (pcStr1 == WILC_NULL) { + } else if (pcStr1 == NULL) { s32Result = -1; - } else if (pcStr2 == WILC_NULL) { + } else if (pcStr2 == NULL) { s32Result = 1; } else { s32Result = strncmp(pcStr1, pcStr2, u32Count); diff --git a/drivers/staging/wilc1000/wilc_strutils.h b/drivers/staging/wilc1000/wilc_strutils.h index 62bd1af9e039..8795d56adc4a 100644 --- a/drivers/staging/wilc1000/wilc_strutils.h +++ b/drivers/staging/wilc1000/wilc_strutils.h @@ -97,13 +97,13 @@ WILC_Char *WILC_strncpy(WILC_Char *pcTarget, const WILC_Char *pcSource, /*! * @brief Compares two strings up to u32Count characters - * @details Compares 2 strings reporting which is bigger, WILC_NULL is considered + * @details Compares 2 strings reporting which is bigger, NULL is considered * the smallest string, then a zero length string then all other * strings depending on thier ascii characters order with small case * converted to uppder case - * @param[in] pcStr1 the first string, WILC_NULL is valid and considered smaller + * @param[in] pcStr1 the first string, NULL is valid and considered smaller * than any other non-NULL string (incliding zero lenght strings) - * @param[in] pcStr2 the second string, WILC_NULL is valid and considered smaller + * @param[in] pcStr2 the second string, NULL is valid and considered smaller * than any other non-NULL string (incliding zero lenght strings) * @param[in] u32Count copying will proceed until a null character in pcStr1 or * pcStr2 is encountered or u32Count of bytes copied diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index e9ab2cb35381..aa71b2708569 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -148,7 +148,7 @@ void clear_shadow_scan(void *pUserVoid) int i; priv = (struct WILC_WFI_priv *)pUserVoid; if (op_ifcs == 0) { - WILC_TimerDestroy(&hAgingTimer, WILC_NULL); + WILC_TimerDestroy(&hAgingTimer, NULL); PRINT_INFO(CORECONFIG_DBG, "destroy aging timer\n"); for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) { @@ -198,7 +198,7 @@ void refresh_scan(void *pUserVoid, uint8_t all, WILC_Bool bDirectScan) WILC_Sint32 s32Freq; struct ieee80211_channel *channel; - if (pstrNetworkInfo != WILC_NULL) { + if (pstrNetworkInfo != NULL) { s32Freq = ieee80211_channel_to_frequency((WILC_Sint32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ); channel = ieee80211_get_channel(wiphy, s32Freq); @@ -266,7 +266,7 @@ void remove_network_from_shadow(void *pUserVoid) PRINT_D(CFG80211_DBG, "Number of cached networks: %d\n", u32LastScannedNtwrksCountShadow); if (u32LastScannedNtwrksCountShadow != 0) - WILC_TimerStart(&(hAgingTimer), AGING_TIME, pUserVoid, WILC_NULL); + WILC_TimerStart(&(hAgingTimer), AGING_TIME, pUserVoid, NULL); else PRINT_D(CFG80211_DBG, "No need to restart Aging timer\n"); } @@ -288,7 +288,7 @@ int8_t is_network_in_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid) priv = (struct WILC_WFI_priv *)pUserVoid; if (u32LastScannedNtwrksCountShadow == 0) { PRINT_D(CFG80211_DBG, "Starting Aging timer\n"); - WILC_TimerStart(&(hAgingTimer), AGING_TIME, pUserVoid, WILC_NULL); + WILC_TimerStart(&(hAgingTimer), AGING_TIME, pUserVoid, NULL); state = -1; } else { /* Linear search for now */ @@ -399,7 +399,7 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo WILC_ERRORREPORT(s32Error, WILC_FAIL); } - if (pstrNetworkInfo != WILC_NULL) { + if (pstrNetworkInfo != NULL) { s32Freq = ieee80211_channel_to_frequency((WILC_Sint32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ); channel = ieee80211_get_channel(wiphy, s32Freq); @@ -464,11 +464,11 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo down(&(priv->hSemScanReq)); - if (priv->pstrScanReq != WILC_NULL) { + if (priv->pstrScanReq != NULL) { cfg80211_scan_done(priv->pstrScanReq, WILC_FALSE); priv->u32RcvdChCount = 0; priv->bCfgScanning = WILC_FALSE; - priv->pstrScanReq = WILC_NULL; + priv->pstrScanReq = NULL; } up(&(priv->hSemScanReq)); @@ -478,14 +478,14 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo down(&(priv->hSemScanReq)); PRINT_D(CFG80211_DBG, "Scan Aborted \n"); - if (priv->pstrScanReq != WILC_NULL) { + if (priv->pstrScanReq != NULL) { update_scan_time(priv); refresh_scan(priv, 1, WILC_FALSE); cfg80211_scan_done(priv->pstrScanReq, WILC_FALSE); priv->bCfgScanning = WILC_FALSE; - priv->pstrScanReq = WILC_NULL; + priv->pstrScanReq = NULL; } up(&(priv->hSemScanReq)); } @@ -1230,14 +1230,14 @@ static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 k if (priv->wilc_gtk[key_index] == NULL) { priv->wilc_gtk[key_index] = (struct wilc_wfi_key *)WILC_MALLOC(sizeof(struct wilc_wfi_key)); - priv->wilc_gtk[key_index]->key = WILC_NULL; - priv->wilc_gtk[key_index]->seq = WILC_NULL; + priv->wilc_gtk[key_index]->key = NULL; + priv->wilc_gtk[key_index]->seq = NULL; } if (priv->wilc_ptk[key_index] == NULL) { priv->wilc_ptk[key_index] = (struct wilc_wfi_key *)WILC_MALLOC(sizeof(struct wilc_wfi_key)); - priv->wilc_ptk[key_index]->key = WILC_NULL; - priv->wilc_ptk[key_index]->seq = WILC_NULL; + priv->wilc_ptk[key_index]->key = NULL; + priv->wilc_ptk[key_index]->seq = NULL; } @@ -2867,11 +2867,11 @@ int WILC_WFI_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, struct WILC_WFI_priv *priv; PRINT_D(CFG80211_DBG, " Power save Enabled= %d , TimeOut = %d\n", enabled, timeout); - if (wiphy == WILC_NULL) + if (wiphy == NULL) return -ENOENT; priv = wiphy_priv(wiphy); - if (priv->hWILCWFIDrv == WILC_NULL) { + if (priv->hWILCWFIDrv == NULL) { PRINT_ER("Driver is NULL\n"); return -EIO; } @@ -2922,7 +2922,7 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP g_obtainingIP = WILC_FALSE; - WILC_TimerStop(&hDuringIpTimer, WILC_NULL); + WILC_TimerStop(&hDuringIpTimer, NULL); PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n"); #endif /*BugID_5137*/ @@ -3165,7 +3165,7 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP g_obtainingIP = WILC_TRUE; - WILC_TimerStart(&hDuringIpTimer, duringIP_TIME, WILC_NULL, WILC_NULL); + WILC_TimerStart(&hDuringIpTimer, duringIP_TIME, NULL, NULL); #endif host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0); /*BugID_5222*/ @@ -3460,7 +3460,7 @@ static int WILC_WFI_add_station(struct wiphy *wiphy, struct net_device *dev, PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID); PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates); - if (params->ht_capa == WILC_NULL) { + if (params->ht_capa == NULL) { strStaParams.bIsHTSupported = WILC_FALSE; } else { strStaParams.bIsHTSupported = WILC_TRUE; @@ -3533,7 +3533,7 @@ static int WILC_WFI_del_station(struct wiphy *wiphy, struct net_device *dev, PRINT_D(HOSTAPD_DBG, "Deleting station\n"); - if (mac == WILC_NULL) { + if (mac == NULL) { PRINT_D(HOSTAPD_DBG, "All associated stations \n"); s32Error = host_int_del_allstation(priv->hWILCWFIDrv, priv->assoc_stainfo.au8Sta_AssociatedBss); } else { @@ -3592,7 +3592,7 @@ static int WILC_WFI_change_station(struct wiphy *wiphy, struct net_device *dev, PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID); PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates); - if (params->ht_capa == WILC_NULL) { + if (params->ht_capa == NULL) { strStaParams.bIsHTSupported = WILC_FALSE; } else { strStaParams.bIsHTSupported = WILC_TRUE; @@ -3994,9 +3994,9 @@ int WILC_WFI_InitHostInt(struct net_device *net) PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr); priv = wdev_priv(net->ieee80211_ptr); if (op_ifcs == 0) { - s32Error = WILC_TimerCreate(&(hAgingTimer), remove_network_from_shadow, WILC_NULL); + s32Error = WILC_TimerCreate(&(hAgingTimer), remove_network_from_shadow, NULL); #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP - s32Error = WILC_TimerCreate(&(hDuringIpTimer), clear_duringIP, WILC_NULL); + s32Error = WILC_TimerCreate(&(hDuringIpTimer), clear_duringIP, NULL); #endif } op_ifcs++; @@ -4048,7 +4048,7 @@ int WILC_WFI_DeInitHostInt(struct net_device *net) #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP if (op_ifcs == 0) { PRINT_D(CORECONFIG_DBG, "destroy during ip\n"); - WILC_TimerDestroy(&hDuringIpTimer, WILC_NULL); + WILC_TimerDestroy(&hDuringIpTimer, NULL); } #endif diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index badc8743dd1a..4055962fac81 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -1899,12 +1899,12 @@ static void wilc_wlan_cleanup(void) #ifdef MEMORY_STATIC if (p->rx_buffer) { p->os_func.os_free(p->rx_buffer); - p->rx_buffer = WILC_NULL; + p->rx_buffer = NULL; } #endif if (p->tx_buffer) { p->os_func.os_free(p->tx_buffer); - p->tx_buffer = WILC_NULL; + p->tx_buffer = NULL; } #endif @@ -2294,7 +2294,7 @@ int wilc_wlan_init(wilc_wlan_inp_t *inp, wilc_wlan_oup_t *oup) - if (g_wlan.tx_buffer == WILC_NULL) + if (g_wlan.tx_buffer == NULL) #if (defined WILC_PREALLOC_AT_BOOT) g_wlan.tx_buffer = (uint8_t *)get_tx_buffer(); #else @@ -2302,7 +2302,7 @@ int wilc_wlan_init(wilc_wlan_inp_t *inp, wilc_wlan_oup_t *oup) #endif PRINT_D(TX_DBG, "g_wlan.tx_buffer = %p\n", g_wlan.tx_buffer); - if (g_wlan.tx_buffer == WILC_NULL) { + if (g_wlan.tx_buffer == NULL) { /* ENOBUFS 105 */ ret = -105; PRINT_ER("Can't allocate Tx Buffer"); @@ -2311,14 +2311,14 @@ int wilc_wlan_init(wilc_wlan_inp_t *inp, wilc_wlan_oup_t *oup) /* rx_buffer is not used unless we activate USE_MEM STATIC which is not applicable, allocating such memory is useless*/ #if defined (MEMORY_STATIC) - if (g_wlan.rx_buffer == WILC_NULL) + if (g_wlan.rx_buffer == NULL) #if (defined WILC_PREALLOC_AT_BOOT) g_wlan.rx_buffer = (uint8_t *)get_rx_buffer(); #else g_wlan.rx_buffer = (uint8_t *)g_wlan.os_func.os_malloc(g_wlan.rx_buffer_size); #endif PRINT_D(TX_DBG, "g_wlan.rx_buffer =%p\n", g_wlan.rx_buffer); - if (g_wlan.rx_buffer == WILC_NULL) { + if (g_wlan.rx_buffer == NULL) { /* ENOBUFS 105 */ ret = -105; PRINT_ER("Can't allocate Rx Buffer"); @@ -2375,12 +2375,12 @@ _fail_: #ifdef MEMORY_STATIC if (g_wlan.rx_buffer) { g_wlan.os_func.os_free(g_wlan.rx_buffer); - g_wlan.rx_buffer = WILC_NULL; + g_wlan.rx_buffer = NULL; } #endif if (g_wlan.tx_buffer) { g_wlan.os_func.os_free(g_wlan.tx_buffer); - g_wlan.tx_buffer = WILC_NULL; + g_wlan.tx_buffer = NULL; } #endif From 63d03e47730818afd09d499c3385e56cda5a513e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 2 Jun 2015 14:16:04 +0900 Subject: [PATCH 0783/1163] staging: wilc1000: remove WILC_Uint8 Just use u8, as that's what you really want in a kernel driver. Cc: Johnny Kim Cc: Rachel Kim Cc: Dean Lee Cc: Chris Park Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 210 ++++----- drivers/staging/wilc1000/coreconfigurator.h | 52 +-- drivers/staging/wilc1000/fifo_buffer.c | 4 +- drivers/staging/wilc1000/fifo_buffer.h | 8 +- drivers/staging/wilc1000/host_interface.c | 438 +++++++++--------- drivers/staging/wilc1000/host_interface.h | 150 +++--- drivers/staging/wilc1000/linux_mon.c | 12 +- drivers/staging/wilc1000/linux_wlan.c | 8 +- drivers/staging/wilc1000/wilc_msgqueue.h | 2 +- drivers/staging/wilc1000/wilc_oswrapper.h | 1 - drivers/staging/wilc1000/wilc_strutils.c | 2 +- drivers/staging/wilc1000/wilc_strutils.h | 10 +- drivers/staging/wilc1000/wilc_timer.h | 2 +- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 100 ++-- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 16 +- drivers/staging/wilc1000/wilc_wlan.c | 2 +- 16 files changed, 508 insertions(+), 509 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index 832230a51b02..e3e3f204624e 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -158,9 +158,9 @@ typedef struct { /* Extern Function Declarations */ /*****************************************************************************/ extern WILC_Sint32 SendRawPacket(WILC_Sint8 *ps8Packet, WILC_Sint32 s32PacketLen); -extern void NetworkInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length); -extern void GnrlAsyncInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length); -extern void host_int_ScanCompleteReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length); +extern void NetworkInfoReceived(u8 *pu8Buffer, WILC_Uint32 u32Length); +extern void GnrlAsyncInfoReceived(u8 *pu8Buffer, WILC_Uint32 u32Length); +extern void host_int_ScanCompleteReceived(u8 *pu8Buffer, WILC_Uint32 u32Length); /*****************************************************************************/ /* Global Variables */ /*****************************************************************************/ @@ -171,13 +171,13 @@ static WILC_Sint8 *gps8ConfigPacket; static tstrConfigPktInfo gstrConfigPktInfo; -static WILC_Uint8 g_seqno; +static u8 g_seqno; static WILC_Sint16 g_wid_num = -1; static WILC_Uint16 Res_Len; -static WILC_Uint8 g_oper_mode = SET_CFG; +static u8 g_oper_mode = SET_CFG; /* WID Switches */ static tstrWID gastrWIDs[] = { @@ -318,7 +318,7 @@ WILC_Uint16 g_num_total_switches = (sizeof(gastrWIDs) / sizeof(tstrWID)); /*****************************************************************************/ /* Functions */ /*****************************************************************************/ -INLINE WILC_Uint8 ascii_hex_to_dec(WILC_Uint8 num) +INLINE u8 ascii_hex_to_dec(u8 num) { if ((num >= '0') && (num <= '9')) return (num - '0'); @@ -330,16 +330,16 @@ INLINE WILC_Uint8 ascii_hex_to_dec(WILC_Uint8 num) return INVALID; } -INLINE WILC_Uint8 get_hex_char(WILC_Uint8 inp) +INLINE u8 get_hex_char(u8 inp) { - WILC_Uint8 *d2htab = "0123456789ABCDEF"; + u8 *d2htab = "0123456789ABCDEF"; return d2htab[inp & 0xF]; } /* This function extracts the MAC address held in a string in standard format */ /* into another buffer as integers. */ -INLINE WILC_Uint16 extract_mac_addr(WILC_Char *str, WILC_Uint8 *buff) +INLINE WILC_Uint16 extract_mac_addr(WILC_Char *str, u8 *buff) { *buff = 0; while (*str != '\0') { @@ -356,14 +356,14 @@ INLINE WILC_Uint16 extract_mac_addr(WILC_Char *str, WILC_Uint8 *buff) /* This function creates MAC address in standard format from a buffer of */ /* integers. */ -INLINE void create_mac_addr(WILC_Uint8 *str, WILC_Uint8 *buff) +INLINE void create_mac_addr(u8 *str, u8 *buff) { WILC_Uint32 i = 0; WILC_Uint32 j = 0; for (i = 0; i < MAC_ADDR_LEN; i++) { - str[j++] = get_hex_char((WILC_Uint8)((buff[i] >> 4) & 0x0F)); - str[j++] = get_hex_char((WILC_Uint8)(buff[i] & 0x0F)); + str[j++] = get_hex_char((u8)((buff[i] >> 4) & 0x0F)); + str[j++] = get_hex_char((u8)(buff[i] & 0x0F)); str[j++] = ':'; } str[--j] = '\0'; @@ -375,10 +375,10 @@ INLINE void create_mac_addr(WILC_Uint8 *str, WILC_Uint8 *buff) /* inet_addr is platform independent. */ /* ips=>IP Address String in dotted decimal format */ /* ipn=>Pointer to IP Address in integer format */ -INLINE WILC_Uint8 conv_ip_to_int(WILC_Uint8 *ips, WILC_Uint32 *ipn) +INLINE u8 conv_ip_to_int(u8 *ips, WILC_Uint32 *ipn) { - WILC_Uint8 i = 0; - WILC_Uint8 ipb = 0; + u8 i = 0; + u8 ipb = 0; *ipn = 0; /* Integer to string for each component */ while (ips[i] != '\0') { @@ -402,12 +402,12 @@ INLINE WILC_Uint8 conv_ip_to_int(WILC_Uint8 *ips, WILC_Uint32 *ipn) /* decimal string format. Alternative to std library fn inet_ntoa(). */ /* ips=>Buffer to hold IP Address String dotted decimal format (Min 17B) */ /* ipn=>IP Address in integer format */ -INLINE WILC_Uint8 conv_int_to_ip(WILC_Uint8 *ips, WILC_Uint32 ipn) +INLINE u8 conv_int_to_ip(u8 *ips, WILC_Uint32 ipn) { - WILC_Uint8 i = 0; - WILC_Uint8 ipb = 0; - WILC_Uint8 cnt = 0; - WILC_Uint8 ipbsize = 0; + u8 i = 0; + u8 ipb = 0; + u8 cnt = 0; + u8 ipbsize = 0; for (cnt = 4; cnt > 0; cnt--) { ipb = (ipn >> (8 * (cnt - 1))) & 0xFF; @@ -475,7 +475,7 @@ INLINE tenuWIDtype get_wid_type(WILC_Uint32 wid_num) /* This function extracts the beacon period field from the beacon or probe */ /* response frame. */ -INLINE WILC_Uint16 get_beacon_period(WILC_Uint8 *data) +INLINE WILC_Uint16 get_beacon_period(u8 *data) { WILC_Uint16 bcn_per = 0; @@ -485,7 +485,7 @@ INLINE WILC_Uint16 get_beacon_period(WILC_Uint8 *data) return bcn_per; } -INLINE WILC_Uint32 get_beacon_timestamp_lo(WILC_Uint8 *data) +INLINE WILC_Uint32 get_beacon_timestamp_lo(u8 *data) { WILC_Uint32 time_stamp = 0; WILC_Uint32 index = MAC_HDR_LEN; @@ -514,7 +514,7 @@ INLINE UWORD32 get_beacon_timestamp_hi(UWORD8 *data) /* This function extracts the 'frame type' bits from the MAC header of the */ /* input frame. */ /* Returns the value in the LSB of the returned value. */ -INLINE tenuBasicFrmType get_type(WILC_Uint8 *header) +INLINE tenuBasicFrmType get_type(u8 *header) { return ((tenuBasicFrmType)(header[0] & 0x0C)); } @@ -522,7 +522,7 @@ INLINE tenuBasicFrmType get_type(WILC_Uint8 *header) /* This function extracts the 'frame type and sub type' bits from the MAC */ /* header of the input frame. */ /* Returns the value in the LSB of the returned value. */ -INLINE tenuFrmSubtype get_sub_type(WILC_Uint8 *header) +INLINE tenuFrmSubtype get_sub_type(u8 *header) { return ((tenuFrmSubtype)(header[0] & 0xFC)); } @@ -530,7 +530,7 @@ INLINE tenuFrmSubtype get_sub_type(WILC_Uint8 *header) /* This function extracts the 'to ds' bit from the MAC header of the input */ /* frame. */ /* Returns the value in the LSB of the returned value. */ -INLINE WILC_Uint8 get_to_ds(WILC_Uint8 *header) +INLINE u8 get_to_ds(u8 *header) { return (header[1] & 0x01); } @@ -538,28 +538,28 @@ INLINE WILC_Uint8 get_to_ds(WILC_Uint8 *header) /* This function extracts the 'from ds' bit from the MAC header of the input */ /* frame. */ /* Returns the value in the LSB of the returned value. */ -INLINE WILC_Uint8 get_from_ds(WILC_Uint8 *header) +INLINE u8 get_from_ds(u8 *header) { return ((header[1] & 0x02) >> 1); } /* This function extracts the MAC Address in 'address1' field of the MAC */ /* header and updates the MAC Address in the allocated 'addr' variable. */ -INLINE void get_address1(WILC_Uint8 *pu8msa, WILC_Uint8 *addr) +INLINE void get_address1(u8 *pu8msa, u8 *addr) { WILC_memcpy(addr, pu8msa + 4, 6); } /* This function extracts the MAC Address in 'address2' field of the MAC */ /* header and updates the MAC Address in the allocated 'addr' variable. */ -INLINE void get_address2(WILC_Uint8 *pu8msa, WILC_Uint8 *addr) +INLINE void get_address2(u8 *pu8msa, u8 *addr) { WILC_memcpy(addr, pu8msa + 10, 6); } /* This function extracts the MAC Address in 'address3' field of the MAC */ /* header and updates the MAC Address in the allocated 'addr' variable. */ -INLINE void get_address3(WILC_Uint8 *pu8msa, WILC_Uint8 *addr) +INLINE void get_address3(u8 *pu8msa, u8 *addr) { WILC_memcpy(addr, pu8msa + 16, 6); } @@ -567,7 +567,7 @@ INLINE void get_address3(WILC_Uint8 *pu8msa, WILC_Uint8 *addr) /* This function extracts the BSSID from the incoming WLAN packet based on */ /* the 'from ds' bit, and updates the MAC Address in the allocated 'addr' */ /* variable. */ -INLINE void get_BSSID(WILC_Uint8 *data, WILC_Uint8 *bssid) +INLINE void get_BSSID(u8 *data, u8 *bssid) { if (get_from_ds(data) == 1) get_address2(data, bssid); @@ -578,11 +578,11 @@ INLINE void get_BSSID(WILC_Uint8 *data, WILC_Uint8 *bssid) } /* This function extracts the SSID from a beacon/probe response frame */ -INLINE void get_ssid(WILC_Uint8 *data, WILC_Uint8 *ssid, WILC_Uint8 *p_ssid_len) +INLINE void get_ssid(u8 *data, u8 *ssid, u8 *p_ssid_len) { - WILC_Uint8 len = 0; - WILC_Uint8 i = 0; - WILC_Uint8 j = 0; + u8 len = 0; + u8 i = 0; + u8 j = 0; len = data[MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN + CAP_INFO_LEN + 1]; @@ -604,7 +604,7 @@ INLINE void get_ssid(WILC_Uint8 *data, WILC_Uint8 *ssid, WILC_Uint8 *p_ssid_len) /* This function extracts the capability info field from the beacon or probe */ /* response frame. */ -INLINE WILC_Uint16 get_cap_info(WILC_Uint8 *data) +INLINE WILC_Uint16 get_cap_info(u8 *data) { WILC_Uint16 cap_info = 0; WILC_Uint16 index = MAC_HDR_LEN; @@ -625,7 +625,7 @@ INLINE WILC_Uint16 get_cap_info(WILC_Uint8 *data) /* This function extracts the capability info field from the Association */ /* response frame. */ -INLINE WILC_Uint16 get_assoc_resp_cap_info(WILC_Uint8 *data) +INLINE WILC_Uint16 get_assoc_resp_cap_info(u8 *data) { WILC_Uint16 cap_info = 0; @@ -637,7 +637,7 @@ INLINE WILC_Uint16 get_assoc_resp_cap_info(WILC_Uint8 *data) /* This funcion extracts the association status code from the incoming */ /* association response frame and returns association status code */ -INLINE WILC_Uint16 get_asoc_status(WILC_Uint8 *data) +INLINE WILC_Uint16 get_asoc_status(u8 *data) { WILC_Uint16 asoc_status = 0; @@ -649,7 +649,7 @@ INLINE WILC_Uint16 get_asoc_status(WILC_Uint8 *data) /* This function extracts association ID from the incoming association */ /* response frame */ -INLINE WILC_Uint16 get_asoc_id(WILC_Uint8 *data) +INLINE WILC_Uint16 get_asoc_id(u8 *data) { WILC_Uint16 asoc_id = 0; @@ -691,7 +691,7 @@ _fail_: return s32Error; } -WILC_Uint8 *get_tim_elm(WILC_Uint8 *pu8msa, WILC_Uint16 u16RxLen, WILC_Uint16 u16TagParamOffset) +u8 *get_tim_elm(u8 *pu8msa, WILC_Uint16 u16RxLen, WILC_Uint16 u16TagParamOffset) { WILC_Uint16 u16index = 0; @@ -721,7 +721,7 @@ WILC_Uint8 *get_tim_elm(WILC_Uint8 *pu8msa, WILC_Uint16 u16RxLen, WILC_Uint16 u1 /* This function gets the current channel information from * the 802.11n beacon/probe response frame */ -WILC_Uint8 get_current_channel_802_11n(WILC_Uint8 *pu8msa, WILC_Uint16 u16RxLen) +u8 get_current_channel_802_11n(u8 *pu8msa, WILC_Uint16 u16RxLen) { WILC_Uint16 index; @@ -740,7 +740,7 @@ WILC_Uint8 get_current_channel_802_11n(WILC_Uint8 *pu8msa, WILC_Uint16 u16RxLen) return 0; /* no MIB here */ } -WILC_Uint8 get_current_channel(WILC_Uint8 *pu8msa, WILC_Uint16 u16RxLen) +u8 get_current_channel(u8 *pu8msa, WILC_Uint16 u16RxLen) { #ifdef PHY_802_11n #ifdef FIVE_GHZ_BAND @@ -768,17 +768,17 @@ WILC_Uint8 get_current_channel(WILC_Uint8 *pu8msa, WILC_Uint16 u16RxLen) * @date 1 Mar 2012 * @version 1.0 */ -WILC_Sint32 ParseNetworkInfo(WILC_Uint8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo) +WILC_Sint32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrNetworkInfo *pstrNetworkInfo = NULL; - WILC_Uint8 u8MsgType = 0; - WILC_Uint8 u8MsgID = 0; + u8 u8MsgType = 0; + u8 u8MsgID = 0; WILC_Uint16 u16MsgLen = 0; WILC_Uint16 u16WidID = (WILC_Uint16)WID_NIL; WILC_Uint16 u16WidLen = 0; - WILC_Uint8 *pu8WidVal = 0; + u8 *pu8WidVal = 0; u8MsgType = pu8MsgBuffer[0]; @@ -805,12 +805,12 @@ WILC_Sint32 ParseNetworkInfo(WILC_Uint8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNe /* parse the WID value of the WID "WID_NEWORK_INFO" */ { - WILC_Uint8 *pu8msa = 0; + u8 *pu8msa = 0; WILC_Uint16 u16RxLen = 0; - WILC_Uint8 *pu8TimElm = 0; - WILC_Uint8 *pu8IEs = 0; + u8 *pu8TimElm = 0; + u8 *pu8IEs = 0; WILC_Uint16 u16IEsLen = 0; - WILC_Uint8 u8index = 0; + u8 u8index = 0; WILC_Uint32 u32Tsf_Lo; WILC_Uint32 u32Tsf_Hi; @@ -865,7 +865,7 @@ WILC_Sint32 ParseNetworkInfo(WILC_Uint8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNe u16IEsLen = u16RxLen - (MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN + CAP_INFO_LEN); if (u16IEsLen > 0) { - pstrNetworkInfo->pu8IEs = (WILC_Uint8 *)WILC_MALLOC(u16IEsLen); + pstrNetworkInfo->pu8IEs = (u8 *)WILC_MALLOC(u16IEsLen); WILC_memset((void *)(pstrNetworkInfo->pu8IEs), 0, u16IEsLen); WILC_memcpy(pstrNetworkInfo->pu8IEs, pu8IEs, u16IEsLen); @@ -923,13 +923,13 @@ WILC_Sint32 DeallocateNetworkInfo(tstrNetworkInfo *pstrNetworkInfo) * @date 2 Apr 2012 * @version 1.0 */ -WILC_Sint32 ParseAssocRespInfo(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32BufferLen, +WILC_Sint32 ParseAssocRespInfo(u8 *pu8Buffer, WILC_Uint32 u32BufferLen, tstrConnectRespInfo **ppstrConnectRespInfo) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrConnectRespInfo *pstrConnectRespInfo = NULL; WILC_Uint16 u16AssocRespLen = 0; - WILC_Uint8 *pu8IEs = 0; + u8 *pu8IEs = 0; WILC_Uint16 u16IEsLen = 0; pstrConnectRespInfo = (tstrConnectRespInfo *)WILC_MALLOC(sizeof(tstrConnectRespInfo)); @@ -952,7 +952,7 @@ WILC_Sint32 ParseAssocRespInfo(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32BufferLen, pu8IEs = &pu8Buffer[CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN]; u16IEsLen = u16AssocRespLen - (CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN); - pstrConnectRespInfo->pu8RespIEs = (WILC_Uint8 *)WILC_MALLOC(u16IEsLen); + pstrConnectRespInfo->pu8RespIEs = (u8 *)WILC_MALLOC(u16IEsLen); WILC_memset((void *)(pstrConnectRespInfo->pu8RespIEs), 0, u16IEsLen); WILC_memcpy(pstrConnectRespInfo->pu8RespIEs, pu8IEs, u16IEsLen); @@ -998,7 +998,7 @@ WILC_Sint32 DeallocateAssocRespInfo(tstrConnectRespInfo *pstrConnectRespInfo) } #ifndef CONNECT_DIRECT -WILC_Sint32 ParseSurveyResults(WILC_Uint8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE], +WILC_Sint32 ParseSurveyResults(u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE], wid_site_survey_reslts_s **ppstrSurveyResults, WILC_Uint32 *pu32SurveyResultsCount) { @@ -1006,9 +1006,9 @@ WILC_Sint32 ParseSurveyResults(WILC_Uint8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY wid_site_survey_reslts_s *pstrSurveyResults = NULL; WILC_Uint32 u32SurveyResultsCount = 0; WILC_Uint32 u32SurveyBytesLength = 0; - WILC_Uint8 *pu8BufferPtr; + u8 *pu8BufferPtr; WILC_Uint32 u32RcvdSurveyResultsNum = 2; - WILC_Uint8 u8ReadSurveyResFragNum; + u8 u8ReadSurveyResFragNum; WILC_Uint32 i; WILC_Uint32 j; @@ -1098,8 +1098,8 @@ WILC_Sint32 DeallocateSurveyResults(wid_site_survey_reslts_s *pstrSurveyResults) void ProcessCharWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, tstrWID *pstrWID, WILC_Sint8 *ps8WidVal) { - WILC_Uint8 *pu8val = (WILC_Uint8 *)ps8WidVal; - WILC_Uint8 u8val = 0; + u8 *pu8val = (u8 *)ps8WidVal; + u8 u8val = 0; WILC_Sint32 s32PktLen = *ps32PktLen; if (pstrWID == NULL) { PRINT_WRN(CORECONFIG_DBG, "Can't set CHAR val 0x%x ,NULL structure\n", u8val); @@ -1107,13 +1107,13 @@ void ProcessCharWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, } /* WID */ - pcPacket[s32PktLen++] = (WILC_Uint8)(pstrWID->u16WIDid & 0xFF); - pcPacket[s32PktLen++] = (WILC_Uint8)(pstrWID->u16WIDid >> 8) & 0xFF; + pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid & 0xFF); + pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid >> 8) & 0xFF; if (g_oper_mode == SET_CFG) { u8val = *pu8val; /* Length */ - pcPacket[s32PktLen++] = sizeof(WILC_Uint8); + pcPacket[s32PktLen++] = sizeof(u8); /* Value */ @@ -1161,8 +1161,8 @@ void ProcessShortWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, } /* WID */ - pcPacket[s32PktLen++] = (WILC_Uint8)(pstrWID->u16WIDid & 0xFF); - pcPacket[s32PktLen++] = (WILC_Uint8)((pstrWID->u16WIDid >> 8) & 0xFF); + pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid & 0xFF); + pcPacket[s32PktLen++] = (u8)((pstrWID->u16WIDid >> 8) & 0xFF); if (g_oper_mode == SET_CFG) { u16val = *pu16val; @@ -1171,8 +1171,8 @@ void ProcessShortWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, pcPacket[s32PktLen++] = sizeof(WILC_Uint16); /* Value */ - pcPacket[s32PktLen++] = (WILC_Uint8)(u16val & 0xFF); - pcPacket[s32PktLen++] = (WILC_Uint8)((u16val >> 8) & 0xFF); + pcPacket[s32PktLen++] = (u8)(u16val & 0xFF); + pcPacket[s32PktLen++] = (u8)((u16val >> 8) & 0xFF); } *ps32PktLen = s32PktLen; } @@ -1216,8 +1216,8 @@ void ProcessIntWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, } /* WID */ - pcPacket[s32PktLen++] = (WILC_Uint8)(pstrWID->u16WIDid & 0xFF); - pcPacket[s32PktLen++] = (WILC_Uint8)((pstrWID->u16WIDid >> 8) & 0xFF); + pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid & 0xFF); + pcPacket[s32PktLen++] = (u8)((pstrWID->u16WIDid >> 8) & 0xFF); if (g_oper_mode == SET_CFG) { u32val = *pu32val; @@ -1226,10 +1226,10 @@ void ProcessIntWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, pcPacket[s32PktLen++] = sizeof(WILC_Uint32); /* Value */ - pcPacket[s32PktLen++] = (WILC_Uint8)(u32val & 0xFF); - pcPacket[s32PktLen++] = (WILC_Uint8)((u32val >> 8) & 0xFF); - pcPacket[s32PktLen++] = (WILC_Uint8)((u32val >> 16) & 0xFF); - pcPacket[s32PktLen++] = (WILC_Uint8)((u32val >> 24) & 0xFF); + pcPacket[s32PktLen++] = (u8)(u32val & 0xFF); + pcPacket[s32PktLen++] = (u8)((u32val >> 8) & 0xFF); + pcPacket[s32PktLen++] = (u8)((u32val >> 16) & 0xFF); + pcPacket[s32PktLen++] = (u8)((u32val >> 24) & 0xFF); } *ps32PktLen = s32PktLen; } @@ -1263,7 +1263,7 @@ void ProcessIntWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, /*****************************************************************************/ void ProcessIPwid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, - tstrWID *pstrWID, WILC_Uint8 *pu8ip) + tstrWID *pstrWID, u8 *pu8ip) { WILC_Uint32 u32val = 0; WILC_Sint32 s32PktLen = *ps32PktLen; @@ -1274,8 +1274,8 @@ void ProcessIPwid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, } /* WID */ - pcPacket[s32PktLen++] = (WILC_Uint8)(pstrWID->u16WIDid & 0xFF); - pcPacket[s32PktLen++] = (WILC_Uint8)((pstrWID->u16WIDid >> 8) & 0xFF); + pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid & 0xFF); + pcPacket[s32PktLen++] = (u8)((pstrWID->u16WIDid >> 8) & 0xFF); if (g_oper_mode == SET_CFG) { /* Length */ @@ -1285,10 +1285,10 @@ void ProcessIPwid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, conv_ip_to_int(pu8ip, &u32val); /* Value */ - pcPacket[s32PktLen++] = (WILC_Uint8)(u32val & 0xFF); - pcPacket[s32PktLen++] = (WILC_Uint8)((u32val >> 8) & 0xFF); - pcPacket[s32PktLen++] = (WILC_Uint8)((u32val >> 16) & 0xFF); - pcPacket[s32PktLen++] = (WILC_Uint8)((u32val >> 24) & 0xFF); + pcPacket[s32PktLen++] = (u8)(u32val & 0xFF); + pcPacket[s32PktLen++] = (u8)((u32val >> 8) & 0xFF); + pcPacket[s32PktLen++] = (u8)((u32val >> 16) & 0xFF); + pcPacket[s32PktLen++] = (u8)((u32val >> 24) & 0xFF); } *ps32PktLen = s32PktLen; } @@ -1321,7 +1321,7 @@ void ProcessIPwid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, /*****************************************************************************/ void ProcessStrWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, - tstrWID *pstrWID, WILC_Uint8 *pu8val, WILC_Sint32 s32ValueSize) + tstrWID *pstrWID, u8 *pu8val, WILC_Sint32 s32ValueSize) { WILC_Uint16 u16MsgLen = 0; WILC_Uint16 idx = 0; @@ -1332,8 +1332,8 @@ void ProcessStrWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, } /* WID */ - pcPacket[s32PktLen++] = (WILC_Uint8)(pstrWID->u16WIDid & 0xFF); - pcPacket[s32PktLen++] = (WILC_Uint8)((pstrWID->u16WIDid >> 8) & 0xFF); + pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid & 0xFF); + pcPacket[s32PktLen++] = (u8)((pstrWID->u16WIDid >> 8) & 0xFF); if (g_oper_mode == SET_CFG) { /* Message Length */ @@ -1341,7 +1341,7 @@ void ProcessStrWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, u16MsgLen = (WILC_Uint16)s32ValueSize; /* Length */ - pcPacket[s32PktLen++] = (WILC_Uint8)u16MsgLen; + pcPacket[s32PktLen++] = (u8)u16MsgLen; /* Value */ for (idx = 0; idx < u16MsgLen; idx++) @@ -1378,7 +1378,7 @@ void ProcessStrWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, /*****************************************************************************/ void ProcessAdrWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, - tstrWID *pstrWID, WILC_Uint8 *pu8val) + tstrWID *pstrWID, u8 *pu8val) { WILC_Uint16 u16MsgLen = 0; WILC_Sint32 s32PktLen = *ps32PktLen; @@ -1389,15 +1389,15 @@ void ProcessAdrWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, } /* WID */ - pcPacket[s32PktLen++] = (WILC_Uint8)(pstrWID->u16WIDid & 0xFF); - pcPacket[s32PktLen++] = (WILC_Uint8)((pstrWID->u16WIDid >> 8) & 0xFF); + pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid & 0xFF); + pcPacket[s32PktLen++] = (u8)((pstrWID->u16WIDid >> 8) & 0xFF); if (g_oper_mode == SET_CFG) { /* Message Length */ u16MsgLen = MAC_ADDR_LEN; /* Length */ - pcPacket[s32PktLen++] = (WILC_Uint8)u16MsgLen; + pcPacket[s32PktLen++] = (u8)u16MsgLen; /* Value */ extract_mac_addr(pu8val, pcPacket + s32PktLen); @@ -1442,14 +1442,14 @@ void ProcessAdrWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, /*****************************************************************************/ void ProcessBinWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, - tstrWID *pstrWID, WILC_Uint8 *pu8val, WILC_Sint32 s32ValueSize) + tstrWID *pstrWID, u8 *pu8val, WILC_Sint32 s32ValueSize) { /* WILC_ERROR("processing Binary WIDs is not supported \n"); */ WILC_Uint16 u16MsgLen = 0; WILC_Uint16 idx = 0; WILC_Sint32 s32PktLen = *ps32PktLen; - WILC_Uint8 u8checksum = 0; + u8 u8checksum = 0; if (pstrWID == NULL) { PRINT_WRN(CORECONFIG_DBG, "Can't set BIN val, NULL structure\n"); @@ -1457,17 +1457,17 @@ void ProcessBinWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, } /* WID */ - pcPacket[s32PktLen++] = (WILC_Uint8)(pstrWID->u16WIDid & 0xFF); - pcPacket[s32PktLen++] = (WILC_Uint8)((pstrWID->u16WIDid >> 8) & 0xFF); + pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid & 0xFF); + pcPacket[s32PktLen++] = (u8)((pstrWID->u16WIDid >> 8) & 0xFF); if (g_oper_mode == SET_CFG) { /* Message Length */ u16MsgLen = (WILC_Uint16)s32ValueSize; /* Length */ - /* pcPacket[s32PktLen++] = (WILC_Uint8)u16MsgLen; */ - pcPacket[s32PktLen++] = (WILC_Uint8)(u16MsgLen & 0xFF); - pcPacket[s32PktLen++] = (WILC_Uint8)((u16MsgLen >> 8) & 0xFF); + /* pcPacket[s32PktLen++] = (u8)u16MsgLen; */ + pcPacket[s32PktLen++] = (u8)(u16MsgLen & 0xFF); + pcPacket[s32PktLen++] = (u8)((u16MsgLen >> 8) & 0xFF); /* Value */ for (idx = 0; idx < u16MsgLen; idx++) @@ -1516,7 +1516,7 @@ void ProcessBinWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, /* */ /*****************************************************************************/ -WILC_Sint32 further_process_response(WILC_Uint8 *resp, +WILC_Sint32 further_process_response(u8 *resp, WILC_Uint16 u16WIDid, WILC_Uint16 cfg_len, WILC_Bool process_wid_num, @@ -1525,10 +1525,10 @@ WILC_Sint32 further_process_response(WILC_Uint8 *resp, { WILC_Uint32 retval = 0; WILC_Uint32 idx = 0; - WILC_Uint8 cfg_chr = 0; + u8 cfg_chr = 0; WILC_Uint16 cfg_sht = 0; WILC_Uint32 cfg_int = 0; - WILC_Uint8 cfg_str[256] = {0}; + u8 cfg_str[256] = {0}; tenuWIDtype enuWIDtype = WID_UNDEF; if (process_wid_num) { @@ -1621,7 +1621,7 @@ WILC_Sint32 further_process_response(WILC_Uint8 *resp, case WID_BIN_DATA: #if 0 /* FILE *fp_bin = NULL; */ - WILC_Uint8 first_bin_wid = 1; + u8 first_bin_wid = 1; if (first_bin_wid) { /* fp_bin = fopen("wid_response.bin","wb"); */ first_bin_wid = 0; @@ -1686,7 +1686,7 @@ WILC_Sint32 further_process_response(WILC_Uint8 *resp, /* */ /*****************************************************************************/ -WILC_Sint32 ParseResponse(WILC_Uint8 *resp, tstrWID *pstrWIDcfgResult) +WILC_Sint32 ParseResponse(u8 *resp, tstrWID *pstrWIDcfgResult) { WILC_Uint16 u16RespLen = 0; WILC_Uint16 u16WIDid = 0; @@ -1759,7 +1759,7 @@ WILC_Sint32 ParseResponse(WILC_Uint8 *resp, tstrWID *pstrWIDcfgResult) * @version 1.0 */ -WILC_Sint32 ParseWriteResponse(WILC_Uint8 *pu8RespBuffer) +WILC_Sint32 ParseWriteResponse(u8 *pu8RespBuffer) { WILC_Sint32 s32Error = WILC_FAIL; WILC_Uint16 u16RespLen = 0; @@ -1834,8 +1834,8 @@ WILC_Sint32 CreatePacketHeader(WILC_Char *pcpacket, WILC_Sint32 *ps32PacketLengt pcpacket[u16MsgInd++] = g_seqno++; /* Message Length */ - pcpacket[u16MsgInd++] = (WILC_Uint8)(u16MsgLen & 0xFF); - pcpacket[u16MsgInd++] = (WILC_Uint8)((u16MsgLen >> 8) & 0xFF); + pcpacket[u16MsgInd++] = (u8)(u16MsgLen & 0xFF); + pcpacket[u16MsgInd++] = (u8)((u16MsgLen >> 8) & 0xFF); *ps32PacketLength = u16MsgLen; @@ -1948,7 +1948,7 @@ WILC_Sint32 ConfigWaitResponse(WILC_Char *pcRespBuffer, WILC_Sint32 s32MaxRespBu * @version 1.0 */ #ifdef SIMULATION -WILC_Sint32 SendConfigPkt(WILC_Uint8 u8Mode, tstrWID *pstrWIDs, +WILC_Sint32 SendConfigPkt(u8 u8Mode, tstrWID *pstrWIDs, WILC_Uint32 u32WIDsCount, WILC_Bool bRespRequired, WILC_Uint32 drvHandler) { WILC_Sint32 s32Error = WILC_SUCCESS; @@ -2049,10 +2049,10 @@ WILC_Sint32 ConfigProvideResponse(WILC_Char *pcRespBuffer, WILC_Sint32 s32RespLe * @version 1.0 */ -WILC_Sint32 ConfigPktReceived(WILC_Uint8 *pu8RxPacket, WILC_Sint32 s32RxPacketLen) +WILC_Sint32 ConfigPktReceived(u8 *pu8RxPacket, WILC_Sint32 s32RxPacketLen) { WILC_Sint32 s32Error = WILC_SUCCESS; - WILC_Uint8 u8MsgType = 0; + u8 u8MsgType = 0; u8MsgType = pu8RxPacket[0]; @@ -2127,7 +2127,7 @@ extern wilc_wlan_oup_t *gpstrWlanOps; * @date 1 Mar 2012 * @version 1.0 */ -WILC_Sint32 SendConfigPkt(WILC_Uint8 u8Mode, tstrWID *pstrWIDs, +WILC_Sint32 SendConfigPkt(u8 u8Mode, tstrWID *pstrWIDs, WILC_Uint32 u32WIDsCount, WILC_Bool bRespRequired, WILC_Uint32 drvHandler) { WILC_Sint32 counter = 0, ret = 0; diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h index 9cdfa2ac8fca..73cdbef653ab 100644 --- a/drivers/staging/wilc1000/coreconfigurator.h +++ b/drivers/staging/wilc1000/coreconfigurator.h @@ -402,30 +402,30 @@ typedef struct { } tstrWID; typedef struct { - WILC_Uint8 u8Full; - WILC_Uint8 u8Index; + u8 u8Full; + u8 u8Index; WILC_Sint8 as8RSSI[NUM_RSSI]; } tstrRSSI; /* This structure is used to support parsing of the received 'N' message */ typedef struct { WILC_Sint8 s8rssi; WILC_Uint16 u16CapInfo; - WILC_Uint8 au8ssid[MAX_SSID_LEN]; - WILC_Uint8 u8SsidLen; - WILC_Uint8 au8bssid[6]; + u8 au8ssid[MAX_SSID_LEN]; + u8 u8SsidLen; + u8 au8bssid[6]; WILC_Uint16 u16BeaconPeriod; - WILC_Uint8 u8DtimPeriod; - WILC_Uint8 u8channel; + u8 u8DtimPeriod; + u8 u8channel; unsigned long u32TimeRcvdInScanCached; /* of type unsigned long to be accepted by the linux kernel macro time_after() */ unsigned long u32TimeRcvdInScan; WILC_Bool bNewNetwork; #ifdef AGING_ALG - WILC_Uint8 u8Found; + u8 u8Found; #endif #ifdef WILC_P2P WILC_Uint32 u32Tsf; /* time-stamp [Low only 32 bit] */ #endif - WILC_Uint8 *pu8IEs; + u8 *pu8IEs; WILC_Uint16 u16IEsLen; void *pJoinParams; tstrRSSI strRssi; @@ -437,16 +437,16 @@ typedef struct { WILC_Uint16 u16capability; WILC_Uint16 u16ConnectStatus; WILC_Uint16 u16AssocID; - WILC_Uint8 *pu8RespIEs; + u8 *pu8RespIEs; WILC_Uint16 u16RespIEsLen; } tstrConnectRespInfo; typedef struct { - WILC_Uint8 au8bssid[6]; - WILC_Uint8 *pu8ReqIEs; + u8 au8bssid[6]; + u8 *pu8ReqIEs; size_t ReqIEsLen; - WILC_Uint8 *pu8RespIEs; + u8 *pu8RespIEs; WILC_Uint16 u16RespIEsLen; WILC_Uint16 u16ConnectStatus; } tstrConnectInfo; @@ -455,19 +455,19 @@ typedef struct { typedef struct { WILC_Uint16 u16reason; - WILC_Uint8 *ie; + u8 *ie; size_t ie_len; } tstrDisconnectNotifInfo; #ifndef CONNECT_DIRECT typedef struct wid_site_survey_reslts { WILC_Char SSID[MAX_SSID_LEN]; - WILC_Uint8 BssType; - WILC_Uint8 Channel; - WILC_Uint8 SecurityStatus; - WILC_Uint8 BSSID[6]; + u8 BssType; + u8 Channel; + u8 SecurityStatus; + u8 BSSID[6]; WILC_Char RxPower; - WILC_Uint8 Reserved; + u8 Reserved; } wid_site_survey_reslts_s; #endif @@ -475,24 +475,24 @@ typedef struct wid_site_survey_reslts { extern WILC_Sint32 CoreConfiguratorInit(void); extern WILC_Sint32 CoreConfiguratorDeInit(void); -extern WILC_Sint32 SendConfigPkt(WILC_Uint8 u8Mode, tstrWID *pstrWIDs, +extern WILC_Sint32 SendConfigPkt(u8 u8Mode, tstrWID *pstrWIDs, WILC_Uint32 u32WIDsCount, WILC_Bool bRespRequired, WILC_Uint32 drvHandler); -extern WILC_Sint32 ParseNetworkInfo(WILC_Uint8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo); +extern WILC_Sint32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo); extern WILC_Sint32 DeallocateNetworkInfo(tstrNetworkInfo *pstrNetworkInfo); -extern WILC_Sint32 ParseAssocRespInfo(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32BufferLen, +extern WILC_Sint32 ParseAssocRespInfo(u8 *pu8Buffer, WILC_Uint32 u32BufferLen, tstrConnectRespInfo **ppstrConnectRespInfo); extern WILC_Sint32 DeallocateAssocRespInfo(tstrConnectRespInfo *pstrConnectRespInfo); #ifndef CONNECT_DIRECT -extern WILC_Sint32 ParseSurveyResults(WILC_Uint8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE], +extern WILC_Sint32 ParseSurveyResults(u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE], wid_site_survey_reslts_s **ppstrSurveyResults, WILC_Uint32 *pu32SurveyResultsCount); extern WILC_Sint32 DeallocateSurveyResults(wid_site_survey_reslts_s *pstrSurveyResults); #endif extern WILC_Sint32 SendRawPacket(WILC_Sint8 *pspacket, WILC_Sint32 s32PacketLen); -extern void NetworkInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length); -void GnrlAsyncInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length); -void host_int_ScanCompleteReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length); +extern void NetworkInfoReceived(u8 *pu8Buffer, WILC_Uint32 u32Length); +void GnrlAsyncInfoReceived(u8 *pu8Buffer, WILC_Uint32 u32Length); +void host_int_ScanCompleteReceived(u8 *pu8Buffer, WILC_Uint32 u32Length); #endif diff --git a/drivers/staging/wilc1000/fifo_buffer.c b/drivers/staging/wilc1000/fifo_buffer.c index e23d11130728..f807bfb72539 100644 --- a/drivers/staging/wilc1000/fifo_buffer.c +++ b/drivers/staging/wilc1000/fifo_buffer.c @@ -45,7 +45,7 @@ WILC_Uint32 FIFO_DeInit(tHANDLE hFifo) return u32Error; } -WILC_Uint32 FIFO_ReadBytes(tHANDLE hFifo, WILC_Uint8 *pu8Buffer, WILC_Uint32 u32BytesToRead, WILC_Uint32 *pu32BytesRead) +WILC_Uint32 FIFO_ReadBytes(tHANDLE hFifo, u8 *pu8Buffer, WILC_Uint32 u32BytesToRead, WILC_Uint32 *pu32BytesRead) { WILC_Uint32 u32Error = 0; tstrFifoHandler *pstrFifoHandler = (tstrFifoHandler *) hFifo; @@ -86,7 +86,7 @@ WILC_Uint32 FIFO_ReadBytes(tHANDLE hFifo, WILC_Uint8 *pu8Buffer, WILC_Uint32 u32 return u32Error; } -WILC_Uint32 FIFO_WriteBytes(tHANDLE hFifo, WILC_Uint8 *pu8Buffer, WILC_Uint32 u32BytesToWrite, WILC_Bool bForceOverWrite) +WILC_Uint32 FIFO_WriteBytes(tHANDLE hFifo, u8 *pu8Buffer, WILC_Uint32 u32BytesToWrite, WILC_Bool bForceOverWrite) { WILC_Uint32 u32Error = 0; tstrFifoHandler *pstrFifoHandler = (tstrFifoHandler *) hFifo; diff --git a/drivers/staging/wilc1000/fifo_buffer.h b/drivers/staging/wilc1000/fifo_buffer.h index c7e140be8fab..4d120503c4b2 100644 --- a/drivers/staging/wilc1000/fifo_buffer.h +++ b/drivers/staging/wilc1000/fifo_buffer.h @@ -5,7 +5,7 @@ #define tHANDLE void * typedef struct { - WILC_Uint8 *pu8Buffer; + u8 *pu8Buffer; WILC_Uint32 u32BufferLength; WILC_Uint32 u32WriteOffset; WILC_Uint32 u32ReadOffset; @@ -17,7 +17,7 @@ typedef struct { extern WILC_Uint32 FIFO_InitBuffer(tHANDLE *hBuffer, WILC_Uint32 u32BufferLength); extern WILC_Uint32 FIFO_DeInit(tHANDLE hFifo); -extern WILC_Uint32 FIFO_ReadBytes(tHANDLE hFifo, WILC_Uint8 *pu8Buffer, +extern WILC_Uint32 FIFO_ReadBytes(tHANDLE hFifo, u8 *pu8Buffer, WILC_Uint32 u32BytesToRead, WILC_Uint32 *pu32BytesRead); -extern WILC_Uint32 FIFO_WriteBytes(tHANDLE hFifo, WILC_Uint8 *pu8Buffer, - WILC_Uint32 u32BytesToWrite, WILC_Bool bForceOverWrite); \ No newline at end of file +extern WILC_Uint32 FIFO_WriteBytes(tHANDLE hFifo, u8 *pu8Buffer, + WILC_Uint32 u32BytesToWrite, WILC_Bool bForceOverWrite); diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 462bb10e930b..afe5126f3655 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -5,7 +5,7 @@ extern WILC_Sint32 TransportInit(void); extern WILC_Sint32 TransportDeInit(void); -extern WILC_Uint8 connecting; +extern u8 connecting; #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP extern WILC_TimerHandle hDuringIpTimer; @@ -13,7 +13,7 @@ extern WILC_TimerHandle hDuringIpTimer; extern WILC_Bool bEnablePS; /*BugID_5137*/ -extern WILC_Uint8 g_wilc_initialized; +extern u8 g_wilc_initialized; /*****************************************************************************/ /* Macros */ /*****************************************************************************/ @@ -96,13 +96,13 @@ typedef struct _tstrHostIFCfgParamAttr { * @version 1.0 */ typedef struct _tstrHostIFwpaAttr { - WILC_Uint8 *pu8key; - const WILC_Uint8 *pu8macaddr; - WILC_Uint8 *pu8seq; - WILC_Uint8 u8seqlen; - WILC_Uint8 u8keyidx; - WILC_Uint8 u8Keylen; - WILC_Uint8 u8Ciphermode; + u8 *pu8key; + const u8 *pu8macaddr; + u8 *pu8seq; + u8 u8seqlen; + u8 u8keyidx; + u8 u8Keylen; + u8 u8Ciphermode; } tstrHostIFwpaAttr; @@ -117,10 +117,10 @@ typedef struct _tstrHostIFwpaAttr { * @version 1.0 */ typedef struct _tstrHostIFwepAttr { - WILC_Uint8 *pu8WepKey; - WILC_Uint8 u8WepKeylen; - WILC_Uint8 u8Wepidx; - WILC_Uint8 u8mode; + u8 *pu8WepKey; + u8 u8WepKeylen; + u8 u8Wepidx; + u8 u8mode; AUTHTYPE_T tenuAuth_type; } tstrHostIFwepAttr; @@ -153,7 +153,7 @@ typedef union _tuniHostIFkeyAttr { */ typedef struct _tstrHostIFkeyAttr { tenuKeyType enuKeyType; - WILC_Uint8 u8KeyAction; + u8 u8KeyAction; tuniHostIFkeyAttr uniHostIFkeyAttr; } tstrHostIFkeyAttr; @@ -171,11 +171,11 @@ typedef struct _tstrHostIFkeyAttr { * @version 1.0 */ typedef struct _tstrHostIFscanAttr { - WILC_Uint8 u8ScanSource; - WILC_Uint8 u8ScanType; - WILC_Uint8 *pu8ChnlFreqList; - WILC_Uint8 u8ChnlListLen; - WILC_Uint8 *pu8IEs; + u8 u8ScanSource; + u8 u8ScanType; + u8 *pu8ChnlFreqList; + u8 u8ChnlListLen; + u8 *pu8IEs; size_t IEsLen; tWILCpfScanResult pfScanResult; void *pvUserArg; @@ -195,16 +195,16 @@ typedef struct _tstrHostIFscanAttr { * @version 1.0 */ typedef struct _tstrHostIFconnectAttr { - WILC_Uint8 *pu8bssid; - WILC_Uint8 *pu8ssid; + u8 *pu8bssid; + u8 *pu8ssid; size_t ssidLen; - WILC_Uint8 *pu8IEs; + u8 *pu8IEs; size_t IEsLen; - WILC_Uint8 u8security; + u8 u8security; tWILCpfConnectResult pfConnectResult; void *pvUserArg; AUTHTYPE_T tenuAuth_type; - WILC_Uint8 u8channel; + u8 u8channel; void *pJoinParams; } tstrHostIFconnectAttr; @@ -219,7 +219,7 @@ typedef struct _tstrHostIFconnectAttr { * @version 1.0 */ typedef struct _tstrRcvdGnrlAsyncInfo { - WILC_Uint8 *pu8Buffer; + u8 *pu8Buffer; WILC_Uint32 u32Length; } tstrRcvdGnrlAsyncInfo; @@ -234,7 +234,7 @@ typedef struct _tstrRcvdGnrlAsyncInfo { * @version 1.0 */ typedef struct _tstrHostIFSetChan { - WILC_Uint8 u8SetChan; + u8 u8SetChan; } tstrHostIFSetChan; /*! @@ -248,7 +248,7 @@ typedef struct _tstrHostIFSetChan { * @version 1.0 */ typedef struct _tstrHostIFGetChan { - WILC_Uint8 u8GetChan; + u8 u8GetChan; } tstrHostIFGetChan; /*bug3819: Add Scan acomplete notification to host*/ @@ -264,7 +264,7 @@ typedef struct _tstrHostIFGetChan { */ /*typedef struct _tstrScanComplete * { - * WILC_Uint8* pu8Buffer; + * u8* pu8Buffer; * WILC_Uint32 u32Length; * } tstrScanComplete;*/ @@ -283,10 +283,10 @@ typedef struct _tstrHostIFSetBeacon { WILC_Uint32 u32DTIMPeriod; /*!< DTIM Period. Indicates how many Beacon frames * (including the current frame) appear before the next DTIM */ WILC_Uint32 u32HeadLen; /*!< Length of the head buffer in bytes */ - WILC_Uint8 *pu8Head; /*!< Pointer to the beacon's head buffer. Beacon's head is the part + u8 *pu8Head; /*!< Pointer to the beacon's head buffer. Beacon's head is the part * from the beacon's start till the TIM element, NOT including the TIM */ WILC_Uint32 u32TailLen; /*!< Length of the tail buffer in bytes */ - WILC_Uint8 *pu8Tail; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just + u8 *pu8Tail; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just * after the TIM inormation element */ } tstrHostIFSetBeacon; @@ -303,7 +303,7 @@ typedef struct _tstrHostIFSetBeacon { * @version 1.0 */ typedef struct _tstrHostIFDelBeacon { - WILC_Uint8 u8dummy; + u8 u8dummy; } tstrHostIFDelBeacon; /*! @@ -334,8 +334,8 @@ typedef struct { */ typedef struct { - WILC_Uint8 au8Sta_DelAllSta[MAX_NUM_STA][ETH_ALEN]; - WILC_Uint8 u8Num_AssocSta; + u8 au8Sta_DelAllSta[MAX_NUM_STA][ETH_ALEN]; + u8 u8Num_AssocSta; } tstrHostIFDelAllSta; /*! @@ -350,7 +350,7 @@ typedef struct { */ typedef struct { - WILC_Uint8 au8MacAddr[ETH_ALEN]; + u8 au8MacAddr[ETH_ALEN]; } tstrHostIFDelSta; /*! @@ -395,8 +395,8 @@ typedef struct { */ typedef struct { - WILC_Uint8 *au8IPAddr; - WILC_Uint8 idx; + u8 *au8IPAddr; + u8 idx; } tstrHostIFSetIPAddr; /*! @@ -410,7 +410,7 @@ typedef struct { * @version 1.0 */ typedef struct { - WILC_Uint8 mac[6]; + u8 mac[6]; } tstrHostIfStaInactiveT; /**/ @@ -476,8 +476,8 @@ typedef struct _tstrHostIFmsg { #ifdef CONNECT_DIRECT typedef struct _tstrWidJoinReqExt { WILC_Char SSID[MAX_SSID_LEN]; - WILC_Uint8 u8channel; - WILC_Uint8 BSSID[6]; + u8 u8channel; + u8 BSSID[6]; } tstrWidJoinReqExt; #endif @@ -486,39 +486,39 @@ typedef struct _tstrWidJoinReqExt { /*Struct containg joinParam of each AP*/ typedef struct _tstrJoinBssParam { BSSTYPE_T bss_type; - WILC_Uint8 dtim_period; + u8 dtim_period; WILC_Uint16 beacon_period; WILC_Uint16 cap_info; - WILC_Uint8 au8bssid[6]; + u8 au8bssid[6]; WILC_Char ssid[MAX_SSID_LEN]; - WILC_Uint8 ssidLen; - WILC_Uint8 supp_rates[MAX_RATES_SUPPORTED + 1]; - WILC_Uint8 ht_capable; - WILC_Uint8 wmm_cap; - WILC_Uint8 uapsd_cap; + u8 ssidLen; + u8 supp_rates[MAX_RATES_SUPPORTED + 1]; + u8 ht_capable; + u8 wmm_cap; + u8 uapsd_cap; WILC_Bool rsn_found; - WILC_Uint8 rsn_grp_policy; - WILC_Uint8 mode_802_11i; - WILC_Uint8 rsn_pcip_policy[3]; - WILC_Uint8 rsn_auth_policy[3]; - WILC_Uint8 rsn_cap[2]; + u8 rsn_grp_policy; + u8 mode_802_11i; + u8 rsn_pcip_policy[3]; + u8 rsn_auth_policy[3]; + u8 rsn_cap[2]; struct _tstrJoinParam *nextJoinBss; #ifdef WILC_P2P WILC_Uint32 tsf; - WILC_Uint8 u8NoaEnbaled; - WILC_Uint8 u8OppEnable; - WILC_Uint8 u8CtWindow; - WILC_Uint8 u8Count; - WILC_Uint8 u8Index; - WILC_Uint8 au8Duration[4]; - WILC_Uint8 au8Interval[4]; - WILC_Uint8 au8StartTime[4]; + u8 u8NoaEnbaled; + u8 u8OppEnable; + u8 u8CtWindow; + u8 u8Count; + u8 u8Index; + u8 au8Duration[4]; + u8 au8Interval[4]; + u8 au8StartTime[4]; #endif } tstrJoinBssParam; /*Bug4218: Parsing Join Param*/ /*a linked list table containing needed join parameters entries for each AP found in most recent scan*/ typedef struct _tstrBssTable { - WILC_Uint8 u8noBssEntries; + u8 u8noBssEntries; tstrJoinBssParam *head; tstrJoinBssParam *tail; } tstrBssTable; @@ -542,7 +542,7 @@ tstrWILC_WFIDrv *gWFiDrvHandle = NULL; #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP WILC_Bool g_obtainingIP = WILC_FALSE; #endif -WILC_Uint8 P2P_LISTEN_STATE; +u8 P2P_LISTEN_STATE; static struct task_struct *HostIFthreadHandler; static WILC_MsgQueueHandle gMsgQHostIF; static struct semaphore hSemHostIFthrdEnd; @@ -554,34 +554,34 @@ WILC_TimerHandle g_hPeriodicRSSI; -WILC_Uint8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN]; +u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN]; #ifndef CONNECT_DIRECT -static WILC_Uint8 gapu8RcvdSurveyResults[2][MAX_SURVEY_RESULT_FRAG_SIZE]; +static u8 gapu8RcvdSurveyResults[2][MAX_SURVEY_RESULT_FRAG_SIZE]; #endif -static WILC_Uint8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE]; +static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE]; WILC_Bool gbScanWhileConnected = WILC_FALSE; static WILC_Sint8 gs8Rssi; static WILC_Sint8 gs8lnkspd; -static WILC_Uint8 gu8Chnl; -static WILC_Uint8 gs8SetIP[2][4]; -static WILC_Uint8 gs8GetIP[2][4]; +static u8 gu8Chnl; +static u8 gs8SetIP[2][4]; +static u8 gs8GetIP[2][4]; #ifdef WILC_AP_EXTERNAL_MLME static WILC_Uint32 gu32InactiveTime; -static WILC_Uint8 gu8DelBcn; +static u8 gu8DelBcn; #endif #ifndef SIMULATION static WILC_Uint32 gu32WidConnRstHack; #endif /*BugID_5137*/ -WILC_Uint8 *gu8FlushedJoinReq; -WILC_Uint8 *gu8FlushedInfoElemAsoc; -WILC_Uint8 gu8Flushed11iMode; -WILC_Uint8 gu8FlushedAuthType; +u8 *gu8FlushedJoinReq; +u8 *gu8FlushedInfoElemAsoc; +u8 gu8Flushed11iMode; +u8 gu8FlushedAuthType; WILC_Uint32 gu32FlushedJoinReqSize; WILC_Uint32 gu32FlushedInfoElemAsocSize; WILC_Uint32 gu8FlushedJoinReqDrvHandler; @@ -728,13 +728,13 @@ static WILC_Sint32 Handle_SetOperationMode(void *drvHandler, tstrHostIfSetOperat /** * @brief host_int_set_IPAddress * @details Setting IP address params in message queue - * @param[in] WILC_WFIDrvHandle hWFIDrv, WILC_Uint8* pu8IPAddr + * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr * @return Error code. * @author * @date * @version 1.0 */ -WILC_Sint32 Handle_set_IPAddress(void *drvHandler, WILC_Uint8 *pu8IPAddr, WILC_Uint8 idx) +WILC_Sint32 Handle_set_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx) { WILC_Sint32 s32Error = WILC_SUCCESS; @@ -752,7 +752,7 @@ WILC_Sint32 Handle_set_IPAddress(void *drvHandler, WILC_Uint8 *pu8IPAddr, WILC_U /*prepare configuration packet*/ strWID.u16WIDid = (WILC_Uint16)WID_IP_ADDRESS; strWID.enuWIDtype = WID_STR; - strWID.ps8WidVal = (WILC_Uint8 *)pu8IPAddr; + strWID.ps8WidVal = (u8 *)pu8IPAddr; strWID.s32ValueSize = IP_ALEN; s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); @@ -780,13 +780,13 @@ WILC_Sint32 Handle_set_IPAddress(void *drvHandler, WILC_Uint8 *pu8IPAddr, WILC_U /** * @brief Handle_get_IPAddress * @details Setting IP address params in message queue - * @param[in] WILC_WFIDrvHandle hWFIDrv, WILC_Uint8* pu8IPAddr + * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr * @return Error code. * @author * @date * @version 1.0 */ -WILC_Sint32 Handle_get_IPAddress(void *drvHandler, WILC_Uint8 *pu8IPAddr, WILC_Uint8 idx) +WILC_Sint32 Handle_get_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx) { WILC_Sint32 s32Error = WILC_SUCCESS; @@ -796,12 +796,12 @@ WILC_Sint32 Handle_get_IPAddress(void *drvHandler, WILC_Uint8 *pu8IPAddr, WILC_U /*prepare configuration packet*/ strWID.u16WIDid = (WILC_Uint16)WID_IP_ADDRESS; strWID.enuWIDtype = WID_STR; - strWID.ps8WidVal = (WILC_Uint8 *)WILC_MALLOC(IP_ALEN); + strWID.ps8WidVal = (u8 *)WILC_MALLOC(IP_ALEN); strWID.s32ValueSize = IP_ALEN; s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); - PRINT_INFO(HOSTINF_DBG, "%d.%d.%d.%d\n", (WILC_Uint8)(strWID.ps8WidVal[0]), (WILC_Uint8)(strWID.ps8WidVal[1]), (WILC_Uint8)(strWID.ps8WidVal[2]), (WILC_Uint8)(strWID.ps8WidVal[3])); + PRINT_INFO(HOSTINF_DBG, "%d.%d.%d.%d\n", (u8)(strWID.ps8WidVal[0]), (u8)(strWID.ps8WidVal[1]), (u8)(strWID.ps8WidVal[2]), (u8)(strWID.ps8WidVal[3])); WILC_memcpy(gs8GetIP[idx], strWID.ps8WidVal, IP_ALEN); @@ -845,7 +845,7 @@ static WILC_Sint32 Handle_SetMacAddress(void *drvHandler, tstrHostIfSetMacAddres WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWID; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; - WILC_Uint8 *mac_buf = (WILC_Uint8 *)WILC_MALLOC(ETH_ALEN); + u8 *mac_buf = (u8 *)WILC_MALLOC(ETH_ALEN); if (mac_buf == NULL) { PRINT_ER("No buffer to send mac address\n"); return WILC_FAIL; @@ -925,7 +925,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWIDList[32]; - WILC_Uint8 u8WidCnt = 0; + u8 u8WidCnt = 0; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -946,7 +946,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type; strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); - pstrWFIDrv->strCfgValues.bss_type = (WILC_Uint8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type; + pstrWFIDrv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -964,7 +964,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type; strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); - pstrWFIDrv->strCfgValues.auth_type = (WILC_Uint8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type; + pstrWFIDrv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -996,7 +996,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode; strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); - pstrWFIDrv->strCfgValues.power_mgmt_mode = (WILC_Uint8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode; + pstrWFIDrv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -1078,7 +1078,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed; strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); - pstrWFIDrv->strCfgValues.short_slot_allowed = (WILC_Uint8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed; + pstrWFIDrv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -1094,7 +1094,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled; strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); - pstrWFIDrv->strCfgValues.txop_prot_disabled = (WILC_Uint8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled; + pstrWFIDrv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -1137,7 +1137,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled; strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); - pstrWFIDrv->strCfgValues.site_survey_enabled = (WILC_Uint8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled; + pstrWFIDrv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -1199,7 +1199,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&curr_tx_rate; strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16); - pstrWFIDrv->strCfgValues.curr_tx_rate = (WILC_Uint8)curr_tx_rate; + pstrWFIDrv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -1251,9 +1251,9 @@ static WILC_Sint32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFs tstrWID strWIDList[5]; WILC_Uint32 u32WidsCount = 0; WILC_Uint32 i; - WILC_Uint8 *pu8Buffer; - WILC_Uint8 valuesize = 0; - WILC_Uint8 *pu8HdnNtwrksWidVal = NULL; + u8 *pu8Buffer; + u8 valuesize = 0; + u8 *pu8HdnNtwrksWidVal = NULL; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler; PRINT_D(HOSTINF_DBG, "Setting SCAN params\n"); @@ -1433,7 +1433,7 @@ static WILC_Sint32 Handle_ScanDone(void *drvHandler, tenuScanEvent enuEvent) tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; - WILC_Uint8 u8abort_running_scan; + u8 u8abort_running_scan; tstrWID strWID; @@ -1485,7 +1485,7 @@ static WILC_Sint32 Handle_ScanDone(void *drvHandler, tenuScanEvent enuEvent) * @date * @version 1.0 */ -WILC_Uint8 u8ConnectedSSID[6] = {0}; +u8 u8ConnectedSSID[6] = {0}; static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFconnectAttr) { tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler; @@ -1496,10 +1496,10 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH #ifndef CONNECT_DIRECT WILC_Sint32 s32Err = WILC_SUCCESS; WILC_Uint32 i; - WILC_Uint8 u8bssDscListIndex; + u8 u8bssDscListIndex; wid_site_survey_reslts_s *pstrSurveyResults = NULL; #else - WILC_Uint8 *pu8CurrByte = NULL; + u8 *pu8CurrByte = NULL; /*Bug4218: Parsing Join Param*/ #ifdef WILC_PARSE_SCAN_IN_HOST tstrJoinBssParam *ptstrJoinBssParam; @@ -1576,13 +1576,13 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n"); if (pstrHostIFconnectAttr->pu8bssid != NULL) { - pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = (WILC_Uint8 *)WILC_MALLOC(6); + pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = (u8 *)WILC_MALLOC(6); WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6); } pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen; if (pstrHostIFconnectAttr->pu8ssid != NULL) { - pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = (WILC_Uint8 *)WILC_MALLOC(pstrHostIFconnectAttr->ssidLen + 1); + pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->ssidLen + 1); WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen); pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0'; @@ -1590,7 +1590,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen; if (pstrHostIFconnectAttr->pu8IEs != NULL) { - pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = (WILC_Uint8 *)WILC_MALLOC(pstrHostIFconnectAttr->IEsLen); + pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->IEsLen); WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs, pstrHostIFconnectAttr->IEsLen); } @@ -1696,13 +1696,13 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH #endif if (pstrHostIFconnectAttr->pu8bssid != NULL) { - pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = (WILC_Uint8 *)WILC_MALLOC(6); + pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = (u8 *)WILC_MALLOC(6); WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6); } pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen; if (pstrHostIFconnectAttr->pu8ssid != NULL) { - pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = (WILC_Uint8 *)WILC_MALLOC(pstrHostIFconnectAttr->ssidLen + 1); + pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->ssidLen + 1); WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen); pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0'; @@ -1710,7 +1710,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen; if (pstrHostIFconnectAttr->pu8IEs != NULL) { - pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = (WILC_Uint8 *)WILC_MALLOC(pstrHostIFconnectAttr->IEsLen); + pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->IEsLen); WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs, pstrHostIFconnectAttr->IEsLen); } @@ -1778,7 +1778,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH /*BugID_5137*/ if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) - gu8FlushedAuthType = (WILC_Uint8)pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type; + gu8FlushedAuthType = (u8)pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type; PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type); /* @@ -2017,7 +2017,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH if (pstrHostIFconnectAttr->pu8IEs != NULL) { strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen; - strConnectInfo.pu8ReqIEs = (WILC_Uint8 *)WILC_MALLOC(pstrHostIFconnectAttr->IEsLen); + strConnectInfo.pu8ReqIEs = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->IEsLen); WILC_memcpy(strConnectInfo.pu8ReqIEs, pstrHostIFconnectAttr->pu8IEs, pstrHostIFconnectAttr->IEsLen); @@ -2082,7 +2082,7 @@ static WILC_Sint32 Handle_FlushConnect(void *drvHandler) WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWIDList[5]; WILC_Uint32 u32WidsCount = 0; - WILC_Uint8 *pu8CurrByte = NULL; + u8 *pu8CurrByte = NULL; /* IEs to be inserted in Association Request */ @@ -2176,7 +2176,7 @@ static WILC_Sint32 Handle_ConnectTimeout(void *drvHandler) if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) { strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen; - strConnectInfo.pu8ReqIEs = (WILC_Uint8 *)WILC_MALLOC(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen); + strConnectInfo.pu8ReqIEs = (u8 *)WILC_MALLOC(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen); WILC_memcpy(strConnectInfo.pu8ReqIEs, pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen); @@ -2380,14 +2380,14 @@ static WILC_Sint32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncI /* TODO: mostafa: till now, this function just handles only the received mac status msg, */ /* which carries only 1 WID which have WID ID = WID_STATUS */ WILC_Sint32 s32Error = WILC_SUCCESS; - WILC_Uint8 u8MsgType = 0; - WILC_Uint8 u8MsgID = 0; + u8 u8MsgType = 0; + u8 u8MsgID = 0; WILC_Uint16 u16MsgLen = 0; WILC_Uint16 u16WidID = (WILC_Uint16)WID_NIL; - WILC_Uint8 u8WidLen = 0; - WILC_Uint8 u8MacStatus; - WILC_Uint8 u8MacStatusReasonCode; - WILC_Uint8 u8MacStatusAdditionalInfo; + u8 u8WidLen = 0; + u8 u8MacStatus; + u8 u8MacStatusReasonCode; + u8 u8MacStatusAdditionalInfo; tstrConnectInfo strConnectInfo; tstrDisconnectNotifInfo strDisconnectNotifInfo; WILC_Sint32 s32Err = WILC_SUCCESS; @@ -2467,7 +2467,7 @@ static WILC_Sint32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncI strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen; - strConnectInfo.pu8RespIEs = (WILC_Uint8 *)WILC_MALLOC(pstrConnectRespInfo->u16RespIEsLen); + strConnectInfo.pu8RespIEs = (u8 *)WILC_MALLOC(pstrConnectRespInfo->u16RespIEsLen); WILC_memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs, pstrConnectRespInfo->u16RespIEsLen); } @@ -2511,7 +2511,7 @@ static WILC_Sint32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncI if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) { strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen; - strConnectInfo.pu8ReqIEs = (WILC_Uint8 *)WILC_MALLOC(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen); + strConnectInfo.pu8ReqIEs = (u8 *)WILC_MALLOC(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen); WILC_memcpy(strConnectInfo.pu8ReqIEs, pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen); @@ -2713,8 +2713,8 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) #ifdef WILC_AP_EXTERNAL_MLME tstrWID strWIDList[5]; #endif - WILC_Uint8 i; - WILC_Uint8 *pu8keybuf; + u8 i; + u8 *pu8keybuf; WILC_Sint8 s8idxarray[1]; WILC_Sint8 ret = 0; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -2747,7 +2747,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) strWIDList[2].s32ValueSize = sizeof(WILC_Char); - pu8keybuf = (WILC_Uint8 *)WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen); + pu8keybuf = (u8 *)WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen); if (pu8keybuf == NULL) { @@ -2776,7 +2776,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) { PRINT_D(HOSTINF_DBG, "Handling WEP key\n"); - pu8keybuf = (WILC_Uint8 *)WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2); + pu8keybuf = (u8 *)WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2); if (pu8keybuf == NULL) { PRINT_ER("No buffer to send Key\n"); return -1; @@ -2824,7 +2824,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) case WPARxGtk: #ifdef WILC_AP_EXTERNAL_MLME if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) { - pu8keybuf = (WILC_Uint8 *)WILC_MALLOC(RX_MIC_KEY_MSG_LEN); + pu8keybuf = (u8 *)WILC_MALLOC(RX_MIC_KEY_MSG_LEN); if (pu8keybuf == NULL) { PRINT_ER("No buffer to send RxGTK Key\n"); ret = -1; @@ -2875,7 +2875,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) { PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n"); - pu8keybuf = (WILC_Uint8 *)WILC_MALLOC(RX_MIC_KEY_MSG_LEN); + pu8keybuf = (u8 *)WILC_MALLOC(RX_MIC_KEY_MSG_LEN); if (pu8keybuf == NULL) { PRINT_ER("No buffer to send RxGTK Key\n"); ret = -1; @@ -2930,7 +2930,7 @@ _WPARxGtk_end_case_: if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) { - pu8keybuf = (WILC_Uint8 *)WILC_MALLOC(PTK_KEY_MSG_LEN + 1); + pu8keybuf = (u8 *)WILC_MALLOC(PTK_KEY_MSG_LEN + 1); @@ -2977,7 +2977,7 @@ _WPARxGtk_end_case_: if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) { - pu8keybuf = (WILC_Uint8 *)WILC_MALLOC(PTK_KEY_MSG_LEN); + pu8keybuf = (u8 *)WILC_MALLOC(PTK_KEY_MSG_LEN); @@ -3027,7 +3027,7 @@ _WPAPtk_end_case_: PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n"); - pu8keybuf = (WILC_Uint8 *)WILC_MALLOC((pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1); + pu8keybuf = (u8 *)WILC_MALLOC((pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1); if (pu8keybuf == NULL) { PRINT_ER("No buffer to send PMKSA Key\n"); return -1; @@ -3407,7 +3407,7 @@ static WILC_Sint32 Handle_Get_InActiveTime(void *drvHandler, tstrHostIfStaInacti { WILC_Sint32 s32Error = WILC_SUCCESS; - WILC_Uint8 *stamac; + u8 *stamac; tstrWID strWID; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -3415,7 +3415,7 @@ static WILC_Sint32 Handle_Get_InActiveTime(void *drvHandler, tstrHostIfStaInacti strWID.u16WIDid = (WILC_Uint16)WID_SET_STA_MAC_INACTIVE_TIME; strWID.enuWIDtype = WID_STR; strWID.s32ValueSize = ETH_ALEN; - strWID.ps8WidVal = (WILC_Uint8 *)WILC_MALLOC(strWID.s32ValueSize); + strWID.ps8WidVal = (u8 *)WILC_MALLOC(strWID.s32ValueSize); stamac = strWID.ps8WidVal; @@ -3476,7 +3476,7 @@ static void Handle_AddBeacon(void *drvHandler, tstrHostIFSetBeacon *pstrSetBeaco { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWID; - WILC_Uint8 *pu8CurrByte; + u8 *pu8CurrByte; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; PRINT_D(HOSTINF_DBG, "Adding BEACON\n"); @@ -3548,7 +3548,7 @@ static void Handle_DelBeacon(void *drvHandler, tstrHostIFDelBeacon *pstrDelBeaco { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWID; - WILC_Uint8 *pu8CurrByte; + u8 *pu8CurrByte; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; strWID.u16WIDid = (WILC_Uint16)WID_DEL_BEACON; strWID.enuWIDtype = WID_CHAR; @@ -3581,15 +3581,15 @@ static void Handle_DelBeacon(void *drvHandler, tstrHostIFDelBeacon *pstrDelBeaco /** * @brief WILC_HostIf_PackStaParam * @details Handling packing of the station params in a buffer - * @param[in] WILC_Uint8* pu8Buffer, tstrWILC_AddStaParam* pstrStationParam + * @param[in] u8* pu8Buffer, tstrWILC_AddStaParam* pstrStationParam * @return NONE * @author * @date * @version 1.0 */ -static WILC_Uint32 WILC_HostIf_PackStaParam(WILC_Uint8 *pu8Buffer, tstrWILC_AddStaParam *pstrStationParam) +static WILC_Uint32 WILC_HostIf_PackStaParam(u8 *pu8Buffer, tstrWILC_AddStaParam *pstrStationParam) { - WILC_Uint8 *pu8CurrByte; + u8 *pu8CurrByte; pu8CurrByte = pu8Buffer; @@ -3646,7 +3646,7 @@ static void Handle_AddStation(void *drvHandler, tstrWILC_AddStaParam *pstrStatio { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWID; - WILC_Uint8 *pu8CurrByte; + u8 *pu8CurrByte; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; PRINT_D(HOSTINF_DBG, "Handling add station\n"); strWID.u16WIDid = (WILC_Uint16)WID_ADD_STA; @@ -3689,9 +3689,9 @@ static void Handle_DelAllSta(void *drvHandler, tstrHostIFDelAllSta *pstrDelAllSt { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWID; - WILC_Uint8 *pu8CurrByte; + u8 *pu8CurrByte; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; - WILC_Uint8 i; + u8 i; UWORD8 au8Zero_Buff[6] = {0}; strWID.u16WIDid = (WILC_Uint16)WID_DEL_ALL_STA; strWID.enuWIDtype = WID_STR; @@ -3747,7 +3747,7 @@ static void Handle_DelStation(void *drvHandler, tstrHostIFDelSta *pstrDelStaPara { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWID; - WILC_Uint8 *pu8CurrByte; + u8 *pu8CurrByte; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; strWID.u16WIDid = (WILC_Uint16)WID_REMOVE_STA; @@ -3793,7 +3793,7 @@ static void Handle_EditStation(void *drvHandler, tstrWILC_AddStaParam *pstrStati { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWID; - WILC_Uint8 *pu8CurrByte; + u8 *pu8CurrByte; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; strWID.u16WIDid = (WILC_Uint16)WID_EDIT_STA; @@ -3838,7 +3838,7 @@ static void Handle_EditStation(void *drvHandler, tstrWILC_AddStaParam *pstrStati static int Handle_RemainOnChan(void *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan) { WILC_Sint32 s32Error = WILC_SUCCESS; - WILC_Uint8 u8remain_on_chan_flag; + u8 u8remain_on_chan_flag; tstrWID strWID; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler; @@ -3921,7 +3921,7 @@ static int Handle_RegisterFrame(void *drvHandler, tstrHostIfRegisterFrame *pstrH { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWID; - WILC_Uint8 *pu8CurrByte; + u8 *pu8CurrByte; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType); @@ -3972,7 +3972,7 @@ static int Handle_RegisterFrame(void *drvHandler, tstrHostIfRegisterFrame *pstrH #define FALSE_FRMWR_CHANNEL 100 static WILC_Uint32 Handle_ListenStateExpired(void *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan) { - WILC_Uint8 u8remain_on_chan_flag; + u8 u8remain_on_chan_flag; tstrWID strWID; WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler; @@ -4108,7 +4108,7 @@ static void Handle_SetMulticastFilter(void *drvHandler, tstrHostIFSetMulti *strH { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWID; - WILC_Uint8 *pu8CurrByte; + u8 *pu8CurrByte; PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n"); @@ -4177,7 +4177,7 @@ static WILC_Sint32 Handle_AddBASession(void *drvHandler, tstrHostIfBASessionInfo strWID.u16WIDid = (WILC_Uint16)WID_11E_P_ACTION_REQ; strWID.enuWIDtype = WID_STR; - strWID.ps8WidVal = (WILC_Uint8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE); + strWID.ps8WidVal = (u8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE); strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE; ptr = strWID.ps8WidVal; /* *ptr++ = 0x14; */ @@ -4262,7 +4262,7 @@ static WILC_Sint32 Handle_DelBASession(void *drvHandler, tstrHostIfBASessionInfo strWID.u16WIDid = (WILC_Uint16)WID_11E_P_ACTION_REQ; strWID.enuWIDtype = WID_STR; - strWID.ps8WidVal = (WILC_Uint8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE); + strWID.ps8WidVal = (u8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE); strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE; ptr = strWID.ps8WidVal; /* *ptr++ = 0x14; */ @@ -4332,7 +4332,7 @@ static WILC_Sint32 Handle_DelAllRxBASessions(void *drvHandler, tstrHostIfBASessi strWID.u16WIDid = (WILC_Uint16)WID_DEL_ALL_RX_BA; strWID.enuWIDtype = WID_STR; - strWID.ps8WidVal = (WILC_Uint8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE); + strWID.ps8WidVal = (u8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE); strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE; ptr = strWID.ps8WidVal; *ptr++ = 0x14; @@ -4634,7 +4634,7 @@ static void TimerCB_Connect(void *pvArg) * @version 1.0 */ /* Check implementation in core adding 9 bytes to the input! */ -WILC_Sint32 host_int_remove_key(WILC_WFIDrvHandle hWFIDrv, const WILC_Uint8 *pu8StaAddress) +WILC_Sint32 host_int_remove_key(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8StaAddress) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWID; @@ -4663,7 +4663,7 @@ WILC_Sint32 host_int_remove_key(WILC_WFIDrvHandle hWFIDrv, const WILC_Uint8 *pu8 * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8keyIdx) +WILC_Sint32 host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv, u8 u8keyIdx) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -4713,7 +4713,7 @@ WILC_Sint32 host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8keyI * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_set_WEPDefaultKeyID(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8Index) +WILC_Sint32 host_int_set_WEPDefaultKeyID(WILC_WFIDrvHandle hWFIDrv, u8 u8Index) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -4770,7 +4770,7 @@ WILC_Sint32 host_int_set_WEPDefaultKeyID(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv, const WILC_Uint8 *pu8WepKey, WILC_Uint8 u8WepKeylen, WILC_Uint8 u8Keyidx) +WILC_Sint32 host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx) { WILC_Sint32 s32Error = WILC_SUCCESS; @@ -4793,7 +4793,7 @@ WILC_Sint32 host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv, const WILC_U strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. - uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = (WILC_Uint8 *)WILC_MALLOC(u8WepKeylen); + uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = (u8 *)WILC_MALLOC(u8WepKeylen); WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey, pu8WepKey, u8WepKeylen); @@ -4836,13 +4836,13 @@ WILC_Sint32 host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv, const WILC_U * @date 28 FEB 2013 * @version 1.0 */ -WILC_Sint32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const WILC_Uint8 *pu8WepKey, WILC_Uint8 u8WepKeylen, WILC_Uint8 u8Keyidx, WILC_Uint8 u8mode, AUTHTYPE_T tenuAuth_type) +WILC_Sint32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx, u8 u8mode, AUTHTYPE_T tenuAuth_type) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; - WILC_Uint8 i; + u8 i; if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); @@ -4863,7 +4863,7 @@ WILC_Sint32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const WILC_Ui strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. - uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = (WILC_Uint8 *)WILC_MALLOC((u8WepKeylen)); + uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = (u8 *)WILC_MALLOC((u8WepKeylen)); WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey, @@ -4912,13 +4912,13 @@ WILC_Sint32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const WILC_Ui * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8Ptk, WILC_Uint8 u8PtkKeylen, - const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, WILC_Uint8 mode, WILC_Uint8 u8Ciphermode, WILC_Uint8 u8Idx) +WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen, + const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode, u8 u8Idx) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; - WILC_Uint8 u8KeyLen = u8PtkKeylen; + u8 u8KeyLen = u8PtkKeylen; WILC_Uint32 i; if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); @@ -4948,7 +4948,7 @@ WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8Ptk, WILC_U strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. - uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = (WILC_Uint8 *)WILC_MALLOC(u8PtkKeylen); + uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = (u8 *)WILC_MALLOC(u8PtkKeylen); WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key, @@ -5014,14 +5014,14 @@ WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8Ptk, WILC_U * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8RxGtk, WILC_Uint8 u8GtkKeylen, - WILC_Uint8 u8KeyIdx, WILC_Uint32 u32KeyRSClen, const u8 *KeyRSC, - const u8 *pu8RxMic, const u8 *pu8TxMic, WILC_Uint8 mode, WILC_Uint8 u8Ciphermode) +WILC_Sint32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen, + u8 u8KeyIdx, WILC_Uint32 u32KeyRSClen, const u8 *KeyRSC, + const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; - WILC_Uint8 u8KeyLen = u8GtkKeylen; + u8 u8KeyLen = u8GtkKeylen; if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); @@ -5038,7 +5038,7 @@ WILC_Sint32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8RxGtk, W } if (KeyRSC != NULL) { strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. - uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = (WILC_Uint8 *)WILC_MALLOC(u32KeyRSClen); + uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = (u8 *)WILC_MALLOC(u32KeyRSClen); WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, KeyRSC, u32KeyRSClen); @@ -5060,7 +5060,7 @@ WILC_Sint32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8RxGtk, W strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. - uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = (WILC_Uint8 *)WILC_MALLOC(u8KeyLen); + uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = (u8 *)WILC_MALLOC(u8KeyLen); WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key, pu8RxGtk, u8GtkKeylen); @@ -5120,7 +5120,7 @@ WILC_Sint32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8RxGtk, W * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_add_tx_gtk(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8KeyLen, WILC_Uint8 *pu8TxGtk, WILC_Uint8 u8KeyIdx) +WILC_Sint32 host_int_add_tx_gtk(WILC_WFIDrvHandle hWFIDrv, u8 u8KeyLen, u8 *pu8TxGtk, u8 u8KeyIdx) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -5138,7 +5138,7 @@ WILC_Sint32 host_int_add_tx_gtk(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8KeyLen, strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY; strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr. - uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = (WILC_Uint8 *)WILC_MALLOC(u8KeyLen); + uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = (u8 *)WILC_MALLOC(u8KeyLen); WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key, pu8TxGtk, u8KeyLen); @@ -5245,7 +5245,7 @@ WILC_Sint32 host_int_set_pmkid_info(WILC_WFIDrvHandle hWFIDrv, tstrHostIFpmkidAt * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_get_pmkid_info(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8PmkidInfoArray, +WILC_Sint32 host_int_get_pmkid_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PmkidInfoArray, WILC_Uint32 u32PmkidInfoLen) { WILC_Sint32 s32Error = WILC_SUCCESS; @@ -5274,14 +5274,14 @@ WILC_Sint32 host_int_get_pmkid_info(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8Pm * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_set_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8PassPhrase, - WILC_Uint8 u8Psklength) +WILC_Sint32 host_int_set_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PassPhrase, + u8 u8Psklength) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWID; /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ - /* WILC_Uint8 u8Psklength = WILC_strlen(pu8PassPhrase); */ + /* u8 u8Psklength = WILC_strlen(pu8PassPhrase); */ /*validating psk length*/ if ((u8Psklength > 7) && (u8Psklength < 65)) { strWID.u16WIDid = (WILC_Uint16)WID_11I_PSK; @@ -5303,7 +5303,7 @@ WILC_Sint32 host_int_set_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, WILC * @date 19 April 2012 * @version 1.0 */ -WILC_Sint32 host_int_get_MacAddress(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8MacAddress) +WILC_Sint32 host_int_get_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; @@ -5337,7 +5337,7 @@ WILC_Sint32 host_int_get_MacAddress(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8Ma * @date 16 July 2012 * @version 1.0 */ -WILC_Sint32 host_int_set_MacAddress(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8MacAddress) +WILC_Sint32 host_int_set_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; @@ -5379,7 +5379,7 @@ WILC_Sint32 host_int_set_MacAddress(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8Ma * @version 1.0 */ WILC_Sint32 host_int_get_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, - WILC_Uint8 *pu8PassPhrase, WILC_Uint8 u8Psklength) + u8 *pu8PassPhrase, u8 u8Psklength) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWID; @@ -5426,7 +5426,7 @@ WILC_Sint32 host_int_get_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, */ #ifndef CONNECT_DIRECT WILC_Sint32 host_int_get_site_survey_results(WILC_WFIDrvHandle hWFIDrv, - WILC_Uint8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE], + u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE], WILC_Uint32 u32MaxSiteSrvyFragLen) { WILC_Sint32 s32Error = WILC_SUCCESS; @@ -5475,7 +5475,7 @@ WILC_Sint32 host_int_get_site_survey_results(WILC_WFIDrvHandle hWFIDrv, * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_set_start_scan_req(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 scanSource) +WILC_Sint32 host_int_set_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 scanSource) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWID; @@ -5505,7 +5505,7 @@ WILC_Sint32 host_int_set_start_scan_req(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 sc * @version 1.0 */ -WILC_Sint32 host_int_get_start_scan_req(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8ScanSource) +WILC_Sint32 host_int_get_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ScanSource) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWID; @@ -5530,12 +5530,12 @@ WILC_Sint32 host_int_get_start_scan_req(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *p * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8bssid, +WILC_Sint32 host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8bssid, const u8 *pu8ssid, size_t ssidLen, - const WILC_Uint8 *pu8IEs, size_t IEsLen, + const u8 *pu8IEs, size_t IEsLen, tWILCpfConnectResult pfConnectResult, void *pvUserArg, - WILC_Uint8 u8security, AUTHTYPE_T tenuAuth_type, - WILC_Uint8 u8channel, + u8 u8security, AUTHTYPE_T tenuAuth_type, + u8 u8channel, void *pJoinParams) { WILC_Sint32 s32Error = WILC_SUCCESS; @@ -5578,14 +5578,14 @@ WILC_Sint32 host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8bssi strHostIFmsg.drvHandler = hWFIDrv; if (pu8bssid != NULL) { - strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid = (WILC_Uint8 *)WILC_MALLOC(6); /* will be deallocated by the receiving thread */ + strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid = (u8 *)WILC_MALLOC(6); /* will be deallocated by the receiving thread */ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid, pu8bssid, 6); } if (pu8ssid != NULL) { strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.ssidLen = ssidLen; - strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid = (WILC_Uint8 *)WILC_MALLOC(ssidLen); /* will be deallocated by the receiving thread */ + strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid = (u8 *)WILC_MALLOC(ssidLen); /* will be deallocated by the receiving thread */ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid, pu8ssid, ssidLen); @@ -5593,7 +5593,7 @@ WILC_Sint32 host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8bssi if (pu8IEs != NULL) { strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.IEsLen = IEsLen; - strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs = (WILC_Uint8 *)WILC_MALLOC(IEsLen); /* will be deallocated by the receiving thread */ + strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs = (u8 *)WILC_MALLOC(IEsLen); /* will be deallocated by the receiving thread */ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs, pu8IEs, IEsLen); } @@ -5725,7 +5725,7 @@ WILC_Sint32 host_int_disconnect(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16Reason * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_disconnect_station(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 assoc_id) +WILC_Sint32 host_int_disconnect_station(WILC_WFIDrvHandle hWFIDrv, u8 assoc_id) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWID; @@ -5765,7 +5765,7 @@ WILC_Sint32 host_int_disconnect_station(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 as * @version 1.0 */ -WILC_Sint32 host_int_get_assoc_req_info(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8AssocReqInfo, +WILC_Sint32 host_int_get_assoc_req_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocReqInfo, WILC_Uint32 u32AssocReqInfoLen) { WILC_Sint32 s32Error = WILC_SUCCESS; @@ -5792,7 +5792,7 @@ WILC_Sint32 host_int_get_assoc_req_info(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *p * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8AssocRespInfo, +WILC_Sint32 host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocRespInfo, WILC_Uint32 u32MaxAssocRespInfoLen, WILC_Uint32 *pu32RcvdAssocRespInfoLen) { WILC_Sint32 s32Error = WILC_SUCCESS; @@ -5842,7 +5842,7 @@ WILC_Sint32 host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *p * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_get_rx_power_level(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8RxPowerLevel, +WILC_Sint32 host_int_get_rx_power_level(WILC_WFIDrvHandle hWFIDrv, u8 *pu8RxPowerLevel, WILC_Uint32 u32RxPowerLevelLen) { WILC_Sint32 s32Error = WILC_SUCCESS; @@ -5873,7 +5873,7 @@ WILC_Sint32 host_int_get_rx_power_level(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *p * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_set_mac_chnl_num(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8ChNum) +WILC_Sint32 host_int_set_mac_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 u8ChNum) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -5997,7 +5997,7 @@ WILC_Sint32 host_int_set_operation_mode(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_get_host_chnl_num(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *pu8ChNo) +WILC_Sint32 host_int_get_host_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ChNo) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -6297,9 +6297,9 @@ WILC_Sint32 host_int_get_statistics(WILC_WFIDrvHandle hWFIDrv, tstrStatistics *p * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_scan(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8ScanSource, - WILC_Uint8 u8ScanType, WILC_Uint8 *pu8ChnlFreqList, - WILC_Uint8 u8ChnlListLen, const WILC_Uint8 *pu8IEs, +WILC_Sint32 host_int_scan(WILC_WFIDrvHandle hWFIDrv, u8 u8ScanSource, + u8 u8ScanType, u8 *pu8ChnlFreqList, + u8 u8ChnlListLen, const u8 *pu8IEs, size_t IEsLen, tWILCpfScanResult ScanResult, void *pvUserArg, tstrHiddenNetwork *pstrHiddenNetwork) { @@ -6332,12 +6332,12 @@ WILC_Sint32 host_int_scan(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 u8ScanSource, strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pvUserArg = pvUserArg; strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ChnlListLen = u8ChnlListLen; - strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList = (WILC_Uint8 *)WILC_MALLOC(u8ChnlListLen); /* will be deallocated by the receiving thread */ + strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList = (u8 *)WILC_MALLOC(u8ChnlListLen); /* will be deallocated by the receiving thread */ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList, pu8ChnlFreqList, u8ChnlListLen); strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.IEsLen = IEsLen; - strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs = (WILC_Uint8 *)WILC_MALLOC(IEsLen); /* will be deallocated by the receiving thread */ + strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs = (u8 *)WILC_MALLOC(IEsLen); /* will be deallocated by the receiving thread */ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs, pu8IEs, IEsLen); @@ -6531,7 +6531,7 @@ WILC_Sint32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16WID, WILC_Uint * @version 1.0 */ void host_int_send_join_leave_info_to_host - (WILC_Uint16 assocId, WILC_Uint8 *stationAddr, WILC_Bool joining) + (WILC_Uint16 assocId, u8 *stationAddr, WILC_Bool joining) { } /** @@ -6578,7 +6578,7 @@ void GetPeriodicRSSI(void *pvArg) void host_int_send_network_info_to_host - (WILC_Uint8 *macStartAddress, WILC_Uint16 u16RxFrameLen, WILC_Sint8 s8Rssi) + (u8 *macStartAddress, WILC_Uint16 u16RxFrameLen, WILC_Sint8 s8Rssi) { } /** @@ -6914,7 +6914,7 @@ WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv) * @date 1 Mar 2012 * @version 1.0 */ -void NetworkInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) +void NetworkInfoReceived(u8 *pu8Buffer, WILC_Uint32 u32Length) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; @@ -6939,7 +6939,7 @@ void NetworkInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) strHostIFmsg.drvHandler = pstrWFIDrv; strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.u32Length = u32Length; - strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer = (WILC_Uint8 *)WILC_MALLOC(u32Length); /* will be deallocated by the receiving thread */ + strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer = (u8 *)WILC_MALLOC(u32Length); /* will be deallocated by the receiving thread */ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer, pu8Buffer, u32Length); @@ -6964,7 +6964,7 @@ void NetworkInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) * @date 15 Mar 2012 * @version 1.0 */ -void GnrlAsyncInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) +void GnrlAsyncInfoReceived(u8 *pu8Buffer, WILC_Uint32 u32Length) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; @@ -7003,7 +7003,7 @@ void GnrlAsyncInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.u32Length = u32Length; - strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer = (WILC_Uint8 *)WILC_MALLOC(u32Length); /* will be deallocated by the receiving thread */ + strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer = (u8 *)WILC_MALLOC(u32Length); /* will be deallocated by the receiving thread */ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer, pu8Buffer, u32Length); @@ -7021,13 +7021,13 @@ void GnrlAsyncInfoReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) /** * @brief host_int_ScanCompleteReceived * @details Setting scan complete received notifcation in message queue - * @param[in] WILC_Uint8* pu8Buffer, WILC_Uint32 u32Length + * @param[in] u8* pu8Buffer, WILC_Uint32 u32Length * @return Error code. * @author * @date * @version 1.0 */ -void host_int_ScanCompleteReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) +void host_int_ScanCompleteReceived(u8 *pu8Buffer, WILC_Uint32 u32Length) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; @@ -7056,7 +7056,7 @@ void host_int_ScanCompleteReceived(WILC_Uint8 *pu8Buffer, WILC_Uint32 u32Length) /*no need to send message body*/ /*strHostIFmsg.uniHostIFmsgBody.strScanComplete.u32Length = u32Length; - * strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer = (WILC_Uint8*)WILC_MALLOC(u32Length); + * strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length); * WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer, * pu8Buffer, u32Length); */ @@ -7227,8 +7227,8 @@ WILC_Sint32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16Fr * @brief host_int_add_beacon * @details Setting add beacon params in message queue * @param[in] WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32Interval, - * WILC_Uint32 u32DTIMPeriod,WILC_Uint32 u32HeadLen, WILC_Uint8* pu8Head, - * WILC_Uint32 u32TailLen, WILC_Uint8* pu8Tail + * WILC_Uint32 u32DTIMPeriod,WILC_Uint32 u32HeadLen, u8* pu8Head, + * WILC_Uint32 u32TailLen, u8* pu8Tail * @return Error code. * @author * @date @@ -7236,8 +7236,8 @@ WILC_Sint32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16Fr */ WILC_Sint32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32Interval, WILC_Uint32 u32DTIMPeriod, - WILC_Uint32 u32HeadLen, WILC_Uint8 *pu8Head, - WILC_Uint32 u32TailLen, WILC_Uint8 *pu8Tail) + WILC_Uint32 u32HeadLen, u8 *pu8Head, + WILC_Uint32 u32TailLen, u8 *pu8Tail) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -7259,7 +7259,7 @@ WILC_Sint32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32Interv pstrSetBeaconParam->u32Interval = u32Interval; pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod; pstrSetBeaconParam->u32HeadLen = u32HeadLen; - pstrSetBeaconParam->pu8Head = (WILC_Uint8 *)WILC_MALLOC(u32HeadLen); + pstrSetBeaconParam->pu8Head = (u8 *)WILC_MALLOC(u32HeadLen); if (pstrSetBeaconParam->pu8Head == NULL) { WILC_ERRORREPORT(s32Error, WILC_NO_MEM); } @@ -7268,7 +7268,7 @@ WILC_Sint32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32Interv /* Bug 4599 : if tail length = 0 skip allocating & copying */ if (u32TailLen > 0) { - pstrSetBeaconParam->pu8Tail = (WILC_Uint8 *)WILC_MALLOC(u32TailLen); + pstrSetBeaconParam->pu8Tail = (u8 *)WILC_MALLOC(u32TailLen); if (pstrSetBeaconParam->pu8Tail == NULL) { WILC_ERRORREPORT(s32Error, WILC_NO_MEM); } @@ -7386,7 +7386,7 @@ WILC_Sint32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam /** * @brief host_int_del_station * @details Setting delete station params in message queue - * @param[in] WILC_WFIDrvHandle hWFIDrv, WILC_Uint8* pu8MacAddr + * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr * @return Error code. * @author * @date @@ -7432,7 +7432,7 @@ WILC_Sint32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8MacAddr /** * @brief host_int_del_allstation * @details Setting del station params in message queue - * @param[in] WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 pu8MacAddr[][ETH_ALEN]s + * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s * @return Error code. * @author * @date @@ -7444,9 +7444,9 @@ WILC_Sint32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][E tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; tstrHostIFDelAllSta *pstrDelAllStationMsg = &strHostIFmsg.uniHostIFmsgBody.strHostIFDelAllSta; - WILC_Uint8 au8Zero_Buff[ETH_ALEN] = {0}; + u8 au8Zero_Buff[ETH_ALEN] = {0}; WILC_Uint32 i; - WILC_Uint8 u8AssocNumb = 0; + u8 u8AssocNumb = 0; if (pstrWFIDrv == NULL) { @@ -7630,17 +7630,17 @@ WILC_Sint32 host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv, WILC_Bool static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo) { tstrJoinBssParam *pNewJoinBssParam = NULL; - WILC_Uint8 *pu8IEs; + u8 *pu8IEs; WILC_Uint16 u16IEsLen; WILC_Uint16 index = 0; - WILC_Uint8 suppRatesNo = 0; - WILC_Uint8 extSuppRatesNo; + u8 suppRatesNo = 0; + u8 extSuppRatesNo; WILC_Uint16 jumpOffset; - WILC_Uint8 pcipherCount; - WILC_Uint8 authCount; - WILC_Uint8 pcipherTotalCount = 0; - WILC_Uint8 authTotalCount = 0; - WILC_Uint8 i, j; + u8 pcipherCount; + u8 authCount; + u8 pcipherTotalCount = 0; + u8 authTotalCount = 0; + u8 i, j; pu8IEs = ptstrNetworkInfo->pu8IEs; u16IEsLen = ptstrNetworkInfo->u16IEsLen; @@ -7654,7 +7654,7 @@ static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo) WILC_memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6); /*for(i=0; i<6;i++) * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/ - WILC_memcpy((WILC_Uint8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1); + WILC_memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1); pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen; WILC_memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3); WILC_memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3); @@ -7964,7 +7964,7 @@ WILC_Sint32 host_int_del_All_Rx_BASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSI * @author Abdelrahman Sobhy * @date * @version 1.0*/ -WILC_Sint32 host_int_setup_ipaddress(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *u16ipadd, WILC_Uint8 idx) +WILC_Sint32 host_int_setup_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *u16ipadd, u8 idx) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -8008,7 +8008,7 @@ WILC_Sint32 host_int_setup_ipaddress(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *u16i * @author Abdelrahman Sobhy * @date * @version 1.0*/ -WILC_Sint32 host_int_get_ipaddress(WILC_WFIDrvHandle hWFIDrv, WILC_Uint8 *u16ipadd, WILC_Uint8 idx) +WILC_Sint32 host_int_get_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *u16ipadd, u8 idx) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 5c17076d10f6..d03a5753cb33 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -132,7 +132,7 @@ typedef struct { } cfg_param_t; typedef struct _tstrStatistics { - WILC_Uint8 u8LinkSpeed; + u8 u8LinkSpeed; WILC_Sint8 s8RSSI; WILC_Uint32 u32TxCount; WILC_Uint32 u32RxCount; @@ -152,12 +152,12 @@ typedef enum { } tenuHostIFstate; typedef struct _tstrHostIFpmkid { - WILC_Uint8 bssid[ETH_ALEN]; - WILC_Uint8 pmkid[PMKID_LEN]; + u8 bssid[ETH_ALEN]; + u8 pmkid[PMKID_LEN]; } tstrHostIFpmkid; typedef struct _tstrHostIFpmkidAttr { - WILC_Uint8 numpmkid; + u8 numpmkid; tstrHostIFpmkid pmkidlist[WILC_MAX_NUM_PMKIDS]; } tstrHostIFpmkidAttr; #if 0 @@ -190,23 +190,23 @@ typedef enum { typedef struct { WILC_Uint32 u32SetCfgFlag; - WILC_Uint8 ht_enable; - WILC_Uint8 bss_type; - WILC_Uint8 auth_type; + u8 ht_enable; + u8 bss_type; + u8 auth_type; WILC_Uint16 auth_timeout; - WILC_Uint8 power_mgmt_mode; + u8 power_mgmt_mode; WILC_Uint16 short_retry_limit; WILC_Uint16 long_retry_limit; WILC_Uint16 frag_threshold; WILC_Uint16 rts_threshold; WILC_Uint16 preamble_type; - WILC_Uint8 short_slot_allowed; - WILC_Uint8 txop_prot_disabled; + u8 short_slot_allowed; + u8 txop_prot_disabled; WILC_Uint16 beacon_interval; WILC_Uint16 dtim_period; SITE_SURVEY_T site_survey_enabled; WILC_Uint16 site_survey_scan_time; - WILC_Uint8 scan_source; + u8 scan_source; WILC_Uint16 active_scan_time; WILC_Uint16 passive_scan_time; CURRENT_TX_RATE_T curr_tx_rate; @@ -236,7 +236,7 @@ typedef enum { } tenuCfgParam; typedef struct { - WILC_Uint8 au8bssid[6]; + u8 au8bssid[6]; WILC_Sint8 s8rssi; } tstrFoundNetworkInfo; @@ -266,7 +266,7 @@ typedef void (*tWILCpfScanResult)(tenuScanEvent, tstrNetworkInfo *, void *, void /*Connect callBack function definition*/ typedef void (*tWILCpfConnectResult)(tenuConnDisconnEvent, tstrConnectInfo *, - WILC_Uint8, + u8, tstrDisconnectNotifInfo *, void *); @@ -291,21 +291,21 @@ typedef struct { * @version 1.0 */ typedef struct _tstrRcvdNetworkInfo { - WILC_Uint8 *pu8Buffer; + u8 *pu8Buffer; WILC_Uint32 u32Length; } tstrRcvdNetworkInfo; /*BugID_4156*/ typedef struct _tstrHiddenNetworkInfo { - WILC_Uint8 *pu8ssid; - WILC_Uint8 u8ssidlen; + u8 *pu8ssid; + u8 u8ssidlen; } tstrHiddenNetworkInfo; typedef struct _tstrHiddenNetwork { /* MAX_SSID_LEN */ tstrHiddenNetworkInfo *pstrHiddenNetworkInfo; - WILC_Uint8 u8ssidnum; + u8 u8ssidnum; } tstrHiddenNetwork; @@ -321,12 +321,12 @@ typedef struct { } tstrWILC_UsrScanReq; typedef struct { - WILC_Uint8 *pu8bssid; - WILC_Uint8 *pu8ssid; - WILC_Uint8 u8security; + u8 *pu8bssid; + u8 *pu8ssid; + u8 u8security; AUTHTYPE_T tenuAuth_type; size_t ssidLen; - WILC_Uint8 *pu8ConnReqIEs; + u8 *pu8ConnReqIEs; size_t ConnReqIEsLen; /* Connect user call back function */ tWILCpfConnectResult pfUserConnectResult; @@ -345,18 +345,18 @@ typedef struct { /*BugID_5077*/ typedef struct { - WILC_Uint8 u8MacAddress[ETH_ALEN]; + u8 u8MacAddress[ETH_ALEN]; } tstrHostIfSetMacAddress; /*BugID_5213*/ typedef struct { - WILC_Uint8 *u8MacAddress; + u8 *u8MacAddress; } tstrHostIfGetMacAddress; /*BugID_5222*/ typedef struct { - WILC_Uint8 au8Bssid[ETH_ALEN]; - WILC_Uint8 u8Ted; + u8 au8Bssid[ETH_ALEN]; + u8 u8Ted; WILC_Uint16 u16BufferSize; WILC_Uint16 u16SessionTimeout; } tstrHostIfBASessionInfo; @@ -375,7 +375,7 @@ typedef struct { WILC_Bool bReg; WILC_Uint16 u16FrameType; - WILC_Uint8 u8Regid; + u8 u8Regid; } tstrHostIfRegisterFrame; @@ -405,9 +405,9 @@ typedef struct { #ifdef WILC_P2P /*Remain on channel struvture*/ tstrHostIfRemainOnChan strHostIfRemainOnChan; - WILC_Uint8 u8RemainOnChan_pendingreq; + u8 u8RemainOnChan_pendingreq; WILC_Uint64 u64P2p_MgmtTimeout; - WILC_Uint8 u8P2PConnect; + u8 u8P2PConnect; #endif tenuHostIFstate enuHostIFstate; @@ -419,7 +419,7 @@ typedef struct { wid_site_survey_reslts_s astrSurveyResults[MAX_NUM_SCANNED_NETWORKS]; #endif - WILC_Uint8 au8AssociatedBSSID[ETH_ALEN]; + u8 au8AssociatedBSSID[ETH_ALEN]; tstrCfgParamVal strCfgValues; /* semaphores */ struct semaphore gtOsCfgValuesSem; @@ -461,22 +461,22 @@ typedef enum { } tenuWILC_StaFlag; typedef struct { - WILC_Uint8 au8BSSID[ETH_ALEN]; + u8 au8BSSID[ETH_ALEN]; WILC_Uint16 u16AssocID; - WILC_Uint8 u8NumRates; + u8 u8NumRates; const u8 *pu8Rates; WILC_Bool bIsHTSupported; WILC_Uint16 u16HTCapInfo; - WILC_Uint8 u8AmpduParams; - WILC_Uint8 au8SuppMCsSet[16]; + u8 u8AmpduParams; + u8 au8SuppMCsSet[16]; WILC_Uint16 u16HTExtParams; WILC_Uint32 u32TxBeamformingCap; - WILC_Uint8 u8ASELCap; + u8 u8ASELCap; WILC_Uint16 u16FlagsMask; /**/ WILC_Uint16 u16FlagsSet; /*buff; + u8 *buf = pv_data->buff; @@ -418,7 +418,7 @@ void WILC_mgm_HOSTAPD_ACK(void *priv, WILC_Bool bStatus) struct wilc_wfi_radiotap_cb_hdr *cb_hdr; struct tx_complete_mon_data *pv_data = (struct tx_complete_mon_data *)priv; - WILC_Uint8 *buf = pv_data->buff; + u8 *buf = pv_data->buff; /* len of the original frame without the added pointer at the tail */ WILC_Uint16 u16len = (pv_data->size) - sizeof(struct tx_complete_mon_data *); @@ -502,7 +502,7 @@ static void WILC_WFI_mon_setup(struct net_device *dev) /* u8 * mac_add; */ unsigned char mac_add[] = {0x00, 0x50, 0xc2, 0x5e, 0x10, 0x8f}; /* priv = wiphy_priv(priv->dev->ieee80211_ptr->wiphy); */ - /* mac_add = (WILC_Uint8*)WILC_MALLOC(ETH_ALEN); */ + /* mac_add = (u8*)WILC_MALLOC(ETH_ALEN); */ /* status = host_int_get_MacAddress(priv->hWILCWFIDrv,mac_add); */ /* mac_add[ETH_ALEN-1]+=1; */ memcpy(dev->dev_addr, mac_add, ETH_ALEN); diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index b92626ed02e1..b033eb879ca1 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -69,7 +69,7 @@ extern WILC_Bool g_obtainingIP; #endif extern WILC_Uint16 Set_machw_change_vir_if(WILC_Bool bValue); extern void resolve_disconnect_aberration(void *drvHandler); -extern WILC_Uint8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN]; +extern u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN]; void wilc1000_wlan_deinit(linux_wlan_t *nic); #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP extern WILC_TimerHandle hDuringIpTimer; @@ -258,10 +258,10 @@ static int dev_state_ev_handler(struct notifier_block *this, unsigned long event struct WILC_WFI_priv *priv; tstrWILC_WFIDrv *pstrWFIDrv; struct net_device *dev; - WILC_Uint8 *pIP_Add_buff; + u8 *pIP_Add_buff; WILC_Sint32 s32status = WILC_FAIL; perInterface_wlan_t *nic; - WILC_Uint8 null_ip[4] = {0}; + u8 null_ip[4] = {0}; char wlan_dev_name[5] = "wlan0"; if (dev_iface == NULL || dev_iface->ifa_dev == NULL || dev_iface->ifa_dev->dev == NULL) { @@ -2377,7 +2377,7 @@ int mac_close(struct net_device *ndev) int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) { - WILC_Uint8 *buff = NULL; + u8 *buff = NULL; WILC_Sint8 rssi; WILC_Uint32 size = 0, length = 0; perInterface_wlan_t *nic; diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h b/drivers/staging/wilc1000/wilc_msgqueue.h index 84157368335d..d7e4b1ce3497 100644 --- a/drivers/staging/wilc1000/wilc_msgqueue.h +++ b/drivers/staging/wilc1000/wilc_msgqueue.h @@ -19,7 +19,7 @@ */ typedef struct { /* a dummy member to avoid compiler errors*/ - WILC_Uint8 dummy; + u8 dummy; } tstrWILC_MsgQueueAttrs; diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index 3cdc05305109..4b4cfa202043 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -14,7 +14,6 @@ #define WILC_OSW_INTERFACE_VER 2 /* Integer Types */ -typedef unsigned char WILC_Uint8; typedef unsigned short WILC_Uint16; typedef unsigned int WILC_Uint32; typedef unsigned long long WILC_Uint64; diff --git a/drivers/staging/wilc1000/wilc_strutils.c b/drivers/staging/wilc1000/wilc_strutils.c index d349eaa2b51f..c6af13cba543 100644 --- a/drivers/staging/wilc1000/wilc_strutils.c +++ b/drivers/staging/wilc1000/wilc_strutils.c @@ -30,7 +30,7 @@ void WILC_memcpy_INTERNAL(void *pvTarget, const void *pvSource, WILC_Uint32 u32C * @date 18 Aug 2010 * @version 1.0 */ -void *WILC_memset(void *pvTarget, WILC_Uint8 u8SetValue, WILC_Uint32 u32Count) +void *WILC_memset(void *pvTarget, u8 u8SetValue, WILC_Uint32 u32Count) { return memset(pvTarget, u8SetValue, u32Count); } diff --git a/drivers/staging/wilc1000/wilc_strutils.h b/drivers/staging/wilc1000/wilc_strutils.h index 8795d56adc4a..ddc54ab21f67 100644 --- a/drivers/staging/wilc1000/wilc_strutils.h +++ b/drivers/staging/wilc1000/wilc_strutils.h @@ -53,11 +53,11 @@ void WILC_memcpy_INTERNAL(void *pvTarget, const void *pvSource, WILC_Uint32 u32C static WILC_ErrNo WILC_memcpy(void *pvTarget, const void *pvSource, WILC_Uint32 u32Count) { if ( - (((WILC_Uint8 *)pvTarget <= (WILC_Uint8 *)pvSource) - && (((WILC_Uint8 *)pvTarget + u32Count) > (WILC_Uint8 *)pvSource)) + (((u8 *)pvTarget <= (u8 *)pvSource) + && (((u8 *)pvTarget + u32Count) > (u8 *)pvSource)) - || (((WILC_Uint8 *)pvSource <= (WILC_Uint8 *)pvTarget) - && (((WILC_Uint8 *)pvSource + u32Count) > (WILC_Uint8 *)pvTarget)) + || (((u8 *)pvSource <= (u8 *)pvTarget) + && (((u8 *)pvSource + u32Count) > (u8 *)pvTarget)) ) { /* ovelapped memory, return Error */ return WILC_FAIL; @@ -78,7 +78,7 @@ static WILC_ErrNo WILC_memcpy(void *pvTarget, const void *pvSource, WILC_Uint32 * @date 18 Aug 2010 * @version 1.0 */ -void *WILC_memset(void *pvTarget, WILC_Uint8 u8SetValue, WILC_Uint32 u32Count); +void *WILC_memset(void *pvTarget, u8 u8SetValue, WILC_Uint32 u32Count); /*! * @brief copies the contents of source string into the target string diff --git a/drivers/staging/wilc1000/wilc_timer.h b/drivers/staging/wilc1000/wilc_timer.h index 41c6784ab8e1..72b27155293e 100644 --- a/drivers/staging/wilc1000/wilc_timer.h +++ b/drivers/staging/wilc1000/wilc_timer.h @@ -21,7 +21,7 @@ typedef void (*tpfWILC_TimerFunction)(void *); */ typedef struct { /* a dummy member to avoid compiler errors*/ - WILC_Uint8 dummy; + u8 dummy; } tstrWILC_TimerAttrs; /*! diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index aa71b2708569..f5eff0933e7d 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -36,11 +36,11 @@ WILC_Uint32 u32LastScannedNtwrksCountShadow; WILC_TimerHandle hDuringIpTimer; #endif WILC_TimerHandle hAgingTimer; -static WILC_Uint8 op_ifcs; -extern WILC_Uint8 u8ConnectedSSID[6]; +static u8 op_ifcs; +extern u8 u8ConnectedSSID[6]; /*BugID_5137*/ -WILC_Uint8 g_wilc_initialized = 1; +u8 g_wilc_initialized = 1; extern linux_wlan_t *g_linux_wlan; #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP extern WILC_Bool g_obtainingIP; @@ -103,15 +103,15 @@ struct p2p_mgmt_data { }; /*Global variable used to state the current connected STA channel*/ -WILC_Uint8 u8WLANChannel = INVALID_CHANNEL; +u8 u8WLANChannel = INVALID_CHANNEL; /*BugID_5442*/ -WILC_Uint8 u8CurrChannel; +u8 u8CurrChannel; -WILC_Uint8 u8P2P_oui[] = {0x50, 0x6f, 0x9A, 0x09}; -WILC_Uint8 u8P2Plocalrandom = 0x01; -WILC_Uint8 u8P2Precvrandom = 0x00; -WILC_Uint8 u8P2P_vendorspec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03}; +u8 u8P2P_oui[] = {0x50, 0x6f, 0x9A, 0x09}; +u8 u8P2Plocalrandom = 0x01; +u8 u8P2Precvrandom = 0x00; +u8 u8P2P_vendorspec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03}; WILC_Bool bWilc_ie = WILC_FALSE; #endif @@ -134,7 +134,7 @@ struct wilc_wfi_key g_key_gtk_params; struct add_key_params g_add_ptk_key_params; struct wilc_wfi_key g_key_ptk_params; struct wilc_wfi_wep_key g_key_wep_params; -WILC_Uint8 g_flushing_in_progress; +u8 g_flushing_in_progress; WILC_Bool g_ptk_keys_saved = WILC_FALSE; WILC_Bool g_gtk_keys_saved = WILC_FALSE; WILC_Bool g_wep_keys_saved = WILC_FALSE; @@ -349,7 +349,7 @@ void add_network_to_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, vo if (ap_found != -1) WILC_FREE(astrLastScannedNtwrksShadow[ap_index].pu8IEs); astrLastScannedNtwrksShadow[ap_index].pu8IEs = - (WILC_Uint8 *)WILC_MALLOC(pstrNetworkInfo->u16IEsLen); /* will be deallocated by the WILC_WFI_CfgScan() function */ + (u8 *)WILC_MALLOC(pstrNetworkInfo->u16IEsLen); /* will be deallocated by the WILC_WFI_CfgScan() function */ WILC_memcpy(astrLastScannedNtwrksShadow[ap_index].pu8IEs, pstrNetworkInfo->pu8IEs, pstrNetworkInfo->u16IEsLen); @@ -507,7 +507,7 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo * @date 01 MAR 2012 * @version 1.0 */ -int WILC_WFI_Set_PMKSA(WILC_Uint8 *bssid, struct WILC_WFI_priv *priv) +int WILC_WFI_Set_PMKSA(u8 *bssid, struct WILC_WFI_priv *priv) { WILC_Uint32 i; WILC_Sint32 s32Error = WILC_SUCCESS; @@ -542,7 +542,7 @@ int linux_wlan_set_bssid(struct net_device *wilc_netdev, uint8_t *pBSSID); * @param[in] tenuConnDisconnEvent enuConnDisconnEvent: Type of connection response either * connection response or disconnection notification. * tstrConnectInfo* pstrConnectInfo: COnnection information. - * WILC_Uint8 u8MacStatus: Mac Status from firmware + * u8 u8MacStatus: Mac Status from firmware * tstrDisconnectNotifInfo* pstrDisconnectNotifInfo: Disconnection Notification * void* pUserVoid: Private data associated with wireless interface * @return NONE @@ -554,7 +554,7 @@ int connecting; static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent, tstrConnectInfo *pstrConnectInfo, - WILC_Uint8 u8MacStatus, + u8 u8MacStatus, tstrDisconnectNotifInfo *pstrDisconnectNotifInfo, void *pUserVoid) { @@ -563,7 +563,7 @@ static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent, #ifdef WILC_P2P tstrWILC_WFIDrv *pstrWFIDrv; #endif - WILC_Uint8 NullBssid[ETH_ALEN] = {0}; + u8 NullBssid[ETH_ALEN] = {0}; connecting = 0; priv = (struct WILC_WFI_priv *)pUserVoid; @@ -742,7 +742,7 @@ static int WILC_WFI_CfgScan(struct wiphy *wiphy, struct cfg80211_scan_request *r struct WILC_WFI_priv *priv; WILC_Uint32 i; WILC_Sint32 s32Error = WILC_SUCCESS; - WILC_Uint8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS]; + u8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS]; tstrHiddenNetwork strHiddenNetwork; priv = wiphy_priv(wiphy); @@ -773,7 +773,7 @@ static int WILC_WFI_CfgScan(struct wiphy *wiphy, struct cfg80211_scan_request *r if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */ /* max_scan_ssids */ for (i = 0; i < request->n_channels; i++) { - au8ScanChanList[i] = (WILC_Uint8)ieee80211_frequency_to_channel(request->channels[i]->center_freq); + au8ScanChanList[i] = (u8)ieee80211_frequency_to_channel(request->channels[i]->center_freq); PRINT_INFO(CFG80211_DBG, "ScanChannel List[%d] = %d,", i, au8ScanChanList[i]); } @@ -804,13 +804,13 @@ static int WILC_WFI_CfgScan(struct wiphy *wiphy, struct cfg80211_scan_request *r PRINT_D(CFG80211_DBG, "Trigger Scan Request \n"); s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN, au8ScanChanList, request->n_channels, - (const WILC_Uint8 *)request->ie, request->ie_len, + (const u8 *)request->ie, request->ie_len, CfgScanResult, (void *)priv, &strHiddenNetwork); } else { PRINT_D(CFG80211_DBG, "Trigger Scan Request \n"); s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN, au8ScanChanList, request->n_channels, - (const WILC_Uint8 *)request->ie, request->ie_len, + (const u8 *)request->ie, request->ie_len, CfgScanResult, (void *)priv, NULL); } @@ -845,7 +845,7 @@ static int WILC_WFI_CfgConnect(struct wiphy *wiphy, struct net_device *dev, WILC_Sint32 s32Error = WILC_SUCCESS; WILC_Uint32 i; /* SECURITY_T tenuSecurity_t = NO_SECURITY; */ - WILC_Uint8 u8security = NO_ENCRYPT; + u8 u8security = NO_ENCRYPT; AUTHTYPE_T tenuAuth_type = ANY; WILC_Char *pcgroup_encrypt_val; WILC_Char *pccipher_group; @@ -1161,10 +1161,10 @@ static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 k struct WILC_WFI_priv *priv; const u8 *pu8RxMic = NULL; const u8 *pu8TxMic = NULL; - WILC_Uint8 u8mode = NO_ENCRYPT; + u8 u8mode = NO_ENCRYPT; #ifdef WILC_AP_EXTERNAL_MLME - WILC_Uint8 u8gmode = NO_ENCRYPT; - WILC_Uint8 u8pmode = NO_ENCRYPT; + u8 u8gmode = NO_ENCRYPT; + u8 u8pmode = NO_ENCRYPT; AUTHTYPE_T tenuAuth_type = ANY; #endif @@ -1261,7 +1261,7 @@ static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 k if (priv->wilc_gtk[key_index]->key) WILC_FREE(priv->wilc_gtk[key_index]->key); - priv->wilc_gtk[key_index]->key = (WILC_Uint8 *)WILC_MALLOC(params->key_len); + priv->wilc_gtk[key_index]->key = (u8 *)WILC_MALLOC(params->key_len); WILC_memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len); /* if there has been previous allocation for the same index through its seq, free that memory and allocate again*/ @@ -1269,7 +1269,7 @@ static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 k WILC_FREE(priv->wilc_gtk[key_index]->seq); if ((params->seq_len) > 0) { - priv->wilc_gtk[key_index]->seq = (WILC_Uint8 *)WILC_MALLOC(params->seq_len); + priv->wilc_gtk[key_index]->seq = (u8 *)WILC_MALLOC(params->seq_len); WILC_memcpy(priv->wilc_gtk[key_index]->seq, params->seq, params->seq_len); } @@ -1307,13 +1307,13 @@ static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 k if (priv->wilc_ptk[key_index]->key) WILC_FREE(priv->wilc_ptk[key_index]->key); - priv->wilc_ptk[key_index]->key = (WILC_Uint8 *)WILC_MALLOC(params->key_len); + priv->wilc_ptk[key_index]->key = (u8 *)WILC_MALLOC(params->key_len); if (priv->wilc_ptk[key_index]->seq) WILC_FREE(priv->wilc_ptk[key_index]->seq); if ((params->seq_len) > 0) - priv->wilc_ptk[key_index]->seq = (WILC_Uint8 *)WILC_MALLOC(params->seq_len); + priv->wilc_ptk[key_index]->seq = (u8 *)WILC_MALLOC(params->seq_len); if (INFO) { for (i = 0; i < params->key_len; i++) @@ -1943,7 +1943,7 @@ static int WILC_WFI_set_pmksa(struct wiphy *wiphy, struct net_device *netdev, { WILC_Uint32 i; WILC_Sint32 s32Error = WILC_SUCCESS; - WILC_Uint8 flag = 0; + u8 flag = 0; struct WILC_WFI_priv *priv = wiphy_priv(wiphy); @@ -1993,7 +1993,7 @@ static int WILC_WFI_del_pmksa(struct wiphy *wiphy, struct net_device *netdev, { WILC_Uint32 i; - WILC_Uint8 flag = 0; + u8 flag = 0; WILC_Sint32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv = wiphy_priv(wiphy); @@ -2067,19 +2067,19 @@ static int WILC_WFI_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) * @version */ -void WILC_WFI_CfgParseRxAction(WILC_Uint8 *buf, WILC_Uint32 len) +void WILC_WFI_CfgParseRxAction(u8 *buf, WILC_Uint32 len) { WILC_Uint32 index = 0; WILC_Uint32 i = 0, j = 0; /*BugID_5460*/ #ifdef USE_SUPPLICANT_GO_INTENT - WILC_Uint8 intent; - WILC_Uint8 tie_breaker; + u8 intent; + u8 tie_breaker; WILC_Bool is_wilc_go = WILC_TRUE; #endif - WILC_Uint8 op_channel_attr_index = 0; - WILC_Uint8 channel_list_attr_index = 0; + u8 op_channel_attr_index = 0; + u8 channel_list_attr_index = 0; while (index < len) { if (buf[index] == GO_INTENT_ATTR_ID) { @@ -2163,13 +2163,13 @@ void WILC_WFI_CfgParseRxAction(WILC_Uint8 *buf, WILC_Uint32 len) * @date 12 DEC 2012 * @version */ -void WILC_WFI_CfgParseTxAction(WILC_Uint8 *buf, WILC_Uint32 len, WILC_Bool bOperChan, WILC_Uint8 iftype) +void WILC_WFI_CfgParseTxAction(u8 *buf, WILC_Uint32 len, WILC_Bool bOperChan, u8 iftype) { WILC_Uint32 index = 0; WILC_Uint32 i = 0, j = 0; - WILC_Uint8 op_channel_attr_index = 0; - WILC_Uint8 channel_list_attr_index = 0; + u8 op_channel_attr_index = 0; + u8 channel_list_attr_index = 0; #ifdef USE_SUPPLICANT_GO_INTENT WILC_Bool is_wilc_go = WILC_FALSE; @@ -2521,13 +2521,13 @@ static int WILC_WFI_cancel_remain_on_channel(struct wiphy *wiphy, * @brief WILC_WFI_add_wilcvendorspec * @details Adding WILC information elemet to allow two WILC devices to * identify each other and connect - * @param[in] WILC_Uint8 * buf + * @param[in] u8 * buf * @return void * @author mdaftedar * @date 01 JAN 2014 * @version 1.0 */ -void WILC_WFI_add_wilcvendorspec(WILC_Uint8 *buff) +void WILC_WFI_add_wilcvendorspec(u8 *buff) { WILC_memcpy(buff, u8P2P_vendorspec, sizeof(u8P2P_vendorspec)); } @@ -2904,10 +2904,10 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev struct WILC_WFI_priv *priv; /* struct WILC_WFI_mon_priv* mon_priv; */ perInterface_wlan_t *nic; - WILC_Uint8 interface_type; + u8 interface_type; WILC_Uint16 TID = 0; #ifdef WILC_P2P - WILC_Uint8 i; + u8 i; #endif nic = netdev_priv(dev); @@ -3330,14 +3330,14 @@ static int WILC_WFI_start_ap(struct wiphy *wiphy, struct net_device *dev, s32Error = host_int_add_beacon(priv->hWILCWFIDrv, settings->beacon_interval, settings->dtim_period, - beacon->head_len, (WILC_Uint8 *)beacon->head, - beacon->tail_len, (WILC_Uint8 *)beacon->tail); + beacon->head_len, (u8 *)beacon->head, + beacon->tail_len, (u8 *)beacon->tail); #else s32Error = host_add_beacon(priv->hWILCWFIDrv, settings->beacon_interval, settings->dtim_period, - beacon->head_len, (WILC_Uint8 *)beacon->head, - beacon->tail_len, (WILC_Uint8 *)beacon->tail); + beacon->head_len, (u8 *)beacon->head, + beacon->tail_len, (u8 *)beacon->tail); #endif return s32Error; @@ -3369,14 +3369,14 @@ static int WILC_WFI_change_beacon(struct wiphy *wiphy, struct net_device *dev, s32Error = host_int_add_beacon(priv->hWILCWFIDrv, 0, 0, - beacon->head_len, (WILC_Uint8 *)beacon->head, - beacon->tail_len, (WILC_Uint8 *)beacon->tail); + beacon->head_len, (u8 *)beacon->head, + beacon->tail_len, (u8 *)beacon->tail); #else s32Error = host_add_beacon(priv->hWILCWFIDrv, 0, 0, - beacon->head_len, (WILC_Uint8 *)beacon->head, - beacon->tail_len, (WILC_Uint8 *)beacon->tail); + beacon->head_len, (u8 *)beacon->head, + beacon->tail_len, (u8 *)beacon->tail); #endif return s32Error; @@ -3395,7 +3395,7 @@ static int WILC_WFI_stop_ap(struct wiphy *wiphy, struct net_device *dev) { WILC_Sint32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv; - WILC_Uint8 NullBssid[ETH_ALEN] = {0}; + u8 NullBssid[ETH_ALEN] = {0}; WILC_NULLCHECK(s32Error, wiphy); diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 0fc383b272aa..b322f0f956ea 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -109,7 +109,7 @@ struct wilc_wfi_wep_key { }; struct sta_info { - WILC_Uint8 au8Sta_AssociatedBss[MAX_NUM_STA][ETH_ALEN]; + u8 au8Sta_AssociatedBss[MAX_NUM_STA][ETH_ALEN]; }; #ifdef WILC_P2P @@ -139,10 +139,10 @@ struct WILC_WFI_priv { - WILC_Uint8 au8AssociatedBss[ETH_ALEN]; + u8 au8AssociatedBss[ETH_ALEN]; struct sta_info assoc_stainfo; struct net_device_stats stats; - WILC_Uint8 monitor_flag; + u8 monitor_flag; int status; struct WILC_WFI_packet *ppool; struct WILC_WFI_packet *rx_queue; /* List of incoming packets */ @@ -157,13 +157,13 @@ struct WILC_WFI_priv { WILC_WFIDrvHandle hWILCWFIDrv_2; tstrHostIFpmkidAttr pmkid_list; struct WILC_WFI_stats netstats; - WILC_Uint8 WILC_WFI_wep_default; - WILC_Uint8 WILC_WFI_wep_key[4][WLAN_KEY_LEN_WEP104]; - WILC_Uint8 WILC_WFI_wep_key_len[4]; + u8 WILC_WFI_wep_default; + u8 WILC_WFI_wep_key[4][WLAN_KEY_LEN_WEP104]; + u8 WILC_WFI_wep_key_len[4]; struct net_device *real_ndev; /* The real interface that the monitor is on */ struct wilc_wfi_key *wilc_gtk[MAX_NUM_STA]; struct wilc_wfi_key *wilc_ptk[MAX_NUM_STA]; - WILC_Uint8 wilc_groupkey; + u8 wilc_groupkey; /* semaphores */ struct semaphore SemHandleUpdateStats; struct semaphore hSemScanReq; @@ -250,7 +250,7 @@ typedef struct { typedef struct { uint8_t u8IfIdx; - WILC_Uint8 iftype; + u8 iftype; int monitor_flag; int mac_opened; #ifdef WILC_P2P diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index 4055962fac81..e63788f17b5b 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -21,7 +21,7 @@ extern wilc_hif_func_t hif_sdio; extern wilc_hif_func_t hif_spi; extern wilc_cfg_func_t mac_cfg; #if defined(PLAT_RK3026_TCHIP) -extern WILC_Uint8 g_wilc_initialized; /* AMR : 0422 RK3026 Crash issue */ +extern u8 g_wilc_initialized; /* AMR : 0422 RK3026 Crash issue */ #endif extern void WILC_WFI_mgmt_rx(uint8_t *buff, uint32_t size); extern void frmw_to_linux(uint8_t *buff, uint32_t size); From b32c4997c03d9d1fcfc1c6771f70d7526ffdbbe4 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Mon, 1 Jun 2015 13:00:26 -0400 Subject: [PATCH 0784/1163] staging: unisys: Move channel creation up the stack Instead of creating a channel struct to temporarily hold the channel info and passing it through multiple functions until the device is created, just create the channel from the start. This allows us to remove the channel_info struct. I noticed 'chan_info.addr_type' was not being used, so I just deleted it. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorbus_main.c | 88 ++++++------------- .../unisys/visorbus/visorbus_private.h | 16 +--- .../staging/unisys/visorbus/visorchipset.c | 54 +++++++----- 3 files changed, 63 insertions(+), 95 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 00f9a146806c..fccf4df1e9b4 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -1010,11 +1010,9 @@ EXPORT_SYMBOL_GPL(visorbus_disable_channel_interrupts); static int create_visor_device(struct visorbus_devdata *devdata, struct visorchipset_device_info *dev_info, - struct visorchipset_channel_info chan_info, u64 partition_handle) { int rc = -1; - struct visorchannel *visorchannel = NULL; struct visor_device *dev = NULL; bool gotten = false, registered1 = false, registered2 = false; u32 chipset_bus_no = dev_info->bus_no; @@ -1022,16 +1020,6 @@ create_visor_device(struct visorbus_devdata *devdata, POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, chipset_dev_no, chipset_bus_no, POSTCODE_SEVERITY_INFO); - /* prepare chan_hdr (abstraction to read/write channel memory) */ - visorchannel = visorchannel_create(chan_info.channel_addr, - chan_info.n_channel_bytes, - GFP_KERNEL, - chan_info.channel_type_uuid); - if (!visorchannel) { - POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, chipset_dev_no, - DIAG_SEVERITY_ERR); - goto away; - } dev = kmalloc(sizeof(*dev), GFP_KERNEL); if (!dev) { POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, chipset_dev_no, @@ -1040,9 +1028,8 @@ create_visor_device(struct visorbus_devdata *devdata, } memset(dev, 0, sizeof(struct visor_device)); - dev->visorchannel = visorchannel; - dev->channel_type_guid = chan_info.channel_type_uuid; - dev->channel_bytes = chan_info.n_channel_bytes; + dev->visorchannel = dev_info->visorchannel; + dev->channel_type_guid = dev_info->channel_type_guid; dev->chipset_bus_no = chipset_bus_no; dev->chipset_dev_no = chipset_dev_no; dev->device.parent = &devdata->dev; @@ -1114,8 +1101,6 @@ away: unregister_devmajorminor_attributes(dev); if (gotten) put_device(&dev->device); - if (visorchannel) - visorchannel_destroy(visorchannel); kfree(dev); } else { total_devices_created++; @@ -1134,7 +1119,7 @@ remove_visor_device(struct visor_device *dev) } static struct visor_device * -find_visor_device_by_channel(u64 channel_physaddr) +find_visor_device_by_channel(struct visorchannel *channel) { struct list_head *listentry, *listtmp; @@ -1142,8 +1127,7 @@ find_visor_device_by_channel(u64 channel_physaddr) struct visor_device *dev = list_entry(listentry, struct visor_device, list_all); - if (visorchannel_get_physaddr(dev->visorchannel) == - channel_physaddr) + if (dev->visorchannel == channel) return dev; } return NULL; @@ -1363,41 +1347,23 @@ create_bus_instance(struct visorchipset_bus_info *bus_info) goto away; } devdata->devno = id; - if ((bus_info->chan_info.channel_addr > 0) && - (bus_info->chan_info.n_channel_bytes > 0)) { - u64 channel_addr = bus_info->chan_info.channel_addr; - unsigned long n_channel_bytes = - (unsigned long) - bus_info->chan_info.n_channel_bytes; - uuid_le channel_type_guid = - bus_info->chan_info.channel_type_uuid; - - devdata->chan = visorchannel_create(channel_addr, - n_channel_bytes, - GFP_KERNEL, - channel_type_guid); - if (!devdata->chan) { - POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, channel_addr, - POSTCODE_SEVERITY_ERR); - } else { - if (bus_info->flags.server) { - init_vbus_channel(devdata->chan); - } else { - if (get_vbus_header_info(devdata->chan, - &devdata-> - vbus_hdr_info) >= 0) { - devdata->vbus_valid = true; - write_vbus_chp_info(devdata->chan, - &devdata-> - vbus_hdr_info, - &chipset_driverinfo - ); - write_vbus_bus_info(devdata->chan, - &devdata-> - vbus_hdr_info, - &clientbus_driverinfo); - } - } + devdata->chan = bus_info->visorchannel; + if (bus_info->flags.server) { + init_vbus_channel(devdata->chan); + } else { + if (get_vbus_header_info(devdata->chan, + &devdata-> + vbus_hdr_info) >= 0) { + devdata->vbus_valid = true; + write_vbus_chp_info(devdata->chan, + &devdata-> + vbus_hdr_info, + &chipset_driverinfo + ); + write_vbus_bus_info(devdata->chan, + &devdata-> + vbus_hdr_info, + &clientbus_driverinfo); } } bus_count++; @@ -1468,7 +1434,7 @@ remove_all_visor_devices(void) } static bool entered_testing_mode; -static struct visorchipset_channel_info test_channel_infos[MAXDEVICETEST]; +static struct visorchannel *test_channel_infos[MAXDEVICETEST]; static unsigned long test_bus_nos[MAXDEVICETEST]; static unsigned long test_dev_nos[MAXDEVICETEST]; @@ -1538,7 +1504,7 @@ chipset_device_create(struct visorchipset_device_info *dev_info) if (visorbus_devicetest) if (total_devices_created < MAXDEVICETEST) { test_channel_infos[total_devices_created] = - dev_info->chan_info; + dev_info->visorchannel; test_bus_nos[total_devices_created] = bus_no; test_dev_nos[total_devices_created] = dev_no; } @@ -1552,9 +1518,7 @@ away: return; } devdata = (struct visorbus_devdata *)(bus_info.bus_driver_context); - rc = create_visor_device(devdata, dev_info, - dev_info->chan_info, - bus_info.partition_handle); + rc = create_visor_device(devdata, dev_info, bus_info.partition_handle); POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); if (rc < 0) @@ -1570,7 +1534,7 @@ chipset_device_destroy(struct visorchipset_device_info *dev_info) if (entered_testing_mode) return; - dev = find_visor_device_by_channel(dev_info->chan_info.channel_addr); + dev = find_visor_device_by_channel(dev_info->visorchannel); if (!dev) goto away; rc = 0; @@ -1650,7 +1614,7 @@ initiate_chipset_device_pause_resume(struct visorchipset_device_info *dev_info, if (!notify_func) goto away; - dev = find_visor_device_by_channel(dev_info->chan_info.channel_addr); + dev = find_visor_device_by_channel(dev_info->visorchannel); if (!dev) goto away; diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h index 81e4e8c24191..912b6cdfb299 100644 --- a/drivers/staging/unisys/visorbus/visorbus_private.h +++ b/drivers/staging/unisys/visorbus/visorbus_private.h @@ -40,17 +40,6 @@ enum visorchipset_addresstype { ADDRTYPE_LOCALTEST, }; -/** Attributes for a particular Supervisor channel. - */ -struct visorchipset_channel_info { - enum visorchipset_addresstype addr_type; - u64 channel_addr; - struct irq_info intr; - u64 n_channel_bytes; - uuid_le channel_type_uuid; - uuid_le channel_inst_uuid; -}; - /** Attributes for a particular Supervisor device. * Any visorchipset client can query these attributes using * visorchipset_get_client_device_info() or @@ -62,7 +51,8 @@ struct visorchipset_device_info { u32 dev_no; uuid_le dev_inst_uuid; struct visorchipset_state state; - struct visorchipset_channel_info chan_info; + struct visorchannel *visorchannel; + uuid_le channel_type_guid; u32 reserved1; /* control_vm_id */ u64 reserved2; u32 switch_no; /* when devState.attached==1 */ @@ -82,7 +72,7 @@ struct visorchipset_bus_info { struct list_head entry; u32 bus_no; struct visorchipset_state state; - struct visorchipset_channel_info chan_info; + struct visorchannel *visorchannel; uuid_le partition_uuid; u64 partition_handle; u8 *name; /* UTF8 */ diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 9bbc0804f878..3d0866148870 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -1197,6 +1197,7 @@ bus_create(struct controlvm_message *inmsg) u32 bus_no = cmd->create_bus.bus_no; int rc = CONTROLVM_RESP_SUCCESS; struct visorchipset_bus_info *bus_info; + struct visorchannel *visorchannel; bus_info = bus_find(&bus_info_list, bus_no); if (bus_info && (bus_info->state.created == 1)) { @@ -1218,18 +1219,22 @@ bus_create(struct controlvm_message *inmsg) POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO); - if (inmsg->hdr.flags.test_message == 1) - bus_info->chan_info.addr_type = ADDRTYPE_LOCALTEST; - else - bus_info->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL; - bus_info->flags.server = inmsg->hdr.flags.server; - bus_info->chan_info.channel_addr = cmd->create_bus.channel_addr; - bus_info->chan_info.n_channel_bytes = cmd->create_bus.channel_bytes; - bus_info->chan_info.channel_type_uuid = - cmd->create_bus.bus_data_type_uuid; - bus_info->chan_info.channel_inst_uuid = cmd->create_bus.bus_inst_uuid; + visorchannel = visorchannel_create(cmd->create_bus.channel_addr, + cmd->create_bus.channel_bytes, + GFP_KERNEL, + cmd->create_bus.bus_data_type_uuid); + + if (!visorchannel) { + POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no, + POSTCODE_SEVERITY_ERR); + rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED; + kfree(bus_info); + bus_info = NULL; + goto cleanup; + } + bus_info->visorchannel = visorchannel; list_add(&bus_info->entry, &bus_info_list); POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO); @@ -1285,7 +1290,8 @@ bus_configure(struct controlvm_message *inmsg, POSTCODE_SEVERITY_ERR); rc = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT; } else { - bus_info->partition_handle = cmd->configure_bus.guest_handle; + visorchannel_set_clientpartition(bus_info->visorchannel, + cmd->configure_bus.guest_handle); bus_info->partition_uuid = parser_id_get(parser_ctx); parser_param_start(parser_ctx, PARSERSTRING_NAME); bus_info->name = parser_string_get(parser_ctx); @@ -1306,6 +1312,7 @@ my_device_create(struct controlvm_message *inmsg) u32 dev_no = cmd->create_device.dev_no; struct visorchipset_device_info *dev_info; struct visorchipset_bus_info *bus_info; + struct visorchannel *visorchannel; int rc = CONTROLVM_RESP_SUCCESS; dev_info = device_find(&dev_info_list, bus_no, dev_no); @@ -1343,21 +1350,28 @@ my_device_create(struct controlvm_message *inmsg) POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); - if (inmsg->hdr.flags.test_message == 1) - dev_info->chan_info.addr_type = ADDRTYPE_LOCALTEST; - else - dev_info->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL; - dev_info->chan_info.channel_addr = cmd->create_device.channel_addr; - dev_info->chan_info.n_channel_bytes = cmd->create_device.channel_bytes; - dev_info->chan_info.channel_type_uuid = - cmd->create_device.data_type_uuid; + visorchannel = visorchannel_create(cmd->create_device.channel_addr, + cmd->create_device.channel_bytes, + GFP_KERNEL, + cmd->create_device.data_type_uuid); + + if (!visorchannel) { + POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, + POSTCODE_SEVERITY_ERR); + rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED; + kfree(dev_info); + dev_info = NULL; + goto cleanup; + } + dev_info->visorchannel = visorchannel; + dev_info->channel_type_guid = cmd->create_device.data_type_uuid; list_add(&dev_info->entry, &dev_info_list); POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); cleanup: /* get the bus and devNo for DiagPool channel */ if (dev_info && - is_diagpool_channel(dev_info->chan_info.channel_type_uuid)) { + is_diagpool_channel(cmd->create_device.data_type_uuid)) { g_diagpool_bus_no = bus_no; g_diagpool_dev_no = dev_no; } From 0274b5aec1b30f594e2e5975b3bbf672565a6dd7 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Mon, 1 Jun 2015 13:00:27 -0400 Subject: [PATCH 0785/1163] staging: unisys: Convert pending_msg_hdr to a pointer In order for bus/dev_info structs to become public structs, one element, pending_msg_hdr, needs to become opaque. This is to keep all the internals of the controlvm struct private to the bus layer. So a simple conversion of embedding the pending_msg_hdr struct into a pointer is done. The rest of the patch is the fallout. The rules are modified slightly. Instead of relying on the 'id' to be CONTROLVM_INVALID to indicate invalid, just use the pointer set to NULL. In addition, because bus/dev_info can be NULL and we still need to send a response, pass pending_msg_hdr to all 'responders' instead of bus/ That change causes some fallout in the success case. Instead of setting state bits and clearing info in the responders, do all that magic in the responder wrappers. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/visorbus/visorbus_private.h | 4 +- .../staging/unisys/visorbus/visorchipset.c | 187 +++++++++++------- 2 files changed, 119 insertions(+), 72 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h index 912b6cdfb299..f371f9d646a5 100644 --- a/drivers/staging/unisys/visorbus/visorbus_private.h +++ b/drivers/staging/unisys/visorbus/visorbus_private.h @@ -57,7 +57,7 @@ struct visorchipset_device_info { u64 reserved2; u32 switch_no; /* when devState.attached==1 */ u32 internal_port_no; /* when devState.attached==1 */ - struct controlvm_message_header pending_msg_hdr;/* CONTROLVM_MESSAGE */ + struct controlvm_message_header *pending_msg_hdr;/* CONTROLVM_MESSAGE */ /** For private use by the bus driver */ void *bus_driver_context; }; @@ -84,7 +84,7 @@ struct visorchipset_bus_info { /* Add new fields above. */ /* Remaining bits in this 32-bit word are unused. */ } flags; - struct controlvm_message_header pending_msg_hdr;/* CONTROLVM MsgHdr */ + struct controlvm_message_header *pending_msg_hdr;/* CONTROLVM MsgHdr */ /** For private use by the bus driver */ void *bus_driver_context; }; diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 3d0866148870..247888970d91 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -962,37 +962,17 @@ enum crash_obj_type { }; static void -bus_responder(enum controlvm_id cmd_id, struct visorchipset_bus_info *p, +bus_responder(enum controlvm_id cmd_id, + struct controlvm_message_header *pending_msg_hdr, int response) { - bool need_clear = false; - u32 bus_no = p->bus_no; - - if (!p) - return; - - if (response < 0) { - if ((cmd_id == CONTROLVM_BUS_CREATE) && - (response != (-CONTROLVM_RESP_ERROR_ALREADY_DONE))) - /* undo the row we just created... */ - busdevices_del(&dev_info_list, bus_no); - } else { - if (cmd_id == CONTROLVM_BUS_CREATE) - p->state.created = 1; - if (cmd_id == CONTROLVM_BUS_DESTROY) - need_clear = true; - } - - if (p->pending_msg_hdr.id == CONTROLVM_INVALID) + if (pending_msg_hdr == NULL) return; /* no controlvm response needed */ - if (p->pending_msg_hdr.id != (u32)cmd_id) + + if (pending_msg_hdr->id != (u32)cmd_id) return; - controlvm_respond(&p->pending_msg_hdr, response); - p->pending_msg_hdr.id = CONTROLVM_INVALID; - if (need_clear) { - bus_info_clear(p); - busdevices_del(&dev_info_list, bus_no); - } + + controlvm_respond(pending_msg_hdr, response); } static void @@ -1004,14 +984,12 @@ device_changestate_responder(enum controlvm_id cmd_id, u32 bus_no = p->bus_no; u32 dev_no = p->dev_no; - if (!p) - return; - if (p->pending_msg_hdr.id == CONTROLVM_INVALID) + if (p->pending_msg_hdr == NULL) return; /* no controlvm response needed */ - if (p->pending_msg_hdr.id != cmd_id) + if (p->pending_msg_hdr->id != cmd_id) return; - controlvm_init_response(&outmsg, &p->pending_msg_hdr, response); + controlvm_init_response(&outmsg, p->pending_msg_hdr, response); outmsg.cmd.device_change_state.bus_no = bus_no; outmsg.cmd.device_change_state.dev_no = dev_no; @@ -1020,35 +998,20 @@ device_changestate_responder(enum controlvm_id cmd_id, if (!visorchannel_signalinsert(controlvm_channel, CONTROLVM_QUEUE_REQUEST, &outmsg)) return; - - p->pending_msg_hdr.id = CONTROLVM_INVALID; } static void -device_responder(enum controlvm_id cmd_id, struct visorchipset_device_info *p, +device_responder(enum controlvm_id cmd_id, + struct controlvm_message_header *pending_msg_hdr, int response) { - bool need_clear = false; - - if (!p) - return; - if (response >= 0) { - if (cmd_id == CONTROLVM_DEVICE_CREATE) - p->state.created = 1; - if (cmd_id == CONTROLVM_DEVICE_DESTROY) - need_clear = true; - } - - if (p->pending_msg_hdr.id == CONTROLVM_INVALID) + if (pending_msg_hdr == NULL) return; /* no controlvm response needed */ - if (p->pending_msg_hdr.id != (u32)cmd_id) + if (pending_msg_hdr->id != (u32)cmd_id) return; - controlvm_respond(&p->pending_msg_hdr, response); - p->pending_msg_hdr.id = CONTROLVM_INVALID; - if (need_clear) - dev_info_clear(p); + controlvm_respond(pending_msg_hdr, response); } static void @@ -1057,15 +1020,32 @@ bus_epilog(struct visorchipset_bus_info *bus_info, int response, bool need_response) { bool notified = false; + struct controlvm_message_header *pmsg_hdr = NULL; - if (!bus_info) - return; + if (!bus_info) { + /* relying on a valid passed in response code */ + /* be lazy and re-use msg_hdr for this failure, is this ok?? */ + pmsg_hdr = msg_hdr; + goto away; + } + + if (bus_info->pending_msg_hdr) { + /* only non-NULL if dev is still waiting on a response */ + response = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT; + pmsg_hdr = bus_info->pending_msg_hdr; + goto away; + } if (need_response) { - memcpy(&bus_info->pending_msg_hdr, msg_hdr, + pmsg_hdr = kzalloc(sizeof(*pmsg_hdr), GFP_KERNEL); + if (!pmsg_hdr) { + response = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED; + goto away; + } + + memcpy(pmsg_hdr, msg_hdr, sizeof(struct controlvm_message_header)); - } else { - bus_info->pending_msg_hdr.id = CONTROLVM_INVALID; + bus_info->pending_msg_hdr = pmsg_hdr; } down(¬ifier_lock); @@ -1085,6 +1065,7 @@ bus_epilog(struct visorchipset_bus_info *bus_info, break; } } +away: if (notified) /* The callback function just called above is responsible * for calling the appropriate visorchipset_busdev_responders @@ -1092,7 +1073,12 @@ bus_epilog(struct visorchipset_bus_info *bus_info, */ ; else - bus_responder(cmd, bus_info, response); + /* + * Do not kfree(pmsg_hdr) as this is the failure path. + * The success path ('notified') will call the responder + * directly and kfree() there. + */ + bus_responder(cmd, pmsg_hdr, response); up(¬ifier_lock); } @@ -1106,22 +1092,39 @@ device_epilog(struct visorchipset_device_info *dev_info, bool notified = false; u32 bus_no = dev_info->bus_no; u32 dev_no = dev_info->dev_no; + struct controlvm_message_header *pmsg_hdr = NULL; char *envp[] = { "SPARSP_DIAGPOOL_PAUSED_STATE = 1", NULL }; - if (!dev_info) - return; - notifiers = &busdev_notifiers; + if (!dev_info) { + /* relying on a valid passed in response code */ + /* be lazy and re-use msg_hdr for this failure, is this ok?? */ + pmsg_hdr = msg_hdr; + goto away; + } + + if (dev_info->pending_msg_hdr) { + /* only non-NULL if dev is still waiting on a response */ + response = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT; + pmsg_hdr = dev_info->pending_msg_hdr; + goto away; + } + if (need_response) { - memcpy(&dev_info->pending_msg_hdr, msg_hdr, + pmsg_hdr = kzalloc(sizeof(*pmsg_hdr), GFP_KERNEL); + if (!pmsg_hdr) { + response = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED; + goto away; + } + + memcpy(pmsg_hdr, msg_hdr, sizeof(struct controlvm_message_header)); - } else { - dev_info->pending_msg_hdr.id = CONTROLVM_INVALID; + dev_info->pending_msg_hdr = pmsg_hdr; } down(¬ifier_lock); @@ -1179,6 +1182,7 @@ device_epilog(struct visorchipset_device_info *dev_info, break; } } +away: if (notified) /* The callback function just called above is responsible * for calling the appropriate visorchipset_busdev_responders @@ -1186,7 +1190,12 @@ device_epilog(struct visorchipset_device_info *dev_info, */ ; else - device_responder(cmd, dev_info, response); + /* + * Do not kfree(pmsg_hdr) as this is the failure path. + * The success path ('notified') will call the responder + * directly and kfree() there. + */ + device_responder(cmd, pmsg_hdr, response); up(¬ifier_lock); } @@ -1285,7 +1294,7 @@ bus_configure(struct controlvm_message *inmsg, POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no, POSTCODE_SEVERITY_ERR); rc = -CONTROLVM_RESP_ERROR_BUS_INVALID; - } else if (bus_info->pending_msg_hdr.id != CONTROLVM_INVALID) { + } else if (bus_info->pending_msg_hdr != NULL) { POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no, POSTCODE_SEVERITY_ERR); rc = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT; @@ -2127,25 +2136,57 @@ cleanup: static void bus_create_response(struct visorchipset_bus_info *bus_info, int response) { - bus_responder(CONTROLVM_BUS_CREATE, bus_info, response); + if (response >= 0) { + bus_info->state.created = 1; + } else { + if (response != -CONTROLVM_RESP_ERROR_ALREADY_DONE) + /* undo the row we just created... */ + busdevices_del(&dev_info_list, bus_info->bus_no); + } + + bus_responder(CONTROLVM_BUS_CREATE, bus_info->pending_msg_hdr, + response); + + kfree(bus_info->pending_msg_hdr); + bus_info->pending_msg_hdr = NULL; } static void bus_destroy_response(struct visorchipset_bus_info *bus_info, int response) { - bus_responder(CONTROLVM_BUS_DESTROY, bus_info, response); + bus_responder(CONTROLVM_BUS_DESTROY, bus_info->pending_msg_hdr, + response); + + kfree(bus_info->pending_msg_hdr); + bus_info->pending_msg_hdr = NULL; + + bus_info_clear(bus_info); + busdevices_del(&dev_info_list, bus_info->bus_no); } static void device_create_response(struct visorchipset_device_info *dev_info, int response) { - device_responder(CONTROLVM_DEVICE_CREATE, dev_info, response); + if (response >= 0) + dev_info->state.created = 1; + + device_responder(CONTROLVM_DEVICE_CREATE, dev_info->pending_msg_hdr, + response); + + kfree(dev_info->pending_msg_hdr); + dev_info->pending_msg_hdr = NULL; } static void device_destroy_response(struct visorchipset_device_info *dev_info, int response) { - device_responder(CONTROLVM_DEVICE_DESTROY, dev_info, response); + device_responder(CONTROLVM_DEVICE_DESTROY, dev_info->pending_msg_hdr, + response); + + kfree(dev_info->pending_msg_hdr); + dev_info->pending_msg_hdr = NULL; + + dev_info_clear(dev_info); } static void @@ -2155,6 +2196,9 @@ visorchipset_device_pause_response(struct visorchipset_device_info *dev_info, device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE, dev_info, response, segment_state_standby); + + kfree(dev_info->pending_msg_hdr); + dev_info->pending_msg_hdr = NULL; } static void @@ -2163,6 +2207,9 @@ device_resume_response(struct visorchipset_device_info *dev_info, int response) device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE, dev_info, response, segment_state_running); + + kfree(dev_info->pending_msg_hdr); + dev_info->pending_msg_hdr = NULL; } bool From 7726f81357f9ddb55611995b1ec2e75abbd733a1 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Mon, 1 Jun 2015 13:00:28 -0400 Subject: [PATCH 0786/1163] staging: unisys: Prepare vbus_hdr_info to be public In order to remove bus_info, we need to migrate vbus_hdr_info into the public namespace of visor_device. Because the struct is private, we use a void * to hide the contents. As a result, we need to allocate vbus_hdr_info and manage it. Also work around vbus_valid, as that variable will not be used in the public namespace. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorbus_main.c | 52 +++++++++++-------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index fccf4df1e9b4..c7db6817f1b4 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -45,7 +45,7 @@ struct visorbus_devdata { struct kobject kobj; struct visorchannel *chan; /* channel area for bus itself */ bool vbus_valid; - struct spar_vbus_headerinfo vbus_hdr_info; + void *vbus_hdr_info; }; #define CURRENT_FILE_PC VISOR_BUS_PC_visorbus_main_c @@ -1276,10 +1276,13 @@ fix_vbus_dev_info(struct visor_device *visordev) int dev_no = visordev->chipset_dev_no; struct ultra_vbus_deviceinfo dev_info; const char *chan_type_name = NULL; + struct spar_vbus_headerinfo *hdr_info; if (!visordev->device.driver) return; + hdr_info = (struct spar_vbus_headerinfo *)visordev->vbus_hdr_info; + visordrv = to_visor_driver(visordev->device.driver); if (!visorchipset_get_bus_info(bus_no, &bus_info)) return; @@ -1288,7 +1291,7 @@ fix_vbus_dev_info(struct visor_device *visordev) if (!devdata) return; - if (!devdata->vbus_valid) + if (!hdr_info) return; /* Within the list of device types (by GUID) that the driver @@ -1308,16 +1311,13 @@ fix_vbus_dev_info(struct visor_device *visordev) bus_device_info_init(&dev_info, chan_type_name, visordrv->name, visordrv->version, visordrv->vertag); - write_vbus_dev_info(devdata->chan, - &devdata->vbus_hdr_info, &dev_info, dev_no); + write_vbus_dev_info(devdata->chan, hdr_info, &dev_info, dev_no); /* Re-write bus+chipset info, because it is possible that this * was previously written by our evil counterpart, virtpci. */ - write_vbus_chp_info(devdata->chan, &devdata->vbus_hdr_info, - &chipset_driverinfo); - write_vbus_bus_info(devdata->chan, &devdata->vbus_hdr_info, - &clientbus_driverinfo); + write_vbus_chp_info(devdata->chan, hdr_info, &chipset_driverinfo); + write_vbus_bus_info(devdata->chan, hdr_info, &clientbus_driverinfo); } /** Create a device instance for the visor bus itself. @@ -1328,6 +1328,7 @@ create_bus_instance(struct visorchipset_bus_info *bus_info) struct visorbus_devdata *rc = NULL; struct visorbus_devdata *devdata = NULL; int id = bus_info->bus_no; + struct spar_vbus_headerinfo *hdr_info; POSTCODE_LINUX_2(BUS_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); devdata = kzalloc(sizeof(*devdata), GFP_KERNEL); @@ -1336,6 +1337,13 @@ create_bus_instance(struct visorchipset_bus_info *bus_info) rc = NULL; goto away; } + + hdr_info = kzalloc(sizeof(*hdr_info), GFP_KERNEL); + if (!hdr_info) { + rc = NULL; + goto away_mem; + } + dev_set_name(&devdata->dev, "visorbus%d", id); devdata->dev.bus = &visorbus_type; devdata->dev.groups = visorbus_groups; @@ -1344,26 +1352,19 @@ create_bus_instance(struct visorchipset_bus_info *bus_info) POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, id, POSTCODE_SEVERITY_ERR); rc = NULL; - goto away; + goto away_mem2; } devdata->devno = id; devdata->chan = bus_info->visorchannel; if (bus_info->flags.server) { init_vbus_channel(devdata->chan); } else { - if (get_vbus_header_info(devdata->chan, - &devdata-> - vbus_hdr_info) >= 0) { - devdata->vbus_valid = true; - write_vbus_chp_info(devdata->chan, - &devdata-> - vbus_hdr_info, - &chipset_driverinfo - ); - write_vbus_bus_info(devdata->chan, - &devdata-> - vbus_hdr_info, - &clientbus_driverinfo); + if (get_vbus_header_info(devdata->chan, hdr_info) >= 0) { + devdata->vbus_hdr_info = (void *)hdr_info; + write_vbus_chp_info(devdata->chan, hdr_info, + &chipset_driverinfo); + write_vbus_bus_info(devdata->chan, hdr_info, + &clientbus_driverinfo); } } bus_count++; @@ -1372,6 +1373,12 @@ create_bus_instance(struct visorchipset_bus_info *bus_info) devdata = devdata; /* for testing ONLY */ dev_set_drvdata(&devdata->dev, devdata); rc = devdata; + return rc; + +away_mem2: + kfree(hdr_info); +away_mem: + kfree(devdata); away: return rc; } @@ -1393,6 +1400,7 @@ remove_bus_instance(struct visorbus_devdata *devdata) visorchannel_destroy(devdata->chan); devdata->chan = NULL; } + kfree(devdata->vbus_hdr_info); list_del(&devdata->list_all); device_unregister(&devdata->dev); } From 084861124d00b046cb4159b0158e1b74626b8257 Mon Sep 17 00:00:00 2001 From: Nicholas Mc Guire Date: Fri, 29 May 2015 17:31:16 +0200 Subject: [PATCH 0787/1163] staging: unisys: use schedule_timeout_interruptible() API consolidation with coccinelle found: ./drivers/staging/unisys/visorbus/periodic_work.c:196:3-19: consolidation with schedule_timeout_*() recommended This is a 1:1 conversion with respect to schedule_timeout() to the schedule_timeout_interruptible() helper only - so only an API consolidation to improve readability. The hard coded timeout of 10 jiffies is HZ dependent which it should not be, so it is converted with msecs_to_jiffies. Patch was compile tested with x86_64_defconfig + CONFIG_STAGING=y, CONFIG_UNISYSSPAR=y, CONFIG_UNISYS_VISORBUS=m Patch is against 4.1-rc5 (localversion-next is -next-20150529) Signed-off-by: Nicholas Mc Guire Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/periodic_work.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visorbus/periodic_work.c b/drivers/staging/unisys/visorbus/periodic_work.c index 3562e8b2824b..5e56088cf855 100644 --- a/drivers/staging/unisys/visorbus/periodic_work.c +++ b/drivers/staging/unisys/visorbus/periodic_work.c @@ -192,8 +192,7 @@ bool visor_periodic_work_stop(struct periodic_work *pw) } if (pw->is_scheduled) { write_unlock(&pw->lock); - __set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(10); + schedule_timeout_interruptible(msecs_to_jiffies(10)); write_lock(&pw->lock); } else { pw->want_to_stop = false; From a52ffebcf19afea27588abe75828f9d300e08f3d Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Fri, 5 Jun 2015 14:03:10 +0300 Subject: [PATCH 0788/1163] iio: magnetometer: mmc35240: i2c device name should be lower case This is the standard convention for i2c device name and also this is the name used in some Intel platforms DT files. Fixes: abeb6b1e7b ("iio: magnetometer: Add support for MEMSIC MMC35240") Signed-off-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/mmc35240.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c index c71392cf1370..d8cf5a6f9291 100644 --- a/drivers/iio/magnetometer/mmc35240.c +++ b/drivers/iio/magnetometer/mmc35240.c @@ -490,7 +490,7 @@ static const struct acpi_device_id mmc35240_acpi_match[] = { MODULE_DEVICE_TABLE(acpi, mmc35240_acpi_match); static const struct i2c_device_id mmc35240_id[] = { - {"MMC35240", 0}, + {"mmc35240", 0}, {} }; MODULE_DEVICE_TABLE(i2c, mmc35240_id); From bd35a214f56158d11e46c4a9d8436139f58e7099 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Fri, 5 Jun 2015 14:03:11 +0300 Subject: [PATCH 0789/1163] iio: magnetometer: mmc35240: NULL terminate attribute array This avoid nasty crashes when registering the IIO device. Fixes: abeb6b1e7b ("iio: magnetometer: Add support for MEMSIC MMC35240") Signed-off-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/mmc35240.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c index d8cf5a6f9291..78da0d15c8eb 100644 --- a/drivers/iio/magnetometer/mmc35240.c +++ b/drivers/iio/magnetometer/mmc35240.c @@ -125,6 +125,7 @@ static const struct iio_chan_spec mmc35240_channels[] = { static struct attribute *mmc35240_attributes[] = { &iio_const_attr_sampling_frequency_available.dev_attr.attr, + NULL }; static const struct attribute_group mmc35240_attribute_group = { From c2890547a035e019df646be5d56adc0ee1b0a327 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Fri, 5 Jun 2015 14:03:12 +0300 Subject: [PATCH 0790/1163] iio: magnetometer: mmc35240: Fix broken processed value The current computation for fractional part of the magnetic field is broken. This patch fixes it by taking a different approach. We expose the raw reading in milli Gauss (to avoid rounding errors) with a scale of 0.001. Thus the final computation is done in userspace where floating point operation are more relaxed. Fixes: abeb6b1e7b ("iio: magnetometer: Add support for MEMSIC MMC35240") Signed-off-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/mmc35240.c | 43 ++++++++++++++++++----------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c index 78da0d15c8eb..146ae6613537 100644 --- a/drivers/iio/magnetometer/mmc35240.c +++ b/drivers/iio/magnetometer/mmc35240.c @@ -113,8 +113,9 @@ static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("100 200 333 666"); .modified = 1, \ .channel2 = IIO_MOD_ ## _axis, \ .address = AXIS_ ## _axis, \ - .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), \ - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ), \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \ + BIT(IIO_CHAN_INFO_SCALE), \ } static const struct iio_chan_spec mmc35240_channels[] = { @@ -241,9 +242,19 @@ static int mmc35240_read_measurement(struct mmc35240_data *data, __le16 buf[3]) 3 * sizeof(__le16)); } -static int mmc35240_raw_to_gauss(struct mmc35240_data *data, int index, - __le16 buf[], - int *val, int *val2) +/** + * mmc35240_raw_to_mgauss - convert raw readings to milli gauss. Also apply + compensation for output value. + * + * @data: device private data + * @index: axis index for which we want the conversion + * @buf: raw data to be converted, 2 bytes in little endian format + * @val: compensated output reading (unit is milli gauss) + * + * Returns: 0 in case of success, -EINVAL when @index is not valid + */ +static int mmc35240_raw_to_mgauss(struct mmc35240_data *data, int index, + __le16 buf[], int *val) { int raw_x, raw_y, raw_z; int sens_x, sens_y, sens_z; @@ -261,18 +272,15 @@ static int mmc35240_raw_to_gauss(struct mmc35240_data *data, int index, switch (index) { case AXIS_X: - *val = (raw_x - nfo) / sens_x; - *val2 = ((raw_x - nfo) % sens_x) * 1000000; + *val = (raw_x - nfo) * 1000 / sens_x; break; case AXIS_Y: - *val = (raw_y - nfo) / sens_y - (raw_z - nfo) / sens_z; - *val2 = (((raw_y - nfo) % sens_y - (raw_z - nfo) % sens_z)) - * 1000000; + *val = (raw_y - nfo) * 1000 / sens_y - + (raw_z - nfo) * 1000 / sens_z; break; case AXIS_Z: - *val = (raw_y - nfo) / sens_y + (raw_z - nfo) / sens_z; - *val2 = (((raw_y - nfo) % sens_y + (raw_z - nfo) % sens_z)) - * 1000000; + *val = (raw_y - nfo) * 1000 / sens_y + + (raw_z - nfo) * 1000 / sens_z; break; default: return -EINVAL; @@ -290,16 +298,19 @@ static int mmc35240_read_raw(struct iio_dev *indio_dev, __le16 buf[3]; switch (mask) { - case IIO_CHAN_INFO_PROCESSED: + case IIO_CHAN_INFO_RAW: mutex_lock(&data->mutex); ret = mmc35240_read_measurement(data, buf); mutex_unlock(&data->mutex); if (ret < 0) return ret; - ret = mmc35240_raw_to_gauss(data, chan->address, - buf, val, val2); + ret = mmc35240_raw_to_mgauss(data, chan->address, buf, val); if (ret < 0) return ret; + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + *val = 0; + *val2 = 1000; return IIO_VAL_INT_PLUS_MICRO; case IIO_CHAN_INFO_SAMP_FREQ: mutex_lock(&data->mutex); From 787f55c4d1842e5fb037a81bca9bd9d9fdfd46fe Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Fri, 5 Jun 2015 14:03:13 +0300 Subject: [PATCH 0791/1163] iio: magnetometer: mmc35240: Use a smaller sleep value According to datasheet, Page 8, minimum wait time to complete measurement is 10ms. Adjusting this value will increase the userspace polling rate. Fixes: abeb6b1e7b ("iio: magnetometer: Add support for MEMSIC MMC35240") Signed-off-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/mmc35240.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c index 146ae6613537..7fdf906b94c9 100644 --- a/drivers/iio/magnetometer/mmc35240.c +++ b/drivers/iio/magnetometer/mmc35240.c @@ -219,7 +219,8 @@ static int mmc35240_take_measurement(struct mmc35240_data *data) return ret; if (reg_status & MMC35240_STATUS_MEAS_DONE_BIT) break; - msleep(20); + /* minimum wait time to complete measurement is 10 ms */ + usleep_range(10000, 11000); } if (tries < 0) { From 6b90da4b58b39a80f490479953aa2563c3c41a6d Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Fri, 5 Jun 2015 14:03:14 +0300 Subject: [PATCH 0792/1163] iio: magnetometer: mmc35240: Fix sensitivity on z-axis Datasheet says (Page 2) that typical value for sensitivity for 16 bits mode on Z-axis is 770. Anyhow, looking at the input driver provided by Memsic the value for MMC35240 is 1024. Also, testing shows that using 1024 for Z-axis senzitivity offers better results. Fixes: abeb6b1e7b ("iio: magnetometer: Add support for MEMSIC MMC35240") Signed-off-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/mmc35240.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c index 7fdf906b94c9..b2ab58ea15f0 100644 --- a/drivers/iio/magnetometer/mmc35240.c +++ b/drivers/iio/magnetometer/mmc35240.c @@ -77,7 +77,7 @@ static const struct { } mmc35240_props_table[] = { /* 16 bits, 100Hz ODR */ { - {1024, 1024, 770}, + {1024, 1024, 1024}, 32768, }, /* 16 bits, 200Hz ODR */ From 4892688d7004c004765a51976087a8f51ce3586d Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Fri, 5 Jun 2015 14:03:15 +0300 Subject: [PATCH 0793/1163] iio: magnetometer: mmc35240: Add compensation for raw values This patch adds compensation formula to raw readings, borrowed from Memsic's input driver. Signed-off-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/mmc35240.c | 62 +++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c index b2ab58ea15f0..7a2ea71c659a 100644 --- a/drivers/iio/magnetometer/mmc35240.c +++ b/drivers/iio/magnetometer/mmc35240.c @@ -58,6 +58,31 @@ #define MMC35240_WAIT_CHARGE_PUMP 50000 /* us */ #define MMC53240_WAIT_SET_RESET 1000 /* us */ +/* + * Memsic OTP process code piece is put here for reference: + * + * #define OTP_CONVERT(REG) ((float)((REG) >=32 ? (32 - (REG)) : (REG)) * 0.006 + * 1) For X axis, the COEFFICIENT is always 1. + * 2) For Y axis, the COEFFICIENT is as below: + * f_OTP_matrix[4] = OTP_CONVERT(((reg_data[1] & 0x03) << 4) | + * (reg_data[2] >> 4)) + 1.0; + * 3) For Z axis, the COEFFICIENT is as below: + * f_OTP_matrix[8] = (OTP_CONVERT(reg_data[3] & 0x3f) + 1) * 1.35; + * We implemented the OTP logic into driver. + */ + +/* scale = 1000 here for Y otp */ +#define MMC35240_OTP_CONVERT_Y(REG) (((REG) >= 32 ? (32 - (REG)) : (REG)) * 6) + +/* 0.6 * 1.35 = 0.81, scale 10000 for Z otp */ +#define MMC35240_OTP_CONVERT_Z(REG) (((REG) >= 32 ? (32 - (REG)) : (REG)) * 81) + +#define MMC35240_X_COEFF(x) (x) +#define MMC35240_Y_COEFF(y) (y + 1000) +#define MMC35240_Z_COEFF(z) (z + 13500) + +#define MMC35240_OTP_START_ADDR 0x1B + enum mmc35240_resolution { MMC35240_16_BITS_SLOW = 0, /* 100 Hz */ MMC35240_16_BITS_FAST, /* 200 Hz */ @@ -102,6 +127,10 @@ struct mmc35240_data { struct mutex mutex; struct regmap *regmap; enum mmc35240_resolution res; + + /* OTP compensation */ + int axis_coef[3]; + int axis_scale[3]; }; static const int mmc35240_samp_freq[] = {100, 200, 333, 666}; @@ -172,8 +201,9 @@ static int mmc35240_hw_set(struct mmc35240_data *data, bool set) static int mmc35240_init(struct mmc35240_data *data) { - int ret; + int ret, y_convert, z_convert; unsigned int reg_id; + u8 otp_data[6]; ret = regmap_read(data->regmap, MMC35240_REG_ID, ®_id); if (ret < 0) { @@ -197,9 +227,30 @@ static int mmc35240_init(struct mmc35240_data *data) return ret; /* set default sampling frequency */ - return regmap_update_bits(data->regmap, MMC35240_REG_CTRL1, - MMC35240_CTRL1_BW_MASK, - data->res << MMC35240_CTRL1_BW_SHIFT); + ret = regmap_update_bits(data->regmap, MMC35240_REG_CTRL1, + MMC35240_CTRL1_BW_MASK, + data->res << MMC35240_CTRL1_BW_SHIFT); + if (ret < 0) + return ret; + + ret = regmap_bulk_read(data->regmap, MMC35240_OTP_START_ADDR, + (u8 *)otp_data, sizeof(otp_data)); + if (ret < 0) + return ret; + + y_convert = MMC35240_OTP_CONVERT_Y(((otp_data[1] & 0x03) << 4) | + (otp_data[2] >> 4)); + z_convert = MMC35240_OTP_CONVERT_Z(otp_data[3] & 0x3f); + + data->axis_coef[0] = MMC35240_X_COEFF(1); + data->axis_coef[1] = MMC35240_Y_COEFF(y_convert); + data->axis_coef[2] = MMC35240_Z_COEFF(z_convert); + + data->axis_scale[0] = 1; + data->axis_scale[1] = 1000; + data->axis_scale[2] = 10000; + + return 0; } static int mmc35240_take_measurement(struct mmc35240_data *data) @@ -286,6 +337,9 @@ static int mmc35240_raw_to_mgauss(struct mmc35240_data *data, int index, default: return -EINVAL; } + /* apply OTP compensation */ + *val = (*val) * data->axis_coef[index] / data->axis_scale[index]; + return 0; } From 28e3427824ccc864b2866905eb10278c584b461d Mon Sep 17 00:00:00 2001 From: Martin Fuzzey Date: Mon, 1 Jun 2015 15:39:52 +0200 Subject: [PATCH 0794/1163] iio: mma8452: Basic support for transient events. The event is triggered when the highpass filtered absolute acceleration exceeds the threshold. Signed-off-by: Martin Fuzzey Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma8452.c | 212 +++++++++++++++++++++++++++++++++++- 1 file changed, 211 insertions(+), 1 deletion(-) diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index 877ce2954196..f30eb9b7a99c 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -9,7 +9,7 @@ * * 7-bit I2C slave address 0x1c/0x1d (pin selectable) * - * TODO: interrupt, thresholding, orientation / freefall events, autosleep + * TODO: orientation / freefall events, autosleep */ #include @@ -19,20 +19,33 @@ #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_INT_SRC 0x0c #define MMA8452_WHO_AM_I 0x0d #define MMA8452_DATA_CFG 0x0e +#define MMA8452_TRANSIENT_CFG 0x1d +#define MMA8452_TRANSIENT_CFG_ELE BIT(4) +#define MMA8452_TRANSIENT_CFG_CHAN(chan) BIT(chan + 1) +#define MMA8452_TRANSIENT_SRC 0x1e +#define MMA8452_TRANSIENT_SRC_XTRANSE BIT(1) +#define MMA8452_TRANSIENT_SRC_YTRANSE BIT(3) +#define MMA8452_TRANSIENT_SRC_ZTRANSE BIT(5) +#define MMA8452_TRANSIENT_THS 0x1f +#define MMA8452_TRANSIENT_THS_MASK 0x7f #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_CTRL_REG2_RST BIT(6) +#define MMA8452_CTRL_REG4 0x2d +#define MMA8452_CTRL_REG5 0x2e #define MMA8452_MAX_REG 0x31 @@ -48,6 +61,8 @@ #define MMA8452_DATA_CFG_FS_4G 1 #define MMA8452_DATA_CFG_FS_8G 2 +#define MMA8452_INT_TRANS BIT(5) + #define MMA8452_DEVICE_ID 0x2a struct mma8452_data { @@ -274,6 +289,126 @@ static int mma8452_write_raw(struct iio_dev *indio_dev, } } +static int mma8452_read_thresh(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) +{ + struct mma8452_data *data = iio_priv(indio_dev); + int ret; + + ret = i2c_smbus_read_byte_data(data->client, MMA8452_TRANSIENT_THS); + if (ret < 0) + return ret; + + *val = ret & MMA8452_TRANSIENT_THS_MASK; + + return IIO_VAL_INT; +} + +static int mma8452_write_thresh(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) +{ + struct mma8452_data *data = iio_priv(indio_dev); + + return mma8452_change_config(data, MMA8452_TRANSIENT_THS, + val & MMA8452_TRANSIENT_THS_MASK); +} + +static int mma8452_read_event_config(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir) +{ + struct mma8452_data *data = iio_priv(indio_dev); + int ret; + + ret = i2c_smbus_read_byte_data(data->client, MMA8452_TRANSIENT_CFG); + if (ret < 0) + return ret; + + return ret & MMA8452_TRANSIENT_CFG_CHAN(chan->scan_index) ? 1 : 0; +} + +static int mma8452_write_event_config(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir, + int state) +{ + struct mma8452_data *data = iio_priv(indio_dev); + int val; + + val = i2c_smbus_read_byte_data(data->client, MMA8452_TRANSIENT_CFG); + if (val < 0) + return val; + + if (state) + val |= MMA8452_TRANSIENT_CFG_CHAN(chan->scan_index); + else + val &= ~MMA8452_TRANSIENT_CFG_CHAN(chan->scan_index); + + val |= MMA8452_TRANSIENT_CFG_ELE; + + return mma8452_change_config(data, MMA8452_TRANSIENT_CFG, val); +} + +static void mma8452_transient_interrupt(struct iio_dev *indio_dev) +{ + struct mma8452_data *data = iio_priv(indio_dev); + s64 ts = iio_get_time_ns(); + int src; + + src = i2c_smbus_read_byte_data(data->client, MMA8452_TRANSIENT_SRC); + if (src < 0) + return; + + if (src & MMA8452_TRANSIENT_SRC_XTRANSE) + iio_push_event(indio_dev, + IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_X, + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_RISING), + ts); + + if (src & MMA8452_TRANSIENT_SRC_YTRANSE) + iio_push_event(indio_dev, + IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_Y, + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_RISING), + ts); + + if (src & MMA8452_TRANSIENT_SRC_ZTRANSE) + iio_push_event(indio_dev, + IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_Z, + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_RISING), + ts); +} + +static irqreturn_t mma8452_interrupt(int irq, void *p) +{ + struct iio_dev *indio_dev = p; + struct mma8452_data *data = iio_priv(indio_dev); + int src; + + src = i2c_smbus_read_byte_data(data->client, MMA8452_INT_SRC); + if (src < 0) + return IRQ_NONE; + + if (src & MMA8452_INT_TRANS) { + mma8452_transient_interrupt(indio_dev); + return IRQ_HANDLED; + } + + return IRQ_NONE; +} + static irqreturn_t mma8452_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; @@ -316,6 +451,31 @@ static int mma8452_reg_access_dbg(struct iio_dev *indio_dev, return 0; } +static const struct iio_event_spec mma8452_transient_event[] = { + { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_RISING, + .mask_separate = BIT(IIO_EV_INFO_ENABLE), + .mask_shared_by_type = BIT(IIO_EV_INFO_VALUE) + }, +}; + +/* + * Threshold is configured in fixed 8G/127 steps regardless of + * currently selected scale for measurement. + */ +static IIO_CONST_ATTR_NAMED(accel_transient_scale, in_accel_scale, "0.617742"); + +static struct attribute *mma8452_event_attributes[] = { + &iio_const_attr_accel_transient_scale.dev_attr.attr, + NULL, +}; + +static struct attribute_group mma8452_event_attribute_group = { + .attrs = mma8452_event_attributes, + .name = "events", +}; + #define MMA8452_CHANNEL(axis, idx) { \ .type = IIO_ACCEL, \ .modified = 1, \ @@ -332,6 +492,8 @@ static int mma8452_reg_access_dbg(struct iio_dev *indio_dev, .shift = 4, \ .endianness = IIO_BE, \ }, \ + .event_spec = mma8452_transient_event, \ + .num_event_specs = ARRAY_SIZE(mma8452_transient_event), \ } static const struct iio_chan_spec mma8452_channels[] = { @@ -355,6 +517,11 @@ static const struct iio_info mma8452_info = { .attrs = &mma8452_group, .read_raw = &mma8452_read_raw, .write_raw = &mma8452_write_raw, + .event_attrs = &mma8452_event_attribute_group, + .read_event_value = &mma8452_read_thresh, + .write_event_value = &mma8452_write_thresh, + .read_event_config = &mma8452_read_event_config, + .write_event_config = &mma8452_write_event_config, .debugfs_reg_access = &mma8452_reg_access_dbg, .driver_module = THIS_MODULE, }; @@ -425,6 +592,38 @@ static int mma8452_probe(struct i2c_client *client, if (ret < 0) return ret; + /* + * By default set transient threshold to max to avoid events if + * enabling without configuring threshold. + */ + ret = i2c_smbus_write_byte_data(client, MMA8452_TRANSIENT_THS, + MMA8452_TRANSIENT_THS_MASK); + if (ret < 0) + return ret; + + if (client->irq) { + /* + * Although we enable the transient interrupt source once and + * for all here the transient event detection itself is not + * enabled until userspace asks for it by + * mma8452_write_event_config() + */ + int supported_interrupts = MMA8452_INT_TRANS; + + /* Assume wired to INT1 pin */ + ret = i2c_smbus_write_byte_data(client, + MMA8452_CTRL_REG5, + supported_interrupts); + if (ret < 0) + return ret; + + ret = i2c_smbus_write_byte_data(client, + MMA8452_CTRL_REG4, + supported_interrupts); + if (ret < 0) + return ret; + } + data->ctrl_reg1 = MMA8452_CTRL_ACTIVE | (MMA8452_CTRL_DR_DEFAULT << MMA8452_CTRL_DR_SHIFT); ret = i2c_smbus_write_byte_data(client, MMA8452_CTRL_REG1, @@ -437,9 +636,20 @@ static int mma8452_probe(struct i2c_client *client, if (ret < 0) return ret; + if (client->irq) { + ret = devm_request_threaded_irq(&client->dev, + client->irq, + NULL, mma8452_interrupt, + IRQF_TRIGGER_LOW | IRQF_ONESHOT, + client->name, indio_dev); + if (ret) + goto buffer_cleanup; + } + ret = iio_device_register(indio_dev); if (ret < 0) goto buffer_cleanup; + return 0; buffer_cleanup: From 5dbbd19f11846574e9143ae96da8603017cf823b Mon Sep 17 00:00:00 2001 From: Martin Fuzzey Date: Mon, 1 Jun 2015 15:39:54 +0200 Subject: [PATCH 0795/1163] iio: mma8452: Add support for transient event debouncing Allow the debouce counter for transient events to be configured using the sysfs attribute events/in_accel_thresh_rising_period Signed-off-by: Martin Fuzzey Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma8452.c | 76 +++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 11 deletions(-) diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index f30eb9b7a99c..7429df3a191e 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -38,6 +38,7 @@ #define MMA8452_TRANSIENT_SRC_ZTRANSE BIT(5) #define MMA8452_TRANSIENT_THS 0x1f #define MMA8452_TRANSIENT_THS_MASK 0x7f +#define MMA8452_TRANSIENT_COUNT 0x20 #define MMA8452_OFF_X 0x2f #define MMA8452_OFF_Y 0x30 #define MMA8452_OFF_Z 0x31 @@ -124,6 +125,12 @@ static int mma8452_get_int_plus_micros_index(const int (*vals)[2], int n, return -EINVAL; } +static int mma8452_get_odr_index(struct mma8452_data *data) +{ + return (data->ctrl_reg1 & MMA8452_CTRL_DR_MASK) >> + MMA8452_CTRL_DR_SHIFT; +} + static const int mma8452_samp_freq[8][2] = { {800, 0}, {400, 0}, {200, 0}, {100, 0}, {50, 0}, {12, 500000}, {6, 250000}, {1, 560000} @@ -139,6 +146,18 @@ static const int mma8452_scales[3][2] = { {0, 9577}, {0, 19154}, {0, 38307} }; +/* Datasheet table 35 (step time vs sample frequency) */ +static const int mma8452_transient_time_step_us[8] = { + 1250, + 2500, + 5000, + 10000, + 20000, + 20000, + 20000, + 20000 +}; + static ssize_t mma8452_show_samp_freq_avail(struct device *dev, struct device_attribute *attr, char *buf) { @@ -198,8 +217,7 @@ static int mma8452_read_raw(struct iio_dev *indio_dev, *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; + i = mma8452_get_odr_index(data); *val = mma8452_samp_freq[i][0]; *val2 = mma8452_samp_freq[i][1]; return IIO_VAL_INT_PLUS_MICRO; @@ -297,15 +315,33 @@ static int mma8452_read_thresh(struct iio_dev *indio_dev, int *val, int *val2) { struct mma8452_data *data = iio_priv(indio_dev); - int ret; + int ret, us; - ret = i2c_smbus_read_byte_data(data->client, MMA8452_TRANSIENT_THS); - if (ret < 0) - return ret; + switch (info) { + case IIO_EV_INFO_VALUE: + ret = i2c_smbus_read_byte_data(data->client, + MMA8452_TRANSIENT_THS); + if (ret < 0) + return ret; - *val = ret & MMA8452_TRANSIENT_THS_MASK; + *val = ret & MMA8452_TRANSIENT_THS_MASK; + return IIO_VAL_INT; - return IIO_VAL_INT; + case IIO_EV_INFO_PERIOD: + ret = i2c_smbus_read_byte_data(data->client, + MMA8452_TRANSIENT_COUNT); + if (ret < 0) + return ret; + + us = ret * mma8452_transient_time_step_us[ + mma8452_get_odr_index(data)]; + *val = us / USEC_PER_SEC; + *val2 = us % USEC_PER_SEC; + return IIO_VAL_INT_PLUS_MICRO; + + default: + return -EINVAL; + } } static int mma8452_write_thresh(struct iio_dev *indio_dev, @@ -316,9 +352,26 @@ static int mma8452_write_thresh(struct iio_dev *indio_dev, int val, int val2) { struct mma8452_data *data = iio_priv(indio_dev); + int steps; - return mma8452_change_config(data, MMA8452_TRANSIENT_THS, - val & MMA8452_TRANSIENT_THS_MASK); + switch (info) { + case IIO_EV_INFO_VALUE: + return mma8452_change_config(data, MMA8452_TRANSIENT_THS, + val & MMA8452_TRANSIENT_THS_MASK); + + case IIO_EV_INFO_PERIOD: + steps = (val * USEC_PER_SEC + val2) / + mma8452_transient_time_step_us[ + mma8452_get_odr_index(data)]; + + if (steps > 0xff) + return -EINVAL; + + return mma8452_change_config(data, MMA8452_TRANSIENT_COUNT, + steps); + default: + return -EINVAL; + } } static int mma8452_read_event_config(struct iio_dev *indio_dev, @@ -456,7 +509,8 @@ static const struct iio_event_spec mma8452_transient_event[] = { .type = IIO_EV_TYPE_THRESH, .dir = IIO_EV_DIR_RISING, .mask_separate = BIT(IIO_EV_INFO_ENABLE), - .mask_shared_by_type = BIT(IIO_EV_INFO_VALUE) + .mask_shared_by_type = BIT(IIO_EV_INFO_VALUE) | + BIT(IIO_EV_INFO_PERIOD) }, }; From 1e79841a00e46506da887c718dd36a86b24b63e5 Mon Sep 17 00:00:00 2001 From: Martin Fuzzey Date: Mon, 1 Jun 2015 15:39:56 +0200 Subject: [PATCH 0796/1163] iio: mma8452: Add highpass filter configuration. Allow the cutoff frequency of the high pass filter to be configured. Signed-off-by: Martin Fuzzey Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma8452.c | 140 ++++++++++++++++++++++++++++++++++-- 1 file changed, 136 insertions(+), 4 deletions(-) diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index 7429df3a191e..51ae751e64a7 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -29,9 +29,12 @@ #define MMA8452_INT_SRC 0x0c #define MMA8452_WHO_AM_I 0x0d #define MMA8452_DATA_CFG 0x0e +#define MMA8452_HP_FILTER_CUTOFF 0x0f +#define MMA8452_HP_FILTER_CUTOFF_SEL_MASK (BIT(0) | BIT(1)) #define MMA8452_TRANSIENT_CFG 0x1d #define MMA8452_TRANSIENT_CFG_ELE BIT(4) #define MMA8452_TRANSIENT_CFG_CHAN(chan) BIT(chan + 1) +#define MMA8452_TRANSIENT_CFG_HPF_BYP BIT(0) #define MMA8452_TRANSIENT_SRC 0x1e #define MMA8452_TRANSIENT_SRC_XTRANSE BIT(1) #define MMA8452_TRANSIENT_SRC_YTRANSE BIT(3) @@ -61,6 +64,7 @@ #define MMA8452_DATA_CFG_FS_2G 0 #define MMA8452_DATA_CFG_FS_4G 1 #define MMA8452_DATA_CFG_FS_8G 2 +#define MMA8452_DATA_CFG_HPF_MASK BIT(4) #define MMA8452_INT_TRANS BIT(5) @@ -158,6 +162,18 @@ static const int mma8452_transient_time_step_us[8] = { 20000 }; +/* Datasheet table 18 (normal mode) */ +static const int mma8452_hp_filter_cutoff[8][4][2] = { + { {16, 0}, {8, 0}, {4, 0}, {2, 0} }, /* 800 Hz sample */ + { {16, 0}, {8, 0}, {4, 0}, {2, 0} }, /* 400 Hz sample */ + { {8, 0}, {4, 0}, {2, 0}, {1, 0} }, /* 200 Hz sample */ + { {4, 0}, {2, 0}, {1, 0}, {0, 500000} }, /* 100 Hz sample */ + { {2, 0}, {1, 0}, {0, 500000}, {0, 250000} }, /* 50 Hz sample */ + { {2, 0}, {1, 0}, {0, 500000}, {0, 250000} }, /* 12.5 Hz sample */ + { {2, 0}, {1, 0}, {0, 500000}, {0, 250000} }, /* 6.25 Hz sample */ + { {2, 0}, {1, 0}, {0, 500000}, {0, 250000} } /* 1.56 Hz sample */ +}; + static ssize_t mma8452_show_samp_freq_avail(struct device *dev, struct device_attribute *attr, char *buf) { @@ -172,9 +188,23 @@ static ssize_t mma8452_show_scale_avail(struct device *dev, ARRAY_SIZE(mma8452_scales)); } +static ssize_t mma8452_show_hp_cutoff_avail(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct mma8452_data *data = iio_priv(indio_dev); + int i = mma8452_get_odr_index(data); + + return mma8452_show_int_plus_micros(buf, mma8452_hp_filter_cutoff[i], + ARRAY_SIZE(mma8452_hp_filter_cutoff[0])); +} + 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 IIO_DEVICE_ATTR(in_accel_filter_high_pass_3db_frequency_available, + S_IRUGO, mma8452_show_hp_cutoff_avail, NULL, 0); static int mma8452_get_samp_freq_index(struct mma8452_data *data, int val, int val2) @@ -190,6 +220,31 @@ static int mma8452_get_scale_index(struct mma8452_data *data, ARRAY_SIZE(mma8452_scales), val, val2); } +static int mma8452_get_hp_filter_index(struct mma8452_data *data, + int val, int val2) +{ + int i = mma8452_get_odr_index(data); + + return mma8452_get_int_plus_micros_index(mma8452_hp_filter_cutoff[i], + ARRAY_SIZE(mma8452_scales[0]), val, val2); +} + +static int mma8452_read_hp_filter(struct mma8452_data *data, int *hz, int *uHz) +{ + int i, ret; + + ret = i2c_smbus_read_byte_data(data->client, MMA8452_HP_FILTER_CUTOFF); + if (ret < 0) + return ret; + + i = mma8452_get_odr_index(data); + ret &= MMA8452_HP_FILTER_CUTOFF_SEL_MASK; + *hz = mma8452_hp_filter_cutoff[i][ret][0]; + *uHz = mma8452_hp_filter_cutoff[i][ret][1]; + + return 0; +} + static int mma8452_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) @@ -228,6 +283,16 @@ static int mma8452_read_raw(struct iio_dev *indio_dev, return ret; *val = sign_extend32(ret, 7); return IIO_VAL_INT; + case IIO_CHAN_INFO_HIGH_PASS_FILTER_3DB_FREQUENCY: + if (data->data_cfg & MMA8452_DATA_CFG_HPF_MASK) { + ret = mma8452_read_hp_filter(data, val, val2); + if (ret < 0) + return ret; + } else { + *val = 0; + *val2 = 0; + } + return IIO_VAL_INT_PLUS_MICRO; } return -EINVAL; } @@ -269,12 +334,31 @@ fail: return ret; } +static int mma8452_set_hp_filter_frequency(struct mma8452_data *data, + int val, int val2) +{ + int i, reg; + + i = mma8452_get_hp_filter_index(data, val, val2); + if (i < 0) + return -EINVAL; + + reg = i2c_smbus_read_byte_data(data->client, + MMA8452_HP_FILTER_CUTOFF); + if (reg < 0) + return reg; + reg &= ~MMA8452_HP_FILTER_CUTOFF_SEL_MASK; + reg |= i; + + return mma8452_change_config(data, MMA8452_HP_FILTER_CUTOFF, reg); +} + 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; + int i, ret; if (iio_buffer_enabled(indio_dev)) return -EBUSY; @@ -302,6 +386,19 @@ static int mma8452_write_raw(struct iio_dev *indio_dev, return -EINVAL; return mma8452_change_config(data, MMA8452_OFF_X + chan->scan_index, val); + + case IIO_CHAN_INFO_HIGH_PASS_FILTER_3DB_FREQUENCY: + if (val == 0 && val2 == 0) { + data->data_cfg &= ~MMA8452_DATA_CFG_HPF_MASK; + } else { + data->data_cfg |= MMA8452_DATA_CFG_HPF_MASK; + ret = mma8452_set_hp_filter_frequency(data, val, val2); + if (ret < 0) + return ret; + } + return mma8452_change_config(data, MMA8452_DATA_CFG, + data->data_cfg); + default: return -EINVAL; } @@ -339,6 +436,22 @@ static int mma8452_read_thresh(struct iio_dev *indio_dev, *val2 = us % USEC_PER_SEC; return IIO_VAL_INT_PLUS_MICRO; + case IIO_EV_INFO_HIGH_PASS_FILTER_3DB: + ret = i2c_smbus_read_byte_data(data->client, + MMA8452_TRANSIENT_CFG); + if (ret < 0) + return ret; + + if (ret & MMA8452_TRANSIENT_CFG_HPF_BYP) { + *val = 0; + *val2 = 0; + } else { + ret = mma8452_read_hp_filter(data, val, val2); + if (ret < 0) + return ret; + } + return IIO_VAL_INT_PLUS_MICRO; + default: return -EINVAL; } @@ -352,7 +465,7 @@ static int mma8452_write_thresh(struct iio_dev *indio_dev, int val, int val2) { struct mma8452_data *data = iio_priv(indio_dev); - int steps; + int ret, reg, steps; switch (info) { case IIO_EV_INFO_VALUE: @@ -369,6 +482,22 @@ static int mma8452_write_thresh(struct iio_dev *indio_dev, return mma8452_change_config(data, MMA8452_TRANSIENT_COUNT, steps); + case IIO_EV_INFO_HIGH_PASS_FILTER_3DB: + reg = i2c_smbus_read_byte_data(data->client, + MMA8452_TRANSIENT_CFG); + if (reg < 0) + return reg; + + if (val == 0 && val2 == 0) { + reg |= MMA8452_TRANSIENT_CFG_HPF_BYP; + } else { + reg &= ~MMA8452_TRANSIENT_CFG_HPF_BYP; + ret = mma8452_set_hp_filter_frequency(data, val, val2); + if (ret < 0) + return ret; + } + return mma8452_change_config(data, MMA8452_TRANSIENT_CFG, reg); + default: return -EINVAL; } @@ -510,7 +639,8 @@ static const struct iio_event_spec mma8452_transient_event[] = { .dir = IIO_EV_DIR_RISING, .mask_separate = BIT(IIO_EV_INFO_ENABLE), .mask_shared_by_type = BIT(IIO_EV_INFO_VALUE) | - BIT(IIO_EV_INFO_PERIOD) + BIT(IIO_EV_INFO_PERIOD) | + BIT(IIO_EV_INFO_HIGH_PASS_FILTER_3DB) }, }; @@ -537,7 +667,8 @@ static struct attribute_group mma8452_event_attribute_group = { .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), \ + BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_HIGH_PASS_FILTER_3DB_FREQUENCY), \ .scan_index = idx, \ .scan_type = { \ .sign = 's', \ @@ -560,6 +691,7 @@ static const struct iio_chan_spec mma8452_channels[] = { static struct attribute *mma8452_attributes[] = { &iio_dev_attr_sampling_frequency_available.dev_attr.attr, &iio_dev_attr_in_accel_scale_available.dev_attr.attr, + &iio_dev_attr_in_accel_filter_high_pass_3db_frequency_available.dev_attr.attr, NULL }; From ae6d9ce05691bf79694074db7c7da980080548af Mon Sep 17 00:00:00 2001 From: Martin Fuzzey Date: Mon, 1 Jun 2015 15:39:58 +0200 Subject: [PATCH 0797/1163] iio: mma8452: Add support for interrupt driven triggers. Implement interrupt driven trigger for data ready. This allows more efficient access to the sample data. Signed-off-by: Martin Fuzzey Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma8452.c | 101 +++++++++++++++++++++++++++++++++--- 1 file changed, 93 insertions(+), 8 deletions(-) diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index 51ae751e64a7..e8e2077c7244 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include #include #include @@ -66,6 +68,7 @@ #define MMA8452_DATA_CFG_FS_8G 2 #define MMA8452_DATA_CFG_HPF_MASK BIT(4) +#define MMA8452_INT_DRDY BIT(0) #define MMA8452_INT_TRANS BIT(5) #define MMA8452_DEVICE_ID 0x2a @@ -577,18 +580,24 @@ static irqreturn_t mma8452_interrupt(int irq, void *p) { struct iio_dev *indio_dev = p; struct mma8452_data *data = iio_priv(indio_dev); + int ret = IRQ_NONE; int src; src = i2c_smbus_read_byte_data(data->client, MMA8452_INT_SRC); if (src < 0) return IRQ_NONE; - if (src & MMA8452_INT_TRANS) { - mma8452_transient_interrupt(indio_dev); - return IRQ_HANDLED; + if (src & MMA8452_INT_DRDY) { + iio_trigger_poll_chained(indio_dev->trig); + ret = IRQ_HANDLED; } - return IRQ_NONE; + if (src & MMA8452_INT_TRANS) { + mma8452_transient_interrupt(indio_dev); + ret = IRQ_HANDLED; + } + + return ret; } static irqreturn_t mma8452_trigger_handler(int irq, void *p) @@ -714,6 +723,72 @@ static const struct iio_info mma8452_info = { static const unsigned long mma8452_scan_masks[] = {0x7, 0}; +static int mma8452_data_rdy_trigger_set_state(struct iio_trigger *trig, + bool state) +{ + struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); + struct mma8452_data *data = iio_priv(indio_dev); + int reg; + + reg = i2c_smbus_read_byte_data(data->client, MMA8452_CTRL_REG4); + if (reg < 0) + return reg; + + if (state) + reg |= MMA8452_INT_DRDY; + else + reg &= ~MMA8452_INT_DRDY; + + return mma8452_change_config(data, MMA8452_CTRL_REG4, reg); +} + +static int mma8452_validate_device(struct iio_trigger *trig, + struct iio_dev *indio_dev) +{ + struct iio_dev *indio = iio_trigger_get_drvdata(trig); + + if (indio != indio_dev) + return -EINVAL; + + return 0; +} + +static const struct iio_trigger_ops mma8452_trigger_ops = { + .set_trigger_state = mma8452_data_rdy_trigger_set_state, + .validate_device = mma8452_validate_device, + .owner = THIS_MODULE, +}; + +static int mma8452_trigger_setup(struct iio_dev *indio_dev) +{ + struct mma8452_data *data = iio_priv(indio_dev); + struct iio_trigger *trig; + int ret; + + trig = devm_iio_trigger_alloc(&data->client->dev, "%s-dev%d", + indio_dev->name, + indio_dev->id); + if (!trig) + return -ENOMEM; + + trig->dev.parent = &data->client->dev; + trig->ops = &mma8452_trigger_ops; + iio_trigger_set_drvdata(trig, indio_dev); + + ret = iio_trigger_register(trig); + if (ret) + return ret; + + indio_dev->trig = trig; + return 0; +} + +static void mma8452_trigger_cleanup(struct iio_dev *indio_dev) +{ + if (indio_dev->trig) + iio_trigger_unregister(indio_dev->trig); +} + static int mma8452_reset(struct i2c_client *client) { int i; @@ -794,7 +869,8 @@ static int mma8452_probe(struct i2c_client *client, * enabled until userspace asks for it by * mma8452_write_event_config() */ - int supported_interrupts = MMA8452_INT_TRANS; + int supported_interrupts = MMA8452_INT_DRDY | MMA8452_INT_TRANS; + int enabled_interrupts = MMA8452_INT_TRANS; /* Assume wired to INT1 pin */ ret = i2c_smbus_write_byte_data(client, @@ -805,7 +881,11 @@ static int mma8452_probe(struct i2c_client *client, ret = i2c_smbus_write_byte_data(client, MMA8452_CTRL_REG4, - supported_interrupts); + enabled_interrupts); + if (ret < 0) + return ret; + + ret = mma8452_trigger_setup(indio_dev); if (ret < 0) return ret; } @@ -815,12 +895,12 @@ static int mma8452_probe(struct i2c_client *client, ret = i2c_smbus_write_byte_data(client, MMA8452_CTRL_REG1, data->ctrl_reg1); if (ret < 0) - return ret; + goto trigger_cleanup; ret = iio_triggered_buffer_setup(indio_dev, NULL, mma8452_trigger_handler, NULL); if (ret < 0) - return ret; + goto trigger_cleanup; if (client->irq) { ret = devm_request_threaded_irq(&client->dev, @@ -840,6 +920,10 @@ static int mma8452_probe(struct i2c_client *client, buffer_cleanup: iio_triggered_buffer_cleanup(indio_dev); + +trigger_cleanup: + mma8452_trigger_cleanup(indio_dev); + return ret; } @@ -849,6 +933,7 @@ static int mma8452_remove(struct i2c_client *client) iio_device_unregister(indio_dev); iio_triggered_buffer_cleanup(indio_dev); + mma8452_trigger_cleanup(indio_dev); mma8452_standby(iio_priv(indio_dev)); return 0; From 0cbb39f1432096cf00eca21f2d10f6d2057c26ba Mon Sep 17 00:00:00 2001 From: "H. Nikolaus Schaller" Date: Thu, 28 May 2015 21:50:18 +0200 Subject: [PATCH 0798/1163] iio: adc: twl4030_madc: Fix calculation of the temperature sense current The bit mask to read the setting of the constant current source for measuring the NTC voltage was the wrong one. Since default value is initialized to the lowest level (000 = 10uA) the difference was probably never noticed in practice. Signed-off-by: H. Nikolaus Schaller Signed-off-by: Marek Belisko Signed-off-by: Jonathan Cameron --- drivers/iio/adc/twl4030-madc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/twl4030-madc.c b/drivers/iio/adc/twl4030-madc.c index 94c5f05b4bc1..6d2d429a48e0 100644 --- a/drivers/iio/adc/twl4030-madc.c +++ b/drivers/iio/adc/twl4030-madc.c @@ -235,7 +235,7 @@ static int twl4030battery_temperature(int raw_volt) if (ret < 0) return ret; - curr = ((val & TWL4030_BCI_ITHEN) + 1) * 10; + curr = ((val & TWL4030_BCI_ITHSENS) + 1) * 10; /* Getting and calculating the thermistor resistance in ohms */ res = volt * 1000 / curr; /* calculating temperature */ From 994bda83dc6facc3fdd2130b0162b2abf09b2100 Mon Sep 17 00:00:00 2001 From: "H. Nikolaus Schaller" Date: Thu, 28 May 2015 21:50:19 +0200 Subject: [PATCH 0799/1163] iio: adc: twl4030_madc: Fix description of twl4030_madc_set_current_generator() The @chan parameter can be 0 or 1 and not a bit mask. Fix wrong description. Signed-off-by: H. Nikolaus Schaller Signed-off-by: Marek Belisko Signed-off-by: Jonathan Cameron --- drivers/iio/adc/twl4030-madc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/twl4030-madc.c b/drivers/iio/adc/twl4030-madc.c index 6d2d429a48e0..06f4792240f0 100644 --- a/drivers/iio/adc/twl4030-madc.c +++ b/drivers/iio/adc/twl4030-madc.c @@ -662,10 +662,8 @@ EXPORT_SYMBOL_GPL(twl4030_get_madc_conversion); * * @madc: pointer to twl4030_madc_data struct * @chan: can be one of the two values: - * TWL4030_BCI_ITHEN - * Enables bias current for main battery type reading - * TWL4030_BCI_TYPEN - * Enables bias current for main battery temperature sensing + * 0 - Enables bias current for main battery type reading + * 1 - Enables bias current for main battery temperature sensing * @on: enable or disable chan. * * Function to enable or disable bias current for From bf04c1a367e3d52b2e071cc7c7047c27dc1c3c5f Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Wed, 27 May 2015 14:47:51 +0200 Subject: [PATCH 0800/1163] iio: adc: vf610: implement configurable conversion modes Support configurable conversion mode through sysfs. So far, the mode used was low-power, which is enabled by default now. Beside that, the modes normal and high-speed are selectable as well. Use the new device tree property which specifies the maximum ADC conversion clock frequencies. Depending on the mode used, the available resulting conversion frequency are calculated dynamically. Acked-by: Fugang Duan Signed-off-by: Stefan Agner Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio-vf610 | 7 + .../devicetree/bindings/iio/adc/vf610-adc.txt | 9 ++ drivers/iio/adc/vf610_adc.c | 146 +++++++++++++----- 3 files changed, 120 insertions(+), 42 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-vf610 diff --git a/Documentation/ABI/testing/sysfs-bus-iio-vf610 b/Documentation/ABI/testing/sysfs-bus-iio-vf610 new file mode 100644 index 000000000000..ecbc1f4af921 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-iio-vf610 @@ -0,0 +1,7 @@ +What: /sys/bus/iio/devices/iio:deviceX/conversion_mode +KernelVersion: 4.2 +Contact: linux-iio@vger.kernel.org +Description: + Specifies the hardware conversion mode used. The three + available modes are "normal", "high-speed" and "low-power", + where the last is the default mode. diff --git a/Documentation/devicetree/bindings/iio/adc/vf610-adc.txt b/Documentation/devicetree/bindings/iio/adc/vf610-adc.txt index 1a4a43d5c9ea..3eb40e20c143 100644 --- a/Documentation/devicetree/bindings/iio/adc/vf610-adc.txt +++ b/Documentation/devicetree/bindings/iio/adc/vf610-adc.txt @@ -11,6 +11,13 @@ Required properties: - clock-names: Must contain "adc", matching entry in the clocks property. - vref-supply: The regulator supply ADC reference voltage. +Recommended properties: +- fsl,adck-max-frequency: Maximum frequencies according to datasheets operating + requirements. Three values are required, depending on conversion mode: + - Frequency in normal mode (ADLPC=0, ADHSC=0) + - Frequency in high-speed mode (ADLPC=0, ADHSC=1) + - Frequency in low-power mode (ADLPC=1, ADHSC=0) + Example: adc0: adc@4003b000 { compatible = "fsl,vf610-adc"; @@ -18,5 +25,7 @@ adc0: adc@4003b000 { interrupts = <0 53 0x04>; clocks = <&clks VF610_CLK_ADC0>; clock-names = "adc"; + fsl,adck-max-frequency = <30000000>, <40000000>, + <20000000>; vref-supply = <®_vcc_3v3_mcu>; }; diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c index 56292ae4538d..480f335a0f9f 100644 --- a/drivers/iio/adc/vf610_adc.c +++ b/drivers/iio/adc/vf610_adc.c @@ -118,15 +118,21 @@ enum average_sel { VF610_ADC_SAMPLE_32, }; +enum conversion_mode_sel { + VF610_ADC_CONV_NORMAL, + VF610_ADC_CONV_HIGH_SPEED, + VF610_ADC_CONV_LOW_POWER, +}; + struct vf610_adc_feature { enum clk_sel clk_sel; enum vol_ref vol_ref; + enum conversion_mode_sel conv_mode; int clk_div; int sample_rate; int res_mode; - bool lpm; bool calibration; bool ovwren; }; @@ -139,6 +145,8 @@ struct vf610_adc { u32 vref_uv; u32 value; struct regulator *vref; + + u32 max_adck_rate[3]; struct vf610_adc_feature adc_feature; u32 sample_freq_avail[5]; @@ -148,46 +156,22 @@ struct vf610_adc { static const u32 vf610_hw_avgs[] = { 1, 4, 8, 16, 32 }; -#define VF610_ADC_CHAN(_idx, _chan_type) { \ - .type = (_chan_type), \ - .indexed = 1, \ - .channel = (_idx), \ - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ - BIT(IIO_CHAN_INFO_SAMP_FREQ), \ -} - -#define VF610_ADC_TEMPERATURE_CHAN(_idx, _chan_type) { \ - .type = (_chan_type), \ - .channel = (_idx), \ - .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), \ -} - -static const struct iio_chan_spec vf610_adc_iio_channels[] = { - VF610_ADC_CHAN(0, IIO_VOLTAGE), - VF610_ADC_CHAN(1, IIO_VOLTAGE), - VF610_ADC_CHAN(2, IIO_VOLTAGE), - VF610_ADC_CHAN(3, IIO_VOLTAGE), - VF610_ADC_CHAN(4, IIO_VOLTAGE), - VF610_ADC_CHAN(5, IIO_VOLTAGE), - VF610_ADC_CHAN(6, IIO_VOLTAGE), - VF610_ADC_CHAN(7, IIO_VOLTAGE), - VF610_ADC_CHAN(8, IIO_VOLTAGE), - VF610_ADC_CHAN(9, IIO_VOLTAGE), - VF610_ADC_CHAN(10, IIO_VOLTAGE), - VF610_ADC_CHAN(11, IIO_VOLTAGE), - VF610_ADC_CHAN(12, IIO_VOLTAGE), - VF610_ADC_CHAN(13, IIO_VOLTAGE), - VF610_ADC_CHAN(14, IIO_VOLTAGE), - VF610_ADC_CHAN(15, IIO_VOLTAGE), - VF610_ADC_TEMPERATURE_CHAN(26, IIO_TEMP), - /* sentinel */ -}; - static inline void vf610_adc_calculate_rates(struct vf610_adc *info) { + struct vf610_adc_feature *adc_feature = &info->adc_feature; unsigned long adck_rate, ipg_rate = clk_get_rate(info->clk); - int i; + int divisor, i; + + adck_rate = info->max_adck_rate[adc_feature->conv_mode]; + + if (adck_rate) { + /* calculate clk divider which is within specification */ + divisor = ipg_rate / adck_rate; + adc_feature->clk_div = 1 << fls(divisor + 1); + } else { + /* fall-back value using a safe divisor */ + adc_feature->clk_div = 8; + } /* * Calculate ADC sample frequencies @@ -219,10 +203,8 @@ static inline void vf610_adc_cfg_init(struct vf610_adc *info) adc_feature->res_mode = 12; adc_feature->sample_rate = 1; - adc_feature->lpm = true; - /* Use a save ADCK which is below 20MHz on all devices */ - adc_feature->clk_div = 8; + adc_feature->conv_mode = VF610_ADC_CONV_LOW_POWER; vf610_adc_calculate_rates(info); } @@ -304,10 +286,12 @@ static void vf610_adc_cfg_set(struct vf610_adc *info) cfg_data = readl(info->regs + VF610_REG_ADC_CFG); cfg_data &= ~VF610_ADC_ADLPC_EN; - if (adc_feature->lpm) + if (adc_feature->conv_mode == VF610_ADC_CONV_LOW_POWER) cfg_data |= VF610_ADC_ADLPC_EN; cfg_data &= ~VF610_ADC_ADHSC_EN; + if (adc_feature->conv_mode == VF610_ADC_CONV_HIGH_SPEED) + cfg_data |= VF610_ADC_ADHSC_EN; writel(cfg_data, info->regs + VF610_REG_ADC_CFG); } @@ -409,6 +393,81 @@ static void vf610_adc_hw_init(struct vf610_adc *info) vf610_adc_cfg_set(info); } +static int vf610_set_conversion_mode(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + unsigned int mode) +{ + struct vf610_adc *info = iio_priv(indio_dev); + + mutex_lock(&indio_dev->mlock); + info->adc_feature.conv_mode = mode; + vf610_adc_calculate_rates(info); + vf610_adc_hw_init(info); + mutex_unlock(&indio_dev->mlock); + + return 0; +} + +static int vf610_get_conversion_mode(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + struct vf610_adc *info = iio_priv(indio_dev); + + return info->adc_feature.conv_mode; +} + +static const char * const vf610_conv_modes[] = { "normal", "high-speed", + "low-power" }; + +static const struct iio_enum vf610_conversion_mode = { + .items = vf610_conv_modes, + .num_items = ARRAY_SIZE(vf610_conv_modes), + .get = vf610_get_conversion_mode, + .set = vf610_set_conversion_mode, +}; + +static const struct iio_chan_spec_ext_info vf610_ext_info[] = { + IIO_ENUM("conversion_mode", IIO_SHARED_BY_DIR, &vf610_conversion_mode), + {}, +}; + +#define VF610_ADC_CHAN(_idx, _chan_type) { \ + .type = (_chan_type), \ + .indexed = 1, \ + .channel = (_idx), \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_SAMP_FREQ), \ + .ext_info = vf610_ext_info, \ +} + +#define VF610_ADC_TEMPERATURE_CHAN(_idx, _chan_type) { \ + .type = (_chan_type), \ + .channel = (_idx), \ + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), \ +} + +static const struct iio_chan_spec vf610_adc_iio_channels[] = { + VF610_ADC_CHAN(0, IIO_VOLTAGE), + VF610_ADC_CHAN(1, IIO_VOLTAGE), + VF610_ADC_CHAN(2, IIO_VOLTAGE), + VF610_ADC_CHAN(3, IIO_VOLTAGE), + VF610_ADC_CHAN(4, IIO_VOLTAGE), + VF610_ADC_CHAN(5, IIO_VOLTAGE), + VF610_ADC_CHAN(6, IIO_VOLTAGE), + VF610_ADC_CHAN(7, IIO_VOLTAGE), + VF610_ADC_CHAN(8, IIO_VOLTAGE), + VF610_ADC_CHAN(9, IIO_VOLTAGE), + VF610_ADC_CHAN(10, IIO_VOLTAGE), + VF610_ADC_CHAN(11, IIO_VOLTAGE), + VF610_ADC_CHAN(12, IIO_VOLTAGE), + VF610_ADC_CHAN(13, IIO_VOLTAGE), + VF610_ADC_CHAN(14, IIO_VOLTAGE), + VF610_ADC_CHAN(15, IIO_VOLTAGE), + VF610_ADC_TEMPERATURE_CHAN(26, IIO_TEMP), + /* sentinel */ +}; + static int vf610_adc_read_data(struct vf610_adc *info) { int result; @@ -651,6 +710,9 @@ static int vf610_adc_probe(struct platform_device *pdev) info->vref_uv = regulator_get_voltage(info->vref); + of_property_read_u32_array(pdev->dev.of_node, "fsl,adck-max-frequency", + info->max_adck_rate, 3); + platform_set_drvdata(pdev, indio_dev); init_completion(&info->completion); From 4861a007bfd71a9fc0a83cc7fad41dda9bf8b5b7 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 19 May 2015 15:37:02 +0200 Subject: [PATCH 0801/1163] iio: st_accel: support 8bit channel data Some sensors like the LIS331DL only support 8bit data by a single register per axis. These utilize the MSB byte. Make it possible to register these apropriately. A oneliner change is needed in the ST sensors core to handle 8bit reads as this is the first supported 8bit sensor. Signed-off-by: Linus Walleij Acked-by: Denis Ciocca Signed-off-by: Jonathan Cameron --- drivers/iio/accel/st_accel_core.c | 16 ++++++++++++++++ drivers/iio/common/st_sensors/st_sensors_core.c | 4 +++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index 58d1d13d552a..ad19fb4304df 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c @@ -153,6 +153,22 @@ #define ST_ACCEL_4_IG1_EN_MASK 0x08 #define ST_ACCEL_4_MULTIREAD_BIT true +static const struct iio_chan_spec st_accel_8bit_channels[] = { + ST_SENSORS_LSM_CHANNELS(IIO_ACCEL, + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), + ST_SENSORS_SCAN_X, 1, IIO_MOD_X, 's', IIO_LE, 8, 8, + ST_ACCEL_DEFAULT_OUT_X_L_ADDR+1), + ST_SENSORS_LSM_CHANNELS(IIO_ACCEL, + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), + ST_SENSORS_SCAN_Y, 1, IIO_MOD_Y, 's', IIO_LE, 8, 8, + ST_ACCEL_DEFAULT_OUT_Y_L_ADDR+1), + ST_SENSORS_LSM_CHANNELS(IIO_ACCEL, + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), + ST_SENSORS_SCAN_Z, 1, IIO_MOD_Z, 's', IIO_LE, 8, 8, + ST_ACCEL_DEFAULT_OUT_Z_L_ADDR+1), + IIO_CHAN_SOFT_TIMESTAMP(3) +}; + static const struct iio_chan_spec st_accel_12bit_channels[] = { ST_SENSORS_LSM_CHANNELS(IIO_ACCEL, BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index 1255b157c71c..bf4b13f9defc 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -433,7 +433,9 @@ static int st_sensors_read_axis_data(struct iio_dev *indio_dev, if (err < 0) goto st_sensors_free_memory; - if (byte_for_channel == 2) + if (byte_for_channel == 1) + *data = (s8)*outdata; + else if (byte_for_channel == 2) *data = (s16)get_unaligned_le16(outdata); else if (byte_for_channel == 3) *data = (s32)st_sensors_get_unaligned_le24(outdata); From 23191c97c0f3a07eb45c6c9ecda4fced8fbb0719 Mon Sep 17 00:00:00 2001 From: Antonio Murdaca Date: Mon, 1 Jun 2015 23:14:14 +0200 Subject: [PATCH 0802/1163] staging: lustre: lov: remove unnecessary parentheses fix checkpatch.pl warning about unnecessary parentheses Signed-off-by: Antonio Murdaca Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lov/lov_obd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index b5dc9e138d30..ca1caaea2701 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -1400,7 +1400,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, __u32 flags; memcpy(&index, data->ioc_inlbuf2, sizeof(__u32)); - if ((index >= count)) + if (index >= count) return -ENODEV; if (!lov->lov_tgts[index]) From f559cfe37bc7036ba62215d4d2851e9fc56bd936 Mon Sep 17 00:00:00 2001 From: Prasanna Karthik Date: Tue, 2 Jun 2015 10:38:29 +0000 Subject: [PATCH 0803/1163] Staging: lustre: Clean up Coding style Fix Preferred use of '*' is adjacent to the data name or function name Signed-off-by: Prasanna Karthik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 1f9a5f7841ae..ce4a71f7171a 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -147,7 +147,7 @@ int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd, char *s1, char *s2, char *s3, char *s4) { struct lustre_cfg_bufs bufs; - struct lustre_cfg * lcfg = NULL; + struct lustre_cfg *lcfg = NULL; int rc; CDEBUG(D_TRACE, "lcfg %s %#x %s %s %s %s\n", cfgname, From 06d0c4989fa40012957c6d96ed0a05684c3b7c61 Mon Sep 17 00:00:00 2001 From: Aparna Karuthodi Date: Wed, 3 Jun 2015 15:03:57 +0530 Subject: [PATCH 0804/1163] staging: lustre: llite: Fix No space after the declaration Added a new line Signed-off-by: Aparna Karuthodi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_capa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/lustre/lustre/llite/llite_capa.c b/drivers/staging/lustre/lustre/llite/llite_capa.c index aec9a44120c0..a6268718b76e 100644 --- a/drivers/staging/lustre/lustre/llite/llite_capa.c +++ b/drivers/staging/lustre/lustre/llite/llite_capa.c @@ -140,6 +140,7 @@ static void sort_add_capa(struct obd_capa *ocapa, struct list_head *head) static inline int obd_capa_open_count(struct obd_capa *oc) { struct ll_inode_info *lli = ll_i2info(oc->u.cli.inode); + return atomic_read(&lli->lli_open_count); } From 29ac6840d7c8b4ce60c9dcd0a55fce6a84d3bae0 Mon Sep 17 00:00:00 2001 From: Chris Hanna Date: Wed, 3 Jun 2015 10:23:42 -0400 Subject: [PATCH 0805/1163] staging: lustre: osc: clean up whitespace and align function parameters Minor changes to remove excessive whitespace and improve readability of osc functions. Signed-off-by: Chris Hanna Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/osc/lproc_osc.c | 18 +- drivers/staging/lustre/lustre/osc/osc_cache.c | 196 +++++++++--------- drivers/staging/lustre/lustre/osc/osc_dev.c | 12 +- drivers/staging/lustre/lustre/osc/osc_io.c | 122 +++++------ drivers/staging/lustre/lustre/osc/osc_lock.c | 148 ++++++------- .../staging/lustre/lustre/osc/osc_object.c | 18 +- drivers/staging/lustre/lustre/osc/osc_page.c | 38 ++-- drivers/staging/lustre/lustre/osc/osc_quota.c | 14 +- .../staging/lustre/lustre/osc/osc_request.c | 169 ++++++++------- 9 files changed, 367 insertions(+), 368 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 9dc84ba7aa55..ff6d2e2ffdab 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -417,8 +417,8 @@ static ssize_t osc_checksum_type_seq_write(struct file *file, LPROC_SEQ_FOPS(osc_checksum_type); static ssize_t resend_count_show(struct kobject *kobj, - struct attribute *attr, - char *buf) + struct attribute *attr, + char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, obd_kobj); @@ -427,9 +427,9 @@ static ssize_t resend_count_show(struct kobject *kobj, } static ssize_t resend_count_store(struct kobject *kobj, - struct attribute *attr, - const char *buffer, - size_t count) + struct attribute *attr, + const char *buffer, + size_t count) { struct obd_device *obd = container_of(kobj, struct obd_device, obd_kobj); @@ -682,8 +682,8 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v) #undef pct static ssize_t osc_rpc_stats_seq_write(struct file *file, - const char __user *buf, - size_t len, loff_t *off) + const char __user *buf, + size_t len, loff_t *off) { struct seq_file *seq = file->private_data; struct obd_device *dev = seq->private; @@ -721,8 +721,8 @@ static int osc_stats_seq_show(struct seq_file *seq, void *v) } static ssize_t osc_stats_seq_write(struct file *file, - const char __user *buf, - size_t len, loff_t *off) + const char __user *buf, + size_t len, loff_t *off) { struct seq_file *seq = file->private_data; struct obd_device *dev = seq->private; diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index d44b3d4ffe4d..5592d32a1a95 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -112,8 +112,8 @@ static const char *oes_strings[] = { /* ----- extent part 0 ----- */ \ __ext, EXTPARA(__ext), \ /* ----- part 1 ----- */ \ - atomic_read(&__ext->oe_refc), \ - atomic_read(&__ext->oe_users), \ + atomic_read(&__ext->oe_refc), \ + atomic_read(&__ext->oe_users), \ list_empty_marker(&__ext->oe_link), \ oes_strings[__ext->oe_state], ext_flags(__ext, __buf), \ __ext->oe_obj, \ @@ -297,12 +297,12 @@ out: #define sanity_check_nolock(ext) \ osc_extent_sanity_check0(ext, __func__, __LINE__) -#define sanity_check(ext) ({ \ - int __res; \ +#define sanity_check(ext) ({ \ + int __res; \ osc_object_lock((ext)->oe_obj); \ - __res = sanity_check_nolock(ext); \ - osc_object_unlock((ext)->oe_obj); \ - __res; \ + __res = sanity_check_nolock(ext); \ + osc_object_unlock((ext)->oe_obj); \ + __res; \ }) @@ -411,7 +411,7 @@ static void osc_extent_put_trust(struct osc_extent *ext) static struct osc_extent *osc_extent_search(struct osc_object *obj, pgoff_t index) { - struct rb_node *n = obj->oo_root.rb_node; + struct rb_node *n = obj->oo_root.rb_node; struct osc_extent *tmp, *p = NULL; LASSERT(osc_object_is_locked(obj)); @@ -447,8 +447,8 @@ static struct osc_extent *osc_extent_lookup(struct osc_object *obj, /* caller must have held object lock. */ static void osc_extent_insert(struct osc_object *obj, struct osc_extent *ext) { - struct rb_node **n = &obj->oo_root.rb_node; - struct rb_node *parent = NULL; + struct rb_node **n = &obj->oo_root.rb_node; + struct rb_node *parent = NULL; struct osc_extent *tmp; LASSERT(ext->oe_intree == 0); @@ -544,19 +544,19 @@ static int osc_extent_merge(const struct lu_env *env, struct osc_extent *cur, LASSERT(cur->oe_osclock == victim->oe_osclock); ppc_bits = osc_cli(obj)->cl_chunkbits - PAGE_CACHE_SHIFT; chunk_start = cur->oe_start >> ppc_bits; - chunk_end = cur->oe_end >> ppc_bits; - if (chunk_start != (victim->oe_end >> ppc_bits) + 1 && + chunk_end = cur->oe_end >> ppc_bits; + if (chunk_start != (victim->oe_end >> ppc_bits) + 1 && chunk_end + 1 != victim->oe_start >> ppc_bits) return -ERANGE; OSC_EXTENT_DUMP(D_CACHE, victim, "will be merged by %p.\n", cur); - cur->oe_start = min(cur->oe_start, victim->oe_start); - cur->oe_end = max(cur->oe_end, victim->oe_end); - cur->oe_grants += victim->oe_grants; + cur->oe_start = min(cur->oe_start, victim->oe_start); + cur->oe_end = max(cur->oe_end, victim->oe_end); + cur->oe_grants += victim->oe_grants; cur->oe_nr_pages += victim->oe_nr_pages; /* only the following bits are needed to merge */ - cur->oe_urgent |= victim->oe_urgent; + cur->oe_urgent |= victim->oe_urgent; cur->oe_memalloc |= victim->oe_memalloc; list_splice_init(&victim->oe_pages, &cur->oe_pages); list_del_init(&victim->oe_link); @@ -624,18 +624,18 @@ struct osc_extent *osc_extent_find(const struct lu_env *env, { struct client_obd *cli = osc_cli(obj); - struct cl_lock *lock; + struct cl_lock *lock; struct osc_extent *cur; struct osc_extent *ext; struct osc_extent *conflict = NULL; struct osc_extent *found = NULL; - pgoff_t chunk; - pgoff_t max_end; - int max_pages; /* max_pages_per_rpc */ - int chunksize; - int ppc_bits; /* pages per chunk bits */ - int chunk_mask; - int rc; + pgoff_t chunk; + pgoff_t max_end; + int max_pages; /* max_pages_per_rpc */ + int chunksize; + int ppc_bits; /* pages per chunk bits */ + int chunk_mask; + int rc; cur = osc_extent_alloc(obj); if (cur == NULL) @@ -646,10 +646,10 @@ struct osc_extent *osc_extent_find(const struct lu_env *env, LASSERT(lock->cll_descr.cld_mode >= CLM_WRITE); LASSERT(cli->cl_chunkbits >= PAGE_CACHE_SHIFT); - ppc_bits = cli->cl_chunkbits - PAGE_CACHE_SHIFT; + ppc_bits = cli->cl_chunkbits - PAGE_CACHE_SHIFT; chunk_mask = ~((1 << ppc_bits) - 1); - chunksize = 1 << cli->cl_chunkbits; - chunk = index >> ppc_bits; + chunksize = 1 << cli->cl_chunkbits; + chunk = index >> ppc_bits; /* align end to rpc edge, rpc size may not be a power 2 integer. */ max_pages = cli->cl_max_pages_per_rpc; @@ -659,15 +659,15 @@ struct osc_extent *osc_extent_find(const struct lu_env *env, /* initialize new extent by parameters so far */ cur->oe_max_end = max_end; - cur->oe_start = index & chunk_mask; - cur->oe_end = ((index + ~chunk_mask + 1) & chunk_mask) - 1; + cur->oe_start = index & chunk_mask; + cur->oe_end = ((index + ~chunk_mask + 1) & chunk_mask) - 1; if (cur->oe_start < lock->cll_descr.cld_start) cur->oe_start = lock->cll_descr.cld_start; if (cur->oe_end > max_end) cur->oe_end = max_end; cur->oe_osclock = lock; - cur->oe_grants = 0; - cur->oe_mppr = max_pages; + cur->oe_grants = 0; + cur->oe_mppr = max_pages; /* grants has been allocated by caller */ LASSERTF(*grants >= chunksize + cli->cl_extent_tax, @@ -681,7 +681,7 @@ restart: ext = first_extent(obj); while (ext != NULL) { loff_t ext_chk_start = ext->oe_start >> ppc_bits; - loff_t ext_chk_end = ext->oe_end >> ppc_bits; + loff_t ext_chk_end = ext->oe_end >> ppc_bits; LASSERT(sanity_check_nolock(ext) == 0); if (chunk > ext_chk_end + 1) @@ -755,14 +755,14 @@ restart: EASSERT((ext->oe_start & ~chunk_mask) == 0, ext); /* pull ext's start back to cover cur */ - ext->oe_start = cur->oe_start; + ext->oe_start = cur->oe_start; ext->oe_grants += chunksize; *grants -= chunksize; found = osc_extent_hold(ext); } else if (chunk == ext_chk_end + 1) { /* rear merge */ - ext->oe_end = cur->oe_end; + ext->oe_end = cur->oe_end; ext->oe_grants += chunksize; *grants -= chunksize; @@ -943,21 +943,21 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext, * @size, then partial truncate happens. */ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, - bool partial) + bool partial) { - struct cl_env_nest nest; - struct lu_env *env; - struct cl_io *io; - struct osc_object *obj = ext->oe_obj; - struct client_obd *cli = osc_cli(obj); + struct cl_env_nest nest; + struct lu_env *env; + struct cl_io *io; + struct osc_object *obj = ext->oe_obj; + struct client_obd *cli = osc_cli(obj); struct osc_async_page *oap; struct osc_async_page *tmp; - int pages_in_chunk = 0; - int ppc_bits = cli->cl_chunkbits - PAGE_CACHE_SHIFT; - __u64 trunc_chunk = trunc_index >> ppc_bits; - int grants = 0; - int nr_pages = 0; - int rc = 0; + int pages_in_chunk = 0; + int ppc_bits = cli->cl_chunkbits - PAGE_CACHE_SHIFT; + __u64 trunc_chunk = trunc_index >> ppc_bits; + int grants = 0; + int nr_pages = 0; + int rc = 0; LASSERT(sanity_check(ext) == 0); EASSERT(ext->oe_state == OES_TRUNC, ext); @@ -976,8 +976,8 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, /* discard all pages with index greater then trunc_index */ list_for_each_entry_safe(oap, tmp, &ext->oe_pages, oap_pending_item) { - struct cl_page *sub = oap2cl_page(oap); - struct cl_page *page = cl_page_top(sub); + struct cl_page *sub = oap2cl_page(oap); + struct cl_page *page = cl_page_top(sub); LASSERT(list_empty(&oap->oap_rpc_item)); @@ -1022,7 +1022,7 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, grants = ext->oe_grants; ext->oe_grants = 0; } else { /* calculate how many grants we can free */ - int chunks = (ext->oe_end >> ppc_bits) - trunc_chunk; + int chunks = (ext->oe_end >> ppc_bits) - trunc_chunk; pgoff_t last_index; @@ -1038,10 +1038,10 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, } /* this is what we can free from this extent */ - grants = chunks << cli->cl_chunkbits; + grants = chunks << cli->cl_chunkbits; ext->oe_grants -= grants; - last_index = ((trunc_chunk + 1) << ppc_bits) - 1; - ext->oe_end = min(last_index, ext->oe_max_end); + last_index = ((trunc_chunk + 1) << ppc_bits) - 1; + ext->oe_end = min(last_index, ext->oe_max_end); LASSERT(ext->oe_end >= ext->oe_start); LASSERT(ext->oe_grants > 0); } @@ -1236,8 +1236,8 @@ static inline int osc_is_ready(struct osc_object *osc) static int osc_make_ready(const struct lu_env *env, struct osc_async_page *oap, int cmd) { - struct osc_page *opg = oap2osc_page(oap); - struct cl_page *page = cl_page_top(oap2cl_page(oap)); + struct osc_page *opg = oap2osc_page(oap); + struct cl_page *page = cl_page_top(oap2cl_page(oap)); int result; LASSERT(cmd == OBD_BRW_WRITE); /* no cached reads */ @@ -1251,10 +1251,10 @@ static int osc_make_ready(const struct lu_env *env, struct osc_async_page *oap, static int osc_refresh_count(const struct lu_env *env, struct osc_async_page *oap, int cmd) { - struct osc_page *opg = oap2osc_page(oap); - struct cl_page *page = oap2cl_page(oap); + struct osc_page *opg = oap2osc_page(oap); + struct cl_page *page = oap2cl_page(oap); struct cl_object *obj; - struct cl_attr *attr = &osc_env_info(env)->oti_attr; + struct cl_attr *attr = &osc_env_info(env)->oti_attr; int result; loff_t kms; @@ -1283,10 +1283,10 @@ static int osc_refresh_count(const struct lu_env *env, static int osc_completion(const struct lu_env *env, struct osc_async_page *oap, int cmd, int rc) { - struct osc_page *opg = oap2osc_page(oap); - struct cl_page *page = cl_page_top(oap2cl_page(oap)); - struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); - enum cl_req_type crt; + struct osc_page *opg = oap2osc_page(oap); + struct cl_page *page = cl_page_top(oap2cl_page(oap)); + struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); + enum cl_req_type crt; int srvlock; cmd &= ~OBD_BRW_NOQUOTA; @@ -1318,7 +1318,7 @@ static int osc_completion(const struct lu_env *env, struct osc_async_page *oap, /* statistic */ if (rc == 0 && srvlock) { - struct lu_device *ld = opg->ops_cl.cpl_obj->co_lu.lo_dev; + struct lu_device *ld = opg->ops_cl.cpl_obj->co_lu.lo_dev; struct osc_stats *stats = &lu2osc_dev(ld)->od_stats; int bytes = oap->oap_count; @@ -1396,7 +1396,7 @@ static int osc_reserve_grant(struct client_obd *cli, unsigned int bytes) int rc = -EDQUOT; if (cli->cl_avail_grant >= bytes) { - cli->cl_avail_grant -= bytes; + cli->cl_avail_grant -= bytes; cli->cl_reserved_grant += bytes; rc = 0; } @@ -1527,7 +1527,7 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, struct osc_async_page *oap, int bytes) { struct osc_object *osc = oap->oap_obj; - struct lov_oinfo *loi = osc->oo_oinfo; + struct lov_oinfo *loi = osc->oo_oinfo; struct osc_cache_waiter ocw; struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); int rc = -EDQUOT; @@ -1782,7 +1782,7 @@ static void osc_ap_completion(const struct lu_env *env, struct client_obd *cli, struct osc_async_page *oap, int sent, int rc) { struct osc_object *osc = oap->oap_obj; - struct lov_oinfo *loi = osc->oo_oinfo; + struct lov_oinfo *loi = osc->oo_oinfo; __u64 xid = 0; if (oap->oap_request != NULL) { @@ -2049,7 +2049,7 @@ osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli, #define list_to_obj(list, item) ({ \ struct list_head *__tmp = (list)->next; \ - list_del_init(__tmp); \ + list_del_init(__tmp); \ list_entry(__tmp, struct osc_object, oo_##item); \ }) @@ -2179,7 +2179,7 @@ static int osc_io_unplug0(const struct lu_env *env, struct client_obd *cli, } static int osc_io_unplug_async(const struct lu_env *env, - struct client_obd *cli, struct osc_object *osc) + struct client_obd *cli, struct osc_object *osc) { /* XXX: policy is no use actually. */ return osc_io_unplug0(env, cli, osc, PDL_POLICY_ROUND, 1); @@ -2194,7 +2194,7 @@ void osc_io_unplug(const struct lu_env *env, struct client_obd *cli, int osc_prep_async_page(struct osc_object *osc, struct osc_page *ops, struct page *page, loff_t offset) { - struct obd_export *exp = osc_export(osc); + struct obd_export *exp = osc_export(osc); struct osc_async_page *oap = &ops->ops_oap; if (!page) @@ -2224,16 +2224,16 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, struct osc_page *ops) { struct osc_io *oio = osc_env_io(env); - struct osc_extent *ext = NULL; + struct osc_extent *ext = NULL; struct osc_async_page *oap = &ops->ops_oap; - struct client_obd *cli = oap->oap_cli; - struct osc_object *osc = oap->oap_obj; + struct client_obd *cli = oap->oap_cli; + struct osc_object *osc = oap->oap_obj; pgoff_t index; - int grants = 0; - int brw_flags = OBD_BRW_ASYNC; - int cmd = OBD_BRW_WRITE; - int need_release = 0; - int rc = 0; + int grants = 0; + int brw_flags = OBD_BRW_ASYNC; + int cmd = OBD_BRW_WRITE; + int need_release = 0; + int rc = 0; if (oap->oap_magic != OAP_MAGIC) return -EINVAL; @@ -2256,7 +2256,7 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, /* check if the file's owner/group is over quota */ if (!(cmd & OBD_BRW_NOQUOTA)) { struct cl_object *obj; - struct cl_attr *attr; + struct cl_attr *attr; unsigned int qid[MAXQUOTAS]; obj = cl_object_top(&osc->oo_cl); @@ -2386,7 +2386,7 @@ int osc_teardown_async_page(const struct lu_env *env, struct osc_object *obj, struct osc_page *ops) { struct osc_async_page *oap = &ops->ops_oap; - struct osc_extent *ext = NULL; + struct osc_extent *ext = NULL; int rc = 0; LASSERT(oap->oap_magic == OAP_MAGIC); @@ -2425,10 +2425,10 @@ int osc_teardown_async_page(const struct lu_env *env, int osc_flush_async_page(const struct lu_env *env, struct cl_io *io, struct osc_page *ops) { - struct osc_extent *ext = NULL; - struct osc_object *obj = cl2osc(ops->ops_cl.cpl_obj); - struct cl_page *cp = ops->ops_cl.cpl_page; - pgoff_t index = cp->cp_index; + struct osc_extent *ext = NULL; + struct osc_object *obj = cl2osc(ops->ops_cl.cpl_obj); + struct cl_page *cp = ops->ops_cl.cpl_page; + pgoff_t index = cp->cp_index; struct osc_async_page *oap = &ops->ops_oap; bool unplug = false; int rc = 0; @@ -2507,14 +2507,14 @@ out: int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops) { struct osc_async_page *oap = &ops->ops_oap; - struct osc_object *obj = oap->oap_obj; - struct client_obd *cli = osc_cli(obj); - struct osc_extent *ext; - struct osc_extent *found = NULL; - struct list_head *plist; + struct osc_object *obj = oap->oap_obj; + struct client_obd *cli = osc_cli(obj); + struct osc_extent *ext; + struct osc_extent *found = NULL; + struct list_head *plist; pgoff_t index = oap2cl_page(oap)->cp_index; - int rc = -EBUSY; - int cmd; + int rc = -EBUSY; + int cmd; LASSERT(!oap->oap_interrupted); oap->oap_interrupted = 1; @@ -2523,10 +2523,10 @@ int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops) osc_object_lock(obj); if (oap->oap_cmd & OBD_BRW_WRITE) { plist = &obj->oo_urgent_exts; - cmd = OBD_BRW_WRITE; + cmd = OBD_BRW_WRITE; } else { plist = &obj->oo_reading_exts; - cmd = OBD_BRW_READ; + cmd = OBD_BRW_READ; } list_for_each_entry(ext, plist, oe_link) { if (ext->oe_start <= index && ext->oe_end >= index) { @@ -2564,13 +2564,13 @@ int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops) int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj, struct list_head *list, int cmd, int brw_flags) { - struct client_obd *cli = osc_cli(obj); - struct osc_extent *ext; + struct client_obd *cli = osc_cli(obj); + struct osc_extent *ext; struct osc_async_page *oap, *tmp; - int page_count = 0; - int mppr = cli->cl_max_pages_per_rpc; - pgoff_t start = CL_PAGE_EOF; - pgoff_t end = 0; + int page_count = 0; + int mppr = cli->cl_max_pages_per_rpc; + pgoff_t start = CL_PAGE_EOF; + pgoff_t end = 0; list_for_each_entry(oap, list, oap_pending_item) { struct cl_page *cp = oap2cl_page(oap); @@ -2785,7 +2785,7 @@ int osc_cache_wait_range(const struct lu_env *env, struct osc_object *obj, { struct osc_extent *ext; pgoff_t index = start; - int result = 0; + int result = 0; again: osc_object_lock(obj); diff --git a/drivers/staging/lustre/lustre/osc/osc_dev.c b/drivers/staging/lustre/lustre/osc/osc_dev.c index ce5c3af1237b..9222c9f4faae 100644 --- a/drivers/staging/lustre/lustre/osc/osc_dev.c +++ b/drivers/staging/lustre/lustre/osc/osc_dev.c @@ -118,7 +118,7 @@ static struct lu_device *osc2lu_dev(struct osc_device *osc) */ static void *osc_key_init(const struct lu_context *ctx, - struct lu_context_key *key) + struct lu_context_key *key) { struct osc_thread_info *info; @@ -248,14 +248,14 @@ static const struct lu_device_type_operations osc_device_type_ops = { .ldto_device_alloc = osc_device_alloc, .ldto_device_free = osc_device_free, - .ldto_device_init = osc_device_init, - .ldto_device_fini = osc_device_fini + .ldto_device_init = osc_device_init, + .ldto_device_fini = osc_device_fini }; struct lu_device_type osc_device_type = { - .ldt_tags = LU_DEVICE_CL, - .ldt_name = LUSTRE_OSC_NAME, - .ldt_ops = &osc_device_type_ops, + .ldt_tags = LU_DEVICE_CL, + .ldt_name = LUSTRE_OSC_NAME, + .ldt_ops = &osc_device_type_ops, .ldt_ctx_tags = LCT_CL_THREAD }; diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index 3c7300b0651d..fa24e9ed1831 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -100,16 +100,16 @@ static int osc_io_submit(const struct lu_env *env, const struct cl_io_slice *ios, enum cl_req_type crt, struct cl_2queue *queue) { - struct cl_page *page; - struct cl_page *tmp; - struct client_obd *cli = NULL; - struct osc_object *osc = NULL; /* to keep gcc happy */ - struct osc_page *opg; - struct cl_io *io; + struct cl_page *page; + struct cl_page *tmp; + struct client_obd *cli = NULL; + struct osc_object *osc = NULL; /* to keep gcc happy */ + struct osc_page *opg; + struct cl_io *io; LIST_HEAD(list); - struct cl_page_list *qin = &queue->c2_qin; - struct cl_page_list *qout = &queue->c2_qout; + struct cl_page_list *qin = &queue->c2_qin; + struct cl_page_list *qout = &queue->c2_qout; int queued = 0; int result = 0; int cmd; @@ -189,8 +189,8 @@ static int osc_io_submit(const struct lu_env *env, static void osc_page_touch_at(const struct lu_env *env, struct cl_object *obj, pgoff_t idx, unsigned to) { - struct lov_oinfo *loi = cl2osc(obj)->oo_oinfo; - struct cl_attr *attr = &osc_env_info(env)->oti_attr; + struct lov_oinfo *loi = cl2osc(obj)->oo_oinfo; + struct cl_attr *attr = &osc_env_info(env)->oti_attr; int valid; __u64 kms; @@ -233,8 +233,8 @@ static void osc_page_touch_at(const struct lu_env *env, static void osc_page_touch(const struct lu_env *env, struct osc_page *opage, unsigned to) { - struct cl_page *page = opage->ops_cl.cpl_page; - struct cl_object *obj = opage->ops_cl.cpl_obj; + struct cl_page *page = opage->ops_cl.cpl_page; + struct cl_object *obj = opage->ops_cl.cpl_obj; osc_page_touch_at(env, obj, page->cp_index, to); } @@ -260,7 +260,7 @@ static int osc_io_prepare_write(const struct lu_env *env, { struct osc_device *dev = lu2osc_dev(slice->cpl_obj->co_lu.lo_dev); struct obd_import *imp = class_exp2cliimp(dev->od_exp); - struct osc_io *oio = cl2osc_io(env, ios); + struct osc_io *oio = cl2osc_io(env, ios); int result = 0; /* @@ -284,9 +284,9 @@ static int osc_io_commit_write(const struct lu_env *env, const struct cl_page_slice *slice, unsigned from, unsigned to) { - struct osc_io *oio = cl2osc_io(env, ios); - struct osc_page *opg = cl2osc_page(slice); - struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); + struct osc_io *oio = cl2osc_io(env, ios); + struct osc_page *opg = cl2osc_page(slice); + struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); struct osc_async_page *oap = &opg->ops_oap; LASSERT(to > 0); @@ -311,10 +311,10 @@ static int osc_io_commit_write(const struct lu_env *env, static int osc_io_fault_start(const struct lu_env *env, const struct cl_io_slice *ios) { - struct cl_io *io; + struct cl_io *io; struct cl_fault_io *fio; - io = ios->cis_io; + io = ios->cis_io; fio = &io->u.ci_fault; CDEBUG(D_INFO, "%lu %d %d\n", fio->ft_index, fio->ft_writable, fio->ft_nob); @@ -375,11 +375,11 @@ static void osc_trunc_check(const struct lu_env *env, struct cl_io *io, struct osc_io *oio, __u64 size) { struct cl_object *clob; - int partial; + int partial; pgoff_t start; - clob = oio->oi_cl.cis_obj; - start = cl_index(clob, size); + clob = oio->oi_cl.cis_obj; + start = cl_index(clob, size); partial = cl_offset(clob, start) < size; /* @@ -392,17 +392,17 @@ static void osc_trunc_check(const struct lu_env *env, struct cl_io *io, static int osc_io_setattr_start(const struct lu_env *env, const struct cl_io_slice *slice) { - struct cl_io *io = slice->cis_io; - struct osc_io *oio = cl2osc_io(env, slice); - struct cl_object *obj = slice->cis_obj; - struct lov_oinfo *loi = cl2osc(obj)->oo_oinfo; - struct cl_attr *attr = &osc_env_info(env)->oti_attr; - struct obdo *oa = &oio->oi_oa; + struct cl_io *io = slice->cis_io; + struct osc_io *oio = cl2osc_io(env, slice); + struct cl_object *obj = slice->cis_obj; + struct lov_oinfo *loi = cl2osc(obj)->oo_oinfo; + struct cl_attr *attr = &osc_env_info(env)->oti_attr; + struct obdo *oa = &oio->oi_oa; struct osc_async_cbargs *cbargs = &oio->oi_cbarg; - __u64 size = io->u.ci_setattr.sa_attr.lvb_size; - unsigned int ia_valid = io->u.ci_setattr.sa_valid; - int result = 0; - struct obd_info oinfo = { { { 0 } } }; + __u64 size = io->u.ci_setattr.sa_attr.lvb_size; + unsigned int ia_valid = io->u.ci_setattr.sa_valid; + int result = 0; + struct obd_info oinfo = { { { 0 } } }; /* truncate cache dirty pages first */ if (cl_io_is_trunc(io)) @@ -477,8 +477,8 @@ static int osc_io_setattr_start(const struct lu_env *env, static void osc_io_setattr_end(const struct lu_env *env, const struct cl_io_slice *slice) { - struct cl_io *io = slice->cis_io; - struct osc_io *oio = cl2osc_io(env, slice); + struct cl_io *io = slice->cis_io; + struct osc_io *oio = cl2osc_io(env, slice); struct cl_object *obj = slice->cis_obj; struct osc_async_cbargs *cbargs = &oio->oi_cbarg; int result = 0; @@ -512,8 +512,8 @@ 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 cl_object *obj = slice->cis_obj; - struct cl_attr *attr = &osc_env_info(env)->oti_attr; + struct cl_object *obj = slice->cis_obj; + struct cl_attr *attr = &osc_env_info(env)->oti_attr; int rc = 0; if (!slice->cis_io->ci_noatime) { @@ -528,8 +528,8 @@ 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 cl_object *obj = slice->cis_obj; - struct cl_attr *attr = &osc_env_info(env)->oti_attr; + struct cl_object *obj = slice->cis_obj; + struct cl_attr *attr = &osc_env_info(env)->oti_attr; int rc = 0; OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_DELAY_SETTIME, 1); @@ -544,10 +544,10 @@ static int osc_io_write_start(const struct lu_env *env, static int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj, struct cl_fsync_io *fio) { - struct osc_io *oio = osc_env_io(env); - struct obdo *oa = &oio->oi_oa; - struct obd_info *oinfo = &oio->oi_info; - struct lov_oinfo *loi = obj->oo_oinfo; + struct osc_io *oio = osc_env_io(env); + struct obdo *oa = &oio->oi_oa; + struct obd_info *oinfo = &oio->oi_info; + struct lov_oinfo *loi = obj->oo_oinfo; struct osc_async_cbargs *cbargs = &oio->oi_cbarg; int rc = 0; @@ -575,13 +575,13 @@ static int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj, static int osc_io_fsync_start(const struct lu_env *env, const struct cl_io_slice *slice) { - struct cl_io *io = slice->cis_io; + struct cl_io *io = slice->cis_io; struct cl_fsync_io *fio = &io->u.ci_fsync; - struct cl_object *obj = slice->cis_obj; - struct osc_object *osc = cl2osc(obj); - pgoff_t start = cl_index(obj, fio->fi_start); - pgoff_t end = cl_index(obj, fio->fi_end); - int result = 0; + struct cl_object *obj = slice->cis_obj; + struct osc_object *osc = cl2osc(obj); + pgoff_t start = cl_index(obj, fio->fi_start); + pgoff_t end = cl_index(obj, fio->fi_end); + int result = 0; if (fio->fi_end == OBD_OBJECT_EOF) end = CL_PAGE_EOF; @@ -615,15 +615,15 @@ static void osc_io_fsync_end(const struct lu_env *env, const struct cl_io_slice *slice) { struct cl_fsync_io *fio = &slice->cis_io->u.ci_fsync; - struct cl_object *obj = slice->cis_obj; + struct cl_object *obj = slice->cis_obj; pgoff_t start = cl_index(obj, fio->fi_start); - pgoff_t end = cl_index(obj, fio->fi_end); + pgoff_t end = cl_index(obj, fio->fi_end); int result = 0; if (fio->fi_mode == CL_FSYNC_LOCAL) { result = osc_cache_wait_range(env, cl2osc(obj), start, end); } else if (fio->fi_mode == CL_FSYNC_ALL) { - struct osc_io *oio = cl2osc_io(env, slice); + struct osc_io *oio = cl2osc_io(env, slice); struct osc_async_cbargs *cbargs = &oio->oi_cbarg; wait_for_completion(&cbargs->opc_sync); @@ -717,17 +717,17 @@ static void osc_req_attr_set(const struct lu_env *env, struct cl_req_attr *attr, u64 flags) { struct lov_oinfo *oinfo; - struct cl_req *clerq; - struct cl_page *apage; /* _some_ page in @clerq */ - struct cl_lock *lock; /* _some_ lock protecting @apage */ - struct osc_lock *olck; - struct osc_page *opg; - struct obdo *oa; - struct ost_lvb *lvb; + struct cl_req *clerq; + struct cl_page *apage; /* _some_ page in @clerq */ + struct cl_lock *lock; /* _some_ lock protecting @apage */ + struct osc_lock *olck; + struct osc_page *opg; + struct obdo *oa; + struct ost_lvb *lvb; - oinfo = cl2osc(obj)->oo_oinfo; - lvb = &oinfo->loi_lvb; - oa = attr->cra_oa; + oinfo = cl2osc(obj)->oo_oinfo; + lvb = &oinfo->loi_lvb; + oa = attr->cra_oa; if ((flags & OBD_MD_FLMTIME) != 0) { oa->o_mtime = lvb->lvb_mtime; @@ -759,7 +759,7 @@ static void osc_req_attr_set(const struct lu_env *env, lock = cl_lock_at_page(env, apage->cp_obj, apage, NULL, 1, 1); if (lock == NULL) { struct cl_object_header *head; - struct cl_lock *scan; + struct cl_lock *scan; head = cl_object_header(apage->cp_obj); list_for_each_entry(scan, &head->coh_locks, diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index 350ad49550ab..06837f5f4e64 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -89,9 +89,9 @@ static struct ldlm_lock *osc_handle_ptr(struct lustre_handle *handle) */ static int osc_lock_invariant(struct osc_lock *ols) { - struct ldlm_lock *lock = osc_handle_ptr(&ols->ols_handle); - struct ldlm_lock *olock = ols->ols_lock; - int handle_used = lustre_handle_is_used(&ols->ols_handle); + struct ldlm_lock *lock = osc_handle_ptr(&ols->ols_handle); + struct ldlm_lock *olock = ols->ols_lock; + int handle_used = lustre_handle_is_used(&ols->ols_handle); if (ergo(osc_lock_is_lockless(ols), ols->ols_locklessable && ols->ols_lock == NULL)) @@ -164,7 +164,7 @@ static void osc_lock_detach(const struct lu_env *env, struct osc_lock *olck) lock_res_and_lock(dlmlock); if (dlmlock->l_granted_mode == dlmlock->l_req_mode) { struct cl_object *obj = olck->ols_cl.cls_obj; - struct cl_attr *attr = &osc_env_info(env)->oti_attr; + struct cl_attr *attr = &osc_env_info(env)->oti_attr; __u64 old_kms; cl_object_attr_lock(obj); @@ -237,7 +237,7 @@ static int osc_lock_unuse(const struct lu_env *env, static void osc_lock_fini(const struct lu_env *env, struct cl_lock_slice *slice) { - struct osc_lock *ols = cl2osc_lock(slice); + struct osc_lock *ols = cl2osc_lock(slice); LINVRNT(osc_lock_invariant(ols)); /* @@ -337,25 +337,25 @@ static void osc_ast_data_put(const struct lu_env *env, struct osc_lock *olck) static void osc_lock_lvb_update(const struct lu_env *env, struct osc_lock *olck, int rc) { - struct ost_lvb *lvb; - struct cl_object *obj; - struct lov_oinfo *oinfo; - struct cl_attr *attr; - unsigned valid; + struct ost_lvb *lvb; + struct cl_object *obj; + struct lov_oinfo *oinfo; + struct cl_attr *attr; + unsigned valid; if (!(olck->ols_flags & LDLM_FL_LVB_READY)) return; - lvb = &olck->ols_lvb; - obj = olck->ols_cl.cls_obj; + lvb = &olck->ols_lvb; + obj = olck->ols_cl.cls_obj; oinfo = cl2osc(obj)->oo_oinfo; - attr = &osc_env_info(env)->oti_attr; + attr = &osc_env_info(env)->oti_attr; valid = CAT_BLOCKS | CAT_ATIME | CAT_CTIME | CAT_MTIME | CAT_SIZE; cl_lvb2attr(attr, lvb); cl_object_attr_lock(obj); if (rc == 0) { - struct ldlm_lock *dlmlock; + struct ldlm_lock *dlmlock; __u64 size; dlmlock = olck->ols_lock; @@ -401,23 +401,23 @@ static void osc_lock_lvb_update(const struct lu_env *env, struct osc_lock *olck, static void osc_lock_granted(const struct lu_env *env, struct osc_lock *olck, struct ldlm_lock *dlmlock, int rc) { - struct ldlm_extent *ext; - struct cl_lock *lock; + struct ldlm_extent *ext; + struct cl_lock *lock; struct cl_lock_descr *descr; LASSERT(dlmlock->l_granted_mode == dlmlock->l_req_mode); if (olck->ols_state < OLS_GRANTED) { - lock = olck->ols_cl.cls_lock; - ext = &dlmlock->l_policy_data.l_extent; + lock = olck->ols_cl.cls_lock; + ext = &dlmlock->l_policy_data.l_extent; descr = &osc_env_info(env)->oti_descr; descr->cld_obj = lock->cll_descr.cld_obj; /* XXX check that ->l_granted_mode is valid. */ - descr->cld_mode = osc_ldlm2cl_lock(dlmlock->l_granted_mode); + descr->cld_mode = osc_ldlm2cl_lock(dlmlock->l_granted_mode); descr->cld_start = cl_index(descr->cld_obj, ext->start); - descr->cld_end = cl_index(descr->cld_obj, ext->end); - descr->cld_gid = ext->gid; + descr->cld_end = cl_index(descr->cld_obj, ext->end); + descr->cld_gid = ext->gid; /* * tell upper layers the extent of the lock that was actually * granted @@ -482,11 +482,11 @@ static void osc_lock_upcall0(const struct lu_env *env, struct osc_lock *olck) */ static int osc_lock_upcall(void *cookie, int errcode) { - struct osc_lock *olck = cookie; - struct cl_lock_slice *slice = &olck->ols_cl; - struct cl_lock *lock = slice->cls_lock; - struct lu_env *env; - struct cl_env_nest nest; + struct osc_lock *olck = cookie; + struct cl_lock_slice *slice = &olck->ols_cl; + struct cl_lock *lock = slice->cls_lock; + struct lu_env *env; + struct cl_env_nest nest; env = cl_env_nested_get(&nest); if (!IS_ERR(env)) { @@ -626,7 +626,7 @@ static int osc_dlm_blocking_ast0(const struct lu_env *env, void *data, int flag) { struct osc_lock *olck; - struct cl_lock *lock; + struct cl_lock *lock; int result; int cancel; @@ -733,9 +733,9 @@ static int osc_ldlm_blocking_ast(struct ldlm_lock *dlmlock, struct ldlm_lock_desc *new, void *data, int flag) { - struct lu_env *env; + struct lu_env *env; struct cl_env_nest nest; - int result; + int result; /* * This can be called in the context of outer IO, e.g., @@ -774,9 +774,9 @@ static int osc_ldlm_completion_ast(struct ldlm_lock *dlmlock, __u64 flags, void *data) { struct cl_env_nest nest; - struct lu_env *env; - struct osc_lock *olck; - struct cl_lock *lock; + struct lu_env *env; + struct osc_lock *olck; + struct cl_lock *lock; int result; int dlmrc; @@ -830,15 +830,15 @@ static int osc_ldlm_completion_ast(struct ldlm_lock *dlmlock, static int osc_ldlm_glimpse_ast(struct ldlm_lock *dlmlock, void *data) { - struct ptlrpc_request *req = data; + struct ptlrpc_request *req = data; struct osc_lock *olck; - struct cl_lock *lock; - struct cl_object *obj; - struct cl_env_nest nest; - struct lu_env *env; - struct ost_lvb *lvb; - struct req_capsule *cap; - int result; + struct cl_lock *lock; + struct cl_object *obj; + struct cl_env_nest nest; + struct lu_env *env; + struct ost_lvb *lvb; + struct req_capsule *cap; + int result; LASSERT(lustre_msg_get_opc(req->rq_reqmsg) == LDLM_GL_CALLBACK); @@ -916,11 +916,11 @@ static void osc_lock_build_einfo(const struct lu_env *env, */ mode = CLM_READ; - einfo->ei_type = LDLM_EXTENT; - einfo->ei_mode = osc_cl_lock2ldlm(mode); - einfo->ei_cb_bl = osc_ldlm_blocking_ast; - einfo->ei_cb_cp = osc_ldlm_completion_ast; - einfo->ei_cb_gl = osc_ldlm_glimpse_ast; + einfo->ei_type = LDLM_EXTENT; + einfo->ei_mode = osc_cl_lock2ldlm(mode); + einfo->ei_cb_bl = osc_ldlm_blocking_ast; + einfo->ei_cb_cp = osc_ldlm_completion_ast; + einfo->ei_cb_gl = osc_ldlm_glimpse_ast; einfo->ei_cbdata = lock; /* value to be put into ->l_ast_data */ } @@ -948,9 +948,9 @@ static void osc_lock_to_lockless(const struct lu_env *env, ols->ols_locklessable = 1; slice->cls_ops = &osc_lock_lockless_ops; } else { - struct osc_io *oio = osc_env_io(env); - struct cl_io *io = oio->oi_cl.cis_io; - struct cl_object *obj = slice->cls_obj; + struct osc_io *oio = osc_env_io(env); + struct cl_io *io = oio->oi_cl.cis_io; + struct cl_object *obj = slice->cls_obj; struct osc_object *oob = cl2osc(obj); const struct osc_device *osd = lu2osc_dev(obj->co_lu.lo_dev); struct obd_connect_data *ocd; @@ -1006,13 +1006,13 @@ static int osc_lock_compatible(const struct osc_lock *qing, static int osc_lock_enqueue_wait(const struct lu_env *env, const struct osc_lock *olck) { - struct cl_lock *lock = olck->ols_cl.cls_lock; - struct cl_lock_descr *descr = &lock->cll_descr; - struct cl_object_header *hdr = cl_object_header(descr->cld_obj); - struct cl_lock *scan; - struct cl_lock *conflict = NULL; - int lockless = osc_lock_is_lockless(olck); - int rc = 0; + struct cl_lock *lock = olck->ols_cl.cls_lock; + struct cl_lock_descr *descr = &lock->cll_descr; + struct cl_object_header *hdr = cl_object_header(descr->cld_obj); + struct cl_lock *scan; + struct cl_lock *conflict = NULL; + int lockless = osc_lock_is_lockless(olck); + int rc = 0; LASSERT(cl_lock_is_mutexed(lock)); @@ -1102,8 +1102,8 @@ static int osc_lock_enqueue(const struct lu_env *env, const struct cl_lock_slice *slice, struct cl_io *unused, __u32 enqflags) { - struct osc_lock *ols = cl2osc_lock(slice); - struct cl_lock *lock = ols->ols_cl.cls_lock; + struct osc_lock *ols = cl2osc_lock(slice); + struct cl_lock *lock = ols->ols_cl.cls_lock; int result; LASSERT(cl_lock_is_mutexed(lock)); @@ -1116,10 +1116,10 @@ static int osc_lock_enqueue(const struct lu_env *env, result = osc_lock_enqueue_wait(env, ols); if (result == 0) { if (!osc_lock_is_lockless(ols)) { - struct osc_object *obj = cl2osc(slice->cls_obj); - struct osc_thread_info *info = osc_env_info(env); - struct ldlm_res_id *resname = &info->oti_resname; - ldlm_policy_data_t *policy = &info->oti_policy; + struct osc_object *obj = cl2osc(slice->cls_obj); + struct osc_thread_info *info = osc_env_info(env); + struct ldlm_res_id *resname = &info->oti_resname; + ldlm_policy_data_t *policy = &info->oti_policy; struct ldlm_enqueue_info *einfo = &ols->ols_einfo; /* lock will be passed as upcall cookie, @@ -1164,7 +1164,7 @@ static int osc_lock_wait(const struct lu_env *env, const struct cl_lock_slice *slice) { struct osc_lock *olck = cl2osc_lock(slice); - struct cl_lock *lock = olck->ols_cl.cls_lock; + struct cl_lock *lock = olck->ols_cl.cls_lock; LINVRNT(osc_lock_invariant(olck)); @@ -1245,14 +1245,14 @@ static int osc_lock_use(const struct lu_env *env, static int osc_lock_flush(struct osc_lock *ols, int discard) { - struct cl_lock *lock = ols->ols_cl.cls_lock; - struct cl_env_nest nest; - struct lu_env *env; + struct cl_lock *lock = ols->ols_cl.cls_lock; + struct cl_env_nest nest; + struct lu_env *env; int result = 0; env = cl_env_nested_get(&nest); if (!IS_ERR(env)) { - struct osc_object *obj = cl2osc(ols->ols_cl.cls_obj); + struct osc_object *obj = cl2osc(ols->ols_cl.cls_obj); struct cl_lock_descr *descr = &lock->cll_descr; int rc = 0; @@ -1298,11 +1298,11 @@ static int osc_lock_flush(struct osc_lock *ols, int discard) static void osc_lock_cancel(const struct lu_env *env, const struct cl_lock_slice *slice) { - struct cl_lock *lock = slice->cls_lock; - struct osc_lock *olck = cl2osc_lock(slice); + struct cl_lock *lock = slice->cls_lock; + struct osc_lock *olck = cl2osc_lock(slice); struct ldlm_lock *dlmlock = olck->ols_lock; - int result = 0; - int discard; + int result = 0; + int discard; LASSERT(cl_lock_is_mutexed(lock)); LINVRNT(osc_lock_invariant(olck)); @@ -1482,7 +1482,7 @@ static int osc_lock_lockless_unuse(const struct lu_env *env, static void osc_lock_lockless_cancel(const struct lu_env *env, const struct cl_lock_slice *slice) { - struct osc_lock *ols = cl2osc_lock(slice); + struct osc_lock *ols = cl2osc_lock(slice); int result; result = osc_lock_flush(ols, 0); @@ -1496,7 +1496,7 @@ static int osc_lock_lockless_wait(const struct lu_env *env, const struct cl_lock_slice *slice) { struct osc_lock *olck = cl2osc_lock(slice); - struct cl_lock *lock = olck->ols_cl.cls_lock; + struct cl_lock *lock = olck->ols_cl.cls_lock; LINVRNT(osc_lock_invariant(olck)); LASSERT(olck->ols_state >= OLS_UPCALL_RECEIVED); @@ -1512,7 +1512,7 @@ static void osc_lock_lockless_state(const struct lu_env *env, LINVRNT(osc_lock_invariant(lock)); if (state == CLS_HELD) { - struct osc_io *oio = osc_env_io(env); + struct osc_io *oio = osc_env_io(env); LASSERT(ergo(lock->ols_owner, lock->ols_owner == oio)); lock->ols_owner = oio; @@ -1591,7 +1591,7 @@ int osc_lock_init(const struct lu_env *env, int osc_dlm_lock_pageref(struct ldlm_lock *dlm) { struct osc_lock *olock; - int rc = 0; + int rc = 0; spin_lock(&osc_ast_guard); olock = dlm->l_ast_data; diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c index 92c202f70395..c628a250ebd6 100644 --- a/drivers/staging/lustre/lustre/osc/osc_object.c +++ b/drivers/staging/lustre/lustre/osc/osc_object.c @@ -72,7 +72,7 @@ static struct osc_object *lu2osc(const struct lu_object *obj) static int osc_object_init(const struct lu_env *env, struct lu_object *obj, const struct lu_object_conf *conf) { - struct osc_object *osc = lu2osc(obj); + struct osc_object *osc = lu2osc(obj); const struct cl_object_conf *cconf = lu2cl_conf(conf); int i; @@ -136,9 +136,9 @@ int osc_lvb_print(const struct lu_env *env, void *cookie, static int osc_object_print(const struct lu_env *env, void *cookie, lu_printer_t p, const struct lu_object *obj) { - struct osc_object *osc = lu2osc(obj); - struct lov_oinfo *oinfo = osc->oo_oinfo; - struct osc_async_rc *ar = &oinfo->loi_ar; + struct osc_object *osc = lu2osc(obj); + struct lov_oinfo *oinfo = osc->oo_oinfo; + struct osc_async_rc *ar = &oinfo->loi_ar; (*p)(env, cookie, "id: " DOSTID " idx: %d gen: %d kms_valid: %u kms %llu rc: %d force_sync: %d min_xid: %llu ", POSTID(&oinfo->loi_oi), oinfo->loi_ost_idx, @@ -163,7 +163,7 @@ int osc_attr_set(const struct lu_env *env, struct cl_object *obj, const struct cl_attr *attr, unsigned valid) { struct lov_oinfo *oinfo = cl2osc(obj)->oo_oinfo; - struct ost_lvb *lvb = &oinfo->loi_lvb; + struct ost_lvb *lvb = &oinfo->loi_lvb; if (valid & CAT_SIZE) lvb->lvb_size = attr->cat_size; @@ -188,7 +188,7 @@ static int osc_object_glimpse(const struct lu_env *env, { struct lov_oinfo *oinfo = cl2osc(obj)->oo_oinfo; - lvb->lvb_size = oinfo->loi_kms; + lvb->lvb_size = oinfo->loi_kms; lvb->lvb_blocks = oinfo->loi_lvb.lvb_blocks; return 0; } @@ -208,9 +208,9 @@ void osc_object_clear_contended(struct osc_object *obj) int osc_object_is_contended(struct osc_object *obj) { - struct osc_device *dev = lu2osc_dev(obj->oo_cl.co_lu.lo_dev); + struct osc_device *dev = lu2osc_dev(obj->oo_cl.co_lu.lo_dev); int osc_contention_time = dev->od_contention_time; - unsigned long cur_time = cfs_time_current(); + unsigned long cur_time = cfs_time_current(); unsigned long retry_time; if (OBD_FAIL_CHECK(OBD_FAIL_OSC_OBJECT_CONTENTION)) @@ -255,7 +255,7 @@ struct lu_object *osc_object_alloc(const struct lu_env *env, struct lu_device *dev) { struct osc_object *osc; - struct lu_object *obj; + struct lu_object *obj; OBD_SLAB_ALLOC_PTR_GFP(osc, osc_object_kmem, GFP_NOFS); if (osc != NULL) { diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index 76ba58b09c5d..43dfa73dd3a6 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -216,7 +216,7 @@ static int osc_page_cache_add(const struct lu_env *env, const struct cl_page_slice *slice, struct cl_io *io) { - struct osc_io *oio = osc_env_io(env); + struct osc_io *oio = osc_env_io(env); struct osc_page *opg = cl2osc_page(slice); int result; @@ -247,7 +247,7 @@ void osc_index2policy(ldlm_policy_data_t *policy, const struct cl_object *obj, { memset(policy, 0, sizeof(*policy)); policy->l_extent.start = cl_offset(obj, start); - policy->l_extent.end = cl_offset(obj, end + 1) - 1; + policy->l_extent.end = cl_offset(obj, end + 1) - 1; } static int osc_page_addref_lock(const struct lu_env *env, @@ -255,7 +255,7 @@ static int osc_page_addref_lock(const struct lu_env *env, struct cl_lock *lock) { struct osc_lock *olock; - int rc; + int rc; LASSERT(opg->ops_lock == NULL); @@ -274,7 +274,7 @@ static int osc_page_addref_lock(const struct lu_env *env, static void osc_page_putref_lock(const struct lu_env *env, struct osc_page *opg) { - struct cl_lock *lock = opg->ops_lock; + struct cl_lock *lock = opg->ops_lock; struct osc_lock *olock; LASSERT(lock != NULL); @@ -291,7 +291,7 @@ static int osc_page_is_under_lock(const struct lu_env *env, struct cl_io *unused) { struct cl_lock *lock; - int result = -ENODATA; + int result = -ENODATA; lock = cl_lock_at_page(env, slice->cpl_obj, slice->cpl_page, NULL, 1, 0); @@ -317,7 +317,7 @@ static void osc_page_completion_read(const struct lu_env *env, const struct cl_page_slice *slice, int ioret) { - struct osc_page *opg = cl2osc_page(slice); + struct osc_page *opg = cl2osc_page(slice); struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); if (likely(opg->ops_lock)) @@ -329,7 +329,7 @@ static void osc_page_completion_write(const struct lu_env *env, const struct cl_page_slice *slice, int ioret) { - struct osc_page *opg = cl2osc_page(slice); + struct osc_page *opg = cl2osc_page(slice); struct osc_object *obj = cl2osc(slice->cpl_obj); osc_lru_add(osc_cli(obj), opg); @@ -364,10 +364,10 @@ static int osc_page_print(const struct lu_env *env, const struct cl_page_slice *slice, void *cookie, lu_printer_t printer) { - struct osc_page *opg = cl2osc_page(slice); + struct osc_page *opg = cl2osc_page(slice); struct osc_async_page *oap = &opg->ops_oap; - struct osc_object *obj = cl2osc(slice->cpl_obj); - struct client_obd *cli = &osc_export(obj)->exp_obd->u.cli; + struct osc_object *obj = cl2osc(slice->cpl_obj); + struct client_obd *cli = &osc_export(obj)->exp_obd->u.cli; return (*printer)(env, cookie, LUSTRE_OSC_NAME "-page@%p: 1< %#x %d %u %s %s > 2< %llu %u %u %#x %#x | %p %p %p > 3< %s %p %d %lu %d > 4< %d %d %d %lu %s | %s %s %s %s > 5< %s %s %s %s | %d %s | %d %s %s>\n", opg, @@ -408,7 +408,7 @@ static int osc_page_print(const struct lu_env *env, static void osc_page_delete(const struct lu_env *env, const struct cl_page_slice *slice) { - struct osc_page *opg = cl2osc_page(slice); + struct osc_page *opg = cl2osc_page(slice); struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); int rc; @@ -437,13 +437,13 @@ static void osc_page_delete(const struct lu_env *env, void osc_page_clip(const struct lu_env *env, const struct cl_page_slice *slice, int from, int to) { - struct osc_page *opg = cl2osc_page(slice); + struct osc_page *opg = cl2osc_page(slice); struct osc_async_page *oap = &opg->ops_oap; LINVRNT(osc_page_protected(env, opg, CLM_READ, 0)); opg->ops_from = from; - opg->ops_to = to; + opg->ops_to = to; spin_lock(&oap->oap_lock); oap->oap_async_flags |= ASYNC_COUNT_STABLE; spin_unlock(&oap->oap_lock); @@ -502,11 +502,11 @@ int osc_page_init(const struct lu_env *env, struct cl_object *obj, struct cl_page *page, struct page *vmpage) { struct osc_object *osc = cl2osc(obj); - struct osc_page *opg = cl_object_page_slice(obj, page); + struct osc_page *opg = cl_object_page_slice(obj, page); int result; opg->ops_from = 0; - opg->ops_to = PAGE_CACHE_SIZE; + opg->ops_to = PAGE_CACHE_SIZE; result = osc_prep_async_page(osc, opg, vmpage, cl_offset(obj, page->cp_index)); @@ -540,7 +540,7 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg, enum cl_req_type crt, int brw_flags) { struct osc_async_page *oap = &opg->ops_oap; - struct osc_object *obj = oap->oap_obj; + struct osc_object *obj = oap->oap_obj; LINVRNT(osc_page_protected(env, opg, crt == CRT_WRITE ? CLM_WRITE : CLM_READ, 1)); @@ -550,9 +550,9 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg, LASSERT(oap->oap_async_flags & ASYNC_READY); LASSERT(oap->oap_async_flags & ASYNC_COUNT_STABLE); - oap->oap_cmd = crt == CRT_WRITE ? OBD_BRW_WRITE : OBD_BRW_READ; - oap->oap_page_off = opg->ops_from; - oap->oap_count = opg->ops_to - opg->ops_from; + oap->oap_cmd = crt == CRT_WRITE ? OBD_BRW_WRITE : OBD_BRW_READ; + oap->oap_page_off = opg->ops_from; + oap->oap_count = opg->ops_to - opg->ops_from; oap->oap_brw_flags = OBD_BRW_SYNC | brw_flags; if (!client_is_remote(osc_export(obj)) && diff --git a/drivers/staging/lustre/lustre/osc/osc_quota.c b/drivers/staging/lustre/lustre/osc/osc_quota.c index 6690f149a04c..2ff253f458f8 100644 --- a/drivers/staging/lustre/lustre/osc/osc_quota.c +++ b/drivers/staging/lustre/lustre/osc/osc_quota.c @@ -232,7 +232,7 @@ int osc_quota_setup(struct obd_device *obd) int osc_quota_cleanup(struct obd_device *obd) { - struct client_obd *cli = &obd->u.cli; + struct client_obd *cli = &obd->u.cli; int type; for (type = 0; type < MAXQUOTAS; type++) @@ -245,8 +245,8 @@ int osc_quotactl(struct obd_device *unused, struct obd_export *exp, struct obd_quotactl *oqctl) { struct ptlrpc_request *req; - struct obd_quotactl *oqc; - int rc; + struct obd_quotactl *oqc; + int rc; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_OST_QUOTACTL, LUSTRE_OST_VERSION, @@ -285,10 +285,10 @@ int osc_quotactl(struct obd_device *unused, struct obd_export *exp, int osc_quotacheck(struct obd_device *unused, struct obd_export *exp, struct obd_quotactl *oqctl) { - struct client_obd *cli = &exp->exp_obd->u.cli; - struct ptlrpc_request *req; - struct obd_quotactl *body; - int rc; + struct client_obd *cli = &exp->exp_obd->u.cli; + struct ptlrpc_request *req; + struct obd_quotactl *body; + int rc; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_OST_QUOTACHECK, LUSTRE_OST_VERSION, diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 6b6851ad3990..c174de9fb309 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -264,7 +264,7 @@ static int osc_getattr_async(struct obd_export *exp, struct obd_info *oinfo, { struct ptlrpc_request *req; struct osc_async_args *aa; - int rc; + int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GETATTR); if (req == NULL) @@ -294,8 +294,8 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp, struct obd_info *oinfo) { struct ptlrpc_request *req; - struct ost_body *body; - int rc; + struct ost_body *body; + int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GETATTR); if (req == NULL) @@ -338,8 +338,8 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp, struct obd_info *oinfo, struct obd_trans_info *oti) { struct ptlrpc_request *req; - struct ost_body *body; - int rc; + struct ost_body *body; + int rc; LASSERT(oinfo->oi_oa->o_valid & OBD_MD_FLGROUP); @@ -403,9 +403,9 @@ int osc_setattr_async_base(struct obd_export *exp, struct obd_info *oinfo, obd_enqueue_update_f upcall, void *cookie, struct ptlrpc_request_set *rqset) { - struct ptlrpc_request *req; + struct ptlrpc_request *req; struct osc_setattr_args *sa; - int rc; + int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SETATTR); if (req == NULL) @@ -460,9 +460,9 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa, struct lov_stripe_md **ea, struct obd_trans_info *oti) { struct ptlrpc_request *req; - struct ost_body *body; - struct lov_stripe_md *lsm; - int rc; + struct ost_body *body; + struct lov_stripe_md *lsm; + int rc; LASSERT(oa); LASSERT(ea); @@ -548,10 +548,10 @@ int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo, obd_enqueue_update_f upcall, void *cookie, struct ptlrpc_request_set *rqset) { - struct ptlrpc_request *req; + struct ptlrpc_request *req; struct osc_setattr_args *sa; - struct ost_body *body; - int rc; + struct ost_body *body; + int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_PUNCH); if (req == NULL) @@ -577,7 +577,7 @@ int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo, req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_setattr_interpret; CLASSERT (sizeof(*sa) <= sizeof(req->rq_async_args)); sa = ptlrpc_req_async_args(req); - sa->sa_oa = oinfo->oi_oa; + sa->sa_oa = oinfo->oi_oa; sa->sa_upcall = upcall; sa->sa_cookie = cookie; if (rqset == PTLRPCD_SET) @@ -616,9 +616,9 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo, struct ptlrpc_request_set *rqset) { struct ptlrpc_request *req; - struct ost_body *body; + struct ost_body *body; struct osc_fsync_args *fa; - int rc; + int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SYNC); if (req == NULL) @@ -757,9 +757,9 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, struct obd_trans_info *oti, struct obd_export *md_export, void *capa) { - struct client_obd *cli = &exp->exp_obd->u.cli; + struct client_obd *cli = &exp->exp_obd->u.cli; struct ptlrpc_request *req; - struct ost_body *body; + struct ost_body *body; LIST_HEAD(cancels); int rc, count; @@ -947,7 +947,7 @@ static int osc_shrink_grant(struct client_obd *cli) int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes) { - int rc = 0; + int rc = 0; struct ost_body *body; client_obd_list_lock(&cli->cl_loi_list_lock); @@ -1131,8 +1131,8 @@ static int check_write_rcs(struct ptlrpc_request *req, int requested_nob, int niocount, u32 page_count, struct brw_page **pga) { - int i; - __u32 *remote_rcs; + int i; + __u32 *remote_rcs; remote_rcs = req_capsule_server_sized_get(&req->rq_pill, &RMF_RCS, sizeof(*remote_rcs) * @@ -1182,15 +1182,15 @@ static inline int can_merge_pages(struct brw_page *p1, struct brw_page *p2) } static u32 osc_checksum_bulk(int nob, u32 pg_count, - struct brw_page **pga, int opc, - cksum_type_t cksum_type) + struct brw_page **pga, int opc, + cksum_type_t cksum_type) { - __u32 cksum; - int i = 0; - struct cfs_crypto_hash_desc *hdesc; - unsigned int bufsize; - int err; - unsigned char cfs_alg = cksum_obd2cfs(cksum_type); + __u32 cksum; + int i = 0; + struct cfs_crypto_hash_desc *hdesc; + unsigned int bufsize; + int err; + unsigned char cfs_alg = cksum_obd2cfs(cksum_type); LASSERT(pg_count > 0); @@ -1250,14 +1250,14 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, struct obd_capa *ocapa, int reserve, int resend) { - struct ptlrpc_request *req; + struct ptlrpc_request *req; struct ptlrpc_bulk_desc *desc; - struct ost_body *body; - struct obd_ioobj *ioobj; - struct niobuf_remote *niobuf; + struct ost_body *body; + struct obd_ioobj *ioobj; + struct niobuf_remote *niobuf; int niocount, i, requested_nob, opc, rc; struct osc_brw_async_args *aa; - struct req_capsule *pill; + struct req_capsule *pill; struct brw_page *pg_prev; if (OBD_FAIL_CHECK(OBD_FAIL_OSC_BRW_PREP_REQ)) @@ -1359,8 +1359,8 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, niobuf->len += pg->count; } else { niobuf->offset = pg->off; - niobuf->len = pg->count; - niobuf->flags = pg->flag; + niobuf->len = pg->count; + niobuf->flags = pg->flag; } pg_prev = pg; } @@ -1581,9 +1581,9 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) if (body->oa.o_valid & OBD_MD_FLCKSUM) { static int cksum_counter; - __u32 server_cksum = body->oa.o_cksum; - char *via; - char *router; + __u32 server_cksum = body->oa.o_cksum; + char *via; + char *router; cksum_type_t cksum_type; cksum_type = cksum_type_unpack(body->oa.o_valid &OBD_MD_FLFLAGS? @@ -1758,7 +1758,7 @@ static int brw_interpret(const struct lu_env *env, struct osc_brw_async_args *aa = data; struct osc_extent *ext; struct osc_extent *tmp; - struct cl_object *obj = NULL; + struct cl_object *obj = NULL; struct client_obd *cli = aa->aa_cli; rc = osc_brw_fini_request(req, rc); @@ -1862,26 +1862,25 @@ static int brw_interpret(const struct lu_env *env, int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, struct list_head *ext_list, int cmd, pdl_policy_t pol) { - struct ptlrpc_request *req = NULL; - struct osc_extent *ext; - struct brw_page **pga = NULL; - struct osc_brw_async_args *aa = NULL; - struct obdo *oa = NULL; - struct osc_async_page *oap; - struct osc_async_page *tmp; - struct cl_req *clerq = NULL; - enum cl_req_type crt = (cmd & OBD_BRW_WRITE) ? CRT_WRITE : - CRT_READ; - struct ldlm_lock *lock = NULL; - struct cl_req_attr *crattr = NULL; - u64 starting_offset = OBD_OBJECT_EOF; - u64 ending_offset = 0; - int mpflag = 0; - int mem_tight = 0; - int page_count = 0; - int i; - int rc; - struct ost_body *body; + struct ptlrpc_request *req = NULL; + struct osc_extent *ext; + struct brw_page **pga = NULL; + struct osc_brw_async_args *aa = NULL; + struct obdo *oa = NULL; + struct osc_async_page *oap; + struct osc_async_page *tmp; + struct cl_req *clerq = NULL; + enum cl_req_type crt = (cmd & OBD_BRW_WRITE) ? CRT_WRITE : CRT_READ; + struct ldlm_lock *lock = NULL; + struct cl_req_attr *crattr = NULL; + u64 starting_offset = OBD_OBJECT_EOF; + u64 ending_offset = 0; + int mpflag = 0; + int mem_tight = 0; + int page_count = 0; + int i; + int rc; + struct ost_body *body; LIST_HEAD(rpc_list); LASSERT(!list_empty(ext_list)); @@ -2480,10 +2479,10 @@ static int osc_statfs_async(struct obd_export *exp, struct obd_info *oinfo, __u64 max_age, struct ptlrpc_request_set *rqset) { - struct obd_device *obd = class_exp2obd(exp); + struct obd_device *obd = class_exp2obd(exp); struct ptlrpc_request *req; struct osc_async_args *aa; - int rc; + int rc; /* We could possibly pass max_age in the request (as an absolute * timestamp or a "seconds.usec ago") so the target can avoid doing @@ -2522,10 +2521,10 @@ static int osc_statfs_async(struct obd_export *exp, static int osc_statfs(const struct lu_env *env, struct obd_export *exp, struct obd_statfs *osfs, __u64 max_age, __u32 flags) { - struct obd_device *obd = class_exp2obd(exp); - struct obd_statfs *msfs; + struct obd_device *obd = class_exp2obd(exp); + struct obd_statfs *msfs; struct ptlrpc_request *req; - struct obd_import *imp = NULL; + struct obd_import *imp = NULL; int rc; /*Since the request might also come from lprocfs, so we need @@ -2749,9 +2748,9 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, return 0; } else if (KEY_IS(KEY_LAST_ID)) { struct ptlrpc_request *req; - u64 *reply; - char *tmp; - int rc; + u64 *reply; + char *tmp; + int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GET_INFO_LAST_ID); @@ -2788,14 +2787,14 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, } else if (KEY_IS(KEY_FIEMAP)) { struct ll_fiemap_info_key *fm_key = (struct ll_fiemap_info_key *)key; - struct ldlm_res_id res_id; - ldlm_policy_data_t policy; - struct lustre_handle lockh; - ldlm_mode_t mode = 0; - struct ptlrpc_request *req; - struct ll_user_fiemap *reply; - char *tmp; - int rc; + struct ldlm_res_id res_id; + ldlm_policy_data_t policy; + struct lustre_handle lockh; + ldlm_mode_t mode = 0; + struct ptlrpc_request *req; + struct ll_user_fiemap *reply; + char *tmp; + int rc; if (!(fm_key->fiemap.fm_flags & FIEMAP_FLAG_SYNC)) goto skip_locking; @@ -2881,10 +2880,10 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, void *val, struct ptlrpc_request_set *set) { struct ptlrpc_request *req; - struct obd_device *obd = exp->exp_obd; - struct obd_import *imp = class_exp2cliimp(exp); - char *tmp; - int rc; + struct obd_device *obd = exp->exp_obd; + struct obd_import *imp = class_exp2cliimp(exp); + char *tmp; + int rc; OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_SHUTDOWN, 10); @@ -3071,8 +3070,8 @@ static int osc_import_event(struct obd_device *obd, } case IMP_EVENT_INVALIDATE: { struct ldlm_namespace *ns = obd->obd_namespace; - struct lu_env *env; - int refcheck; + struct lu_env *env; + int refcheck; env = cl_env_get(&refcheck); if (!IS_ERR(env)) { @@ -3159,9 +3158,9 @@ static int brw_queue_work(const struct lu_env *env, void *data) int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { struct lprocfs_static_vars lvars = { NULL }; - struct client_obd *cli = &obd->u.cli; - void *handler; - int rc; + struct client_obd *cli = &obd->u.cli; + void *handler; + int rc; rc = ptlrpcd_addref(); if (rc) From d0bfef31f4d40888683e801dfd3f7448078d7e2b Mon Sep 17 00:00:00 2001 From: Chris Hanna Date: Wed, 3 Jun 2015 10:28:26 -0400 Subject: [PATCH 0806/1163] staging: lustre: ptlrpc: clean up whitespace and align function params Minor changes to remove excessive whitespace and improve readability of ptlrpc functions. Signed-off-by: Chris Hanna Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/client.c | 90 +++---- drivers/staging/lustre/lustre/ptlrpc/events.c | 60 ++--- drivers/staging/lustre/lustre/ptlrpc/import.c | 8 +- drivers/staging/lustre/lustre/ptlrpc/layout.c | 70 +++--- .../lustre/lustre/ptlrpc/llog_client.c | 82 +++--- .../lustre/lustre/ptlrpc/lproc_ptlrpc.c | 104 ++++---- drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 62 ++--- drivers/staging/lustre/lustre/ptlrpc/nrs.c | 146 +++++------ .../staging/lustre/lustre/ptlrpc/nrs_fifo.c | 4 +- .../lustre/lustre/ptlrpc/pack_generic.c | 18 +- drivers/staging/lustre/lustre/ptlrpc/pinger.c | 4 +- .../staging/lustre/lustre/ptlrpc/ptlrpcd.c | 6 +- drivers/staging/lustre/lustre/ptlrpc/sec.c | 96 +++---- .../staging/lustre/lustre/ptlrpc/sec_bulk.c | 48 ++-- .../staging/lustre/lustre/ptlrpc/sec_config.c | 60 ++--- drivers/staging/lustre/lustre/ptlrpc/sec_gc.c | 2 +- .../staging/lustre/lustre/ptlrpc/sec_lproc.c | 4 +- .../staging/lustre/lustre/ptlrpc/sec_null.c | 8 +- .../staging/lustre/lustre/ptlrpc/sec_plain.c | 78 +++--- .../staging/lustre/lustre/ptlrpc/service.c | 238 +++++++++--------- 20 files changed, 594 insertions(+), 594 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 347110e6e822..35ebe0f35bd1 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -57,8 +57,8 @@ void ptlrpc_init_client(int req_portal, int rep_portal, char *name, struct ptlrpc_client *cl) { cl->cli_request_portal = req_portal; - cl->cli_reply_portal = rep_portal; - cl->cli_name = name; + cl->cli_reply_portal = rep_portal; + cl->cli_name = name; } EXPORT_SYMBOL(ptlrpc_init_client); @@ -68,9 +68,9 @@ EXPORT_SYMBOL(ptlrpc_init_client); struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid) { struct ptlrpc_connection *c; - lnet_nid_t self; - lnet_process_id_t peer; - int err; + lnet_nid_t self; + lnet_process_id_t peer; + int err; /* ptlrpc_uuid_to_peer() initializes its 2nd parameter * before accessing its values. */ @@ -148,7 +148,7 @@ struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp(struct ptlrpc_request *req, desc->bd_import = class_import_get(imp); desc->bd_req = req; - desc->bd_cbid.cbid_fn = client_bulk_callback; + desc->bd_cbid.cbid_fn = client_bulk_callback; desc->bd_cbid.cbid_arg = desc; /* This makes req own desc, and free it when she frees herself */ @@ -343,8 +343,8 @@ static int unpack_reply(struct ptlrpc_request *req) static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req) { struct ptlrpc_request *early_req; - time_t olddl; - int rc; + time_t olddl; + int rc; req->rq_early = 0; spin_unlock(&req->rq_lock); @@ -580,8 +580,8 @@ static int __ptlrpc_request_bufs_pack(struct ptlrpc_request *request, int count, __u32 *lengths, char **bufs, struct ptlrpc_cli_ctx *ctx) { - struct obd_import *imp = request->rq_import; - int rc; + struct obd_import *imp = request->rq_import; + int rc; if (unlikely(ctx)) request->rq_cli_ctx = sptlrpc_cli_ctx_get(ctx); @@ -605,10 +605,10 @@ static int __ptlrpc_request_bufs_pack(struct ptlrpc_request *request, request->rq_type = PTL_RPC_MSG_REQUEST; request->rq_export = NULL; - request->rq_req_cbid.cbid_fn = request_out_callback; + request->rq_req_cbid.cbid_fn = request_out_callback; request->rq_req_cbid.cbid_arg = request; - request->rq_reply_cbid.cbid_fn = reply_in_callback; + request->rq_reply_cbid.cbid_fn = reply_in_callback; request->rq_reply_cbid.cbid_arg = request; request->rq_reply_deadline = 0; @@ -761,8 +761,8 @@ EXPORT_SYMBOL(ptlrpc_request_alloc); * initialize its buffer structure according to capsule template \a format. */ struct ptlrpc_request *ptlrpc_request_alloc_pool(struct obd_import *imp, - struct ptlrpc_request_pool *pool, - const struct req_format *format) + struct ptlrpc_request_pool *pool, + const struct req_format *format) { return ptlrpc_request_alloc_internal(imp, pool, format); } @@ -789,11 +789,11 @@ EXPORT_SYMBOL(ptlrpc_request_free); * Returns allocated request or NULL on error. */ struct ptlrpc_request *ptlrpc_request_alloc_pack(struct obd_import *imp, - const struct req_format *format, - __u32 version, int opcode) + const struct req_format *format, + __u32 version, int opcode) { struct ptlrpc_request *req = ptlrpc_request_alloc(imp, format); - int rc; + int rc; if (req) { rc = ptlrpc_request_pack(req, version, opcode); @@ -820,7 +820,7 @@ ptlrpc_prep_req_pool(struct obd_import *imp, struct ptlrpc_request_pool *pool) { struct ptlrpc_request *request; - int rc; + int rc; request = __ptlrpc_request_alloc(imp, pool); if (!request) @@ -868,9 +868,9 @@ struct ptlrpc_request_set *ptlrpc_prep_set(void) INIT_LIST_HEAD(&set->set_new_requests); INIT_LIST_HEAD(&set->set_cblist); set->set_max_inflight = UINT_MAX; - set->set_producer = NULL; + set->set_producer = NULL; set->set_producer_arg = NULL; - set->set_rc = 0; + set->set_rc = 0; return set; } @@ -894,9 +894,9 @@ struct ptlrpc_request_set *ptlrpc_prep_fcset(int max, set_producer_func func, if (!set) return NULL; - set->set_max_inflight = max; - set->set_producer = func; - set->set_producer_arg = arg; + set->set_max_inflight = max; + set->set_producer = func; + set->set_producer_arg = arg; return set; } @@ -912,10 +912,10 @@ EXPORT_SYMBOL(ptlrpc_prep_fcset); */ void ptlrpc_set_destroy(struct ptlrpc_request_set *set) { - struct list_head *tmp; - struct list_head *next; - int expected_phase; - int n = 0; + struct list_head *tmp; + struct list_head *next; + int expected_phase; + int n = 0; /* Requests on the set should either all be completed, or all be new */ expected_phase = (atomic_read(&set->set_remaining) == 0) ? @@ -1013,7 +1013,7 @@ EXPORT_SYMBOL(ptlrpc_set_add_req); * Currently only used for ptlrpcd. */ void ptlrpc_set_add_new_req(struct ptlrpcd_ctl *pc, - struct ptlrpc_request *req) + struct ptlrpc_request *req) { struct ptlrpc_request_set *set = pc->pc_set; int count, i; @@ -1400,7 +1400,7 @@ static int after_reply(struct ptlrpc_request *req) */ static int ptlrpc_send_new_req(struct ptlrpc_request *req) { - struct obd_import *imp = req->rq_import; + struct obd_import *imp = req->rq_import; int rc; LASSERT(req->rq_phase == RQ_PHASE_NEW); @@ -1669,7 +1669,7 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) continue; } - if (status != 0) { + if (status != 0) { req->rq_status = status; ptlrpc_rqphase_move(req, RQ_PHASE_INTERPRET); @@ -1969,8 +1969,8 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink) int ptlrpc_expired_set(void *data) { struct ptlrpc_request_set *set = data; - struct list_head *tmp; - time_t now = get_seconds(); + struct list_head *tmp; + time_t now = get_seconds(); LASSERT(set != NULL); @@ -2052,11 +2052,11 @@ EXPORT_SYMBOL(ptlrpc_interrupted_set); */ int ptlrpc_set_next_timeout(struct ptlrpc_request_set *set) { - struct list_head *tmp; - time_t now = get_seconds(); - int timeout = 0; + struct list_head *tmp; + time_t now = get_seconds(); + int timeout = 0; struct ptlrpc_request *req; - int deadline; + int deadline; list_for_each(tmp, &set->set_requests) { req = list_entry(tmp, struct ptlrpc_request, rq_set_chain); @@ -2105,10 +2105,10 @@ EXPORT_SYMBOL(ptlrpc_set_next_timeout); */ int ptlrpc_set_wait(struct ptlrpc_request_set *set) { - struct list_head *tmp; + struct list_head *tmp; struct ptlrpc_request *req; - struct l_wait_info lwi; - int rc, timeout; + struct l_wait_info lwi; + int rc, timeout; if (set->set_producer) (void)ptlrpc_set_producer(set); @@ -2353,8 +2353,8 @@ EXPORT_SYMBOL(ptlrpc_req_xid); */ int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async) { - int rc; - wait_queue_head_t *wq; + int rc; + wait_queue_head_t *wq; struct l_wait_info lwi; /* @@ -2471,7 +2471,7 @@ void ptlrpc_free_committed(struct obd_import *imp) { struct ptlrpc_request *req, *saved; struct ptlrpc_request *last_req = NULL; /* temporary fire escape */ - bool skip_committed_list = true; + bool skip_committed_list = true; LASSERT(imp != NULL); assert_spin_locked(&imp->imp_lock); @@ -3023,8 +3023,8 @@ EXPORT_SYMBOL(ptlrpc_sample_next_xid); * have delay before it really runs by ptlrpcd thread. */ struct ptlrpc_work_async_args { - int (*cb)(const struct lu_env *, void *); - void *cbdata; + int (*cb)(const struct lu_env *, void *); + void *cbdata; }; static void ptlrpcd_add_work_req(struct ptlrpc_request *req) @@ -3113,7 +3113,7 @@ void *ptlrpcd_alloc_work(struct obd_import *imp, CLASSERT(sizeof(*args) <= sizeof(req->rq_async_args)); args = ptlrpc_req_async_args(req); - args->cb = cb; + args->cb = cb; args->cbdata = cbdata; return req; diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index 7f8644e01112..8cb1929fd31d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -53,7 +53,7 @@ lnet_handle_eq_t ptlrpc_eq_h; */ void request_out_callback(lnet_event_t *ev) { - struct ptlrpc_cb_id *cbid = ev->md.user_ptr; + struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_request *req = cbid->cbid_arg; LASSERT(ev->type == LNET_EVENT_SEND || @@ -86,7 +86,7 @@ void request_out_callback(lnet_event_t *ev) */ void reply_in_callback(lnet_event_t *ev) { - struct ptlrpc_cb_id *cbid = ev->md.user_ptr; + struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_request *req = cbid->cbid_arg; DEBUG_REQ(D_NET, req, "type %d, status %d", ev->type, ev->status); @@ -172,9 +172,9 @@ out_wake: */ void client_bulk_callback(lnet_event_t *ev) { - struct ptlrpc_cb_id *cbid = ev->md.user_ptr; + struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_bulk_desc *desc = cbid->cbid_arg; - struct ptlrpc_request *req; + struct ptlrpc_request *req; LASSERT((desc->bd_type == BULK_PUT_SINK && ev->type == LNET_EVENT_PUT) || @@ -245,9 +245,9 @@ void client_bulk_callback(lnet_event_t *ev) static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt, struct ptlrpc_request *req) { - __u64 sec = req->rq_arrival_time.tv_sec; - __u32 usec = req->rq_arrival_time.tv_usec >> 4; /* usec / 16 */ - __u64 new_seq; + __u64 sec = req->rq_arrival_time.tv_sec; + __u32 usec = req->rq_arrival_time.tv_usec >> 4; /* usec / 16 */ + __u64 new_seq; /* set sequence ID for request and add it to history list, * it must be called with hold svcpt::scp_lock */ @@ -281,11 +281,11 @@ static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt, */ void request_in_callback(lnet_event_t *ev) { - struct ptlrpc_cb_id *cbid = ev->md.user_ptr; + struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_request_buffer_desc *rqbd = cbid->cbid_arg; - struct ptlrpc_service_part *svcpt = rqbd->rqbd_svcpt; - struct ptlrpc_service *service = svcpt->scp_service; - struct ptlrpc_request *req; + struct ptlrpc_service_part *svcpt = rqbd->rqbd_svcpt; + struct ptlrpc_service *service = svcpt->scp_service; + struct ptlrpc_request *req; LASSERT(ev->type == LNET_EVENT_PUT || ev->type == LNET_EVENT_UNLINK); @@ -380,7 +380,7 @@ void request_in_callback(lnet_event_t *ev) */ void reply_out_callback(lnet_event_t *ev) { - struct ptlrpc_cb_id *cbid = ev->md.user_ptr; + struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_reply_state *rs = cbid->cbid_arg; struct ptlrpc_service_part *svcpt = rs->rs_svcpt; @@ -433,17 +433,17 @@ static void ptlrpc_master_callback(lnet_event_t *ev) } int ptlrpc_uuid_to_peer(struct obd_uuid *uuid, - lnet_process_id_t *peer, lnet_nid_t *self) + lnet_process_id_t *peer, lnet_nid_t *self) { - int best_dist = 0; - __u32 best_order = 0; - int count = 0; - int rc = -ENOENT; - int portals_compatibility; - int dist; - __u32 order; - lnet_nid_t dst_nid; - lnet_nid_t src_nid; + int best_dist = 0; + __u32 best_order = 0; + int count = 0; + int rc = -ENOENT; + int portals_compatibility; + int dist; + __u32 order; + lnet_nid_t dst_nid; + lnet_nid_t src_nid; portals_compatibility = LNetCtl(IOC_LIBCFS_PORTALS_COMPATIBILITY, NULL); @@ -487,10 +487,10 @@ int ptlrpc_uuid_to_peer(struct obd_uuid *uuid, void ptlrpc_ni_fini(void) { - wait_queue_head_t waitq; - struct l_wait_info lwi; - int rc; - int retries; + wait_queue_head_t waitq; + struct l_wait_info lwi; + int rc; + int retries; /* Wait for the event queue to become idle since there may still be * messages in flight with pending events (i.e. the fire-and-forget @@ -523,7 +523,7 @@ void ptlrpc_ni_fini(void) lnet_pid_t ptl_get_pid(void) { - lnet_pid_t pid; + lnet_pid_t pid; pid = LUSTRE_SRV_LNET_PID; return pid; @@ -531,8 +531,8 @@ lnet_pid_t ptl_get_pid(void) int ptlrpc_ni_init(void) { - int rc; - lnet_pid_t pid; + int rc; + lnet_pid_t pid; pid = ptl_get_pid(); CDEBUG(D_NET, "My pid is: %x\n", pid); @@ -563,7 +563,7 @@ int ptlrpc_ni_init(void) int ptlrpc_init_portals(void) { - int rc = ptlrpc_ni_init(); + int rc = ptlrpc_ni_init(); if (rc != 0) { CERROR("network initialisation failed\n"); diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index d5fc689c008b..c9b8481dd384 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -119,7 +119,7 @@ int ptlrpc_init_import(struct obd_import *imp) spin_lock(&imp->imp_lock); imp->imp_generation++; - imp->imp_state = LUSTRE_IMP_NEW; + imp->imp_state = LUSTRE_IMP_NEW; spin_unlock(&imp->imp_lock); @@ -369,7 +369,7 @@ void ptlrpc_invalidate_import(struct obd_import *imp) imp_unregistering)); } spin_unlock(&imp->imp_lock); - } + } } while (rc != 0); /* @@ -559,7 +559,7 @@ static int import_select_connection(struct obd_import *imp) ptlrpc_connection_put(imp->imp_connection); imp->imp_connection = ptlrpc_connection_addref(imp_conn->oic_conn); - dlmexp = class_conn2export(&imp->imp_dlm_handle); + dlmexp = class_conn2export(&imp->imp_dlm_handle); LASSERT(dlmexp != NULL); if (dlmexp->exp_connection) ptlrpc_connection_put(dlmexp->exp_connection); @@ -1490,7 +1490,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose) INITIAL_CONNECT_TIMEOUT); IMPORT_SET_STATE(imp, LUSTRE_IMP_CONNECTING); - req->rq_send_state = LUSTRE_IMP_CONNECTING; + req->rq_send_state = LUSTRE_IMP_CONNECTING; ptlrpc_request_set_replen(req); rc = ptlrpc_queue_wait(req); ptlrpc_req_finished(req); diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c index a42335e26de9..d14c20008850 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c +++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c @@ -807,11 +807,11 @@ struct req_capsule; /* * Request fields. */ -#define DEFINE_MSGF(name, flags, size, swabber, dumper) { \ - .rmf_name = (name), \ - .rmf_flags = (flags), \ - .rmf_size = (size), \ - .rmf_swabber = (void (*)(void *))(swabber), \ +#define DEFINE_MSGF(name, flags, size, swabber, dumper) { \ + .rmf_name = (name), \ + .rmf_flags = (flags), \ + .rmf_size = (size), \ + .rmf_swabber = (void (*)(void *))(swabber), \ .rmf_dumper = (void (*)(void *))(dumper) \ } @@ -1164,25 +1164,25 @@ EXPORT_SYMBOL(RMF_SWAP_LAYOUTS); struct req_format { const char *rf_name; - int rf_idx; + int rf_idx; struct { - int nr; + int nr; const struct req_msg_field **d; } rf_fields[RCL_NR]; }; -#define DEFINE_REQ_FMT(name, client, client_nr, server, server_nr) { \ - .rf_name = name, \ - .rf_fields = { \ +#define DEFINE_REQ_FMT(name, client, client_nr, server, server_nr) { \ + .rf_name = name, \ + .rf_fields = { \ [RCL_CLIENT] = { \ .nr = client_nr, \ - .d = client \ - }, \ + .d = client \ + }, \ [RCL_SERVER] = { \ .nr = server_nr, \ - .d = server \ - } \ - } \ + .d = server \ + } \ + } \ } #define DEFINE_REQ_FMT0(name, client, server) \ @@ -1769,10 +1769,10 @@ EXPORT_SYMBOL(req_capsule_set); * field of a \a pill's \a rc_fmt's RMF's. */ int req_capsule_filled_sizes(struct req_capsule *pill, - enum req_location loc) + enum req_location loc) { const struct req_format *fmt = pill->rc_fmt; - int i; + int i; LASSERT(fmt != NULL); @@ -1806,8 +1806,8 @@ EXPORT_SYMBOL(req_capsule_filled_sizes); int req_capsule_server_pack(struct req_capsule *pill) { const struct req_format *fmt; - int count; - int rc; + int count; + int rc; LASSERT(pill->rc_loc == RCL_SERVER); fmt = pill->rc_fmt; @@ -1857,11 +1857,11 @@ swabber_dumper_helper(struct req_capsule *pill, int offset, void *value, int len, int dump, void (*swabber)(void *)) { - void *p; - int i; - int n; - int do_swab; - int inout = loc == RCL_CLIENT; + void *p; + int i; + int n; + int do_swab; + int inout = loc == RCL_CLIENT; swabber = swabber ?: field->rmf_swabber; @@ -1936,10 +1936,10 @@ static void *__req_capsule_get(struct req_capsule *pill, int dump) { const struct req_format *fmt; - struct lustre_msg *msg; - void *value; - int len; - int offset; + struct lustre_msg *msg; + void *value; + int len; + int offset; void *(*getter)(struct lustre_msg *m, int n, int minlen); @@ -2000,10 +2000,10 @@ static void *__req_capsule_get(struct req_capsule *pill, */ static void __req_capsule_dump(struct req_capsule *pill, enum req_location loc) { - const struct req_format *fmt; - const struct req_msg_field *field; - int len; - int i; + const struct req_format *fmt; + const struct req_msg_field *field; + int len; + int i; fmt = pill->rc_fmt; @@ -2350,9 +2350,9 @@ void req_capsule_shrink(struct req_capsule *pill, enum req_location loc) { const struct req_format *fmt; - struct lustre_msg *msg; - int len; - int offset; + struct lustre_msg *msg; + int len; + int offset; fmt = pill->rc_fmt; LASSERT(fmt != NULL); diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c index e9baf5bbee3a..1c701e0a0bc7 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c @@ -49,29 +49,29 @@ #include "../include/lustre_net.h" #include -#define LLOG_CLIENT_ENTRY(ctxt, imp) do { \ - mutex_lock(&ctxt->loc_mutex); \ - if (ctxt->loc_imp) { \ - imp = class_import_get(ctxt->loc_imp); \ - } else { \ - CERROR("ctxt->loc_imp == NULL for context idx %d." \ - "Unable to complete MDS/OSS recovery," \ - "but I'll try again next time. Not fatal.\n", \ - ctxt->loc_idx); \ - imp = NULL; \ - mutex_unlock(&ctxt->loc_mutex); \ - return (-EINVAL); \ - } \ - mutex_unlock(&ctxt->loc_mutex); \ +#define LLOG_CLIENT_ENTRY(ctxt, imp) do { \ + mutex_lock(&ctxt->loc_mutex); \ + if (ctxt->loc_imp) { \ + imp = class_import_get(ctxt->loc_imp); \ + } else { \ + CERROR("ctxt->loc_imp == NULL for context idx %d." \ + "Unable to complete MDS/OSS recovery," \ + "but I'll try again next time. Not fatal.\n", \ + ctxt->loc_idx); \ + imp = NULL; \ + mutex_unlock(&ctxt->loc_mutex); \ + return (-EINVAL); \ + } \ + mutex_unlock(&ctxt->loc_mutex); \ } while (0) -#define LLOG_CLIENT_EXIT(ctxt, imp) do { \ - mutex_lock(&ctxt->loc_mutex); \ - if (ctxt->loc_imp != imp) \ - CWARN("loc_imp has changed from %p to %p\n", \ - ctxt->loc_imp, imp); \ - class_import_put(imp); \ - mutex_unlock(&ctxt->loc_mutex); \ +#define LLOG_CLIENT_EXIT(ctxt, imp) do { \ + mutex_lock(&ctxt->loc_mutex); \ + if (ctxt->loc_imp != imp) \ + CWARN("loc_imp has changed from %p to %p\n", \ + ctxt->loc_imp, imp); \ + class_import_put(imp); \ + mutex_unlock(&ctxt->loc_mutex); \ } while (0) /* This is a callback from the llog_* functions. @@ -80,11 +80,11 @@ static int llog_client_open(const struct lu_env *env, struct llog_handle *lgh, struct llog_logid *logid, char *name, enum llog_open_param open_param) { - struct obd_import *imp; - struct llogd_body *body; - struct llog_ctxt *ctxt = lgh->lgh_ctxt; + struct obd_import *imp; + struct llogd_body *body; + struct llog_ctxt *ctxt = lgh->lgh_ctxt; struct ptlrpc_request *req = NULL; - int rc; + int rc; LLOG_CLIENT_ENTRY(ctxt, imp); @@ -145,10 +145,10 @@ out: static int llog_client_destroy(const struct lu_env *env, struct llog_handle *loghandle) { - struct obd_import *imp; + struct obd_import *imp; struct ptlrpc_request *req = NULL; - struct llogd_body *body; - int rc; + struct llogd_body *body; + int rc; LLOG_CLIENT_ENTRY(loghandle->lgh_ctxt, imp); req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_DESTROY, @@ -182,11 +182,11 @@ static int llog_client_next_block(const struct lu_env *env, int *cur_idx, int next_idx, __u64 *cur_offset, void *buf, int len) { - struct obd_import *imp; + struct obd_import *imp; struct ptlrpc_request *req = NULL; - struct llogd_body *body; - void *ptr; - int rc; + struct llogd_body *body; + void *ptr; + int rc; LLOG_CLIENT_ENTRY(loghandle->lgh_ctxt, imp); req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_NEXT_BLOCK, @@ -240,11 +240,11 @@ static int llog_client_prev_block(const struct lu_env *env, struct llog_handle *loghandle, int prev_idx, void *buf, int len) { - struct obd_import *imp; + struct obd_import *imp; struct ptlrpc_request *req = NULL; - struct llogd_body *body; - void *ptr; - int rc; + struct llogd_body *body; + void *ptr; + int rc; LLOG_CLIENT_ENTRY(loghandle->lgh_ctxt, imp); req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_PREV_BLOCK, @@ -292,12 +292,12 @@ err_exit: static int llog_client_read_header(const struct lu_env *env, struct llog_handle *handle) { - struct obd_import *imp; + struct obd_import *imp; struct ptlrpc_request *req = NULL; - struct llogd_body *body; - struct llog_log_hdr *hdr; - struct llog_rec_hdr *llh_hdr; - int rc; + struct llogd_body *body; + struct llog_log_hdr *hdr; + struct llog_rec_hdr *llh_hdr; + int rc; LLOG_CLIENT_ENTRY(handle->lgh_ctxt, imp); req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_READ_HEADER, diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 1362160983a9..c04ae50c2c29 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -261,8 +261,8 @@ ptlrpc_lprocfs_req_history_len_seq_show(struct seq_file *m, void *v) { struct ptlrpc_service *svc = m->private; struct ptlrpc_service_part *svcpt; - int total = 0; - int i; + int total = 0; + int i; ptlrpc_service_for_each_part(svcpt, i, svc) total += svcpt->scp_hist_nrqbds; @@ -277,8 +277,8 @@ ptlrpc_lprocfs_req_history_max_seq_show(struct seq_file *m, void *n) { struct ptlrpc_service *svc = m->private; struct ptlrpc_service_part *svcpt; - int total = 0; - int i; + int total = 0; + int i; ptlrpc_service_for_each_part(svcpt, i, svc) total += svc->srv_hist_nrqbds_cpt_max; @@ -289,13 +289,13 @@ ptlrpc_lprocfs_req_history_max_seq_show(struct seq_file *m, void *n) static ssize_t ptlrpc_lprocfs_req_history_max_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) + const char __user *buffer, + size_t count, loff_t *off) { struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private; - int bufpages; - int val; - int rc; + int bufpages; + int val; + int rc; rc = lprocfs_write_helper(buffer, count, &val); if (rc < 0) @@ -478,17 +478,17 @@ void nrs_policy_get_info_locked(struct ptlrpc_nrs_policy *policy, */ static int ptlrpc_lprocfs_nrs_seq_show(struct seq_file *m, void *n) { - struct ptlrpc_service *svc = m->private; - struct ptlrpc_service_part *svcpt; - struct ptlrpc_nrs *nrs; - struct ptlrpc_nrs_policy *policy; - struct ptlrpc_nrs_pol_info *infos; - struct ptlrpc_nrs_pol_info tmp; - unsigned num_pols; - unsigned pol_idx = 0; - bool hp = false; - int i; - int rc = 0; + struct ptlrpc_service *svc = m->private; + struct ptlrpc_service_part *svcpt; + struct ptlrpc_nrs *nrs; + struct ptlrpc_nrs_policy *policy; + struct ptlrpc_nrs_pol_info *infos; + struct ptlrpc_nrs_pol_info tmp; + unsigned num_pols; + unsigned pol_idx = 0; + bool hp = false; + int i; + int rc = 0; /** * Serialize NRS core lprocfs operations with policy registration/ @@ -638,15 +638,15 @@ unlock: * regular and high-priority (if the service has one) NRS head. */ static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) + const char __user *buffer, + size_t count, loff_t *off) { struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private; - enum ptlrpc_nrs_queue_type queue = PTLRPC_NRS_QUEUE_BOTH; - char *cmd; - char *cmd_copy = NULL; - char *token; - int rc = 0; + enum ptlrpc_nrs_queue_type queue = PTLRPC_NRS_QUEUE_BOTH; + char *cmd; + char *cmd_copy = NULL; + char *token; + int rc = 0; if (count >= LPROCFS_NRS_WR_MAX_CMD) return -EINVAL; @@ -729,8 +729,8 @@ ptlrpc_lprocfs_svc_req_history_seek(struct ptlrpc_service_part *svcpt, struct ptlrpc_srh_iterator *srhi, __u64 seq) { - struct list_head *e; - struct ptlrpc_request *req; + struct list_head *e; + struct ptlrpc_request *req; if (srhi->srhi_req != NULL && srhi->srhi_seq > svcpt->scp_hist_seq_culled && @@ -860,12 +860,12 @@ static void * ptlrpc_lprocfs_svc_req_history_next(struct seq_file *s, void *iter, loff_t *pos) { - struct ptlrpc_service *svc = s->private; - struct ptlrpc_srh_iterator *srhi = iter; - struct ptlrpc_service_part *svcpt; - __u64 seq; - int rc; - int i; + struct ptlrpc_service *svc = s->private; + struct ptlrpc_srh_iterator *srhi = iter; + struct ptlrpc_service_part *svcpt; + __u64 seq; + int rc; + int i; for (i = srhi->srhi_idx; i < svc->srv_ncpts; i++) { svcpt = svc->srv_parts[i]; @@ -923,11 +923,11 @@ EXPORT_SYMBOL(target_print_req); static int ptlrpc_lprocfs_svc_req_history_show(struct seq_file *s, void *iter) { - struct ptlrpc_service *svc = s->private; - struct ptlrpc_srh_iterator *srhi = iter; - struct ptlrpc_service_part *svcpt; - struct ptlrpc_request *req; - int rc; + struct ptlrpc_service *svc = s->private; + struct ptlrpc_srh_iterator *srhi = iter; + struct ptlrpc_service_part *svcpt; + struct ptlrpc_request *req; + int rc; LASSERT(srhi->srhi_idx < svc->srv_ncpts); @@ -972,8 +972,8 @@ ptlrpc_lprocfs_svc_req_history_open(struct inode *inode, struct file *file) .next = ptlrpc_lprocfs_svc_req_history_next, .show = ptlrpc_lprocfs_svc_req_history_show, }; - struct seq_file *seqf; - int rc; + struct seq_file *seqf; + int rc; rc = seq_open(file, &sops); if (rc) @@ -987,13 +987,13 @@ ptlrpc_lprocfs_svc_req_history_open(struct inode *inode, struct file *file) /* See also lprocfs_rd_timeouts */ static int ptlrpc_lprocfs_timeouts_seq_show(struct seq_file *m, void *n) { - struct ptlrpc_service *svc = m->private; - struct ptlrpc_service_part *svcpt; - struct dhms ts; - time_t worstt; - unsigned int cur; - unsigned int worst; - int i; + struct ptlrpc_service *svc = m->private; + struct ptlrpc_service_part *svcpt; + struct dhms ts; + time_t worstt; + unsigned int cur; + unsigned int worst; + int i; if (AT_OFF) { seq_printf(m, "adaptive timeouts off, using obd_timeout %u\n", @@ -1215,8 +1215,8 @@ int lprocfs_wr_evict_client(struct file *file, const char __user *buffer, size_t count, loff_t *off) { struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - char *kbuf; - char *tmpbuf; + char *kbuf; + char *tmpbuf; kbuf = kzalloc(BUFLEN, GFP_NOFS); if (kbuf == NULL) @@ -1264,7 +1264,7 @@ int lprocfs_wr_ping(struct file *file, const char __user *buffer, { struct obd_device *obd = ((struct seq_file *)file->private_data)->private; struct ptlrpc_request *req; - int rc; + int rc; LPROCFS_CLIMP_CHECK(obd); req = ptlrpc_prep_ping(obd->u.cli.cl_import); diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index 2fa2585584a3..92c746b44462 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -52,17 +52,17 @@ static int ptl_send_buf(lnet_handle_md_t *mdh, void *base, int len, struct ptlrpc_connection *conn, int portal, __u64 xid, unsigned int offset) { - int rc; - lnet_md_t md; + int rc; + lnet_md_t md; LASSERT(portal != 0); LASSERT(conn != NULL); CDEBUG(D_INFO, "conn=%p id %s\n", conn, libcfs_id2str(conn->c_peer)); - md.start = base; - md.length = len; + md.start = base; + md.length = len; md.threshold = (ack == LNET_ACK_REQ) ? 2 : 1; - md.options = PTLRPC_MD_OPTIONS; - md.user_ptr = cbid; + md.options = PTLRPC_MD_OPTIONS; + md.user_ptr = cbid; md.eq_handle = ptlrpc_eq_h; if (unlikely(ack == LNET_ACK_REQ && @@ -120,8 +120,8 @@ int ptlrpc_register_bulk(struct ptlrpc_request *req) int posted_md; int total_md; __u64 xid; - lnet_handle_me_t me_h; - lnet_md_t md; + lnet_handle_me_t me_h; + lnet_md_t md; if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_BULK_GET_NET)) return 0; @@ -243,9 +243,9 @@ EXPORT_SYMBOL(ptlrpc_register_bulk); int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async) { struct ptlrpc_bulk_desc *desc = req->rq_bulk; - wait_queue_head_t *wq; - struct l_wait_info lwi; - int rc; + wait_queue_head_t *wq; + struct l_wait_info lwi; + int rc; LASSERT(!in_interrupt()); /* might sleep */ @@ -301,8 +301,8 @@ EXPORT_SYMBOL(ptlrpc_unregister_bulk); static void ptlrpc_at_set_reply(struct ptlrpc_request *req, int flags) { - struct ptlrpc_service_part *svcpt = req->rq_rqbd->rqbd_svcpt; - struct ptlrpc_service *svc = svcpt->scp_service; + struct ptlrpc_service_part *svcpt = req->rq_rqbd->rqbd_svcpt; + struct ptlrpc_service *svc = svcpt->scp_service; int service_time = max_t(int, get_seconds() - req->rq_arrival_time.tv_sec, 1); @@ -353,8 +353,8 @@ static void ptlrpc_at_set_reply(struct ptlrpc_request *req, int flags) int ptlrpc_send_reply(struct ptlrpc_request *req, int flags) { struct ptlrpc_reply_state *rs = req->rq_reply_state; - struct ptlrpc_connection *conn; - int rc; + struct ptlrpc_connection *conn; + int rc; /* We must already have a reply buffer (only ptlrpc_error() may be * called without one). The reply generated by sptlrpc layer (e.g. @@ -491,8 +491,8 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) int rc2; int mpflag = 0; struct ptlrpc_connection *connection; - lnet_handle_me_t reply_me_h; - lnet_md_t reply_md; + lnet_handle_me_t reply_me_h; + lnet_md_t reply_md; struct obd_device *obd = request->rq_import->imp_obd; if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_DROP_RPC)) @@ -594,15 +594,15 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) spin_unlock(&request->rq_lock); if (!noreply) { - reply_md.start = request->rq_repbuf; - reply_md.length = request->rq_repbuf_len; + reply_md.start = request->rq_repbuf; + reply_md.length = request->rq_repbuf_len; /* Allow multiple early replies */ reply_md.threshold = LNET_MD_THRESH_INF; /* Manage remote for early replies */ - reply_md.options = PTLRPC_MD_OPTIONS | LNET_MD_OP_PUT | + reply_md.options = PTLRPC_MD_OPTIONS | LNET_MD_OP_PUT | LNET_MD_MANAGE_REMOTE | LNET_MD_TRUNCATE; /* allow to make EOVERFLOW error */; - reply_md.user_ptr = &request->rq_reply_cbid; + reply_md.user_ptr = &request->rq_reply_cbid; reply_md.eq_handle = ptlrpc_eq_h; /* We must see the unlink callback to unset rq_reply_unlink, @@ -682,11 +682,11 @@ EXPORT_SYMBOL(ptl_send_rpc); */ int ptlrpc_register_rqbd(struct ptlrpc_request_buffer_desc *rqbd) { - struct ptlrpc_service *service = rqbd->rqbd_svcpt->scp_service; - static lnet_process_id_t match_id = {LNET_NID_ANY, LNET_PID_ANY}; - int rc; - lnet_md_t md; - lnet_handle_me_t me_h; + struct ptlrpc_service *service = rqbd->rqbd_svcpt->scp_service; + static lnet_process_id_t match_id = {LNET_NID_ANY, LNET_PID_ANY}; + int rc; + lnet_md_t md; + lnet_handle_me_t me_h; CDEBUG(D_NET, "LNetMEAttach: portal %d\n", service->srv_req_portal); @@ -709,12 +709,12 @@ int ptlrpc_register_rqbd(struct ptlrpc_request_buffer_desc *rqbd) LASSERT(rqbd->rqbd_refcount == 0); rqbd->rqbd_refcount = 1; - md.start = rqbd->rqbd_buffer; - md.length = service->srv_buf_size; - md.max_size = service->srv_max_req_size; + md.start = rqbd->rqbd_buffer; + md.length = service->srv_buf_size; + md.max_size = service->srv_max_req_size; md.threshold = LNET_MD_THRESH_INF; - md.options = PTLRPC_MD_OPTIONS | LNET_MD_OP_PUT | LNET_MD_MAX_SIZE; - md.user_ptr = &rqbd->rqbd_cbid; + md.options = PTLRPC_MD_OPTIONS | LNET_MD_OP_PUT | LNET_MD_MAX_SIZE; + md.user_ptr = &rqbd->rqbd_cbid; md.eq_handle = ptlrpc_eq_h; rc = LNetMDAttach(me_h, md, LNET_UNLINK, &rqbd->rqbd_md_h); diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c index d38a1af8bfd7..9516acadb7a1 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c @@ -188,8 +188,8 @@ static void nrs_policy_stop_primary(struct ptlrpc_nrs *nrs) */ static int nrs_policy_start_locked(struct ptlrpc_nrs_policy *policy) { - struct ptlrpc_nrs *nrs = policy->pol_nrs; - int rc = 0; + struct ptlrpc_nrs *nrs = policy->pol_nrs; + int rc = 0; /** * Don't allow multiple starting which is too complex, and has no real @@ -377,15 +377,15 @@ static void nrs_resource_put(struct ptlrpc_nrs_resource *res) */ static struct ptlrpc_nrs_resource *nrs_resource_get(struct ptlrpc_nrs_policy *policy, - struct ptlrpc_nrs_request *nrq, - bool moving_req) + struct ptlrpc_nrs_request *nrq, + bool moving_req) { /** * Set to NULL to traverse the resource hierarchy from the top. */ struct ptlrpc_nrs_resource *res = NULL; struct ptlrpc_nrs_resource *tmp = NULL; - int rc; + int rc; while (1) { rc = policy->pol_desc->pd_ops->op_res_get(policy, nrq, res, @@ -432,8 +432,8 @@ static void nrs_resource_get_safe(struct ptlrpc_nrs *nrs, struct ptlrpc_nrs_resource **resp, bool moving_req) { - struct ptlrpc_nrs_policy *primary = NULL; - struct ptlrpc_nrs_policy *fallback = NULL; + struct ptlrpc_nrs_policy *primary = NULL; + struct ptlrpc_nrs_policy *fallback = NULL; memset(resp, 0, sizeof(resp[0]) * NRS_RES_MAX); @@ -484,8 +484,8 @@ static void nrs_resource_get_safe(struct ptlrpc_nrs *nrs, static void nrs_resource_put_safe(struct ptlrpc_nrs_resource **resp) { struct ptlrpc_nrs_policy *pols[NRS_RES_MAX]; - struct ptlrpc_nrs *nrs = NULL; - int i; + struct ptlrpc_nrs *nrs = NULL; + int i; for (i = 0; i < NRS_RES_MAX; i++) { if (resp[i] != NULL) { @@ -530,7 +530,7 @@ static void nrs_resource_put_safe(struct ptlrpc_nrs_resource **resp) */ static inline struct ptlrpc_nrs_request *nrs_request_get(struct ptlrpc_nrs_policy *policy, - bool peek, bool force) + bool peek, bool force) { struct ptlrpc_nrs_request *nrq; @@ -556,8 +556,8 @@ struct ptlrpc_nrs_request *nrs_request_get(struct ptlrpc_nrs_policy *policy, static inline void nrs_request_enqueue(struct ptlrpc_nrs_request *nrq) { struct ptlrpc_nrs_policy *policy; - int rc; - int i; + int rc; + int i; /** * Try in descending order, because the primary policy (if any) is @@ -628,8 +628,8 @@ static inline void nrs_request_stop(struct ptlrpc_nrs_request *nrq) static int nrs_policy_ctl(struct ptlrpc_nrs *nrs, char *name, enum ptlrpc_nrs_ctl opc, void *arg) { - struct ptlrpc_nrs_policy *policy; - int rc = 0; + struct ptlrpc_nrs_policy *policy; + int rc = 0; spin_lock(&nrs->nrs_lock); @@ -733,10 +733,10 @@ static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name) static int nrs_policy_register(struct ptlrpc_nrs *nrs, struct ptlrpc_nrs_pol_desc *desc) { - struct ptlrpc_nrs_policy *policy; - struct ptlrpc_nrs_policy *tmp; - struct ptlrpc_service_part *svcpt = nrs->nrs_svcpt; - int rc; + struct ptlrpc_nrs_policy *policy; + struct ptlrpc_nrs_policy *tmp; + struct ptlrpc_service_part *svcpt = nrs->nrs_svcpt; + int rc; LASSERT(svcpt != NULL); LASSERT(desc->pd_ops != NULL); @@ -752,10 +752,10 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, if (policy == NULL) return -ENOMEM; - policy->pol_nrs = nrs; - policy->pol_desc = desc; - policy->pol_state = NRS_POL_STATE_STOPPED; - policy->pol_flags = desc->pd_flags; + policy->pol_nrs = nrs; + policy->pol_desc = desc; + policy->pol_state = NRS_POL_STATE_STOPPED; + policy->pol_flags = desc->pd_flags; INIT_LIST_HEAD(&policy->pol_list); INIT_LIST_HEAD(&policy->pol_list_queued); @@ -804,7 +804,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, */ static void ptlrpc_nrs_req_add_nolock(struct ptlrpc_request *req) { - struct ptlrpc_nrs_policy *policy; + struct ptlrpc_nrs_policy *policy; LASSERT(req->rq_nrq.nr_initialized); LASSERT(!req->rq_nrq.nr_enqueued); @@ -829,7 +829,7 @@ static void ptlrpc_nrs_req_add_nolock(struct ptlrpc_request *req) */ static void ptlrpc_nrs_hpreq_add_nolock(struct ptlrpc_request *req) { - int opc = lustre_msg_get_opc(req->rq_reqmsg); + int opc = lustre_msg_get_opc(req->rq_reqmsg); spin_lock(&req->rq_lock); req->rq_hp = 1; @@ -872,9 +872,9 @@ static int nrs_register_policies_locked(struct ptlrpc_nrs *nrs) { struct ptlrpc_nrs_pol_desc *desc; /* for convenience */ - struct ptlrpc_service_part *svcpt = nrs->nrs_svcpt; - struct ptlrpc_service *svc = svcpt->scp_service; - int rc = -EINVAL; + struct ptlrpc_service_part *svcpt = nrs->nrs_svcpt; + struct ptlrpc_service *svc = svcpt->scp_service; + int rc = -EINVAL; LASSERT(mutex_is_locked(&nrs_core.nrs_mutex)); @@ -912,7 +912,7 @@ static int nrs_register_policies_locked(struct ptlrpc_nrs *nrs) static int nrs_svcpt_setup_locked0(struct ptlrpc_nrs *nrs, struct ptlrpc_service_part *svcpt) { - enum ptlrpc_nrs_queue_type queue; + enum ptlrpc_nrs_queue_type queue; LASSERT(mutex_is_locked(&nrs_core.nrs_mutex)); @@ -943,8 +943,8 @@ static int nrs_svcpt_setup_locked0(struct ptlrpc_nrs *nrs, */ static int nrs_svcpt_setup_locked(struct ptlrpc_service_part *svcpt) { - struct ptlrpc_nrs *nrs; - int rc; + struct ptlrpc_nrs *nrs; + int rc; LASSERT(mutex_is_locked(&nrs_core.nrs_mutex)); @@ -988,11 +988,11 @@ out: */ static void nrs_svcpt_cleanup_locked(struct ptlrpc_service_part *svcpt) { - struct ptlrpc_nrs *nrs; - struct ptlrpc_nrs_policy *policy; - struct ptlrpc_nrs_policy *tmp; - int rc; - bool hp = false; + struct ptlrpc_nrs *nrs; + struct ptlrpc_nrs_policy *policy; + struct ptlrpc_nrs_policy *tmp; + int rc; + bool hp = false; LASSERT(mutex_is_locked(&nrs_core.nrs_mutex)); @@ -1028,7 +1028,7 @@ again: */ static struct ptlrpc_nrs_pol_desc *nrs_policy_find_desc_locked(const char *name) { - struct ptlrpc_nrs_pol_desc *tmp; + struct ptlrpc_nrs_pol_desc *tmp; list_for_each_entry(tmp, &nrs_core.nrs_policies, pd_list) { if (strncmp(tmp->pd_name, name, NRS_POL_NAME_MAX) == 0) @@ -1051,11 +1051,11 @@ static struct ptlrpc_nrs_pol_desc *nrs_policy_find_desc_locked(const char *name) */ static int nrs_policy_unregister_locked(struct ptlrpc_nrs_pol_desc *desc) { - struct ptlrpc_nrs *nrs; - struct ptlrpc_service *svc; - struct ptlrpc_service_part *svcpt; - int i; - int rc = 0; + struct ptlrpc_nrs *nrs; + struct ptlrpc_service *svc; + struct ptlrpc_service_part *svcpt; + int i; + int rc = 0; LASSERT(mutex_is_locked(&nrs_core.nrs_mutex)); LASSERT(mutex_is_locked(&ptlrpc_all_services_mutex)); @@ -1115,9 +1115,9 @@ again: */ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) { - struct ptlrpc_service *svc; - struct ptlrpc_nrs_pol_desc *desc; - int rc = 0; + struct ptlrpc_service *svc; + struct ptlrpc_nrs_pol_desc *desc; + int rc = 0; LASSERT(conf != NULL); LASSERT(conf->nc_ops != NULL); @@ -1162,12 +1162,12 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) } strncpy(desc->pd_name, conf->nc_name, NRS_POL_NAME_MAX); - desc->pd_ops = conf->nc_ops; - desc->pd_compat = conf->nc_compat; + desc->pd_ops = conf->nc_ops; + desc->pd_compat = conf->nc_compat; desc->pd_compat_svc_name = conf->nc_compat_svc_name; if ((conf->nc_flags & PTLRPC_NRS_FL_REG_EXTERN) != 0) - desc->pd_owner = conf->nc_owner; - desc->pd_flags = conf->nc_flags; + desc->pd_owner = conf->nc_owner; + desc->pd_flags = conf->nc_flags; atomic_set(&desc->pd_refs, 0); /** @@ -1187,17 +1187,17 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) mutex_lock(&ptlrpc_all_services_mutex); list_for_each_entry(svc, &ptlrpc_all_services, srv_list) { - struct ptlrpc_service_part *svcpt; - int i; - int rc2; + struct ptlrpc_service_part *svcpt; + int i; + int rc2; if (!nrs_policy_compatible(svc, desc) || unlikely(svc->srv_is_stopping)) continue; ptlrpc_service_for_each_part(svcpt, i, svc) { - struct ptlrpc_nrs *nrs; - bool hp = false; + struct ptlrpc_nrs *nrs; + bool hp = false; again: nrs = nrs_svcpt2nrs(svcpt, hp); rc = nrs_policy_register(nrs, desc); @@ -1267,8 +1267,8 @@ EXPORT_SYMBOL(ptlrpc_nrs_policy_register); */ int ptlrpc_nrs_policy_unregister(struct ptlrpc_nrs_pol_conf *conf) { - struct ptlrpc_nrs_pol_desc *desc; - int rc; + struct ptlrpc_nrs_pol_desc *desc; + int rc; LASSERT(conf != NULL); @@ -1331,10 +1331,10 @@ EXPORT_SYMBOL(ptlrpc_nrs_policy_unregister); */ int ptlrpc_service_nrs_setup(struct ptlrpc_service *svc) { - struct ptlrpc_service_part *svcpt; - const struct ptlrpc_nrs_pol_desc *desc; - int i; - int rc = 0; + struct ptlrpc_service_part *svcpt; + const struct ptlrpc_nrs_pol_desc *desc; + int i; + int rc = 0; mutex_lock(&nrs_core.nrs_mutex); @@ -1376,9 +1376,9 @@ failed: */ void ptlrpc_service_nrs_cleanup(struct ptlrpc_service *svc) { - struct ptlrpc_service_part *svcpt; - const struct ptlrpc_nrs_pol_desc *desc; - int i; + struct ptlrpc_service_part *svcpt; + const struct ptlrpc_nrs_pol_desc *desc; + int i; mutex_lock(&nrs_core.nrs_mutex); @@ -1417,7 +1417,7 @@ void ptlrpc_service_nrs_cleanup(struct ptlrpc_service *svc) void ptlrpc_nrs_req_initialize(struct ptlrpc_service_part *svcpt, struct ptlrpc_request *req, bool hp) { - struct ptlrpc_nrs *nrs = nrs_svcpt2nrs(svcpt, hp); + struct ptlrpc_nrs *nrs = nrs_svcpt2nrs(svcpt, hp); memset(&req->rq_nrq, 0, sizeof(req->rq_nrq)); nrs_resource_get_safe(nrs, &req->rq_nrq, req->rq_nrq.nr_res_ptrs, @@ -1525,8 +1525,8 @@ struct ptlrpc_request * ptlrpc_nrs_req_get_nolock0(struct ptlrpc_service_part *svcpt, bool hp, bool peek, bool force) { - struct ptlrpc_nrs *nrs = nrs_svcpt2nrs(svcpt, hp); - struct ptlrpc_nrs_policy *policy; + struct ptlrpc_nrs *nrs = nrs_svcpt2nrs(svcpt, hp); + struct ptlrpc_nrs_policy *policy; struct ptlrpc_nrs_request *nrq; /** @@ -1596,10 +1596,10 @@ bool ptlrpc_nrs_req_pending_nolock(struct ptlrpc_service_part *svcpt, bool hp) */ void ptlrpc_nrs_req_hp_move(struct ptlrpc_request *req) { - struct ptlrpc_service_part *svcpt = req->rq_rqbd->rqbd_svcpt; - struct ptlrpc_nrs_request *nrq = &req->rq_nrq; - struct ptlrpc_nrs_resource *res1[NRS_RES_MAX]; - struct ptlrpc_nrs_resource *res2[NRS_RES_MAX]; + struct ptlrpc_service_part *svcpt = req->rq_rqbd->rqbd_svcpt; + struct ptlrpc_nrs_request *nrq = &req->rq_nrq; + struct ptlrpc_nrs_resource *res1[NRS_RES_MAX]; + struct ptlrpc_nrs_resource *res2[NRS_RES_MAX]; /** * Obtain the high-priority NRS head resources. @@ -1661,9 +1661,9 @@ int ptlrpc_nrs_policy_control(const struct ptlrpc_service *svc, enum ptlrpc_nrs_queue_type queue, char *name, enum ptlrpc_nrs_ctl opc, bool single, void *arg) { - struct ptlrpc_service_part *svcpt; - int i; - int rc = 0; + struct ptlrpc_service_part *svcpt; + int i; + int rc = 0; LASSERT(opc != PTLRPC_NRS_CTL_INVALID); @@ -1711,7 +1711,7 @@ extern struct ptlrpc_nrs_pol_conf nrs_conf_fifo; */ int ptlrpc_nrs_init(void) { - int rc; + int rc; mutex_init(&nrs_core.nrs_mutex); INIT_LIST_HEAD(&nrs_core.nrs_policies); diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c index 6a61c85cfb11..8e21f0cdc8f8 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c @@ -160,9 +160,9 @@ static int nrs_fifo_res_get(struct ptlrpc_nrs_policy *policy, */ static struct ptlrpc_nrs_request *nrs_fifo_req_get(struct ptlrpc_nrs_policy *policy, - bool peek, bool force) + bool peek, bool force) { - struct nrs_fifo_head *head = policy->pol_private; + struct nrs_fifo_head *head = policy->pol_private; struct ptlrpc_nrs_request *nrq; nrq = unlikely(list_empty(&head->fh_list)) ? NULL : diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index b51af9bf37b7..2787bfd67165 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -279,8 +279,8 @@ lustre_get_emerg_rs(struct ptlrpc_service_part *svcpt) /* See if we have anything in a pool, and wait if nothing */ while (list_empty(&svcpt->scp_rep_idle)) { - struct l_wait_info lwi; - int rc; + struct l_wait_info lwi; + int rc; spin_unlock(&svcpt->scp_rep_lock); /* If we cannot get anything for some long time, we better @@ -321,7 +321,7 @@ int lustre_pack_reply_v2(struct ptlrpc_request *req, int count, __u32 *lens, char **bufs, int flags) { struct ptlrpc_reply_state *rs; - int msg_len, rc; + int msg_len, rc; LASSERT(req->rq_reply_state == NULL); @@ -440,8 +440,8 @@ EXPORT_SYMBOL(lustre_msg_buf); int lustre_shrink_msg_v2(struct lustre_msg_v2 *msg, int segment, unsigned int newlen, int move_data) { - char *tail = NULL, *newpos; - int tail_len = 0, n; + char *tail = NULL, *newpos; + int tail_len = 0, n; LASSERT(msg); LASSERT(msg->lm_bufcount > segment); @@ -1577,8 +1577,8 @@ int do_set_info_async(struct obd_import *imp, struct ptlrpc_request_set *set) { struct ptlrpc_request *req; - char *tmp; - int rc; + char *tmp; + int rc; req = ptlrpc_request_alloc(imp, &RQF_OBD_SET_INFO); if (req == NULL) @@ -1688,7 +1688,7 @@ void lustre_swab_connect(struct obd_connect_data *ocd) CLASSERT(offsetof(typeof(*ocd), paddingF) != 0); } -void lustre_swab_obdo(struct obdo *o) +void lustre_swab_obdo(struct obdo *o) { __swab64s(&o->o_valid); lustre_swab_ost_id(&o->o_oi); @@ -2179,7 +2179,7 @@ EXPORT_SYMBOL(lustre_swab_lov_user_md_objects); void lustre_swab_ldlm_res_id(struct ldlm_res_id *id) { - int i; + int i; for (i = 0; i < RES_NAME_SIZE; i++) __swab64s(&id->name[i]); diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index 9fc815676eb8..61e33be865b2 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -546,8 +546,8 @@ void ptlrpc_pinger_wake_up(void) #define PET_TERMINATE 2 static int pet_refcount; -static int pet_state; -static wait_queue_head_t pet_waitq; +static int pet_state; +static wait_queue_head_t pet_waitq; static LIST_HEAD(pet_list); static DEFINE_SPINLOCK(pet_lock); diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index 5ba3e6ed5289..e591cff323ec 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c @@ -68,9 +68,9 @@ #include "ptlrpc_internal.h" struct ptlrpcd { - int pd_size; - int pd_index; - int pd_nthreads; + int pd_size; + int pd_index; + int pd_nthreads; struct ptlrpcd_ctl pd_thread_rcv; struct ptlrpcd_ctl pd_threads[0]; }; diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index bcfd0b0b6f93..8798fab31f77 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -113,10 +113,10 @@ static struct ptlrpc_sec_policy *sptlrpc_wireflavor2policy(__u32 flavor) { static DEFINE_MUTEX(load_mutex); - static atomic_t loaded = ATOMIC_INIT(0); + static atomic_t loaded = ATOMIC_INIT(0); struct ptlrpc_sec_policy *policy; - __u16 number = SPTLRPC_FLVR_POLICY(flavor); - __u16 flag = 0; + __u16 number = SPTLRPC_FLVR_POLICY(flavor); + __u16 flag = 0; if (number >= SPTLRPC_POLICY_MAX) return NULL; @@ -339,7 +339,7 @@ int sptlrpc_cli_ctx_display(struct ptlrpc_cli_ctx *ctx, char *buf, int bufsize) static int import_sec_check_expire(struct obd_import *imp) { - int adapt = 0; + int adapt = 0; spin_lock(&imp->imp_lock); if (imp->imp_sec_expire && @@ -359,7 +359,7 @@ static int import_sec_check_expire(struct obd_import *imp) static int import_sec_validate_get(struct obd_import *imp, struct ptlrpc_sec **sec) { - int rc; + int rc; if (unlikely(imp->imp_sec_expire)) { rc = import_sec_check_expire(imp); @@ -447,10 +447,10 @@ int sptlrpc_req_ctx_switch(struct ptlrpc_request *req, struct ptlrpc_cli_ctx *oldctx, struct ptlrpc_cli_ctx *newctx) { - struct sptlrpc_flavor old_flvr; - char *reqmsg = NULL; /* to workaround old gcc */ - int reqmsg_size; - int rc = 0; + struct sptlrpc_flavor old_flvr; + char *reqmsg = NULL; /* to workaround old gcc */ + int reqmsg_size; + int rc = 0; LASSERT(req->rq_reqmsg); LASSERT(req->rq_reqlen); @@ -514,7 +514,7 @@ int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req) { struct ptlrpc_cli_ctx *oldctx = req->rq_cli_ctx; struct ptlrpc_cli_ctx *newctx; - int rc; + int rc; LASSERT(oldctx); @@ -629,10 +629,10 @@ void req_off_ctx_list(struct ptlrpc_request *req, struct ptlrpc_cli_ctx *ctx) */ int sptlrpc_req_refresh_ctx(struct ptlrpc_request *req, long timeout) { - struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx; - struct ptlrpc_sec *sec; - struct l_wait_info lwi; - int rc; + struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx; + struct ptlrpc_sec *sec; + struct l_wait_info lwi; + int rc; LASSERT(ctx); @@ -878,7 +878,7 @@ void sptlrpc_request_out_callback(struct ptlrpc_request *req) */ int sptlrpc_import_check_ctx(struct obd_import *imp) { - struct ptlrpc_sec *sec; + struct ptlrpc_sec *sec; struct ptlrpc_cli_ctx *ctx; struct ptlrpc_request *req = NULL; int rc; @@ -974,7 +974,7 @@ int sptlrpc_cli_wrap_request(struct ptlrpc_request *req) static int do_cli_unwrap_reply(struct ptlrpc_request *req) { struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx; - int rc; + int rc; LASSERT(ctx); LASSERT(ctx->cc_sec); @@ -1082,10 +1082,10 @@ int sptlrpc_cli_unwrap_reply(struct ptlrpc_request *req) int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req, struct ptlrpc_request **req_ret) { - struct ptlrpc_request *early_req; - char *early_buf; - int early_bufsz, early_size; - int rc; + struct ptlrpc_request *early_req; + char *early_buf; + int early_bufsz, early_size; + int rc; early_req = ptlrpc_request_cache_alloc(GFP_NOFS); if (early_req == NULL) @@ -1273,13 +1273,13 @@ EXPORT_SYMBOL(sptlrpc_sec_put); */ static struct ptlrpc_sec *sptlrpc_sec_create(struct obd_import *imp, - struct ptlrpc_svc_ctx *svc_ctx, - struct sptlrpc_flavor *sf, - enum lustre_sec_part sp) + struct ptlrpc_svc_ctx *svc_ctx, + struct sptlrpc_flavor *sf, + enum lustre_sec_part sp) { struct ptlrpc_sec_policy *policy; - struct ptlrpc_sec *sec; - char str[32]; + struct ptlrpc_sec *sec; + char str[32]; if (svc_ctx) { LASSERT(imp->imp_dlm_fake == 1); @@ -1369,7 +1369,7 @@ static void sptlrpc_import_sec_adapt_inplace(struct obd_import *imp, struct ptlrpc_sec *sec, struct sptlrpc_flavor *sf) { - char str1[32], str2[32]; + char str1[32], str2[32]; if (sec->ps_flvr.sf_flags != sf->sf_flags) CDEBUG(D_SEC, "changing sec flags: %s -> %s\n", @@ -1394,12 +1394,12 @@ int sptlrpc_import_sec_adapt(struct obd_import *imp, struct ptlrpc_svc_ctx *svc_ctx, struct sptlrpc_flavor *flvr) { - struct ptlrpc_connection *conn; - struct sptlrpc_flavor sf; - struct ptlrpc_sec *sec, *newsec; - enum lustre_sec_part sp; - char str[24]; - int rc = 0; + struct ptlrpc_connection *conn; + struct sptlrpc_flavor sf; + struct ptlrpc_sec *sec, *newsec; + enum lustre_sec_part sp; + char str[24]; + int rc = 0; might_sleep(); @@ -1436,7 +1436,7 @@ int sptlrpc_import_sec_adapt(struct obd_import *imp, sec = sptlrpc_import_sec_ref(imp); if (sec) { - char str2[24]; + char str2[24]; if (flavor_equal(&sf, &sec->ps_flvr)) goto out; @@ -1585,8 +1585,8 @@ void sptlrpc_cli_free_reqbuf(struct ptlrpc_request *req) void _sptlrpc_enlarge_msg_inplace(struct lustre_msg *msg, int segment, int newsize) { - void *src, *dst; - int oldsize, oldmsg_size, movesize; + void *src, *dst; + int oldsize, oldmsg_size, movesize; LASSERT(segment < msg->lm_bufcount); LASSERT(msg->lm_buflens[segment] <= newsize); @@ -1635,9 +1635,9 @@ EXPORT_SYMBOL(_sptlrpc_enlarge_msg_inplace); int sptlrpc_cli_enlarge_reqbuf(struct ptlrpc_request *req, int segment, int newsize) { - struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx; - struct ptlrpc_sec_cops *cops; - struct lustre_msg *msg = req->rq_reqmsg; + struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx; + struct ptlrpc_sec_cops *cops; + struct lustre_msg *msg = req->rq_reqmsg; LASSERT(ctx); LASSERT(msg); @@ -1748,7 +1748,7 @@ static int flavor_allowed(struct sptlrpc_flavor *exp, int sptlrpc_target_export_check(struct obd_export *exp, struct ptlrpc_request *req) { - struct sptlrpc_flavor flavor; + struct sptlrpc_flavor flavor; if (exp == NULL) return 0; @@ -1926,8 +1926,8 @@ EXPORT_SYMBOL(sptlrpc_target_export_check); void sptlrpc_target_update_exp_flavor(struct obd_device *obd, struct sptlrpc_rule_set *rset) { - struct obd_export *exp; - struct sptlrpc_flavor new_flvr; + struct obd_export *exp; + struct sptlrpc_flavor new_flvr; LASSERT(obd); @@ -2019,8 +2019,8 @@ static int sptlrpc_svc_check_from(struct ptlrpc_request *req, int svc_rc) int sptlrpc_svc_unwrap_request(struct ptlrpc_request *req) { struct ptlrpc_sec_policy *policy; - struct lustre_msg *msg = req->rq_reqbuf; - int rc; + struct lustre_msg *msg = req->rq_reqbuf; + int rc; LASSERT(msg); LASSERT(req->rq_reqmsg == NULL); @@ -2231,8 +2231,8 @@ int sptlrpc_cli_unwrap_bulk_read(struct ptlrpc_request *req, struct ptlrpc_bulk_desc *desc, int nob) { - struct ptlrpc_cli_ctx *ctx; - int rc; + struct ptlrpc_cli_ctx *ctx; + int rc; LASSERT(req->rq_bulk_read && !req->rq_bulk_write); @@ -2256,8 +2256,8 @@ EXPORT_SYMBOL(sptlrpc_cli_unwrap_bulk_read); int sptlrpc_cli_unwrap_bulk_write(struct ptlrpc_request *req, struct ptlrpc_bulk_desc *desc) { - struct ptlrpc_cli_ctx *ctx; - int rc; + struct ptlrpc_cli_ctx *ctx; + int rc; LASSERT(!req->rq_bulk_read && req->rq_bulk_write); @@ -2329,7 +2329,7 @@ EXPORT_SYMBOL(sptlrpc_pack_user_desc); int sptlrpc_unpack_user_desc(struct lustre_msg *msg, int offset, int swabbed) { struct ptlrpc_user_desc *pud; - int i; + int i; pud = lustre_msg_buf(msg, offset, sizeof(*pud)); if (!pud) diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index 97edc9174da3..ea35ca54e729 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -62,7 +62,7 @@ #define POINTERS_PER_PAGE (PAGE_CACHE_SIZE / sizeof(void *)) #define PAGES_PER_POOL (POINTERS_PER_PAGE) -#define IDLE_IDX_MAX (100) +#define IDLE_IDX_MAX (100) #define IDLE_IDX_WEIGHT (3) #define CACHE_QUIESCENT_PERIOD (20) @@ -173,8 +173,8 @@ int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v) static void enc_pools_release_free_pages(long npages) { - int p_idx, g_idx; - int p_idx_max1, p_idx_max2; + int p_idx, g_idx; + int p_idx_max1, p_idx_max2; LASSERT(npages > 0); LASSERT(npages <= page_pools.epp_free_pages); @@ -284,7 +284,7 @@ int npages_to_npools(unsigned long npages) static unsigned long enc_pools_cleanup(struct page ***pools, int npools) { unsigned long cleaned = 0; - int i, j; + int i, j; for (i = 0; i < npools; i++) { if (pools[i]) { @@ -311,9 +311,9 @@ static unsigned long enc_pools_cleanup(struct page ***pools, int npools) */ static void enc_pools_insert(struct page ***pools, int npools, int npages) { - int freeslot; - int op_idx, np_idx, og_idx, ng_idx; - int cur_npools, end_npools; + int freeslot; + int op_idx, np_idx, og_idx, ng_idx; + int cur_npools, end_npools; LASSERT(npages > 0); LASSERT(page_pools.epp_total_pages+npages <= page_pools.epp_max_pages); @@ -393,9 +393,9 @@ static void enc_pools_insert(struct page ***pools, int npools, int npages) static int enc_pools_add_pages(int npages) { static DEFINE_MUTEX(add_pages_mutex); - struct page ***pools; - int npools, alloced = 0; - int i, j, rc = -ENOMEM; + struct page ***pools; + int npools, alloced = 0; + int i, j, rc = -ENOMEM; if (npages < PTLRPC_MAX_BRW_PAGES) npages = PTLRPC_MAX_BRW_PAGES; @@ -494,12 +494,12 @@ static int enc_pools_should_grow(int page_needed, long now) */ int sptlrpc_enc_pool_get_pages(struct ptlrpc_bulk_desc *desc) { - wait_queue_t waitlink; - unsigned long this_idle = -1; - unsigned long tick = 0; - long now; - int p_idx, g_idx; - int i; + wait_queue_t waitlink; + unsigned long this_idle = -1; + unsigned long tick = 0; + long now; + int p_idx, g_idx; + int i; LASSERT(desc->bd_iov_count > 0); LASSERT(desc->bd_iov_count <= page_pools.epp_max_pages); @@ -609,8 +609,8 @@ EXPORT_SYMBOL(sptlrpc_enc_pool_get_pages); void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc) { - int p_idx, g_idx; - int i; + int p_idx, g_idx; + int i; if (desc->bd_enc_iov == NULL) return; @@ -658,7 +658,7 @@ EXPORT_SYMBOL(sptlrpc_enc_pool_put_pages); */ int sptlrpc_enc_pool_add_user(void) { - int need_grow = 0; + int need_grow = 0; spin_lock(&page_pools.epp_lock); if (page_pools.epp_growing == 0 && page_pools.epp_total_pages == 0) { @@ -842,11 +842,11 @@ EXPORT_SYMBOL(bulk_sec_desc_unpack); int sptlrpc_get_bulk_checksum(struct ptlrpc_bulk_desc *desc, __u8 alg, void *buf, int buflen) { - struct cfs_crypto_hash_desc *hdesc; - int hashsize; - char hashbuf[64]; - unsigned int bufsize; - int i, err; + struct cfs_crypto_hash_desc *hdesc; + int hashsize; + char hashbuf[64]; + unsigned int bufsize; + int i, err; LASSERT(alg > BULK_HASH_ALG_NULL && alg < BULK_HASH_ALG_MAX); LASSERT(buflen >= 4); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c index 16dbf3fcfc84..31da43e8b3c6 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c @@ -94,8 +94,8 @@ EXPORT_SYMBOL(sptlrpc_target_sec_part); */ int sptlrpc_parse_flavor(const char *str, struct sptlrpc_flavor *flvr) { - char buf[32]; - char *bulk, *alg; + char buf[32]; + char *bulk, *alg; memset(flvr, 0, sizeof(*flvr)); @@ -182,8 +182,8 @@ static void sptlrpc_rule_init(struct sptlrpc_rule *rule) */ int sptlrpc_parse_rule(char *param, struct sptlrpc_rule *rule) { - char *flavor, *dir; - int rc; + char *flavor, *dir; + int rc; sptlrpc_rule_init(rule); @@ -309,9 +309,9 @@ static inline int rule_match_net(struct sptlrpc_rule *r1, int sptlrpc_rule_set_merge(struct sptlrpc_rule_set *rset, struct sptlrpc_rule *rule) { - struct sptlrpc_rule *p = rset->srs_rules; - int spec_dir, spec_net; - int rc, n, match = 0; + struct sptlrpc_rule *p = rset->srs_rules; + int spec_dir, spec_net; + int rc, n, match = 0; might_sleep(); @@ -403,8 +403,8 @@ int sptlrpc_rule_set_choose(struct sptlrpc_rule_set *rset, lnet_nid_t nid, struct sptlrpc_flavor *sf) { - struct sptlrpc_rule *r; - int n; + struct sptlrpc_rule *r; + int n; for (n = 0; n < rset->srs_nrule; n++) { r = &rset->srs_rules[n]; @@ -433,7 +433,7 @@ EXPORT_SYMBOL(sptlrpc_rule_set_choose); void sptlrpc_rule_set_dump(struct sptlrpc_rule_set *rset) { struct sptlrpc_rule *r; - int n; + int n; for (n = 0; n < rset->srs_nrule; n++) { r = &rset->srs_rules[n]; @@ -474,8 +474,8 @@ static inline int is_hex(char c) static void target2fsname(const char *tgt, char *fsname, int buflen) { - const char *ptr; - int len; + const char *ptr; + int len; ptr = strrchr(tgt, '-'); if (ptr) { @@ -583,8 +583,8 @@ static int sptlrpc_conf_merge_rule(struct sptlrpc_conf *conf, const char *target, struct sptlrpc_rule *rule) { - struct sptlrpc_conf_tgt *conf_tgt; - struct sptlrpc_rule_set *rule_set; + struct sptlrpc_conf_tgt *conf_tgt; + struct sptlrpc_rule_set *rule_set; /* fsname == target means general rules for the whole fs */ if (strcmp(conf->sc_fsname, target) == 0) { @@ -610,10 +610,10 @@ static int sptlrpc_conf_merge_rule(struct sptlrpc_conf *conf, static int __sptlrpc_process_config(struct lustre_cfg *lcfg, struct sptlrpc_conf *conf) { - char *target, *param; - char fsname[MTI_NAME_MAXLEN]; - struct sptlrpc_rule rule; - int rc; + char *target, *param; + char fsname[MTI_NAME_MAXLEN]; + struct sptlrpc_rule rule; + int rc; target = lustre_cfg_string(lcfg, 1); if (target == NULL) { @@ -671,8 +671,8 @@ EXPORT_SYMBOL(sptlrpc_process_config); static int logname2fsname(const char *logname, char *buf, int buflen) { - char *ptr; - int len; + char *ptr; + int len; ptr = strrchr(logname, '-'); if (ptr == NULL || strcmp(ptr, "-sptlrpc")) { @@ -690,7 +690,7 @@ static int logname2fsname(const char *logname, char *buf, int buflen) void sptlrpc_conf_log_update_begin(const char *logname) { struct sptlrpc_conf *conf; - char fsname[16]; + char fsname[16]; if (logname2fsname(logname, fsname, sizeof(fsname))) return; @@ -716,7 +716,7 @@ EXPORT_SYMBOL(sptlrpc_conf_log_update_begin); void sptlrpc_conf_log_update_end(const char *logname) { struct sptlrpc_conf *conf; - char fsname[16]; + char fsname[16]; if (logname2fsname(logname, fsname, sizeof(fsname))) return; @@ -741,7 +741,7 @@ EXPORT_SYMBOL(sptlrpc_conf_log_update_end); void sptlrpc_conf_log_start(const char *logname) { - char fsname[16]; + char fsname[16]; if (logname2fsname(logname, fsname, sizeof(fsname))) return; @@ -755,7 +755,7 @@ EXPORT_SYMBOL(sptlrpc_conf_log_start); void sptlrpc_conf_log_stop(const char *logname) { struct sptlrpc_conf *conf; - char fsname[16]; + char fsname[16]; if (logname2fsname(logname, fsname, sizeof(fsname))) return; @@ -799,10 +799,10 @@ void sptlrpc_conf_choose_flavor(enum lustre_sec_part from, lnet_nid_t nid, struct sptlrpc_flavor *sf) { - struct sptlrpc_conf *conf; + struct sptlrpc_conf *conf; struct sptlrpc_conf_tgt *conf_tgt; - char name[MTI_NAME_MAXLEN]; - int len, rc = 0; + char name[MTI_NAME_MAXLEN]; + int len, rc = 0; target2fsname(target->uuid, name, sizeof(name)); @@ -858,7 +858,7 @@ EXPORT_SYMBOL(sptlrpc_target_choose_flavor); */ void sptlrpc_conf_client_adapt(struct obd_device *obd) { - struct obd_import *imp; + struct obd_import *imp; LASSERT(strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 || strcmp(obd->obd_type->typ_name, LUSTRE_OSC_NAME) == 0); @@ -880,7 +880,7 @@ void sptlrpc_conf_client_adapt(struct obd_device *obd) } EXPORT_SYMBOL(sptlrpc_conf_client_adapt); -int sptlrpc_conf_init(void) +int sptlrpc_conf_init(void) { mutex_init(&sptlrpc_conf_lock); return 0; @@ -888,7 +888,7 @@ int sptlrpc_conf_init(void) void sptlrpc_conf_fini(void) { - struct sptlrpc_conf *conf, *conf_next; + struct sptlrpc_conf *conf, *conf_next; mutex_lock(&sptlrpc_conf_lock); list_for_each_entry_safe(conf, conf_next, &sptlrpc_confs, sc_list) { diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c index 81de68edb04e..cdad608bdb8d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c @@ -164,7 +164,7 @@ static void sec_do_gc(struct ptlrpc_sec *sec) static int sec_gc_main(void *arg) { struct ptlrpc_thread *thread = (struct ptlrpc_thread *) arg; - struct l_wait_info lwi; + struct l_wait_info lwi; unshare_fs_struct(); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c index 982512febf05..68fcac14b3ee 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c @@ -74,7 +74,7 @@ static int sptlrpc_info_lprocfs_seq_show(struct seq_file *seq, void *v) struct obd_device *dev = seq->private; struct client_obd *cli = &dev->u.cli; struct ptlrpc_sec *sec = NULL; - char str[32]; + char str[32]; LASSERT(strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) == 0 || strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 || @@ -134,7 +134,7 @@ LPROC_SEQ_FOPS_RO(sptlrpc_ctxs_lprocfs); int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev) { - int rc; + int rc; if (strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) != 0 && strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) != 0 && diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c index 4e132435b450..8c28b6b7ff02 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c @@ -92,7 +92,7 @@ int null_ctx_sign(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) static int null_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) { - __u32 cksums, cksumc; + __u32 cksums, cksumc; LASSERT(req->rq_repdata); @@ -226,9 +226,9 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec, struct ptlrpc_request *req, int segment, int newsize) { - struct lustre_msg *newbuf; - struct lustre_msg *oldbuf = req->rq_reqmsg; - int oldsize, newmsg_size, alloc_size; + struct lustre_msg *newbuf; + struct lustre_msg *oldbuf = req->rq_reqmsg; + int oldsize, newmsg_size, alloc_size; LASSERT(req->rq_reqbuf); LASSERT(req->rq_reqbuf == req->rq_reqmsg); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c index 65f3ab42829c..ed39970417d8 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c @@ -136,7 +136,7 @@ static int plain_verify_bulk_csum(struct ptlrpc_bulk_desc *desc, struct plain_bulk_token *tokenr) { struct plain_bulk_token tokenv; - int rc; + int rc; if (hash_alg == BULK_HASH_ALG_NULL) return 0; @@ -154,8 +154,8 @@ static int plain_verify_bulk_csum(struct ptlrpc_bulk_desc *desc, static void corrupt_bulk_data(struct ptlrpc_bulk_desc *desc) { - char *ptr; - unsigned int off, i; + char *ptr; + unsigned int off, i; for (i = 0; i < desc->bd_iov_count; i++) { if (desc->bd_iov[i].kiov_len == 0) @@ -190,7 +190,7 @@ int plain_ctx_validate(struct ptlrpc_cli_ctx *ctx) static int plain_ctx_sign(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) { - struct lustre_msg *msg = req->rq_reqbuf; + struct lustre_msg *msg = req->rq_reqbuf; struct plain_header *phdr; msg->lm_secflvr = req->rq_flvr.sf_rpc; @@ -214,10 +214,10 @@ int plain_ctx_sign(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) static int plain_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) { - struct lustre_msg *msg = req->rq_repdata; + struct lustre_msg *msg = req->rq_repdata; struct plain_header *phdr; - __u32 cksum; - int swabbed; + __u32 cksum; + int swabbed; if (msg->lm_bufcount != PLAIN_PACK_SEGMENTS) { CERROR("unexpected reply buf count %u\n", msg->lm_bufcount); @@ -290,8 +290,8 @@ int plain_cli_wrap_bulk(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_bulk_desc *desc) { struct ptlrpc_bulk_sec_desc *bsd; - struct plain_bulk_token *token; - int rc; + struct plain_bulk_token *token; + int rc; LASSERT(req->rq_pack_bulk); LASSERT(req->rq_reqbuf->lm_bufcount == PLAIN_PACK_SEGMENTS); @@ -333,9 +333,9 @@ int plain_cli_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_bulk_desc *desc) { struct ptlrpc_bulk_sec_desc *bsdv; - struct plain_bulk_token *tokenv; - int rc; - int i, nob; + struct plain_bulk_token *tokenv; + int rc; + int i, nob; LASSERT(req->rq_pack_bulk); LASSERT(req->rq_reqbuf->lm_bufcount == PLAIN_PACK_SEGMENTS); @@ -374,7 +374,7 @@ int plain_cli_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, static struct ptlrpc_cli_ctx *plain_sec_install_ctx(struct plain_sec *plsec) { - struct ptlrpc_cli_ctx *ctx, *ctx_new; + struct ptlrpc_cli_ctx *ctx, *ctx_new; ctx_new = kzalloc(sizeof(*ctx_new), GFP_NOFS); @@ -413,7 +413,7 @@ struct ptlrpc_cli_ctx *plain_sec_install_ctx(struct plain_sec *plsec) static void plain_destroy_sec(struct ptlrpc_sec *sec) { - struct plain_sec *plsec = sec2plsec(sec); + struct plain_sec *plsec = sec2plsec(sec); LASSERT(sec->ps_policy == &plain_policy); LASSERT(sec->ps_import); @@ -437,9 +437,9 @@ struct ptlrpc_sec *plain_create_sec(struct obd_import *imp, struct ptlrpc_svc_ctx *svc_ctx, struct sptlrpc_flavor *sf) { - struct plain_sec *plsec; - struct ptlrpc_sec *sec; - struct ptlrpc_cli_ctx *ctx; + struct plain_sec *plsec; + struct ptlrpc_sec *sec; + struct ptlrpc_cli_ctx *ctx; LASSERT(SPTLRPC_FLVR_POLICY(sf->sf_rpc) == SPTLRPC_POLICY_PLAIN); @@ -483,8 +483,8 @@ struct ptlrpc_cli_ctx *plain_lookup_ctx(struct ptlrpc_sec *sec, struct vfs_cred *vcred, int create, int remove_dead) { - struct plain_sec *plsec = sec2plsec(sec); - struct ptlrpc_cli_ctx *ctx; + struct plain_sec *plsec = sec2plsec(sec); + struct ptlrpc_cli_ctx *ctx; read_lock(&plsec->pls_lock); ctx = plsec->pls_ctx; @@ -517,8 +517,8 @@ static int plain_flush_ctx_cache(struct ptlrpc_sec *sec, uid_t uid, int grace, int force) { - struct plain_sec *plsec = sec2plsec(sec); - struct ptlrpc_cli_ctx *ctx; + struct plain_sec *plsec = sec2plsec(sec); + struct ptlrpc_cli_ctx *ctx; /* do nothing unless caller want to flush for 'all' */ if (uid != -1) @@ -540,7 +540,7 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec, int msgsize) { __u32 buflens[PLAIN_PACK_SEGMENTS] = { 0, }; - int alloc_len; + int alloc_len; buflens[PLAIN_PACK_HDR_OFF] = sizeof(struct plain_header); buflens[PLAIN_PACK_MSG_OFF] = msgsize; @@ -635,9 +635,9 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec, struct ptlrpc_request *req, int segment, int newsize) { - struct lustre_msg *newbuf; - int oldsize; - int newmsg_size, newbuf_size; + struct lustre_msg *newbuf; + int oldsize; + int newmsg_size, newbuf_size; LASSERT(req->rq_reqbuf); LASSERT(req->rq_reqbuf_len >= req->rq_reqlen); @@ -709,9 +709,9 @@ static struct ptlrpc_svc_ctx plain_svc_ctx = { static int plain_accept(struct ptlrpc_request *req) { - struct lustre_msg *msg = req->rq_reqbuf; + struct lustre_msg *msg = req->rq_reqbuf; struct plain_header *phdr; - int swabbed; + int swabbed; LASSERT(SPTLRPC_FLVR_POLICY(req->rq_flvr.sf_rpc) == SPTLRPC_POLICY_PLAIN); @@ -780,9 +780,9 @@ int plain_accept(struct ptlrpc_request *req) static int plain_alloc_rs(struct ptlrpc_request *req, int msgsize) { - struct ptlrpc_reply_state *rs; - __u32 buflens[PLAIN_PACK_SEGMENTS] = { 0, }; - int rs_size = sizeof(*rs); + struct ptlrpc_reply_state *rs; + __u32 buflens[PLAIN_PACK_SEGMENTS] = { 0, }; + int rs_size = sizeof(*rs); LASSERT(msgsize % 8 == 0); @@ -833,9 +833,9 @@ static int plain_authorize(struct ptlrpc_request *req) { struct ptlrpc_reply_state *rs = req->rq_reply_state; - struct lustre_msg_v2 *msg = rs->rs_repbuf; - struct plain_header *phdr; - int len; + struct lustre_msg_v2 *msg = rs->rs_repbuf; + struct plain_header *phdr; + int len; LASSERT(rs); LASSERT(msg); @@ -880,10 +880,10 @@ static int plain_svc_unwrap_bulk(struct ptlrpc_request *req, struct ptlrpc_bulk_desc *desc) { - struct ptlrpc_reply_state *rs = req->rq_reply_state; + struct ptlrpc_reply_state *rs = req->rq_reply_state; struct ptlrpc_bulk_sec_desc *bsdr, *bsdv; - struct plain_bulk_token *tokenr; - int rc; + struct plain_bulk_token *tokenr; + int rc; LASSERT(req->rq_bulk_write); LASSERT(req->rq_pack_bulk); @@ -914,10 +914,10 @@ static int plain_svc_wrap_bulk(struct ptlrpc_request *req, struct ptlrpc_bulk_desc *desc) { - struct ptlrpc_reply_state *rs = req->rq_reply_state; + struct ptlrpc_reply_state *rs = req->rq_reply_state; struct ptlrpc_bulk_sec_desc *bsdr, *bsdv; - struct plain_bulk_token *tokenv; - int rc; + struct plain_bulk_token *tokenv; + int rc; LASSERT(req->rq_bulk_read); LASSERT(req->rq_pack_bulk); diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 454d1a8640a5..25ccbcb1772f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -72,7 +72,7 @@ struct mutex ptlrpc_all_services_mutex; struct ptlrpc_request_buffer_desc * ptlrpc_alloc_rqbd(struct ptlrpc_service_part *svcpt) { - struct ptlrpc_service *svc = svcpt->scp_service; + struct ptlrpc_service *svc = svcpt->scp_service; struct ptlrpc_request_buffer_desc *rqbd; rqbd = kzalloc_node(sizeof(*rqbd), GFP_NOFS, @@ -121,10 +121,10 @@ ptlrpc_free_rqbd(struct ptlrpc_request_buffer_desc *rqbd) int ptlrpc_grow_req_bufs(struct ptlrpc_service_part *svcpt, int post) { - struct ptlrpc_service *svc = svcpt->scp_service; + struct ptlrpc_service *svc = svcpt->scp_service; struct ptlrpc_request_buffer_desc *rqbd; - int rc = 0; - int i; + int rc = 0; + int i; if (svcpt->scp_rqbd_allocating) goto try_post; @@ -186,7 +186,7 @@ ptlrpc_save_lock(struct ptlrpc_request *req, struct lustre_handle *lock, int mode, int no_ack) { struct ptlrpc_reply_state *rs = req->rq_reply_state; - int idx; + int idx; LASSERT(rs != NULL); LASSERT(rs->rs_nlocks < RS_MAX_LOCKS); @@ -275,8 +275,8 @@ static void rs_batch_init(struct rs_batch *b) static struct ptlrpc_hr_thread * ptlrpc_hr_select(struct ptlrpc_service_part *svcpt) { - struct ptlrpc_hr_partition *hrp; - unsigned int rotor; + struct ptlrpc_hr_partition *hrp; + unsigned int rotor; if (svcpt->scp_cpt >= 0 && svcpt->scp_service->srv_cptable == ptlrpc_hr.hr_cpt_table) { @@ -431,8 +431,8 @@ static int ptlrpc_server_post_idle_rqbds(struct ptlrpc_service_part *svcpt) { struct ptlrpc_request_buffer_desc *rqbd; - int rc; - int posted = 0; + int rc; + int posted = 0; for (;;) { spin_lock(&svcpt->scp_lock); @@ -489,11 +489,11 @@ static void ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, struct ptlrpc_service_conf *conf) { - struct ptlrpc_service_thr_conf *tc = &conf->psc_thr; - unsigned init; - unsigned total; - unsigned nthrs; - int weight; + struct ptlrpc_service_thr_conf *tc = &conf->psc_thr; + unsigned init; + unsigned total; + unsigned nthrs; + int weight; /* * Common code for estimating & validating threads number. @@ -517,7 +517,7 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, * be up to 8 * nthrs_max */ total = min(tc->tc_nthrs_max * 8, tc->tc_nthrs_user); nthrs = total / svc->srv_ncpts; - init = max(init, nthrs); + init = max(init, nthrs); goto out; } @@ -531,7 +531,7 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, nthrs = tc->tc_nthrs_base; if (svc->srv_ncpts == 1) { - int i; + int i; /* NB: Increase the base number if it's single partition * and total number of cores/HTs is larger or equal to 4. @@ -543,7 +543,7 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, } if (tc->tc_thr_factor != 0) { - int factor = tc->tc_thr_factor; + int factor = tc->tc_thr_factor; const int fade = 4; /* @@ -595,9 +595,9 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, struct ptlrpc_service_part *svcpt, int cpt) { struct ptlrpc_at_array *array; - int size; - int index; - int rc; + int size; + int index; + int rc; svcpt->scp_cpt = cpt; INIT_LIST_HEAD(&svcpt->scp_threads); @@ -627,8 +627,8 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, array = &svcpt->scp_at_array; size = at_est2timeout(at_max); - array->paa_size = size; - array->paa_count = 0; + array->paa_size = size; + array->paa_count = 0; array->paa_deadline = -1; /* allocate memory for scp_at_array (ptlrpc_at_array) */ @@ -683,15 +683,15 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, struct kset *parent, struct dentry *debugfs_entry) { - struct ptlrpc_service_cpt_conf *cconf = &conf->psc_cpt; - struct ptlrpc_service *service; - struct ptlrpc_service_part *svcpt; - struct cfs_cpt_table *cptable; - __u32 *cpts = NULL; - int ncpts; - int cpt; - int rc; - int i; + struct ptlrpc_service_cpt_conf *cconf = &conf->psc_cpt; + struct ptlrpc_service *service; + struct ptlrpc_service_part *svcpt; + struct cfs_cpt_table *cptable; + __u32 *cpts = NULL; + int ncpts; + int cpt; + int rc; + int i; LASSERT(conf->psc_buf.bc_nbufs > 0); LASSERT(conf->psc_buf.bc_buf_size >= @@ -707,7 +707,7 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, } else { ncpts = cfs_cpt_number(cptable); if (cconf->cc_pattern != NULL) { - struct cfs_expr_list *el; + struct cfs_expr_list *el; rc = cfs_expr_list_parse(cconf->cc_pattern, strlen(cconf->cc_pattern), @@ -737,9 +737,9 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, return ERR_PTR(-ENOMEM); } - service->srv_cptable = cptable; - service->srv_cpts = cpts; - service->srv_ncpts = ncpts; + service->srv_cptable = cptable; + service->srv_cpts = cpts; + service->srv_ncpts = ncpts; service->srv_cpt_bits = 0; /* it's zero already, easy to read... */ while ((1 << service->srv_cpt_bits) < cfs_cpt_number(cptable)) @@ -747,18 +747,18 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, /* public members */ spin_lock_init(&service->srv_lock); - service->srv_name = conf->psc_name; - service->srv_watchdog_factor = conf->psc_watchdog_factor; + service->srv_name = conf->psc_name; + service->srv_watchdog_factor = conf->psc_watchdog_factor; INIT_LIST_HEAD(&service->srv_list); /* for safety of cleanup */ /* buffer configuration */ - service->srv_nbuf_per_group = test_req_buffer_pressure ? + service->srv_nbuf_per_group = test_req_buffer_pressure ? 1 : conf->psc_buf.bc_nbufs; - service->srv_max_req_size = conf->psc_buf.bc_req_max_size + + service->srv_max_req_size = conf->psc_buf.bc_req_max_size + SPTLRPC_MAX_PAYLOAD; - service->srv_buf_size = conf->psc_buf.bc_buf_size; - service->srv_rep_portal = conf->psc_buf.bc_rep_portal; - service->srv_req_portal = conf->psc_buf.bc_req_portal; + service->srv_buf_size = conf->psc_buf.bc_buf_size; + service->srv_rep_portal = conf->psc_buf.bc_rep_portal; + service->srv_req_portal = conf->psc_buf.bc_req_portal; /* Increase max reply size to next power of two */ service->srv_max_reply_size = 1; @@ -766,10 +766,10 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, conf->psc_buf.bc_rep_max_size + SPTLRPC_MAX_PAYLOAD) service->srv_max_reply_size <<= 1; - service->srv_thread_name = conf->psc_thr.tc_thr_name; - service->srv_ctx_tags = conf->psc_thr.tc_ctx_tags; - service->srv_hpreq_ratio = PTLRPC_SVC_HP_RATIO; - service->srv_ops = conf->psc_ops; + service->srv_thread_name = conf->psc_thr.tc_thr_name; + service->srv_ctx_tags = conf->psc_thr.tc_ctx_tags; + service->srv_hpreq_ratio = PTLRPC_SVC_HP_RATIO; + service->srv_ops = conf->psc_ops; for (i = 0; i < ncpts; i++) { if (!conf->psc_thr.tc_cpu_affinity) @@ -859,11 +859,11 @@ static void ptlrpc_server_free_request(struct ptlrpc_request *req) void ptlrpc_server_drop_request(struct ptlrpc_request *req) { struct ptlrpc_request_buffer_desc *rqbd = req->rq_rqbd; - struct ptlrpc_service_part *svcpt = rqbd->rqbd_svcpt; - struct ptlrpc_service *svc = svcpt->scp_service; - int refcount; - struct list_head *tmp; - struct list_head *nxt; + struct ptlrpc_service_part *svcpt = rqbd->rqbd_svcpt; + struct ptlrpc_service *svc = svcpt->scp_service; + int refcount; + struct list_head *tmp; + struct list_head *nxt; if (!atomic_dec_and_test(&req->rq_refcount)) return; @@ -1387,7 +1387,7 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) struct ptlrpc_at_array *array = &svcpt->scp_at_array; struct ptlrpc_request *rq, *n; struct list_head work_list; - __u32 index, count; + __u32 index, count; time_t deadline; time_t now = get_seconds(); long delay; @@ -1732,10 +1732,10 @@ static int ptlrpc_server_handle_req_in(struct ptlrpc_service_part *svcpt, struct ptlrpc_thread *thread) { - struct ptlrpc_service *svc = svcpt->scp_service; - struct ptlrpc_request *req; - __u32 deadline; - int rc; + struct ptlrpc_service *svc = svcpt->scp_service; + struct ptlrpc_request *req; + __u32 deadline; + int rc; spin_lock(&svcpt->scp_lock); if (list_empty(&svcpt->scp_req_incoming)) { @@ -1876,11 +1876,11 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, { struct ptlrpc_service *svc = svcpt->scp_service; struct ptlrpc_request *request; - struct timeval work_start; - struct timeval work_end; - long timediff; - int rc; - int fail_opc = 0; + struct timeval work_start; + struct timeval work_end; + long timediff; + int rc; + int fail_opc = 0; request = ptlrpc_server_request_get(svcpt, false); if (request == NULL) @@ -2032,10 +2032,10 @@ static int ptlrpc_handle_rs(struct ptlrpc_reply_state *rs) { struct ptlrpc_service_part *svcpt = rs->rs_svcpt; - struct ptlrpc_service *svc = svcpt->scp_service; - struct obd_export *exp; - int nlocks; - int been_handled; + struct ptlrpc_service *svc = svcpt->scp_service; + struct obd_export *exp; + int nlocks; + int been_handled; exp = rs->rs_export; @@ -2262,10 +2262,10 @@ ptlrpc_wait_event(struct ptlrpc_service_part *svcpt, */ static int ptlrpc_main(void *arg) { - struct ptlrpc_thread *thread = (struct ptlrpc_thread *)arg; - struct ptlrpc_service_part *svcpt = thread->t_svcpt; - struct ptlrpc_service *svc = svcpt->scp_service; - struct ptlrpc_reply_state *rs; + struct ptlrpc_thread *thread = (struct ptlrpc_thread *)arg; + struct ptlrpc_service_part *svcpt = thread->t_svcpt; + struct ptlrpc_service *svc = svcpt->scp_service; + struct ptlrpc_reply_state *rs; struct group_info *ginfo = NULL; struct lu_env *env; int counter = 0, rc = 0; @@ -2464,11 +2464,11 @@ static int hrt_dont_sleep(struct ptlrpc_hr_thread *hrt, */ static int ptlrpc_hr_main(void *arg) { - struct ptlrpc_hr_thread *hrt = (struct ptlrpc_hr_thread *)arg; - struct ptlrpc_hr_partition *hrp = hrt->hrt_partition; - LIST_HEAD (replies); - char threadname[20]; - int rc; + struct ptlrpc_hr_thread *hrt = (struct ptlrpc_hr_thread *)arg; + struct ptlrpc_hr_partition *hrp = hrt->hrt_partition; + LIST_HEAD (replies); + char threadname[20]; + int rc; snprintf(threadname, sizeof(threadname), "ptlrpc_hr%02d_%03d", hrp->hrp_cpt, hrt->hrt_id); @@ -2505,9 +2505,9 @@ static int ptlrpc_hr_main(void *arg) static void ptlrpc_stop_hr_threads(void) { - struct ptlrpc_hr_partition *hrp; - int i; - int j; + struct ptlrpc_hr_partition *hrp; + int i; + int j; ptlrpc_hr.hr_stopping = 1; @@ -2529,12 +2529,12 @@ static void ptlrpc_stop_hr_threads(void) static int ptlrpc_start_hr_threads(void) { - struct ptlrpc_hr_partition *hrp; - int i; - int j; + struct ptlrpc_hr_partition *hrp; + int i; + int j; cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) { - int rc = 0; + int rc = 0; for (j = 0; j < hrp->hrp_nthrs; j++) { struct ptlrpc_hr_thread *hrt = &hrp->hrp_thrs[j]; @@ -2561,9 +2561,9 @@ static int ptlrpc_start_hr_threads(void) static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt) { - struct l_wait_info lwi = { 0 }; - struct ptlrpc_thread *thread; - LIST_HEAD (zombie); + struct l_wait_info lwi = { 0 }; + struct ptlrpc_thread *thread; + LIST_HEAD (zombie); CDEBUG(D_INFO, "Stopping threads for service %s\n", svcpt->scp_service->srv_name); @@ -2612,7 +2612,7 @@ static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt) void ptlrpc_stop_all_threads(struct ptlrpc_service *svc) { struct ptlrpc_service_part *svcpt; - int i; + int i; ptlrpc_service_for_each_part(svcpt, i, svc) { if (svcpt->scp_service != NULL) @@ -2623,9 +2623,9 @@ EXPORT_SYMBOL(ptlrpc_stop_all_threads); int ptlrpc_start_threads(struct ptlrpc_service *svc) { - int rc = 0; - int i; - int j; + int rc = 0; + int i; + int j; /* We require 2 threads min, see note in ptlrpc_server_handle_request */ LASSERT(svc->srv_nthrs_cpt_init >= PTLRPC_NTHRS_INIT); @@ -2654,10 +2654,10 @@ EXPORT_SYMBOL(ptlrpc_start_threads); int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) { - struct l_wait_info lwi = { 0 }; - struct ptlrpc_thread *thread; - struct ptlrpc_service *svc; - int rc; + struct l_wait_info lwi = { 0 }; + struct ptlrpc_thread *thread; + struct ptlrpc_service *svc; + int rc; LASSERT(svcpt != NULL); @@ -2759,12 +2759,12 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) int ptlrpc_hr_init(void) { - struct ptlrpc_hr_partition *hrp; - struct ptlrpc_hr_thread *hrt; - int rc; - int i; - int j; - int weight; + struct ptlrpc_hr_partition *hrp; + struct ptlrpc_hr_thread *hrt; + int rc; + int i; + int j; + int weight; memset(&ptlrpc_hr, 0, sizeof(ptlrpc_hr)); ptlrpc_hr.hr_cpt_table = cfs_cpt_table; @@ -2817,8 +2817,8 @@ out: void ptlrpc_hr_fini(void) { - struct ptlrpc_hr_partition *hrp; - int i; + struct ptlrpc_hr_partition *hrp; + int i; if (ptlrpc_hr.hr_partitions == NULL) return; @@ -2858,8 +2858,8 @@ static void ptlrpc_wait_replies(struct ptlrpc_service_part *svcpt) static void ptlrpc_service_del_atimer(struct ptlrpc_service *svc) { - struct ptlrpc_service_part *svcpt; - int i; + struct ptlrpc_service_part *svcpt; + int i; /* early disarm AT timer... */ ptlrpc_service_for_each_part(svcpt, i, svc) { @@ -2871,11 +2871,11 @@ ptlrpc_service_del_atimer(struct ptlrpc_service *svc) static void ptlrpc_service_unlink_rqbd(struct ptlrpc_service *svc) { - struct ptlrpc_service_part *svcpt; + struct ptlrpc_service_part *svcpt; struct ptlrpc_request_buffer_desc *rqbd; - struct l_wait_info lwi; - int rc; - int i; + struct l_wait_info lwi; + int rc; + int i; /* All history will be culled when the next request buffer is * freed in ptlrpc_service_purge_all() */ @@ -2927,11 +2927,11 @@ ptlrpc_service_unlink_rqbd(struct ptlrpc_service *svc) static void ptlrpc_service_purge_all(struct ptlrpc_service *svc) { - struct ptlrpc_service_part *svcpt; - struct ptlrpc_request_buffer_desc *rqbd; - struct ptlrpc_request *req; - struct ptlrpc_reply_state *rs; - int i; + struct ptlrpc_service_part *svcpt; + struct ptlrpc_request_buffer_desc *rqbd; + struct ptlrpc_request *req; + struct ptlrpc_reply_state *rs; + int i; ptlrpc_service_for_each_part(svcpt, i, svc) { if (svcpt->scp_service == NULL) @@ -2995,9 +2995,9 @@ ptlrpc_service_purge_all(struct ptlrpc_service *svc) static void ptlrpc_service_free(struct ptlrpc_service *svc) { - struct ptlrpc_service_part *svcpt; - struct ptlrpc_at_array *array; - int i; + struct ptlrpc_service_part *svcpt; + struct ptlrpc_at_array *array; + int i; ptlrpc_service_for_each_part(svcpt, i, svc) { if (svcpt->scp_service == NULL) @@ -3056,9 +3056,9 @@ EXPORT_SYMBOL(ptlrpc_unregister_service); * to be shot, so it's intentionally non-aggressive. */ int ptlrpc_svcpt_health_check(struct ptlrpc_service_part *svcpt) { - struct ptlrpc_request *request = NULL; - struct timeval right_now; - long timediff; + struct ptlrpc_request *request = NULL; + struct timeval right_now; + long timediff; do_gettimeofday(&right_now); @@ -3090,8 +3090,8 @@ int ptlrpc_svcpt_health_check(struct ptlrpc_service_part *svcpt) int ptlrpc_service_health_check(struct ptlrpc_service *svc) { - struct ptlrpc_service_part *svcpt; - int i; + struct ptlrpc_service_part *svcpt; + int i; if (svc == NULL) return 0; From d9c90615a4e24135a9881c701ea1f0bc8821d700 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Wed, 3 Jun 2015 16:43:20 -0400 Subject: [PATCH 0807/1163] staging:lustre: assume a kernel build In lnet/lnet/ and lnet/selftest/ assume a kernel build (assume that __KERNEL__ is defined). Remove some common code only needed for user space LNet. Signed-off-by: John L. Hammond Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2675 Reviewed-on: http://review.whamcloud.com/13121 Reviewed-by: James Simmons Reviewed-by: Amir Shehata Reviewed-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/lnet/lib-lnet.h | 215 +----------------- .../lustre/include/linux/lnet/lib-types.h | 20 -- drivers/staging/lustre/lnet/lnet/api-ni.c | 69 +----- drivers/staging/lustre/lnet/lnet/lib-eq.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-md.c | 6 +- drivers/staging/lustre/lnet/lnet/lib-me.c | 6 +- drivers/staging/lustre/lnet/lnet/lib-msg.c | 2 +- 7 files changed, 16 insertions(+), 304 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index d84aa9a4c56d..de9e097b0ecd 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -49,24 +49,17 @@ extern lnet_t the_lnet; /* THE network */ -#if defined(LNET_USE_LIB_FREELIST) -/* 1 CPT, simplify implementation... */ -# define LNET_CPT_MAX_BITS 0 - -#else /* KERNEL and no freelist */ - -# if (BITS_PER_LONG == 32) +#if (BITS_PER_LONG == 32) /* 2 CPTs, allowing more CPTs might make us under memory pressure */ -# define LNET_CPT_MAX_BITS 1 +# define LNET_CPT_MAX_BITS 1 -# else /* 64-bit system */ +#else /* 64-bit system */ /* * 256 CPTs for thousands of CPUs, allowing more CPTs might make us * under risk of consuming all lh_cookie. */ -# define LNET_CPT_MAX_BITS 8 -# endif /* BITS_PER_LONG == 32 */ -#endif +# define LNET_CPT_MAX_BITS 8 +#endif /* BITS_PER_LONG == 32 */ /* max allowed CPT number */ #define LNET_CPT_MAX (1 << LNET_CPT_MAX_BITS) @@ -175,191 +168,9 @@ 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 implementation */ -#define LNET_FL_MAX_MES 2048 -#define LNET_FL_MAX_MDS 2048 -#define LNET_FL_MAX_EQS 512 -#define LNET_FL_MAX_MSGS 2048 /* Outstanding messages */ - -#ifdef LNET_USE_LIB_FREELIST - -int lnet_freelist_init(lnet_freelist_t *fl, int n, int size); -void lnet_freelist_fini(lnet_freelist_t *fl); - -static inline void * -lnet_freelist_alloc(lnet_freelist_t *fl) -{ - /* ALWAYS called with liblock held */ - lnet_freeobj_t *o; - - if (list_empty(&fl->fl_list)) - return NULL; - - o = list_entry(fl->fl_list.next, lnet_freeobj_t, fo_list); - list_del(&o->fo_list); - return (void *)&o->fo_contents; -} - -static inline void -lnet_freelist_free(lnet_freelist_t *fl, void *obj) -{ - /* ALWAYS called with liblock held */ - lnet_freeobj_t *o = list_entry(obj, lnet_freeobj_t, fo_contents); - - list_add(&o->fo_list, &fl->fl_list); -} - static inline lnet_eq_t * lnet_eq_alloc(void) { - /* NEVER called with resource lock held */ - struct lnet_res_container *rec = &the_lnet.ln_eq_container; - lnet_eq_t *eq; - - LASSERT(LNET_CPT_NUMBER == 1); - - lnet_res_lock(0); - eq = (lnet_eq_t *)lnet_freelist_alloc(&rec->rec_freelist); - lnet_res_unlock(0); - - return eq; -} - -static inline void -lnet_eq_free_locked(lnet_eq_t *eq) -{ - /* ALWAYS called with resource lock held */ - struct lnet_res_container *rec = &the_lnet.ln_eq_container; - - LASSERT(LNET_CPT_NUMBER == 1); - lnet_freelist_free(&rec->rec_freelist, eq); -} - -static inline void -lnet_eq_free(lnet_eq_t *eq) -{ - lnet_res_lock(0); - lnet_eq_free_locked(eq); - lnet_res_unlock(0); -} - -static inline lnet_libmd_t * -lnet_md_alloc(lnet_md_t *umd) -{ - /* NEVER called with resource lock held */ - struct lnet_res_container *rec = the_lnet.ln_md_containers[0]; - lnet_libmd_t *md; - - LASSERT(LNET_CPT_NUMBER == 1); - - lnet_res_lock(0); - md = (lnet_libmd_t *)lnet_freelist_alloc(&rec->rec_freelist); - lnet_res_unlock(0); - - if (md != NULL) - INIT_LIST_HEAD(&md->md_list); - - return md; -} - -static inline void -lnet_md_free_locked(lnet_libmd_t *md) -{ - /* ALWAYS called with resource lock held */ - struct lnet_res_container *rec = the_lnet.ln_md_containers[0]; - - LASSERT(LNET_CPT_NUMBER == 1); - lnet_freelist_free(&rec->rec_freelist, md); -} - -static inline void -lnet_md_free(lnet_libmd_t *md) -{ - lnet_res_lock(0); - lnet_md_free_locked(md); - lnet_res_unlock(0); -} - -static inline lnet_me_t * -lnet_me_alloc(void) -{ - /* NEVER called with resource lock held */ - struct lnet_res_container *rec = the_lnet.ln_me_containers[0]; - lnet_me_t *me; - - LASSERT(LNET_CPT_NUMBER == 1); - - lnet_res_lock(0); - me = (lnet_me_t *)lnet_freelist_alloc(&rec->rec_freelist); - lnet_res_unlock(0); - - return me; -} - -static inline void -lnet_me_free_locked(lnet_me_t *me) -{ - /* ALWAYS called with resource lock held */ - struct lnet_res_container *rec = the_lnet.ln_me_containers[0]; - - LASSERT(LNET_CPT_NUMBER == 1); - lnet_freelist_free(&rec->rec_freelist, me); -} - -static inline void -lnet_me_free(lnet_me_t *me) -{ - lnet_res_lock(0); - lnet_me_free_locked(me); - lnet_res_unlock(0); -} - -static inline lnet_msg_t * -lnet_msg_alloc(void) -{ - /* NEVER called with network lock held */ - struct lnet_msg_container *msc = the_lnet.ln_msg_containers[0]; - lnet_msg_t *msg; - - LASSERT(LNET_CPT_NUMBER == 1); - - lnet_net_lock(0); - msg = (lnet_msg_t *)lnet_freelist_alloc(&msc->msc_freelist); - lnet_net_unlock(0); - - if (msg != NULL) { - /* NULL pointers, clear flags etc */ - memset(msg, 0, sizeof(*msg)); - } - return msg; -} - -static inline void -lnet_msg_free_locked(lnet_msg_t *msg) -{ - /* ALWAYS called with network lock held */ - struct lnet_msg_container *msc = the_lnet.ln_msg_containers[0]; - - LASSERT(LNET_CPT_NUMBER == 1); - LASSERT(!msg->msg_onactivelist); - lnet_freelist_free(&msc->msc_freelist, msg); -} - -static inline void -lnet_msg_free(lnet_msg_t *msg) -{ - lnet_net_lock(0); - lnet_msg_free_locked(msg); - lnet_net_unlock(0); -} - -#else /* !LNET_USE_LIB_FREELIST */ - -static inline lnet_eq_t * -lnet_eq_alloc(void) -{ - /* NEVER called with liblock held */ lnet_eq_t *eq; LIBCFS_ALLOC(eq, sizeof(*eq)); @@ -369,14 +180,12 @@ lnet_eq_alloc(void) static inline void lnet_eq_free(lnet_eq_t *eq) { - /* ALWAYS called with resource lock held */ LIBCFS_FREE(eq, sizeof(*eq)); } static inline lnet_libmd_t * lnet_md_alloc(lnet_md_t *umd) { - /* NEVER called with liblock held */ lnet_libmd_t *md; unsigned int size; unsigned int niov; @@ -405,7 +214,6 @@ lnet_md_alloc(lnet_md_t *umd) static inline void lnet_md_free(lnet_libmd_t *md) { - /* ALWAYS called with resource lock held */ unsigned int size; if ((md->md_options & LNET_MD_KIOV) != 0) @@ -419,7 +227,6 @@ lnet_md_free(lnet_libmd_t *md) static inline lnet_me_t * lnet_me_alloc(void) { - /* NEVER called with liblock held */ lnet_me_t *me; LIBCFS_ALLOC(me, sizeof(*me)); @@ -429,14 +236,12 @@ lnet_me_alloc(void) static inline void lnet_me_free(lnet_me_t *me) { - /* ALWAYS called with resource lock held */ LIBCFS_FREE(me, sizeof(*me)); } static inline lnet_msg_t * lnet_msg_alloc(void) { - /* NEVER called with liblock held */ lnet_msg_t *msg; LIBCFS_ALLOC(msg, sizeof(*msg)); @@ -448,18 +253,10 @@ lnet_msg_alloc(void) static inline void lnet_msg_free(lnet_msg_t *msg) { - /* ALWAYS called with network lock held */ LASSERT(!msg->msg_onactivelist); LIBCFS_FREE(msg, sizeof(*msg)); } -#define lnet_eq_free_locked(eq) lnet_eq_free(eq) -#define lnet_md_free_locked(md) lnet_md_free(md) -#define lnet_me_free_locked(me) lnet_me_free(me) -#define lnet_msg_free_locked(msg) lnet_msg_free(msg) - -#endif /* LNET_USE_LIB_FREELIST */ - lnet_libhandle_t *lnet_res_lh_lookup(struct lnet_res_container *rec, __u64 cookie); void lnet_res_lh_initialize(struct lnet_res_container *rec, @@ -467,7 +264,6 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, static inline void lnet_res_lh_invalidate(lnet_libhandle_t *lh) { - /* ALWAYS called with resource lock held */ /* NB: cookie is still useful, don't reset it */ list_del(&lh->lh_hash_chain); } @@ -486,7 +282,6 @@ lnet_eq2handle(lnet_handle_eq_t *handle, lnet_eq_t *eq) static inline lnet_eq_t * lnet_handle2eq(lnet_handle_eq_t *handle) { - /* ALWAYS called with resource lock held */ lnet_libhandle_t *lh; lh = lnet_res_lh_lookup(&the_lnet.ln_eq_container, handle->cookie); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 50537668f59d..41827a0c8f74 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -280,20 +280,6 @@ typedef struct lnet_libmd { #define LNET_MD_FLAG_AUTO_UNLINK (1 << 1) #define LNET_MD_FLAG_ABORTED (1 << 2) -#ifdef LNET_USE_LIB_FREELIST -typedef struct { - void *fl_objs; /* single contiguous array of objects */ - int fl_nobjs; /* the number of them */ - int fl_objsize; /* the size (including overhead) of each of them */ - struct list_head fl_list; /* where they are enqueued */ -} lnet_freelist_t; - -typedef struct { - struct list_head fo_list; /* enqueue on fl_list */ - void *fo_contents; /* aligned contents */ -} lnet_freeobj_t; -#endif - typedef struct { /* info about peers we are trying to fail */ struct list_head tp_list; /* ln_test_peers */ @@ -639,9 +625,6 @@ struct lnet_res_container { __u64 rec_lh_cookie; /* cookie generator */ struct list_head rec_active; /* active resource list */ struct list_head *rec_lh_hash; /* handle hash */ -#ifdef LNET_USE_LIB_FREELIST - lnet_freelist_t rec_freelist; /* freelist for resources */ -#endif }; /* message container */ @@ -654,9 +637,6 @@ struct lnet_msg_container { struct list_head msc_active; /* active message list */ /* threads doing finalization */ void **msc_finalizers; -#ifdef LNET_USE_LIB_FREELIST - lnet_freelist_t msc_freelist; /* freelist for messages */ -#endif }; /* Router Checker states */ diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 2230eb0193a1..0740ab9764ea 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -356,56 +356,6 @@ lnet_counters_reset(void) } EXPORT_SYMBOL(lnet_counters_reset); -#ifdef LNET_USE_LIB_FREELIST - -int -lnet_freelist_init(lnet_freelist_t *fl, int n, int size) -{ - char *space; - - LASSERT(n > 0); - - size += offsetof(lnet_freeobj_t, fo_contents); - - LIBCFS_ALLOC(space, n * size); - if (space == NULL) - return -ENOMEM; - - INIT_LIST_HEAD(&fl->fl_list); - fl->fl_objs = space; - fl->fl_nobjs = n; - fl->fl_objsize = size; - - do { - memset(space, 0, size); - list_add((struct list_head *)space, &fl->fl_list); - space += size; - } while (--n != 0); - - return 0; -} - -void -lnet_freelist_fini(lnet_freelist_t *fl) -{ - struct list_head *el; - int count; - - if (fl->fl_nobjs == 0) - return; - - count = 0; - for (el = fl->fl_list.next; el != &fl->fl_list; el = el->next) - count++; - - LASSERT(count == fl->fl_nobjs); - - LIBCFS_FREE(fl->fl_objs, fl->fl_nobjs * fl->fl_objsize); - memset(fl, 0, sizeof(*fl)); -} - -#endif /* LNET_USE_LIB_FREELIST */ - static __u64 lnet_create_interface_cookie(void) { @@ -462,9 +412,6 @@ lnet_res_container_cleanup(struct lnet_res_container *rec) count, lnet_res_type2str(rec->rec_type)); } -#ifdef LNET_USE_LIB_FREELIST - lnet_freelist_fini(&rec->rec_freelist); -#endif if (rec->rec_lh_hash != NULL) { LIBCFS_FREE(rec->rec_lh_hash, LNET_LH_HASH_SIZE * sizeof(rec->rec_lh_hash[0])); @@ -485,13 +432,6 @@ lnet_res_container_setup(struct lnet_res_container *rec, rec->rec_type = type; INIT_LIST_HEAD(&rec->rec_active); - -#ifdef LNET_USE_LIB_FREELIST - memset(&rec->rec_freelist, 0, sizeof(rec->rec_freelist)); - rc = lnet_freelist_init(&rec->rec_freelist, objnum, objsz); - if (rc != 0) - goto out; -#endif rec->rec_lh_cookie = (cpt << LNET_COOKIE_TYPE_BITS) | type; /* Arbitrary choice of hash table size */ @@ -635,13 +575,11 @@ lnet_prepare(lnet_pid_t requested_pid) goto failed; rc = lnet_res_container_setup(&the_lnet.ln_eq_container, 0, - LNET_COOKIE_TYPE_EQ, LNET_FL_MAX_EQS, - sizeof(lnet_eq_t)); + LNET_COOKIE_TYPE_EQ, 0, 0); if (rc != 0) goto failed; - recs = lnet_res_containers_create(LNET_COOKIE_TYPE_ME, LNET_FL_MAX_MES, - sizeof(lnet_me_t)); + recs = lnet_res_containers_create(LNET_COOKIE_TYPE_ME, 0, 0); if (recs == NULL) { rc = -ENOMEM; goto failed; @@ -649,8 +587,7 @@ lnet_prepare(lnet_pid_t requested_pid) the_lnet.ln_me_containers = recs; - recs = lnet_res_containers_create(LNET_COOKIE_TYPE_MD, LNET_FL_MAX_MDS, - sizeof(lnet_libmd_t)); + recs = lnet_res_containers_create(LNET_COOKIE_TYPE_MD, 0, 0); if (recs == NULL) { rc = -ENOMEM; goto failed; diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c index 28858fb215c3..f19ce9ae6a9a 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c @@ -191,7 +191,7 @@ LNetEQFree(lnet_handle_eq_t eqh) lnet_res_lh_invalidate(&eq->eq_lh); list_del(&eq->eq_list); - lnet_eq_free_locked(eq); + lnet_eq_free(eq); out: lnet_eq_wait_unlock(); lnet_res_unlock(LNET_LOCK_EX); diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c index 5856c30503ea..758f5bedef7e 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-md.c +++ b/drivers/staging/lustre/lnet/lnet/lib-md.c @@ -82,7 +82,7 @@ lnet_md_unlink(lnet_libmd_t *md) LASSERT(!list_empty(&md->md_list)); list_del_init(&md->md_list); - lnet_md_free_locked(md); + lnet_md_free(md); } static int @@ -320,7 +320,7 @@ LNetMDAttach(lnet_handle_me_t meh, lnet_md_t umd, return 0; failed: - lnet_md_free_locked(md); + lnet_md_free(md); lnet_res_unlock(cpt); return rc; @@ -381,7 +381,7 @@ LNetMDBind(lnet_md_t umd, lnet_unlink_t unlink, lnet_handle_md_t *handle) return 0; failed: - lnet_md_free_locked(md); + lnet_md_free(md); lnet_res_unlock(cpt); return rc; diff --git a/drivers/staging/lustre/lnet/lnet/lib-me.c b/drivers/staging/lustre/lnet/lnet/lib-me.c index 09e90087c74a..42fc99ef9f80 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-me.c +++ b/drivers/staging/lustre/lnet/lnet/lib-me.c @@ -172,7 +172,7 @@ LNetMEInsert(lnet_handle_me_t current_meh, current_me = lnet_handle2me(¤t_meh); if (current_me == NULL) { - lnet_me_free_locked(new_me); + lnet_me_free(new_me); lnet_res_unlock(cpt); return -ENOENT; @@ -183,7 +183,7 @@ LNetMEInsert(lnet_handle_me_t current_meh, ptl = the_lnet.ln_portals[current_me->me_portal]; if (lnet_ptl_is_unique(ptl)) { /* nosense to insertion on unique portal */ - lnet_me_free_locked(new_me); + lnet_me_free(new_me); lnet_res_unlock(cpt); return -EPERM; } @@ -276,7 +276,7 @@ lnet_me_unlink(lnet_me_t *me) } lnet_res_lh_invalidate(&me->me_lh); - lnet_me_free_locked(me); + lnet_me_free(me); } #if 0 diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c index 65d7595d6555..43977e8dffbb 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-msg.c +++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c @@ -427,7 +427,7 @@ lnet_complete_msg_locked(lnet_msg_t *msg, int cpt) } lnet_msg_decommit(msg, cpt, status); - lnet_msg_free_locked(msg); + lnet_msg_free(msg); return 0; } From 394453676b87508ae141458105172f0f72f2778c Mon Sep 17 00:00:00 2001 From: James Simmons Date: Wed, 3 Jun 2015 16:43:21 -0400 Subject: [PATCH 0808/1163] staging:lustre: fixup LNet resource container api Both lnet_res_container_setup and lnet_res_container_create have additional parameters that are no longer used with the removal of the FREELIST code. This patch removes the no longer needed function arguments. Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/api-ni.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 0740ab9764ea..9fc3bf6cb052 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -422,8 +422,7 @@ lnet_res_container_cleanup(struct lnet_res_container *rec) } static int -lnet_res_container_setup(struct lnet_res_container *rec, - int cpt, int type, int objnum, int objsz) +lnet_res_container_setup(struct lnet_res_container *rec, int cpt, int type) { int rc = 0; int i; @@ -467,7 +466,7 @@ lnet_res_containers_destroy(struct lnet_res_container **recs) } static struct lnet_res_container ** -lnet_res_containers_create(int type, int objnum, int objsz) +lnet_res_containers_create(int type) { struct lnet_res_container **recs; struct lnet_res_container *rec; @@ -482,7 +481,7 @@ lnet_res_containers_create(int type, int objnum, int objsz) } cfs_percpt_for_each(rec, i, recs) { - rc = lnet_res_container_setup(rec, i, type, objnum, objsz); + rc = lnet_res_container_setup(rec, i, type); if (rc != 0) { lnet_res_containers_destroy(recs); return NULL; @@ -575,11 +574,11 @@ lnet_prepare(lnet_pid_t requested_pid) goto failed; rc = lnet_res_container_setup(&the_lnet.ln_eq_container, 0, - LNET_COOKIE_TYPE_EQ, 0, 0); + LNET_COOKIE_TYPE_EQ); if (rc != 0) goto failed; - recs = lnet_res_containers_create(LNET_COOKIE_TYPE_ME, 0, 0); + recs = lnet_res_containers_create(LNET_COOKIE_TYPE_ME); if (recs == NULL) { rc = -ENOMEM; goto failed; @@ -587,7 +586,7 @@ lnet_prepare(lnet_pid_t requested_pid) the_lnet.ln_me_containers = recs; - recs = lnet_res_containers_create(LNET_COOKIE_TYPE_MD, 0, 0); + recs = lnet_res_containers_create(LNET_COOKIE_TYPE_MD); if (recs == NULL) { rc = -ENOMEM; goto failed; From 2f4246f71d4f302ae57aae804c88fffc4b0478b5 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Wed, 3 Jun 2015 18:38:06 -0400 Subject: [PATCH 0809/1163] staging:lustre: cleanup libcfs lock handling Previously with libcfs being built for user land and kernel space wrappers were created to transparently handle locking. Now that user land support has been removed we delete all those locking wrappers with this patch. Many of those changes landed upstream but some nice cleanups still remain that are pushed in this patch. Signed-off-by: James Simmons Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6245 Reviewed-on: http://review.whamcloud.com/13793 Reviewed-by: Dmitry Eremin Reviewed-by: John L. Hammond Reviewed-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/acceptor.c | 2 +- drivers/staging/lustre/lustre/libcfs/fail.c | 2 +- .../lustre/lustre/libcfs/linux/linux-tracefile.c | 4 +--- drivers/staging/lustre/lustre/libcfs/module.c | 11 ++--------- drivers/staging/lustre/lustre/libcfs/tracefile.c | 2 +- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c index 69d4b193dd75..954f8d3fcebc 100644 --- a/drivers/staging/lustre/lnet/lnet/acceptor.c +++ b/drivers/staging/lustre/lnet/lnet/acceptor.c @@ -35,9 +35,9 @@ */ #define DEBUG_SUBSYSTEM S_LNET +#include #include "../../include/linux/lnet/lib-lnet.h" - static int accept_port = 988; static int accept_backlog = 127; static int accept_timeout = 5; diff --git a/drivers/staging/lustre/lustre/libcfs/fail.c b/drivers/staging/lustre/lustre/libcfs/fail.c index 92444b0fe2a3..7b7fc215e633 100644 --- a/drivers/staging/lustre/lustre/libcfs/fail.c +++ b/drivers/staging/lustre/lustre/libcfs/fail.c @@ -41,7 +41,7 @@ EXPORT_SYMBOL(cfs_fail_loc); unsigned int cfs_fail_val = 0; EXPORT_SYMBOL(cfs_fail_val); -wait_queue_head_t cfs_race_waitq; +DECLARE_WAIT_QUEUE_HEAD(cfs_race_waitq); EXPORT_SYMBOL(cfs_race_waitq); int cfs_race_state; diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c index 483cbc82e538..eb10e3b478aa 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c @@ -49,7 +49,7 @@ static unsigned int pages_factor[CFS_TCD_TYPE_MAX] = { char *cfs_trace_console_buffers[NR_CPUS][CFS_TCD_TYPE_MAX]; -struct rw_semaphore cfs_tracefile_sem; +static DECLARE_RWSEM(cfs_tracefile_sem); int cfs_tracefile_init_arch(void) { @@ -57,8 +57,6 @@ int cfs_tracefile_init_arch(void) int j; struct cfs_trace_cpu_data *tcd; - init_rwsem(&cfs_tracefile_sem); - /* initialize trace_data */ memset(cfs_trace_data, 0, sizeof(cfs_trace_data)); for (i = 0; i < CFS_TCD_TYPE_MAX; i++) { diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c index 83b1a708b1e3..e60b2e9b9194 100644 --- a/drivers/staging/lustre/lustre/libcfs/module.c +++ b/drivers/staging/lustre/lustre/libcfs/module.c @@ -66,8 +66,6 @@ MODULE_DESCRIPTION("Portals v3.1"); MODULE_LICENSE("GPL"); extern struct miscdevice libcfs_dev; -extern struct rw_semaphore cfs_tracefile_sem; -extern struct mutex cfs_trace_thread_mutex; extern struct cfs_wi_sched *cfs_sched_rehash; extern void libcfs_init_nidstrings(void); @@ -248,8 +246,8 @@ static int libcfs_psdev_release(unsigned long flags, void *args) return 0; } -static struct rw_semaphore ioctl_list_sem; -static struct list_head ioctl_list; +static DECLARE_RWSEM(ioctl_list_sem); +static LIST_HEAD(ioctl_list); int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand) { @@ -392,11 +390,6 @@ static int init_libcfs_module(void) libcfs_arch_init(); libcfs_init_nidstrings(); - init_rwsem(&cfs_tracefile_sem); - mutex_init(&cfs_trace_thread_mutex); - init_rwsem(&ioctl_list_sem); - INIT_LIST_HEAD(&ioctl_list); - init_waitqueue_head(&cfs_race_waitq); rc = libcfs_debug_init(5 * 1024 * 1024); if (rc < 0) { diff --git a/drivers/staging/lustre/lustre/libcfs/tracefile.c b/drivers/staging/lustre/lustre/libcfs/tracefile.c index c86394f7f4d9..6ee2adcf8890 100644 --- a/drivers/staging/lustre/lustre/libcfs/tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/tracefile.c @@ -52,7 +52,7 @@ union cfs_trace_data_union (*cfs_trace_data[TCD_MAX_TYPES])[NR_CPUS] __cacheline char cfs_tracefile[TRACEFILE_NAME_SIZE]; long long cfs_tracefile_size = CFS_TRACEFILE_SIZE; static struct tracefiled_ctl trace_tctl; -struct mutex cfs_trace_thread_mutex; +static DEFINE_MUTEX(cfs_trace_thread_mutex); static int thread_running; static atomic_t cfs_tage_allocated = ATOMIC_INIT(0); From 02b310794b8aa34573ef657b694b8f1f18ef4abf Mon Sep 17 00:00:00 2001 From: Xavier Roche Date: Fri, 5 Jun 2015 10:19:20 +0200 Subject: [PATCH 0810/1163] staging: lustre: fixed const warnings (struct seq_operations should be const in these contexts) Minor warnings spotted by checkpatch.pl in lustre regarding const correctness: struct seq_operations should be const. Signed-off-by: Xavier Roche Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/vvp_dev.c | 2 +- drivers/staging/lustre/lustre/lmv/lproc_lmv.c | 2 +- drivers/staging/lustre/lustre/lov/lov_pool.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index 2aae5f5fa8ea..b8f6a8779fd3 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c @@ -517,7 +517,7 @@ static void vvp_pgcache_stop(struct seq_file *f, void *v) /* Nothing to do */ } -static struct seq_operations vvp_pgcache_ops = { +static const struct seq_operations vvp_pgcache_ops = { .start = vvp_pgcache_start, .next = vvp_pgcache_next, .stop = vvp_pgcache_stop, diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index 8583fe229cdd..311fc1b70c4d 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -177,7 +177,7 @@ static int lmv_tgt_seq_show(struct seq_file *p, void *v) return 0; } -static struct seq_operations lmv_tgt_sops = { +static const struct seq_operations lmv_tgt_sops = { .start = lmv_tgt_seq_start, .stop = lmv_tgt_seq_stop, .next = lmv_tgt_seq_next, diff --git a/drivers/staging/lustre/lustre/lov/lov_pool.c b/drivers/staging/lustre/lustre/lov/lov_pool.c index 3c46c368cf13..1e4d3fbee323 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pool.c +++ b/drivers/staging/lustre/lustre/lov/lov_pool.c @@ -268,7 +268,7 @@ static int pool_proc_show(struct seq_file *s, void *v) return 0; } -static struct seq_operations pool_proc_ops = { +static const struct seq_operations pool_proc_ops = { .start = pool_proc_start, .next = pool_proc_next, .stop = pool_proc_stop, From b815555df8ede8aca07ff72d3fbe7727a008620e Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 5 Jun 2015 12:22:57 +0300 Subject: [PATCH 0811/1163] Staging: lustre: ptlrpc: signedness bug in high_priority_ratio_store() We want to store a non-negative int here. The original code had a check for unsigned long less than zero which is a mistake but also casting from a positive long to an int can result in a negative number. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index c04ae50c2c29..aaaabbf5f1b9 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -1035,9 +1035,9 @@ static ssize_t high_priority_ratio_store(struct kobject *kobj, struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service, srv_kobj); int rc; - unsigned long val; + int val; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtoint(buffer, 10, &val); if (rc < 0) return rc; From 1c01737a4b6450553cc2fd387b27847d408ca936 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 5 Jun 2015 12:23:31 +0300 Subject: [PATCH 0812/1163] Staging: Lustre: lproc_fid: remove some dead code We know "rc == 0" so there is no need to check. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/fid/lproc_fid.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c b/drivers/staging/lustre/lustre/fid/lproc_fid.c index 41ab2eeaf18c..cc2201c25339 100644 --- a/drivers/staging/lustre/lustre/fid/lproc_fid.c +++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c @@ -157,10 +157,8 @@ ldebugfs_fid_width_seq_write(struct file *file, if (val <= max && val > 0) { seq->lcs_width = val; - if (rc == 0) { - CDEBUG(D_INFO, "%s: Sequence size: %llu\n", - seq->lcs_name, seq->lcs_width); - } + CDEBUG(D_INFO, "%s: Sequence size: %llu\n", seq->lcs_name, + seq->lcs_width); } mutex_unlock(&seq->lcs_mutex); From 8fd18211d645a8af72396238c3df5b62049a6b1e Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 8 Jun 2015 14:53:18 +0200 Subject: [PATCH 0813/1163] lustre: lov: Drop lov_lock_handles structure The lov_lock_handles structure is only used as the type of the field set_lockh in the lov_request_set structure, and this field is never set to any value. Drop a test and free of this field in lov_finish_set. This change enables also removing the functions lov_handle2llh and lov_llh_put that manipulate values of type lov_lock_handles, but are now never called. Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/lov/lov_internal.h | 34 ------------------- .../staging/lustre/lustre/lov/lov_request.c | 3 -- 2 files changed, 37 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h index 5e8bcc6ba01a..f52a90c8caf7 100644 --- a/drivers/staging/lustre/lustre/lov/lov_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h @@ -71,13 +71,6 @@ }) #endif -struct lov_lock_handles { - struct portals_handle llh_handle; - atomic_t llh_refcount; - int llh_stripe_count; - struct lustre_handle llh_handles[0]; -}; - struct lov_request { struct obd_info rq_oi; struct lov_request_set *rq_rqset; @@ -111,7 +104,6 @@ struct lov_request_set { struct obd_trans_info *set_oti; u32 set_oabufs; struct brw_page *set_pga; - struct lov_lock_handles *set_lockh; struct list_head set_list; wait_queue_head_t set_waitq; spinlock_t set_lock; @@ -136,32 +128,6 @@ static inline void lov_put_reqset(struct lov_request_set *set) lov_finish_set(set); } -static inline struct lov_lock_handles * -lov_handle2llh(struct lustre_handle *handle) -{ - LASSERT(handle != NULL); - return class_handle2object(handle->cookie); -} - -static inline void lov_llh_put(struct lov_lock_handles *llh) -{ - CDEBUG(D_INFO, "PUTting llh %p : new refcount %d\n", llh, - atomic_read(&llh->llh_refcount) - 1); - LASSERT(atomic_read(&llh->llh_refcount) > 0 && - atomic_read(&llh->llh_refcount) < 0x5a5a); - if (atomic_dec_and_test(&llh->llh_refcount)) { - class_handle_unhash(&llh->llh_handle); - /* The structure may be held by other threads because RCU. - * -jxiong */ - if (atomic_read(&llh->llh_refcount)) - return; - - OBD_FREE_RCU(llh, sizeof(*llh) + - sizeof(*llh->llh_handles) * llh->llh_stripe_count, - &llh->llh_handle); - } -} - #define lov_uuid2str(lv, index) \ (char *)((lv)->lov_tgts[index]->ltd_uuid.uuid) diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index f6e13149d2ad..7769f149af92 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -78,9 +78,6 @@ void lov_finish_set(struct lov_request_set *set) int len = set->set_oabufs * sizeof(*set->set_pga); OBD_FREE_LARGE(set->set_pga, len); } - if (set->set_lockh) - lov_llh_put(set->set_lockh); - kfree(set); } From 2b692c2e9be1c41fd450db0bace2141e3ba8fa27 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 8 Jun 2015 14:53:19 +0200 Subject: [PATCH 0814/1163] lustre: lov: Drop unneeded set_oabufs and set_pga fields The fields set_oabufs and set_pga fields in the lov_request_set structure are never set, so drop them. Drop also the corresponding test and free in lov_finish_set. Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lov/lov_internal.h | 2 -- drivers/staging/lustre/lustre/lov/lov_request.c | 5 ----- 2 files changed, 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h index f52a90c8caf7..e4e0cfdfd8ea 100644 --- a/drivers/staging/lustre/lustre/lov/lov_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h @@ -102,8 +102,6 @@ struct lov_request_set { struct llog_cookie *set_cookies; int set_cookie_sent; struct obd_trans_info *set_oti; - u32 set_oabufs; - struct brw_page *set_pga; struct list_head set_list; wait_queue_head_t set_waitq; spinlock_t set_lock; diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index 7769f149af92..ada0a3cf1c0f 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -73,11 +73,6 @@ void lov_finish_set(struct lov_request_set *set) kfree(req->rq_oi.oi_osfs); kfree(req); } - - if (set->set_pga) { - int len = set->set_oabufs * sizeof(*set->set_pga); - OBD_FREE_LARGE(set->set_pga, len); - } kfree(set); } From 2d78b3c1ec6299654d3857928db718c64e62d494 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 8 Jun 2015 14:53:20 +0200 Subject: [PATCH 0815/1163] lustre: lov: Drop rq_buflen field The rq_buflen field of the lov_request structure is never initialized. It is only used in the free of req->rq_oi.oi_md in lov_finish_set. But no oi_md field is ever initialized to the result of calling OBD_ALLOC_LARGE. So it seems that the call to OBD_FREE_LARGE in lov_finish_set and the rq_buflen in the lov_request structure are simply not needed. Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lov/lov_internal.h | 1 - drivers/staging/lustre/lustre/lov/lov_request.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h index e4e0cfdfd8ea..dde9656d4dd6 100644 --- a/drivers/staging/lustre/lustre/lov/lov_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h @@ -81,7 +81,6 @@ struct lov_request { int rq_stripe; /* stripe number */ int rq_complete; int rq_rc; - int rq_buflen; /* length of sub_md */ u32 rq_oabufs; u32 rq_pgaidx; diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index ada0a3cf1c0f..f4f2058abd2b 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -68,8 +68,6 @@ void lov_finish_set(struct lov_request_set *set) if (req->rq_oi.oi_oa) OBDO_FREE(req->rq_oi.oi_oa); - if (req->rq_oi.oi_md) - OBD_FREE_LARGE(req->rq_oi.oi_md, req->rq_buflen); kfree(req->rq_oi.oi_osfs); kfree(req); } From 52db7520775e5c4103e0e06a61abbadcf73d2d96 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Tue, 2 Jun 2015 14:28:17 +0530 Subject: [PATCH 0816/1163] staging: wilc1000: fix warning while printing size_t should print using %zu and unsigned long int should use %lu but here it was using %d and hence we were getting warning while printing. Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_spi.c | 2 +- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c index d0e761080ca5..6d854fd9101d 100644 --- a/drivers/staging/wilc1000/wilc_spi.c +++ b/drivers/staging/wilc1000/wilc_spi.c @@ -404,7 +404,7 @@ static int spi_cmd_complete(uint8_t cmd, uint32_t adr, uint8_t *b, uint32_t sz, #undef NUM_DUMMY_BYTES if (len2 > (sizeof(wb) / sizeof(wb[0]))) { - PRINT_ER("[wilc spi]: spi buffer size too small (%d) (%d)\n", + PRINT_ER("[wilc spi]: spi buffer size too small (%d) (%lu)\n", len2, (sizeof(wb) / sizeof(wb[0]))); result = N_FAIL; return result; diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index f5eff0933e7d..cbee14e19d9c 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -638,7 +638,7 @@ static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent, } - PRINT_D(CFG80211_DBG, "Association request info elements length = %d\n", pstrConnectInfo->ReqIEsLen); + PRINT_D(CFG80211_DBG, "Association request info elements length = %zu\n", pstrConnectInfo->ReqIEsLen); PRINT_D(CFG80211_DBG, "Association response info elements length = %d\n", pstrConnectInfo->u16RespIEsLen); @@ -778,7 +778,7 @@ static int WILC_WFI_CfgScan(struct wiphy *wiphy, struct cfg80211_scan_request *r } PRINT_D(CFG80211_DBG, "Requested num of scan channel %d\n", request->n_channels); - PRINT_D(CFG80211_DBG, "Scan Request IE len = %d\n", request->ie_len); + PRINT_D(CFG80211_DBG, "Scan Request IE len = %zu\n", request->ie_len); PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids); @@ -3316,7 +3316,7 @@ static int WILC_WFI_start_ap(struct wiphy *wiphy, struct net_device *dev, priv = wiphy_priv(wiphy); PRINT_D(HOSTAPD_DBG, "Starting ap\n"); - PRINT_D(HOSTAPD_DBG, "Interval = %d \n DTIM period = %d\n Head length = %d Tail length = %d\n", + PRINT_D(HOSTAPD_DBG, "Interval = %d \n DTIM period = %d\n Head length = %zu Tail length = %zu\n", settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len); s32Error = WILC_WFI_CfgSetChannel(wiphy, &settings->chandef); From 0feae20091dd4a1c79e085ce1c0572affdbe6247 Mon Sep 17 00:00:00 2001 From: Chaitanya Dhere Date: Tue, 2 Jun 2015 09:58:50 +0000 Subject: [PATCH 0817/1163] staging: wilc1000: Modification in code to use ARRAY_SIZE macro In this patch, ARRAY_SIZE() macro is used to determine the size. This change was detected with the help of coccinelle tool. Signed-off-by: Chaitanya Dhere Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index b033eb879ca1..592b8aec40e9 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -1737,7 +1737,7 @@ static int linux_wlan_read_mac_addr(void *vp) mm_segment_t old_fs; loff_t pos = 0; int index; - int array_size = sizeof(path_string) / sizeof(path_string[0]); + int array_size = ARRAY_SIZE(path_string); /* change to KERNEL_DS address limit */ old_fs = get_fs(); From 37bc15d8dde2d98a1083757e037678b6287e7555 Mon Sep 17 00:00:00 2001 From: Hari Prasath Gujulan Elango Date: Tue, 2 Jun 2015 12:48:05 +0000 Subject: [PATCH 0818/1163] staging: wilc1000: remove unnecessary typecast Remove ununecessary typecast for kzalloc.This patch was generated by coccinelle tool Signed-off-by: Hari Prasath Gujulan Elango Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan_spi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan_spi.c b/drivers/staging/wilc1000/linux_wlan_spi.c index e5d794590f00..1b3333c32c20 100644 --- a/drivers/staging/wilc1000/linux_wlan_spi.c +++ b/drivers/staging/wilc1000/linux_wlan_spi.c @@ -162,7 +162,7 @@ int linux_spi_write(uint8_t *b, uint32_t len) int blk = len / TXRX_PHASE_SIZE; int remainder = len % TXRX_PHASE_SIZE; - char *r_buffer = (char *) kzalloc(TXRX_PHASE_SIZE, GFP_KERNEL); + char *r_buffer = kzalloc(TXRX_PHASE_SIZE, GFP_KERNEL); if (!r_buffer) { PRINT_ER("Failed to allocate memory for r_buffer\n"); } @@ -260,7 +260,7 @@ int linux_spi_write(uint8_t *b, uint32_t len) .speed_hz = SPEED, .delay_usecs = 0, }; - char *r_buffer = (char *) kzalloc(len, GFP_KERNEL); + char *r_buffer = kzalloc(len, GFP_KERNEL); if (!r_buffer) { PRINT_ER("Failed to allocate memory for r_buffer\n"); } @@ -341,7 +341,7 @@ int linux_spi_read(unsigned char *rb, unsigned long rlen) int blk = rlen / TXRX_PHASE_SIZE; int remainder = rlen % TXRX_PHASE_SIZE; - char *t_buffer = (char *) kzalloc(TXRX_PHASE_SIZE, GFP_KERNEL); + char *t_buffer = kzalloc(TXRX_PHASE_SIZE, GFP_KERNEL); if (!t_buffer) { PRINT_ER("Failed to allocate memory for t_buffer\n"); } @@ -430,7 +430,7 @@ int linux_spi_read(unsigned char *rb, unsigned long rlen) .delay_usecs = 0, }; - char *t_buffer = (char *) kzalloc(rlen, GFP_KERNEL); + char *t_buffer = kzalloc(rlen, GFP_KERNEL); if (!t_buffer) { PRINT_ER("Failed to allocate memory for t_buffer\n"); } From 4d77c6ccfb5e5ac6794cfad0c47dda86385e6010 Mon Sep 17 00:00:00 2001 From: Hari Prasath Gujulan Elango Date: Tue, 2 Jun 2015 12:49:12 +0000 Subject: [PATCH 0819/1163] staging: wilc1000: remove dead code Remove dead code or commented code Signed-off-by: Hari Prasath Gujulan Elango Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan_spi.c | 28 +---------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan_spi.c b/drivers/staging/wilc1000/linux_wlan_spi.c index 1b3333c32c20..1eee1d560bc7 100644 --- a/drivers/staging/wilc1000/linux_wlan_spi.c +++ b/drivers/staging/wilc1000/linux_wlan_spi.c @@ -57,8 +57,6 @@ static int __init wilc_bus_probe(struct spi_device *spi) static int __exit wilc_bus_remove(struct spi_device *spi) { - /* linux_spi_deinit(NULL); */ - return 0; } @@ -172,18 +170,12 @@ int linux_spi_write(uint8_t *b, uint32_t len) struct spi_message msg; struct spi_transfer tr = { .tx_buf = b + (i * TXRX_PHASE_SIZE), - /* .rx_buf = NULL, */ .len = TXRX_PHASE_SIZE, .speed_hz = SPEED, .bits_per_word = 8, .delay_usecs = 0, }; - /* - * char *r_buffer = (char*) kzalloc(TXRX_PHASE_SIZE, GFP_KERNEL); - * if(! r_buffer){ - * PRINT_ER("Failed to allocate memory for r_buffer\n"); - * } - */ + tr.rx_buf = r_buffer; memset(&msg, 0, sizeof(msg)); @@ -196,7 +188,6 @@ int linux_spi_write(uint8_t *b, uint32_t len) if (ret < 0) { PRINT_ER("SPI transaction failed\n"); } - /* i += MJ_WRITE_SIZE; */ i++; } @@ -205,18 +196,11 @@ int linux_spi_write(uint8_t *b, uint32_t len) struct spi_message msg; struct spi_transfer tr = { .tx_buf = b + (blk * TXRX_PHASE_SIZE), - /* .rx_buf = NULL, */ .len = remainder, .speed_hz = SPEED, .bits_per_word = 8, .delay_usecs = 0, }; - /* - * char *r_buffer = (char*) kzalloc(remainder, GFP_KERNEL); - * if(! r_buffer){ - * PRINT_ER("Failed to allocate memory for r_buffer\n"); - * } - */ tr.rx_buf = r_buffer; memset(&msg, 0, sizeof(msg)); @@ -255,7 +239,6 @@ int linux_spi_write(uint8_t *b, uint32_t len) if (len > 0 && b != NULL) { struct spi_transfer tr = { .tx_buf = b, - /* .rx_buf = r_buffer, */ .len = len, .speed_hz = SPEED, .delay_usecs = 0, @@ -350,7 +333,6 @@ int linux_spi_read(unsigned char *rb, unsigned long rlen) while (i < blk) { struct spi_message msg; struct spi_transfer tr = { - /* .tx_buf = NULL, */ .rx_buf = rb + (i * TXRX_PHASE_SIZE), .len = TXRX_PHASE_SIZE, .speed_hz = SPEED, @@ -375,19 +357,12 @@ int linux_spi_read(unsigned char *rb, unsigned long rlen) if (remainder) { struct spi_message msg; struct spi_transfer tr = { - /* .tx_buf = NULL, */ .rx_buf = rb + (blk * TXRX_PHASE_SIZE), .len = remainder, .speed_hz = SPEED, .bits_per_word = 8, .delay_usecs = 0, }; - /* - * char *t_buffer = (char*) kzalloc(remainder, GFP_KERNEL); - * if(! t_buffer){ - * PRINT_ER("Failed to allocate memory for t_buffer\n"); - * } - */ tr.tx_buf = t_buffer; memset(&msg, 0, sizeof(msg)); @@ -423,7 +398,6 @@ int linux_spi_read(unsigned char *rb, unsigned long rlen) if (rlen > 0) { struct spi_message msg; struct spi_transfer tr = { - /* .tx_buf = t_buffer, */ .rx_buf = rb, .len = rlen, .speed_hz = SPEED, From 1a093b5fcd4ca202ee2024134dae7620eb150d59 Mon Sep 17 00:00:00 2001 From: Hari Prasath Gujulan yyElango Date: Tue, 2 Jun 2015 12:50:37 +0000 Subject: [PATCH 0820/1163] staging: wilc1000: use time_after_eq use the time_after_eq macro for the comparison operation Signed-off-by: Hari Prasath Gujulan yyElango Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index cbee14e19d9c..fd474d7c232c 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -2296,7 +2296,7 @@ void WILC_WFI_p2p_rx (struct net_device *dev, uint8_t *buff, uint32_t size) if (ieee80211_is_action(buff[FRAME_TYPE_ID])) { PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]); - if (priv->bCfgScanning == WILC_TRUE && jiffies >= pstrWFIDrv->u64P2p_MgmtTimeout) { + if (priv->bCfgScanning == WILC_TRUE && time_after_eq(jiffies, pstrWFIDrv->u64P2p_MgmtTimeout)) { PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n"); return; } From aa02a9392e68154a0ab7b897cbf541eb6afbfb44 Mon Sep 17 00:00:00 2001 From: Hari Prasath Gujulan Elango Date: Wed, 3 Jun 2015 09:07:44 +0000 Subject: [PATCH 0821/1163] staging: wilc1000: remove ununsed function The function WILC_WFI_InitPriv() is not used anywhere in the driver.Hence remove it. Signed-off-by: Hari Prasath Gujulan Elango Signed-off-by: Greg Kroah-Hartman --- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index fd474d7c232c..7807e23ba9a4 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -3796,30 +3796,7 @@ int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed) #endif return 0; } -/** - * @brief WILC_WFI_InitPriv - * @details Initialization of the net device, private data - * @param[in] NONE - * @return NONE - * @author mdaftedar - * @date 01 MAR 2012 - * @version 1.0 - */ -void WILC_WFI_InitPriv(struct net_device *dev) -{ - struct WILC_WFI_priv *priv; - priv = netdev_priv(dev); - - priv->netstats.rx_packets = 0; - priv->netstats.tx_packets = 0; - priv->netstats.rx_bytes = 0; - priv->netstats.rx_bytes = 0; - priv->netstats.rx_time = 0; - priv->netstats.tx_time = 0; - - -} /** * @brief WILC_WFI_CfgAlloc * @details Allocation of the wireless device structure and assigning it From 0dcbea196b4e62c3c81a3ba823c3e071b6835d01 Mon Sep 17 00:00:00 2001 From: Hari Prasath Gujulan Elango Date: Wed, 3 Jun 2015 09:08:16 +0000 Subject: [PATCH 0822/1163] staging: wilc1000: remove commented code Remove commented code from this file. Signed-off-by: Hari Prasath Gujulan Elango Signed-off-by: Greg Kroah-Hartman --- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 117 ------------------ 1 file changed, 117 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 7807e23ba9a4..0db7f3dfc352 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -606,9 +606,6 @@ static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent, pstrConnectInfo->au8bssid[1], pstrConnectInfo->au8bssid[2], pstrConnectInfo->au8bssid[3], pstrConnectInfo->au8bssid[4], pstrConnectInfo->au8bssid[5]); WILC_memcpy(priv->au8AssociatedBss, pstrConnectInfo->au8bssid, ETH_ALEN); - /* set bssid in frame filter */ - /* linux_wlan_set_bssid(dev,pstrConnectInfo->au8bssid); */ - /* BugID_4209: if this network has expired in the scan results in the above nl80211 layer, refresh them here by calling * cfg80211_inform_bss() with the last Scan results before calling cfg80211_connect_result() to avoid * Linux kernel warning generated at the nl80211 layer */ @@ -628,7 +625,6 @@ static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent, } if (bNeedScanRefresh == WILC_TRUE) { - /* RefreshScanResult(priv); */ /*BugID_5418*/ /*Also, refrsh DIRECT- results if */ refresh_scan(priv, 1, WILC_TRUE); @@ -747,19 +743,6 @@ static int WILC_WFI_CfgScan(struct wiphy *wiphy, struct cfg80211_scan_request *r priv = wiphy_priv(wiphy); - /*if(connecting) - * return -EBUSY; */ - - /*BugID_4800: if in AP mode, return.*/ - /*This check is to handle the situation when user*/ - /*requests "create group" during a running scan*/ - /* host_int_set_wfi_drv_handler(priv->hWILCWFIDrv); */ -#if 0 - if (priv->dev->ieee80211_ptr->iftype == NL80211_IFTYPE_AP) { - PRINT_D(GENERIC_DBG, "Required scan while in AP mode"); - return s32Error; - } -#endif /* end of if 0 */ priv->pstrScanReq = request; priv->u32RcvdChCount = 0; @@ -844,7 +827,6 @@ static int WILC_WFI_CfgConnect(struct wiphy *wiphy, struct net_device *dev, { WILC_Sint32 s32Error = WILC_SUCCESS; WILC_Uint32 i; - /* SECURITY_T tenuSecurity_t = NO_SECURITY; */ u8 u8security = NO_ENCRYPT; AUTHTYPE_T tenuAuth_type = ANY; WILC_Char *pcgroup_encrypt_val; @@ -862,7 +844,6 @@ static int WILC_WFI_CfgConnect(struct wiphy *wiphy, struct net_device *dev, host_int_set_wfi_drv_handler((WILC_Uint32)priv->hWILCWFIDrv); - /* host_int_set_wfi_drv_handler((WILC_Uint32)priv->hWILCWFIDrv); */ PRINT_D(CFG80211_DBG, "Connecting to SSID [%s] on netdev [%p] host if [%x]\n", sme->ssid, dev, (WILC_Uint32)priv->hWILCWFIDrv); #ifdef WILC_P2P if (!(WILC_strncmp(sme->ssid, "DIRECT-", 7))) { @@ -935,9 +916,7 @@ static int WILC_WFI_CfgConnect(struct wiphy *wiphy, struct net_device *dev, * we will add to it the pairwise cipher suite(s) */ pcwpa_version = "Default"; PRINT_D(CORECONFIG_DBG, ">> sme->crypto.wpa_versions: %x\n", sme->crypto.wpa_versions); - /* case NL80211_WPA_VERSION_1: */ if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) { - /* tenuSecurity_t = WEP_40; */ u8security = ENCRYPT_ENABLED | WEP; pcgroup_encrypt_val = "WEP40"; pccipher_group = "WLAN_CIPHER_SUITE_WEP40"; @@ -961,7 +940,6 @@ static int WILC_WFI_CfgConnect(struct wiphy *wiphy, struct net_device *dev, host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx); host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx); } else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) { - /* tenuSecurity_t = WEP_104; */ u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED; pcgroup_encrypt_val = "WEP104"; pccipher_group = "WLAN_CIPHER_SUITE_WEP104"; @@ -980,9 +958,7 @@ static int WILC_WFI_CfgConnect(struct wiphy *wiphy, struct net_device *dev, host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx); host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx); } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) { - /* case NL80211_WPA_VERSION_2: */ if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) { - /* tenuSecurity_t = WPA2_TKIP; */ u8security = ENCRYPT_ENABLED | WPA2 | TKIP; pcgroup_encrypt_val = "WPA2_TKIP"; pccipher_group = "TKIP"; @@ -995,7 +971,6 @@ static int WILC_WFI_CfgConnect(struct wiphy *wiphy, struct net_device *dev, pcwpa_version = "WPA_VERSION_2"; } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) { if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) { - /* tenuSecurity_t = WPA_TKIP; */ u8security = ENCRYPT_ENABLED | WPA | TKIP; pcgroup_encrypt_val = "WPA_TKIP"; pccipher_group = "TKIP"; @@ -1008,7 +983,6 @@ static int WILC_WFI_CfgConnect(struct wiphy *wiphy, struct net_device *dev, } pcwpa_version = "WPA_VERSION_1"; - /* break; */ } else { s32Error = -ENOTSUPP; PRINT_ER("Not supported cipher: Error(%d)\n", s32Error); @@ -1379,7 +1353,6 @@ static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 k host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen, key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, STATION_MODE, u8mode); - /* host_int_add_tx_gtk(priv->hWILCWFIDrv,params->key_len,params->key,key_index); */ } else { if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { /* swap the tx mic by rx mic */ @@ -1851,7 +1824,6 @@ static int WILC_WFI_set_wiphy_params(struct wiphy *wiphy, u32 changed) struct WILC_WFI_priv *priv; priv = wiphy_priv(wiphy); -/* priv = netdev_priv(priv->wdev->netdev); */ pstrCfgParamVal.u32SetCfgFlag = 0; PRINT_D(CFG80211_DBG, "Setting Wiphy params \n"); @@ -1907,22 +1879,8 @@ static int WILC_WFI_set_bitrate_mask(struct wiphy *wiphy, const struct cfg80211_bitrate_mask *mask) { WILC_Sint32 s32Error = WILC_SUCCESS; - /* strCfgParamVal pstrCfgParamVal; */ - /* struct WILC_WFI_priv* priv; */ PRINT_D(CFG80211_DBG, "Setting Bitrate mask function\n"); -#if 0 - priv = wiphy_priv(wiphy); - /* priv = netdev_priv(priv->wdev->netdev); */ - - pstrCfgParamVal.curr_tx_rate = mask->control[IEEE80211_BAND_2GHZ].legacy; - - PRINT_D(CFG80211_DBG, "Tx rate = %d\n", pstrCfgParamVal.curr_tx_rate); - s32Error = hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal); - - if (s32Error) - PRINT_ER("Error in setting bitrate\n"); -#endif return s32Error; } @@ -1997,7 +1955,6 @@ static int WILC_WFI_del_pmksa(struct wiphy *wiphy, struct net_device *netdev, WILC_Sint32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv = wiphy_priv(wiphy); - /* priv = netdev_priv(priv->wdev->netdev); */ PRINT_D(CFG80211_DBG, "Deleting PMKSA keys\n"); @@ -2041,7 +1998,6 @@ static int WILC_WFI_del_pmksa(struct wiphy *wiphy, struct net_device *netdev, static int WILC_WFI_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) { struct WILC_WFI_priv *priv = wiphy_priv(wiphy); - /* priv = netdev_priv(priv->wdev->netdev); */ PRINT_D(CFG80211_DBG, "Flushing PMKID key values\n"); @@ -2827,26 +2783,11 @@ static int WILC_WFI_dump_station(struct wiphy *wiphy, struct net_device *dev, return -ENOENT; priv = wiphy_priv(wiphy); - /* priv = netdev_priv(priv->wdev->netdev); */ sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL); host_int_get_rssi(priv->hWILCWFIDrv, &(sinfo->signal)); -#if 0 - sinfo->filled |= STATION_INFO_TX_BYTES | - STATION_INFO_TX_PACKETS | - STATION_INFO_RX_BYTES | - STATION_INFO_RX_PACKETS | STATION_INFO_SIGNAL | STATION_INFO_INACTIVE_TIME; - - down(&SemHandleUpdateStats); - sinfo->inactive_time = priv->netstats.rx_time > priv->netstats.tx_time ? jiffies_to_msecs(jiffies - priv->netstats.tx_time) : jiffies_to_msecs(jiffies - priv->netstats.rx_time); - sinfo->rx_bytes = priv->netstats.rx_bytes; - sinfo->tx_bytes = priv->netstats.tx_bytes; - sinfo->rx_packets = priv->netstats.rx_packets; - sinfo->tx_packets = priv->netstats.tx_packets; - up(&SemHandleUpdateStats); -#endif return 0; } @@ -2902,7 +2843,6 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev { WILC_Sint32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv; - /* struct WILC_WFI_mon_priv* mon_priv; */ perInterface_wlan_t *nic; u8 interface_type; WILC_Uint16 TID = 0; @@ -2935,7 +2875,6 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev case NL80211_IFTYPE_STATION: connecting = 0; PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n"); - /* linux_wlan_set_bssid(dev,g_linux_wlan->strInterfaceInfo[0].aSrcAddress); */ /* send delba over wlan interface */ @@ -3033,7 +2972,6 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0); connecting = 0; PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n"); - /* linux_wlan_set_bssid(dev,g_linux_wlan->strInterfaceInfo[0].aSrcAddress); */ host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID); @@ -3119,12 +3057,8 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev break; case NL80211_IFTYPE_AP: - /* connecting = 1; */ bEnablePS = WILC_FALSE; PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type); - /* linux_wlan_set_bssid(dev,g_linux_wlan->strInterfaceInfo[0].aSrcAddress); */ - /* mon_priv = netdev_priv(dev); */ - /* mon_priv->real_ndev = dev; */ dev->ieee80211_ptr->iftype = type; priv->wdev->iftype = type; nic->iftype = AP_MODE; @@ -3141,11 +3075,6 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev mac_close(dev); mac_open(dev); - /* wilc1000_wlan_deinit(g_linux_wlan); */ - /* wilc1000_wlan_init(dev,nic); */ - /* repeat_power_cycle(nic); */ - /* nic->iftype = STATION_MODE; */ - /*BugID_4847: registered frames in firmware are now lost * due to mac close. So re-register those frames */ for (i = 0; i < num_reg_frame; i++) { @@ -3176,14 +3105,10 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID); bEnablePS = WILC_FALSE; PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n"); - /* linux_wlan_set_bssid(dev,g_linux_wlan->strInterfaceInfo[0].aSrcAddress); */ - /* mon_priv = netdev_priv(dev); */ - /* mon_priv->real_ndev = dev; */ dev->ieee80211_ptr->iftype = type; priv->wdev->iftype = type; PRINT_D(CORECONFIG_DBG, "(WILC_Uint32)priv->hWILCWFIDrv[%x]\n", (WILC_Uint32)priv->hWILCWFIDrv); - /* host_int_set_operation_mode((WILC_Uint32)priv->hWILCWFIDrv,AP_MODE); */ #ifndef SIMULATION #ifdef WILC_P2P @@ -3195,14 +3120,7 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev /* ensure that the message Q is empty */ host_int_wait_msg_queue_idle(); - - /*while(!g_hif_thread_idle) - * { - * PRINT_D(GENERIC_DBG, "Wait for host IF idle\n"); - * WILC_Sleep(10); - * }*/ wilc1000_wlan_deinit(g_linux_wlan); - /* repeat_power_cycle_partially(g_linux_wlan); */ wilc1000_wlan_init(dev, nic); g_wilc_initialized = 1; @@ -3523,8 +3441,6 @@ static int WILC_WFI_del_station(struct wiphy *wiphy, struct net_device *dev, struct WILC_WFI_priv *priv; perInterface_wlan_t *nic; WILC_NULLCHECK(s32Error, wiphy); - /*BugID_4795: mac may be null pointer to indicate deleting all stations, so avoid null check*/ - /* WILC_NULLCHECK(s32Error, mac); */ priv = wiphy_priv(wiphy); nic = netdev_priv(dev); @@ -3649,7 +3565,6 @@ struct wireless_dev *WILC_WFI_add_virt_intf(struct wiphy *wiphy, const char *nam { perInterface_wlan_t *nic; struct WILC_WFI_priv *priv; - /* struct WILC_WFI_mon_priv* mon_priv; */ struct net_device *new_ifc = NULL; priv = wiphy_priv(wiphy); @@ -3707,7 +3622,6 @@ static struct cfg80211_ops WILC_WFI_cfg80211_ops = { .del_key = WILC_WFI_del_key, .get_key = WILC_WFI_get_key, .set_default_key = WILC_WFI_set_default_key, - /* .dump_survey = WILC_WFI_dump_survey, */ #ifdef WILC_AP_EXTERNAL_MLME .add_virtual_intf = WILC_WFI_add_virt_intf, .del_virtual_intf = WILC_WFI_del_virt_intf, @@ -3725,13 +3639,8 @@ static struct cfg80211_ops WILC_WFI_cfg80211_ops = { #endif .dump_station = WILC_WFI_dump_station, .change_bss = WILC_WFI_change_bss, - /* .auth = WILC_WFI_auth, */ - /* .assoc = WILC_WFI_assoc, */ - /* .deauth = WILC_WFI_deauth, */ - /* .disassoc = WILC_WFI_disassoc, */ .set_wiphy_params = WILC_WFI_set_wiphy_params, - /* .set_bitrate_mask = WILC_WFI_set_bitrate_mask, */ .set_pmksa = WILC_WFI_set_pmksa, .del_pmksa = WILC_WFI_del_pmksa, .flush_pmksa = WILC_WFI_flush_pmksa, @@ -3741,7 +3650,6 @@ static struct cfg80211_ops WILC_WFI_cfg80211_ops = { .mgmt_tx_cancel_wait = WILC_WFI_mgmt_tx_cancel_wait, .mgmt_tx = WILC_WFI_mgmt_tx, .mgmt_frame_register = WILC_WFI_frame_register, - /* .mgmt_tx_cancel_wait = WILC_WFI_mgmt_tx_cancel_wait, */ .set_power_mgmt = WILC_WFI_set_power_mgmt, .set_cqm_rssi_config = WILC_WFI_set_cqm_rssi_config, #endif @@ -3767,13 +3675,11 @@ int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed) struct WILC_WFI_priv *priv; priv = wiphy_priv(wiphy); - /* down(&SemHandleUpdateStats); */ #if 1 switch (changed) { case WILC_WFI_RX_PKT: { - /* MI_PRINTF("In Rx Receive Packet\n"); */ priv->netstats.rx_packets++; priv->netstats.rx_bytes += pktlen; priv->netstats.rx_time = get_jiffies_64(); @@ -3792,7 +3698,6 @@ int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed) default: break; } - /* down(&SemHandleUpdateStats); */ #endif return 0; } @@ -3927,27 +3832,7 @@ struct wireless_dev *WILC_WFI_WiphyRegister(struct net_device *net) PRINT_D(CFG80211_DBG, "Successful Registering\n"); } -#if 0 - /*wdev[i]->wiphy->interface_modes = - * BIT(NL80211_IFTYPE_AP); - * wdev[i]->iftype = NL80211_IFTYPE_AP; - */ - - /*Pointing the priv structure the netdev*/ - priv = netdev_priv(net); - - /*linking the wireless_dev structure with the netdevice*/ - priv->dev->ieee80211_ptr = wdev; - priv->dev->ml_priv = priv; - wdev->netdev = priv->dev; -#endif priv->dev = net; -#if 0 - ret = host_int_init(&priv->hWILCWFIDrv); - if (ret) { - PRINT_ER("Error Init Driver\n"); - } -#endif return wdev; @@ -3988,7 +3873,6 @@ int WILC_WFI_InitHostInt(struct net_device *net) sema_init(&(priv->hSemScanReq), 1); s32Error = host_int_init(&priv->hWILCWFIDrv); - /* s32Error = host_int_init(&priv->hWILCWFIDrv_2); */ if (s32Error) { PRINT_ER("Error while initializing hostinterface\n"); } @@ -4018,7 +3902,6 @@ int WILC_WFI_DeInitHostInt(struct net_device *net) op_ifcs--; s32Error = host_int_deinit(priv->hWILCWFIDrv); - /* s32Error = host_int_deinit(priv->hWILCWFIDrv_2); */ /* Clear the Shadow scan */ clear_shadow_scan(priv); From 542a6bc5cfe3835e2e06ed75e4b7f6f8e29fb180 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Date: Wed, 3 Jun 2015 10:09:16 +0000 Subject: [PATCH 0823/1163] staging: wilc1000: Remove commented variable declerations Removing the commented static variable declerations. Signed-off-by: Abhishek Sharma Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wlan.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index e63788f17b5b..e1d9755856b8 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -29,10 +29,6 @@ int sdio_xfer_cnt(void); uint32_t wilc_get_chipid(uint8_t update); WILC_Uint16 Set_machw_change_vir_if(WILC_Bool bValue); -/* static uint32_t vmm_table[WILC_VMM_TBL_SIZE]; */ -/* static uint32_t vmm_table_rbk[WILC_VMM_TBL_SIZE]; */ - -/* static uint32_t vmm_table_rbk[WILC_VMM_TBL_SIZE]; */ typedef struct { From d35ebe80259e889548aa9714e0365aa12fcba7a2 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Date: Wed, 3 Jun 2015 12:25:50 +0000 Subject: [PATCH 0824/1163] staging: wilc1000: Remove commented code lines Removing the commented code lines. Signed-off-by: Abhishek Sharma Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wlan.c | 65 ---------------------------- 1 file changed, 65 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index e1d9755856b8..9edc851cb705 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -170,7 +170,6 @@ static void wilc_wlan_txq_remove(struct txq_entry_t *tqe) wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan; /* unsigned long flags; */ - /* p->os_func.os_spin_lock(p->txq_spinlock, &flags); */ if (tqe == p->txq_head) { p->txq_head = tqe->next; @@ -187,7 +186,6 @@ static void wilc_wlan_txq_remove(struct txq_entry_t *tqe) tqe->next->prev = tqe->prev; } p->txq_entries -= 1; - /* p->os_func.os_spin_unlock(p->txq_spinlock, &flags); */ } @@ -198,7 +196,6 @@ static struct txq_entry_t *wilc_wlan_txq_remove_from_head(void) unsigned long flags; p->os_func.os_spin_lock(p->txq_spinlock, &flags); if (p->txq_head) { - /* p->os_func.os_enter_cs(p->txq_lock); */ tqe = p->txq_head; p->txq_head = tqe->next; if (p->txq_head) { @@ -209,7 +206,6 @@ static struct txq_entry_t *wilc_wlan_txq_remove_from_head(void) /*Added by Amr - BugID_4720*/ - /* p->os_func.os_leave_cs(p->txq_lock); */ } else { tqe = NULL; @@ -225,13 +221,11 @@ static void wilc_wlan_txq_add_to_tail(struct txq_entry_t *tqe) /*Added by Amr - BugID_4720*/ p->os_func.os_spin_lock(p->txq_spinlock, &flags); -/* p->os_func.os_enter_cs(p->txq_lock); */ if (p->txq_head == NULL) { tqe->next = NULL; tqe->prev = NULL; p->txq_head = tqe; p->txq_tail = tqe; - /* p->os_func.os_signal(p->txq_wait); */ } else { tqe->next = NULL; tqe->prev = p->txq_tail; @@ -240,7 +234,6 @@ static void wilc_wlan_txq_add_to_tail(struct txq_entry_t *tqe) } p->txq_entries += 1; PRINT_D(TX_DBG, "Number of entries in TxQ = %d\n", p->txq_entries); -/* p->os_func.os_leave_cs(p->txq_lock); */ /*Added by Amr - BugID_4720*/ p->os_func.os_spin_unlock(p->txq_spinlock, &flags); @@ -265,7 +258,6 @@ static int wilc_wlan_txq_add_to_head(struct txq_entry_t *tqe) p->os_func.os_spin_lock(p->txq_spinlock, &flags); - /* p->os_func.os_enter_cs(p->txq_lock); */ if (p->txq_head == NULL) { tqe->next = NULL; tqe->prev = NULL; @@ -279,7 +271,6 @@ static int wilc_wlan_txq_add_to_head(struct txq_entry_t *tqe) } p->txq_entries += 1; PRINT_D(TX_DBG, "Number of entries in TxQ = %d\n", p->txq_entries); - /* p->os_func.os_leave_cs(p->txq_lock); */ /*Added by Amr - BugID_4720*/ p->os_func.os_spin_unlock(p->txq_spinlock, &flags); @@ -291,7 +282,6 @@ static int wilc_wlan_txq_add_to_head(struct txq_entry_t *tqe) **/ p->os_func.os_signal(p->txq_wait); PRINT_D(TX_DBG, "Wake up the txq_handler\n"); -/* complete(p->txq_wait); */ /*Added by Amr - BugID_4720*/ return 0; @@ -308,19 +298,12 @@ typedef struct Ack_session_info { uint16_t src_port; uint16_t dst_port; uint16_t status; - /* struct Ack_session_info * next; */ - /* struct Ack_session_info * prev; */ } Ack_session_info_t; typedef struct { uint32_t ack_num; - /* uint32_t seq_num; */ - /* uint16_t src_port; */ - /* uint16_t dst_port; */ - /* uint32_t dst_ip_addr; */ uint32_t Session_index; struct txq_entry_t *txqe; - /* Ack_session_info * Ack_session; */ } Pending_Acks_info_t /*Ack_info_t*/; @@ -348,17 +331,6 @@ uint32_t Pending_Acks; static __inline int Init_TCP_tracking(void) { - /*uint32_t i; - * Free_head=&Acks_keep_track_info[0]; - * i=1; - * Acks_keep_track_info[0].next=&Acks_keep_track_info[1]; - * for(i=1<;itx_complete_func(tqe->priv, tqe->status); p->os_func.os_free(tqe); Dropped++; - /* p->txq_entries -= 1; */ } } } @@ -563,7 +534,6 @@ static int wilc_wlan_txq_add_cfg_pkt(uint8_t *buffer, uint32_t buffer_size) /*Edited by Amr - BugID_4720*/ if (wilc_wlan_txq_add_to_head(tqe)) return 0; - /* wilc_wlan_txq_add_to_tail(tqe); */ return 1; } @@ -659,13 +629,11 @@ static struct txq_entry_t *wilc_wlan_txq_get_first(void) /*Added by Amr - BugID_4720*/ p->os_func.os_spin_lock(p->txq_spinlock, &flags); - /* p->os_func.os_enter_cs(p->txq_lock); */ tqe = p->txq_head; /*Added by Amr - BugID_4720*/ p->os_func.os_spin_unlock(p->txq_spinlock, &flags); - /* p->os_func.os_leave_cs(p->txq_lock); */ return tqe; } @@ -677,13 +645,10 @@ static struct txq_entry_t *wilc_wlan_txq_get_next(struct txq_entry_t *tqe) /*Added by Amr - BugID_4720*/ p->os_func.os_spin_lock(p->txq_spinlock, &flags); - /* p->os_func.os_enter_cs(p->txq_lock); */ tqe = tqe->next; - /*Added by Amr - BugID_4720*/ p->os_func.os_spin_unlock(p->txq_spinlock, &flags); - /* p->os_func.os_leave_cs(p->txq_lock); */ return tqe; } @@ -856,7 +821,6 @@ INLINE void chip_wakeup(void) do { /* Wait for the chip to stabilize*/ -/* WILC_Sleep(2); */ mdelay(3); /* Make sure chip is awake. This is an extra step that can be removed */ @@ -988,9 +952,7 @@ static int wilc_wlan_handle_txq(uint32_t *pu32TxqCount) #ifdef BIG_ENDIAN vmm_table[i] = BYTE_SWAP(vmm_table[i]); #endif - /* p->hif_func.hif_write_reg(0x1160,vmm_table[0]); */ - /* wilc_debug(N_TXQ, "[wilc txq]: vmm table[%d] = %08x\n", i, vmm_table[i]); */ i++; sum += vmm_sz; PRINT_D(TX_DBG, "sum = %d\n", sum); @@ -1158,11 +1120,6 @@ static int wilc_wlan_handle_txq(uint32_t *pu32TxqCount) header &= ~(1 << 30); } #endif - /*else if(tqe->type == WILC_DATA_PKT_MAC_HDR) - * { - * header |= (1<< 29); - * }*/ - /* wilc_debug(N_TXQ, "[wilc txq]: header (%08x), real size (%d), vmm size (%d)\n", header, tqe->buffer_size, vmm_sz); */ #ifdef BIG_ENDIAN header = BYTE_SWAP(header); @@ -1232,7 +1189,6 @@ _end_: if (ret != 1) break; } while (0); - /* remove_TCP_related(); */ /*Added by Amr - BugID_4720*/ p->os_func.os_signal(p->txq_add_to_head_lock); @@ -1317,7 +1273,6 @@ static void wilc_wlan_handle_rxq(void) else #endif { - /* wilc_debug(N_RXQ, "[wilc rxq]: packet, tp len(%d), len (%d), offset (%d), cfg (%d)\n", tp_len, pkt_len, pkt_offset, is_cfg_packet); */ if (!is_cfg_packet) { @@ -1341,7 +1296,6 @@ static void wilc_wlan_handle_rxq(void) if (p->cfg_seq_no == rsp.seq_no) { p->os_func.os_signal(p->cfg_wait); } - /* p->os_func.os_signal(p->cfg_wait); */ } else if (rsp.type == WILC_CFG_RSP_STATUS) { /** * Call back to indicate status... @@ -1741,7 +1695,6 @@ static int wilc_wlan_start(void) * Go... **/ - /* p->hif_func.hif_write_reg(0x150014, reg); */ p->hif_func.hif_read_reg(WILC_GLB_RESET_0, ®); if ((reg & (1ul << 10)) == (1ul << 10)) { @@ -1850,22 +1803,6 @@ static void wilc_wlan_cleanup(void) int ret; p->quit = 1; - /** - * wait for queue end - **/ - /* p->os_func.os_signal(p->txq_wait); */ - /* p->os_func.os_signal(p->rxq_wait); */ - - /* complete(p->txq_wait); */ - /* complete(p->rxq_wait); */ - /*do { - * if (p->txq_exit && p->rxq_exit) - * break; - * } while (1);*/ - - /** - * clean up the queue - **/ do { tqe = wilc_wlan_txq_remove_from_head(); if (tqe == NULL) @@ -2231,7 +2168,6 @@ int wilc_wlan_init(wilc_wlan_inp_t *inp, wilc_wlan_oup_t *oup) #if defined (MEMORY_STATIC) g_wlan.rx_buffer_size = inp->os_context.rx_buffer_size; #endif - /* g_wlan.os_func.os_lock(g_wlan.cfg_wait); */ /*** * host interface init **/ @@ -2331,7 +2267,6 @@ int wilc_wlan_init(wilc_wlan_inp_t *inp, wilc_wlan_oup_t *oup) oup->wlan_add_to_tx_que = wilc_wlan_txq_add_net_pkt; oup->wlan_handle_tx_que = wilc_wlan_handle_txq; oup->wlan_handle_rx_que = wilc_wlan_handle_rxq; - /* oup->wlan_handle_rx_isr = wilc_wlan_handle_isr; */ oup->wlan_handle_rx_isr = wilc_handle_isr; oup->wlan_cleanup = wilc_wlan_cleanup; oup->wlan_cfg_set = wilc_wlan_cfg_set; From 9ee81443b99ae3a022ba145ed62e22a5173e33f6 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 4 Jun 2015 11:59:34 +0300 Subject: [PATCH 0825/1163] staging: wilc1000: prevent some overflows in debugfs Add some limits here so we don't corrupt memory. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_debugfs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/staging/wilc1000/wilc_debugfs.c b/drivers/staging/wilc1000/wilc_debugfs.c index 74b9fd5ba27b..c328208cda29 100644 --- a/drivers/staging/wilc1000/wilc_debugfs.c +++ b/drivers/staging/wilc1000/wilc_debugfs.c @@ -53,6 +53,9 @@ static ssize_t wilc_debug_level_write(struct file *filp, const char *buf, size_t char buffer[128] = {}; int flag = 0; + if (count > sizeof(buffer)) + return -EINVAL; + if (copy_from_user(buffer, buf, count)) { return -EFAULT; } @@ -99,6 +102,9 @@ static ssize_t wilc_debug_region_write(struct file *filp, const char *buf, size_ char buffer[128] = {}; int flag; + if (count > sizeof(buffer)) + return -EINVAL; + if (copy_from_user(buffer, buf, count)) { return -EFAULT; } From 71e8dd9a2f8dc9fc14fe9b20515709cc33f4a255 Mon Sep 17 00:00:00 2001 From: Antonio Murdaca Date: Mon, 8 Jun 2015 21:48:41 +0200 Subject: [PATCH 0826/1163] staging: lustre: cleanup not needed else clauses cleanup checkpatch.pl warnings about not needed else clauses after a break or return Signed-off-by: Antonio Murdaca Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/fid/fid_request.c | 5 ++--- .../staging/lustre/lustre/include/lprocfs_status.h | 3 +-- drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 3 +-- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 11 ++++++----- drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 3 +-- drivers/staging/lustre/lustre/lov/lov_request.c | 3 +-- drivers/staging/lustre/lustre/mdc/mdc_request.c | 8 ++++---- drivers/staging/lustre/lustre/obdclass/cl_object.c | 6 ++---- drivers/staging/lustre/lustre/obdclass/llog_cat.c | 6 ++---- drivers/staging/lustre/lustre/osc/osc_lock.c | 3 +-- drivers/staging/lustre/lustre/osc/osc_request.c | 14 ++++++++------ drivers/staging/lustre/lustre/ptlrpc/pinger.c | 8 +++----- 12 files changed, 32 insertions(+), 41 deletions(-) diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c index 7b4e3c6782c3..1362783b7eab 100644 --- a/drivers/staging/lustre/lustre/fid/fid_request.c +++ b/drivers/staging/lustre/lustre/fid/fid_request.c @@ -203,10 +203,9 @@ static int seq_client_alloc_seq(const struct lu_env *env, CERROR("%s: Can't allocate new meta-sequence, rc %d\n", seq->lcs_name, rc); return rc; - } else { - CDEBUG(D_INFO, "%s: New range - "DRANGE"\n", - seq->lcs_name, PRANGE(&seq->lcs_space)); } + CDEBUG(D_INFO, "%s: New range - "DRANGE"\n", + seq->lcs_name, PRANGE(&seq->lcs_space)); } else { rc = 0; } diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 3292fd3c588a..8ede2a00ca4f 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -421,9 +421,8 @@ static inline int lprocfs_stats_lock(struct lprocfs_stats *stats, int opc, else spin_lock(&stats->ls_lock); return 1; - } else { - return stats->ls_biggest_alloc_num; } + return stats->ls_biggest_alloc_num; } } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index 0a0b435f11fc..764f98684d74 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -667,10 +667,9 @@ int target_send_reply_msg(struct ptlrpc_request *req, int rc, int fail_id) DEBUG_REQ(D_NET, req, "processing error (%d)", rc); req->rq_status = rc; return ptlrpc_send_error(req, 1); - } else { - DEBUG_REQ(D_NET, req, "sending reply"); } + DEBUG_REQ(D_NET, req, "sending reply"); return ptlrpc_send_reply(req, PTLRPC_REPLY_MAYBE_DIFFICULT); } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 6a22f4183b30..bb2246d3b22b 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -931,7 +931,9 @@ static void search_granted_lock(struct list_head *queue, prev->mode_link = &mode_end->l_sl_mode; prev->policy_link = &req->l_sl_policy; return; - } else if (lock->l_resource->lr_type == LDLM_IBITS) { + } + + if (lock->l_resource->lr_type == LDLM_IBITS) { for (;;) { policy_end = list_entry(lock->l_sl_policy.prev, @@ -967,11 +969,10 @@ static void search_granted_lock(struct list_head *queue, prev->mode_link = &mode_end->l_sl_mode; prev->policy_link = &req->l_sl_policy; return; - } else { - LDLM_ERROR(lock, - "is not LDLM_PLAIN or LDLM_IBITS lock"); - LBUG(); } + + LDLM_ERROR(lock, "is not LDLM_PLAIN or LDLM_IBITS lock"); + LBUG(); } /* insert point is last lock on the queue, diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 310cc60252fa..1605b9c69271 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -1401,8 +1401,7 @@ static int ldlm_pools_thread_main(void *arg) if (thread_test_and_clear_flags(thread, SVC_STOPPING)) break; - else - thread_test_and_clear_flags(thread, SVC_EVENT); + thread_test_and_clear_flags(thread, SVC_EVENT); } thread_set_flags(thread, SVC_STOPPED); diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index f4f2058abd2b..f4de8b84c5c2 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -607,8 +607,7 @@ void lov_update_statfs(struct obd_statfs *osfs, struct obd_statfs *lov_sfs, if (tmp & 1) { if (quit) break; - else - quit = 1; + quit = 1; shift = 0; } tmp >>= 1; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index c9639413b105..c23511f7c142 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -75,11 +75,11 @@ static int mdc_unpack_capa(struct obd_export *exp, struct ptlrpc_request *req, if (IS_ERR(c)) { CDEBUG(D_INFO, "alloc capa failed!\n"); return PTR_ERR(c); - } else { - c->c_capa = *capa; - *oc = c; - return 0; } + + c->c_capa = *capa; + *oc = c; + return 0; } static inline int mdc_queue_wait(struct ptlrpc_request *req) diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index f13d1fbffd9d..163fe0cd7f9a 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -906,10 +906,8 @@ struct lu_env *cl_env_nested_get(struct cl_env_nest *nest) if (env != NULL) { if (!cl_io_is_going(env)) return env; - else { - cl_env_put(env, &nest->cen_refcheck); - nest->cen_cookie = cl_env_reenter(); - } + cl_env_put(env, &nest->cen_refcheck); + nest->cen_cookie = cl_env_reenter(); } env = cl_env_get(&nest->cen_refcheck); if (IS_ERR(env)) { diff --git a/drivers/staging/lustre/lustre/obdclass/llog_cat.c b/drivers/staging/lustre/lustre/obdclass/llog_cat.c index c8f6ab006124..48dbbcf97702 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_cat.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_cat.c @@ -279,9 +279,8 @@ static struct llog_handle *llog_cat_current_log(struct llog_handle *cathandle, loghandle->lgh_last_idx < LLOG_BITMAP_SIZE(llh) - 1) { up_read(&cathandle->lgh_lock); return loghandle; - } else { - up_write(&loghandle->lgh_lock); } + up_write(&loghandle->lgh_lock); } up_read(&cathandle->lgh_lock); @@ -299,9 +298,8 @@ static struct llog_handle *llog_cat_current_log(struct llog_handle *cathandle, if (loghandle->lgh_last_idx < LLOG_BITMAP_SIZE(llh) - 1) { up_write(&cathandle->lgh_lock); return loghandle; - } else { - up_write(&loghandle->lgh_lock); } + up_write(&loghandle->lgh_lock); } CDEBUG(D_INODE, "use next log\n"); diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index 06837f5f4e64..70b1b43f692b 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -1176,8 +1176,7 @@ static int osc_lock_wait(const struct lu_env *env, /* It is from enqueue RPC reply upcall for * updating state. Do not re-enqueue. */ return -ENAVAIL; - else - olck->ols_state = OLS_NEW; + olck->ols_state = OLS_NEW; } else { LASSERT(lock->cll_error); return lock->cll_error; diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index c174de9fb309..f84b4c78a8a0 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -1007,8 +1007,8 @@ static int osc_should_shrink_grant(struct client_obd *client) if (client->cl_import->imp_state == LUSTRE_IMP_FULL && client->cl_avail_grant > brw_size) return 1; - else - osc_update_next_shrink(client); + + osc_update_next_shrink(client); } return 0; } @@ -2299,7 +2299,9 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, ldlm_lock_decref(lockh, mode); LDLM_LOCK_PUT(matched); return -ECANCELED; - } else if (osc_set_lock_data_with_check(matched, einfo)) { + } + + if (osc_set_lock_data_with_check(matched, einfo)) { *flags |= LDLM_FL_LVB_READY; /* addref the lock only if not async requests and PW * lock is matched whereas we asked for PR. */ @@ -2324,10 +2326,10 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, ldlm_lock_decref(lockh, einfo->ei_mode); LDLM_LOCK_PUT(matched); return ELDLM_OK; - } else { - ldlm_lock_decref(lockh, mode); - LDLM_LOCK_PUT(matched); } + + ldlm_lock_decref(lockh, mode); + LDLM_LOCK_PUT(matched); } no_match: diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index 61e33be865b2..d05c37c1fd30 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -289,12 +289,10 @@ static int ptlrpc_pinger_main(void *arg) thread_is_stopping(thread) || thread_is_event(thread), &lwi); - if (thread_test_and_clear_flags(thread, SVC_STOPPING)) { + if (thread_test_and_clear_flags(thread, SVC_STOPPING)) break; - } else { - /* woken after adding import to reset timer */ - thread_test_and_clear_flags(thread, SVC_EVENT); - } + /* woken after adding import to reset timer */ + thread_test_and_clear_flags(thread, SVC_EVENT); } } From 51bb618bff1e77c891f68405c3f8f3a492fecc17 Mon Sep 17 00:00:00 2001 From: Joglekar Tejas Date: Mon, 1 Jun 2015 09:44:51 +0530 Subject: [PATCH 0827/1163] Staging: comedi: ni_at_a2150: remove extra spaces before tab This patch fix warning given by checkpatch.pl abouts spaces given before tab Signed-off-by: Joglekar Tejas Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_at_a2150.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c index 3a972d1538ab..60469bb77ee4 100644 --- a/drivers/staging/comedi/drivers/ni_at_a2150.c +++ b/drivers/staging/comedi/drivers/ni_at_a2150.c @@ -106,7 +106,7 @@ TRIG_WAKE_EOS #define IRQ_LVL_BITS(x) (((x) & 0xf) << 4) /* sets irq level */ #define FIFO_INTR_EN_BIT 0x100 /* enable fifo interrupts */ #define FIFO_INTR_FHF_BIT 0x200 /* interrupt fifo half full */ -#define DMA_INTR_EN_BIT 0x800 /* enable interrupt on dma terminal count */ +#define DMA_INTR_EN_BIT 0x800 /* enable interrupt on dma terminal count */ #define DMA_DEM_EN_BIT 0x1000 /* enables demand mode dma */ #define I8253_BASE_REG 0x14 From e1f9ae3bcaf270fb306702e4182d9beccf7fb001 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Date: Mon, 1 Jun 2015 06:06:53 +0000 Subject: [PATCH 0828/1163] Staging: comedi: adv_pci1724: Remove redundant return statements Replace unnecessary conditional checks for variable 'ret' and replace by single return statement. Signed-off-by: Abhishek Sharma Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1724.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index f7a7dab013db..9677111f9ab2 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -180,11 +180,7 @@ static int adv_pci1724_auto_attach(struct comedi_device *dev, s->insn_write = adv_pci1724_insn_write; s->private = (void *)PCI1724_DAC_CTRL_MODE_GAIN; - ret = comedi_alloc_subdev_readback(s); - if (ret) - return ret; - - return 0; + return comedi_alloc_subdev_readback(s); } static struct comedi_driver adv_pci1724_driver = { From b38c760ab0e1d7e051f13e31771514b5809de222 Mon Sep 17 00:00:00 2001 From: Madhusudhanan Ravindran Date: Mon, 1 Jun 2015 12:34:56 +0000 Subject: [PATCH 0829/1163] staging: fbtft: replace fbtft_dev_dbg with standard dev_dbg call This patch attempts to simplify the debugging using standard dev_dbg call so that individual debug prints can be enabled or disbled by dynamic debugging rather than using module params. Signed-off-by: Madhusudhanan Ravindran Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fb_agm1264k-fl.c | 6 +++--- drivers/staging/fbtft/fbtft-core.c | 15 +++++++-------- drivers/staging/fbtft/fbtft.h | 5 ----- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/drivers/staging/fbtft/fb_agm1264k-fl.c b/drivers/staging/fbtft/fb_agm1264k-fl.c index 8f5af1db852c..94dd49ce18de 100644 --- a/drivers/staging/fbtft/fb_agm1264k-fl.c +++ b/drivers/staging/fbtft/fb_agm1264k-fl.c @@ -94,7 +94,7 @@ static void reset(struct fbtft_par *par) if (par->gpio.reset == -1) return; - fbtft_dev_dbg(DEBUG_RESET, par, par->info->device, "%s()\n", __func__); + dev_dbg(par->info->device, "%s()\n", __func__); gpio_set_value(par->gpio.reset, 0); udelay(20); @@ -107,7 +107,7 @@ static int verify_gpios(struct fbtft_par *par) { int i; - fbtft_dev_dbg(DEBUG_VERIFY_GPIOS, par, par->info->device, + dev_dbg(par->info->device, "%s()\n", __func__); if (par->EPIN < 0) { @@ -145,7 +145,7 @@ static int verify_gpios(struct fbtft_par *par) static unsigned long request_gpios_match(struct fbtft_par *par, const struct fbtft_gpio *gpio) { - fbtft_dev_dbg(DEBUG_REQUEST_GPIOS_MATCH, par, par->info->device, + dev_dbg(par->info->device, "%s('%s')\n", __func__, gpio->name); if (strcasecmp(gpio->name, "wr") == 0) { diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c index ce645213a539..d01856f7d1bc 100644 --- a/drivers/staging/fbtft/fbtft-core.c +++ b/drivers/staging/fbtft/fbtft-core.c @@ -486,7 +486,7 @@ static void fbtft_deferred_io(struct fb_info *info, struct list_head *pagelist) index = page->index << PAGE_SHIFT; y_low = index / info->fix.line_length; y_high = (index + PAGE_SIZE - 1) / info->fix.line_length; - fbtft_dev_dbg(DEBUG_DEFERRED_IO, par, info->device, + dev_dbg(info->device, "page->index=%lu y_low=%d y_high=%d\n", page->index, y_low, y_high); if (y_high > info->var.yres - 1) @@ -507,7 +507,7 @@ static void fbtft_fb_fillrect(struct fb_info *info, { struct fbtft_par *par = info->par; - fbtft_dev_dbg(DEBUG_FB_FILLRECT, par, info->dev, + dev_dbg(info->dev, "%s: dx=%d, dy=%d, width=%d, height=%d\n", __func__, rect->dx, rect->dy, rect->width, rect->height); sys_fillrect(info, rect); @@ -520,7 +520,7 @@ static void fbtft_fb_copyarea(struct fb_info *info, { struct fbtft_par *par = info->par; - fbtft_dev_dbg(DEBUG_FB_COPYAREA, par, info->dev, + dev_dbg(info->dev, "%s: dx=%d, dy=%d, width=%d, height=%d\n", __func__, area->dx, area->dy, area->width, area->height); sys_copyarea(info, area); @@ -533,7 +533,7 @@ static void fbtft_fb_imageblit(struct fb_info *info, { struct fbtft_par *par = info->par; - fbtft_dev_dbg(DEBUG_FB_IMAGEBLIT, par, info->dev, + dev_dbg(info->dev, "%s: dx=%d, dy=%d, width=%d, height=%d\n", __func__, image->dx, image->dy, image->width, image->height); sys_imageblit(info, image); @@ -547,7 +547,7 @@ static ssize_t fbtft_fb_write(struct fb_info *info, const char __user *buf, struct fbtft_par *par = info->par; ssize_t res; - fbtft_dev_dbg(DEBUG_FB_WRITE, par, info->dev, + dev_dbg(info->dev, "%s: count=%zd, ppos=%llu\n", __func__, count, *ppos); res = fb_sys_write(info, buf, count, ppos); @@ -570,11 +570,10 @@ static int fbtft_fb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue, unsigned transp, struct fb_info *info) { - struct fbtft_par *par = info->par; unsigned val; int ret = 1; - fbtft_dev_dbg(DEBUG_FB_SETCOLREG, par, info->dev, + dev_dbg(info->dev, "%s(regno=%u, red=0x%X, green=0x%X, blue=0x%X, trans=0x%X)\n", __func__, regno, red, green, blue, transp); @@ -601,7 +600,7 @@ static int fbtft_fb_blank(int blank, struct fb_info *info) struct fbtft_par *par = info->par; int ret = -EINVAL; - fbtft_dev_dbg(DEBUG_FB_BLANK, par, info->dev, "%s(blank=%d)\n", + dev_dbg(info->dev, "%s(blank=%d)\n", __func__, blank); if (!par->fbtftops.blank) diff --git a/drivers/staging/fbtft/fbtft.h b/drivers/staging/fbtft/fbtft.h index 9fd98cb53418..7d817eb26eab 100644 --- a/drivers/staging/fbtft/fbtft.h +++ b/drivers/staging/fbtft/fbtft.h @@ -430,11 +430,6 @@ do { \ dev_info(par->info->device, format, ##arg); \ } while (0) -#define fbtft_dev_dbg(level, par, dev, format, arg...) \ -do { \ - if (unlikely(par->debug & level)) \ - dev_info(dev, format, ##arg); \ -} while (0) #define fbtft_par_dbg_hex(level, par, dev, type, buf, num, format, arg...) \ do { \ From e6ffd1ba55a4931c429448cc69db5e7152921c85 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Thu, 4 Jun 2015 19:04:52 +0530 Subject: [PATCH 0830/1163] staging: fbtft: fix out of bound access str was 16 bytes but was mentioned as 128 in snprintf. again msg is 128 bytes but not sufficient to hold the complete debug message of register values. Now removed the use of str, msg and print the register values from the loop. Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fbtft-core.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c index d01856f7d1bc..2889f51bf3f8 100644 --- a/drivers/staging/fbtft/fbtft-core.c +++ b/drivers/staging/fbtft/fbtft-core.c @@ -1066,8 +1066,6 @@ static int fbtft_init_display_dt(struct fbtft_par *par) const __be32 *p; u32 val; int buf[64], i, j; - char msg[128]; - char str[16]; fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__); @@ -1093,13 +1091,11 @@ static int fbtft_init_display_dt(struct fbtft_par *par) p = of_prop_next_u32(prop, p, &val); } /* make debug message */ - msg[0] = '\0'; - for (j = 0; j < i; j++) { - snprintf(str, 128, " %02X", buf[j]); - strcat(msg, str); - } fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "init: write_register:%s\n", msg); + for (j = 0; j < i; j++) + fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, + "buf[%d] = %02X\n", j, buf[j]); par->fbtftops.write_register(par, i, buf[0], buf[1], buf[2], buf[3], From af17b56d1f42bd761709ec68a00ce4f1a089e597 Mon Sep 17 00:00:00 2001 From: David Decotigny Date: Sun, 7 Jun 2015 17:43:01 -0700 Subject: [PATCH 0831/1163] staging: rtl8723au: core: avoid bitwise arithmetic with forced endianness This fixes bitwise arithmetic performed on the host on a variable previously converted to little-endian, and subsequently converted again to little-endian: - issue_action_BA23a() called with "status" crafted in host byte order - "status" converted to LE - bitwise arithmetic on the (LE) "status", performed with masks and shifts in host byte order - result converted to LE (again) and stored in device structure Sparse warning addressed by this patch: drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3806:16: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3806:16: expected unsigned short [unsigned] status drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3806:16: got restricted __le16 [usertype] Additional notes: initial cpu_to_le16 was introduced by kernel bulk commit 5e93f3520 "staging: r8723au: Add source files for new driver - part 1", initially from github according to commit description. On github, this traces back to another bulk commit: 2896bda04353 "Add new files in core directory", which is the 1st version of the driver. Signed-off-by: David Decotigny Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 196beafde6f0..7c3b5dd177d2 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -3803,8 +3803,6 @@ void issue_action_BA23a(struct rtw_adapter *padapter, pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr) + 1; - status = cpu_to_le16(status); - switch (action) { case WLAN_ACTION_ADDBA_REQ: pattrib->pktlen += sizeof(mgmt->u.action.u.addba_req); From 02632342d4831dc3d197a45f83de291e2d3980cc Mon Sep 17 00:00:00 2001 From: David Decotigny Date: Sun, 7 Jun 2015 17:43:02 -0700 Subject: [PATCH 0832/1163] staging: rtl8723au: core: remove redundant endianness conversion Source and destination have the same little-endian annotation: this patch removes incorrect byte-swap on non-LE cpus. This addresses the following sparse warning: drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3911:56: warning: incorrect type in argument 1 (different base types) drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3911:56: expected unsigned short [unsigned] [usertype] val drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3911:56: got restricted __le16 [usertype] BA_timeout_value Signed-off-by: David Decotigny 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 7c3b5dd177d2..142f214108c6 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -3906,8 +3906,8 @@ void issue_action_BA23a(struct rtw_adapter *padapter, put_unaligned_le16(BA_para_set, &mgmt->u.action.u.addba_resp.capab); - put_unaligned_le16(pmlmeinfo->ADDBA_req.BA_timeout_value, - &mgmt->u.action.u.addba_resp.timeout); + mgmt->u.action.u.addba_resp.timeout + = pmlmeinfo->ADDBA_req.BA_timeout_value; pattrib->pktlen += 8; break; From 2dc340910b199f83864ca01bf3f0fa1249088982 Mon Sep 17 00:00:00 2001 From: Hari Prasath Gujulan Elango Date: Mon, 1 Jun 2015 09:31:39 +0000 Subject: [PATCH 0833/1163] staging: sm750fb: Add missing Kconfig dependency The sm750fb driver has few Framebuffer configuration dependencies that need to be selected in order to get compiled successfully Signed-off-by: Hari Prasath Gujulan Elango Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/Kconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/sm750fb/Kconfig b/drivers/staging/sm750fb/Kconfig index c40d088a4d3b..ccebc25c2ec1 100644 --- a/drivers/staging/sm750fb/Kconfig +++ b/drivers/staging/sm750fb/Kconfig @@ -1,6 +1,10 @@ config FB_SM750 tristate "Silicon Motion SM750 framebuffer support" depends on FB && PCI + select FB_MODE_HELPERS + select FB_CFB_FILLRECT + select FB_CFB_COPYAREA + select FB_CFB_IMAGEBLIT help Frame buffer driver for the Silicon Motion SM750 chip with 2D accelearion and dual head support. From e9f490ea0c2b8e20588bb1700cbcd4a575de9c49 Mon Sep 17 00:00:00 2001 From: Isaac Assegai Date: Tue, 2 Jun 2015 03:14:20 -0700 Subject: [PATCH 0834/1163] Staging: sm750fb: sm750_hw.h: Insert spaces after commas. Insert Spaces after commas in sm750_hw.h to rectify the following checkpatch errors in sm750_hw.h: ERROR: space required after that ',' Signed-off-by: Isaac Assegai Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750_hw.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/sm750fb/sm750_hw.h b/drivers/staging/sm750fb/sm750_hw.h index c607d9b81cd8..4fee28d22b58 100644 --- a/drivers/staging/sm750fb/sm750_hw.h +++ b/drivers/staging/sm750fb/sm750_hw.h @@ -81,20 +81,20 @@ struct sm750_share{ */ }; -int hw_sm750_map(struct lynx_share* share,struct pci_dev* pdev); -int hw_sm750_inithw(struct lynx_share*,struct pci_dev *); +int hw_sm750_map(struct lynx_share* share, struct pci_dev* pdev); +int hw_sm750_inithw(struct lynx_share*, struct pci_dev *); void hw_sm750_initAccel(struct lynx_share *); int hw_sm750_deWait(void); int hw_sm750le_deWait(void); resource_size_t hw_sm750_getVMSize(struct lynx_share *); -int hw_sm750_output_checkMode(struct lynxfb_output*,struct fb_var_screeninfo*); -int hw_sm750_output_setMode(struct lynxfb_output*,struct fb_var_screeninfo*,struct fb_fix_screeninfo*); -int hw_sm750_crtc_checkMode(struct lynxfb_crtc*,struct fb_var_screeninfo*); -int hw_sm750_crtc_setMode(struct lynxfb_crtc*,struct fb_var_screeninfo*,struct fb_fix_screeninfo*); -int hw_sm750_setColReg(struct lynxfb_crtc*,ushort,ushort,ushort,ushort); -int hw_sm750_setBLANK(struct lynxfb_output*,int); -int hw_sm750le_setBLANK(struct lynxfb_output*,int); +int hw_sm750_output_checkMode(struct lynxfb_output*, struct fb_var_screeninfo*); +int hw_sm750_output_setMode(struct lynxfb_output*, struct fb_var_screeninfo*, struct fb_fix_screeninfo*); +int hw_sm750_crtc_checkMode(struct lynxfb_crtc*, struct fb_var_screeninfo*); +int hw_sm750_crtc_setMode(struct lynxfb_crtc*, struct fb_var_screeninfo*, struct fb_fix_screeninfo*); +int hw_sm750_setColReg(struct lynxfb_crtc*, ushort, ushort, ushort, ushort); +int hw_sm750_setBLANK(struct lynxfb_output*, int); +int hw_sm750le_setBLANK(struct lynxfb_output*, int); void hw_sm750_crtc_clear(struct lynxfb_crtc*); void hw_sm750_output_clear(struct lynxfb_output*); int hw_sm750_pan_display(struct lynxfb_crtc *crtc, From afa34e7e749347598847a929fdfe5f40c6735725 Mon Sep 17 00:00:00 2001 From: Isaac Assegai Date: Tue, 2 Jun 2015 03:14:21 -0700 Subject: [PATCH 0835/1163] Staging: sm750fb: sm750_help.h: Insert spaces after commas. Insert Spaces after commas to rectify the following checkpatch errors in sm750_help.h: ERROR: space required after that ',' Signed-off-by: Isaac Assegai Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750_help.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/sm750fb/sm750_help.h b/drivers/staging/sm750fb/sm750_help.h index e0128d2a9ead..ebc946cfe81b 100644 --- a/drivers/staging/sm750fb/sm750_help.h +++ b/drivers/staging/sm750fb/sm750_help.h @@ -10,11 +10,11 @@ #define RAW_MASK(f) (0xFFFFFFFF >> (32 - _COUNT(f))) #define GET_MASK(f) (RAW_MASK(f) << _LSB(f)) -#define GET_FIELD(d,f) (((d) >> _LSB(f)) & RAW_MASK(f)) -#define TEST_FIELD(d,f,v) (GET_FIELD(d,f) == f ## _ ## v) -#define SET_FIELD(d,f,v) (((d) & ~GET_MASK(f)) | \ +#define GET_FIELD(d, f) (((d) >> _LSB(f)) & RAW_MASK(f)) +#define TEST_FIELD(d, f, v) (GET_FIELD(d, f) == f ## _ ## v) +#define SET_FIELD(d, f, v) (((d) & ~GET_MASK(f)) | \ (((f ## _ ## v) & RAW_MASK(f)) << _LSB(f))) -#define SET_FIELDV(d,f,v) (((d) & ~GET_MASK(f)) | \ +#define SET_FIELDV(d, f, v) (((d) & ~GET_MASK(f)) | \ (((v) & RAW_MASK(f)) << _LSB(f))) @@ -91,7 +91,7 @@ (unsigned short) ((((r) & 0xF8) << 8) | (((g) & 0xFC) << 3) | (((b) & 0xF8) >> 3)) \ ) -static inline unsigned int absDiff(unsigned int a,unsigned int b) +static inline unsigned int absDiff(unsigned int a, unsigned int b) { if(a Date: Tue, 2 Jun 2015 03:14:22 -0700 Subject: [PATCH 0836/1163] Staging: sm750fb: sm750.h: Insert spaces after commas. Insert Spaces after commas to rectify the following checkpatch errors in sm750.h: ERROR: space required after that ',' Signed-off-by: Isaac Assegai Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750.h | 35 +++++++++++++++++---------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/staging/sm750fb/sm750.h b/drivers/staging/sm750fb/sm750.h index 55289126f72c..30aa31239125 100644 --- a/drivers/staging/sm750fb/sm750.h +++ b/drivers/staging/sm750fb/sm750.h @@ -12,7 +12,7 @@ #define MB(x) ((x)<<20) #define MHZ(x) ((x) * 1000000) /* align should be 2,4,8,16 */ -#define PADDING(align,data) (((data)+(align)-1)&(~((align) -1))) +#define PADDING(align, data) (((data)+(align)-1)&(~((align) -1))) extern int smi_indent; @@ -27,15 +27,16 @@ struct lynx_accel{ int (*de_wait)(void);/* see if hardware ready to work */ - int (*de_fillrect)(struct lynx_accel *,u32,u32,u32, - u32,u32,u32,u32,u32,u32); + int (*de_fillrect)(struct lynx_accel *, u32, u32, u32, u32, + u32, u32, u32, u32, u32); - int (*de_copyarea)(struct lynx_accel *,u32,u32,u32,u32, - u32,u32,u32,u32, - u32,u32,u32,u32); + int (*de_copyarea)(struct lynx_accel *, u32, u32, u32, u32, + u32, u32, u32, u32, + u32, u32, u32, u32); - int (*de_imageblit)(struct lynx_accel *,const char *,u32,u32,u32, - u32,u32,u32,u32,u32,u32,u32,u32,u32); + int (*de_imageblit)(struct lynx_accel *, const char *, u32, u32, u32, u32, + u32, u32, u32, u32, + u32, u32, u32, u32); }; @@ -87,10 +88,10 @@ struct lynx_cursor{ /* proc_routines */ void (*enable)(struct lynx_cursor *); void (*disable)(struct lynx_cursor *); - void (*setSize)(struct lynx_cursor *,int,int); - void (*setPos)(struct lynx_cursor *,int,int); - void (*setColor)(struct lynx_cursor *,u32,u32); - void (*setData)(struct lynx_cursor *,u16,const u8*,const u8*); + void (*setSize)(struct lynx_cursor *, int, int); + void (*setPos)(struct lynx_cursor *, int, int); + void (*setColor)(struct lynx_cursor *, u32, u32); + void (*setData)(struct lynx_cursor *, u16, const u8*, const u8*); }; struct lynxfb_crtc{ @@ -113,8 +114,8 @@ struct lynxfb_crtc{ struct fb_var_screeninfo*, struct fb_fix_screeninfo*); - int(*proc_checkMode)(struct lynxfb_crtc*,struct fb_var_screeninfo*); - int(*proc_setColReg)(struct lynxfb_crtc*,ushort,ushort,ushort,ushort); + int(*proc_checkMode)(struct lynxfb_crtc*, struct fb_var_screeninfo*); + int(*proc_setColReg)(struct lynxfb_crtc*, ushort, ushort, ushort, ushort); void (*clear)(struct lynxfb_crtc*); /* pan display */ int (*proc_panDisplay)(struct lynxfb_crtc *, @@ -145,8 +146,8 @@ struct lynxfb_output{ struct fb_var_screeninfo*, struct fb_fix_screeninfo*); - int(*proc_checkMode)(struct lynxfb_output*,struct fb_var_screeninfo*); - int(*proc_setBLANK)(struct lynxfb_output*,int); + int(*proc_checkMode)(struct lynxfb_output*, struct fb_var_screeninfo*); + int(*proc_setBLANK)(struct lynxfb_output*, int); void (*clear)(struct lynxfb_output*); }; @@ -168,7 +169,7 @@ struct lynxfb_par{ #define PS_TO_HZ(ps) \ ({ \ unsigned long long hz = 1000*1000*1000*1000ULL; \ - do_div(hz,ps); \ + do_div(hz, ps); \ (unsigned long)hz;}) static inline unsigned long ps_to_hz(unsigned int psvalue) From 5e9358138820b171e0094709cde3ea9ac6ff1679 Mon Sep 17 00:00:00 2001 From: Isaac Assegai Date: Tue, 2 Jun 2015 03:14:23 -0700 Subject: [PATCH 0837/1163] Staging: sm750fb: Inserted spaces after commas in four files. Insert Spaces after commas to rectify the following checkpatch errors in sm750_cursor.h, sm750_accel.h, ddk750_power.h and ddk750_mode.h: ERROR: space required after that ',' Signed-off-by: Isaac Assegai Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/ddk750_mode.h | 2 +- drivers/staging/sm750fb/ddk750_power.h | 2 +- drivers/staging/sm750fb/sm750_accel.h | 8 ++++---- drivers/staging/sm750fb/sm750_cursor.h | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/sm750fb/ddk750_mode.h b/drivers/staging/sm750fb/ddk750_mode.h index 6f8df96a8b02..4e8fab3f17e4 100644 --- a/drivers/staging/sm750fb/ddk750_mode.h +++ b/drivers/staging/sm750fb/ddk750_mode.h @@ -37,7 +37,7 @@ typedef struct _mode_parameter_t } mode_parameter_t; -int ddk750_setModeTiming(mode_parameter_t *,clock_type_t); +int ddk750_setModeTiming(mode_parameter_t *, clock_type_t); #endif diff --git a/drivers/staging/sm750fb/ddk750_power.h b/drivers/staging/sm750fb/ddk750_power.h index 71dc7f980069..4e00955a07dd 100644 --- a/drivers/staging/sm750fb/ddk750_power.h +++ b/drivers/staging/sm750fb/ddk750_power.h @@ -12,7 +12,7 @@ DPMS_t; #define setDAC(off) \ { \ - POKE32(MISC_CTRL,FIELD_VALUE(PEEK32(MISC_CTRL), \ + POKE32(MISC_CTRL, FIELD_VALUE(PEEK32(MISC_CTRL), \ MISC_CTRL, \ DAC_POWER, \ off)); \ diff --git a/drivers/staging/sm750fb/sm750_accel.h b/drivers/staging/sm750fb/sm750_accel.h index 3ee0bd89257b..e9d217b88a50 100644 --- a/drivers/staging/sm750fb/sm750_accel.h +++ b/drivers/staging/sm750fb/sm750_accel.h @@ -234,14 +234,14 @@ #define BOTTOM_TO_TOP 1 #define RIGHT_TO_LEFT 1 -void hw_set2dformat(struct lynx_accel * accel,int fmt); +void hw_set2dformat(struct lynx_accel * accel, int fmt); void hw_de_init(struct lynx_accel * accel); int hw_fillrect(struct lynx_accel * accel, - u32 base,u32 pitch,u32 Bpp, - u32 x,u32 y,u32 width,u32 height, - u32 color,u32 rop); + u32 base, u32 pitch, u32 Bpp, + u32 x, u32 y, u32 width, u32 height, + u32 color, u32 rop); int hw_copyarea( struct lynx_accel * accel, diff --git a/drivers/staging/sm750fb/sm750_cursor.h b/drivers/staging/sm750fb/sm750_cursor.h index 8cede0721332..be588687a81d 100644 --- a/drivers/staging/sm750fb/sm750_cursor.h +++ b/drivers/staging/sm750fb/sm750_cursor.h @@ -5,13 +5,13 @@ void hw_cursor_enable(struct lynx_cursor * cursor); void hw_cursor_disable(struct lynx_cursor * cursor); void hw_cursor_setSize(struct lynx_cursor * cursor, - int w,int h); + int w, int h); void hw_cursor_setPos(struct lynx_cursor * cursor, - int x,int y); + int x, int y); void hw_cursor_setColor(struct lynx_cursor * cursor, - u32 fg,u32 bg); + u32 fg, u32 bg); void hw_cursor_setData(struct lynx_cursor * cursor, - u16 rop,const u8* data,const u8* mask); + u16 rop, const u8* data, const u8* mask); void hw_cursor_setData2(struct lynx_cursor * cursor, - u16 rop,const u8* data,const u8* mask); + u16 rop, const u8* data, const u8* mask); #endif From 555a6b1e2483c256eb33d458d6d4146ef11ce3bc Mon Sep 17 00:00:00 2001 From: Isaac Assegai Date: Tue, 2 Jun 2015 03:14:24 -0700 Subject: [PATCH 0838/1163] Staging: sm750fb: Inserted spaces after commas in three files. Insert Spaces after commas to rectify the following checkpatch errors in ddk750_hwi2c.h, ddk750_help.h and ddk750_chip.h: ERROR: space required after that ',' Signed-off-by: Isaac Assegai Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/ddk750_chip.h | 6 +++--- drivers/staging/sm750fb/ddk750_help.h | 4 ++-- drivers/staging/sm750fb/ddk750_hwi2c.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/sm750fb/ddk750_chip.h b/drivers/staging/sm750fb/ddk750_chip.h index 83821de68f40..4e030e820cf3 100644 --- a/drivers/staging/sm750fb/ddk750_chip.h +++ b/drivers/staging/sm750fb/ddk750_chip.h @@ -76,10 +76,10 @@ initchip_param_t; logical_chip_type_t getChipType(void); -unsigned int calcPllValue(unsigned int request,pll_value_t *pll); -unsigned int calcPllValue2(unsigned int,pll_value_t *); +unsigned int calcPllValue(unsigned int request, pll_value_t *pll); +unsigned int calcPllValue2(unsigned int, pll_value_t *); unsigned int formatPllReg(pll_value_t *pPLL); -void ddk750_set_mmio(void __iomem *,unsigned short,char); +void ddk750_set_mmio(void __iomem *, unsigned short, char); unsigned int ddk750_getVMSize(void); int ddk750_initHw(initchip_param_t *); unsigned int getPllValue(clock_type_t clockType, pll_value_t *pPLL); diff --git a/drivers/staging/sm750fb/ddk750_help.h b/drivers/staging/sm750fb/ddk750_help.h index e7e49cebd303..f99f907f0ad9 100644 --- a/drivers/staging/sm750fb/ddk750_help.h +++ b/drivers/staging/sm750fb/ddk750_help.h @@ -13,10 +13,10 @@ /* if 718 big endian turned on,be aware that don't use this driver for general use,only for ppc big-endian */ #warning "big endian on target cpu and enable nature big endian support of 718 capability !" #define PEEK32(addr) __raw_readl(mmio750 + addr) -#define POKE32(addr,data) __raw_writel(data, mmio750 + addr) +#define POKE32(addr, data) __raw_writel(data, mmio750 + addr) #else /* software control endianness */ #define PEEK32(addr) readl(addr + mmio750) -#define POKE32(addr,data) writel(data, addr + mmio750) +#define POKE32(addr, data) writel(data, addr + mmio750) #endif extern void __iomem * mmio750; diff --git a/drivers/staging/sm750fb/ddk750_hwi2c.h b/drivers/staging/sm750fb/ddk750_hwi2c.h index ad311493c9fc..0b830ba65eec 100644 --- a/drivers/staging/sm750fb/ddk750_hwi2c.h +++ b/drivers/staging/sm750fb/ddk750_hwi2c.h @@ -5,6 +5,6 @@ int hwI2CInit(unsigned char busSpeedMode); void hwI2CClose(void); -unsigned char hwI2CReadReg(unsigned char deviceAddress,unsigned char registerIndex); -int hwI2CWriteReg(unsigned char deviceAddress,unsigned char registerIndex,unsigned char data); +unsigned char hwI2CReadReg(unsigned char deviceAddress, unsigned char registerIndex); +int hwI2CWriteReg(unsigned char deviceAddress, unsigned char registerIndex, unsigned char data); #endif From bdec77735e30ee106307cb5e85004c73cb707382 Mon Sep 17 00:00:00 2001 From: Isaac Assegai Date: Tue, 2 Jun 2015 03:14:25 -0700 Subject: [PATCH 0839/1163] Staging: sm750fb: sm750_hw.c: Insert spaces after commas. Insert Spaces after commas to rectify the following checkpatch errors in sm750_hw.c: ERROR: space required after that ',' Signed-off-by: Isaac Assegai Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750_hw.c | 64 +++++++++++++++--------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/drivers/staging/sm750fb/sm750_hw.c b/drivers/staging/sm750fb/sm750_hw.c index 4b77eb1b9277..131125ca5737 100644 --- a/drivers/staging/sm750fb/sm750_hw.c +++ b/drivers/staging/sm750fb/sm750_hw.c @@ -30,7 +30,7 @@ int hw_sm750_map(struct lynx_share* share, struct pci_dev* pdev) struct sm750_share * spec_share; - spec_share = container_of(share, struct sm750_share,share); + spec_share = container_of(share, struct sm750_share, share); ret = 0; share->vidreg_start = pci_resource_start(pdev, 1); @@ -64,7 +64,7 @@ int hw_sm750_map(struct lynx_share* share, struct pci_dev* pdev) share->accel.dprBase = share->pvReg + DE_BASE_ADDR_TYPE1; share->accel.dpPortBase = share->pvReg + DE_PORT_ADDR_TYPE1; - ddk750_set_mmio(share->pvReg,share->devid, share->revid); + ddk750_set_mmio(share->pvReg, share->devid, share->revid); share->vidmem_start = pci_resource_start(pdev, 0); /* don't use pdev_resource[x].end - resource[x].start to @@ -78,7 +78,7 @@ int hw_sm750_map(struct lynx_share* share, struct pci_dev* pdev) /* reserve the vidmem space of smi adaptor */ #if 0 - if((ret = pci_request_region(pdev,0,_moduleName_))) + if((ret = pci_request_region(pdev, 0, _moduleName_))) { pr_err("Can not request PCI regions.\n"); goto exit; @@ -105,7 +105,7 @@ int hw_sm750_inithw(struct lynx_share* share, struct pci_dev * pdev) struct sm750_share * spec_share; struct init_status * parm; - spec_share = container_of(share, struct sm750_share,share); + spec_share = container_of(share, struct sm750_share, share); parm = &spec_share->state.initParm; if(parm->chip_clk == 0) parm->chip_clk = (getChipType() == SM750LE)? @@ -171,7 +171,7 @@ int hw_sm750_inithw(struct lynx_share* share, struct pci_dev * pdev) /* Set up GPIO for software I2C to program DVI chip in the Xilinx SP605 board, in order to have video signal. */ - swI2CInit(0,1); + swI2CInit(0, 1); /* Customer may NOT use CH7301 DVI chip, which has to be @@ -269,7 +269,7 @@ int hw_sm750_crtc_checkMode(struct lynxfb_crtc* crtc, struct fb_var_screeninfo* struct lynx_share * share; - share = container_of(crtc, struct lynxfb_par,crtc)->share; + share = container_of(crtc, struct lynxfb_par, crtc)->share; switch (var->bits_per_pixel){ case 8: @@ -297,7 +297,7 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc* crtc, struct fb_var_screeninfo* var, struct fb_fix_screeninfo* fix) { - int ret,fmt; + int ret, fmt; u32 reg; mode_parameter_t modparm; clock_type_t clock; @@ -364,7 +364,7 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc* crtc, reg = var->xres * (var->bits_per_pixel >> 3); /* crtc->channel is not equal to par->index on numeric,be aware of that */ - reg = PADDING(crtc->line_pad,reg); + reg = PADDING(crtc->line_pad, reg); POKE32(PANEL_FB_WIDTH, FIELD_VALUE(0, PANEL_FB_WIDTH, WIDTH, reg)| @@ -382,7 +382,7 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc* crtc, POKE32(PANEL_PLANE_BR, FIELD_VALUE(0, PANEL_PLANE_BR, BOTTOM, var->yres - 1)| - FIELD_VALUE(0, PANEL_PLANE_BR,RIGHT, var->xres - 1)); + FIELD_VALUE(0, PANEL_PLANE_BR, RIGHT, var->xres - 1)); /* set pixel format */ reg = PEEK32(PANEL_DISPLAY_CTRL); @@ -423,17 +423,17 @@ void hw_sm750_crtc_clear(struct lynxfb_crtc* crtc) int hw_sm750_setColReg(struct lynxfb_crtc* crtc, ushort index, ushort red, ushort green, ushort blue) { - static unsigned int add[]={PANEL_PALETTE_RAM,CRT_PALETTE_RAM}; + static unsigned int add[]={PANEL_PALETTE_RAM, CRT_PALETTE_RAM}; POKE32(add[crtc->channel] + index*4, (red<<16)|(green<<8)|blue); return 0; } int hw_sm750le_setBLANK(struct lynxfb_output * output, int blank){ - int dpms,crtdb; + int dpms, crtdb; switch(blank) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10) case FB_BLANK_UNBLANK: #else case VESA_NO_BLANKING: @@ -441,13 +441,13 @@ int hw_sm750le_setBLANK(struct lynxfb_output * output, int blank){ dpms = CRT_DISPLAY_CTRL_DPMS_0; crtdb = CRT_DISPLAY_CTRL_BLANK_OFF; break; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10) case FB_BLANK_NORMAL: dpms = CRT_DISPLAY_CTRL_DPMS_0; crtdb = CRT_DISPLAY_CTRL_BLANK_ON; break; #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10) case FB_BLANK_VSYNC_SUSPEND: #else case VESA_VSYNC_SUSPEND: @@ -455,7 +455,7 @@ int hw_sm750le_setBLANK(struct lynxfb_output * output, int blank){ dpms = CRT_DISPLAY_CTRL_DPMS_2; crtdb = CRT_DISPLAY_CTRL_BLANK_ON; break; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10) case FB_BLANK_HSYNC_SUSPEND: #else case VESA_HSYNC_SUSPEND: @@ -463,7 +463,7 @@ int hw_sm750le_setBLANK(struct lynxfb_output * output, int blank){ dpms = CRT_DISPLAY_CTRL_DPMS_1; crtdb = CRT_DISPLAY_CTRL_BLANK_ON; break; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10) case FB_BLANK_POWERDOWN: #else case VESA_POWERDOWN: @@ -482,7 +482,7 @@ int hw_sm750le_setBLANK(struct lynxfb_output * output, int blank){ return 0; } -int hw_sm750_setBLANK(struct lynxfb_output* output,int blank) +int hw_sm750_setBLANK(struct lynxfb_output* output, int blank) { unsigned int dpms, pps, crtdb; @@ -490,7 +490,7 @@ int hw_sm750_setBLANK(struct lynxfb_output* output,int blank) switch (blank) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10) case FB_BLANK_UNBLANK: #else case VESA_NO_BLANKING: @@ -500,7 +500,7 @@ int hw_sm750_setBLANK(struct lynxfb_output* output,int blank) pps = PANEL_DISPLAY_CTRL_DATA_ENABLE; crtdb = CRT_DISPLAY_CTRL_BLANK_OFF; break; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10) case FB_BLANK_NORMAL: pr_info("flag = FB_BLANK_NORMAL \n"); dpms = SYSTEM_CTRL_DPMS_VPHP; @@ -508,7 +508,7 @@ int hw_sm750_setBLANK(struct lynxfb_output* output,int blank) crtdb = CRT_DISPLAY_CTRL_BLANK_ON; break; #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10) case FB_BLANK_VSYNC_SUSPEND: #else case VESA_VSYNC_SUSPEND: @@ -517,7 +517,7 @@ int hw_sm750_setBLANK(struct lynxfb_output* output,int blank) pps = PANEL_DISPLAY_CTRL_DATA_DISABLE; crtdb = CRT_DISPLAY_CTRL_BLANK_ON; break; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10) case FB_BLANK_HSYNC_SUSPEND: #else case VESA_HSYNC_SUSPEND: @@ -526,7 +526,7 @@ int hw_sm750_setBLANK(struct lynxfb_output* output,int blank) pps = PANEL_DISPLAY_CTRL_DATA_DISABLE; crtdb = CRT_DISPLAY_CTRL_BLANK_ON; break; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10) case FB_BLANK_POWERDOWN: #else case VESA_POWERDOWN: @@ -539,8 +539,8 @@ int hw_sm750_setBLANK(struct lynxfb_output* output,int blank) if(output->paths & sm750_crt){ - POKE32(SYSTEM_CTRL,FIELD_VALUE(PEEK32(SYSTEM_CTRL), SYSTEM_CTRL, DPMS, dpms)); - POKE32(CRT_DISPLAY_CTRL,FIELD_VALUE(PEEK32(CRT_DISPLAY_CTRL), CRT_DISPLAY_CTRL,BLANK, crtdb)); + POKE32(SYSTEM_CTRL, FIELD_VALUE(PEEK32(SYSTEM_CTRL), SYSTEM_CTRL, DPMS, dpms)); + POKE32(CRT_DISPLAY_CTRL, FIELD_VALUE(PEEK32(CRT_DISPLAY_CTRL), CRT_DISPLAY_CTRL, BLANK, crtdb)); } if(output->paths & sm750_panel){ @@ -558,21 +558,21 @@ void hw_sm750_initAccel(struct lynx_share * share) if(getChipType() == SM750LE){ reg = PEEK32(DE_STATE1); - reg = FIELD_SET(reg, DE_STATE1, DE_ABORT,ON); - POKE32(DE_STATE1,reg); + reg = FIELD_SET(reg, DE_STATE1, DE_ABORT, ON); + POKE32(DE_STATE1, reg); reg = PEEK32(DE_STATE1); - reg = FIELD_SET(reg, DE_STATE1, DE_ABORT,OFF); + reg = FIELD_SET(reg, DE_STATE1, DE_ABORT, OFF); POKE32(DE_STATE1, reg); }else{ /* engine reset */ reg = PEEK32(SYSTEM_CTRL); - reg = FIELD_SET(reg, SYSTEM_CTRL, DE_ABORT,ON); + reg = FIELD_SET(reg, SYSTEM_CTRL, DE_ABORT, ON); POKE32(SYSTEM_CTRL, reg); reg = PEEK32(SYSTEM_CTRL); - reg = FIELD_SET(reg, SYSTEM_CTRL, DE_ABORT,OFF); + reg = FIELD_SET(reg, SYSTEM_CTRL, DE_ABORT, OFF); POKE32(SYSTEM_CTRL, reg); } @@ -602,9 +602,9 @@ int hw_sm750_deWait(void) int i=0x10000000; while(i--){ unsigned int dwVal = PEEK32(SYSTEM_CTRL); - if((FIELD_GET(dwVal,SYSTEM_CTRL,DE_STATUS) == SYSTEM_CTRL_DE_STATUS_IDLE) && - (FIELD_GET(dwVal,SYSTEM_CTRL,DE_FIFO) == SYSTEM_CTRL_DE_FIFO_EMPTY) && - (FIELD_GET(dwVal,SYSTEM_CTRL,DE_MEM_FIFO) == SYSTEM_CTRL_DE_MEM_FIFO_EMPTY)) + if((FIELD_GET(dwVal, SYSTEM_CTRL, DE_STATUS) == SYSTEM_CTRL_DE_STATUS_IDLE) && + (FIELD_GET(dwVal, SYSTEM_CTRL, DE_FIFO) == SYSTEM_CTRL_DE_FIFO_EMPTY) && + (FIELD_GET(dwVal, SYSTEM_CTRL, DE_MEM_FIFO) == SYSTEM_CTRL_DE_MEM_FIFO_EMPTY)) { return 0; } From b5d63974bb04d352b316108b2ec5118de3ecae12 Mon Sep 17 00:00:00 2001 From: Isaac Assegai Date: Tue, 2 Jun 2015 03:14:27 -0700 Subject: [PATCH 0840/1163] Staging: sm750fb: sm750_accel.c: Insert spaces after commas. Insert Spaces after commas to rectify the following checkpatch errors in sm750_accel.c: ERROR: space required after that ',' Signed-off-by: Isaac Assegai Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750_accel.c | 160 +++++++++++++------------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/drivers/staging/sm750fb/sm750_accel.c b/drivers/staging/sm750fb/sm750_accel.c index 6a04ef86eb13..001e98031056 100644 --- a/drivers/staging/sm750fb/sm750_accel.c +++ b/drivers/staging/sm750fb/sm750_accel.c @@ -18,81 +18,81 @@ #include "sm750.h" #include "sm750_accel.h" #include "sm750_help.h" -static inline void write_dpr(struct lynx_accel * accel,int offset,u32 regValue) +static inline void write_dpr(struct lynx_accel * accel, int offset, u32 regValue) { - writel(regValue,accel->dprBase + offset); + writel(regValue, accel->dprBase + offset); } -static inline u32 read_dpr(struct lynx_accel * accel,int offset) +static inline u32 read_dpr(struct lynx_accel * accel, int offset) { return readl(accel->dprBase + offset); } -static inline void write_dpPort(struct lynx_accel * accel,u32 data) +static inline void write_dpPort(struct lynx_accel * accel, u32 data) { - writel(data,accel->dpPortBase); + writel(data, accel->dpPortBase); } void hw_de_init(struct lynx_accel * accel) { /* setup 2d engine registers */ - u32 reg,clr; + u32 reg, clr; - write_dpr(accel,DE_MASKS,0xFFFFFFFF); + write_dpr(accel, DE_MASKS, 0xFFFFFFFF); /* dpr1c */ - reg = FIELD_SET(0,DE_STRETCH_FORMAT,PATTERN_XY,NORMAL)| - FIELD_VALUE(0,DE_STRETCH_FORMAT,PATTERN_Y,0)| - FIELD_VALUE(0,DE_STRETCH_FORMAT,PATTERN_X,0)| - FIELD_SET(0,DE_STRETCH_FORMAT,ADDRESSING,XY)| - FIELD_VALUE(0,DE_STRETCH_FORMAT,SOURCE_HEIGHT,3); + reg = FIELD_SET(0, DE_STRETCH_FORMAT, PATTERN_XY, NORMAL)| + FIELD_VALUE(0, DE_STRETCH_FORMAT, PATTERN_Y, 0)| + FIELD_VALUE(0, DE_STRETCH_FORMAT, PATTERN_X, 0)| + FIELD_SET(0, DE_STRETCH_FORMAT, ADDRESSING, XY)| + FIELD_VALUE(0, DE_STRETCH_FORMAT, SOURCE_HEIGHT, 3); - clr = FIELD_CLEAR(DE_STRETCH_FORMAT,PATTERN_XY)& - FIELD_CLEAR(DE_STRETCH_FORMAT,PATTERN_Y)& - FIELD_CLEAR(DE_STRETCH_FORMAT,PATTERN_X)& - FIELD_CLEAR(DE_STRETCH_FORMAT,ADDRESSING)& - FIELD_CLEAR(DE_STRETCH_FORMAT,SOURCE_HEIGHT); + clr = FIELD_CLEAR(DE_STRETCH_FORMAT, PATTERN_XY)& + FIELD_CLEAR(DE_STRETCH_FORMAT, PATTERN_Y)& + FIELD_CLEAR(DE_STRETCH_FORMAT, PATTERN_X)& + FIELD_CLEAR(DE_STRETCH_FORMAT, ADDRESSING)& + FIELD_CLEAR(DE_STRETCH_FORMAT, SOURCE_HEIGHT); /* DE_STRETCH bpp format need be initilized in setMode routine */ - write_dpr(accel,DE_STRETCH_FORMAT,(read_dpr(accel,DE_STRETCH_FORMAT) & clr) | reg); + write_dpr(accel, DE_STRETCH_FORMAT, (read_dpr(accel, DE_STRETCH_FORMAT) & clr) | reg); /* disable clipping and transparent */ - write_dpr(accel,DE_CLIP_TL,0);//dpr2c - write_dpr(accel,DE_CLIP_BR,0);//dpr30 + write_dpr(accel, DE_CLIP_TL, 0);//dpr2c + write_dpr(accel, DE_CLIP_BR, 0);//dpr30 - write_dpr(accel,DE_COLOR_COMPARE_MASK,0);//dpr24 - write_dpr(accel,DE_COLOR_COMPARE,0); + write_dpr(accel, DE_COLOR_COMPARE_MASK, 0);//dpr24 + write_dpr(accel, DE_COLOR_COMPARE, 0); - reg = FIELD_SET(0,DE_CONTROL,TRANSPARENCY,DISABLE)| - FIELD_SET(0,DE_CONTROL,TRANSPARENCY_MATCH,OPAQUE)| - FIELD_SET(0,DE_CONTROL,TRANSPARENCY_SELECT,SOURCE); + reg = FIELD_SET(0, DE_CONTROL, TRANSPARENCY, DISABLE)| + FIELD_SET(0, DE_CONTROL, TRANSPARENCY_MATCH, OPAQUE)| + FIELD_SET(0, DE_CONTROL, TRANSPARENCY_SELECT, SOURCE); - clr = FIELD_CLEAR(DE_CONTROL,TRANSPARENCY)& - FIELD_CLEAR(DE_CONTROL,TRANSPARENCY_MATCH)& - FIELD_CLEAR(DE_CONTROL,TRANSPARENCY_SELECT); + clr = FIELD_CLEAR(DE_CONTROL, TRANSPARENCY)& + FIELD_CLEAR(DE_CONTROL, TRANSPARENCY_MATCH)& + FIELD_CLEAR(DE_CONTROL, TRANSPARENCY_SELECT); /* dpr0c */ - write_dpr(accel,DE_CONTROL,(read_dpr(accel,DE_CONTROL)&clr)|reg); + write_dpr(accel, DE_CONTROL, (read_dpr(accel, DE_CONTROL)&clr)|reg); } /* set2dformat only be called from setmode functions * but if you need dual framebuffer driver,need call set2dformat * every time you use 2d function */ -void hw_set2dformat(struct lynx_accel * accel,int fmt) +void hw_set2dformat(struct lynx_accel * accel, int fmt) { u32 reg; /* fmt=0,1,2 for 8,16,32,bpp on sm718/750/502 */ - reg = read_dpr(accel,DE_STRETCH_FORMAT); - reg = FIELD_VALUE(reg,DE_STRETCH_FORMAT,PIXEL_FORMAT,fmt); - write_dpr(accel,DE_STRETCH_FORMAT,reg); + reg = read_dpr(accel, DE_STRETCH_FORMAT); + reg = FIELD_VALUE(reg, DE_STRETCH_FORMAT, PIXEL_FORMAT, fmt); + write_dpr(accel, DE_STRETCH_FORMAT, reg); } int hw_fillrect(struct lynx_accel * accel, - u32 base,u32 pitch,u32 Bpp, - u32 x,u32 y,u32 width,u32 height, - u32 color,u32 rop) + u32 base, u32 pitch, u32 Bpp, + u32 x, u32 y, u32 width, u32 height, + u32 color, u32 rop) { u32 deCtrl; @@ -100,39 +100,39 @@ int hw_fillrect(struct lynx_accel * accel, { /* int time wait and always busy,seems hardware * got something error */ - pr_debug("%s:De engine always bussy\n",__func__); + pr_debug("%s:De engine always bussy\n", __func__); return -1; } - write_dpr(accel,DE_WINDOW_DESTINATION_BASE,base);//dpr40 - write_dpr(accel,DE_PITCH, - FIELD_VALUE(0,DE_PITCH,DESTINATION,pitch/Bpp)| - FIELD_VALUE(0,DE_PITCH,SOURCE,pitch/Bpp));//dpr10 + write_dpr(accel, DE_WINDOW_DESTINATION_BASE, base);//dpr40 + write_dpr(accel, DE_PITCH, + FIELD_VALUE(0, DE_PITCH, DESTINATION, pitch/Bpp)| + FIELD_VALUE(0, DE_PITCH, SOURCE, pitch/Bpp));//dpr10 - write_dpr(accel,DE_WINDOW_WIDTH, - FIELD_VALUE(0,DE_WINDOW_WIDTH,DESTINATION,pitch/Bpp)| - FIELD_VALUE(0,DE_WINDOW_WIDTH,SOURCE,pitch/Bpp));//dpr44 + write_dpr(accel, DE_WINDOW_WIDTH, + FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION, pitch/Bpp)| + FIELD_VALUE(0, DE_WINDOW_WIDTH, SOURCE, pitch/Bpp));//dpr44 - write_dpr(accel,DE_FOREGROUND,color);//DPR14 + write_dpr(accel, DE_FOREGROUND, color);//DPR14 - write_dpr(accel,DE_DESTINATION, - FIELD_SET(0,DE_DESTINATION,WRAP,DISABLE)| - FIELD_VALUE(0,DE_DESTINATION,X,x)| - FIELD_VALUE(0,DE_DESTINATION,Y,y));//dpr4 + write_dpr(accel, DE_DESTINATION, + FIELD_SET(0, DE_DESTINATION, WRAP, DISABLE)| + FIELD_VALUE(0, DE_DESTINATION, X, x)| + FIELD_VALUE(0, DE_DESTINATION, Y, y));//dpr4 - write_dpr(accel,DE_DIMENSION, - FIELD_VALUE(0,DE_DIMENSION,X,width)| - FIELD_VALUE(0,DE_DIMENSION,Y_ET,height));//dpr8 + write_dpr(accel, DE_DIMENSION, + FIELD_VALUE(0, DE_DIMENSION, X, width)| + FIELD_VALUE(0, DE_DIMENSION, Y_ET, height));//dpr8 deCtrl = - FIELD_SET(0,DE_CONTROL,STATUS,START)| - FIELD_SET(0,DE_CONTROL,DIRECTION,LEFT_TO_RIGHT)| - FIELD_SET(0,DE_CONTROL,LAST_PIXEL,ON)| - FIELD_SET(0,DE_CONTROL,COMMAND,RECTANGLE_FILL)| - FIELD_SET(0,DE_CONTROL,ROP_SELECT,ROP2)| - FIELD_VALUE(0,DE_CONTROL,ROP,rop);//dpr0xc + FIELD_SET(0, DE_CONTROL, STATUS, START)| + FIELD_SET(0, DE_CONTROL, DIRECTION, LEFT_TO_RIGHT)| + FIELD_SET(0, DE_CONTROL, LAST_PIXEL, ON)| + FIELD_SET(0, DE_CONTROL, COMMAND, RECTANGLE_FILL)| + FIELD_SET(0, DE_CONTROL, ROP_SELECT, ROP2)| + FIELD_VALUE(0, DE_CONTROL, ROP, rop);//dpr0xc - write_dpr(accel,DE_CONTROL,deCtrl); + write_dpr(accel, DE_CONTROL, deCtrl); return 0; } @@ -236,12 +236,12 @@ unsigned int rop2) /* ROP value */ /* 2D Source Base. It is an address offset (128 bit aligned) from the beginning of frame buffer. */ - write_dpr(accel,DE_WINDOW_SOURCE_BASE, sBase);//dpr40 + write_dpr(accel, DE_WINDOW_SOURCE_BASE, sBase);//dpr40 /* 2D Destination Base. It is an address offset (128 bit aligned) from the beginning of frame buffer. */ - write_dpr(accel,DE_WINDOW_DESTINATION_BASE, dBase);//dpr44 + write_dpr(accel, DE_WINDOW_DESTINATION_BASE, dBase);//dpr44 #if 0 /* Program pitch (distance between the 1st points of two adjacent lines). @@ -252,14 +252,14 @@ unsigned int rop2) /* ROP value */ sx *= 3; dx *= 3; width *= 3; - write_dpr(accel,DE_PITCH, + write_dpr(accel, DE_PITCH, FIELD_VALUE(0, DE_PITCH, DESTINATION, dPitch) | FIELD_VALUE(0, DE_PITCH, SOURCE, sPitch));//dpr10 } else #endif { - write_dpr(accel,DE_PITCH, + write_dpr(accel, DE_PITCH, FIELD_VALUE(0, DE_PITCH, DESTINATION, (dPitch/Bpp)) | FIELD_VALUE(0, DE_PITCH, SOURCE, (sPitch/Bpp)));//dpr10 } @@ -267,7 +267,7 @@ unsigned int rop2) /* ROP value */ /* Screen Window width in Pixels. 2D engine uses this value to calculate the linear address in frame buffer for a given point. */ - write_dpr(accel,DE_WINDOW_WIDTH, + write_dpr(accel, DE_WINDOW_WIDTH, FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION, (dPitch/Bpp)) | FIELD_VALUE(0, DE_WINDOW_WIDTH, SOURCE, (sPitch/Bpp)));//dpr3c @@ -277,15 +277,15 @@ unsigned int rop2) /* ROP value */ { - write_dpr(accel,DE_SOURCE, + write_dpr(accel, DE_SOURCE, FIELD_SET (0, DE_SOURCE, WRAP, DISABLE) | FIELD_VALUE(0, DE_SOURCE, X_K1, sx) | FIELD_VALUE(0, DE_SOURCE, Y_K2, sy));//dpr0 - write_dpr(accel,DE_DESTINATION, + write_dpr(accel, DE_DESTINATION, FIELD_SET (0, DE_DESTINATION, WRAP, DISABLE) | FIELD_VALUE(0, DE_DESTINATION, X, dx) | FIELD_VALUE(0, DE_DESTINATION, Y, dy));//dpr04 - write_dpr(accel,DE_DIMENSION, + write_dpr(accel, DE_DIMENSION, FIELD_VALUE(0, DE_DIMENSION, X, width) | FIELD_VALUE(0, DE_DIMENSION, Y_ET, height));//dpr08 @@ -297,7 +297,7 @@ unsigned int rop2) /* ROP value */ FIELD_SET(0, DE_CONTROL, DIRECTION, RIGHT_TO_LEFT) : FIELD_SET(0, DE_CONTROL, DIRECTION, LEFT_TO_RIGHT)) | FIELD_SET(0, DE_CONTROL, STATUS, START); - write_dpr(accel,DE_CONTROL,de_ctrl);//dpr0c + write_dpr(accel, DE_CONTROL, de_ctrl);//dpr0c } return 0; @@ -307,7 +307,7 @@ static unsigned int deGetTransparency(struct lynx_accel * accel) { unsigned int de_ctrl; - de_ctrl = read_dpr(accel,DE_CONTROL); + de_ctrl = read_dpr(accel, DE_CONTROL); de_ctrl &= FIELD_MASK(DE_CONTROL_TRANSPARENCY_MATCH) | @@ -353,12 +353,12 @@ int hw_imageblit(struct lynx_accel *accel, /* 2D Source Base. Use 0 for HOST Blt. */ - write_dpr(accel,DE_WINDOW_SOURCE_BASE, 0); + write_dpr(accel, DE_WINDOW_SOURCE_BASE, 0); /* 2D Destination Base. It is an address offset (128 bit aligned) from the beginning of frame buffer. */ - write_dpr(accel,DE_WINDOW_DESTINATION_BASE, dBase); + write_dpr(accel, DE_WINDOW_DESTINATION_BASE, dBase); #if 0 /* Program pitch (distance between the 1st points of two adjacent lines). Note that input pitch is BYTE value, but the 2D Pitch register uses @@ -368,7 +368,7 @@ int hw_imageblit(struct lynx_accel *accel, dx *= 3; width *= 3; startBit *= 3; - write_dpr(accel,DE_PITCH, + write_dpr(accel, DE_PITCH, FIELD_VALUE(0, DE_PITCH, DESTINATION, dPitch) | FIELD_VALUE(0, DE_PITCH, SOURCE, dPitch));//dpr10 @@ -376,7 +376,7 @@ int hw_imageblit(struct lynx_accel *accel, else #endif { - write_dpr(accel,DE_PITCH, + write_dpr(accel, DE_PITCH, FIELD_VALUE(0, DE_PITCH, DESTINATION, dPitch/bytePerPixel) | FIELD_VALUE(0, DE_PITCH, SOURCE, dPitch/bytePerPixel));//dpr10 } @@ -384,27 +384,27 @@ int hw_imageblit(struct lynx_accel *accel, /* Screen Window width in Pixels. 2D engine uses this value to calculate the linear address in frame buffer for a given point. */ - write_dpr(accel,DE_WINDOW_WIDTH, + write_dpr(accel, DE_WINDOW_WIDTH, FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION, (dPitch/bytePerPixel)) | FIELD_VALUE(0, DE_WINDOW_WIDTH, SOURCE, (dPitch/bytePerPixel))); /* Note: For 2D Source in Host Write, only X_K1_MONO field is needed, and Y_K2 field is not used. For mono bitmap, use startBit for X_K1. */ - write_dpr(accel,DE_SOURCE, + write_dpr(accel, DE_SOURCE, FIELD_SET (0, DE_SOURCE, WRAP, DISABLE) | FIELD_VALUE(0, DE_SOURCE, X_K1_MONO, startBit));//dpr00 - write_dpr(accel,DE_DESTINATION, + write_dpr(accel, DE_DESTINATION, FIELD_SET (0, DE_DESTINATION, WRAP, DISABLE) | FIELD_VALUE(0, DE_DESTINATION, X, dx) | FIELD_VALUE(0, DE_DESTINATION, Y, dy));//dpr04 - write_dpr(accel,DE_DIMENSION, + write_dpr(accel, DE_DIMENSION, FIELD_VALUE(0, DE_DIMENSION, X, width) | FIELD_VALUE(0, DE_DIMENSION, Y_ET, height));//dpr08 - write_dpr(accel,DE_FOREGROUND, fColor); - write_dpr(accel,DE_BACKGROUND, bColor); + write_dpr(accel, DE_FOREGROUND, fColor); + write_dpr(accel, DE_BACKGROUND, bColor); de_ctrl = FIELD_VALUE(0, DE_CONTROL, ROP, rop2) | FIELD_SET(0, DE_CONTROL, ROP_SELECT, ROP2) | @@ -412,7 +412,7 @@ int hw_imageblit(struct lynx_accel *accel, FIELD_SET(0, DE_CONTROL, HOST, MONO) | FIELD_SET(0, DE_CONTROL, STATUS, START); - write_dpr(accel,DE_CONTROL, de_ctrl | deGetTransparency(accel)); + write_dpr(accel, DE_CONTROL, de_ctrl | deGetTransparency(accel)); /* Write MONO data (line by line) to 2D Engine data port */ for (i=0; i Date: Tue, 2 Jun 2015 03:14:26 -0700 Subject: [PATCH 0841/1163] Staging: sm750fb: sm750_cursor.c: Insert spaces after commas. Insert Spaces after commas to rectify the following checkpatch errors in sm750_cursor.c: ERROR: space required after that ',' Signed-off-by: Isaac Assegai Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750_cursor.c | 40 +++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/sm750fb/sm750_cursor.c b/drivers/staging/sm750fb/sm750_cursor.c index 68d5cbc3e513..b14528574d59 100644 --- a/drivers/staging/sm750fb/sm750_cursor.c +++ b/drivers/staging/sm750fb/sm750_cursor.c @@ -23,8 +23,8 @@ #define PEEK32(addr) \ readl(cursor->mmio + (addr)) -#define POKE32(addr,data) \ -writel((data),cursor->mmio + (addr)) +#define POKE32(addr, data) \ +writel((data), cursor->mmio + (addr)) /* cursor control for voyager and 718/750*/ #define HWC_ADDRESS 0x0 @@ -61,42 +61,42 @@ writel((data),cursor->mmio + (addr)) void hw_cursor_enable(struct lynx_cursor * cursor) { u32 reg; - reg = FIELD_VALUE(0,HWC_ADDRESS,ADDRESS,cursor->offset)| - FIELD_SET(0,HWC_ADDRESS,EXT,LOCAL)| - FIELD_SET(0,HWC_ADDRESS,ENABLE,ENABLE); - POKE32(HWC_ADDRESS,reg); + reg = FIELD_VALUE(0, HWC_ADDRESS, ADDRESS, cursor->offset)| + FIELD_SET(0, HWC_ADDRESS, EXT, LOCAL)| + FIELD_SET(0, HWC_ADDRESS, ENABLE, ENABLE); + POKE32(HWC_ADDRESS, reg); } void hw_cursor_disable(struct lynx_cursor * cursor) { - POKE32(HWC_ADDRESS,0); + POKE32(HWC_ADDRESS, 0); } void hw_cursor_setSize(struct lynx_cursor * cursor, - int w,int h) + int w, int h) { cursor->w = w; cursor->h = h; } void hw_cursor_setPos(struct lynx_cursor * cursor, - int x,int y) + int x, int y) { u32 reg; - reg = FIELD_VALUE(0,HWC_LOCATION,Y,y)| - FIELD_VALUE(0,HWC_LOCATION,X,x); - POKE32(HWC_LOCATION,reg); + reg = FIELD_VALUE(0, HWC_LOCATION, Y, y)| + FIELD_VALUE(0, HWC_LOCATION, X, x); + POKE32(HWC_LOCATION, reg); } void hw_cursor_setColor(struct lynx_cursor * cursor, - u32 fg,u32 bg) + u32 fg, u32 bg) { - POKE32(HWC_COLOR_12,(fg<<16)|(bg&0xffff)); - POKE32(HWC_COLOR_3,0xffe0); + POKE32(HWC_COLOR_12, (fg<<16)|(bg&0xffff)); + POKE32(HWC_COLOR_3, 0xffe0); } void hw_cursor_setData(struct lynx_cursor * cursor, - u16 rop,const u8* pcol,const u8* pmsk) + u16 rop, const u8* pcol, const u8* pmsk) { - int i,j,count,pitch,offset; - u8 color,mask,opr; + int i, j, count, pitch, offset; + u8 color, mask, opr; u16 data; void __iomem *pbuffer, *pstart; @@ -184,9 +184,9 @@ void hw_cursor_setData(struct lynx_cursor * cursor, void hw_cursor_setData2(struct lynx_cursor * cursor, - u16 rop,const u8* pcol,const u8* pmsk) + u16 rop, const u8* pcol, const u8* pmsk) { - int i,j,count,pitch,offset; + int i, j, count, pitch, offset; u8 color, mask; u16 data; void __iomem *pbuffer, *pstart; From f31b55ac2ad8227ac005be29e5e81b743e1ec3b7 Mon Sep 17 00:00:00 2001 From: Isaac Assegai Date: Tue, 2 Jun 2015 03:14:28 -0700 Subject: [PATCH 0842/1163] Staging: sm750fb: Insert spaces after commas in two files. Insert Spaces after commas to rectify the following checkpatch errors in ddk750_power.c and ddk750_swi2c.c: ERROR: space required after that ',' Signed-off-by: Isaac Assegai : Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/ddk750_power.c | 4 ++-- drivers/staging/sm750fb/ddk750_swi2c.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/sm750fb/ddk750_power.c b/drivers/staging/sm750fb/ddk750_power.c index cbb97676b33c..1e5f398aed10 100644 --- a/drivers/staging/sm750fb/ddk750_power.c +++ b/drivers/staging/sm750fb/ddk750_power.c @@ -7,10 +7,10 @@ void ddk750_setDPMS(DPMS_t state) unsigned int value; if(getChipType() == SM750LE){ value = PEEK32(CRT_DISPLAY_CTRL); - POKE32(CRT_DISPLAY_CTRL,FIELD_VALUE(value,CRT_DISPLAY_CTRL,DPMS,state)); + POKE32(CRT_DISPLAY_CTRL, FIELD_VALUE(value, CRT_DISPLAY_CTRL, DPMS, state)); }else{ value = PEEK32(SYSTEM_CTRL); - value= FIELD_VALUE(value,SYSTEM_CTRL,DPMS,state); + value= FIELD_VALUE(value, SYSTEM_CTRL, DPMS, state); POKE32(SYSTEM_CTRL, value); } } diff --git a/drivers/staging/sm750fb/ddk750_swi2c.c b/drivers/staging/sm750fb/ddk750_swi2c.c index 901b3737f1ed..fc8f5a51e43c 100644 --- a/drivers/staging/sm750fb/ddk750_swi2c.c +++ b/drivers/staging/sm750fb/ddk750_swi2c.c @@ -96,7 +96,7 @@ static void swI2CWait(void) it's more reliable than counter loop .. write 0x61 to 0x3ce and read from 0x3cf */ - while(peekIO(0x3ce,0x61) & 0x10); + while(peekIO(0x3ce, 0x61) & 0x10); #else int i, Temp; From 195d2b643bebc9f96d2bbe9e9b092ed4f30505fe Mon Sep 17 00:00:00 2001 From: Isaac Assegai Date: Tue, 2 Jun 2015 03:14:29 -0700 Subject: [PATCH 0843/1163] Staging: sm750fb: Insert spaces after commas in two files. Insert Spaces after commas to rectify the following checkpatch errors in ddk750_help.c and ddk750_mode.c: ERROR: space required after that ',' Signed-off-by: Isaac Assegai Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/ddk750_help.c | 2 +- drivers/staging/sm750fb/ddk750_mode.c | 54 +++++++++++++-------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/staging/sm750fb/ddk750_help.c b/drivers/staging/sm750fb/ddk750_help.c index c68ff3b5751a..647004d5690c 100644 --- a/drivers/staging/sm750fb/ddk750_help.c +++ b/drivers/staging/sm750fb/ddk750_help.c @@ -7,7 +7,7 @@ char revId750 = 0; unsigned short devId750 = 0; /* after driver mapped io registers, use this function first */ -void ddk750_set_mmio(void __iomem * addr,unsigned short devId,char revId) +void ddk750_set_mmio(void __iomem * addr, unsigned short devId, char revId) { mmio750 = addr; devId750 = devId; diff --git a/drivers/staging/sm750fb/ddk750_mode.c b/drivers/staging/sm750fb/ddk750_mode.c index 021d4c3b2b10..a05474793ad4 100644 --- a/drivers/staging/sm750fb/ddk750_mode.c +++ b/drivers/staging/sm750fb/ddk750_mode.c @@ -75,15 +75,15 @@ static unsigned long displayControlAdjust_SM750LE(mode_parameter_t *pModeParam, /* only timing related registers will be programed */ -static int programModeRegisters(mode_parameter_t * pModeParam,pll_value_t * pll) +static int programModeRegisters(mode_parameter_t * pModeParam, pll_value_t * pll) { int ret = 0; int cnt = 0; - unsigned int ulTmpValue,ulReg; + unsigned int ulTmpValue, ulReg; if(pll->clockType == SECONDARY_PLL) { /* programe secondary pixel clock */ - POKE32(CRT_PLL_CTRL,formatPllReg(pll)); + POKE32(CRT_PLL_CTRL, formatPllReg(pll)); POKE32(CRT_HORIZONTAL_TOTAL, FIELD_VALUE(0, CRT_HORIZONTAL_TOTAL, TOTAL, pModeParam->horizontal_total - 1) | FIELD_VALUE(0, CRT_HORIZONTAL_TOTAL, DISPLAY_END, pModeParam->horizontal_display_end - 1)); @@ -101,29 +101,29 @@ static int programModeRegisters(mode_parameter_t * pModeParam,pll_value_t * pll) | FIELD_VALUE(0, CRT_VERTICAL_SYNC, START, pModeParam->vertical_sync_start - 1)); - ulTmpValue = FIELD_VALUE(0,CRT_DISPLAY_CTRL,VSYNC_PHASE,pModeParam->vertical_sync_polarity)| - FIELD_VALUE(0,CRT_DISPLAY_CTRL,HSYNC_PHASE,pModeParam->horizontal_sync_polarity)| - FIELD_SET(0,CRT_DISPLAY_CTRL,TIMING,ENABLE)| - FIELD_SET(0,CRT_DISPLAY_CTRL,PLANE,ENABLE); + ulTmpValue = FIELD_VALUE(0, CRT_DISPLAY_CTRL, VSYNC_PHASE, pModeParam->vertical_sync_polarity)| + FIELD_VALUE(0, CRT_DISPLAY_CTRL, HSYNC_PHASE, pModeParam->horizontal_sync_polarity)| + FIELD_SET(0, CRT_DISPLAY_CTRL, TIMING, ENABLE)| + FIELD_SET(0, CRT_DISPLAY_CTRL, PLANE, ENABLE); if(getChipType() == SM750LE){ - displayControlAdjust_SM750LE(pModeParam,ulTmpValue); + displayControlAdjust_SM750LE(pModeParam, ulTmpValue); }else{ ulReg = PEEK32(CRT_DISPLAY_CTRL) - & FIELD_CLEAR(CRT_DISPLAY_CTRL,VSYNC_PHASE) - & FIELD_CLEAR(CRT_DISPLAY_CTRL,HSYNC_PHASE) - & FIELD_CLEAR(CRT_DISPLAY_CTRL,TIMING) - & FIELD_CLEAR(CRT_DISPLAY_CTRL,PLANE); + & FIELD_CLEAR(CRT_DISPLAY_CTRL, VSYNC_PHASE) + & FIELD_CLEAR(CRT_DISPLAY_CTRL, HSYNC_PHASE) + & FIELD_CLEAR(CRT_DISPLAY_CTRL, TIMING) + & FIELD_CLEAR(CRT_DISPLAY_CTRL, PLANE); - POKE32(CRT_DISPLAY_CTRL,ulTmpValue|ulReg); + POKE32(CRT_DISPLAY_CTRL, ulTmpValue|ulReg); } } else if(pll->clockType == PRIMARY_PLL) { unsigned int ulReservedBits; - POKE32(PANEL_PLL_CTRL,formatPllReg(pll)); + POKE32(PANEL_PLL_CTRL, formatPllReg(pll)); POKE32(PANEL_HORIZONTAL_TOTAL, FIELD_VALUE(0, PANEL_HORIZONTAL_TOTAL, TOTAL, pModeParam->horizontal_total - 1) @@ -141,16 +141,16 @@ static int programModeRegisters(mode_parameter_t * pModeParam,pll_value_t * pll) FIELD_VALUE(0, PANEL_VERTICAL_SYNC, HEIGHT, pModeParam->vertical_sync_height) | FIELD_VALUE(0, PANEL_VERTICAL_SYNC, START, pModeParam->vertical_sync_start - 1)); - ulTmpValue = FIELD_VALUE(0,PANEL_DISPLAY_CTRL,VSYNC_PHASE,pModeParam->vertical_sync_polarity)| - FIELD_VALUE(0,PANEL_DISPLAY_CTRL,HSYNC_PHASE,pModeParam->horizontal_sync_polarity)| - FIELD_VALUE(0,PANEL_DISPLAY_CTRL,CLOCK_PHASE,pModeParam->clock_phase_polarity)| - FIELD_SET(0,PANEL_DISPLAY_CTRL,TIMING,ENABLE)| - FIELD_SET(0,PANEL_DISPLAY_CTRL,PLANE,ENABLE); + ulTmpValue = FIELD_VALUE(0, PANEL_DISPLAY_CTRL, VSYNC_PHASE, pModeParam->vertical_sync_polarity)| + FIELD_VALUE(0, PANEL_DISPLAY_CTRL, HSYNC_PHASE, pModeParam->horizontal_sync_polarity)| + FIELD_VALUE(0, PANEL_DISPLAY_CTRL, CLOCK_PHASE, pModeParam->clock_phase_polarity)| + FIELD_SET(0, PANEL_DISPLAY_CTRL, TIMING, ENABLE)| + FIELD_SET(0, PANEL_DISPLAY_CTRL, PLANE, ENABLE); ulReservedBits = FIELD_SET(0, PANEL_DISPLAY_CTRL, RESERVED_1_MASK, ENABLE) | FIELD_SET(0, PANEL_DISPLAY_CTRL, RESERVED_2_MASK, ENABLE) | FIELD_SET(0, PANEL_DISPLAY_CTRL, RESERVED_3_MASK, ENABLE)| - FIELD_SET(0,PANEL_DISPLAY_CTRL,VSYNC,ACTIVE_LOW); + FIELD_SET(0, PANEL_DISPLAY_CTRL, VSYNC, ACTIVE_LOW); ulReg = (PEEK32(PANEL_DISPLAY_CTRL) & ~ulReservedBits) & FIELD_CLEAR(PANEL_DISPLAY_CTRL, CLOCK_PHASE) @@ -168,14 +168,14 @@ static int programModeRegisters(mode_parameter_t * pModeParam,pll_value_t * pll) * next vertical sync to turn on/off the plane. */ - POKE32(PANEL_DISPLAY_CTRL,ulTmpValue|ulReg); + POKE32(PANEL_DISPLAY_CTRL, ulTmpValue|ulReg); #if 1 while((PEEK32(PANEL_DISPLAY_CTRL) & ~ulReservedBits) != (ulTmpValue|ulReg)) { cnt++; if(cnt > 1000) break; - POKE32(PANEL_DISPLAY_CTRL,ulTmpValue|ulReg); + POKE32(PANEL_DISPLAY_CTRL, ulTmpValue|ulReg); } #endif } @@ -185,20 +185,20 @@ static int programModeRegisters(mode_parameter_t * pModeParam,pll_value_t * pll) return ret; } -int ddk750_setModeTiming(mode_parameter_t * parm,clock_type_t clock) +int ddk750_setModeTiming(mode_parameter_t * parm, clock_type_t clock) { pll_value_t pll; unsigned int uiActualPixelClk; pll.inputFreq = DEFAULT_INPUT_CLOCK; pll.clockType = clock; - uiActualPixelClk = calcPllValue(parm->pixel_clock,&pll); + uiActualPixelClk = calcPllValue(parm->pixel_clock, &pll); if(getChipType() == SM750LE){ /* set graphic mode via IO method */ - outb_p(0x88,0x3d4); - outb_p(0x06,0x3d5); + outb_p(0x88, 0x3d4); + outb_p(0x06, 0x3d5); } - programModeRegisters(parm,&pll); + programModeRegisters(parm, &pll); return 0; } From da295041a811adc2d7d809f4b0901f241b8f16ea Mon Sep 17 00:00:00 2001 From: Isaac Assegai Date: Tue, 2 Jun 2015 03:14:30 -0700 Subject: [PATCH 0844/1163] Staging: sm750fb: ddk750_display.c: Insert spaces after commas. Insert Spaces after commas to rectify the following checkpatch errors in ddk750_display.c: ERROR: space required after that ',' Signed-off-by: Isaac Assegai Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/ddk750_display.c | 44 ++++++++++++------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/staging/sm750fb/ddk750_display.c b/drivers/staging/sm750fb/ddk750_display.c index c84196ac055d..a3e672056ef8 100644 --- a/drivers/staging/sm750fb/ddk750_display.c +++ b/drivers/staging/sm750fb/ddk750_display.c @@ -4,9 +4,9 @@ #include "ddk750_power.h" #include "ddk750_dvi.h" -#define primaryWaitVerticalSync(delay) waitNextVerticalSync(0,delay) +#define primaryWaitVerticalSync(delay) waitNextVerticalSync(0, delay) -static void setDisplayControl(int ctrl,int dispState) +static void setDisplayControl(int ctrl, int dispState) { /* state != 0 means turn on both timing & plane en_bit */ unsigned long ulDisplayCtrlReg, ulReservedBits; @@ -51,7 +51,7 @@ static void setDisplayControl(int ctrl,int dispState) POKE32(PANEL_DISPLAY_CTRL, ulDisplayCtrlReg); } while((PEEK32(PANEL_DISPLAY_CTRL) & ~ulReservedBits) != (ulDisplayCtrlReg & ~ulReservedBits)); - printk("Set Panel Plane enbit:after tried %d times\n",cnt); + printk("Set Panel Plane enbit:after tried %d times\n", cnt); } else { @@ -106,7 +106,7 @@ static void setDisplayControl(int ctrl,int dispState) POKE32(CRT_DISPLAY_CTRL, ulDisplayCtrlReg); } while((PEEK32(CRT_DISPLAY_CTRL) & ~ulReservedBits) != (ulDisplayCtrlReg & ~ulReservedBits)); - printk("Set Crt Plane enbit:after tried %d times\n",cnt); + printk("Set Crt Plane enbit:after tried %d times\n", cnt); } else { @@ -129,7 +129,7 @@ static void setDisplayControl(int ctrl,int dispState) } -static void waitNextVerticalSync(int ctrl,int delay) +static void waitNextVerticalSync(int ctrl, int delay) { unsigned int status; if(!ctrl){ @@ -201,31 +201,31 @@ static void waitNextVerticalSync(int ctrl,int delay) } } -static void swPanelPowerSequence(int disp,int delay) +static void swPanelPowerSequence(int disp, int delay) { unsigned int reg; /* disp should be 1 to open sequence */ reg = PEEK32(PANEL_DISPLAY_CTRL); - reg = FIELD_VALUE(reg,PANEL_DISPLAY_CTRL,FPEN,disp); - POKE32(PANEL_DISPLAY_CTRL,reg); + reg = FIELD_VALUE(reg, PANEL_DISPLAY_CTRL, FPEN, disp); + POKE32(PANEL_DISPLAY_CTRL, reg); primaryWaitVerticalSync(delay); reg = PEEK32(PANEL_DISPLAY_CTRL); - reg = FIELD_VALUE(reg,PANEL_DISPLAY_CTRL,DATA,disp); - POKE32(PANEL_DISPLAY_CTRL,reg); + reg = FIELD_VALUE(reg, PANEL_DISPLAY_CTRL, DATA, disp); + POKE32(PANEL_DISPLAY_CTRL, reg); primaryWaitVerticalSync(delay); reg = PEEK32(PANEL_DISPLAY_CTRL); - reg = FIELD_VALUE(reg,PANEL_DISPLAY_CTRL,VBIASEN,disp); - POKE32(PANEL_DISPLAY_CTRL,reg); + reg = FIELD_VALUE(reg, PANEL_DISPLAY_CTRL, VBIASEN, disp); + POKE32(PANEL_DISPLAY_CTRL, reg); primaryWaitVerticalSync(delay); reg = PEEK32(PANEL_DISPLAY_CTRL); - reg = FIELD_VALUE(reg,PANEL_DISPLAY_CTRL,FPEN,disp); - POKE32(PANEL_DISPLAY_CTRL,reg); + reg = FIELD_VALUE(reg, PANEL_DISPLAY_CTRL, FPEN, disp); + POKE32(PANEL_DISPLAY_CTRL, reg); primaryWaitVerticalSync(delay); } @@ -236,33 +236,33 @@ void ddk750_setLogicalDispOut(disp_output_t output) if(output & PNL_2_USAGE){ /* set panel path controller select */ reg = PEEK32(PANEL_DISPLAY_CTRL); - reg = FIELD_VALUE(reg,PANEL_DISPLAY_CTRL,SELECT,(output & PNL_2_MASK)>>PNL_2_OFFSET); - POKE32(PANEL_DISPLAY_CTRL,reg); + reg = FIELD_VALUE(reg, PANEL_DISPLAY_CTRL, SELECT, (output & PNL_2_MASK)>>PNL_2_OFFSET); + POKE32(PANEL_DISPLAY_CTRL, reg); } if(output & CRT_2_USAGE){ /* set crt path controller select */ reg = PEEK32(CRT_DISPLAY_CTRL); - reg = FIELD_VALUE(reg,CRT_DISPLAY_CTRL,SELECT,(output & CRT_2_MASK)>>CRT_2_OFFSET); + reg = FIELD_VALUE(reg, CRT_DISPLAY_CTRL, SELECT, (output & CRT_2_MASK)>>CRT_2_OFFSET); /*se blank off */ - reg = FIELD_SET(reg,CRT_DISPLAY_CTRL,BLANK,OFF); - POKE32(CRT_DISPLAY_CTRL,reg); + reg = FIELD_SET(reg, CRT_DISPLAY_CTRL, BLANK, OFF); + POKE32(CRT_DISPLAY_CTRL, reg); } if(output & PRI_TP_USAGE){ /* set primary timing and plane en_bit */ - setDisplayControl(0,(output&PRI_TP_MASK)>>PRI_TP_OFFSET); + setDisplayControl(0, (output&PRI_TP_MASK)>>PRI_TP_OFFSET); } if(output & SEC_TP_USAGE){ /* set secondary timing and plane en_bit*/ - setDisplayControl(1,(output&SEC_TP_MASK)>>SEC_TP_OFFSET); + setDisplayControl(1, (output&SEC_TP_MASK)>>SEC_TP_OFFSET); } if(output & PNL_SEQ_USAGE){ /* set panel sequence */ - swPanelPowerSequence((output&PNL_SEQ_MASK)>>PNL_SEQ_OFFSET,4); + swPanelPowerSequence((output&PNL_SEQ_MASK)>>PNL_SEQ_OFFSET, 4); } if(output & DAC_USAGE) From 0aae092b5e6162c53d49f2e0cc1822ef8a1c771e Mon Sep 17 00:00:00 2001 From: Hari Prasath Gujulan Elango Date: Mon, 1 Jun 2015 13:06:54 +0000 Subject: [PATCH 0845/1163] staging: dgnc: remove ununsed Macro Remove the ununsed Macro Signed-off-by: Hari Prasath Gujulan Elango Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_driver.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h index 3dee9f392fb3..ebb34398885d 100644 --- a/drivers/staging/dgnc/dgnc_driver.h +++ b/drivers/staging/dgnc/dgnc_driver.h @@ -66,7 +66,6 @@ /* 4 extra for alignment play space */ #define WRITEBUFLEN ((4096) + 4) -#define MYFLIPLEN N_TTY_BUF_SIZE #define dgnc_jiffies_from_ms(a) (((a) * HZ) / 1000) From 3b83fb7589cb295908524cb33a53c67d996cd09f Mon Sep 17 00:00:00 2001 From: Hari Prasath Gujulan Elango Date: Mon, 1 Jun 2015 09:48:49 +0000 Subject: [PATCH 0846/1163] staging: rtl8188eu: remove unwanted assignment remove an unwanted assignment to a variable which is overwritten in the very next line.The first value assigned is not used. Signed-off-by: Hari Prasath Gujulan Elango Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_halinit.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index 7b01d5aa6b23..872622214264 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -2077,7 +2077,6 @@ static void UpdateHalRAMask8188EUsb(struct adapter *adapt, u32 mac_id, u8 rssi_l break; } - rate_bitmap = 0x0fffffff; rate_bitmap = ODM_Get_Rate_Bitmap(&haldata->odmpriv, mac_id, mask, rssi_level); DBG_88E("%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); From 7eea766ad712bdeb20e15dde826672dfe12677bf Mon Sep 17 00:00:00 2001 From: Hari Prasath Gujulan Elango Date: Mon, 1 Jun 2015 09:55:23 +0000 Subject: [PATCH 0847/1163] staging: rtl8712: fix indentation issue Fixed indentation issue in few lines Signed-off-by: Hari Prasath Gujulan Elango Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/recv_linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8712/recv_linux.c b/drivers/staging/rtl8712/recv_linux.c index 799a0f9a5b2d..4201ce776e0c 100644 --- a/drivers/staging/rtl8712/recv_linux.c +++ b/drivers/staging/rtl8712/recv_linux.c @@ -132,9 +132,9 @@ void r8712_recv_indicatepkt(struct _adapter *padapter, return; _recv_indicatepkt_drop: /*enqueue back to free_recv_queue*/ - if (precv_frame) + if (precv_frame) r8712_free_recvframe(precv_frame, pfree_recv_queue); - precvpriv->rx_drop++; + precvpriv->rx_drop++; } static void _r8712_reordering_ctrl_timeout_handler (unsigned long data) From f51cd2b7d16dc89ec812721b43d07e5fc7734ea4 Mon Sep 17 00:00:00 2001 From: Madhusudhanan Ravindran Date: Mon, 1 Jun 2015 12:37:48 +0000 Subject: [PATCH 0848/1163] staging: emxx_udc: remove commented code removed the commented INFO lines. Signed-off-by: Madhusudhanan Ravindran Signed-off-by: Greg Kroah-Hartman --- drivers/staging/emxx_udc/emxx_udc.c | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index 163ca56a11ab..4178d96f94cf 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -2249,8 +2249,6 @@ static int _nbu2ss_pullup(struct nbu2ss_udc *udc, int is_on) if (is_on) { /* D+ Pullup */ -/* INFO(" --- D+ Pullup\n"); */ - if (udc->driver) { reg_dt = (_nbu2ss_readl(&udc->p_regs->USB_CONTROL) | PUE2) & ~(u32)CONNECTB; @@ -2260,8 +2258,6 @@ static int _nbu2ss_pullup(struct nbu2ss_udc *udc, int is_on) } else { /* D+ Pulldown */ -/* INFO(" --- D+ Pulldown\n"); */ - reg_dt = (_nbu2ss_readl(&udc->p_regs->USB_CONTROL) | CONNECTB) & ~(u32)PUE2; @@ -2731,8 +2727,6 @@ static int nbu2ss_ep_queue( ep = container_of(_ep, struct nbu2ss_ep, ep); udc = ep->udc; -/* INFO("=== %s(ep%d), zero=%d\n", __func__, ep->epnum, _req->zero); */ - if (udc->vbus_active == 0) { dev_info(udc->dev, "Can't ep_queue (VBUS OFF)\n"); return -ESHUTDOWN; @@ -2808,8 +2802,6 @@ static int nbu2ss_ep_dequeue( struct nbu2ss_udc *udc; unsigned long flags; - /*INFO("=== %s()\n", __func__);*/ - /* catch various bogus parameters */ if ((_ep == NULL) || (_req == NULL)) { /* pr_err("%s, bad param(1)\n", __func__); */ @@ -2855,8 +2847,6 @@ static int nbu2ss_ep_set_halt(struct usb_ep *_ep, int value) struct nbu2ss_ep *ep; struct nbu2ss_udc *udc; -/* INFO("=== %s()\n", __func__); */ - if (!_ep) { pr_err("%s, bad param\n", __func__); return -EINVAL; @@ -2909,8 +2899,6 @@ static int nbu2ss_ep_fifo_status(struct usb_ep *_ep) unsigned long flags; struct fc_regs *preg; -/* INFO("=== %s()\n", __func__); */ - if (!_ep) { pr_err("%s, bad param\n", __func__); return -EINVAL; @@ -2957,8 +2945,6 @@ static void nbu2ss_ep_fifo_flush(struct usb_ep *_ep) struct nbu2ss_udc *udc; unsigned long flags; -/* INFO("=== %s()\n", __func__); */ - if (!_ep) { pr_err("udc: %s, bad param\n", __func__); return; @@ -3013,8 +2999,6 @@ static int nbu2ss_gad_get_frame(struct usb_gadget *pgadget) u32 data; struct nbu2ss_udc *udc; -/* INFO("=== %s()\n", __func__); */ - if (pgadget == NULL) { pr_err("udc: %s, bad param\n", __func__); return -EINVAL; @@ -3043,8 +3027,6 @@ static int nbu2ss_gad_wakeup(struct usb_gadget *pgadget) struct nbu2ss_udc *udc; -/* INFO("=== %s()\n", __func__); */ - if (pgadget == NULL) { pr_err("%s, bad param\n", __func__); return -EINVAL; @@ -3083,8 +3065,6 @@ static int nbu2ss_gad_set_selfpowered(struct usb_gadget *pgadget, struct nbu2ss_udc *udc; unsigned long flags; -/* INFO("=== %s()\n", __func__); */ - if (pgadget == NULL) { pr_err("%s, bad param\n", __func__); return -EINVAL; @@ -3102,7 +3082,6 @@ static int nbu2ss_gad_set_selfpowered(struct usb_gadget *pgadget, /*-------------------------------------------------------------------------*/ static int nbu2ss_gad_vbus_session(struct usb_gadget *pgadget, int is_active) { -/* INFO("=== %s()\n", __func__); */ return 0; } @@ -3112,8 +3091,6 @@ static int nbu2ss_gad_vbus_draw(struct usb_gadget *pgadget, unsigned mA) struct nbu2ss_udc *udc; unsigned long flags; -/* INFO("=== %s()\n", __func__); */ - if (pgadget == NULL) { pr_err("%s, bad param\n", __func__); return -EINVAL; @@ -3134,8 +3111,6 @@ static int nbu2ss_gad_pullup(struct usb_gadget *pgadget, int is_on) struct nbu2ss_udc *udc; unsigned long flags; -/* INFO("=== %s()\n", __func__); */ - if (pgadget == NULL) { pr_err("%s, bad param\n", __func__); return -EINVAL; @@ -3164,7 +3139,6 @@ static int nbu2ss_gad_ioctl( unsigned code, unsigned long param) { -/* INFO("=== %s()\n", __func__); */ return 0; } From cfa6954ced97004242057b48b0e30113a02c19c4 Mon Sep 17 00:00:00 2001 From: Douglas Barbonaglia Sathler Figueiredo Date: Mon, 1 Jun 2015 10:37:11 -0300 Subject: [PATCH 0849/1163] staging: wlan-ng: fix long line Style (line over 80 chars) in drivers/staging/wlan-ng/prism2fw.c Signed-off-by: Douglas Barbonaglia Sathler Figueiredo Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/prism2fw.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c index 9408644cc8b8..fe36613589ae 100644 --- a/drivers/staging/wlan-ng/prism2fw.c +++ b/drivers/staging/wlan-ng/prism2fw.c @@ -708,7 +708,10 @@ static int plugimage(struct imgchunk *fchunk, unsigned int nfchunks, continue; } - /* Validate plug address against chunk data and identify chunk */ + /* + * Validate plug address against + * chunk data and identify chunk + */ for (c = 0; c < nfchunks; c++) { cstart = fchunk[c].addr; cend = fchunk[c].addr + fchunk[c].len; @@ -923,7 +926,8 @@ static int read_fwfile(const struct ihex_binrec *record) rcnt, s3info[ns3info].len, s3info[ns3info].type); - if (((s3info[ns3info].len - 1) * sizeof(u16)) > sizeof(s3info[ns3info].info)) { + if (((s3info[ns3info].len - 1) * sizeof(u16)) > + sizeof(s3info[ns3info].info)) { pr_err("S3 inforec length too long - aborting\n"); return 1; } From a4f649bdab2827c28db913b33bfc64bb82d147f6 Mon Sep 17 00:00:00 2001 From: Chaitanya Dhere Date: Tue, 2 Jun 2015 06:20:55 +0000 Subject: [PATCH 0850/1163] staging: rtl8192u: Patch to modify if, else conditions In this patch, the if, else conditions are modified to remove the unnecessary equality checks. This change was detected with help of coccinelle tool. Signed-off-by: Chaitanya Dhere Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index d2e8b125b989..1742e58b1fb0 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -1364,12 +1364,10 @@ static void ieee80211_associate_complete_wq(struct work_struct *work) ieee->LinkDetectInfo.NumRecvDataInPeriod= 1; } ieee->link_change(ieee->dev); - if(ieee->is_silent_reset == 0){ + if (!ieee->is_silent_reset) { printk("============>normal associate\n"); notify_wx_assoc_event(ieee); - } - else if(ieee->is_silent_reset == 1) - { + } else { printk("==================>silent reset associate\n"); ieee->is_silent_reset = false; } From 9c708f94610b69161591f4eabc0aebcaa037f69b Mon Sep 17 00:00:00 2001 From: Chaitanya Dhere Date: Tue, 2 Jun 2015 06:22:26 +0000 Subject: [PATCH 0851/1163] staging: rtl8192u: Fix indentation issue This change was detected with help of checkpatch.pl script. Signed-off-by: Chaitanya Dhere Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 1742e58b1fb0..e08ef100d9d0 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -1366,7 +1366,7 @@ static void ieee80211_associate_complete_wq(struct work_struct *work) ieee->link_change(ieee->dev); if (!ieee->is_silent_reset) { printk("============>normal associate\n"); - notify_wx_assoc_event(ieee); + notify_wx_assoc_event(ieee); } else { printk("==================>silent reset associate\n"); ieee->is_silent_reset = false; From 343506bf0ac102eef76129f453add81c3974ad0d Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Thu, 4 Jun 2015 09:22:37 -0400 Subject: [PATCH 0852/1163] staging: unisys: Migrate bus from devdata to visor_device The bus device and regular device were using two different structs. Let's combine them as they are not entirely different from one another. This allows us to move this creation up the stack later and actually remove bus/dev_info easily. Most of the churn is just renaming devdata -> dev and 'struct visorbus_devdata' to 'struct visor_device'. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorbus_main.c | 127 ++++++++---------- 1 file changed, 57 insertions(+), 70 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index c7db6817f1b4..380ea62d4ef5 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -36,18 +36,6 @@ static int visorbus_devicetest; static int visorbus_debugref; #define SERIALLOOPBACKCHANADDR (100 * 1024 * 1024) -/** This is the private data that we store for each bus device instance. - */ -struct visorbus_devdata { - int devno; /* this is the chipset busNo */ - struct list_head list_all; - struct device dev; - struct kobject kobj; - struct visorchannel *chan; /* channel area for bus itself */ - bool vbus_valid; - void *vbus_hdr_info; -}; - #define CURRENT_FILE_PC VISOR_BUS_PC_visorbus_main_c #define POLLJIFFIES_TESTWORK 100 #define POLLJIFFIES_NORMALCHANNEL 10 @@ -137,7 +125,7 @@ static struct ultra_vbus_deviceinfo chipset_driverinfo; /* filled in with info about this driver, wrt it servicing client busses */ static struct ultra_vbus_deviceinfo clientbus_driverinfo; -/** list of visorbus_devdata structs, linked via .list_all */ +/** list of visor_device structs, linked via .list_all */ static LIST_HEAD(list_all_bus_instances); /** list of visor_device structs, linked via .list_all */ static LIST_HEAD(list_all_device_instances); @@ -195,10 +183,10 @@ away: static void visorbus_release_busdevice(struct device *xdev) { - struct visorbus_devdata *devdata = dev_get_drvdata(xdev); + struct visor_device *dev = dev_get_drvdata(xdev); dev_set_drvdata(xdev, NULL); - kfree(devdata); + kfree(dev); kfree(xdev); } @@ -524,9 +512,6 @@ static const struct attribute_group *visorbus_dev_groups[] = { /* end implementation of specific channel attributes */ -#define to_visorbus_devdata(obj) \ - container_of(obj, struct visorbus_devdata, dev) - /* BUS instance attributes * * define & implement display of bus attributes under @@ -1008,7 +993,7 @@ EXPORT_SYMBOL_GPL(visorbus_disable_channel_interrupts); * device. */ static int -create_visor_device(struct visorbus_devdata *devdata, +create_visor_device(struct visor_device *bdev, struct visorchipset_device_info *dev_info, u64 partition_handle) { @@ -1032,7 +1017,7 @@ create_visor_device(struct visorbus_devdata *devdata, dev->channel_type_guid = dev_info->channel_type_guid; dev->chipset_bus_no = chipset_bus_no; dev->chipset_dev_no = chipset_dev_no; - dev->device.parent = &devdata->dev; + dev->device.parent = &bdev->device; sema_init(&dev->visordriver_callback_lock, 1); /* unlocked */ dev->device.bus = &visorbus_type; dev->device.groups = visorbus_dev_groups; @@ -1270,7 +1255,7 @@ fix_vbus_dev_info(struct visor_device *visordev) { int i; struct visorchipset_bus_info bus_info; - struct visorbus_devdata *devdata = NULL; + struct visor_device *dev = NULL; struct visor_driver *visordrv; int bus_no = visordev->chipset_bus_no; int dev_no = visordev->chipset_dev_no; @@ -1287,8 +1272,8 @@ fix_vbus_dev_info(struct visor_device *visordev) if (!visorchipset_get_bus_info(bus_no, &bus_info)) return; - devdata = (struct visorbus_devdata *)(bus_info.bus_driver_context); - if (!devdata) + dev = (struct visor_device *)(bus_info.bus_driver_context); + if (!dev) return; if (!hdr_info) @@ -1311,28 +1296,28 @@ fix_vbus_dev_info(struct visor_device *visordev) bus_device_info_init(&dev_info, chan_type_name, visordrv->name, visordrv->version, visordrv->vertag); - write_vbus_dev_info(devdata->chan, hdr_info, &dev_info, dev_no); + write_vbus_dev_info(dev->visorchannel, hdr_info, &dev_info, dev_no); /* Re-write bus+chipset info, because it is possible that this * was previously written by our evil counterpart, virtpci. */ - write_vbus_chp_info(devdata->chan, hdr_info, &chipset_driverinfo); - write_vbus_bus_info(devdata->chan, hdr_info, &clientbus_driverinfo); + write_vbus_chp_info(dev->visorchannel, hdr_info, &chipset_driverinfo); + write_vbus_bus_info(dev->visorchannel, hdr_info, &clientbus_driverinfo); } /** Create a device instance for the visor bus itself. */ -static struct visorbus_devdata * +static struct visor_device * create_bus_instance(struct visorchipset_bus_info *bus_info) { - struct visorbus_devdata *rc = NULL; - struct visorbus_devdata *devdata = NULL; + struct visor_device *rc = NULL; + struct visor_device *dev = NULL; int id = bus_info->bus_no; struct spar_vbus_headerinfo *hdr_info; POSTCODE_LINUX_2(BUS_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); - devdata = kzalloc(sizeof(*devdata), GFP_KERNEL); - if (!devdata) { + dev = kzalloc(sizeof(*dev), GFP_KERNEL); + if (!dev) { POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR); rc = NULL; goto away; @@ -1344,41 +1329,43 @@ create_bus_instance(struct visorchipset_bus_info *bus_info) goto away_mem; } - dev_set_name(&devdata->dev, "visorbus%d", id); - devdata->dev.bus = &visorbus_type; - devdata->dev.groups = visorbus_groups; - devdata->dev.release = visorbus_release_busdevice; - if (device_register(&devdata->dev) < 0) { + dev_set_name(&dev->device, "visorbus%d", id); + dev->device.bus = &visorbus_type; + dev->device.groups = visorbus_groups; + dev->device.release = visorbus_release_busdevice; + if (device_register(&dev->device) < 0) { POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, id, POSTCODE_SEVERITY_ERR); rc = NULL; goto away_mem2; } - devdata->devno = id; - devdata->chan = bus_info->visorchannel; + dev->chipset_bus_no = id; + dev->visorchannel = bus_info->visorchannel; if (bus_info->flags.server) { - init_vbus_channel(devdata->chan); + init_vbus_channel(dev->visorchannel); } else { - if (get_vbus_header_info(devdata->chan, hdr_info) >= 0) { - devdata->vbus_hdr_info = (void *)hdr_info; - write_vbus_chp_info(devdata->chan, hdr_info, + if (get_vbus_header_info(dev->visorchannel, hdr_info) >= 0) { + dev->vbus_hdr_info = (void *)hdr_info; + write_vbus_chp_info(dev->visorchannel, hdr_info, &chipset_driverinfo); - write_vbus_bus_info(devdata->chan, hdr_info, + write_vbus_bus_info(dev->visorchannel, hdr_info, &clientbus_driverinfo); + } else { + kfree(hdr_info); } } bus_count++; - list_add_tail(&devdata->list_all, &list_all_bus_instances); + list_add_tail(&dev->list_all, &list_all_bus_instances); if (id == 0) - devdata = devdata; /* for testing ONLY */ - dev_set_drvdata(&devdata->dev, devdata); - rc = devdata; + dev = dev; /* for testing ONLY */ + dev_set_drvdata(&dev->device, dev); + rc = dev; return rc; away_mem2: kfree(hdr_info); away_mem: - kfree(devdata); + kfree(dev); away: return rc; } @@ -1386,23 +1373,23 @@ away: /** Remove a device instance for the visor bus itself. */ static void -remove_bus_instance(struct visorbus_devdata *devdata) +remove_bus_instance(struct visor_device *dev) { /* Note that this will result in the release method for - * devdata->dev being called, which will call + * dev->dev being called, which will call * visorbus_release_busdevice(). This has something to do with * the put_device() done in device_unregister(), but I have never * successfully been able to trace thru the code to see where/how * release() gets called. But I know it does. */ bus_count--; - if (devdata->chan) { - visorchannel_destroy(devdata->chan); - devdata->chan = NULL; + if (dev->visorchannel) { + visorchannel_destroy(dev->visorchannel); + dev->visorchannel = NULL; } - kfree(devdata->vbus_hdr_info); - list_del(&devdata->list_all); - device_unregister(&devdata->dev); + kfree(dev->vbus_hdr_info); + list_del(&dev->list_all); + device_unregister(&dev->device); } /** Create and register the one-and-only one instance of @@ -1449,15 +1436,15 @@ static unsigned long test_dev_nos[MAXDEVICETEST]; static void chipset_bus_create(struct visorchipset_bus_info *bus_info) { - struct visorbus_devdata *devdata; + struct visor_device *dev; int rc = -1; u32 bus_no = bus_info->bus_no; POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO); - devdata = create_bus_instance(bus_info); - if (!devdata) + dev = create_bus_instance(bus_info); + if (!dev) goto away; - if (!visorchipset_set_bus_context(bus_info, devdata)) + if (!visorchipset_set_bus_context(bus_info, dev)) goto away; POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO); rc = 0; @@ -1476,13 +1463,13 @@ away: static void chipset_bus_destroy(struct visorchipset_bus_info *bus_info) { - struct visorbus_devdata *devdata; + struct visor_device *dev; int rc = -1; - devdata = (struct visorbus_devdata *)(bus_info->bus_driver_context); - if (!devdata) + dev = (struct visor_device *)(bus_info->bus_driver_context); + if (!dev) goto away; - remove_bus_instance(devdata); + remove_bus_instance(dev); if (!visorchipset_set_bus_context(bus_info, NULL)) goto away; rc = 0; @@ -1497,7 +1484,7 @@ static void chipset_device_create(struct visorchipset_device_info *dev_info) { struct visorchipset_bus_info bus_info; - struct visorbus_devdata *devdata = NULL; + struct visor_device *dev = NULL; int rc = -1; u32 bus_no = dev_info->bus_no; u32 dev_no = dev_info->dev_no; @@ -1525,8 +1512,8 @@ away: POSTCODE_SEVERITY_ERR); return; } - devdata = (struct visorbus_devdata *)(bus_info.bus_driver_context); - rc = create_visor_device(devdata, dev_info, bus_info.partition_handle); + dev = (struct visor_device *)(bus_info.bus_driver_context); + rc = create_visor_device(dev, dev_info, bus_info.partition_handle); POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); if (rc < 0) @@ -1758,11 +1745,11 @@ visorbus_exit(void) } list_for_each_safe(listentry, listtmp, &list_all_bus_instances) { - struct visorbus_devdata *devdata = list_entry(listentry, + struct visor_device *dev = list_entry(listentry, struct - visorbus_devdata, + visor_device, list_all); - remove_bus_instance(devdata); + remove_bus_instance(dev); } remove_bus_type(); } From 52c4cbd3fdba4debfb771ecb2282fcba0eff120b Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Thu, 4 Jun 2015 09:22:38 -0400 Subject: [PATCH 0853/1163] staging: unisys: Remove unused cruft Removing stuff that isn't being used. Another prepartion patch to allow us to use visor_device everywhere without the baggage of bus/dev_info. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorbus_main.c | 71 ------------------- .../unisys/visorbus/visorbus_private.h | 13 ---- 2 files changed, 84 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 380ea62d4ef5..b43e7328f1a5 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -31,8 +31,6 @@ static int visorbus_debug; static int visorbus_forcematch; static int visorbus_forcenomatch; -#define MAXDEVICETEST 4 -static int visorbus_devicetest; static int visorbus_debugref; #define SERIALLOOPBACKCHANADDR (100 * 1024 * 1024) @@ -93,7 +91,6 @@ static struct delayed_work periodic_work; static struct workqueue_struct *periodic_test_workqueue; static struct workqueue_struct *periodic_dev_workqueue; static long long bus_count; /** number of bus instances */ -static long long total_devices_created; /** ever-increasing */ static void chipset_bus_create(struct visorchipset_bus_info *bus_info); @@ -462,33 +459,12 @@ static ssize_t typename_show(struct device *dev, struct device_attribute *attr, return snprintf(buf, PAGE_SIZE, "%s\n", drv->channel_types[i - 1].name); } -static ssize_t dump_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ -/* TODO: replace this with debugfs code - struct visor_device *vdev = to_visor_device(dev); - int count = 0; - struct seq_file *m = NULL; - if (vdev->visorchannel == NULL) - return 0; - m = visor_seq_file_new_buffer(buf, PAGE_SIZE - 1); - if (m == NULL) - return 0; - visorchannel_debug(vdev->visorchannel, 1, m, 0); - count = m->count; - visor_seq_file_done_buffer(m); - m = NULL; -*/ - return 0; -} - static DEVICE_ATTR_RO(physaddr); static DEVICE_ATTR_RO(nbytes); static DEVICE_ATTR_RO(clientpartition); static DEVICE_ATTR_RO(typeguid); static DEVICE_ATTR_RO(zoneguid); static DEVICE_ATTR_RO(typename); -static DEVICE_ATTR_RO(dump); static struct attribute *channel_attrs[] = { &dev_attr_physaddr.attr, @@ -497,7 +473,6 @@ static struct attribute *channel_attrs[] = { &dev_attr_typeguid.attr, &dev_attr_zoneguid.attr, &dev_attr_typename.attr, - &dev_attr_dump.attr, }; static struct attribute_group channel_attr_grp = { @@ -702,25 +677,6 @@ unregister_driver_attributes(struct visor_driver *drv) driver_remove_file(&drv->driver, &drv->version_attr); } -/* DEVICE attributes - * - * define & implement display of device attributes under - * /sys/bus/visorbus/devices/. - * - */ - -#define DEVATTR(nam, func) { \ - .attr = { .name = __stringify(nam), \ - .mode = 0444, \ - .owner = THIS_MODULE }, \ - .show = func, \ -} - -static struct device_attribute visor_device_attrs[] = { - /* DEVATTR(channel_nbytes, DEVICE_ATTR_channel_nbytes), */ - __ATTR_NULL -}; - static void dev_periodic_work(void *xdev) { @@ -1088,7 +1044,6 @@ away: put_device(&dev->device); kfree(dev); } else { - total_devices_created++; list_add_tail(&dev->list_all, &list_all_device_instances); } return rc; @@ -1400,7 +1355,6 @@ create_bus_type(void) { int rc = 0; - visorbus_type.dev_attrs = visor_device_attrs; rc = bus_register(&visorbus_type); return rc; } @@ -1428,11 +1382,6 @@ remove_all_visor_devices(void) } } -static bool entered_testing_mode; -static struct visorchannel *test_channel_infos[MAXDEVICETEST]; -static unsigned long test_bus_nos[MAXDEVICETEST]; -static unsigned long test_dev_nos[MAXDEVICETEST]; - static void chipset_bus_create(struct visorchipset_bus_info *bus_info) { @@ -1492,17 +1441,8 @@ chipset_device_create(struct visorchipset_device_info *dev_info) POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); - if (entered_testing_mode) - return; if (!visorchipset_get_bus_info(bus_no, &bus_info)) goto away; - if (visorbus_devicetest) - if (total_devices_created < MAXDEVICETEST) { - test_channel_infos[total_devices_created] = - dev_info->visorchannel; - test_bus_nos[total_devices_created] = bus_no; - test_dev_nos[total_devices_created] = dev_no; - } POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); rc = 0; @@ -1527,8 +1467,6 @@ chipset_device_destroy(struct visorchipset_device_info *dev_info) struct visor_device *dev; int rc = -1; - if (entered_testing_mode) - return; dev = find_visor_device_by_channel(dev_info->visorchannel); if (!dev) goto away; @@ -1691,11 +1629,6 @@ visorbus_init(void) "clientbus", "visorbus", VERSION, NULL); - /* process module options */ - - if (visorbus_devicetest > MAXDEVICETEST) - visorbus_devicetest = MAXDEVICETEST; - rc = create_bus_type(); if (rc < 0) { POSTCODE_LINUX_2(BUS_CREATE_ENTRY_PC, DIAG_SEVERITY_ERR); @@ -1765,10 +1698,6 @@ module_param_named(forcenomatch, visorbus_forcenomatch, int, S_IRUGO); MODULE_PARM_DESC(visorbus_forcenomatch, "1 to force an UNsuccessful dev <--> drv match"); -module_param_named(devicetest, visorbus_devicetest, int, S_IRUGO); -MODULE_PARM_DESC(visorbus_devicetest, - "non-0 to just test device creation and destruction"); - module_param_named(debugref, visorbus_debugref, int, S_IRUGO); MODULE_PARM_DESC(visorbus_debugref, "1 to debug reference counting"); diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h index f371f9d646a5..57db0628af28 100644 --- a/drivers/staging/unisys/visorbus/visorbus_private.h +++ b/drivers/staging/unisys/visorbus/visorbus_private.h @@ -27,19 +27,6 @@ struct visorchannel; -enum visorchipset_addresstype { - /** address is guest physical, but outside of the physical memory - * region that is controlled by the running OS (this is the normal - * address type for Supervisor channels) - */ - ADDRTYPE_LOCALPHYSICAL, - - /** address is guest physical, and withIN the confines of the - * physical memory controlled by the running OS. - */ - ADDRTYPE_LOCALTEST, -}; - /** Attributes for a particular Supervisor device. * Any visorchipset client can query these attributes using * visorchipset_get_client_device_info() or From ee983d902ecea8d1d524f3f2505b89a315555abe Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Thu, 4 Jun 2015 09:22:39 -0400 Subject: [PATCH 0854/1163] staging: unisys: Remove server flags The bus driver doesn't work in server mode, just remove the left over pieces. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorbus_main.c | 66 ++----------------- .../unisys/visorbus/visorbus_private.h | 5 -- .../staging/unisys/visorbus/visorchipset.c | 2 - 3 files changed, 7 insertions(+), 66 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index b43e7328f1a5..19bb355ba1a0 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -1073,54 +1073,6 @@ find_visor_device_by_channel(struct visorchannel *channel) return NULL; } -static int -init_vbus_channel(struct visorchannel *chan) -{ - int rc = -1; - unsigned long allocated_bytes = visorchannel_get_nbytes(chan); - struct spar_vbus_channel_protocol *x = - kmalloc(sizeof(struct spar_vbus_channel_protocol), - GFP_KERNEL); - - POSTCODE_LINUX_3(VBUS_CHANNEL_ENTRY_PC, rc, POSTCODE_SEVERITY_INFO); - - if (x) { - POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR); - goto away; - } - if (visorchannel_clear(chan, 0, 0, allocated_bytes) < 0) { - POSTCODE_LINUX_2(VBUS_CHANNEL_FAILURE_PC, - POSTCODE_SEVERITY_ERR); - goto away; - } - if (visorchannel_read - (chan, 0, x, sizeof(struct spar_vbus_channel_protocol)) < 0) { - POSTCODE_LINUX_2(VBUS_CHANNEL_FAILURE_PC, - POSTCODE_SEVERITY_ERR); - goto away; - } - if (!SPAR_VBUS_CHANNEL_OK_SERVER(allocated_bytes)) { - POSTCODE_LINUX_2(VBUS_CHANNEL_FAILURE_PC, - POSTCODE_SEVERITY_ERR); - goto away; - } - - if (visorchannel_write - (chan, 0, x, sizeof(struct spar_vbus_channel_protocol)) < 0) { - POSTCODE_LINUX_3(VBUS_CHANNEL_FAILURE_PC, chan, - POSTCODE_SEVERITY_ERR); - goto away; - } - - POSTCODE_LINUX_3(VBUS_CHANNEL_EXIT_PC, chan, POSTCODE_SEVERITY_INFO); - rc = 0; - -away: - kfree(x); - x = NULL; - return rc; -} - static int get_vbus_header_info(struct visorchannel *chan, struct spar_vbus_headerinfo *hdr_info) @@ -1296,18 +1248,14 @@ create_bus_instance(struct visorchipset_bus_info *bus_info) } dev->chipset_bus_no = id; dev->visorchannel = bus_info->visorchannel; - if (bus_info->flags.server) { - init_vbus_channel(dev->visorchannel); + if (get_vbus_header_info(dev->visorchannel, hdr_info) >= 0) { + dev->vbus_hdr_info = (void *)hdr_info; + write_vbus_chp_info(dev->visorchannel, hdr_info, + &chipset_driverinfo); + write_vbus_bus_info(dev->visorchannel, hdr_info, + &clientbus_driverinfo); } else { - if (get_vbus_header_info(dev->visorchannel, hdr_info) >= 0) { - dev->vbus_hdr_info = (void *)hdr_info; - write_vbus_chp_info(dev->visorchannel, hdr_info, - &chipset_driverinfo); - write_vbus_bus_info(dev->visorchannel, hdr_info, - &clientbus_driverinfo); - } else { - kfree(hdr_info); - } + kfree(hdr_info); } bus_count++; list_add_tail(&dev->list_all, &list_all_bus_instances); diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h index 57db0628af28..af71809828dd 100644 --- a/drivers/staging/unisys/visorbus/visorbus_private.h +++ b/drivers/staging/unisys/visorbus/visorbus_private.h @@ -66,11 +66,6 @@ struct visorchipset_bus_info { u8 *description; /* UTF8 */ u64 reserved1; u32 reserved2; - struct { - u32 server:1; - /* Add new fields above. */ - /* Remaining bits in this 32-bit word are unused. */ - } flags; struct controlvm_message_header *pending_msg_hdr;/* CONTROLVM MsgHdr */ /** For private use by the bus driver */ void *bus_driver_context; diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 247888970d91..4dd0a075b992 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -1228,8 +1228,6 @@ bus_create(struct controlvm_message *inmsg) POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO); - bus_info->flags.server = inmsg->hdr.flags.server; - visorchannel = visorchannel_create(cmd->create_bus.channel_addr, cmd->create_bus.channel_bytes, GFP_KERNEL, From 65bd6e4607a19eafbf0d23ce184b6cefc19e317d Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Thu, 4 Jun 2015 09:22:40 -0400 Subject: [PATCH 0855/1163] staging: unisys: Do not use 0 as the default bus root device number I used 0 as the device id for the bus root, neglecting the fact that device 0 is a valid id in Unisys's configuration. Modify this to use UINT_MAX instead as a unique number. As fallout from this change it was noticed the bus_no and dev_no was not defined the same way consistently. Fix visorbus.h to use u32 there. Fix the resulting printk warning too. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/visorbus.h | 4 ++-- drivers/staging/unisys/visorbus/visorbus_main.c | 2 +- drivers/staging/unisys/visorbus/visorchipset.c | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h index 3152ba47c702..c60f7d41f640 100644 --- a/drivers/staging/unisys/include/visorbus.h +++ b/drivers/staging/unisys/include/visorbus.h @@ -150,8 +150,8 @@ struct visor_device { struct semaphore visordriver_callback_lock; bool pausing; bool resuming; - unsigned long chipset_bus_no; - unsigned long chipset_dev_no; + u32 chipset_bus_no; + u32 chipset_dev_no; struct visorchipset_state state; uuid_le type; uuid_le inst; diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 19bb355ba1a0..ec3022b5af9b 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -572,7 +572,7 @@ static ssize_t client_bus_info_show(struct device *dev, if (vdev->name) partition_name = vdev->name; x = snprintf(p, remain, - "Client device / client driver info for %s partition (vbus #%ld):\n", + "Client device / client driver info for %s partition (vbus #%d):\n", partition_name, vdev->chipset_dev_no); p += x; remain -= x; diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 4dd0a075b992..618732b6e2e1 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -56,6 +56,8 @@ #define UNISYS_SPAR_ID_ECX 0x70537379 #define UNISYS_SPAR_ID_EDX 0x34367261 +#define BUS_ROOT_DEVICE UINT_MAX + /* * Module parameters */ @@ -727,8 +729,8 @@ static int match_visorbus_dev_by_id(struct device *dev, void *data) u32 bus_no = id->bus_no; u32 dev_no = id->dev_no; - if (((bus_no == -1) || (vdev->chipset_bus_no == bus_no)) && - ((dev_no == -1) || (vdev->chipset_dev_no == dev_no))) + if ((vdev->chipset_bus_no == bus_no) && + (vdev->chipset_dev_no == dev_no)) return 1; return 0; From d32517e392b90354f79f6c7a357f96c37b5fe4fd Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Thu, 4 Jun 2015 09:22:41 -0400 Subject: [PATCH 0856/1163] staging: unisys: Convert bus creation to use visor_device This patch removes the legacy bus_info struct and instead creates and passes around a traditional struct device. This allows us to remove a lot of the various look up code and removes the doubt if the struct exists or not. Half of the churn is just the conversion of visorchipset_bus_info to visor_device. Various cleanups include re-arranging the failure paths to make more sense. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/visorbus.h | 3 + .../staging/unisys/visorbus/visorbus_main.c | 133 +++++++----------- .../unisys/visorbus/visorbus_private.h | 34 +---- .../staging/unisys/visorbus/visorchipset.c | 95 +++---------- 4 files changed, 78 insertions(+), 187 deletions(-) diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h index c60f7d41f640..e7f99848fe1a 100644 --- a/drivers/staging/unisys/include/visorbus.h +++ b/drivers/staging/unisys/include/visorbus.h @@ -220,4 +220,7 @@ void visorchannel_debug(struct visorchannel *channel, int num_queues, struct seq_file *seq, u32 off); void __iomem *visorchannel_get_header(struct visorchannel *channel); +#define BUS_ROOT_DEVICE UINT_MAX +struct visor_device *visorbus_get_device_by_id(u32 bus_no, u32 dev_no, + struct visor_device *from); #endif diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index ec3022b5af9b..60bdf69264df 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -93,8 +93,8 @@ static struct workqueue_struct *periodic_dev_workqueue; static long long bus_count; /** number of bus instances */ /** ever-increasing */ -static void chipset_bus_create(struct visorchipset_bus_info *bus_info); -static void chipset_bus_destroy(struct visorchipset_bus_info *bus_info); +static void chipset_bus_create(struct visor_device *bus_info); +static void chipset_bus_destroy(struct visor_device *bus_info); static void chipset_device_create(struct visorchipset_device_info *dev_info); static void chipset_device_destroy(struct visorchipset_device_info *dev_info); static void chipset_device_pause(struct visorchipset_device_info *dev_info); @@ -950,8 +950,7 @@ EXPORT_SYMBOL_GPL(visorbus_disable_channel_interrupts); */ static int create_visor_device(struct visor_device *bdev, - struct visorchipset_device_info *dev_info, - u64 partition_handle) + struct visorchipset_device_info *dev_info) { int rc = -1; struct visor_device *dev = NULL; @@ -1161,8 +1160,7 @@ static void fix_vbus_dev_info(struct visor_device *visordev) { int i; - struct visorchipset_bus_info bus_info; - struct visor_device *dev = NULL; + struct visor_device *bdev; struct visor_driver *visordrv; int bus_no = visordev->chipset_bus_no; int dev_no = visordev->chipset_dev_no; @@ -1174,17 +1172,14 @@ fix_vbus_dev_info(struct visor_device *visordev) return; hdr_info = (struct spar_vbus_headerinfo *)visordev->vbus_hdr_info; + if (!hdr_info) + return; + + bdev = visorbus_get_device_by_id(bus_no, BUS_ROOT_DEVICE, NULL); + if (!bdev) + return; visordrv = to_visor_driver(visordev->device.driver); - if (!visorchipset_get_bus_info(bus_no, &bus_info)) - return; - - dev = (struct visor_device *)(bus_info.bus_driver_context); - if (!dev) - return; - - if (!hdr_info) - return; /* Within the list of device types (by GUID) that the driver * says it supports, find out which one of those types matches @@ -1203,51 +1198,45 @@ fix_vbus_dev_info(struct visor_device *visordev) bus_device_info_init(&dev_info, chan_type_name, visordrv->name, visordrv->version, visordrv->vertag); - write_vbus_dev_info(dev->visorchannel, hdr_info, &dev_info, dev_no); + write_vbus_dev_info(bdev->visorchannel, hdr_info, &dev_info, dev_no); /* Re-write bus+chipset info, because it is possible that this * was previously written by our evil counterpart, virtpci. */ - write_vbus_chp_info(dev->visorchannel, hdr_info, &chipset_driverinfo); - write_vbus_bus_info(dev->visorchannel, hdr_info, &clientbus_driverinfo); + write_vbus_chp_info(bdev->visorchannel, hdr_info, &chipset_driverinfo); + write_vbus_bus_info(bdev->visorchannel, hdr_info, + &clientbus_driverinfo); } /** Create a device instance for the visor bus itself. */ -static struct visor_device * -create_bus_instance(struct visorchipset_bus_info *bus_info) +static int +create_bus_instance(struct visor_device *dev) { - struct visor_device *rc = NULL; - struct visor_device *dev = NULL; - int id = bus_info->bus_no; + int rc; + int id = dev->chipset_bus_no; struct spar_vbus_headerinfo *hdr_info; POSTCODE_LINUX_2(BUS_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); - dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (!dev) { - POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR); - rc = NULL; - goto away; - } hdr_info = kzalloc(sizeof(*hdr_info), GFP_KERNEL); if (!hdr_info) { - rc = NULL; - goto away_mem; + rc = -1; + goto away; } dev_set_name(&dev->device, "visorbus%d", id); dev->device.bus = &visorbus_type; dev->device.groups = visorbus_groups; dev->device.release = visorbus_release_busdevice; + if (device_register(&dev->device) < 0) { POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, id, POSTCODE_SEVERITY_ERR); - rc = NULL; - goto away_mem2; + rc = -1; + goto away_mem; } - dev->chipset_bus_no = id; - dev->visorchannel = bus_info->visorchannel; + if (get_vbus_header_info(dev->visorchannel, hdr_info) >= 0) { dev->vbus_hdr_info = (void *)hdr_info; write_vbus_chp_info(dev->visorchannel, hdr_info, @@ -1259,16 +1248,11 @@ create_bus_instance(struct visorchipset_bus_info *bus_info) } bus_count++; list_add_tail(&dev->list_all, &list_all_bus_instances); - if (id == 0) - dev = dev; /* for testing ONLY */ dev_set_drvdata(&dev->device, dev); - rc = dev; - return rc; + return 0; -away_mem2: - kfree(hdr_info); away_mem: - kfree(dev); + kfree(hdr_info); away: return rc; } @@ -1331,57 +1315,38 @@ remove_all_visor_devices(void) } static void -chipset_bus_create(struct visorchipset_bus_info *bus_info) +chipset_bus_create(struct visor_device *dev) { - struct visor_device *dev; - int rc = -1; - u32 bus_no = bus_info->bus_no; + int rc; + u32 bus_no = dev->chipset_bus_no; POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO); - dev = create_bus_instance(bus_info); - if (!dev) - goto away; - if (!visorchipset_set_bus_context(bus_info, dev)) - goto away; + rc = create_bus_instance(dev); POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO); - rc = 0; -away: - if (rc < 0) { + + if (rc < 0) POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no, POSTCODE_SEVERITY_ERR); - return; - } - POSTCODE_LINUX_3(CHIPSET_INIT_SUCCESS_PC, bus_no, - POSTCODE_SEVERITY_INFO); + else + POSTCODE_LINUX_3(CHIPSET_INIT_SUCCESS_PC, bus_no, + POSTCODE_SEVERITY_INFO); + if (chipset_responders.bus_create) - (*chipset_responders.bus_create) (bus_info, rc); + (*chipset_responders.bus_create) (dev, rc); } static void -chipset_bus_destroy(struct visorchipset_bus_info *bus_info) +chipset_bus_destroy(struct visor_device *dev) { - struct visor_device *dev; - int rc = -1; - - dev = (struct visor_device *)(bus_info->bus_driver_context); - if (!dev) - goto away; remove_bus_instance(dev); - if (!visorchipset_set_bus_context(bus_info, NULL)) - goto away; - rc = 0; -away: - if (rc < 0) - return; if (chipset_responders.bus_destroy) - (*chipset_responders.bus_destroy)(bus_info, rc); + (*chipset_responders.bus_destroy)(dev, 0); } static void chipset_device_create(struct visorchipset_device_info *dev_info) { - struct visorchipset_bus_info bus_info; - struct visor_device *dev = NULL; + struct visor_device *bdev; int rc = -1; u32 bus_no = dev_info->bus_no; u32 dev_no = dev_info->dev_no; @@ -1389,24 +1354,24 @@ chipset_device_create(struct visorchipset_device_info *dev_info) POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); - if (!visorchipset_get_bus_info(bus_no, &bus_info)) + bdev = visorbus_get_device_by_id(bus_no, BUS_ROOT_DEVICE, NULL); + if (!bdev) goto away; + POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); - rc = 0; + + rc = create_visor_device(bdev, dev_info); away: if (rc < 0) { POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, POSTCODE_SEVERITY_ERR); - return; - } - dev = (struct visor_device *)(bus_info.bus_driver_context); - rc = create_visor_device(dev, dev_info, bus_info.partition_handle); - POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, dev_no, bus_no, - POSTCODE_SEVERITY_INFO); - if (rc < 0) if (chipset_responders.device_create) (*chipset_responders.device_create)(dev_info, rc); + } + + POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, dev_no, bus_no, + POSTCODE_SEVERITY_INFO); } static void diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h index af71809828dd..6fd55af8926c 100644 --- a/drivers/staging/unisys/visorbus/visorbus_private.h +++ b/drivers/staging/unisys/visorbus/visorbus_private.h @@ -49,35 +49,13 @@ struct visorchipset_device_info { void *bus_driver_context; }; -/** Attributes for a particular Supervisor bus. - * (For a service partition acting as the server for buses/devices, there - * is a 1-to-1 relationship between busses and guest partitions.) - * Any visorchipset client can query these attributes using - * visorchipset_get_client_bus_info() or visorchipset_get_bus_info(). - */ -struct visorchipset_bus_info { - struct list_head entry; - u32 bus_no; - struct visorchipset_state state; - struct visorchannel *visorchannel; - uuid_le partition_uuid; - u64 partition_handle; - u8 *name; /* UTF8 */ - u8 *description; /* UTF8 */ - u64 reserved1; - u32 reserved2; - struct controlvm_message_header *pending_msg_hdr;/* CONTROLVM MsgHdr */ - /** For private use by the bus driver */ - void *bus_driver_context; -}; - /* These functions will be called from within visorchipset when certain * events happen. (The implementation of these functions is outside of * visorchipset.) */ struct visorchipset_busdev_notifiers { - void (*bus_create)(struct visorchipset_bus_info *bus_info); - void (*bus_destroy)(struct visorchipset_bus_info *bus_info); + void (*bus_create)(struct visor_device *bus_info); + void (*bus_destroy)(struct visor_device *bus_info); void (*device_create)(struct visorchipset_device_info *bus_info); void (*device_destroy)(struct visorchipset_device_info *bus_info); void (*device_pause)(struct visorchipset_device_info *bus_info); @@ -91,8 +69,8 @@ struct visorchipset_busdev_notifiers { * -1 = it failed */ struct visorchipset_busdev_responders { - void (*bus_create)(struct visorchipset_bus_info *p, int response); - void (*bus_destroy)(struct visorchipset_bus_info *p, int response); + void (*bus_create)(struct visor_device *p, int response); + void (*bus_destroy)(struct visor_device *p, int response); void (*device_create)(struct visorchipset_device_info *p, int response); void (*device_destroy)(struct visorchipset_device_info *p, int response); @@ -112,10 +90,10 @@ visorchipset_register_busdev( struct ultra_vbus_deviceinfo *driver_info); bool visorchipset_get_bus_info(u32 bus_no, - struct visorchipset_bus_info *bus_info); + struct visor_device *bus_info); bool visorchipset_get_device_info(u32 bus_no, u32 dev_no, struct visorchipset_device_info *dev_info); -bool visorchipset_set_bus_context(struct visorchipset_bus_info *bus_info, +bool visorchipset_set_bus_context(struct visor_device *bus_info, void *context); /* visorbus init and exit functions */ diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 618732b6e2e1..4404f4fadd7e 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -56,8 +56,6 @@ #define UNISYS_SPAR_ID_ECX 0x70537379 #define UNISYS_SPAR_ID_EDX 0x34367261 -#define BUS_ROOT_DEVICE UINT_MAX - /* * Module parameters */ @@ -230,8 +228,8 @@ static void parahotplug_process_list(void); */ static struct visorchipset_busdev_notifiers busdev_notifiers; -static void bus_create_response(struct visorchipset_bus_info *p, int response); -static void bus_destroy_response(struct visorchipset_bus_info *p, int response); +static void bus_create_response(struct visor_device *p, int response); +static void bus_destroy_response(struct visor_device *p, int response); static void device_create_response(struct visorchipset_device_info *p, int response); static void device_destroy_response(struct visorchipset_device_info *p, @@ -698,16 +696,6 @@ static ssize_t remaining_steps_store(struct device *dev, return count; } -static void -bus_info_clear(void *v) -{ - struct visorchipset_bus_info *p = (struct visorchipset_bus_info *) v; - - kfree(p->name); - kfree(p->description); - memset(p, 0, sizeof(struct visorchipset_bus_info)); -} - static void dev_info_clear(void *v) { @@ -756,19 +744,6 @@ struct visor_device *visorbus_get_device_by_id(u32 bus_no, u32 dev_no, } EXPORT_SYMBOL(visorbus_get_device_by_id); -static struct visorchipset_bus_info * -bus_find(struct list_head *list, u32 bus_no) -{ - struct visorchipset_bus_info *p; - - list_for_each_entry(p, list, entry) { - if (p->bus_no == bus_no) - return p; - } - - return NULL; -} - static struct visorchipset_device_info * device_find(struct list_head *list, u32 bus_no, u32 dev_no) { @@ -842,15 +817,8 @@ EXPORT_SYMBOL_GPL(visorchipset_register_busdev); static void cleanup_controlvm_structures(void) { - struct visorchipset_bus_info *bi, *tmp_bi; struct visorchipset_device_info *di, *tmp_di; - list_for_each_entry_safe(bi, tmp_bi, &bus_info_list, entry) { - bus_info_clear(bi); - list_del(&bi->entry); - kfree(bi); - } - list_for_each_entry_safe(di, tmp_di, &dev_info_list, entry) { dev_info_clear(di); list_del(&di->entry); @@ -1017,7 +985,7 @@ device_responder(enum controlvm_id cmd_id, } static void -bus_epilog(struct visorchipset_bus_info *bus_info, +bus_epilog(struct visor_device *bus_info, u32 cmd, struct controlvm_message_header *msg_hdr, int response, bool need_response) { @@ -1207,10 +1175,10 @@ bus_create(struct controlvm_message *inmsg) struct controlvm_message_packet *cmd = &inmsg->cmd; u32 bus_no = cmd->create_bus.bus_no; int rc = CONTROLVM_RESP_SUCCESS; - struct visorchipset_bus_info *bus_info; + struct visor_device *bus_info; struct visorchannel *visorchannel; - bus_info = bus_find(&bus_info_list, bus_no); + bus_info = visorbus_get_device_by_id(bus_no, BUS_ROOT_DEVICE, NULL); if (bus_info && (bus_info->state.created == 1)) { POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no, POSTCODE_SEVERITY_ERR); @@ -1225,8 +1193,8 @@ bus_create(struct controlvm_message *inmsg) goto cleanup; } - INIT_LIST_HEAD(&bus_info->entry); - bus_info->bus_no = bus_no; + bus_info->chipset_bus_no = bus_no; + bus_info->chipset_dev_no = BUS_ROOT_DEVICE; POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO); @@ -1244,7 +1212,6 @@ bus_create(struct controlvm_message *inmsg) goto cleanup; } bus_info->visorchannel = visorchannel; - list_add(&bus_info->entry, &bus_info_list); POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO); @@ -1258,10 +1225,10 @@ bus_destroy(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; u32 bus_no = cmd->destroy_bus.bus_no; - struct visorchipset_bus_info *bus_info; + struct visor_device *bus_info; int rc = CONTROLVM_RESP_SUCCESS; - bus_info = bus_find(&bus_info_list, bus_no); + bus_info = visorbus_get_device_by_id(bus_no, BUS_ROOT_DEVICE, NULL); if (!bus_info) rc = -CONTROLVM_RESP_ERROR_BUS_INVALID; else if (bus_info->state.created == 0) @@ -1269,6 +1236,8 @@ bus_destroy(struct controlvm_message *inmsg) bus_epilog(bus_info, CONTROLVM_BUS_DESTROY, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1); + + /* bus_info is freed as part of the busdevice_release function */ } static void @@ -1277,15 +1246,14 @@ bus_configure(struct controlvm_message *inmsg, { struct controlvm_message_packet *cmd = &inmsg->cmd; u32 bus_no; - struct visorchipset_bus_info *bus_info; + struct visor_device *bus_info; int rc = CONTROLVM_RESP_SUCCESS; - char s[99]; bus_no = cmd->configure_bus.bus_no; POSTCODE_LINUX_3(BUS_CONFIGURE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO); - bus_info = bus_find(&bus_info_list, bus_no); + bus_info = visorbus_get_device_by_id(bus_no, BUS_ROOT_DEVICE, NULL); if (!bus_info) { POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no, POSTCODE_SEVERITY_ERR); @@ -1305,7 +1273,6 @@ bus_configure(struct controlvm_message *inmsg, parser_param_start(parser_ctx, PARSERSTRING_NAME); bus_info->name = parser_string_get(parser_ctx); - visorchannel_uuid_id(&bus_info->partition_uuid, s); POSTCODE_LINUX_3(BUS_CONFIGURE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO); } @@ -1320,7 +1287,7 @@ my_device_create(struct controlvm_message *inmsg) u32 bus_no = cmd->create_device.bus_no; u32 dev_no = cmd->create_device.dev_no; struct visorchipset_device_info *dev_info; - struct visorchipset_bus_info *bus_info; + struct visor_device *bus_info; struct visorchannel *visorchannel; int rc = CONTROLVM_RESP_SUCCESS; @@ -1331,7 +1298,7 @@ my_device_create(struct controlvm_message *inmsg) rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE; goto cleanup; } - bus_info = bus_find(&bus_info_list, bus_no); + bus_info = visorbus_get_device_by_id(bus_no, dev_no, NULL); if (!bus_info) { POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, POSTCODE_SEVERITY_ERR); @@ -2134,14 +2101,15 @@ cleanup: } static void -bus_create_response(struct visorchipset_bus_info *bus_info, int response) +bus_create_response(struct visor_device *bus_info, int response) { if (response >= 0) { bus_info->state.created = 1; } else { if (response != -CONTROLVM_RESP_ERROR_ALREADY_DONE) /* undo the row we just created... */ - busdevices_del(&dev_info_list, bus_info->bus_no); + busdevices_del(&dev_info_list, + bus_info->chipset_bus_no); } bus_responder(CONTROLVM_BUS_CREATE, bus_info->pending_msg_hdr, @@ -2152,7 +2120,7 @@ bus_create_response(struct visorchipset_bus_info *bus_info, int response) } static void -bus_destroy_response(struct visorchipset_bus_info *bus_info, int response) +bus_destroy_response(struct visor_device *bus_info, int response) { bus_responder(CONTROLVM_BUS_DESTROY, bus_info->pending_msg_hdr, response); @@ -2160,8 +2128,7 @@ bus_destroy_response(struct visorchipset_bus_info *bus_info, int response) kfree(bus_info->pending_msg_hdr); bus_info->pending_msg_hdr = NULL; - bus_info_clear(bus_info); - busdevices_del(&dev_info_list, bus_info->bus_no); + busdevices_del(&dev_info_list, bus_info->chipset_bus_no); } static void @@ -2212,28 +2179,6 @@ device_resume_response(struct visorchipset_device_info *dev_info, int response) dev_info->pending_msg_hdr = NULL; } -bool -visorchipset_get_bus_info(u32 bus_no, struct visorchipset_bus_info *bus_info) -{ - void *p = bus_find(&bus_info_list, bus_no); - - if (!p) - return false; - memcpy(bus_info, p, sizeof(struct visorchipset_bus_info)); - return true; -} -EXPORT_SYMBOL_GPL(visorchipset_get_bus_info); - -bool -visorchipset_set_bus_context(struct visorchipset_bus_info *p, void *context) -{ - if (!p) - return false; - p->bus_driver_context = context; - return true; -} -EXPORT_SYMBOL_GPL(visorchipset_set_bus_context); - bool visorchipset_get_device_info(u32 bus_no, u32 dev_no, struct visorchipset_device_info *dev_info) From a298bc0b59132a9536739c22d77c6662ee17ffc3 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Thu, 4 Jun 2015 09:22:42 -0400 Subject: [PATCH 0857/1163] staging: unisys: Convert device creation to use visor_device This patch removes the legacy dev_info struct and instead creates and passes around a traditional struct device. This allows us to remove a lot of the various look up code and removes the doubt if the struct exists or not. Half of the churn is just the conversion of visorchipset_device_info to visor_device. Various cleanups include re-arranging the failure paths to make more sense. Pay attention to the create_visor_device function. This had a lot of churn to simplify everything. Lots of functions disappeared because they are not needed any more. Signed-off-by: Don Zickus Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/visorbus.h | 8 +- .../staging/unisys/visorbus/visorbus_main.c | 146 ++++------------ .../unisys/visorbus/visorbus_private.h | 49 +----- .../staging/unisys/visorbus/visorchipset.c | 159 +++++------------- 4 files changed, 81 insertions(+), 281 deletions(-) diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h index e7f99848fe1a..581d962980f9 100644 --- a/drivers/staging/unisys/include/visorbus.h +++ b/drivers/staging/unisys/include/visorbus.h @@ -43,7 +43,7 @@ struct visor_device; extern struct bus_type visorbus_type; typedef void (*visorbus_state_complete_func) (struct visor_device *dev, - int status, void *dev_info); + int status); struct visorchipset_state { u32 created:1; u32 attached:1; @@ -106,11 +106,9 @@ struct visor_driver { * fails or completes successfully. */ int (*pause)(struct visor_device *dev, - visorbus_state_complete_func complete_func, - void *dev_info); + visorbus_state_complete_func complete_func); int (*resume)(struct visor_device *dev, - visorbus_state_complete_func complete_func, - void *dev_info); + visorbus_state_complete_func complete_func); /** These fields are for private use by the bus driver only. */ struct device_driver driver; diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 60bdf69264df..688bd8494fe4 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -95,10 +95,10 @@ static long long bus_count; /** number of bus instances */ static void chipset_bus_create(struct visor_device *bus_info); static void chipset_bus_destroy(struct visor_device *bus_info); -static void chipset_device_create(struct visorchipset_device_info *dev_info); -static void chipset_device_destroy(struct visorchipset_device_info *dev_info); -static void chipset_device_pause(struct visorchipset_device_info *dev_info); -static void chipset_device_resume(struct visorchipset_device_info *dev_info); +static void chipset_device_create(struct visor_device *dev_info); +static void chipset_device_destroy(struct visor_device *dev_info); +static void chipset_device_pause(struct visor_device *dev_info); +static void chipset_device_resume(struct visor_device *dev_info); /** These functions are implemented herein, and are called by the chipset * driver to notify us about specific events. @@ -184,7 +184,6 @@ visorbus_release_busdevice(struct device *xdev) dev_set_drvdata(xdev, NULL); kfree(dev); - kfree(xdev); } /** This is called when device_unregister() is called for each child @@ -754,17 +753,10 @@ away: * initialized. */ if (!dev->responded_to_device_create) { - struct visorchipset_device_info dev_info; - - if (!visorchipset_get_device_info(dev->chipset_bus_no, - dev->chipset_dev_no, - &dev_info)) - /* hmm, what to do here */ - return rc; dev->responded_to_device_create = true; if (chipset_responders.device_create) - (*chipset_responders.device_create)(&dev_info, rc); + (*chipset_responders.device_create)(dev, rc); } return rc; } @@ -949,30 +941,15 @@ EXPORT_SYMBOL_GPL(visorbus_disable_channel_interrupts); * device. */ static int -create_visor_device(struct visor_device *bdev, - struct visorchipset_device_info *dev_info) +create_visor_device(struct visor_device *dev) { int rc = -1; - struct visor_device *dev = NULL; - bool gotten = false, registered1 = false, registered2 = false; - u32 chipset_bus_no = dev_info->bus_no; - u32 chipset_dev_no = dev_info->dev_no; + u32 chipset_bus_no = dev->chipset_bus_no; + u32 chipset_dev_no = dev->chipset_dev_no; POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, chipset_dev_no, chipset_bus_no, POSTCODE_SEVERITY_INFO); - dev = kmalloc(sizeof(*dev), GFP_KERNEL); - if (!dev) { - POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, chipset_dev_no, - DIAG_SEVERITY_ERR); - goto away; - } - memset(dev, 0, sizeof(struct visor_device)); - dev->visorchannel = dev_info->visorchannel; - dev->channel_type_guid = dev_info->channel_type_guid; - dev->chipset_bus_no = chipset_bus_no; - dev->chipset_dev_no = chipset_dev_no; - dev->device.parent = &bdev->device; sema_init(&dev->visordriver_callback_lock, 1); /* unlocked */ dev->device.bus = &visorbus_type; dev->device.groups = visorbus_dev_groups; @@ -980,7 +957,6 @@ create_visor_device(struct visor_device *bdev, dev->device.release = visorbus_release_device; /* keep a reference just for us (now 2) */ get_device(&dev->device); - gotten = true; dev->periodic_work = visor_periodic_work_create(POLLJIFFIES_NORMALCHANNEL, periodic_dev_workqueue, @@ -1022,29 +998,20 @@ create_visor_device(struct visor_device *bdev, goto away; } - /* note: device_register is simply device_initialize + device_add */ - registered1 = true; - rc = register_devmajorminor_attributes(dev); if (rc < 0) { POSTCODE_LINUX_3(DEVICE_REGISTER_FAILURE_PC, chipset_dev_no, DIAG_SEVERITY_ERR); - goto away; + goto away_register; } - registered2 = true; - rc = 0; + list_add_tail(&dev->list_all, &list_all_device_instances); + return 0; +away_register: + device_unregister(&dev->device); away: - if (rc < 0) { - if (registered2) - unregister_devmajorminor_attributes(dev); - if (gotten) - put_device(&dev->device); - kfree(dev); - } else { - list_add_tail(&dev->list_all, &list_all_device_instances); - } + put_device(&dev->device); return rc; } @@ -1057,21 +1024,6 @@ remove_visor_device(struct visor_device *dev) device_unregister(&dev->device); } -static struct visor_device * -find_visor_device_by_channel(struct visorchannel *channel) -{ - struct list_head *listentry, *listtmp; - - list_for_each_safe(listentry, listtmp, &list_all_device_instances) { - struct visor_device *dev = list_entry(listentry, - struct visor_device, - list_all); - if (dev->visorchannel == channel) - return dev; - } - return NULL; -} - static int get_vbus_header_info(struct visorchannel *chan, struct spar_vbus_headerinfo *hdr_info) @@ -1344,25 +1296,16 @@ chipset_bus_destroy(struct visor_device *dev) } static void -chipset_device_create(struct visorchipset_device_info *dev_info) +chipset_device_create(struct visor_device *dev_info) { - struct visor_device *bdev; int rc = -1; - u32 bus_no = dev_info->bus_no; - u32 dev_no = dev_info->dev_no; + u32 bus_no = dev_info->chipset_bus_no; + u32 dev_no = dev_info->chipset_dev_no; POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); - bdev = visorbus_get_device_by_id(bus_no, BUS_ROOT_DEVICE, NULL); - if (!bdev) - goto away; - - POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no, - POSTCODE_SEVERITY_INFO); - - rc = create_visor_device(bdev, dev_info); -away: + rc = create_visor_device(dev_info); if (rc < 0) { POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, POSTCODE_SEVERITY_ERR); @@ -1375,22 +1318,12 @@ away: } static void -chipset_device_destroy(struct visorchipset_device_info *dev_info) +chipset_device_destroy(struct visor_device *dev_info) { - struct visor_device *dev; - int rc = -1; - - dev = find_visor_device_by_channel(dev_info->visorchannel); - if (!dev) - goto away; - rc = 0; -away: - if (rc < 0) - return; + remove_visor_device(dev_info); if (chipset_responders.device_destroy) - (*chipset_responders.device_destroy) (dev_info, rc); - remove_visor_device(dev); + (*chipset_responders.device_destroy) (dev_info, 0); } /* This is the callback function specified for a function driver, to @@ -1398,11 +1331,8 @@ away: * completed. */ static void -pause_state_change_complete(struct visor_device *dev, int status, - void *info) +pause_state_change_complete(struct visor_device *dev, int status) { - struct visorchipset_device_info *dev_info = info; - if (!dev->pausing) return; @@ -1413,7 +1343,7 @@ pause_state_change_complete(struct visor_device *dev, int status, /* Notify the chipset driver that the pause is complete, which * will presumably want to send some sort of response to the * initiator. */ - (*chipset_responders.device_pause) (dev_info, status); + (*chipset_responders.device_pause) (dev, status); } /* This is the callback function specified for a function driver, to @@ -1421,11 +1351,8 @@ pause_state_change_complete(struct visor_device *dev, int status, * completed. */ static void -resume_state_change_complete(struct visor_device *dev, int status, - void *info) +resume_state_change_complete(struct visor_device *dev, int status) { - struct visorchipset_device_info *dev_info = info; - if (!dev->resuming) return; @@ -1436,7 +1363,7 @@ resume_state_change_complete(struct visor_device *dev, int status, /* Notify the chipset driver that the resume is complete, * which will presumably want to send some sort of response to * the initiator. */ - (*chipset_responders.device_resume) (dev_info, status); + (*chipset_responders.device_resume) (dev, status); } /* Tell the subordinate function driver for a specific device to pause @@ -1444,14 +1371,11 @@ resume_state_change_complete(struct visor_device *dev, int status, * callback function. */ static void -initiate_chipset_device_pause_resume(struct visorchipset_device_info *dev_info, - bool is_pause) +initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause) { - struct visor_device *dev = NULL; int rc = -1, x; struct visor_driver *drv = NULL; - void (*notify_func)(struct visorchipset_device_info *dev_info, - int response) = NULL; + void (*notify_func)(struct visor_device *dev, int response) = NULL; if (is_pause) notify_func = chipset_responders.device_pause; @@ -1460,10 +1384,6 @@ initiate_chipset_device_pause_resume(struct visorchipset_device_info *dev_info, if (!notify_func) goto away; - dev = find_visor_device_by_channel(dev_info->visorchannel); - if (!dev) - goto away; - drv = to_visor_driver(dev->device.driver); if (!drv) goto away; @@ -1483,8 +1403,7 @@ initiate_chipset_device_pause_resume(struct visorchipset_device_info *dev_info, goto away; dev->pausing = true; - x = drv->pause(dev, pause_state_change_complete, - (void *)dev_info); + x = drv->pause(dev, pause_state_change_complete); } else { /* This should be done at BUS resume time, but an * existing problem prevents us from ever getting a bus @@ -1496,8 +1415,7 @@ initiate_chipset_device_pause_resume(struct visorchipset_device_info *dev_info, goto away; dev->resuming = true; - x = drv->resume(dev, resume_state_change_complete, - (void *)dev_info); + x = drv->resume(dev, resume_state_change_complete); } if (x < 0) { if (is_pause) @@ -1510,18 +1428,18 @@ initiate_chipset_device_pause_resume(struct visorchipset_device_info *dev_info, away: if (rc < 0) { if (notify_func) - (*notify_func)(dev_info, rc); + (*notify_func)(dev, rc); } } static void -chipset_device_pause(struct visorchipset_device_info *dev_info) +chipset_device_pause(struct visor_device *dev_info) { initiate_chipset_device_pause_resume(dev_info, true); } static void -chipset_device_resume(struct visorchipset_device_info *dev_info) +chipset_device_resume(struct visor_device *dev_info) { initiate_chipset_device_pause_resume(dev_info, false); } diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h index 6fd55af8926c..2f12483e38ab 100644 --- a/drivers/staging/unisys/visorbus/visorbus_private.h +++ b/drivers/staging/unisys/visorbus/visorbus_private.h @@ -20,35 +20,10 @@ #include -#include "channel.h" #include "controlvmchannel.h" #include "vbusdeviceinfo.h" #include "vbushelper.h" -struct visorchannel; - -/** Attributes for a particular Supervisor device. - * Any visorchipset client can query these attributes using - * visorchipset_get_client_device_info() or - * visorchipset_get_server_device_info(). - */ -struct visorchipset_device_info { - struct list_head entry; - u32 bus_no; - u32 dev_no; - uuid_le dev_inst_uuid; - struct visorchipset_state state; - struct visorchannel *visorchannel; - uuid_le channel_type_guid; - u32 reserved1; /* control_vm_id */ - u64 reserved2; - u32 switch_no; /* when devState.attached==1 */ - u32 internal_port_no; /* when devState.attached==1 */ - struct controlvm_message_header *pending_msg_hdr;/* CONTROLVM_MESSAGE */ - /** For private use by the bus driver */ - void *bus_driver_context; -}; - /* These functions will be called from within visorchipset when certain * events happen. (The implementation of these functions is outside of * visorchipset.) @@ -56,10 +31,10 @@ struct visorchipset_device_info { struct visorchipset_busdev_notifiers { void (*bus_create)(struct visor_device *bus_info); void (*bus_destroy)(struct visor_device *bus_info); - void (*device_create)(struct visorchipset_device_info *bus_info); - void (*device_destroy)(struct visorchipset_device_info *bus_info); - void (*device_pause)(struct visorchipset_device_info *bus_info); - void (*device_resume)(struct visorchipset_device_info *bus_info); + void (*device_create)(struct visor_device *bus_info); + void (*device_destroy)(struct visor_device *bus_info); + void (*device_pause)(struct visor_device *bus_info); + void (*device_resume)(struct visor_device *bus_info); }; /* These functions live inside visorchipset, and will be called to indicate @@ -71,11 +46,10 @@ struct visorchipset_busdev_notifiers { struct visorchipset_busdev_responders { void (*bus_create)(struct visor_device *p, int response); void (*bus_destroy)(struct visor_device *p, int response); - void (*device_create)(struct visorchipset_device_info *p, int response); - void (*device_destroy)(struct visorchipset_device_info *p, - int response); - void (*device_pause)(struct visorchipset_device_info *p, int response); - void (*device_resume)(struct visorchipset_device_info *p, int response); + void (*device_create)(struct visor_device *p, int response); + void (*device_destroy)(struct visor_device *p, int response); + void (*device_pause)(struct visor_device *p, int response); + void (*device_resume)(struct visor_device *p, int response); }; /** Register functions (in the bus driver) to get called by visorchipset @@ -89,13 +63,6 @@ visorchipset_register_busdev( struct visorchipset_busdev_responders *responders, struct ultra_vbus_deviceinfo *driver_info); -bool visorchipset_get_bus_info(u32 bus_no, - struct visor_device *bus_info); -bool visorchipset_get_device_info(u32 bus_no, u32 dev_no, - struct visorchipset_device_info *dev_info); -bool visorchipset_set_bus_context(struct visor_device *bus_info, - void *context); - /* visorbus init and exit functions */ int visorbus_init(void); void visorbus_exit(void); diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 4404f4fadd7e..4385b155ad60 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -230,16 +230,12 @@ static struct visorchipset_busdev_notifiers busdev_notifiers; static void bus_create_response(struct visor_device *p, int response); static void bus_destroy_response(struct visor_device *p, int response); -static void device_create_response(struct visorchipset_device_info *p, - int response); -static void device_destroy_response(struct visorchipset_device_info *p, - int response); -static void device_resume_response(struct visorchipset_device_info *p, - int response); +static void device_create_response(struct visor_device *p, int response); +static void device_destroy_response(struct visor_device *p, int response); +static void device_resume_response(struct visor_device *p, int response); -static void -visorchipset_device_pause_response(struct visorchipset_device_info *p, - int response); +static void visorchipset_device_pause_response(struct visor_device *p, + int response); static struct visorchipset_busdev_responders busdev_responders = { .bus_create = bus_create_response, @@ -696,15 +692,6 @@ static ssize_t remaining_steps_store(struct device *dev, return count; } -static void -dev_info_clear(void *v) -{ - struct visorchipset_device_info *p = - (struct visorchipset_device_info *) v; - - memset(p, 0, sizeof(struct visorchipset_device_info)); -} - struct visor_busdev { u32 bus_no; u32 dev_no; @@ -744,31 +731,6 @@ struct visor_device *visorbus_get_device_by_id(u32 bus_no, u32 dev_no, } EXPORT_SYMBOL(visorbus_get_device_by_id); -static struct visorchipset_device_info * -device_find(struct list_head *list, u32 bus_no, u32 dev_no) -{ - struct visorchipset_device_info *p; - - list_for_each_entry(p, list, entry) { - if (p->bus_no == bus_no && p->dev_no == dev_no) - return p; - } - - return NULL; -} - -static void busdevices_del(struct list_head *list, u32 bus_no) -{ - struct visorchipset_device_info *p, *tmp; - - list_for_each_entry_safe(p, tmp, list, entry) { - if (p->bus_no == bus_no) { - list_del(&p->entry); - kfree(p); - } - } -} - static u8 check_chipset_events(void) { @@ -814,18 +776,6 @@ visorchipset_register_busdev( } EXPORT_SYMBOL_GPL(visorchipset_register_busdev); -static void -cleanup_controlvm_structures(void) -{ - struct visorchipset_device_info *di, *tmp_di; - - list_for_each_entry_safe(di, tmp_di, &dev_info_list, entry) { - dev_info_clear(di); - list_del(&di->entry); - kfree(di); - } -} - static void chipset_init(struct controlvm_message *inmsg) { @@ -852,8 +802,6 @@ chipset_init(struct controlvm_message *inmsg) features |= ULTRA_CHIPSET_FEATURE_REPLY; cleanup: - if (rc < 0) - cleanup_controlvm_structures(); if (inmsg->hdr.flags.response_expected) controlvm_respond_chipset_init(&inmsg->hdr, rc, features); } @@ -947,12 +895,12 @@ bus_responder(enum controlvm_id cmd_id, static void device_changestate_responder(enum controlvm_id cmd_id, - struct visorchipset_device_info *p, int response, + struct visor_device *p, int response, struct spar_segment_state response_state) { struct controlvm_message outmsg; - u32 bus_no = p->bus_no; - u32 dev_no = p->dev_no; + u32 bus_no = p->chipset_bus_no; + u32 dev_no = p->chipset_dev_no; if (p->pending_msg_hdr == NULL) return; /* no controlvm response needed */ @@ -1053,15 +1001,15 @@ away: } static void -device_epilog(struct visorchipset_device_info *dev_info, +device_epilog(struct visor_device *dev_info, struct spar_segment_state state, u32 cmd, struct controlvm_message_header *msg_hdr, int response, bool need_response, bool for_visorbus) { struct visorchipset_busdev_notifiers *notifiers; bool notified = false; - u32 bus_no = dev_info->bus_no; - u32 dev_no = dev_info->dev_no; + u32 bus_no = dev_info->chipset_bus_no; + u32 dev_no = dev_info->chipset_dev_no; struct controlvm_message_header *pmsg_hdr = NULL; char *envp[] = { @@ -1286,31 +1234,34 @@ my_device_create(struct controlvm_message *inmsg) struct controlvm_message_packet *cmd = &inmsg->cmd; u32 bus_no = cmd->create_device.bus_no; u32 dev_no = cmd->create_device.dev_no; - struct visorchipset_device_info *dev_info; + struct visor_device *dev_info = NULL; struct visor_device *bus_info; struct visorchannel *visorchannel; int rc = CONTROLVM_RESP_SUCCESS; - dev_info = device_find(&dev_info_list, bus_no, dev_no); - if (dev_info && (dev_info->state.created == 1)) { - POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, - POSTCODE_SEVERITY_ERR); - rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE; - goto cleanup; - } - bus_info = visorbus_get_device_by_id(bus_no, dev_no, NULL); + bus_info = visorbus_get_device_by_id(bus_no, BUS_ROOT_DEVICE, NULL); if (!bus_info) { POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, POSTCODE_SEVERITY_ERR); rc = -CONTROLVM_RESP_ERROR_BUS_INVALID; goto cleanup; } + if (bus_info->state.created == 0) { POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, POSTCODE_SEVERITY_ERR); rc = -CONTROLVM_RESP_ERROR_BUS_INVALID; goto cleanup; } + + dev_info = visorbus_get_device_by_id(bus_no, dev_no, NULL); + if (dev_info && (dev_info->state.created == 1)) { + POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, + POSTCODE_SEVERITY_ERR); + rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE; + goto cleanup; + } + dev_info = kzalloc(sizeof(*dev_info), GFP_KERNEL); if (!dev_info) { POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, @@ -1319,10 +1270,13 @@ my_device_create(struct controlvm_message *inmsg) goto cleanup; } - INIT_LIST_HEAD(&dev_info->entry); - dev_info->bus_no = bus_no; - dev_info->dev_no = dev_no; - dev_info->dev_inst_uuid = cmd->create_device.dev_inst_uuid; + dev_info->chipset_bus_no = bus_no; + dev_info->chipset_dev_no = dev_no; + dev_info->inst = cmd->create_device.dev_inst_uuid; + + /* not sure where the best place to set the 'parent' */ + dev_info->device.parent = &bus_info->device; + POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); @@ -1341,7 +1295,6 @@ my_device_create(struct controlvm_message *inmsg) } dev_info->visorchannel = visorchannel; dev_info->channel_type_guid = cmd->create_device.data_type_uuid; - list_add(&dev_info->entry, &dev_info_list); POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); cleanup: @@ -1363,10 +1316,10 @@ my_device_changestate(struct controlvm_message *inmsg) u32 bus_no = cmd->device_change_state.bus_no; u32 dev_no = cmd->device_change_state.dev_no; struct spar_segment_state state = cmd->device_change_state.state; - struct visorchipset_device_info *dev_info; + struct visor_device *dev_info; int rc = CONTROLVM_RESP_SUCCESS; - dev_info = device_find(&dev_info_list, bus_no, dev_no); + dev_info = visorbus_get_device_by_id(bus_no, dev_no, NULL); if (!dev_info) { POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, dev_no, bus_no, POSTCODE_SEVERITY_ERR); @@ -1388,10 +1341,10 @@ my_device_destroy(struct controlvm_message *inmsg) struct controlvm_message_packet *cmd = &inmsg->cmd; u32 bus_no = cmd->destroy_device.bus_no; u32 dev_no = cmd->destroy_device.dev_no; - struct visorchipset_device_info *dev_info; + struct visor_device *dev_info; int rc = CONTROLVM_RESP_SUCCESS; - dev_info = device_find(&dev_info_list, bus_no, dev_no); + dev_info = visorbus_get_device_by_id(bus_no, dev_no, NULL); if (!dev_info) rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID; else if (dev_info->state.created == 0) @@ -2105,11 +2058,6 @@ bus_create_response(struct visor_device *bus_info, int response) { if (response >= 0) { bus_info->state.created = 1; - } else { - if (response != -CONTROLVM_RESP_ERROR_ALREADY_DONE) - /* undo the row we just created... */ - busdevices_del(&dev_info_list, - bus_info->chipset_bus_no); } bus_responder(CONTROLVM_BUS_CREATE, bus_info->pending_msg_hdr, @@ -2127,12 +2075,10 @@ bus_destroy_response(struct visor_device *bus_info, int response) kfree(bus_info->pending_msg_hdr); bus_info->pending_msg_hdr = NULL; - - busdevices_del(&dev_info_list, bus_info->chipset_bus_no); } static void -device_create_response(struct visorchipset_device_info *dev_info, int response) +device_create_response(struct visor_device *dev_info, int response) { if (response >= 0) dev_info->state.created = 1; @@ -2141,23 +2087,20 @@ device_create_response(struct visorchipset_device_info *dev_info, int response) response); kfree(dev_info->pending_msg_hdr); - dev_info->pending_msg_hdr = NULL; } static void -device_destroy_response(struct visorchipset_device_info *dev_info, int response) +device_destroy_response(struct visor_device *dev_info, int response) { device_responder(CONTROLVM_DEVICE_DESTROY, dev_info->pending_msg_hdr, response); kfree(dev_info->pending_msg_hdr); dev_info->pending_msg_hdr = NULL; - - dev_info_clear(dev_info); } static void -visorchipset_device_pause_response(struct visorchipset_device_info *dev_info, +visorchipset_device_pause_response(struct visor_device *dev_info, int response) { device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE, @@ -2169,7 +2112,7 @@ visorchipset_device_pause_response(struct visorchipset_device_info *dev_info, } static void -device_resume_response(struct visorchipset_device_info *dev_info, int response) +device_resume_response(struct visor_device *dev_info, int response) { device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE, dev_info, response, @@ -2179,30 +2122,6 @@ device_resume_response(struct visorchipset_device_info *dev_info, int response) dev_info->pending_msg_hdr = NULL; } -bool -visorchipset_get_device_info(u32 bus_no, u32 dev_no, - struct visorchipset_device_info *dev_info) -{ - void *p = device_find(&dev_info_list, bus_no, dev_no); - - if (!p) - return false; - memcpy(dev_info, p, sizeof(struct visorchipset_device_info)); - return true; -} -EXPORT_SYMBOL_GPL(visorchipset_get_device_info); - -bool -visorchipset_set_device_context(struct visorchipset_device_info *p, - void *context) -{ - if (!p) - return false; - p->bus_driver_context = context; - return true; -} -EXPORT_SYMBOL_GPL(visorchipset_set_device_context); - static ssize_t chipsetready_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) @@ -2476,8 +2395,6 @@ visorchipset_exit(struct acpi_device *acpi_device) periodic_controlvm_workqueue = NULL; destroy_controlvm_payload_info(&controlvm_payload_info); - cleanup_controlvm_structures(); - memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header)); visorchannel_destroy(controlvm_channel); From 4239f82294398982d31505b89df9664da81671af Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Thu, 4 Jun 2015 09:22:43 -0400 Subject: [PATCH 0858/1163] staging: unisys: Removed unused entries from struct visor_channeltype_descriptor min_size/max_size aren't used anywhere, and they were just causing headaches in the drivers being ported over to the new interfaces. Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/visorbus.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h index 581d962980f9..e4a21e42e868 100644 --- a/drivers/staging/unisys/include/visorbus.h +++ b/drivers/staging/unisys/include/visorbus.h @@ -59,8 +59,6 @@ struct visorchipset_state { struct visor_channeltype_descriptor { const uuid_le guid; const char *name; - unsigned long min_size; - unsigned long max_size; }; /** Information provided by each visor driver when it registers with the From 01ef15f722c65bb747118eee09a5ffa85df934a7 Mon Sep 17 00:00:00 2001 From: David Kershner Date: Thu, 4 Jun 2015 09:22:44 -0400 Subject: [PATCH 0859/1163] staging: unisys: Update diag serverity enum Give the enum the correct values instead of based on other values. Signed-off-by: David Kershner Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/diagchannel.h | 34 ++++++-------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/drivers/staging/unisys/include/diagchannel.h b/drivers/staging/unisys/include/diagchannel.h index e8fb8678a8e2..c1e74e85ecc8 100644 --- a/drivers/staging/unisys/include/diagchannel.h +++ b/drivers/staging/unisys/include/diagchannel.h @@ -58,20 +58,6 @@ static const uuid_le spar_diag_channel_protocol_uuid = * increment this. */ #define ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID 2 -#define SPAR_DIAG_CHANNEL_OK_CLIENT(ch)\ - (spar_check_channel_client(ch,\ - spar_diag_channel_protocol_uuid,\ - "diag",\ - sizeof(struct spar_diag_channel_protocol),\ - ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID,\ - ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE)) - -#define SPAR_DIAG_CHANNEL_OK_SERVER(bytes)\ - (spar_check_channel_server(spar_diag_channel_protocol_uuid,\ - "diag",\ - sizeof(struct spar_diag_channel_protocol),\ - bytes)) - #define MAX_MODULE_NAME_SIZE 128 /* Maximum length of module name... */ #define MAX_ADDITIONAL_INFO_SIZE 256 /* Maximum length of any additional info * accompanying event... */ @@ -204,16 +190,16 @@ struct diag_channel_event { * change is made to this enum, they should also be reflected in that file. */ enum diag_severity { DIAG_SEVERITY_ENUM_BEGIN = 0, - DIAG_SEVERITY_OVERRIDE = DIAG_SEVERITY_ENUM_BEGIN, - DIAG_SEVERITY_VERBOSE = DIAG_SEVERITY_OVERRIDE, /* 0 */ - DIAG_SEVERITY_INFO = DIAG_SEVERITY_VERBOSE + 1, /* 1 */ - DIAG_SEVERITY_WARNING = DIAG_SEVERITY_INFO + 1, /* 2 */ - DIAG_SEVERITY_ERR = DIAG_SEVERITY_WARNING + 1, /* 3 */ - DIAG_SEVERITY_PRINT = DIAG_SEVERITY_ERR + 1, /* 4 */ - DIAG_SEVERITY_SHUTOFF = DIAG_SEVERITY_PRINT + 1, /* 5 */ - DIAG_SEVERITY_ENUM_END = DIAG_SEVERITY_SHUTOFF, /* 5 */ - DIAG_SEVERITY_NONFATAL_ERR = DIAG_SEVERITY_ERR, - DIAG_SEVERITY_FATAL_ERR = DIAG_SEVERITY_PRINT + DIAG_SEVERITY_OVERRIDE = 0, + DIAG_SEVERITY_VERBOSE = 0, + DIAG_SEVERITY_INFO = 1, + DIAG_SEVERITY_WARNING = 2, + DIAG_SEVERITY_ERR = 3, + DIAG_SEVERITY_NONFATAL_ERR = 3, + DIAG_SEVERITY_PRINT = 4, + DIAG_SEVERITY_FATAL_ERR = 4, + DIAG_SEVERITY_SHUTOFF = 5, + DIAG_SEVERITY_ENUM_END = 5 }; /* Event Cause enums From ee872fde4bbab069bb44b0b3c23bd2eddea8bbb6 Mon Sep 17 00:00:00 2001 From: David Kershner Date: Thu, 4 Jun 2015 09:22:45 -0400 Subject: [PATCH 0860/1163] staging: unisys: Remove unneeded fields in diagchannel.h Diagchannel.h is used primarily for the diagnostics channel. The diagnostics channel is not being used by linux guests currently, so the majority of the file is not needed. What is left is what is needed to perform postcode vmcalls. Those postcodes will eventually end up in the diag channel. Signed-off-by: David Kershner Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/diagchannel.h | 366 +----------------- .../staging/unisys/visorbus/visorchipset.c | 45 --- 2 files changed, 2 insertions(+), 409 deletions(-) diff --git a/drivers/staging/unisys/include/diagchannel.h b/drivers/staging/unisys/include/diagchannel.h index c1e74e85ecc8..82932c53f5c6 100644 --- a/drivers/staging/unisys/include/diagchannel.h +++ b/drivers/staging/unisys/include/diagchannel.h @@ -13,169 +13,15 @@ * details. */ -/*++ - * - * Module Name: - * - * diagchannel.h - * - * Abstract: - * - * This file defines the DiagChannel protocol. This protocol is used to aid in - * preserving event data sent by external applications. This protocol provides - * a region for event data to reside in. This data will eventually be sent to - * the Boot Partition where it will be committed to memory and/or disk. This - * file contains platform-independent data that can be built using any - * Supervisor build environment (Windows, Linux, EFI). - * -*/ - #ifndef _DIAG_CHANNEL_H_ #define _DIAG_CHANNEL_H_ #include -#include "channel.h" - -/* {EEA7A573-DB82-447c-8716-EFBEAAAE4858} */ -#define SPAR_DIAG_CHANNEL_PROTOCOL_UUID \ - UUID_LE(0xeea7a573, 0xdb82, 0x447c, \ - 0x87, 0x16, 0xef, 0xbe, 0xaa, 0xae, 0x48, 0x58) - -static const uuid_le spar_diag_channel_protocol_uuid = - SPAR_DIAG_CHANNEL_PROTOCOL_UUID; - -/* {E850F968-3263-4484-8CA5-2A35D087A5A8} */ -#define ULTRA_DIAG_ROOT_CHANNEL_PROTOCOL_GUID \ - UUID_LE(0xe850f968, 0x3263, 0x4484, \ - 0x8c, 0xa5, 0x2a, 0x35, 0xd0, 0x87, 0xa5, 0xa8) - -#define ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE ULTRA_CHANNEL_PROTOCOL_SIGNATURE - -/* Must increment this whenever you insert or delete fields within this channel -* struct. Also increment whenever you change the meaning of fields within this -* channel struct so as to break pre-existing software. Note that you can -* usually add fields to the END of the channel struct withOUT needing to -* increment this. */ -#define ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID 2 #define MAX_MODULE_NAME_SIZE 128 /* Maximum length of module name... */ #define MAX_ADDITIONAL_INFO_SIZE 256 /* Maximum length of any additional info - * accompanying event... */ -#define MAX_SUBSYSTEMS 64 /* Maximum number of subsystems allowed in - * DiagChannel... */ -#define LOW_SUBSYSTEMS 32 /* Half of MAX_SUBSYSTEMS to allow 64-bit - * math */ -#define SUBSYSTEM_DEBUG 0 /* Standard subsystem for debug events */ -#define SUBSYSTEM_DEFAULT 1 /* Default subsystem for legacy calls to - * ReportEvent */ - -/* few useful subsystem mask values */ -#define SUBSYSTEM_MASK_DEBUG 0x01 /* Standard subsystem for debug - * events */ -#define SUBSYSTEM_MASK_DEFAULT 0x02 /* Default subsystem for legacy calls to - * ReportEvents */ - -/* Event parameter "Severity" is overloaded with Cause in byte 2 and Severity in - * byte 0, bytes 1 and 3 are reserved */ -#define SEVERITY_MASK 0x0FF /* mask out all but the Severity in byte 0 */ -#define CAUSE_MASK 0x0FF0000 /* mask out all but the cause in byte 2 */ -#define CAUSE_SHIFT_AMT 16 /* shift 2 bytes to place it in byte 2 */ - -/* SubsystemSeverityFilter */ -#define SEVERITY_FILTER_MASK 0x0F /* mask out the Cause half, SeverityFilter is - * in the lower nibble */ -#define CAUSE_FILTER_MASK 0xF0 /* mask out the Severity half, CauseFilter is in - * the upper nibble */ -#define CAUSE_FILTER_SHIFT_AMT 4 /* shift amount to place it in lower or upper - * nibble */ - -/* Copied from EFI's EFI_TIME struct in efidef.h. EFI headers are not allowed -* in some of the Supervisor areas, such as Monitor, so it has been "ported" here -* for use in diagnostic event timestamps... */ -struct diag_efi_time { - u16 year; /* 1998 - 20XX */ - u8 month; /* 1 - 12 */ - u8 day; /* 1 - 31 */ - u8 hour; /* 0 - 23 */ - u8 minute; /* 0 - 59 */ - u8 second; /* 0 - 59 */ - u8 pad1; - u32 nanosecond; /* 0 - 999, 999, 999 */ - s16 timezone; /* -1440 to 1440 or 2047 */ - u8 daylight; - u8 pad2; -}; - -enum spar_component_types { - ULTRA_COMPONENT_GUEST = 0, - ULTRA_COMPONENT_MONITOR = 0x01, - ULTRA_COMPONENT_CCM = 0x02, /* Common Control module */ - /* RESERVED 0x03 - 0x7 */ - - /* Ultravisor Components */ - ULTRA_COMPONENT_BOOT = 0x08, - ULTRA_COMPONENT_IDLE = 0x09, - ULTRA_COMPONENT_CONTROL = 0x0A, - ULTRA_COMPONENT_LOGGER = 0x0B, - ULTRA_COMPONENT_ACPI = 0X0C, - /* RESERVED 0x0D - 0x0F */ - - /* sPAR Components */ - ULTRA_COMPONENT_COMMAND = 0x10, - ULTRA_COMPONENT_IODRIVER = 0x11, - ULTRA_COMPONENT_CONSOLE = 0x12, - ULTRA_COMPONENT_OPERATIONS = 0x13, - ULTRA_COMPONENT_MANAGEMENT = 0x14, - ULTRA_COMPONENT_DIAG = 0x15, - ULTRA_COMPONENT_HWDIAG = 0x16, - ULTRA_COMPONENT_PSERVICES = 0x17, - ULTRA_COMPONENT_PDIAG = 0x18 - /* RESERVED 0x18 - 0x1F */ -}; - -/* Structure: diag_channel_event Purpose: Contains attributes that make up an - * event to be written to the DIAG_CHANNEL memory. Attributes: EventId: Id of - * the diagnostic event to write to memory. Severity: Severity of the event - * (Error, Info, etc). ModuleName: Module/file name where event originated. - * LineNumber: Line number in module name where event originated. Timestamp: - * Date/time when event was received by ReportEvent, and written to DiagChannel. - * Reserved: Padding to align structure on a 64-byte cache line boundary. - * AdditionalInfo: Array of characters for additional event info (may be - * empty). */ -struct diag_channel_event { - u32 event_id; - u32 severity; - u8 module_name[MAX_MODULE_NAME_SIZE]; - u32 line_number; - struct diag_efi_time timestamp; /* Size = 16 bytes */ - u32 partition_number; /* Filled in by Diag Switch as pool blocks are - * filled */ - u16 vcpu_number; - u16 lcpu_number; - u8 component_type; /* ULTRA_COMPONENT_TYPES */ - u8 subsystem; - u16 reserved0; /* pad to u64 alignment */ - u32 block_no; /* filled in by DiagSwitch as pool blocks are - * filled */ - u32 block_no_high; - u32 event_no; /* filled in by DiagSwitch as pool blocks are - * filled */ - u32 event_no_high; - - /* The block_no and event_no fields are set only by DiagSwitch - * and referenced only by WinDiagDisplay formatting tool as - * additional diagnostic information. Other tools including - * WinDiagDisplay currently ignore these 'Reserved' bytes. */ - u8 reserved[8]; - u8 additional_info[MAX_ADDITIONAL_INFO_SIZE]; - - /* NOTE: Changes to diag_channel_event generally need to be reflected in - * existing copies * - * - for AppOS at - * GuestLinux/visordiag_early/supervisor_diagchannel.h * - * - for WinDiagDisplay at - * EFI/Ultra/Tools/WinDiagDisplay/WinDiagDisplay/diagstruct.h */ -}; + * accompanying event... + */ /* Levels of severity for diagnostic events, in order from lowest severity to * highest (i.e. fatal errors are the most severe, and should always be logged, @@ -202,212 +48,4 @@ enum diag_severity { DIAG_SEVERITY_ENUM_END = 5 }; -/* Event Cause enums -* -* Levels of cause for diagnostic events, in order from least to greatest cause -* Internal errors are most urgent since ideally they should never exist -* Invalid requests are preventable by avoiding invalid inputs -* Operations errors depend on environmental factors which may impact which -* requests are possible -* Manifest provides intermediate value to capture firmware and configuration -* version information -* Trace provides suplimental debug information in release firmware -* Unknown Log captures unclasified LogEvent calls. -* Debug is the least urgent since it provides suplimental debug information only -* in debug firmware -* Unknown Debug captures unclassified DebugEvent calls. -* This enum is also defined in -* DotNet\sParFramework\ControlFramework\ControlFramework.cs. -* If a change is made to this enum, they should also be reflected in that -* file. */ - -/* A cause value "DIAG_CAUSE_FILE_XFER" together with a severity value of -* "DIAG_SEVERITY_PRINT" (=4), is used for transferring text or binary file to -* the Diag partition. This cause-severity combination will be used by Logger -* DiagSwitch to segregate events into block types. The files are transferred in -* 256 byte chunks maximum, in the AdditionalInfo field of the diag_channel_event -* structure. In the file transfer mode, some event fields will have different -* meaning: EventId specifies the file offset, severity specifies the block type, -* ModuleName specifies the filename, LineNumber specifies the number of valid -* data bytes in an event and AdditionalInfo contains up to 256 bytes of data. */ - -/* The Diag DiagWriter appends event blocks to events.raw as today, and for data - * blocks uses diag_channel_event - * PartitionNumber to extract and append 'AdditionalInfo' to filename (specified - * by ModuleName). */ - -/* The Dell PDiag uses this new mechanism to stash DSET .zip onto the - * 'diagnostic' virtual disk. */ -enum diag_cause { - DIAG_CAUSE_UNKNOWN = 0, - DIAG_CAUSE_UNKNOWN_DEBUG = DIAG_CAUSE_UNKNOWN + 1, /* 1 */ - DIAG_CAUSE_DEBUG = DIAG_CAUSE_UNKNOWN_DEBUG + 1, /* 2 */ - DIAG_CAUSE_UNKNOWN_LOG = DIAG_CAUSE_DEBUG + 1, /* 3 */ - DIAG_CAUSE_TRACE = DIAG_CAUSE_UNKNOWN_LOG + 1, /* 4 */ - DIAG_CAUSE_MANIFEST = DIAG_CAUSE_TRACE + 1, /* 5 */ - DIAG_CAUSE_OPERATIONS_ERROR = DIAG_CAUSE_MANIFEST + 1, /* 6 */ - DIAG_CAUSE_INVALID_REQUEST = DIAG_CAUSE_OPERATIONS_ERROR + 1, /* 7 */ - DIAG_CAUSE_INTERNAL_ERROR = DIAG_CAUSE_INVALID_REQUEST + 1, /* 8 */ - DIAG_CAUSE_FILE_XFER = DIAG_CAUSE_INTERNAL_ERROR + 1, /* 9 */ - DIAG_CAUSE_ENUM_END = DIAG_CAUSE_FILE_XFER /* 9 */ -}; - -/* Event Cause category defined into the byte 2 of Severity */ -#define CAUSE_DEBUG (DIAG_CAUSE_DEBUG << CAUSE_SHIFT_AMT) -#define CAUSE_TRACE (DIAG_CAUSE_TRACE << CAUSE_SHIFT_AMT) -#define CAUSE_MANIFEST (DIAG_CAUSE_MANIFEST << CAUSE_SHIFT_AMT) -#define CAUSE_OPERATIONS_ERROR (DIAG_CAUSE_OPERATIONS_ERROR << CAUSE_SHIFT_AMT) -#define CAUSE_INVALID_REQUEST (DIAG_CAUSE_INVALID_REQUEST << CAUSE_SHIFT_AMT) -#define CAUSE_INTERNAL_ERROR (DIAG_CAUSE_INTERNAL_ERROR << CAUSE_SHIFT_AMT) -#define CAUSE_FILE_XFER (DIAG_CAUSE_FILE_XFER << CAUSE_SHIFT_AMT) -#define CAUSE_ENUM_END CAUSE_FILE_XFER - -/* Combine Cause and Severity categories into one */ -#define CAUSE_DEBUG_SEVERITY_VERBOSE \ - (CAUSE_DEBUG | DIAG_SEVERITY_VERBOSE) -#define CAUSE_TRACE_SEVERITY_VERBOSE \ - (CAUSE_TRACE | DIAG_SEVERITY_VERBOSE) -#define CAUSE_MANIFEST_SEVERITY_VERBOSE\ - (CAUSE_MANIFEST | DIAG_SEVERITY_VERBOSE) -#define CAUSE_OPERATIONS_SEVERITY_VERBOSE \ - (CAUSE_OPERATIONS_ERROR | DIAG_SEVERITY_VERBOSE) -#define CAUSE_INVALID_SEVERITY_VERBOSE \ - (CAUSE_INVALID_REQUEST | DIAG_SEVERITY_VERBOSE) -#define CAUSE_INTERNAL_SEVERITY_VERBOSE \ - (CAUSE_INTERNAL_ERROR | DIAG_SEVERITY_VERBOSE) - -#define CAUSE_DEBUG_SEVERITY_INFO \ - (CAUSE_DEBUG | DIAG_SEVERITY_INFO) -#define CAUSE_TRACE_SEVERITY_INFO \ - (CAUSE_TRACE | DIAG_SEVERITY_INFO) -#define CAUSE_MANIFEST_SEVERITY_INFO \ - (CAUSE_MANIFEST | DIAG_SEVERITY_INFO) -#define CAUSE_OPERATIONS_SEVERITY_INFO \ - (CAUSE_OPERATIONS_ERROR | DIAG_SEVERITY_INFO) -#define CAUSE_INVALID_SEVERITY_INFO \ - (CAUSE_INVALID_REQUEST | DIAG_SEVERITY_INFO) -#define CAUSE_INTERNAL_SEVERITY_INFO \ - (CAUSE_INTERNAL_ERROR | DIAG_SEVERITY_INFO) - -#define CAUSE_DEBUG_SEVERITY_WARN \ - (CAUSE_DEBUG | DIAG_SEVERITY_WARNING) -#define CAUSE_TRACE_SEVERITY_WARN \ - (CAUSE_TRACE | DIAG_SEVERITY_WARNING) -#define CAUSE_MANIFEST_SEVERITY_WARN \ - (CAUSE_MANIFEST | DIAG_SEVERITY_WARNING) -#define CAUSE_OPERATIONS_SEVERITY_WARN \ - (CAUSE_OPERATIONS_ERROR | DIAG_SEVERITY_WARNING) -#define CAUSE_INVALID_SEVERITY_WARN \ - (CAUSE_INVALID_REQUEST | DIAG_SEVERITY_WARNING) -#define CAUSE_INTERNAL_SEVERITY_WARN \ - (CAUSE_INTERNAL_ERROR | DIAG_SEVERITY_WARNING) - -#define CAUSE_DEBUG_SEVERITY_ERR \ - (CAUSE_DEBUG | DIAG_SEVERITY_ERR) -#define CAUSE_TRACE_SEVERITY_ERR \ - (CAUSE_TRACE | DIAG_SEVERITY_ERR) -#define CAUSE_MANIFEST_SEVERITY_ERR \ - (CAUSE_MANIFEST | DIAG_SEVERITY_ERR) -#define CAUSE_OPERATIONS_SEVERITY_ERR \ - (CAUSE_OPERATIONS_ERROR | DIAG_SEVERITY_ERR) -#define CAUSE_INVALID_SEVERITY_ERR \ - (CAUSE_INVALID_REQUEST | DIAG_SEVERITY_ERR) -#define CAUSE_INTERNAL_SEVERITY_ERR \ - (CAUSE_INTERNAL_ERROR | DIAG_SEVERITY_ERR) - -#define CAUSE_DEBUG_SEVERITY_PRINT \ - (CAUSE_DEBUG | DIAG_SEVERITY_PRINT) -#define CAUSE_TRACE_SEVERITY_PRINT \ - (CAUSE_TRACE | DIAG_SEVERITY_PRINT) -#define CAUSE_MANIFEST_SEVERITY_PRINT \ - (CAUSE_MANIFEST | DIAG_SEVERITY_PRINT) -#define CAUSE_OPERATIONS_SEVERITY_PRINT \ - (CAUSE_OPERATIONS_ERROR | DIAG_SEVERITY_PRINT) -#define CAUSE_INVALID_SEVERITY_PRINT \ - (CAUSE_INVALID_REQUEST | DIAG_SEVERITY_PRINT) -#define CAUSE_INTERNAL_SEVERITY_PRINT \ - (CAUSE_INTERNAL_ERROR | DIAG_SEVERITY_PRINT) -#define CAUSE_FILE_XFER_SEVERITY_PRINT \ - (CAUSE_FILE_XFER | DIAG_SEVERITY_PRINT) - -/* Structure: diag_channel_protocol_header - * - * Purpose: Contains attributes that make up the header specific to the - * DIAG_CHANNEL area. - * - * Attributes: - * - * DiagLock: Diag Channel spinlock. - * - *IsChannelInitialized: 1 iff SignalInit was called for this channel; otherwise - * 0, and assume the channel is not ready for use yet. - * - * 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 - * particular subsystem below this level will be discarded. - */ -struct diag_channel_protocol_header { - u32 diag_lock; - u8 channel_initialized; - u8 reserved[3]; - u8 subsystem_severity_filter[64]; -}; - -/* The Diagram for the Diagnostic Channel: */ -/* ----------------------- */ -/* | Channel Header | Defined by ULTRA_CHANNEL_PROTOCOL */ -/* ----------------------- */ -/* | Signal Queue Header | Defined by SIGNAL_QUEUE_HEADER */ -/* ----------------------- */ -/* | DiagChannel Header | Defined by diag_channel_protocol_header */ -/* ----------------------- */ -/* | Channel Event Info | Defined by diag_channel_event*MAX_EVENTS */ -/* ----------------------- */ -/* | Reserved | Reserved (pad out to 4MB) */ -/* ----------------------- */ - -/* Offsets/sizes for diagnostic channel attributes... */ -#define DIAG_CH_QUEUE_HEADER_OFFSET (sizeof(struct channel_header)) -#define DIAG_CH_QUEUE_HEADER_SIZE (sizeof(struct signal_queue_header)) -#define DIAG_CH_PROTOCOL_HEADER_OFFSET \ - (DIAG_CH_QUEUE_HEADER_OFFSET + DIAG_CH_QUEUE_HEADER_SIZE) -#define DIAG_CH_PROTOCOL_HEADER_SIZE \ - (sizeof(struct diag_channel_protocol_header)) -#define DIAG_CH_EVENT_OFFSET \ - (DIAG_CH_PROTOCOL_HEADER_OFFSET + DIAG_CH_PROTOCOL_HEADER_SIZE) -#define DIAG_CH_SIZE (4096 * 1024) - -/* For Control and Idle Partitions with larger (8 MB) diagnostic(root) - * channels */ -#define DIAG_CH_LRG_SIZE (2 * DIAG_CH_SIZE) /* 8 MB */ - -/* - * Structure: spar_diag_channel_protocol - * - * Purpose: Contains attributes that make up the DIAG_CHANNEL memory. - * - * Attributes: - * - * CommonChannelHeader: Header info common to all channels. - * - * QueueHeader: Queue header common to all channels - used to determine where to - * store event. - * - * DiagChannelHeader: Diagnostic channel header info (see - * diag_channel_protocol_header comments). - * - * Events: Area where diagnostic events (up to MAX_EVENTS) are written. - * - *Reserved: Reserved area to allow for correct channel size padding. -*/ -struct spar_diag_channel_protocol { - struct channel_header common_channel_header; - struct signal_queue_header queue_header; - struct diag_channel_protocol_header diag_channel_header; - struct diag_channel_event events[(DIAG_CH_SIZE - DIAG_CH_EVENT_OFFSET) / - sizeof(struct diag_channel_event)]; -}; - #endif diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 4385b155ad60..90a3c30c9701 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -110,17 +110,8 @@ static DEFINE_SEMAPHORE(notifier_lock); static struct cdev file_cdev; static struct visorchannel **file_controlvm_channel; static struct controlvm_message_header g_chipset_msg_hdr; -static const uuid_le spar_diag_pool_channel_protocol_uuid = - SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID; -/* 0xffffff is an invalid Bus/Device number */ -static u32 g_diagpool_bus_no = 0xffffff; -static u32 g_diagpool_dev_no = 0xffffff; static struct controlvm_message_packet g_devicechangestate_packet; -#define is_diagpool_channel(channel_type_guid) \ - (uuid_le_cmp(channel_type_guid,\ - spar_diag_pool_channel_protocol_uuid) == 0) - static LIST_HEAD(bus_info_list); static LIST_HEAD(dev_info_list); @@ -827,14 +818,6 @@ controlvm_respond(struct controlvm_message_header *msg_hdr, int response) struct controlvm_message outmsg; controlvm_init_response(&outmsg, msg_hdr, response); - /* For DiagPool channel DEVICE_CHANGESTATE, we need to send - * back the deviceChangeState structure in the packet. */ - if (msg_hdr->id == CONTROLVM_DEVICE_CHANGESTATE && - g_devicechangestate_packet.device_change_state.bus_no == - g_diagpool_bus_no && - g_devicechangestate_packet.device_change_state.dev_no == - g_diagpool_dev_no) - outmsg.cmd = g_devicechangestate_packet; if (outmsg.hdr.flags.test_message == 1) return; @@ -1008,15 +991,8 @@ device_epilog(struct visor_device *dev_info, { struct visorchipset_busdev_notifiers *notifiers; bool notified = false; - u32 bus_no = dev_info->chipset_bus_no; - u32 dev_no = dev_info->chipset_dev_no; struct controlvm_message_header *pmsg_hdr = NULL; - char *envp[] = { - "SPARSP_DIAGPOOL_PAUSED_STATE = 1", - NULL - }; - notifiers = &busdev_notifiers; if (!dev_info) { @@ -1075,21 +1051,6 @@ device_epilog(struct visor_device *dev_info, (*notifiers->device_pause) (dev_info); notified = true; } - } else if (state.alive == segment_state_paused.alive && - state.operating == - segment_state_paused.operating) { - /* this is lite pause where channel is - * still valid just 'pause' of it - */ - if (bus_no == g_diagpool_bus_no && - dev_no == g_diagpool_dev_no) { - /* this will trigger the - * diag_shutdown.sh script in - * the visorchipset hotplug */ - kobject_uevent_env - (&visorchipset_platform_device.dev. - kobj, KOBJ_ONLINE, envp); - } } break; case CONTROLVM_DEVICE_DESTROY: @@ -1298,12 +1259,6 @@ my_device_create(struct controlvm_message *inmsg) POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); cleanup: - /* get the bus and devNo for DiagPool channel */ - if (dev_info && - is_diagpool_channel(cmd->create_device.data_type_uuid)) { - g_diagpool_bus_no = bus_no; - g_diagpool_dev_no = dev_no; - } device_epilog(dev_info, segment_state_running, CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1, 1); From c81e15a4b5622fa6f856435d424344828f6b3654 Mon Sep 17 00:00:00 2001 From: David Kershner Date: Thu, 4 Jun 2015 09:22:46 -0400 Subject: [PATCH 0861/1163] staging: unisys: Clean up diag_serverity enum Get rid of unused values in the enum. Signed-off-by: David Kershner Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/diagchannel.h | 32 ++++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/drivers/staging/unisys/include/diagchannel.h b/drivers/staging/unisys/include/diagchannel.h index 82932c53f5c6..d2d35685d69f 100644 --- a/drivers/staging/unisys/include/diagchannel.h +++ b/drivers/staging/unisys/include/diagchannel.h @@ -16,36 +16,28 @@ #ifndef _DIAG_CHANNEL_H_ #define _DIAG_CHANNEL_H_ -#include - #define MAX_MODULE_NAME_SIZE 128 /* Maximum length of module name... */ -#define MAX_ADDITIONAL_INFO_SIZE 256 /* Maximum length of any additional info - * accompanying event... +#define MAX_ADDITIONAL_INFO_SIZE 256 /* Maximum length of any additional + * info accompanying event... */ /* Levels of severity for diagnostic events, in order from lowest severity to -* highest (i.e. fatal errors are the most severe, and should always be logged, -* but info events rarely need to be logged except during debugging). The values -* DIAG_SEVERITY_ENUM_BEGIN and DIAG_SEVERITY_ENUM_END are not valid severity -* values. They exist merely to dilineate the list, so that future additions -* won't require changes to the driver (i.e. when checking for out-of-range -* severities in SetSeverity). The values DIAG_SEVERITY_OVERRIDE and -* DIAG_SEVERITY_SHUTOFF are not valid severity values for logging events but -* they are valid for controlling the amount of event data. This enum is also -* defined in DotNet\sParFramework\ControlFramework\ControlFramework.cs. If a -* change is made to this enum, they should also be reflected in that file. */ + * highest (i.e. fatal errors are the most severe, and should always be logged, + * but info events rarely need to be logged except during debugging). The + * values DIAG_SEVERITY_ENUM_BEGIN and DIAG_SEVERITY_ENUM_END are not valid + * severity values. They exist merely to dilineate the list, so that future + * additions won't require changes to the driver (i.e. when checking for + * out-of-range severities in SetSeverity). The values DIAG_SEVERITY_OVERRIDE + * and DIAG_SEVERITY_SHUTOFF are not valid severity values for logging events + * but they are valid for controlling the amount of event data. Changes made + * to the enum, need to be reflected in s-Par. + */ enum diag_severity { - DIAG_SEVERITY_ENUM_BEGIN = 0, - DIAG_SEVERITY_OVERRIDE = 0, DIAG_SEVERITY_VERBOSE = 0, DIAG_SEVERITY_INFO = 1, DIAG_SEVERITY_WARNING = 2, DIAG_SEVERITY_ERR = 3, - DIAG_SEVERITY_NONFATAL_ERR = 3, DIAG_SEVERITY_PRINT = 4, - DIAG_SEVERITY_FATAL_ERR = 4, - DIAG_SEVERITY_SHUTOFF = 5, - DIAG_SEVERITY_ENUM_END = 5 }; #endif From 75439a17d4e82f630a86b4ca07a6d38ca6fbaa21 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Thu, 4 Jun 2015 09:22:47 -0400 Subject: [PATCH 0862/1163] staging: unisys: Fix double sysfs create for module version When we combined visorchipset and visorbus into one driver we negelected to strip out some of the MODULE_ stuff from one of the files. When building the drivers in, it causes a WARN that we try to create /proc/modules/visorbus/version when it is already created. visorchipset.c is the driver entry point, remove the cruft from visorbus_main.c. Signed-off-by: Don Zickus Signed-off-by: David Kershner Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorbus_main.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 688bd8494fe4..22c6150f543e 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -1531,8 +1531,3 @@ MODULE_PARM_DESC(visorbus_forcenomatch, module_param_named(debugref, visorbus_debugref, int, S_IRUGO); MODULE_PARM_DESC(visorbus_debugref, "1 to debug reference counting"); - -MODULE_AUTHOR("Unisys"); -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("Supervisor bus driver for service partition: ver " VERSION); -MODULE_VERSION(VERSION); From 04dacacc14b4d60d58725c14f066a052cee6ff02 Mon Sep 17 00:00:00 2001 From: Don Zickus Date: Thu, 4 Jun 2015 09:22:48 -0400 Subject: [PATCH 0863/1163] staging: unisys: Fix clean up path When unloading a module, we need to cleanup the platform registration. However, unregistering the platform uncovered a couple of quirks, namely a missing device_release function. Fix things up so module unload works and allows us to reload the module. Signed-off-by: Don Zickus Signed-off-by: David Kershner Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorbus_main.c | 2 +- drivers/staging/unisys/visorbus/visorchipset.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 22c6150f543e..dcce1f02d54d 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -320,7 +320,7 @@ devmajorminor_remove_file(struct visor_device *dev, int slot) if (slot < 0 || slot >= maxdevnodes) return; myattr = (struct devmajorminor_attribute *)(dev->devnodes[slot].attr); - if (myattr) + if (!myattr) return; sysfs_remove_file(&dev->kobjdevmajorminor, &myattr->attr); kobject_uevent(&dev->device.kobj, KOBJ_OFFLINE); diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 90a3c30c9701..99fa96e80e1e 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -331,11 +331,16 @@ static const struct attribute_group *visorchipset_dev_groups[] = { NULL }; +static void visorchipset_dev_release(struct device *dev) +{ +} + /* /sys/devices/platform/visorchipset */ static struct platform_device visorchipset_platform_device = { .name = "visorchipset", .id = -1, .dev.groups = visorchipset_dev_groups, + .dev.release = visorchipset_dev_release, }; /* Function prototypes */ @@ -2355,6 +2360,7 @@ visorchipset_exit(struct acpi_device *acpi_device) visorchannel_destroy(controlvm_channel); visorchipset_file_cleanup(visorchipset_platform_device.dev.devt); + platform_device_unregister(&visorchipset_platform_device); POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO); return 0; From 4abce83dca116e2d0b49e1601bff2983e6cf0491 Mon Sep 17 00:00:00 2001 From: David Kershner Date: Thu, 4 Jun 2015 09:22:49 -0400 Subject: [PATCH 0864/1163] staging: unisys: Add the bus device to the visor device list. When the bus device was created the list_all variables were not being initialized. When the CONTROLVM_BUS_CONFIGURE message was being sent, it was failing to find the bus and produced a panic. Initialize the bus_info->list_all variable by doing a INIT_LIST_HEAD. Signed-off-by: David Kershner Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchipset.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 99fa96e80e1e..cf35d9d3a9bc 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -1107,6 +1107,7 @@ bus_create(struct controlvm_message *inmsg) goto cleanup; } + INIT_LIST_HEAD(&bus_info->list_all); bus_info->chipset_bus_no = bus_no; bus_info->chipset_dev_no = BUS_ROOT_DEVICE; From 05871f994e326fb3d95b34575b311c832ba4ccea Mon Sep 17 00:00:00 2001 From: Prasanna Karthik Date: Thu, 4 Jun 2015 04:48:51 +0000 Subject: [PATCH 0865/1163] staging:rtl8712:Fix compressed return statement Fix reported by coccinelle compressing last two lines with single return call Signed-off-by: Prasanna Karthik Acked-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_sta_mgt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_sta_mgt.c b/drivers/staging/rtl8712/rtl871x_sta_mgt.c index a9b93d0f6f56..6ae8cdc1bfd1 100644 --- a/drivers/staging/rtl8712/rtl871x_sta_mgt.c +++ b/drivers/staging/rtl8712/rtl871x_sta_mgt.c @@ -270,12 +270,10 @@ void r8712_init_bcmc_stainfo(struct _adapter *padapter) struct sta_info *r8712_get_bcmc_stainfo(struct _adapter *padapter) { - struct sta_info *psta; struct sta_priv *pstapriv = &padapter->stapriv; u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - psta = r8712_get_stainfo(pstapriv, bc_addr); - return psta; + return r8712_get_stainfo(pstapriv, bc_addr); } From 6ed977428a7e46f860f3e7a2d878dc8dd023202b Mon Sep 17 00:00:00 2001 From: Yijing Wang Date: Fri, 5 Jun 2015 14:04:59 +0800 Subject: [PATCH 0866/1163] staging: rts5208: Use common pci_get_bus_and_slot() instead of private one We already have a inline pci_get_bus_and_slot() in include/linux/pci.h, Use it instead of local one. Signed-off-by: Yijing Wang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/rts5208/rtsx.h b/drivers/staging/rts5208/rtsx.h index aa1e034f7f45..1396263e13e6 100644 --- a/drivers/staging/rts5208/rtsx.h +++ b/drivers/staging/rts5208/rtsx.h @@ -48,9 +48,6 @@ #define CR_DRIVER_NAME "rts5208" -#define pci_get_bus_and_slot(bus, devfn) \ - pci_get_domain_bus_and_slot(0, (bus), (devfn)) - /* * macros for easy use */ From ed701c4ab2b9719851a97e841907fec283d6a2bb Mon Sep 17 00:00:00 2001 From: Hari Prasath Gujulan Elango Date: Mon, 1 Jun 2015 12:43:01 +0000 Subject: [PATCH 0867/1163] staging: rtl8188eu: use table to get channel plan from country code Use a table to get a channel plan from a given country code.This was a TODO mentioned as a comment in the driver. Signed-off-by: Hari Prasath Gujulan Elango Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/core/rtw_ioctl_set.c | 19 ++++++++----------- .../staging/rtl8188eu/include/rtw_mlme_ext.h | 8 ++++++++ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c index 969150a48661..8c05cb021c46 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c @@ -642,21 +642,18 @@ u16 rtw_get_cur_max_rate(struct adapter *adapter) */ int rtw_set_country(struct adapter *adapter, const char *country_code) { + int i; int channel_plan = RT_CHANNEL_DOMAIN_WORLD_WIDE_5G; DBG_88E("%s country_code:%s\n", __func__, country_code); + for (i = 0; i < ARRAY_SIZE(channel_table); i++) { + if (0 == strcmp(channel_table[i].name, country_code)) { + channel_plan = channel_table[i].channel_plan; + break; + } + } - /* TODO: should have a table to match country code and RT_CHANNEL_DOMAIN */ - /* TODO: should consider 2-character and 3-character country code */ - if (0 == strcmp(country_code, "US")) - channel_plan = RT_CHANNEL_DOMAIN_FCC; - else if (0 == strcmp(country_code, "EU")) - channel_plan = RT_CHANNEL_DOMAIN_ETSI; - else if (0 == strcmp(country_code, "JP")) - channel_plan = RT_CHANNEL_DOMAIN_MKK; - else if (0 == strcmp(country_code, "CN")) - channel_plan = RT_CHANNEL_DOMAIN_CHINA; - else + if (i == ARRAY_SIZE(channel_table)) DBG_88E("%s unknown country_code:%s\n", __func__, country_code); return rtw_set_chplan_cmd(adapter, channel_plan, 1); diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h index 2bebf46b053a..2bd11acb4c03 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -191,6 +191,14 @@ struct rt_channel_plan_map { unsigned char Index2G; }; +static const struct { + int channel_plan; + char *name; +} channel_table[] = { { RT_CHANNEL_DOMAIN_FCC, "US" }, + { RT_CHANNEL_DOMAIN_ETSI, "EU" }, + { RT_CHANNEL_DOMAIN_MKK, "JP" }, + { RT_CHANNEL_DOMAIN_CHINA, "CN"} }; + enum Associated_AP { atherosAP = 0, broadcomAP = 1, From f57d0b6bafbd0406825772d2e04fabd738a89d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bu=C5=A3iu=20Alexandru=20Octavian?= Date: Mon, 1 Jun 2015 16:05:06 +0300 Subject: [PATCH 0868/1163] staging: drivers: rtl8192u: r819xU_firmware.h: removed commented macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed commented macro that was no longer needed Signed-off-by: Buţiu Alexandru Octavian Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_firmware.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_firmware.h b/drivers/staging/rtl8192u/r819xU_firmware.h index cfa222350a9a..d6a022470317 100644 --- a/drivers/staging/rtl8192u/r819xU_firmware.h +++ b/drivers/staging/rtl8192u/r819xU_firmware.h @@ -2,15 +2,7 @@ #define __INC_FIRMWARE_H #define RTL8190_CPU_START_OFFSET 0x80 -/* TODO: this definition is TBD */ -//#define USB_HWDESC_HEADER_LEN 0 - -/* It should be double word alignment */ -//#if DEV_BUS_TYPE==PCI_INTERFACE -//#define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) 4*(v/4) - 8 -//#else #define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) (4*(v/4) - 8 - USB_HWDESC_HEADER_LEN) -//#endif typedef enum _firmware_init_step { FW_INIT_STEP0_BOOT = 0, From c938699ebb92918afe66776bb6d69277aea86507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bu=C5=A3iu=20Alexandru=20Octavian?= Date: Mon, 1 Jun 2015 16:05:07 +0300 Subject: [PATCH 0869/1163] staging: rtl8192u: r819xU_firmware.h: fix line over 80 characters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed coding style issue line "over 80 characters" detected by checkpatch.pl in r819xU_firmware.h Signed-off-by: Buţiu Alexandru Octavian Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_firmware.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/r819xU_firmware.h b/drivers/staging/rtl8192u/r819xU_firmware.h index d6a022470317..24b63f2ec509 100644 --- a/drivers/staging/rtl8192u/r819xU_firmware.h +++ b/drivers/staging/rtl8192u/r819xU_firmware.h @@ -2,7 +2,8 @@ #define __INC_FIRMWARE_H #define RTL8190_CPU_START_OFFSET 0x80 -#define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) (4*(v/4) - 8 - USB_HWDESC_HEADER_LEN) +#define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) \ + (4*(v/4) - 8 - USB_HWDESC_HEADER_LEN) typedef enum _firmware_init_step { FW_INIT_STEP0_BOOT = 0, From ba470f7c0e9f4a71a915a48392e69f56ce7edbf9 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 2 Jun 2015 15:20:25 +0300 Subject: [PATCH 0870/1163] staging: ozwpan: prevent a couple of underflows The underflow in OZ_DATA_F_ISOC_FIXED seems not harmful, but this patch is a clean up and makes my static checker a bit happier. The underflow in OZ_VENDOR_CLASS_RSP seems like it could result in memory corruption. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozusbsvc1.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/staging/ozwpan/ozusbsvc1.c b/drivers/staging/ozwpan/ozusbsvc1.c index f660bb198c65..301fee8625ed 100644 --- a/drivers/staging/ozwpan/ozusbsvc1.c +++ b/drivers/staging/ozwpan/ozusbsvc1.c @@ -342,12 +342,16 @@ static void oz_usb_handle_ep_data(struct oz_usb_ctx *usb_ctx, case OZ_DATA_F_ISOC_FIXED: { struct oz_isoc_fixed *body = (struct oz_isoc_fixed *)data_hdr; - int data_len = len-sizeof(struct oz_isoc_fixed)+1; + int data_len; int unit_size = body->unit_size; u8 *data = body->data; int count; int i; + if (len < sizeof(struct oz_isoc_fixed) - 1) + break; + data_len = len - (sizeof(struct oz_isoc_fixed) - 1); + if (!unit_size) break; count = data_len/unit_size; @@ -427,6 +431,11 @@ void oz_usb_rx(struct oz_pd *pd, struct oz_elt *elt) case OZ_VENDOR_CLASS_RSP: { struct oz_vendor_class_rsp *body = (struct oz_vendor_class_rsp *)usb_hdr; + + if (elt->length < + sizeof(struct oz_vendor_class_rsp) - 1) + break; + oz_hcd_control_cnf(usb_ctx->hport, body->req_id, body->rcode, body->data, elt->length- sizeof(struct oz_vendor_class_rsp)+1); From 2bd239d70e69425b858bba10e45d41f5a9a16b2b Mon Sep 17 00:00:00 2001 From: Tolga Ceylan Date: Tue, 2 Jun 2015 09:08:35 -0700 Subject: [PATCH 0871/1163] staging: rtl8192u/ieee80211/ieee80211_softmac.c: auth parse error code byte order fix auth_parse() return result is in incorrect le16 byte order. Currently this still works since the user code merely checks if error code is equal to 0. However debug statement in ieee80211_check_auth_response() prints the error code in the incorrect le16 byte order. This fix corrects the byte order as cpu order. Signed-off-by: Tolga Ceylan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index e08ef100d9d0..5bba968da25b 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -1556,7 +1556,7 @@ static inline u16 auth_parse(struct sk_buff *skb, u8 **challenge, int *chlen) } } - return cpu_to_le16(a->status); + return le16_to_cpu(a->status); } From bf95628e61c373f2e614b507718fa90b7490fbdb Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Tue, 2 Jun 2015 15:06:18 -0300 Subject: [PATCH 0872/1163] staging: rtl8192u: ieee80211: Fix sparse endianness warnings Fix the following sparse warnings: drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:663:32: warning: incorrect type in assignment (different base types) drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:663:32: expected restricted __le16 [usertype] frame_ctl drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:663:32: got int drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:664:50: warning: invalid assignment: |= drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:664:50: left side has type restricted __le16 drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:664:50: right side has type int Signed-off-by: Gaston Gonzalez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 5bba968da25b..b00f5fd31abf 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -660,8 +660,11 @@ inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *be auth = (struct ieee80211_authentication *) skb_put(skb, sizeof(struct ieee80211_authentication)); - auth->header.frame_ctl = IEEE80211_STYPE_AUTH; - if (challengelen) auth->header.frame_ctl |= IEEE80211_FCTL_WEP; + if (challengelen) + auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH + | IEEE80211_FCTL_WEP); + else + auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); auth->header.duration_id = 0x013a; //FIXME From 251ae75c69c427149ab0f70b12a436144edd81b1 Mon Sep 17 00:00:00 2001 From: Pedro Marzo Perez Date: Wed, 3 Jun 2015 01:28:38 +0200 Subject: [PATCH 0873/1163] Staging: rtl8192u: Simplify error check code at prism2_wep_init Simplify prism2_wep_init error check code employing goto when a failure is detected. Removed pr_debug which was given a checkpatch.pl error because of literal string splitted across two lines of code, it was seldom going to be printed anyway. Signed-off-by: Pedro Marzo Perez Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/ieee80211_crypt_wep.c | 32 ++++++------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c index 26f2fb15e2a3..651bd6517eae 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c @@ -43,38 +43,24 @@ static void *prism2_wep_init(int keyidx) priv = kzalloc(sizeof(*priv), GFP_ATOMIC); if (priv == NULL) - goto fail; + return NULL; priv->key_idx = keyidx; priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); - if (IS_ERR(priv->tx_tfm)) { - pr_debug("ieee80211_crypt_wep: could not allocate " - "crypto API arc4\n"); - priv->tx_tfm = NULL; - goto fail; - } + if (IS_ERR(priv->tx_tfm)) + goto free_priv; priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); - if (IS_ERR(priv->rx_tfm)) { - pr_debug("ieee80211_crypt_wep: could not allocate " - "crypto API arc4\n"); - priv->rx_tfm = NULL; - goto fail; - } + if (IS_ERR(priv->rx_tfm)) + goto free_tx; /* start WEP IV from a random value */ get_random_bytes(&priv->iv, 4); return priv; - -fail: - if (priv) { - if (priv->tx_tfm) - crypto_free_blkcipher(priv->tx_tfm); - if (priv->rx_tfm) - crypto_free_blkcipher(priv->rx_tfm); - kfree(priv); - } - +free_tx: + crypto_free_blkcipher(priv->tx_tfm); +free_priv: + kfree(priv); return NULL; } From c1ab2fa969aed60851264bcb904326db99bfd3fd Mon Sep 17 00:00:00 2001 From: Pedro Marzo Perez Date: Wed, 3 Jun 2015 01:28:39 +0200 Subject: [PATCH 0874/1163] Staging: rtl8192u: Remove two useless lines at ieee80211_wep_null Remove two lines at ieee80211_wep_null which checkpatch.pl reported as errors. The first one because it has a C99 comment style and the second one because it is a void return which is useless. The function ieee80211_wep_null cannot be completely removed because it is exported and used to autoload the module. Signed-off-by: Pedro Marzo Perez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c index 651bd6517eae..681611dc93d3 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c @@ -276,6 +276,4 @@ void __exit ieee80211_crypto_wep_exit(void) void ieee80211_wep_null(void) { -// printk("============>%s()\n", __func__); - return; } From 669adbe6c9cb5414412fc2d0a6a4e3d844fa071f Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Tue, 2 Jun 2015 22:48:05 +0200 Subject: [PATCH 0875/1163] staging: rtl8192e: Remove dead code Delete unused code. Removed some macros, enums, unions and several structures (tx_fwinfo, wmm_tspec, qos_tstream, sta_qos, bss_qos). Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192e/rtl8192e/r8190P_def.h | 40 ---- .../rtl8192e/rtl8192e/r8192E_firmware.h | 5 - .../staging/rtl8192e/rtl8192e/r8192E_hwimg.h | 6 - drivers/staging/rtl8192e/rtl8192e/rtl_cam.h | 1 - drivers/staging/rtl8192e/rtl8192e/rtl_wx.h | 4 - drivers/staging/rtl8192e/rtl819x_Qos.h | 194 ------------------ 6 files changed, 250 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/r8190P_def.h b/drivers/staging/rtl8192e/rtl8192e/r8190P_def.h index b7bb71fa9ecd..d0b08301b88f 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8190P_def.h +++ b/drivers/staging/rtl8192e/rtl8192e/r8190P_def.h @@ -144,19 +144,6 @@ enum rf_optype { RF_OP_MAX }; - -enum power_save_mode { - POWER_SAVE_MODE_ACTIVE, - POWER_SAVE_MODE_SAVE, -}; - -enum interface_select_8190pci { - INTF_SEL1_MINICARD = 0, - INTF_SEL0_PCIE = 1, - INTF_SEL2_RSV = 2, - INTF_SEL3_RSV = 3, -}; - struct bb_reg_definition { u32 rfintfs; u32 rfintfi; @@ -178,33 +165,6 @@ struct bb_reg_definition { u32 rfLSSIReadBackPi; }; -struct tx_fwinfo { - u8 TxRate:7; - u8 CtsEnable:1; - u8 RtsRate:7; - u8 RtsEnable:1; - u8 TxHT:1; - u8 Short:1; - u8 TxBandwidth:1; - u8 TxSubCarrier:2; - u8 STBC:2; - u8 AllowAggregation:1; - u8 RtsHT:1; - u8 RtsShort:1; - u8 RtsBandwidth:1; - u8 RtsSubcarrier:2; - u8 RtsSTBC:2; - u8 EnableCPUDur:1; - - u32 RxMF:2; - u32 RxAMD:3; - u32 Reserved1:3; - u32 TxAGCOffset:4; - u32 TxAGCSign:1; - u32 Tx_INFO_RSVD:6; - u32 PacketID:13; -}; - struct tx_fwinfo_8190pci { u8 TxRate:7; u8 CtsEnable:1; diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.h b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.h index 94fa16b4993d..d79e54203199 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.h +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.h @@ -52,11 +52,6 @@ enum firmware_status { FW_STATUS_5_READY = 5, }; -struct fw_seg_container { - u16 seg_size; - u8 *seg_ptr; -}; - struct rt_firmware { enum firmware_status firmware_status; u16 cmdpacket_frag_thresold; diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_hwimg.h b/drivers/staging/rtl8192e/rtl8192e/r8192E_hwimg.h index d804876dd92f..5bd3b3530aa6 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_hwimg.h +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_hwimg.h @@ -23,12 +23,6 @@ #include -#define BootArrayLengthPciE 344 -extern u8 Rtl8192PciEFwBootArray[BootArrayLengthPciE]; -#define MainArrayLengthPciE 43012 -extern u8 Rtl8192PciEFwMainArray[MainArrayLengthPciE]; -#define DataArrayLengthPciE 848 -extern u8 Rtl8192PciEFwDataArray[DataArrayLengthPciE]; #define PHY_REGArrayLengthPciE 1 extern u32 Rtl8192PciEPHY_REGArray[PHY_REGArrayLengthPciE]; #define PHY_REG_1T2RArrayLengthPciE 296 diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h index 864a7f607bca..ec77bf8efda5 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h @@ -34,7 +34,6 @@ void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent); void set_swcam(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh); -void CamPrintDbgReg(struct net_device *dev); u32 read_cam(struct net_device *dev, u8 addr); void write_cam(struct net_device *dev, u8 addr, u32 data); diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.h b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.h index 58398517f5b3..771284019e08 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.h @@ -20,11 +20,7 @@ #ifndef R819x_WX_H #define R819x_WX_H -struct net_device; struct iw_handler_def; -struct iw_statistics; extern const struct iw_handler_def r8192_wx_handlers_def; -u16 rtl8192_11n_user_show_rates(struct net_device *dev); - #endif diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index b3e7dae982a7..3aa35ced2b8b 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -91,122 +91,22 @@ union tspec_body { } f; }; -struct wmm_tspec { - u8 ID; - u8 Length; - u8 OUI[3]; - u8 OUI_Type; - u8 OUI_SubType; - u8 Version; - union tspec_body Body; -}; - struct octet_string { u8 *Octet; u16 Length; }; -#define MAX_WMMELE_LENGTH 64 - -#define QOS_MODE u32 - -#define QOS_DISABLE 0 -#define QOS_WMM 1 -#define QOS_WMMSA 2 -#define QOS_EDCA 4 -#define QOS_HCCA 8 -#define QOS_WMM_UAPSD 16 - -#define WMM_PARAM_ELE_BODY_LEN 18 - -#define MAX_STA_TS_COUNT 16 -#define MAX_AP_TS_COUNT 32 -#define QOS_TSTREAM_KEY_SIZE 13 - -#define WMM_ACTION_CATEGORY_CODE 17 -#define WMM_PARAM_ELE_BODY_LEN 18 - -#define MAX_TSPEC_TSID 15 -#define SESSION_REJECT_TSID 0xfe -#define DEFAULT_TSID 0xff - -#define ADDTS_TIME_SLOT 100 - -#define ACM_TIMEOUT 1000 -#define SESSION_REJECT_TIMEOUT 60000 - enum ack_policy { eAckPlc0_ACK = 0x00, eAckPlc1_NoACK = 0x01, }; - -#define SET_WMM_QOS_INFO_FIELD(_pStart, _val) \ - WriteEF1Byte(_pStart, _val) - -#define GET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart) \ - LE_BITS_TO_1BYTE(_pStart, 0, 4) -#define SET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart, _val) \ - SET_BITS_TO_LE_1BYTE(_pStart, 0, 4, _val) - -#define GET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart) \ - LE_BITS_TO_1BYTE(_pStart, 7, 1) -#define SET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart, _val) \ - SET_BITS_TO_LE_1BYTE(_pStart, 7, 1, _val) - -#define GET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart) \ - LE_BITS_TO_1BYTE(_pStart, 0, 1) -#define SET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart, _val) \ - SET_BITS_TO_LE_1BYTE(_pStart, 0, 1, _val) - -#define GET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart) \ - LE_BITS_TO_1BYTE(_pStart, 1, 1) -#define SET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart, _val) \ - SET_BITS_TO_LE_1BYTE(_pStart, 1, 1, _val) - -#define GET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart) \ - LE_BITS_TO_1BYTE(_pStart, 2, 1) -#define SET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart, _val) \ - SET_BITS_TO_LE_1BYTE(_pStart, 2, 1, _val) - -#define GET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart) \ - LE_BITS_TO_1BYTE(_pStart, 3, 1) -#define SET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart, _val) \ - SET_BITS_TO_LE_1BYTE(_pStart, 3, 1, _val) - -#define GET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart) \ - LE_BITS_TO_1BYTE(_pStart, 5, 2) -#define SET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart, _val) \ - SET_BITS_TO_LE_1BYTE(_pStart, 5, 2, _val) - -enum qos_ie_source { - QOSIE_SRC_ADDTSREQ, - QOSIE_SRC_ADDTSRSP, - QOSIE_SRC_REASOCREQ, - QOSIE_SRC_REASOCRSP, - QOSIE_SRC_DELTS, -}; - - -#define AC_CODING u32 - #define AC0_BE 0 #define AC1_BK 1 #define AC2_VI 2 #define AC3_VO 3 #define AC_MAX 4 - -#define AC_PARAM_SIZE 4 - -#define WMM_PARAM_ELEMENT_SIZE (8+(4*AC_PARAM_SIZE)) - -enum qos_ele_subtype { - QOSELE_TYPE_INFO = 0x00, - QOSELE_TYPE_PARAM = 0x01, -}; - - enum direction_value { DIR_UP = 0, DIR_DOWN = 1, @@ -227,22 +127,6 @@ struct acm { u8 HwAcmCtl; }; - - -#define AC_UAPSD u8 - -#define GET_VO_UAPSD(_apsd) ((_apsd) & BIT0) -#define SET_VO_UAPSD(_apsd) ((_apsd) |= BIT0) - -#define GET_VI_UAPSD(_apsd) ((_apsd) & BIT1) -#define SET_VI_UAPSD(_apsd) ((_apsd) |= BIT1) - -#define GET_BK_UAPSD(_apsd) ((_apsd) & BIT2) -#define SET_BK_UAPSD(_apsd) ((_apsd) |= BIT2) - -#define GET_BE_UAPSD(_apsd) ((_apsd) & BIT3) -#define SET_BE_UAPSD(_apsd) ((_apsd) |= BIT3) - union qos_tclas { struct _TYPE_GENERAL { @@ -294,65 +178,6 @@ union qos_tclas { } TYPE2_8021Q; }; -struct qos_tstream { - - bool bUsed; - u16 MsduLifetime; - bool bEstablishing; - u8 TimeSlotCount; - u8 DialogToken; - struct wmm_tspec TSpec; - struct wmm_tspec OutStandingTSpec; - u8 NominalPhyRate; -}; - -struct sta_qos { - u8 WMMIEBuf[MAX_WMMELE_LENGTH]; - u8 *WMMIE; - - QOS_MODE QosCapability; - QOS_MODE CurrentQosMode; - - AC_UAPSD b4ac_Uapsd; - AC_UAPSD Curr4acUapsd; - u8 bInServicePeriod; - u8 MaxSPLength; - int NumBcnBeforeTrigger; - - u8 *pWMMInfoEle; - u8 WMMParamEle[WMM_PARAM_ELEMENT_SIZE]; - - struct acm acm[4]; - enum acm_method AcmMethod; - - struct qos_tstream StaTsArray[MAX_STA_TS_COUNT]; - u8 DialogToken; - struct wmm_tspec TSpec; - - u8 QBssWirelessMode; - - bool bNoAck; - - bool bEnableRxImmBA; - -}; - -#define QBSS_LOAD_SIZE 5 - -struct bss_qos { - QOS_MODE bdQoSMode; - u8 bdWMMIEBuf[MAX_WMMELE_LENGTH]; - struct octet_string bdWMMIE; - - enum qos_ele_subtype EleSubType; - - u8 *pWMMInfoEle; - u8 *pWMMParamEle; - - u8 QBssLoad[QBSS_LOAD_SIZE]; - bool bQBssLoadValid; -}; - #define IsACValid(ac) ((ac >= 0 && ac <= 7) ? true : false) @@ -367,23 +192,4 @@ union aci_aifsn { } f; }; -union ecw { - u8 charData; - struct { - u8 ECWmin:4; - u8 ECWmax:4; - } f; -}; - -union ac_param { - u32 longData; - u8 charData[4]; - - struct { - union aci_aifsn AciAifsn; - union ecw Ecw; - u16 TXOPLimit; - } f; -}; - #endif From e8fdea21e167f2f7ddc8c42b967a261f55482626 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Tue, 2 Jun 2015 22:48:06 +0200 Subject: [PATCH 0876/1163] staging: rtl8192e: Remove dead code: cmpk_handle_query_config_rx() Remove cmpk_handle_query_config_rx function. It is called once, does some calculation, but generates no output - it has neither return value, nor modify its parameters. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c index ecdd2e5c6bac..53676a60ca7c 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c @@ -198,23 +198,6 @@ static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg) } -static void cmpk_handle_query_config_rx(struct net_device *dev, u8 *pmsg) -{ - cmpk_query_cfg_t rx_query_cfg; - - - rx_query_cfg.cfg_action = (pmsg[4] & 0x80000000)>>31; - rx_query_cfg.cfg_type = (pmsg[4] & 0x60) >> 5; - rx_query_cfg.cfg_size = (pmsg[4] & 0x18) >> 3; - rx_query_cfg.cfg_page = (pmsg[6] & 0x0F) >> 0; - rx_query_cfg.cfg_offset = pmsg[7]; - rx_query_cfg.value = (pmsg[8] << 24) | (pmsg[9] << 16) | - (pmsg[10] << 8) | (pmsg[11] << 0); - rx_query_cfg.mask = (pmsg[12] << 24) | (pmsg[13] << 16) | - (pmsg[14] << 8) | (pmsg[15] << 0); - -} - static void cmpk_count_tx_status(struct net_device *dev, struct cmpk_tx_status *pstx_status) { @@ -346,7 +329,6 @@ u32 cmpk_message_handle_rx(struct net_device *dev, case BOTH_QUERY_CONFIG: RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():BOTH_QUERY_CONFIG\n"); - cmpk_handle_query_config_rx(dev, pcmd_buff); cmd_length = CMPK_BOTH_QUERY_CONFIG_SIZE; break; case RX_TX_STATUS: From 0ac3bb4ef489487027a5e87253d9e342f734c440 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Tue, 2 Jun 2015 22:48:07 +0200 Subject: [PATCH 0877/1163] staging: rtl8192e: Remove dead code: cmpk_message_handle_rx() Remove cmpk_message_handle_rx() and static functions used by it. This function was never called. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c | 272 ------------------ .../staging/rtl8192e/rtl8192e/r8192E_cmdpkt.h | 134 --------- 2 files changed, 406 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c index 53676a60ca7c..ebd08a16685e 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c @@ -88,275 +88,3 @@ bool cmpk_message_handle_tx( Failed: return rt_status; } - -static void -cmpk_count_txstatistic( - struct net_device *dev, - struct cmpk_txfb *pstx_fb) -{ - struct r8192_priv *priv = rtllib_priv(dev); -#ifdef ENABLE_PS - enum rt_rf_power_state rtState; - - pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, - (pu1Byte)(&rtState)); - - if (rtState == eRfOff) - return; -#endif - - if (pstx_fb->tok) { - priv->stats.txfeedbackok++; - priv->stats.txoktotal++; - priv->stats.txokbytestotal += pstx_fb->pkt_length; - priv->stats.txokinperiod++; - - if (pstx_fb->pkt_type == PACKET_MULTICAST) { - priv->stats.txmulticast++; - priv->stats.txbytesmulticast += pstx_fb->pkt_length; - } else if (pstx_fb->pkt_type == PACKET_BROADCAST) { - priv->stats.txbroadcast++; - priv->stats.txbytesbroadcast += pstx_fb->pkt_length; - } else { - priv->stats.txunicast++; - priv->stats.txbytesunicast += pstx_fb->pkt_length; - } - } else { - priv->stats.txfeedbackfail++; - priv->stats.txerrtotal++; - priv->stats.txerrbytestotal += pstx_fb->pkt_length; - - if (pstx_fb->pkt_type == PACKET_MULTICAST) - priv->stats.txerrmulticast++; - else if (pstx_fb->pkt_type == PACKET_BROADCAST) - priv->stats.txerrbroadcast++; - else - priv->stats.txerrunicast++; - } - - priv->stats.txretrycount += pstx_fb->retry_cnt; - priv->stats.txfeedbackretry += pstx_fb->retry_cnt; -} - -static void cmpk_handle_tx_feedback(struct net_device *dev, u8 *pmsg) -{ - struct r8192_priv *priv = rtllib_priv(dev); - struct cmpk_txfb rx_tx_fb; - - priv->stats.txfeedback++; - - - memcpy((u8 *)&rx_tx_fb, pmsg, sizeof(struct cmpk_txfb)); - cmpk_count_txstatistic(dev, &rx_tx_fb); -} - -static void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev) -{ - struct r8192_priv *priv = rtllib_priv(dev); - - if ((priv->rtllib->current_network.mode == IEEE_A) || - (priv->rtllib->current_network.mode == IEEE_N_5G) || - ((priv->rtllib->current_network.mode == IEEE_N_24G) && - (!priv->rtllib->pHTInfo->bCurSuppCCK))) - DMESG("send beacon frame tx rate is 6Mbpm\n"); - else - DMESG("send beacon frame tx rate is 1Mbpm\n"); -} - -static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg) -{ - struct cmpk_intr_sta rx_intr_status; - struct r8192_priv *priv = rtllib_priv(dev); - - DMESG("---> cmpk_Handle_Interrupt_Status()\n"); - - rx_intr_status.length = pmsg[1]; - if (rx_intr_status.length != (sizeof(struct cmpk_intr_sta) - 2)) { - DMESG("cmpk_Handle_Interrupt_Status: wrong length!\n"); - return; - } - - if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { - rx_intr_status.interrupt_status = *((u32 *)(pmsg + 4)); - - DMESG("interrupt status = 0x%x\n", - rx_intr_status.interrupt_status); - - if (rx_intr_status.interrupt_status & ISR_TxBcnOk) { - priv->rtllib->bibsscoordinator = true; - priv->stats.txbeaconokint++; - } else if (rx_intr_status.interrupt_status & ISR_TxBcnErr) { - priv->rtllib->bibsscoordinator = false; - priv->stats.txbeaconerr++; - } - - if (rx_intr_status.interrupt_status & ISR_BcnTimerIntr) - cmdpkt_beacontimerinterrupt_819xusb(dev); - } - - DMESG("<---- cmpk_handle_interrupt_status()\n"); - -} - -static void cmpk_count_tx_status(struct net_device *dev, - struct cmpk_tx_status *pstx_status) -{ - struct r8192_priv *priv = rtllib_priv(dev); - -#ifdef ENABLE_PS - - enum rt_rf_power_state rtstate; - - pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, - (pu1Byte)(&rtState)); - - if (rtState == eRfOff) - return; -#endif - - priv->stats.txfeedbackok += pstx_status->txok; - priv->stats.txoktotal += pstx_status->txok; - - priv->stats.txfeedbackfail += pstx_status->txfail; - priv->stats.txerrtotal += pstx_status->txfail; - - priv->stats.txretrycount += pstx_status->txretry; - priv->stats.txfeedbackretry += pstx_status->txretry; - - - priv->stats.txmulticast += pstx_status->txmcok; - priv->stats.txbroadcast += pstx_status->txbcok; - priv->stats.txunicast += pstx_status->txucok; - - priv->stats.txerrmulticast += pstx_status->txmcfail; - priv->stats.txerrbroadcast += pstx_status->txbcfail; - priv->stats.txerrunicast += pstx_status->txucfail; - - priv->stats.txbytesmulticast += pstx_status->txmclength; - priv->stats.txbytesbroadcast += pstx_status->txbclength; - priv->stats.txbytesunicast += pstx_status->txuclength; - - priv->stats.last_packet_rate = pstx_status->rate; -} - -static void cmpk_handle_tx_status(struct net_device *dev, u8 *pmsg) -{ - struct cmpk_tx_status rx_tx_sts; - - memcpy((void *)&rx_tx_sts, (void *)pmsg, sizeof(struct cmpk_tx_status)); - cmpk_count_tx_status(dev, &rx_tx_sts); -} - -static void cmpk_handle_tx_rate_history(struct net_device *dev, u8 *pmsg) -{ - struct cmpk_tx_rahis *ptxrate; - u8 i, j; - u16 length = sizeof(struct cmpk_tx_rahis); - u32 *ptemp; - struct r8192_priv *priv = rtllib_priv(dev); - -#ifdef ENABLE_PS - pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, - (pu1Byte)(&rtState)); - - if (rtState == eRfOff) - return; -#endif - - ptemp = (u32 *)pmsg; - - for (i = 0; i < (length / 4); i++) { - u16 temp1, temp2; - - temp1 = ptemp[i] & 0x0000FFFF; - temp2 = ptemp[i] >> 16; - ptemp[i] = (temp1 << 16) | temp2; - } - - ptxrate = (struct cmpk_tx_rahis *)pmsg; - - if (ptxrate == NULL) - return; - - for (i = 0; i < 16; i++) { - if (i < 4) - priv->stats.txrate.cck[i] += ptxrate->cck[i]; - - if (i < 8) - priv->stats.txrate.ofdm[i] += ptxrate->ofdm[i]; - - for (j = 0; j < 4; j++) - priv->stats.txrate.ht_mcs[j][i] += - ptxrate->ht_mcs[j][i]; - } -} - -u32 cmpk_message_handle_rx(struct net_device *dev, - struct rtllib_rx_stats *pstats) -{ - int total_length; - u8 cmd_length, exe_cnt = 0; - u8 element_id; - u8 *pcmd_buff; - - RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx()\n"); - - if (pstats == NULL) - return 0; - - total_length = pstats->Length; - - pcmd_buff = pstats->virtual_address; - - element_id = pcmd_buff[0]; - - while (total_length > 0 || exe_cnt++ > 100) { - element_id = pcmd_buff[0]; - - switch (element_id) { - case RX_TX_FEEDBACK: - RT_TRACE(COMP_CMDPKT, - "---->cmpk_message_handle_rx():RX_TX_FEEDBACK\n"); - cmpk_handle_tx_feedback(dev, pcmd_buff); - cmd_length = CMPK_RX_TX_FB_SIZE; - break; - case RX_INTERRUPT_STATUS: - RT_TRACE(COMP_CMDPKT, - "---->cmpk_message_handle_rx():RX_INTERRUPT_STATUS\n"); - cmpk_handle_interrupt_status(dev, pcmd_buff); - cmd_length = sizeof(struct cmpk_intr_sta); - break; - case BOTH_QUERY_CONFIG: - RT_TRACE(COMP_CMDPKT, - "---->cmpk_message_handle_rx():BOTH_QUERY_CONFIG\n"); - cmd_length = CMPK_BOTH_QUERY_CONFIG_SIZE; - break; - case RX_TX_STATUS: - RT_TRACE(COMP_CMDPKT, - "---->cmpk_message_handle_rx():RX_TX_STATUS\n"); - cmpk_handle_tx_status(dev, pcmd_buff); - cmd_length = CMPK_RX_TX_STS_SIZE; - break; - case RX_TX_PER_PKT_FEEDBACK: - RT_TRACE(COMP_CMDPKT, - "---->cmpk_message_handle_rx():RX_TX_PER_PKT_FEEDBACK\n"); - cmd_length = CMPK_RX_TX_FB_SIZE; - break; - case RX_TX_RATE_HISTORY: - RT_TRACE(COMP_CMDPKT, - "---->cmpk_message_handle_rx():RX_TX_HISTORY\n"); - cmpk_handle_tx_rate_history(dev, pcmd_buff); - cmd_length = CMPK_TX_RAHIS_SIZE; - break; - default: - - RT_TRACE(COMP_CMDPKT, - "---->cmpk_message_handle_rx():unknown CMD Element\n"); - return 1; - } - - total_length -= cmd_length; - pcmd_buff += cmd_length; - } - return 1; -} diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.h b/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.h index 2693682644df..f714d5100059 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.h +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.h @@ -18,142 +18,8 @@ ******************************************************************************/ #ifndef R819XUSB_CMDPKT_H #define R819XUSB_CMDPKT_H -#define CMPK_RX_TX_FB_SIZE sizeof(struct cmpk_txfb) -#define CMPK_TX_SET_CONFIG_SIZE sizeof(struct cmpk_set_cfg) -#define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(struct cmpk_set_cfg) -#define CMPK_RX_TX_STS_SIZE sizeof(struct cmpk_tx_status) -#define CMPK_RX_DBG_MSG_SIZE sizeof(struct cmpk_rx_dbginfo) -#define CMPK_TX_RAHIS_SIZE sizeof(struct cmpk_tx_rahis) -#define ISR_TxBcnOk BIT27 -#define ISR_TxBcnErr BIT26 -#define ISR_BcnTimerIntr BIT13 - - -struct cmpk_txfb { - u8 element_id; - u8 length; - u8 TID:4; - u8 fail_reason:3; - u8 tok:1; - u8 reserve1:4; - u8 pkt_type:2; - u8 bandwidth:1; - u8 qos_pkt:1; - - u8 reserve2; - u8 retry_cnt; - u16 pkt_id; - - u16 seq_num; - u8 s_rate; - u8 f_rate; - - u8 s_rts_rate; - u8 f_rts_rate; - u16 pkt_length; - - u16 reserve3; - u16 duration; -}; - -struct cmpk_intr_sta { - u8 element_id; - u8 length; - u16 reserve; - u32 interrupt_status; -}; - - -struct cmpk_set_cfg { - u8 element_id; - u8 length; - u16 reserve1; - u8 cfg_reserve1:3; - u8 cfg_size:2; - u8 cfg_type:2; - u8 cfg_action:1; - u8 cfg_reserve2; - u8 cfg_page:4; - u8 cfg_reserve3:4; - u8 cfg_offset; - u32 value; - u32 mask; -}; - -#define cmpk_query_cfg_t struct cmpk_set_cfg - -struct cmpk_tx_status { - u16 reserve1; - u8 length; - u8 element_id; - - u16 txfail; - u16 txok; - - u16 txmcok; - u16 txretry; - - u16 txucok; - u16 txbcok; - - u16 txbcfail; - u16 txmcfail; - - u16 reserve2; - u16 txucfail; - - u32 txmclength; - u32 txbclength; - u32 txuclength; - - u16 reserve3_23; - u8 reserve3_1; - u8 rate; -} __packed; - -struct cmpk_rx_dbginfo { - u16 reserve1; - u8 length; - u8 element_id; - - -}; - -struct cmpk_tx_rahis { - u8 element_id; - u8 length; - u16 reserved1; - - u16 cck[4]; - - u16 ofdm[8]; - - - - - - u16 ht_mcs[4][16]; - -} __packed; - -enum cmpk_element { - RX_TX_FEEDBACK = 0, - RX_INTERRUPT_STATUS = 1, - TX_SET_CONFIG = 2, - BOTH_QUERY_CONFIG = 3, - RX_TX_STATUS = 4, - RX_DBGINFO_FEEDBACK = 5, - RX_TX_PER_PKT_FEEDBACK = 6, - RX_TX_RATE_HISTORY = 7, - RX_CMD_ELE_MAX -}; - -extern u32 cmpk_message_handle_rx(struct net_device *dev, - struct rtllib_rx_stats *pstats); extern bool cmpk_message_handle_tx(struct net_device *dev, u8 *codevirtualaddress, u32 packettype, u32 buffer_len); - - #endif From e6d948a57dcb854e80b47e1f7cc9b09041f8a6c2 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Tue, 2 Jun 2015 22:48:08 +0200 Subject: [PATCH 0878/1163] staging: rtl8192e: Remove dead code: read/write_cam Both functions are never used. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_cam.c | 12 ------------ drivers/staging/rtl8192e/rtl8192e/rtl_cam.h | 4 ---- 2 files changed, 16 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c index 89c3d3318e51..f246222e5fc9 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c @@ -36,18 +36,6 @@ void CamResetAllEntry(struct net_device *dev) write_nic_dword(dev, RWCAM, ulcommand); } -void write_cam(struct net_device *dev, u8 addr, u32 data) -{ - write_nic_dword(dev, WCAMI, data); - write_nic_dword(dev, RWCAM, BIT31|BIT16|(addr&0xff)); -} - -u32 read_cam(struct net_device *dev, u8 addr) -{ - write_nic_dword(dev, RWCAM, 0x80000000|(addr&0xff)); - return read_nic_dword(dev, 0xa8); -} - void EnableHWSecurityConfig8192(struct net_device *dev) { u8 SECR_value = 0x0; diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h index ec77bf8efda5..f23ab46c77e7 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h @@ -34,10 +34,6 @@ void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent); void set_swcam(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh); - -u32 read_cam(struct net_device *dev, u8 addr); -void write_cam(struct net_device *dev, u8 addr, u32 data); - void CamRestoreAllEntry(struct net_device *dev); #endif From b81b6d2843b319608413de01284de8186a364eb9 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Tue, 2 Jun 2015 22:48:09 +0200 Subject: [PATCH 0879/1163] staging: rtl8192e: Remove unused macros/structures in rtl_core.h - Removed unused macros/enums/structures - Remove unused fields in r8192_priv Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 154 ------------------- 1 file changed, 154 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h index 6127e92d8b93..7d18d05039d2 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h @@ -68,74 +68,19 @@ #define DRV_AUTHOR "" #define DRV_VERSION "0014.0401.2010" -#define IS_HARDWARE_TYPE_819xP(_priv) \ - ((((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8190P) || \ - (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192E)) #define IS_HARDWARE_TYPE_8192SE(_priv) \ (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192SE) -#define IS_HARDWARE_TYPE_8192CE(_priv) \ - (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192CE) -#define IS_HARDWARE_TYPE_8192CU(_priv) \ - (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192CU) -#define IS_HARDWARE_TYPE_8192DE(_priv) \ - (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192DE) -#define IS_HARDWARE_TYPE_8192DU(_priv) \ - (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192DU) #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 RTL_MAX_SCAN_SIZE 128 - -#define RTL_RATE_MAX 30 - #define TOTAL_CAM_ENTRY 32 #define CAM_CONTENT_COUNT 8 -#ifndef BIT -#define BIT(_i) (1<<(_i)) -#endif - -#define IS_ADAPTER_SENDS_BEACON(dev) 0 - -#define HAL_MEMORY_MAPPED_IO_RANGE_8190PCI 0x1000 -#define HAL_HW_PCI_REVISION_ID_8190PCI 0x00 -#define HAL_MEMORY_MAPPED_IO_RANGE_8192PCIE 0x4000 #define HAL_HW_PCI_REVISION_ID_8192PCIE 0x01 -#define HAL_MEMORY_MAPPED_IO_RANGE_8192SE 0x4000 #define HAL_HW_PCI_REVISION_ID_8192SE 0x10 -#define HAL_HW_PCI_REVISION_ID_8192CE 0x1 -#define HAL_MEMORY_MAPPED_IO_RANGE_8192CE 0x4000 -#define HAL_HW_PCI_REVISION_ID_8192DE 0x0 -#define HAL_MEMORY_MAPPED_IO_RANGE_8192DE 0x4000 - -#define HAL_HW_PCI_8180_DEVICE_ID 0x8180 -#define HAL_HW_PCI_8185_DEVICE_ID 0x8185 -#define HAL_HW_PCI_8188_DEVICE_ID 0x8188 -#define HAL_HW_PCI_8198_DEVICE_ID 0x8198 -#define HAL_HW_PCI_8190_DEVICE_ID 0x8190 -#define HAL_HW_PCI_8192_DEVICE_ID 0x8192 -#define HAL_HW_PCI_8192SE_DEVICE_ID 0x8192 -#define HAL_HW_PCI_8174_DEVICE_ID 0x8174 -#define HAL_HW_PCI_8173_DEVICE_ID 0x8173 -#define HAL_HW_PCI_8172_DEVICE_ID 0x8172 -#define HAL_HW_PCI_8171_DEVICE_ID 0x8171 -#define HAL_HW_PCI_0045_DEVICE_ID 0x0045 -#define HAL_HW_PCI_0046_DEVICE_ID 0x0046 -#define HAL_HW_PCI_0044_DEVICE_ID 0x0044 -#define HAL_HW_PCI_0047_DEVICE_ID 0x0047 -#define HAL_HW_PCI_700F_DEVICE_ID 0x700F -#define HAL_HW_PCI_701F_DEVICE_ID 0x701F -#define HAL_HW_PCI_DLINK_DEVICE_ID 0x3304 -#define HAL_HW_PCI_8192CET_DEVICE_ID 0x8191 -#define HAL_HW_PCI_8192CE_DEVICE_ID 0x8178 -#define HAL_HW_PCI_8191CE_DEVICE_ID 0x8177 -#define HAL_HW_PCI_8188CE_DEVICE_ID 0x8176 -#define HAL_HW_PCI_8192CU_DEVICE_ID 0x8191 -#define HAL_HW_PCI_8192DE_DEVICE_ID 0x092D -#define HAL_HW_PCI_8192DU_DEVICE_ID 0x092D #define RTL819X_DEFAULT_RF_TYPE RF_1T2R @@ -150,16 +95,12 @@ (1600 + (MAX_802_11_HEADER_LENGTH + ENCRYPTION_MAX_OVERHEAD) * \ MAX_FRAGMENT_COUNT) -#define scrclng 4 - #define DEFAULT_FRAG_THRESHOLD 2342U #define MIN_FRAG_THRESHOLD 256U #define DEFAULT_BEACONINTERVAL 0x64U -#define DEFAULT_SSID "" #define DEFAULT_RETRY_RTS 7 #define DEFAULT_RETRY_DATA 7 -#define PRISM_HDR_SIZE 64 #define PHY_RSSI_SLID_WIN_MAX 100 @@ -183,29 +124,6 @@ extern int hwwep; -enum RTL819x_PHY_PARAM { - RTL819X_PHY_MACPHY_REG = 0, - RTL819X_PHY_MACPHY_REG_PG = 1, - RTL8188C_PHY_MACREG = 2, - RTL8192C_PHY_MACREG = 3, - RTL819X_PHY_REG = 4, - RTL819X_PHY_REG_1T2R = 5, - RTL819X_PHY_REG_to1T1R = 6, - RTL819X_PHY_REG_to1T2R = 7, - RTL819X_PHY_REG_to2T2R = 8, - RTL819X_PHY_REG_PG = 9, - RTL819X_AGC_TAB = 10, - RTL819X_PHY_RADIO_A = 11, - RTL819X_PHY_RADIO_A_1T = 12, - RTL819X_PHY_RADIO_A_2T = 13, - RTL819X_PHY_RADIO_B = 14, - RTL819X_PHY_RADIO_B_GM = 15, - RTL819X_PHY_RADIO_C = 16, - RTL819X_PHY_RADIO_D = 17, - RTL819X_EEPROM_MAP = 18, - RTL819X_EFUSE_MAP = 19, -}; - enum nic_t { NIC_UNKNOWN = 0, NIC_8192E = 1, @@ -220,7 +138,6 @@ enum nic_t { enum rt_eeprom_type { EEPROM_93C46, EEPROM_93C56, - EEPROM_BOOT_EFUSE, }; enum dcmg_txcmd_op { @@ -242,19 +159,6 @@ enum rt_rf_type_819xu { RF_PSEUDO_11N = 5, }; -enum rf_step { - RF_STEP_INIT = 0, - RF_STEP_NORMAL, - RF_STEP_MAX -}; - -enum rt_status { - RT_STATUS_SUCCESS, - RT_STATUS_FAILURE, - RT_STATUS_PENDING, - RT_STATUS_RESOURCE -}; - enum rt_customer_id { RT_CID_DEFAULT = 0, RT_CID_8187_ALPHA0 = 1, @@ -294,51 +198,6 @@ enum reset_type { RESET_TYPE_SILENT = 0x02 }; -enum ic_inferiority_8192s { - IC_INFERIORITY_A = 0, - IC_INFERIORITY_B = 1, -}; - -enum pci_bridge_vendor { - PCI_BRIDGE_VENDOR_INTEL = 0x0, - PCI_BRIDGE_VENDOR_ATI, - PCI_BRIDGE_VENDOR_AMD, - PCI_BRIDGE_VENDOR_SIS, - PCI_BRIDGE_VENDOR_UNKNOWN, - PCI_BRIDGE_VENDOR_MAX, -}; - -struct buffer { - struct buffer *next; - u32 *buf; - dma_addr_t dma; - -}; - -struct rtl_reg_debug { - unsigned int cmd; - struct { - unsigned char type; - unsigned char addr; - unsigned char page; - unsigned char length; - } head; - unsigned char buf[0xff]; -}; - -struct rt_tx_rahis { - u32 cck[4]; - u32 ofdm[8]; - u32 ht_mcs[4][16]; -}; - -struct rt_smooth_data_4rf { - char elements[4][100]; - u32 index; - u32 TotalNum; - u32 TotalVal[4]; -}; - struct rt_stats { unsigned long txrdu; unsigned long rxrdu; @@ -426,10 +285,8 @@ struct rt_stats { u8 rx_rssi_percentage[4]; u8 rx_evm_percentage[2]; long rxSNRdB[4]; - struct rt_tx_rahis txrate; u32 Slide_Beacon_pwdb[100]; u32 Slide_Beacon_Total; - struct rt_smooth_data_4rf cck_adc_pwdb; u32 CurrentShowTxate; }; @@ -442,15 +299,6 @@ struct channel_access_setting { u16 CWmaxIndex; }; -enum two_port_status { - TWO_PORT_STATUS__DEFAULT_ONLY, - TWO_PORT_STATUS__EXTENSION_ONLY, - TWO_PORT_STATUS__EXTENSION_FOLLOW_DEFAULT, - TWO_PORT_STATUS__DEFAULT_G_EXTENSION_N20, - TWO_PORT_STATUS__ADHOC, - TWO_PORT_STATUS__WITHOUT_ANY_ASSOCIATE -}; - struct init_gain { u8 xaagccore1; u8 xbagccore1; @@ -553,7 +401,6 @@ struct r8192_priv { enum rt_rf_type_819xu rf_chip; - enum ic_inferiority_8192s IC_Class; enum ht_channel_width CurrentChannelBW; struct bb_reg_definition PHYRegDef[4]; struct rate_adaptive rate_adaptive; @@ -792,7 +639,6 @@ struct r8192_priv { u8 bHwRfOffAction; bool aspm_clkreq_enable; - u32 pci_bridge_vendor; u8 RegHostPciASPMSetting; u8 RegDevicePciASPMSetting; From 4f1c29687abc618d8c6b1e49fabbfbf07940f648 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Tue, 2 Jun 2015 22:48:10 +0200 Subject: [PATCH 0880/1163] staging: rtl8192e: Remove dead code: rtl_dm.[ch] - Remove unused fields in dig_t structures. Some of them were only initialized and never accessed. - Remove unused enums/macros/defines in rtl_dm.h - Remove duplicated function declarations - Remove unused dm_change_dynamic_initgain_thresh() function - Remove unused dm_shadow_init() function Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 80 ---------------------- drivers/staging/rtl8192e/rtl8192e/rtl_dm.h | 70 ------------------- 2 files changed, 150 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c index d480229394a5..d8696293c6e1 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c @@ -1303,63 +1303,14 @@ static void dm_bb_initialgain_backup(struct net_device *dev) } -void dm_change_dynamic_initgain_thresh(struct net_device *dev, - u32 dm_type, u32 dm_value) -{ - if (dm_type == DIG_TYPE_THRESH_HIGH) { - dm_digtable.rssi_high_thresh = dm_value; - } else if (dm_type == DIG_TYPE_THRESH_LOW) { - dm_digtable.rssi_low_thresh = dm_value; - } else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH) { - dm_digtable.rssi_high_power_highthresh = dm_value; - } else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_LOW) { - dm_digtable.rssi_high_power_lowthresh = dm_value; - } else if (dm_type == DIG_TYPE_ENABLE) { - dm_digtable.dig_state = DM_STA_DIG_MAX; - dm_digtable.dig_enable_flag = true; - } else if (dm_type == DIG_TYPE_DISABLE) { - dm_digtable.dig_state = DM_STA_DIG_MAX; - dm_digtable.dig_enable_flag = false; - } else if (dm_type == DIG_TYPE_DBG_MODE) { - if (dm_value >= DM_DBG_MAX) - dm_value = DM_DBG_OFF; - dm_digtable.dbg_mode = (u8)dm_value; - } else if (dm_type == DIG_TYPE_RSSI) { - if (dm_value > 100) - dm_value = 30; - dm_digtable.rssi_val = (long)dm_value; - } else if (dm_type == DIG_TYPE_ALGORITHM) { - if (dm_value >= DIG_ALGO_MAX) - dm_value = DIG_ALGO_BY_FALSE_ALARM; - if (dm_digtable.dig_algorithm != (u8)dm_value) - dm_digtable.dig_algorithm_switch = 1; - dm_digtable.dig_algorithm = (u8)dm_value; - } else if (dm_type == DIG_TYPE_BACKOFF) { - if (dm_value > 30) - dm_value = 30; - dm_digtable.backoff_val = (u8)dm_value; - } else if (dm_type == DIG_TYPE_RX_GAIN_MIN) { - if (dm_value == 0) - dm_value = 0x1; - dm_digtable.rx_gain_range_min = (u8)dm_value; - } else if (dm_type == DIG_TYPE_RX_GAIN_MAX) { - if (dm_value > 0x50) - dm_value = 0x50; - dm_digtable.rx_gain_range_max = (u8)dm_value; - } -} - static void dm_dig_init(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); dm_digtable.dig_enable_flag = true; - dm_digtable.Backoff_Enable_Flag = true; dm_digtable.dig_algorithm = DIG_ALGO_BY_RSSI; - dm_digtable.Dig_TwoPort_Algorithm = DIG_TWO_PORT_ALGO_RSSI; - dm_digtable.Dig_Ext_Port_Stage = DIG_EXT_PORT_STAGE_MAX; dm_digtable.dbg_mode = DM_DBG_OFF; dm_digtable.dig_algorithm_switch = 0; @@ -1367,16 +1318,10 @@ static void dm_dig_init(struct net_device *dev) dm_digtable.dig_highpwr_state = DM_STA_DIG_MAX; dm_digtable.CurSTAConnectState = DIG_STA_DISCONNECT; dm_digtable.PreSTAConnectState = DIG_STA_DISCONNECT; - dm_digtable.CurAPConnectState = DIG_AP_DISCONNECT; - dm_digtable.PreAPConnectState = DIG_AP_DISCONNECT; - dm_digtable.initialgain_lowerbound_state = false; dm_digtable.rssi_low_thresh = DM_DIG_THRESH_LOW; dm_digtable.rssi_high_thresh = DM_DIG_THRESH_HIGH; - dm_digtable.FALowThresh = DM_FALSEALARM_THRESH_LOW; - dm_digtable.FAHighThresh = DM_FALSEALARM_THRESH_HIGH; - dm_digtable.rssi_high_power_lowthresh = DM_DIG_HIGH_PWR_THRESH_LOW; dm_digtable.rssi_high_power_highthresh = DM_DIG_HIGH_PWR_THRESH_HIGH; @@ -1387,9 +1332,6 @@ static void dm_dig_init(struct net_device *dev) dm_digtable.rx_gain_range_min = DM_DIG_MIN_Netcore; else dm_digtable.rx_gain_range_min = DM_DIG_MIN; - - dm_digtable.BackoffVal_range_max = DM_DIG_BACKOFF_MAX; - dm_digtable.BackoffVal_range_min = DM_DIG_BACKOFF_MIN; } static void dm_ctrl_initgain_byrssi(struct net_device *dev) @@ -2565,28 +2507,6 @@ void dm_check_fsync(struct net_device *dev) } } -void dm_shadow_init(struct net_device *dev) -{ - u8 page; - u16 offset; - - for (page = 0; page < 5; page++) - for (offset = 0; offset < 256; offset++) - dm_shadow[page][offset] = read_nic_byte(dev, - offset+page * 256); - - for (page = 8; page < 11; page++) - for (offset = 0; offset < 256; offset++) - dm_shadow[page][offset] = read_nic_byte(dev, - offset+page * 256); - - for (page = 12; page < 15; page++) - for (offset = 0; offset < 256; offset++) - dm_shadow[page][offset] = read_nic_byte(dev, - offset+page*256); - -} - /*---------------------------Define function prototype------------------------*/ static void dm_init_dynamic_txpower(struct net_device *dev) { diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h index 6be8e8bd640a..b0d936703515 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h @@ -87,17 +87,12 @@ struct dig_t { u8 dig_enable_flag; u8 dig_algorithm; - u8 Dig_TwoPort_Algorithm; - u8 Dig_Ext_Port_Stage; u8 dbg_mode; u8 dig_algorithm_switch; long rssi_low_thresh; long rssi_high_thresh; - u32 FALowThresh; - u32 FAHighThresh; - long rssi_high_power_lowthresh; long rssi_high_power_highthresh; @@ -105,8 +100,6 @@ struct dig_t { u8 dig_highpwr_state; u8 CurSTAConnectState; u8 PreSTAConnectState; - u8 CurAPConnectState; - u8 PreAPConnectState; u8 curpd_thstate; u8 prepd_thstate; @@ -116,13 +109,9 @@ struct dig_t { u32 pre_ig_value; u32 cur_ig_value; - u8 Backoff_Enable_Flag; u8 backoff_val; - char BackoffVal_range_max; - char BackoffVal_range_min; u8 rx_gain_range_max; u8 rx_gain_range_min; - bool initialgain_lowerbound_state; long rssi_val; }; @@ -166,26 +155,6 @@ enum dm_dig_alg { DIG_ALGO_MAX }; -enum dm_dig_two_port_alg { - DIG_TWO_PORT_ALGO_RSSI = 0, - DIG_TWO_PORT_ALGO_FALSE_ALARM = 1, -}; - - -enum dm_dig_ext_port_alg { - DIG_EXT_PORT_STAGE_0 = 0, - DIG_EXT_PORT_STAGE_1 = 1, - DIG_EXT_PORT_STAGE_2 = 2, - DIG_EXT_PORT_STAGE_3 = 3, - DIG_EXT_PORT_STAGE_MAX = 4, -}; - -enum dm_dig_dbg { - DIG_DBG_OFF = 0, - DIG_DBG_ON = 1, - DIG_DBG_MAX -}; - enum dm_dig_connect { DIG_STA_DISCONNECT = 0, DIG_STA_CONNECT = 1, @@ -251,8 +220,6 @@ extern struct dig_t dm_digtable; extern u8 dm_shadow[16][256]; extern struct drx_path_sel DM_RxPathSelTable; -extern u8 test_flag; - /* Pre-calculated gain tables */ extern const u32 dm_tx_bb_gain[TxBBGainTableLength]; extern const u8 dm_cck_tx_bb_gain[CCKTxBBGainTableLength][8]; @@ -279,47 +246,10 @@ extern void dm_cck_txpower_adjust(struct net_device *dev, bool binch14); extern void dm_restore_dynamic_mechanism_state(struct net_device *dev); extern void dm_backup_dynamic_mechanism_state(struct net_device *dev); -extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, - u32 dm_type, - u32 dm_value); -extern void DM_ChangeFsyncSetting(struct net_device *dev, - s32 DM_Type, - s32 DM_Value); -extern void dm_force_tx_fw_info(struct net_device *dev, - u32 force_type, - u32 force_value); extern void dm_init_edca_turbo(struct net_device *dev); -extern void dm_rf_operation_test_callback(unsigned long data); extern void dm_rf_pathcheck_workitemcallback(void *data); extern void dm_fsync_timer_callback(unsigned long data); extern void dm_check_fsync(struct net_device *dev); -extern void dm_shadow_init(struct net_device *dev); extern void dm_initialize_txpower_tracking(struct net_device *dev); extern void dm_CheckRfCtrlGPIO(void *data); -extern void dm_InitRateAdaptiveMask(struct net_device *dev); -extern void init_hal_dm(struct net_device *dev); -extern void deinit_hal_dm(struct net_device *dev); -extern void hal_dm_watchdog(struct net_device *dev); -extern void init_rate_adaptive(struct net_device *dev); -extern void dm_txpower_trackingcallback(void *data); -extern void dm_restore_dynamic_mechanism_state(struct net_device *dev); -extern void dm_backup_dynamic_mechanism_state(struct net_device *dev); -extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, - u32 dm_type, - u32 dm_value); -extern void DM_ChangeFsyncSetting(struct net_device *dev, - s32 DM_Type, - s32 DM_Value); -extern void dm_force_tx_fw_info(struct net_device *dev, - u32 force_type, - u32 force_value); -extern void dm_init_edca_turbo(struct net_device *dev); -extern void dm_rf_operation_test_callback(unsigned long data); -extern void dm_rf_pathcheck_workitemcallback(void *data); -extern void dm_fsync_timer_callback(unsigned long data); -extern void dm_check_fsync(struct net_device *dev); -extern void dm_shadow_init(struct net_device *dev); -extern void dm_initialize_txpower_tracking(struct net_device *dev); -extern void dm_CheckRfCtrlGPIO(void *data); - #endif /*__R8192UDM_H__ */ From c4262bdf246c2fdcd3b13a4f9ff68f2dd6f13e60 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Tue, 2 Jun 2015 22:48:13 +0200 Subject: [PATCH 0881/1163] staging: rtl8192e: Remove dead code: undefined arrays Remove undefined and unused PHY array forward-declarations. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/r8192E_phy.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.h b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.h index 7318f8857af2..18bc58240fbe 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.h +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.h @@ -41,13 +41,7 @@ #define Rtl819XPHY_REGArray Rtl8192PciEPHY_REGArray #define Rtl819XPHY_REG_1T2RArray Rtl8192PciEPHY_REG_1T2RArray -extern u32 rtl819XMACPHY_Array_PG[]; -extern u32 rtl819XPHY_REG_1T2RArray[]; extern u32 rtl819XAGCTAB_Array[]; -extern u32 rtl819XRadioA_Array[]; -extern u32 rtl819XRadioB_Array[]; -extern u32 rtl819XRadioC_Array[]; -extern u32 rtl819XRadioD_Array[]; enum hw90_block { HW90_BLOCK_MAC = 0, From b2b94bc9e9a4090b95707648c1fac6313bf0f4af Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Tue, 2 Jun 2015 22:48:12 +0200 Subject: [PATCH 0882/1163] staging: rtl8192e: Remove dead code: rt_stats Remove unused fields from rt_stats structure. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 40 -------------------- 1 file changed, 40 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h index 7d18d05039d2..71f0c0274c51 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h @@ -199,12 +199,8 @@ enum reset_type { }; struct rt_stats { - unsigned long txrdu; unsigned long rxrdu; unsigned long rxok; - unsigned long rxframgment; - unsigned long rxurberr; - unsigned long rxstaterr; unsigned long rxdatacrcerr; unsigned long rxmgmtcrcerr; unsigned long rxcrcerrmin; @@ -212,8 +208,6 @@ struct rt_stats { unsigned long rxcrcerrmax; unsigned long received_rate_histogram[4][32]; unsigned long received_preamble_GI[2][32]; - unsigned long rx_AMPDUsize_histogram[5]; - unsigned long rx_AMPDUnum_histogram[5]; unsigned long numpacket_matchbssid; unsigned long numpacket_toself; unsigned long num_process_phyinfo; @@ -221,58 +215,24 @@ struct rt_stats { unsigned long numqry_phystatusCCK; unsigned long numqry_phystatusHT; unsigned long received_bwtype[5]; - unsigned long txnperr; - unsigned long txnpdrop; - unsigned long txresumed; unsigned long rxoverflow; unsigned long rxint; - unsigned long txnpokint; unsigned long ints; unsigned long shints; unsigned long txoverflow; - unsigned long txlpokint; - unsigned long txlpdrop; - unsigned long txlperr; unsigned long txbeokint; - unsigned long txbedrop; - unsigned long txbeerr; unsigned long txbkokint; - unsigned long txbkdrop; - unsigned long txbkerr; unsigned long txviokint; - unsigned long txvidrop; - unsigned long txvierr; unsigned long txvookint; - unsigned long txvodrop; - unsigned long txvoerr; unsigned long txbeaconokint; - unsigned long txbeacondrop; unsigned long txbeaconerr; unsigned long txmanageokint; - unsigned long txmanagedrop; - unsigned long txmanageerr; unsigned long txcmdpktokint; - unsigned long txdatapkt; - unsigned long txfeedback; - unsigned long txfeedbackok; - unsigned long txoktotal; - unsigned long txokbytestotal; - unsigned long txokinperiod; - unsigned long txmulticast; unsigned long txbytesmulticast; - unsigned long txbroadcast; unsigned long txbytesbroadcast; - unsigned long txunicast; unsigned long txbytesunicast; unsigned long rxbytesunicast; - unsigned long txfeedbackfail; - unsigned long txerrtotal; - unsigned long txerrbytestotal; - unsigned long txerrmulticast; - unsigned long txerrbroadcast; - unsigned long txerrunicast; unsigned long txretrycount; - unsigned long txfeedbackretry; u8 last_packet_rate; unsigned long slide_signal_strength[100]; unsigned long slide_evm[100]; From d8ca20fe8315ec88e0cd21023ef8d6ffbec2e10a Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Tue, 2 Jun 2015 22:48:14 +0200 Subject: [PATCH 0883/1163] staging: rtl8192e: Remove dead code: r8192_priv members Remove unused members of rtl8192_priv structure. Some of them are never used, other are just initialized and never accessed. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192e/rtl8192e/r8192E_dev.c | 11 - drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 32 --- drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 204 ------------------ 3 files changed, 247 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c index b5e4d35ee6d4..f6661bbae7a8 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c @@ -2199,14 +2199,6 @@ rtl8192_InitializeVariables(struct net_device *dev) priv->ShortRetryLimit = 0x30; priv->LongRetryLimit = 0x30; - priv->EarlyRxThreshold = 7; - priv->pwrGroupCnt = 0; - - priv->bIgnoreSilentReset = false; - priv->enable_gpio0 = 0; - - priv->TransmitConfig = 0; - priv->ReceiveConfig = RCR_ADD3 | RCR_AMF | RCR_ADF | RCR_AICV | @@ -2221,9 +2213,6 @@ rtl8192_InitializeVariables(struct net_device *dev) IMR_RDU | IMR_RXFOVW | IMR_TXFOVW | IMR_BcnInt | IMR_TBDOK | IMR_TBDER); - - priv->MidHighPwrTHR_L1 = 0x3B; - priv->MidHighPwrTHR_L2 = 0x40; priv->PwrDomainProtect = false; priv->bfirst_after_down = false; diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index fcc9188a209f..4c53c873aff1 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -1087,16 +1087,6 @@ static void rtl8192_init_priv_constant(struct net_device *dev) &(priv->rtllib->PowerSaveControl); pPSC->RegMaxLPSAwakeIntvl = 5; - - priv->RegPciASPM = 2; - - priv->RegDevicePciASPMSetting = 0x03; - - priv->RegHostPciASPMSetting = 0x02; - - priv->RegHwSwRfOffD3 = 2; - - priv->RegSupportPciASPM = 2; } @@ -1109,9 +1099,6 @@ static void rtl8192_init_priv_variable(struct net_device *dev) priv->dot11CurrentPreambleMode = PREAMBLE_AUTO; priv->rtllib->hwscan_sem_up = 1; priv->rtllib->status = 0; - priv->H2CTxCmdSeq = 0; - priv->bDisableFrameBursting = false; - priv->bDMInitialGainEnable = true; priv->polling_timer_on = 0; priv->up_first_time = 1; priv->blinked_ingpio = false; @@ -1125,12 +1112,7 @@ static void rtl8192_init_priv_variable(struct net_device *dev) priv->rxringcount = MAX_RX_COUNT; priv->irq_enabled = 0; priv->chan = 1; - priv->RegWirelessMode = WIRELESS_MODE_AUTO; priv->RegChannelPlan = 0xf; - priv->nrxAMPDU_size = 0; - priv->nrxAMPDU_aggr_num = 0; - priv->last_rxdesc_tsf_high = 0; - priv->last_rxdesc_tsf_low = 0; priv->rtllib->mode = WIRELESS_MODE_AUTO; priv->rtllib->iw_mode = IW_MODE_INFRA; priv->rtllib->bNetPromiscuousMode = false; @@ -1176,12 +1158,6 @@ static void rtl8192_init_priv_variable(struct net_device *dev) priv->rtllib->sta_sleep = LPS_IS_WAKE; priv->rtllib->eRFPowerState = eRfOn; - priv->txpower_checkcnt = 0; - priv->thermal_readback_index = 0; - priv->txpower_tracking_callback_cnt = 0; - priv->ccktxpower_adjustcnt_ch14 = 0; - priv->ccktxpower_adjustcnt_not_ch14 = 0; - priv->rtllib->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; priv->rtllib->iw_mode = IW_MODE_INFRA; priv->rtllib->active_scan = 1; @@ -1198,13 +1174,11 @@ static void rtl8192_init_priv_variable(struct net_device *dev) priv->card_type = PCI; - priv->AcmControl = 0; priv->pFirmware = vzalloc(sizeof(struct rt_firmware)); if (!priv->pFirmware) netdev_err(dev, "rtl8192e: Unable to allocate space for firmware\n"); - skb_queue_head_init(&priv->rx_queue); skb_queue_head_init(&priv->skb_queue); for (i = 0; i < MAX_QUEUE_SIZE; i++) @@ -1215,14 +1189,10 @@ static void rtl8192_init_priv_variable(struct net_device *dev) static void rtl8192_init_priv_lock(struct r8192_priv *priv) { - spin_lock_init(&priv->fw_scan_lock); spin_lock_init(&priv->tx_lock); - spin_lock_init(&priv->irq_lock); spin_lock_init(&priv->irq_th_lock); spin_lock_init(&priv->rf_ps_lock); spin_lock_init(&priv->ps_lock); - spin_lock_init(&priv->rf_lock); - spin_lock_init(&priv->rt_h2c_lock); sema_init(&priv->wx_sem, 1); sema_init(&priv->rf_sem, 1); mutex_init(&priv->mutex); @@ -2994,8 +2964,6 @@ static void rtl8192_pci_disconnect(struct pci_dev *pdev) } free_rtllib(dev); - kfree(priv->scan_cmd); - if (dev->mem_start != 0) { iounmap((void __iomem *)dev->mem_start); release_mem_region(pci_resource_start(pdev, 1), diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h index 71f0c0274c51..e1686cbd99a3 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h @@ -339,10 +339,6 @@ struct r8192_priv { struct delayed_work txpower_tracking_wq; struct delayed_work rfpath_check_wq; struct delayed_work gpio_change_rf_wq; - struct delayed_work initialgain_operate_wq; - struct delayed_work check_hw_scan_wq; - struct delayed_work hw_scan_simu_wq; - struct delayed_work start_hw_scan_wq; struct workqueue_struct *priv_wq; @@ -374,17 +370,11 @@ struct r8192_priv { struct timer_list fsync_timer; struct timer_list gpio_polling_timer; - spinlock_t fw_scan_lock; - spinlock_t irq_lock; spinlock_t irq_th_lock; spinlock_t tx_lock; spinlock_t rf_ps_lock; - spinlock_t rw_lock; - spinlock_t rt_h2c_lock; - spinlock_t rf_lock; spinlock_t ps_lock; - struct sk_buff_head rx_queue; struct sk_buff_head skb_queue; struct tasklet_struct irq_rx_tasklet; @@ -397,12 +387,9 @@ struct r8192_priv { struct rt_stats stats; struct iw_statistics wstats; - struct proc_dir_entry *dir_dev; short (*rf_set_sens)(struct net_device *dev, short sens); u8 (*rf_set_chan)(struct net_device *dev, u8 ch); - void (*rf_close)(struct net_device *dev); - void (*rf_init)(struct net_device *dev); struct rx_desc *rx_ring[MAX_RX_QUEUE]; struct sk_buff *rx_buf[MAX_RX_QUEUE][MAX_RX_COUNT]; @@ -413,28 +400,19 @@ struct r8192_priv { u64 LastRxDescTSF; - u16 EarlyRxThreshold; u32 ReceiveConfig; - u8 AcmControl; - u8 RFProgType; u8 retry_data; u8 retry_rts; u16 rts; struct rtl8192_tx_ring tx_ring[MAX_TX_QUEUE_COUNT]; int txringcount; - int txbuffsize; - int txfwbuffersize; atomic_t tx_pending[0x10]; u16 ShortRetryLimit; u16 LongRetryLimit; - u32 TransmitConfig; - u8 RegCWinMin; - u8 keepAliveLevel; bool bHwRadioOff; - bool pwrdown; bool blinked_ingpio; u8 polling_timer_on; @@ -447,17 +425,11 @@ struct r8192_priv { struct work_struct qos_activate; - u8 bIbssCoordinator; - short promisc; - short crcmon; - - int txbeaconcount; short chan; short sens; short max_sens; - u32 rx_prevlen; u8 ScanDelay; bool ps_force; @@ -468,114 +440,43 @@ struct r8192_priv { enum nic_t card_8192; u8 card_8192_version; - short enable_gpio0; - u8 rf_type; u8 IC_Cut; char nick[IW_ESSID_MAX_SIZE + 1]; - - u8 RegBcnCtrlVal; - bool bHwAntDiv; - - bool bTKIPinNmodeFromReg; - bool bWEPinNmodeFromReg; - - bool bLedOpenDrain; - u8 check_roaming_cnt; - bool bIgnoreSilentReset; - u32 SilentResetRxSoltNum; u32 SilentResetRxSlotIndex; u32 SilentResetRxStuckEvent[MAX_SILENT_RESET_RX_SLOT_NUM]; - void *scan_cmd; - u8 hwscan_bw_40; - - u16 nrxAMPDU_size; - u8 nrxAMPDU_aggr_num; - - u32 last_rxdesc_tsf_high; - u32 last_rxdesc_tsf_low; - u16 basic_rate; u8 short_preamble; u8 dot11CurrentPreambleMode; u8 slot_time; u16 SifsTime; - u8 RegWirelessMode; - - u8 firmware_version; - u16 FirmwareSubVersion; - u16 rf_pathmap; bool AutoloadFailFlag; - u8 RegPciASPM; - u8 RegAMDPciASPM; - u8 RegHwSwRfOffD3; - u8 RegSupportPciASPM; - bool bSupportASPM; - - u32 RfRegChnlVal[2]; - - u8 ShowRateMode; - u8 RATRTableBitmap; - - u8 EfuseMap[2][HWSET_MAX_SIZE_92S]; - u16 EfuseUsedBytes; - u8 EfuseUsedPercentage; - short epromtype; u16 eeprom_vid; u16 eeprom_did; - u16 eeprom_svid; - u16 eeprom_smid; u8 eeprom_CustomerID; u16 eeprom_ChannelPlan; - u8 eeprom_version; - - u8 EEPROMRegulatory; - u8 EEPROMPwrGroup[2][3]; - u8 EEPROMOptional; u8 EEPROMTxPowerLevelCCK[14]; u8 EEPROMTxPowerLevelOFDM24G[14]; - u8 EEPROMTxPowerLevelOFDM5G[24]; u8 EEPROMRfACCKChnl1TxPwLevel[3]; u8 EEPROMRfAOfdmChnlTxPwLevel[3]; u8 EEPROMRfCCCKChnl1TxPwLevel[3]; u8 EEPROMRfCOfdmChnlTxPwLevel[3]; - u16 EEPROMTxPowerDiff; u16 EEPROMAntPwDiff; u8 EEPROMThermalMeter; - u8 EEPROMPwDiff; u8 EEPROMCrystalCap; - u8 EEPROMBluetoothCoexist; - u8 EEPROMBluetoothType; - u8 EEPROMBluetoothAntNum; - u8 EEPROMBluetoothAntIsolation; - u8 EEPROMBluetoothRadioShared; - - - u8 EEPROMSupportWoWLAN; - u8 EEPROMBoardType; - u8 EEPROM_Def_Ver; - u8 EEPROMHT2T_TxPwr[6]; - u8 EEPROMTSSI_A; - u8 EEPROMTSSI_B; - u8 EEPROMTxPowerLevelCCK_V1[3]; u8 EEPROMLegacyHTTxPowerDiff; - u8 BluetoothCoexist; - u8 CrystalCap; u8 ThermalMeter[2]; - u16 FwCmdIOMap; - u32 FwCmdIOParam; - u8 SwChnlInProgress; u8 SwChnlStage; u8 SwChnlStep; @@ -591,59 +492,16 @@ struct r8192_priv { u16 RegChannelPlan; u16 ChannelPlan; - bool bChnlPlanFromHW; bool RegRfOff; bool isRFOff; bool bInPowerSaveMode; u8 bHwRfOffAction; - bool aspm_clkreq_enable; - u8 RegHostPciASPMSetting; - u8 RegDevicePciASPMSetting; - bool RFChangeInProgress; bool SetRFPowerStateInProgress; bool bdisable_nic; - u8 pwrGroupCnt; - - u8 ThermalValue_LCK; - u8 ThermalValue_IQK; - bool bRfPiEnable; - - u32 APKoutput[2][2]; - bool bAPKdone; - - long RegE94; - long RegE9C; - long RegEB4; - long RegEBC; - - u32 RegC04; - u32 Reg874; - u32 RegC08; - u32 ADDA_backup[16]; - u32 IQK_MAC_backup[3]; - - bool SetFwCmdInProgress; - u8 CurrentFwCmdIO; - - u8 rssi_level; - - bool bInformFWDriverControlDM; - u8 PwrGroupHT20[2][14]; - u8 PwrGroupHT40[2][14]; - - u8 ThermalValue; - long EntryMinUndecoratedSmoothedPWDB; - long EntryMaxUndecoratedSmoothedPWDB; - u8 DynamicTxHighPowerLvl; - u8 LastDTPLvl; - u32 CurrentRATR0; - struct false_alarm_stats FalseAlmCnt; - - u8 DMFlag; u8 DM_Type; u8 CckPwEnl; @@ -653,54 +511,32 @@ struct r8192_priv { u8 CCKPresentAttentuation_40Mdefault; char CCKPresentAttentuation_difference; char CCKPresentAttentuation; - u8 bCckHighPower; long undecorated_smoothed_pwdb; - long undecorated_smoothed_cck_adc_pwdb[4]; u32 MCSTxPowerLevelOriginalOffset[6]; - u32 CCKTxPowerLevelOriginalOffset; u8 TxPowerLevelCCK[14]; u8 TxPowerLevelCCK_A[14]; u8 TxPowerLevelCCK_C[14]; u8 TxPowerLevelOFDM24G[14]; - u8 TxPowerLevelOFDM5G[14]; u8 TxPowerLevelOFDM24G_A[14]; u8 TxPowerLevelOFDM24G_C[14]; u8 LegacyHTTxPowerDiff; - u8 TxPowerDiff; s8 RF_C_TxPwDiff; - s8 RF_B_TxPwDiff; - u8 RfTxPwrLevelCck[2][14]; - u8 RfTxPwrLevelOfdm1T[2][14]; - u8 RfTxPwrLevelOfdm2T[2][14]; u8 AntennaTxPwDiff[3]; - u8 TxPwrHt20Diff[2][14]; - u8 TxPwrLegacyHtDiff[2][14]; - u8 TxPwrSafetyFlag; - u8 HT2T_TxPwr_A[14]; - u8 HT2T_TxPwr_B[14]; - u8 CurrentCckTxPwrIdx; - u8 CurrentOfdm24GTxPwrIdx; - bool bdynamic_txpower; bool bDynamicTxHighPower; bool bDynamicTxLowPower; bool bLastDTPFlag_High; bool bLastDTPFlag_Low; - bool bstore_last_dtpflag; - bool bstart_txctrl_bydtp; - u8 rfa_txpowertrackingindex; u8 rfa_txpowertrackingindex_real; u8 rfa_txpowertracking_default; u8 rfc_txpowertrackingindex; u8 rfc_txpowertrackingindex_real; - u8 rfc_txpowertracking_default; bool btxpower_tracking; bool bcck_in_ch14; - u8 TxPowerTrackControl; u8 txpower_count; bool btxpower_trackingInit; @@ -716,11 +552,6 @@ struct r8192_priv { bool bcurrent_turbo_EDCA; bool bis_cur_rdlstate; - bool bCCKinCH14; - - u8 MidHighPwrTHR_L1; - u8 MidHighPwrTHR_L2; - bool bfsync_processing; u32 rate_record; u32 rateCountDiffRecord; @@ -730,56 +561,21 @@ struct r8192_priv { u32 framesyncC34; u8 framesyncMonitor; - bool bDMInitialGainEnable; - bool MutualAuthenticationFail; - - bool bDisableFrameBursting; - u32 reset_count; - bool bpbc_pressed; - - u32 txpower_checkcnt; - u32 txpower_tracking_callback_cnt; - u8 thermal_read_val[40]; - u8 thermal_readback_index; - u32 ccktxpower_adjustcnt_not_ch14; - u32 ccktxpower_adjustcnt_ch14; enum reset_type ResetProgress; bool bForcedSilentReset; bool bDisableNormalResetCheck; u16 TxCounter; u16 RxCounter; - int IrpPendingCount; bool bResetInProgress; bool force_reset; bool force_lps; - u8 InitialGainOperateType; bool chan_forced; - bool bSingleCarrier; - bool RegBoard; - bool bCckContTx; - bool bOfdmContTx; - bool bStartContTx; - u8 RegPaModel; - u8 btMpCckTxPower; - u8 btMpOfdmTxPower; - - u32 MptActType; - u32 MptIoOffset; - u32 MptIoValue; - u32 MptRfPath; - - u32 MptBandWidth; - u32 MptRateIndex; - u8 MptChannelToSw; - u32 MptRCR; u8 PwrDomainProtect; u8 H2CTxCmdSeq; - - }; extern const struct ethtool_ops rtl819x_ethtool_ops; From 9c2ce8275d62e9a78f17aa226c77e2e2a115c6bf Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Tue, 2 Jun 2015 22:48:15 +0200 Subject: [PATCH 0884/1163] staging: rtl8192e: Remove dead code: mp_adapter mp_adapter structure was used in past, but now is only initialized and never read. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 2 -- drivers/staging/rtl8192e/rtl8192e/rtl_pci.c | 4 +--- drivers/staging/rtl8192e/rtl8192e/rtl_pci.h | 17 ----------------- 3 files changed, 1 insertion(+), 22 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h index e1686cbd99a3..776d950655cb 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h @@ -344,8 +344,6 @@ struct r8192_priv { struct channel_access_setting ChannelAccessSetting; - struct mp_adapter NdisAdapter; - struct rtl819x_ops *ops; struct rtllib_device *rtllib; diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c index e8065c0ed05f..6bbd1c626e24 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c @@ -34,10 +34,8 @@ static void rtl8192_parse_pci_configuration(struct pci_dev *pdev, u16 LinkCtrlReg; pcie_capability_read_word(priv->pdev, PCI_EXP_LNKCTL, &LinkCtrlReg); - priv->NdisAdapter.LinkCtrlReg = (u8)LinkCtrlReg; - RT_TRACE(COMP_INIT, "Link Control Register =%x\n", - priv->NdisAdapter.LinkCtrlReg); + RT_TRACE(COMP_INIT, "Link Control Register =%x\n", LinkCtrlReg); pci_read_config_byte(pdev, 0x98, &tmp); tmp |= BIT4; diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h index 4b94653c50d9..e8d5527a5f04 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h @@ -28,23 +28,6 @@ #include #include -struct mp_adapter { - u8 LinkCtrlReg; - - u8 BusNumber; - u8 DevNumber; - u8 FuncNumber; - - u8 PciBridgeBusNum; - u8 PciBridgeDevNum; - u8 PciBridgeFuncNum; - u8 PciBridgeVendor; - u16 PciBridgeVendorId; - u16 PciBridgeDeviceId; - u8 PciBridgePCIeHdrOffset; - u8 PciBridgeLinkCtrlReg; -}; - struct net_device; bool rtl8192_pci_findadapter(struct pci_dev *pdev, struct net_device *dev); From 1208097416fb382b8fcdb8bf9e63954c36cdb62b Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 5 Jun 2015 12:24:06 +0300 Subject: [PATCH 0885/1163] staging: rtl8192e: fix some confusing indenting The indenting here causes a static checker warning: drivers/staging/rtl8192e/rtllib_rx.c:626 RxReorderIndicatePacket() warn: curly braces intended? The code is actually correct, it's just that these lines were pushed in an extra indent level by mistake in 35e33b0468ab ('staging: rtl8192e: Fix LONG_LINE warnings'). Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_rx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 6977f04ccd4d..2bef1f63be79 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -623,9 +623,9 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, else pTS->RxIndicateSeq = 4095 - (WinSize - (SeqNum + 1)) + 1; - netdev_dbg(ieee->dev, - "Window Shift! IndicateSeq: %d, NewSeq: %d\n", - pTS->RxIndicateSeq, SeqNum); + netdev_dbg(ieee->dev, + "Window Shift! IndicateSeq: %d, NewSeq: %d\n", + pTS->RxIndicateSeq, SeqNum); } /* Indication process. From bfee7c9665931fd391981fe360666793ad7267bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20B=C3=B6hme?= Date: Sat, 6 Jun 2015 15:52:32 +0200 Subject: [PATCH 0886/1163] staging: rtl8188eu: core/rtw_led.c: fix coding style issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Convert spaces at the start of a line to a tab. Signed-off-by: Markus Böhme Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_led.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_led.c b/drivers/staging/rtl8188eu/core/rtw_led.c index 94405dc44220..14461cf34037 100644 --- a/drivers/staging/rtl8188eu/core/rtw_led.c +++ b/drivers/staging/rtl8188eu/core/rtw_led.c @@ -477,7 +477,7 @@ void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction) { struct led_priv *ledpriv = &(padapter->ledpriv); - if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped) || + if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped) || (!padapter->hw_init_completed)) return; From bbf5f037fad47e4affef6696aaf88a40b261e639 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 19 May 2015 15:37:18 +0200 Subject: [PATCH 0887/1163] iio: st_accel: support the LIS331DL sensor This adds support for the LIS331DL sensor version. This is a simple 8bit-only accelerometer. Signed-off-by: Linus Walleij Acked-by: Denis Ciocca Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/st-sensors.txt | 1 + drivers/iio/accel/st_accel.h | 1 + drivers/iio/accel/st_accel_core.c | 70 +++++++++++++++++++ drivers/iio/accel/st_accel_i2c.c | 4 ++ 4 files changed, 76 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt index fb5e0c2d18b5..8a6be3bdf267 100644 --- a/Documentation/devicetree/bindings/iio/st-sensors.txt +++ b/Documentation/devicetree/bindings/iio/st-sensors.txt @@ -30,6 +30,7 @@ Accelerometers: - st,lsm330d-accel - st,lsm330dl-accel - st,lsm330dlc-accel +- st,lis331dl-accel - st,lis331dlh-accel - st,lsm303dl-accel - st,lsm303dlm-accel diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h index 7ee9724b1428..aa1001931d0c 100644 --- a/drivers/iio/accel/st_accel.h +++ b/drivers/iio/accel/st_accel.h @@ -20,6 +20,7 @@ #define LSM330D_ACCEL_DEV_NAME "lsm330d_accel" #define LSM330DL_ACCEL_DEV_NAME "lsm330dl_accel" #define LSM330DLC_ACCEL_DEV_NAME "lsm330dlc_accel" +#define LIS331DL_ACCEL_DEV_NAME "lis331dl_accel" #define LIS331DLH_ACCEL_DEV_NAME "lis331dlh" #define LSM303DL_ACCEL_DEV_NAME "lsm303dl_accel" #define LSM303DLH_ACCEL_DEV_NAME "lsm303dlh_accel" diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index ad19fb4304df..970e9f904dde 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c @@ -153,6 +153,28 @@ #define ST_ACCEL_4_IG1_EN_MASK 0x08 #define ST_ACCEL_4_MULTIREAD_BIT true +/* CUSTOM VALUES FOR SENSOR 5 */ +#define ST_ACCEL_5_WAI_EXP 0x3b +#define ST_ACCEL_5_ODR_ADDR 0x20 +#define ST_ACCEL_5_ODR_MASK 0x80 +#define ST_ACCEL_5_ODR_AVL_100HZ_VAL 0x00 +#define ST_ACCEL_5_ODR_AVL_400HZ_VAL 0x01 +#define ST_ACCEL_5_PW_ADDR 0x20 +#define ST_ACCEL_5_PW_MASK 0x40 +#define ST_ACCEL_5_FS_ADDR 0x20 +#define ST_ACCEL_5_FS_MASK 0x20 +#define ST_ACCEL_5_FS_AVL_2_VAL 0X00 +#define ST_ACCEL_5_FS_AVL_8_VAL 0X01 +/* TODO: check these resulting gain settings, these are not in the datsheet */ +#define ST_ACCEL_5_FS_AVL_2_GAIN IIO_G_TO_M_S_2(18000) +#define ST_ACCEL_5_FS_AVL_8_GAIN IIO_G_TO_M_S_2(72000) +#define ST_ACCEL_5_DRDY_IRQ_ADDR 0x22 +#define ST_ACCEL_5_DRDY_IRQ_INT1_MASK 0x04 +#define ST_ACCEL_5_DRDY_IRQ_INT2_MASK 0x20 +#define ST_ACCEL_5_IG1_EN_ADDR 0x21 +#define ST_ACCEL_5_IG1_EN_MASK 0x08 +#define ST_ACCEL_5_MULTIREAD_BIT false + static const struct iio_chan_spec st_accel_8bit_channels[] = { ST_SENSORS_LSM_CHANNELS(IIO_ACCEL, BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), @@ -470,6 +492,54 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { .multi_read_bit = ST_ACCEL_4_MULTIREAD_BIT, .bootime = 2, /* guess */ }, + { + .wai = ST_ACCEL_5_WAI_EXP, + .sensors_supported = { + [0] = LIS331DL_ACCEL_DEV_NAME, + }, + .ch = (struct iio_chan_spec *)st_accel_8bit_channels, + .odr = { + .addr = ST_ACCEL_5_ODR_ADDR, + .mask = ST_ACCEL_5_ODR_MASK, + .odr_avl = { + { 100, ST_ACCEL_5_ODR_AVL_100HZ_VAL }, + { 400, ST_ACCEL_5_ODR_AVL_400HZ_VAL, }, + }, + }, + .pw = { + .addr = ST_ACCEL_5_PW_ADDR, + .mask = ST_ACCEL_5_PW_MASK, + .value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE, + .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE, + }, + .enable_axis = { + .addr = ST_SENSORS_DEFAULT_AXIS_ADDR, + .mask = ST_SENSORS_DEFAULT_AXIS_MASK, + }, + .fs = { + .addr = ST_ACCEL_5_FS_ADDR, + .mask = ST_ACCEL_5_FS_MASK, + .fs_avl = { + [0] = { + .num = ST_ACCEL_FS_AVL_2G, + .value = ST_ACCEL_5_FS_AVL_2_VAL, + .gain = ST_ACCEL_5_FS_AVL_2_GAIN, + }, + [1] = { + .num = ST_ACCEL_FS_AVL_8G, + .value = ST_ACCEL_5_FS_AVL_8_VAL, + .gain = ST_ACCEL_5_FS_AVL_8_GAIN, + }, + }, + }, + .drdy_irq = { + .addr = ST_ACCEL_5_DRDY_IRQ_ADDR, + .mask_int1 = ST_ACCEL_5_DRDY_IRQ_INT1_MASK, + .mask_int2 = ST_ACCEL_5_DRDY_IRQ_INT2_MASK, + }, + .multi_read_bit = ST_ACCEL_5_MULTIREAD_BIT, + .bootime = 2, /* guess */ + }, }; static int st_accel_read_raw(struct iio_dev *indio_dev, diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c index 6b720c190b2d..d4ad72ca4a3d 100644 --- a/drivers/iio/accel/st_accel_i2c.c +++ b/drivers/iio/accel/st_accel_i2c.c @@ -48,6 +48,10 @@ static const struct of_device_id st_accel_of_match[] = { .compatible = "st,lsm330dlc-accel", .data = LSM330DLC_ACCEL_DEV_NAME, }, + { + .compatible = "st,lis331dl-accel", + .data = LIS331DL_ACCEL_DEV_NAME, + }, { .compatible = "st,lis331dlh-accel", .data = LIS331DLH_ACCEL_DEV_NAME, From 11f2323ad3572348e10a7a152656a6e9889f44cc Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Tue, 9 Jun 2015 14:40:43 +0530 Subject: [PATCH 0888/1163] staging: fbtft: fix build error while building on i386 it gives a build warning about msg undeclared. Fixes: e6ffd1ba55a4931c ("staging: fbtft: fix out of bound access") Reported-by: kbuild test robot Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fbtft-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c index 2889f51bf3f8..9cc81412be69 100644 --- a/drivers/staging/fbtft/fbtft-core.c +++ b/drivers/staging/fbtft/fbtft-core.c @@ -1092,7 +1092,7 @@ static int fbtft_init_display_dt(struct fbtft_par *par) } /* make debug message */ fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, - "init: write_register:%s\n", msg); + "init: write_register:\n"); for (j = 0; j < i; j++) fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "buf[%d] = %02X\n", j, buf[j]); From 21175ef7e0db27989f37096ff5121255ac201c12 Mon Sep 17 00:00:00 2001 From: Madhusudhanan Ravindran Date: Tue, 9 Jun 2015 11:19:06 +0000 Subject: [PATCH 0889/1163] staging: wilc1000: remove unused variables removed few variables which are assigned but never used. Signed-off-by: Madhusudhanan Ravindran Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 592b8aec40e9..860f3361314f 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -259,7 +259,6 @@ static int dev_state_ev_handler(struct notifier_block *this, unsigned long event tstrWILC_WFIDrv *pstrWFIDrv; struct net_device *dev; u8 *pIP_Add_buff; - WILC_Sint32 s32status = WILC_FAIL; perInterface_wlan_t *nic; u8 null_ip[4] = {0}; char wlan_dev_name[5] = "wlan0"; @@ -317,7 +316,7 @@ static int dev_state_ev_handler(struct notifier_block *this, unsigned long event pIP_Add_buff = (char *) (&(dev_iface->ifa_address)); PRINT_D(GENERIC_DBG, "IP add=%d:%d:%d:%d \n", pIP_Add_buff[0], pIP_Add_buff[1], pIP_Add_buff[2], pIP_Add_buff[3]); - s32status = host_int_setup_ipaddress((WILC_WFIDrvHandle)pstrWFIDrv, pIP_Add_buff, nic->u8IfIdx); + host_int_setup_ipaddress((WILC_WFIDrvHandle)pstrWFIDrv, pIP_Add_buff, nic->u8IfIdx); break; @@ -341,7 +340,7 @@ static int dev_state_ev_handler(struct notifier_block *this, unsigned long event pIP_Add_buff = null_ip; PRINT_D(GENERIC_DBG, "IP add=%d:%d:%d:%d \n", pIP_Add_buff[0], pIP_Add_buff[1], pIP_Add_buff[2], pIP_Add_buff[3]); - s32status = host_int_setup_ipaddress((WILC_WFIDrvHandle)pstrWFIDrv, pIP_Add_buff, nic->u8IfIdx); + host_int_setup_ipaddress((WILC_WFIDrvHandle)pstrWFIDrv, pIP_Add_buff, nic->u8IfIdx); break; @@ -1102,7 +1101,6 @@ static int linux_wlan_init_test_config(struct net_device *dev, linux_wlan_t *p_n #ifndef STATIC_MACADDRESS unsigned char mac_add[] = {0x00, 0x80, 0xC2, 0x5E, 0xa2, 0xff}; #endif - unsigned int chipid = 0; /*BugID_5077*/ struct WILC_WFI_priv *priv; @@ -1118,7 +1116,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, linux_wlan_t *p_n PRINT_D(INIT_DBG, "Host = %x\n", (WILC_Uint32)pstrWFIDrv); PRINT_D(INIT_DBG, "MAC address is : %02x-%02x-%02x-%02x-%02x-%02x\n", mac_add[0], mac_add[1], mac_add[2], mac_add[3], mac_add[4], mac_add[5]); - chipid = wilc_get_chipid(0); + wilc_get_chipid(0); if (g_linux_wlan->oup.wlan_cfg_set == NULL) { @@ -2066,7 +2064,6 @@ int mac_open(struct net_device *ndev) /*No need for setting mac address here anymore,*/ /*Just set it in init_test_config()*/ unsigned char mac_add[ETH_ALEN] = {0}; - int status; int ret = 0; int i = 0; struct WILC_WFI_priv *priv; @@ -2095,7 +2092,7 @@ int mac_open(struct net_device *ndev) Set_machw_change_vir_if(WILC_FALSE); - status = host_int_get_MacAddress(priv->hWILCWFIDrv, mac_add); + host_int_get_MacAddress(priv->hWILCWFIDrv, mac_add); PRINT_D(INIT_DBG, "Mac address: %x:%x:%x:%x:%x:%x\n", mac_add[0], mac_add[1], mac_add[2], mac_add[3], mac_add[4], mac_add[5]); From 96baf5a61b14119eca3f5b282700e2560e5bda28 Mon Sep 17 00:00:00 2001 From: Hari Prasath Gujulan Elango Date: Wed, 10 Jun 2015 04:25:37 +0000 Subject: [PATCH 0890/1163] staging: wilc1000: fix build warning related to time_after_eq macro This patch fixes a build warning related to the use of the time_after_eq macro.Adding a typecast to the second argument suppresses the warning.This warning was created by one my previous patch. Signed-off-by: Hari Prasath Gujulan Elango Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 0db7f3dfc352..0441d7b23485 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -2252,7 +2252,7 @@ void WILC_WFI_p2p_rx (struct net_device *dev, uint8_t *buff, uint32_t size) if (ieee80211_is_action(buff[FRAME_TYPE_ID])) { PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]); - if (priv->bCfgScanning == WILC_TRUE && time_after_eq(jiffies, pstrWFIDrv->u64P2p_MgmtTimeout)) { + if (priv->bCfgScanning == WILC_TRUE && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->u64P2p_MgmtTimeout)) { PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n"); return; } From 8a14330f6ded9b22a9d8231ac988963a402ea067 Mon Sep 17 00:00:00 2001 From: Johnny Kim Date: Wed, 10 Jun 2015 17:06:46 +0900 Subject: [PATCH 0891/1163] staging: wilc1000: modify printk format This remove compile warnings about printk format. Signed-off-by: Johnny Kim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 8 ++++---- drivers/staging/wilc1000/linux_wlan.c | 2 +- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index afe5126f3655..1ecb37341780 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -703,7 +703,7 @@ static WILC_Sint32 Handle_SetOperationMode(void *drvHandler, tstrHostIfSetOperat strWID.s32ValueSize = sizeof(WILC_Uint32); /*Sending Cfg*/ - PRINT_INFO(HOSTINF_DBG, "(WILC_Uint32)pstrWFIDrv= %x \n", (WILC_Uint32)pstrWFIDrv); + PRINT_INFO(HOSTINF_DBG, "(size_t)pstrWFIDrv= %p \n", pstrWFIDrv); s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); @@ -6631,7 +6631,7 @@ WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) g_obtainingIP = WILC_FALSE; #endif - PRINT_D(HOSTINF_DBG, "Global handle pointer value=%x\n", (WILC_Uint32)pstrWFIDrv); + PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", pstrWFIDrv); /* /////////////////////////////////////// */ if (clients_count == 0) { sema_init(&hSemHostIFthrdEnd, 0); @@ -6928,7 +6928,7 @@ void NetworkInfoReceived(u8 *pu8Buffer, WILC_Uint32 u32Length) if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) { - PRINT_ER("NetworkInfo received but driver not init[%x]\n", (WILC_Uint32)pstrWFIDrv); + PRINT_ER("NetworkInfo received but driver not init[%p]\n", pstrWFIDrv); return; } @@ -7037,7 +7037,7 @@ void host_int_ScanCompleteReceived(u8 *pu8Buffer, WILC_Uint32 u32Length) pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; - PRINT_D(GENERIC_DBG, "Scan notification received %x\n", (WILC_Uint32)pstrWFIDrv); + PRINT_D(GENERIC_DBG, "Scan notification received %p\n", pstrWFIDrv); if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) { return; diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 860f3361314f..3956c701c689 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -1113,7 +1113,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, linux_wlan_t *p_n #endif priv = wiphy_priv(dev->ieee80211_ptr->wiphy); pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv; - PRINT_D(INIT_DBG, "Host = %x\n", (WILC_Uint32)pstrWFIDrv); + PRINT_D(INIT_DBG, "Host = %p\n", pstrWFIDrv); PRINT_D(INIT_DBG, "MAC address is : %02x-%02x-%02x-%02x-%02x-%02x\n", mac_add[0], mac_add[1], mac_add[2], mac_add[3], mac_add[4], mac_add[5]); wilc_get_chipid(0); diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 0441d7b23485..61f1f2010645 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -844,7 +844,7 @@ static int WILC_WFI_CfgConnect(struct wiphy *wiphy, struct net_device *dev, host_int_set_wfi_drv_handler((WILC_Uint32)priv->hWILCWFIDrv); - PRINT_D(CFG80211_DBG, "Connecting to SSID [%s] on netdev [%p] host if [%x]\n", sme->ssid, dev, (WILC_Uint32)priv->hWILCWFIDrv); + PRINT_D(CFG80211_DBG, "Connecting to SSID [%s] on netdev [%p] host if [%p]\n", sme->ssid, dev, priv->hWILCWFIDrv); #ifdef WILC_P2P if (!(WILC_strncmp(sme->ssid, "DIRECT-", 7))) { PRINT_D(CFG80211_DBG, "Connected to Direct network,OBSS disabled\n"); @@ -1147,7 +1147,7 @@ static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 k PRINT_D(CFG80211_DBG, "Adding key with cipher suite = %x\n", params->cipher); /*BugID_5137*/ - PRINT_D(CFG80211_DBG, "%x %x %d\n", (WILC_Uint32)wiphy, (WILC_Uint32)netdev, key_index); + PRINT_D(CFG80211_DBG, "%p %p %d\n", wiphy, netdev, key_index); PRINT_D(CFG80211_DBG, "key %x %x %x\n", params->key[0], params->key[1], @@ -3062,7 +3062,7 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev dev->ieee80211_ptr->iftype = type; priv->wdev->iftype = type; nic->iftype = AP_MODE; - PRINT_D(CORECONFIG_DBG, "(WILC_Uint32)priv->hWILCWFIDrv[%x]\n", (WILC_Uint32)priv->hWILCWFIDrv); + PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv); #ifndef SIMULATION PRINT_D(HOSTAPD_DBG, "Downloading AP firmware\n"); @@ -3108,7 +3108,7 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev dev->ieee80211_ptr->iftype = type; priv->wdev->iftype = type; - PRINT_D(CORECONFIG_DBG, "(WILC_Uint32)priv->hWILCWFIDrv[%x]\n", (WILC_Uint32)priv->hWILCWFIDrv); + PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv); #ifndef SIMULATION #ifdef WILC_P2P From 842f1d71f6a00aa3d0a6fa277585cd7713122e3f Mon Sep 17 00:00:00 2001 From: Johnny Kim Date: Wed, 10 Jun 2015 17:06:47 +0900 Subject: [PATCH 0892/1163] staging: wilc1000: remove uninitialized warnings This patch is for the initialization of the local variables. Signed-off-by: Johnny Kim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 2 +- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 3956c701c689..e92ba59382ef 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -2778,7 +2778,7 @@ late_initcall(init_wilc_driver); static void __exit exit_wilc_driver(void) { int i = 0; - perInterface_wlan_t *nic[NUM_CONCURRENT_IFC]; + perInterface_wlan_t *nic[NUM_CONCURRENT_IFC] = {NULL,}; #define CLOSE_TIMEOUT (12 * 1000) if ((g_linux_wlan != NULL) && (((g_linux_wlan->strInterfaceInfo[0].wilc_netdev) != NULL) diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 61f1f2010645..5844eba90b91 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -829,9 +829,9 @@ static int WILC_WFI_CfgConnect(struct wiphy *wiphy, struct net_device *dev, WILC_Uint32 i; u8 u8security = NO_ENCRYPT; AUTHTYPE_T tenuAuth_type = ANY; - WILC_Char *pcgroup_encrypt_val; - WILC_Char *pccipher_group; - WILC_Char *pcwpa_version; + WILC_Char *pcgroup_encrypt_val = NULL; + WILC_Char *pccipher_group = NULL; + WILC_Char *pcwpa_version = NULL; struct WILC_WFI_priv *priv; tstrWILC_WFIDrv *pstrWFIDrv; From 1fad279db55bb4482e8f661788102707a8a957c1 Mon Sep 17 00:00:00 2001 From: Stanislav Kholmanskikh Date: Wed, 10 Jun 2015 21:57:24 +0300 Subject: [PATCH 0893/1163] staging: wilc1000: coreconfigurator: Remove spaces before "\n" In accordance to checkpatch.pl, a space before a quoted newline ("\n") is unnecessary, therefore substituted " \n" with "\n" in coreconfigurator.c Signed-off-by: Stanislav Kholmanskikh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index e3e3f204624e..b54e43a36d62 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -672,14 +672,14 @@ INLINE WILC_Uint16 get_asoc_id(u8 *data) WILC_Sint32 CoreConfiguratorInit(void) { WILC_Sint32 s32Error = WILC_SUCCESS; - PRINT_D(CORECONFIG_DBG, "CoreConfiguratorInit() \n"); + PRINT_D(CORECONFIG_DBG, "CoreConfiguratorInit()\n"); sema_init(&SemHandleSendPkt, 1); sema_init(&SemHandlePktResp, 0); gps8ConfigPacket = (WILC_Sint8 *)WILC_MALLOC(MAX_PACKET_BUFF_SIZE); if (gps8ConfigPacket == NULL) { - PRINT_ER("failed in gps8ConfigPacket allocation \n"); + PRINT_ER("failed in gps8ConfigPacket allocation\n"); s32Error = WILC_NO_MEM; goto _fail_; } @@ -1444,7 +1444,7 @@ void ProcessAdrWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, void ProcessBinWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, tstrWID *pstrWID, u8 *pu8val, WILC_Sint32 s32ValueSize) { - /* WILC_ERROR("processing Binary WIDs is not supported \n"); */ + /* WILC_ERROR("processing Binary WIDs is not supported\n"); */ WILC_Uint16 u16MsgLen = 0; WILC_Uint16 idx = 0; @@ -1583,7 +1583,7 @@ WILC_Sint32 further_process_response(u8 *resp, WILC_memcpy(pstrWIDresult->ps8WidVal, cfg_str, cfg_len); /* mostafa: no need currently for the extra NULL byte */ pstrWIDresult->s32ValueSize = cfg_len; } else { - PRINT_ER("allocated WID buffer length is smaller than the received WID Length \n"); + PRINT_ER("allocated WID buffer length is smaller than the received WID Length\n"); retval = -2; } @@ -2027,7 +2027,7 @@ WILC_Sint32 ConfigProvideResponse(WILC_Char *pcRespBuffer, WILC_Sint32 s32RespLe } else { WILC_memcpy(gstrConfigPktInfo.pcRespBuffer, pcRespBuffer, gstrConfigPktInfo.s32MaxRespBuffLen); gstrConfigPktInfo.s32BytesRead = gstrConfigPktInfo.s32MaxRespBuffLen; - PRINT_ER("BusProvideResponse() Response greater than the prepared Buffer Size \n"); + PRINT_ER("BusProvideResponse() Response greater than the prepared Buffer Size\n"); } up(&SemHandlePktResp); @@ -2076,7 +2076,7 @@ WILC_Sint32 ConfigPktReceived(u8 *pu8RxPacket, WILC_Sint32 s32RxPacketLen) break; default: - PRINT_ER("ConfigPktReceived(): invalid received msg type at the Core Configurator \n"); + PRINT_ER("ConfigPktReceived(): invalid received msg type at the Core Configurator\n"); break; } @@ -2097,7 +2097,7 @@ WILC_Sint32 CoreConfiguratorDeInit(void) { WILC_Sint32 s32Error = WILC_SUCCESS; - PRINT_D(CORECONFIG_DBG, "CoreConfiguratorDeInit() \n"); + PRINT_D(CORECONFIG_DBG, "CoreConfiguratorDeInit()\n"); if (gps8ConfigPacket != NULL) { From cea3b20212ca8e897d472988d008682aaa44cbb6 Mon Sep 17 00:00:00 2001 From: Stanislav Kholmanskikh Date: Wed, 10 Jun 2015 21:57:25 +0300 Subject: [PATCH 0894/1163] staging: wilc1000: coreconfigurator: Change return(X) to return X Changed 'return(X)' to 'return X' in coreconfigurator.c to satisfy checkpatch.pl warning: ERROR: return is not a function, parentheses are not required Signed-off-by: Stanislav Kholmanskikh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index b54e43a36d62..b90eaf156b70 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -710,13 +710,13 @@ u8 *get_tim_elm(u8 *pu8msa, WILC_Uint16 u16RxLen, WILC_Uint16 u16TagParamOffset) /* Search for the TIM Element Field and return if the element is found */ while (u16index < (u16RxLen - FCS_LEN)) { if (pu8msa[u16index] == ITIM) { - return(&pu8msa[u16index]); + return &pu8msa[u16index]; } else { u16index += (IE_HDR_LEN + pu8msa[u16index + 1]); } } - return(0); + return 0; } /* This function gets the current channel information from @@ -728,7 +728,7 @@ u8 get_current_channel_802_11n(u8 *pu8msa, WILC_Uint16 u16RxLen) index = TAG_PARAM_OFFSET; while (index < (u16RxLen - FCS_LEN)) { if (pu8msa[index] == IDSPARMS) - return (pu8msa[index + 2]); + return pu8msa[index + 2]; else /* Increment index by length information and header */ index += pu8msa[index + 1] + IE_HDR_LEN; @@ -750,7 +750,7 @@ u8 get_current_channel(u8 *pu8msa, WILC_Uint16 u16RxLen) #else /* FIVE_GHZ_BAND */ /* Extract current channel information from */ /* the beacon/probe response frame */ - return (get_current_channel_802_11n(pu8msa, u16RxLen)); + return get_current_channel_802_11n(pu8msa, u16RxLen); #endif /* FIVE_GHZ_BAND */ #else return 0; From 13994d1e05290d5cc5dfc137c6dd135474f3d686 Mon Sep 17 00:00:00 2001 From: Stanislav Kholmanskikh Date: Wed, 10 Jun 2015 21:57:26 +0300 Subject: [PATCH 0895/1163] staging: wilc1000: coreconfigurator: Align enums and defines Aligned enum members and defines to follow a common style per enum/(group of defines). Signed-off-by: Stanislav Kholmanskikh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 29 +++++----- drivers/staging/wilc1000/coreconfigurator.h | 62 ++++++++++----------- 2 files changed, 46 insertions(+), 45 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index b90eaf156b70..3a6c5baf0abb 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -40,11 +40,12 @@ /*****************************************************************************/ /* Basic Frame Type Codes (2-bit) */ -typedef enum {FRAME_TYPE_CONTROL = 0x04, - FRAME_TYPE_DATA = 0x08, - FRAME_TYPE_MANAGEMENT = 0x00, - FRAME_TYPE_RESERVED = 0x0C, - FRAME_TYPE_FORCE_32BIT = 0xFFFFFFFF +typedef enum { + FRAME_TYPE_CONTROL = 0x04, + FRAME_TYPE_DATA = 0x08, + FRAME_TYPE_MANAGEMENT = 0x00, + FRAME_TYPE_RESERVED = 0x0C, + FRAME_TYPE_FORCE_32BIT = 0xFFFFFFFF } tenuBasicFrmType; /* Frame Type and Subtype Codes (6-bit) */ @@ -188,7 +189,7 @@ static tstrWID gastrWIDs[] = { {WID_QOS_ENABLE, WID_CHAR}, {WID_11I_MODE, WID_CHAR}, {WID_CURRENT_TX_RATE, WID_CHAR}, - {WID_LINKSPEED, WID_CHAR}, + {WID_LINKSPEED, WID_CHAR}, {WID_RTS_THRESHOLD, WID_SHORT}, {WID_FRAG_THRESHOLD, WID_SHORT}, {WID_SSID, WID_STR}, @@ -223,14 +224,14 @@ static tstrWID gastrWIDs[] = { {WID_MEMORY_ACCESS_32BIT, WID_INT}, {WID_MEMORY_ACCESS_16BIT, WID_SHORT}, {WID_MEMORY_ACCESS_8BIT, WID_CHAR}, - {WID_SITE_SURVEY_RESULTS, WID_STR}, - {WID_PMKID_INFO, WID_STR}, - {WID_ASSOC_RES_INFO, WID_STR}, - {WID_MANUFACTURER, WID_STR}, /* 4 Wids added for the CAPI tool*/ - {WID_MODEL_NAME, WID_STR}, - {WID_MODEL_NUM, WID_STR}, - {WID_DEVICE_NAME, WID_STR}, - {WID_SSID_PROBE_REQ, WID_STR}, + {WID_SITE_SURVEY_RESULTS, WID_STR}, + {WID_PMKID_INFO, WID_STR}, + {WID_ASSOC_RES_INFO, WID_STR}, + {WID_MANUFACTURER, WID_STR}, /* 4 Wids added for the CAPI tool*/ + {WID_MODEL_NAME, WID_STR}, + {WID_MODEL_NUM, WID_STR}, + {WID_DEVICE_NAME, WID_STR}, + {WID_SSID_PROBE_REQ, WID_STR}, #ifdef MAC_802_11N {WID_11N_ENABLE, WID_CHAR}, diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h index 73cdbef653ab..b8e52414ebcc 100644 --- a/drivers/staging/wilc1000/coreconfigurator.h +++ b/drivers/staging/wilc1000/coreconfigurator.h @@ -19,9 +19,9 @@ /*****************************************************************************/ /* Number of WID Options Supported */ #define NUM_BASIC_SWITCHES 45 -#define NUM_FHSS_SWITCHES 0 +#define NUM_FHSS_SWITCHES 0 -#define NUM_RSSI 5 +#define NUM_RSSI 5 #ifdef MAC_802_11N #define NUM_11N_BASIC_SWITCHES 25 @@ -51,14 +51,14 @@ extern WILC_Uint16 g_num_total_switches; #define MAX_PACKET_BUFF_SIZE 1596 -#define MAX_STRING_LEN 256 -#define MAX_SURVEY_RESULT_FRAG_SIZE MAX_STRING_LEN -#define SURVEY_RESULT_LENGTH 44 -#define MAX_ASSOC_RESP_FRAME_SIZE MAX_STRING_LEN +#define MAX_STRING_LEN 256 +#define MAX_SURVEY_RESULT_FRAG_SIZE MAX_STRING_LEN +#define SURVEY_RESULT_LENGTH 44 +#define MAX_ASSOC_RESP_FRAME_SIZE MAX_STRING_LEN -#define STATUS_MSG_LEN 12 -#define MAC_CONNECTED 1 -#define MAC_DISCONNECTED 0 +#define STATUS_MSG_LEN 12 +#define MAC_CONNECTED 1 +#define MAC_DISCONNECTED 0 @@ -327,10 +327,10 @@ typedef enum { WID_SUPP_PASSWORD = 0x3011, WID_SITE_SURVEY_RESULTS = 0x3012, WID_RX_POWER_LEVEL = 0x3013, - WID_MANUFACTURER = 0x3026, /*Added for CAPI tool */ - WID_MODEL_NAME = 0x3027, /*Added for CAPI tool */ - WID_MODEL_NUM = 0x3028, /*Added for CAPI tool */ - WID_DEVICE_NAME = 0x3029, /*Added for CAPI tool */ + WID_MANUFACTURER = 0x3026, /*Added for CAPI tool */ + WID_MODEL_NAME = 0x3027, /*Added for CAPI tool */ + WID_MODEL_NUM = 0x3028, /*Added for CAPI tool */ + WID_DEVICE_NAME = 0x3029, /*Added for CAPI tool */ WID_ASSOC_RES_INFO = 0x3020, @@ -362,9 +362,9 @@ typedef enum { WID_HUT_LOG_STATS = 0x4083, /*BugID_3746 WID to add IE to be added in next probe request*/ - WID_INFO_ELEMENT_PROBE = 0x4085, + WID_INFO_ELEMENT_PROBE = 0x4085, /*BugID_3746 WID to add IE to be added in next associate request*/ - WID_INFO_ELEMENT_ASSOCIATE = 0x4086, + WID_INFO_ELEMENT_ASSOCIATE = 0x4086, /* Miscellaneous WIDs */ WID_ALL = 0x7FFE, @@ -374,22 +374,22 @@ typedef enum { /* Status Codes for Authentication and Association Frames */ typedef enum { - SUCCESSFUL_STATUSCODE = 0, - UNSPEC_FAIL = 1, - UNSUP_CAP = 10, - REASOC_NO_ASOC = 11, - FAIL_OTHER = 12, - UNSUPT_ALG = 13, - AUTH_SEQ_FAIL = 14, - CHLNG_FAIL = 15, - AUTH_TIMEOUT = 16, - AP_FULL = 17, - UNSUP_RATE = 18, - SHORT_PREAMBLE_UNSUP = 19, - PBCC_UNSUP = 20, - CHANNEL_AGIL_UNSUP = 21, - SHORT_SLOT_UNSUP = 25, - OFDM_DSSS_UNSUP = 26, + SUCCESSFUL_STATUSCODE = 0, + UNSPEC_FAIL = 1, + UNSUP_CAP = 10, + REASOC_NO_ASOC = 11, + FAIL_OTHER = 12, + UNSUPT_ALG = 13, + AUTH_SEQ_FAIL = 14, + CHLNG_FAIL = 15, + AUTH_TIMEOUT = 16, + AP_FULL = 17, + UNSUP_RATE = 18, + SHORT_PREAMBLE_UNSUP = 19, + PBCC_UNSUP = 20, + CHANNEL_AGIL_UNSUP = 21, + SHORT_SLOT_UNSUP = 25, + OFDM_DSSS_UNSUP = 26, CONNECT_STS_FORCE_16_BIT = 0xFFFF } tenuConnectSts; From 7da308e1c4ce8a262d8744a1f8e09ddc025c1312 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Mon, 8 Jun 2015 22:27:07 -0400 Subject: [PATCH 0896/1163] staging:lustre: move tcpip abstraction Rename libcfs/linux/linux-tcpip.c to lnet/lnet/lib-socket.c Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/Makefile | 7 ++++--- .../libcfs/linux/linux-tcpip.c => lnet/lnet/lib-socket.c} | 3 ++- drivers/staging/lustre/lustre/libcfs/Makefile | 1 - 3 files changed, 6 insertions(+), 5 deletions(-) rename drivers/staging/lustre/{lustre/libcfs/linux/linux-tcpip.c => lnet/lnet/lib-socket.c} (99%) diff --git a/drivers/staging/lustre/lnet/lnet/Makefile b/drivers/staging/lustre/lnet/lnet/Makefile index 336b8ea4fdf6..52492fb10f85 100644 --- a/drivers/staging/lustre/lnet/lnet/Makefile +++ b/drivers/staging/lustre/lnet/lnet/Makefile @@ -1,5 +1,6 @@ obj-$(CONFIG_LNET) += lnet.o -lnet-y := api-ni.o config.o lib-me.o lib-msg.o lib-eq.o \ - lib-md.o lib-ptl.o lib-move.o module.o lo.o router.o \ - router_proc.o acceptor.o peer.o +lnet-y := api-ni.o config.o \ + lib-me.o lib-msg.o lib-eq.o lib-md.o lib-ptl.o \ + lib-socket.o lib-move.o module.o lo.o \ + router.o router_proc.o acceptor.o peer.o diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c similarity index 99% rename from drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c rename to drivers/staging/lustre/lnet/lnet/lib-socket.c index f2462e7f04bc..7f80612cd3e5 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c +++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c @@ -35,7 +35,8 @@ */ #define DEBUG_SUBSYSTEM S_LNET -#include "../../../include/linux/libcfs/libcfs.h" +#include "../../include/linux/libcfs/libcfs.h" +#include "../../include/linux/lnet/lib-lnet.h" #include #include diff --git a/drivers/staging/lustre/lustre/libcfs/Makefile b/drivers/staging/lustre/lustre/libcfs/Makefile index fabdd3e5de9e..ec98f44a10dd 100644 --- a/drivers/staging/lustre/lustre/libcfs/Makefile +++ b/drivers/staging/lustre/lustre/libcfs/Makefile @@ -2,7 +2,6 @@ obj-$(CONFIG_LUSTRE_FS) += libcfs.o libcfs-linux-objs := linux-tracefile.o linux-debug.o libcfs-linux-objs += linux-prim.o linux-cpu.o -libcfs-linux-objs += linux-tcpip.o libcfs-linux-objs += linux-curproc.o libcfs-linux-objs += linux-module.o libcfs-linux-objs += linux-crypto.o From e52fc91d4006f957e186ce3e2687544a06477531 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Mon, 8 Jun 2015 22:27:08 -0400 Subject: [PATCH 0897/1163] staging:lustre: remove useless libcfs_sock_release There is no reason to have a one line exported function libcfs_sock_release. Instead we can call sock_release directly. Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/libcfs.h | 1 - drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 2 +- drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h | 2 +- drivers/staging/lustre/lnet/lnet/acceptor.c | 8 ++++---- drivers/staging/lustre/lnet/lnet/lib-socket.c | 8 -------- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h index a789559b81c2..f46933357bc3 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h @@ -80,7 +80,6 @@ int libcfs_sock_getbuf(struct socket *socket, int *txbufsize, int *rxbufsize); int libcfs_sock_getaddr(struct socket *socket, int remote, __u32 *ip, int *port); int libcfs_sock_write(struct socket *sock, void *buffer, int nob, int timeout); int libcfs_sock_read(struct socket *sock, void *buffer, int nob, int timeout); -void libcfs_sock_release(struct socket *sock); /* need both kernel and user-land acceptor */ #define LNET_ACCEPTOR_MIN_RESERVED_PORT 512 diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index 7b5d4078ba4e..38e831f84abc 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -1386,7 +1386,7 @@ ksocknal_create_conn(lnet_ni_t *ni, ksock_route_t *route, LIBCFS_FREE(conn, sizeof(*conn)); failed_0: - libcfs_sock_release(sock); + sock_release(sock); return rc; } diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h index c34378c0220a..06531c1d2ffb 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h @@ -519,7 +519,7 @@ ksocknal_connsock_decref(ksock_conn_t *conn) LASSERT(atomic_read(&conn->ksnc_sock_refcount) > 0); if (atomic_dec_and_test(&conn->ksnc_sock_refcount)) { LASSERT(conn->ksnc_closing); - libcfs_sock_release(conn->ksnc_sock); + sock_release(conn->ksnc_sock); conn->ksnc_sock = NULL; ksocknal_finalize_zcreq(conn); } diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c index 954f8d3fcebc..1657106beab5 100644 --- a/drivers/staging/lustre/lnet/lnet/acceptor.c +++ b/drivers/staging/lustre/lnet/lnet/acceptor.c @@ -197,7 +197,7 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid, goto failed; failed_sock: - libcfs_sock_release(sock); + sock_release(sock); failed: lnet_connect_console_error(rc, peer_nid, peer_ip, peer_port); return rc; @@ -379,7 +379,7 @@ lnet_acceptor(void *arg) /* maybe we're waken up with libcfs_sock_abort_accept() */ if (lnet_acceptor_state.pta_shutdown) { - libcfs_sock_release(newsock); + sock_release(newsock); break; } @@ -410,10 +410,10 @@ lnet_acceptor(void *arg) continue; failed: - libcfs_sock_release(newsock); + sock_release(newsock); } - libcfs_sock_release(lnet_acceptor_state.pta_sock); + sock_release(lnet_acceptor_state.pta_sock); lnet_acceptor_state.pta_sock = NULL; CDEBUG(D_NET, "Acceptor stopping\n"); diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c index 7f80612cd3e5..259db61e216a 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-socket.c +++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c @@ -614,11 +614,3 @@ libcfs_sock_connect (struct socket **sockp, int *fatal, } EXPORT_SYMBOL(libcfs_sock_connect); - -void -libcfs_sock_release (struct socket *sock) -{ - sock_release(sock); -} - -EXPORT_SYMBOL(libcfs_sock_release); From 45bd3ebe32bff9c3b45eb2d0f9a7c15157be060d Mon Sep 17 00:00:00 2001 From: James Simmons Date: Mon, 8 Jun 2015 22:27:09 -0400 Subject: [PATCH 0898/1163] staging:lustre: remove useless libcfs_sock_abort_accept Another one of those silly one line wrappers which is not needed. Replace libcfs_sock_abort_accept wrapper with a direct call to wake_up_all on the lnet_acceptor_state sock. Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/libcfs.h | 1 - drivers/staging/lustre/lnet/lnet/acceptor.c | 4 ++-- drivers/staging/lustre/lnet/lnet/lib-socket.c | 8 -------- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h index f46933357bc3..457ce9ad74da 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h @@ -71,7 +71,6 @@ int libcfs_ipif_enumerate(char ***names); void libcfs_ipif_free_enumeration(char **names, int n); int libcfs_sock_listen(struct socket **sockp, __u32 ip, int port, int backlog); int libcfs_sock_accept(struct socket **newsockp, struct socket *sock); -void libcfs_sock_abort_accept(struct socket *sock); int libcfs_sock_connect(struct socket **sockp, int *fatal, __u32 local_ip, int local_port, __u32 peer_ip, int peer_port); diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c index 1657106beab5..246a5835a9e6 100644 --- a/drivers/staging/lustre/lnet/lnet/acceptor.c +++ b/drivers/staging/lustre/lnet/lnet/acceptor.c @@ -377,7 +377,7 @@ lnet_acceptor(void *arg) continue; } - /* maybe we're waken up with libcfs_sock_abort_accept() */ + /* maybe the LNet acceptor thread has been waken */ if (lnet_acceptor_state.pta_shutdown) { sock_release(newsock); break; @@ -493,7 +493,7 @@ lnet_acceptor_stop(void) return; lnet_acceptor_state.pta_shutdown = 1; - libcfs_sock_abort_accept(lnet_acceptor_state.pta_sock); + wake_up_all(sk_sleep(lnet_acceptor_state.pta_sock->sk)); /* block until acceptor signals exit */ wait_for_completion(&lnet_acceptor_state.pta_signal); diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c index 259db61e216a..bb8d9c2a0da6 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-socket.c +++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c @@ -568,14 +568,6 @@ libcfs_sock_accept (struct socket **newsockp, struct socket *sock) EXPORT_SYMBOL(libcfs_sock_accept); -void -libcfs_sock_abort_accept (struct socket *sock) -{ - wake_up_all(sk_sleep(sock->sk)); -} - -EXPORT_SYMBOL(libcfs_sock_abort_accept); - int libcfs_sock_connect (struct socket **sockp, int *fatal, __u32 local_ip, int local_port, From 1ad6a73ef2bb2a13a60ea804ea7a4cbfc857bcb8 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Mon, 8 Jun 2015 22:27:10 -0400 Subject: [PATCH 0899/1163] staging:lustre: rename tcpip handling functions to lnet_* prefix With all the TCPIP handling done in the lnet layer we should rename all the functions with the prefix lnet_*. One other change done was changing the remove argument of lnet_sock_getaddr from a int to a bool. Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/libcfs/libcfs.h | 15 ----- .../lustre/include/linux/lnet/lib-lnet.h | 16 +++++ .../lustre/lnet/klnds/o2iblnd/o2iblnd.c | 2 +- .../lustre/lnet/klnds/socklnd/socklnd.c | 11 ++-- .../lustre/lnet/klnds/socklnd/socklnd_cb.c | 6 +- .../lnet/klnds/socklnd/socklnd_lib-linux.c | 15 ++--- .../lustre/lnet/klnds/socklnd/socklnd_proto.c | 43 ++++++------ drivers/staging/lustre/lnet/lnet/acceptor.c | 43 ++++++------ drivers/staging/lustre/lnet/lnet/config.c | 21 +++--- drivers/staging/lustre/lnet/lnet/lib-socket.c | 66 +++++++++---------- 10 files changed, 110 insertions(+), 128 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h index 457ce9ad74da..5dd9cdfae30c 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h @@ -65,21 +65,6 @@ static inline int __is_po2(unsigned long long val) int libcfs_arch_init(void); void libcfs_arch_cleanup(void); -/* libcfs tcpip */ -int libcfs_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask); -int libcfs_ipif_enumerate(char ***names); -void libcfs_ipif_free_enumeration(char **names, int n); -int libcfs_sock_listen(struct socket **sockp, __u32 ip, int port, int backlog); -int libcfs_sock_accept(struct socket **newsockp, struct socket *sock); -int libcfs_sock_connect(struct socket **sockp, int *fatal, - __u32 local_ip, int local_port, - __u32 peer_ip, int peer_port); -int libcfs_sock_setbuf(struct socket *socket, int txbufsize, int rxbufsize); -int libcfs_sock_getbuf(struct socket *socket, int *txbufsize, int *rxbufsize); -int libcfs_sock_getaddr(struct socket *socket, int remote, __u32 *ip, int *port); -int libcfs_sock_write(struct socket *sock, void *buffer, int nob, int timeout); -int libcfs_sock_read(struct socket *sock, void *buffer, int nob, int timeout); - /* need both kernel and user-land acceptor */ #define LNET_ACCEPTOR_MIN_RESERVED_PORT 512 #define LNET_ACCEPTOR_MAX_RESERVED_PORT 1023 diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index de9e097b0ecd..ac3be9486e8f 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -639,6 +639,22 @@ int lnet_acceptor_port(void); int lnet_acceptor_start(void); void lnet_acceptor_stop(void); +int lnet_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask); +int lnet_ipif_enumerate(char ***names); +void lnet_ipif_free_enumeration(char **names, int n); +int lnet_sock_setbuf(struct socket *socket, int txbufsize, int rxbufsize); +int lnet_sock_getbuf(struct socket *socket, int *txbufsize, int *rxbufsize); +int lnet_sock_getaddr(struct socket *socket, bool remote, __u32 *ip, int *port); +int lnet_sock_write(struct socket *sock, void *buffer, int nob, int timeout); +int lnet_sock_read(struct socket *sock, void *buffer, int nob, int timeout); + +int lnet_sock_listen(struct socket **sockp, __u32 ip, int port, int backlog); +int lnet_sock_accept(struct socket **newsockp, struct socket *sock); +int lnet_sock_connect(struct socket **sockp, int *fatal, + __u32 local_ip, int local_port, + __u32 peer_ip, int peer_port); +void libcfs_sock_release(struct socket *sock); + void lnet_get_tunables(void); int lnet_peers_start_down(void); int lnet_peer_buffer_credits(lnet_ni_t *ni); diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index a57c5c35ee68..060b7399e921 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -2617,7 +2617,7 @@ static kib_dev_t *kiblnd_create_dev(char *ifname) int up; int rc; - rc = libcfs_ipif_query(ifname, &up, &ip, &netmask); + rc = lnet_ipif_query(ifname, &up, &ip, &netmask); if (rc != 0) { CERROR("Can't query IPoIB interface %s: %d\n", ifname, rc); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index 38e831f84abc..ee5cf35422d0 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -968,7 +968,7 @@ ksocknal_accept(lnet_ni_t *ni, struct socket *sock) __u32 peer_ip; int peer_port; - rc = libcfs_sock_getaddr(sock, 1, &peer_ip, &peer_port); + rc = lnet_sock_getaddr(sock, 1, &peer_ip, &peer_port); LASSERT(rc == 0); /* we succeeded before */ LIBCFS_ALLOC(cr, sizeof(*cr)); @@ -2594,7 +2594,7 @@ ksocknal_enumerate_interfaces(ksock_net_t *net) int rc; int n; - n = libcfs_ipif_enumerate(&names); + n = lnet_ipif_enumerate(&names); if (n <= 0) { CERROR("Can't enumerate interfaces: %d\n", n); return n; @@ -2608,7 +2608,7 @@ ksocknal_enumerate_interfaces(ksock_net_t *net) if (!strcmp(names[i], "lo")) /* skip the loopback IF */ continue; - rc = libcfs_ipif_query(names[i], &up, &ip, &mask); + rc = lnet_ipif_query(names[i], &up, &ip, &mask); if (rc != 0) { CWARN("Can't get interface %s info: %d\n", names[i], rc); @@ -2634,7 +2634,7 @@ ksocknal_enumerate_interfaces(ksock_net_t *net) j++; } - libcfs_ipif_free_enumeration(names, n); + lnet_ipif_free_enumeration(names, n); if (j == 0) CERROR("Can't find any usable interfaces\n"); @@ -2796,8 +2796,7 @@ ksocknal_startup(lnet_ni_t *ni) if (ni->ni_interfaces[i] == NULL) break; - rc = libcfs_ipif_query( - ni->ni_interfaces[i], &up, + rc = lnet_ipif_query(ni->ni_interfaces[i], &up, &net->ksnn_interfaces[i].ksni_ipaddr, &net->ksnn_interfaces[i].ksni_netmask); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index a1a4ac027fb5..fe2a83a540cd 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -1707,7 +1707,7 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, timeout = active ? *ksocknal_tunables.ksnd_timeout : lnet_acceptor_timeout(); - rc = libcfs_sock_read(sock, &hello->kshm_magic, sizeof (hello->kshm_magic), timeout); + rc = lnet_sock_read(sock, &hello->kshm_magic, sizeof (hello->kshm_magic), timeout); if (rc != 0) { CERROR("Error %d reading HELLO from %pI4h\n", rc, &conn->ksnc_ipaddr); @@ -1726,8 +1726,8 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, return -EPROTO; } - rc = libcfs_sock_read(sock, &hello->kshm_version, - sizeof(hello->kshm_version), timeout); + rc = lnet_sock_read(sock, &hello->kshm_version, + sizeof(hello->kshm_version), timeout); if (rc != 0) { CERROR("Error %d reading HELLO from %pI4h\n", rc, &conn->ksnc_ipaddr); 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 caeb3477da97..34c6a728b71b 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c @@ -39,9 +39,8 @@ int ksocknal_lib_get_conn_addrs(ksock_conn_t *conn) { - int rc = libcfs_sock_getaddr(conn->ksnc_sock, 1, - &conn->ksnc_ipaddr, - &conn->ksnc_port); + int rc = lnet_sock_getaddr(conn->ksnc_sock, 1, &conn->ksnc_ipaddr, + &conn->ksnc_port); /* Didn't need the {get,put}connsock dance to deref ksnc_sock... */ LASSERT(!conn->ksnc_closing); @@ -51,8 +50,7 @@ ksocknal_lib_get_conn_addrs(ksock_conn_t *conn) return rc; } - rc = libcfs_sock_getaddr(conn->ksnc_sock, 0, - &conn->ksnc_myipaddr, NULL); + rc = lnet_sock_getaddr(conn->ksnc_sock, 0, &conn->ksnc_myipaddr, NULL); if (rc != 0) { CERROR("Error %d getting sock local IP\n", rc); return rc; @@ -436,7 +434,7 @@ ksocknal_lib_get_conn_tunables(ksock_conn_t *conn, int *txmem, int *rxmem, int * return -ESHUTDOWN; } - rc = libcfs_sock_getbuf(sock, txmem, rxmem); + rc = lnet_sock_getbuf(sock, txmem, rxmem); if (rc == 0) { len = sizeof(*nagle); rc = kernel_getsockopt(sock, SOL_TCP, TCP_NODELAY, @@ -498,9 +496,8 @@ ksocknal_lib_setup_sock(struct socket *sock) } } - rc = libcfs_sock_setbuf(sock, - *ksocknal_tunables.ksnd_tx_buffer_size, - *ksocknal_tunables.ksnd_rx_buffer_size); + rc = lnet_sock_setbuf(sock, *ksocknal_tunables.ksnd_tx_buffer_size, + *ksocknal_tunables.ksnd_rx_buffer_size); if (rc != 0) { CERROR("Can't set buffer tx %d, rx %d buffers: %d\n", *ksocknal_tunables.ksnd_tx_buffer_size, diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c index 1938d6a9b3a4..986bce4c9f3b 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c @@ -495,9 +495,7 @@ ksocknal_send_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello) hdr->msg.hello.type = cpu_to_le32 (hello->kshm_ctype); hdr->msg.hello.incarnation = cpu_to_le64 (hello->kshm_src_incarnation); - rc = libcfs_sock_write(sock, hdr, sizeof(*hdr), - lnet_acceptor_timeout()); - + rc = lnet_sock_write(sock, hdr, sizeof(*hdr), lnet_acceptor_timeout()); if (rc != 0) { CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n", rc, &conn->ksnc_ipaddr, conn->ksnc_port); @@ -511,9 +509,9 @@ ksocknal_send_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello) hello->kshm_ips[i] = __cpu_to_le32 (hello->kshm_ips[i]); } - rc = libcfs_sock_write(sock, hello->kshm_ips, - hello->kshm_nips * sizeof(__u32), - lnet_acceptor_timeout()); + rc = lnet_sock_write(sock, hello->kshm_ips, + hello->kshm_nips * sizeof(__u32), + lnet_acceptor_timeout()); if (rc != 0) { CNETERR("Error %d sending HELLO payload (%d) to %pI4h/%d\n", rc, hello->kshm_nips, @@ -544,9 +542,8 @@ ksocknal_send_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello) LNET_UNLOCK(); } - rc = libcfs_sock_write(sock, hello, offsetof(ksock_hello_msg_t, kshm_ips), - lnet_acceptor_timeout()); - + rc = lnet_sock_write(sock, hello, offsetof(ksock_hello_msg_t, kshm_ips), + lnet_acceptor_timeout()); if (rc != 0) { CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n", rc, &conn->ksnc_ipaddr, conn->ksnc_port); @@ -556,9 +553,9 @@ ksocknal_send_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello) if (hello->kshm_nips == 0) return 0; - rc = libcfs_sock_write(sock, hello->kshm_ips, - hello->kshm_nips * sizeof(__u32), - lnet_acceptor_timeout()); + rc = lnet_sock_write(sock, hello->kshm_ips, + hello->kshm_nips * sizeof(__u32), + lnet_acceptor_timeout()); if (rc != 0) { CNETERR("Error %d sending HELLO payload (%d) to %pI4h/%d\n", rc, hello->kshm_nips, @@ -583,9 +580,9 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello, return -ENOMEM; } - rc = libcfs_sock_read(sock, &hdr->src_nid, - sizeof(*hdr) - offsetof(lnet_hdr_t, src_nid), - timeout); + rc = lnet_sock_read(sock, &hdr->src_nid, + sizeof(*hdr) - offsetof(lnet_hdr_t, src_nid), + timeout); if (rc != 0) { CERROR("Error %d reading rest of HELLO hdr from %pI4h\n", rc, &conn->ksnc_ipaddr); @@ -619,8 +616,8 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello, if (hello->kshm_nips == 0) goto out; - rc = libcfs_sock_read(sock, hello->kshm_ips, - hello->kshm_nips * sizeof(__u32), timeout); + rc = lnet_sock_read(sock, hello->kshm_ips, + hello->kshm_nips * sizeof(__u32), timeout); if (rc != 0) { CERROR("Error %d reading IPs from ip %pI4h\n", rc, &conn->ksnc_ipaddr); @@ -656,10 +653,10 @@ ksocknal_recv_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeout else conn->ksnc_flip = 1; - rc = libcfs_sock_read(sock, &hello->kshm_src_nid, - offsetof(ksock_hello_msg_t, kshm_ips) - - offsetof(ksock_hello_msg_t, kshm_src_nid), - timeout); + rc = lnet_sock_read(sock, &hello->kshm_src_nid, + offsetof(ksock_hello_msg_t, kshm_ips) - + offsetof(ksock_hello_msg_t, kshm_src_nid), + timeout); if (rc != 0) { CERROR("Error %d reading HELLO from %pI4h\n", rc, &conn->ksnc_ipaddr); @@ -687,8 +684,8 @@ ksocknal_recv_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeout if (hello->kshm_nips == 0) return 0; - rc = libcfs_sock_read(sock, hello->kshm_ips, - hello->kshm_nips * sizeof(__u32), timeout); + rc = lnet_sock_read(sock, hello->kshm_ips, + hello->kshm_nips * sizeof(__u32), timeout); if (rc != 0) { CERROR("Error %d reading IPs from ip %pI4h\n", rc, &conn->ksnc_ipaddr); diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c index 246a5835a9e6..be850353d02d 100644 --- a/drivers/staging/lustre/lnet/lnet/acceptor.c +++ b/drivers/staging/lustre/lnet/lnet/acceptor.c @@ -155,9 +155,8 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid, --port) { /* Iterate through reserved ports. */ - rc = libcfs_sock_connect(&sock, &fatal, - local_ip, port, - peer_ip, peer_port); + rc = lnet_sock_connect(&sock, &fatal, local_ip, port, peer_ip, + peer_port); if (rc != 0) { if (fatal) goto failed; @@ -184,8 +183,7 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid, lnet_net_unlock(LNET_LOCK_EX); } - rc = libcfs_sock_write(sock, &cr, sizeof(cr), - accept_timeout); + rc = lnet_sock_write(sock, &cr, sizeof(cr), accept_timeout); if (rc != 0) goto failed_sock; @@ -220,7 +218,7 @@ lnet_accept(struct socket *sock, __u32 magic) LASSERT(sizeof(cr) <= 16); /* not too big for the stack */ - rc = libcfs_sock_getaddr(sock, 1, &peer_ip, &peer_port); + rc = lnet_sock_getaddr(sock, 1, &peer_ip, &peer_port); LASSERT(rc == 0); /* we succeeded before */ if (!lnet_accept_magic(magic, LNET_PROTO_ACCEPTOR_MAGIC)) { @@ -234,8 +232,8 @@ lnet_accept(struct socket *sock, __u32 magic) memset(&cr, 0, sizeof(cr)); cr.acr_magic = LNET_PROTO_ACCEPTOR_MAGIC; cr.acr_version = LNET_PROTO_ACCEPTOR_VERSION; - rc = libcfs_sock_write(sock, &cr, sizeof(cr), - accept_timeout); + rc = lnet_sock_write(sock, &cr, sizeof(cr), + accept_timeout); if (rc != 0) CERROR("Error sending magic+version in response to LNET magic from %pI4h: %d\n", @@ -257,9 +255,8 @@ lnet_accept(struct socket *sock, __u32 magic) flip = (magic != LNET_PROTO_ACCEPTOR_MAGIC); - rc = libcfs_sock_read(sock, &cr.acr_version, - sizeof(cr.acr_version), - accept_timeout); + rc = lnet_sock_read(sock, &cr.acr_version, sizeof(cr.acr_version), + accept_timeout); if (rc != 0) { CERROR("Error %d reading connection request version from %pI4h\n", rc, &peer_ip); @@ -280,19 +277,17 @@ lnet_accept(struct socket *sock, __u32 magic) cr.acr_magic = LNET_PROTO_ACCEPTOR_MAGIC; cr.acr_version = LNET_PROTO_ACCEPTOR_VERSION; - rc = libcfs_sock_write(sock, &cr, sizeof(cr), - accept_timeout); - + rc = lnet_sock_write(sock, &cr, sizeof(cr), accept_timeout); if (rc != 0) CERROR("Error sending magic+version in response to version %d from %pI4h: %d\n", peer_version, &peer_ip, rc); return -EPROTO; } - rc = libcfs_sock_read(sock, &cr.acr_nid, - sizeof(cr) - - offsetof(lnet_acceptor_connreq_t, acr_nid), - accept_timeout); + rc = lnet_sock_read(sock, &cr.acr_nid, + sizeof(cr) - + offsetof(lnet_acceptor_connreq_t, acr_nid), + accept_timeout); if (rc != 0) { CERROR("Error %d reading connection request from %pI4h\n", rc, &peer_ip); @@ -343,8 +338,8 @@ lnet_acceptor(void *arg) cfs_block_allsigs(); - rc = libcfs_sock_listen(&lnet_acceptor_state.pta_sock, - 0, accept_port, accept_backlog); + rc = lnet_sock_listen(&lnet_acceptor_state.pta_sock, 0, accept_port, + accept_backlog); if (rc != 0) { if (rc == -EADDRINUSE) LCONSOLE_ERROR_MSG(0x122, "Can't start acceptor on port %d: port already in use\n", @@ -367,7 +362,7 @@ lnet_acceptor(void *arg) while (!lnet_acceptor_state.pta_shutdown) { - rc = libcfs_sock_accept(&newsock, lnet_acceptor_state.pta_sock); + rc = lnet_sock_accept(&newsock, lnet_acceptor_state.pta_sock); if (rc != 0) { if (rc != -EAGAIN) { CWARN("Accept error %d: pausing...\n", rc); @@ -383,7 +378,7 @@ lnet_acceptor(void *arg) break; } - rc = libcfs_sock_getaddr(newsock, 1, &peer_ip, &peer_port); + rc = lnet_sock_getaddr(newsock, 1, &peer_ip, &peer_port); if (rc != 0) { CERROR("Can't determine new connection's address\n"); goto failed; @@ -395,8 +390,8 @@ lnet_acceptor(void *arg) goto failed; } - rc = libcfs_sock_read(newsock, &magic, sizeof(magic), - accept_timeout); + rc = lnet_sock_read(newsock, &magic, sizeof(magic), + accept_timeout); if (rc != 0) { CERROR("Error %d reading connection request from %pI4h\n", rc, &peer_ip); diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c index 70bc8096b66b..efbb74a9e4e6 100644 --- a/drivers/staging/lustre/lnet/lnet/config.c +++ b/drivers/staging/lustre/lnet/lnet/config.c @@ -1118,7 +1118,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp) __u32 *ipaddrs2; int nip; char **ifnames; - int nif = libcfs_ipif_enumerate(&ifnames); + int nif = lnet_ipif_enumerate(&ifnames); int i; int rc; @@ -1128,7 +1128,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp) LIBCFS_ALLOC(ipaddrs, nif * sizeof(*ipaddrs)); if (ipaddrs == NULL) { CERROR("Can't allocate ipaddrs[%d]\n", nif); - libcfs_ipif_free_enumeration(ifnames, nif); + lnet_ipif_free_enumeration(ifnames, nif); return -ENOMEM; } @@ -1136,8 +1136,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp) if (!strcmp(ifnames[i], "lo")) continue; - rc = libcfs_ipif_query(ifnames[i], &up, - &ipaddrs[nip], &netmask); + rc = lnet_ipif_query(ifnames[i], &up, &ipaddrs[nip], &netmask); if (rc != 0) { CWARN("Can't query interface %s: %d\n", ifnames[i], rc); @@ -1153,7 +1152,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp) nip++; } - libcfs_ipif_free_enumeration(ifnames, nif); + lnet_ipif_free_enumeration(ifnames, nif); if (nip == nif) { *ipaddrsp = ipaddrs; @@ -1237,8 +1236,7 @@ lnet_set_ip_niaddr(lnet_ni_t *ni) return -EPERM; } - rc = libcfs_ipif_query(ni->ni_interfaces[0], - &up, &ip, &netmask); + rc = lnet_ipif_query(ni->ni_interfaces[0], &up, &ip, &netmask); if (rc != 0) { CERROR("Net %s can't query interface %s: %d\n", libcfs_net2str(net), ni->ni_interfaces[0], rc); @@ -1255,7 +1253,7 @@ lnet_set_ip_niaddr(lnet_ni_t *ni) return 0; } - n = libcfs_ipif_enumerate(&names); + n = lnet_ipif_enumerate(&names); if (n <= 0) { CERROR("Net %s can't enumerate interfaces: %d\n", libcfs_net2str(net), n); @@ -1266,8 +1264,7 @@ lnet_set_ip_niaddr(lnet_ni_t *ni) if (!strcmp(names[i], "lo")) /* skip the loopback IF */ continue; - rc = libcfs_ipif_query(names[i], &up, &ip, &netmask); - + rc = lnet_ipif_query(names[i], &up, &ip, &netmask); if (rc != 0) { CWARN("Net %s can't query interface %s: %d\n", libcfs_net2str(net), names[i], rc); @@ -1280,13 +1277,13 @@ lnet_set_ip_niaddr(lnet_ni_t *ni) continue; } - libcfs_ipif_free_enumeration(names, n); + lnet_ipif_free_enumeration(names, n); ni->ni_nid = LNET_MKNID(net, ip); return 0; } CERROR("Net %s can't find any interfaces\n", libcfs_net2str(net)); - libcfs_ipif_free_enumeration(names, n); + lnet_ipif_free_enumeration(names, n); return -ENOENT; } EXPORT_SYMBOL(lnet_set_ip_niaddr); diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c index bb8d9c2a0da6..2e87168bbf54 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-socket.c +++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c @@ -45,7 +45,7 @@ #include static int -libcfs_sock_ioctl(int cmd, unsigned long arg) +lnet_sock_ioctl(int cmd, unsigned long arg) { mm_segment_t oldmm = get_fs(); struct socket *sock; @@ -76,7 +76,7 @@ out: } int -libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask) +lnet_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask) { struct ifreq ifr; int nob; @@ -92,8 +92,7 @@ libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask) CLASSERT (sizeof(ifr.ifr_name) >= IFNAMSIZ); strcpy(ifr.ifr_name, name); - rc = libcfs_sock_ioctl(SIOCGIFFLAGS, (unsigned long)&ifr); - + rc = lnet_sock_ioctl(SIOCGIFFLAGS, (unsigned long)&ifr); if (rc != 0) { CERROR("Can't get flags for interface %s\n", name); return rc; @@ -110,8 +109,7 @@ libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask) strcpy(ifr.ifr_name, name); ifr.ifr_addr.sa_family = AF_INET; - rc = libcfs_sock_ioctl(SIOCGIFADDR, (unsigned long)&ifr); - + rc = lnet_sock_ioctl(SIOCGIFADDR, (unsigned long)&ifr); if (rc != 0) { CERROR("Can't get IP address for interface %s\n", name); return rc; @@ -122,8 +120,7 @@ libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask) strcpy(ifr.ifr_name, name); ifr.ifr_addr.sa_family = AF_INET; - rc = libcfs_sock_ioctl(SIOCGIFNETMASK, (unsigned long)&ifr); - + rc = lnet_sock_ioctl(SIOCGIFNETMASK, (unsigned long)&ifr); if (rc != 0) { CERROR("Can't get netmask for interface %s\n", name); return rc; @@ -135,10 +132,10 @@ libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask) return 0; } -EXPORT_SYMBOL(libcfs_ipif_query); +EXPORT_SYMBOL(lnet_ipif_query); int -libcfs_ipif_enumerate (char ***namesp) +lnet_ipif_enumerate (char ***namesp) { /* Allocate and fill in 'names', returning # interfaces/error */ char **names; @@ -172,8 +169,7 @@ libcfs_ipif_enumerate (char ***namesp) ifc.ifc_buf = (char *)ifr; ifc.ifc_len = nalloc * sizeof(*ifr); - rc = libcfs_sock_ioctl(SIOCGIFCONF, (unsigned long)&ifc); - + rc = lnet_sock_ioctl(SIOCGIFCONF, (unsigned long)&ifc); if (rc < 0) { CERROR ("Error %d enumerating interfaces\n", rc); goto out1; @@ -226,17 +222,17 @@ libcfs_ipif_enumerate (char ***namesp) out2: if (rc < 0) - libcfs_ipif_free_enumeration(names, nfound); + lnet_ipif_free_enumeration(names, nfound); out1: LIBCFS_FREE(ifr, nalloc * sizeof(*ifr)); out0: return rc; } -EXPORT_SYMBOL(libcfs_ipif_enumerate); +EXPORT_SYMBOL(lnet_ipif_enumerate); void -libcfs_ipif_free_enumeration (char **names, int n) +lnet_ipif_free_enumeration (char **names, int n) { int i; @@ -248,10 +244,10 @@ libcfs_ipif_free_enumeration (char **names, int n) LIBCFS_FREE(names, n * sizeof(*names)); } -EXPORT_SYMBOL(libcfs_ipif_free_enumeration); +EXPORT_SYMBOL(lnet_ipif_free_enumeration); int -libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout) +lnet_sock_write (struct socket *sock, void *buffer, int nob, int timeout) { int rc; long ticks = timeout * HZ; @@ -310,10 +306,10 @@ libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout) return 0; } -EXPORT_SYMBOL(libcfs_sock_write); +EXPORT_SYMBOL(lnet_sock_write); int -libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout) +lnet_sock_read (struct socket *sock, void *buffer, int nob, int timeout) { int rc; long ticks = timeout * HZ; @@ -366,10 +362,10 @@ libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout) } } -EXPORT_SYMBOL(libcfs_sock_read); +EXPORT_SYMBOL(lnet_sock_read); static int -libcfs_sock_create (struct socket **sockp, int *fatal, +lnet_sock_create (struct socket **sockp, int *fatal, __u32 local_ip, int local_port) { struct sockaddr_in locaddr; @@ -424,7 +420,7 @@ libcfs_sock_create (struct socket **sockp, int *fatal, } int -libcfs_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize) +lnet_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize) { int option; int rc; @@ -454,10 +450,10 @@ libcfs_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize) return 0; } -EXPORT_SYMBOL(libcfs_sock_setbuf); +EXPORT_SYMBOL(lnet_sock_setbuf); int -libcfs_sock_getaddr (struct socket *sock, int remote, __u32 *ip, int *port) +lnet_sock_getaddr (struct socket *sock, bool remote, __u32 *ip, int *port) { struct sockaddr_in sin; int len = sizeof (sin); @@ -480,10 +476,10 @@ libcfs_sock_getaddr (struct socket *sock, int remote, __u32 *ip, int *port) return 0; } -EXPORT_SYMBOL(libcfs_sock_getaddr); +EXPORT_SYMBOL(lnet_sock_getaddr); int -libcfs_sock_getbuf (struct socket *sock, int *txbufsize, int *rxbufsize) +lnet_sock_getbuf (struct socket *sock, int *txbufsize, int *rxbufsize) { if (txbufsize != NULL) { @@ -497,16 +493,16 @@ libcfs_sock_getbuf (struct socket *sock, int *txbufsize, int *rxbufsize) return 0; } -EXPORT_SYMBOL(libcfs_sock_getbuf); +EXPORT_SYMBOL(lnet_sock_getbuf); int -libcfs_sock_listen (struct socket **sockp, +lnet_sock_listen (struct socket **sockp, __u32 local_ip, int local_port, int backlog) { int fatal; int rc; - rc = libcfs_sock_create(sockp, &fatal, local_ip, local_port); + rc = lnet_sock_create(sockp, &fatal, local_ip, local_port); if (rc != 0) { if (!fatal) CERROR("Can't create socket: port %d already in use\n", @@ -523,10 +519,10 @@ libcfs_sock_listen (struct socket **sockp, return rc; } -EXPORT_SYMBOL(libcfs_sock_listen); +EXPORT_SYMBOL(lnet_sock_listen); int -libcfs_sock_accept (struct socket **newsockp, struct socket *sock) +lnet_sock_accept (struct socket **newsockp, struct socket *sock) { wait_queue_t wait; struct socket *newsock; @@ -566,17 +562,17 @@ libcfs_sock_accept (struct socket **newsockp, struct socket *sock) return rc; } -EXPORT_SYMBOL(libcfs_sock_accept); +EXPORT_SYMBOL(lnet_sock_accept); int -libcfs_sock_connect (struct socket **sockp, int *fatal, +lnet_sock_connect (struct socket **sockp, int *fatal, __u32 local_ip, int local_port, __u32 peer_ip, int peer_port) { struct sockaddr_in srvaddr; int rc; - rc = libcfs_sock_create(sockp, fatal, local_ip, local_port); + rc = lnet_sock_create(sockp, fatal, local_ip, local_port); if (rc != 0) return rc; @@ -605,4 +601,4 @@ libcfs_sock_connect (struct socket **sockp, int *fatal, return rc; } -EXPORT_SYMBOL(libcfs_sock_connect); +EXPORT_SYMBOL(lnet_sock_connect); From 5c2414ef1cac1dcdc0a8b67ad6966935fba9d284 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Mon, 8 Jun 2015 22:27:11 -0400 Subject: [PATCH 0900/1163] staging:lustre: use available kernel wrappers in lib-socket.c Instead of handling calls to struct proto ourselves we can use equivalent kernel wrappers. No wrapper exist for unlocked ioctl handling so we create one here for our use. I expect some day that function will be integrated into sock.c. Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/lib-socket.c | 51 ++++++++++++------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c index 2e87168bbf54..2d46a69c0afa 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-socket.c +++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c @@ -35,22 +35,37 @@ */ #define DEBUG_SUBSYSTEM S_LNET +#include +#include +#include +#include +#include +/* For sys_open & sys_close */ +#include +#include + #include "../../include/linux/libcfs/libcfs.h" #include "../../include/linux/lnet/lib-lnet.h" -#include -#include -#include -/* For sys_open & sys_close */ -#include +static int +kernel_sock_unlocked_ioctl(struct file *filp, int cmd, unsigned long arg) +{ + mm_segment_t oldfs = get_fs(); + int err; + + set_fs(KERNEL_DS); + err = filp->f_op->unlocked_ioctl(filp, cmd, arg); + set_fs(oldfs); + + return err; +} static int lnet_sock_ioctl(int cmd, unsigned long arg) { - mm_segment_t oldmm = get_fs(); + struct file *sock_filp; struct socket *sock; int rc; - struct file *sock_filp; rc = sock_create (PF_INET, SOCK_STREAM, 0, &sock); if (rc != 0) { @@ -65,10 +80,7 @@ lnet_sock_ioctl(int cmd, unsigned long arg) 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); + rc = kernel_sock_unlocked_ioctl(sock_filp, cmd, arg); fput(sock_filp); out: @@ -398,8 +410,8 @@ lnet_sock_create (struct socket **sockp, int *fatal, locaddr.sin_addr.s_addr = (local_ip == 0) ? INADDR_ANY : htonl(local_ip); - rc = sock->ops->bind(sock, (struct sockaddr *)&locaddr, - sizeof(locaddr)); + rc = kernel_bind(sock, (struct sockaddr *)&locaddr, + sizeof(locaddr)); if (rc == -EADDRINUSE) { CDEBUG(D_NET, "Port %d already in use\n", local_port); *fatal = 0; @@ -459,8 +471,10 @@ lnet_sock_getaddr (struct socket *sock, bool remote, __u32 *ip, int *port) int len = sizeof (sin); int rc; - rc = sock->ops->getname (sock, (struct sockaddr *)&sin, &len, - remote ? 2 : 0); + if (remote) + rc = kernel_getpeername(sock, (struct sockaddr *)&sin, &len); + else + rc = kernel_getsockname(sock, (struct sockaddr *)&sin, &len); if (rc != 0) { CERROR ("Error %d getting sock %s IP/port\n", rc, remote ? "peer" : "local"); @@ -510,7 +524,7 @@ lnet_sock_listen (struct socket **sockp, return rc; } - rc = (*sockp)->ops->listen(*sockp, backlog); + rc = kernel_listen(*sockp, backlog); if (rc == 0) return 0; @@ -581,9 +595,8 @@ lnet_sock_connect (struct socket **sockp, int *fatal, srvaddr.sin_port = htons(peer_port); srvaddr.sin_addr.s_addr = htonl(peer_ip); - rc = (*sockp)->ops->connect(*sockp, - (struct sockaddr *)&srvaddr, sizeof(srvaddr), - 0); + rc = kernel_connect(*sockp, (struct sockaddr *)&srvaddr, + sizeof(srvaddr), 0); if (rc == 0) return 0; From 7309289203ed6c9ab79b202bbc37dcb12c94495f Mon Sep 17 00:00:00 2001 From: James Simmons Date: Mon, 8 Jun 2015 22:27:12 -0400 Subject: [PATCH 0901/1163] staging:lustre: lib-socket.c code cleanup - indentation etc Handle all the style issues reported by checkpatch.pl. Remove general white spaces, spaces in function calls, etc. Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- .../lustre/lnet/klnds/socklnd/socklnd.c | 4 +- drivers/staging/lustre/lnet/lnet/lib-socket.c | 203 ++++++++---------- 2 files changed, 94 insertions(+), 113 deletions(-) diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index ee5cf35422d0..4128a92218a9 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -1378,14 +1378,14 @@ ksocknal_create_conn(lnet_ni_t *ni, ksock_route_t *route, ksocknal_txlist_done(ni, &zombies, 1); ksocknal_peer_decref(peer); - failed_1: +failed_1: if (hello != NULL) LIBCFS_FREE(hello, offsetof(ksock_hello_msg_t, kshm_ips[LNET_MAX_INTERFACES])); LIBCFS_FREE(conn, sizeof(*conn)); - failed_0: +failed_0: sock_release(sock); return rc; } diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c index 2d46a69c0afa..e6dd15baac12 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-socket.c +++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c @@ -63,13 +63,13 @@ kernel_sock_unlocked_ioctl(struct file *filp, int cmd, unsigned long arg) static int lnet_sock_ioctl(int cmd, unsigned long arg) { - struct file *sock_filp; - struct socket *sock; - int rc; + struct file *sock_filp; + struct socket *sock; + int rc; - rc = sock_create (PF_INET, SOCK_STREAM, 0, &sock); + rc = sock_create(PF_INET, SOCK_STREAM, 0, &sock); if (rc != 0) { - CERROR ("Can't create socket: %d\n", rc); + CERROR("Can't create socket: %d\n", rc); return rc; } @@ -88,12 +88,12 @@ out: } int -lnet_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask) +lnet_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask) { - struct ifreq ifr; - int nob; - int rc; - __u32 val; + struct ifreq ifr; + int nob; + int rc; + __u32 val; nob = strnlen(name, IFNAMSIZ); if (nob == IFNAMSIZ) { @@ -101,7 +101,7 @@ lnet_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask) return -EINVAL; } - CLASSERT (sizeof(ifr.ifr_name) >= IFNAMSIZ); + CLASSERT(sizeof(ifr.ifr_name) >= IFNAMSIZ); strcpy(ifr.ifr_name, name); rc = lnet_sock_ioctl(SIOCGIFFLAGS, (unsigned long)&ifr); @@ -116,7 +116,6 @@ lnet_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask) *ip = *mask = 0; return 0; } - *up = 1; strcpy(ifr.ifr_name, name); @@ -143,23 +142,21 @@ lnet_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask) return 0; } - EXPORT_SYMBOL(lnet_ipif_query); int -lnet_ipif_enumerate (char ***namesp) +lnet_ipif_enumerate(char ***namesp) { /* Allocate and fill in 'names', returning # interfaces/error */ - char **names; - int toobig; - int nalloc; - int nfound; - struct ifreq *ifr; - struct ifconf ifc; - int rc; - int nob; - int i; - + char **names; + int toobig; + int nalloc; + int nfound; + struct ifreq *ifr; + struct ifconf ifc; + int rc; + int nob; + int i; nalloc = 16; /* first guess at max interfaces */ toobig = 0; @@ -173,7 +170,8 @@ lnet_ipif_enumerate (char ***namesp) LIBCFS_ALLOC(ifr, nalloc * sizeof(*ifr)); if (ifr == NULL) { - CERROR ("ENOMEM enumerating up to %d interfaces\n", nalloc); + CERROR("ENOMEM enumerating up to %d interfaces\n", + nalloc); rc = -ENOMEM; goto out0; } @@ -183,14 +181,14 @@ lnet_ipif_enumerate (char ***namesp) rc = lnet_sock_ioctl(SIOCGIFCONF, (unsigned long)&ifc); if (rc < 0) { - CERROR ("Error %d enumerating interfaces\n", rc); + CERROR("Error %d enumerating interfaces\n", rc); goto out1; } - LASSERT (rc == 0); + LASSERT(rc == 0); nfound = ifc.ifc_len/sizeof(*ifr); - LASSERT (nfound <= nalloc); + LASSERT(nfound <= nalloc); if (nfound < nalloc || toobig) break; @@ -209,8 +207,7 @@ lnet_ipif_enumerate (char ***namesp) } for (i = 0; i < nfound; i++) { - - nob = strnlen (ifr[i].ifr_name, IFNAMSIZ); + nob = strnlen(ifr[i].ifr_name, IFNAMSIZ); if (nob == IFNAMSIZ) { /* no space for terminating NULL */ CERROR("interface name %.*s too long (%d max)\n", @@ -232,41 +229,39 @@ lnet_ipif_enumerate (char ***namesp) *namesp = names; rc = nfound; - out2: +out2: if (rc < 0) lnet_ipif_free_enumeration(names, nfound); - out1: +out1: LIBCFS_FREE(ifr, nalloc * sizeof(*ifr)); - out0: +out0: return rc; } - EXPORT_SYMBOL(lnet_ipif_enumerate); void -lnet_ipif_free_enumeration (char **names, int n) +lnet_ipif_free_enumeration(char **names, int n) { - int i; + int i; - LASSERT (n > 0); + LASSERT(n > 0); for (i = 0; i < n && names[i] != NULL; i++) LIBCFS_FREE(names[i], IFNAMSIZ); LIBCFS_FREE(names, n * sizeof(*names)); } - EXPORT_SYMBOL(lnet_ipif_free_enumeration); int -lnet_sock_write (struct socket *sock, void *buffer, int nob, int timeout) +lnet_sock_write(struct socket *sock, void *buffer, int nob, int timeout) { - int rc; - long ticks = timeout * HZ; - unsigned long then; + int rc; + long ticks = timeout * HZ; + unsigned long then; struct timeval tv; - LASSERT (nob > 0); + LASSERT(nob > 0); /* Caller may pass a zero timeout if she thinks the socket buffer is * empty enough to take the whole message immediately */ @@ -286,7 +281,7 @@ lnet_sock_write (struct socket *sock, void *buffer, int nob, int timeout) .tv_usec = ((ticks % HZ) * 1000000) / HZ }; rc = kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, - (char *)&tv, sizeof(tv)); + (char *)&tv, sizeof(tv)); if (rc != 0) { CERROR("Can't set socket send timeout %ld.%06d: %d\n", (long)tv.tv_sec, (int)tv.tv_usec, rc); @@ -305,7 +300,7 @@ lnet_sock_write (struct socket *sock, void *buffer, int nob, int timeout) return rc; if (rc == 0) { - CERROR ("Unexpected zero rc\n"); + CERROR("Unexpected zero rc\n"); return -ECONNABORTED; } @@ -315,21 +310,20 @@ lnet_sock_write (struct socket *sock, void *buffer, int nob, int timeout) buffer = ((char *)buffer) + rc; nob -= rc; } - return 0; } EXPORT_SYMBOL(lnet_sock_write); int -lnet_sock_read (struct socket *sock, void *buffer, int nob, int timeout) +lnet_sock_read(struct socket *sock, void *buffer, int nob, int timeout) { - int rc; - long ticks = timeout * HZ; - unsigned long then; + int rc; + long ticks = timeout * HZ; + unsigned long then; struct timeval tv; - LASSERT (nob > 0); - LASSERT (ticks > 0); + LASSERT(nob > 0); + LASSERT(ticks > 0); for (;;) { struct kvec iov = { @@ -337,7 +331,7 @@ lnet_sock_read (struct socket *sock, void *buffer, int nob, int timeout) .iov_len = nob }; struct msghdr msg = { - .msg_flags = 0 + .msg_flags = 0 }; /* Set receive timeout to remaining time */ @@ -346,7 +340,7 @@ lnet_sock_read (struct socket *sock, void *buffer, int nob, int timeout) .tv_usec = ((ticks % HZ) * 1000000) / HZ }; rc = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, - (char *)&tv, sizeof(tv)); + (char *)&tv, sizeof(tv)); if (rc != 0) { CERROR("Can't set socket recv timeout %ld.%06d: %d\n", (long)tv.tv_sec, (int)tv.tv_usec, rc); @@ -373,31 +367,30 @@ lnet_sock_read (struct socket *sock, void *buffer, int nob, int timeout) return -ETIMEDOUT; } } - EXPORT_SYMBOL(lnet_sock_read); static int -lnet_sock_create (struct socket **sockp, int *fatal, - __u32 local_ip, int local_port) +lnet_sock_create(struct socket **sockp, int *fatal, __u32 local_ip, + int local_port) { - struct sockaddr_in locaddr; - struct socket *sock; - int rc; - int option; + struct sockaddr_in locaddr; + struct socket *sock; + int rc; + int option; /* All errors are fatal except bind failure if the port is in use */ *fatal = 1; - rc = sock_create (PF_INET, SOCK_STREAM, 0, &sock); + rc = sock_create(PF_INET, SOCK_STREAM, 0, &sock); *sockp = sock; if (rc != 0) { - CERROR ("Can't create socket: %d\n", rc); + CERROR("Can't create socket: %d\n", rc); return rc; } option = 1; rc = kernel_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, - (char *)&option, sizeof (option)); + (char *)&option, sizeof(option)); if (rc != 0) { CERROR("Can't set SO_REUSEADDR for socket: %d\n", rc); goto failed; @@ -423,27 +416,26 @@ lnet_sock_create (struct socket **sockp, int *fatal, goto failed; } } - return 0; - failed: +failed: sock_release(sock); return rc; } int -lnet_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize) +lnet_sock_setbuf(struct socket *sock, int txbufsize, int rxbufsize) { - int option; - int rc; + int option; + int rc; if (txbufsize != 0) { option = txbufsize; rc = kernel_setsockopt(sock, SOL_SOCKET, SO_SNDBUF, - (char *)&option, sizeof (option)); + (char *)&option, sizeof(option)); if (rc != 0) { - CERROR ("Can't set send buffer %d: %d\n", - option, rc); + CERROR("Can't set send buffer %d: %d\n", + option, rc); return rc; } } @@ -451,70 +443,63 @@ lnet_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize) if (rxbufsize != 0) { option = rxbufsize; rc = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVBUF, - (char *)&option, sizeof (option)); + (char *)&option, sizeof(option)); if (rc != 0) { - CERROR ("Can't set receive buffer %d: %d\n", - option, rc); + CERROR("Can't set receive buffer %d: %d\n", + option, rc); return rc; } } - return 0; } - EXPORT_SYMBOL(lnet_sock_setbuf); int -lnet_sock_getaddr (struct socket *sock, bool remote, __u32 *ip, int *port) +lnet_sock_getaddr(struct socket *sock, bool remote, __u32 *ip, int *port) { struct sockaddr_in sin; - int len = sizeof (sin); - int rc; + int len = sizeof(sin); + int rc; if (remote) rc = kernel_getpeername(sock, (struct sockaddr *)&sin, &len); else rc = kernel_getsockname(sock, (struct sockaddr *)&sin, &len); if (rc != 0) { - CERROR ("Error %d getting sock %s IP/port\n", - rc, remote ? "peer" : "local"); + CERROR("Error %d getting sock %s IP/port\n", + rc, remote ? "peer" : "local"); return rc; } if (ip != NULL) - *ip = ntohl (sin.sin_addr.s_addr); + *ip = ntohl(sin.sin_addr.s_addr); if (port != NULL) - *port = ntohs (sin.sin_port); + *port = ntohs(sin.sin_port); return 0; } - EXPORT_SYMBOL(lnet_sock_getaddr); int -lnet_sock_getbuf (struct socket *sock, int *txbufsize, int *rxbufsize) +lnet_sock_getbuf(struct socket *sock, int *txbufsize, int *rxbufsize) { - - if (txbufsize != NULL) { + if (txbufsize != NULL) *txbufsize = sock->sk->sk_sndbuf; - } - if (rxbufsize != NULL) { + if (rxbufsize != NULL) *rxbufsize = sock->sk->sk_rcvbuf; - } return 0; } - EXPORT_SYMBOL(lnet_sock_getbuf); int -lnet_sock_listen (struct socket **sockp, - __u32 local_ip, int local_port, int backlog) +lnet_sock_listen(struct socket **sockp, __u32 local_ip, int local_port, + int backlog) { - int fatal; - int rc; + int fatal; + int rc; rc = lnet_sock_create(sockp, &fatal, local_ip, local_port); if (rc != 0) { @@ -532,15 +517,14 @@ lnet_sock_listen (struct socket **sockp, sock_release(*sockp); return rc; } - EXPORT_SYMBOL(lnet_sock_listen); int -lnet_sock_accept (struct socket **newsockp, struct socket *sock) +lnet_sock_accept(struct socket **newsockp, struct socket *sock) { - wait_queue_t wait; + wait_queue_t wait; struct socket *newsock; - int rc; + int rc; init_waitqueue_entry(&wait, current); @@ -571,26 +555,24 @@ lnet_sock_accept (struct socket **newsockp, struct socket *sock) *newsockp = newsock; return 0; - failed: +failed: sock_release(newsock); return rc; } - EXPORT_SYMBOL(lnet_sock_accept); int -lnet_sock_connect (struct socket **sockp, int *fatal, - __u32 local_ip, int local_port, - __u32 peer_ip, int peer_port) +lnet_sock_connect(struct socket **sockp, int *fatal, __u32 local_ip, + int local_port, __u32 peer_ip, int peer_port) { - struct sockaddr_in srvaddr; - int rc; + struct sockaddr_in srvaddr; + int rc; rc = lnet_sock_create(sockp, fatal, local_ip, local_port); if (rc != 0) return rc; - memset (&srvaddr, 0, sizeof (srvaddr)); + memset(&srvaddr, 0, sizeof(srvaddr)); srvaddr.sin_family = AF_INET; srvaddr.sin_port = htons(peer_port); srvaddr.sin_addr.s_addr = htonl(peer_ip); @@ -607,11 +589,10 @@ lnet_sock_connect (struct socket **sockp, int *fatal, *fatal = !(rc == -EADDRNOTAVAIL); CDEBUG_LIMIT(*fatal ? D_NETERROR : D_NET, - "Error %d connecting %pI4h/%d -> %pI4h/%d\n", rc, - &local_ip, local_port, &peer_ip, peer_port); + "Error %d connecting %pI4h/%d -> %pI4h/%d\n", rc, + &local_ip, local_port, &peer_ip, peer_port); sock_release(*sockp); return rc; } - EXPORT_SYMBOL(lnet_sock_connect); From 60ecf96eb24e813fdf24ba2714927b80dc5a83c3 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Mon, 8 Jun 2015 22:27:13 -0400 Subject: [PATCH 0902/1163] staging:lustre: Update license and copyright for lib-socket.c Point to the right place for GNU license. Update Intel copyright. Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/lib-socket.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c index e6dd15baac12..6f7ef4c737cd 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-socket.c +++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c @@ -15,11 +15,7 @@ * * 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. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ @@ -27,11 +23,11 @@ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2012, Intel Corporation. + * Copyright (c) 2012, 2015 Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. + * Lustre is a trademark of Seagate, Inc. */ #define DEBUG_SUBSYSTEM S_LNET From 6d37b171929a94b41214dfabc65881f60c9da095 Mon Sep 17 00:00:00 2001 From: Fabian Frederick Date: Wed, 10 Jun 2015 18:32:21 +0200 Subject: [PATCH 0903/1163] staging: lustre: lnet: o2iblnd: use swap() in kiblnd_dev_failover() Use kernel.h macro definition. Thanks to Julia Lawall for Coccinelle scripting support. Signed-off-by: Fabian Frederick Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index 060b7399e921..2a72427bdd69 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -2463,7 +2463,6 @@ int kiblnd_dev_failover(kib_dev_t *dev) LIST_HEAD(zombie_fpo); struct rdma_cm_id *cmid = NULL; kib_hca_dev_t *hdev = NULL; - kib_hca_dev_t *old; struct ib_pd *pd; kib_net_t *net; struct sockaddr_in addr; @@ -2555,9 +2554,7 @@ int kiblnd_dev_failover(kib_dev_t *dev) write_lock_irqsave(&kiblnd_data.kib_global_lock, flags); - old = dev->ibd_hdev; - dev->ibd_hdev = hdev; /* take over the refcount */ - hdev = old; + swap(dev->ibd_hdev, hdev); /* take over the refcount */ list_for_each_entry(net, &dev->ibd_nets, ibn_list) { cfs_cpt_for_each(i, lnet_cpt_table()) { From 84ea37b6d24a2e6b53e3e4736341e008fcac4eb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Lajos=20Kis?= Date: Wed, 10 Jun 2015 22:00:15 +0200 Subject: [PATCH 0904/1163] Staging: lustre: fix line over 80 characters in dt_object.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes a line over 80 characters warining in lustre/lustre/obdclass/dt_object.c that was found by the checkpatch.pl tool. Signed-off-by: Zoltán Lajos Kis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/dt_object.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/obdclass/dt_object.c b/drivers/staging/lustre/lustre/obdclass/dt_object.c index 6ce407ff8318..4b5c828d6f05 100644 --- a/drivers/staging/lustre/lustre/obdclass/dt_object.c +++ b/drivers/staging/lustre/lustre/obdclass/dt_object.c @@ -235,7 +235,8 @@ EXPORT_SYMBOL(dt_locate_at); /** * find a object named \a entry in given \a dfh->dfh_o directory. */ -static int dt_find_entry(const struct lu_env *env, const char *entry, void *data) +static int dt_find_entry(const struct lu_env *env, + const char *entry, void *data) { struct dt_find_hint *dfh = data; struct dt_device *dt = dfh->dfh_dt; From 4828d1fdf4858072f714a22eaf8b65b1011b6d67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Lajos=20Kis?= Date: Wed, 10 Jun 2015 22:00:16 +0200 Subject: [PATCH 0905/1163] Staging: lustre: fix braces are not necessary in dt_object.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes a braces {} are not necessary for any arm of this statement warning in lustre/lustre/obdclass/dt_object.c that was found by the checkpatch.pl tool. Signed-off-by: Zoltán Lajos Kis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/dt_object.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/dt_object.c b/drivers/staging/lustre/lustre/obdclass/dt_object.c index 4b5c828d6f05..46fbf216e7f8 100644 --- a/drivers/staging/lustre/lustre/obdclass/dt_object.c +++ b/drivers/staging/lustre/lustre/obdclass/dt_object.c @@ -329,9 +329,9 @@ static struct dt_object *dt_reg_open(const struct lu_env *env, int result; result = dt_lookup_dir(env, p, name, fid); - if (result == 0){ + if (result == 0) o = dt_locate(env, dt, fid); - } else + else o = ERR_PTR(result); return o; From 623f0e137c0fedb81bbf3d88be4ed300eee163da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Lajos=20Kis?= Date: Wed, 10 Jun 2015 22:00:17 +0200 Subject: [PATCH 0906/1163] Staging: lustre: fix space before and after comma in dt_object.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes a space prohibited before that ',' and space required after that ',' error in lustre/lustre/obdclass/dt_object.c that were found by the checkpatch.pl tool. Signed-off-by: Zoltán Lajos Kis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/dt_object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/obdclass/dt_object.c b/drivers/staging/lustre/lustre/obdclass/dt_object.c index 46fbf216e7f8..b67b0feb03e0 100644 --- a/drivers/staging/lustre/lustre/obdclass/dt_object.c +++ b/drivers/staging/lustre/lustre/obdclass/dt_object.c @@ -922,7 +922,7 @@ int dt_index_read(const struct lu_env *env, struct dt_device *dev, ii->ii_version = dt_version_get(env, obj); /* walk the index and fill lu_idxpages with key/record pairs */ - rc = dt_index_walk(env, obj, rdpg, dt_index_page_build ,ii); + rc = dt_index_walk(env, obj, rdpg, dt_index_page_build, ii); dt_read_unlock(env, obj); if (rc == 0) { From e703f23747e25db6ccc1f752f787925f86c27f31 Mon Sep 17 00:00:00 2001 From: Andrzej Pietrasiewicz Date: Mon, 8 Jun 2015 23:16:44 +0200 Subject: [PATCH 0907/1163] staging: rtl8188eu: eliminate spaces before commas Eliminate "space prohibited before that ','" errors found by checkpatch, but do this only to lines which after the patch is applied do not exceed 80 characters. Out of that only those lines are changed, whose context does not exceed 80 characters in each line. In other words the changes are limited to cases where the patch generated is itself checkpatch-correct. Rebased onto next-20150605. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_efuse.c | 2 +- drivers/staging/rtl8188eu/core/rtw_mlme.c | 8 ++++---- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 10 +++++----- drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c | 2 +- drivers/staging/rtl8188eu/hal/pwrseqcmd.c | 2 +- drivers/staging/rtl8188eu/include/rtw_led.h | 2 +- drivers/staging/rtl8188eu/include/rtw_mlme_ext.h | 2 +- drivers/staging/rtl8188eu/include/rtw_security.h | 2 +- drivers/staging/rtl8188eu/os_dep/rtw_android.c | 2 +- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c index b66746160223..dbaba2c6cce5 100644 --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c @@ -31,7 +31,7 @@ enum{ VOLTAGE_V25 = 0x03, - LDOE25_SHIFT = 28 , + LDOE25_SHIFT = 28, }; /* diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 6c91aa58d924..a0f9f9e63b7f 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -141,7 +141,7 @@ struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv)/* _queue *f } plist = free_queue->queue.next; - pnetwork = container_of(plist , struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); list_del_init(&pnetwork->list); @@ -219,7 +219,7 @@ struct wlan_network *rtw_find_network(struct __queue *scanned_queue, u8 *addr) plist = phead->next; while (plist != phead) { - pnetwork = container_of(plist, struct wlan_network , list); + pnetwork = container_of(plist, struct wlan_network, list); if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN)) break; plist = plist->next; @@ -724,11 +724,11 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) pmlmeext = &adapter->mlmeextpriv; } -void rtw_dummy_event_callback(struct adapter *adapter , u8 *pbuf) +void rtw_dummy_event_callback(struct adapter *adapter, u8 *pbuf) { } -void rtw_fwdbg_event_callback(struct adapter *adapter , u8 *pbuf) +void rtw_fwdbg_event_callback(struct adapter *adapter, u8 *pbuf) { } diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 0169a7d3e4c2..052d0f456956 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -804,7 +804,7 @@ unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame) auth_fail: if (pstat) - rtw_free_stainfo(padapter , pstat); + rtw_free_stainfo(padapter, pstat); pstat = &stat; memset((char *)pstat, '\0', sizeof(stat)); diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 0b1cb03ab7b2..19b3a0d6de9a 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -156,7 +156,7 @@ static void rtw_mfree_all_stainfo(struct sta_priv *pstapriv) plist = phead->next; while (phead != plist) { - psta = container_of(plist, struct sta_info , list); + psta = container_of(plist, struct sta_info, list); plist = plist->next; } @@ -257,7 +257,7 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, ("alloc number_%d stainfo with hwaddr = %pM\n", - pstapriv->asoc_sta_count , hwaddr)); + pstapriv->asoc_sta_count, hwaddr)); init_addba_retry_timer(pstapriv->padapter, psta); @@ -291,7 +291,7 @@ exit: } /* using pstapriv->sta_hash_lock to protect */ -u32 rtw_free_stainfo(struct adapter *padapter , struct sta_info *psta) +u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) { int i; struct __queue *pfree_sta_queue; @@ -440,12 +440,12 @@ void rtw_free_all_stainfo(struct adapter *padapter) plist = phead->next; while (phead != plist) { - psta = container_of(plist, struct sta_info , hash_list); + psta = container_of(plist, struct sta_info, hash_list); plist = plist->next; if (pbcmc_stainfo != psta) - rtw_free_stainfo(padapter , psta); + rtw_free_stainfo(padapter, psta); } } spin_unlock_bh(&pstapriv->sta_hash_lock); diff --git a/drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c b/drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c index 082f0ca198ef..15a176596305 100644 --- a/drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c +++ b/drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c @@ -87,7 +87,7 @@ static u8 DROPING_NECESSARY[RATESIZE] = { static u8 PendingForRateUpFail[5] = {2, 10, 24, 40, 60}; static u16 DynamicTxRPTTiming[6] = { - 0x186a, 0x30d4, 0x493e, 0x61a8, 0x7a12 , 0x927c}; /* 200ms-1200ms */ + 0x186a, 0x30d4, 0x493e, 0x61a8, 0x7a12, 0x927c}; /* 200ms-1200ms */ /* End Rate adaptive parameters */ diff --git a/drivers/staging/rtl8188eu/hal/pwrseqcmd.c b/drivers/staging/rtl8188eu/hal/pwrseqcmd.c index 73e1f8b36b37..3e60b23819ae 100644 --- a/drivers/staging/rtl8188eu/hal/pwrseqcmd.c +++ b/drivers/staging/rtl8188eu/hal/pwrseqcmd.c @@ -37,7 +37,7 @@ u8 rtl88eu_pwrseqcmdparsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, do { pwrcfgcmd = pwrseqcmd[aryidx]; - RT_TRACE(_module_hal_init_c_ , _drv_info_, + RT_TRACE(_module_hal_init_c_, _drv_info_, ("rtl88eu_pwrseqcmdparsing: offset(%#x) cut_msk(%#x)" "fab_msk(%#x) interface_msk(%#x) base(%#x) cmd(%#x)" "msk(%#x) value(%#x)\n", diff --git a/drivers/staging/rtl8188eu/include/rtw_led.h b/drivers/staging/rtl8188eu/include/rtw_led.h index 7a5303d50d49..f2054ef70358 100644 --- a/drivers/staging/rtl8188eu/include/rtw_led.h +++ b/drivers/staging/rtl8188eu/include/rtw_led.h @@ -30,7 +30,7 @@ enum LED_CTL_MODE { LED_CTL_LINK, LED_CTL_NO_LINK, LED_CTL_TX, - LED_CTL_RX , + LED_CTL_RX, LED_CTL_SITE_SURVEY, LED_CTL_POWER_OFF, LED_CTL_START_TO_LINK, diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h index 2bd11acb4c03..1df586aa0a9a 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -759,7 +759,7 @@ enum rtw_c2h_event { GEN_EVT_CODE(_Survey), /*8*/ GEN_EVT_CODE(_SurveyDone), /*9*/ - GEN_EVT_CODE(_JoinBss) , /*10*/ + GEN_EVT_CODE(_JoinBss), /*10*/ GEN_EVT_CODE(_AddSTA), GEN_EVT_CODE(_DelSTA), GEN_EVT_CODE(_AtimDone), diff --git a/drivers/staging/rtl8188eu/include/rtw_security.h b/drivers/staging/rtl8188eu/include/rtw_security.h index e9723a72af5e..abe7e21e6e20 100644 --- a/drivers/staging/rtl8188eu/include/rtw_security.h +++ b/drivers/staging/rtl8188eu/include/rtw_security.h @@ -328,7 +328,7 @@ static const unsigned long K[64] = { #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 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)) diff --git a/drivers/staging/rtl8188eu/os_dep/rtw_android.c b/drivers/staging/rtl8188eu/os_dep/rtw_android.c index 99ce077007f4..5f3337c281ee 100644 --- a/drivers/staging/rtl8188eu/os_dep/rtw_android.c +++ b/drivers/staging/rtl8188eu/os_dep/rtw_android.c @@ -79,7 +79,7 @@ int rtw_android_cmdstr_to_num(char *cmdstr) { int cmd_num; for (cmd_num = 0; cmd_num < ANDROID_WIFI_CMD_MAX; cmd_num++) - if (0 == strncasecmp(cmdstr , android_wifi_cmd_str[cmd_num], + if (0 == strncasecmp(cmdstr, android_wifi_cmd_str[cmd_num], strlen(android_wifi_cmd_str[cmd_num]))) break; return cmd_num; From d8bc89a7f34242d67e7eefade6fc0df057c34ec1 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 11 Jun 2015 01:37:50 -0400 Subject: [PATCH 0908/1163] staging/lustre/llite: remove LL_IOC_REMOVE_ENTRY handler It uses getname in unsafe manner and since it's to deal with corrupted or inconsistent filesystem, we are probably better to deal with it from lfsck anyway. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/lustre/lustre_user.h | 1 - drivers/staging/lustre/lustre/llite/dir.c | 29 ------------------- 2 files changed, 30 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h index 89794fdfec9d..e095ada40ed2 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h @@ -243,7 +243,6 @@ struct ost_id { #define LL_IOC_LMV_SETSTRIPE _IOWR('f', 240, struct lmv_user_md) #define LL_IOC_LMV_GETSTRIPE _IOWR('f', 241, struct lmv_user_md) -#define LL_IOC_REMOVE_ENTRY _IOWR('f', 242, __u64) #define LL_IOC_SET_LEASE _IOWR('f', 243, long) #define LL_IOC_GET_LEASE _IO('f', 244) #define LL_IOC_HSM_IMPORT _IOWR('f', 245, struct hsm_user_import) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 4b0de8d89e5c..87a042c0433a 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -1436,35 +1436,6 @@ free_lmv: kfree(tmp); return rc; } - case LL_IOC_REMOVE_ENTRY: { - char *filename = NULL; - int namelen = 0; - int rc; - - /* Here is a little hack to avoid sending REINT_RMENTRY to - * unsupported server, which might crash the server(LU-2730), - * Because both LVB_TYPE and REINT_RMENTRY will be supported - * on 2.4, we use OBD_CONNECT_LVB_TYPE to detect whether the - * server will support REINT_RMENTRY XXX*/ - if (!(exp_connect_flags(sbi->ll_md_exp) & OBD_CONNECT_LVB_TYPE)) - return -ENOTSUPP; - - filename = ll_getname((const char *)arg); - if (IS_ERR(filename)) - return PTR_ERR(filename); - - namelen = strlen(filename); - if (namelen < 1) { - rc = -EINVAL; - goto out_rmdir; - } - - rc = ll_rmdir_entry(inode, filename, namelen); -out_rmdir: - if (filename) - ll_putname(filename); - return rc; - } case LL_IOC_LOV_SWAP_LAYOUTS: return -EPERM; case LL_IOC_OBD_STATFS: From a75034345b3026f1cf5668e70688ea53184e49c1 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 11 Jun 2015 01:37:51 -0400 Subject: [PATCH 0909/1163] staging/lustre/llite: fix ll_getname user buffer copy strncpy_from_user could return negative values on error, so need to take those into account. Since ll_getname is used to get a single component name from userspace to transfer to server as-is, there's no need to allocate 4k buffer as done by __getname. Allocate NAME_MAX+1 buffer instead to ensure we have enough for a null terminated max valid length buffer. This was discovered by Al Viro in https://lkml.org/lkml/2015/4/11/243 Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dir.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 87a042c0433a..50d685b0dda0 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -1213,29 +1213,34 @@ out: return rc; } -static char * -ll_getname(const char __user *filename) +/* This function tries to get a single name component, + * to send to the server. No actual path traversal involved, + * so we limit to NAME_MAX */ +static char *ll_getname(const char __user *filename) { int ret = 0, len; - char *tmp = __getname(); + char *tmp; + tmp = kzalloc(NAME_MAX + 1, GFP_KERNEL); if (!tmp) return ERR_PTR(-ENOMEM); - len = strncpy_from_user(tmp, filename, PATH_MAX); - if (len == 0) + len = strncpy_from_user(tmp, filename, NAME_MAX + 1); + if (len < 0) + ret = len; + else if (len == 0) ret = -ENOENT; - else if (len > PATH_MAX) + else if (len > NAME_MAX && tmp[NAME_MAX] != 0) ret = -ENAMETOOLONG; if (ret) { - __putname(tmp); + kfree(tmp); tmp = ERR_PTR(ret); } return tmp; } -#define ll_putname(filename) __putname(filename) +#define ll_putname(filename) kfree(filename) static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { From e958f49bc72c47fe9a1635bccf149964f006cbbe Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Thu, 11 Jun 2015 14:02:52 +0200 Subject: [PATCH 0910/1163] lustre: llite: Replace uses of OBD_{ALLOC,FREE}_LARGE Replace uses of OBD_ALLOC_LARGE by libcfs_kvzalloc and OBD_FREE_LARGE by kvfree. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr,size; @@ - OBD_ALLOC_LARGE(ptr,size) + ptr = libcfs_kvzalloc(size, GFP_NOFS) @@ expression ptr,size; @@ - OBD_FREE_LARGE(ptr, size); + kvfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dir.c | 10 +++++----- drivers/staging/lustre/lustre/llite/file.c | 22 +++++++++++----------- drivers/staging/lustre/lustre/llite/rw26.c | 4 ++-- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 50d685b0dda0..c2eb4f2ea5b5 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -1548,7 +1548,7 @@ out_req: if (rc) return rc; - OBD_ALLOC_LARGE(lmm, lmmsize); + lmm = libcfs_kvzalloc(lmmsize, GFP_NOFS); if (lmm == NULL) return -ENOMEM; if (copy_from_user(lmm, lum, lmmsize)) { @@ -1601,7 +1601,7 @@ out_req: free_lsm: obd_free_memmd(sbi->ll_dt_exp, &lsm); free_lmm: - OBD_FREE_LARGE(lmm, lmmsize); + kvfree(lmm); return rc; } case OBD_IOC_LLOG_CATINFO: { @@ -1767,13 +1767,13 @@ out_quotactl: if (totalsize >= MDS_MAXREQSIZE / 3) return -E2BIG; - OBD_ALLOC_LARGE(hur, totalsize); + hur = libcfs_kvzalloc(totalsize, GFP_NOFS); if (hur == NULL) return -ENOMEM; /* Copy the whole struct */ if (copy_from_user(hur, (void *)arg, totalsize)) { - OBD_FREE_LARGE(hur, totalsize); + kvfree(hur); return -EFAULT; } @@ -1800,7 +1800,7 @@ out_quotactl: hur, NULL); } - OBD_FREE_LARGE(hur, totalsize); + kvfree(hur); return rc; } diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 5c05f41d3575..4f9b1c796285 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -1282,7 +1282,7 @@ static int ll_lov_recreate(struct inode *inode, struct ost_id *oi, u32 ost_idx) lsm_size = sizeof(*lsm) + (sizeof(struct lov_oinfo) * (lsm->lsm_stripe_count)); - OBD_ALLOC_LARGE(lsm2, lsm_size); + lsm2 = libcfs_kvzalloc(lsm_size, GFP_NOFS); if (lsm2 == NULL) { rc = -ENOMEM; goto out; @@ -1300,7 +1300,7 @@ static int ll_lov_recreate(struct inode *inode, struct ost_id *oi, u32 ost_idx) rc = obd_create(NULL, exp, oa, &lsm2, &oti); ll_inode_size_unlock(inode); - OBD_FREE_LARGE(lsm2, lsm_size); + kvfree(lsm2); goto out; out: ccc_inode_lsm_put(inode, lsm); @@ -1477,12 +1477,12 @@ static int ll_lov_setea(struct inode *inode, struct file *file, if (!capable(CFS_CAP_SYS_ADMIN)) return -EPERM; - OBD_ALLOC_LARGE(lump, lum_size); + lump = libcfs_kvzalloc(lum_size, GFP_NOFS); if (lump == NULL) return -ENOMEM; if (copy_from_user(lump, (struct lov_user_md *)arg, lum_size)) { - OBD_FREE_LARGE(lump, lum_size); + kvfree(lump); return -EFAULT; } @@ -1490,7 +1490,7 @@ static int ll_lov_setea(struct inode *inode, struct file *file, lum_size); cl_lov_delay_create_clear(&file->f_flags); - OBD_FREE_LARGE(lump, lum_size); + kvfree(lump); return rc; } @@ -1802,7 +1802,7 @@ static int ll_ioctl_fiemap(struct inode *inode, unsigned long arg) num_bytes = sizeof(*fiemap_s) + (extent_count * sizeof(struct ll_fiemap_extent)); - OBD_ALLOC_LARGE(fiemap_s, num_bytes); + fiemap_s = libcfs_kvzalloc(num_bytes, GFP_NOFS); if (fiemap_s == NULL) return -ENOMEM; @@ -1839,7 +1839,7 @@ static int ll_ioctl_fiemap(struct inode *inode, unsigned long arg) rc = -EFAULT; error: - OBD_FREE_LARGE(fiemap_s, num_bytes); + kvfree(fiemap_s); return rc; } @@ -3055,7 +3055,7 @@ static int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, num_bytes = sizeof(*fiemap) + (extent_count * sizeof(struct ll_fiemap_extent)); - OBD_ALLOC_LARGE(fiemap, num_bytes); + fiemap = libcfs_kvzalloc(num_bytes, GFP_NOFS); if (fiemap == NULL) return -ENOMEM; @@ -3077,7 +3077,7 @@ static int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, fiemap->fm_mapped_extents * sizeof(struct ll_fiemap_extent)); - OBD_FREE_LARGE(fiemap, num_bytes); + kvfree(fiemap); return rc; } @@ -3366,7 +3366,7 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) goto out; } - OBD_ALLOC_LARGE(lvbdata, lmmsize); + lvbdata = libcfs_kvzalloc(lmmsize, GFP_NOFS); if (lvbdata == NULL) { rc = -ENOMEM; goto out; @@ -3375,7 +3375,7 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) memcpy(lvbdata, lmm, lmmsize); lock_res_and_lock(lock); if (lock->l_lvb_data != NULL) - OBD_FREE_LARGE(lock->l_lvb_data, lock->l_lvb_len); + kvfree(lock->l_lvb_data); lock->l_lvb_data = lvbdata; lock->l_lvb_len = lmmsize; diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index 7c643130499f..b17b7cea582c 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -200,12 +200,12 @@ static inline int ll_get_user_pages(int rw, unsigned long user_addr, *max_pages = (user_addr + size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; *max_pages -= user_addr >> PAGE_CACHE_SHIFT; - OBD_ALLOC_LARGE(*pages, *max_pages * sizeof(**pages)); + *pages = libcfs_kvzalloc(*max_pages * sizeof(**pages), GFP_NOFS); if (*pages) { result = get_user_pages_fast(user_addr, *max_pages, (rw == READ), *pages); if (unlikely(result <= 0)) - OBD_FREE_LARGE(*pages, *max_pages * sizeof(**pages)); + kvfree(*pages); } return result; From 8cc3792a2a5afe160567a7b29401dc4b6814f055 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Thu, 11 Jun 2015 14:02:53 +0200 Subject: [PATCH 0911/1163] lustre: lmv: Replace uses of OBD_{ALLOC,FREE}_LARGE Replace uses of OBD_ALLOC_LARGE by libcfs_kvzalloc and OBD_FREE_LARGE by kvfree. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr,size; @@ - OBD_ALLOC_LARGE(ptr,size) + ptr = libcfs_kvzalloc(size, GFP_NOFS) @@ expression ptr,size; @@ - OBD_FREE_LARGE(ptr, size); + kvfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index aca686a2ca10..ac5053cd5da5 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -1045,7 +1045,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, reqlen = offsetof(typeof(*hur), hur_user_item[nr]) + hur->hur_request.hr_data_len; - OBD_ALLOC_LARGE(req, reqlen); + req = libcfs_kvzalloc(reqlen, GFP_NOFS); if (req == NULL) return -ENOMEM; @@ -1055,7 +1055,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, reqlen, req, uarg); if (rc1 != 0 && rc == 0) rc = rc1; - OBD_FREE_LARGE(req, reqlen); + kvfree(req); } } break; @@ -2400,13 +2400,13 @@ static int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, return mea_size; if (*lmmp && !lsm) { - OBD_FREE_LARGE(*lmmp, mea_size); + kvfree(*lmmp); *lmmp = NULL; return 0; } if (*lmmp == NULL) { - OBD_ALLOC_LARGE(*lmmp, mea_size); + *lmmp = libcfs_kvzalloc(mea_size, GFP_NOFS); if (*lmmp == NULL) return -ENOMEM; } @@ -2449,14 +2449,14 @@ static int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, return mea_size; if (*lsmp != NULL && lmm == NULL) { - OBD_FREE_LARGE(*tmea, mea_size); + kvfree(*tmea); *lsmp = NULL; return 0; } LASSERT(mea_size == lmm_size); - OBD_ALLOC_LARGE(*tmea, mea_size); + *tmea = libcfs_kvzalloc(mea_size, GFP_NOFS); if (*tmea == NULL) return -ENOMEM; From 3d0ba7160c659fca3186c960523e33f8afd5ea47 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Thu, 11 Jun 2015 14:02:54 +0200 Subject: [PATCH 0912/1163] lustre: lov: Replace uses of OBD_{ALLOC,FREE}_LARGE Replace uses of OBD_ALLOC_LARGE by libcfs_kvzalloc and OBD_FREE_LARGE by kvfree. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr,size; @@ - OBD_ALLOC_LARGE(ptr,size) + ptr = libcfs_kvzalloc(size, GFP_NOFS) @@ expression ptr,size; @@ - OBD_FREE_LARGE(ptr, size); + kvfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lov/lov_ea.c | 7 +++---- drivers/staging/lustre/lustre/lov/lov_io.c | 18 ++++++++++-------- drivers/staging/lustre/lustre/lov/lov_lock.c | 5 ++--- drivers/staging/lustre/lustre/lov/lov_obd.c | 4 ++-- drivers/staging/lustre/lustre/lov/lov_object.c | 5 +++-- drivers/staging/lustre/lustre/lov/lov_pack.c | 8 ++++---- 6 files changed, 24 insertions(+), 23 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c index 2bcfaeaff6fa..3f51b573e1fb 100644 --- a/drivers/staging/lustre/lustre/lov/lov_ea.c +++ b/drivers/staging/lustre/lustre/lov/lov_ea.c @@ -95,7 +95,7 @@ struct lov_stripe_md *lsm_alloc_plain(__u16 stripe_count, int *size) oinfo_ptrs_size = sizeof(struct lov_oinfo *) * stripe_count; *size = sizeof(struct lov_stripe_md) + oinfo_ptrs_size; - OBD_ALLOC_LARGE(lsm, *size); + lsm = libcfs_kvzalloc(*size, GFP_NOFS); if (!lsm) return NULL; @@ -111,7 +111,7 @@ struct lov_stripe_md *lsm_alloc_plain(__u16 stripe_count, int *size) err: while (--i >= 0) OBD_SLAB_FREE(lsm->lsm_oinfo[i], lov_oinfo_slab, sizeof(*loi)); - OBD_FREE_LARGE(lsm, *size); + kvfree(lsm); return NULL; } @@ -123,8 +123,7 @@ void lsm_free_plain(struct lov_stripe_md *lsm) for (i = 0; i < stripe_count; i++) OBD_SLAB_FREE(lsm->lsm_oinfo[i], lov_oinfo_slab, sizeof(struct lov_oinfo)); - OBD_FREE_LARGE(lsm, sizeof(struct lov_stripe_md) + - stripe_count * sizeof(struct lov_oinfo *)); + kvfree(lsm); } static void lsm_unpackmd_common(struct lov_stripe_md *lsm, diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c index a043df0c519f..11c1081b1d3d 100644 --- a/drivers/staging/lustre/lustre/lov/lov_io.c +++ b/drivers/staging/lustre/lustre/lov/lov_io.c @@ -286,8 +286,10 @@ static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio, * Need to be optimized, we can't afford to allocate a piece of memory * when writing a page. -jay */ - OBD_ALLOC_LARGE(lio->lis_subs, - lsm->lsm_stripe_count * sizeof(lio->lis_subs[0])); + lio->lis_subs = + libcfs_kvzalloc(lsm->lsm_stripe_count * + sizeof(lio->lis_subs[0]), + GFP_NOFS); if (lio->lis_subs != NULL) { lio->lis_nr_subios = lio->lis_stripe_count; lio->lis_single_subio_index = -1; @@ -360,8 +362,7 @@ static void lov_io_fini(const struct lu_env *env, const struct cl_io_slice *ios) if (lio->lis_subs != NULL) { for (i = 0; i < lio->lis_nr_subios; i++) lov_io_sub_fini(env, lio, &lio->lis_subs[i]); - OBD_FREE_LARGE(lio->lis_subs, - lio->lis_nr_subios * sizeof(lio->lis_subs[0])); + kvfree(lio->lis_subs); lio->lis_nr_subios = 0; } @@ -604,8 +605,10 @@ static int lov_io_submit(const struct lu_env *env, LASSERT(lio->lis_subs != NULL); if (alloc) { - OBD_ALLOC_LARGE(stripes_qin, - sizeof(*stripes_qin) * lio->lis_nr_subios); + stripes_qin = + libcfs_kvzalloc(sizeof(*stripes_qin) * + lio->lis_nr_subios, + GFP_NOFS); if (stripes_qin == NULL) return -ENOMEM; @@ -658,8 +661,7 @@ static int lov_io_submit(const struct lu_env *env, } if (alloc) { - OBD_FREE_LARGE(stripes_qin, - sizeof(*stripes_qin) * lio->lis_nr_subios); + kvfree(stripes_qin); } else { int i; diff --git a/drivers/staging/lustre/lustre/lov/lov_lock.c b/drivers/staging/lustre/lustre/lov/lov_lock.c index f2eca565bdda..a6938085ff24 100644 --- a/drivers/staging/lustre/lustre/lov/lov_lock.c +++ b/drivers/staging/lustre/lustre/lov/lov_lock.c @@ -314,7 +314,7 @@ static int lov_lock_sub_init(const struct lu_env *env, nr++; } LASSERT(nr > 0); - OBD_ALLOC_LARGE(lck->lls_sub, nr * sizeof(lck->lls_sub[0])); + lck->lls_sub = libcfs_kvzalloc(nr * sizeof(lck->lls_sub[0]), GFP_NOFS); if (lck->lls_sub == NULL) return -ENOMEM; @@ -441,8 +441,7 @@ static void lov_lock_fini(const struct lu_env *env, * a reference on its parent. */ LASSERT(lck->lls_sub[i].sub_lock == NULL); - OBD_FREE_LARGE(lck->lls_sub, - lck->lls_nr * sizeof(lck->lls_sub[0])); + kvfree(lck->lls_sub); } OBD_SLAB_FREE_PTR(lck, lov_lock_kmem); } diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index ca1caaea2701..96c55acd52ae 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -1737,7 +1737,7 @@ static int lov_fiemap(struct lov_obd *lov, __u32 keylen, void *key, if (fiemap_count_to_size(fm_key->fiemap.fm_extent_count) < buffer_size) buffer_size = fiemap_count_to_size(fm_key->fiemap.fm_extent_count); - OBD_ALLOC_LARGE(fm_local, buffer_size); + fm_local = libcfs_kvzalloc(buffer_size, GFP_NOFS); if (fm_local == NULL) { rc = -ENOMEM; goto out; @@ -1943,7 +1943,7 @@ skip_last_device_calc: fiemap->fm_mapped_extents = current_extent; out: - OBD_FREE_LARGE(fm_local, buffer_size); + kvfree(fm_local); return rc; } diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index a22342fa792d..4d7cd924a27e 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/drivers/staging/lustre/lustre/lov/lov_object.c @@ -218,7 +218,8 @@ static int lov_init_raid0(const struct lu_env *env, r0->lo_nr = lsm->lsm_stripe_count; LASSERT(r0->lo_nr <= lov_targets_nr(dev)); - OBD_ALLOC_LARGE(r0->lo_sub, r0->lo_nr * sizeof(r0->lo_sub[0])); + r0->lo_sub = libcfs_kvzalloc(r0->lo_nr * sizeof(r0->lo_sub[0]), + GFP_NOFS); if (r0->lo_sub != NULL) { result = 0; subconf->coc_inode = conf->coc_inode; @@ -375,7 +376,7 @@ static void lov_fini_raid0(const struct lu_env *env, struct lov_object *lov, struct lov_layout_raid0 *r0 = &state->raid0; if (r0->lo_sub != NULL) { - OBD_FREE_LARGE(r0->lo_sub, r0->lo_nr * sizeof(r0->lo_sub[0])); + kvfree(r0->lo_sub); r0->lo_sub = NULL; } diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c index 92b9ffece4a0..6b1c135c9ab0 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c @@ -192,13 +192,13 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, if (*lmmp && !lsm) { stripe_count = le16_to_cpu((*lmmp)->lmm_stripe_count); lmm_size = lov_mds_md_size(stripe_count, lmm_magic); - OBD_FREE_LARGE(*lmmp, lmm_size); + kvfree(*lmmp); *lmmp = NULL; return 0; } if (!*lmmp) { - OBD_ALLOC_LARGE(*lmmp, lmm_size); + *lmmp = libcfs_kvzalloc(lmm_size, GFP_NOFS); if (!*lmmp) return -ENOMEM; } @@ -285,7 +285,7 @@ static int lov_verify_lmm(void *lmm, int lmm_bytes, __u16 *stripe_count) CERROR("bad disk LOV MAGIC: 0x%08X; dumping LMM (size=%d):\n", le32_to_cpu(*(__u32 *)lmm), lmm_bytes); sz = lmm_bytes * 2 + 1; - OBD_ALLOC_LARGE(buffer, sz); + buffer = libcfs_kvzalloc(sz, GFP_NOFS); if (buffer != NULL) { int i; @@ -293,7 +293,7 @@ static int lov_verify_lmm(void *lmm, int lmm_bytes, __u16 *stripe_count) sprintf(buffer+2*i, "%.2X", ((char *)lmm)[i]); buffer[sz - 1] = '\0'; CERROR("%s\n", buffer); - OBD_FREE_LARGE(buffer, sz); + kvfree(buffer); } return -EINVAL; } From 337844670a4b305314a6238879db6faa812adddc Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Thu, 11 Jun 2015 14:02:55 +0200 Subject: [PATCH 0913/1163] lustre: mdc: Replace uses of OBD_{ALLOC,FREE}_LARGE Replace uses of OBD_ALLOC_LARGE by libcfs_kvzalloc and OBD_FREE_LARGE by kvfree. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr,size; @@ - OBD_ALLOC_LARGE(ptr,size) + ptr = libcfs_kvzalloc(size, GFP_NOFS) @@ expression ptr,size; @@ - OBD_FREE_LARGE(ptr, size); + kvfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index f93579739083..bcb6c00c49ff 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -746,7 +746,7 @@ static int mdc_finish_enqueue(struct obd_export *exp, LDLM_DEBUG(lock, "layout lock returned by: %s, lvb_len: %d\n", ldlm_it2str(it->it_op), lvb_len); - OBD_ALLOC_LARGE(lmm, lvb_len); + lmm = libcfs_kvzalloc(lvb_len, GFP_NOFS); if (lmm == NULL) { LDLM_LOCK_PUT(lock); return -ENOMEM; @@ -763,7 +763,7 @@ static int mdc_finish_enqueue(struct obd_export *exp, } unlock_res_and_lock(lock); if (lmm != NULL) - OBD_FREE_LARGE(lmm, lvb_len); + kvfree(lmm); } if (lock != NULL) LDLM_LOCK_PUT(lock); From fea2e68e21f88f6694540bafc2c22e797f2f4bda Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Thu, 11 Jun 2015 14:02:56 +0200 Subject: [PATCH 0914/1163] lustre: obdclass: Replace uses of OBD_{ALLOC,FREE}_LARGE Replace uses of OBD_ALLOC_LARGE by libcfs_kvzalloc and OBD_FREE_LARGE by kvfree. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr,size; @@ - OBD_ALLOC_LARGE(ptr,size) + ptr = libcfs_kvzalloc(size, GFP_NOFS) @@ expression ptr,size; @@ - OBD_FREE_LARGE(ptr, size); + kvfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/lu_object.c | 8 ++++---- drivers/staging/lustre/lustre/obdclass/lustre_handles.c | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index eae660660358..4d9b6333eeae 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -2121,7 +2121,7 @@ void lu_buf_free(struct lu_buf *buf) LASSERT(buf); if (buf->lb_buf) { LASSERT(buf->lb_len > 0); - OBD_FREE_LARGE(buf->lb_buf, buf->lb_len); + kvfree(buf->lb_buf); buf->lb_buf = NULL; buf->lb_len = 0; } @@ -2133,7 +2133,7 @@ void lu_buf_alloc(struct lu_buf *buf, int size) LASSERT(buf); LASSERT(buf->lb_buf == NULL); LASSERT(buf->lb_len == 0); - OBD_ALLOC_LARGE(buf->lb_buf, size); + buf->lb_buf = libcfs_kvzalloc(size, GFP_NOFS); if (likely(buf->lb_buf)) buf->lb_len = size; } @@ -2171,14 +2171,14 @@ int lu_buf_check_and_grow(struct lu_buf *buf, int len) if (len <= buf->lb_len) return 0; - OBD_ALLOC_LARGE(ptr, len); + ptr = libcfs_kvzalloc(len, GFP_NOFS); if (ptr == NULL) return -ENOMEM; /* Free the old buf */ if (buf->lb_buf != NULL) { memcpy(ptr, buf->lb_buf, buf->lb_len); - OBD_FREE_LARGE(buf->lb_buf, buf->lb_len); + kvfree(buf->lb_buf); } buf->lb_buf = ptr; diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index 1cfaabfef6e3..35a94a8f4fd3 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c @@ -198,7 +198,8 @@ int class_handle_init(void) LASSERT(handle_hash == NULL); - OBD_ALLOC_LARGE(handle_hash, sizeof(*bucket) * HANDLE_HASH_SIZE); + handle_hash = libcfs_kvzalloc(sizeof(*bucket) * HANDLE_HASH_SIZE, + GFP_NOFS); if (handle_hash == NULL) return -ENOMEM; @@ -249,7 +250,7 @@ void class_handle_cleanup(void) count = cleanup_all_handles(); - OBD_FREE_LARGE(handle_hash, sizeof(*handle_hash) * HANDLE_HASH_SIZE); + kvfree(handle_hash); handle_hash = NULL; if (count != 0) From 6b0e43db2855db06b822cde88416366e985cc113 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Thu, 11 Jun 2015 14:02:57 +0200 Subject: [PATCH 0915/1163] lustre: obdclass: linux: Replace uses of OBD_{ALLOC, FREE}_LARGE Replace uses of OBD_ALLOC_LARGE by libcfs_kvzalloc and OBD_FREE_LARGE by kvfree. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr,size; @@ - OBD_ALLOC_LARGE(ptr,size) + ptr = libcfs_kvzalloc(size, GFP_NOFS) @@ expression ptr,size; @@ - OBD_FREE_LARGE(ptr, size); + kvfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/linux/linux-module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index e3c6dcb42cff..84f75dce0d4c 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -107,7 +107,7 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg) * system, the high lock contention will hurt performance badly, * obdfilter-survey is an example, which relies on ioctl. So we'd * better avoid vmalloc on ioctl path. LU-66 */ - OBD_ALLOC_LARGE(*buf, hdr.ioc_len); + *buf = libcfs_kvzalloc(hdr.ioc_len, GFP_NOFS); if (*buf == NULL) { CERROR("Cannot allocate control buffer of len %d\n", hdr.ioc_len); @@ -153,7 +153,7 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg) return 0; free_buf: - OBD_FREE_LARGE(*buf, hdr.ioc_len); + kvfree(*buf); return err; } EXPORT_SYMBOL(obd_ioctl_getdata); From ee0ec1946ec2aa11930bfa62a2b12d35256122c2 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Thu, 11 Jun 2015 14:02:58 +0200 Subject: [PATCH 0916/1163] lustre: ptlrpc: Replace uses of OBD_{ALLOC,FREE}_LARGE Replace uses of OBD_ALLOC_LARGE by libcfs_kvzalloc and OBD_FREE_LARGE by kvfree. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression ptr,size; @@ - OBD_ALLOC_LARGE(ptr,size) + ptr = libcfs_kvzalloc(size, GFP_NOFS) @@ expression ptr,size; @@ - OBD_FREE_LARGE(ptr, size); + kvfree(ptr); // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/client.c | 4 ++-- drivers/staging/lustre/lustre/ptlrpc/sec.c | 10 +++++----- drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 11 +++++------ drivers/staging/lustre/lustre/ptlrpc/sec_null.c | 16 ++++++++-------- drivers/staging/lustre/lustre/ptlrpc/sec_plain.c | 16 ++++++++-------- drivers/staging/lustre/lustre/ptlrpc/service.c | 10 +++++----- 6 files changed, 33 insertions(+), 34 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 35ebe0f35bd1..a12cd66b2365 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -435,7 +435,7 @@ void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool) list_del(&req->rq_list); LASSERT(req->rq_reqbuf); LASSERT(req->rq_reqbuf_len == pool->prp_rq_size); - OBD_FREE_LARGE(req->rq_reqbuf, pool->prp_rq_size); + kvfree(req->rq_reqbuf); ptlrpc_request_cache_free(req); } spin_unlock(&pool->prp_lock); @@ -469,7 +469,7 @@ void ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq) req = ptlrpc_request_cache_alloc(GFP_NOFS); if (!req) return; - OBD_ALLOC_LARGE(msg, size); + msg = libcfs_kvzalloc(size, GFP_NOFS); if (!msg) { ptlrpc_request_cache_free(req); return; diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index 8798fab31f77..b9821db22904 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -469,7 +469,7 @@ int sptlrpc_req_ctx_switch(struct ptlrpc_request *req, /* save request message */ reqmsg_size = req->rq_reqlen; if (reqmsg_size != 0) { - OBD_ALLOC_LARGE(reqmsg, reqmsg_size); + reqmsg = libcfs_kvzalloc(reqmsg_size, GFP_NOFS); if (reqmsg == NULL) return -ENOMEM; memcpy(reqmsg, req->rq_reqmsg, reqmsg_size); @@ -497,7 +497,7 @@ int sptlrpc_req_ctx_switch(struct ptlrpc_request *req, req->rq_flvr = old_flvr; } - OBD_FREE_LARGE(reqmsg, reqmsg_size); + kvfree(reqmsg); } return rc; } @@ -1093,7 +1093,7 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req, early_size = req->rq_nob_received; early_bufsz = size_roundup_power2(early_size); - OBD_ALLOC_LARGE(early_buf, early_bufsz); + early_buf = libcfs_kvzalloc(early_bufsz, GFP_NOFS); if (early_buf == NULL) { rc = -ENOMEM; goto err_req; @@ -1163,7 +1163,7 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req, err_ctx: sptlrpc_cli_ctx_put(early_req->rq_cli_ctx, 1); err_buf: - OBD_FREE_LARGE(early_buf, early_bufsz); + kvfree(early_buf); err_req: ptlrpc_request_cache_free(early_req); return rc; @@ -1181,7 +1181,7 @@ void sptlrpc_cli_finish_early_reply(struct ptlrpc_request *early_req) LASSERT(early_req->rq_repmsg); sptlrpc_cli_ctx_put(early_req->rq_cli_ctx, 1); - OBD_FREE_LARGE(early_req->rq_repbuf, early_req->rq_repbuf_len); + kvfree(early_req->rq_repbuf); ptlrpc_request_cache_free(early_req); } diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index ea35ca54e729..69d73c430696 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -689,9 +689,10 @@ EXPORT_SYMBOL(sptlrpc_enc_pool_del_user); static inline void enc_pools_alloc(void) { LASSERT(page_pools.epp_max_pools); - OBD_ALLOC_LARGE(page_pools.epp_pools, - page_pools.epp_max_pools * - sizeof(*page_pools.epp_pools)); + page_pools.epp_pools = + libcfs_kvzalloc(page_pools.epp_max_pools * + sizeof(*page_pools.epp_pools), + GFP_NOFS); } static inline void enc_pools_free(void) @@ -699,9 +700,7 @@ static inline void enc_pools_free(void) LASSERT(page_pools.epp_max_pools); LASSERT(page_pools.epp_pools); - OBD_FREE_LARGE(page_pools.epp_pools, - page_pools.epp_max_pools * - sizeof(*page_pools.epp_pools)); + kvfree(page_pools.epp_pools); } static struct shrinker pools_shrinker = { diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c index 8c28b6b7ff02..ce1c563d0175 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c @@ -159,7 +159,7 @@ int null_alloc_reqbuf(struct ptlrpc_sec *sec, int alloc_size = size_roundup_power2(msgsize); LASSERT(!req->rq_pool); - OBD_ALLOC_LARGE(req->rq_reqbuf, alloc_size); + req->rq_reqbuf = libcfs_kvzalloc(alloc_size, GFP_NOFS); if (!req->rq_reqbuf) return -ENOMEM; @@ -186,7 +186,7 @@ void null_free_reqbuf(struct ptlrpc_sec *sec, "req %p: reqlen %d should smaller than buflen %d\n", req, req->rq_reqlen, req->rq_reqbuf_len); - OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len); + kvfree(req->rq_reqbuf); req->rq_reqbuf = NULL; req->rq_reqbuf_len = 0; } @@ -202,7 +202,7 @@ int null_alloc_repbuf(struct ptlrpc_sec *sec, msgsize = size_roundup_power2(msgsize); - OBD_ALLOC_LARGE(req->rq_repbuf, msgsize); + req->rq_repbuf = libcfs_kvzalloc(msgsize, GFP_NOFS); if (!req->rq_repbuf) return -ENOMEM; @@ -216,7 +216,7 @@ void null_free_repbuf(struct ptlrpc_sec *sec, { LASSERT(req->rq_repbuf); - OBD_FREE_LARGE(req->rq_repbuf, req->rq_repbuf_len); + kvfree(req->rq_repbuf); req->rq_repbuf = NULL; req->rq_repbuf_len = 0; } @@ -247,7 +247,7 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec, if (req->rq_reqbuf_len < newmsg_size) { alloc_size = size_roundup_power2(newmsg_size); - OBD_ALLOC_LARGE(newbuf, alloc_size); + newbuf = libcfs_kvzalloc(alloc_size, GFP_NOFS); if (newbuf == NULL) return -ENOMEM; @@ -261,7 +261,7 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec, spin_lock(&req->rq_import->imp_lock); memcpy(newbuf, req->rq_reqbuf, req->rq_reqlen); - OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len); + kvfree(req->rq_reqbuf); req->rq_reqbuf = req->rq_reqmsg = newbuf; req->rq_reqbuf_len = alloc_size; @@ -316,7 +316,7 @@ int null_alloc_rs(struct ptlrpc_request *req, int msgsize) /* pre-allocated */ LASSERT(rs->rs_size >= rs_size); } else { - OBD_ALLOC_LARGE(rs, rs_size); + rs = libcfs_kvzalloc(rs_size, GFP_NOFS); if (rs == NULL) return -ENOMEM; @@ -341,7 +341,7 @@ void null_free_rs(struct ptlrpc_reply_state *rs) atomic_dec(&rs->rs_svc_ctx->sc_refcount); if (!rs->rs_prealloc) - OBD_FREE_LARGE(rs, rs->rs_size); + kvfree(rs); } static diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c index ed39970417d8..53ce0d14bd46 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c @@ -559,7 +559,7 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec, LASSERT(!req->rq_pool); alloc_len = size_roundup_power2(alloc_len); - OBD_ALLOC_LARGE(req->rq_reqbuf, alloc_len); + req->rq_reqbuf = libcfs_kvzalloc(alloc_len, GFP_NOFS); if (!req->rq_reqbuf) return -ENOMEM; @@ -584,7 +584,7 @@ void plain_free_reqbuf(struct ptlrpc_sec *sec, struct ptlrpc_request *req) { if (!req->rq_pool) { - OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len); + kvfree(req->rq_reqbuf); req->rq_reqbuf = NULL; req->rq_reqbuf_len = 0; } @@ -613,7 +613,7 @@ int plain_alloc_repbuf(struct ptlrpc_sec *sec, alloc_len = size_roundup_power2(alloc_len); - OBD_ALLOC_LARGE(req->rq_repbuf, alloc_len); + req->rq_repbuf = libcfs_kvzalloc(alloc_len, GFP_NOFS); if (!req->rq_repbuf) return -ENOMEM; @@ -625,7 +625,7 @@ static void plain_free_repbuf(struct ptlrpc_sec *sec, struct ptlrpc_request *req) { - OBD_FREE_LARGE(req->rq_repbuf, req->rq_repbuf_len); + kvfree(req->rq_repbuf); req->rq_repbuf = NULL; req->rq_repbuf_len = 0; } @@ -664,7 +664,7 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec, if (req->rq_reqbuf_len < newbuf_size) { newbuf_size = size_roundup_power2(newbuf_size); - OBD_ALLOC_LARGE(newbuf, newbuf_size); + newbuf = libcfs_kvzalloc(newbuf_size, GFP_NOFS); if (newbuf == NULL) return -ENOMEM; @@ -679,7 +679,7 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec, memcpy(newbuf, req->rq_reqbuf, req->rq_reqbuf_len); - OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len); + kvfree(req->rq_reqbuf); req->rq_reqbuf = newbuf; req->rq_reqbuf_len = newbuf_size; req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf, @@ -800,7 +800,7 @@ int plain_alloc_rs(struct ptlrpc_request *req, int msgsize) /* pre-allocated */ LASSERT(rs->rs_size >= rs_size); } else { - OBD_ALLOC_LARGE(rs, rs_size); + rs = libcfs_kvzalloc(rs_size, GFP_NOFS); if (rs == NULL) return -ENOMEM; @@ -826,7 +826,7 @@ void plain_free_rs(struct ptlrpc_reply_state *rs) atomic_dec(&rs->rs_svc_ctx->sc_refcount); if (!rs->rs_prealloc) - OBD_FREE_LARGE(rs, rs->rs_size); + kvfree(rs); } static diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 25ccbcb1772f..0d33154e095a 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -114,7 +114,7 @@ ptlrpc_free_rqbd(struct ptlrpc_request_buffer_desc *rqbd) svcpt->scp_nrqbds_total--; spin_unlock(&svcpt->scp_lock); - OBD_FREE_LARGE(rqbd->rqbd_buffer, svcpt->scp_service->srv_buf_size); + kvfree(rqbd->rqbd_buffer); kfree(rqbd); } @@ -1310,7 +1310,7 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) reqcopy = ptlrpc_request_cache_alloc(GFP_NOFS); if (reqcopy == NULL) return -ENOMEM; - OBD_ALLOC_LARGE(reqmsg, req->rq_reqlen); + reqmsg = libcfs_kvzalloc(req->rq_reqlen, GFP_NOFS); if (!reqmsg) { rc = -ENOMEM; goto out_free; @@ -1374,7 +1374,7 @@ out_put: class_export_put(reqcopy->rq_export); out: sptlrpc_svc_ctx_decref(reqcopy); - OBD_FREE_LARGE(reqmsg, req->rq_reqlen); + kvfree(reqmsg); out_free: ptlrpc_request_cache_free(reqcopy); return rc; @@ -2323,7 +2323,7 @@ static int ptlrpc_main(void *arg) } /* Alloc reply state structure for this one */ - OBD_ALLOC_LARGE(rs, svc->srv_max_reply_size); + rs = libcfs_kvzalloc(svc->srv_max_reply_size, GFP_NOFS); if (!rs) { rc = -ENOMEM; goto out_srv_fini; @@ -2987,7 +2987,7 @@ ptlrpc_service_purge_all(struct ptlrpc_service *svc) struct ptlrpc_reply_state, rs_list); list_del(&rs->rs_list); - OBD_FREE_LARGE(rs, svc->srv_max_reply_size); + kvfree(rs); } } } From 3703480b02446b35e8427f6a114a5690b64324a8 Mon Sep 17 00:00:00 2001 From: Chaehyun Lim Date: Thu, 11 Jun 2015 14:34:32 +0900 Subject: [PATCH 0917/1163] staging: wilc1000: remove UWORD8 Use u8 instead of UWORD8. Signed-off-by: Chaehyun Lim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 2 +- drivers/staging/wilc1000/host_interface.c | 2 +- drivers/staging/wilc1000/itypes.h | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index 3a6c5baf0abb..339b2a5c4384 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -499,7 +499,7 @@ INLINE WILC_Uint32 get_beacon_timestamp_lo(u8 *data) return time_stamp; } -INLINE UWORD32 get_beacon_timestamp_hi(UWORD8 *data) +INLINE UWORD32 get_beacon_timestamp_hi(u8 *data) { UWORD32 time_stamp = 0; UWORD32 index = (MAC_HDR_LEN + 4); diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 1ecb37341780..b2bbb45143d1 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -3692,7 +3692,7 @@ static void Handle_DelAllSta(void *drvHandler, tstrHostIFDelAllSta *pstrDelAllSt u8 *pu8CurrByte; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; u8 i; - UWORD8 au8Zero_Buff[6] = {0}; + u8 au8Zero_Buff[6] = {0}; strWID.u16WIDid = (WILC_Uint16)WID_DEL_ALL_STA; strWID.enuWIDtype = WID_STR; strWID.s32ValueSize = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1; diff --git a/drivers/staging/wilc1000/itypes.h b/drivers/staging/wilc1000/itypes.h index 6c2bd791a0b1..91c8f0dca6d6 100644 --- a/drivers/staging/wilc1000/itypes.h +++ b/drivers/staging/wilc1000/itypes.h @@ -46,7 +46,6 @@ typedef short WORD16; typedef char WORD8; typedef unsigned int UWORD32; typedef unsigned short UWORD16; -typedef unsigned char UWORD8; /*****************************************************************************/ /* Enums */ From 8a54d91719a9cef4e599f6c699fb6a5136ed7a3f Mon Sep 17 00:00:00 2001 From: Chaehyun Lim Date: Thu, 11 Jun 2015 14:35:53 +0900 Subject: [PATCH 0918/1163] staging: wilc1000: remove UWORD32 Use u32 instead of UWORD32. Signed-off-by: Chaehyun Lim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 6 +++--- drivers/staging/wilc1000/itypes.h | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index 339b2a5c4384..d3a006937619 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -499,10 +499,10 @@ INLINE WILC_Uint32 get_beacon_timestamp_lo(u8 *data) return time_stamp; } -INLINE UWORD32 get_beacon_timestamp_hi(u8 *data) +INLINE u32 get_beacon_timestamp_hi(u8 *data) { - UWORD32 time_stamp = 0; - UWORD32 index = (MAC_HDR_LEN + 4); + u32 time_stamp = 0; + u32 index = (MAC_HDR_LEN + 4); time_stamp |= data[index++]; time_stamp |= (data[index++] << 8); diff --git a/drivers/staging/wilc1000/itypes.h b/drivers/staging/wilc1000/itypes.h index 91c8f0dca6d6..c99f8cabcaee 100644 --- a/drivers/staging/wilc1000/itypes.h +++ b/drivers/staging/wilc1000/itypes.h @@ -44,7 +44,6 @@ typedef int WORD32; typedef short WORD16; typedef char WORD8; -typedef unsigned int UWORD32; typedef unsigned short UWORD16; /*****************************************************************************/ From d85f5326e4a4b1606a0dbb3f8a320a0359fdb2d8 Mon Sep 17 00:00:00 2001 From: Chaehyun Lim Date: Thu, 11 Jun 2015 14:35:54 +0900 Subject: [PATCH 0919/1163] staging: wilc1000: remove WILC_Uint16 Use u16 instead of WILC_Uint16. Signed-off-by: Chaehyun Lim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 98 +++--- drivers/staging/wilc1000/coreconfigurator.h | 26 +- drivers/staging/wilc1000/host_interface.c | 300 +++++++++--------- drivers/staging/wilc1000/host_interface.h | 56 ++-- drivers/staging/wilc1000/linux_mon.c | 2 +- drivers/staging/wilc1000/linux_wlan.c | 2 +- drivers/staging/wilc1000/wilc_oswrapper.h | 1 - .../staging/wilc1000/wilc_wfi_cfgoperations.c | 8 +- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 2 +- drivers/staging/wilc1000/wilc_wlan.c | 8 +- 10 files changed, 251 insertions(+), 252 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index d3a006937619..cc4455f47309 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -176,7 +176,7 @@ static u8 g_seqno; static WILC_Sint16 g_wid_num = -1; -static WILC_Uint16 Res_Len; +static u16 Res_Len; static u8 g_oper_mode = SET_CFG; @@ -309,7 +309,7 @@ static tstrWID gastrWIDs[] = { #endif /* MAC_802_11N */ }; -WILC_Uint16 g_num_total_switches = (sizeof(gastrWIDs) / sizeof(tstrWID)); +u16 g_num_total_switches = (sizeof(gastrWIDs) / sizeof(tstrWID)); /*****************************************************************************/ /* Static Function Declarations */ /*****************************************************************************/ @@ -340,7 +340,7 @@ INLINE u8 get_hex_char(u8 inp) /* This function extracts the MAC address held in a string in standard format */ /* into another buffer as integers. */ -INLINE WILC_Uint16 extract_mac_addr(WILC_Char *str, u8 *buff) +INLINE u16 extract_mac_addr(WILC_Char *str, u8 *buff) { *buff = 0; while (*str != '\0') { @@ -476,9 +476,9 @@ INLINE tenuWIDtype get_wid_type(WILC_Uint32 wid_num) /* This function extracts the beacon period field from the beacon or probe */ /* response frame. */ -INLINE WILC_Uint16 get_beacon_period(u8 *data) +INLINE u16 get_beacon_period(u8 *data) { - WILC_Uint16 bcn_per = 0; + u16 bcn_per = 0; bcn_per = data[0]; bcn_per |= (data[1] << 8); @@ -605,10 +605,10 @@ INLINE void get_ssid(u8 *data, u8 *ssid, u8 *p_ssid_len) /* This function extracts the capability info field from the beacon or probe */ /* response frame. */ -INLINE WILC_Uint16 get_cap_info(u8 *data) +INLINE u16 get_cap_info(u8 *data) { - WILC_Uint16 cap_info = 0; - WILC_Uint16 index = MAC_HDR_LEN; + u16 cap_info = 0; + u16 index = MAC_HDR_LEN; tenuFrmSubtype st = BEACON; st = get_sub_type(data); @@ -626,9 +626,9 @@ INLINE WILC_Uint16 get_cap_info(u8 *data) /* This function extracts the capability info field from the Association */ /* response frame. */ -INLINE WILC_Uint16 get_assoc_resp_cap_info(u8 *data) +INLINE u16 get_assoc_resp_cap_info(u8 *data) { - WILC_Uint16 cap_info = 0; + u16 cap_info = 0; cap_info = data[0]; cap_info |= (data[1] << 8); @@ -638,9 +638,9 @@ INLINE WILC_Uint16 get_assoc_resp_cap_info(u8 *data) /* This funcion extracts the association status code from the incoming */ /* association response frame and returns association status code */ -INLINE WILC_Uint16 get_asoc_status(u8 *data) +INLINE u16 get_asoc_status(u8 *data) { - WILC_Uint16 asoc_status = 0; + u16 asoc_status = 0; asoc_status = data[3]; asoc_status = (asoc_status << 8) | data[2]; @@ -650,9 +650,9 @@ INLINE WILC_Uint16 get_asoc_status(u8 *data) /* This function extracts association ID from the incoming association */ /* response frame */ -INLINE WILC_Uint16 get_asoc_id(u8 *data) +INLINE u16 get_asoc_id(u8 *data) { - WILC_Uint16 asoc_id = 0; + u16 asoc_id = 0; asoc_id = data[4]; asoc_id |= (data[5] << 8); @@ -692,9 +692,9 @@ _fail_: return s32Error; } -u8 *get_tim_elm(u8 *pu8msa, WILC_Uint16 u16RxLen, WILC_Uint16 u16TagParamOffset) +u8 *get_tim_elm(u8 *pu8msa, u16 u16RxLen, u16 u16TagParamOffset) { - WILC_Uint16 u16index = 0; + u16 u16index = 0; /*************************************************************************/ /* Beacon Frame - Frame Body */ @@ -722,9 +722,9 @@ u8 *get_tim_elm(u8 *pu8msa, WILC_Uint16 u16RxLen, WILC_Uint16 u16TagParamOffset) /* This function gets the current channel information from * the 802.11n beacon/probe response frame */ -u8 get_current_channel_802_11n(u8 *pu8msa, WILC_Uint16 u16RxLen) +u8 get_current_channel_802_11n(u8 *pu8msa, u16 u16RxLen) { - WILC_Uint16 index; + u16 index; index = TAG_PARAM_OFFSET; while (index < (u16RxLen - FCS_LEN)) { @@ -741,7 +741,7 @@ u8 get_current_channel_802_11n(u8 *pu8msa, WILC_Uint16 u16RxLen) return 0; /* no MIB here */ } -u8 get_current_channel(u8 *pu8msa, WILC_Uint16 u16RxLen) +u8 get_current_channel(u8 *pu8msa, u16 u16RxLen) { #ifdef PHY_802_11n #ifdef FIVE_GHZ_BAND @@ -775,10 +775,10 @@ WILC_Sint32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInf tstrNetworkInfo *pstrNetworkInfo = NULL; u8 u8MsgType = 0; u8 u8MsgID = 0; - WILC_Uint16 u16MsgLen = 0; + u16 u16MsgLen = 0; - WILC_Uint16 u16WidID = (WILC_Uint16)WID_NIL; - WILC_Uint16 u16WidLen = 0; + u16 u16WidID = (u16)WID_NIL; + u16 u16WidLen = 0; u8 *pu8WidVal = 0; u8MsgType = pu8MsgBuffer[0]; @@ -807,10 +807,10 @@ WILC_Sint32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInf /* parse the WID value of the WID "WID_NEWORK_INFO" */ { u8 *pu8msa = 0; - WILC_Uint16 u16RxLen = 0; + u16 u16RxLen = 0; u8 *pu8TimElm = 0; u8 *pu8IEs = 0; - WILC_Uint16 u16IEsLen = 0; + u16 u16IEsLen = 0; u8 u8index = 0; WILC_Uint32 u32Tsf_Lo; WILC_Uint32 u32Tsf_Hi; @@ -929,15 +929,15 @@ WILC_Sint32 ParseAssocRespInfo(u8 *pu8Buffer, WILC_Uint32 u32BufferLen, { WILC_Sint32 s32Error = WILC_SUCCESS; tstrConnectRespInfo *pstrConnectRespInfo = NULL; - WILC_Uint16 u16AssocRespLen = 0; + u16 u16AssocRespLen = 0; u8 *pu8IEs = 0; - WILC_Uint16 u16IEsLen = 0; + u16 u16IEsLen = 0; pstrConnectRespInfo = (tstrConnectRespInfo *)WILC_MALLOC(sizeof(tstrConnectRespInfo)); WILC_memset((void *)(pstrConnectRespInfo), 0, sizeof(tstrConnectRespInfo)); /* u16AssocRespLen = pu8Buffer[0]; */ - u16AssocRespLen = (WILC_Uint16)u32BufferLen; + u16AssocRespLen = (u16)u32BufferLen; /* get the status code */ pstrConnectRespInfo->u16ConnectStatus = get_asoc_status(pu8Buffer); @@ -1153,8 +1153,8 @@ void ProcessCharWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, void ProcessShortWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, tstrWID *pstrWID, WILC_Sint8 *ps8WidVal) { - WILC_Uint16 *pu16val = (WILC_Uint16 *)ps8WidVal; - WILC_Uint16 u16val = 0; + u16 *pu16val = (u16 *)ps8WidVal; + u16 u16val = 0; WILC_Sint32 s32PktLen = *ps32PktLen; if (pstrWID == NULL) { PRINT_WRN(CORECONFIG_DBG, "Can't set SHORT val 0x%x ,NULL structure\n", u16val); @@ -1169,7 +1169,7 @@ void ProcessShortWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, u16val = *pu16val; /* Length */ - pcPacket[s32PktLen++] = sizeof(WILC_Uint16); + pcPacket[s32PktLen++] = sizeof(u16); /* Value */ pcPacket[s32PktLen++] = (u8)(u16val & 0xFF); @@ -1324,8 +1324,8 @@ void ProcessIPwid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, void ProcessStrWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, tstrWID *pstrWID, u8 *pu8val, WILC_Sint32 s32ValueSize) { - WILC_Uint16 u16MsgLen = 0; - WILC_Uint16 idx = 0; + u16 u16MsgLen = 0; + u16 idx = 0; WILC_Sint32 s32PktLen = *ps32PktLen; if (pstrWID == NULL) { PRINT_WRN(CORECONFIG_DBG, "Can't set STR val, NULL structure\n"); @@ -1339,7 +1339,7 @@ void ProcessStrWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, if (g_oper_mode == SET_CFG) { /* Message Length */ /* u16MsgLen = WILC_strlen(pu8val); */ - u16MsgLen = (WILC_Uint16)s32ValueSize; + u16MsgLen = (u16)s32ValueSize; /* Length */ pcPacket[s32PktLen++] = (u8)u16MsgLen; @@ -1381,7 +1381,7 @@ void ProcessStrWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, void ProcessAdrWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, tstrWID *pstrWID, u8 *pu8val) { - WILC_Uint16 u16MsgLen = 0; + u16 u16MsgLen = 0; WILC_Sint32 s32PktLen = *ps32PktLen; if (pstrWID == NULL) { @@ -1447,8 +1447,8 @@ void ProcessBinWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, { /* WILC_ERROR("processing Binary WIDs is not supported\n"); */ - WILC_Uint16 u16MsgLen = 0; - WILC_Uint16 idx = 0; + u16 u16MsgLen = 0; + u16 idx = 0; WILC_Sint32 s32PktLen = *ps32PktLen; u8 u8checksum = 0; @@ -1463,7 +1463,7 @@ void ProcessBinWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, if (g_oper_mode == SET_CFG) { /* Message Length */ - u16MsgLen = (WILC_Uint16)s32ValueSize; + u16MsgLen = (u16)s32ValueSize; /* Length */ /* pcPacket[s32PktLen++] = (u8)u16MsgLen; */ @@ -1518,8 +1518,8 @@ void ProcessBinWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, /*****************************************************************************/ WILC_Sint32 further_process_response(u8 *resp, - WILC_Uint16 u16WIDid, - WILC_Uint16 cfg_len, + u16 u16WIDid, + u16 cfg_len, WILC_Bool process_wid_num, WILC_Uint32 cnt, tstrWID *pstrWIDresult) @@ -1527,7 +1527,7 @@ WILC_Sint32 further_process_response(u8 *resp, WILC_Uint32 retval = 0; WILC_Uint32 idx = 0; u8 cfg_chr = 0; - WILC_Uint16 cfg_sht = 0; + u16 cfg_sht = 0; WILC_Uint32 cfg_int = 0; u8 cfg_str[256] = {0}; tenuWIDtype enuWIDtype = WID_UNDEF; @@ -1548,7 +1548,7 @@ WILC_Sint32 further_process_response(u8 *resp, case WID_SHORT: { - WILC_Uint16 *pu16val = (WILC_Uint16 *)(pstrWIDresult->ps8WidVal); + u16 *pu16val = (u16 *)(pstrWIDresult->ps8WidVal); cfg_sht = MAKE_WORD16(resp[idx], resp[idx + 1]); /*Set local copy of WID*/ /* pstrWIDresult->ps8WidVal = (WILC_Sint8*)(WILC_Sint32)cfg_sht; */ @@ -1689,9 +1689,9 @@ WILC_Sint32 further_process_response(u8 *resp, WILC_Sint32 ParseResponse(u8 *resp, tstrWID *pstrWIDcfgResult) { - WILC_Uint16 u16RespLen = 0; - WILC_Uint16 u16WIDid = 0; - WILC_Uint16 cfg_len = 0; + u16 u16RespLen = 0; + u16 u16WIDid = 0; + u16 cfg_len = 0; tenuWIDtype enuWIDtype = WID_UNDEF; WILC_Bool num_wid_processed = WILC_FALSE; WILC_Uint32 cnt = 0; @@ -1713,7 +1713,7 @@ WILC_Sint32 ParseResponse(u8 *resp, tstrWID *pstrWIDcfgResult) /* Incase of Bin Type Wid, the length is given by two byte field */ enuWIDtype = get_wid_type(u16WIDid); if (WID_BIN_DATA == enuWIDtype) { - cfg_len |= ((WILC_Uint16)resp[idx + 3] << 8) & 0xFF00; + cfg_len |= ((u16)resp[idx + 3] << 8) & 0xFF00; idx++; } idx += 3; @@ -1763,8 +1763,8 @@ WILC_Sint32 ParseResponse(u8 *resp, tstrWID *pstrWIDcfgResult) WILC_Sint32 ParseWriteResponse(u8 *pu8RespBuffer) { WILC_Sint32 s32Error = WILC_FAIL; - WILC_Uint16 u16RespLen = 0; - WILC_Uint16 u16WIDtype = (WILC_Uint16)WID_NIL; + u16 u16RespLen = 0; + u16 u16WIDtype = (u16)WID_NIL; /* Check whether the received frame is a valid response */ if (RESP_MSG_TYPE != pu8RespBuffer[0]) { @@ -1806,8 +1806,8 @@ WILC_Sint32 ParseWriteResponse(u8 *pu8RespBuffer) WILC_Sint32 CreatePacketHeader(WILC_Char *pcpacket, WILC_Sint32 *ps32PacketLength) { WILC_Sint32 s32Error = WILC_SUCCESS; - WILC_Uint16 u16MsgLen = (WILC_Uint16)(*ps32PacketLength); - WILC_Uint16 u16MsgInd = 0; + u16 u16MsgLen = (u16)(*ps32PacketLength); + u16 u16MsgInd = 0; /* The format of the message is: */ /* +-------------------------------------------------------------------+ */ diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h index b8e52414ebcc..640dc50860f9 100644 --- a/drivers/staging/wilc1000/coreconfigurator.h +++ b/drivers/staging/wilc1000/coreconfigurator.h @@ -31,7 +31,7 @@ #define NUM_11N_HUT_SWITCHES 0 #endif /* MAC_802_11N */ -extern WILC_Uint16 g_num_total_switches; +extern u16 g_num_total_switches; #define MAC_HDR_LEN 24 /* No Address4 - non-ESS */ #define MAX_SSID_LEN 33 @@ -65,7 +65,7 @@ extern WILC_Uint16 g_num_total_switches; /*****************************************************************************/ /* Function Macros */ /*****************************************************************************/ -#define MAKE_WORD16(lsb, msb) ((((WILC_Uint16)(msb) << 8) & 0xFF00) | (lsb)) +#define MAKE_WORD16(lsb, msb) ((((u16)(msb) << 8) & 0xFF00) | (lsb)) #define MAKE_WORD32(lsw, msw) ((((WILC_Uint32)(msw) << 16) & 0xFFFF0000) | (lsw)) @@ -394,7 +394,7 @@ typedef enum { } tenuConnectSts; typedef struct { - WILC_Uint16 u16WIDid; + u16 u16WIDid; tenuWIDtype enuWIDtype; WILC_Sint32 s32ValueSize; WILC_Sint8 *ps8WidVal; @@ -409,11 +409,11 @@ typedef struct { /* This structure is used to support parsing of the received 'N' message */ typedef struct { WILC_Sint8 s8rssi; - WILC_Uint16 u16CapInfo; + u16 u16CapInfo; u8 au8ssid[MAX_SSID_LEN]; u8 u8SsidLen; u8 au8bssid[6]; - WILC_Uint16 u16BeaconPeriod; + u16 u16BeaconPeriod; u8 u8DtimPeriod; u8 u8channel; unsigned long u32TimeRcvdInScanCached; /* of type unsigned long to be accepted by the linux kernel macro time_after() */ @@ -426,7 +426,7 @@ typedef struct { WILC_Uint32 u32Tsf; /* time-stamp [Low only 32 bit] */ #endif u8 *pu8IEs; - WILC_Uint16 u16IEsLen; + u16 u16IEsLen; void *pJoinParams; tstrRSSI strRssi; WILC_Uint64 u64Tsf; /* time-stamp [Low and High 64 bit] */ @@ -434,11 +434,11 @@ typedef struct { /* This structure is used to support parsing of the received Association Response frame */ typedef struct { - WILC_Uint16 u16capability; - WILC_Uint16 u16ConnectStatus; - WILC_Uint16 u16AssocID; + u16 u16capability; + u16 u16ConnectStatus; + u16 u16AssocID; u8 *pu8RespIEs; - WILC_Uint16 u16RespIEsLen; + u16 u16RespIEsLen; } tstrConnectRespInfo; @@ -447,14 +447,14 @@ typedef struct { u8 *pu8ReqIEs; size_t ReqIEsLen; u8 *pu8RespIEs; - WILC_Uint16 u16RespIEsLen; - WILC_Uint16 u16ConnectStatus; + u16 u16RespIEsLen; + u16 u16ConnectStatus; } tstrConnectInfo; typedef struct { - WILC_Uint16 u16reason; + u16 u16reason; u8 *ie; size_t ie_len; } tstrDisconnectNotifInfo; diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index b2bbb45143d1..4b6265c21c6f 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -19,46 +19,46 @@ extern u8 g_wilc_initialized; /*****************************************************************************/ /* Message types of the Host IF Message Queue*/ -#define HOST_IF_MSG_SCAN ((WILC_Uint16)0) -#define HOST_IF_MSG_CONNECT ((WILC_Uint16)1) -#define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO ((WILC_Uint16)2) -#define HOST_IF_MSG_KEY ((WILC_Uint16)3) -#define HOST_IF_MSG_RCVD_NTWRK_INFO ((WILC_Uint16)4) -#define HOST_IF_MSG_RCVD_SCAN_COMPLETE ((WILC_Uint16)5) -#define HOST_IF_MSG_CFG_PARAMS ((WILC_Uint16)6) -#define HOST_IF_MSG_SET_CHANNEL ((WILC_Uint16)7) -#define HOST_IF_MSG_DISCONNECT ((WILC_Uint16)8) -#define HOST_IF_MSG_GET_RSSI ((WILC_Uint16)9) -#define HOST_IF_MSG_GET_CHNL ((WILC_Uint16)10) -#define HOST_IF_MSG_ADD_BEACON ((WILC_Uint16)11) -#define HOST_IF_MSG_DEL_BEACON ((WILC_Uint16)12) -#define HOST_IF_MSG_ADD_STATION ((WILC_Uint16)13) -#define HOST_IF_MSG_DEL_STATION ((WILC_Uint16)14) -#define HOST_IF_MSG_EDIT_STATION ((WILC_Uint16)15) -#define HOST_IF_MSG_SCAN_TIMER_FIRED ((WILC_Uint16)16) -#define HOST_IF_MSG_CONNECT_TIMER_FIRED ((WILC_Uint16)17) -#define HOST_IF_MSG_POWER_MGMT ((WILC_Uint16)18) -#define HOST_IF_MSG_GET_INACTIVETIME ((WILC_Uint16)19) -#define HOST_IF_MSG_REMAIN_ON_CHAN ((WILC_Uint16)20) -#define HOST_IF_MSG_REGISTER_FRAME ((WILC_Uint16)21) -#define HOST_IF_MSG_LISTEN_TIMER_FIRED ((WILC_Uint16)22) -#define HOST_IF_MSG_GET_LINKSPEED ((WILC_Uint16)23) -#define HOST_IF_MSG_SET_WFIDRV_HANDLER ((WILC_Uint16)24) -#define HOST_IF_MSG_SET_MAC_ADDRESS ((WILC_Uint16)25) -#define HOST_IF_MSG_GET_MAC_ADDRESS ((WILC_Uint16)26) -#define HOST_IF_MSG_SET_OPERATION_MODE ((WILC_Uint16)27) -#define HOST_IF_MSG_SET_IPADDRESS ((WILC_Uint16)28) -#define HOST_IF_MSG_GET_IPADDRESS ((WILC_Uint16)29) -#define HOST_IF_MSG_FLUSH_CONNECT ((WILC_Uint16)30) -#define HOST_IF_MSG_GET_STATISTICS ((WILC_Uint16)31) -#define HOST_IF_MSG_SET_MULTICAST_FILTER ((WILC_Uint16)32) -#define HOST_IF_MSG_ADD_BA_SESSION ((WILC_Uint16)33) -#define HOST_IF_MSG_DEL_BA_SESSION ((WILC_Uint16)34) -#define HOST_IF_MSG_Q_IDLE ((WILC_Uint16)35) -#define HOST_IF_MSG_DEL_ALL_STA ((WILC_Uint16)36) -#define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS ((WILC_Uint16)34) +#define HOST_IF_MSG_SCAN ((u16)0) +#define HOST_IF_MSG_CONNECT ((u16)1) +#define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO ((u16)2) +#define HOST_IF_MSG_KEY ((u16)3) +#define HOST_IF_MSG_RCVD_NTWRK_INFO ((u16)4) +#define HOST_IF_MSG_RCVD_SCAN_COMPLETE ((u16)5) +#define HOST_IF_MSG_CFG_PARAMS ((u16)6) +#define HOST_IF_MSG_SET_CHANNEL ((u16)7) +#define HOST_IF_MSG_DISCONNECT ((u16)8) +#define HOST_IF_MSG_GET_RSSI ((u16)9) +#define HOST_IF_MSG_GET_CHNL ((u16)10) +#define HOST_IF_MSG_ADD_BEACON ((u16)11) +#define HOST_IF_MSG_DEL_BEACON ((u16)12) +#define HOST_IF_MSG_ADD_STATION ((u16)13) +#define HOST_IF_MSG_DEL_STATION ((u16)14) +#define HOST_IF_MSG_EDIT_STATION ((u16)15) +#define HOST_IF_MSG_SCAN_TIMER_FIRED ((u16)16) +#define HOST_IF_MSG_CONNECT_TIMER_FIRED ((u16)17) +#define HOST_IF_MSG_POWER_MGMT ((u16)18) +#define HOST_IF_MSG_GET_INACTIVETIME ((u16)19) +#define HOST_IF_MSG_REMAIN_ON_CHAN ((u16)20) +#define HOST_IF_MSG_REGISTER_FRAME ((u16)21) +#define HOST_IF_MSG_LISTEN_TIMER_FIRED ((u16)22) +#define HOST_IF_MSG_GET_LINKSPEED ((u16)23) +#define HOST_IF_MSG_SET_WFIDRV_HANDLER ((u16)24) +#define HOST_IF_MSG_SET_MAC_ADDRESS ((u16)25) +#define HOST_IF_MSG_GET_MAC_ADDRESS ((u16)26) +#define HOST_IF_MSG_SET_OPERATION_MODE ((u16)27) +#define HOST_IF_MSG_SET_IPADDRESS ((u16)28) +#define HOST_IF_MSG_GET_IPADDRESS ((u16)29) +#define HOST_IF_MSG_FLUSH_CONNECT ((u16)30) +#define HOST_IF_MSG_GET_STATISTICS ((u16)31) +#define HOST_IF_MSG_SET_MULTICAST_FILTER ((u16)32) +#define HOST_IF_MSG_ADD_BA_SESSION ((u16)33) +#define HOST_IF_MSG_DEL_BA_SESSION ((u16)34) +#define HOST_IF_MSG_Q_IDLE ((u16)35) +#define HOST_IF_MSG_DEL_ALL_STA ((u16)36) +#define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS ((u16)34) -#define HOST_IF_MSG_EXIT ((WILC_Uint16)100) +#define HOST_IF_MSG_EXIT ((u16)100) #define HOST_IF_SCAN_TIMEOUT 4000 #define HOST_IF_CONNECT_TIMEOUT 9500 @@ -468,7 +468,7 @@ typedef union _tuniHostIFmsgBody { * @version 1.0 */ typedef struct _tstrHostIFmsg { - WILC_Uint16 u16MsgId; /*!< Message ID */ + u16 u16MsgId; /*!< Message ID */ tuniHostIFmsgBody uniHostIFmsgBody; /*!< Message body */ void *drvHandler; } tstrHostIFmsg; @@ -487,8 +487,8 @@ typedef struct _tstrWidJoinReqExt { typedef struct _tstrJoinBssParam { BSSTYPE_T bss_type; u8 dtim_period; - WILC_Uint16 beacon_period; - WILC_Uint16 cap_info; + u16 beacon_period; + u16 cap_info; u8 au8bssid[6]; WILC_Char ssid[MAX_SSID_LEN]; u8 ssidLen; @@ -615,7 +615,7 @@ static WILC_Sint32 Handle_SetChannel(void *drvHandler, tstrHostIFSetChan *pstrHo tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; /*prepare configuration packet*/ - strWID.u16WIDid = (WILC_Uint16)WID_CURRENT_CHANNEL; + strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = (WILC_Char *)&(pstrHostIFSetChan->u8SetChan); strWID.s32ValueSize = sizeof(WILC_Char); @@ -652,7 +652,7 @@ static WILC_Sint32 Handle_SetWfiDrvHandler(tstrHostIfSetDrvHandler *pstrHostIfSe /*prepare configuration packet*/ - strWID.u16WIDid = (WILC_Uint16)WID_SET_DRV_HANDLER; + strWID.u16WIDid = (u16)WID_SET_DRV_HANDLER; strWID.enuWIDtype = WID_INT; strWID.ps8WidVal = (WILC_Sint8 *)&(pstrHostIfSetDrvHandler->u32Address); strWID.s32ValueSize = sizeof(WILC_Uint32); @@ -697,7 +697,7 @@ static WILC_Sint32 Handle_SetOperationMode(void *drvHandler, tstrHostIfSetOperat /*prepare configuration packet*/ - strWID.u16WIDid = (WILC_Uint16)WID_SET_OPERATION_MODE; + strWID.u16WIDid = (u16)WID_SET_OPERATION_MODE; strWID.enuWIDtype = WID_INT; strWID.ps8WidVal = (WILC_Sint8 *)&(pstrHostIfSetOperationMode->u32Mode); strWID.s32ValueSize = sizeof(WILC_Uint32); @@ -750,7 +750,7 @@ WILC_Sint32 Handle_set_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx) WILC_memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN); /*prepare configuration packet*/ - strWID.u16WIDid = (WILC_Uint16)WID_IP_ADDRESS; + strWID.u16WIDid = (u16)WID_IP_ADDRESS; strWID.enuWIDtype = WID_STR; strWID.ps8WidVal = (u8 *)pu8IPAddr; strWID.s32ValueSize = IP_ALEN; @@ -794,7 +794,7 @@ WILC_Sint32 Handle_get_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx) tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; /*prepare configuration packet*/ - strWID.u16WIDid = (WILC_Uint16)WID_IP_ADDRESS; + strWID.u16WIDid = (u16)WID_IP_ADDRESS; strWID.enuWIDtype = WID_STR; strWID.ps8WidVal = (u8 *)WILC_MALLOC(IP_ALEN); strWID.s32ValueSize = IP_ALEN; @@ -853,7 +853,7 @@ static WILC_Sint32 Handle_SetMacAddress(void *drvHandler, tstrHostIfSetMacAddres WILC_memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN); /*prepare configuration packet*/ - strWID.u16WIDid = (WILC_Uint16)WID_MAC_ADDR; + strWID.u16WIDid = (u16)WID_MAC_ADDR; strWID.enuWIDtype = WID_STR; strWID.ps8WidVal = mac_buf; strWID.s32ValueSize = ETH_ALEN; @@ -891,7 +891,7 @@ static WILC_Sint32 Handle_GetMacAddress(void *drvHandler, tstrHostIfGetMacAddres tstrWID strWID; /*prepare configuration packet*/ - strWID.u16WIDid = (WILC_Uint16)WID_MAC_ADDR; + strWID.u16WIDid = (u16)WID_MAC_ADDR; strWID.enuWIDtype = WID_STR; strWID.ps8WidVal = pstrHostIfGetMacAddress->u8MacAddress; strWID.s32ValueSize = ETH_ALEN; @@ -976,7 +976,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TIMEOUT; strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout; strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; - strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16); + strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); pstrWFIDrv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); @@ -1008,7 +1008,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str strWIDList[u8WidCnt].u16WIDid = WID_SHORT_RETRY_LIMIT; strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit; strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; - strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16); + strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); pstrWFIDrv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); @@ -1022,7 +1022,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit; strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; - strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16); + strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); pstrWFIDrv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); @@ -1035,7 +1035,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str strWIDList[u8WidCnt].u16WIDid = WID_FRAG_THRESHOLD; strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold; strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; - strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16); + strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); pstrWFIDrv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); @@ -1048,7 +1048,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str strWIDList[u8WidCnt].u16WIDid = WID_RTS_THRESHOLD; strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold; strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; - strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16); + strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); pstrWFIDrv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); @@ -1106,7 +1106,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str strWIDList[u8WidCnt].u16WIDid = WID_BEACON_INTERVAL; strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval; strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; - strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16); + strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); pstrWFIDrv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); @@ -1149,7 +1149,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY_SCAN_TIME; strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time; strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; - strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16); + strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); pstrWFIDrv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); @@ -1162,7 +1162,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str strWIDList[u8WidCnt].u16WIDid = WID_ACTIVE_SCAN_TIME; strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time; strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; - strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16); + strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); pstrWFIDrv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); @@ -1175,7 +1175,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str strWIDList[u8WidCnt].u16WIDid = WID_PASSIVE_SCAN_TIME; strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time; strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; - strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16); + strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); pstrWFIDrv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); @@ -1198,7 +1198,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str strWIDList[u8WidCnt].u16WIDid = WID_CURRENT_TX_RATE; strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&curr_tx_rate; strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; - strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16); + strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); pstrWFIDrv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); @@ -1291,7 +1291,7 @@ static WILC_Sint32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFs pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount = 0; /*BugID_4189*/ - strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_SSID_PROBE_REQ; + strWIDList[u32WidsCount].u16WIDid = (u16)WID_SSID_PROBE_REQ; strWIDList[u32WidsCount].enuWIDtype = WID_STR; for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) { @@ -1444,7 +1444,7 @@ static WILC_Sint32 Handle_ScanDone(void *drvHandler, tenuScanEvent enuEvent) if (enuEvent == SCAN_EVENT_ABORTED) { PRINT_D(GENERIC_DBG, "Abort running scan\n"); u8abort_running_scan = 1; - strWID.u16WIDid = (WILC_Uint16)WID_ABORT_RUNNING_SCAN; + strWID.u16WIDid = (u16)WID_ABORT_RUNNING_SCAN; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = (WILC_Sint8 *)&u8abort_running_scan; strWID.s32ValueSize = sizeof(WILC_Char); @@ -1611,7 +1611,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen; u32WidsCount++; } - strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_11I_MODE; + strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security)); @@ -1619,7 +1619,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security); - strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_AUTH_TYPE; + strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type); @@ -1627,14 +1627,14 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type); /* - * strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_11I_PSK; + * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK; * strWIDList[u32WidsCount].enuWIDtype = WID_STR; * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase); * strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8*)(passphrase); * u32WidsCount++; */ - strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_JOIN_REQ; + strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)&u8bssDscListIndex; @@ -1757,7 +1757,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH gu32FlushedInfoElemAsocSize); } } - strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_11I_MODE; + strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security)); @@ -1770,7 +1770,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security); - strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_AUTH_TYPE; + strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type); @@ -1782,7 +1782,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type); /* - * strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_11I_PSK; + * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK; * strWIDList[u32WidsCount].enuWIDtype = WID_STR; * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase); * strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8*)(passphrase); @@ -1794,7 +1794,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH #ifndef WILC_PARSE_SCAN_IN_HOST - strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_JOIN_REQ_EXTENDED; + strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED; strWIDList[u32WidsCount].enuWIDtype = WID_STR; strWIDList[u32WidsCount].s32ValueSize = MAX_SSID_LEN + 7; strWIDList[u32WidsCount].ps8WidVal = WILC_MALLOC(strWIDList[u32WidsCount].s32ValueSize); @@ -1826,7 +1826,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH #else - strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_JOIN_REQ_EXTENDED; + strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED; strWIDList[u32WidsCount].enuWIDtype = WID_STR; /*Sending NoA attributes during connection*/ @@ -2092,7 +2092,7 @@ static WILC_Sint32 Handle_FlushConnect(void *drvHandler) strWIDList[u32WidsCount].s32ValueSize = gu32FlushedInfoElemAsocSize; u32WidsCount++; - strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_11I_MODE; + strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(gu8Flushed11iMode)); @@ -2100,7 +2100,7 @@ static WILC_Sint32 Handle_FlushConnect(void *drvHandler) - strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_AUTH_TYPE; + strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&gu8FlushedAuthType); @@ -2108,7 +2108,7 @@ static WILC_Sint32 Handle_FlushConnect(void *drvHandler) #ifdef WILC_PARSE_SCAN_IN_HOST - strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_JOIN_REQ_EXTENDED; + strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED; strWIDList[u32WidsCount].enuWIDtype = WID_STR; strWIDList[u32WidsCount].s32ValueSize = gu32FlushedJoinReqSize; strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)gu8FlushedJoinReq; @@ -2149,7 +2149,7 @@ static WILC_Sint32 Handle_ConnectTimeout(void *drvHandler) WILC_Sint32 s32Error = WILC_SUCCESS; tstrConnectInfo strConnectInfo; tstrWID strWID; - WILC_Uint16 u16DummyReasonCode = 0; + u16 u16DummyReasonCode = 0; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler; if (pstrWFIDrv == NULL) { @@ -2199,7 +2199,7 @@ static WILC_Sint32 Handle_ConnectTimeout(void *drvHandler) /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying * WID_DISCONNECT} */ - strWID.u16WIDid = (WILC_Uint16)WID_DISCONNECT; + strWID.u16WIDid = (u16)WID_DISCONNECT; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = (WILC_Sint8 *)&u16DummyReasonCode; strWID.s32ValueSize = sizeof(WILC_Char); @@ -2382,8 +2382,8 @@ static WILC_Sint32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncI WILC_Sint32 s32Error = WILC_SUCCESS; u8 u8MsgType = 0; u8 u8MsgID = 0; - WILC_Uint16 u16MsgLen = 0; - WILC_Uint16 u16WidID = (WILC_Uint16)WID_NIL; + u16 u16MsgLen = 0; + u16 u16WidID = (u16)WID_NIL; u8 u8WidLen = 0; u8 u8MacStatus; u8 u8MacStatusReasonCode; @@ -2730,7 +2730,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) PRINT_D(HOSTINF_DBG, "Handling WEP key\n"); PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx)); - strWIDList[0].u16WIDid = (WILC_Uint16)WID_11I_MODE; + strWIDList[0].u16WIDid = (u16)WID_11I_MODE; strWIDList[0].enuWIDtype = WID_CHAR; strWIDList[0].s32ValueSize = sizeof(WILC_Char); strWIDList[0].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode)); @@ -2740,7 +2740,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) strWIDList[1].s32ValueSize = sizeof(WILC_Char); strWIDList[1].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type)); - strWIDList[2].u16WIDid = (WILC_Uint16)WID_KEY_ID; + strWIDList[2].u16WIDid = (u16)WID_KEY_ID; strWIDList[2].enuWIDtype = WID_CHAR; strWIDList[2].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx)); @@ -2761,7 +2761,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey); - strWIDList[3].u16WIDid = (WILC_Uint16)WID_WEP_KEY_VALUE; + strWIDList[3].u16WIDid = (u16)WID_WEP_KEY_VALUE; strWIDList[3].enuWIDtype = WID_STR; strWIDList[3].s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen; strWIDList[3].ps8WidVal = (WILC_Sint8 *)pu8keybuf; @@ -2790,7 +2790,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey); - strWID.u16WIDid = (WILC_Uint16)WID_ADD_WEP_KEY; + strWID.u16WIDid = (u16)WID_ADD_WEP_KEY; strWID.enuWIDtype = WID_STR; strWID.ps8WidVal = (WILC_Sint8 *)pu8keybuf; strWID.s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2; @@ -2800,7 +2800,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY) { PRINT_D(HOSTINF_DBG, "Removing key\n"); - strWID.u16WIDid = (WILC_Uint16)WID_REMOVE_WEP_KEY; + strWID.u16WIDid = (u16)WID_REMOVE_WEP_KEY; strWID.enuWIDtype = WID_STR; s8idxarray[0] = (WILC_Sint8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx; @@ -2809,7 +2809,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); } else { - strWID.u16WIDid = (WILC_Uint16)WID_KEY_ID; + strWID.u16WIDid = (u16)WID_KEY_ID; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx)); strWID.s32ValueSize = sizeof(WILC_Char); @@ -2852,12 +2852,12 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) WILC_memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen); /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */ - strWIDList[0].u16WIDid = (WILC_Uint16)WID_11I_MODE; + strWIDList[0].u16WIDid = (u16)WID_11I_MODE; strWIDList[0].enuWIDtype = WID_CHAR; strWIDList[0].s32ValueSize = sizeof(WILC_Char); strWIDList[0].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode)); - strWIDList[1].u16WIDid = (WILC_Uint16)WID_ADD_RX_GTK; + strWIDList[1].u16WIDid = (u16)WID_ADD_RX_GTK; strWIDList[1].enuWIDtype = WID_STR; strWIDList[1].ps8WidVal = (WILC_Sint8 *)pu8keybuf; strWIDList[1].s32ValueSize = RX_MIC_KEY_MSG_LEN; @@ -2904,7 +2904,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) WILC_memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen); - strWID.u16WIDid = (WILC_Uint16)WID_ADD_RX_GTK; + strWID.u16WIDid = (u16)WID_ADD_RX_GTK; strWID.enuWIDtype = WID_STR; strWID.ps8WidVal = (WILC_Sint8 *)pu8keybuf; strWID.s32ValueSize = RX_MIC_KEY_MSG_LEN; @@ -2956,12 +2956,12 @@ _WPARxGtk_end_case_: pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen); - strWIDList[0].u16WIDid = (WILC_Uint16)WID_11I_MODE; + strWIDList[0].u16WIDid = (u16)WID_11I_MODE; strWIDList[0].enuWIDtype = WID_CHAR; strWIDList[0].s32ValueSize = sizeof(WILC_Char); strWIDList[0].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode)); - strWIDList[1].u16WIDid = (WILC_Uint16)WID_ADD_PTK; + strWIDList[1].u16WIDid = (u16)WID_ADD_PTK; strWIDList[1].enuWIDtype = WID_STR; strWIDList[1].ps8WidVal = (WILC_Sint8 *)pu8keybuf; strWIDList[1].s32ValueSize = PTK_KEY_MSG_LEN + 1; @@ -3002,7 +3002,7 @@ _WPARxGtk_end_case_: pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen); - strWID.u16WIDid = (WILC_Uint16)WID_ADD_PTK; + strWID.u16WIDid = (u16)WID_ADD_PTK; strWID.enuWIDtype = WID_STR; strWID.ps8WidVal = (WILC_Sint8 *)pu8keybuf; strWID.s32ValueSize = PTK_KEY_MSG_LEN; @@ -3041,7 +3041,7 @@ _WPAPtk_end_case_: WILC_memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, PMKID_LEN); } - strWID.u16WIDid = (WILC_Uint16)WID_PMKID_INFO; + strWID.u16WIDid = (u16)WID_PMKID_INFO; strWID.enuWIDtype = WID_STR; strWID.ps8WidVal = (WILC_Sint8 *)pu8keybuf; strWID.s32ValueSize = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1; @@ -3074,11 +3074,11 @@ static void Handle_Disconnect(void *drvHandler) tstrWID strWID; WILC_Sint32 s32Error = WILC_SUCCESS; - WILC_Uint16 u16DummyReasonCode = 0; + u16 u16DummyReasonCode = 0; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; - strWID.u16WIDid = (WILC_Uint16)WID_DISCONNECT; + strWID.u16WIDid = (u16)WID_DISCONNECT; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = (WILC_Sint8 *)&u16DummyReasonCode; strWID.s32ValueSize = sizeof(WILC_Char); @@ -3203,7 +3203,7 @@ static WILC_Sint32 Switch_Log_Terminal(void *drvHandler) static char dummy = 9; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; - strWID.u16WIDid = (WILC_Uint16)WID_LOGTerminal_Switch; + strWID.u16WIDid = (u16)WID_LOGTerminal_Switch; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = &dummy; strWID.s32ValueSize = sizeof(WILC_Char); @@ -3245,7 +3245,7 @@ static WILC_Sint32 Handle_GetChnl(void *drvHandler) tstrWID strWID; /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; - strWID.u16WIDid = (WILC_Uint16)WID_CURRENT_CHANNEL; + strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = (WILC_Sint8 *)&gu8Chnl; strWID.s32ValueSize = sizeof(WILC_Char); @@ -3288,7 +3288,7 @@ static void Handle_GetRssi(void *drvHandler) tstrWID strWID; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; - strWID.u16WIDid = (WILC_Uint16)WID_RSSI; + strWID.u16WIDid = (u16)WID_RSSI; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = &gs8Rssi; strWID.s32ValueSize = sizeof(WILC_Char); @@ -3320,7 +3320,7 @@ static void Handle_GetLinkspeed(void *drvHandler) gs8lnkspd = 0; - strWID.u16WIDid = (WILC_Uint16)WID_LINKSPEED; + strWID.u16WIDid = (u16)WID_LINKSPEED; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = &gs8lnkspd; strWID.s32ValueSize = sizeof(WILC_Char); @@ -3412,7 +3412,7 @@ static WILC_Sint32 Handle_Get_InActiveTime(void *drvHandler, tstrHostIfStaInacti tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; - strWID.u16WIDid = (WILC_Uint16)WID_SET_STA_MAC_INACTIVE_TIME; + strWID.u16WIDid = (u16)WID_SET_STA_MAC_INACTIVE_TIME; strWID.enuWIDtype = WID_STR; strWID.s32ValueSize = ETH_ALEN; strWID.ps8WidVal = (u8 *)WILC_MALLOC(strWID.s32ValueSize); @@ -3433,7 +3433,7 @@ static WILC_Sint32 Handle_Get_InActiveTime(void *drvHandler, tstrHostIfStaInacti } - strWID.u16WIDid = (WILC_Uint16)WID_GET_INACTIVE_TIME; + strWID.u16WIDid = (u16)WID_GET_INACTIVE_TIME; strWID.enuWIDtype = WID_INT; strWID.ps8WidVal = (WILC_Sint8 *)&gu32InactiveTime; strWID.s32ValueSize = sizeof(WILC_Uint32); @@ -3480,7 +3480,7 @@ static void Handle_AddBeacon(void *drvHandler, tstrHostIFSetBeacon *pstrSetBeaco tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; PRINT_D(HOSTINF_DBG, "Adding BEACON\n"); - strWID.u16WIDid = (WILC_Uint16)WID_ADD_BEACON; + strWID.u16WIDid = (u16)WID_ADD_BEACON; strWID.enuWIDtype = WID_BIN; strWID.s32ValueSize = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16; strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize); @@ -3550,7 +3550,7 @@ static void Handle_DelBeacon(void *drvHandler, tstrHostIFDelBeacon *pstrDelBeaco tstrWID strWID; u8 *pu8CurrByte; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; - strWID.u16WIDid = (WILC_Uint16)WID_DEL_BEACON; + strWID.u16WIDid = (u16)WID_DEL_BEACON; strWID.enuWIDtype = WID_CHAR; strWID.s32ValueSize = sizeof(WILC_Char); strWID.ps8WidVal = &gu8DelBcn; @@ -3649,7 +3649,7 @@ static void Handle_AddStation(void *drvHandler, tstrWILC_AddStaParam *pstrStatio u8 *pu8CurrByte; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; PRINT_D(HOSTINF_DBG, "Handling add station\n"); - strWID.u16WIDid = (WILC_Uint16)WID_ADD_STA; + strWID.u16WIDid = (u16)WID_ADD_STA; strWID.enuWIDtype = WID_BIN; strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates; @@ -3693,7 +3693,7 @@ static void Handle_DelAllSta(void *drvHandler, tstrHostIFDelAllSta *pstrDelAllSt tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; u8 i; u8 au8Zero_Buff[6] = {0}; - strWID.u16WIDid = (WILC_Uint16)WID_DEL_ALL_STA; + strWID.u16WIDid = (u16)WID_DEL_ALL_STA; strWID.enuWIDtype = WID_STR; strWID.s32ValueSize = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1; @@ -3750,7 +3750,7 @@ static void Handle_DelStation(void *drvHandler, tstrHostIFDelSta *pstrDelStaPara u8 *pu8CurrByte; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; - strWID.u16WIDid = (WILC_Uint16)WID_REMOVE_STA; + strWID.u16WIDid = (u16)WID_REMOVE_STA; strWID.enuWIDtype = WID_BIN; strWID.s32ValueSize = ETH_ALEN; @@ -3796,7 +3796,7 @@ static void Handle_EditStation(void *drvHandler, tstrWILC_AddStaParam *pstrStati u8 *pu8CurrByte; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; - strWID.u16WIDid = (WILC_Uint16)WID_EDIT_STA; + strWID.u16WIDid = (u16)WID_EDIT_STA; strWID.enuWIDtype = WID_BIN; strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates; @@ -3874,7 +3874,7 @@ static int Handle_RemainOnChan(void *drvHandler, tstrHostIfRemainOnChan *pstrHos PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel); u8remain_on_chan_flag = WILC_TRUE; - strWID.u16WIDid = (WILC_Uint16)WID_REMAIN_ON_CHAN; + strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN; strWID.enuWIDtype = WID_STR; strWID.s32ValueSize = 2; strWID.ps8WidVal = (WILC_Sint8 *)WILC_MALLOC(strWID.s32ValueSize); @@ -3927,9 +3927,9 @@ static int Handle_RegisterFrame(void *drvHandler, tstrHostIfRegisterFrame *pstrH PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType); /*prepare configuration packet*/ - strWID.u16WIDid = (WILC_Uint16)WID_REGISTER_FRAME; + strWID.u16WIDid = (u16)WID_REGISTER_FRAME; strWID.enuWIDtype = WID_STR; - strWID.ps8WidVal = WILC_MALLOC(sizeof(WILC_Uint16) + 2); + strWID.ps8WidVal = WILC_MALLOC(sizeof(u16) + 2); if (strWID.ps8WidVal == NULL) { WILC_ERRORREPORT(s32Error, WILC_NO_MEM); } @@ -3938,10 +3938,10 @@ static int Handle_RegisterFrame(void *drvHandler, tstrHostIfRegisterFrame *pstrH *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg; *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid; - WILC_memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(WILC_Uint16)); + WILC_memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16)); - strWID.s32ValueSize = sizeof(WILC_Uint16) + 2; + strWID.s32ValueSize = sizeof(u16) + 2; /*Sending Cfg*/ @@ -3984,7 +3984,7 @@ static WILC_Uint32 Handle_ListenStateExpired(void *drvHandler, tstrHostIfRemainO /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/ if (P2P_LISTEN_STATE) { u8remain_on_chan_flag = WILC_FALSE; - strWID.u16WIDid = (WILC_Uint16)WID_REMAIN_ON_CHAN; + strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN; strWID.enuWIDtype = WID_STR; strWID.s32ValueSize = 2; strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize); @@ -4069,7 +4069,7 @@ static void Handle_PowerManagement(void *drvHandler, tstrHostIfPowerMgmtParam *s tstrWID strWID; WILC_Sint8 s8PowerMode; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; - strWID.u16WIDid = (WILC_Uint16)WID_POWER_MANAGEMENT; + strWID.u16WIDid = (u16)WID_POWER_MANAGEMENT; if (strPowerMgmtParam->bIsEnabled == WILC_TRUE) { s8PowerMode = MIN_FAST_PS; @@ -4112,7 +4112,7 @@ static void Handle_SetMulticastFilter(void *drvHandler, tstrHostIFSetMulti *strH PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n"); - strWID.u16WIDid = (WILC_Uint16)WID_SETUP_MULTICAST_FILTER; + strWID.u16WIDid = (u16)WID_SETUP_MULTICAST_FILTER; strWID.enuWIDtype = WID_BIN; strWID.s32ValueSize = sizeof(tstrHostIFSetMulti) + ((strHostIfSetMulti->u32count) * ETH_ALEN); strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize); @@ -4175,7 +4175,7 @@ static WILC_Sint32 Handle_AddBASession(void *drvHandler, tstrHostIfBASessionInfo strHostIfBASessionInfo->u16SessionTimeout, strHostIfBASessionInfo->u8Ted); - strWID.u16WIDid = (WILC_Uint16)WID_11E_P_ACTION_REQ; + strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ; strWID.enuWIDtype = WID_STR; strWID.ps8WidVal = (u8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE); strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE; @@ -4208,7 +4208,7 @@ static WILC_Sint32 Handle_AddBASession(void *drvHandler, tstrHostIfBASessionInfo PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n"); - strWID.u16WIDid = (WILC_Uint16)WID_11E_P_ACTION_REQ; + strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ; strWID.enuWIDtype = WID_STR; strWID.s32ValueSize = 15; ptr = strWID.ps8WidVal; @@ -4260,7 +4260,7 @@ static WILC_Sint32 Handle_DelBASession(void *drvHandler, tstrHostIfBASessionInfo strHostIfBASessionInfo->au8Bssid[2], strHostIfBASessionInfo->u8Ted); - strWID.u16WIDid = (WILC_Uint16)WID_11E_P_ACTION_REQ; + strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ; strWID.enuWIDtype = WID_STR; strWID.ps8WidVal = (u8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE); strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE; @@ -4282,7 +4282,7 @@ static WILC_Sint32 Handle_DelBASession(void *drvHandler, tstrHostIfBASessionInfo PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n"); - strWID.u16WIDid = (WILC_Uint16)WID_11E_P_ACTION_REQ; + strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ; strWID.enuWIDtype = WID_STR; strWID.s32ValueSize = 15; ptr = strWID.ps8WidVal; @@ -4330,7 +4330,7 @@ static WILC_Sint32 Handle_DelAllRxBASessions(void *drvHandler, tstrHostIfBASessi strHostIfBASessionInfo->au8Bssid[2], strHostIfBASessionInfo->u8Ted); - strWID.u16WIDid = (WILC_Uint16)WID_DEL_ALL_RX_BA; + strWID.u16WIDid = (u16)WID_DEL_ALL_RX_BA; strWID.enuWIDtype = WID_STR; strWID.ps8WidVal = (u8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE); strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE; @@ -4640,7 +4640,7 @@ WILC_Sint32 host_int_remove_key(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8StaAddre tstrWID strWID; /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ - strWID.u16WIDid = (WILC_Uint16)WID_REMOVE_KEY; + strWID.u16WIDid = (u16)WID_REMOVE_KEY; strWID.enuWIDtype = WID_STR; strWID.ps8WidVal = (WILC_Sint8 *)pu8StaAddress; strWID.s32ValueSize = 6; @@ -5252,7 +5252,7 @@ WILC_Sint32 host_int_get_pmkid_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PmkidInfoA tstrWID strWID; /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ - strWID.u16WIDid = (WILC_Uint16)WID_PMKID_INFO; + strWID.u16WIDid = (u16)WID_PMKID_INFO; strWID.enuWIDtype = WID_STR; strWID.s32ValueSize = u32PmkidInfoLen; strWID.ps8WidVal = pu8PmkidInfoArray; @@ -5284,7 +5284,7 @@ WILC_Sint32 host_int_set_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, u8 * /* u8 u8Psklength = WILC_strlen(pu8PassPhrase); */ /*validating psk length*/ if ((u8Psklength > 7) && (u8Psklength < 65)) { - strWID.u16WIDid = (WILC_Uint16)WID_11I_PSK; + strWID.u16WIDid = (u16)WID_11I_PSK; strWID.enuWIDtype = WID_STR; strWID.ps8WidVal = pu8PassPhrase; strWID.s32ValueSize = u8Psklength; @@ -5385,7 +5385,7 @@ WILC_Sint32 host_int_get_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, tstrWID strWID; /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ - strWID.u16WIDid = (WILC_Uint16)WID_11I_PSK; + strWID.u16WIDid = (u16)WID_11I_PSK; strWID.enuWIDtype = WID_STR; strWID.s32ValueSize = u8Psklength; strWID.ps8WidVal = pu8PassPhrase; @@ -5433,12 +5433,12 @@ WILC_Sint32 host_int_get_site_survey_results(WILC_WFIDrvHandle hWFIDrv, tstrWID astrWIDList[2]; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; - astrWIDList[0].u16WIDid = (WILC_Uint16)WID_SITE_SURVEY_RESULTS; + astrWIDList[0].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS; astrWIDList[0].enuWIDtype = WID_STR; astrWIDList[0].ps8WidVal = ppu8RcvdSiteSurveyResults[0]; astrWIDList[0].s32ValueSize = u32MaxSiteSrvyFragLen; - astrWIDList[1].u16WIDid = (WILC_Uint16)WID_SITE_SURVEY_RESULTS; + astrWIDList[1].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS; astrWIDList[1].enuWIDtype = WID_STR; astrWIDList[1].ps8WidVal = ppu8RcvdSiteSurveyResults[1]; astrWIDList[1].s32ValueSize = u32MaxSiteSrvyFragLen; @@ -5481,7 +5481,7 @@ WILC_Sint32 host_int_set_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 scanSource tstrWID strWID; /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ - strWID.u16WIDid = (WILC_Uint16)WID_START_SCAN_REQ; + strWID.u16WIDid = (u16)WID_START_SCAN_REQ; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = (WILC_Sint8 *)&scanSource; strWID.s32ValueSize = sizeof(WILC_Char); @@ -5511,7 +5511,7 @@ WILC_Sint32 host_int_get_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ScanSo tstrWID strWID; /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ - strWID.u16WIDid = (WILC_Uint16)WID_START_SCAN_REQ; + strWID.u16WIDid = (u16)WID_START_SCAN_REQ; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = (WILC_Sint8 *)pu8ScanSource; strWID.s32ValueSize = sizeof(WILC_Char); @@ -5676,7 +5676,7 @@ WILC_Sint32 host_int_flush_join_req(WILC_WFIDrvHandle hWFIDrv) * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_disconnect(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16ReasonCode) +WILC_Sint32 host_int_disconnect(WILC_WFIDrvHandle hWFIDrv, u16 u16ReasonCode) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; @@ -5731,7 +5731,7 @@ WILC_Sint32 host_int_disconnect_station(WILC_WFIDrvHandle hWFIDrv, u8 assoc_id) tstrWID strWID; /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ - strWID.u16WIDid = (WILC_Uint16)WID_DISCONNECT; + strWID.u16WIDid = (u16)WID_DISCONNECT; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = (WILC_Sint8 *)&assoc_id; strWID.s32ValueSize = sizeof(WILC_Char); @@ -5772,7 +5772,7 @@ WILC_Sint32 host_int_get_assoc_req_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocR tstrWID strWID; /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ - strWID.u16WIDid = (WILC_Uint16)WID_ASSOC_REQ_INFO; + strWID.u16WIDid = (u16)WID_ASSOC_REQ_INFO; strWID.enuWIDtype = WID_STR; strWID.ps8WidVal = pu8AssocReqInfo; strWID.s32ValueSize = u32AssocReqInfoLen; @@ -5804,7 +5804,7 @@ WILC_Sint32 host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocR WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } - strWID.u16WIDid = (WILC_Uint16)WID_ASSOC_RES_INFO; + strWID.u16WIDid = (u16)WID_ASSOC_RES_INFO; strWID.enuWIDtype = WID_STR; strWID.ps8WidVal = pu8AssocRespInfo; strWID.s32ValueSize = u32MaxAssocRespInfoLen; @@ -5849,7 +5849,7 @@ WILC_Sint32 host_int_get_rx_power_level(WILC_WFIDrvHandle hWFIDrv, u8 *pu8RxPowe tstrWID strWID; /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ - strWID.u16WIDid = (WILC_Uint16)WID_RX_POWER_LEVEL; + strWID.u16WIDid = (u16)WID_RX_POWER_LEVEL; strWID.enuWIDtype = WID_STR; strWID.ps8WidVal = pu8RxPowerLevel; strWID.s32ValueSize = u32RxPowerLevelLen; @@ -6056,7 +6056,7 @@ WILC_Sint32 host_int_test_set_int_wid(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32 } /*prepare configuration packet*/ - strWID.u16WIDid = (WILC_Uint16)WID_MEMORY_ADDRESS; + strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS; strWID.enuWIDtype = WID_INT; strWID.ps8WidVal = (WILC_Char *)&u32TestMemAddr; strWID.s32ValueSize = sizeof(WILC_Uint32); @@ -6149,7 +6149,7 @@ WILC_Sint32 host_int_test_get_int_wid(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 *pu WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } - strWID.u16WIDid = (WILC_Uint16)WID_MEMORY_ADDRESS; + strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS; strWID.enuWIDtype = WID_INT; strWID.ps8WidVal = (WILC_Sint8 *)pu32TestMemAddr; strWID.s32ValueSize = sizeof(WILC_Uint32); @@ -6413,7 +6413,7 @@ WILC_Sint32 hif_set_cfg(WILC_WFIDrvHandle hWFIDrv, tstrCfgParamVal *pstrCfgParam * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16WID, WILC_Uint16 *pu16WID_Value) +WILC_Sint32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, u16 u16WID, u16 *pu16WID_Value) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -6428,11 +6428,11 @@ WILC_Sint32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16WID, WILC_Uint switch (u16WID) { case WID_BSS_TYPE: - *pu16WID_Value = (WILC_Uint16)pstrWFIDrv->strCfgValues.bss_type; + *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.bss_type; break; case WID_AUTH_TYPE: - *pu16WID_Value = (WILC_Uint16)pstrWFIDrv->strCfgValues.auth_type; + *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.auth_type; break; case WID_AUTH_TIMEOUT: @@ -6440,7 +6440,7 @@ WILC_Sint32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16WID, WILC_Uint break; case WID_POWER_MANAGEMENT: - *pu16WID_Value = (WILC_Uint16)pstrWFIDrv->strCfgValues.power_mgmt_mode; + *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.power_mgmt_mode; break; case WID_SHORT_RETRY_LIMIT: @@ -6460,15 +6460,15 @@ WILC_Sint32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16WID, WILC_Uint break; case WID_PREAMBLE: - *pu16WID_Value = (WILC_Uint16)pstrWFIDrv->strCfgValues.preamble_type; + *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.preamble_type; break; case WID_SHORT_SLOT_ALLOWED: - *pu16WID_Value = (WILC_Uint16) pstrWFIDrv->strCfgValues.short_slot_allowed; + *pu16WID_Value = (u16) pstrWFIDrv->strCfgValues.short_slot_allowed; break; case WID_11N_TXOP_PROT_DISABLE: - *pu16WID_Value = (WILC_Uint16)pstrWFIDrv->strCfgValues.txop_prot_disabled; + *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.txop_prot_disabled; break; case WID_BEACON_INTERVAL: @@ -6476,11 +6476,11 @@ WILC_Sint32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16WID, WILC_Uint break; case WID_DTIM_PERIOD: - *pu16WID_Value = (WILC_Uint16)pstrWFIDrv->strCfgValues.dtim_period; + *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.dtim_period; break; case WID_SITE_SURVEY: - *pu16WID_Value = (WILC_Uint16)pstrWFIDrv->strCfgValues.site_survey_enabled; + *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.site_survey_enabled; break; case WID_SITE_SURVEY_SCAN_TIME: @@ -6531,7 +6531,7 @@ WILC_Sint32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16WID, WILC_Uint * @version 1.0 */ void host_int_send_join_leave_info_to_host - (WILC_Uint16 assocId, u8 *stationAddr, WILC_Bool joining) + (u16 assocId, u8 *stationAddr, WILC_Bool joining) { } /** @@ -6578,7 +6578,7 @@ void GetPeriodicRSSI(void *pvArg) void host_int_send_network_info_to_host - (u8 *macStartAddress, WILC_Uint16 u16RxFrameLen, WILC_Sint8 s8Rssi) + (u8 *macStartAddress, u16 u16RxFrameLen, WILC_Sint8 s8Rssi) { } /** @@ -7087,7 +7087,7 @@ void host_int_ScanCompleteReceived(u8 *pu8Buffer, WILC_Uint32 u32Length) * @date * @version 1.0 */ -WILC_Sint32 host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32SessionID, WILC_Uint32 u32duration, WILC_Uint16 chan, tWILCpfRemainOnChanExpired RemainOnChanExpired, tWILCpfRemainOnChanReady RemainOnChanReady, void *pvUserArg) +WILC_Sint32 host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32SessionID, WILC_Uint32 u32duration, u16 chan, tWILCpfRemainOnChanExpired RemainOnChanExpired, tWILCpfRemainOnChanReady RemainOnChanReady, void *pvUserArg) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -7174,7 +7174,7 @@ WILC_Sint32 host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u * @author * @date * @version 1.0*/ -WILC_Sint32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16FrameType, WILC_Bool bReg) +WILC_Sint32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, u16 u16FrameType, WILC_Bool bReg) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -7631,11 +7631,11 @@ static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo) { tstrJoinBssParam *pNewJoinBssParam = NULL; u8 *pu8IEs; - WILC_Uint16 u16IEsLen; - WILC_Uint16 index = 0; + u16 u16IEsLen; + u16 index = 0; u8 suppRatesNo = 0; u8 extSuppRatesNo; - WILC_Uint16 jumpOffset; + u16 jumpOffset; u8 pcipherCount; u8 authCount; u8 pcipherTotalCount = 0; @@ -7723,7 +7723,7 @@ static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo) (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) && (pu8IEs[index + 4] == 0x9a) && /* OUI */ (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type */ - WILC_Uint16 u16P2P_count; + u16 u16P2P_count; pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf; pNewJoinBssParam->u8NoaEnbaled = 1; pNewJoinBssParam->u8Index = pu8IEs[index + 9]; @@ -7759,7 +7759,7 @@ static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo) ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) && (pu8IEs[index + 5] == 0x01))) { - WILC_Uint16 rsnIndex = index; + u16 rsnIndex = index; /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]); * for(i=0; i*/ - WILC_Uint16 u16FlagsSet; /**/ + u16 u16FlagsSet; /*buff; /* len of the original frame without the added pointer at the tail */ - WILC_Uint16 u16len = (pv_data->size) - sizeof(struct tx_complete_mon_data *); + u16 u16len = (pv_data->size) - sizeof(struct tx_complete_mon_data *); /*if(bStatus == 1){ diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index e92ba59382ef..70df3a1e7546 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -67,7 +67,7 @@ unsigned char mac_add[] = {0x00, 0x80, 0xC2, 0x5E, 0xa2, 0xb2}; #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP extern WILC_Bool g_obtainingIP; #endif -extern WILC_Uint16 Set_machw_change_vir_if(WILC_Bool bValue); +extern u16 Set_machw_change_vir_if(WILC_Bool bValue); extern void resolve_disconnect_aberration(void *drvHandler); extern u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN]; void wilc1000_wlan_deinit(linux_wlan_t *nic); diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index 4b4cfa202043..2e873b6942b6 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -14,7 +14,6 @@ #define WILC_OSW_INTERFACE_VER 2 /* Integer Types */ -typedef unsigned short WILC_Uint16; typedef unsigned int WILC_Uint32; typedef unsigned long long WILC_Uint64; typedef signed char WILC_Sint8; diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 5844eba90b91..a2047e3b6050 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -25,7 +25,7 @@ extern void linux_wlan_free(void *vp); extern int linux_wlan_get_firmware(perInterface_wlan_t *p_nic); extern void linux_wlan_unlock(void *vp); -extern WILC_Uint16 Set_machw_change_vir_if(WILC_Bool bValue); +extern u16 Set_machw_change_vir_if(WILC_Bool bValue); extern int mac_open(struct net_device *ndev); extern int mac_close(struct net_device *ndev); @@ -574,7 +574,7 @@ static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent, if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) { /*Initialization*/ - WILC_Uint16 u16ConnectStatus = WLAN_STATUS_SUCCESS; + u16 u16ConnectStatus = WLAN_STATUS_SUCCESS; u16ConnectStatus = pstrConnectInfo->u16ConnectStatus; @@ -2549,7 +2549,7 @@ int WILC_WFI_mgmt_tx(struct wiphy *wiphy, /*Save the current channel after we tune to it*/ u8CurrChannel = chan->hw_value; } else if (ieee80211_is_action(mgmt->frame_control)) { - PRINT_D(GENERIC_DBG, "ACTION FRAME:%x\n", (WILC_Uint16)mgmt->frame_control); + PRINT_D(GENERIC_DBG, "ACTION FRAME:%x\n", (u16)mgmt->frame_control); /*BugID_4847*/ @@ -2845,7 +2845,7 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev struct WILC_WFI_priv *priv; perInterface_wlan_t *nic; u8 interface_type; - WILC_Uint16 TID = 0; + u16 TID = 0; #ifdef WILC_P2P u8 i; #endif diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index b322f0f956ea..d07216a237a0 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -175,7 +175,7 @@ struct WILC_WFI_priv { }; typedef struct { - WILC_Uint16 frame_type; + u16 frame_type; WILC_Bool reg; } struct_frame_reg; diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index 9edc851cb705..2a015e8e7038 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -27,7 +27,7 @@ extern void WILC_WFI_mgmt_rx(uint8_t *buff, uint32_t size); extern void frmw_to_linux(uint8_t *buff, uint32_t size); int sdio_xfer_cnt(void); uint32_t wilc_get_chipid(uint8_t update); -WILC_Uint16 Set_machw_change_vir_if(WILC_Bool bValue); +u16 Set_machw_change_vir_if(WILC_Bool bValue); @@ -2325,9 +2325,9 @@ _fail_: } #define BIT31 (1 << 31) -WILC_Uint16 Set_machw_change_vir_if(WILC_Bool bValue) +u16 Set_machw_change_vir_if(WILC_Bool bValue) { - WILC_Uint16 ret; + u16 ret; WILC_Uint32 reg; /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/ @@ -2354,7 +2354,7 @@ WILC_Uint16 Set_machw_change_vir_if(WILC_Bool bValue) } #ifdef WILC_FULLY_HOSTING_AP -wilc_wlan_dev_t *Get_wlan_context(WILC_Uint16 *pu16size) +wilc_wlan_dev_t *Get_wlan_context(u16 *pu16size) { *pu16size = sizeof(wilc_wlan_dev_t); return &g_wlan; From 4e4467fdd6e89fbbc5208636a85177e4b973ded9 Mon Sep 17 00:00:00 2001 From: Chaehyun Lim Date: Thu, 11 Jun 2015 14:35:55 +0900 Subject: [PATCH 0920/1163] staging: wilc1000: remove WILC_Uint32 Use u32 instead of WILC_Uint32. Signed-off-by: Chaehyun Lim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 74 ++--- drivers/staging/wilc1000/coreconfigurator.h | 16 +- drivers/staging/wilc1000/fifo_buffer.c | 20 +- drivers/staging/wilc1000/fifo_buffer.h | 22 +- drivers/staging/wilc1000/host_interface.c | 266 +++++++++--------- drivers/staging/wilc1000/host_interface.h | 70 ++--- drivers/staging/wilc1000/linux_mon.c | 4 +- drivers/staging/wilc1000/linux_wlan.c | 12 +- drivers/staging/wilc1000/wilc_memory.c | 14 +- drivers/staging/wilc1000/wilc_memory.h | 18 +- drivers/staging/wilc1000/wilc_msgqueue.c | 6 +- drivers/staging/wilc1000/wilc_msgqueue.h | 6 +- drivers/staging/wilc1000/wilc_oswrapper.h | 1 - drivers/staging/wilc1000/wilc_platform.h | 4 +- drivers/staging/wilc1000/wilc_sleep.c | 4 +- drivers/staging/wilc1000/wilc_sleep.h | 2 +- drivers/staging/wilc1000/wilc_strutils.c | 14 +- drivers/staging/wilc1000/wilc_strutils.h | 14 +- drivers/staging/wilc1000/wilc_timer.c | 2 +- drivers/staging/wilc1000/wilc_timer.h | 2 +- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 54 ++-- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 6 +- drivers/staging/wilc1000/wilc_wlan.c | 6 +- drivers/staging/wilc1000/wilc_wlan_cfg.c | 2 +- drivers/staging/wilc1000/wilc_wlan_if.h | 4 +- 25 files changed, 321 insertions(+), 322 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index cc4455f47309..2bb513dde065 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -159,9 +159,9 @@ typedef struct { /* Extern Function Declarations */ /*****************************************************************************/ extern WILC_Sint32 SendRawPacket(WILC_Sint8 *ps8Packet, WILC_Sint32 s32PacketLen); -extern void NetworkInfoReceived(u8 *pu8Buffer, WILC_Uint32 u32Length); -extern void GnrlAsyncInfoReceived(u8 *pu8Buffer, WILC_Uint32 u32Length); -extern void host_int_ScanCompleteReceived(u8 *pu8Buffer, WILC_Uint32 u32Length); +extern void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length); +extern void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length); +extern void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length); /*****************************************************************************/ /* Global Variables */ /*****************************************************************************/ @@ -359,8 +359,8 @@ INLINE u16 extract_mac_addr(WILC_Char *str, u8 *buff) /* integers. */ INLINE void create_mac_addr(u8 *str, u8 *buff) { - WILC_Uint32 i = 0; - WILC_Uint32 j = 0; + u32 i = 0; + u32 j = 0; for (i = 0; i < MAC_ADDR_LEN; i++) { str[j++] = get_hex_char((u8)((buff[i] >> 4) & 0x0F)); @@ -376,7 +376,7 @@ INLINE void create_mac_addr(u8 *str, u8 *buff) /* inet_addr is platform independent. */ /* ips=>IP Address String in dotted decimal format */ /* ipn=>Pointer to IP Address in integer format */ -INLINE u8 conv_ip_to_int(u8 *ips, WILC_Uint32 *ipn) +INLINE u8 conv_ip_to_int(u8 *ips, u32 *ipn) { u8 i = 0; u8 ipb = 0; @@ -403,7 +403,7 @@ INLINE u8 conv_ip_to_int(u8 *ips, WILC_Uint32 *ipn) /* decimal string format. Alternative to std library fn inet_ntoa(). */ /* ips=>Buffer to hold IP Address String dotted decimal format (Min 17B) */ /* ipn=>IP Address in integer format */ -INLINE u8 conv_int_to_ip(u8 *ips, WILC_Uint32 ipn) +INLINE u8 conv_int_to_ip(u8 *ips, u32 ipn) { u8 i = 0; u8 ipb = 0; @@ -442,7 +442,7 @@ INLINE u8 conv_int_to_ip(u8 *ips, WILC_Uint32 ipn) return i; } -INLINE tenuWIDtype get_wid_type(WILC_Uint32 wid_num) +INLINE tenuWIDtype get_wid_type(u32 wid_num) { /* Check for iconfig specific WID types first */ if ((wid_num == WID_BSSID) || @@ -486,10 +486,10 @@ INLINE u16 get_beacon_period(u8 *data) return bcn_per; } -INLINE WILC_Uint32 get_beacon_timestamp_lo(u8 *data) +INLINE u32 get_beacon_timestamp_lo(u8 *data) { - WILC_Uint32 time_stamp = 0; - WILC_Uint32 index = MAC_HDR_LEN; + u32 time_stamp = 0; + u32 index = MAC_HDR_LEN; time_stamp |= data[index++]; time_stamp |= (data[index++] << 8); @@ -812,8 +812,8 @@ WILC_Sint32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInf u8 *pu8IEs = 0; u16 u16IEsLen = 0; u8 u8index = 0; - WILC_Uint32 u32Tsf_Lo; - WILC_Uint32 u32Tsf_Hi; + u32 u32Tsf_Lo; + u32 u32Tsf_Hi; pstrNetworkInfo = (tstrNetworkInfo *)WILC_MALLOC(sizeof(tstrNetworkInfo)); WILC_memset((void *)(pstrNetworkInfo), 0, sizeof(tstrNetworkInfo)); @@ -924,7 +924,7 @@ WILC_Sint32 DeallocateNetworkInfo(tstrNetworkInfo *pstrNetworkInfo) * @date 2 Apr 2012 * @version 1.0 */ -WILC_Sint32 ParseAssocRespInfo(u8 *pu8Buffer, WILC_Uint32 u32BufferLen, +WILC_Sint32 ParseAssocRespInfo(u8 *pu8Buffer, u32 u32BufferLen, tstrConnectRespInfo **ppstrConnectRespInfo) { WILC_Sint32 s32Error = WILC_SUCCESS; @@ -1001,17 +1001,17 @@ WILC_Sint32 DeallocateAssocRespInfo(tstrConnectRespInfo *pstrConnectRespInfo) #ifndef CONNECT_DIRECT WILC_Sint32 ParseSurveyResults(u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE], wid_site_survey_reslts_s **ppstrSurveyResults, - WILC_Uint32 *pu32SurveyResultsCount) + u32 *pu32SurveyResultsCount) { WILC_Sint32 s32Error = WILC_SUCCESS; wid_site_survey_reslts_s *pstrSurveyResults = NULL; - WILC_Uint32 u32SurveyResultsCount = 0; - WILC_Uint32 u32SurveyBytesLength = 0; + u32 u32SurveyResultsCount = 0; + u32 u32SurveyBytesLength = 0; u8 *pu8BufferPtr; - WILC_Uint32 u32RcvdSurveyResultsNum = 2; + u32 u32RcvdSurveyResultsNum = 2; u8 u8ReadSurveyResFragNum; - WILC_Uint32 i; - WILC_Uint32 j; + u32 i; + u32 j; for (i = 0; i < u32RcvdSurveyResultsNum; i++) { u32SurveyBytesLength = ppu8RcvdSiteSurveyResults[i][0]; @@ -1208,8 +1208,8 @@ void ProcessShortWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, void ProcessIntWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, tstrWID *pstrWID, WILC_Sint8 *ps8WidVal) { - WILC_Uint32 *pu32val = (WILC_Uint32 *)ps8WidVal; - WILC_Uint32 u32val = 0; + u32 *pu32val = (u32 *)ps8WidVal; + u32 u32val = 0; WILC_Sint32 s32PktLen = *ps32PktLen; if (pstrWID == NULL) { PRINT_WRN(CORECONFIG_DBG, "Can't set INT val 0x%x , NULL structure\n", u32val); @@ -1224,7 +1224,7 @@ void ProcessIntWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, u32val = *pu32val; /* Length */ - pcPacket[s32PktLen++] = sizeof(WILC_Uint32); + pcPacket[s32PktLen++] = sizeof(u32); /* Value */ pcPacket[s32PktLen++] = (u8)(u32val & 0xFF); @@ -1266,7 +1266,7 @@ void ProcessIntWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, void ProcessIPwid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, tstrWID *pstrWID, u8 *pu8ip) { - WILC_Uint32 u32val = 0; + u32 u32val = 0; WILC_Sint32 s32PktLen = *ps32PktLen; if (pstrWID == NULL) { @@ -1280,7 +1280,7 @@ void ProcessIPwid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, if (g_oper_mode == SET_CFG) { /* Length */ - pcPacket[s32PktLen++] = sizeof(WILC_Uint32); + pcPacket[s32PktLen++] = sizeof(u32); /* Convert the IP Address String to Integer */ conv_ip_to_int(pu8ip, &u32val); @@ -1521,14 +1521,14 @@ WILC_Sint32 further_process_response(u8 *resp, u16 u16WIDid, u16 cfg_len, WILC_Bool process_wid_num, - WILC_Uint32 cnt, + u32 cnt, tstrWID *pstrWIDresult) { - WILC_Uint32 retval = 0; - WILC_Uint32 idx = 0; + u32 retval = 0; + u32 idx = 0; u8 cfg_chr = 0; u16 cfg_sht = 0; - WILC_Uint32 cfg_int = 0; + u32 cfg_int = 0; u8 cfg_str[256] = {0}; tenuWIDtype enuWIDtype = WID_UNDEF; @@ -1558,7 +1558,7 @@ WILC_Sint32 further_process_response(u8 *resp, case WID_INT: { - WILC_Uint32 *pu32val = (WILC_Uint32 *)(pstrWIDresult->ps8WidVal); + u32 *pu32val = (u32 *)(pstrWIDresult->ps8WidVal); cfg_int = MAKE_WORD32( MAKE_WORD16(resp[idx], resp[idx + 1]), MAKE_WORD16(resp[idx + 2], resp[idx + 3]) @@ -1694,9 +1694,9 @@ WILC_Sint32 ParseResponse(u8 *resp, tstrWID *pstrWIDcfgResult) u16 cfg_len = 0; tenuWIDtype enuWIDtype = WID_UNDEF; WILC_Bool num_wid_processed = WILC_FALSE; - WILC_Uint32 cnt = 0; - WILC_Uint32 idx = 0; - WILC_Uint32 ResCnt = 0; + u32 cnt = 0; + u32 idx = 0; + u32 ResCnt = 0; /* Check whether the received frame is a valid response */ if (RESP_MSG_TYPE != resp[0]) { PRINT_INFO(CORECONFIG_DBG, "Received Message format incorrect.\n"); @@ -1858,10 +1858,10 @@ WILC_Sint32 CreatePacketHeader(WILC_Char *pcpacket, WILC_Sint32 *ps32PacketLengt */ WILC_Sint32 CreateConfigPacket(WILC_Sint8 *ps8packet, WILC_Sint32 *ps32PacketLength, - tstrWID *pstrWIDs, WILC_Uint32 u32WIDsCount) + tstrWID *pstrWIDs, u32 u32WIDsCount) { WILC_Sint32 s32Error = WILC_SUCCESS; - WILC_Uint32 u32idx = 0; + u32 u32idx = 0; *ps32PacketLength = MSG_HEADER_LEN; for (u32idx = 0; u32idx < u32WIDsCount; u32idx++) { switch (pstrWIDs[u32idx].enuWIDtype) { @@ -1950,7 +1950,7 @@ WILC_Sint32 ConfigWaitResponse(WILC_Char *pcRespBuffer, WILC_Sint32 s32MaxRespBu */ #ifdef SIMULATION WILC_Sint32 SendConfigPkt(u8 u8Mode, tstrWID *pstrWIDs, - WILC_Uint32 u32WIDsCount, WILC_Bool bRespRequired, WILC_Uint32 drvHandler) + u32 u32WIDsCount, WILC_Bool bRespRequired, u32 drvHandler) { WILC_Sint32 s32Error = WILC_SUCCESS; WILC_Sint32 err = WILC_SUCCESS; @@ -2129,7 +2129,7 @@ extern wilc_wlan_oup_t *gpstrWlanOps; * @version 1.0 */ WILC_Sint32 SendConfigPkt(u8 u8Mode, tstrWID *pstrWIDs, - WILC_Uint32 u32WIDsCount, WILC_Bool bRespRequired, WILC_Uint32 drvHandler) + u32 u32WIDsCount, WILC_Bool bRespRequired, u32 drvHandler) { WILC_Sint32 counter = 0, ret = 0; if (gpstrWlanOps == NULL) { diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h index 640dc50860f9..c2a6d5b00bf7 100644 --- a/drivers/staging/wilc1000/coreconfigurator.h +++ b/drivers/staging/wilc1000/coreconfigurator.h @@ -66,7 +66,7 @@ extern u16 g_num_total_switches; /* Function Macros */ /*****************************************************************************/ #define MAKE_WORD16(lsb, msb) ((((u16)(msb) << 8) & 0xFF00) | (lsb)) -#define MAKE_WORD32(lsw, msw) ((((WILC_Uint32)(msw) << 16) & 0xFFFF0000) | (lsw)) +#define MAKE_WORD32(lsw, msw) ((((u32)(msw) << 16) & 0xFFFF0000) | (lsw)) /*****************************************************************************/ @@ -423,7 +423,7 @@ typedef struct { u8 u8Found; #endif #ifdef WILC_P2P - WILC_Uint32 u32Tsf; /* time-stamp [Low only 32 bit] */ + u32 u32Tsf; /* time-stamp [Low only 32 bit] */ #endif u8 *pu8IEs; u16 u16IEsLen; @@ -476,23 +476,23 @@ extern WILC_Sint32 CoreConfiguratorInit(void); extern WILC_Sint32 CoreConfiguratorDeInit(void); extern WILC_Sint32 SendConfigPkt(u8 u8Mode, tstrWID *pstrWIDs, - WILC_Uint32 u32WIDsCount, WILC_Bool bRespRequired, WILC_Uint32 drvHandler); + u32 u32WIDsCount, WILC_Bool bRespRequired, u32 drvHandler); extern WILC_Sint32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo); extern WILC_Sint32 DeallocateNetworkInfo(tstrNetworkInfo *pstrNetworkInfo); -extern WILC_Sint32 ParseAssocRespInfo(u8 *pu8Buffer, WILC_Uint32 u32BufferLen, +extern WILC_Sint32 ParseAssocRespInfo(u8 *pu8Buffer, u32 u32BufferLen, tstrConnectRespInfo **ppstrConnectRespInfo); extern WILC_Sint32 DeallocateAssocRespInfo(tstrConnectRespInfo *pstrConnectRespInfo); #ifndef CONNECT_DIRECT extern WILC_Sint32 ParseSurveyResults(u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE], - wid_site_survey_reslts_s **ppstrSurveyResults, WILC_Uint32 *pu32SurveyResultsCount); + wid_site_survey_reslts_s **ppstrSurveyResults, u32 *pu32SurveyResultsCount); extern WILC_Sint32 DeallocateSurveyResults(wid_site_survey_reslts_s *pstrSurveyResults); #endif extern WILC_Sint32 SendRawPacket(WILC_Sint8 *pspacket, WILC_Sint32 s32PacketLen); -extern void NetworkInfoReceived(u8 *pu8Buffer, WILC_Uint32 u32Length); -void GnrlAsyncInfoReceived(u8 *pu8Buffer, WILC_Uint32 u32Length); -void host_int_ScanCompleteReceived(u8 *pu8Buffer, WILC_Uint32 u32Length); +extern void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length); +void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length); +void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length); #endif diff --git a/drivers/staging/wilc1000/fifo_buffer.c b/drivers/staging/wilc1000/fifo_buffer.c index f807bfb72539..788398ca76e5 100644 --- a/drivers/staging/wilc1000/fifo_buffer.c +++ b/drivers/staging/wilc1000/fifo_buffer.c @@ -5,9 +5,9 @@ -WILC_Uint32 FIFO_InitBuffer(tHANDLE *hBuffer, WILC_Uint32 u32BufferLength) +u32 FIFO_InitBuffer(tHANDLE *hBuffer, u32 u32BufferLength) { - WILC_Uint32 u32Error = 0; + u32 u32Error = 0; tstrFifoHandler *pstrFifoHandler = WILC_MALLOC (sizeof (tstrFifoHandler)); if (pstrFifoHandler) { WILC_memset (pstrFifoHandler, 0, sizeof (tstrFifoHandler)); @@ -27,9 +27,9 @@ WILC_Uint32 FIFO_InitBuffer(tHANDLE *hBuffer, WILC_Uint32 u32BufferLength) } return u32Error; } -WILC_Uint32 FIFO_DeInit(tHANDLE hFifo) +u32 FIFO_DeInit(tHANDLE hFifo) { - WILC_Uint32 u32Error = 0; + u32 u32Error = 0; tstrFifoHandler *pstrFifoHandler = (tstrFifoHandler *) hFifo; if (pstrFifoHandler) { if (pstrFifoHandler->pu8Buffer) { @@ -45,9 +45,9 @@ WILC_Uint32 FIFO_DeInit(tHANDLE hFifo) return u32Error; } -WILC_Uint32 FIFO_ReadBytes(tHANDLE hFifo, u8 *pu8Buffer, WILC_Uint32 u32BytesToRead, WILC_Uint32 *pu32BytesRead) +u32 FIFO_ReadBytes(tHANDLE hFifo, u8 *pu8Buffer, u32 u32BytesToRead, u32 *pu32BytesRead) { - WILC_Uint32 u32Error = 0; + u32 u32Error = 0; tstrFifoHandler *pstrFifoHandler = (tstrFifoHandler *) hFifo; if (pstrFifoHandler && pu32BytesRead) { if (pstrFifoHandler->u32TotalBytes) { @@ -66,7 +66,7 @@ WILC_Uint32 FIFO_ReadBytes(tHANDLE hFifo, u8 *pu8Buffer, WILC_Uint32 u32BytesToR pstrFifoHandler->u32TotalBytes -= u32BytesToRead; } else { - WILC_Uint32 u32FirstPart = + u32 u32FirstPart = pstrFifoHandler->u32BufferLength - pstrFifoHandler->u32ReadOffset; WILC_memcpy(pu8Buffer, pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32ReadOffset, u32FirstPart); @@ -86,9 +86,9 @@ WILC_Uint32 FIFO_ReadBytes(tHANDLE hFifo, u8 *pu8Buffer, WILC_Uint32 u32BytesToR return u32Error; } -WILC_Uint32 FIFO_WriteBytes(tHANDLE hFifo, u8 *pu8Buffer, WILC_Uint32 u32BytesToWrite, WILC_Bool bForceOverWrite) +u32 FIFO_WriteBytes(tHANDLE hFifo, u8 *pu8Buffer, u32 u32BytesToWrite, WILC_Bool bForceOverWrite) { - WILC_Uint32 u32Error = 0; + u32 u32Error = 0; tstrFifoHandler *pstrFifoHandler = (tstrFifoHandler *) hFifo; if (pstrFifoHandler) { if (u32BytesToWrite < pstrFifoHandler->u32BufferLength) { @@ -103,7 +103,7 @@ WILC_Uint32 FIFO_WriteBytes(tHANDLE hFifo, u8 *pu8Buffer, WILC_Uint32 u32BytesTo pstrFifoHandler->u32TotalBytes += u32BytesToWrite; } else { - WILC_Uint32 u32FirstPart = + u32 u32FirstPart = pstrFifoHandler->u32BufferLength - pstrFifoHandler->u32WriteOffset; WILC_memcpy(pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32WriteOffset, pu8Buffer, u32FirstPart); diff --git a/drivers/staging/wilc1000/fifo_buffer.h b/drivers/staging/wilc1000/fifo_buffer.h index 4d120503c4b2..912a33327bc7 100644 --- a/drivers/staging/wilc1000/fifo_buffer.h +++ b/drivers/staging/wilc1000/fifo_buffer.h @@ -6,18 +6,18 @@ typedef struct { u8 *pu8Buffer; - WILC_Uint32 u32BufferLength; - WILC_Uint32 u32WriteOffset; - WILC_Uint32 u32ReadOffset; - WILC_Uint32 u32TotalBytes; + u32 u32BufferLength; + u32 u32WriteOffset; + u32 u32ReadOffset; + u32 u32TotalBytes; struct semaphore SemBuffer; } tstrFifoHandler; -extern WILC_Uint32 FIFO_InitBuffer(tHANDLE *hBuffer, - WILC_Uint32 u32BufferLength); -extern WILC_Uint32 FIFO_DeInit(tHANDLE hFifo); -extern WILC_Uint32 FIFO_ReadBytes(tHANDLE hFifo, u8 *pu8Buffer, - WILC_Uint32 u32BytesToRead, WILC_Uint32 *pu32BytesRead); -extern WILC_Uint32 FIFO_WriteBytes(tHANDLE hFifo, u8 *pu8Buffer, - WILC_Uint32 u32BytesToWrite, WILC_Bool bForceOverWrite); +extern u32 FIFO_InitBuffer(tHANDLE *hBuffer, + u32 u32BufferLength); +extern u32 FIFO_DeInit(tHANDLE hFifo); +extern u32 FIFO_ReadBytes(tHANDLE hFifo, u8 *pu8Buffer, + u32 u32BytesToRead, u32 *pu32BytesRead); +extern u32 FIFO_WriteBytes(tHANDLE hFifo, u8 *pu8Buffer, + u32 u32BytesToWrite, WILC_Bool bForceOverWrite); diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 4b6265c21c6f..75effdb22a02 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -220,7 +220,7 @@ typedef struct _tstrHostIFconnectAttr { */ typedef struct _tstrRcvdGnrlAsyncInfo { u8 *pu8Buffer; - WILC_Uint32 u32Length; + u32 u32Length; } tstrRcvdGnrlAsyncInfo; /*! @@ -265,7 +265,7 @@ typedef struct _tstrHostIFGetChan { /*typedef struct _tstrScanComplete * { * u8* pu8Buffer; - * WILC_Uint32 u32Length; + * u32 u32Length; * } tstrScanComplete;*/ /*! @@ -279,13 +279,13 @@ typedef struct _tstrHostIFGetChan { * @version 1.0 */ typedef struct _tstrHostIFSetBeacon { - WILC_Uint32 u32Interval; /*!< Beacon Interval. Period between two successive beacons on air */ - WILC_Uint32 u32DTIMPeriod; /*!< DTIM Period. Indicates how many Beacon frames + u32 u32Interval; /*!< Beacon Interval. Period between two successive beacons on air */ + u32 u32DTIMPeriod; /*!< DTIM Period. Indicates how many Beacon frames * (including the current frame) appear before the next DTIM */ - WILC_Uint32 u32HeadLen; /*!< Length of the head buffer in bytes */ + u32 u32HeadLen; /*!< Length of the head buffer in bytes */ u8 *pu8Head; /*!< Pointer to the beacon's head buffer. Beacon's head is the part * from the beacon's start till the TIM element, NOT including the TIM */ - WILC_Uint32 u32TailLen; /*!< Length of the tail buffer in bytes */ + u32 u32TailLen; /*!< Length of the tail buffer in bytes */ u8 *pu8Tail; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just * after the TIM inormation element */ } tstrHostIFSetBeacon; @@ -319,7 +319,7 @@ typedef struct _tstrHostIFDelBeacon { typedef struct { WILC_Bool bIsEnabled; - WILC_Uint32 u32count; + u32 u32count; } tstrHostIFSetMulti; /*! @@ -380,7 +380,7 @@ typedef struct _tstrTimerCb { typedef struct { WILC_Bool bIsEnabled; - WILC_Uint32 u32Timeout; + u32 u32Timeout; } tstrHostIfPowerMgmtParam; /*! @@ -504,7 +504,7 @@ typedef struct _tstrJoinBssParam { u8 rsn_cap[2]; struct _tstrJoinParam *nextJoinBss; #ifdef WILC_P2P - WILC_Uint32 tsf; + u32 tsf; u8 u8NoaEnbaled; u8 u8OppEnable; u8 u8CtWindow; @@ -570,11 +570,11 @@ static u8 gu8Chnl; static u8 gs8SetIP[2][4]; static u8 gs8GetIP[2][4]; #ifdef WILC_AP_EXTERNAL_MLME -static WILC_Uint32 gu32InactiveTime; +static u32 gu32InactiveTime; static u8 gu8DelBcn; #endif #ifndef SIMULATION -static WILC_Uint32 gu32WidConnRstHack; +static u32 gu32WidConnRstHack; #endif /*BugID_5137*/ @@ -582,9 +582,9 @@ u8 *gu8FlushedJoinReq; u8 *gu8FlushedInfoElemAsoc; u8 gu8Flushed11iMode; u8 gu8FlushedAuthType; -WILC_Uint32 gu32FlushedJoinReqSize; -WILC_Uint32 gu32FlushedInfoElemAsocSize; -WILC_Uint32 gu8FlushedJoinReqDrvHandler; +u32 gu32FlushedJoinReqSize; +u32 gu32FlushedInfoElemAsocSize; +u32 gu8FlushedJoinReqDrvHandler; #define REAL_JOIN_REQ 0 #define FLUSHED_JOIN_REQ 1 #define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */ @@ -595,7 +595,7 @@ WILC_Uint32 gu8FlushedJoinReqDrvHandler; static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo); #endif /*WILC_PARSE_SCAN_IN_HOST*/ -extern void chip_sleep_manually(WILC_Uint32 u32SleepTime); +extern void chip_sleep_manually(u32 u32SleepTime); extern int linux_wlan_get_num_conn_ifcs(void); /** @@ -622,7 +622,7 @@ static WILC_Sint32 Handle_SetChannel(void *drvHandler, tstrHostIFSetChan *pstrHo PRINT_D(HOSTINF_DBG, "Setting channel\n"); /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to set channel\n"); WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); @@ -655,14 +655,14 @@ static WILC_Sint32 Handle_SetWfiDrvHandler(tstrHostIfSetDrvHandler *pstrHostIfSe strWID.u16WIDid = (u16)WID_SET_DRV_HANDLER; strWID.enuWIDtype = WID_INT; strWID.ps8WidVal = (WILC_Sint8 *)&(pstrHostIfSetDrvHandler->u32Address); - strWID.s32ValueSize = sizeof(WILC_Uint32); + strWID.s32ValueSize = sizeof(u32); /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); - if ((pstrHostIfSetDrvHandler->u32Address) == (WILC_Uint32)NULL) { + if ((pstrHostIfSetDrvHandler->u32Address) == (u32)NULL) { up(&hSemDeinitDrvHandle); } @@ -700,15 +700,15 @@ static WILC_Sint32 Handle_SetOperationMode(void *drvHandler, tstrHostIfSetOperat strWID.u16WIDid = (u16)WID_SET_OPERATION_MODE; strWID.enuWIDtype = WID_INT; strWID.ps8WidVal = (WILC_Sint8 *)&(pstrHostIfSetOperationMode->u32Mode); - strWID.s32ValueSize = sizeof(WILC_Uint32); + strWID.s32ValueSize = sizeof(u32); /*Sending Cfg*/ PRINT_INFO(HOSTINF_DBG, "(size_t)pstrWFIDrv= %p \n", pstrWFIDrv); - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); - if ((pstrHostIfSetOperationMode->u32Mode) == (WILC_Uint32)NULL) { + if ((pstrHostIfSetOperationMode->u32Mode) == (u32)NULL) { up(&hSemDeinitDrvHandle); } @@ -755,7 +755,7 @@ WILC_Sint32 Handle_set_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx) strWID.ps8WidVal = (u8 *)pu8IPAddr; strWID.s32ValueSize = IP_ALEN; - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); @@ -799,7 +799,7 @@ WILC_Sint32 Handle_get_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx) strWID.ps8WidVal = (u8 *)WILC_MALLOC(IP_ALEN); strWID.s32ValueSize = IP_ALEN; - s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); PRINT_INFO(HOSTINF_DBG, "%d.%d.%d.%d\n", (u8)(strWID.ps8WidVal[0]), (u8)(strWID.ps8WidVal[1]), (u8)(strWID.ps8WidVal[2]), (u8)(strWID.ps8WidVal[3])); @@ -859,7 +859,7 @@ static WILC_Sint32 Handle_SetMacAddress(void *drvHandler, tstrHostIfSetMacAddres strWID.s32ValueSize = ETH_ALEN; PRINT_D(GENERIC_DBG, "mac addr = :%x:%x:%x:%x:%x:%x\n", strWID.ps8WidVal[0], strWID.ps8WidVal[1], strWID.ps8WidVal[2], strWID.ps8WidVal[3], strWID.ps8WidVal[4], strWID.ps8WidVal[5]); /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to set mac address\n"); WILC_ERRORREPORT(s32Error, WILC_FAIL); @@ -897,7 +897,7 @@ static WILC_Sint32 Handle_GetMacAddress(void *drvHandler, tstrHostIfGetMacAddres strWID.s32ValueSize = ETH_ALEN; /*Sending Cfg*/ - s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)drvHandler); + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_FALSE, (u32)drvHandler); if (s32Error) { PRINT_ER("Failed to get mac address\n"); WILC_ERRORREPORT(s32Error, WILC_FAIL); @@ -1205,7 +1205,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str } u8WidCnt++; } - s32Error = SendConfigPkt(SET_CFG, strWIDList, u8WidCnt, WILC_FALSE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, strWIDList, u8WidCnt, WILC_FALSE, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Error in setting CFG params\n"); @@ -1249,8 +1249,8 @@ static WILC_Sint32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFs { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWIDList[5]; - WILC_Uint32 u32WidsCount = 0; - WILC_Uint32 i; + u32 u32WidsCount = 0; + u32 i; u8 *pu8Buffer; u8 valuesize = 0; u8 *pu8HdnNtwrksWidVal = NULL; @@ -1372,7 +1372,7 @@ static WILC_Sint32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFs gbScanWhileConnected = WILC_FALSE; } - s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, WILC_FALSE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, WILC_FALSE, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to send scan paramters config packet\n"); @@ -1450,7 +1450,7 @@ static WILC_Sint32 Handle_ScanDone(void *drvHandler, tenuScanEvent enuEvent) strWID.s32ValueSize = sizeof(WILC_Char); /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); if (s32Error != WILC_SUCCESS) { PRINT_ER("Failed to set abort running scan\n"); WILC_ERRORREPORT(s32Error, WILC_FAIL); @@ -1491,11 +1491,11 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler; WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWIDList[8]; - WILC_Uint32 u32WidsCount = 0, dummyval = 0; + u32 u32WidsCount = 0, dummyval = 0; /* char passphrase[] = "12345678"; */ #ifndef CONNECT_DIRECT WILC_Sint32 s32Err = WILC_SUCCESS; - WILC_Uint32 i; + u32 i; u8 u8bssDscListIndex; wid_site_survey_reslts_s *pstrSurveyResults = NULL; #else @@ -1649,7 +1649,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH /* ////////////////////// */ #endif - s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, WILC_FALSE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, WILC_FALSE, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Handle_Connect()] failed to send config packet\n"); WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); @@ -1722,19 +1722,19 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT; strWIDList[u32WidsCount].enuWIDtype = WID_INT; - strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Uint32); + strWIDList[u32WidsCount].s32ValueSize = sizeof(u32); strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(dummyval)); u32WidsCount++; strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT; strWIDList[u32WidsCount].enuWIDtype = WID_INT; - strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Uint32); + strWIDList[u32WidsCount].s32ValueSize = sizeof(u32); strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(dummyval)); u32WidsCount++; strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT; strWIDList[u32WidsCount].enuWIDtype = WID_INT; - strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Uint32); + strWIDList[u32WidsCount].s32ValueSize = sizeof(u32); strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(dummyval)); u32WidsCount++; @@ -1978,7 +1978,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH /*BugID_5137*/ if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) { memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize); - gu8FlushedJoinReqDrvHandler = (WILC_Uint32)pstrWFIDrv; + gu8FlushedJoinReqDrvHandler = (u32)pstrWFIDrv; } PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n"); @@ -1990,7 +1990,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH PRINT_D(GENERIC_DBG, "save bssid = %x:%x:%x:%x:%x:%x\n", (u8ConnectedSSID[0]), (u8ConnectedSSID[1]), (u8ConnectedSSID[2]), (u8ConnectedSSID[3]), (u8ConnectedSSID[4]), (u8ConnectedSSID[5])); } - s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, WILC_FALSE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, WILC_FALSE, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Handle_Connect()] failed to send config packet\n"); WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); @@ -2081,7 +2081,7 @@ static WILC_Sint32 Handle_FlushConnect(void *drvHandler) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWIDList[5]; - WILC_Uint32 u32WidsCount = 0; + u32 u32WidsCount = 0; u8 *pu8CurrByte = NULL; @@ -2206,7 +2206,7 @@ static WILC_Sint32 Handle_ConnectTimeout(void *drvHandler) PRINT_D(HOSTINF_DBG, "Sending disconnect request\n"); - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to send dissconect config packet\n"); } @@ -2232,11 +2232,11 @@ static WILC_Sint32 Handle_ConnectTimeout(void *drvHandler) WILC_memset(u8ConnectedSSID, 0, ETH_ALEN); /*BugID_5213*/ /*Freeing flushed join request params on connect timeout*/ - if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (WILC_Uint32)drvHandler) { + if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) { WILC_FREE(gu8FlushedJoinReq); gu8FlushedJoinReq = NULL; } - if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (WILC_Uint32)drvHandler) { + if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) { WILC_FREE(gu8FlushedInfoElemAsoc); gu8FlushedInfoElemAsoc = NULL; } @@ -2255,7 +2255,7 @@ static WILC_Sint32 Handle_ConnectTimeout(void *drvHandler) */ static WILC_Sint32 Handle_RcvdNtwrkInfo(void *drvHandler, tstrRcvdNetworkInfo *pstrRcvdNetworkInfo) { - WILC_Uint32 i; + u32 i; WILC_Bool bNewNtwrkFound; @@ -2433,7 +2433,7 @@ static WILC_Sint32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncI PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo); if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) { /* our station had sent Association Request frame, so here it will get the Association Response frame then parse it */ - WILC_Uint32 u32RcvdAssocRespInfoLen; + u32 u32RcvdAssocRespInfoLen; tstrConnectRespInfo *pstrConnectRespInfo = NULL; PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo); @@ -2657,11 +2657,11 @@ static WILC_Sint32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncI /*BugID_5213*/ /*Freeing flushed join request params on receiving*/ /*MAC_DISCONNECTED while connected*/ - if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (WILC_Uint32)drvHandler) { + if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) { WILC_FREE(gu8FlushedJoinReq); gu8FlushedJoinReq = NULL; } - if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (WILC_Uint32)drvHandler) { + if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) { WILC_FREE(gu8FlushedInfoElemAsoc); gu8FlushedInfoElemAsoc = NULL; } @@ -2767,7 +2767,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) strWIDList[3].ps8WidVal = (WILC_Sint8 *)pu8keybuf; - s32Error = SendConfigPkt(SET_CFG, strWIDList, 4, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, strWIDList, 4, WILC_TRUE, (u32)pstrWFIDrv); WILC_FREE(pu8keybuf); @@ -2795,7 +2795,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) strWID.ps8WidVal = (WILC_Sint8 *)pu8keybuf; strWID.s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2; - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); WILC_FREE(pu8keybuf); } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY) { @@ -2807,7 +2807,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) strWID.ps8WidVal = s8idxarray; strWID.s32ValueSize = 1; - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); } else { strWID.u16WIDid = (u16)WID_KEY_ID; strWID.enuWIDtype = WID_CHAR; @@ -2816,7 +2816,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) PRINT_D(HOSTINF_DBG, "Setting default key index\n"); - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); } up(&(pstrWFIDrv->hSemTestKeyBlock)); break; @@ -2862,7 +2862,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) strWIDList[1].ps8WidVal = (WILC_Sint8 *)pu8keybuf; strWIDList[1].s32ValueSize = RX_MIC_KEY_MSG_LEN; - s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, WILC_TRUE, (u32)pstrWFIDrv); WILC_FREE(pu8keybuf); @@ -2909,7 +2909,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) strWID.ps8WidVal = (WILC_Sint8 *)pu8keybuf; strWID.s32ValueSize = RX_MIC_KEY_MSG_LEN; - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); WILC_FREE(pu8keybuf); @@ -2966,7 +2966,7 @@ _WPARxGtk_end_case_: strWIDList[1].ps8WidVal = (WILC_Sint8 *)pu8keybuf; strWIDList[1].s32ValueSize = PTK_KEY_MSG_LEN + 1; - s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, WILC_TRUE, (u32)pstrWFIDrv); WILC_FREE(pu8keybuf); /* ////////////////////////// */ @@ -3007,7 +3007,7 @@ _WPARxGtk_end_case_: strWID.ps8WidVal = (WILC_Sint8 *)pu8keybuf; strWID.s32ValueSize = PTK_KEY_MSG_LEN; - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); WILC_FREE(pu8keybuf); /* ////////////////////////// */ @@ -3046,7 +3046,7 @@ _WPAPtk_end_case_: strWID.ps8WidVal = (WILC_Sint8 *)pu8keybuf; strWID.s32ValueSize = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1; - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); WILC_FREE(pu8keybuf); break; @@ -3095,7 +3095,7 @@ static void Handle_Disconnect(void *drvHandler) WILC_memset(u8ConnectedSSID, 0, ETH_ALEN); - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to send dissconect config packet\n"); @@ -3159,11 +3159,11 @@ static void Handle_Disconnect(void *drvHandler) /*BugID_5137*/ - if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (WILC_Uint32)drvHandler) { + if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) { WILC_FREE(gu8FlushedJoinReq); gu8FlushedJoinReq = NULL; } - if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (WILC_Uint32)drvHandler) { + if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) { WILC_FREE(gu8FlushedInfoElemAsoc); gu8FlushedInfoElemAsoc = NULL; } @@ -3208,7 +3208,7 @@ static WILC_Sint32 Switch_Log_Terminal(void *drvHandler) strWID.ps8WidVal = &dummy; strWID.s32ValueSize = sizeof(WILC_Char); - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); if (s32Error) { @@ -3252,7 +3252,7 @@ static WILC_Sint32 Handle_GetChnl(void *drvHandler) PRINT_D(HOSTINF_DBG, "Getting channel value\n"); - s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); /*get the value by searching the local copy*/ if (s32Error) { PRINT_ER("Failed to get channel number\n"); @@ -3296,7 +3296,7 @@ static void Handle_GetRssi(void *drvHandler) /*Sending Cfg*/ PRINT_D(HOSTINF_DBG, "Getting RSSI value\n"); - s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to get RSSI value\n"); WILC_ERRORREPORT(s32Error, WILC_FAIL); @@ -3327,7 +3327,7 @@ static void Handle_GetLinkspeed(void *drvHandler) /*Sending Cfg*/ PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n"); - s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to get LINKSPEED value\n"); WILC_ERRORREPORT(s32Error, WILC_FAIL); @@ -3361,23 +3361,23 @@ WILC_Sint32 Handle_GetStatistics(void *drvHandler, tstrStatistics *pstrStatistic strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT; strWIDList[u32WidsCount].enuWIDtype = WID_INT; - strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Uint32); + strWIDList[u32WidsCount].s32ValueSize = sizeof(u32); strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrStatistics->u32TxCount)); u32WidsCount++; strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT; strWIDList[u32WidsCount].enuWIDtype = WID_INT; - strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Uint32); + strWIDList[u32WidsCount].s32ValueSize = sizeof(u32); strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrStatistics->u32RxCount)); u32WidsCount++; strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT; strWIDList[u32WidsCount].enuWIDtype = WID_INT; - strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Uint32); + strWIDList[u32WidsCount].s32ValueSize = sizeof(u32); strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrStatistics->u32TxFailureCount)); u32WidsCount++; - s32Error = SendConfigPkt(GET_CFG, strWIDList, u32WidsCount, WILC_FALSE, (WILC_Uint32)drvHandler); + s32Error = SendConfigPkt(GET_CFG, strWIDList, u32WidsCount, WILC_FALSE, (u32)drvHandler); if (s32Error) { PRINT_ER("Failed to send scan paramters config packet\n"); @@ -3425,7 +3425,7 @@ static WILC_Sint32 Handle_Get_InActiveTime(void *drvHandler, tstrHostIfStaInacti PRINT_D(CFG80211_DBG, "SETING STA inactive time\n"); - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); /*get the value by searching the local copy*/ if (s32Error) { PRINT_ER("Failed to SET incative time\n"); @@ -3436,10 +3436,10 @@ static WILC_Sint32 Handle_Get_InActiveTime(void *drvHandler, tstrHostIfStaInacti strWID.u16WIDid = (u16)WID_GET_INACTIVE_TIME; strWID.enuWIDtype = WID_INT; strWID.ps8WidVal = (WILC_Sint8 *)&gu32InactiveTime; - strWID.s32ValueSize = sizeof(WILC_Uint32); + strWID.s32ValueSize = sizeof(u32); - s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); /*get the value by searching the local copy*/ if (s32Error) { PRINT_ER("Failed to get incative time\n"); @@ -3520,7 +3520,7 @@ static void Handle_AddBeacon(void *drvHandler, tstrHostIFSetBeacon *pstrSetBeaco /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to send add beacon config packet\n"); WILC_ERRORREPORT(s32Error, WILC_FAIL); @@ -3565,7 +3565,7 @@ static void Handle_DelBeacon(void *drvHandler, tstrHostIFDelBeacon *pstrDelBeaco /* TODO: build del beacon message*/ /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to send delete beacon config packet\n"); @@ -3587,7 +3587,7 @@ static void Handle_DelBeacon(void *drvHandler, tstrHostIFDelBeacon *pstrDelBeaco * @date * @version 1.0 */ -static WILC_Uint32 WILC_HostIf_PackStaParam(u8 *pu8Buffer, tstrWILC_AddStaParam *pstrStationParam) +static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer, tstrWILC_AddStaParam *pstrStationParam) { u8 *pu8CurrByte; @@ -3662,7 +3662,7 @@ static void Handle_AddStation(void *drvHandler, tstrWILC_AddStaParam *pstrStatio pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam); /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (u32)pstrWFIDrv); if (s32Error != WILC_SUCCESS) { PRINT_ER("Failed to send add station config packet\n"); @@ -3718,7 +3718,7 @@ static void Handle_DelAllSta(void *drvHandler, tstrHostIFDelAllSta *pstrDelAllSt } /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to send add station config packe\n"); @@ -3766,7 +3766,7 @@ static void Handle_DelStation(void *drvHandler, tstrHostIFDelSta *pstrDelStaPara WILC_memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN); /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to send add station config packe\n"); @@ -3810,7 +3810,7 @@ static void Handle_EditStation(void *drvHandler, tstrWILC_AddStaParam *pstrStati pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam); /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to send edit station config packet\n"); @@ -3887,7 +3887,7 @@ static int Handle_RemainOnChan(void *drvHandler, tstrHostIfRemainOnChan *pstrHos strWID.ps8WidVal[1] = (WILC_Sint8)pstrHostIfRemainOnChan->u16Channel; /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); if (s32Error != WILC_SUCCESS) { PRINT_ER("Failed to set remain on channel\n"); } @@ -3945,7 +3945,7 @@ static int Handle_RegisterFrame(void *drvHandler, tstrHostIfRegisterFrame *pstrH /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to frame register config packet\n"); WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); @@ -3970,7 +3970,7 @@ static int Handle_RegisterFrame(void *drvHandler, tstrHostIfRegisterFrame *pstrH * @version 1.0 */ #define FALSE_FRMWR_CHANNEL 100 -static WILC_Uint32 Handle_ListenStateExpired(void *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan) +static u32 Handle_ListenStateExpired(void *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan) { u8 u8remain_on_chan_flag; tstrWID strWID; @@ -3997,7 +3997,7 @@ static WILC_Uint32 Handle_ListenStateExpired(void *drvHandler, tstrHostIfRemainO strWID.ps8WidVal[1] = FALSE_FRMWR_CHANNEL; /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); if (s32Error != WILC_SUCCESS) { PRINT_ER("Failed to set remain on channel\n"); goto _done_; @@ -4083,7 +4083,7 @@ static void Handle_PowerManagement(void *drvHandler, tstrHostIfPowerMgmtParam *s PRINT_D(HOSTINF_DBG, "Handling Power Management\n"); /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to send power management config packet\n"); WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); @@ -4135,7 +4135,7 @@ static void Handle_SetMulticastFilter(void *drvHandler, tstrHostIFSetMulti *strH memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN)); /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)drvHandler); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (u32)drvHandler); if (s32Error) { PRINT_ER("Failed to send setup multicast config packet\n"); WILC_ERRORREPORT(s32Error, WILC_FAIL); @@ -4203,7 +4203,7 @@ static WILC_Sint32 Handle_AddBASession(void *drvHandler, tstrHostIfBASessionInfo /* Group Buffer Timeout */ *ptr++ = 0; - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); if (s32Error) PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n"); @@ -4227,7 +4227,7 @@ static WILC_Sint32 Handle_AddBASession(void *drvHandler, tstrHostIfBASessionInfo *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF); /*Ack-Policy */ *ptr++ = 3; - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); if (strWID.ps8WidVal != NULL) WILC_FREE(strWID.ps8WidVal); @@ -4277,7 +4277,7 @@ static WILC_Sint32 Handle_DelBASession(void *drvHandler, tstrHostIfBASessionInfo /* Delba Reason */ *ptr++ = 32; /* Unspecific QOS reason */ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); if (s32Error) PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n"); @@ -4295,7 +4295,7 @@ static WILC_Sint32 Handle_DelBASession(void *drvHandler, tstrHostIfBASessionInfo /* TID*/ *ptr++ = strHostIfBASessionInfo->u8Ted; - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); if (strWID.ps8WidVal != NULL) WILC_FREE(strWID.ps8WidVal); @@ -4346,7 +4346,7 @@ static WILC_Sint32 Handle_DelAllRxBASessions(void *drvHandler, tstrHostIfBASessi /* Delba Reason */ *ptr++ = 32; /* Unspecific QOS reason */ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); if (s32Error) PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n"); @@ -4372,7 +4372,7 @@ static WILC_Sint32 Handle_DelAllRxBASessions(void *drvHandler, tstrHostIfBASessi */ static int hostIFthread(void *pvArg) { - WILC_Uint32 u32Ret; + u32 u32Ret; tstrHostIFmsg strHostIFmsg; tstrWILC_WFIDrv *pstrWFIDrv; @@ -4919,7 +4919,7 @@ WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8Ptk, u8 u8P tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; u8 u8KeyLen = u8PtkKeylen; - WILC_Uint32 i; + u32 i; if (pstrWFIDrv == NULL) { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); } @@ -5015,7 +5015,7 @@ WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8Ptk, u8 u8P * @version 1.0 */ WILC_Sint32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen, - u8 u8KeyIdx, WILC_Uint32 u32KeyRSClen, const u8 *KeyRSC, + u8 u8KeyIdx, u32 u32KeyRSClen, const u8 *KeyRSC, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode) { WILC_Sint32 s32Error = WILC_SUCCESS; @@ -5187,7 +5187,7 @@ WILC_Sint32 host_int_set_pmkid_info(WILC_WFIDrvHandle hWFIDrv, tstrHostIFpmkidAt WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; - WILC_Uint32 i; + u32 i; if (pstrWFIDrv == NULL) { @@ -5246,7 +5246,7 @@ WILC_Sint32 host_int_set_pmkid_info(WILC_WFIDrvHandle hWFIDrv, tstrHostIFpmkidAt * @version 1.0 */ WILC_Sint32 host_int_get_pmkid_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PmkidInfoArray, - WILC_Uint32 u32PmkidInfoLen) + u32 u32PmkidInfoLen) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWID; @@ -5427,7 +5427,7 @@ WILC_Sint32 host_int_get_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, #ifndef CONNECT_DIRECT WILC_Sint32 host_int_get_site_survey_results(WILC_WFIDrvHandle hWFIDrv, u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE], - WILC_Uint32 u32MaxSiteSrvyFragLen) + u32 u32MaxSiteSrvyFragLen) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID astrWIDList[2]; @@ -5443,7 +5443,7 @@ WILC_Sint32 host_int_get_site_survey_results(WILC_WFIDrvHandle hWFIDrv, astrWIDList[1].ps8WidVal = ppu8RcvdSiteSurveyResults[1]; astrWIDList[1].s32ValueSize = u32MaxSiteSrvyFragLen; - s32Error = SendConfigPkt(GET_CFG, astrWIDList, 2, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(GET_CFG, astrWIDList, 2, WILC_TRUE, (u32)pstrWFIDrv); /*get the value by searching the local copy*/ if (s32Error) { @@ -5766,7 +5766,7 @@ WILC_Sint32 host_int_disconnect_station(WILC_WFIDrvHandle hWFIDrv, u8 assoc_id) */ WILC_Sint32 host_int_get_assoc_req_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocReqInfo, - WILC_Uint32 u32AssocReqInfoLen) + u32 u32AssocReqInfoLen) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWID; @@ -5793,7 +5793,7 @@ WILC_Sint32 host_int_get_assoc_req_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocR * @version 1.0 */ WILC_Sint32 host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocRespInfo, - WILC_Uint32 u32MaxAssocRespInfoLen, WILC_Uint32 *pu32RcvdAssocRespInfoLen) + u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWID; @@ -5811,7 +5811,7 @@ WILC_Sint32 host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocR /* Sending Configuration packet */ - s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to send association response config packet\n"); *pu32RcvdAssocRespInfoLen = 0; @@ -5843,7 +5843,7 @@ WILC_Sint32 host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocR * @version 1.0 */ WILC_Sint32 host_int_get_rx_power_level(WILC_WFIDrvHandle hWFIDrv, u8 *pu8RxPowerLevel, - WILC_Uint32 u32RxPowerLevelLen) + u32 u32RxPowerLevelLen) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWID; @@ -5928,7 +5928,7 @@ WILC_Sint32 host_int_wait_msg_queue_idle(void) } -WILC_Sint32 host_int_set_wfi_drv_handler(WILC_Uint32 u32address) +WILC_Sint32 host_int_set_wfi_drv_handler(u32 u32address) { WILC_Sint32 s32Error = WILC_SUCCESS; @@ -5956,7 +5956,7 @@ WILC_Sint32 host_int_set_wfi_drv_handler(WILC_Uint32 u32address) -WILC_Sint32 host_int_set_operation_mode(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32mode) +WILC_Sint32 host_int_set_operation_mode(WILC_WFIDrvHandle hWFIDrv, u32 u32mode) { WILC_Sint32 s32Error = WILC_SUCCESS; @@ -6036,14 +6036,14 @@ WILC_Sint32 host_int_get_host_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ChNo) /** * @brief host_int_test_set_int_wid * @details Test function for setting wids - * @param[in,out] WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32TestMemAddr + * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr * @return Error code indicating success/failure * @note * @author zsalah * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_test_set_int_wid(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32TestMemAddr) +WILC_Sint32 host_int_test_set_int_wid(WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWID; @@ -6059,10 +6059,10 @@ WILC_Sint32 host_int_test_set_int_wid(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS; strWID.enuWIDtype = WID_INT; strWID.ps8WidVal = (WILC_Char *)&u32TestMemAddr; - strWID.s32ValueSize = sizeof(WILC_Uint32); + strWID.s32ValueSize = sizeof(u32); /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Test Function: Failed to set wid value\n"); WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); @@ -6090,7 +6090,7 @@ WILC_Sint32 host_int_test_set_int_wid(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32 * @date * @version 1.0 */ -WILC_Sint32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, const u8 *mac, WILC_Uint32 *pu32InactiveTime) +WILC_Sint32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, const u8 *mac, u32 *pu32InactiveTime) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -6129,14 +6129,14 @@ WILC_Sint32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, const u8 *mac, /** * @brief host_int_test_get_int_wid * @details Test function for getting wids - * @param[in,out] WILC_WFIDrvHandle hWFIDrv, WILC_Uint32* pu32TestMemAddr + * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr * @return Error code indicating success/failure * @note * @author zsalah * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_test_get_int_wid(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 *pu32TestMemAddr) +WILC_Sint32 host_int_test_get_int_wid(WILC_WFIDrvHandle hWFIDrv, u32 *pu32TestMemAddr) { WILC_Sint32 s32Error = WILC_SUCCESS; @@ -6152,9 +6152,9 @@ WILC_Sint32 host_int_test_get_int_wid(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 *pu strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS; strWID.enuWIDtype = WID_INT; strWID.ps8WidVal = (WILC_Sint8 *)pu32TestMemAddr; - strWID.s32ValueSize = sizeof(WILC_Uint32); + strWID.s32ValueSize = sizeof(u32); - s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv); + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); /*get the value by searching the local copy*/ if (s32Error) { PRINT_ER("Test Function: Failed to get wid value\n"); @@ -6590,9 +6590,9 @@ void host_int_send_network_info_to_host * @date 8 March 2012 * @version 1.0 */ -static WILC_Uint32 u32Intialized; -static WILC_Uint32 msgQ_created; -static WILC_Uint32 clients_count; +static u32 u32Intialized; +static u32 msgQ_created; +static u32 clients_count; WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) { @@ -6837,7 +6837,7 @@ WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv) WILC_TimerDestroy(&(pstrWFIDrv->hRemainOnChannel), NULL); #endif - host_int_set_wfi_drv_handler((WILC_Uint32)NULL); + host_int_set_wfi_drv_handler((u32)NULL); down(&hSemDeinitDrvHandle); @@ -6914,11 +6914,11 @@ WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv) * @date 1 Mar 2012 * @version 1.0 */ -void NetworkInfoReceived(u8 *pu8Buffer, WILC_Uint32 u32Length) +void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; - WILC_Uint32 drvHandler; + u32 drvHandler; tstrWILC_WFIDrv *pstrWFIDrv = NULL; drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24)); @@ -6964,11 +6964,11 @@ void NetworkInfoReceived(u8 *pu8Buffer, WILC_Uint32 u32Length) * @date 15 Mar 2012 * @version 1.0 */ -void GnrlAsyncInfoReceived(u8 *pu8Buffer, WILC_Uint32 u32Length) +void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; - WILC_Uint32 drvHandler; + u32 drvHandler; tstrWILC_WFIDrv *pstrWFIDrv = NULL; /*BugID_5348*/ @@ -7021,17 +7021,17 @@ void GnrlAsyncInfoReceived(u8 *pu8Buffer, WILC_Uint32 u32Length) /** * @brief host_int_ScanCompleteReceived * @details Setting scan complete received notifcation in message queue - * @param[in] u8* pu8Buffer, WILC_Uint32 u32Length + * @param[in] u8* pu8Buffer, u32 u32Length * @return Error code. * @author * @date * @version 1.0 */ -void host_int_ScanCompleteReceived(u8 *pu8Buffer, WILC_Uint32 u32Length) +void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; - WILC_Uint32 drvHandler; + u32 drvHandler; tstrWILC_WFIDrv *pstrWFIDrv = NULL; drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24)); pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -7087,7 +7087,7 @@ void host_int_ScanCompleteReceived(u8 *pu8Buffer, WILC_Uint32 u32Length) * @date * @version 1.0 */ -WILC_Sint32 host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32SessionID, WILC_Uint32 u32duration, u16 chan, tWILCpfRemainOnChanExpired RemainOnChanExpired, tWILCpfRemainOnChanReady RemainOnChanReady, void *pvUserArg) +WILC_Sint32 host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv, u32 u32SessionID, u32 u32duration, u16 chan, tWILCpfRemainOnChanExpired RemainOnChanExpired, tWILCpfRemainOnChanReady RemainOnChanReady, void *pvUserArg) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -7136,7 +7136,7 @@ WILC_Sint32 host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u3 * @date * @version 1.0 */ -WILC_Sint32 host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32SessionID) +WILC_Sint32 host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv, u32 u32SessionID) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -7226,18 +7226,18 @@ WILC_Sint32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, u16 u16FrameType, /** * @brief host_int_add_beacon * @details Setting add beacon params in message queue - * @param[in] WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32Interval, - * WILC_Uint32 u32DTIMPeriod,WILC_Uint32 u32HeadLen, u8* pu8Head, - * WILC_Uint32 u32TailLen, u8* pu8Tail + * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval, + * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head, + * u32 u32TailLen, u8* pu8Tail * @return Error code. * @author * @date * @version 1.0 */ -WILC_Sint32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32Interval, - WILC_Uint32 u32DTIMPeriod, - WILC_Uint32 u32HeadLen, u8 *pu8Head, - WILC_Uint32 u32TailLen, u8 *pu8Tail) +WILC_Sint32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, u32 u32Interval, + u32 u32DTIMPeriod, + u32 u32HeadLen, u8 *pu8Head, + u32 u32TailLen, u8 *pu8Tail) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -7445,7 +7445,7 @@ WILC_Sint32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][E tstrHostIFmsg strHostIFmsg; tstrHostIFDelAllSta *pstrDelAllStationMsg = &strHostIFmsg.uniHostIFmsgBody.strHostIFDelAllSta; u8 au8Zero_Buff[ETH_ALEN] = {0}; - WILC_Uint32 i; + u32 i; u8 u8AssocNumb = 0; @@ -7542,7 +7542,7 @@ WILC_Sint32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaPara #endif /*WILC_AP_EXTERNAL_MLME*/ uint32_t wilc_get_chipid(uint8_t); -WILC_Sint32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, WILC_Uint32 u32Timeout) +WILC_Sint32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, u32 u32Timeout) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -7578,7 +7578,7 @@ WILC_Sint32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnab return s32Error; } -WILC_Sint32 host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, WILC_Uint32 u32count) +WILC_Sint32 host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, u32 u32count) { WILC_Sint32 s32Error = WILC_SUCCESS; diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index c6ff07aa1df8..85eb3f40e9d0 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -62,9 +62,9 @@ #define IP_ALEN 4 -#define BIT2 ((WILC_Uint32)(1 << 2)) -#define BIT1 ((WILC_Uint32)(1 << 1)) -#define BIT0 ((WILC_Uint32)(1 << 0)) +#define BIT2 ((u32)(1 << 2)) +#define BIT1 ((u32)(1 << 1)) +#define BIT0 ((u32)(1 << 0)) #define AP_MODE 0x01 #define STATION_MODE 0x02 @@ -134,9 +134,9 @@ typedef struct { typedef struct _tstrStatistics { u8 u8LinkSpeed; WILC_Sint8 s8RSSI; - WILC_Uint32 u32TxCount; - WILC_Uint32 u32RxCount; - WILC_Uint32 u32TxFailureCount; + u32 u32TxCount; + u32 u32RxCount; + u32 u32TxFailureCount; } tstrStatistics; @@ -189,7 +189,7 @@ typedef enum { } CURRENT_TX_RATE_T; typedef struct { - WILC_Uint32 u32SetCfgFlag; + u32 u32SetCfgFlag; u8 ht_enable; u8 bss_type; u8 auth_type; @@ -271,11 +271,11 @@ typedef void (*tWILCpfConnectResult)(tenuConnDisconnEvent, void *); #ifdef WILC_P2P -typedef void (*tWILCpfRemainOnChanExpired)(void *, WILC_Uint32); /*Remain on channel expiration callback function*/ +typedef void (*tWILCpfRemainOnChanExpired)(void *, u32); /*Remain on channel expiration callback function*/ typedef void (*tWILCpfRemainOnChanReady)(void *); /*Remain on channel callback function*/ #endif -/* typedef WILC_Uint32 WILC_WFIDrvHandle; */ +/* typedef u32 WILC_WFIDrvHandle; */ typedef struct { WILC_Sint32 s32Dummy; } *WILC_WFIDrvHandle; @@ -292,7 +292,7 @@ typedef struct { */ typedef struct _tstrRcvdNetworkInfo { u8 *pu8Buffer; - WILC_Uint32 u32Length; + u32 u32Length; } tstrRcvdNetworkInfo; /*BugID_4156*/ @@ -316,7 +316,7 @@ typedef struct { /* User specific parameter to be delivered through the Scan User Callback function */ void *u32UserScanPvoid; - WILC_Uint32 u32RcvdChCount; + u32 u32RcvdChCount; tstrFoundNetworkInfo astrFoundNetworkInfo[MAX_NUM_SCANNED_NETWORKS]; } tstrWILC_UsrScanReq; @@ -336,11 +336,11 @@ typedef struct { } tstrWILC_UsrConnReq; typedef struct { - WILC_Uint32 u32Address; + u32 u32Address; } tstrHostIfSetDrvHandler; typedef struct { - WILC_Uint32 u32Mode; + u32 u32Mode; } tstrHostIfSetOperationMode; /*BugID_5077*/ @@ -364,11 +364,11 @@ typedef struct { #ifdef WILC_P2P typedef struct { u16 u16Channel; - WILC_Uint32 u32duration; + u32 u32duration; tWILCpfRemainOnChanExpired pRemainOnChanExpired; tWILCpfRemainOnChanReady pRemainOnChanReady; void *pVoid; - WILC_Uint32 u32ListenSessionID; + u32 u32ListenSessionID; } tstrHostIfRemainOnChan; typedef struct { @@ -415,7 +415,7 @@ typedef struct { /* WILC_Bool bPendingConnRequest; */ #ifndef CONNECT_DIRECT - WILC_Uint32 u32SurveyResultsCount; + u32 u32SurveyResultsCount; wid_site_survey_reslts_s astrSurveyResults[MAX_NUM_SCANNED_NETWORKS]; #endif @@ -470,7 +470,7 @@ typedef struct { u8 u8AmpduParams; u8 au8SuppMCsSet[16]; u16 u16HTExtParams; - WILC_Uint32 u32TxBeamformingCap; + u32 u32TxBeamformingCap; u8 u8ASELCap; u16 u16FlagsMask; /**/ u16 u16FlagsSet; /*oup.wlan_cfg_set(1, WID_SET_DRV_HANDLER, c_val, 4, 0, 0)) goto _fail_; @@ -1364,7 +1364,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, linux_wlan_t *p_n goto _fail_; c_val[0] = 1; /* Enable N with immediate block ack. */ - if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_IMMEDIATE_BA_ENABLED, c_val, 1, 1, (WILC_Uint32)pstrWFIDrv)) + if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_IMMEDIATE_BA_ENABLED, c_val, 1, 1, (u32)pstrWFIDrv)) goto _fail_; return 0; @@ -2100,7 +2100,7 @@ int mac_open(struct net_device *ndev) for (i = 0; i < g_linux_wlan->u8NoIfcs; i++) { if (ndev == g_linux_wlan->strInterfaceInfo[i].wilc_netdev) { memcpy(g_linux_wlan->strInterfaceInfo[i].aSrcAddress, mac_add, ETH_ALEN); - g_linux_wlan->strInterfaceInfo[i].drvHandler = (WILC_Uint32)priv->hWILCWFIDrv; + g_linux_wlan->strInterfaceInfo[i].drvHandler = (u32)priv->hWILCWFIDrv; break; } } @@ -2376,7 +2376,7 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) u8 *buff = NULL; WILC_Sint8 rssi; - WILC_Uint32 size = 0, length = 0; + u32 size = 0, length = 0; perInterface_wlan_t *nic; struct WILC_WFI_priv *priv; WILC_Sint32 s32Error = WILC_SUCCESS; diff --git a/drivers/staging/wilc1000/wilc_memory.c b/drivers/staging/wilc1000/wilc_memory.c index f44827528667..2282951eb574 100644 --- a/drivers/staging/wilc1000/wilc_memory.c +++ b/drivers/staging/wilc1000/wilc_memory.c @@ -6,8 +6,8 @@ * @date 18 Aug 2010 * @version 1.0 */ -void *WILC_MemoryAlloc(WILC_Uint32 u32Size, tstrWILC_MemoryAttrs *strAttrs, - WILC_Char *pcFileName, WILC_Uint32 u32LineNo) +void *WILC_MemoryAlloc(u32 u32Size, tstrWILC_MemoryAttrs *strAttrs, + WILC_Char *pcFileName, u32 u32LineNo) { if (u32Size > 0) { return kmalloc(u32Size, GFP_ATOMIC); @@ -21,8 +21,8 @@ void *WILC_MemoryAlloc(WILC_Uint32 u32Size, tstrWILC_MemoryAttrs *strAttrs, * @date 18 Aug 2010 * @version 1.0 */ -void *WILC_MemoryCalloc(WILC_Uint32 u32Size, tstrWILC_MemoryAttrs *strAttrs, - WILC_Char *pcFileName, WILC_Uint32 u32LineNo) +void *WILC_MemoryCalloc(u32 u32Size, tstrWILC_MemoryAttrs *strAttrs, + WILC_Char *pcFileName, u32 u32LineNo) { return kcalloc(u32Size, 1, GFP_KERNEL); } @@ -32,8 +32,8 @@ void *WILC_MemoryCalloc(WILC_Uint32 u32Size, tstrWILC_MemoryAttrs *strAttrs, * @date 18 Aug 2010 * @version 1.0 */ -void *WILC_MemoryRealloc(void *pvOldBlock, WILC_Uint32 u32NewSize, - tstrWILC_MemoryAttrs *strAttrs, WILC_Char *pcFileName, WILC_Uint32 u32LineNo) +void *WILC_MemoryRealloc(void *pvOldBlock, u32 u32NewSize, + tstrWILC_MemoryAttrs *strAttrs, WILC_Char *pcFileName, u32 u32LineNo) { if (u32NewSize == 0) { kfree(pvOldBlock); @@ -52,7 +52,7 @@ void *WILC_MemoryRealloc(void *pvOldBlock, WILC_Uint32 u32NewSize, * @version 1.0 */ void WILC_MemoryFree(const void *pvBlock, tstrWILC_MemoryAttrs *strAttrs, - WILC_Char *pcFileName, WILC_Uint32 u32LineNo) + WILC_Char *pcFileName, u32 u32LineNo) { kfree(pvBlock); } diff --git a/drivers/staging/wilc1000/wilc_memory.h b/drivers/staging/wilc1000/wilc_memory.h index 6f404ac272a1..8a2be8ae7739 100644 --- a/drivers/staging/wilc1000/wilc_memory.h +++ b/drivers/staging/wilc1000/wilc_memory.h @@ -41,8 +41,8 @@ typedef struct { * @date 16 Aug 2010 * @version 1.0 */ -void *WILC_MemoryAlloc(WILC_Uint32 u32Size, tstrWILC_MemoryAttrs *strAttrs, - WILC_Char *pcFileName, WILC_Uint32 u32LineNo); +void *WILC_MemoryAlloc(u32 u32Size, tstrWILC_MemoryAttrs *strAttrs, + WILC_Char *pcFileName, u32 u32LineNo); /*! * @brief Allocates a given size of bytes and zero filling it @@ -65,8 +65,8 @@ void *WILC_MemoryAlloc(WILC_Uint32 u32Size, tstrWILC_MemoryAttrs *strAttrs, * @date 16 Aug 2010 * @version 1.0 */ -void *WILC_MemoryCalloc(WILC_Uint32 u32Size, tstrWILC_MemoryAttrs *strAttrs, - WILC_Char *pcFileName, WILC_Uint32 u32LineNo); +void *WILC_MemoryCalloc(u32 u32Size, tstrWILC_MemoryAttrs *strAttrs, + WILC_Char *pcFileName, u32 u32LineNo); /*! * @brief Reallocates a given block to a new size @@ -93,8 +93,8 @@ void *WILC_MemoryCalloc(WILC_Uint32 u32Size, tstrWILC_MemoryAttrs *strAttrs, * @date 16 Aug 2010 * @version 1.0 */ -void *WILC_MemoryRealloc(void *pvOldBlock, WILC_Uint32 u32NewSize, - tstrWILC_MemoryAttrs *strAttrs, WILC_Char *pcFileName, WILC_Uint32 u32LineNo); +void *WILC_MemoryRealloc(void *pvOldBlock, u32 u32NewSize, + tstrWILC_MemoryAttrs *strAttrs, WILC_Char *pcFileName, u32 u32LineNo); /*! * @brief Frees given block @@ -114,7 +114,7 @@ void *WILC_MemoryRealloc(void *pvOldBlock, WILC_Uint32 u32NewSize, * @version 1.0 */ void WILC_MemoryFree(const void *pvBlock, tstrWILC_MemoryAttrs *strAttrs, - WILC_Char *pcFileName, WILC_Uint32 u32LineNo); + WILC_Char *pcFileName, u32 u32LineNo); /*! * @brief standrad malloc wrapper with custom attributes @@ -149,7 +149,7 @@ void WILC_MemoryFree(const void *pvBlock, tstrWILC_MemoryAttrs *strAttrs, */ #define WILC_NEW_EX(__struct_type__, __n_structs__, __attrs__) \ ((__struct_type__ *)WILC_MALLOC_EX( \ - sizeof(__struct_type__) * (WILC_Uint32)(__n_structs__), __attrs__)) + sizeof(__struct_type__) * (u32)(__n_structs__), __attrs__)) /*! * @brief Allocates a block (with custom attributes) of given type and number of @@ -157,7 +157,7 @@ void WILC_MemoryFree(const void *pvBlock, tstrWILC_MemoryAttrs *strAttrs, */ #define WILC_NEW_0_EX(__struct_type__, __n_structs__, __attrs__) \ ((__struct_type__ *)WILC_CALLOC_EX( \ - sizeof(__struct_type__) * (WILC_Uint32)(__n_structs__), __attrs__)) + sizeof(__struct_type__) * (u32)(__n_structs__), __attrs__)) /*! * @brief Frees a block (with custom attributes), also setting the original pointer diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c b/drivers/staging/wilc1000/wilc_msgqueue.c index ebbba8b24de0..8531bf1adb78 100644 --- a/drivers/staging/wilc1000/wilc_msgqueue.c +++ b/drivers/staging/wilc1000/wilc_msgqueue.c @@ -53,7 +53,7 @@ WILC_ErrNo WILC_MsgQueueDestroy(WILC_MsgQueueHandle *pHandle, * @version 1.0 */ WILC_ErrNo WILC_MsgQueueSend(WILC_MsgQueueHandle *pHandle, - const void *pvSendBuffer, WILC_Uint32 u32SendBufferSize, + const void *pvSendBuffer, u32 u32SendBufferSize, tstrWILC_MsgQueueAttrs *pstrAttrs) { WILC_ErrNo s32RetStatus = WILC_SUCCESS; @@ -118,8 +118,8 @@ WILC_ErrNo WILC_MsgQueueSend(WILC_MsgQueueHandle *pHandle, * @version 1.0 */ WILC_ErrNo WILC_MsgQueueRecv(WILC_MsgQueueHandle *pHandle, - void *pvRecvBuffer, WILC_Uint32 u32RecvBufferSize, - WILC_Uint32 *pu32ReceivedLength, + void *pvRecvBuffer, u32 u32RecvBufferSize, + u32 *pu32ReceivedLength, tstrWILC_MsgQueueAttrs *pstrAttrs) { diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h b/drivers/staging/wilc1000/wilc_msgqueue.h index d7e4b1ce3497..2ca02db95ee2 100644 --- a/drivers/staging/wilc1000/wilc_msgqueue.h +++ b/drivers/staging/wilc1000/wilc_msgqueue.h @@ -58,7 +58,7 @@ WILC_ErrNo WILC_MsgQueueCreate(WILC_MsgQueueHandle *pHandle, * @version 1.0 */ WILC_ErrNo WILC_MsgQueueSend(WILC_MsgQueueHandle *pHandle, - const void *pvSendBuffer, WILC_Uint32 u32SendBufferSize, + const void *pvSendBuffer, u32 u32SendBufferSize, tstrWILC_MsgQueueAttrs *pstrAttrs); @@ -80,8 +80,8 @@ WILC_ErrNo WILC_MsgQueueSend(WILC_MsgQueueHandle *pHandle, * @version 1.0 */ WILC_ErrNo WILC_MsgQueueRecv(WILC_MsgQueueHandle *pHandle, - void *pvRecvBuffer, WILC_Uint32 u32RecvBufferSize, - WILC_Uint32 *pu32ReceivedLength, + void *pvRecvBuffer, u32 u32RecvBufferSize, + u32 *pu32ReceivedLength, tstrWILC_MsgQueueAttrs *pstrAttrs); diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index 2e873b6942b6..964e818b24a8 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -14,7 +14,6 @@ #define WILC_OSW_INTERFACE_VER 2 /* Integer Types */ -typedef unsigned int WILC_Uint32; typedef unsigned long long WILC_Uint64; typedef signed char WILC_Sint8; typedef signed short WILC_Sint16; diff --git a/drivers/staging/wilc1000/wilc_platform.h b/drivers/staging/wilc1000/wilc_platform.h index ae42bbcbd5eb..e185eb32024b 100644 --- a/drivers/staging/wilc1000/wilc_platform.h +++ b/drivers/staging/wilc1000/wilc_platform.h @@ -23,7 +23,7 @@ typedef struct timer_list WILC_TimerHandle; /* Message Queue type is a structure */ typedef struct __Message_struct { void *pvBuffer; - WILC_Uint32 u32Length; + u32 u32Length; struct __Message_struct *pstrNext; } Message; @@ -31,7 +31,7 @@ typedef struct __MessageQueue_struct { struct semaphore hSem; spinlock_t strCriticalSection; WILC_Bool bExiting; - WILC_Uint32 u32ReceiversCount; + u32 u32ReceiversCount; Message *pstrMessageList; } WILC_MsgQueueHandle; diff --git a/drivers/staging/wilc1000/wilc_sleep.c b/drivers/staging/wilc1000/wilc_sleep.c index 98a079f3d6c9..569b833a71e9 100644 --- a/drivers/staging/wilc1000/wilc_sleep.c +++ b/drivers/staging/wilc1000/wilc_sleep.c @@ -6,10 +6,10 @@ * @date 10 Aug 2010 * @version 1.0 */ -void WILC_Sleep(WILC_Uint32 u32TimeMilliSec) +void WILC_Sleep(u32 u32TimeMilliSec) { if (u32TimeMilliSec <= 4000000) { - WILC_Uint32 u32Temp = u32TimeMilliSec * 1000; + u32 u32Temp = u32TimeMilliSec * 1000; usleep_range(u32Temp, u32Temp); } else { msleep(u32TimeMilliSec); diff --git a/drivers/staging/wilc1000/wilc_sleep.h b/drivers/staging/wilc1000/wilc_sleep.h index 2865c8e44346..261f4ede338c 100644 --- a/drivers/staging/wilc1000/wilc_sleep.h +++ b/drivers/staging/wilc1000/wilc_sleep.h @@ -12,6 +12,6 @@ * sleep, for accurate high resolution sleep use u32TimeMicoSec */ /* TODO: remove and open-code in callers */ -void WILC_Sleep(WILC_Uint32 u32TimeMilliSec); +void WILC_Sleep(u32 u32TimeMilliSec); #endif diff --git a/drivers/staging/wilc1000/wilc_strutils.c b/drivers/staging/wilc1000/wilc_strutils.c index c6af13cba543..52df793e0a37 100644 --- a/drivers/staging/wilc1000/wilc_strutils.c +++ b/drivers/staging/wilc1000/wilc_strutils.c @@ -9,7 +9,7 @@ * @date 18 Aug 2010 * @version 1.0 */ -WILC_Sint32 WILC_memcmp(const void *pvArg1, const void *pvArg2, WILC_Uint32 u32Count) +WILC_Sint32 WILC_memcmp(const void *pvArg1, const void *pvArg2, u32 u32Count) { return memcmp(pvArg1, pvArg2, u32Count); } @@ -20,7 +20,7 @@ WILC_Sint32 WILC_memcmp(const void *pvArg1, const void *pvArg2, WILC_Uint32 u32C * @date 18 Aug 2010 * @version 1.0 */ -void WILC_memcpy_INTERNAL(void *pvTarget, const void *pvSource, WILC_Uint32 u32Count) +void WILC_memcpy_INTERNAL(void *pvTarget, const void *pvSource, u32 u32Count) { memcpy(pvTarget, pvSource, u32Count); } @@ -30,7 +30,7 @@ void WILC_memcpy_INTERNAL(void *pvTarget, const void *pvSource, WILC_Uint32 u32C * @date 18 Aug 2010 * @version 1.0 */ -void *WILC_memset(void *pvTarget, u8 u8SetValue, WILC_Uint32 u32Count) +void *WILC_memset(void *pvTarget, u8 u8SetValue, u32 u32Count) { return memset(pvTarget, u8SetValue, u32Count); } @@ -41,13 +41,13 @@ void *WILC_memset(void *pvTarget, u8 u8SetValue, WILC_Uint32 u32Count) * @version 1.0 */ WILC_Char *WILC_strncpy(WILC_Char *pcTarget, const WILC_Char *pcSource, - WILC_Uint32 u32Count) + u32 u32Count) { return strncpy(pcTarget, pcSource, u32Count); } WILC_Sint32 WILC_strncmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2, - WILC_Uint32 u32Count) + u32 u32Count) { WILC_Sint32 s32Result; @@ -74,7 +74,7 @@ WILC_Sint32 WILC_strncmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2, * @date 18 Aug 2010 * @version 1.0 */ -WILC_Uint32 WILC_strlen(const WILC_Char *pcStr) +u32 WILC_strlen(const WILC_Char *pcStr) { - return (WILC_Uint32)strlen(pcStr); + return (u32)strlen(pcStr); } diff --git a/drivers/staging/wilc1000/wilc_strutils.h b/drivers/staging/wilc1000/wilc_strutils.h index ddc54ab21f67..6d9b400ecc18 100644 --- a/drivers/staging/wilc1000/wilc_strutils.h +++ b/drivers/staging/wilc1000/wilc_strutils.h @@ -22,7 +22,7 @@ * @date 18 Aug 2010 * @version 1.0 */ -WILC_Sint32 WILC_memcmp(const void *pvArg1, const void *pvArg2, WILC_Uint32 u32Count); +WILC_Sint32 WILC_memcmp(const void *pvArg1, const void *pvArg2, u32 u32Count); /*! * @brief Internal implementation for memory copy @@ -34,7 +34,7 @@ WILC_Sint32 WILC_memcmp(const void *pvArg1, const void *pvArg2, WILC_Uint32 u32C * @date 18 Aug 2010 * @version 1.0 */ -void WILC_memcpy_INTERNAL(void *pvTarget, const void *pvSource, WILC_Uint32 u32Count); +void WILC_memcpy_INTERNAL(void *pvTarget, const void *pvSource, u32 u32Count); /*! * @brief Copies the contents of a memory buffer into another @@ -50,7 +50,7 @@ void WILC_memcpy_INTERNAL(void *pvTarget, const void *pvSource, WILC_Uint32 u32C * @date 18 Aug 2010 * @version 1.0 */ -static WILC_ErrNo WILC_memcpy(void *pvTarget, const void *pvSource, WILC_Uint32 u32Count) +static WILC_ErrNo WILC_memcpy(void *pvTarget, const void *pvSource, u32 u32Count) { if ( (((u8 *)pvTarget <= (u8 *)pvSource) @@ -78,7 +78,7 @@ static WILC_ErrNo WILC_memcpy(void *pvTarget, const void *pvSource, WILC_Uint32 * @date 18 Aug 2010 * @version 1.0 */ -void *WILC_memset(void *pvTarget, u8 u8SetValue, WILC_Uint32 u32Count); +void *WILC_memset(void *pvTarget, u8 u8SetValue, u32 u32Count); /*! * @brief copies the contents of source string into the target string @@ -93,7 +93,7 @@ void *WILC_memset(void *pvTarget, u8 u8SetValue, WILC_Uint32 u32Count); * @version 1.0 */ WILC_Char *WILC_strncpy(WILC_Char *pcTarget, const WILC_Char *pcSource, - WILC_Uint32 u32Count); + u32 u32Count); /*! * @brief Compares two strings up to u32Count characters @@ -114,7 +114,7 @@ WILC_Char *WILC_strncpy(WILC_Char *pcTarget, const WILC_Char *pcSource, * @version 1.0 */ WILC_Sint32 WILC_strncmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2, - WILC_Uint32 u32Count); + u32 u32Count); /*! * @brief gets the length of a string @@ -125,6 +125,6 @@ WILC_Sint32 WILC_strncmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2, * @date 18 Aug 2010 * @version 1.0 */ -WILC_Uint32 WILC_strlen(const WILC_Char *pcStr); +u32 WILC_strlen(const WILC_Char *pcStr); #endif diff --git a/drivers/staging/wilc1000/wilc_timer.c b/drivers/staging/wilc1000/wilc_timer.c index 7d2e6f19c00b..c31bf0c5e590 100644 --- a/drivers/staging/wilc1000/wilc_timer.c +++ b/drivers/staging/wilc1000/wilc_timer.c @@ -23,7 +23,7 @@ WILC_ErrNo WILC_TimerDestroy(WILC_TimerHandle *pHandle, } -WILC_ErrNo WILC_TimerStart(WILC_TimerHandle *pHandle, WILC_Uint32 u32Timeout, +WILC_ErrNo WILC_TimerStart(WILC_TimerHandle *pHandle, u32 u32Timeout, void *pvArg, tstrWILC_TimerAttrs *pstrAttrs) { WILC_ErrNo s32RetStatus = WILC_FAIL; diff --git a/drivers/staging/wilc1000/wilc_timer.h b/drivers/staging/wilc1000/wilc_timer.h index 72b27155293e..72efa85ade2d 100644 --- a/drivers/staging/wilc1000/wilc_timer.h +++ b/drivers/staging/wilc1000/wilc_timer.h @@ -96,7 +96,7 @@ WILC_ErrNo WILC_TimerDestroy(WILC_TimerHandle *pHandle, * @date 16 Aug 2010 * @version 1.0 */ -WILC_ErrNo WILC_TimerStart(WILC_TimerHandle *pHandle, WILC_Uint32 u32Timeout, void *pvArg, +WILC_ErrNo WILC_TimerStart(WILC_TimerHandle *pHandle, u32 u32Timeout, void *pvArg, tstrWILC_TimerAttrs *pstrAttrs); diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index a2047e3b6050..f330876e465b 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -31,7 +31,7 @@ extern int mac_open(struct net_device *ndev); extern int mac_close(struct net_device *ndev); tstrNetworkInfo astrLastScannedNtwrksShadow[MAX_NUM_SCANNED_NETWORKS_SHADOW]; -WILC_Uint32 u32LastScannedNtwrksCountShadow; +u32 u32LastScannedNtwrksCountShadow; #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP WILC_TimerHandle hDuringIpTimer; #endif @@ -438,7 +438,7 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo PRINT_ER("Discovered networks exceeded the max limit\n"); } } else { - WILC_Uint32 i; + u32 i; /* So this network is discovered before, we'll just update its RSSI */ for (i = 0; i < priv->u32RcvdChCount; i++) { if (WILC_memcmp(astrLastScannedNtwrksShadow[i].au8bssid, pstrNetworkInfo->au8bssid, 6) == 0) { @@ -509,7 +509,7 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo */ int WILC_WFI_Set_PMKSA(u8 *bssid, struct WILC_WFI_priv *priv) { - WILC_Uint32 i; + u32 i; WILC_Sint32 s32Error = WILC_SUCCESS; @@ -600,7 +600,7 @@ static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent, if (u16ConnectStatus == WLAN_STATUS_SUCCESS) { WILC_Bool bNeedScanRefresh = WILC_FALSE; - WILC_Uint32 i; + u32 i; PRINT_INFO(CFG80211_DBG, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo->au8bssid[0], pstrConnectInfo->au8bssid[1], pstrConnectInfo->au8bssid[2], pstrConnectInfo->au8bssid[3], pstrConnectInfo->au8bssid[4], pstrConnectInfo->au8bssid[5]); @@ -699,7 +699,7 @@ static int WILC_WFI_CfgSetChannel(struct wiphy *wiphy, struct cfg80211_chan_def *chandef) { - WILC_Uint32 channelnum = 0; + u32 channelnum = 0; struct WILC_WFI_priv *priv; WILC_Sint32 s32Error = WILC_SUCCESS; priv = wiphy_priv(wiphy); @@ -736,7 +736,7 @@ static int WILC_WFI_CfgSetChannel(struct wiphy *wiphy, static int WILC_WFI_CfgScan(struct wiphy *wiphy, struct cfg80211_scan_request *request) { struct WILC_WFI_priv *priv; - WILC_Uint32 i; + u32 i; WILC_Sint32 s32Error = WILC_SUCCESS; u8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS]; tstrHiddenNetwork strHiddenNetwork; @@ -747,7 +747,7 @@ static int WILC_WFI_CfgScan(struct wiphy *wiphy, struct cfg80211_scan_request *r priv->u32RcvdChCount = 0; - host_int_set_wfi_drv_handler((WILC_Uint32)priv->hWILCWFIDrv); + host_int_set_wfi_drv_handler((u32)priv->hWILCWFIDrv); reset_shadow_found(priv); @@ -826,7 +826,7 @@ static int WILC_WFI_CfgConnect(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_connect_params *sme) { WILC_Sint32 s32Error = WILC_SUCCESS; - WILC_Uint32 i; + u32 i; u8 u8security = NO_ENCRYPT; AUTHTYPE_T tenuAuth_type = ANY; WILC_Char *pcgroup_encrypt_val = NULL; @@ -842,7 +842,7 @@ static int WILC_WFI_CfgConnect(struct wiphy *wiphy, struct net_device *dev, priv = wiphy_priv(wiphy); pstrWFIDrv = (tstrWILC_WFIDrv *)(priv->hWILCWFIDrv); - host_int_set_wfi_drv_handler((WILC_Uint32)priv->hWILCWFIDrv); + host_int_set_wfi_drv_handler((u32)priv->hWILCWFIDrv); PRINT_D(CFG80211_DBG, "Connecting to SSID [%s] on netdev [%p] host if [%p]\n", sme->ssid, dev, priv->hWILCWFIDrv); #ifdef WILC_P2P @@ -1131,7 +1131,7 @@ static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 k { WILC_Sint32 s32Error = WILC_SUCCESS, KeyLen = params->key_len; - WILC_Uint32 i; + u32 i; struct WILC_WFI_priv *priv; const u8 *pu8RxMic = NULL; const u8 *pu8TxMic = NULL; @@ -1538,7 +1538,7 @@ static int WILC_WFI_get_key(struct wiphy *wiphy, struct net_device *netdev, u8 k struct WILC_WFI_priv *priv; struct key_params key_params; - WILC_Uint32 i; + u32 i; priv = wiphy_priv(wiphy); @@ -1641,9 +1641,9 @@ static int WILC_WFI_get_station(struct wiphy *wiphy, struct net_device *dev, struct WILC_WFI_priv *priv; perInterface_wlan_t *nic; #ifdef WILC_AP_EXTERNAL_MLME - WILC_Uint32 i = 0; - WILC_Uint32 associatedsta = 0; - WILC_Uint32 inactive_time = 0; + u32 i = 0; + u32 associatedsta = 0; + u32 inactive_time = 0; #endif priv = wiphy_priv(wiphy); nic = netdev_priv(dev); @@ -1899,7 +1899,7 @@ static int WILC_WFI_set_bitrate_mask(struct wiphy *wiphy, static int WILC_WFI_set_pmksa(struct wiphy *wiphy, struct net_device *netdev, struct cfg80211_pmksa *pmksa) { - WILC_Uint32 i; + u32 i; WILC_Sint32 s32Error = WILC_SUCCESS; u8 flag = 0; @@ -1950,7 +1950,7 @@ static int WILC_WFI_del_pmksa(struct wiphy *wiphy, struct net_device *netdev, struct cfg80211_pmksa *pmksa) { - WILC_Uint32 i; + u32 i; u8 flag = 0; WILC_Sint32 s32Error = WILC_SUCCESS; @@ -2023,10 +2023,10 @@ static int WILC_WFI_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) * @version */ -void WILC_WFI_CfgParseRxAction(u8 *buf, WILC_Uint32 len) +void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len) { - WILC_Uint32 index = 0; - WILC_Uint32 i = 0, j = 0; + u32 index = 0; + u32 i = 0, j = 0; /*BugID_5460*/ #ifdef USE_SUPPLICANT_GO_INTENT @@ -2119,10 +2119,10 @@ void WILC_WFI_CfgParseRxAction(u8 *buf, WILC_Uint32 len) * @date 12 DEC 2012 * @version */ -void WILC_WFI_CfgParseTxAction(u8 *buf, WILC_Uint32 len, WILC_Bool bOperChan, u8 iftype) +void WILC_WFI_CfgParseTxAction(u8 *buf, u32 len, WILC_Bool bOperChan, u8 iftype) { - WILC_Uint32 index = 0; - WILC_Uint32 i = 0, j = 0; + u32 index = 0; + u32 i = 0, j = 0; u8 op_channel_attr_index = 0; u8 channel_list_attr_index = 0; @@ -2210,9 +2210,9 @@ void WILC_WFI_p2p_rx (struct net_device *dev, uint8_t *buff, uint32_t size) { struct WILC_WFI_priv *priv; - WILC_Uint32 header, pkt_offset; + u32 header, pkt_offset; tstrWILC_WFIDrv *pstrWFIDrv; - WILC_Uint32 i = 0; + u32 i = 0; WILC_Sint32 s32Freq; priv = wiphy_priv(dev->ieee80211_ptr->wiphy); pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv; @@ -2372,7 +2372,7 @@ static void WILC_WFI_RemainOnChannelReady(void *pUserVoid) * @version */ -static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, WILC_Uint32 u32SessionID) +static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, u32 u32SessionID) { struct WILC_WFI_priv *priv; priv = (struct WILC_WFI_priv *)pUserVoid; @@ -2513,9 +2513,9 @@ int WILC_WFI_mgmt_tx(struct wiphy *wiphy, struct WILC_WFI_priv *priv; WILC_Sint32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv; - WILC_Uint32 i; + u32 i; perInterface_wlan_t *nic; - WILC_Uint32 buf_len = len + sizeof(u8P2P_vendorspec) + sizeof(u8P2Plocalrandom); + u32 buf_len = len + sizeof(u8P2P_vendorspec) + sizeof(u8P2Plocalrandom); nic = netdev_priv(wdev->netdev); priv = wiphy_priv(wiphy); diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index d07216a237a0..108d4533c4e4 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -117,9 +117,9 @@ struct sta_info { struct wilc_wfi_p2pListenParams { struct ieee80211_channel *pstrListenChan; enum nl80211_channel_type tenuChannelType; - WILC_Uint32 u32ListenDuration; + u32 u32ListenDuration; WILC_Uint64 u64ListenCookie; - WILC_Uint32 u32ListenSessionID; + u32 u32ListenSessionID; }; #endif /*WILC_P2P*/ @@ -135,7 +135,7 @@ struct WILC_WFI_priv { #endif WILC_Bool bCfgScanning; - WILC_Uint32 u32RcvdChCount; + u32 u32RcvdChCount; diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index 2a015e8e7038..a456d0d140c1 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -852,7 +852,7 @@ INLINE void chip_wakeup(void) genuChipPSstate = CHIP_WAKEDUP; } #endif -void chip_sleep_manually(WILC_Uint32 u32SleepTime) +void chip_sleep_manually(u32 u32SleepTime) { if (genuChipPSstate != CHIP_WAKEDUP) { /* chip is already sleeping. Do nothing */ @@ -1869,7 +1869,7 @@ static int wilc_wlan_cfg_commit(int type, uint32_t drvHandler) wilc_cfg_frame_t *cfg = &p->cfg_frame; int total_len = p->cfg_frame_offset + 4 + DRIVER_HANDLER_SIZE; int seq_no = p->cfg_seq_no % 256; - int driver_handler = (WILC_Uint32)drvHandler; + int driver_handler = (u32)drvHandler; /** @@ -2328,7 +2328,7 @@ _fail_: u16 Set_machw_change_vir_if(WILC_Bool bValue) { u16 ret; - WILC_Uint32 reg; + u32 reg; /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/ (&g_wlan)->os_func.os_enter_cs((&g_wlan)->hif_lock); diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.c b/drivers/staging/wilc1000/wilc_wlan_cfg.c index a627c5870960..d7e7e92536f6 100644 --- a/drivers/staging/wilc1000/wilc_wlan_cfg.c +++ b/drivers/staging/wilc1000/wilc_wlan_cfg.c @@ -541,7 +541,7 @@ static int wilc_wlan_cfg_indicate_rx(uint8_t *frame, int size, wilc_cfg_rsp_t *r uint8_t msg_id; uint16_t msg_len; #ifdef WILC_FULLY_HOSTING_AP - WILC_Uint32 *ptru32Frame; + u32 *ptru32Frame; WILC_Bool bStatus = frame[2]; #ifdef BIG_ENDIAN diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h index dd86ca7dd3f3..ea0ec412b907 100644 --- a/drivers/staging/wilc1000/wilc_wlan_if.h +++ b/drivers/staging/wilc1000/wilc_wlan_if.h @@ -92,7 +92,7 @@ typedef struct { void (*os_free)(void *); void (*os_lock)(void *); void (*os_unlock)(void *); - int (*os_wait)(void *, WILC_Uint32); + int (*os_wait)(void *, u32); void (*os_signal)(void *); void (*os_enter_cs)(void *); void (*os_leave_cs)(void *); @@ -238,7 +238,7 @@ typedef struct { #define MAX_SSID_LEN 33 #define MAX_RATES_SUPPORTED 12 -#define INFINITE_SLEEP_TIME ((WILC_Uint32)0xFFFFFFFF) +#define INFINITE_SLEEP_TIME ((u32)0xFFFFFFFF) #ifdef WILC_PARSE_SCAN_IN_HOST typedef enum { From 57b298f54e7573df71eff677c9f6cce085c153e3 Mon Sep 17 00:00:00 2001 From: Chaehyun Lim Date: Thu, 11 Jun 2015 14:35:56 +0900 Subject: [PATCH 0921/1163] staging: wilc1000: remove WILC_Uint64 Use u64 instead of WILC_Uint64. Signed-off-by: Chaehyun Lim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 2 +- drivers/staging/wilc1000/coreconfigurator.h | 2 +- drivers/staging/wilc1000/host_interface.h | 2 +- drivers/staging/wilc1000/wilc_oswrapper.h | 1 - drivers/staging/wilc1000/wilc_wfi_netdevice.h | 4 ++-- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index 2bb513dde065..0a030806844a 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -839,7 +839,7 @@ WILC_Sint32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInf u32Tsf_Lo = get_beacon_timestamp_lo(pu8msa); u32Tsf_Hi = get_beacon_timestamp_hi(pu8msa); - pstrNetworkInfo->u64Tsf = u32Tsf_Lo | ((WILC_Uint64)u32Tsf_Hi << 32); + pstrNetworkInfo->u64Tsf = u32Tsf_Lo | ((u64)u32Tsf_Hi << 32); /* Get SSID */ get_ssid(pu8msa, pstrNetworkInfo->au8ssid, &(pstrNetworkInfo->u8SsidLen)); diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h index c2a6d5b00bf7..6d16bba79902 100644 --- a/drivers/staging/wilc1000/coreconfigurator.h +++ b/drivers/staging/wilc1000/coreconfigurator.h @@ -429,7 +429,7 @@ typedef struct { u16 u16IEsLen; void *pJoinParams; tstrRSSI strRssi; - WILC_Uint64 u64Tsf; /* time-stamp [Low and High 64 bit] */ + u64 u64Tsf; /* time-stamp [Low and High 64 bit] */ } tstrNetworkInfo; /* This structure is used to support parsing of the received Association Response frame */ diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 85eb3f40e9d0..a75efbfb1929 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -406,7 +406,7 @@ typedef struct { /*Remain on channel struvture*/ tstrHostIfRemainOnChan strHostIfRemainOnChan; u8 u8RemainOnChan_pendingreq; - WILC_Uint64 u64P2p_MgmtTimeout; + u64 u64P2p_MgmtTimeout; u8 u8P2PConnect; #endif diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index 964e818b24a8..3af48da5751d 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -14,7 +14,6 @@ #define WILC_OSW_INTERFACE_VER 2 /* Integer Types */ -typedef unsigned long long WILC_Uint64; typedef signed char WILC_Sint8; typedef signed short WILC_Sint16; typedef signed int WILC_Sint32; diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 108d4533c4e4..10e6b1a22fd6 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -118,7 +118,7 @@ struct wilc_wfi_p2pListenParams { struct ieee80211_channel *pstrListenChan; enum nl80211_channel_type tenuChannelType; u32 u32ListenDuration; - WILC_Uint64 u64ListenCookie; + u64 u64ListenCookie; u32 u32ListenSessionID; }; @@ -130,7 +130,7 @@ struct WILC_WFI_priv { #ifdef WILC_P2P struct wilc_wfi_p2pListenParams strRemainOnChanParams; - WILC_Uint64 u64tx_cookie; + u64 u64tx_cookie; #endif From ca356ada7cf4668bf3eaa65a6a25671f185c2229 Mon Sep 17 00:00:00 2001 From: Chaehyun Lim Date: Thu, 11 Jun 2015 14:35:57 +0900 Subject: [PATCH 0922/1163] staging: wilc1000: remove WILC_Sint8 Use s8 instead of WILC_Sint8. Signed-off-by: Chaehyun Lim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 18 +-- drivers/staging/wilc1000/coreconfigurator.h | 8 +- drivers/staging/wilc1000/host_interface.c | 148 ++++++++++---------- drivers/staging/wilc1000/host_interface.h | 12 +- drivers/staging/wilc1000/linux_wlan.c | 2 +- drivers/staging/wilc1000/wilc_oswrapper.h | 1 - 6 files changed, 94 insertions(+), 95 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index 0a030806844a..f51bfa48028e 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -158,7 +158,7 @@ typedef struct { /*****************************************************************************/ /* Extern Function Declarations */ /*****************************************************************************/ -extern WILC_Sint32 SendRawPacket(WILC_Sint8 *ps8Packet, WILC_Sint32 s32PacketLen); +extern WILC_Sint32 SendRawPacket(s8 *ps8Packet, WILC_Sint32 s32PacketLen); extern void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length); extern void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length); extern void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length); @@ -168,7 +168,7 @@ extern void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length); static struct semaphore SemHandleSendPkt; static struct semaphore SemHandlePktResp; -static WILC_Sint8 *gps8ConfigPacket; +static s8 *gps8ConfigPacket; static tstrConfigPktInfo gstrConfigPktInfo; @@ -678,7 +678,7 @@ WILC_Sint32 CoreConfiguratorInit(void) sema_init(&SemHandleSendPkt, 1); sema_init(&SemHandlePktResp, 0); - gps8ConfigPacket = (WILC_Sint8 *)WILC_MALLOC(MAX_PACKET_BUFF_SIZE); + gps8ConfigPacket = (s8 *)WILC_MALLOC(MAX_PACKET_BUFF_SIZE); if (gps8ConfigPacket == NULL) { PRINT_ER("failed in gps8ConfigPacket allocation\n"); s32Error = WILC_NO_MEM; @@ -1097,7 +1097,7 @@ WILC_Sint32 DeallocateSurveyResults(wid_site_survey_reslts_s *pstrSurveyResults) /*****************************************************************************/ void ProcessCharWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, - tstrWID *pstrWID, WILC_Sint8 *ps8WidVal) + tstrWID *pstrWID, s8 *ps8WidVal) { u8 *pu8val = (u8 *)ps8WidVal; u8 u8val = 0; @@ -1151,7 +1151,7 @@ void ProcessCharWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, /*****************************************************************************/ void ProcessShortWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, - tstrWID *pstrWID, WILC_Sint8 *ps8WidVal) + tstrWID *pstrWID, s8 *ps8WidVal) { u16 *pu16val = (u16 *)ps8WidVal; u16 u16val = 0; @@ -1206,7 +1206,7 @@ void ProcessShortWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, /*****************************************************************************/ void ProcessIntWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, - tstrWID *pstrWID, WILC_Sint8 *ps8WidVal) + tstrWID *pstrWID, s8 *ps8WidVal) { u32 *pu32val = (u32 *)ps8WidVal; u32 u32val = 0; @@ -1551,7 +1551,7 @@ WILC_Sint32 further_process_response(u8 *resp, u16 *pu16val = (u16 *)(pstrWIDresult->ps8WidVal); cfg_sht = MAKE_WORD16(resp[idx], resp[idx + 1]); /*Set local copy of WID*/ - /* pstrWIDresult->ps8WidVal = (WILC_Sint8*)(WILC_Sint32)cfg_sht; */ + /* pstrWIDresult->ps8WidVal = (s8*)(WILC_Sint32)cfg_sht; */ *pu16val = cfg_sht; break; } @@ -1564,7 +1564,7 @@ WILC_Sint32 further_process_response(u8 *resp, MAKE_WORD16(resp[idx + 2], resp[idx + 3]) ); /*Set local copy of WID*/ - /* pstrWIDresult->ps8WidVal = (WILC_Sint8*)cfg_int; */ + /* pstrWIDresult->ps8WidVal = (s8*)cfg_int; */ *pu32val = cfg_int; break; } @@ -1857,7 +1857,7 @@ WILC_Sint32 CreatePacketHeader(WILC_Char *pcpacket, WILC_Sint32 *ps32PacketLengt * @version 1.0 */ -WILC_Sint32 CreateConfigPacket(WILC_Sint8 *ps8packet, WILC_Sint32 *ps32PacketLength, +WILC_Sint32 CreateConfigPacket(s8 *ps8packet, WILC_Sint32 *ps32PacketLength, tstrWID *pstrWIDs, u32 u32WIDsCount) { WILC_Sint32 s32Error = WILC_SUCCESS; diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h index 6d16bba79902..44941cdbd3e2 100644 --- a/drivers/staging/wilc1000/coreconfigurator.h +++ b/drivers/staging/wilc1000/coreconfigurator.h @@ -397,18 +397,18 @@ typedef struct { u16 u16WIDid; tenuWIDtype enuWIDtype; WILC_Sint32 s32ValueSize; - WILC_Sint8 *ps8WidVal; + s8 *ps8WidVal; } tstrWID; typedef struct { u8 u8Full; u8 u8Index; - WILC_Sint8 as8RSSI[NUM_RSSI]; + s8 as8RSSI[NUM_RSSI]; } tstrRSSI; /* This structure is used to support parsing of the received 'N' message */ typedef struct { - WILC_Sint8 s8rssi; + s8 s8rssi; u16 u16CapInfo; u8 au8ssid[MAX_SSID_LEN]; u8 u8SsidLen; @@ -490,7 +490,7 @@ extern WILC_Sint32 ParseSurveyResults(u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_ extern WILC_Sint32 DeallocateSurveyResults(wid_site_survey_reslts_s *pstrSurveyResults); #endif -extern WILC_Sint32 SendRawPacket(WILC_Sint8 *pspacket, WILC_Sint32 s32PacketLen); +extern WILC_Sint32 SendRawPacket(s8 *pspacket, WILC_Sint32 s32PacketLen); extern void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length); void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length); void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length); diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 75effdb22a02..ce8e5b36b398 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -564,8 +564,8 @@ static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE]; WILC_Bool gbScanWhileConnected = WILC_FALSE; -static WILC_Sint8 gs8Rssi; -static WILC_Sint8 gs8lnkspd; +static s8 gs8Rssi; +static s8 gs8lnkspd; static u8 gu8Chnl; static u8 gs8SetIP[2][4]; static u8 gs8GetIP[2][4]; @@ -654,7 +654,7 @@ static WILC_Sint32 Handle_SetWfiDrvHandler(tstrHostIfSetDrvHandler *pstrHostIfSe /*prepare configuration packet*/ strWID.u16WIDid = (u16)WID_SET_DRV_HANDLER; strWID.enuWIDtype = WID_INT; - strWID.ps8WidVal = (WILC_Sint8 *)&(pstrHostIfSetDrvHandler->u32Address); + strWID.ps8WidVal = (s8 *)&(pstrHostIfSetDrvHandler->u32Address); strWID.s32ValueSize = sizeof(u32); /*Sending Cfg*/ @@ -699,7 +699,7 @@ static WILC_Sint32 Handle_SetOperationMode(void *drvHandler, tstrHostIfSetOperat /*prepare configuration packet*/ strWID.u16WIDid = (u16)WID_SET_OPERATION_MODE; strWID.enuWIDtype = WID_INT; - strWID.ps8WidVal = (WILC_Sint8 *)&(pstrHostIfSetOperationMode->u32Mode); + strWID.ps8WidVal = (s8 *)&(pstrHostIfSetOperationMode->u32Mode); strWID.s32ValueSize = sizeof(u32); /*Sending Cfg*/ @@ -943,7 +943,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str /* validate input then copy>> need to check value 4 and 5 */ if (strHostIFCfgParamAttr->pstrCfgParamVal.bss_type < 6) { strWIDList[u8WidCnt].u16WIDid = WID_BSS_TYPE; - strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type; + strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type; strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); pstrWFIDrv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type; @@ -961,7 +961,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str /*validate Possible values*/ if ((strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 1 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 2 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 5) { strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TYPE; - strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type; + strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type; strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); pstrWFIDrv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type; @@ -974,7 +974,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str /* range is 1 to 65535. */ if (strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout < 65536) { strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TIMEOUT; - strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout; + strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout; strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); pstrWFIDrv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout; @@ -993,7 +993,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str /*----------------------------------------------------------*/ if (strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode < 5) { strWIDList[u8WidCnt].u16WIDid = WID_POWER_MANAGEMENT; - strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode; + strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode; strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); pstrWFIDrv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode; @@ -1006,7 +1006,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str /* range from 1 to 256 */ if ((strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit < 256)) { strWIDList[u8WidCnt].u16WIDid = WID_SHORT_RETRY_LIMIT; - strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit; + strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit; strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); pstrWFIDrv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit; @@ -1019,7 +1019,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str /* range from 1 to 256 */ if ((strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit < 256)) { strWIDList[u8WidCnt].u16WIDid = WID_LONG_RETRY_LIMIT; - strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit; + strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit; strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); @@ -1033,7 +1033,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str if (strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold < 7937) { strWIDList[u8WidCnt].u16WIDid = WID_FRAG_THRESHOLD; - strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold; + strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold; strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); pstrWFIDrv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold; @@ -1046,7 +1046,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str /* range 256 to 65535 */ if (strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold < 65536) { strWIDList[u8WidCnt].u16WIDid = WID_RTS_THRESHOLD; - strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold; + strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold; strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); pstrWFIDrv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold; @@ -1063,7 +1063,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str /*------------------------------------------------------*/ if (strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type < 3) { strWIDList[u8WidCnt].u16WIDid = WID_PREAMBLE; - strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type; + strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type; strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); pstrWFIDrv->strCfgValues.preamble_type = strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type; @@ -1075,7 +1075,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SHORT_SLOT_ALLOWED) { if (strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed < 2) { strWIDList[u8WidCnt].u16WIDid = WID_SHORT_SLOT_ALLOWED; - strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed; + strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed; strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); pstrWFIDrv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed; @@ -1091,7 +1091,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str /*Input Values: 1 for enable and 0 for disable. */ if (strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled < 2) { strWIDList[u8WidCnt].u16WIDid = WID_11N_TXOP_PROT_DISABLE; - strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled; + strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled; strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); pstrWFIDrv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled; @@ -1104,7 +1104,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str /* range is 1 to 65535. */ if (strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval < 65536) { strWIDList[u8WidCnt].u16WIDid = WID_BEACON_INTERVAL; - strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval; + strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval; strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); pstrWFIDrv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval; @@ -1117,7 +1117,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str /* range is 1 to 255. */ if (strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period < 256) { strWIDList[u8WidCnt].u16WIDid = WID_DTIM_PERIOD; - strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period; + strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period; strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); pstrWFIDrv->strCfgValues.dtim_period = strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period; @@ -1134,7 +1134,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str /*----------------------------------------------------------------------*/ if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled < 3) { strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY; - strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled; + strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled; strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); pstrWFIDrv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled; @@ -1147,7 +1147,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str /* range is 1 to 65535. */ if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time < 65536) { strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY_SCAN_TIME; - strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time; + strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time; strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); pstrWFIDrv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time; @@ -1160,7 +1160,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str /* range is 1 to 65535. */ if (strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time < 65536) { strWIDList[u8WidCnt].u16WIDid = WID_ACTIVE_SCAN_TIME; - strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time; + strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time; strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); pstrWFIDrv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time; @@ -1173,7 +1173,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str /* range is 1 to 65535. */ if (strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time < 65536) { strWIDList[u8WidCnt].u16WIDid = WID_PASSIVE_SCAN_TIME; - strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time; + strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time; strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); pstrWFIDrv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time; @@ -1196,7 +1196,7 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) { strWIDList[u8WidCnt].u16WIDid = WID_CURRENT_TX_RATE; - strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&curr_tx_rate; + strWIDList[u8WidCnt].ps8WidVal = (s8 *)&curr_tx_rate; strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); pstrWFIDrv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate; @@ -1334,7 +1334,7 @@ static WILC_Sint32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFs strWIDList[u32WidsCount].u16WIDid = WID_SCAN_TYPE; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); - strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFscanAttr->u8ScanType)); + strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanType)); u32WidsCount++; /*list of channels to be scanned*/ @@ -1360,7 +1360,7 @@ static WILC_Sint32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFs strWIDList[u32WidsCount].u16WIDid = WID_START_SCAN_REQ; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); - strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFscanAttr->u8ScanSource)); + strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanSource)); u32WidsCount++; /*keep the state as is , no need to change it*/ @@ -1446,7 +1446,7 @@ static WILC_Sint32 Handle_ScanDone(void *drvHandler, tenuScanEvent enuEvent) u8abort_running_scan = 1; strWID.u16WIDid = (u16)WID_ABORT_RUNNING_SCAN; strWID.enuWIDtype = WID_CHAR; - strWID.ps8WidVal = (WILC_Sint8 *)&u8abort_running_scan; + strWID.ps8WidVal = (s8 *)&u8abort_running_scan; strWID.s32ValueSize = sizeof(WILC_Char); /*Sending Cfg*/ @@ -1614,7 +1614,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); - strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security)); + strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security)); u32WidsCount++; PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security); @@ -1622,7 +1622,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); - strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type); + strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type); u32WidsCount++; PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type); @@ -1630,14 +1630,14 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK; * strWIDList[u32WidsCount].enuWIDtype = WID_STR; * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase); - * strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8*)(passphrase); + * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase); * u32WidsCount++; */ strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); - strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)&u8bssDscListIndex; + strWIDList[u32WidsCount].ps8WidVal = (s8 *)&u8bssDscListIndex; u32WidsCount++; #ifndef SIMULATION @@ -1723,19 +1723,19 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT; strWIDList[u32WidsCount].enuWIDtype = WID_INT; strWIDList[u32WidsCount].s32ValueSize = sizeof(u32); - strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(dummyval)); + strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval)); u32WidsCount++; strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT; strWIDList[u32WidsCount].enuWIDtype = WID_INT; strWIDList[u32WidsCount].s32ValueSize = sizeof(u32); - strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(dummyval)); + strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval)); u32WidsCount++; strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT; strWIDList[u32WidsCount].enuWIDtype = WID_INT; strWIDList[u32WidsCount].s32ValueSize = sizeof(u32); - strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(dummyval)); + strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval)); u32WidsCount++; /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */ @@ -1760,7 +1760,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); - strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security)); + strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security)); u32WidsCount++; /*BugID_5137*/ @@ -1773,7 +1773,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); - strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type); + strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type); u32WidsCount++; /*BugID_5137*/ @@ -1785,7 +1785,7 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK; * strWIDList[u32WidsCount].enuWIDtype = WID_STR; * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase); - * strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8*)(passphrase); + * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase); * u32WidsCount++; */ @@ -2095,7 +2095,7 @@ static WILC_Sint32 Handle_FlushConnect(void *drvHandler) strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); - strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(gu8Flushed11iMode)); + strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(gu8Flushed11iMode)); u32WidsCount++; @@ -2103,7 +2103,7 @@ static WILC_Sint32 Handle_FlushConnect(void *drvHandler) strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); - strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&gu8FlushedAuthType); + strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&gu8FlushedAuthType); u32WidsCount++; @@ -2111,7 +2111,7 @@ static WILC_Sint32 Handle_FlushConnect(void *drvHandler) strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED; strWIDList[u32WidsCount].enuWIDtype = WID_STR; strWIDList[u32WidsCount].s32ValueSize = gu32FlushedJoinReqSize; - strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)gu8FlushedJoinReq; + strWIDList[u32WidsCount].ps8WidVal = (s8 *)gu8FlushedJoinReq; pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal; pu8CurrByte += FLUSHED_BYTE_POS; @@ -2201,7 +2201,7 @@ static WILC_Sint32 Handle_ConnectTimeout(void *drvHandler) * WID_DISCONNECT} */ strWID.u16WIDid = (u16)WID_DISCONNECT; strWID.enuWIDtype = WID_CHAR; - strWID.ps8WidVal = (WILC_Sint8 *)&u16DummyReasonCode; + strWID.ps8WidVal = (s8 *)&u16DummyReasonCode; strWID.s32ValueSize = sizeof(WILC_Char); PRINT_D(HOSTINF_DBG, "Sending disconnect request\n"); @@ -2715,8 +2715,8 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) #endif u8 i; u8 *pu8keybuf; - WILC_Sint8 s8idxarray[1]; - WILC_Sint8 ret = 0; + s8 s8idxarray[1]; + s8 ret = 0; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -2733,17 +2733,17 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) strWIDList[0].u16WIDid = (u16)WID_11I_MODE; strWIDList[0].enuWIDtype = WID_CHAR; strWIDList[0].s32ValueSize = sizeof(WILC_Char); - strWIDList[0].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode)); + strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode)); strWIDList[1].u16WIDid = WID_AUTH_TYPE; strWIDList[1].enuWIDtype = WID_CHAR; strWIDList[1].s32ValueSize = sizeof(WILC_Char); - strWIDList[1].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type)); + strWIDList[1].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type)); strWIDList[2].u16WIDid = (u16)WID_KEY_ID; strWIDList[2].enuWIDtype = WID_CHAR; - strWIDList[2].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx)); + strWIDList[2].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx)); strWIDList[2].s32ValueSize = sizeof(WILC_Char); @@ -2764,7 +2764,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) strWIDList[3].u16WIDid = (u16)WID_WEP_KEY_VALUE; strWIDList[3].enuWIDtype = WID_STR; strWIDList[3].s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen; - strWIDList[3].ps8WidVal = (WILC_Sint8 *)pu8keybuf; + strWIDList[3].ps8WidVal = (s8 *)pu8keybuf; s32Error = SendConfigPkt(SET_CFG, strWIDList, 4, WILC_TRUE, (u32)pstrWFIDrv); @@ -2792,7 +2792,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) strWID.u16WIDid = (u16)WID_ADD_WEP_KEY; strWID.enuWIDtype = WID_STR; - strWID.ps8WidVal = (WILC_Sint8 *)pu8keybuf; + strWID.ps8WidVal = (s8 *)pu8keybuf; strWID.s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2; s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); @@ -2803,7 +2803,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) strWID.u16WIDid = (u16)WID_REMOVE_WEP_KEY; strWID.enuWIDtype = WID_STR; - s8idxarray[0] = (WILC_Sint8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx; + s8idxarray[0] = (s8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx; strWID.ps8WidVal = s8idxarray; strWID.s32ValueSize = 1; @@ -2811,7 +2811,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) } else { strWID.u16WIDid = (u16)WID_KEY_ID; strWID.enuWIDtype = WID_CHAR; - strWID.ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx)); + strWID.ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx)); strWID.s32ValueSize = sizeof(WILC_Char); PRINT_D(HOSTINF_DBG, "Setting default key index\n"); @@ -2855,11 +2855,11 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) strWIDList[0].u16WIDid = (u16)WID_11I_MODE; strWIDList[0].enuWIDtype = WID_CHAR; strWIDList[0].s32ValueSize = sizeof(WILC_Char); - strWIDList[0].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode)); + strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode)); strWIDList[1].u16WIDid = (u16)WID_ADD_RX_GTK; strWIDList[1].enuWIDtype = WID_STR; - strWIDList[1].ps8WidVal = (WILC_Sint8 *)pu8keybuf; + strWIDList[1].ps8WidVal = (s8 *)pu8keybuf; strWIDList[1].s32ValueSize = RX_MIC_KEY_MSG_LEN; s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, WILC_TRUE, (u32)pstrWFIDrv); @@ -2906,7 +2906,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) strWID.u16WIDid = (u16)WID_ADD_RX_GTK; strWID.enuWIDtype = WID_STR; - strWID.ps8WidVal = (WILC_Sint8 *)pu8keybuf; + strWID.ps8WidVal = (s8 *)pu8keybuf; strWID.s32ValueSize = RX_MIC_KEY_MSG_LEN; s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); @@ -2959,11 +2959,11 @@ _WPARxGtk_end_case_: strWIDList[0].u16WIDid = (u16)WID_11I_MODE; strWIDList[0].enuWIDtype = WID_CHAR; strWIDList[0].s32ValueSize = sizeof(WILC_Char); - strWIDList[0].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode)); + strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode)); strWIDList[1].u16WIDid = (u16)WID_ADD_PTK; strWIDList[1].enuWIDtype = WID_STR; - strWIDList[1].ps8WidVal = (WILC_Sint8 *)pu8keybuf; + strWIDList[1].ps8WidVal = (s8 *)pu8keybuf; strWIDList[1].s32ValueSize = PTK_KEY_MSG_LEN + 1; s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, WILC_TRUE, (u32)pstrWFIDrv); @@ -3004,7 +3004,7 @@ _WPARxGtk_end_case_: strWID.u16WIDid = (u16)WID_ADD_PTK; strWID.enuWIDtype = WID_STR; - strWID.ps8WidVal = (WILC_Sint8 *)pu8keybuf; + strWID.ps8WidVal = (s8 *)pu8keybuf; strWID.s32ValueSize = PTK_KEY_MSG_LEN; s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); @@ -3043,7 +3043,7 @@ _WPAPtk_end_case_: strWID.u16WIDid = (u16)WID_PMKID_INFO; strWID.enuWIDtype = WID_STR; - strWID.ps8WidVal = (WILC_Sint8 *)pu8keybuf; + strWID.ps8WidVal = (s8 *)pu8keybuf; strWID.s32ValueSize = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1; s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); @@ -3080,7 +3080,7 @@ static void Handle_Disconnect(void *drvHandler) strWID.u16WIDid = (u16)WID_DISCONNECT; strWID.enuWIDtype = WID_CHAR; - strWID.ps8WidVal = (WILC_Sint8 *)&u16DummyReasonCode; + strWID.ps8WidVal = (s8 *)&u16DummyReasonCode; strWID.s32ValueSize = sizeof(WILC_Char); @@ -3247,7 +3247,7 @@ static WILC_Sint32 Handle_GetChnl(void *drvHandler) tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL; strWID.enuWIDtype = WID_CHAR; - strWID.ps8WidVal = (WILC_Sint8 *)&gu8Chnl; + strWID.ps8WidVal = (s8 *)&gu8Chnl; strWID.s32ValueSize = sizeof(WILC_Char); PRINT_D(HOSTINF_DBG, "Getting channel value\n"); @@ -3350,31 +3350,31 @@ WILC_Sint32 Handle_GetStatistics(void *drvHandler, tstrStatistics *pstrStatistic strWIDList[u32WidsCount].u16WIDid = WID_LINKSPEED; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); - strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrStatistics->u8LinkSpeed)); + strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u8LinkSpeed)); u32WidsCount++; strWIDList[u32WidsCount].u16WIDid = WID_RSSI; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); - strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrStatistics->s8RSSI)); + strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->s8RSSI)); u32WidsCount++; strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT; strWIDList[u32WidsCount].enuWIDtype = WID_INT; strWIDList[u32WidsCount].s32ValueSize = sizeof(u32); - strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrStatistics->u32TxCount)); + strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxCount)); u32WidsCount++; strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT; strWIDList[u32WidsCount].enuWIDtype = WID_INT; strWIDList[u32WidsCount].s32ValueSize = sizeof(u32); - strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrStatistics->u32RxCount)); + strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32RxCount)); u32WidsCount++; strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT; strWIDList[u32WidsCount].enuWIDtype = WID_INT; strWIDList[u32WidsCount].s32ValueSize = sizeof(u32); - strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrStatistics->u32TxFailureCount)); + strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxFailureCount)); u32WidsCount++; s32Error = SendConfigPkt(GET_CFG, strWIDList, u32WidsCount, WILC_FALSE, (u32)drvHandler); @@ -3435,7 +3435,7 @@ static WILC_Sint32 Handle_Get_InActiveTime(void *drvHandler, tstrHostIfStaInacti strWID.u16WIDid = (u16)WID_GET_INACTIVE_TIME; strWID.enuWIDtype = WID_INT; - strWID.ps8WidVal = (WILC_Sint8 *)&gu32InactiveTime; + strWID.ps8WidVal = (s8 *)&gu32InactiveTime; strWID.s32ValueSize = sizeof(u32); @@ -3877,14 +3877,14 @@ static int Handle_RemainOnChan(void *drvHandler, tstrHostIfRemainOnChan *pstrHos strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN; strWID.enuWIDtype = WID_STR; strWID.s32ValueSize = 2; - strWID.ps8WidVal = (WILC_Sint8 *)WILC_MALLOC(strWID.s32ValueSize); + strWID.ps8WidVal = (s8 *)WILC_MALLOC(strWID.s32ValueSize); if (strWID.ps8WidVal == NULL) { WILC_ERRORREPORT(s32Error, WILC_NO_MEM); } strWID.ps8WidVal[0] = u8remain_on_chan_flag; - strWID.ps8WidVal[1] = (WILC_Sint8)pstrHostIfRemainOnChan->u16Channel; + strWID.ps8WidVal[1] = (s8)pstrHostIfRemainOnChan->u16Channel; /*Sending Cfg*/ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); @@ -4067,7 +4067,7 @@ static void Handle_PowerManagement(void *drvHandler, tstrHostIfPowerMgmtParam *s { WILC_Sint32 s32Error = WILC_SUCCESS; tstrWID strWID; - WILC_Sint8 s8PowerMode; + s8 s8PowerMode; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; strWID.u16WIDid = (u16)WID_POWER_MANAGEMENT; @@ -4642,7 +4642,7 @@ WILC_Sint32 host_int_remove_key(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8StaAddre strWID.u16WIDid = (u16)WID_REMOVE_KEY; strWID.enuWIDtype = WID_STR; - strWID.ps8WidVal = (WILC_Sint8 *)pu8StaAddress; + strWID.ps8WidVal = (s8 *)pu8StaAddress; strWID.s32ValueSize = 6; return s32Error; @@ -5483,7 +5483,7 @@ WILC_Sint32 host_int_set_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 scanSource strWID.u16WIDid = (u16)WID_START_SCAN_REQ; strWID.enuWIDtype = WID_CHAR; - strWID.ps8WidVal = (WILC_Sint8 *)&scanSource; + strWID.ps8WidVal = (s8 *)&scanSource; strWID.s32ValueSize = sizeof(WILC_Char); return s32Error; @@ -5513,7 +5513,7 @@ WILC_Sint32 host_int_get_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ScanSo strWID.u16WIDid = (u16)WID_START_SCAN_REQ; strWID.enuWIDtype = WID_CHAR; - strWID.ps8WidVal = (WILC_Sint8 *)pu8ScanSource; + strWID.ps8WidVal = (s8 *)pu8ScanSource; strWID.s32ValueSize = sizeof(WILC_Char); return s32Error; @@ -5733,7 +5733,7 @@ WILC_Sint32 host_int_disconnect_station(WILC_WFIDrvHandle hWFIDrv, u8 assoc_id) strWID.u16WIDid = (u16)WID_DISCONNECT; strWID.enuWIDtype = WID_CHAR; - strWID.ps8WidVal = (WILC_Sint8 *)&assoc_id; + strWID.ps8WidVal = (s8 *)&assoc_id; strWID.s32ValueSize = sizeof(WILC_Char); return s32Error; @@ -6151,7 +6151,7 @@ WILC_Sint32 host_int_test_get_int_wid(WILC_WFIDrvHandle hWFIDrv, u32 *pu32TestMe strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS; strWID.enuWIDtype = WID_INT; - strWID.ps8WidVal = (WILC_Sint8 *)pu32TestMemAddr; + strWID.ps8WidVal = (s8 *)pu32TestMemAddr; strWID.s32ValueSize = sizeof(u32); s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); @@ -6185,7 +6185,7 @@ WILC_Sint32 host_int_test_get_int_wid(WILC_WFIDrvHandle hWFIDrv, u32 *pu32TestMe * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_get_rssi(WILC_WFIDrvHandle hWFIDrv, WILC_Sint8 *ps8Rssi) +WILC_Sint32 host_int_get_rssi(WILC_WFIDrvHandle hWFIDrv, s8 *ps8Rssi) { WILC_Sint32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; @@ -6220,7 +6220,7 @@ WILC_Sint32 host_int_get_rssi(WILC_WFIDrvHandle hWFIDrv, WILC_Sint8 *ps8Rssi) return s32Error; } -WILC_Sint32 host_int_get_link_speed(WILC_WFIDrvHandle hWFIDrv, WILC_Sint8 *ps8lnkspd) +WILC_Sint32 host_int_get_link_speed(WILC_WFIDrvHandle hWFIDrv, s8 *ps8lnkspd) { tstrHostIFmsg strHostIFmsg; WILC_Sint32 s32Error = WILC_SUCCESS; @@ -6578,7 +6578,7 @@ void GetPeriodicRSSI(void *pvArg) void host_int_send_network_info_to_host - (u8 *macStartAddress, u16 u16RxFrameLen, WILC_Sint8 s8Rssi) + (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi) { } /** diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index a75efbfb1929..1f107d0b2ce0 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -128,12 +128,12 @@ typedef enum {WID_CHAR = 0, typedef struct { u16 cfg_wid; WID_TYPE_T cfg_type; - WILC_Sint8 *pu8Para; + s8 *pu8Para; } cfg_param_t; typedef struct _tstrStatistics { u8 u8LinkSpeed; - WILC_Sint8 s8RSSI; + s8 s8RSSI; u32 u32TxCount; u32 u32RxCount; u32 u32TxFailureCount; @@ -237,7 +237,7 @@ typedef enum { typedef struct { u8 au8bssid[6]; - WILC_Sint8 s8rssi; + s8 s8rssi; } tstrFoundNetworkInfo; typedef enum {SCAN_EVENT_NETWORK_FOUND = 0, @@ -989,8 +989,8 @@ WILC_Sint32 host_int_get_host_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ChNo); * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_get_rssi(WILC_WFIDrvHandle hWFIDrv, WILC_Sint8 *ps8Rssi); -WILC_Sint32 host_int_get_link_speed(WILC_WFIDrvHandle hWFIDrv, WILC_Sint8 *ps8lnkspd); +WILC_Sint32 host_int_get_rssi(WILC_WFIDrvHandle hWFIDrv, s8 *ps8Rssi); +WILC_Sint32 host_int_get_link_speed(WILC_WFIDrvHandle hWFIDrv, s8 *ps8lnkspd); /** * @brief scans a set of channels * @details @@ -1074,7 +1074,7 @@ void host_int_send_join_leave_info_to_host * @version 1.0 */ void host_int_send_network_info_to_host - (u8 *macStartAddress, u16 u16RxFrameLen, WILC_Sint8 s8Rssi); + (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi); /** * @brief host interface initialization function diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index de576b58128b..6b8001da31c6 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -2375,7 +2375,7 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) { u8 *buff = NULL; - WILC_Sint8 rssi; + s8 rssi; u32 size = 0, length = 0; perInterface_wlan_t *nic; struct WILC_WFI_priv *priv; diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index 3af48da5751d..7e84475e2278 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -14,7 +14,6 @@ #define WILC_OSW_INTERFACE_VER 2 /* Integer Types */ -typedef signed char WILC_Sint8; typedef signed short WILC_Sint16; typedef signed int WILC_Sint32; typedef signed long long WILC_Sint64; From 4320f6febcd5f296fecd263b9624f442e4c9e307 Mon Sep 17 00:00:00 2001 From: Chaehyun Lim Date: Thu, 11 Jun 2015 14:35:58 +0900 Subject: [PATCH 0923/1163] staging: wilc1000: remove WILC_Sint16 Use s16 instead of WILC_Sint16. Signed-off-by: Chaehyun Lim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 2 +- drivers/staging/wilc1000/wilc_oswrapper.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index f51bfa48028e..cff3ff8f3604 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -174,7 +174,7 @@ static tstrConfigPktInfo gstrConfigPktInfo; static u8 g_seqno; -static WILC_Sint16 g_wid_num = -1; +static s16 g_wid_num = -1; static u16 Res_Len; diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index 7e84475e2278..6deec34646a6 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -14,7 +14,6 @@ #define WILC_OSW_INTERFACE_VER 2 /* Integer Types */ -typedef signed short WILC_Sint16; typedef signed int WILC_Sint32; typedef signed long long WILC_Sint64; From fb4ec9caa464666c200ca95069cf135bb199b855 Mon Sep 17 00:00:00 2001 From: Chaehyun Lim Date: Thu, 11 Jun 2015 14:35:59 +0900 Subject: [PATCH 0924/1163] staging: wilc1000: remove WILC_Sint32 Use s32 instead of WILC_Sint32. Signed-off-by: Chaehyun Lim Signed-off-by: Greg Kroah-Hartman --- .../staging/wilc1000/coreconfigsimulator.h | 4 +- drivers/staging/wilc1000/coreconfigurator.c | 114 +++--- drivers/staging/wilc1000/coreconfigurator.h | 22 +- drivers/staging/wilc1000/host_interface.c | 362 +++++++++--------- drivers/staging/wilc1000/host_interface.h | 124 +++--- drivers/staging/wilc1000/linux_wlan.c | 2 +- drivers/staging/wilc1000/wilc_errorsupport.h | 2 +- drivers/staging/wilc1000/wilc_oswrapper.h | 1 - drivers/staging/wilc1000/wilc_strutils.c | 6 +- drivers/staging/wilc1000/wilc_strutils.h | 4 +- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 78 ++-- 11 files changed, 359 insertions(+), 360 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigsimulator.h b/drivers/staging/wilc1000/coreconfigsimulator.h index 6c3f431314fa..25e3c2ce2278 100644 --- a/drivers/staging/wilc1000/coreconfigsimulator.h +++ b/drivers/staging/wilc1000/coreconfigsimulator.h @@ -13,8 +13,8 @@ #define CORECONFIGSIMULATOR_H -extern WILC_Sint32 CoreConfigSimulatorInit (void); -extern WILC_Sint32 CoreConfigSimulatorDeInit (void); +extern s32 CoreConfigSimulatorInit (void); +extern s32 CoreConfigSimulatorDeInit (void); #endif \ No newline at end of file diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index cff3ff8f3604..c9cc817e7dca 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -143,8 +143,8 @@ typedef enum { typedef struct { WILC_Char *pcRespBuffer; - WILC_Sint32 s32MaxRespBuffLen; - WILC_Sint32 s32BytesRead; + s32 s32MaxRespBuffLen; + s32 s32BytesRead; WILC_Bool bRespRequired; } tstrConfigPktInfo; @@ -158,7 +158,7 @@ typedef struct { /*****************************************************************************/ /* Extern Function Declarations */ /*****************************************************************************/ -extern WILC_Sint32 SendRawPacket(s8 *ps8Packet, WILC_Sint32 s32PacketLen); +extern s32 SendRawPacket(s8 *ps8Packet, s32 s32PacketLen); extern void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length); extern void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length); extern void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length); @@ -670,9 +670,9 @@ INLINE u16 get_asoc_id(u8 *data) * @version 1.0 */ -WILC_Sint32 CoreConfiguratorInit(void) +s32 CoreConfiguratorInit(void) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; PRINT_D(CORECONFIG_DBG, "CoreConfiguratorInit()\n"); sema_init(&SemHandleSendPkt, 1); @@ -769,9 +769,9 @@ u8 get_current_channel(u8 *pu8msa, u16 u16RxLen) * @date 1 Mar 2012 * @version 1.0 */ -WILC_Sint32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo) +s32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrNetworkInfo *pstrNetworkInfo = NULL; u8 u8MsgType = 0; u8 u8MsgID = 0; @@ -891,9 +891,9 @@ ERRORHANDLER: * @date 1 Mar 2012 * @version 1.0 */ -WILC_Sint32 DeallocateNetworkInfo(tstrNetworkInfo *pstrNetworkInfo) +s32 DeallocateNetworkInfo(tstrNetworkInfo *pstrNetworkInfo) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; if (pstrNetworkInfo != NULL) { if (pstrNetworkInfo->pu8IEs != NULL) { @@ -924,10 +924,10 @@ WILC_Sint32 DeallocateNetworkInfo(tstrNetworkInfo *pstrNetworkInfo) * @date 2 Apr 2012 * @version 1.0 */ -WILC_Sint32 ParseAssocRespInfo(u8 *pu8Buffer, u32 u32BufferLen, +s32 ParseAssocRespInfo(u8 *pu8Buffer, u32 u32BufferLen, tstrConnectRespInfo **ppstrConnectRespInfo) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrConnectRespInfo *pstrConnectRespInfo = NULL; u16 u16AssocRespLen = 0; u8 *pu8IEs = 0; @@ -976,9 +976,9 @@ WILC_Sint32 ParseAssocRespInfo(u8 *pu8Buffer, u32 u32BufferLen, * @date 2 Apr 2012 * @version 1.0 */ -WILC_Sint32 DeallocateAssocRespInfo(tstrConnectRespInfo *pstrConnectRespInfo) +s32 DeallocateAssocRespInfo(tstrConnectRespInfo *pstrConnectRespInfo) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; if (pstrConnectRespInfo != NULL) { if (pstrConnectRespInfo->pu8RespIEs != NULL) { @@ -999,11 +999,11 @@ WILC_Sint32 DeallocateAssocRespInfo(tstrConnectRespInfo *pstrConnectRespInfo) } #ifndef CONNECT_DIRECT -WILC_Sint32 ParseSurveyResults(u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE], +s32 ParseSurveyResults(u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE], wid_site_survey_reslts_s **ppstrSurveyResults, u32 *pu32SurveyResultsCount) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; wid_site_survey_reslts_s *pstrSurveyResults = NULL; u32 u32SurveyResultsCount = 0; u32 u32SurveyBytesLength = 0; @@ -1057,9 +1057,9 @@ ERRORHANDLER: } -WILC_Sint32 DeallocateSurveyResults(wid_site_survey_reslts_s *pstrSurveyResults) +s32 DeallocateSurveyResults(wid_site_survey_reslts_s *pstrSurveyResults) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; if (pstrSurveyResults != NULL) { WILC_FREE(pstrSurveyResults); @@ -1096,12 +1096,12 @@ WILC_Sint32 DeallocateSurveyResults(wid_site_survey_reslts_s *pstrSurveyResults) /* */ /*****************************************************************************/ -void ProcessCharWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, +void ProcessCharWid(WILC_Char *pcPacket, s32 *ps32PktLen, tstrWID *pstrWID, s8 *ps8WidVal) { u8 *pu8val = (u8 *)ps8WidVal; u8 u8val = 0; - WILC_Sint32 s32PktLen = *ps32PktLen; + s32 s32PktLen = *ps32PktLen; if (pstrWID == NULL) { PRINT_WRN(CORECONFIG_DBG, "Can't set CHAR val 0x%x ,NULL structure\n", u8val); return; @@ -1150,12 +1150,12 @@ void ProcessCharWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, /* */ /*****************************************************************************/ -void ProcessShortWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, +void ProcessShortWid(WILC_Char *pcPacket, s32 *ps32PktLen, tstrWID *pstrWID, s8 *ps8WidVal) { u16 *pu16val = (u16 *)ps8WidVal; u16 u16val = 0; - WILC_Sint32 s32PktLen = *ps32PktLen; + s32 s32PktLen = *ps32PktLen; if (pstrWID == NULL) { PRINT_WRN(CORECONFIG_DBG, "Can't set SHORT val 0x%x ,NULL structure\n", u16val); return; @@ -1205,12 +1205,12 @@ void ProcessShortWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, /* */ /*****************************************************************************/ -void ProcessIntWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, +void ProcessIntWid(WILC_Char *pcPacket, s32 *ps32PktLen, tstrWID *pstrWID, s8 *ps8WidVal) { u32 *pu32val = (u32 *)ps8WidVal; u32 u32val = 0; - WILC_Sint32 s32PktLen = *ps32PktLen; + s32 s32PktLen = *ps32PktLen; if (pstrWID == NULL) { PRINT_WRN(CORECONFIG_DBG, "Can't set INT val 0x%x , NULL structure\n", u32val); return; @@ -1263,11 +1263,11 @@ void ProcessIntWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, /* */ /*****************************************************************************/ -void ProcessIPwid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, +void ProcessIPwid(WILC_Char *pcPacket, s32 *ps32PktLen, tstrWID *pstrWID, u8 *pu8ip) { u32 u32val = 0; - WILC_Sint32 s32PktLen = *ps32PktLen; + s32 s32PktLen = *ps32PktLen; if (pstrWID == NULL) { PRINT_WRN(CORECONFIG_DBG, "Can't set IP Addr , NULL structure\n"); @@ -1321,12 +1321,12 @@ void ProcessIPwid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, /* */ /*****************************************************************************/ -void ProcessStrWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, - tstrWID *pstrWID, u8 *pu8val, WILC_Sint32 s32ValueSize) +void ProcessStrWid(WILC_Char *pcPacket, s32 *ps32PktLen, + tstrWID *pstrWID, u8 *pu8val, s32 s32ValueSize) { u16 u16MsgLen = 0; u16 idx = 0; - WILC_Sint32 s32PktLen = *ps32PktLen; + s32 s32PktLen = *ps32PktLen; if (pstrWID == NULL) { PRINT_WRN(CORECONFIG_DBG, "Can't set STR val, NULL structure\n"); return; @@ -1378,11 +1378,11 @@ void ProcessStrWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, /* */ /*****************************************************************************/ -void ProcessAdrWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, +void ProcessAdrWid(WILC_Char *pcPacket, s32 *ps32PktLen, tstrWID *pstrWID, u8 *pu8val) { u16 u16MsgLen = 0; - WILC_Sint32 s32PktLen = *ps32PktLen; + s32 s32PktLen = *ps32PktLen; if (pstrWID == NULL) { PRINT_WRN(CORECONFIG_DBG, "Can't set Addr WID, NULL structure\n"); @@ -1442,14 +1442,14 @@ void ProcessAdrWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, /* */ /*****************************************************************************/ -void ProcessBinWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, - tstrWID *pstrWID, u8 *pu8val, WILC_Sint32 s32ValueSize) +void ProcessBinWid(WILC_Char *pcPacket, s32 *ps32PktLen, + tstrWID *pstrWID, u8 *pu8val, s32 s32ValueSize) { /* WILC_ERROR("processing Binary WIDs is not supported\n"); */ u16 u16MsgLen = 0; u16 idx = 0; - WILC_Sint32 s32PktLen = *ps32PktLen; + s32 s32PktLen = *ps32PktLen; u8 u8checksum = 0; if (pstrWID == NULL) { @@ -1517,7 +1517,7 @@ void ProcessBinWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen, /* */ /*****************************************************************************/ -WILC_Sint32 further_process_response(u8 *resp, +s32 further_process_response(u8 *resp, u16 u16WIDid, u16 cfg_len, WILC_Bool process_wid_num, @@ -1551,7 +1551,7 @@ WILC_Sint32 further_process_response(u8 *resp, u16 *pu16val = (u16 *)(pstrWIDresult->ps8WidVal); cfg_sht = MAKE_WORD16(resp[idx], resp[idx + 1]); /*Set local copy of WID*/ - /* pstrWIDresult->ps8WidVal = (s8*)(WILC_Sint32)cfg_sht; */ + /* pstrWIDresult->ps8WidVal = (s8*)(s32)cfg_sht; */ *pu16val = cfg_sht; break; } @@ -1687,7 +1687,7 @@ WILC_Sint32 further_process_response(u8 *resp, /* */ /*****************************************************************************/ -WILC_Sint32 ParseResponse(u8 *resp, tstrWID *pstrWIDcfgResult) +s32 ParseResponse(u8 *resp, tstrWID *pstrWIDcfgResult) { u16 u16RespLen = 0; u16 u16WIDid = 0; @@ -1760,9 +1760,9 @@ WILC_Sint32 ParseResponse(u8 *resp, tstrWID *pstrWIDcfgResult) * @version 1.0 */ -WILC_Sint32 ParseWriteResponse(u8 *pu8RespBuffer) +s32 ParseWriteResponse(u8 *pu8RespBuffer) { - WILC_Sint32 s32Error = WILC_FAIL; + s32 s32Error = WILC_FAIL; u16 u16RespLen = 0; u16 u16WIDtype = (u16)WID_NIL; @@ -1803,9 +1803,9 @@ WILC_Sint32 ParseWriteResponse(u8 *pu8RespBuffer) * @version 1.0 */ -WILC_Sint32 CreatePacketHeader(WILC_Char *pcpacket, WILC_Sint32 *ps32PacketLength) +s32 CreatePacketHeader(WILC_Char *pcpacket, s32 *ps32PacketLength) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; u16 u16MsgLen = (u16)(*ps32PacketLength); u16 u16MsgInd = 0; @@ -1857,10 +1857,10 @@ WILC_Sint32 CreatePacketHeader(WILC_Char *pcpacket, WILC_Sint32 *ps32PacketLengt * @version 1.0 */ -WILC_Sint32 CreateConfigPacket(s8 *ps8packet, WILC_Sint32 *ps32PacketLength, +s32 CreateConfigPacket(s8 *ps8packet, s32 *ps32PacketLength, tstrWID *pstrWIDs, u32 u32WIDsCount) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; u32 u32idx = 0; *ps32PacketLength = MSG_HEADER_LEN; for (u32idx = 0; u32idx < u32WIDsCount; u32idx++) { @@ -1912,10 +1912,10 @@ WILC_Sint32 CreateConfigPacket(s8 *ps8packet, WILC_Sint32 *ps32PacketLength, return s32Error; } -WILC_Sint32 ConfigWaitResponse(WILC_Char *pcRespBuffer, WILC_Sint32 s32MaxRespBuffLen, WILC_Sint32 *ps32BytesRead, +s32 ConfigWaitResponse(WILC_Char *pcRespBuffer, s32 s32MaxRespBuffLen, s32 *ps32BytesRead, WILC_Bool bRespRequired) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; /*bug 3878*/ /*removed to caller function*/ /*gstrConfigPktInfo.pcRespBuffer = pcRespBuffer; @@ -1949,13 +1949,13 @@ WILC_Sint32 ConfigWaitResponse(WILC_Char *pcRespBuffer, WILC_Sint32 s32MaxRespBu * @version 1.0 */ #ifdef SIMULATION -WILC_Sint32 SendConfigPkt(u8 u8Mode, tstrWID *pstrWIDs, +s32 SendConfigPkt(u8 u8Mode, tstrWID *pstrWIDs, u32 u32WIDsCount, WILC_Bool bRespRequired, u32 drvHandler) { - WILC_Sint32 s32Error = WILC_SUCCESS; - WILC_Sint32 err = WILC_SUCCESS; - WILC_Sint32 s32ConfigPacketLen = 0; - WILC_Sint32 s32RcvdRespLen = 0; + s32 s32Error = WILC_SUCCESS; + s32 err = WILC_SUCCESS; + s32 s32ConfigPacketLen = 0; + s32 s32RcvdRespLen = 0; down(&SemHandleSendPkt); @@ -2017,9 +2017,9 @@ End_ConfigPkt: return s32Error; } #endif -WILC_Sint32 ConfigProvideResponse(WILC_Char *pcRespBuffer, WILC_Sint32 s32RespLen) +s32 ConfigProvideResponse(WILC_Char *pcRespBuffer, s32 s32RespLen) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; if (gstrConfigPktInfo.bRespRequired == WILC_TRUE) { if (s32RespLen <= gstrConfigPktInfo.s32MaxRespBuffLen) { @@ -2050,9 +2050,9 @@ WILC_Sint32 ConfigProvideResponse(WILC_Char *pcRespBuffer, WILC_Sint32 s32RespLe * @version 1.0 */ -WILC_Sint32 ConfigPktReceived(u8 *pu8RxPacket, WILC_Sint32 s32RxPacketLen) +s32 ConfigPktReceived(u8 *pu8RxPacket, s32 s32RxPacketLen) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; u8 u8MsgType = 0; u8MsgType = pu8RxPacket[0]; @@ -2094,9 +2094,9 @@ WILC_Sint32 ConfigPktReceived(u8 *pu8RxPacket, WILC_Sint32 s32RxPacketLen) * @version 1.0 */ -WILC_Sint32 CoreConfiguratorDeInit(void) +s32 CoreConfiguratorDeInit(void) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; PRINT_D(CORECONFIG_DBG, "CoreConfiguratorDeInit()\n"); @@ -2128,10 +2128,10 @@ extern wilc_wlan_oup_t *gpstrWlanOps; * @date 1 Mar 2012 * @version 1.0 */ -WILC_Sint32 SendConfigPkt(u8 u8Mode, tstrWID *pstrWIDs, +s32 SendConfigPkt(u8 u8Mode, tstrWID *pstrWIDs, u32 u32WIDsCount, WILC_Bool bRespRequired, u32 drvHandler) { - WILC_Sint32 counter = 0, ret = 0; + s32 counter = 0, ret = 0; if (gpstrWlanOps == NULL) { PRINT_D(CORECONFIG_DBG, "Net Dev is still not initialized\n"); return 1; diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h index 44941cdbd3e2..63db151fa752 100644 --- a/drivers/staging/wilc1000/coreconfigurator.h +++ b/drivers/staging/wilc1000/coreconfigurator.h @@ -396,7 +396,7 @@ typedef enum { typedef struct { u16 u16WIDid; tenuWIDtype enuWIDtype; - WILC_Sint32 s32ValueSize; + s32 s32ValueSize; s8 *ps8WidVal; } tstrWID; @@ -472,25 +472,25 @@ typedef struct wid_site_survey_reslts { } wid_site_survey_reslts_s; #endif -extern WILC_Sint32 CoreConfiguratorInit(void); -extern WILC_Sint32 CoreConfiguratorDeInit(void); +extern s32 CoreConfiguratorInit(void); +extern s32 CoreConfiguratorDeInit(void); -extern WILC_Sint32 SendConfigPkt(u8 u8Mode, tstrWID *pstrWIDs, +extern s32 SendConfigPkt(u8 u8Mode, tstrWID *pstrWIDs, u32 u32WIDsCount, WILC_Bool bRespRequired, u32 drvHandler); -extern WILC_Sint32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo); -extern WILC_Sint32 DeallocateNetworkInfo(tstrNetworkInfo *pstrNetworkInfo); +extern s32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo); +extern s32 DeallocateNetworkInfo(tstrNetworkInfo *pstrNetworkInfo); -extern WILC_Sint32 ParseAssocRespInfo(u8 *pu8Buffer, u32 u32BufferLen, +extern s32 ParseAssocRespInfo(u8 *pu8Buffer, u32 u32BufferLen, tstrConnectRespInfo **ppstrConnectRespInfo); -extern WILC_Sint32 DeallocateAssocRespInfo(tstrConnectRespInfo *pstrConnectRespInfo); +extern s32 DeallocateAssocRespInfo(tstrConnectRespInfo *pstrConnectRespInfo); #ifndef CONNECT_DIRECT -extern WILC_Sint32 ParseSurveyResults(u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE], +extern s32 ParseSurveyResults(u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE], wid_site_survey_reslts_s **ppstrSurveyResults, u32 *pu32SurveyResultsCount); -extern WILC_Sint32 DeallocateSurveyResults(wid_site_survey_reslts_s *pstrSurveyResults); +extern s32 DeallocateSurveyResults(wid_site_survey_reslts_s *pstrSurveyResults); #endif -extern WILC_Sint32 SendRawPacket(s8 *pspacket, WILC_Sint32 s32PacketLen); +extern s32 SendRawPacket(s8 *pspacket, s32 s32PacketLen); extern void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length); void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length); void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length); diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index ce8e5b36b398..9207d222787a 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -3,8 +3,8 @@ #include "itypes.h" #include "coreconfigurator.h" -extern WILC_Sint32 TransportInit(void); -extern WILC_Sint32 TransportDeInit(void); +extern s32 TransportInit(void); +extern s32 TransportDeInit(void); extern u8 connecting; #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP @@ -607,10 +607,10 @@ extern int linux_wlan_get_num_conn_ifcs(void); * @date * @version 1.0 */ -static WILC_Sint32 Handle_SetChannel(void *drvHandler, tstrHostIFSetChan *pstrHostIFSetChan) +static s32 Handle_SetChannel(void *drvHandler, tstrHostIFSetChan *pstrHostIFSetChan) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -643,10 +643,10 @@ static WILC_Sint32 Handle_SetChannel(void *drvHandler, tstrHostIFSetChan *pstrHo * @date * @version 1.0 */ -static WILC_Sint32 Handle_SetWfiDrvHandler(tstrHostIfSetDrvHandler *pstrHostIfSetDrvHandler) +static s32 Handle_SetWfiDrvHandler(tstrHostIfSetDrvHandler *pstrHostIfSetDrvHandler) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)((pstrHostIfSetDrvHandler->u32Address)); @@ -688,10 +688,10 @@ static WILC_Sint32 Handle_SetWfiDrvHandler(tstrHostIfSetDrvHandler *pstrHostIfSe * @date * @version 1.0 */ -static WILC_Sint32 Handle_SetOperationMode(void *drvHandler, tstrHostIfSetOperationMode *pstrHostIfSetOperationMode) +static s32 Handle_SetOperationMode(void *drvHandler, tstrHostIfSetOperationMode *pstrHostIfSetOperationMode) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -734,10 +734,10 @@ static WILC_Sint32 Handle_SetOperationMode(void *drvHandler, tstrHostIfSetOperat * @date * @version 1.0 */ -WILC_Sint32 Handle_set_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx) +s32 Handle_set_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; char firmwareIPAddress[4] = {0}; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -786,10 +786,10 @@ WILC_Sint32 Handle_set_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx) * @date * @version 1.0 */ -WILC_Sint32 Handle_get_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx) +s32 Handle_get_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -839,10 +839,10 @@ WILC_Sint32 Handle_get_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx) * @date November 2013 * @version 7.0 */ -static WILC_Sint32 Handle_SetMacAddress(void *drvHandler, tstrHostIfSetMacAddress *pstrHostIfSetMacAddress) +static s32 Handle_SetMacAddress(void *drvHandler, tstrHostIfSetMacAddress *pstrHostIfSetMacAddress) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; u8 *mac_buf = (u8 *)WILC_MALLOC(ETH_ALEN); @@ -884,10 +884,10 @@ static WILC_Sint32 Handle_SetMacAddress(void *drvHandler, tstrHostIfSetMacAddres * @date JAN 2013 * @version 8.0 */ -static WILC_Sint32 Handle_GetMacAddress(void *drvHandler, tstrHostIfGetMacAddress *pstrHostIfGetMacAddress) +static s32 Handle_GetMacAddress(void *drvHandler, tstrHostIfGetMacAddress *pstrHostIfGetMacAddress) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; /*prepare configuration packet*/ @@ -921,9 +921,9 @@ static WILC_Sint32 Handle_GetMacAddress(void *drvHandler, tstrHostIfGetMacAddres * @date * @version 1.0 */ -static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *strHostIFCfgParamAttr) +static s32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *strHostIFCfgParamAttr) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWIDList[32]; u8 u8WidCnt = 0; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -1228,9 +1228,9 @@ static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *str * @date * @version 1.0 */ -static WILC_Sint32 Handle_wait_msg_q_empty(void) +static s32 Handle_wait_msg_q_empty(void) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; g_wilc_initialized = 0; up(&hWaitResponse); return s32Error; @@ -1245,9 +1245,9 @@ static WILC_Sint32 Handle_wait_msg_q_empty(void) * @date * @version 1.0 */ -static WILC_Sint32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFscanAttr) +static s32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFscanAttr) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWIDList[5]; u32 u32WidsCount = 0; u32 i; @@ -1314,7 +1314,7 @@ static WILC_Sint32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFs - strWIDList[u32WidsCount].s32ValueSize = (WILC_Sint32)(valuesize + 1); + strWIDList[u32WidsCount].s32ValueSize = (s32)(valuesize + 1); u32WidsCount++; } @@ -1426,9 +1426,9 @@ static WILC_Sint32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFs * @date * @version 1.0 */ -static WILC_Sint32 Handle_ScanDone(void *drvHandler, tenuScanEvent enuEvent) +static s32 Handle_ScanDone(void *drvHandler, tenuScanEvent enuEvent) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -1486,15 +1486,15 @@ static WILC_Sint32 Handle_ScanDone(void *drvHandler, tenuScanEvent enuEvent) * @version 1.0 */ u8 u8ConnectedSSID[6] = {0}; -static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFconnectAttr) +static s32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFconnectAttr) { tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler; - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWIDList[8]; u32 u32WidsCount = 0, dummyval = 0; /* char passphrase[] = "12345678"; */ #ifndef CONNECT_DIRECT - WILC_Sint32 s32Err = WILC_SUCCESS; + s32 s32Err = WILC_SUCCESS; u32 i; u8 u8bssDscListIndex; wid_site_survey_reslts_s *pstrSurveyResults = NULL; @@ -2077,9 +2077,9 @@ static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrH * @version 8.0 */ -static WILC_Sint32 Handle_FlushConnect(void *drvHandler) +static s32 Handle_FlushConnect(void *drvHandler) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWIDList[5]; u32 u32WidsCount = 0; u8 *pu8CurrByte = NULL; @@ -2144,9 +2144,9 @@ static WILC_Sint32 Handle_FlushConnect(void *drvHandler) * @date * @version 1.0 */ -static WILC_Sint32 Handle_ConnectTimeout(void *drvHandler) +static s32 Handle_ConnectTimeout(void *drvHandler) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrConnectInfo strConnectInfo; tstrWID strWID; u16 u16DummyReasonCode = 0; @@ -2253,14 +2253,14 @@ static WILC_Sint32 Handle_ConnectTimeout(void *drvHandler) * @date * @version 1.0 */ -static WILC_Sint32 Handle_RcvdNtwrkInfo(void *drvHandler, tstrRcvdNetworkInfo *pstrRcvdNetworkInfo) +static s32 Handle_RcvdNtwrkInfo(void *drvHandler, tstrRcvdNetworkInfo *pstrRcvdNetworkInfo) { u32 i; WILC_Bool bNewNtwrkFound; - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrNetworkInfo *pstrNetworkInfo = NULL; void *pJoinParams = NULL; @@ -2375,11 +2375,11 @@ done: * @date * @version 1.0 */ -static WILC_Sint32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncInfo *pstrRcvdGnrlAsyncInfo) +static s32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncInfo *pstrRcvdGnrlAsyncInfo) { /* TODO: mostafa: till now, this function just handles only the received mac status msg, */ /* which carries only 1 WID which have WID ID = WID_STATUS */ - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; u8 u8MsgType = 0; u8 u8MsgID = 0; u16 u16MsgLen = 0; @@ -2390,7 +2390,7 @@ static WILC_Sint32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncI u8 u8MacStatusAdditionalInfo; tstrConnectInfo strConnectInfo; tstrDisconnectNotifInfo strDisconnectNotifInfo; - WILC_Sint32 s32Err = WILC_SUCCESS; + s32 s32Err = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler; if (pstrWFIDrv == NULL) { PRINT_ER("Driver handler is NULL\n"); @@ -2708,7 +2708,7 @@ static WILC_Sint32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncI */ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; #ifdef WILC_AP_EXTERNAL_MLME tstrWID strWIDList[5]; @@ -3073,7 +3073,7 @@ static void Handle_Disconnect(void *drvHandler) { tstrWID strWID; - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; u16 u16DummyReasonCode = 0; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -3194,11 +3194,11 @@ void resolve_disconnect_aberration(void *drvHandler) host_int_disconnect((WILC_WFIDrvHandle)pstrWFIDrv, 1); } } -static WILC_Sint32 Switch_Log_Terminal(void *drvHandler) +static s32 Switch_Log_Terminal(void *drvHandler) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; static char dummy = 9; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -3238,10 +3238,10 @@ static WILC_Sint32 Switch_Log_Terminal(void *drvHandler) * @date * @version 1.0 */ -static WILC_Sint32 Handle_GetChnl(void *drvHandler) +static s32 Handle_GetChnl(void *drvHandler) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -3284,7 +3284,7 @@ static WILC_Sint32 Handle_GetChnl(void *drvHandler) */ static void Handle_GetRssi(void *drvHandler) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -3314,7 +3314,7 @@ static void Handle_GetRssi(void *drvHandler) static void Handle_GetLinkspeed(void *drvHandler) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -3342,7 +3342,7 @@ static void Handle_GetLinkspeed(void *drvHandler) } -WILC_Sint32 Handle_GetStatistics(void *drvHandler, tstrStatistics *pstrStatistics) +s32 Handle_GetStatistics(void *drvHandler, tstrStatistics *pstrStatistics) { tstrWID strWIDList[5]; uint32_t u32WidsCount = 0, s32Error = 0; @@ -3403,10 +3403,10 @@ WILC_Sint32 Handle_GetStatistics(void *drvHandler, tstrStatistics *pstrStatistic * @date * @version 1.0 */ -static WILC_Sint32 Handle_Get_InActiveTime(void *drvHandler, tstrHostIfStaInactiveT *strHostIfStaInactiveT) +static s32 Handle_Get_InActiveTime(void *drvHandler, tstrHostIfStaInactiveT *strHostIfStaInactiveT) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; u8 *stamac; tstrWID strWID; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -3474,7 +3474,7 @@ static WILC_Sint32 Handle_Get_InActiveTime(void *drvHandler, tstrHostIfStaInacti */ static void Handle_AddBeacon(void *drvHandler, tstrHostIFSetBeacon *pstrSetBeaconParam) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; u8 *pu8CurrByte; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -3546,7 +3546,7 @@ static void Handle_AddBeacon(void *drvHandler, tstrHostIFSetBeacon *pstrSetBeaco */ static void Handle_DelBeacon(void *drvHandler, tstrHostIFDelBeacon *pstrDelBeacon) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; u8 *pu8CurrByte; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -3644,7 +3644,7 @@ static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer, tstrWILC_AddStaParam *pstrSta */ static void Handle_AddStation(void *drvHandler, tstrWILC_AddStaParam *pstrStationParam) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; u8 *pu8CurrByte; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -3687,7 +3687,7 @@ static void Handle_AddStation(void *drvHandler, tstrWILC_AddStaParam *pstrStatio */ static void Handle_DelAllSta(void *drvHandler, tstrHostIFDelAllSta *pstrDelAllStaParam) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; u8 *pu8CurrByte; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -3745,7 +3745,7 @@ static void Handle_DelAllSta(void *drvHandler, tstrHostIFDelAllSta *pstrDelAllSt */ static void Handle_DelStation(void *drvHandler, tstrHostIFDelSta *pstrDelStaParam) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; u8 *pu8CurrByte; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -3791,7 +3791,7 @@ static void Handle_DelStation(void *drvHandler, tstrHostIFDelSta *pstrDelStaPara */ static void Handle_EditStation(void *drvHandler, tstrWILC_AddStaParam *pstrStationParam) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; u8 *pu8CurrByte; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -3837,7 +3837,7 @@ static void Handle_EditStation(void *drvHandler, tstrWILC_AddStaParam *pstrStati */ static int Handle_RemainOnChan(void *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; u8 u8remain_on_chan_flag; tstrWID strWID; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler; @@ -3919,7 +3919,7 @@ static int Handle_RemainOnChan(void *drvHandler, tstrHostIfRemainOnChan *pstrHos */ static int Handle_RegisterFrame(void *drvHandler, tstrHostIfRegisterFrame *pstrHostIfRegisterFrame) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; u8 *pu8CurrByte; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -3974,7 +3974,7 @@ static u32 Handle_ListenStateExpired(void *drvHandler, tstrHostIfRemainOnChan *p { u8 u8remain_on_chan_flag; tstrWID strWID; - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler; PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n"); @@ -4029,7 +4029,7 @@ _done_: */ static void ListenTimerCB(void *pvArg) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)pvArg; /*Stopping remain-on-channel timer*/ @@ -4065,7 +4065,7 @@ static void ListenTimerCB(void *pvArg) */ static void Handle_PowerManagement(void *drvHandler, tstrHostIfPowerMgmtParam *strPowerMgmtParam) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; s8 s8PowerMode; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -4106,7 +4106,7 @@ static void Handle_PowerManagement(void *drvHandler, tstrHostIfPowerMgmtParam *s */ static void Handle_SetMulticastFilter(void *drvHandler, tstrHostIFSetMulti *strHostIfSetMulti) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; u8 *pu8CurrByte; @@ -4159,9 +4159,9 @@ static void Handle_SetMulticastFilter(void *drvHandler, tstrHostIFSetMulti *strH * @date Feb. 2014 * @version 9.0 */ -static WILC_Sint32 Handle_AddBASession(void *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo) +static s32 Handle_AddBASession(void *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; int AddbaTimeout = 100; char *ptr = NULL; @@ -4247,9 +4247,9 @@ static WILC_Sint32 Handle_AddBASession(void *drvHandler, tstrHostIfBASessionInfo * @date Feb. 2013 * @version 9.0 */ -static WILC_Sint32 Handle_DelBASession(void *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo) +static s32 Handle_DelBASession(void *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; char *ptr = NULL; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -4317,9 +4317,9 @@ static WILC_Sint32 Handle_DelBASession(void *drvHandler, tstrHostIfBASessionInfo * @date Feb. 2013 * @version 9.0 */ -static WILC_Sint32 Handle_DelAllRxBASessions(void *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo) +static s32 Handle_DelAllRxBASessions(void *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; char *ptr = NULL; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; @@ -4634,9 +4634,9 @@ static void TimerCB_Connect(void *pvArg) * @version 1.0 */ /* Check implementation in core adding 9 bytes to the input! */ -WILC_Sint32 host_int_remove_key(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8StaAddress) +s32 host_int_remove_key(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8StaAddress) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ @@ -4663,9 +4663,9 @@ WILC_Sint32 host_int_remove_key(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8StaAddre * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv, u8 u8keyIdx) +s32 host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv, u8 u8keyIdx) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; @@ -4713,9 +4713,9 @@ WILC_Sint32 host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv, u8 u8keyIdx) * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_set_WEPDefaultKeyID(WILC_WFIDrvHandle hWFIDrv, u8 u8Index) +s32 host_int_set_WEPDefaultKeyID(WILC_WFIDrvHandle hWFIDrv, u8 u8Index) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; @@ -4770,10 +4770,10 @@ WILC_Sint32 host_int_set_WEPDefaultKeyID(WILC_WFIDrvHandle hWFIDrv, u8 u8Index) * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx) +s32 host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; @@ -4836,10 +4836,10 @@ WILC_Sint32 host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv, const u8 *pu * @date 28 FEB 2013 * @version 1.0 */ -WILC_Sint32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx, u8 u8mode, AUTHTYPE_T tenuAuth_type) +s32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx, u8 u8mode, AUTHTYPE_T tenuAuth_type) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; u8 i; @@ -4912,10 +4912,10 @@ WILC_Sint32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8 * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen, +s32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen, const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode, u8 u8Idx) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; u8 u8KeyLen = u8PtkKeylen; @@ -5014,11 +5014,11 @@ WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8Ptk, u8 u8P * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen, +s32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen, u8 u8KeyIdx, u32 u32KeyRSClen, const u8 *KeyRSC, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; u8 u8KeyLen = u8GtkKeylen; @@ -5120,9 +5120,9 @@ WILC_Sint32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8RxGtk, u * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_add_tx_gtk(WILC_WFIDrvHandle hWFIDrv, u8 u8KeyLen, u8 *pu8TxGtk, u8 u8KeyIdx) +s32 host_int_add_tx_gtk(WILC_WFIDrvHandle hWFIDrv, u8 u8KeyLen, u8 *pu8TxGtk, u8 u8KeyIdx) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; @@ -5182,9 +5182,9 @@ WILC_Sint32 host_int_add_tx_gtk(WILC_WFIDrvHandle hWFIDrv, u8 u8KeyLen, u8 *pu8T * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_set_pmkid_info(WILC_WFIDrvHandle hWFIDrv, tstrHostIFpmkidAttr *pu8PmkidInfoArray) +s32 host_int_set_pmkid_info(WILC_WFIDrvHandle hWFIDrv, tstrHostIFpmkidAttr *pu8PmkidInfoArray) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; u32 i; @@ -5245,10 +5245,10 @@ WILC_Sint32 host_int_set_pmkid_info(WILC_WFIDrvHandle hWFIDrv, tstrHostIFpmkidAt * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_get_pmkid_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PmkidInfoArray, +s32 host_int_get_pmkid_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PmkidInfoArray, u32 u32PmkidInfoLen) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ @@ -5274,10 +5274,10 @@ WILC_Sint32 host_int_get_pmkid_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PmkidInfoA * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_set_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PassPhrase, +s32 host_int_set_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PassPhrase, u8 u8Psklength) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ @@ -5303,9 +5303,9 @@ WILC_Sint32 host_int_set_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, u8 * * @date 19 April 2012 * @version 1.0 */ -WILC_Sint32 host_int_get_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress) +s32 host_int_get_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; @@ -5337,9 +5337,9 @@ WILC_Sint32 host_int_get_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress * @date 16 July 2012 * @version 1.0 */ -WILC_Sint32 host_int_set_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress) +s32 host_int_set_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]); @@ -5378,10 +5378,10 @@ WILC_Sint32 host_int_set_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_get_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, +s32 host_int_get_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PassPhrase, u8 u8Psklength) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ @@ -5425,11 +5425,11 @@ WILC_Sint32 host_int_get_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, * @version 1.0 */ #ifndef CONNECT_DIRECT -WILC_Sint32 host_int_get_site_survey_results(WILC_WFIDrvHandle hWFIDrv, +s32 host_int_get_site_survey_results(WILC_WFIDrvHandle hWFIDrv, u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE], u32 u32MaxSiteSrvyFragLen) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID astrWIDList[2]; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -5475,9 +5475,9 @@ WILC_Sint32 host_int_get_site_survey_results(WILC_WFIDrvHandle hWFIDrv, * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_set_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 scanSource) +s32 host_int_set_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 scanSource) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ @@ -5505,9 +5505,9 @@ WILC_Sint32 host_int_set_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 scanSource * @version 1.0 */ -WILC_Sint32 host_int_get_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ScanSource) +s32 host_int_get_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ScanSource) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ @@ -5530,7 +5530,7 @@ WILC_Sint32 host_int_get_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ScanSo * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8bssid, +s32 host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8bssid, const u8 *pu8ssid, size_t ssidLen, const u8 *pu8IEs, size_t IEsLen, tWILCpfConnectResult pfConnectResult, void *pvUserArg, @@ -5538,7 +5538,7 @@ WILC_Sint32 host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8bssid, u8 u8channel, void *pJoinParams) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; tenuScanConnTimer enuScanConnTimer; @@ -5632,9 +5632,9 @@ WILC_Sint32 host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8bssid, * @version 8.0 */ -WILC_Sint32 host_int_flush_join_req(WILC_WFIDrvHandle hWFIDrv) +s32 host_int_flush_join_req(WILC_WFIDrvHandle hWFIDrv) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; if (!gu8FlushedJoinReq) { @@ -5676,9 +5676,9 @@ WILC_Sint32 host_int_flush_join_req(WILC_WFIDrvHandle hWFIDrv) * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_disconnect(WILC_WFIDrvHandle hWFIDrv, u16 u16ReasonCode) +s32 host_int_disconnect(WILC_WFIDrvHandle hWFIDrv, u16 u16ReasonCode) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -5725,9 +5725,9 @@ WILC_Sint32 host_int_disconnect(WILC_WFIDrvHandle hWFIDrv, u16 u16ReasonCode) * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_disconnect_station(WILC_WFIDrvHandle hWFIDrv, u8 assoc_id) +s32 host_int_disconnect_station(WILC_WFIDrvHandle hWFIDrv, u8 assoc_id) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ @@ -5765,10 +5765,10 @@ WILC_Sint32 host_int_disconnect_station(WILC_WFIDrvHandle hWFIDrv, u8 assoc_id) * @version 1.0 */ -WILC_Sint32 host_int_get_assoc_req_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocReqInfo, +s32 host_int_get_assoc_req_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocReqInfo, u32 u32AssocReqInfoLen) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ @@ -5792,10 +5792,10 @@ WILC_Sint32 host_int_get_assoc_req_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocR * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocRespInfo, +s32 host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocRespInfo, u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -5842,10 +5842,10 @@ WILC_Sint32 host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocR * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_get_rx_power_level(WILC_WFIDrvHandle hWFIDrv, u8 *pu8RxPowerLevel, +s32 host_int_get_rx_power_level(WILC_WFIDrvHandle hWFIDrv, u8 *pu8RxPowerLevel, u32 u32RxPowerLevelLen) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ @@ -5873,9 +5873,9 @@ WILC_Sint32 host_int_get_rx_power_level(WILC_WFIDrvHandle hWFIDrv, u8 *pu8RxPowe * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_set_mac_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 u8ChNum) +s32 host_int_set_mac_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 u8ChNum) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; @@ -5902,9 +5902,9 @@ WILC_Sint32 host_int_set_mac_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 u8ChNum) } -WILC_Sint32 host_int_wait_msg_queue_idle(void) +s32 host_int_wait_msg_queue_idle(void) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; @@ -5928,9 +5928,9 @@ WILC_Sint32 host_int_wait_msg_queue_idle(void) } -WILC_Sint32 host_int_set_wfi_drv_handler(u32 u32address) +s32 host_int_set_wfi_drv_handler(u32 u32address) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; @@ -5956,9 +5956,9 @@ WILC_Sint32 host_int_set_wfi_drv_handler(u32 u32address) -WILC_Sint32 host_int_set_operation_mode(WILC_WFIDrvHandle hWFIDrv, u32 u32mode) +s32 host_int_set_operation_mode(WILC_WFIDrvHandle hWFIDrv, u32 u32mode) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; @@ -5997,9 +5997,9 @@ WILC_Sint32 host_int_set_operation_mode(WILC_WFIDrvHandle hWFIDrv, u32 u32mode) * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_get_host_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ChNo) +s32 host_int_get_host_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ChNo) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; @@ -6043,9 +6043,9 @@ WILC_Sint32 host_int_get_host_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ChNo) * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_test_set_int_wid(WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr) +s32 host_int_test_set_int_wid(WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -6090,9 +6090,9 @@ WILC_Sint32 host_int_test_set_int_wid(WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemA * @date * @version 1.0 */ -WILC_Sint32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, const u8 *mac, u32 *pu32InactiveTime) +s32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, const u8 *mac, u32 *pu32InactiveTime) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; @@ -6136,10 +6136,10 @@ WILC_Sint32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, const u8 *mac, * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_test_get_int_wid(WILC_WFIDrvHandle hWFIDrv, u32 *pu32TestMemAddr) +s32 host_int_test_get_int_wid(WILC_WFIDrvHandle hWFIDrv, u32 *pu32TestMemAddr) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWID strWID; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -6185,9 +6185,9 @@ WILC_Sint32 host_int_test_get_int_wid(WILC_WFIDrvHandle hWFIDrv, u32 *pu32TestMe * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_get_rssi(WILC_WFIDrvHandle hWFIDrv, s8 *ps8Rssi) +s32 host_int_get_rssi(WILC_WFIDrvHandle hWFIDrv, s8 *ps8Rssi) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -6220,10 +6220,10 @@ WILC_Sint32 host_int_get_rssi(WILC_WFIDrvHandle hWFIDrv, s8 *ps8Rssi) return s32Error; } -WILC_Sint32 host_int_get_link_speed(WILC_WFIDrvHandle hWFIDrv, s8 *ps8lnkspd) +s32 host_int_get_link_speed(WILC_WFIDrvHandle hWFIDrv, s8 *ps8lnkspd) { tstrHostIFmsg strHostIFmsg; - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -6257,9 +6257,9 @@ WILC_Sint32 host_int_get_link_speed(WILC_WFIDrvHandle hWFIDrv, s8 *ps8lnkspd) return s32Error; } -WILC_Sint32 host_int_get_statistics(WILC_WFIDrvHandle hWFIDrv, tstrStatistics *pstrStatistics) +s32 host_int_get_statistics(WILC_WFIDrvHandle hWFIDrv, tstrStatistics *pstrStatistics) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; @@ -6297,13 +6297,13 @@ WILC_Sint32 host_int_get_statistics(WILC_WFIDrvHandle hWFIDrv, tstrStatistics *p * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_scan(WILC_WFIDrvHandle hWFIDrv, u8 u8ScanSource, +s32 host_int_scan(WILC_WFIDrvHandle hWFIDrv, u8 u8ScanSource, u8 u8ScanType, u8 *pu8ChnlFreqList, u8 u8ChnlListLen, const u8 *pu8IEs, size_t IEsLen, tWILCpfScanResult ScanResult, void *pvUserArg, tstrHiddenNetwork *pstrHiddenNetwork) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; tenuScanConnTimer enuScanConnTimer; @@ -6371,10 +6371,10 @@ WILC_Sint32 host_int_scan(WILC_WFIDrvHandle hWFIDrv, u8 u8ScanSource, * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 hif_set_cfg(WILC_WFIDrvHandle hWFIDrv, tstrCfgParamVal *pstrCfgParamVal) +s32 hif_set_cfg(WILC_WFIDrvHandle hWFIDrv, tstrCfgParamVal *pstrCfgParamVal) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; @@ -6413,9 +6413,9 @@ WILC_Sint32 hif_set_cfg(WILC_WFIDrvHandle hWFIDrv, tstrCfgParamVal *pstrCfgParam * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, u16 u16WID, u16 *pu16WID_Value) +s32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, u16 u16WID, u16 *pu16WID_Value) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; down(&(pstrWFIDrv->gtOsCfgValuesSem)); @@ -6557,7 +6557,7 @@ void GetPeriodicRSSI(void *pvArg) } if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; /* prepare the Get RSSI Message */ @@ -6594,9 +6594,9 @@ static u32 u32Intialized; static u32 msgQ_created; static u32 clients_count; -WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) +s32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv; /*if(u32Intialized == 1) @@ -6787,9 +6787,9 @@ _fail_: * @version 1.0 */ -WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv) +s32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; @@ -6916,7 +6916,7 @@ WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv) */ void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; u32 drvHandler; tstrWILC_WFIDrv *pstrWFIDrv = NULL; @@ -6966,7 +6966,7 @@ void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length) */ void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; u32 drvHandler; tstrWILC_WFIDrv *pstrWFIDrv = NULL; @@ -7029,7 +7029,7 @@ void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length) */ void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrHostIFmsg strHostIFmsg; u32 drvHandler; tstrWILC_WFIDrv *pstrWFIDrv = NULL; @@ -7087,9 +7087,9 @@ void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length) * @date * @version 1.0 */ -WILC_Sint32 host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv, u32 u32SessionID, u32 u32duration, u16 chan, tWILCpfRemainOnChanExpired RemainOnChanExpired, tWILCpfRemainOnChanReady RemainOnChanReady, void *pvUserArg) +s32 host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv, u32 u32SessionID, u32 u32duration, u16 chan, tWILCpfRemainOnChanExpired RemainOnChanExpired, tWILCpfRemainOnChanReady RemainOnChanReady, void *pvUserArg) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; @@ -7136,9 +7136,9 @@ WILC_Sint32 host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv, u32 u32Session * @date * @version 1.0 */ -WILC_Sint32 host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv, u32 u32SessionID) +s32 host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv, u32 u32SessionID) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; @@ -7174,9 +7174,9 @@ WILC_Sint32 host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv, u32 u32Sessio * @author * @date * @version 1.0*/ -WILC_Sint32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, u16 u16FrameType, WILC_Bool bReg) +s32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, u16 u16FrameType, WILC_Bool bReg) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; @@ -7234,12 +7234,12 @@ WILC_Sint32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, u16 u16FrameType, * @date * @version 1.0 */ -WILC_Sint32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, u32 u32Interval, +s32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, u32 u32Interval, u32 u32DTIMPeriod, u32 u32HeadLen, u8 *pu8Head, u32 u32TailLen, u8 *pu8Tail) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; tstrHostIFSetBeacon *pstrSetBeaconParam = &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon; @@ -7307,9 +7307,9 @@ WILC_Sint32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, u32 u32Interval, * @date * @version 1.0 */ -WILC_Sint32 host_int_del_beacon(WILC_WFIDrvHandle hWFIDrv) +s32 host_int_del_beacon(WILC_WFIDrvHandle hWFIDrv) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; @@ -7341,9 +7341,9 @@ WILC_Sint32 host_int_del_beacon(WILC_WFIDrvHandle hWFIDrv) * @date * @version 1.0 */ -WILC_Sint32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrStaParams) +s32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrStaParams) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam; @@ -7392,9 +7392,9 @@ WILC_Sint32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam * @date * @version 1.0 */ -WILC_Sint32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8MacAddr) +s32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8MacAddr) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; tstrHostIFDelSta *pstrDelStationMsg = &strHostIFmsg.uniHostIFmsgBody.strDelStaParam; @@ -7438,9 +7438,9 @@ WILC_Sint32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8MacAddr * @date * @version 1.0 */ -WILC_Sint32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]) +s32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; tstrHostIFDelAllSta *pstrDelAllStationMsg = &strHostIFmsg.uniHostIFmsgBody.strHostIFDelAllSta; @@ -7502,9 +7502,9 @@ WILC_Sint32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][E * @date * @version 1.0 */ -WILC_Sint32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrStaParams) +s32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrStaParams) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam; @@ -7542,9 +7542,9 @@ WILC_Sint32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaPara #endif /*WILC_AP_EXTERNAL_MLME*/ uint32_t wilc_get_chipid(uint8_t); -WILC_Sint32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, u32 u32Timeout) +s32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, u32 u32Timeout) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; tstrHostIfPowerMgmtParam *pstrPowerMgmtParam = &strHostIFmsg.uniHostIFmsgBody.strPowerMgmtparam; @@ -7578,9 +7578,9 @@ WILC_Sint32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnab return s32Error; } -WILC_Sint32 host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, u32 u32count) +s32 host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, u32 u32count) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; @@ -7853,7 +7853,7 @@ void host_int_freeJoinParams(void *pJoinParams) static int host_int_addBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID, short int BufferSize, short int SessionTimeout, void *drvHandler) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo; @@ -7886,9 +7886,9 @@ static int host_int_addBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char T } -WILC_Sint32 host_int_delBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID) +s32 host_int_delBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo; @@ -7921,9 +7921,9 @@ WILC_Sint32 host_int_delBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char return s32Error; } -WILC_Sint32 host_int_del_All_Rx_BASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID) +s32 host_int_del_All_Rx_BASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo; @@ -7964,9 +7964,9 @@ WILC_Sint32 host_int_del_All_Rx_BASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSI * @author Abdelrahman Sobhy * @date * @version 1.0*/ -WILC_Sint32 host_int_setup_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *u16ipadd, u8 idx) +s32 host_int_setup_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *u16ipadd, u8 idx) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; @@ -8008,9 +8008,9 @@ WILC_Sint32 host_int_setup_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *u16ipadd, u8 * @author Abdelrahman Sobhy * @date * @version 1.0*/ -WILC_Sint32 host_int_get_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *u16ipadd, u8 idx) +s32 host_int_get_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *u16ipadd, u8 idx) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; tstrHostIFmsg strHostIFmsg; diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 1f107d0b2ce0..afe92063f44f 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -277,7 +277,7 @@ typedef void (*tWILCpfRemainOnChanReady)(void *); /*Remain on channel callback f /* typedef u32 WILC_WFIDrvHandle; */ typedef struct { - WILC_Sint32 s32Dummy; + s32 s32Dummy; } *WILC_WFIDrvHandle; /*! @@ -496,7 +496,7 @@ typedef struct { * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_remove_key(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8StaAddress); +s32 host_int_remove_key(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8StaAddress); /** * @brief removes WEP key * @details valid only in BSS STA mode if External Supplicant support is enabled. @@ -511,7 +511,7 @@ WILC_Sint32 host_int_remove_key(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8StaAddre * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv, u8 u8Index); +s32 host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv, u8 u8Index); /** * @brief sets WEP deafault key * @details Sets the index of the WEP encryption key in use, @@ -524,7 +524,7 @@ WILC_Sint32 host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv, u8 u8Index); * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_set_WEPDefaultKeyID(WILC_WFIDrvHandle hWFIDrv, u8 u8Index); +s32 host_int_set_WEPDefaultKeyID(WILC_WFIDrvHandle hWFIDrv, u8 u8Index); /** * @brief sets WEP deafault key @@ -545,7 +545,7 @@ WILC_Sint32 host_int_set_WEPDefaultKeyID(WILC_WFIDrvHandle hWFIDrv, u8 u8Index); * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx); +s32 host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx); /** * @brief host_int_add_wep_key_bss_ap * @details valid only in AP mode if External Supplicant support is enabled. @@ -560,7 +560,7 @@ WILC_Sint32 host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv, const u8 *pu * @date 28 Feb 2013 * @version 1.0 */ -WILC_Sint32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx, u8 u8mode, AUTHTYPE_T tenuAuth_type); +s32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx, u8 u8mode, AUTHTYPE_T tenuAuth_type); /** * @brief adds ptk Key @@ -578,7 +578,7 @@ WILC_Sint32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8 * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen, +s32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen, const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode, u8 u8Idx); /** @@ -593,7 +593,7 @@ WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8Ptk, u8 u8P * @date 15 April 2013 * @version 1.0 */ -WILC_Sint32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, const u8 *mac, u32 *pu32InactiveTime); +s32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, const u8 *mac, u32 *pu32InactiveTime); /** * @brief adds Rx GTk Key @@ -611,7 +611,7 @@ WILC_Sint32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, const u8 *mac, * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen, +s32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen, u8 u8KeyIdx, u32 u32KeyRSClen, const u8 *KeyRSC, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode); @@ -632,7 +632,7 @@ WILC_Sint32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8RxGtk, u * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_add_tx_gtk(WILC_WFIDrvHandle hWFIDrv, u8 u8KeyLen, u8 *pu8TxGtk, u8 u8KeyIdx); +s32 host_int_add_tx_gtk(WILC_WFIDrvHandle hWFIDrv, u8 u8KeyLen, u8 *pu8TxGtk, u8 u8KeyIdx); /** * @brief caches the pmkid @@ -655,7 +655,7 @@ WILC_Sint32 host_int_add_tx_gtk(WILC_WFIDrvHandle hWFIDrv, u8 u8KeyLen, u8 *pu8T * @version 1.0 */ -WILC_Sint32 host_int_set_pmkid_info(WILC_WFIDrvHandle hWFIDrv, tstrHostIFpmkidAttr *pu8PmkidInfoArray); +s32 host_int_set_pmkid_info(WILC_WFIDrvHandle hWFIDrv, tstrHostIFpmkidAttr *pu8PmkidInfoArray); /** * @brief gets the cached the pmkid info * @details valid only in BSS STA mode if External Supplicant @@ -679,7 +679,7 @@ WILC_Sint32 host_int_set_pmkid_info(WILC_WFIDrvHandle hWFIDrv, tstrHostIFpmkidAt * @version 1.0 */ -WILC_Sint32 host_int_get_pmkid_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PmkidInfoArray, +s32 host_int_get_pmkid_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PmkidInfoArray, u32 u32PmkidInfoLen); /** @@ -696,7 +696,7 @@ WILC_Sint32 host_int_get_pmkid_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PmkidInfoA * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_set_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PassPhrase, +s32 host_int_set_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PassPhrase, u8 u8Psklength); /** * @brief gets the pass phrase @@ -712,7 +712,7 @@ WILC_Sint32 host_int_set_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, u8 * * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_get_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, +s32 host_int_get_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PassPhrase, u8 u8Psklength); /** @@ -726,7 +726,7 @@ WILC_Sint32 host_int_get_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, * @date 19 April 2012 * @version 1.0 */ -WILC_Sint32 host_int_get_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress); +s32 host_int_get_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress); /** * @brief sets mac address @@ -739,7 +739,7 @@ WILC_Sint32 host_int_get_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress * @date 16 July 2012 * @version 1.0 */ -WILC_Sint32 host_int_set_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress); +s32 host_int_set_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress); /** * @brief wait until msg q is empty @@ -752,7 +752,7 @@ WILC_Sint32 host_int_set_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress * @date 19 march 2014 * @version 1.0 */ -WILC_Sint32 host_int_wait_msg_queue_idle(void); +s32 host_int_wait_msg_queue_idle(void); /** * @brief gets the site survey results @@ -784,7 +784,7 @@ WILC_Sint32 host_int_wait_msg_queue_idle(void); * @version 1.0 */ #ifndef CONNECT_DIRECT -WILC_Sint32 host_int_get_site_survey_results(WILC_WFIDrvHandle hWFIDrv, +s32 host_int_get_site_survey_results(WILC_WFIDrvHandle hWFIDrv, u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE], u32 u32MaxSiteSrvyFragLen); #endif @@ -805,7 +805,7 @@ WILC_Sint32 host_int_get_site_survey_results(WILC_WFIDrvHandle hWFIDrv, * @version 1.0 */ -WILC_Sint32 host_int_set_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 scanSource); +s32 host_int_set_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 scanSource); /** * @brief gets scan source of the last scan * @details @@ -821,7 +821,7 @@ WILC_Sint32 host_int_set_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 scanSource * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_get_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ScanSource); +s32 host_int_get_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ScanSource); /** * @brief sets a join request @@ -835,7 +835,7 @@ WILC_Sint32 host_int_get_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ScanSo * @version 1.0 */ -WILC_Sint32 host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8bssid, +s32 host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8bssid, const u8 *pu8ssid, size_t ssidLen, const u8 *pu8IEs, size_t IEsLen, tWILCpfConnectResult pfConnectResult, void *pvUserArg, @@ -855,7 +855,7 @@ WILC_Sint32 host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8bssid, * @version 8.0 */ -WILC_Sint32 host_int_flush_join_req(WILC_WFIDrvHandle hWFIDrv); +s32 host_int_flush_join_req(WILC_WFIDrvHandle hWFIDrv); /** @@ -869,7 +869,7 @@ WILC_Sint32 host_int_flush_join_req(WILC_WFIDrvHandle hWFIDrv); * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_disconnect(WILC_WFIDrvHandle hWFIDrv, u16 u16ReasonCode); +s32 host_int_disconnect(WILC_WFIDrvHandle hWFIDrv, u16 u16ReasonCode); /** * @brief disconnects a sta @@ -882,7 +882,7 @@ WILC_Sint32 host_int_disconnect(WILC_WFIDrvHandle hWFIDrv, u16 u16ReasonCode); * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_disconnect_station(WILC_WFIDrvHandle hWFIDrv, u8 assoc_id); +s32 host_int_disconnect_station(WILC_WFIDrvHandle hWFIDrv, u8 assoc_id); /** * @brief gets a Association request info * @details @@ -909,7 +909,7 @@ WILC_Sint32 host_int_disconnect_station(WILC_WFIDrvHandle hWFIDrv, u8 assoc_id); * @version 1.0 */ -WILC_Sint32 host_int_get_assoc_req_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocReqInfo, +s32 host_int_get_assoc_req_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocReqInfo, u32 u32AssocReqInfoLen); /** * @brief gets a Association Response info @@ -923,7 +923,7 @@ WILC_Sint32 host_int_get_assoc_req_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocR * @version 1.0 */ -WILC_Sint32 host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocRespInfo, +s32 host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocRespInfo, u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen); /** * @brief gets a Association Response info @@ -940,7 +940,7 @@ WILC_Sint32 host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocR * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_get_rx_power_level(WILC_WFIDrvHandle hWFIDrv, u8 *pu8RxPowerLevel, +s32 host_int_get_rx_power_level(WILC_WFIDrvHandle hWFIDrv, u8 *pu8RxPowerLevel, u32 u32RxPowerLevelLen); /** @@ -958,7 +958,7 @@ WILC_Sint32 host_int_get_rx_power_level(WILC_WFIDrvHandle hWFIDrv, u8 *pu8RxPowe * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_set_mac_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 u8ChNum); +s32 host_int_set_mac_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 u8ChNum); /** * @brief gets the current channel index @@ -975,7 +975,7 @@ WILC_Sint32 host_int_set_mac_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 u8ChNum); * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_get_host_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ChNo); +s32 host_int_get_host_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ChNo); /** * @brief gets the sta rssi * @details gets the currently maintained RSSI value for the station. @@ -989,8 +989,8 @@ WILC_Sint32 host_int_get_host_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ChNo); * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_get_rssi(WILC_WFIDrvHandle hWFIDrv, s8 *ps8Rssi); -WILC_Sint32 host_int_get_link_speed(WILC_WFIDrvHandle hWFIDrv, s8 *ps8lnkspd); +s32 host_int_get_rssi(WILC_WFIDrvHandle hWFIDrv, s8 *ps8Rssi); +s32 host_int_get_link_speed(WILC_WFIDrvHandle hWFIDrv, s8 *ps8lnkspd); /** * @brief scans a set of channels * @details @@ -1008,7 +1008,7 @@ WILC_Sint32 host_int_get_link_speed(WILC_WFIDrvHandle hWFIDrv, s8 *ps8lnkspd); * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_scan(WILC_WFIDrvHandle hWFIDrv, u8 u8ScanSource, +s32 host_int_scan(WILC_WFIDrvHandle hWFIDrv, u8 u8ScanSource, u8 u8ScanType, u8 *pu8ChnlFreqList, u8 u8ChnlListLen, const u8 *pu8IEs, size_t IEsLen, tWILCpfScanResult ScanResult, @@ -1024,7 +1024,7 @@ WILC_Sint32 host_int_scan(WILC_WFIDrvHandle hWFIDrv, u8 u8ScanSource, * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 hif_set_cfg(WILC_WFIDrvHandle hWFIDrv, tstrCfgParamVal *pstrCfgParamVal); +s32 hif_set_cfg(WILC_WFIDrvHandle hWFIDrv, tstrCfgParamVal *pstrCfgParamVal); /** * @brief gets configuration wids values @@ -1038,7 +1038,7 @@ WILC_Sint32 hif_set_cfg(WILC_WFIDrvHandle hWFIDrv, tstrCfgParamVal *pstrCfgParam * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, u16 u16WID, u16 *pu16WID_Value); +s32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, u16 u16WID, u16 *pu16WID_Value); /*****************************************************************************/ /* Notification Functions */ /*****************************************************************************/ @@ -1085,7 +1085,7 @@ void host_int_send_network_info_to_host * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv); +s32 host_int_init(WILC_WFIDrvHandle *phWFIDrv); /** * @brief host interface initialization function @@ -1096,11 +1096,11 @@ WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv); * @date 8 March 2012 * @version 1.0 */ -WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv); +s32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv); /*! - * @fn WILC_Sint32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv,u8 u8Index) + * @fn s32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv,u8 u8Index) * @brief Sends a beacon to the firmware to be transmitted over the air * @details * @param[in,out] hWFIDrv handle to the wifi driver @@ -1121,14 +1121,14 @@ WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv); * @version 1.0 Description * */ -WILC_Sint32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, u32 u32Interval, +s32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, u32 u32Interval, u32 u32DTIMPeriod, u32 u32HeadLen, u8 *pu8Head, u32 u32TailLen, u8 *pu8tail); /*! - * @fn WILC_Sint32 host_int_del_beacon(WILC_WFIDrvHandle hWFIDrv) + * @fn s32 host_int_del_beacon(WILC_WFIDrvHandle hWFIDrv) * @brief Removes the beacon and stops trawilctting it over the air * @details * @param[in,out] hWFIDrv handle to the wifi driver @@ -1139,10 +1139,10 @@ WILC_Sint32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, u32 u32Interval, * @date 10 Julys 2012 * @version 1.0 Description */ -WILC_Sint32 host_int_del_beacon(WILC_WFIDrvHandle hWFIDrv); +s32 host_int_del_beacon(WILC_WFIDrvHandle hWFIDrv); /*! - * @fn WILC_Sint32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam strStaParams) + * @fn s32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam strStaParams) * @brief Notifies the firmware with a new associated stations * @details * @param[in,out] hWFIDrv handle to the wifi driver @@ -1154,10 +1154,10 @@ WILC_Sint32 host_int_del_beacon(WILC_WFIDrvHandle hWFIDrv); * @date 12 July 2012 * @version 1.0 Description */ -WILC_Sint32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrStaParams); +s32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrStaParams); /*! - * @fn WILC_Sint32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, const u8* pu8MacAddr) + * @fn s32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, const u8* pu8MacAddr) * @brief Deauthenticates clients when group is terminating * @details * @param[in,out] hWFIDrv handle to the wifi driver @@ -1169,10 +1169,10 @@ WILC_Sint32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam * @date 09 April 2014 * @version 1.0 Description */ -WILC_Sint32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]); +s32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]); /*! - * @fn WILC_Sint32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr) + * @fn s32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr) * @brief Notifies the firmware with a new deleted station * @details * @param[in,out] hWFIDrv handle to the wifi driver @@ -1184,10 +1184,10 @@ WILC_Sint32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][E * @date 15 July 2012 * @version 1.0 Description */ -WILC_Sint32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8MacAddr); +s32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8MacAddr); /*! - * @fn WILC_Sint32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam strStaParams) + * @fn s32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam strStaParams) * @brief Notifies the firmware with new parameters of an already associated station * @details * @param[in,out] hWFIDrv handle to the wifi driver @@ -1199,10 +1199,10 @@ WILC_Sint32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8MacAddr * @date 15 July 2012 * @version 1.0 Description */ -WILC_Sint32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrStaParams); +s32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrStaParams); /*! - * @fn WILC_Sint32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, u32 u32Timeout) + * @fn s32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, u32 u32Timeout) * @brief Set the power management mode to enabled or disabled * @details * @param[in,out] hWFIDrv handle to the wifi driver @@ -1216,7 +1216,7 @@ WILC_Sint32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaPara * @date 24 November 2012 * @version 1.0 Description */ -WILC_Sint32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, u32 u32Timeout); +s32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, u32 u32Timeout); /* @param[in,out] hWFIDrv handle to the wifi driver * @param[in] bIsEnabled TRUE if enabled, FALSE otherwise * @param[in] u8count count of mac address entries in the filter table @@ -1228,7 +1228,7 @@ WILC_Sint32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnab * @date 24 November 2012 * @version 1.0 Description */ -WILC_Sint32 host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, u32 u32count); +s32 host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, u32 u32count); /** * @brief host_int_setup_ipaddress * @details set IP address on firmware @@ -1238,7 +1238,7 @@ WILC_Sint32 host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv, WILC_Bool * @date * @version 1.0 */ -WILC_Sint32 host_int_setup_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8IPAddr, u8 idx); +s32 host_int_setup_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8IPAddr, u8 idx); /** @@ -1250,7 +1250,7 @@ WILC_Sint32 host_int_setup_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8IPAddr, u * @date * @version 1.0 */ -WILC_Sint32 host_int_delBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID); +s32 host_int_delBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID); /** * @brief host_int_delBASession @@ -1261,7 +1261,7 @@ WILC_Sint32 host_int_delBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char * @date * @version 1.0 */ -WILC_Sint32 host_int_del_All_Rx_BASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID); +s32 host_int_del_All_Rx_BASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID); /** @@ -1273,7 +1273,7 @@ WILC_Sint32 host_int_del_All_Rx_BASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSI * @date * @version 1.0 */ -WILC_Sint32 host_int_get_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8IPAddr, u8 idx); +s32 host_int_get_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8IPAddr, u8 idx); #ifdef WILC_P2P /** @@ -1285,7 +1285,7 @@ WILC_Sint32 host_int_get_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8IPAddr, u8 * @date * @version 1.0 */ -WILC_Sint32 host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv, u32 u32SessionID, u32 u32duration, u16 chan, tWILCpfRemainOnChanExpired RemainOnChanExpired, tWILCpfRemainOnChanReady RemainOnChanReady, void *pvUserArg); +s32 host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv, u32 u32SessionID, u32 u32duration, u16 chan, tWILCpfRemainOnChanExpired RemainOnChanExpired, tWILCpfRemainOnChanReady RemainOnChanReady, void *pvUserArg); /** * @brief host_int_ListenStateExpired @@ -1301,7 +1301,7 @@ WILC_Sint32 host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv, u32 u32Session * @date * @version 1.0 */ -WILC_Sint32 host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv, u32 u32SessionID); +s32 host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv, u32 u32SessionID); /** * @brief host_int_frame_register @@ -1312,7 +1312,7 @@ WILC_Sint32 host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv, u32 u32Sessio * @date * @version 1.0 */ -WILC_Sint32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, u16 u16FrameType, WILC_Bool bReg); +s32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, u16 u16FrameType, WILC_Bool bReg); #endif /** * @brief host_int_set_wfi_drv_handler @@ -1323,10 +1323,10 @@ WILC_Sint32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, u16 u16FrameType, * @date * @version 1.0 */ -WILC_Sint32 host_int_set_wfi_drv_handler(u32 u32address); -WILC_Sint32 host_int_set_operation_mode(WILC_WFIDrvHandle hWFIDrv, u32 u32mode); +s32 host_int_set_wfi_drv_handler(u32 u32address); +s32 host_int_set_operation_mode(WILC_WFIDrvHandle hWFIDrv, u32 u32mode); -static WILC_Sint32 Handle_ScanDone(void *drvHandler, tenuScanEvent enuEvent); +static s32 Handle_ScanDone(void *drvHandler, tenuScanEvent enuEvent); static int host_int_addBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID, short int BufferSize, short int SessionTimeout, void *drvHandler); @@ -1334,7 +1334,7 @@ static int host_int_addBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char T void host_int_freeJoinParams(void *pJoinParams); -WILC_Sint32 host_int_get_statistics(WILC_WFIDrvHandle hWFIDrv, tstrStatistics *pstrStatistics); +s32 host_int_get_statistics(WILC_WFIDrvHandle hWFIDrv, tstrStatistics *pstrStatistics); /*****************************************************************************/ /* */ diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 6b8001da31c6..3aa9a4b6b4f0 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -2379,7 +2379,7 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) u32 size = 0, length = 0; perInterface_wlan_t *nic; struct WILC_WFI_priv *priv; - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; diff --git a/drivers/staging/wilc1000/wilc_errorsupport.h b/drivers/staging/wilc1000/wilc_errorsupport.h index dd8affabc80d..6963a4694d3f 100644 --- a/drivers/staging/wilc1000/wilc_errorsupport.h +++ b/drivers/staging/wilc1000/wilc_errorsupport.h @@ -37,7 +37,7 @@ /* Error type */ -typedef WILC_Sint32 WILC_ErrNo; +typedef s32 WILC_ErrNo; #define WILC_IS_ERR(__status__) (__status__ < WILC_SUCCESS) diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index 6deec34646a6..f9a5a3afffe9 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -14,7 +14,6 @@ #define WILC_OSW_INTERFACE_VER 2 /* Integer Types */ -typedef signed int WILC_Sint32; typedef signed long long WILC_Sint64; /* Boolean type */ diff --git a/drivers/staging/wilc1000/wilc_strutils.c b/drivers/staging/wilc1000/wilc_strutils.c index 52df793e0a37..e9f487a3b956 100644 --- a/drivers/staging/wilc1000/wilc_strutils.c +++ b/drivers/staging/wilc1000/wilc_strutils.c @@ -9,7 +9,7 @@ * @date 18 Aug 2010 * @version 1.0 */ -WILC_Sint32 WILC_memcmp(const void *pvArg1, const void *pvArg2, u32 u32Count) +s32 WILC_memcmp(const void *pvArg1, const void *pvArg2, u32 u32Count) { return memcmp(pvArg1, pvArg2, u32Count); } @@ -46,10 +46,10 @@ WILC_Char *WILC_strncpy(WILC_Char *pcTarget, const WILC_Char *pcSource, return strncpy(pcTarget, pcSource, u32Count); } -WILC_Sint32 WILC_strncmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2, +s32 WILC_strncmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2, u32 u32Count) { - WILC_Sint32 s32Result; + s32 s32Result; if (pcStr1 == NULL && pcStr2 == NULL) { s32Result = 0; diff --git a/drivers/staging/wilc1000/wilc_strutils.h b/drivers/staging/wilc1000/wilc_strutils.h index 6d9b400ecc18..75670a2800bc 100644 --- a/drivers/staging/wilc1000/wilc_strutils.h +++ b/drivers/staging/wilc1000/wilc_strutils.h @@ -22,7 +22,7 @@ * @date 18 Aug 2010 * @version 1.0 */ -WILC_Sint32 WILC_memcmp(const void *pvArg1, const void *pvArg2, u32 u32Count); +s32 WILC_memcmp(const void *pvArg1, const void *pvArg2, u32 u32Count); /*! * @brief Internal implementation for memory copy @@ -113,7 +113,7 @@ WILC_Char *WILC_strncpy(WILC_Char *pcTarget, const WILC_Char *pcSource, * @date 7 Dec 2010 * @version 1.0 */ -WILC_Sint32 WILC_strncmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2, +s32 WILC_strncmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2, u32 u32Count); /*! diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index f330876e465b..fde2a649e758 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -195,19 +195,19 @@ void refresh_scan(void *pUserVoid, uint8_t all, WILC_Bool bDirectScan) if ((!pstrNetworkInfo->u8Found) || all) { - WILC_Sint32 s32Freq; + s32 s32Freq; struct ieee80211_channel *channel; if (pstrNetworkInfo != NULL) { - s32Freq = ieee80211_channel_to_frequency((WILC_Sint32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ); + s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ); channel = ieee80211_get_channel(wiphy, s32Freq); rssi = get_rssi_avg(pstrNetworkInfo); if (WILC_memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7) || bDirectScan) { bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs, - (size_t)pstrNetworkInfo->u16IEsLen, (((WILC_Sint32)rssi) * 100), GFP_KERNEL); + (size_t)pstrNetworkInfo->u16IEsLen, (((s32)rssi) * 100), GFP_KERNEL); cfg80211_put_bss(wiphy, bss); } } @@ -380,9 +380,9 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo { struct WILC_WFI_priv *priv; struct wiphy *wiphy; - WILC_Sint32 s32Freq; + s32 s32Freq; struct ieee80211_channel *channel; - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; struct cfg80211_bss *bss = NULL; priv = (struct WILC_WFI_priv *)pUserVoid; @@ -392,21 +392,21 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo WILC_NULLCHECK(s32Error, wiphy); if (wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC && - ((((WILC_Sint32)pstrNetworkInfo->s8rssi) * 100) < 0 + ((((s32)pstrNetworkInfo->s8rssi) * 100) < 0 || - (((WILC_Sint32)pstrNetworkInfo->s8rssi) * 100) > 100) + (((s32)pstrNetworkInfo->s8rssi) * 100) > 100) ) { WILC_ERRORREPORT(s32Error, WILC_FAIL); } if (pstrNetworkInfo != NULL) { - s32Freq = ieee80211_channel_to_frequency((WILC_Sint32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ); + s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ); channel = ieee80211_get_channel(wiphy, s32Freq); WILC_NULLCHECK(s32Error, channel); PRINT_INFO(CFG80211_DBG, "Network Info:: CHANNEL Frequency: %d, RSSI: %d, CapabilityInfo: %d," - "BeaconPeriod: %d \n", channel->center_freq, (((WILC_Sint32)pstrNetworkInfo->s8rssi) * 100), + "BeaconPeriod: %d \n", channel->center_freq, (((s32)pstrNetworkInfo->s8rssi) * 100), pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod); if (pstrNetworkInfo->bNewNetwork == WILC_TRUE) { @@ -429,7 +429,7 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo if (!(WILC_memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7))) { bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs, - (size_t)pstrNetworkInfo->u16IEsLen, (((WILC_Sint32)pstrNetworkInfo->s8rssi) * 100), GFP_KERNEL); + (size_t)pstrNetworkInfo->u16IEsLen, (((s32)pstrNetworkInfo->s8rssi) * 100), GFP_KERNEL); cfg80211_put_bss(wiphy, bss); } @@ -510,7 +510,7 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo int WILC_WFI_Set_PMKSA(u8 *bssid, struct WILC_WFI_priv *priv) { u32 i; - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; for (i = 0; i < priv->pmkid_list.numpmkid; i++) { @@ -701,7 +701,7 @@ static int WILC_WFI_CfgSetChannel(struct wiphy *wiphy, u32 channelnum = 0; struct WILC_WFI_priv *priv; - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; priv = wiphy_priv(wiphy); channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq); @@ -737,7 +737,7 @@ static int WILC_WFI_CfgScan(struct wiphy *wiphy, struct cfg80211_scan_request *r { struct WILC_WFI_priv *priv; u32 i; - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; u8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS]; tstrHiddenNetwork strHiddenNetwork; @@ -825,7 +825,7 @@ static int WILC_WFI_CfgScan(struct wiphy *wiphy, struct cfg80211_scan_request *r static int WILC_WFI_CfgConnect(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_connect_params *sme) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; u32 i; u8 u8security = NO_ENCRYPT; AUTHTYPE_T tenuAuth_type = ANY; @@ -1079,7 +1079,7 @@ done: */ static int WILC_WFI_disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv; #ifdef WILC_P2P tstrWILC_WFIDrv *pstrWFIDrv; @@ -1130,7 +1130,7 @@ static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 k const u8 *mac_addr, struct key_params *params) { - WILC_Sint32 s32Error = WILC_SUCCESS, KeyLen = params->key_len; + s32 s32Error = WILC_SUCCESS, KeyLen = params->key_len; u32 i; struct WILC_WFI_priv *priv; const u8 *pu8RxMic = NULL; @@ -1424,7 +1424,7 @@ static int WILC_WFI_del_key(struct wiphy *wiphy, struct net_device *netdev, const u8 *mac_addr) { struct WILC_WFI_priv *priv; - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; priv = wiphy_priv(wiphy); @@ -1534,7 +1534,7 @@ static int WILC_WFI_get_key(struct wiphy *wiphy, struct net_device *netdev, u8 k const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *)) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv; struct key_params key_params; @@ -1582,7 +1582,7 @@ static int WILC_WFI_get_key(struct wiphy *wiphy, struct net_device *netdev, u8 k static int WILC_WFI_set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, bool unicast, bool multicast) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv; @@ -1610,7 +1610,7 @@ static int WILC_WFI_set_default_key(struct wiphy *wiphy, struct net_device *netd static int WILC_WFI_dump_survey(struct wiphy *wiphy, struct net_device *netdev, int idx, struct survey_info *info) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; if (idx != 0) { @@ -1637,7 +1637,7 @@ extern uint32_t Statisitcs_totalAcks, Statisitcs_DroppedAcks; static int WILC_WFI_get_station(struct wiphy *wiphy, struct net_device *dev, const u8 *mac, struct station_info *sinfo) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv; perInterface_wlan_t *nic; #ifdef WILC_AP_EXTERNAL_MLME @@ -1819,7 +1819,7 @@ static int WILC_WFI_disassoc(struct wiphy *wiphy, struct net_device *dev, */ static int WILC_WFI_set_wiphy_params(struct wiphy *wiphy, u32 changed) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrCfgParamVal pstrCfgParamVal; struct WILC_WFI_priv *priv; @@ -1878,7 +1878,7 @@ static int WILC_WFI_set_bitrate_mask(struct wiphy *wiphy, struct net_device *dev, const u8 *peer, const struct cfg80211_bitrate_mask *mask) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; PRINT_D(CFG80211_DBG, "Setting Bitrate mask function\n"); return s32Error; @@ -1900,7 +1900,7 @@ static int WILC_WFI_set_pmksa(struct wiphy *wiphy, struct net_device *netdev, struct cfg80211_pmksa *pmksa) { u32 i; - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; u8 flag = 0; struct WILC_WFI_priv *priv = wiphy_priv(wiphy); @@ -1952,7 +1952,7 @@ static int WILC_WFI_del_pmksa(struct wiphy *wiphy, struct net_device *netdev, u32 i; u8 flag = 0; - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv = wiphy_priv(wiphy); @@ -2213,7 +2213,7 @@ void WILC_WFI_p2p_rx (struct net_device *dev, uint8_t *buff, uint32_t size) u32 header, pkt_offset; tstrWILC_WFIDrv *pstrWFIDrv; u32 i = 0; - WILC_Sint32 s32Freq; + s32 s32Freq; priv = wiphy_priv(dev->ieee80211_ptr->wiphy); pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv; @@ -2413,7 +2413,7 @@ static int WILC_WFI_remain_on_channel(struct wiphy *wiphy, struct ieee80211_channel *chan, unsigned int duration, u64 *cookie) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv; priv = wiphy_priv(wiphy); @@ -2464,7 +2464,7 @@ static int WILC_WFI_cancel_remain_on_channel(struct wiphy *wiphy, struct wireless_dev *wdev, u64 cookie) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv; priv = wiphy_priv(wiphy); @@ -2511,7 +2511,7 @@ int WILC_WFI_mgmt_tx(struct wiphy *wiphy, const struct ieee80211_mgmt *mgmt; struct p2p_mgmt_data *mgmt_tx; struct WILC_WFI_priv *priv; - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv; u32 i; perInterface_wlan_t *nic; @@ -2841,7 +2841,7 @@ int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic); static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev, enum nl80211_iftype type, u32 *flags, struct vif_params *params) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv; perInterface_wlan_t *nic; u8 interface_type; @@ -3229,7 +3229,7 @@ static int WILC_WFI_start_ap(struct wiphy *wiphy, struct net_device *dev, { struct cfg80211_beacon_data *beacon = &(settings->beacon); struct WILC_WFI_priv *priv; - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; priv = wiphy_priv(wiphy); PRINT_D(HOSTAPD_DBG, "Starting ap\n"); @@ -3277,7 +3277,7 @@ static int WILC_WFI_change_beacon(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_beacon_data *beacon) { struct WILC_WFI_priv *priv; - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; priv = wiphy_priv(wiphy); PRINT_D(HOSTAPD_DBG, "Setting beacon\n"); @@ -3311,7 +3311,7 @@ static int WILC_WFI_change_beacon(struct wiphy *wiphy, struct net_device *dev, */ static int WILC_WFI_stop_ap(struct wiphy *wiphy, struct net_device *dev) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv; u8 NullBssid[ETH_ALEN] = {0}; @@ -3351,7 +3351,7 @@ static int WILC_WFI_stop_ap(struct wiphy *wiphy, struct net_device *dev) static int WILC_WFI_add_station(struct wiphy *wiphy, struct net_device *dev, const u8 *mac, struct station_parameters *params) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv; tstrWILC_AddStaParam strStaParams = {{0}}; perInterface_wlan_t *nic; @@ -3437,7 +3437,7 @@ static int WILC_WFI_del_station(struct wiphy *wiphy, struct net_device *dev, struct station_del_parameters *params) { const u8 *mac = params->mac; - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv; perInterface_wlan_t *nic; WILC_NULLCHECK(s32Error, wiphy); @@ -3482,7 +3482,7 @@ static int WILC_WFI_del_station(struct wiphy *wiphy, struct net_device *dev, static int WILC_WFI_change_station(struct wiphy *wiphy, struct net_device *dev, const u8 *mac, struct station_parameters *params) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv; tstrWILC_AddStaParam strStaParams = {{0}}; perInterface_wlan_t *nic; @@ -3767,7 +3767,7 @@ struct wireless_dev *WILC_WFI_WiphyRegister(struct net_device *net) { struct WILC_WFI_priv *priv; struct wireless_dev *wdev; - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; PRINT_D(CFG80211_DBG, "Registering wifi device\n"); @@ -3849,7 +3849,7 @@ struct wireless_dev *WILC_WFI_WiphyRegister(struct net_device *net) int WILC_WFI_InitHostInt(struct net_device *net) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv; @@ -3890,7 +3890,7 @@ int WILC_WFI_InitHostInt(struct net_device *net) */ int WILC_WFI_DeInitHostInt(struct net_device *net) { - WILC_Sint32 s32Error = WILC_SUCCESS; + s32 s32Error = WILC_SUCCESS; struct WILC_WFI_priv *priv; priv = wdev_priv(net->ieee80211_ptr); From 8a69ebc277aa77e815fc85949aae6cc8ec04c7aa Mon Sep 17 00:00:00 2001 From: Chaehyun Lim Date: Thu, 11 Jun 2015 14:36:00 +0900 Subject: [PATCH 0925/1163] staging: wilc1000: remove WILC_Sint64 remove unused WILC_Sint64. Signed-off-by: Chaehyun Lim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_oswrapper.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index f9a5a3afffe9..016f964c1335 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -13,9 +13,6 @@ /* OS Wrapper interface version */ #define WILC_OSW_INTERFACE_VER 2 -/* Integer Types */ -typedef signed long long WILC_Sint64; - /* Boolean type */ typedef enum { WILC_FALSE = 0, From 1b612a127e9d8119faec28534a033e06c174b6c1 Mon Sep 17 00:00:00 2001 From: Chris Park Date: Thu, 11 Jun 2015 12:42:23 +0900 Subject: [PATCH 0926/1163] staging: wilc1000: fix warning while printing size_t should print using %zu, but here it was use %lu. we were getting warning while printing. Signed-off-by: Chris Park Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c index 6d854fd9101d..a43dc9b5f43a 100644 --- a/drivers/staging/wilc1000/wilc_spi.c +++ b/drivers/staging/wilc1000/wilc_spi.c @@ -404,7 +404,7 @@ static int spi_cmd_complete(uint8_t cmd, uint32_t adr, uint8_t *b, uint32_t sz, #undef NUM_DUMMY_BYTES if (len2 > (sizeof(wb) / sizeof(wb[0]))) { - PRINT_ER("[wilc spi]: spi buffer size too small (%d) (%lu)\n", + PRINT_ER("[wilc spi]: spi buffer size too small (%d) (%zu)\n", len2, (sizeof(wb) / sizeof(wb[0]))); result = N_FAIL; return result; From 2235fb69ef09e0bc0f8b8fb94d1375bdf9d78bf3 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 11 Jun 2015 12:44:24 +0900 Subject: [PATCH 0927/1163] staging: wilc1000: modify odd print message This driver has odd message in print string. So this patch removes the data type. Signed-off-by: Dean Lee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 9207d222787a..8ee71ee16d40 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -703,7 +703,7 @@ static s32 Handle_SetOperationMode(void *drvHandler, tstrHostIfSetOperationMode strWID.s32ValueSize = sizeof(u32); /*Sending Cfg*/ - PRINT_INFO(HOSTINF_DBG, "(size_t)pstrWFIDrv= %p \n", pstrWFIDrv); + PRINT_INFO(HOSTINF_DBG, "pstrWFIDrv= %p \n", pstrWFIDrv); s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); @@ -8040,4 +8040,3 @@ s32 host_int_get_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *u16ipadd, u8 idx) } - From 4a01f1c3abd6aa65bef32d14ba7b37a237c894d4 Mon Sep 17 00:00:00 2001 From: Hari Prasath Gujulan Elango Date: Thu, 11 Jun 2015 07:48:13 +0000 Subject: [PATCH 0928/1163] staging: wilc1000: use memdup_user This patch replaces the kmalloc followed by copy_from_user by the wrapper routine memdup_user. Signed-off-by: Hari Prasath Gujulan Elango Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 3aa9a4b6b4f0..387d4ecc2f2c 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -2459,16 +2459,10 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) size = wrq->u.data.length; if (size && wrq->u.data.pointer) { - buff = kmalloc(size, GFP_KERNEL); - if (!buff) { - s32Error = -ENOMEM; - goto done; - } - if (copy_from_user - (buff, wrq->u.data.pointer, - wrq->u.data.length)) { - s32Error = -EFAULT; + buff = memdup_user(wrq->u.data.pointer, wrq->u.data.length); + if (IS_ERR(buff)) { + s32Error = PTR_ERR(buff); goto done; } From ab6a167f1936eb25c853e3f5caee5f469161916b Mon Sep 17 00:00:00 2001 From: Chaehyun Lim Date: Fri, 12 Jun 2015 12:38:05 +0900 Subject: [PATCH 0929/1163] staging: wilc1000: remove unused typedef Remove unused typedef for custom data types. Signed-off-by: Chaehyun Lim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/itypes.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/wilc1000/itypes.h b/drivers/staging/wilc1000/itypes.h index c99f8cabcaee..2441853f9153 100644 --- a/drivers/staging/wilc1000/itypes.h +++ b/drivers/staging/wilc1000/itypes.h @@ -36,16 +36,6 @@ #ifndef ITYPES_H #define ITYPES_H - -/*****************************************************************************/ -/* Data Types */ -/*****************************************************************************/ - -typedef int WORD32; -typedef short WORD16; -typedef char WORD8; -typedef unsigned short UWORD16; - /*****************************************************************************/ /* Enums */ /*****************************************************************************/ From 72ed4dc73dd7e67bdf37266e5d188fd01bcb32e1 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Fri, 12 Jun 2015 14:11:44 +0900 Subject: [PATCH 0930/1163] staging: wilc1000: change WILC_BOOL to bool change own data type(WILC_BOOL) to common data type(bool) but that's contain true/false value. so change with them. Signed-off-by: Dean Lee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 26 +-- drivers/staging/wilc1000/coreconfigurator.h | 4 +- drivers/staging/wilc1000/fifo_buffer.c | 2 +- drivers/staging/wilc1000/fifo_buffer.h | 2 +- drivers/staging/wilc1000/host_interface.c | 166 +++++++++--------- drivers/staging/wilc1000/host_interface.h | 20 +-- drivers/staging/wilc1000/linux_mon.c | 6 +- drivers/staging/wilc1000/linux_wlan.c | 20 +-- drivers/staging/wilc1000/wilc_msgqueue.c | 8 +- drivers/staging/wilc1000/wilc_oswrapper.h | 6 - drivers/staging/wilc1000/wilc_platform.h | 2 +- drivers/staging/wilc1000/wilc_spi.c | 1 - drivers/staging/wilc1000/wilc_timer.h | 4 +- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 136 +++++++------- .../staging/wilc1000/wilc_wfi_cfgoperations.h | 2 +- drivers/staging/wilc1000/wilc_wfi_netdevice.c | 2 +- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 8 +- drivers/staging/wilc1000/wilc_wlan.c | 34 ++-- drivers/staging/wilc1000/wilc_wlan_cfg.c | 4 +- 19 files changed, 223 insertions(+), 230 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index c9cc817e7dca..9abc73d3646d 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -145,7 +145,7 @@ typedef struct { WILC_Char *pcRespBuffer; s32 s32MaxRespBuffLen; s32 s32BytesRead; - WILC_Bool bRespRequired; + bool bRespRequired; } tstrConfigPktInfo; @@ -1520,7 +1520,7 @@ void ProcessBinWid(WILC_Char *pcPacket, s32 *ps32PktLen, s32 further_process_response(u8 *resp, u16 u16WIDid, u16 cfg_len, - WILC_Bool process_wid_num, + bool process_wid_num, u32 cnt, tstrWID *pstrWIDresult) { @@ -1693,7 +1693,7 @@ s32 ParseResponse(u8 *resp, tstrWID *pstrWIDcfgResult) u16 u16WIDid = 0; u16 cfg_len = 0; tenuWIDtype enuWIDtype = WID_UNDEF; - WILC_Bool num_wid_processed = WILC_FALSE; + bool num_wid_processed = false; u32 cnt = 0; u32 idx = 0; u32 ResCnt = 0; @@ -1717,17 +1717,17 @@ s32 ParseResponse(u8 *resp, tstrWID *pstrWIDcfgResult) idx++; } idx += 3; - if ((u16WIDid == g_wid_num) && (num_wid_processed == WILC_FALSE)) { - num_wid_processed = WILC_TRUE; + if ((u16WIDid == g_wid_num) && (num_wid_processed == false)) { + num_wid_processed = true; - if (-2 == further_process_response(&resp[idx], u16WIDid, cfg_len, WILC_TRUE, 0, &pstrWIDcfgResult[ResCnt])) { + if (-2 == further_process_response(&resp[idx], u16WIDid, cfg_len, true, 0, &pstrWIDcfgResult[ResCnt])) { return -2; } ResCnt++; } else { for (cnt = 0; cnt < g_num_total_switches; cnt++) { if (gastrWIDs[cnt].u16WIDid == u16WIDid) { - if (-2 == further_process_response(&resp[idx], u16WIDid, cfg_len, WILC_FALSE, cnt, + if (-2 == further_process_response(&resp[idx], u16WIDid, cfg_len, false, cnt, &pstrWIDcfgResult[ResCnt])) { return -2; } @@ -1913,7 +1913,7 @@ s32 CreateConfigPacket(s8 *ps8packet, s32 *ps32PacketLength, } s32 ConfigWaitResponse(WILC_Char *pcRespBuffer, s32 s32MaxRespBuffLen, s32 *ps32BytesRead, - WILC_Bool bRespRequired) + bool bRespRequired) { s32 s32Error = WILC_SUCCESS; /*bug 3878*/ @@ -1923,7 +1923,7 @@ s32 ConfigWaitResponse(WILC_Char *pcRespBuffer, s32 s32MaxRespBuffLen, s32 *ps32 * gstrConfigPktInfo.bRespRequired = bRespRequired;*/ - if (gstrConfigPktInfo.bRespRequired == WILC_TRUE) { + if (gstrConfigPktInfo.bRespRequired == true) { down(&SemHandlePktResp); *ps32BytesRead = gstrConfigPktInfo.s32BytesRead; @@ -1950,7 +1950,7 @@ s32 ConfigWaitResponse(WILC_Char *pcRespBuffer, s32 s32MaxRespBuffLen, s32 *ps32 */ #ifdef SIMULATION s32 SendConfigPkt(u8 u8Mode, tstrWID *pstrWIDs, - u32 u32WIDsCount, WILC_Bool bRespRequired, u32 drvHandler) + u32 u32WIDsCount, bool bRespRequired, u32 drvHandler) { s32 s32Error = WILC_SUCCESS; s32 err = WILC_SUCCESS; @@ -1984,7 +1984,7 @@ s32 SendConfigPkt(u8 u8Mode, tstrWID *pstrWIDs, ConfigWaitResponse(gps8ConfigPacket, MAX_PACKET_BUFF_SIZE, &s32RcvdRespLen, bRespRequired); - if (bRespRequired == WILC_TRUE) { + if (bRespRequired == true) { /* If the operating Mode is GET, then we expect a response frame from */ /* the driver. Hence start listening to the port for response */ if (g_oper_mode == GET_CFG) { @@ -2021,7 +2021,7 @@ s32 ConfigProvideResponse(WILC_Char *pcRespBuffer, s32 s32RespLen) { s32 s32Error = WILC_SUCCESS; - if (gstrConfigPktInfo.bRespRequired == WILC_TRUE) { + if (gstrConfigPktInfo.bRespRequired == true) { if (s32RespLen <= gstrConfigPktInfo.s32MaxRespBuffLen) { WILC_memcpy(gstrConfigPktInfo.pcRespBuffer, pcRespBuffer, s32RespLen); gstrConfigPktInfo.s32BytesRead = s32RespLen; @@ -2129,7 +2129,7 @@ extern wilc_wlan_oup_t *gpstrWlanOps; * @version 1.0 */ s32 SendConfigPkt(u8 u8Mode, tstrWID *pstrWIDs, - u32 u32WIDsCount, WILC_Bool bRespRequired, u32 drvHandler) + u32 u32WIDsCount, bool bRespRequired, u32 drvHandler) { s32 counter = 0, ret = 0; if (gpstrWlanOps == NULL) { diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h index 63db151fa752..6ed82e2b4fc9 100644 --- a/drivers/staging/wilc1000/coreconfigurator.h +++ b/drivers/staging/wilc1000/coreconfigurator.h @@ -418,7 +418,7 @@ typedef struct { u8 u8channel; unsigned long u32TimeRcvdInScanCached; /* of type unsigned long to be accepted by the linux kernel macro time_after() */ unsigned long u32TimeRcvdInScan; - WILC_Bool bNewNetwork; + bool bNewNetwork; #ifdef AGING_ALG u8 u8Found; #endif @@ -476,7 +476,7 @@ extern s32 CoreConfiguratorInit(void); extern s32 CoreConfiguratorDeInit(void); extern s32 SendConfigPkt(u8 u8Mode, tstrWID *pstrWIDs, - u32 u32WIDsCount, WILC_Bool bRespRequired, u32 drvHandler); + u32 u32WIDsCount, bool bRespRequired, u32 drvHandler); extern s32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo); extern s32 DeallocateNetworkInfo(tstrNetworkInfo *pstrNetworkInfo); diff --git a/drivers/staging/wilc1000/fifo_buffer.c b/drivers/staging/wilc1000/fifo_buffer.c index 788398ca76e5..c801406d1aa8 100644 --- a/drivers/staging/wilc1000/fifo_buffer.c +++ b/drivers/staging/wilc1000/fifo_buffer.c @@ -86,7 +86,7 @@ u32 FIFO_ReadBytes(tHANDLE hFifo, u8 *pu8Buffer, u32 u32BytesToRead, u32 *pu32By return u32Error; } -u32 FIFO_WriteBytes(tHANDLE hFifo, u8 *pu8Buffer, u32 u32BytesToWrite, WILC_Bool bForceOverWrite) +u32 FIFO_WriteBytes(tHANDLE hFifo, u8 *pu8Buffer, u32 u32BytesToWrite, bool bForceOverWrite) { u32 u32Error = 0; tstrFifoHandler *pstrFifoHandler = (tstrFifoHandler *) hFifo; diff --git a/drivers/staging/wilc1000/fifo_buffer.h b/drivers/staging/wilc1000/fifo_buffer.h index 912a33327bc7..57f7732db2da 100644 --- a/drivers/staging/wilc1000/fifo_buffer.h +++ b/drivers/staging/wilc1000/fifo_buffer.h @@ -20,4 +20,4 @@ extern u32 FIFO_DeInit(tHANDLE hFifo); extern u32 FIFO_ReadBytes(tHANDLE hFifo, u8 *pu8Buffer, u32 u32BytesToRead, u32 *pu32BytesRead); extern u32 FIFO_WriteBytes(tHANDLE hFifo, u8 *pu8Buffer, - u32 u32BytesToWrite, WILC_Bool bForceOverWrite); + u32 u32BytesToWrite, bool bForceOverWrite); diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 8ee71ee16d40..17ab5cdfcf12 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -11,7 +11,7 @@ extern u8 connecting; extern WILC_TimerHandle hDuringIpTimer; #endif -extern WILC_Bool bEnablePS; +extern bool bEnablePS; /*BugID_5137*/ extern u8 g_wilc_initialized; /*****************************************************************************/ @@ -318,7 +318,7 @@ typedef struct _tstrHostIFDelBeacon { */ typedef struct { - WILC_Bool bIsEnabled; + bool bIsEnabled; u32 u32count; } tstrHostIFSetMulti; @@ -379,7 +379,7 @@ typedef struct _tstrTimerCb { */ typedef struct { - WILC_Bool bIsEnabled; + bool bIsEnabled; u32 u32Timeout; } tstrHostIfPowerMgmtParam; @@ -496,7 +496,7 @@ typedef struct _tstrJoinBssParam { u8 ht_capable; u8 wmm_cap; u8 uapsd_cap; - WILC_Bool rsn_found; + bool rsn_found; u8 rsn_grp_policy; u8 mode_802_11i; u8 rsn_pcip_policy[3]; @@ -540,7 +540,7 @@ typedef enum { tstrWILC_WFIDrv *terminated_handle = NULL; tstrWILC_WFIDrv *gWFiDrvHandle = NULL; #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP -WILC_Bool g_obtainingIP = WILC_FALSE; +bool g_obtainingIP = false; #endif u8 P2P_LISTEN_STATE; static struct task_struct *HostIFthreadHandler; @@ -562,7 +562,7 @@ static u8 gapu8RcvdSurveyResults[2][MAX_SURVEY_RESULT_FRAG_SIZE]; static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE]; -WILC_Bool gbScanWhileConnected = WILC_FALSE; +bool gbScanWhileConnected = false; static s8 gs8Rssi; static s8 gs8lnkspd; @@ -622,7 +622,7 @@ static s32 Handle_SetChannel(void *drvHandler, tstrHostIFSetChan *pstrHostIFSetC PRINT_D(HOSTINF_DBG, "Setting channel\n"); /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to set channel\n"); WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); @@ -659,7 +659,7 @@ static s32 Handle_SetWfiDrvHandler(tstrHostIfSetDrvHandler *pstrHostIfSetDrvHand /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); if ((pstrHostIfSetDrvHandler->u32Address) == (u32)NULL) { @@ -705,7 +705,7 @@ static s32 Handle_SetOperationMode(void *drvHandler, tstrHostIfSetOperationMode /*Sending Cfg*/ PRINT_INFO(HOSTINF_DBG, "pstrWFIDrv= %p \n", pstrWFIDrv); - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); if ((pstrHostIfSetOperationMode->u32Mode) == (u32)NULL) { @@ -755,7 +755,7 @@ s32 Handle_set_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx) strWID.ps8WidVal = (u8 *)pu8IPAddr; strWID.s32ValueSize = IP_ALEN; - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); @@ -799,7 +799,7 @@ s32 Handle_get_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx) strWID.ps8WidVal = (u8 *)WILC_MALLOC(IP_ALEN); strWID.s32ValueSize = IP_ALEN; - s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); PRINT_INFO(HOSTINF_DBG, "%d.%d.%d.%d\n", (u8)(strWID.ps8WidVal[0]), (u8)(strWID.ps8WidVal[1]), (u8)(strWID.ps8WidVal[2]), (u8)(strWID.ps8WidVal[3])); @@ -859,7 +859,7 @@ static s32 Handle_SetMacAddress(void *drvHandler, tstrHostIfSetMacAddress *pstrH strWID.s32ValueSize = ETH_ALEN; PRINT_D(GENERIC_DBG, "mac addr = :%x:%x:%x:%x:%x:%x\n", strWID.ps8WidVal[0], strWID.ps8WidVal[1], strWID.ps8WidVal[2], strWID.ps8WidVal[3], strWID.ps8WidVal[4], strWID.ps8WidVal[5]); /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to set mac address\n"); WILC_ERRORREPORT(s32Error, WILC_FAIL); @@ -897,7 +897,7 @@ static s32 Handle_GetMacAddress(void *drvHandler, tstrHostIfGetMacAddress *pstrH strWID.s32ValueSize = ETH_ALEN; /*Sending Cfg*/ - s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_FALSE, (u32)drvHandler); + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, false, (u32)drvHandler); if (s32Error) { PRINT_ER("Failed to get mac address\n"); WILC_ERRORREPORT(s32Error, WILC_FAIL); @@ -1205,7 +1205,7 @@ static s32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *strHostIFCf } u8WidCnt++; } - s32Error = SendConfigPkt(SET_CFG, strWIDList, u8WidCnt, WILC_FALSE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, strWIDList, u8WidCnt, false, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Error in setting CFG params\n"); @@ -1367,12 +1367,12 @@ static s32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFscanAttr) /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */ if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) { - gbScanWhileConnected = WILC_TRUE; + gbScanWhileConnected = true; } else if (pstrWFIDrv->enuHostIFstate == HOST_IF_IDLE) { - gbScanWhileConnected = WILC_FALSE; + gbScanWhileConnected = false; } - s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, WILC_FALSE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to send scan paramters config packet\n"); @@ -1450,7 +1450,7 @@ static s32 Handle_ScanDone(void *drvHandler, tenuScanEvent enuEvent) strWID.s32ValueSize = sizeof(WILC_Char); /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); if (s32Error != WILC_SUCCESS) { PRINT_ER("Failed to set abort running scan\n"); WILC_ERRORREPORT(s32Error, WILC_FAIL); @@ -1649,7 +1649,7 @@ static s32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFcon /* ////////////////////// */ #endif - s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, WILC_FALSE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Handle_Connect()] failed to send config packet\n"); WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); @@ -1990,7 +1990,7 @@ static s32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFcon PRINT_D(GENERIC_DBG, "save bssid = %x:%x:%x:%x:%x:%x\n", (u8ConnectedSSID[0]), (u8ConnectedSSID[1]), (u8ConnectedSSID[2]), (u8ConnectedSSID[3]), (u8ConnectedSSID[4]), (u8ConnectedSSID[5])); } - s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, WILC_FALSE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Handle_Connect()] failed to send config packet\n"); WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); @@ -2121,7 +2121,7 @@ static s32 Handle_FlushConnect(void *drvHandler) #endif - s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, WILC_FALSE, gu8FlushedJoinReqDrvHandler); + s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, gu8FlushedJoinReqDrvHandler); if (s32Error) { PRINT_ER("Handle_Flush_Connect()] failed to send config packet\n"); WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); @@ -2159,7 +2159,7 @@ static s32 Handle_ConnectTimeout(void *drvHandler) pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE; - gbScanWhileConnected = WILC_FALSE; + gbScanWhileConnected = false; WILC_memset(&strConnectInfo, 0, sizeof(tstrConnectInfo)); @@ -2206,7 +2206,7 @@ static s32 Handle_ConnectTimeout(void *drvHandler) PRINT_D(HOSTINF_DBG, "Sending disconnect request\n"); - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to send dissconect config packet\n"); } @@ -2256,7 +2256,7 @@ static s32 Handle_ConnectTimeout(void *drvHandler) static s32 Handle_RcvdNtwrkInfo(void *drvHandler, tstrRcvdNetworkInfo *pstrRcvdNetworkInfo) { u32 i; - WILC_Bool bNewNtwrkFound; + bool bNewNtwrkFound; @@ -2268,7 +2268,7 @@ static s32 Handle_RcvdNtwrkInfo(void *drvHandler, tstrRcvdNetworkInfo *pstrRcvdN - bNewNtwrkFound = WILC_TRUE; + bNewNtwrkFound = true; PRINT_INFO(HOSTINF_DBG, "Handling received network info\n"); /*if there is a an ongoing scan request*/ @@ -2297,14 +2297,14 @@ static s32 Handle_RcvdNtwrkInfo(void *drvHandler, tstrRcvdNetworkInfo *pstrRcvdN * the rssi for this cached network and send this updated network to the upper layer but * don't add a new record for it */ pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi; - bNewNtwrkFound = WILC_FALSE; + bNewNtwrkFound = false; break; } } } } - if (bNewNtwrkFound == WILC_TRUE) { + if (bNewNtwrkFound == true) { /* here it is confirmed that it is a new discovered network, * so add its record then call the User CallBack function */ @@ -2320,7 +2320,7 @@ static s32 Handle_RcvdNtwrkInfo(void *drvHandler, tstrRcvdNetworkInfo *pstrRcvdN pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount++; - pstrNetworkInfo->bNewNetwork = WILC_TRUE; + pstrNetworkInfo->bNewNetwork = true; /*Bug4218: Parsing Join Param*/ /* add new BSS to JoinBssTable */ #ifdef WILC_PARSE_SCAN_IN_HOST @@ -2337,7 +2337,7 @@ static s32 Handle_RcvdNtwrkInfo(void *drvHandler, tstrRcvdNetworkInfo *pstrRcvdN PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit \n"); } } else { - pstrNetworkInfo->bNewNetwork = WILC_FALSE; + pstrNetworkInfo->bNewNetwork = false; /* just call the User CallBack function to send the same discovered network with its updated RSSI */ pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo, pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL); @@ -2541,7 +2541,7 @@ static s32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncInfo *pst #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n"); - g_obtainingIP = WILC_TRUE; + g_obtainingIP = true; WILC_TimerStart(&hDuringIpTimer, 10000, NULL, NULL); #endif @@ -2556,7 +2556,7 @@ static s32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncInfo *pst } else { PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus); pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE; - gbScanWhileConnected = WILC_FALSE; + gbScanWhileConnected = false; } /* Deallocation */ @@ -2608,7 +2608,7 @@ static s32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncInfo *pst if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) { #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP - g_obtainingIP = WILC_FALSE; + g_obtainingIP = false; host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 0, 0); #endif @@ -2667,7 +2667,7 @@ static s32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncInfo *pst } pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE; - gbScanWhileConnected = WILC_FALSE; + gbScanWhileConnected = false; } else if ((u8MacStatus == MAC_DISCONNECTED) && (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL)) { @@ -2767,7 +2767,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) strWIDList[3].ps8WidVal = (s8 *)pu8keybuf; - s32Error = SendConfigPkt(SET_CFG, strWIDList, 4, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, strWIDList, 4, true, (u32)pstrWFIDrv); WILC_FREE(pu8keybuf); @@ -2795,7 +2795,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) strWID.ps8WidVal = (s8 *)pu8keybuf; strWID.s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2; - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); WILC_FREE(pu8keybuf); } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY) { @@ -2807,7 +2807,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) strWID.ps8WidVal = s8idxarray; strWID.s32ValueSize = 1; - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); } else { strWID.u16WIDid = (u16)WID_KEY_ID; strWID.enuWIDtype = WID_CHAR; @@ -2816,7 +2816,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) PRINT_D(HOSTINF_DBG, "Setting default key index\n"); - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); } up(&(pstrWFIDrv->hSemTestKeyBlock)); break; @@ -2862,7 +2862,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) strWIDList[1].ps8WidVal = (s8 *)pu8keybuf; strWIDList[1].s32ValueSize = RX_MIC_KEY_MSG_LEN; - s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true, (u32)pstrWFIDrv); WILC_FREE(pu8keybuf); @@ -2909,7 +2909,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) strWID.ps8WidVal = (s8 *)pu8keybuf; strWID.s32ValueSize = RX_MIC_KEY_MSG_LEN; - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); WILC_FREE(pu8keybuf); @@ -2966,7 +2966,7 @@ _WPARxGtk_end_case_: strWIDList[1].ps8WidVal = (s8 *)pu8keybuf; strWIDList[1].s32ValueSize = PTK_KEY_MSG_LEN + 1; - s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true, (u32)pstrWFIDrv); WILC_FREE(pu8keybuf); /* ////////////////////////// */ @@ -3007,7 +3007,7 @@ _WPARxGtk_end_case_: strWID.ps8WidVal = (s8 *)pu8keybuf; strWID.s32ValueSize = PTK_KEY_MSG_LEN; - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); WILC_FREE(pu8keybuf); /* ////////////////////////// */ @@ -3046,7 +3046,7 @@ _WPAPtk_end_case_: strWID.ps8WidVal = (s8 *)pu8keybuf; strWID.s32ValueSize = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1; - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); WILC_FREE(pu8keybuf); break; @@ -3089,13 +3089,13 @@ static void Handle_Disconnect(void *drvHandler) #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP - g_obtainingIP = WILC_FALSE; + g_obtainingIP = false; host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 0, 0); #endif WILC_memset(u8ConnectedSSID, 0, ETH_ALEN); - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to send dissconect config packet\n"); @@ -3132,7 +3132,7 @@ static void Handle_Disconnect(void *drvHandler) PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL \n"); } - gbScanWhileConnected = WILC_FALSE; + gbScanWhileConnected = false; pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE; @@ -3208,7 +3208,7 @@ static s32 Switch_Log_Terminal(void *drvHandler) strWID.ps8WidVal = &dummy; strWID.s32ValueSize = sizeof(WILC_Char); - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); if (s32Error) { @@ -3252,7 +3252,7 @@ static s32 Handle_GetChnl(void *drvHandler) PRINT_D(HOSTINF_DBG, "Getting channel value\n"); - s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); /*get the value by searching the local copy*/ if (s32Error) { PRINT_ER("Failed to get channel number\n"); @@ -3296,7 +3296,7 @@ static void Handle_GetRssi(void *drvHandler) /*Sending Cfg*/ PRINT_D(HOSTINF_DBG, "Getting RSSI value\n"); - s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to get RSSI value\n"); WILC_ERRORREPORT(s32Error, WILC_FAIL); @@ -3327,7 +3327,7 @@ static void Handle_GetLinkspeed(void *drvHandler) /*Sending Cfg*/ PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n"); - s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to get LINKSPEED value\n"); WILC_ERRORREPORT(s32Error, WILC_FAIL); @@ -3377,7 +3377,7 @@ s32 Handle_GetStatistics(void *drvHandler, tstrStatistics *pstrStatistics) strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxFailureCount)); u32WidsCount++; - s32Error = SendConfigPkt(GET_CFG, strWIDList, u32WidsCount, WILC_FALSE, (u32)drvHandler); + s32Error = SendConfigPkt(GET_CFG, strWIDList, u32WidsCount, false, (u32)drvHandler); if (s32Error) { PRINT_ER("Failed to send scan paramters config packet\n"); @@ -3425,7 +3425,7 @@ static s32 Handle_Get_InActiveTime(void *drvHandler, tstrHostIfStaInactiveT *str PRINT_D(CFG80211_DBG, "SETING STA inactive time\n"); - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); /*get the value by searching the local copy*/ if (s32Error) { PRINT_ER("Failed to SET incative time\n"); @@ -3439,7 +3439,7 @@ static s32 Handle_Get_InActiveTime(void *drvHandler, tstrHostIfStaInactiveT *str strWID.s32ValueSize = sizeof(u32); - s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); /*get the value by searching the local copy*/ if (s32Error) { PRINT_ER("Failed to get incative time\n"); @@ -3520,7 +3520,7 @@ static void Handle_AddBeacon(void *drvHandler, tstrHostIFSetBeacon *pstrSetBeaco /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to send add beacon config packet\n"); WILC_ERRORREPORT(s32Error, WILC_FAIL); @@ -3565,7 +3565,7 @@ static void Handle_DelBeacon(void *drvHandler, tstrHostIFDelBeacon *pstrDelBeaco /* TODO: build del beacon message*/ /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to send delete beacon config packet\n"); @@ -3662,7 +3662,7 @@ static void Handle_AddStation(void *drvHandler, tstrWILC_AddStaParam *pstrStatio pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam); /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv); if (s32Error != WILC_SUCCESS) { PRINT_ER("Failed to send add station config packet\n"); @@ -3718,7 +3718,7 @@ static void Handle_DelAllSta(void *drvHandler, tstrHostIFDelAllSta *pstrDelAllSt } /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to send add station config packe\n"); @@ -3766,7 +3766,7 @@ static void Handle_DelStation(void *drvHandler, tstrHostIFDelSta *pstrDelStaPara WILC_memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN); /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to send add station config packe\n"); @@ -3810,7 +3810,7 @@ static void Handle_EditStation(void *drvHandler, tstrWILC_AddStaParam *pstrStati pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam); /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to send edit station config packet\n"); @@ -3873,7 +3873,7 @@ static int Handle_RemainOnChan(void *drvHandler, tstrHostIfRemainOnChan *pstrHos PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel); - u8remain_on_chan_flag = WILC_TRUE; + u8remain_on_chan_flag = true; strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN; strWID.enuWIDtype = WID_STR; strWID.s32ValueSize = 2; @@ -3887,7 +3887,7 @@ static int Handle_RemainOnChan(void *drvHandler, tstrHostIfRemainOnChan *pstrHos strWID.ps8WidVal[1] = (s8)pstrHostIfRemainOnChan->u16Channel; /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); if (s32Error != WILC_SUCCESS) { PRINT_ER("Failed to set remain on channel\n"); } @@ -3945,7 +3945,7 @@ static int Handle_RegisterFrame(void *drvHandler, tstrHostIfRegisterFrame *pstrH /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to frame register config packet\n"); WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); @@ -3983,7 +3983,7 @@ static u32 Handle_ListenStateExpired(void *drvHandler, tstrHostIfRemainOnChan *p /*Make sure we are already in listen state*/ /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/ if (P2P_LISTEN_STATE) { - u8remain_on_chan_flag = WILC_FALSE; + u8remain_on_chan_flag = false; strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN; strWID.enuWIDtype = WID_STR; strWID.s32ValueSize = 2; @@ -3997,7 +3997,7 @@ static u32 Handle_ListenStateExpired(void *drvHandler, tstrHostIfRemainOnChan *p strWID.ps8WidVal[1] = FALSE_FRMWR_CHANNEL; /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); if (s32Error != WILC_SUCCESS) { PRINT_ER("Failed to set remain on channel\n"); goto _done_; @@ -4071,7 +4071,7 @@ static void Handle_PowerManagement(void *drvHandler, tstrHostIfPowerMgmtParam *s tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; strWID.u16WIDid = (u16)WID_POWER_MANAGEMENT; - if (strPowerMgmtParam->bIsEnabled == WILC_TRUE) { + if (strPowerMgmtParam->bIsEnabled == true) { s8PowerMode = MIN_FAST_PS; } else { s8PowerMode = NO_POWERSAVE; @@ -4083,7 +4083,7 @@ static void Handle_PowerManagement(void *drvHandler, tstrHostIfPowerMgmtParam *s PRINT_D(HOSTINF_DBG, "Handling Power Management\n"); /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to send power management config packet\n"); WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); @@ -4135,7 +4135,7 @@ static void Handle_SetMulticastFilter(void *drvHandler, tstrHostIFSetMulti *strH memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN)); /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (u32)drvHandler); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)drvHandler); if (s32Error) { PRINT_ER("Failed to send setup multicast config packet\n"); WILC_ERRORREPORT(s32Error, WILC_FAIL); @@ -4203,7 +4203,7 @@ static s32 Handle_AddBASession(void *drvHandler, tstrHostIfBASessionInfo *strHos /* Group Buffer Timeout */ *ptr++ = 0; - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); if (s32Error) PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n"); @@ -4227,7 +4227,7 @@ static s32 Handle_AddBASession(void *drvHandler, tstrHostIfBASessionInfo *strHos *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF); /*Ack-Policy */ *ptr++ = 3; - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); if (strWID.ps8WidVal != NULL) WILC_FREE(strWID.ps8WidVal); @@ -4277,7 +4277,7 @@ static s32 Handle_DelBASession(void *drvHandler, tstrHostIfBASessionInfo *strHos /* Delba Reason */ *ptr++ = 32; /* Unspecific QOS reason */ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); if (s32Error) PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n"); @@ -4295,7 +4295,7 @@ static s32 Handle_DelBASession(void *drvHandler, tstrHostIfBASessionInfo *strHos /* TID*/ *ptr++ = strHostIfBASessionInfo->u8Ted; - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); if (strWID.ps8WidVal != NULL) WILC_FREE(strWID.ps8WidVal); @@ -4346,7 +4346,7 @@ static s32 Handle_DelAllRxBASessions(void *drvHandler, tstrHostIfBASessionInfo * /* Delba Reason */ *ptr++ = 32; /* Unspecific QOS reason */ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); if (s32Error) PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n"); @@ -5443,7 +5443,7 @@ s32 host_int_get_site_survey_results(WILC_WFIDrvHandle hWFIDrv, astrWIDList[1].ps8WidVal = ppu8RcvdSiteSurveyResults[1]; astrWIDList[1].s32ValueSize = u32MaxSiteSrvyFragLen; - s32Error = SendConfigPkt(GET_CFG, astrWIDList, 2, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(GET_CFG, astrWIDList, 2, true, (u32)pstrWFIDrv); /*get the value by searching the local copy*/ if (s32Error) { @@ -5811,7 +5811,7 @@ s32 host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocRespInfo, /* Sending Configuration packet */ - s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Failed to send association response config packet\n"); *pu32RcvdAssocRespInfoLen = 0; @@ -6062,7 +6062,7 @@ s32 host_int_test_set_int_wid(WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr) strWID.s32ValueSize = sizeof(u32); /*Sending Cfg*/ - s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); if (s32Error) { PRINT_ER("Test Function: Failed to set wid value\n"); WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE); @@ -6154,7 +6154,7 @@ s32 host_int_test_get_int_wid(WILC_WFIDrvHandle hWFIDrv, u32 *pu32TestMemAddr) strWID.ps8WidVal = (s8 *)pu32TestMemAddr; strWID.s32ValueSize = sizeof(u32); - s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (u32)pstrWFIDrv); + s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); /*get the value by searching the local copy*/ if (s32Error) { PRINT_ER("Test Function: Failed to get wid value\n"); @@ -6531,7 +6531,7 @@ s32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, u16 u16WID, u16 *pu16WID_Value) * @version 1.0 */ void host_int_send_join_leave_info_to_host - (u16 assocId, u8 *stationAddr, WILC_Bool joining) + (u16 assocId, u8 *stationAddr, bool joining) { } /** @@ -6607,7 +6607,7 @@ s32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) * } */ PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1); - gbScanWhileConnected = WILC_FALSE; + gbScanWhileConnected = false; sema_init(&hWaitResponse, 0); @@ -6628,7 +6628,7 @@ s32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP - g_obtainingIP = WILC_FALSE; + g_obtainingIP = false; #endif PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", pstrWFIDrv); @@ -6711,7 +6711,7 @@ s32 host_int_init(WILC_WFIDrvHandle *phWFIDrv) #endif pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE; - /* gWFiDrvHandle->bPendingConnRequest = WILC_FALSE; */ + /* gWFiDrvHandle->bPendingConnRequest = false; */ /*Initialize CFG WIDS Defualt Values*/ @@ -6859,7 +6859,7 @@ s32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv) pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE; - gbScanWhileConnected = WILC_FALSE; + gbScanWhileConnected = false; WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); @@ -7174,7 +7174,7 @@ s32 host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv, u32 u32SessionID) * @author * @date * @version 1.0*/ -s32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, u16 u16FrameType, WILC_Bool bReg) +s32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, u16 u16FrameType, bool bReg) { s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -7542,7 +7542,7 @@ s32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrS #endif /*WILC_AP_EXTERNAL_MLME*/ uint32_t wilc_get_chipid(uint8_t); -s32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, u32 u32Timeout) +s32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, bool bIsEnabled, u32 u32Timeout) { s32 s32Error = WILC_SUCCESS; tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; @@ -7578,7 +7578,7 @@ s32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, u32 return s32Error; } -s32 host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, u32 u32count) +s32 host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv, bool bIsEnabled, u32 u32count) { s32 s32Error = WILC_SUCCESS; diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index afe92063f44f..dcd127575409 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -330,7 +330,7 @@ typedef struct { size_t ConnReqIEsLen; /* Connect user call back function */ tWILCpfConnectResult pfUserConnectResult; - WILC_Bool IsHTCapable; + bool IsHTCapable; /* User specific parameter to be delivered through the Connect User Callback function */ void *u32UserConnectPvoid; } tstrWILC_UsrConnReq; @@ -373,7 +373,7 @@ typedef struct { typedef struct { - WILC_Bool bReg; + bool bReg; u16 u16FrameType; u8 u8Regid; @@ -412,7 +412,7 @@ typedef struct { tenuHostIFstate enuHostIFstate; - /* WILC_Bool bPendingConnRequest; */ + /* bool bPendingConnRequest; */ #ifndef CONNECT_DIRECT u32 u32SurveyResultsCount; @@ -437,7 +437,7 @@ typedef struct { WILC_TimerHandle hRemainOnChannel; #endif - WILC_Bool IFC_UP; + bool IFC_UP; } tstrWILC_WFIDrv; /*! @@ -465,7 +465,7 @@ typedef struct { u16 u16AssocID; u8 u8NumRates; const u8 *pu8Rates; - WILC_Bool bIsHTSupported; + bool bIsHTSupported; u16 u16HTCapInfo; u8 u8AmpduParams; u8 au8SuppMCsSet[16]; @@ -1058,7 +1058,7 @@ s32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, u16 u16WID, u16 *pu16WID_Value); * @version 1.0 */ void host_int_send_join_leave_info_to_host - (u16 assocId, u8 *stationAddr, WILC_Bool joining); + (u16 assocId, u8 *stationAddr, bool joining); /** * @brief notifies host with stations found in scan @@ -1202,7 +1202,7 @@ s32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8MacAddr); s32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrStaParams); /*! - * @fn s32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, u32 u32Timeout) + * @fn s32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, bool bIsEnabled, u32 u32Timeout) * @brief Set the power management mode to enabled or disabled * @details * @param[in,out] hWFIDrv handle to the wifi driver @@ -1216,7 +1216,7 @@ s32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrS * @date 24 November 2012 * @version 1.0 Description */ -s32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, u32 u32Timeout); +s32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, bool bIsEnabled, u32 u32Timeout); /* @param[in,out] hWFIDrv handle to the wifi driver * @param[in] bIsEnabled TRUE if enabled, FALSE otherwise * @param[in] u8count count of mac address entries in the filter table @@ -1228,7 +1228,7 @@ s32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, u32 * @date 24 November 2012 * @version 1.0 Description */ -s32 host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, u32 u32count); +s32 host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv, bool bIsEnabled, u32 u32count); /** * @brief host_int_setup_ipaddress * @details set IP address on firmware @@ -1312,7 +1312,7 @@ s32 host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv, u32 u32SessionID); * @date * @version 1.0 */ -s32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, u16 u16FrameType, WILC_Bool bReg); +s32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, u16 u16FrameType, bool bReg); #endif /** * @brief host_int_set_wfi_drv_handler diff --git a/drivers/staging/wilc1000/linux_mon.c b/drivers/staging/wilc1000/linux_mon.c index 708e3213532c..d5860ce749e0 100644 --- a/drivers/staging/wilc1000/linux_mon.c +++ b/drivers/staging/wilc1000/linux_mon.c @@ -274,7 +274,7 @@ static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len) memcpy((mgmt_tx->buff) + (len - sizeof(struct tx_complete_mon_data *)), &mgmt_tx, sizeof(struct tx_complete_mon_data *)); /* filter data frames to handle it's PS */ - if (filter_monitor_data_frames((mgmt_tx->buff), len) == WILC_TRUE) { + if (filter_monitor_data_frames((mgmt_tx->buff), len) == true) { return; } @@ -412,7 +412,7 @@ static const struct net_device_ops wilc_wfi_netdev_ops = { * @date 9 May 2013 * @version 1.0 */ -void WILC_mgm_HOSTAPD_ACK(void *priv, WILC_Bool bStatus) +void WILC_mgm_HOSTAPD_ACK(void *priv, bool bStatus) { struct sk_buff *skb; struct wilc_wfi_radiotap_cb_hdr *cb_hdr; @@ -452,7 +452,7 @@ void WILC_mgm_HOSTAPD_ACK(void *priv, WILC_Bool bStatus) cb_hdr->rate = 5; /* txrate->bitrate / 5; */ - if (WILC_TRUE == bStatus) { + if (true == bStatus) { /* success */ cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_RTS; } else { diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 387d4ecc2f2c..5f871485d973 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -65,9 +65,9 @@ unsigned char mac_add[] = {0x00, 0x80, 0xC2, 0x5E, 0xa2, 0xb2}; #endif #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP -extern WILC_Bool g_obtainingIP; +extern bool g_obtainingIP; #endif -extern u16 Set_machw_change_vir_if(WILC_Bool bValue); +extern u16 Set_machw_change_vir_if(bool bValue); extern void resolve_disconnect_aberration(void *drvHandler); extern u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN]; void wilc1000_wlan_deinit(linux_wlan_t *nic); @@ -178,7 +178,7 @@ static void wilc_set_multicast_list(struct net_device *dev); */ linux_wlan_t *g_linux_wlan; wilc_wlan_oup_t *gpstrWlanOps; -WILC_Bool bEnablePS = WILC_TRUE; +bool bEnablePS = true; static const struct net_device_ops wilc_netdev_ops = { .ndo_init = mac_init_fn, @@ -302,14 +302,14 @@ static int dev_state_ev_handler(struct notifier_block *this, unsigned long event /*If we are in station mode or client mode*/ if (nic->iftype == STATION_MODE || nic->iftype == CLIENT_MODE) { pstrWFIDrv->IFC_UP = 1; - g_obtainingIP = WILC_FALSE; + g_obtainingIP = false; WILC_TimerStop(&hDuringIpTimer, NULL); PRINT_D(GENERIC_DBG, "IP obtained , enable scan\n"); } - if (bEnablePS == WILC_TRUE) + if (bEnablePS == true) host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 1, 0); PRINT_D(GENERIC_DBG, "[%s] Up IP\n", dev_iface->ifa_label); @@ -326,7 +326,7 @@ static int dev_state_ev_handler(struct notifier_block *this, unsigned long event PRINT_INFO(GENERIC_DBG, "\n ============== IP Address Released ===============\n\n"); if (nic->iftype == STATION_MODE || nic->iftype == CLIENT_MODE) { pstrWFIDrv->IFC_UP = 0; - g_obtainingIP = WILC_FALSE; + g_obtainingIP = false; } if (memcmp(dev_iface->ifa_label, wlan_dev_name, 5) == 0) @@ -2090,7 +2090,7 @@ int mac_open(struct net_device *ndev) return ret; } - Set_machw_change_vir_if(WILC_FALSE); + Set_machw_change_vir_if(false); host_int_get_MacAddress(priv->hWILCWFIDrv, mac_add); PRINT_D(INIT_DBG, "Mac address: %x:%x:%x:%x:%x:%x\n", mac_add[0], mac_add[1], mac_add[2], @@ -2187,14 +2187,14 @@ static void wilc_set_multicast_list(struct net_device *dev) if ((dev->flags & IFF_ALLMULTI) || (dev->mc.count) > WILC_MULTICAST_TABLE_SIZE) { PRINT_D(INIT_DBG, "Disable multicast filter, retrive all multicast packets\n"); /* get all multicast packets */ - host_int_setup_multicast_filter((WILC_WFIDrvHandle)pstrWFIDrv, WILC_FALSE, 0); + host_int_setup_multicast_filter((WILC_WFIDrvHandle)pstrWFIDrv, false, 0); return; } /* No multicast? Just get our own stuff */ if ((dev->mc.count) == 0) { PRINT_D(INIT_DBG, "Enable multicast filter, retrive directed packets only.\n"); - host_int_setup_multicast_filter((WILC_WFIDrvHandle)pstrWFIDrv, WILC_TRUE, 0); + host_int_setup_multicast_filter((WILC_WFIDrvHandle)pstrWFIDrv, true, 0); return; } @@ -2207,7 +2207,7 @@ static void wilc_set_multicast_list(struct net_device *dev) i++; } - host_int_setup_multicast_filter((WILC_WFIDrvHandle)pstrWFIDrv, WILC_TRUE, (dev->mc.count)); + host_int_setup_multicast_filter((WILC_WFIDrvHandle)pstrWFIDrv, true, (dev->mc.count)); return; diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c b/drivers/staging/wilc1000/wilc_msgqueue.c index 8531bf1adb78..04fe5a59de5c 100644 --- a/drivers/staging/wilc1000/wilc_msgqueue.c +++ b/drivers/staging/wilc1000/wilc_msgqueue.c @@ -15,7 +15,7 @@ WILC_ErrNo WILC_MsgQueueCreate(WILC_MsgQueueHandle *pHandle, sema_init(&pHandle->hSem, 0); pHandle->pstrMessageList = NULL; pHandle->u32ReceiversCount = 0; - pHandle->bExiting = WILC_FALSE; + pHandle->bExiting = false; return WILC_SUCCESS; } @@ -29,7 +29,7 @@ WILC_ErrNo WILC_MsgQueueDestroy(WILC_MsgQueueHandle *pHandle, tstrWILC_MsgQueueAttrs *pstrAttrs) { - pHandle->bExiting = WILC_TRUE; + pHandle->bExiting = true; /* Release any waiting receiver thread. */ while (pHandle->u32ReceiversCount > 0) { @@ -64,7 +64,7 @@ WILC_ErrNo WILC_MsgQueueSend(WILC_MsgQueueHandle *pHandle, WILC_ERRORREPORT(s32RetStatus, WILC_INVALID_ARGUMENT); } - if (pHandle->bExiting == WILC_TRUE) { + if (pHandle->bExiting == true) { WILC_ERRORREPORT(s32RetStatus, WILC_FAIL); } @@ -131,7 +131,7 @@ WILC_ErrNo WILC_MsgQueueRecv(WILC_MsgQueueHandle *pHandle, WILC_ERRORREPORT(s32RetStatus, WILC_INVALID_ARGUMENT); } - if (pHandle->bExiting == WILC_TRUE) { + if (pHandle->bExiting == true) { WILC_ERRORREPORT(s32RetStatus, WILC_FAIL); } diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index 016f964c1335..d5835d6b09f8 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -13,12 +13,6 @@ /* OS Wrapper interface version */ #define WILC_OSW_INTERFACE_VER 2 -/* Boolean type */ -typedef enum { - WILC_FALSE = 0, - WILC_TRUE = 1 -} WILC_Bool; - /* Character types */ typedef char WILC_Char; diff --git a/drivers/staging/wilc1000/wilc_platform.h b/drivers/staging/wilc1000/wilc_platform.h index e185eb32024b..7ddea8336af6 100644 --- a/drivers/staging/wilc1000/wilc_platform.h +++ b/drivers/staging/wilc1000/wilc_platform.h @@ -30,7 +30,7 @@ typedef struct __Message_struct { typedef struct __MessageQueue_struct { struct semaphore hSem; spinlock_t strCriticalSection; - WILC_Bool bExiting; + bool bExiting; u32 u32ReceiversCount; Message *pstrMessageList; } WILC_MsgQueueHandle; diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c index a43dc9b5f43a..ba9b30acfb57 100644 --- a/drivers/staging/wilc1000/wilc_spi.c +++ b/drivers/staging/wilc1000/wilc_spi.c @@ -1472,4 +1472,3 @@ wilc_hif_func_t hif_spi = { spi_max_bus_speed, spi_default_bus_speed, }; - diff --git a/drivers/staging/wilc1000/wilc_timer.h b/drivers/staging/wilc1000/wilc_timer.h index 72efa85ade2d..a0f91545240e 100644 --- a/drivers/staging/wilc1000/wilc_timer.h +++ b/drivers/staging/wilc1000/wilc_timer.h @@ -82,8 +82,8 @@ WILC_ErrNo WILC_TimerDestroy(WILC_TimerHandle *pHandle, * @details This function will move the timer to the PENDING state until the * given time expires (in msec) then the callback function will be * executed (timer in EXECUTING state) after execution is dene the - * timer either goes to IDLE (if bPeriodicTimer==WILC_FALSE) or - * PENDING with same timeout value (if bPeriodicTimer==WILC_TRUE) + * timer either goes to IDLE (if bPeriodicTimer==false) or + * PENDING with same timeout value (if bPeriodicTimer==true) * @param[in] pHandle handle to the timer object * @param[in] u32Timeout timeout value in msec after witch the callback * function will be executed. Timeout value of 0 is not allowed for diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index fde2a649e758..2293949031df 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -25,7 +25,7 @@ extern void linux_wlan_free(void *vp); extern int linux_wlan_get_firmware(perInterface_wlan_t *p_nic); extern void linux_wlan_unlock(void *vp); -extern u16 Set_machw_change_vir_if(WILC_Bool bValue); +extern u16 Set_machw_change_vir_if(bool bValue); extern int mac_open(struct net_device *ndev); extern int mac_close(struct net_device *ndev); @@ -43,7 +43,7 @@ extern u8 u8ConnectedSSID[6]; u8 g_wilc_initialized = 1; extern linux_wlan_t *g_linux_wlan; #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP -extern WILC_Bool g_obtainingIP; +extern bool g_obtainingIP; #endif #define CHAN2G(_channel, _freq, _flags) { \ @@ -112,7 +112,7 @@ u8 u8P2P_oui[] = {0x50, 0x6f, 0x9A, 0x09}; u8 u8P2Plocalrandom = 0x01; u8 u8P2Precvrandom = 0x00; u8 u8P2P_vendorspec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03}; -WILC_Bool bWilc_ie = WILC_FALSE; +bool bWilc_ie = false; #endif static struct ieee80211_supported_band WILC_WFI_band_2ghz = { @@ -135,9 +135,9 @@ struct add_key_params g_add_ptk_key_params; struct wilc_wfi_key g_key_ptk_params; struct wilc_wfi_wep_key g_key_wep_params; u8 g_flushing_in_progress; -WILC_Bool g_ptk_keys_saved = WILC_FALSE; -WILC_Bool g_gtk_keys_saved = WILC_FALSE; -WILC_Bool g_wep_keys_saved = WILC_FALSE; +bool g_ptk_keys_saved = false; +bool g_gtk_keys_saved = false; +bool g_wep_keys_saved = false; #define AGING_TIME (9 * 1000) #define duringIP_TIME 15000 @@ -178,7 +178,7 @@ uint32_t get_rssi_avg(tstrNetworkInfo *pstrNetworkInfo) return rssi_v; } -void refresh_scan(void *pUserVoid, uint8_t all, WILC_Bool bDirectScan) +void refresh_scan(void *pUserVoid, uint8_t all, bool bDirectScan) { struct WILC_WFI_priv *priv; struct wiphy *wiphy; @@ -275,7 +275,7 @@ void remove_network_from_shadow(void *pUserVoid) void clear_duringIP(void *pUserVoid) { PRINT_D(GENERIC_DBG, "GO:IP Obtained , enable scan\n"); - g_obtainingIP = WILC_FALSE; + g_obtainingIP = false; } #endif @@ -386,7 +386,7 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo struct cfg80211_bss *bss = NULL; priv = (struct WILC_WFI_priv *)pUserVoid; - if (priv->bCfgScanning == WILC_TRUE) { + if (priv->bCfgScanning == true) { if (enuScanEvent == SCAN_EVENT_NETWORK_FOUND) { wiphy = priv->dev->ieee80211_ptr->wiphy; WILC_NULLCHECK(s32Error, wiphy); @@ -409,7 +409,7 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo "BeaconPeriod: %d \n", channel->center_freq, (((s32)pstrNetworkInfo->s8rssi) * 100), pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod); - if (pstrNetworkInfo->bNewNetwork == WILC_TRUE) { + if (pstrNetworkInfo->bNewNetwork == true) { if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */ /* max_scan_ssids */ PRINT_D(CFG80211_DBG, "Network %s found\n", pstrNetworkInfo->au8ssid); @@ -454,7 +454,7 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo } else if (enuScanEvent == SCAN_EVENT_DONE) { PRINT_D(CFG80211_DBG, "Scan Done[%p] \n", priv->dev); PRINT_D(CFG80211_DBG, "Refreshing Scan ... \n"); - refresh_scan(priv, 1, WILC_FALSE); + refresh_scan(priv, 1, false); if (priv->u32RcvdChCount > 0) { PRINT_D(CFG80211_DBG, "%d Network(s) found \n", priv->u32RcvdChCount); @@ -465,9 +465,9 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo down(&(priv->hSemScanReq)); if (priv->pstrScanReq != NULL) { - cfg80211_scan_done(priv->pstrScanReq, WILC_FALSE); + cfg80211_scan_done(priv->pstrScanReq, false); priv->u32RcvdChCount = 0; - priv->bCfgScanning = WILC_FALSE; + priv->bCfgScanning = false; priv->pstrScanReq = NULL; } up(&(priv->hSemScanReq)); @@ -481,10 +481,10 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo if (priv->pstrScanReq != NULL) { update_scan_time(priv); - refresh_scan(priv, 1, WILC_FALSE); + refresh_scan(priv, 1, false); - cfg80211_scan_done(priv->pstrScanReq, WILC_FALSE); - priv->bCfgScanning = WILC_FALSE; + cfg80211_scan_done(priv->pstrScanReq, false); + priv->bCfgScanning = false; priv->pstrScanReq = NULL; } up(&(priv->hSemScanReq)); @@ -599,7 +599,7 @@ static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent, } if (u16ConnectStatus == WLAN_STATUS_SUCCESS) { - WILC_Bool bNeedScanRefresh = WILC_FALSE; + bool bNeedScanRefresh = false; u32 i; PRINT_INFO(CFG80211_DBG, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo->au8bssid[0], @@ -617,17 +617,17 @@ static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent, if (time_after(now, astrLastScannedNtwrksShadow[i].u32TimeRcvdInScanCached + (unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ)))) { - bNeedScanRefresh = WILC_TRUE; + bNeedScanRefresh = true; } break; } } - if (bNeedScanRefresh == WILC_TRUE) { + if (bNeedScanRefresh == true) { /*BugID_5418*/ /*Also, refrsh DIRECT- results if */ - refresh_scan(priv, 1, WILC_TRUE); + refresh_scan(priv, 1, true); } @@ -645,13 +645,13 @@ static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent, /* be replaced by pstrConnectInfo->u16ConnectStatus */ } else if (enuConnDisconnEvent == CONN_DISCONN_EVENT_DISCONN_NOTIF) { #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP - g_obtainingIP = WILC_FALSE; + g_obtainingIP = false; #endif PRINT_ER("Received MAC_DISCONNECTED from firmware with reason %d on dev [%p]\n", pstrDisconnectNotifInfo->u16reason, priv->dev); u8P2Plocalrandom = 0x01; u8P2Precvrandom = 0x00; - bWilc_ie = WILC_FALSE; + bWilc_ie = false; WILC_memset(priv->au8AssociatedBss, 0, ETH_ALEN); linux_wlan_set_bssid(priv->dev, NullBssid); WILC_memset(u8ConnectedSSID, 0, ETH_ALEN); @@ -752,7 +752,7 @@ static int WILC_WFI_CfgScan(struct wiphy *wiphy, struct cfg80211_scan_request *r reset_shadow_found(priv); - priv->bCfgScanning = WILC_TRUE; + priv->bCfgScanning = true; if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */ /* max_scan_ssids */ for (i = 0; i < request->n_channels; i++) { @@ -935,7 +935,7 @@ static int WILC_WFI_CfgConnect(struct wiphy *wiphy, struct net_device *dev, g_key_wep_params.key = WILC_MALLOC(sme->key_len); memcpy(g_key_wep_params.key, sme->key, sme->key_len); g_key_wep_params.key_idx = sme->key_idx; - g_wep_keys_saved = WILC_TRUE; + g_wep_keys_saved = true; host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx); host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx); @@ -953,7 +953,7 @@ static int WILC_WFI_CfgConnect(struct wiphy *wiphy, struct net_device *dev, g_key_wep_params.key = WILC_MALLOC(sme->key_len); memcpy(g_key_wep_params.key, sme->key, sme->key_len); g_key_wep_params.key_idx = sme->key_idx; - g_wep_keys_saved = WILC_TRUE; + g_wep_keys_saved = true; host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx); host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx); @@ -1101,7 +1101,7 @@ static int WILC_WFI_disconnect(struct wiphy *wiphy, struct net_device *dev, u16 u8P2Plocalrandom = 0x01; u8P2Precvrandom = 0x00; - bWilc_ie = WILC_FALSE; + bWilc_ie = false; #ifdef WILC_P2P pstrWFIDrv->u64P2p_MgmtTimeout = 0; #endif @@ -1348,7 +1348,7 @@ static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 k PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_gtk_params.key[0], g_key_gtk_params.key[1], g_key_gtk_params.key[2]); - g_gtk_keys_saved = WILC_TRUE; + g_gtk_keys_saved = true; } host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen, @@ -1385,7 +1385,7 @@ static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 k PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_ptk_params.key[0], g_key_ptk_params.key[1], g_key_ptk_params.key[2]); - g_ptk_keys_saved = WILC_TRUE; + g_ptk_keys_saved = true; } host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr, @@ -1431,9 +1431,9 @@ static int WILC_WFI_del_key(struct wiphy *wiphy, struct net_device *netdev, /*BugID_5137*/ /*delete saved keys, if any*/ if (netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) { - g_ptk_keys_saved = WILC_FALSE; - g_gtk_keys_saved = WILC_FALSE; - g_wep_keys_saved = WILC_FALSE; + g_ptk_keys_saved = false; + g_gtk_keys_saved = false; + g_wep_keys_saved = false; /*Delete saved WEP keys params, if any*/ if (g_key_wep_params.key != NULL) { @@ -1499,7 +1499,7 @@ static int WILC_WFI_del_key(struct wiphy *wiphy, struct net_device *netdev, } /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/ - Set_machw_change_vir_if(WILC_FALSE); + Set_machw_change_vir_if(false); } if (key_index >= 0 && key_index <= 3) { @@ -1702,9 +1702,9 @@ static int WILC_WFI_get_station(struct wiphy *wiphy, struct net_device *dev, #ifdef TCP_ENHANCEMENTS if ((strStatistics.u8LinkSpeed > TCP_ACK_FILTER_LINK_SPEED_THRESH) && (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED)) { - Enable_TCP_ACK_Filter(WILC_TRUE); + Enable_TCP_ACK_Filter(true); } else if (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED) { - Enable_TCP_ACK_Filter(WILC_FALSE); + Enable_TCP_ACK_Filter(false); } #endif @@ -2032,7 +2032,7 @@ void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len) #ifdef USE_SUPPLICANT_GO_INTENT u8 intent; u8 tie_breaker; - WILC_Bool is_wilc_go = WILC_TRUE; + bool is_wilc_go = true; #endif u8 op_channel_attr_index = 0; u8 channel_list_attr_index = 0; @@ -2048,10 +2048,10 @@ void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len) if (intent > SUPPLICANT_GO_INTENT || (intent == SUPPLICANT_GO_INTENT && tie_breaker == 1)) { PRINT_D(GENERIC_DBG, "WILC will be client (intent %d tie breaker %d)\n", intent, tie_breaker); - is_wilc_go = WILC_FALSE; + is_wilc_go = false; } else { PRINT_D(GENERIC_DBG, "WILC will be GO (intent %d tie breaker %d)\n", intent, tie_breaker); - is_wilc_go = WILC_TRUE; + is_wilc_go = true; } #else /* USE_SUPPLICANT_GO_INTENT */ @@ -2070,7 +2070,7 @@ void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len) PRINT_D(GENERIC_DBG, "Group BSSID: %2x:%2x:%2x\n", buf[index + 3] , buf[index + 4] , buf[index + 5]); - is_wilc_go = WILC_FALSE; + is_wilc_go = false; } #endif /* USE_SUPPLICANT_GO_INTENT */ @@ -2119,7 +2119,7 @@ void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len) * @date 12 DEC 2012 * @version */ -void WILC_WFI_CfgParseTxAction(u8 *buf, u32 len, WILC_Bool bOperChan, u8 iftype) +void WILC_WFI_CfgParseTxAction(u8 *buf, u32 len, bool bOperChan, u8 iftype) { u32 index = 0; u32 i = 0, j = 0; @@ -2127,7 +2127,7 @@ void WILC_WFI_CfgParseTxAction(u8 *buf, u32 len, WILC_Bool bOperChan, u8 iftype) u8 op_channel_attr_index = 0; u8 channel_list_attr_index = 0; #ifdef USE_SUPPLICANT_GO_INTENT - WILC_Bool is_wilc_go = WILC_FALSE; + bool is_wilc_go = false; /*BugID_5460*/ /*Case 1: If we are already p2p client, no need to modify channels attributes*/ @@ -2145,7 +2145,7 @@ void WILC_WFI_CfgParseTxAction(u8 *buf, u32 len, WILC_Bool bOperChan, u8 iftype) PRINT_D(GENERIC_DBG, "Group BSSID: %2x:%2x:%2x\n", buf[index + 3] , buf[index + 4] , buf[index + 5]); - is_wilc_go = WILC_TRUE; + is_wilc_go = true; } #else /* USE_SUPPLICANT_GO_INTENT */ @@ -2252,7 +2252,7 @@ void WILC_WFI_p2p_rx (struct net_device *dev, uint8_t *buff, uint32_t size) if (ieee80211_is_action(buff[FRAME_TYPE_ID])) { PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]); - if (priv->bCfgScanning == WILC_TRUE && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->u64P2p_MgmtTimeout)) { + if (priv->bCfgScanning == true && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->u64P2p_MgmtTimeout)) { PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n"); return; } @@ -2276,7 +2276,7 @@ void WILC_WFI_p2p_rx (struct net_device *dev, uint8_t *buff, uint32_t size) for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) { if (!WILC_memcmp(u8P2P_vendorspec, &buff[i], 6)) { u8P2Precvrandom = buff[i + 6]; - bWilc_ie = WILC_TRUE; + bWilc_ie = true; PRINT_D(GENERIC_DBG, "WILC Vendor specific IE:%02x\n", u8P2Precvrandom); break; } @@ -2353,7 +2353,7 @@ static void WILC_WFI_RemainOnChannelReady(void *pUserVoid) PRINT_D(HOSTINF_DBG, "Remain on channel ready \n"); - priv->bInP2PlistenState = WILC_TRUE; + priv->bInP2PlistenState = true; cfg80211_ready_on_channel(priv->wdev, priv->strRemainOnChanParams.u64ListenCookie, @@ -2381,7 +2381,7 @@ static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, u32 u32SessionID) if (u32SessionID == priv->strRemainOnChanParams.u32ListenSessionID) { PRINT_D(GENERIC_DBG, "Remain on channel expired \n"); - priv->bInP2PlistenState = WILC_FALSE; + priv->bInP2PlistenState = false; /*Inform wpas of remain-on-channel expiration*/ cfg80211_remain_on_channel_expired(priv->wdev, @@ -2498,7 +2498,7 @@ void WILC_WFI_add_wilcvendorspec(u8 *buff) * @version */ extern linux_wlan_t *g_linux_wlan; -extern WILC_Bool bEnablePS; +extern bool bEnablePS; int WILC_WFI_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, struct cfg80211_mgmt_tx_params *params, @@ -2602,14 +2602,14 @@ int WILC_WFI_mgmt_tx(struct wiphy *wiphy, for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) { if (buf[i] == P2PELEM_ATTR_ID && !(WILC_memcmp(u8P2P_oui, &buf[i + 2], 4))) { if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP) - WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), WILC_TRUE, nic->iftype); + WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), true, nic->iftype); /*BugID_5460*/ /*If using supplicant go intent, no need at all*/ /*to parse transmitted negotiation frames*/ #ifndef USE_SUPPLICANT_GO_INTENT else - WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), WILC_FALSE, nic->iftype); + WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), false, nic->iftype); #endif break; } @@ -2667,7 +2667,7 @@ int WILC_WFI_mgmt_tx_cancel_wait(struct wiphy *wiphy, PRINT_D(GENERIC_DBG, "Tx Cancel wait :%lu\n", jiffies); pstrWFIDrv->u64P2p_MgmtTimeout = jiffies; - if (priv->bInP2PlistenState == WILC_FALSE) { + if (priv->bInP2PlistenState == false) { /* Bug 5504: This is just to avoid connection failure when getting stuck when the supplicant * considers the driver falsely that it is in Listen state */ cfg80211_remain_on_channel_expired(priv->wdev, @@ -2817,7 +2817,7 @@ int WILC_WFI_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, return -EIO; } - if (bEnablePS == WILC_TRUE) + if (bEnablePS == true) host_int_set_power_mgmt(priv->hWILCWFIDrv, enabled, timeout); @@ -2858,17 +2858,17 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev u8P2Plocalrandom = 0x01; u8P2Precvrandom = 0x00; - bWilc_ie = WILC_FALSE; + bWilc_ie = false; #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP - g_obtainingIP = WILC_FALSE; + g_obtainingIP = false; WILC_TimerStop(&hDuringIpTimer, NULL); PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n"); #endif /*BugID_5137*/ /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/ if (g_ptk_keys_saved && g_gtk_keys_saved) { - Set_machw_change_vir_if(WILC_TRUE); + Set_machw_change_vir_if(true); } switch (type) { @@ -2960,7 +2960,7 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev } } - bEnablePS = WILC_TRUE; + bEnablePS = true; host_int_set_power_mgmt(priv->hWILCWFIDrv, 1, 0); } #endif @@ -2968,7 +2968,7 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev break; case NL80211_IFTYPE_P2P_CLIENT: - bEnablePS = WILC_FALSE; + bEnablePS = false; host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0); connecting = 0; PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n"); @@ -3037,8 +3037,8 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev } /*Refresh scan, to refresh the scan results to the wpa_supplicant. Set MachHw to false to enable further key installments*/ - refresh_scan(priv, 1, WILC_TRUE); - Set_machw_change_vir_if(WILC_FALSE); + refresh_scan(priv, 1, true); + Set_machw_change_vir_if(false); /*BugID_4847: registered frames in firmware are now lost * due to mac close. So re-register those frames */ @@ -3057,7 +3057,7 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev break; case NL80211_IFTYPE_AP: - bEnablePS = WILC_FALSE; + bEnablePS = false; PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type); dev->ieee80211_ptr->iftype = type; priv->wdev->iftype = type; @@ -3093,7 +3093,7 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev PRINT_D(GENERIC_DBG, "start duringIP timer\n"); #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP - g_obtainingIP = WILC_TRUE; + g_obtainingIP = true; WILC_TimerStart(&hDuringIpTimer, duringIP_TIME, NULL, NULL); #endif host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0); @@ -3103,7 +3103,7 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev /*hWaitResponse semaphore, which allows previous config*/ /*packets to actually take action on old FW*/ host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID); - bEnablePS = WILC_FALSE; + bEnablePS = false; PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n"); dev->ieee80211_ptr->iftype = type; priv->wdev->iftype = type; @@ -3379,9 +3379,9 @@ static int WILC_WFI_add_station(struct wiphy *wiphy, struct net_device *dev, PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates); if (params->ht_capa == NULL) { - strStaParams.bIsHTSupported = WILC_FALSE; + strStaParams.bIsHTSupported = false; } else { - strStaParams.bIsHTSupported = WILC_TRUE; + strStaParams.bIsHTSupported = true; strStaParams.u16HTCapInfo = params->ht_capa->cap_info; strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info; WILC_memcpy(strStaParams.au8SuppMCsSet, ¶ms->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE); @@ -3509,9 +3509,9 @@ static int WILC_WFI_change_station(struct wiphy *wiphy, struct net_device *dev, PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates); if (params->ht_capa == NULL) { - strStaParams.bIsHTSupported = WILC_FALSE; + strStaParams.bIsHTSupported = false; } else { - strStaParams.bIsHTSupported = WILC_TRUE; + strStaParams.bIsHTSupported = true; strStaParams.u16HTCapInfo = params->ht_capa->cap_info; strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info; WILC_memcpy(strStaParams.au8SuppMCsSet, ¶ms->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE); @@ -3867,9 +3867,9 @@ int WILC_WFI_InitHostInt(struct net_device *net) return s32Error; } - priv->gbAutoRateAdjusted = WILC_FALSE; + priv->gbAutoRateAdjusted = false; - priv->bInP2PlistenState = WILC_FALSE; + priv->bInP2PlistenState = false; sema_init(&(priv->hSemScanReq), 1); s32Error = host_int_init(&priv->hWILCWFIDrv); @@ -3895,9 +3895,9 @@ int WILC_WFI_DeInitHostInt(struct net_device *net) struct WILC_WFI_priv *priv; priv = wdev_priv(net->ieee80211_ptr); - priv->gbAutoRateAdjusted = WILC_FALSE; + priv->gbAutoRateAdjusted = false; - priv->bInP2PlistenState = WILC_FALSE; + priv->bInP2PlistenState = false; op_ifcs--; diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h index f45a15f4650f..c25350cb58c8 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h @@ -123,7 +123,7 @@ struct net_device *WILC_WFI_init_mon_interface(const char *name, struct net_devi #ifdef TCP_ENHANCEMENTS #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54 #define DEFAULT_LINK_SPEED 72 -extern void Enable_TCP_ACK_Filter(WILC_Bool value); +extern void Enable_TCP_ACK_Filter(bool value); #endif #endif diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.c b/drivers/staging/wilc1000/wilc_wfi_netdevice.c index fbc4b857aa35..f6974a6b116f 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.c +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.c @@ -931,7 +931,7 @@ int WILC_WFI_InitModule(void) /* priv[1]->monitor_flag = 1; */ } - priv[0]->bCfgScanning = WILC_FALSE; + priv[0]->bCfgScanning = false; priv[0]->u32RcvdChCount = 0; WILC_memset(priv[0]->au8AssociatedBss, 0xFF, ETH_ALEN); diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 10e6b1a22fd6..2331a006ec0e 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -134,7 +134,7 @@ struct WILC_WFI_priv { #endif - WILC_Bool bCfgScanning; + bool bCfgScanning; u32 u32RcvdChCount; @@ -168,15 +168,15 @@ struct WILC_WFI_priv { struct semaphore SemHandleUpdateStats; struct semaphore hSemScanReq; /* */ - WILC_Bool gbAutoRateAdjusted; + bool gbAutoRateAdjusted; - WILC_Bool bInP2PlistenState; + bool bInP2PlistenState; }; typedef struct { u16 frame_type; - WILC_Bool reg; + bool reg; } struct_frame_reg; diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index a456d0d140c1..762470c4e052 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -27,7 +27,7 @@ extern void WILC_WFI_mgmt_rx(uint8_t *buff, uint32_t size); extern void frmw_to_linux(uint8_t *buff, uint32_t size); int sdio_xfer_cnt(void); uint32_t wilc_get_chipid(uint8_t update); -u16 Set_machw_change_vir_if(WILC_Bool bValue); +u16 Set_machw_change_vir_if(bool bValue); @@ -487,14 +487,14 @@ static int wilc_wlan_txq_filter_dup_tcp_ack(void) #endif #ifdef TCP_ENHANCEMENTS -WILC_Bool EnableTCPAckFilter = WILC_FALSE; +bool EnableTCPAckFilter = false; -void Enable_TCP_ACK_Filter(WILC_Bool value) +void Enable_TCP_ACK_Filter(bool value) { EnableTCPAckFilter = value; } -WILC_Bool is_TCP_ACK_Filter_Enabled(void) +bool is_TCP_ACK_Filter_Enabled(void) { return EnableTCPAckFilter; } @@ -559,7 +559,7 @@ static int wilc_wlan_txq_add_net_pkt(void *priv, uint8_t *buffer, uint32_t buffe #ifdef TCP_ACK_FILTER tqe->tcp_PendingAck_index = NOT_TCP_ACK; #ifdef TCP_ENHANCEMENTS - if (is_TCP_ACK_Filter_Enabled() == WILC_TRUE) + if (is_TCP_ACK_Filter_Enabled() == true) #endif tcp_process(tqe); #endif @@ -738,12 +738,12 @@ INLINE void chip_wakeup(void) WILC_Sleep(2); /* Make sure chip is awake. This is an extra step that can be removed */ /* later to avoid the bus access overhead */ - if ((wilc_get_chipid(WILC_TRUE) == 0)) { + if ((wilc_get_chipid(true) == 0)) { wilc_debug(N_ERR, "Couldn't read chip id. Wake up failed\n"); } - } while ((wilc_get_chipid(WILC_TRUE) == 0) && ((++trials % 3) == 0)); + } while ((wilc_get_chipid(true) == 0) && ((++trials % 3) == 0)); - } while (wilc_get_chipid(WILC_TRUE) == 0); + } while (wilc_get_chipid(true) == 0); } else if ((g_wlan.io_func.io_type & 0x1) == HIF_SDIO) { g_wlan.hif_func.hif_read_reg(0xf0, ®); do { @@ -782,7 +782,7 @@ INLINE void chip_wakeup(void) reg &= ~(1 << 0); g_wlan.hif_func.hif_write_reg(0x1C0C, reg); - if (wilc_get_chipid(WILC_FALSE) >= 0x1002b0) { + if (wilc_get_chipid(false) >= 0x1002b0) { /* Enable PALDO back right after wakeup */ uint32_t val32; g_wlan.hif_func.hif_read_reg(0x1e1c, &val32); @@ -825,19 +825,19 @@ INLINE void chip_wakeup(void) /* Make sure chip is awake. This is an extra step that can be removed */ /* later to avoid the bus access overhead */ - if ((wilc_get_chipid(WILC_TRUE) == 0)) { + if ((wilc_get_chipid(true) == 0)) { wilc_debug(N_ERR, "Couldn't read chip id. Wake up failed\n"); } - } while ((wilc_get_chipid(WILC_TRUE) == 0) && ((++trials % 3) == 0)); + } while ((wilc_get_chipid(true) == 0) && ((++trials % 3) == 0)); - } while (wilc_get_chipid(WILC_TRUE) == 0); + } while (wilc_get_chipid(true) == 0); if (genuChipPSstate == CHIP_SLEEPING_MANUAL) { g_wlan.hif_func.hif_read_reg(0x1C0C, ®); reg &= ~(1 << 0); g_wlan.hif_func.hif_write_reg(0x1C0C, reg); - if (wilc_get_chipid(WILC_FALSE) >= 0x1002b0) { + if (wilc_get_chipid(false) >= 0x1002b0) { /* Enable PALDO back right after wakeup */ uint32_t val32; g_wlan.hif_func.hif_read_reg(0x1e1c, &val32); @@ -1354,7 +1354,7 @@ static void wilc_pllupdate_isr_ext(uint32_t int_stats) g_wlan.os_func.os_atomic_sleep(WILC_PLL_TO); /* poll till read a valid data */ - while (!(ISWILC1000(wilc_get_chipid(WILC_TRUE)) && --trials)) { + while (!(ISWILC1000(wilc_get_chipid(true)) && --trials)) { PRINT_D(TX_DBG, "PLL update retrying\n"); g_wlan.os_func.os_atomic_sleep(1); } @@ -2012,7 +2012,7 @@ uint32_t init_chip(void) acquire_bus(ACQUIRE_ONLY); #endif - chipid = wilc_get_chipid(WILC_TRUE); + chipid = wilc_get_chipid(true); @@ -2325,7 +2325,7 @@ _fail_: } #define BIT31 (1 << 31) -u16 Set_machw_change_vir_if(WILC_Bool bValue) +u16 Set_machw_change_vir_if(bool bValue) { u16 ret; u32 reg; @@ -2337,7 +2337,7 @@ u16 Set_machw_change_vir_if(WILC_Bool bValue) PRINT_ER("Error while Reading reg WILC_CHANGING_VIR_IF\n"); } - if (bValue == WILC_TRUE) { + if (bValue == true) { reg |= (BIT31); } else { reg &= ~(BIT31); diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.c b/drivers/staging/wilc1000/wilc_wlan_cfg.c index d7e7e92536f6..9631b18c0bb7 100644 --- a/drivers/staging/wilc1000/wilc_wlan_cfg.c +++ b/drivers/staging/wilc1000/wilc_wlan_cfg.c @@ -14,7 +14,7 @@ #ifdef WILC_FULLY_HOSTING_AP #include "wilc_host_ap.h" -void WILC_mgm_HOSTAPD_ACK(void *priv, WILC_Bool bStatus); +void WILC_mgm_HOSTAPD_ACK(void *priv, bool bStatus); #endif /******************************************** @@ -542,7 +542,7 @@ static int wilc_wlan_cfg_indicate_rx(uint8_t *frame, int size, wilc_cfg_rsp_t *r uint16_t msg_len; #ifdef WILC_FULLY_HOSTING_AP u32 *ptru32Frame; - WILC_Bool bStatus = frame[2]; + bool bStatus = frame[2]; #ifdef BIG_ENDIAN ptru32Frame = (frame[4] << 24) | (frame[5] << 16) | (frame[6] << 8) | frame[7]; From f57081a5723b89186ce0c59c38dc7b2fe877b0da Mon Sep 17 00:00:00 2001 From: James Simmons Date: Thu, 11 Jun 2015 15:18:07 -0400 Subject: [PATCH 0931/1163] staging:lustre: Delete all obsolete LND drivers Remove ralnd, ptllnd, mxlnd, qswlnd drivers. They are no longer supported and have not even been buildable for a long time. Signed-off-by: James Simmons Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6209 Reviewed-on: http://review.whamcloud.com/13663 Reviewed-by: Isaac Huang Reviewed-by: Doug Oucharek Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../include/linux/libcfs/libcfs_ioctl.h | 2 +- .../lustre/include/linux/lnet/lib-lnet.h | 1 - .../lustre/include/linux/lnet/lib-types.h | 4 - .../lustre/include/linux/lnet/ptllnd.h | 93 -------------- .../lustre/include/linux/lnet/ptllnd_wire.h | 119 ------------------ drivers/staging/lustre/lnet/lnet/acceptor.c | 2 - drivers/staging/lustre/lnet/lnet/config.c | 77 ------------ 7 files changed, 1 insertion(+), 297 deletions(-) delete mode 100644 drivers/staging/lustre/include/linux/lnet/ptllnd.h delete mode 100644 drivers/staging/lustre/include/linux/lnet/ptllnd_wire.h diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h index 3ee38782ad8c..f5d741f25ffd 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h @@ -134,7 +134,7 @@ struct libcfs_ioctl_handler { #define IOC_LIBCFS_DEL_PEER _IOWR('e', 74, long) #define IOC_LIBCFS_ADD_PEER _IOWR('e', 75, long) #define IOC_LIBCFS_GET_PEER _IOWR('e', 76, long) -#define IOC_LIBCFS_GET_TXDESC _IOWR('e', 77, long) +/* ioctl 77 is free for use */ #define IOC_LIBCFS_ADD_INTERFACE _IOWR('e', 78, long) #define IOC_LIBCFS_DEL_INTERFACE _IOWR('e', 79, long) #define IOC_LIBCFS_GET_INTERFACE _IOWR('e', 80, long) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index ac3be9486e8f..ffe88f670604 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -623,7 +623,6 @@ void lnet_md_deconstruct(lnet_libmd_t *lmd, lnet_md_t *umd); void lnet_register_lnd(lnd_t *lnd); void lnet_unregister_lnd(lnd_t *lnd); -int lnet_set_ip_niaddr(lnet_ni_t *ni); int lnet_connect(struct socket **sockp, lnet_nid_t peer_nid, __u32 local_ip, __u32 peer_ip, int peer_port); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 41827a0c8f74..ad6df8851132 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -142,12 +142,8 @@ typedef struct { /* PROTO MAGIC for LNDs */ #define LNET_PROTO_IB_MAGIC 0x0be91b91 -#define LNET_PROTO_RA_MAGIC 0x0be91b92 -#define LNET_PROTO_QSW_MAGIC 0x0be91b93 #define LNET_PROTO_GNI_MAGIC 0xb00fbabe /* ask Kim */ #define LNET_PROTO_TCP_MAGIC 0xeebc0ded -#define LNET_PROTO_PTL_MAGIC 0x50746C4E /* 'PtlN' unique magic */ -#define LNET_PROTO_MX_MAGIC 0x4d583130 /* 'MX10'! */ #define LNET_PROTO_ACCEPTOR_MAGIC 0xacce7100 #define LNET_PROTO_PING_MAGIC 0x70696E67 /* 'ping' */ diff --git a/drivers/staging/lustre/include/linux/lnet/ptllnd.h b/drivers/staging/lustre/include/linux/lnet/ptllnd.h deleted file mode 100644 index c91d65329995..000000000000 --- a/drivers/staging/lustre/include/linux/lnet/ptllnd.h +++ /dev/null @@ -1,93 +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) 2007, 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. - * - * lnet/include/lnet/ptllnd.h - * - * Author: PJ Kirner - */ - -/* - * The PTLLND was designed to support Portals with - * Lustre and non-lustre UNLINK semantics. - * However for now the two targets are Cray Portals - * on the XT3 and Lustre Portals (for testing) both - * have Lustre UNLINK semantics, so this is defined - * by default. - */ -#define LUSTRE_PORTALS_UNLINK_SEMANTICS - -#ifdef _USING_LUSTRE_PORTALS_ - -/* NIDs are 64-bits on Lustre Portals */ -#define FMT_NID "%llu" -#define FMT_PID "%d" - -/* When using Lustre Portals Lustre completion semantics are imlicit*/ -#define PTL_MD_LUSTRE_COMPLETION_SEMANTICS 0 - -#else /* _USING_CRAY_PORTALS_ */ - -/* NIDs are integers on Cray Portals */ -#define FMT_NID "%u" -#define FMT_PID "%d" - -/* When using Cray Portals this is defined in the Cray Portals Header*/ -/*#define PTL_MD_LUSTRE_COMPLETION_SEMANTICS */ - -/* Can compare handles directly on Cray Portals */ -#define PtlHandleIsEqual(a, b) ((a) == (b)) - -/* Different error types on Cray Portals*/ -#define ptl_err_t ptl_ni_fail_t - -/* - * The Cray Portals has no maximum number of IOVs. The - * maximum is limited only by memory and size of the - * int parameters (2^31-1). - * Lustre only really require that the underyling - * implementation to support at least LNET_MAX_IOV, - * so for Cray portals we can safely just use that - * value here. - * - */ -#define PTL_MD_MAX_IOV LNET_MAX_IOV - -#endif - -#define FMT_PTLID "ptlid:"FMT_PID"-"FMT_NID - -/* Align incoming small request messages to an 8 byte boundary if this is - * supported to avoid alignment issues on some architectures */ -#ifndef PTL_MD_LOCAL_ALIGN8 -# define PTL_MD_LOCAL_ALIGN8 0 -#endif diff --git a/drivers/staging/lustre/include/linux/lnet/ptllnd_wire.h b/drivers/staging/lustre/include/linux/lnet/ptllnd_wire.h deleted file mode 100644 index 808f37b64a4f..000000000000 --- a/drivers/staging/lustre/include/linux/lnet/ptllnd_wire.h +++ /dev/null @@ -1,119 +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) 2007, 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. - * - * lnet/include/lnet/ptllnd_wire.h - * - * Author: PJ Kirner - */ - -/* Minimum buffer size that any peer will post to receive ptllnd messages */ -#define PTLLND_MIN_BUFFER_SIZE 256 - -/************************************************************************ - * Tunable defaults that {u,k}lnds/ptllnd should have in common. - */ - -#define PTLLND_PORTAL 9 /* The same portal PTLPRC used when talking to cray portals */ -#define PTLLND_PID 9 /* The Portals PID */ -#define PTLLND_PEERCREDITS 8 /* concurrent sends to 1 peer */ - -/* Default buffer size for kernel ptllnds (guaranteed eager) */ -#define PTLLND_MAX_KLND_MSG_SIZE 512 - -/* Default buffer size for catamount ptllnds (not guaranteed eager) - large - * enough to avoid RDMA for anything sent while control is not in liblustre */ -#define PTLLND_MAX_ULND_MSG_SIZE 512 - -/************************************************************************ - * Portals LND Wire message format. - * These are sent in sender's byte order (i.e. receiver flips). - */ - -#define PTL_RESERVED_MATCHBITS 0x100 /* below this value is reserved - * above is for bulk data transfer */ -#define LNET_MSG_MATCHBITS 0 /* the value for the message channel */ - -typedef struct { - lnet_hdr_t kptlim_hdr; /* portals header */ - char kptlim_payload[0]; /* piggy-backed payload */ -} WIRE_ATTR kptl_immediate_msg_t; - -typedef struct { - lnet_hdr_t kptlrm_hdr; /* portals header */ - __u64 kptlrm_matchbits; /* matchbits */ -} WIRE_ATTR kptl_rdma_msg_t; - -typedef struct { - __u64 kptlhm_matchbits; /* matchbits */ - __u32 kptlhm_max_msg_size; /* max message size */ -} WIRE_ATTR kptl_hello_msg_t; - -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 */ - __u8 ptlm_type; /* the message type */ - __u8 ptlm_credits; /* returned credits */ - __u32 ptlm_nob; /* # bytes in whole message */ - __u32 ptlm_cksum; /* checksum (0 == no checksum) */ - __u64 ptlm_srcnid; /* sender's NID */ - __u64 ptlm_srcstamp; /* sender's incarnation */ - __u64 ptlm_dstnid; /* destination's NID */ - __u64 ptlm_dststamp; /* destination's incarnation */ - __u32 ptlm_srcpid; /* sender's PID */ - __u32 ptlm_dstpid; /* destination's PID */ - - union { - kptl_immediate_msg_t immediate; - kptl_rdma_msg_t rdma; - kptl_hello_msg_t hello; - } WIRE_ATTR ptlm_u; - -} 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_MAGIC LNET_PROTO_PTL_MAGIC -#define PTLLND_MSG_VERSION 0x04 - -#define PTLLND_RDMA_OK 0x00 -#define PTLLND_RDMA_FAIL 0x01 - -#define PTLLND_MSG_TYPE_INVALID 0x00 -#define PTLLND_MSG_TYPE_PUT 0x01 -#define PTLLND_MSG_TYPE_GET 0x02 -#define PTLLND_MSG_TYPE_IMMEDIATE 0x03 /* No bulk data xfer*/ -#define PTLLND_MSG_TYPE_NOOP 0x04 -#define PTLLND_MSG_TYPE_HELLO 0x05 -#define PTLLND_MSG_TYPE_NAK 0x06 diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c index be850353d02d..99f8396f3822 100644 --- a/drivers/staging/lustre/lnet/lnet/acceptor.c +++ b/drivers/staging/lustre/lnet/lnet/acceptor.c @@ -243,8 +243,6 @@ lnet_accept(struct socket *sock, __u32 magic) if (magic == le32_to_cpu(LNET_PROTO_TCP_MAGIC)) str = "'old' socknal/tcpnal"; - else if (lnet_accept_magic(magic, LNET_PROTO_RA_MAGIC)) - str = "'old' ranal"; else str = "unrecognised"; diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c index efbb74a9e4e6..9c576ce2f455 100644 --- a/drivers/staging/lustre/lnet/lnet/config.c +++ b/drivers/staging/lustre/lnet/lnet/config.c @@ -1210,80 +1210,3 @@ lnet_parse_ip2nets(char **networksp, char *ip2nets) return 0; } - -int -lnet_set_ip_niaddr(lnet_ni_t *ni) -{ - __u32 net = LNET_NIDNET(ni->ni_nid); - char **names; - int n; - __u32 ip; - __u32 netmask; - int up; - int i; - int rc; - - /* Convenience for LNDs that use the IP address of a local interface as - * the local address part of their NID */ - - if (ni->ni_interfaces[0] != NULL) { - - CLASSERT(LNET_MAX_INTERFACES > 1); - - if (ni->ni_interfaces[1] != NULL) { - CERROR("Net %s doesn't support multiple interfaces\n", - libcfs_net2str(net)); - return -EPERM; - } - - rc = lnet_ipif_query(ni->ni_interfaces[0], &up, &ip, &netmask); - if (rc != 0) { - CERROR("Net %s can't query interface %s: %d\n", - libcfs_net2str(net), ni->ni_interfaces[0], rc); - return -EPERM; - } - - if (!up) { - CERROR("Net %s can't use interface %s: it's down\n", - libcfs_net2str(net), ni->ni_interfaces[0]); - return -ENETDOWN; - } - - ni->ni_nid = LNET_MKNID(net, ip); - return 0; - } - - n = lnet_ipif_enumerate(&names); - if (n <= 0) { - CERROR("Net %s can't enumerate interfaces: %d\n", - libcfs_net2str(net), n); - return 0; - } - - for (i = 0; i < n; i++) { - if (!strcmp(names[i], "lo")) /* skip the loopback IF */ - continue; - - rc = lnet_ipif_query(names[i], &up, &ip, &netmask); - if (rc != 0) { - CWARN("Net %s can't query interface %s: %d\n", - libcfs_net2str(net), names[i], rc); - continue; - } - - if (!up) { - CWARN("Net %s ignoring interface %s (down)\n", - libcfs_net2str(net), names[i]); - continue; - } - - lnet_ipif_free_enumeration(names, n); - ni->ni_nid = LNET_MKNID(net, ip); - return 0; - } - - CERROR("Net %s can't find any interfaces\n", libcfs_net2str(net)); - lnet_ipif_free_enumeration(names, n); - return -ENOENT; -} -EXPORT_SYMBOL(lnet_set_ip_niaddr); From d664d1fd5c05f2f93ded3b20fbe3b39dde662673 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Thu, 11 Jun 2015 15:18:08 -0400 Subject: [PATCH 0932/1163] staging:lustre: remove lnet/include/lnet/linux/ Remove the linux specific headers from lnet/include/lnet/linux/, moving whatever was worthwhile from them to their parent headers or elsewhere. Signed-off-by: John L. Hammond Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2675 Reviewed-on: http://review.whamcloud.com/12932 Reviewed-by: Isaac Huang Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/lnet/api-support.h | 44 ------ .../lustre/include/linux/lnet/lib-lnet.h | 2 - .../lustre/include/linux/lnet/lib-types.h | 2 - .../include/linux/lnet/linux/api-support.h | 42 ----- .../include/linux/lnet/linux/lib-lnet.h | 71 --------- .../include/linux/lnet/linux/lib-types.h | 45 ------ .../lustre/include/linux/lnet/linux/lnet.h | 56 ------- .../lustre/include/linux/lnet/lnet-sysctl.h | 49 ------ .../staging/lustre/include/linux/lnet/lnet.h | 2 - .../lustre/lnet/klnds/o2iblnd/o2iblnd.c | 5 +- .../lustre/lnet/klnds/o2iblnd/o2iblnd.h | 1 - .../lustre/lnet/klnds/socklnd/socklnd.h | 1 - .../lnet/klnds/socklnd/socklnd_lib-linux.c | 3 +- drivers/staging/lustre/lnet/lnet/api-ni.c | 2 - drivers/staging/lustre/lnet/lnet/router.c | 145 ------------------ 15 files changed, 4 insertions(+), 466 deletions(-) delete mode 100644 drivers/staging/lustre/include/linux/lnet/api-support.h delete mode 100644 drivers/staging/lustre/include/linux/lnet/linux/api-support.h delete mode 100644 drivers/staging/lustre/include/linux/lnet/linux/lib-lnet.h delete mode 100644 drivers/staging/lustre/include/linux/lnet/linux/lib-types.h delete mode 100644 drivers/staging/lustre/include/linux/lnet/linux/lnet.h delete mode 100644 drivers/staging/lustre/include/linux/lnet/lnet-sysctl.h diff --git a/drivers/staging/lustre/include/linux/lnet/api-support.h b/drivers/staging/lustre/include/linux/lnet/api-support.h deleted file mode 100644 index 8f7fa28b517c..000000000000 --- a/drivers/staging/lustre/include/linux/lnet/api-support.h +++ /dev/null @@ -1,44 +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 __LNET_API_SUPPORT_H__ -#define __LNET_API_SUPPORT_H__ - -#include "linux/api-support.h" - -#include "../libcfs/libcfs.h" -#include "types.h" -#include "lnet.h" - -#endif diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index ffe88f670604..c46e0e6bbefa 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -41,7 +41,6 @@ #ifndef __LNET_LIB_LNET_H__ #define __LNET_LIB_LNET_H__ -#include "linux/lib-lnet.h" #include "../libcfs/libcfs.h" #include "types.h" #include "lnet.h" @@ -654,7 +653,6 @@ int lnet_sock_connect(struct socket **sockp, int *fatal, __u32 peer_ip, int peer_port); void libcfs_sock_release(struct socket *sock); -void lnet_get_tunables(void); int lnet_peers_start_down(void); int lnet_peer_buffer_credits(lnet_ni_t *ni); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index ad6df8851132..4b862d3ea2ec 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -42,8 +42,6 @@ #ifndef __LNET_LIB_TYPES_H__ #define __LNET_LIB_TYPES_H__ -#include "linux/lib-types.h" - #include "../libcfs/libcfs.h" #include #include "types.h" diff --git a/drivers/staging/lustre/include/linux/lnet/linux/api-support.h b/drivers/staging/lustre/include/linux/lnet/linux/api-support.h deleted file mode 100644 index e237ad6af422..000000000000 --- a/drivers/staging/lustre/include/linux/lnet/linux/api-support.h +++ /dev/null @@ -1,42 +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) 2007, 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 __LINUX_API_SUPPORT_H__ -#define __LINUX_API_SUPPORT_H__ - -#ifndef __LNET_API_SUPPORT_H__ -#error Do not #include this file directly. #include instead -#endif - -#endif diff --git a/drivers/staging/lustre/include/linux/lnet/linux/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/linux/lib-lnet.h deleted file mode 100644 index 0f8f04d1ecff..000000000000 --- a/drivers/staging/lustre/include/linux/lnet/linux/lib-lnet.h +++ /dev/null @@ -1,71 +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) 2005, 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 __LNET_LINUX_LIB_LNET_H__ -#define __LNET_LINUX_LIB_LNET_H__ - -#ifndef __LNET_LIB_LNET_H__ -#error Do not #include this file directly. #include instead -#endif - -# include -# include -# include -#include "../../libcfs/libcfs.h" - -static inline __u64 -lnet_page2phys(struct page *p) -{ - /* compiler optimizer will elide unused branches */ - - switch (sizeof(typeof(page_to_phys(p)))) { - case 4: - /* page_to_phys returns a 32 bit physical address. This must - * be a 32 bit machine with <= 4G memory and we must ensure we - * don't sign extend when converting to 64 bits. */ - return (unsigned long)page_to_phys(p); - - case 8: - /* page_to_phys returns a 64 bit physical address :) */ - return page_to_phys(p); - - default: - LBUG(); - return 0; - } -} - -#define LNET_ROUTER - -#endif /* __LNET_LINUX_LIB_LNET_H__ */ diff --git a/drivers/staging/lustre/include/linux/lnet/linux/lib-types.h b/drivers/staging/lustre/include/linux/lnet/linux/lib-types.h deleted file mode 100644 index 669e8c038534..000000000000 --- a/drivers/staging/lustre/include/linux/lnet/linux/lib-types.h +++ /dev/null @@ -1,45 +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) 2005, 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 __LNET_LINUX_LIB_TYPES_H__ -#define __LNET_LINUX_LIB_TYPES_H__ - -#ifndef __LNET_LIB_TYPES_H__ -#error Do not #include this file directly. #include instead -#endif - -# include -# include - -#endif diff --git a/drivers/staging/lustre/include/linux/lnet/linux/lnet.h b/drivers/staging/lustre/include/linux/lnet/linux/lnet.h deleted file mode 100644 index 1e888f1efc45..000000000000 --- a/drivers/staging/lustre/include/linux/lnet/linux/lnet.h +++ /dev/null @@ -1,56 +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) 2005, 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 __LNET_LINUX_LNET_H__ -#define __LNET_LINUX_LNET_H__ - -#ifndef __LNET_H__ -#error Do not #include this file directly. #include instead -#endif - -/* - * lnet.h - * - * User application interface file - */ - -#include -#include - -#define cfs_tcp_sendpage(sk, page, offset, size, flags) \ - tcp_sendpage(sk, page, offset, size, flags) - -#endif diff --git a/drivers/staging/lustre/include/linux/lnet/lnet-sysctl.h b/drivers/staging/lustre/include/linux/lnet/lnet-sysctl.h deleted file mode 100644 index 2dee1b97fb88..000000000000 --- a/drivers/staging/lustre/include/linux/lnet/lnet-sysctl.h +++ /dev/null @@ -1,49 +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) 2008, 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 __LNET_SYSCTL_H__ -#define __LNET_SYSCTL_H__ - -#if defined(CONFIG_SYSCTL) - -#define CTL_KRANAL 201 -#define CTL_O2IBLND 205 -#define CTL_PTLLND 206 -#define CTL_QSWNAL 207 -#define CTL_SOCKLND 208 -#define CTL_GNILND 210 - -#endif - -#endif diff --git a/drivers/staging/lustre/include/linux/lnet/lnet.h b/drivers/staging/lustre/include/linux/lnet/lnet.h index 75c0ab9193cc..8d054a1712c7 100644 --- a/drivers/staging/lustre/include/linux/lnet/lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lnet.h @@ -40,8 +40,6 @@ * * User application interface file */ -#include "linux/lnet.h" - #include "types.h" #include "api.h" diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index 2a72427bdd69..48454a576b7a 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -38,8 +38,9 @@ * Author: Eric Barton */ -#include "o2iblnd.h" #include +#include +#include "o2iblnd.h" static lnd_t the_o2iblnd = { .lnd_type = O2IBLND, @@ -1176,7 +1177,7 @@ void kiblnd_map_rx_descs(kib_conn_t *conn) CDEBUG(D_NET, "rx %d: %p %#llx(%#llx)\n", i, rx->rx_msg, rx->rx_msgaddr, - lnet_page2phys(pg) + pg_off); + (__u64)(page_to_phys(pg) + pg_off)); pg_off += IBLND_MSG_SIZE; LASSERT(pg_off <= PAGE_SIZE); diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h index 7f52c6963427..f5d1d9f8f1ed 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h @@ -65,7 +65,6 @@ #include "../../../include/linux/libcfs/libcfs.h" #include "../../../include/linux/lnet/lnet.h" #include "../../../include/linux/lnet/lib-lnet.h" -#include "../../../include/linux/lnet/lnet-sysctl.h" #include #include diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h index 06531c1d2ffb..53275f9450ba 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h @@ -34,7 +34,6 @@ #include "../../../include/linux/lnet/lnet.h" #include "../../../include/linux/lnet/lib-lnet.h" #include "../../../include/linux/lnet/socklnd.h" -#include "../../../include/linux/lnet/lnet-sysctl.h" #define SOCKNAL_PEER_HASH_SIZE 101 /* # peer lists */ #define SOCKNAL_RESCHED 100 /* # scheduler loops before reschedule */ 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 34c6a728b71b..2b40a9fe00c9 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c @@ -146,8 +146,7 @@ ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx) rc = sk->sk_prot->sendpage(sk, page, offset, fragsize, msgflg); } else { - rc = cfs_tcp_sendpage(sk, page, offset, fragsize, - msgflg); + rc = tcp_sendpage(sk, page, offset, fragsize, msgflg); } } else { #if SOCKNAL_SINGLE_FRAG_TX || !SOCKNAL_RISK_KMAP_DEADLOCK diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 9fc3bf6cb052..a2d0d10772d4 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -1218,8 +1218,6 @@ LNetNIInit(lnet_pid_t requested_pid) goto out; } - lnet_get_tunables(); - if (requested_pid == LNET_PID_ANY) { /* Don't instantiate LNET just for me */ rc = -ENETDOWN; diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index 96886a2b4571..4fbae5ef44a9 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -24,8 +24,6 @@ #define DEBUG_SUBSYSTEM S_LNET #include "../../include/linux/lnet/lib-lnet.h" -#if defined(LNET_ROUTER) - #define LNET_NRB_TINY_MIN 512 /* min value for each CPT */ #define LNET_NRB_TINY (LNET_NRB_TINY_MIN * 4) #define LNET_NRB_SMALL_MIN 4096 /* min value for each CPT */ @@ -70,15 +68,6 @@ lnet_peer_buffer_credits(lnet_ni_t *ni) /* forward ref's */ static int lnet_router_checker(void *); -#else - -int -lnet_peer_buffer_credits(lnet_ni_t *ni) -{ - return 0; -} - -#endif static int check_routers_before_use; module_param(check_routers_before_use, int, 0444); @@ -1163,9 +1152,6 @@ lnet_prune_rc_data(int wait_unlink) lnet_net_unlock(LNET_LOCK_EX); } - -#if defined(LNET_ROUTER) - static int lnet_router_checker(void *arg) { @@ -1573,134 +1559,3 @@ lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when) return 0; } EXPORT_SYMBOL(lnet_notify); - -void -lnet_get_tunables(void) -{ -} - -#else - -int -lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when) -{ - return -EOPNOTSUPP; -} - -void -lnet_router_checker(void) -{ - static time_t last; - static int running; - - time_t now = get_seconds(); - int interval = now - last; - int rc; - __u64 version; - lnet_peer_t *rtr; - - /* It's no use to call me again within a sec - all intervals and - * timeouts are measured in seconds */ - if (last != 0 && interval < 2) - return; - - if (last != 0 && - interval > max(live_router_check_interval, - dead_router_check_interval)) - CNETERR("Checker(%d/%d) not called for %d seconds\n", - live_router_check_interval, dead_router_check_interval, - interval); - - LASSERT(LNET_CPT_NUMBER == 1); - - lnet_net_lock(0); - LASSERT(!running); /* recursion check */ - running = 1; - lnet_net_unlock(0); - - last = now; - - if (the_lnet.ln_rc_state == LNET_RC_STATE_STOPPING) - lnet_prune_rc_data(0); /* unlink all rcd and nowait */ - - /* consume all pending events */ - while (1) { - int i; - lnet_event_t ev; - - /* NB ln_rc_eqh must be the 1st in 'eventqs' otherwise the - * recursion breaker in LNetEQPoll would fail */ - rc = LNetEQPoll(&the_lnet.ln_rc_eqh, 1, 0, &ev, &i); - if (rc == 0) /* no event pending */ - break; - - /* NB a lost SENT prevents me from pinging a router again */ - if (rc == -EOVERFLOW) { - CERROR("Dropped an event!!!\n"); - abort(); - } - - LASSERT(rc == 1); - - lnet_router_checker_event(&ev); - } - - if (the_lnet.ln_rc_state == LNET_RC_STATE_STOPPING) { - lnet_prune_rc_data(1); /* release rcd */ - the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN; - running = 0; - return; - } - - LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING); - - lnet_net_lock(0); - - version = the_lnet.ln_routers_version; - list_for_each_entry(rtr, &the_lnet.ln_routers, lp_rtr_list) { - lnet_ping_router_locked(rtr); - LASSERT(version == the_lnet.ln_routers_version); - } - - lnet_net_unlock(0); - - running = 0; /* lock only needed for the recursion check */ -} - -/* NB lnet_peers_start_down depends on me, - * so must be called before any peer creation */ -void -lnet_get_tunables(void) -{ - char *s; - - s = getenv("LNET_ROUTER_PING_TIMEOUT"); - if (s != NULL) - router_ping_timeout = atoi(s); - - s = getenv("LNET_LIVE_ROUTER_CHECK_INTERVAL"); - if (s != NULL) - live_router_check_interval = atoi(s); - - s = getenv("LNET_DEAD_ROUTER_CHECK_INTERVAL"); - if (s != NULL) - dead_router_check_interval = atoi(s); - - /* This replaces old lnd_notify mechanism */ - check_routers_before_use = 1; - if (dead_router_check_interval <= 0) - dead_router_check_interval = 30; -} - -void -lnet_rtrpools_free(void) -{ -} - -int -lnet_rtrpools_alloc(int im_a_arouter) -{ - return 0; -} - -#endif From 134a7a7a10b70dced17e39136f65c4df81ebfb3a Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Thu, 11 Jun 2015 15:18:09 -0400 Subject: [PATCH 0933/1163] staging:lustre: rename socklnd_lib-linux.c With the move to support only the linux kernel their is no need to keep "linux" in the socklnd source file names. This is broken out of the original patch 12932 that was merged to the Intel/OpenSFS branch. Signed-off-by: John L. Hammond Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2675 Reviewed-on: http://review.whamcloud.com/12932 Reviewed-by: Isaac Huang Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/klnds/socklnd/Makefile | 2 +- .../lnet/klnds/socklnd/{socklnd_lib-linux.c => socklnd_lib.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename drivers/staging/lustre/lnet/klnds/socklnd/{socklnd_lib-linux.c => socklnd_lib.c} (100%) diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/Makefile b/drivers/staging/lustre/lnet/klnds/socklnd/Makefile index f3fb8778c3ad..c011581d3453 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/Makefile +++ b/drivers/staging/lustre/lnet/klnds/socklnd/Makefile @@ -1,3 +1,3 @@ obj-$(CONFIG_LNET) += ksocklnd.o -ksocklnd-y := socklnd.o socklnd_cb.o socklnd_proto.o socklnd_modparams.o socklnd_lib-linux.o +ksocklnd-y := socklnd.o socklnd_cb.o socklnd_proto.o socklnd_modparams.o socklnd_lib.o diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c similarity index 100% rename from drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c rename to drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c From 12c41f001015eb00fff6c677a2d83332cfd2c8b9 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Thu, 11 Jun 2015 15:18:10 -0400 Subject: [PATCH 0934/1163] staging:lustre: merge socklnd_lib-linux.h into socklnd.h Originally socklnd_lib-linux.h contained linux specific wrappers and defines but since the linux kernel is the only supported platform now we can merge what little remains in the header into socklnd.h. This is broken out of the original patch 12932 that was merged to the Intel/OpenSFS branch. Signed-off-by: John L. Hammond Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2675 Reviewed-on: http://review.whamcloud.com/12932 Reviewed-by: Isaac Huang Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- .../lustre/lnet/klnds/socklnd/socklnd.h | 39 ++++++++- .../lnet/klnds/socklnd/socklnd_lib-linux.h | 86 ------------------- .../lustre/lnet/klnds/socklnd/socklnd_lib.c | 4 +- 3 files changed, 40 insertions(+), 89 deletions(-) delete mode 100644 drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h index 53275f9450ba..7125eb955ae5 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h @@ -25,16 +25,40 @@ * */ +#ifndef _SOCKLND_SOCKLND_H_ +#define _SOCKLND_SOCKLND_H_ + #define DEBUG_PORTAL_ALLOC #define DEBUG_SUBSYSTEM S_LND -#include "socklnd_lib-linux.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "../../../include/linux/libcfs/libcfs.h" #include "../../../include/linux/lnet/lnet.h" #include "../../../include/linux/lnet/lib-lnet.h" #include "../../../include/linux/lnet/socklnd.h" +/* assume one thread for each connection type */ +#define SOCKNAL_NSCHEDS 3 +#define SOCKNAL_NSCHEDS_HIGH (SOCKNAL_NSCHEDS << 1) + #define SOCKNAL_PEER_HASH_SIZE 101 /* # peer lists */ #define SOCKNAL_RESCHED 100 /* # scheduler loops before reschedule */ #define SOCKNAL_INSANITY_RECONN 5000 /* connd is trying on reconn infinitely */ @@ -459,6 +483,17 @@ extern ksock_proto_t ksocknal_protocol_v3x; #define CPU_MASK_NONE 0UL #endif +static inline __u32 ksocknal_csum(__u32 crc, unsigned char const *p, size_t len) +{ +#if 1 + return crc32_le(crc, p, len); +#else + while (len-- > 0) + crc = ((crc + 0x100) & ~0xff) | ((crc + *p++) & 0xff) ; + return crc; +#endif +} + static inline int ksocknal_route_mask(void) { @@ -651,3 +686,5 @@ extern void ksocknal_lib_csum_tx(ksock_tx_t *tx); extern int ksocknal_lib_memory_pressure(ksock_conn_t *conn); extern int ksocknal_lib_bind_thread_to_cpu(int id); + +#endif /* _SOCKLND_SOCKLND_H_ */ diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h deleted file mode 100644 index f5563881b25c..000000000000 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h +++ /dev/null @@ -1,86 +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) 2005, 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. - */ - -#define DEBUG_PORTAL_ALLOC - -#ifndef __LINUX_SOCKNAL_LIB_H__ -#define __LINUX_SOCKNAL_LIB_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "../../../include/linux/libcfs/libcfs.h" - -#include -static inline __u32 ksocknal_csum(__u32 crc, unsigned char const *p, size_t len) -{ -#if 1 - return crc32_le(crc, p, len); -#else - while (len-- > 0) - crc = ((crc + 0x100) & ~0xff) | ((crc + *p++) & 0xff) ; - return crc; -#endif -} - -#define SOCKNAL_WSPACE(sk) sk_stream_wspace(sk) -#define SOCKNAL_MIN_WSPACE(sk) sk_stream_min_wspace(sk) - -/* assume one thread for each connection type */ -#define SOCKNAL_NSCHEDS 3 -#define SOCKNAL_NSCHEDS_HIGH (SOCKNAL_NSCHEDS << 1) - -#endif diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c index 2b40a9fe00c9..340706110c21 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c @@ -616,8 +616,8 @@ ksocknal_write_space(struct sock *sk) read_lock(&ksocknal_data.ksnd_global_lock); conn = sk->sk_user_data; - wspace = SOCKNAL_WSPACE(sk); - min_wpace = SOCKNAL_MIN_WSPACE(sk); + wspace = sk_stream_wspace(sk); + min_wpace = sk_stream_min_wspace(sk); CDEBUG(D_NET, "sk %p wspace %d low water %d conn %p%s%s%s\n", sk, wspace, min_wpace, conn, From bbf00c3d91e43372da3b242be3fb3afc92751c79 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Thu, 11 Jun 2015 15:18:11 -0400 Subject: [PATCH 0935/1163] staging:lustre: move LNet NID macros to LNet layer Currently several special macros LNet NID macros exist in libcfs.h and libcfs_private.h. Move those macros out to the lnet header types.h. The new lnet header nidstr.h contains LNet NID string data that can be used by user land LNet utilities and the LNet kernel drivers. Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- .../include/linux/libcfs/libcfs_private.h | 55 -------------- .../lustre/include/linux/lnet/lib-lnet.h | 1 + .../staging/lustre/include/linux/lnet/lnet.h | 5 +- .../lustre/include/linux/lnet/nidstr.h | 76 +++++++++++++++++++ .../staging/lustre/include/linux/lnet/types.h | 33 ++++++++ .../lustre/lustre/include/lustre/lustre_idl.h | 1 + .../lustre/lustre/include/lustre_net.h | 4 +- 7 files changed, 114 insertions(+), 61 deletions(-) create mode 100644 drivers/staging/lustre/include/linux/lnet/nidstr.h diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h index d8f8543de573..ed37d26eb20d 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h @@ -42,14 +42,10 @@ #ifndef __LIBCFS_PRIVATE_H__ #define __LIBCFS_PRIVATE_H__ -/* XXX this layering violation is for nidstrings */ -#include "../lnet/types.h" - #ifndef DEBUG_SUBSYSTEM # define DEBUG_SUBSYSTEM S_UNDEFINED #endif - /* * When this is on, LASSERT macro includes check for assignment used instead * of equality check, but doesn't have unlikely(). Turn this on from time to @@ -410,36 +406,6 @@ int cfs_percpt_atomic_summary(atomic_t **refs); */ #define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0) -/* support decl needed both by kernel and liblustre */ -int libcfs_isknown_lnd(int type); -char *libcfs_lnd2modname(int type); -char *libcfs_lnd2str(int type); -int libcfs_str2lnd(const char *str); -char *libcfs_net2str(__u32 net); -char *libcfs_nid2str(lnet_nid_t nid); -__u32 libcfs_str2net(const char *str); -lnet_nid_t libcfs_str2nid(const char *str); -int libcfs_str2anynid(lnet_nid_t *nid, const char *str); -char *libcfs_id2str(lnet_process_id_t id); -void cfs_free_nidlist(struct list_head *list); -int cfs_parse_nidlist(char *str, int len, struct list_head *list); -int cfs_match_nid(lnet_nid_t nid, struct list_head *list); - -/** \addtogroup lnet_addr - * @{ */ -/* how an LNET NID encodes net:address */ -/** extract the address part of an lnet_nid_t */ -#define LNET_NIDADDR(nid) ((__u32)((nid) & 0xffffffff)) -/** extract the network part of an lnet_nid_t */ -#define LNET_NIDNET(nid) ((__u32)(((nid) >> 32)) & 0xffffffff) -/** make an lnet_nid_t from a network part and an address part */ -#define LNET_MKNID(net, addr) ((((__u64)(net))<<32)|((__u64)(addr))) -/* how net encodes type:number */ -#define LNET_NETNUM(net) ((net) & 0xffff) -#define LNET_NETTYP(net) (((net) >> 16) & 0xffff) -#define LNET_MKNET(typ, num) ((((__u32)(typ))<<16)|((__u32)(num))) -/** @} lnet_addr */ - /* max value for numeric network address */ #define MAX_NUMERIC_VALUE 0xffffffff @@ -519,25 +485,4 @@ do { \ ptr += cfs_size_round(len + 1); \ } while (0) -/** - * Lustre Network Driver types. - */ -enum { - /* Only add to these values (i.e. don't ever change or redefine them): - * network addresses depend on them... */ - QSWLND = 1, - SOCKLND = 2, - GMLND = 3, /* obsolete, keep it so that libcfs_nid2str works */ - PTLLND = 4, - O2IBLND = 5, - CIBLND = 6, - OPENIBLND = 7, - IIBLND = 8, - LOLND = 9, - RALND = 10, - VIBLND = 11, - MXLND = 12, - GNILND = 13, -}; - #endif diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index c46e0e6bbefa..5b3b10318021 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -42,6 +42,7 @@ #define __LNET_LIB_LNET_H__ #include "../libcfs/libcfs.h" +#include "api.h" #include "types.h" #include "lnet.h" #include "lib-types.h" diff --git a/drivers/staging/lustre/include/linux/lnet/lnet.h b/drivers/staging/lustre/include/linux/lnet/lnet.h index 8d054a1712c7..8124d8f64dce 100644 --- a/drivers/staging/lustre/include/linux/lnet/lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lnet.h @@ -41,9 +41,6 @@ * User application interface file */ #include "types.h" -#include "api.h" - -#define LNET_NIDSTR_COUNT 1024 /* # of nidstrings */ -#define LNET_NIDSTR_SIZE 32 /* size of each one (see below for usage) */ +#include "nidstr.h" #endif diff --git a/drivers/staging/lustre/include/linux/lnet/nidstr.h b/drivers/staging/lustre/include/linux/lnet/nidstr.h new file mode 100644 index 000000000000..8eaed1aa11f1 --- /dev/null +++ b/drivers/staging/lustre/include/linux/lnet/nidstr.h @@ -0,0 +1,76 @@ +/* + * 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.gnu.org/licenses/gpl-2.0.html + * + * GPL HEADER END + */ +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 2011, 2014, Intel Corporation. + */ +#ifndef _LNET_NIDSTRINGS_H +#define _LNET_NIDSTRINGS_H +#include "types.h" + +/** + * Lustre Network Driver types. + */ +enum { + /* Only add to these values (i.e. don't ever change or redefine them): + * network addresses depend on them... */ + QSWLND = 1, + SOCKLND = 2, + GMLND = 3, + PTLLND = 4, + O2IBLND = 5, + CIBLND = 6, + OPENIBLND = 7, + IIBLND = 8, + LOLND = 9, + RALND = 10, + VIBLND = 11, + MXLND = 12, + GNILND = 13, + GNIIPLND = 14, +}; + +struct list_head; + +#define LNET_NIDSTR_COUNT 1024 /* # of nidstrings */ +#define LNET_NIDSTR_SIZE 32 /* size of each one (see below for usage) */ + +int libcfs_isknown_lnd(int type); +char *libcfs_lnd2modname(int type); +char *libcfs_lnd2str(int type); +int libcfs_str2lnd(const char *str); +char *libcfs_net2str(__u32 net); +char *libcfs_nid2str(lnet_nid_t nid); +__u32 libcfs_str2net(const char *str); +lnet_nid_t libcfs_str2nid(const char *str); +int libcfs_str2anynid(lnet_nid_t *nid, const char *str); +char *libcfs_id2str(lnet_process_id_t id); +void cfs_free_nidlist(struct list_head *list); +int cfs_parse_nidlist(char *str, int len, struct list_head *list); +int cfs_match_nid(lnet_nid_t nid, struct list_head *list); +bool cfs_nidrange_is_contiguous(struct list_head *nidlist); +void cfs_nidrange_find_min_max(struct list_head *nidlist, char *min_nid, + char *max_nid, size_t nidstr_length); + +#endif /* _LNET_NIDSTRINGS_H */ diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index 68d8139a2b11..15528a18d49b 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -77,6 +77,39 @@ typedef __u32 lnet_pid_t; #define LNET_TIME_FOREVER (-1) +/* how an LNET NID encodes net:address */ +/** extract the address part of an lnet_nid_t */ + +static inline __u32 LNET_NIDADDR(lnet_nid_t nid) +{ + return nid & 0xffffffff; +} + +static inline __u32 LNET_NIDNET(lnet_nid_t nid) +{ + return (nid >> 32) & 0xffffffff; +} + +static inline lnet_nid_t LNET_MKNID(__u32 net, __u32 addr) +{ + return (((__u64)net) << 32) | addr; +} + +static inline __u32 LNET_NETNUM(__u32 net) +{ + return net & 0xffff; +} + +static inline __u32 LNET_NETTYP(__u32 net) +{ + return (net >> 16) & 0xffff; +} + +static inline __u32 LNET_MKNET(__u32 type, __u32 num) +{ + return (type << 16) | num; +} + /** * Objects maintained by the LNet are accessed through handles. Handle types * have names of the form lnet_handle_xx_t, where xx is one of the two letter diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index 305ecbee9b78..4d72d6ed26b0 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -92,6 +92,7 @@ #define _LUSTRE_IDL_H_ #include "../../../include/linux/libcfs/libcfs.h" +#include "../../../include/linux/lnet/types.h" /* Defn's shared with user-space. */ #include "lustre_user.h" diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index 998dcd94c1b2..77a7de98fc8e 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -56,8 +56,8 @@ */ #include "../../include/linux/libcfs/libcfs.h" -// #include -#include "../../include/linux/lnet/lnet.h" +#include "../../include/linux/lnet/nidstr.h" +#include "../../include/linux/lnet/api.h" #include "lustre/lustre_idl.h" #include "lustre_ha.h" #include "lustre_sec.h" From db18b8e98df2b946a0685ac501961d7110a61e26 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Thu, 11 Jun 2015 15:18:12 -0400 Subject: [PATCH 0936/1163] staging:lustre: separate kernel and user land defines in the LNet headers Currently the lnet headers used by user land contain various internal LNet structures that are only used by kernel space. Move the user land structures to headers used by user land. The kernel structures are relocated to headers that are never exposed to user land. Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/lnet/lib-lnet.h | 3 - .../lustre/include/linux/lnet/lib-types.h | 171 ++---------------- .../lustre/include/linux/lnet/lnetctl.h | 7 +- .../lustre/include/linux/lnet/lnetst.h | 5 +- .../lustre/include/linux/lnet/socklnd.h | 1 - .../staging/lustre/include/linux/lnet/types.h | 169 +++++++++++++++-- drivers/staging/lustre/lnet/lnet/api-ni.c | 3 +- 7 files changed, 180 insertions(+), 179 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 5b3b10318021..061e171d24c3 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -34,8 +34,6 @@ * Lustre is a trademark of Sun Microsystems, Inc. * * lnet/include/lnet/lib-lnet.h - * - * Top level include for library side routines */ #ifndef __LNET_LIB_LNET_H__ @@ -43,7 +41,6 @@ #include "../libcfs/libcfs.h" #include "api.h" -#include "types.h" #include "lnet.h" #include "lib-types.h" diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 4b862d3ea2ec..fdf94dd7d07b 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -42,125 +42,20 @@ #ifndef __LNET_LIB_TYPES_H__ #define __LNET_LIB_TYPES_H__ -#include "../libcfs/libcfs.h" -#include +#include +#include +#include +#include + #include "types.h" -#define WIRE_ATTR __attribute__((packed)) - -/* Packed version of lnet_process_id_t to transfer via network */ -typedef struct { - lnet_nid_t nid; - lnet_pid_t pid; /* node id / process id */ -} WIRE_ATTR lnet_process_id_packed_t; - -/* The wire handle's interface cookie only matches one network interface in - * one epoch (i.e. new cookie when the interface restarts or the node - * reboots). The object cookie only matches one object on that interface - * during that object's lifetime (i.e. no cookie re-use). */ -typedef struct { - __u64 wh_interface_cookie; - __u64 wh_object_cookie; -} WIRE_ATTR lnet_handle_wire_t; - -typedef enum { - LNET_MSG_ACK = 0, - LNET_MSG_PUT, - LNET_MSG_GET, - LNET_MSG_REPLY, - LNET_MSG_HELLO, -} lnet_msg_type_t; - -/* The variant fields of the portals message header are aligned on an 8 - * byte boundary in the message header. Note that all types used in these - * wire structs MUST be fixed size and the smaller types are placed at the - * end. */ -typedef struct lnet_ack { - lnet_handle_wire_t dst_wmd; - __u64 match_bits; - __u32 mlength; -} WIRE_ATTR lnet_ack_t; - -typedef struct lnet_put { - lnet_handle_wire_t ack_wmd; - __u64 match_bits; - __u64 hdr_data; - __u32 ptl_index; - __u32 offset; -} WIRE_ATTR lnet_put_t; - -typedef struct lnet_get { - lnet_handle_wire_t return_wmd; - __u64 match_bits; - __u32 ptl_index; - __u32 src_offset; - __u32 sink_length; -} WIRE_ATTR lnet_get_t; - -typedef struct lnet_reply { - lnet_handle_wire_t dst_wmd; -} WIRE_ATTR lnet_reply_t; - -typedef struct lnet_hello { - __u64 incarnation; - __u32 type; -} WIRE_ATTR lnet_hello_t; - -typedef struct { - lnet_nid_t dest_nid; - lnet_nid_t src_nid; - lnet_pid_t dest_pid; - lnet_pid_t src_pid; - __u32 type; /* lnet_msg_type_t */ - __u32 payload_length; /* payload data to follow */ - /*<------__u64 aligned------->*/ - union { - lnet_ack_t ack; - lnet_put_t put; - lnet_get_t get; - lnet_reply_t reply; - lnet_hello_t hello; - } msg; -} WIRE_ATTR lnet_hdr_t; - -/* A HELLO message contains a magic number and protocol version - * code in the header's dest_nid, the peer's NID in the src_nid, and - * LNET_MSG_HELLO in the type field. All other common fields are zero - * (including payload_size; i.e. no payload). - * This is for use by byte-stream LNDs (e.g. TCP/IP) to check the peer is - * running the same protocol and to find out its NID. These LNDs should - * exchange HELLO messages when a connection is first established. Individual - * LNDs can put whatever else they fancy in lnet_hdr_t::msg. - */ -typedef struct { - __u32 magic; /* LNET_PROTO_TCP_MAGIC */ - __u16 version_major; /* increment on incompatible change */ - __u16 version_minor; /* increment on compatible change */ -} WIRE_ATTR lnet_magicversion_t; - -/* PROTO MAGIC for LNDs */ -#define LNET_PROTO_IB_MAGIC 0x0be91b91 -#define LNET_PROTO_GNI_MAGIC 0xb00fbabe /* ask Kim */ -#define LNET_PROTO_TCP_MAGIC 0xeebc0ded -#define LNET_PROTO_ACCEPTOR_MAGIC 0xacce7100 -#define LNET_PROTO_PING_MAGIC 0x70696E67 /* 'ping' */ - -/* Placeholder for a future "unified" protocol across all LNDs */ -/* Current LNDs that receive a request with this magic will respond with a - * "stub" reply using their current protocol */ -#define LNET_PROTO_MAGIC 0x45726963 /* ! */ - -#define LNET_PROTO_TCP_VERSION_MAJOR 1 -#define LNET_PROTO_TCP_VERSION_MINOR 0 - -/* Acceptor connection request */ -typedef struct { - __u32 acr_magic; /* PTL_ACCEPTOR_PROTO_MAGIC */ - __u32 acr_version; /* protocol version */ - __u64 acr_nid; /* target NID */ -} WIRE_ATTR lnet_acceptor_connreq_t; - -#define LNET_PROTO_ACCEPTOR_VERSION 1 +/* Max payload size */ +#define LNET_MAX_PAYLOAD CONFIG_LNET_MAX_PAYLOAD +#if (LNET_MAX_PAYLOAD < LNET_MTU) +# error "LNET_MAX_PAYLOAD too small - error in configure --with-max-payload-mb" +#elif (LNET_MAX_PAYLOAD > (PAGE_SIZE * LNET_MAX_IOV)) +# error "LNET_MAX_PAYLOAD too large - error in configure --with-max-payload-mb" +#endif /* forward refs */ struct lnet_libmd; @@ -295,7 +190,7 @@ typedef struct lnet_lnd { int lnd_refcount; /* # active instances */ /* fields initialised by the LND */ - unsigned int lnd_type; + __u32 lnd_type; int (*lnd_startup)(struct lnet_ni *ni); void (*lnd_shutdown)(struct lnet_ni *ni); @@ -349,15 +244,6 @@ typedef struct lnet_lnd { } lnd_t; -#define LNET_NI_STATUS_UP 0x15aac0de -#define LNET_NI_STATUS_DOWN 0xdeadface -#define LNET_NI_STATUS_INVALID 0x00000000 -typedef struct { - lnet_nid_t ns_nid; - __u32 ns_status; - __u32 ns_unused; -} WIRE_ATTR lnet_ni_status_t; - struct lnet_tx_queue { int tq_credits; /* # tx credits free */ int tq_credits_min; /* lowest it's been */ @@ -365,8 +251,6 @@ struct lnet_tx_queue { struct list_head tq_delayed; /* delayed TXs */ }; -#define LNET_MAX_INTERFACES 16 - typedef struct lnet_ni { spinlock_t ni_lock; struct list_head ni_list; /* chain on ln_nis */ @@ -402,14 +286,6 @@ typedef struct lnet_ni { #define LNET_PING_FEAT_MASK (LNET_PING_FEAT_BASE | \ LNET_PING_FEAT_NI_STATUS) -typedef struct { - __u32 pi_magic; - __u32 pi_features; - lnet_pid_t pi_pid; - __u32 pi_nnis; - lnet_ni_status_t pi_ni[0]; -} WIRE_ATTR lnet_ping_info_t; - /* router checker data, per router */ #define LNET_MAX_RTR_NIS 16 #define LNET_PINGINFO_SIZE offsetof(lnet_ping_info_t, pi_ni[LNET_MAX_RTR_NIS]) @@ -492,6 +368,11 @@ typedef struct { __u32 lrn_net; /* my net number */ } lnet_remotenet_t; +/** lnet message has credit and can be submitted to lnd for send/receive */ +#define LNET_CREDIT_OK 0 +/** lnet message is waiting for credit */ +#define LNET_CREDIT_WAIT 1 + typedef struct { struct list_head rbp_bufs; /* my free buffer pool */ struct list_head rbp_msgs; /* messages blocking for a buffer */ @@ -507,23 +388,9 @@ typedef struct { lnet_kiov_t rb_kiov[0]; /* the buffer space */ } lnet_rtrbuf_t; -typedef struct { - __u32 msgs_alloc; - __u32 msgs_max; - __u32 errors; - __u32 send_count; - __u32 recv_count; - __u32 route_count; - __u32 drop_count; - __u64 send_length; - __u64 recv_length; - __u64 route_length; - __u64 drop_length; -} WIRE_ATTR lnet_counters_t; - #define LNET_PEER_HASHSIZE 503 /* prime! */ -#define LNET_NRBPOOLS 3 /* # different router buffer pools */ +#define LNET_NRBPOOLS 3 /* # different router buffer pools */ enum { /* Didn't match anything */ diff --git a/drivers/staging/lustre/include/linux/lnet/lnetctl.h b/drivers/staging/lustre/include/linux/lnet/lnetctl.h index 98181d389396..bdd69b2af909 100644 --- a/drivers/staging/lustre/include/linux/lnet/lnetctl.h +++ b/drivers/staging/lustre/include/linux/lnet/lnetctl.h @@ -14,12 +14,11 @@ * along with Portals; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * header for libptlctl.a + * header for lnet ioctl */ -#ifndef _PTLCTL_H_ -#define _PTLCTL_H_ +#ifndef _LNETCTL_H_ +#define _LNETCTL_H_ -#include "../libcfs/libcfs.h" #include "types.h" #define LNET_DEV_ID 0 diff --git a/drivers/staging/lustre/include/linux/lnet/lnetst.h b/drivers/staging/lustre/include/linux/lnet/lnetst.h index 885f708d4031..57432fdb927c 100644 --- a/drivers/staging/lustre/include/linux/lnet/lnetst.h +++ b/drivers/staging/lustre/include/linux/lnet/lnetst.h @@ -41,9 +41,7 @@ #ifndef __LNET_ST_H__ #define __LNET_ST_H__ -#include "../libcfs/libcfs.h" -#include "lnet.h" -#include "lib-types.h" +#include #define LST_FEAT_NONE (0) #define LST_FEAT_BULK_LEN (1 << 0) /* enable variable page size */ @@ -468,7 +466,6 @@ typedef struct { int png_flags; /* reserved flags */ } lst_test_ping_param_t; -/* more tests */ typedef struct { __u32 errors; __u32 rpcs_sent; diff --git a/drivers/staging/lustre/include/linux/lnet/socklnd.h b/drivers/staging/lustre/include/linux/lnet/socklnd.h index 389038b122c5..f7c7b08c2d6b 100644 --- a/drivers/staging/lustre/include/linux/lnet/socklnd.h +++ b/drivers/staging/lustre/include/linux/lnet/socklnd.h @@ -39,7 +39,6 @@ #define __LNET_LNET_SOCKLND_H__ #include "types.h" -#include "lib-types.h" #define SOCKLND_CONN_NONE (-1) #define SOCKLND_CONN_ANY 0 diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index 15528a18d49b..32b9431b49d9 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -37,11 +37,11 @@ #ifndef __LNET_TYPES_H__ #define __LNET_TYPES_H__ +#include + /** \addtogroup lnet * @{ */ -#include "../libcfs/libcfs.h" - /** \addtogroup lnet_addr * @{ */ @@ -74,6 +74,7 @@ typedef __u32 lnet_pid_t; #define LNET_PID_RESERVED 0xf0000000 /* reserved bits in PID */ #define LNET_PID_USERFLAG 0x80000000 /* set in userspace peers */ +#define LNET_PID_LUSTRE 12345 #define LNET_TIME_FOREVER (-1) @@ -110,7 +111,158 @@ static inline __u32 LNET_MKNET(__u32 type, __u32 num) return (type << 16) | num; } -/** +#define WIRE_ATTR __packed + +/* Packed version of lnet_process_id_t to transfer via network */ +typedef struct { + /* node id / process id */ + lnet_nid_t nid; + lnet_pid_t pid; +} WIRE_ATTR lnet_process_id_packed_t; + +/* The wire handle's interface cookie only matches one network interface in + * one epoch (i.e. new cookie when the interface restarts or the node + * reboots). The object cookie only matches one object on that interface + * during that object's lifetime (i.e. no cookie re-use). */ +typedef struct { + __u64 wh_interface_cookie; + __u64 wh_object_cookie; +} WIRE_ATTR lnet_handle_wire_t; + +typedef enum { + LNET_MSG_ACK = 0, + LNET_MSG_PUT, + LNET_MSG_GET, + LNET_MSG_REPLY, + LNET_MSG_HELLO, +} lnet_msg_type_t; + +/* The variant fields of the portals message header are aligned on an 8 + * byte boundary in the message header. Note that all types used in these + * wire structs MUST be fixed size and the smaller types are placed at the + * end. */ +typedef struct lnet_ack { + lnet_handle_wire_t dst_wmd; + __u64 match_bits; + __u32 mlength; +} WIRE_ATTR lnet_ack_t; + +typedef struct lnet_put { + lnet_handle_wire_t ack_wmd; + __u64 match_bits; + __u64 hdr_data; + __u32 ptl_index; + __u32 offset; +} WIRE_ATTR lnet_put_t; + +typedef struct lnet_get { + lnet_handle_wire_t return_wmd; + __u64 match_bits; + __u32 ptl_index; + __u32 src_offset; + __u32 sink_length; +} WIRE_ATTR lnet_get_t; + +typedef struct lnet_reply { + lnet_handle_wire_t dst_wmd; +} WIRE_ATTR lnet_reply_t; + +typedef struct lnet_hello { + __u64 incarnation; + __u32 type; +} WIRE_ATTR lnet_hello_t; + +typedef struct { + lnet_nid_t dest_nid; + lnet_nid_t src_nid; + lnet_pid_t dest_pid; + lnet_pid_t src_pid; + __u32 type; /* lnet_msg_type_t */ + __u32 payload_length; /* payload data to follow */ + /*<------__u64 aligned------->*/ + union { + lnet_ack_t ack; + lnet_put_t put; + lnet_get_t get; + lnet_reply_t reply; + lnet_hello_t hello; + } msg; +} WIRE_ATTR lnet_hdr_t; + +/* A HELLO message contains a magic number and protocol version + * code in the header's dest_nid, the peer's NID in the src_nid, and + * LNET_MSG_HELLO in the type field. All other common fields are zero + * (including payload_size; i.e. no payload). + * This is for use by byte-stream LNDs (e.g. TCP/IP) to check the peer is + * running the same protocol and to find out its NID. These LNDs should + * exchange HELLO messages when a connection is first established. Individual + * LNDs can put whatever else they fancy in lnet_hdr_t::msg. + */ +typedef struct { + __u32 magic; /* LNET_PROTO_TCP_MAGIC */ + __u16 version_major; /* increment on incompatible change */ + __u16 version_minor; /* increment on compatible change */ +} WIRE_ATTR lnet_magicversion_t; + +/* PROTO MAGIC for LNDs */ +#define LNET_PROTO_IB_MAGIC 0x0be91b91 +#define LNET_PROTO_GNI_MAGIC 0xb00fbabe /* ask Kim */ +#define LNET_PROTO_TCP_MAGIC 0xeebc0ded +#define LNET_PROTO_ACCEPTOR_MAGIC 0xacce7100 +#define LNET_PROTO_PING_MAGIC 0x70696E67 /* 'ping' */ + +/* Placeholder for a future "unified" protocol across all LNDs */ +/* Current LNDs that receive a request with this magic will respond with a + * "stub" reply using their current protocol */ +#define LNET_PROTO_MAGIC 0x45726963 /* ! */ + +#define LNET_PROTO_TCP_VERSION_MAJOR 1 +#define LNET_PROTO_TCP_VERSION_MINOR 0 + +/* Acceptor connection request */ +typedef struct { + __u32 acr_magic; /* PTL_ACCEPTOR_PROTO_MAGIC */ + __u32 acr_version; /* protocol version */ + __u64 acr_nid; /* target NID */ +} WIRE_ATTR lnet_acceptor_connreq_t; + +#define LNET_PROTO_ACCEPTOR_VERSION 1 + +typedef struct { + lnet_nid_t ns_nid; + __u32 ns_status; + __u32 ns_unused; +} WIRE_ATTR lnet_ni_status_t; + +typedef struct { + __u32 pi_magic; + __u32 pi_features; + lnet_pid_t pi_pid; + __u32 pi_nnis; + lnet_ni_status_t pi_ni[0]; +} WIRE_ATTR lnet_ping_info_t; + +typedef struct lnet_counters { + __u32 msgs_alloc; + __u32 msgs_max; + __u32 errors; + __u32 send_count; + __u32 recv_count; + __u32 route_count; + __u32 drop_count; + __u64 send_length; + __u64 recv_length; + __u64 route_length; + __u64 drop_length; +} WIRE_ATTR lnet_counters_t; + +#define LNET_NI_STATUS_UP 0x15aac0de +#define LNET_NI_STATUS_DOWN 0xdeadface +#define LNET_NI_STATUS_INVALID 0x00000000 + +#define LNET_MAX_INTERFACES 16 + +/* * Objects maintained by the LNet are accessed through handles. Handle types * have names of the form lnet_handle_xx_t, where xx is one of the two letter * object type codes ('eq' for event queue, 'md' for memory descriptor, and @@ -311,17 +463,6 @@ typedef struct { /** limit on the number of fragments in discontiguous MDs */ #define LNET_MAX_IOV 256 -/* Max payload size */ -# define LNET_MAX_PAYLOAD CONFIG_LNET_MAX_PAYLOAD -# if (LNET_MAX_PAYLOAD < LNET_MTU) -# error "LNET_MAX_PAYLOAD too small - error in configure --with-max-payload-mb" -# else -# if (LNET_MAX_PAYLOAD > (PAGE_SIZE * LNET_MAX_IOV)) -/* PAGE_SIZE is a constant: check with cpp! */ -# error "LNET_MAX_PAYLOAD too large - error in configure --with-max-payload-mb" -# endif -# endif - /** * Options for the MD structure. See lnet_md_t::options. */ diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index a2d0d10772d4..57e97520cb1b 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -35,10 +35,11 @@ */ #define DEBUG_SUBSYSTEM S_LNET -#include "../../include/linux/lnet/lib-lnet.h" #include #include +#include "../../include/linux/lnet/lib-lnet.h" + #define D_LNI D_CONSOLE lnet_t the_lnet; /* THE state of the network */ From a9cf72b64257a53c8c0bf2ed8096b59ae16f8686 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Thu, 11 Jun 2015 15:18:13 -0400 Subject: [PATCH 0937/1163] staging:lustre: fix camel case for LNetInit and LNetFini For the functions LNetInit and LNetFini move away from camel case to lnet_init and lnet_fini. Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/lnet/api.h | 3 --- .../staging/lustre/include/linux/lnet/lib-lnet.h | 3 +++ .../lustre/include/linux/lnet/lib-types.h | 2 +- drivers/staging/lustre/lnet/lnet/api-ni.c | 16 ++++++++-------- drivers/staging/lustre/lnet/lnet/module.c | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/api.h b/drivers/staging/lustre/include/linux/lnet/api.h index c4dc1b2f605d..dee7f27a3940 100644 --- a/drivers/staging/lustre/include/linux/lnet/api.h +++ b/drivers/staging/lustre/include/linux/lnet/api.h @@ -52,9 +52,6 @@ /** \defgroup lnet_init_fini Initialization and cleanup * The LNet must be properly initialized before any LNet calls can be made. * @{ */ -int LNetInit(void); -void LNetFini(void); - int LNetNIInit(lnet_pid_t requested_pid); int LNetNIFini(void); /** @} lnet_init_fini */ diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 061e171d24c3..6246e2e0f4c0 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -434,6 +434,9 @@ lnet_ni_t *lnet_nid2ni_locked(lnet_nid_t nid, int cpt); lnet_ni_t *lnet_net2ni_locked(__u32 net, int cpt); lnet_ni_t *lnet_net2ni(__u32 net); +int lnet_init(void); +void lnet_fini(void); + int lnet_notify(lnet_ni_t *ni, lnet_nid_t peer, int alive, unsigned long when); void lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive, unsigned long when); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index fdf94dd7d07b..8e8e72547267 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -575,7 +575,7 @@ typedef struct { struct mutex ln_api_mutex; struct mutex ln_lnd_mutex; - int ln_init; /* LNetInit() called? */ + int ln_init; /* lnet_init() called? */ /* Have I called LNetNIInit myself? */ int ln_niinit_self; /* LNetNIInit/LNetNIFini counter */ diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 57e97520cb1b..d14fe70a56df 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -1101,14 +1101,14 @@ lnet_startup_lndnis(void) * Initialize LNet library. * * Only userspace program needs to call this function - it's automatically - * called in the kernel at module loading time. Caller has to call LNetFini() - * after a call to LNetInit(), if and only if the latter returned 0. It must + * called in the kernel at module loading time. Caller has to call lnet_fini() + * after a call to lnet_init(), if and only if the latter returned 0. It must * be called exactly once. * * \return 0 on success, and -ve on failures. */ int -LNetInit(void) +lnet_init(void) { int rc; @@ -1161,7 +1161,7 @@ LNetInit(void) lnet_register_lnd(&the_lolnd); return 0; } -EXPORT_SYMBOL(LNetInit); +EXPORT_SYMBOL(lnet_init); /** * Finalize LNet library. @@ -1169,11 +1169,11 @@ EXPORT_SYMBOL(LNetInit); * Only userspace program needs to call this function. It can be called * at most once. * - * \pre LNetInit() called with success. + * \pre lnet_init() called with success. * \pre All LNet users called LNetNIFini() for matching LNetNIInit() calls. */ void -LNetFini(void) +lnet_fini(void) { LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount == 0); @@ -1185,12 +1185,12 @@ LNetFini(void) the_lnet.ln_init = 0; } -EXPORT_SYMBOL(LNetFini); +EXPORT_SYMBOL(lnet_fini); /** * Set LNet PID and start LNet interfaces, routing, and forwarding. * - * Userspace program should call this after a successful call to LNetInit(). + * Userspace program should call this after a successful call to lnet_init(). * Users must call this function at least once before any other functions. * For each successful call there must be a corresponding call to * LNetNIFini(). For subsequent calls to LNetNIInit(), \a requested_pid is diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c index 6881b9cf32ce..576201a8390c 100644 --- a/drivers/staging/lustre/lnet/lnet/module.c +++ b/drivers/staging/lustre/lnet/lnet/module.c @@ -117,9 +117,9 @@ init_lnet(void) mutex_init(&lnet_config_mutex); - rc = LNetInit(); + rc = lnet_init(); if (rc != 0) { - CERROR("LNetInit: error %d\n", rc); + CERROR("lnet_init: error %d\n", rc); return rc; } @@ -143,7 +143,7 @@ fini_lnet(void) rc = libcfs_deregister_ioctl(&lnet_ioctl_handler); LASSERT(rc == 0); - LNetFini(); + lnet_fini(); } MODULE_AUTHOR("Peter J. Braam "); From 188acc61fb484e21836b791eea24eb4e001c0ed8 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Thu, 11 Jun 2015 15:18:14 -0400 Subject: [PATCH 0938/1163] staging:lustre: LNet header code cleanup - indentation etc Handle all the style issues reported by checkpatch.pl. Remove general white spaces, spaces in function calls, alignments etc. Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/include/linux/lnet/api.h | 32 +- .../lustre/include/linux/lnet/lib-lnet.h | 36 +- .../lustre/include/linux/lnet/lib-types.h | 451 ++++++++--------- .../lustre/include/linux/lnet/lnetst.h | 455 ++++++++++-------- .../lustre/include/linux/lnet/socklnd.h | 55 +-- .../staging/lustre/include/linux/lnet/types.h | 78 +-- 6 files changed, 582 insertions(+), 525 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/api.h b/drivers/staging/lustre/include/linux/lnet/api.h index dee7f27a3940..2eb0a055784e 100644 --- a/drivers/staging/lustre/include/linux/lnet/api.h +++ b/drivers/staging/lustre/include/linux/lnet/api.h @@ -95,16 +95,16 @@ void LNetSnprintHandle(char *str, int str_len, lnet_handle_any_t handle); * @{ */ int LNetMEAttach(unsigned int portal, lnet_process_id_t match_id_in, - __u64 match_bits_in, - __u64 ignore_bits_in, + __u64 match_bits_in, + __u64 ignore_bits_in, lnet_unlink_t unlink_in, lnet_ins_pos_t pos_in, lnet_handle_me_t *handle_out); int LNetMEInsert(lnet_handle_me_t current_in, lnet_process_id_t match_id_in, - __u64 match_bits_in, - __u64 ignore_bits_in, + __u64 match_bits_in, + __u64 ignore_bits_in, lnet_unlink_t unlink_in, lnet_ins_pos_t position_in, lnet_handle_me_t *handle_out); @@ -125,13 +125,13 @@ int LNetMEUnlink(lnet_handle_me_t current_in); * associated with a MD: LNetMDUnlink(). * @{ */ int LNetMDAttach(lnet_handle_me_t current_in, - lnet_md_t md_in, + lnet_md_t md_in, lnet_unlink_t unlink_in, lnet_handle_md_t *handle_out); -int LNetMDBind(lnet_md_t md_in, - lnet_unlink_t unlink_in, - lnet_handle_md_t *handle_out); +int LNetMDBind(lnet_md_t md_in, + lnet_unlink_t unlink_in, + lnet_handle_md_t *handle_out); int LNetMDUnlink(lnet_handle_md_t md_in); /** @} lnet_md */ @@ -171,10 +171,10 @@ int LNetEQWait(lnet_handle_eq_t eventq_in, lnet_event_t *event_out); int LNetEQPoll(lnet_handle_eq_t *eventqs_in, - int neq_in, - int timeout_ms, + int neq_in, + int timeout_ms, lnet_event_t *event_out, - int *which_eq_out); + int *which_eq_out); /** @} lnet_eq */ /** \defgroup lnet_data Data movement operations @@ -182,20 +182,20 @@ int LNetEQPoll(lnet_handle_eq_t *eventqs_in, * The LNet API provides two data movement operations: LNetPut() * and LNetGet(). * @{ */ -int LNetPut(lnet_nid_t self, +int LNetPut(lnet_nid_t self, lnet_handle_md_t md_in, lnet_ack_req_t ack_req_in, lnet_process_id_t target_in, unsigned int portal_in, - __u64 match_bits_in, + __u64 match_bits_in, unsigned int offset_in, - __u64 hdr_data_in); + __u64 hdr_data_in); -int LNetGet(lnet_nid_t self, +int LNetGet(lnet_nid_t self, lnet_handle_md_t md_in, lnet_process_id_t target_in, unsigned int portal_in, - __u64 match_bits_in, + __u64 match_bits_in, unsigned int offset_in); /** @} lnet_data */ diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 6246e2e0f4c0..0dbab6fed91d 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -44,29 +44,29 @@ #include "lnet.h" #include "lib-types.h" -extern lnet_t the_lnet; /* THE network */ +extern lnet_t the_lnet; /* THE network */ #if (BITS_PER_LONG == 32) /* 2 CPTs, allowing more CPTs might make us under memory pressure */ -# define LNET_CPT_MAX_BITS 1 +#define LNET_CPT_MAX_BITS 1 #else /* 64-bit system */ /* * 256 CPTs for thousands of CPUs, allowing more CPTs might make us * under risk of consuming all lh_cookie. */ -# define LNET_CPT_MAX_BITS 8 +#define LNET_CPT_MAX_BITS 8 #endif /* BITS_PER_LONG == 32 */ /* max allowed CPT number */ -#define LNET_CPT_MAX (1 << LNET_CPT_MAX_BITS) +#define LNET_CPT_MAX (1 << LNET_CPT_MAX_BITS) -#define LNET_CPT_NUMBER (the_lnet.ln_cpt_number) -#define LNET_CPT_BITS (the_lnet.ln_cpt_bits) -#define LNET_CPT_MASK ((1ULL << LNET_CPT_BITS) - 1) +#define LNET_CPT_NUMBER (the_lnet.ln_cpt_number) +#define LNET_CPT_BITS (the_lnet.ln_cpt_bits) +#define LNET_CPT_MASK ((1ULL << LNET_CPT_BITS) - 1) /** exclusive lock */ -#define LNET_LOCK_EX CFS_PERCPT_LOCK_EX +#define LNET_LOCK_EX CFS_PERCPT_LOCK_EX static inline int lnet_is_wire_handle_none(lnet_handle_wire_t *wh) { @@ -163,7 +163,7 @@ lnet_net_lock_current(void) #define lnet_ni_lock(ni) spin_lock(&(ni)->ni_lock) #define lnet_ni_unlock(ni) spin_unlock(&(ni)->ni_lock) -#define MAX_PORTALS 64 +#define MAX_PORTALS 64 static inline lnet_eq_t * lnet_eq_alloc(void) @@ -184,8 +184,8 @@ static inline lnet_libmd_t * lnet_md_alloc(lnet_md_t *umd) { lnet_libmd_t *md; - unsigned int size; - unsigned int niov; + unsigned int size; + unsigned int niov; if ((umd->options & LNET_MD_KIOV) != 0) { niov = umd->length; @@ -211,7 +211,7 @@ lnet_md_alloc(lnet_md_t *umd) static inline void lnet_md_free(lnet_libmd_t *md) { - unsigned int size; + unsigned int size; if ((md->md_options & LNET_MD_KIOV) != 0) size = offsetof(lnet_libmd_t, md_iov.kiov[md->md_niov]); @@ -299,7 +299,7 @@ lnet_handle2md(lnet_handle_md_t *handle) { /* ALWAYS called with resource lock held */ lnet_libhandle_t *lh; - int cpt; + int cpt; cpt = lnet_cpt_of_cookie(handle->cookie); lh = lnet_res_lh_lookup(the_lnet.ln_md_containers[cpt], @@ -315,7 +315,7 @@ lnet_wire_handle2md(lnet_handle_wire_t *wh) { /* ALWAYS called with resource lock held */ lnet_libhandle_t *lh; - int cpt; + int cpt; if (wh->wh_interface_cookie != the_lnet.ln_interface_cookie) return NULL; @@ -340,7 +340,7 @@ lnet_handle2me(lnet_handle_me_t *handle) { /* ALWAYS called with resource lock held */ lnet_libhandle_t *lh; - int cpt; + int cpt; cpt = lnet_cpt_of_cookie(handle->cookie); lh = lnet_res_lh_lookup(the_lnet.ln_me_containers[cpt], @@ -530,7 +530,9 @@ void lnet_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed, unsigned int offset, unsigned int mlen, unsigned int rlen); lnet_msg_t *lnet_create_reply_msg(lnet_ni_t *ni, lnet_msg_t *get_msg); void lnet_set_reply_msg_len(lnet_ni_t *ni, lnet_msg_t *msg, unsigned int len); + void lnet_finalize(lnet_ni_t *ni, lnet_msg_t *msg, int rc); + void lnet_drop_delayed_msg_list(struct list_head *head, char *reason); void lnet_recv_delayed_msg_list(struct list_head *head); @@ -679,12 +681,12 @@ void lnet_peer_tables_destroy(void); int lnet_peer_tables_create(void); void lnet_debug_peer(lnet_nid_t nid); -static inline void lnet_peer_set_alive(lnet_peer_t *lp) +static inline void +lnet_peer_set_alive(lnet_peer_t *lp) { lp->lp_last_alive = lp->lp_last_query = get_seconds(); if (!lp->lp_alive) lnet_notify_locked(lp, 0, 1, lp->lp_last_alive); } - #endif diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 8e8e72547267..fa949d8b1870 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -54,17 +54,17 @@ #if (LNET_MAX_PAYLOAD < LNET_MTU) # error "LNET_MAX_PAYLOAD too small - error in configure --with-max-payload-mb" #elif (LNET_MAX_PAYLOAD > (PAGE_SIZE * LNET_MAX_IOV)) -# error "LNET_MAX_PAYLOAD too large - error in configure --with-max-payload-mb" +# error "LNET_MAX_PAYLOAD too large - error in configure --with-max-payload-mb" #endif /* forward refs */ struct lnet_libmd; typedef struct lnet_msg { - struct list_head msg_activelist; - struct list_head msg_list; /* Q for credits/MD */ + struct list_head msg_activelist; + struct list_head msg_list; /* Q for credits/MD */ - lnet_process_id_t msg_target; + lnet_process_id_t msg_target; /* where is it from, it's only for building event */ lnet_nid_t msg_from; __u32 msg_type; @@ -84,110 +84,111 @@ typedef struct lnet_msg { /* ready for pending on RX delay list */ unsigned int msg_rx_ready_delay:1; - unsigned int msg_vmflush:1; /* VM trying to free memory */ - unsigned int msg_target_is_router:1; /* sending to a router */ - unsigned int msg_routing:1; /* being forwarded */ - unsigned int msg_ack:1; /* ack on finalize (PUT) */ - unsigned int msg_sending:1; /* outgoing message */ - 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 global router credit */ - unsigned int msg_peerrtrcredit:1; /* taken a peer router credit */ - unsigned int msg_onactivelist:1; /* on the activelist */ + unsigned int msg_vmflush:1; /* VM trying to free memory */ + unsigned int msg_target_is_router:1; /* sending to a router */ + unsigned int msg_routing:1; /* being forwarded */ + unsigned int msg_ack:1; /* ack on finalize (PUT) */ + unsigned int msg_sending:1; /* outgoing message */ + 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 global + router credit */ + unsigned int msg_peerrtrcredit:1; /* taken a peer router credit */ + unsigned int msg_onactivelist:1; /* on the activelist */ - struct lnet_peer *msg_txpeer; /* peer I'm sending to */ - struct lnet_peer *msg_rxpeer; /* peer I received from */ + struct lnet_peer *msg_txpeer; /* peer I'm sending to */ + struct lnet_peer *msg_rxpeer; /* peer I received from */ - void *msg_private; - struct lnet_libmd *msg_md; + void *msg_private; + struct lnet_libmd *msg_md; - unsigned int msg_len; - unsigned int msg_wanted; - unsigned int msg_offset; - unsigned int msg_niov; - struct kvec *msg_iov; - lnet_kiov_t *msg_kiov; + unsigned int msg_len; + unsigned int msg_wanted; + unsigned int msg_offset; + unsigned int msg_niov; + struct kvec *msg_iov; + lnet_kiov_t *msg_kiov; - lnet_event_t msg_ev; - lnet_hdr_t msg_hdr; + lnet_event_t msg_ev; + lnet_hdr_t msg_hdr; } lnet_msg_t; typedef struct lnet_libhandle { - struct list_head lh_hash_chain; - __u64 lh_cookie; + struct list_head lh_hash_chain; + __u64 lh_cookie; } lnet_libhandle_t; #define lh_entry(ptr, type, member) \ ((type *)((char *)(ptr)-(char *)(&((type *)0)->member))) typedef struct lnet_eq { - struct list_head eq_list; - lnet_libhandle_t eq_lh; - lnet_seq_t eq_enq_seq; - lnet_seq_t eq_deq_seq; - unsigned int eq_size; - lnet_eq_handler_t eq_callback; - lnet_event_t *eq_events; + struct list_head eq_list; + lnet_libhandle_t eq_lh; + lnet_seq_t eq_enq_seq; + lnet_seq_t eq_deq_seq; + unsigned int eq_size; + lnet_eq_handler_t eq_callback; + lnet_event_t *eq_events; int **eq_refs; /* percpt refcount for EQ */ } lnet_eq_t; typedef struct lnet_me { - struct list_head me_list; - lnet_libhandle_t me_lh; - lnet_process_id_t me_match_id; - unsigned int me_portal; - unsigned int me_pos; /* hash offset in mt_hash */ - __u64 me_match_bits; - __u64 me_ignore_bits; - lnet_unlink_t me_unlink; - struct lnet_libmd *me_md; + struct list_head me_list; + lnet_libhandle_t me_lh; + lnet_process_id_t me_match_id; + unsigned int me_portal; + unsigned int me_pos; /* hash offset in mt_hash */ + __u64 me_match_bits; + __u64 me_ignore_bits; + lnet_unlink_t me_unlink; + struct lnet_libmd *me_md; } lnet_me_t; typedef struct lnet_libmd { - struct list_head md_list; - lnet_libhandle_t md_lh; - lnet_me_t *md_me; - char *md_start; - unsigned int md_offset; - unsigned int md_length; - unsigned int md_max_size; - int md_threshold; - int md_refcount; - unsigned int md_options; - unsigned int md_flags; - void *md_user_ptr; - lnet_eq_t *md_eq; - unsigned int md_niov; /* # frags */ + struct list_head md_list; + lnet_libhandle_t md_lh; + lnet_me_t *md_me; + char *md_start; + unsigned int md_offset; + unsigned int md_length; + unsigned int md_max_size; + int md_threshold; + int md_refcount; + unsigned int md_options; + unsigned int md_flags; + void *md_user_ptr; + lnet_eq_t *md_eq; + unsigned int md_niov; /* # frags */ union { - struct kvec iov[LNET_MAX_IOV]; - lnet_kiov_t kiov[LNET_MAX_IOV]; + struct kvec iov[LNET_MAX_IOV]; + lnet_kiov_t kiov[LNET_MAX_IOV]; } md_iov; } lnet_libmd_t; -#define LNET_MD_FLAG_ZOMBIE (1 << 0) -#define LNET_MD_FLAG_AUTO_UNLINK (1 << 1) -#define LNET_MD_FLAG_ABORTED (1 << 2) +#define LNET_MD_FLAG_ZOMBIE (1 << 0) +#define LNET_MD_FLAG_AUTO_UNLINK (1 << 1) +#define LNET_MD_FLAG_ABORTED (1 << 2) typedef struct { /* info about peers we are trying to fail */ - struct list_head tp_list; /* ln_test_peers */ - lnet_nid_t tp_nid; /* matching nid */ - unsigned int tp_threshold; /* # failures to simulate */ + struct list_head tp_list; /* ln_test_peers */ + lnet_nid_t tp_nid; /* matching nid */ + unsigned int tp_threshold; /* # failures to simulate */ } lnet_test_peer_t; -#define LNET_COOKIE_TYPE_MD 1 -#define LNET_COOKIE_TYPE_ME 2 -#define LNET_COOKIE_TYPE_EQ 3 -#define LNET_COOKIE_TYPE_BITS 2 +#define LNET_COOKIE_TYPE_MD 1 +#define LNET_COOKIE_TYPE_ME 2 +#define LNET_COOKIE_TYPE_EQ 3 +#define LNET_COOKIE_TYPE_BITS 2 #define LNET_COOKIE_MASK ((1ULL << LNET_COOKIE_TYPE_BITS) - 1ULL) -struct lnet_ni; /* forward ref */ +struct lnet_ni; /* forward ref */ typedef struct lnet_lnd { /* fields managed by portals */ - struct list_head lnd_list; /* stash in the LND table */ - int lnd_refcount; /* # active instances */ + struct list_head lnd_list; /* stash in the LND table */ + int lnd_refcount; /* # active instances */ /* fields initialised by the LND */ __u32 lnd_type; @@ -222,7 +223,8 @@ typedef struct lnet_lnd { int (*lnd_recv)(struct lnet_ni *ni, void *private, lnet_msg_t *msg, int delayed, unsigned int niov, struct kvec *iov, lnet_kiov_t *kiov, - unsigned int offset, unsigned int mlen, unsigned int rlen); + unsigned int offset, unsigned int mlen, + unsigned int rlen); /* lnet_parse() has had to delay processing of this message * (e.g. waiting for a forwarding buffer or send credits). Give the @@ -230,49 +232,49 @@ typedef struct lnet_lnd { * for success and do NOT give back a receive credit; that has to wait * until lnd_recv() gets called. On failure return < 0 and * release resources; lnd_recv() will not be called. */ - int (*lnd_eager_recv)(struct lnet_ni *ni, void *private, lnet_msg_t *msg, - void **new_privatep); + int (*lnd_eager_recv)(struct lnet_ni *ni, void *private, + lnet_msg_t *msg, void **new_privatep); /* notification of peer health */ void (*lnd_notify)(struct lnet_ni *ni, lnet_nid_t peer, int alive); /* query of peer aliveness */ - void (*lnd_query)(struct lnet_ni *ni, lnet_nid_t peer, unsigned long *when); + void (*lnd_query)(struct lnet_ni *ni, lnet_nid_t peer, + unsigned long *when); /* accept a new connection */ int (*lnd_accept)(struct lnet_ni *ni, struct socket *sock); - } lnd_t; struct lnet_tx_queue { int tq_credits; /* # tx credits free */ int tq_credits_min; /* lowest it's been */ int tq_credits_max; /* total # tx credits */ - struct list_head tq_delayed; /* delayed TXs */ + struct list_head tq_delayed; /* delayed TXs */ }; typedef struct lnet_ni { - spinlock_t ni_lock; - struct list_head ni_list; /* chain on ln_nis */ - struct list_head ni_cptlist; /* chain on ln_nis_cpt */ - int ni_maxtxcredits; /* # tx credits */ + spinlock_t ni_lock; + struct list_head ni_list; /* chain on ln_nis */ + struct list_head ni_cptlist; /* chain on ln_nis_cpt */ + int ni_maxtxcredits; /* # tx credits */ /* # per-peer send credits */ - int ni_peertxcredits; + int ni_peertxcredits; /* # per-peer router buffer credits */ - int ni_peerrtrcredits; + int ni_peerrtrcredits; /* seconds to consider peer dead */ - int ni_peertimeout; - int ni_ncpts; /* number of CPTs */ - __u32 *ni_cpts; /* bond NI on some CPTs */ - lnet_nid_t ni_nid; /* interface's NID */ - void *ni_data; /* instance-specific data */ - lnd_t *ni_lnd; /* procedural interface */ + int ni_peertimeout; + int ni_ncpts; /* number of CPTs */ + __u32 *ni_cpts; /* bond NI on some CPTs */ + lnet_nid_t ni_nid; /* interface's NID */ + void *ni_data; /* instance-specific data */ + lnd_t *ni_lnd; /* procedural interface */ struct lnet_tx_queue **ni_tx_queues; /* percpt TX queues */ int **ni_refs; /* percpt reference count */ - long ni_last_alive; /* when I was last alive */ - lnet_ni_status_t *ni_status; /* my health status */ + long ni_last_alive;/* when I was last alive */ + lnet_ni_status_t *ni_status; /* my health status */ /* equivalent interfaces to use */ - char *ni_interfaces[LNET_MAX_INTERFACES]; + char *ni_interfaces[LNET_MAX_INTERFACES]; } lnet_ni_t; #define LNET_PROTO_PING_MATCHBITS 0x8000000000000000LL @@ -291,55 +293,65 @@ typedef struct lnet_ni { #define LNET_PINGINFO_SIZE offsetof(lnet_ping_info_t, pi_ni[LNET_MAX_RTR_NIS]) typedef struct { /* chain on the_lnet.ln_zombie_rcd or ln_deathrow_rcd */ - struct list_head rcd_list; - lnet_handle_md_t rcd_mdh; /* ping buffer MD */ + struct list_head rcd_list; + lnet_handle_md_t rcd_mdh; /* ping buffer MD */ struct lnet_peer *rcd_gateway; /* reference to gateway */ lnet_ping_info_t *rcd_pinginfo; /* ping buffer */ } lnet_rc_data_t; typedef struct lnet_peer { - struct list_head lp_hashlist; /* chain on peer hash */ - struct list_head lp_txq; /* messages blocking for tx credits */ - struct list_head lp_rtrq; /* messages blocking for router credits */ - struct list_head lp_rtr_list; /* chain on router list */ - int lp_txcredits; /* # tx credits available */ - int lp_mintxcredits; /* low water mark */ - int lp_rtrcredits; /* # router credits */ - int lp_minrtrcredits; /* low water mark */ - unsigned int lp_alive:1; /* alive/dead? */ - unsigned int lp_notify:1; /* notification outstanding? */ - unsigned int lp_notifylnd:1; /* outstanding notification for LND? */ - unsigned int lp_notifying:1; /* some thread is handling notification */ - unsigned int lp_ping_notsent; /* SEND event outstanding from ping */ - int lp_alive_count; /* # times router went dead<->alive */ - long lp_txqnob; /* bytes queued for sending */ - unsigned long lp_timestamp; /* time of last aliveness news */ - unsigned long lp_ping_timestamp; /* time of last ping attempt */ - unsigned long lp_ping_deadline; /* != 0 if ping reply expected */ - unsigned long lp_last_alive; /* when I was last alive */ - unsigned long lp_last_query; /* when lp_ni was queried last time */ - lnet_ni_t *lp_ni; /* interface peer is on */ - lnet_nid_t lp_nid; /* peer's NID */ - int lp_refcount; /* # refs */ - int lp_cpt; /* CPT this peer attached on */ + struct list_head lp_hashlist; /* chain on peer hash */ + struct list_head lp_txq; /* messages blocking for + tx credits */ + struct list_head lp_rtrq; /* messages blocking for + router credits */ + struct list_head lp_rtr_list; /* chain on router list */ + int lp_txcredits; /* # tx credits available */ + int lp_mintxcredits; /* low water mark */ + int lp_rtrcredits; /* # router credits */ + int lp_minrtrcredits; /* low water mark */ + unsigned int lp_alive:1; /* alive/dead? */ + unsigned int lp_notify:1; /* notification outstanding? */ + unsigned int lp_notifylnd:1;/* outstanding notification + for LND? */ + unsigned int lp_notifying:1; /* some thread is handling + notification */ + unsigned int lp_ping_notsent;/* SEND event outstanding + from ping */ + int lp_alive_count; /* # times router went + dead<->alive */ + long lp_txqnob; /* bytes queued for sending */ + unsigned long lp_timestamp; /* time of last aliveness + news */ + unsigned long lp_ping_timestamp;/* time of last ping + attempt */ + unsigned long lp_ping_deadline; /* != 0 if ping reply + expected */ + unsigned long lp_last_alive; /* when I was last alive */ + unsigned long lp_last_query; /* when lp_ni was queried + last time */ + lnet_ni_t *lp_ni; /* interface peer is on */ + lnet_nid_t lp_nid; /* peer's NID */ + int lp_refcount; /* # refs */ + int lp_cpt; /* CPT this peer attached on */ /* # refs from lnet_route_t::lr_gateway */ - int lp_rtr_refcount; + int lp_rtr_refcount; /* returned RC ping features */ - unsigned int lp_ping_feats; - struct list_head lp_routes; /* routers on this peer */ + unsigned int lp_ping_feats; + struct list_head lp_routes; /* routers on this peer */ lnet_rc_data_t *lp_rcd; /* router checker state */ } lnet_peer_t; /* peer hash size */ -#define LNET_PEER_HASH_BITS 9 -#define LNET_PEER_HASH_SIZE (1 << LNET_PEER_HASH_BITS) +#define LNET_PEER_HASH_BITS 9 +#define LNET_PEER_HASH_SIZE (1 << LNET_PEER_HASH_BITS) /* peer hash table */ struct lnet_peer_table { - int pt_version; /* /proc validity stamp */ - int pt_number; /* # peers extant */ - struct list_head pt_deathrow; /* zombie peers */ - struct list_head *pt_hash; /* NID->peer hash */ + int pt_version; /* /proc validity stamp */ + int pt_number; /* # peers extant */ + struct list_head pt_deathrow; /* zombie peers */ + struct list_head *pt_hash; /* NID->peer hash */ }; /* peer aliveness is enabled only on routers for peers in a network where the @@ -348,14 +360,14 @@ struct lnet_peer_table { (lp)->lp_ni->ni_peertimeout > 0) typedef struct { - struct list_head lr_list; /* chain on net */ - struct list_head lr_gwlist; /* chain on gateway */ + struct list_head lr_list; /* chain on net */ + struct list_head lr_gwlist; /* chain on gateway */ lnet_peer_t *lr_gateway; /* router node */ - __u32 lr_net; /* remote network number */ - int lr_seq; /* sequence for round-robin */ - unsigned int lr_downis; /* number of down NIs */ - unsigned int lr_hops; /* how far I am */ - unsigned int lr_priority; /* route priority */ + __u32 lr_net; /* remote network number */ + int lr_seq; /* sequence for round-robin */ + unsigned int lr_downis; /* number of down NIs */ + unsigned int lr_hops; /* how far I am */ + unsigned int lr_priority; /* route priority */ } lnet_route_t; #define LNET_REMOTE_NETS_HASH_DEFAULT (1U << 7) @@ -363,9 +375,10 @@ typedef struct { #define LNET_REMOTE_NETS_HASH_SIZE (1 << the_lnet.ln_remote_nets_hbits) typedef struct { - struct list_head lrn_list; /* chain on ln_remote_nets_hash */ - struct list_head lrn_routes; /* routes to me */ - __u32 lrn_net; /* my net number */ + struct list_head lrn_list; /* chain on + ln_remote_nets_hash */ + struct list_head lrn_routes; /* routes to me */ + __u32 lrn_net; /* my net number */ } lnet_remotenet_t; /** lnet message has credit and can be submitted to lnd for send/receive */ @@ -374,21 +387,23 @@ typedef struct { #define LNET_CREDIT_WAIT 1 typedef struct { - struct list_head rbp_bufs; /* my free buffer pool */ - struct list_head rbp_msgs; /* messages blocking for a buffer */ - int rbp_npages; /* # pages in each buffer */ - int rbp_nbuffers; /* # buffers */ - int rbp_credits; /* # free buffers / blocked messages */ - int rbp_mincredits; /* low water mark */ + struct list_head rbp_bufs; /* my free buffer pool */ + struct list_head rbp_msgs; /* messages blocking + for a buffer */ + int rbp_npages; /* # pages in each buffer */ + int rbp_nbuffers; /* # buffers */ + int rbp_credits; /* # free buffers / + blocked messages */ + int rbp_mincredits; /* low water mark */ } lnet_rtrbufpool_t; typedef struct { - struct list_head rb_list; /* chain on rbp_bufs */ - lnet_rtrbufpool_t *rb_pool; /* owning pool */ - lnet_kiov_t rb_kiov[0]; /* the buffer space */ + struct list_head rb_list; /* chain on rbp_bufs */ + lnet_rtrbufpool_t *rb_pool; /* owning pool */ + lnet_kiov_t rb_kiov[0]; /* the buffer space */ } lnet_rtrbuf_t; -#define LNET_PEER_HASHSIZE 503 /* prime! */ +#define LNET_PEER_HASHSIZE 503 /* prime! */ #define LNET_NRBPOOLS 3 /* # different router buffer pools */ @@ -400,15 +415,16 @@ enum { /* Must be discarded */ LNET_MATCHMD_DROP = (1 << 2), /* match and buffer is exhausted */ - LNET_MATCHMD_EXHAUSTED = (1 << 3), + LNET_MATCHMD_EXHAUSTED = (1 << 3), /* match or drop */ - LNET_MATCHMD_FINISH = (LNET_MATCHMD_OK | LNET_MATCHMD_DROP), + LNET_MATCHMD_FINISH = (LNET_MATCHMD_OK | LNET_MATCHMD_DROP), }; /* Options for lnet_portal_t::ptl_options */ -#define LNET_PTL_LAZY (1 << 0) -#define LNET_PTL_MATCH_UNIQUE (1 << 1) /* unique match, for RDMA */ -#define LNET_PTL_MATCH_WILDCARD (1 << 2) /* wildcard match, request portal */ +#define LNET_PTL_LAZY (1 << 0) +#define LNET_PTL_MATCH_UNIQUE (1 << 1) /* unique match, for RDMA */ +#define LNET_PTL_MATCH_WILDCARD (1 << 2) /* wildcard match, + request portal */ /* parameter for matching operations (GET, PUT) */ struct lnet_match_info { @@ -437,14 +453,14 @@ struct lnet_match_info { /* portal match table */ struct lnet_match_table { /* reserved for upcoming patches, CPU partition ID */ - unsigned int mt_cpt; - unsigned int mt_portal; /* portal index */ + 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 valid for wildcard portal */ - unsigned int mt_enabled; + unsigned int mt_enabled; /* bitmap to flag whether MEs on mt_hash are exhausted or not */ - __u64 mt_exhausted[LNET_MT_EXHAUSTED_BMAP]; - struct list_head *mt_mhash; /* matching hash */ + __u64 mt_exhausted[LNET_MT_EXHAUSTED_BMAP]; + struct list_head *mt_mhash; /* matching hash */ }; /* these are only useful for wildcard portal */ @@ -458,22 +474,22 @@ struct lnet_match_table { #define LNET_PTL_ROTOR_HASH_RT 3 typedef struct lnet_portal { - spinlock_t ptl_lock; - unsigned int ptl_index; /* portal ID, reserved */ + spinlock_t ptl_lock; + unsigned int ptl_index; /* portal ID, reserved */ /* flags on this portal: lazy, unique... */ - unsigned int ptl_options; + unsigned int ptl_options; /* list of messages which are stealing buffer */ - struct list_head ptl_msg_stealing; + struct list_head ptl_msg_stealing; /* messages blocking for MD */ - struct list_head ptl_msg_delayed; + struct list_head ptl_msg_delayed; /* Match table for each CPT */ struct lnet_match_table **ptl_mtables; /* spread rotor of incoming "PUT" */ - unsigned int ptl_rotor; + unsigned int ptl_rotor; /* # active entries for this portal */ - int ptl_mt_nmaps; + int ptl_mt_nmaps; /* array of active entries' cpu-partition-id */ - int ptl_mt_maps[0]; + int ptl_mt_maps[0]; } lnet_portal_t; #define LNET_LH_HASH_BITS 12 @@ -482,20 +498,20 @@ typedef struct lnet_portal { /* resource container (ME, MD, EQ) */ struct lnet_res_container { - unsigned int rec_type; /* container type */ - __u64 rec_lh_cookie; /* cookie generator */ - struct list_head rec_active; /* active resource list */ - struct list_head *rec_lh_hash; /* handle hash */ + unsigned int rec_type; /* container type */ + __u64 rec_lh_cookie; /* cookie generator */ + struct list_head rec_active; /* active resource list */ + struct list_head *rec_lh_hash; /* handle hash */ }; /* message container */ struct lnet_msg_container { - int msc_init; /* initialized or not */ + int msc_init; /* initialized or not */ /* max # threads finalizing */ - int msc_nfinalizers; + int msc_nfinalizers; /* msgs waiting to complete finalizing */ - struct list_head msc_finalizing; - struct list_head msc_active; /* active message list */ + struct list_head msc_finalizing; + struct list_head msc_active; /* active message list */ /* threads doing finalization */ void **msc_finalizers; }; @@ -507,15 +523,15 @@ struct lnet_msg_container { typedef struct { /* CPU partition table of LNet */ - struct cfs_cpt_table *ln_cpt_table; + struct cfs_cpt_table *ln_cpt_table; /* number of CPTs in ln_cpt_table */ - unsigned int ln_cpt_number; - unsigned int ln_cpt_bits; + unsigned int ln_cpt_number; + unsigned int ln_cpt_bits; /* protect LNet resources (ME/MD/EQ) */ - struct cfs_percpt_lock *ln_res_lock; + struct cfs_percpt_lock *ln_res_lock; /* # portals */ - int ln_nportals; + int ln_nportals; /* the vector of portals */ lnet_portal_t **ln_portals; /* percpt ME containers */ @@ -524,77 +540,78 @@ typedef struct { struct lnet_res_container **ln_md_containers; /* Event Queue container */ - struct lnet_res_container ln_eq_container; - wait_queue_head_t ln_eq_waitq; - spinlock_t ln_eq_wait_lock; - unsigned int ln_remote_nets_hbits; + struct lnet_res_container ln_eq_container; + wait_queue_head_t ln_eq_waitq; + spinlock_t ln_eq_wait_lock; + unsigned int ln_remote_nets_hbits; /* protect NI, peer table, credits, routers, rtrbuf... */ - struct cfs_percpt_lock *ln_net_lock; + struct cfs_percpt_lock *ln_net_lock; /* percpt message containers for active/finalizing/freed message */ struct lnet_msg_container **ln_msg_containers; lnet_counters_t **ln_counters; struct lnet_peer_table **ln_peer_tables; /* failure simulation */ - struct list_head ln_test_peers; + struct list_head ln_test_peers; - struct list_head ln_nis; /* LND instances */ + struct list_head ln_nis; /* LND instances */ /* NIs bond on specific CPT(s) */ - struct list_head ln_nis_cpt; + struct list_head ln_nis_cpt; /* dying LND instances */ - struct list_head ln_nis_zombie; - lnet_ni_t *ln_loni; /* the loopback NI */ + struct list_head ln_nis_zombie; + lnet_ni_t *ln_loni; /* the loopback NI */ /* NI to wait for events in */ - lnet_ni_t *ln_eq_waitni; + lnet_ni_t *ln_eq_waitni; /* remote networks with routes to them */ - struct list_head *ln_remote_nets_hash; + struct list_head *ln_remote_nets_hash; /* validity stamp */ - __u64 ln_remote_nets_version; + __u64 ln_remote_nets_version; /* list of all known routers */ - struct list_head ln_routers; + struct list_head ln_routers; /* validity stamp */ - __u64 ln_routers_version; + __u64 ln_routers_version; /* percpt router buffer pools */ lnet_rtrbufpool_t **ln_rtrpools; - lnet_handle_md_t ln_ping_target_md; - lnet_handle_eq_t ln_ping_target_eq; - lnet_ping_info_t *ln_ping_info; + lnet_handle_md_t ln_ping_target_md; + lnet_handle_eq_t ln_ping_target_eq; + lnet_ping_info_t *ln_ping_info; /* router checker startup/shutdown state */ - int ln_rc_state; + int ln_rc_state; /* router checker's event queue */ - lnet_handle_eq_t ln_rc_eqh; + lnet_handle_eq_t ln_rc_eqh; /* rcd still pending on net */ - struct list_head ln_rcd_deathrow; + struct list_head ln_rcd_deathrow; /* rcd ready for free */ - struct list_head ln_rcd_zombie; + struct list_head ln_rcd_zombie; /* serialise startup/shutdown */ - struct semaphore ln_rc_signal; + struct semaphore ln_rc_signal; - struct mutex ln_api_mutex; - struct mutex ln_lnd_mutex; - int ln_init; /* lnet_init() called? */ + struct mutex ln_api_mutex; + struct mutex ln_lnd_mutex; + int ln_init; /* lnet_init() + called? */ /* Have I called LNetNIInit myself? */ - int ln_niinit_self; + int ln_niinit_self; /* LNetNIInit/LNetNIFini counter */ - int ln_refcount; + int ln_refcount; /* shutdown in progress */ - int ln_shutdown; + int ln_shutdown; - int ln_routing; /* am I a router? */ - lnet_pid_t ln_pid; /* requested pid */ + int ln_routing; /* am I a router? */ + lnet_pid_t ln_pid; /* requested pid */ /* uniquely identifies this ni in this epoch */ - __u64 ln_interface_cookie; + __u64 ln_interface_cookie; /* registered LNDs */ - struct list_head ln_lnds; + struct list_head ln_lnds; /* space for network names */ - char *ln_network_tokens; - int ln_network_tokens_nob; + char *ln_network_tokens; + int ln_network_tokens_nob; /* test protocol compatibility flags */ - int ln_testprotocompat; + int ln_testprotocompat; } lnet_t; diff --git a/drivers/staging/lustre/include/linux/lnet/lnetst.h b/drivers/staging/lustre/include/linux/lnet/lnetst.h index 57432fdb927c..ea1e0c602afb 100644 --- a/drivers/staging/lustre/include/linux/lnet/lnetst.h +++ b/drivers/staging/lustre/include/linux/lnet/lnetst.h @@ -49,99 +49,107 @@ #define LST_FEATS_EMPTY (LST_FEAT_NONE) #define LST_FEATS_MASK (LST_FEAT_NONE | LST_FEAT_BULK_LEN) -#define LST_NAME_SIZE 32 /* max name buffer length */ +#define LST_NAME_SIZE 32 /* max name buffer length */ -#define LSTIO_DEBUG 0xC00 /* debug */ -#define LSTIO_SESSION_NEW 0xC01 /* create session */ -#define LSTIO_SESSION_END 0xC02 /* end session */ -#define LSTIO_SESSION_INFO 0xC03 /* query session */ -#define LSTIO_GROUP_ADD 0xC10 /* add group */ -#define LSTIO_GROUP_LIST 0xC11 /* list all groups in session */ -#define LSTIO_GROUP_INFO 0xC12 /* query default information of specified group */ -#define LSTIO_GROUP_DEL 0xC13 /* delete group */ -#define LSTIO_NODES_ADD 0xC14 /* add nodes to specified group */ -#define LSTIO_GROUP_UPDATE 0xC15 /* update group */ -#define LSTIO_BATCH_ADD 0xC20 /* add batch */ -#define LSTIO_BATCH_START 0xC21 /* start batch */ -#define LSTIO_BATCH_STOP 0xC22 /* stop batch */ -#define LSTIO_BATCH_DEL 0xC23 /* delete batch */ -#define LSTIO_BATCH_LIST 0xC24 /* show all batches in the session */ -#define LSTIO_BATCH_INFO 0xC25 /* show defail of specified batch */ -#define LSTIO_TEST_ADD 0xC26 /* add test (to batch) */ -#define LSTIO_BATCH_QUERY 0xC27 /* query batch status */ -#define LSTIO_STAT_QUERY 0xC30 /* get stats */ +#define LSTIO_DEBUG 0xC00 /* debug */ +#define LSTIO_SESSION_NEW 0xC01 /* create session */ +#define LSTIO_SESSION_END 0xC02 /* end session */ +#define LSTIO_SESSION_INFO 0xC03 /* query session */ +#define LSTIO_GROUP_ADD 0xC10 /* add group */ +#define LSTIO_GROUP_LIST 0xC11 /* list all groups in session */ +#define LSTIO_GROUP_INFO 0xC12 /* query default information of + * specified group */ +#define LSTIO_GROUP_DEL 0xC13 /* delete group */ +#define LSTIO_NODES_ADD 0xC14 /* add nodes to specified group */ +#define LSTIO_GROUP_UPDATE 0xC15 /* update group */ +#define LSTIO_BATCH_ADD 0xC20 /* add batch */ +#define LSTIO_BATCH_START 0xC21 /* start batch */ +#define LSTIO_BATCH_STOP 0xC22 /* stop batch */ +#define LSTIO_BATCH_DEL 0xC23 /* delete batch */ +#define LSTIO_BATCH_LIST 0xC24 /* show all batches in the session */ +#define LSTIO_BATCH_INFO 0xC25 /* show defail of specified batch */ +#define LSTIO_TEST_ADD 0xC26 /* add test (to batch) */ +#define LSTIO_BATCH_QUERY 0xC27 /* query batch status */ +#define LSTIO_STAT_QUERY 0xC30 /* get stats */ typedef struct { - lnet_nid_t ses_nid; /* nid of console node */ - __u64 ses_stamp; /* time stamp */ -} lst_sid_t; /*** session id */ + lnet_nid_t ses_nid; /* nid of console node */ + __u64 ses_stamp; /* time stamp */ +} lst_sid_t; /*** session id */ extern lst_sid_t LST_INVALID_SID; typedef struct { - __u64 bat_id; /* unique id in session */ -} lst_bid_t; /*** batch id (group of tests) */ + __u64 bat_id; /* unique id in session */ +} lst_bid_t; /*** batch id (group of tests) */ /* Status of test node */ -#define LST_NODE_ACTIVE 0x1 /* node in this session */ -#define LST_NODE_BUSY 0x2 /* node is taken by other session */ -#define LST_NODE_DOWN 0x4 /* node is down */ -#define LST_NODE_UNKNOWN 0x8 /* node not in session */ +#define LST_NODE_ACTIVE 0x1 /* node in this session */ +#define LST_NODE_BUSY 0x2 /* node is taken by other session */ +#define LST_NODE_DOWN 0x4 /* node is down */ +#define LST_NODE_UNKNOWN 0x8 /* node not in session */ typedef struct { - lnet_process_id_t nde_id; /* id of node */ - int nde_state; /* state of node */ -} lstcon_node_ent_t; /*** node entry, for list_group command */ + lnet_process_id_t nde_id; /* id of node */ + int nde_state; /* state of node */ +} lstcon_node_ent_t; /*** node entry, for list_group command */ typedef struct { - int nle_nnode; /* # of nodes */ - int nle_nactive; /* # of active nodes */ - int nle_nbusy; /* # of busy nodes */ - int nle_ndown; /* # of down nodes */ - int nle_nunknown; /* # of unknown nodes */ -} lstcon_ndlist_ent_t; /*** node_list entry, for list_batch command */ + int nle_nnode; /* # of nodes */ + int nle_nactive; /* # of active nodes */ + int nle_nbusy; /* # of busy nodes */ + int nle_ndown; /* # of down nodes */ + int nle_nunknown; /* # of unknown nodes */ +} lstcon_ndlist_ent_t; /*** node_list entry, for list_batch command */ typedef struct { - int tse_type; /* test type */ - int tse_loop; /* loop count */ - int tse_concur; /* concurrency of test */ -} lstcon_test_ent_t; /*** test summary entry, for list_batch command */ + int tse_type; /* test type */ + int tse_loop; /* loop count */ + int tse_concur; /* concurrency of test */ +} lstcon_test_ent_t; /*** test summary entry, for + *** list_batch command */ typedef struct { - int bae_state; /* batch status */ - int bae_timeout; /* batch timeout */ - int bae_ntest; /* # of tests in the batch */ -} lstcon_batch_ent_t; /*** batch summary entry, for list_batch command */ + int bae_state; /* batch status */ + int bae_timeout; /* batch timeout */ + int bae_ntest; /* # of tests in the batch */ +} lstcon_batch_ent_t; /*** batch summary entry, for + *** list_batch command */ typedef struct { - lstcon_ndlist_ent_t tbe_cli_nle; /* client (group) node_list entry */ - lstcon_ndlist_ent_t tbe_srv_nle; /* server (group) node_list entry */ + lstcon_ndlist_ent_t tbe_cli_nle; /* client (group) node_list + * entry */ + lstcon_ndlist_ent_t tbe_srv_nle; /* server (group) node_list + * entry */ union { - lstcon_test_ent_t tbe_test; /* test entry */ - lstcon_batch_ent_t tbe_batch; /* batch entry */ + lstcon_test_ent_t tbe_test; /* test entry */ + lstcon_batch_ent_t tbe_batch; /* batch entry */ } u; -} lstcon_test_batch_ent_t; /*** test/batch verbose information entry, - *** for list_batch command */ +} lstcon_test_batch_ent_t; /*** test/batch verbose information entry, + *** for list_batch command */ typedef struct { - struct list_head rpe_link; /* link chain */ - lnet_process_id_t rpe_peer; /* peer's id */ - struct timeval rpe_stamp; /* time stamp of RPC */ - int rpe_state; /* peer's state */ - int rpe_rpc_errno; /* RPC errno */ + struct list_head rpe_link; /* link chain */ + lnet_process_id_t rpe_peer; /* peer's id */ + struct timeval rpe_stamp; /* time stamp of RPC */ + int rpe_state; /* peer's state */ + int rpe_rpc_errno; /* RPC errno */ - lst_sid_t rpe_sid; /* peer's session id */ - int rpe_fwk_errno; /* framework errno */ - int rpe_priv[4]; /* private data */ - char rpe_payload[0]; /* private reply payload */ + lst_sid_t rpe_sid; /* peer's session id */ + int rpe_fwk_errno; /* framework errno */ + int rpe_priv[4]; /* private data */ + char rpe_payload[0]; /* private reply payload */ } lstcon_rpc_ent_t; typedef struct { - int trs_rpc_stat[4]; /* RPCs stat (0: total, 1: failed, 2: finished, 4: reserved */ - int trs_rpc_errno; /* RPC errno */ - int trs_fwk_stat[8]; /* framework stat */ - int trs_fwk_errno; /* errno of the first remote error */ - void *trs_fwk_private; /* private framework stat */ + int trs_rpc_stat[4]; /* RPCs stat (0: total + 1: failed + 2: finished + 4: reserved */ + int trs_rpc_errno; /* RPC errno */ + int trs_fwk_stat[8]; /* framework stat */ + int trs_fwk_errno; /* errno of the first remote error */ + void *trs_fwk_private; /* private framework stat */ } lstcon_trans_stat_t; static inline int @@ -236,234 +244,263 @@ lstcon_statqry_stat_failure(lstcon_trans_stat_t *stat, int inc) /* create a session */ typedef struct { - int lstio_ses_key; /* IN: local key */ - int lstio_ses_timeout; /* IN: session timeout */ - int lstio_ses_force; /* IN: force create ? */ + int lstio_ses_key; /* IN: local key */ + int lstio_ses_timeout; /* IN: session timeout */ + int lstio_ses_force; /* IN: force create ? */ /** IN: session features */ - unsigned lstio_ses_feats; - lst_sid_t *lstio_ses_idp; /* OUT: session id */ - int lstio_ses_nmlen; /* IN: name length */ - char *lstio_ses_namep; /* IN: session name */ + unsigned lstio_ses_feats; + lst_sid_t *lstio_ses_idp; /* OUT: session id */ + int lstio_ses_nmlen; /* IN: name length */ + char *lstio_ses_namep; /* IN: session name */ } lstio_session_new_args_t; /* query current session */ typedef struct { - lst_sid_t *lstio_ses_idp; /* OUT: session id */ - int *lstio_ses_keyp; /* OUT: local key */ + lst_sid_t *lstio_ses_idp; /* OUT: session id */ + int *lstio_ses_keyp; /* OUT: local key */ /** OUT: session features */ - unsigned *lstio_ses_featp; - lstcon_ndlist_ent_t *lstio_ses_ndinfo; /* OUT: */ - int lstio_ses_nmlen; /* IN: name length */ - char *lstio_ses_namep; /* OUT: session name */ + unsigned *lstio_ses_featp; + lstcon_ndlist_ent_t *lstio_ses_ndinfo; /* OUT: */ + int lstio_ses_nmlen; /* IN: name length */ + char *lstio_ses_namep; /* OUT: session name */ } lstio_session_info_args_t; /* delete a session */ typedef struct { - int lstio_ses_key; /* IN: session key */ + int lstio_ses_key; /* IN: session key */ } lstio_session_end_args_t; -#define LST_OPC_SESSION 1 -#define LST_OPC_GROUP 2 -#define LST_OPC_NODES 3 +#define LST_OPC_SESSION 1 +#define LST_OPC_GROUP 2 +#define LST_OPC_NODES 3 #define LST_OPC_BATCHCLI 4 #define LST_OPC_BATCHSRV 5 typedef struct { - int lstio_dbg_key; /* IN: session key */ - int lstio_dbg_type; /* IN: debug sessin|batch|group|nodes list */ - int lstio_dbg_flags; /* IN: reserved debug flags */ - int lstio_dbg_timeout; /* IN: timeout of debug */ - - int lstio_dbg_nmlen; /* IN: len of name */ - char *lstio_dbg_namep; /* IN: name of group|batch */ - int lstio_dbg_count; /* IN: # of test nodes to debug */ - lnet_process_id_t *lstio_dbg_idsp; /* IN: id of test nodes */ - struct list_head *lstio_dbg_resultp; /* OUT: list head of result buffer */ + int lstio_dbg_key; /* IN: session key */ + int lstio_dbg_type; /* IN: debug + session|batch| + group|nodes + list */ + int lstio_dbg_flags; /* IN: reserved debug + flags */ + int lstio_dbg_timeout; /* IN: timeout of + debug */ + int lstio_dbg_nmlen; /* IN: len of name */ + char *lstio_dbg_namep; /* IN: name of + group|batch */ + int lstio_dbg_count; /* IN: # of test nodes + to debug */ + lnet_process_id_t *lstio_dbg_idsp; /* IN: id of test + nodes */ + struct list_head *lstio_dbg_resultp; /* OUT: list head of + result buffer */ } lstio_debug_args_t; typedef struct { - int lstio_grp_key; /* IN: session key */ - int lstio_grp_nmlen; /* IN: name length */ - char *lstio_grp_namep; /* IN: group name */ + int lstio_grp_key; /* IN: session key */ + int lstio_grp_nmlen; /* IN: name length */ + char *lstio_grp_namep; /* IN: group name */ } lstio_group_add_args_t; typedef struct { - int lstio_grp_key; /* IN: session key */ - int lstio_grp_nmlen; /* IN: name length */ - char *lstio_grp_namep; /* IN: group name */ + int lstio_grp_key; /* IN: session key */ + int lstio_grp_nmlen; /* IN: name length */ + char *lstio_grp_namep; /* IN: group name */ } lstio_group_del_args_t; -#define LST_GROUP_CLEAN 1 /* remove inactive nodes in the group */ -#define LST_GROUP_REFRESH 2 /* refresh inactive nodes in the group */ -#define LST_GROUP_RMND 3 /* delete nodes from the group */ +#define LST_GROUP_CLEAN 1 /* remove inactive nodes in the group */ +#define LST_GROUP_REFRESH 2 /* refresh inactive nodes + * in the group */ +#define LST_GROUP_RMND 3 /* delete nodes from the group */ typedef struct { - int lstio_grp_key; /* IN: session key */ - int lstio_grp_opc; /* IN: OPC */ - int lstio_grp_args; /* IN: arguments */ - int lstio_grp_nmlen; /* IN: name length */ - char *lstio_grp_namep; /* IN: group name */ - int lstio_grp_count; /* IN: # of nodes id */ - lnet_process_id_t *lstio_grp_idsp; /* IN: array of nodes */ - struct list_head *lstio_grp_resultp; /* OUT: list head of result buffer */ + int lstio_grp_key; /* IN: session key */ + int lstio_grp_opc; /* IN: OPC */ + int lstio_grp_args; /* IN: arguments */ + int lstio_grp_nmlen; /* IN: name length */ + char *lstio_grp_namep; /* IN: group name */ + int lstio_grp_count; /* IN: # of nodes id */ + lnet_process_id_t *lstio_grp_idsp; /* IN: array of nodes */ + struct list_head *lstio_grp_resultp; /* OUT: list head of + result buffer */ } lstio_group_update_args_t; typedef struct { - int lstio_grp_key; /* IN: session key */ - int lstio_grp_nmlen; /* IN: name length */ - char *lstio_grp_namep; /* IN: group name */ - int lstio_grp_count; /* IN: # of nodes */ + int lstio_grp_key; /* IN: session key */ + int lstio_grp_nmlen; /* IN: name length */ + char *lstio_grp_namep; /* IN: group name */ + int lstio_grp_count; /* IN: # of nodes */ /** OUT: session features */ - unsigned *lstio_grp_featp; - lnet_process_id_t *lstio_grp_idsp; /* IN: nodes */ - struct list_head *lstio_grp_resultp; /* OUT: list head of result buffer */ + unsigned *lstio_grp_featp; + lnet_process_id_t *lstio_grp_idsp; /* IN: nodes */ + struct list_head *lstio_grp_resultp; /* OUT: list head of + result buffer */ } lstio_group_nodes_args_t; typedef struct { - int lstio_grp_key; /* IN: session key */ - int lstio_grp_idx; /* IN: group idx */ - int lstio_grp_nmlen; /* IN: name len */ - char *lstio_grp_namep; /* OUT: name */ + int lstio_grp_key; /* IN: session key */ + int lstio_grp_idx; /* IN: group idx */ + int lstio_grp_nmlen; /* IN: name len */ + char *lstio_grp_namep; /* OUT: name */ } lstio_group_list_args_t; typedef struct { - int lstio_grp_key; /* IN: session key */ - int lstio_grp_nmlen; /* IN: name len */ - char *lstio_grp_namep; /* IN: name */ - lstcon_ndlist_ent_t *lstio_grp_entp; /* OUT: description of group */ - - int *lstio_grp_idxp; /* IN/OUT: node index */ - int *lstio_grp_ndentp; /* IN/OUT: # of nodent */ - lstcon_node_ent_t *lstio_grp_dentsp; /* OUT: nodent array */ + int lstio_grp_key; /* IN: session key */ + int lstio_grp_nmlen; /* IN: name len */ + char *lstio_grp_namep; /* IN: name */ + lstcon_ndlist_ent_t *lstio_grp_entp; /* OUT: description of + group */ + int *lstio_grp_idxp; /* IN/OUT: node index */ + int *lstio_grp_ndentp; /* IN/OUT: # of nodent */ + lstcon_node_ent_t *lstio_grp_dentsp; /* OUT: nodent array */ } lstio_group_info_args_t; -#define LST_DEFAULT_BATCH "batch" /* default batch name */ +#define LST_DEFAULT_BATCH "batch" /* default batch name */ typedef struct { - int lstio_bat_key; /* IN: session key */ - int lstio_bat_nmlen; /* IN: name length */ - char *lstio_bat_namep; /* IN: batch name */ + int lstio_bat_key; /* IN: session key */ + int lstio_bat_nmlen; /* IN: name length */ + char *lstio_bat_namep; /* IN: batch name */ } lstio_batch_add_args_t; typedef struct { - int lstio_bat_key; /* IN: session key */ - int lstio_bat_nmlen; /* IN: name length */ - char *lstio_bat_namep; /* IN: batch name */ + int lstio_bat_key; /* IN: session key */ + int lstio_bat_nmlen; /* IN: name length */ + char *lstio_bat_namep; /* IN: batch name */ } lstio_batch_del_args_t; typedef struct { - int lstio_bat_key; /* IN: session key */ - int lstio_bat_timeout; /* IN: timeout for the batch */ - int lstio_bat_nmlen; /* IN: name length */ - char *lstio_bat_namep; /* IN: batch name */ - struct list_head *lstio_bat_resultp; /* OUT: list head of result buffer */ + int lstio_bat_key; /* IN: session key */ + int lstio_bat_timeout; /* IN: timeout for + the batch */ + int lstio_bat_nmlen; /* IN: name length */ + char *lstio_bat_namep; /* IN: batch name */ + struct list_head *lstio_bat_resultp; /* OUT: list head of + result buffer */ } lstio_batch_run_args_t; typedef struct { - int lstio_bat_key; /* IN: session key */ - int lstio_bat_force; /* IN: abort unfinished test RPC */ - int lstio_bat_nmlen; /* IN: name length */ - char *lstio_bat_namep; /* IN: batch name */ - struct list_head *lstio_bat_resultp; /* OUT: list head of result buffer */ + int lstio_bat_key; /* IN: session key */ + int lstio_bat_force; /* IN: abort unfinished + test RPC */ + int lstio_bat_nmlen; /* IN: name length */ + char *lstio_bat_namep; /* IN: batch name */ + struct list_head *lstio_bat_resultp; /* OUT: list head of + result buffer */ } lstio_batch_stop_args_t; typedef struct { - int lstio_bat_key; /* IN: session key */ - int lstio_bat_testidx; /* IN: test index */ - int lstio_bat_client; /* IN: is test client? */ - int lstio_bat_timeout; /* IN: timeout for waiting */ - int lstio_bat_nmlen; /* IN: name length */ - char *lstio_bat_namep; /* IN: batch name */ - struct list_head *lstio_bat_resultp; /* OUT: list head of result buffer */ + int lstio_bat_key; /* IN: session key */ + int lstio_bat_testidx; /* IN: test index */ + int lstio_bat_client; /* IN: we testing + client? */ + int lstio_bat_timeout; /* IN: timeout for + waiting */ + int lstio_bat_nmlen; /* IN: name length */ + char *lstio_bat_namep; /* IN: batch name */ + struct list_head *lstio_bat_resultp; /* OUT: list head of + result buffer */ } lstio_batch_query_args_t; typedef struct { - int lstio_bat_key; /* IN: session key */ - int lstio_bat_idx; /* IN: index */ - int lstio_bat_nmlen; /* IN: name length */ - char *lstio_bat_namep; /* IN: batch name */ + int lstio_bat_key; /* IN: session key */ + int lstio_bat_idx; /* IN: index */ + int lstio_bat_nmlen; /* IN: name length */ + char *lstio_bat_namep; /* IN: batch name */ } lstio_batch_list_args_t; typedef struct { - int lstio_bat_key; /* IN: session key */ - int lstio_bat_nmlen; /* IN: name length */ - char *lstio_bat_namep; /* IN: name */ - int lstio_bat_server; /* IN: query server or not */ - int lstio_bat_testidx; /* IN: test index */ - lstcon_test_batch_ent_t *lstio_bat_entp; /* OUT: batch ent */ + int lstio_bat_key; /* IN: session key */ + int lstio_bat_nmlen; /* IN: name length */ + char *lstio_bat_namep; /* IN: name */ + int lstio_bat_server; /* IN: query server + or not */ + int lstio_bat_testidx; /* IN: test index */ + lstcon_test_batch_ent_t *lstio_bat_entp; /* OUT: batch ent */ - int *lstio_bat_idxp; /* IN/OUT: index of node */ - int *lstio_bat_ndentp; /* IN/OUT: # of nodent */ - lstcon_node_ent_t *lstio_bat_dentsp; /* array of nodent */ + int *lstio_bat_idxp; /* IN/OUT: index of node */ + int *lstio_bat_ndentp; /* IN/OUT: # of nodent */ + lstcon_node_ent_t *lstio_bat_dentsp; /* array of nodent */ } lstio_batch_info_args_t; /* add stat in session */ typedef struct { - int lstio_sta_key; /* IN: session key */ - 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 */ - lnet_process_id_t *lstio_sta_idsp; /* IN: pid */ - struct list_head *lstio_sta_resultp; /* OUT: list head of result buffer */ + int lstio_sta_key; /* IN: session key */ + 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 */ + lnet_process_id_t *lstio_sta_idsp; /* IN: pid */ + struct list_head *lstio_sta_resultp; /* OUT: list head of + result buffer */ } lstio_stat_args_t; typedef enum { - LST_TEST_BULK = 1, - LST_TEST_PING = 2 + LST_TEST_BULK = 1, + LST_TEST_PING = 2 } lst_test_type_t; /* create a test in a batch */ -#define LST_MAX_CONCUR 1024 /* Max concurrency of test */ +#define LST_MAX_CONCUR 1024 /* Max concurrency of test */ typedef struct { - int lstio_tes_key; /* IN: session key */ - int lstio_tes_bat_nmlen; /* IN: batch name len */ - char *lstio_tes_bat_name; /* IN: batch name */ - int lstio_tes_type; /* IN: test type */ - int lstio_tes_oneside; /* IN: one sided test */ - int lstio_tes_loop; /* IN: loop count */ - int lstio_tes_concur; /* IN: concurrency */ + int lstio_tes_key; /* IN: session key */ + int lstio_tes_bat_nmlen; /* IN: batch name len */ + char *lstio_tes_bat_name; /* IN: batch name */ + int lstio_tes_type; /* IN: test type */ + int lstio_tes_oneside; /* IN: one sided test */ + int lstio_tes_loop; /* IN: loop count */ + int lstio_tes_concur; /* IN: concurrency */ - int lstio_tes_dist; /* IN: node distribution in destination groups */ - int lstio_tes_span; /* IN: node span in destination groups */ - int lstio_tes_sgrp_nmlen; /* IN: source group name length */ - char *lstio_tes_sgrp_name; /* IN: group name */ - int lstio_tes_dgrp_nmlen; /* IN: destination group name length */ - char *lstio_tes_dgrp_name; /* IN: group name */ + int lstio_tes_dist; /* IN: node distribution in + destination groups */ + int lstio_tes_span; /* IN: node span in + destination groups */ + int lstio_tes_sgrp_nmlen; /* IN: source group + name length */ + char *lstio_tes_sgrp_name; /* IN: group name */ + int lstio_tes_dgrp_nmlen; /* IN: destination group + name length */ + char *lstio_tes_dgrp_name; /* IN: group name */ - int lstio_tes_param_len; /* IN: param buffer len */ - void *lstio_tes_param; /* IN: parameter for specified test: - lstio_bulk_param_t, - lstio_ping_param_t, - ... more */ - int *lstio_tes_retp; /* OUT: private returned value */ - struct list_head *lstio_tes_resultp; /* OUT: list head of result buffer */ + int lstio_tes_param_len; /* IN: param buffer len */ + void *lstio_tes_param; /* IN: parameter for specified + test: + lstio_bulk_param_t, + lstio_ping_param_t, + ... more */ + int *lstio_tes_retp; /* OUT: private returned + value */ + struct list_head *lstio_tes_resultp; /* OUT: list head of + result buffer */ } lstio_test_args_t; typedef enum { - LST_BRW_READ = 1, - LST_BRW_WRITE = 2 + LST_BRW_READ = 1, + LST_BRW_WRITE = 2 } lst_brw_type_t; typedef enum { - LST_BRW_CHECK_NONE = 1, - LST_BRW_CHECK_SIMPLE = 2, - LST_BRW_CHECK_FULL = 3 + LST_BRW_CHECK_NONE = 1, + LST_BRW_CHECK_SIMPLE = 2, + LST_BRW_CHECK_FULL = 3 } lst_brw_flags_t; typedef struct { - int blk_opc; /* bulk operation code */ - int blk_size; /* size (bytes) */ - int blk_time; /* time of running the test*/ - int blk_flags; /* reserved flags */ + int blk_opc; /* bulk operation code */ + int blk_size; /* size (bytes) */ + int blk_time; /* time of running the test*/ + int blk_flags; /* reserved flags */ } lst_test_bulk_param_t; typedef struct { - int png_size; /* size of ping message */ - int png_time; /* time */ - int png_loop; /* loop */ - int png_flags; /* reserved flags */ + int png_size; /* size of ping message */ + int png_time; /* time */ + int png_loop; /* loop */ + int png_flags; /* reserved flags */ } lst_test_ping_param_t; typedef struct { diff --git a/drivers/staging/lustre/include/linux/lnet/socklnd.h b/drivers/staging/lustre/include/linux/lnet/socklnd.h index f7c7b08c2d6b..4c790bd24ee3 100644 --- a/drivers/staging/lustre/include/linux/lnet/socklnd.h +++ b/drivers/staging/lustre/include/linux/lnet/socklnd.h @@ -42,29 +42,29 @@ #define SOCKLND_CONN_NONE (-1) #define SOCKLND_CONN_ANY 0 -#define SOCKLND_CONN_CONTROL 1 -#define SOCKLND_CONN_BULK_IN 2 -#define SOCKLND_CONN_BULK_OUT 3 -#define SOCKLND_CONN_NTYPES 4 +#define SOCKLND_CONN_CONTROL 1 +#define SOCKLND_CONN_BULK_IN 2 +#define SOCKLND_CONN_BULK_OUT 3 +#define SOCKLND_CONN_NTYPES 4 #define SOCKLND_CONN_ACK SOCKLND_CONN_BULK_IN typedef struct { - __u32 kshm_magic; /* magic number of socklnd message */ - __u32 kshm_version; /* version of socklnd message */ - lnet_nid_t kshm_src_nid; /* sender's nid */ - lnet_nid_t kshm_dst_nid; /* destination nid */ - lnet_pid_t kshm_src_pid; /* sender's pid */ - lnet_pid_t kshm_dst_pid; /* destination pid */ - __u64 kshm_src_incarnation; /* sender's incarnation */ - __u64 kshm_dst_incarnation; /* destination's incarnation */ - __u32 kshm_ctype; /* connection type */ - __u32 kshm_nips; /* # IP addrs */ - __u32 kshm_ips[0]; /* IP addrs */ + __u32 kshm_magic; /* magic number of socklnd message */ + __u32 kshm_version; /* version of socklnd message */ + lnet_nid_t kshm_src_nid; /* sender's nid */ + lnet_nid_t kshm_dst_nid; /* destination nid */ + lnet_pid_t kshm_src_pid; /* sender's pid */ + lnet_pid_t kshm_dst_pid; /* destination pid */ + __u64 kshm_src_incarnation; /* sender's incarnation */ + __u64 kshm_dst_incarnation; /* destination's incarnation */ + __u32 kshm_ctype; /* connection type */ + __u32 kshm_nips; /* # IP addrs */ + __u32 kshm_ips[0]; /* IP addrs */ } WIRE_ATTR ksock_hello_msg_t; typedef struct { - lnet_hdr_t ksnm_hdr; /* lnet hdr */ + lnet_hdr_t ksnm_hdr; /* lnet hdr */ /* * ksnm_payload is removed because of winnt compiler's limitation: @@ -75,28 +75,29 @@ typedef struct { } WIRE_ATTR ksock_lnet_msg_t; typedef struct { - __u32 ksm_type; /* type of socklnd message */ - __u32 ksm_csum; /* checksum if != 0 */ - __u64 ksm_zc_cookies[2]; /* Zero-Copy request/ACK cookie */ + __u32 ksm_type; /* type of socklnd message */ + __u32 ksm_csum; /* checksum if != 0 */ + __u64 ksm_zc_cookies[2]; /* Zero-Copy request/ACK cookie */ union { - ksock_lnet_msg_t lnetmsg; /* lnet message, it's empty if it's NOOP */ + ksock_lnet_msg_t lnetmsg;/* lnet message, it's empty if + * it's NOOP */ } WIRE_ATTR ksm_u; } WIRE_ATTR ksock_msg_t; static inline void socklnd_init_msg(ksock_msg_t *msg, int type) { - msg->ksm_csum = 0; - msg->ksm_type = type; - msg->ksm_zc_cookies[0] = msg->ksm_zc_cookies[1] = 0; + msg->ksm_csum = 0; + msg->ksm_type = type; + msg->ksm_zc_cookies[0] = msg->ksm_zc_cookies[1] = 0; } -#define KSOCK_MSG_NOOP 0xc0 /* ksm_u empty */ -#define KSOCK_MSG_LNET 0xc1 /* lnet msg */ +#define KSOCK_MSG_NOOP 0xC0 /* ksm_u empty */ +#define KSOCK_MSG_LNET 0xC1 /* lnet msg */ /* We need to know this number to parse hello msg from ksocklnd in * other LND (usocklnd, for example) */ -#define KSOCK_PROTO_V2 2 -#define KSOCK_PROTO_V3 3 +#define KSOCK_PROTO_V2 2 +#define KSOCK_PROTO_V3 3 #endif diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index 32b9431b49d9..06d73c00c56e 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -48,7 +48,7 @@ /** Portal reserved for LNet's own use. * \see lustre/include/lustre/lustre_idl.h for Lustre portal assignments. */ -#define LNET_RESERVED_PORTAL 0 +#define LNET_RESERVED_PORTAL 0 /** * Address of an end-point in an LNet network. @@ -68,15 +68,15 @@ typedef __u64 lnet_nid_t; typedef __u32 lnet_pid_t; /** wildcard NID that matches any end-point address */ -#define LNET_NID_ANY ((lnet_nid_t) -1) +#define LNET_NID_ANY ((lnet_nid_t) -1) /** wildcard PID that matches any lnet_pid_t */ -#define LNET_PID_ANY ((lnet_pid_t) -1) +#define LNET_PID_ANY ((lnet_pid_t) -1) #define LNET_PID_RESERVED 0xf0000000 /* reserved bits in PID */ #define LNET_PID_USERFLAG 0x80000000 /* set in userspace peers */ #define LNET_PID_LUSTRE 12345 -#define LNET_TIME_FOREVER (-1) +#define LNET_TIME_FOREVER (-1) /* how an LNET NID encodes net:address */ /** extract the address part of an lnet_nid_t */ @@ -380,8 +380,8 @@ typedef struct { * one must start on page boundary, and all but the last must end on * page boundary. */ - void *start; - unsigned int length; + void *start; + unsigned int length; /** * Specifies the maximum number of operations that can be performed * on the memory descriptor. An operation is any action that could @@ -392,7 +392,7 @@ typedef struct { * there is no bound on the number of operations that may be applied * to a MD. */ - int threshold; + int threshold; /** * Specifies the largest incoming request that the memory descriptor * should respond to. When the unused portion of a MD (length - @@ -400,7 +400,7 @@ typedef struct { * does not respond to further operations. This value is only used * if the LNET_MD_MAX_SIZE option is set. */ - int max_size; + int max_size; /** * Specifies the behavior of the memory descriptor. A bitwise OR * of the following values can be used: @@ -437,14 +437,14 @@ typedef struct { * region (i.e. sum of all fragment lengths) must not be less than * \a max_size. */ - unsigned int options; + unsigned int options; /** * A user-specified value that is associated with the memory * descriptor. The value does not need to be a pointer, but must fit * in the space used by a pointer. This value is recorded in events * associated with operations on this MD. */ - void *user_ptr; + void *user_ptr; /** * A handle for the event queue used to log the operations performed on * the memory region. If this argument is a NULL handle (i.e. nullified @@ -461,33 +461,33 @@ typedef struct { #define LNET_MTU (1 << LNET_MTU_BITS) /** limit on the number of fragments in discontiguous MDs */ -#define LNET_MAX_IOV 256 +#define LNET_MAX_IOV 256 /** * Options for the MD structure. See lnet_md_t::options. */ -#define LNET_MD_OP_PUT (1 << 0) +#define LNET_MD_OP_PUT (1 << 0) /** See lnet_md_t::options. */ -#define LNET_MD_OP_GET (1 << 1) +#define LNET_MD_OP_GET (1 << 1) /** See lnet_md_t::options. */ #define LNET_MD_MANAGE_REMOTE (1 << 2) -/* unused (1 << 3) */ +/* unused (1 << 3) */ /** See lnet_md_t::options. */ -#define LNET_MD_TRUNCATE (1 << 4) +#define LNET_MD_TRUNCATE (1 << 4) /** See lnet_md_t::options. */ -#define LNET_MD_ACK_DISABLE (1 << 5) +#define LNET_MD_ACK_DISABLE (1 << 5) /** See lnet_md_t::options. */ #define LNET_MD_IOVEC (1 << 6) /** See lnet_md_t::options. */ -#define LNET_MD_MAX_SIZE (1 << 7) +#define LNET_MD_MAX_SIZE (1 << 7) /** See lnet_md_t::options. */ -#define LNET_MD_KIOV (1 << 8) +#define LNET_MD_KIOV (1 << 8) /* For compatibility with Cray Portals */ -#define LNET_MD_PHYS 0 +#define LNET_MD_PHYS 0 /** Infinite threshold on MD operations. See lnet_md_t::threshold */ -#define LNET_MD_THRESH_INF (-1) +#define LNET_MD_THRESH_INF (-1) /* NB lustre portals uses struct iovec internally! */ typedef struct iovec lnet_md_iovec_t; @@ -497,15 +497,15 @@ typedef struct iovec lnet_md_iovec_t; */ typedef struct { /** Pointer to the page where the fragment resides */ - struct page *kiov_page; + struct page *kiov_page; /** Length in bytes of the fragment */ - unsigned int kiov_len; + unsigned int kiov_len; /** * Starting offset of the fragment within the page. Note that the * end of the fragment must not pass the end of the page; i.e., * kiov_len + kiov_offset <= PAGE_CACHE_SIZE. */ - unsigned int kiov_offset; + unsigned int kiov_offset; } lnet_kiov_t; /** @} lnet_md */ @@ -553,7 +553,7 @@ typedef enum { LNET_EVENT_UNLINK, } lnet_event_kind_t; -#define LNET_SEQ_BASETYPE long +#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) @@ -562,23 +562,23 @@ typedef unsigned LNET_SEQ_BASETYPE lnet_seq_t; */ typedef struct { /** The identifier (nid, pid) of the target. */ - lnet_process_id_t target; + lnet_process_id_t target; /** The identifier (nid, pid) of the initiator. */ - lnet_process_id_t initiator; + lnet_process_id_t initiator; /** * The NID of the immediate sender. If the request has been forwarded * by routers, this is the NID of the last hop; otherwise it's the * same as the initiator. */ - lnet_nid_t sender; + lnet_nid_t sender; /** Indicates the type of the event. */ - lnet_event_kind_t type; + lnet_event_kind_t type; /** The portal table index specified in the request */ - unsigned int pt_index; + unsigned int pt_index; /** A copy of the match bits specified in the request. */ - __u64 match_bits; + __u64 match_bits; /** The length (in bytes) specified in the request. */ - unsigned int rlength; + unsigned int rlength; /** * The length (in bytes) of the data that was manipulated by the * operation. For truncated operations, the manipulated length will be @@ -586,47 +586,47 @@ typedef struct { * see lnet_md_t). For all other operations, the manipulated length * will be the length of the requested operation, i.e. rlength. */ - unsigned int mlength; + unsigned int mlength; /** * The handle to the MD associated with the event. The handle may be * invalid if the MD has been unlinked. */ - lnet_handle_md_t md_handle; + lnet_handle_md_t md_handle; /** * A snapshot of the state of the MD immediately after the event has * been processed. In particular, the threshold field in md will * reflect the value of the threshold after the operation occurred. */ - lnet_md_t md; + lnet_md_t md; /** * 64 bits of out-of-band user data. Only valid for LNET_EVENT_PUT. * \see LNetPut */ - __u64 hdr_data; + __u64 hdr_data; /** * Indicates the completion status of the operation. It's 0 for * successful operations, otherwise it's an error code. */ - int status; + int status; /** * Indicates whether the MD has been unlinked. Note that: * - An event with unlinked set is the last event on the MD. * - This field is also set for an explicit LNET_EVENT_UNLINK event. * \see LNetMDUnlink */ - int unlinked; + int unlinked; /** * The displacement (in bytes) into the memory region that the * operation used. The offset can be determined by the operation for * a remote managed MD or by the local MD. * \see lnet_md_t::options */ - unsigned int offset; + unsigned int offset; /** * The sequence number for this event. Sequence numbers are unique * to each event. */ - volatile lnet_seq_t sequence; + volatile lnet_seq_t sequence; } lnet_event_t; /** From 4f3ca89351e62f72144ca592c1c482e529d31539 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Thu, 11 Jun 2015 15:18:15 -0400 Subject: [PATCH 0939/1163] staging:lustre: Update license and copyright for the LNET headers Point to the right place for GNU license. Update Intel copyright. Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/lnet/api.h | 13 +++++-------- .../staging/lustre/include/linux/lnet/lib-lnet.h | 10 +++------- .../staging/lustre/include/linux/lnet/lib-types.h | 13 +++---------- drivers/staging/lustre/include/linux/lnet/lnet.h | 10 ++++------ drivers/staging/lustre/include/linux/lnet/lnetst.h | 12 ++++-------- drivers/staging/lustre/include/linux/lnet/nidstr.h | 3 ++- drivers/staging/lustre/include/linux/lnet/socklnd.h | 12 ++++-------- drivers/staging/lustre/include/linux/lnet/types.h | 10 +++------- 8 files changed, 28 insertions(+), 55 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/api.h b/drivers/staging/lustre/include/linux/lnet/api.h index 2eb0a055784e..9493d5e236c5 100644 --- a/drivers/staging/lustre/include/linux/lnet/api.h +++ b/drivers/staging/lustre/include/linux/lnet/api.h @@ -15,21 +15,19 @@ * * 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. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ /* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2011 - 2015, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. + * Lustre is a trademark of Seagate, Inc. */ #ifndef __LNET_API_H__ @@ -41,9 +39,8 @@ * * LNet is an asynchronous message-passing API, which provides an unreliable * connectionless service that can't guarantee any order. It supports OFA IB, - * TCP/IP, and Cray Portals, and routes between heterogeneous networks. + * TCP/IP, and Cray Interconnects, and routes between heterogeneous networks. * - * LNet can run both in OS kernel space and in userspace as a library. * @{ */ diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 0dbab6fed91d..a9c9a077c77d 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -15,11 +15,7 @@ * * 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. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ @@ -27,11 +23,11 @@ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2012, Intel Corporation. + * Copyright (c) 2012 - 2015, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. + * Lustre is a trademark of Seagate, Inc. * * lnet/include/lnet/lib-lnet.h */ diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index fa949d8b1870..81a63dbdea25 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -15,11 +15,7 @@ * * 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. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ @@ -27,16 +23,13 @@ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2012, Intel Corporation. + * Copyright (c) 2012 - 2015, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. + * Lustre is a trademark of Seagate, Inc. * * lnet/include/lnet/lib-types.h - * - * Types used by the library side routines that do not need to be - * exposed to the user application */ #ifndef __LNET_LIB_TYPES_H__ diff --git a/drivers/staging/lustre/include/linux/lnet/lnet.h b/drivers/staging/lustre/include/linux/lnet/lnet.h index 8124d8f64dce..5d1559a26638 100644 --- a/drivers/staging/lustre/include/linux/lnet/lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lnet.h @@ -15,21 +15,19 @@ * * 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. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ /* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2012 - 2015, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. + * Lustre is a trademark of Seagate, Inc. */ #ifndef __LNET_H__ diff --git a/drivers/staging/lustre/include/linux/lnet/lnetst.h b/drivers/staging/lustre/include/linux/lnet/lnetst.h index ea1e0c602afb..fd1e0fd3696f 100644 --- a/drivers/staging/lustre/include/linux/lnet/lnetst.h +++ b/drivers/staging/lustre/include/linux/lnet/lnetst.h @@ -15,11 +15,7 @@ * * 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. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ @@ -27,15 +23,15 @@ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011, Intel Corporation. + * Copyright (c) 2011 - 2015, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. + * Lustre is a trademark of Seagate, Inc. * * lnet/include/lnet/lnetst.h * - * Author: Liang Zhen + * Author: Liang Zhen */ #ifndef __LNET_ST_H__ diff --git a/drivers/staging/lustre/include/linux/lnet/nidstr.h b/drivers/staging/lustre/include/linux/lnet/nidstr.h index 8eaed1aa11f1..a627be9fcdd0 100644 --- a/drivers/staging/lustre/include/linux/lnet/nidstr.h +++ b/drivers/staging/lustre/include/linux/lnet/nidstr.h @@ -23,10 +23,11 @@ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011, 2014, Intel Corporation. + * Copyright (c) 2011 - 2015, Intel Corporation. */ #ifndef _LNET_NIDSTRINGS_H #define _LNET_NIDSTRINGS_H + #include "types.h" /** diff --git a/drivers/staging/lustre/include/linux/lnet/socklnd.h b/drivers/staging/lustre/include/linux/lnet/socklnd.h index 4c790bd24ee3..599c9f6628fb 100644 --- a/drivers/staging/lustre/include/linux/lnet/socklnd.h +++ b/drivers/staging/lustre/include/linux/lnet/socklnd.h @@ -15,25 +15,21 @@ * * 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. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ /* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2012 - 2015, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. + * Lustre is a trademark of Seagate, Inc. * * lnet/include/lnet/socklnd.h - * - * #defines shared between socknal implementation and utilities */ #ifndef __LNET_LNET_SOCKLND_H__ #define __LNET_LNET_SOCKLND_H__ diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index 06d73c00c56e..940f73f266d1 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -15,11 +15,7 @@ * * 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. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ @@ -27,11 +23,11 @@ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2012, Intel Corporation. + * Copyright (c) 2012 - 2015, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. + * Lustre is a trademark of Seagate, Inc. */ #ifndef __LNET_TYPES_H__ From b08ad6657aacf9b5d7c4b22de2ba891b152d0528 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 12 Jun 2015 16:37:41 +0100 Subject: [PATCH 0940/1163] staging: comedi: cb_pcimdas: fix handlers for DI and DO subdevices Normally, low-level Comedi drivers set an `insn_bits` handler for digital input (DI), digital output (DO) and digital input/output (DIO) subdevice types to handle normal reading and writing of digital channels. The "cb_pcimdas" driver currently has an `insn_read` handler for the DI subdevice and an `insn_write` handler for the DO subdevice. However, the actual handler functions `cb_pcimdas_di_insn_read()` and `cb_pcimdas_do_insn_write()` are written to behave like `insn_bits` handlers. Something's wrong there! To fix it, set the functions as `insn_bits` handlers and rename them for consistency. Fixes: e56d03dee14a ("staging: comedi: cb_pcimdas: add main connector digital input/output") Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcimdas.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c index c458e5010a74..4ebf5aae5019 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdas.c +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c @@ -243,7 +243,7 @@ static int cb_pcimdas_ao_insn_write(struct comedi_device *dev, return insn->n; } -static int cb_pcimdas_di_insn_read(struct comedi_device *dev, +static int cb_pcimdas_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -258,7 +258,7 @@ static int cb_pcimdas_di_insn_read(struct comedi_device *dev, return insn->n; } -static int cb_pcimdas_do_insn_write(struct comedi_device *dev, +static int cb_pcimdas_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -424,7 +424,7 @@ static int cb_pcimdas_auto_attach(struct comedi_device *dev, s->n_chan = 4; s->maxdata = 1; s->range_table = &range_digital; - s->insn_read = cb_pcimdas_di_insn_read; + s->insn_bits = cb_pcimdas_di_insn_bits; /* Digital Output subdevice (main connector) */ s = &dev->subdevices[4]; @@ -433,7 +433,7 @@ static int cb_pcimdas_auto_attach(struct comedi_device *dev, s->n_chan = 4; s->maxdata = 1; s->range_table = &range_digital; - s->insn_write = cb_pcimdas_do_insn_write; + s->insn_bits = cb_pcimdas_do_insn_bits; /* Counter subdevice (8254) */ s = &dev->subdevices[5]; From 71f0d052cc3666546d96ea17ccd4770d4137de32 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:04 +0100 Subject: [PATCH 0941/1163] staging: comedi: das08.h: reformat copyright comment Reformat the copyright comment at the top of the file to use the preferred block comment style. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.h | 32 +++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.h b/drivers/staging/comedi/drivers/das08.h index f86167da5895..57c76401b800 100644 --- a/drivers/staging/comedi/drivers/das08.h +++ b/drivers/staging/comedi/drivers/das08.h @@ -1,20 +1,20 @@ /* - das08.h - - Header for das08.c and das08_cs.c - - Copyright (C) 2003 Frank Mori Hess - - 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. -*/ + * das08.h + * + * Header for das08.c and das08_cs.c + * + * Copyright (C) 2003 Frank Mori Hess + * + * 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. + */ #ifndef _DAS08_H #define _DAS08_H From 884f01c9496c906bbb645abd3de953828b18ffa8 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:05 +0100 Subject: [PATCH 0942/1163] staging: comedi: das08.h: change description in copyright header comment The copyright header comment includes a single-line description saying it is for "das08.c" and "das08_cs.c". However, it is also used by "das08_isa.c" and "das08_pci.c". Update the description to say it is for common DAS08 support, similar to description in "das08.c" (the common module for the DAS08 ISA/PCI/PCMCIA drivers). Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das08.h b/drivers/staging/comedi/drivers/das08.h index 57c76401b800..388855eb9424 100644 --- a/drivers/staging/comedi/drivers/das08.h +++ b/drivers/staging/comedi/drivers/das08.h @@ -1,7 +1,7 @@ /* * das08.h * - * Header for das08.c and das08_cs.c + * Header for common DAS08 support (used by ISA/PCI/PCMCIA drivers) * * Copyright (C) 2003 Frank Mori Hess * From d4d794330dd02397f8a34a4db67738f741302df2 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:06 +0100 Subject: [PATCH 0943/1163] staging: comedi: das08.h: reformat remaining comments Reformat remaining comments to use the preferred style for single-line and block comments. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.h b/drivers/staging/comedi/drivers/das08.h index 388855eb9424..b904b5e5020b 100644 --- a/drivers/staging/comedi/drivers/das08.h +++ b/drivers/staging/comedi/drivers/das08.h @@ -36,13 +36,12 @@ struct das08_board_struct { unsigned int do_nchan; unsigned int i8255_offset; unsigned int i8254_offset; - unsigned int iosize; /* number of ioports used */ + unsigned int iosize; /* number of ioports used */ }; struct das08_private_struct { - unsigned int do_mux_bits; /* bits for do/mux register on boards - * without separate do register - */ + /* bits for do/mux register on boards without separate do register */ + unsigned int do_mux_bits; const unsigned int *pg_gainlist; }; From fba5963c9259252747f79f778805ca7b368d9000 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:07 +0100 Subject: [PATCH 0944/1163] staging: comedi: das08: use indexed initializer for AI range table types The "das08" common module for DAS08 ISA, PCI, and PCMCIA drivers includes a predefined set of AI range tables. The static board data (of type `struct das08_board_struct`) for a particular board contains an index in its `ai_pg` member (of type `enum das08_lrange`) indicating which of the predefined AI range tables to use. The "das08" common module looks up this index in `das08_ai_lranges[]` to get a pointer to the predefined range table for the board. The same index is also looked up in `das08_gainlists[]` to get a corresponding pointer to a list of hardware gain values for each range supported by the board (NULL for boards without programmable gain). To make this clearer, used indexed initializers for `das08_ai_lranges[]` and `das08_gainlists[]`, using the enumerated constants from `enum das08_lrange` as the indices. Also add a short comment to the definition of `enum das08_lrange`. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 20 ++++++++++---------- drivers/staging/comedi/drivers/das08.h | 5 +++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 73f4c8dbbde3..b1cd6eaacf61 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -165,11 +165,11 @@ static const struct comedi_lrange range_das08_pgm = { */ static const struct comedi_lrange *const das08_ai_lranges[] = { - &range_unknown, - &range_bipolar5, - &range_das08_pgh, - &range_das08_pgl, - &range_das08_pgm, + [das08_pg_none] = &range_unknown, + [das08_bipolar5] = &range_bipolar5, + [das08_pgh] = &range_das08_pgh, + [das08_pgl] = &range_das08_pgl, + [das08_pgm] = &range_das08_pgm, }; static const int das08_pgh_gainlist[] = { @@ -179,11 +179,11 @@ static const int das08_pgl_gainlist[] = { 8, 0, 2, 4, 6, 1, 3, 5, 7 }; static const int das08_pgm_gainlist[] = { 8, 0, 10, 12, 14, 9, 11, 13, 15 }; static const int *const das08_gainlists[] = { - NULL, - NULL, - das08_pgh_gainlist, - das08_pgl_gainlist, - das08_pgm_gainlist, + [das08_pg_none] = NULL, + [das08_bipolar5] = NULL, + [das08_pgh] = das08_pgh_gainlist, + [das08_pgl] = das08_pgl_gainlist, + [das08_pgm] = das08_pgm_gainlist, }; static int das08_ai_eoc(struct comedi_device *dev, diff --git a/drivers/staging/comedi/drivers/das08.h b/drivers/staging/comedi/drivers/das08.h index b904b5e5020b..8b1c1a958858 100644 --- a/drivers/staging/comedi/drivers/das08.h +++ b/drivers/staging/comedi/drivers/das08.h @@ -21,8 +21,9 @@ /* different ways ai data is encoded in first two registers */ enum das08_ai_encoding { das08_encode12, das08_encode16, das08_pcm_encode12 }; -enum das08_lrange { das08_pg_none, das08_bipolar5, das08_pgh, das08_pgl, - das08_pgm +/* types of ai range table used by different boards */ +enum das08_lrange { + das08_pg_none, das08_bipolar5, das08_pgh, das08_pgl, das08_pgm }; struct das08_board_struct { From 2b56b35820eee978c9f4bee7e40e18ddb3d9bc26 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:08 +0100 Subject: [PATCH 0945/1163] staging: comedi: das08: improve test for programmable gain `das08_ai_rinsn()` handles Comedi `INSN_READ` instructions for the AI subdevice. This programs the gain for the analog input channel if the board has support for that, and acquires data from the channel. If programmable gain is supported, the gain code is read from the array pointed to by `devpriv->pg_gainlist` indexed by the range index. The function assumes that programmable gain is supported if the AI subdevice's range table supports more than one range. Replace that with a more direct test for `devpriv->pg_gainlist` being non-NULL, as it is only initialized to a non-NULL pointer for boards that support programmable gain. This will also allow range tables to be included for convenience for those boards that support multiple ranges by DIP switches. Those boards are currently initialized to use a single "unknown" range. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index b1cd6eaacf61..25213520e965 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -225,7 +225,7 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL); spin_unlock(&dev->spinlock); - if (s->range_table->length > 1) { + if (devpriv->pg_gainlist) { /* set gain/range */ range = CR_RANGE(insn->chanspec); outb(devpriv->pg_gainlist[range], From 3c7cab30f4c4364f72ccd7a034cf81fba7700525 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:09 +0100 Subject: [PATCH 0946/1163] staging: comedi: das08.h: make self-reliant The Comedi "das08.h" header file is included by drivers for the ComputerBoards/MeasurementComputing and Keithley Metrabyte boards in the DAS08 series. It does not compile cleanly when it is the first header included by the ".c" file. It uses `struct comedi_device *` in the parameter list of a function prototype, so just declare `struct comedi_device` as an incomplete type. It also uses `bool`, so include to declare it. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/comedi/drivers/das08.h b/drivers/staging/comedi/drivers/das08.h index 8b1c1a958858..d27044cb7158 100644 --- a/drivers/staging/comedi/drivers/das08.h +++ b/drivers/staging/comedi/drivers/das08.h @@ -19,6 +19,10 @@ #ifndef _DAS08_H #define _DAS08_H +#include + +struct comedi_device; + /* different ways ai data is encoded in first two registers */ enum das08_ai_encoding { das08_encode12, das08_encode16, das08_pcm_encode12 }; /* types of ai range table used by different boards */ From 5826d99aedda2442f89194cd3b85bc69970c175c Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:10 +0100 Subject: [PATCH 0947/1163] staging: comedi: das08: rename DAS08_LSB and DAS08_MSB The `DAS08_LSB` and `DAS08_MSB` macros contain the offsets to the least-significant and most-significant analog input data registers. Rename them to `DAS08_AI_LSB_REG` and `DAS08_AI_MSB_REG` respectively and add comments to document them. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 25213520e965..1d9e6a679327 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -42,8 +42,20 @@ */ -#define DAS08_LSB 0 -#define DAS08_MSB 1 +/* + * Data format of DAS08_AI_LSB_REG and DAS08_AI_MSB_REG depends on + * 'ai_encoding' member of board structure: + * + * das08_encode12 : DATA[11..4] = MSB[7..0], DATA[3..0] = LSB[7..4]. + * das08_pcm_encode12 : DATA[11..8] = MSB[3..0], DATA[7..9] = LSB[7..0]. + * das08_encode16 : SIGN = MSB[7], MAGNITUDE[14..8] = MSB[6..0], + * MAGNITUDE[7..0] = LSB[7..0]. + * SIGN==0 for negative input, SIGN==1 for positive input. + * Note: when read a second time after conversion + * complete, MSB[7] is an "over-range" bit. + */ +#define DAS08_AI_LSB_REG 0x00 /* (R) AI least significant bits */ +#define DAS08_AI_MSB_REG 0x01 /* (R) AI most significant bits */ #define DAS08_TRIG_12BIT 1 #define DAS08_STATUS 2 #define DAS08_EOC (1<<7) @@ -214,8 +226,8 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, range = CR_RANGE(insn->chanspec); /* clear crap */ - inb(dev->iobase + DAS08_LSB); - inb(dev->iobase + DAS08_MSB); + inb(dev->iobase + DAS08_AI_LSB_REG); + inb(dev->iobase + DAS08_AI_MSB_REG); /* set multiplexer */ /* lock to prevent race with digital output */ @@ -235,7 +247,7 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, for (n = 0; n < insn->n; n++) { /* clear over-range bits for 16-bit boards */ if (thisboard->ai_nbits == 16) - if (inb(dev->iobase + DAS08_MSB) & 0x80) + if (inb(dev->iobase + DAS08_AI_MSB_REG) & 0x80) dev_info(dev->class_dev, "over-range\n"); /* trigger conversion */ @@ -245,8 +257,8 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, if (ret) return ret; - msb = inb(dev->iobase + DAS08_MSB); - lsb = inb(dev->iobase + DAS08_LSB); + msb = inb(dev->iobase + DAS08_AI_MSB_REG); + lsb = inb(dev->iobase + DAS08_AI_LSB_REG); if (thisboard->ai_encoding == das08_encode12) { data[n] = (lsb >> 4) | (msb << 4); } else if (thisboard->ai_encoding == das08_pcm_encode12) { From c2ba9e96376dbfdbdff27ff99a602691b265b0c9 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:11 +0100 Subject: [PATCH 0948/1163] staging: comedi: das08: rename DAS08_TRIG_12BIT The `DAS08_TRIG_12BIT` macro contains the offset to the write-only software trigger register for 12-bit or 16-bit analog-to-digital conversions. Rename the macro to `DAS08_AI_TRIG_REG` and add a comment. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 1d9e6a679327..fa14fa105b00 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -56,7 +56,7 @@ */ #define DAS08_AI_LSB_REG 0x00 /* (R) AI least significant bits */ #define DAS08_AI_MSB_REG 0x01 /* (R) AI most significant bits */ -#define DAS08_TRIG_12BIT 1 +#define DAS08_AI_TRIG_REG 0x01 /* (W) AI software trigger */ #define DAS08_STATUS 2 #define DAS08_EOC (1<<7) #define DAS08_IRQ (1<<3) @@ -251,7 +251,7 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, dev_info(dev->class_dev, "over-range\n"); /* trigger conversion */ - outb_p(0, dev->iobase + DAS08_TRIG_12BIT); + outb_p(0, dev->iobase + DAS08_AI_TRIG_REG); ret = comedi_timeout(dev, s, insn, das08_ai_eoc, 0); if (ret) From b00b3f769abe1dd19cc51552734c44178cb1269d Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:12 +0100 Subject: [PATCH 0949/1163] staging: comedi: das08: rename DAS08_STATUS The `DAS08_STATUS` macro contains the offset to the read-only status register. Rename it to `DAS08_STATUS_REG` and add a comment. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index fa14fa105b00..eecbf4d95942 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -57,7 +57,7 @@ #define DAS08_AI_LSB_REG 0x00 /* (R) AI least significant bits */ #define DAS08_AI_MSB_REG 0x01 /* (R) AI most significant bits */ #define DAS08_AI_TRIG_REG 0x01 /* (W) AI software trigger */ -#define DAS08_STATUS 2 +#define DAS08_STATUS_REG 0x02 /* (R) status */ #define DAS08_EOC (1<<7) #define DAS08_IRQ (1<<3) #define DAS08_IP(x) (((x)>>4)&0x7) @@ -205,7 +205,7 @@ static int das08_ai_eoc(struct comedi_device *dev, { unsigned int status; - status = inb(dev->iobase + DAS08_STATUS); + status = inb(dev->iobase + DAS08_STATUS_REG); if ((status & DAS08_EOC) == 0) return 0; return -EBUSY; @@ -282,7 +282,7 @@ static int das08_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { data[0] = 0; - data[1] = DAS08_IP(inb(dev->iobase + DAS08_STATUS)); + data[1] = DAS08_IP(inb(dev->iobase + DAS08_STATUS_REG)); return insn->n; } From 851e5d5475de796560683e2a4b28af0a7da177e1 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:13 +0100 Subject: [PATCH 0950/1163] staging: comedi: das08: rename and rewrite DAS08_EOC The `DAS08_EOC` macro contains a mask for the "end of A/D conversion" bit in the status register. The logic is reverse sense in that the bit is set to 1 while the conversion is in progress and set to 0 when the conversion is complete. Rename the macro to `DAS08_STATUS_AI_BUSY` and add a comment. Also make use of the `BIT()` macro to define the value. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index eecbf4d95942..04843080b5e8 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -58,7 +58,7 @@ #define DAS08_AI_MSB_REG 0x01 /* (R) AI most significant bits */ #define DAS08_AI_TRIG_REG 0x01 /* (W) AI software trigger */ #define DAS08_STATUS_REG 0x02 /* (R) status */ -#define DAS08_EOC (1<<7) +#define DAS08_STATUS_AI_BUSY BIT(7) /* AI conversion in progress */ #define DAS08_IRQ (1<<3) #define DAS08_IP(x) (((x)>>4)&0x7) #define DAS08_CONTROL 2 @@ -206,7 +206,7 @@ static int das08_ai_eoc(struct comedi_device *dev, unsigned int status; status = inb(dev->iobase + DAS08_STATUS_REG); - if ((status & DAS08_EOC) == 0) + if ((status & DAS08_STATUS_AI_BUSY) == 0) return 0; return -EBUSY; } From 2398391017ddec9427bdb94cc5d70326eaf8a3c5 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:14 +0100 Subject: [PATCH 0951/1163] staging: comedi: das08: rename and rewrite DAS08_IRQ The `DAS08_IRQ` macro contains a mask for the "IRQ" status bit. This is set to 1 when a rising edge is detected on the external interrupt input pin of the external connector (which may be jumpered to a pacer output). It is cleared by setting the "INTE" control bit to 0. It is not used on "JR" boards. Rename the macro to `DAS08_STATUS_IRQ` and add a comment. Also use the `BIT()` macro to define the value. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 04843080b5e8..935bbfb213e6 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -59,7 +59,12 @@ #define DAS08_AI_TRIG_REG 0x01 /* (W) AI software trigger */ #define DAS08_STATUS_REG 0x02 /* (R) status */ #define DAS08_STATUS_AI_BUSY BIT(7) /* AI conversion in progress */ -#define DAS08_IRQ (1<<3) +/* + * The IRQ status bit is set to 1 by a rising edge on the external interrupt + * input (which may be jumpered to the pacer output). It is cleared by + * setting the INTE control bit to 0. Not present on "JR" boards. + */ +#define DAS08_STATUS_IRQ BIT(3) /* latched interrupt input */ #define DAS08_IP(x) (((x)>>4)&0x7) #define DAS08_CONTROL 2 #define DAS08_MUX_MASK 0x7 From 4d14ac8a900961b44173a5dff38e138ecda8e4c7 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:15 +0100 Subject: [PATCH 0952/1163] staging: comedi: das08: rename and rewrite DAS08_IP The `DAS08_IP()` macro takes a value read from the status register and returns the state of the three digital input channels (except on "JR" boards). Rename it to `DAS08_STATUS_DI()` and add a comment. Also re-arrange the expression used to extract the state of the digital inputs for consistency with other register macros. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 935bbfb213e6..eef0456fdc70 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -65,7 +65,8 @@ * setting the INTE control bit to 0. Not present on "JR" boards. */ #define DAS08_STATUS_IRQ BIT(3) /* latched interrupt input */ -#define DAS08_IP(x) (((x)>>4)&0x7) +/* digital inputs (not "JR" boards) */ +#define DAS08_STATUS_DI(x) (((x) & 0x70) >> 4) #define DAS08_CONTROL 2 #define DAS08_MUX_MASK 0x7 #define DAS08_MUX(x) ((x) & DAS08_MUX_MASK) @@ -287,7 +288,7 @@ static int das08_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { data[0] = 0; - data[1] = DAS08_IP(inb(dev->iobase + DAS08_STATUS_REG)); + data[1] = DAS08_STATUS_DI(inb(dev->iobase + DAS08_STATUS_REG)); return insn->n; } From c800e51310ad7204260100b978800e2b9828af3d Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:16 +0100 Subject: [PATCH 0953/1163] staging: comedi: das08: rename DAS08_CONTROL The `DAS08_CONTROL` macro contains the offset to the write-only control register. Rename it to `DAS08_CONTROL_REG` and add a comment. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index eef0456fdc70..b43bc2d6ff5f 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -67,7 +67,7 @@ #define DAS08_STATUS_IRQ BIT(3) /* latched interrupt input */ /* digital inputs (not "JR" boards) */ #define DAS08_STATUS_DI(x) (((x) & 0x70) >> 4) -#define DAS08_CONTROL 2 +#define DAS08_CONTROL_REG 0x02 /* (W) control */ #define DAS08_MUX_MASK 0x7 #define DAS08_MUX(x) ((x) & DAS08_MUX_MASK) #define DAS08_INTE (1<<3) @@ -240,7 +240,7 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, spin_lock(&dev->spinlock); devpriv->do_mux_bits &= ~DAS08_MUX_MASK; devpriv->do_mux_bits |= DAS08_MUX(chan); - outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL); + outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL_REG); spin_unlock(&dev->spinlock); if (devpriv->pg_gainlist) { @@ -305,7 +305,7 @@ static int das08_do_wbits(struct comedi_device *dev, spin_lock(&dev->spinlock); devpriv->do_mux_bits &= ~DAS08_DO_MASK; devpriv->do_mux_bits |= DAS08_OP(s->state); - outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL); + outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL_REG); spin_unlock(&dev->spinlock); } From ac81df6097bb30c61bc8e7e3ce8100adcee14b66 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:17 +0100 Subject: [PATCH 0954/1163] staging: comedi: das08: rename DAS08_MUX() and DAS08_MUX_MASK The `DAS08_MUX_MASK` macro is a bitmask for the control register corresponding to the analog input multiplexor channel selection bits. Rename it to `DAS08_CONTROL_MUX_MASK` and add a comment. Note that the current setting of the multiplexor can also be read from the same bit positions in the status register, but the driver does not use it. Add a comment to that effect. The `DAS08_MUX(x)` macro takes an analog input channel number and returns the corresponding analog input multiplexor channel selection bits for the control register. Rename it to `DAS08_CONTROL_MUX(x)` and add a comment. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index b43bc2d6ff5f..f0ee617028db 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -68,8 +68,12 @@ /* digital inputs (not "JR" boards) */ #define DAS08_STATUS_DI(x) (((x) & 0x70) >> 4) #define DAS08_CONTROL_REG 0x02 /* (W) control */ -#define DAS08_MUX_MASK 0x7 -#define DAS08_MUX(x) ((x) & DAS08_MUX_MASK) +/* + * Note: The AI multiplexor channel can also be read from status register using + * the same mask. + */ +#define DAS08_CONTROL_MUX_MASK 0x7 /* multiplexor channel mask */ +#define DAS08_CONTROL_MUX(x) ((x) & DAS08_CONTROL_MUX_MASK) /* mux channel */ #define DAS08_INTE (1<<3) #define DAS08_DO_MASK 0xf0 #define DAS08_OP(x) (((x) << 4) & DAS08_DO_MASK) @@ -238,8 +242,8 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, /* set multiplexer */ /* lock to prevent race with digital output */ spin_lock(&dev->spinlock); - devpriv->do_mux_bits &= ~DAS08_MUX_MASK; - devpriv->do_mux_bits |= DAS08_MUX(chan); + devpriv->do_mux_bits &= ~DAS08_CONTROL_MUX_MASK; + devpriv->do_mux_bits |= DAS08_CONTROL_MUX(chan); outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL_REG); spin_unlock(&dev->spinlock); From 6a3a22bcada2209520180c8bf0045e4e241003af Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:18 +0100 Subject: [PATCH 0955/1163] staging: comedi: das08: rename and rewrite DAS08_INTE The `DAS08_INTE` macro contains a mask for the "INTE" bit in the control register (except on "JR" boards). Setting it to 1 enables interrupts. Setting it to 0 disables interrupts and clears the "IRQ" bit in the status register. Rename the macro to `DAS08_CONTROL_INTE` and add a comment. Also use the `BIT()` macro to define its value. (Note: the driver does not currently enable interrupts.) Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index f0ee617028db..9898ac0f1335 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -74,7 +74,7 @@ */ #define DAS08_CONTROL_MUX_MASK 0x7 /* multiplexor channel mask */ #define DAS08_CONTROL_MUX(x) ((x) & DAS08_CONTROL_MUX_MASK) /* mux channel */ -#define DAS08_INTE (1<<3) +#define DAS08_CONTROL_INTE BIT(3) /* interrupt enable (not "JR" boards) */ #define DAS08_DO_MASK 0xf0 #define DAS08_OP(x) (((x) << 4) & DAS08_DO_MASK) From 11e8457f02ee41bbd1c0437d340c692ce2d78431 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:19 +0100 Subject: [PATCH 0956/1163] staging: comedi: das08: rename DAS08_OP() and DAS08_DO_MASK The `DAS08_DO_MASK` macro is a bitmask for the control register corresponding to the digital output channels (except on "JR" boards). Rename it to `DAS08_CONTROL_DO_MASK` and add a comment. The `DAS08_OP(x)` macro takes a bitvector of the desired digital output channel states and returns the corresponding bits for the control register (except on "JR" boards). Rename it to `DAS08_CONTROL_DO(x)` and add a comment. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 9898ac0f1335..76e35d4aae93 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -75,8 +75,9 @@ #define DAS08_CONTROL_MUX_MASK 0x7 /* multiplexor channel mask */ #define DAS08_CONTROL_MUX(x) ((x) & DAS08_CONTROL_MUX_MASK) /* mux channel */ #define DAS08_CONTROL_INTE BIT(3) /* interrupt enable (not "JR" boards) */ -#define DAS08_DO_MASK 0xf0 -#define DAS08_OP(x) (((x) << 4) & DAS08_DO_MASK) +#define DAS08_CONTROL_DO_MASK 0xf0 /* digital outputs mask (not "JR") */ +/* digital outputs (not "JR" boards) */ +#define DAS08_CONTROL_DO(x) (((x) << 4) & DAS08_CONTROL_DO_MASK) /* cio-das08jr.pdf @@ -307,8 +308,8 @@ static int das08_do_wbits(struct comedi_device *dev, if (comedi_dio_update_state(s, data)) { /* prevent race with setting of analog input mux */ spin_lock(&dev->spinlock); - devpriv->do_mux_bits &= ~DAS08_DO_MASK; - devpriv->do_mux_bits |= DAS08_OP(s->state); + devpriv->do_mux_bits &= ~DAS08_CONTROL_DO_MASK; + devpriv->do_mux_bits |= DAS08_CONTROL_DO(s->state); outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL_REG); spin_unlock(&dev->spinlock); } From c47c0ed2d53ad829aff1f4ada00e98227c478a57 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:20 +0100 Subject: [PATCH 0957/1163] staging: comedi: das08: rename and split DAS08JR_DIO The `DAS08JR_DIO` macro contains the offset to the read-only digital input register and write-only digital output register on the "JR" boards. Replace the macro with two new macros (with the same numeric value) named `DAS08JR_DI_REG` for the digital input register and `DAS08JR_DO_REG` for the digital output register, and add some comments. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 76e35d4aae93..c015bb6507f3 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -95,7 +95,8 @@ */ -#define DAS08JR_DIO 3 +#define DAS08JR_DI_REG 0x03 /* (R) digital inputs ("JR" boards) */ +#define DAS08JR_DO_REG 0x03 /* (W) digital outputs ("JR" boards) */ #define DAS08JR_AO_LSB(x) ((x) ? 6 : 4) #define DAS08JR_AO_MSB(x) ((x) ? 7 : 5) @@ -324,7 +325,7 @@ static int das08jr_di_rbits(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { data[0] = 0; - data[1] = inb(dev->iobase + DAS08JR_DIO); + data[1] = inb(dev->iobase + DAS08JR_DI_REG); return insn->n; } @@ -335,7 +336,7 @@ static int das08jr_do_wbits(struct comedi_device *dev, unsigned int *data) { if (comedi_dio_update_state(s, data)) - outb(s->state, dev->iobase + DAS08JR_DIO); + outb(s->state, dev->iobase + DAS08JR_DO_REG); data[1] = s->state; @@ -355,7 +356,7 @@ static void das08_ao_set_data(struct comedi_device *dev, outb(lsb, dev->iobase + DAS08JR_AO_LSB(chan)); outb(msb, dev->iobase + DAS08JR_AO_MSB(chan)); /* load DACs */ - inb(dev->iobase + DAS08JR_DIO); + inb(dev->iobase + DAS08JR_DI_REG); } else { outb(lsb, dev->iobase + DAS08AO_AO_LSB(chan)); outb(msb, dev->iobase + DAS08AO_AO_MSB(chan)); From 7b2098f626cfa490eb83eb4563efb1d5b8897ed8 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:21 +0100 Subject: [PATCH 0958/1163] staging: comedi: das08: rename DAS08JR_AO_LSB() and DAS08JR_AO_MSB() The `DAS08JR_AO_LSB(x)` macro returns the offset to the analog output low byte register for channel x (0 or 1) for "JR" boards with analog output support. The `DAS08JR_AO_MSB(x)` macro returns the offset to the corresponding high byte register. Rename the macros to `DAS08JR_AO_LSB_REG(x)` and `DAS08JR_AO_MSB_REG(x)` respectively, and add some comments. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index c015bb6507f3..51637b120ddb 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -97,8 +97,10 @@ #define DAS08JR_DI_REG 0x03 /* (R) digital inputs ("JR" boards) */ #define DAS08JR_DO_REG 0x03 /* (W) digital outputs ("JR" boards) */ -#define DAS08JR_AO_LSB(x) ((x) ? 6 : 4) -#define DAS08JR_AO_MSB(x) ((x) ? 7 : 5) +/* (W) analog output l.s.b. registers for 2 channels ("JR" boards) */ +#define DAS08JR_AO_LSB_REG(x) ((x) ? 0x06 : 0x04) +/* (W) analog output m.s.b. registers for 2 channels ("JR" boards) */ +#define DAS08JR_AO_MSB_REG(x) ((x) ? 0x07 : 0x05) /* cio-das08_aox.pdf @@ -353,8 +355,8 @@ static void das08_ao_set_data(struct comedi_device *dev, lsb = data & 0xff; msb = (data >> 8) & 0xff; if (thisboard->is_jr) { - outb(lsb, dev->iobase + DAS08JR_AO_LSB(chan)); - outb(msb, dev->iobase + DAS08JR_AO_MSB(chan)); + outb(lsb, dev->iobase + DAS08JR_AO_LSB_REG(chan)); + outb(msb, dev->iobase + DAS08JR_AO_MSB_REG(chan)); /* load DACs */ inb(dev->iobase + DAS08JR_DI_REG); } else { From 09ed1b72cf5ebebb37c2487e7269fc00027477df Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:22 +0100 Subject: [PATCH 0959/1163] staging: comedi: das08: add DAS08JR_AO_UPDATE_REG "JR" boards with analog output channels have a jumper that controls whether analog output channels are updated simultaneously or individually. When set to update individually, individual channels are updated when the high byte register is written. When set to update simultaneously, channels are not updated until the digital inputs register is read. The driver doesn't know how the jumper is set and is not interested in the simultaneous output feature, so it updates a channel by writing the low byte, then the high byte, then reading the digital inputs register. To make the code more explicit, add a macro `DAS08JR_AO_UPDATE_REG` with the same value as the `DAS08JR_DI_REG` macro (for digital inputs) and use it when reading the register to update the analog outputs. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 51637b120ddb..4e8756a822ae 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -101,6 +101,11 @@ #define DAS08JR_AO_LSB_REG(x) ((x) ? 0x06 : 0x04) /* (W) analog output m.s.b. registers for 2 channels ("JR" boards) */ #define DAS08JR_AO_MSB_REG(x) ((x) ? 0x07 : 0x05) +/* + * (R) update analog outputs ("JR" boards set for simultaneous output) + * (same register as digital inputs) + */ +#define DAS08JR_AO_UPDATE_REG 0x03 /* cio-das08_aox.pdf @@ -358,7 +363,7 @@ static void das08_ao_set_data(struct comedi_device *dev, outb(lsb, dev->iobase + DAS08JR_AO_LSB_REG(chan)); outb(msb, dev->iobase + DAS08JR_AO_MSB_REG(chan)); /* load DACs */ - inb(dev->iobase + DAS08JR_DI_REG); + inb(dev->iobase + DAS08JR_AO_UPDATE_REG); } else { outb(lsb, dev->iobase + DAS08AO_AO_LSB(chan)); outb(msb, dev->iobase + DAS08AO_AO_MSB(chan)); From f1c04fd42183ccbfa9820ae5a45168e80d70d282 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:23 +0100 Subject: [PATCH 0960/1163] staging: comedi: das08: replace DAS08AO_GAIN_CONTROL/STATUS The `DAS08AO_GAIN_CONTROL` and `DAS08AO_GAIN_STATUS` macros hold the offset to the "programmable gain" register on "PGL", "PGM", "PGH", "AOL", "AOM" and "AOH" boards. Writing a code to this register sets the gain for the current analog input channel (selected in the main control register). The written value can be read back in bits 3..0 of the register. Other bits of the register are read-only and not used by the driver. Rename `DAS08AO_GAIN_CONTROL` to `DAS08_GAIN_REG` and add a comment. Remove `DAS08AO_GAIN_STATUS` as the driver does not use it and the read-only parts of the register are documented in the comment. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 4e8756a822ae..8aa80116f1cf 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -78,6 +78,13 @@ #define DAS08_CONTROL_DO_MASK 0xf0 /* digital outputs mask (not "JR") */ /* digital outputs (not "JR" boards) */ #define DAS08_CONTROL_DO(x) (((x) << 4) & DAS08_CONTROL_DO_MASK) +/* + * (R/W) programmable AI gain ("PGx" and "AOx" boards): + * + bits 3..0 (R/W) show/set the gain for the current AI mux channel + * + bits 6..4 (R) show the current AI mux channel + * + bit 7 (R) not unused + */ +#define DAS08_GAIN_REG 0x03 /* cio-das08jr.pdf @@ -127,9 +134,6 @@ cdef 8255 */ -#define DAS08AO_GAIN_CONTROL 3 -#define DAS08AO_GAIN_STATUS 3 - #define DAS08AO_AO_LSB(x) ((x) ? 0xa : 8) #define DAS08AO_AO_MSB(x) ((x) ? 0xb : 9) #define DAS08AO_AO_UPDATE 8 @@ -260,7 +264,7 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, /* set gain/range */ range = CR_RANGE(insn->chanspec); outb(devpriv->pg_gainlist[range], - dev->iobase + DAS08AO_GAIN_CONTROL); + dev->iobase + DAS08_GAIN_REG); } for (n = 0; n < insn->n; n++) { From 3c98c1d3f1d3912738dca864fd00910654ed2a65 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:24 +0100 Subject: [PATCH 0961/1163] staging: comedi: das08: rename DAS08AO_AO_LSB() and DAS08AO_AO_MSB() The `DAS08AO_AO_LSB(x)` macro returns the offset to the analog output low byte register for channel x (0 or 1) for "AOL", "AOM", and "AOH" boards. The `DAS08AO_AO_MSB(x)` macro returns the offset to the corresponding high byte register. Rename the macros to `DAS08AOX_AO_LSB_REG(x)` and `DAS08AOX_AO_MSB_REG(x)` respectively, and add some comments. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 8aa80116f1cf..005a7ef89f8c 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -134,8 +134,10 @@ cdef 8255 */ -#define DAS08AO_AO_LSB(x) ((x) ? 0xa : 8) -#define DAS08AO_AO_MSB(x) ((x) ? 0xb : 9) +/* (W) analog output l.s.b. registers for 2 channels ("AOx" boards) */ +#define DAS08AOX_AO_LSB_REG(x) ((x) ? 0x0a : 0x08) +/* (W) analog output m.s.b. registers for 2 channels ("AOx" boards) */ +#define DAS08AOX_AO_MSB_REG(x) ((x) ? 0x0b : 0x09) #define DAS08AO_AO_UPDATE 8 /* gainlist same as _pgx_ below */ @@ -369,8 +371,8 @@ static void das08_ao_set_data(struct comedi_device *dev, /* load DACs */ inb(dev->iobase + DAS08JR_AO_UPDATE_REG); } else { - outb(lsb, dev->iobase + DAS08AO_AO_LSB(chan)); - outb(msb, dev->iobase + DAS08AO_AO_MSB(chan)); + outb(lsb, dev->iobase + DAS08AOX_AO_LSB_REG(chan)); + outb(msb, dev->iobase + DAS08AOX_AO_MSB_REG(chan)); /* load DACs */ inb(dev->iobase + DAS08AO_AO_UPDATE); } From 6814b4a3fd3867d4104eecc371f73beced6cb499 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:25 +0100 Subject: [PATCH 0962/1163] staging: comedi: das08: rename DAS08AO_AO_UPDATE "AOL", "AOM", and "AOH" boards have a jumper that controls whether analog output channels are updated simultaneously or individually. When set to update individually, individual channels are updated when the high byte register is written. When set to update simultaneously, channels are not updated until any of the analog output registers are read. The driver doesn't know the jumper setting and is not interested in the simultaneous update feature, so it updates a channel by writing the low byte register, the high byte register, and then reading channel 0's low byte register. The `DAS08AO_AO_UPDATE` macro contains the offset to the low byte register for analog output channel 0 on the "AOL", "AOM", and "AOH" boards, which the driver reads to update the analog outputs. Rename the macro to `DAS08AOX_AO_UPDATE_REG` and add a comment. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 005a7ef89f8c..837c96892fcb 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -138,7 +138,11 @@ #define DAS08AOX_AO_LSB_REG(x) ((x) ? 0x0a : 0x08) /* (W) analog output m.s.b. registers for 2 channels ("AOx" boards) */ #define DAS08AOX_AO_MSB_REG(x) ((x) ? 0x0b : 0x09) -#define DAS08AO_AO_UPDATE 8 +/* + * (R) update analog outputs ("AOx" boards set for simultaneous output) + * (any of the analog output registers could be used for this) + */ +#define DAS08AOX_AO_UPDATE_REG 0x08 /* gainlist same as _pgx_ below */ @@ -374,7 +378,7 @@ static void das08_ao_set_data(struct comedi_device *dev, outb(lsb, dev->iobase + DAS08AOX_AO_LSB_REG(chan)); outb(msb, dev->iobase + DAS08AOX_AO_MSB_REG(chan)); /* load DACs */ - inb(dev->iobase + DAS08AO_AO_UPDATE); + inb(dev->iobase + DAS08AOX_AO_UPDATE_REG); } } From 646e70c5d1611edf2d36448ef0d377a0cf239cc1 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:26 +0100 Subject: [PATCH 0963/1163] staging: comedi: das08: remove board register map comments The "das08" module contains some comments outlining the register maps for some of the ISA boards supported by this module in combination with the "das08_isa" module. The comments are somewhat sporadically placed, don't detail all the boards, and don't use the preferred block comment style. If anywhere, they should probably be in the "das08_isa" module. Just remove them. The comments for the register macros indicate which boards they apply to anyway, so we don't lose much information. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 68 +------------------------- 1 file changed, 1 insertion(+), 67 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 837c96892fcb..a4b21c6ac762 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -26,22 +26,6 @@ #include "comedi_8254.h" #include "das08.h" -/* - cio-das08.pdf - - "isa-das08" - - 0 a/d bits 0-3 start 8 bit - 1 a/d bits 4-11 start 12 bit - 2 eoc, ip1-3, irq, mux op1-4, inte, mux - 3 unused unused - 4567 8254 - 89ab 8255 - - requires hard-wiring for async ai - -*/ - /* * Data format of DAS08_AI_LSB_REG and DAS08_AI_MSB_REG depends on * 'ai_encoding' member of board structure: @@ -86,22 +70,6 @@ */ #define DAS08_GAIN_REG 0x03 -/* - cio-das08jr.pdf - - "das08/jr-ao" - - 0 a/d bits 0-3 unused - 1 a/d bits 4-11 start 12 bit - 2 eoc, mux mux - 3 di do - 4 unused ao0_lsb - 5 unused ao0_msb - 6 unused ao1_lsb - 7 unused ao1_msb - -*/ - #define DAS08JR_DI_REG 0x03 /* (R) digital inputs ("JR" boards) */ #define DAS08JR_DO_REG 0x03 /* (W) digital outputs ("JR" boards) */ /* (W) analog output l.s.b. registers for 2 channels ("JR" boards) */ @@ -114,26 +82,6 @@ */ #define DAS08JR_AO_UPDATE_REG 0x03 -/* - cio-das08_aox.pdf - - "das08-aoh" - "das08-aol" - "das08-aom" - - 0 a/d bits 0-3 start 8 bit - 1 a/d bits 4-11 start 12 bit - 2 eoc, ip1-3, irq, mux op1-4, inte, mux - 3 mux, gain status gain control - 4567 8254 - 8 unused ao0_lsb - 9 unused ao0_msb - a unused ao1_lsb - b unused ao1_msb - 89ab - cdef 8255 -*/ - /* (W) analog output l.s.b. registers for 2 channels ("AOx" boards) */ #define DAS08AOX_AO_LSB_REG(x) ((x) ? 0x0a : 0x08) /* (W) analog output m.s.b. registers for 2 channels ("AOx" boards) */ @@ -189,21 +137,7 @@ static const struct comedi_lrange range_das08_pgm = { UNI_RANGE(0.1), UNI_RANGE(0.01) } -}; /* - cio-das08jr.pdf - - "das08/jr-ao" - - 0 a/d bits 0-3 unused - 1 a/d bits 4-11 start 12 bit - 2 eoc, mux mux - 3 di do - 4 unused ao0_lsb - 5 unused ao0_msb - 6 unused ao1_lsb - 7 unused ao1_msb - - */ +}; static const struct comedi_lrange *const das08_ai_lranges[] = { [das08_pg_none] = &range_unknown, From 66774ce6ca9f4b5bf656de5c58834a4fb95a3c6e Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:27 +0100 Subject: [PATCH 0964/1163] staging: comedi: das08.c: reformat copyright comment Replace double spaces with single spaces at the start of each line in the copyright comment at the top of the file. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 28 +++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index a4b21c6ac762..898622ff8b79 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -1,21 +1,21 @@ /* - * comedi/drivers/das08.c - * comedi module for common DAS08 support (used by ISA/PCI/PCMCIA drivers) + * comedi/drivers/das08.c + * comedi module for common DAS08 support (used by ISA/PCI/PCMCIA drivers) * - * COMEDI - Linux Control and Measurement Device Interface - * Copyright (C) 2000 David A. Schleef - * Copyright (C) 2001,2002,2003 Frank Mori Hess - * Copyright (C) 2004 Salvador E. Tropea + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 2000 David A. Schleef + * Copyright (C) 2001,2002,2003 Frank Mori Hess + * Copyright (C) 2004 Salvador E. Tropea * - * 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 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. + * 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 From 194869dbe81145650cd436ed6d3a101d2451779d Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:28 +0100 Subject: [PATCH 0965/1163] staging: comedi: das08.c: reformat remaining comments Use the preferred style for block comments. Squash double spaces after the comment opening sequence for single-line comments. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 898622ff8b79..4bde52a4a17a 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -193,7 +193,7 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, inb(dev->iobase + DAS08_AI_MSB_REG); /* set multiplexer */ - /* lock to prevent race with digital output */ + /* lock to prevent race with digital output */ spin_lock(&dev->spinlock); devpriv->do_mux_bits &= ~DAS08_CONTROL_MUX_MASK; devpriv->do_mux_bits |= DAS08_CONTROL_MUX(chan); @@ -354,7 +354,8 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) /* ai */ if (thisboard->ai_nbits) { s->type = COMEDI_SUBD_AI; - /* XXX some boards actually have differential + /* + * XXX some boards actually have differential * inputs instead of single ended. * The driver does nothing with arefs though, * so it's no big deal. From a76ccfa81e8268025b3dc3dfd76420f6049032f7 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:29 +0100 Subject: [PATCH 0966/1163] staging: comedi: das08: rename ai range tables The `range_das08_pgl`, `range_das08_pgm`, and `range_das08_pgh` variables define the analog input ranges for the "PGL", "PGM", and "PGH" board variants, and are also used for the "AOL", "AOM", and "AOH" board variants. Rename them to use the `das08_` prefix for consistency. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 4bde52a4a17a..9f2113c1e1fc 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -94,7 +94,7 @@ /* gainlist same as _pgx_ below */ -static const struct comedi_lrange range_das08_pgl = { +static const struct comedi_lrange das08_pgl_ai_range = { 9, { BIP_RANGE(10), BIP_RANGE(5), @@ -108,7 +108,7 @@ static const struct comedi_lrange range_das08_pgl = { } }; -static const struct comedi_lrange range_das08_pgh = { +static const struct comedi_lrange das08_pgh_ai_range = { 12, { BIP_RANGE(10), BIP_RANGE(5), @@ -125,7 +125,7 @@ static const struct comedi_lrange range_das08_pgh = { } }; -static const struct comedi_lrange range_das08_pgm = { +static const struct comedi_lrange das08_pgm_ai_range = { 9, { BIP_RANGE(10), BIP_RANGE(5), @@ -142,9 +142,9 @@ static const struct comedi_lrange range_das08_pgm = { static const struct comedi_lrange *const das08_ai_lranges[] = { [das08_pg_none] = &range_unknown, [das08_bipolar5] = &range_bipolar5, - [das08_pgh] = &range_das08_pgh, - [das08_pgl] = &range_das08_pgl, - [das08_pgm] = &range_das08_pgm, + [das08_pgh] = &das08_pgh_ai_range, + [das08_pgl] = &das08_pgl_ai_range, + [das08_pgm] = &das08_pgm_ai_range, }; static const int das08_pgh_gainlist[] = { From fcd63ec8f325d964cfdf0a7c92a9dcac475f85e6 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:30 +0100 Subject: [PATCH 0967/1163] staging: comedi: das08: rename the gainlist variables `das08_pgh_gainlist[]`, `das08_pgl_gainlist[]`, and `das08_pgm_gainlist[]` hold the gain codes indexed by range index for various boards that support programmable gain. `das08_gainlist[]` is a look-up table to find the appropriate gain list for a board. These are all associated with the analog input Comedi subdevice. Rename the variables to reflect that. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 9f2113c1e1fc..ec0998bdb58d 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -147,18 +147,18 @@ static const struct comedi_lrange *const das08_ai_lranges[] = { [das08_pgm] = &das08_pgm_ai_range, }; -static const int das08_pgh_gainlist[] = { +static const int das08_pgh_ai_gainlist[] = { 8, 0, 10, 2, 12, 4, 14, 6, 1, 3, 5, 7 }; -static const int das08_pgl_gainlist[] = { 8, 0, 2, 4, 6, 1, 3, 5, 7 }; -static const int das08_pgm_gainlist[] = { 8, 0, 10, 12, 14, 9, 11, 13, 15 }; +static const int das08_pgl_ai_gainlist[] = { 8, 0, 2, 4, 6, 1, 3, 5, 7 }; +static const int das08_pgm_ai_gainlist[] = { 8, 0, 10, 12, 14, 9, 11, 13, 15 }; -static const int *const das08_gainlists[] = { +static const int *const das08_ai_gainlists[] = { [das08_pg_none] = NULL, [das08_bipolar5] = NULL, - [das08_pgh] = das08_pgh_gainlist, - [das08_pgl] = das08_pgl_gainlist, - [das08_pgm] = das08_pgm_gainlist, + [das08_pgh] = das08_pgh_ai_gainlist, + [das08_pgl] = das08_pgl_ai_gainlist, + [das08_pgm] = das08_pgm_ai_gainlist, }; static int das08_ai_eoc(struct comedi_device *dev, @@ -365,7 +365,7 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) s->maxdata = (1 << thisboard->ai_nbits) - 1; s->range_table = das08_ai_lranges[thisboard->ai_pg]; s->insn_read = das08_ai_rinsn; - devpriv->pg_gainlist = das08_gainlists[thisboard->ai_pg]; + devpriv->pg_gainlist = das08_ai_gainlists[thisboard->ai_pg]; } else { s->type = COMEDI_SUBD_UNUSED; } From c224a9195745e909b2c457bba1a7a6b57ac9e284 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:31 +0100 Subject: [PATCH 0968/1163] staging: comedi: das08: rename das08_ai_rinsn() `das08_ai_rinsn()` is the handler for Comedi `INSN_READ` instructions for the AI subdevice. Rename the function to `das08_ai_insn_read()` for consistency. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index ec0998bdb58d..98df71848184 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -174,8 +174,9 @@ static int das08_ai_eoc(struct comedi_device *dev, return -EBUSY; } -static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int das08_ai_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { const struct das08_board_struct *thisboard = dev->board_ptr; struct das08_private_struct *devpriv = dev->private; @@ -364,7 +365,7 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) s->n_chan = 8; s->maxdata = (1 << thisboard->ai_nbits) - 1; s->range_table = das08_ai_lranges[thisboard->ai_pg]; - s->insn_read = das08_ai_rinsn; + s->insn_read = das08_ai_insn_read; devpriv->pg_gainlist = das08_ai_gainlists[thisboard->ai_pg]; } else { s->type = COMEDI_SUBD_UNUSED; From 9f05914d0c7ce5083e54bb37d50c41d942adf03b Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:32 +0100 Subject: [PATCH 0969/1163] staging: comedi: das08: rename das08_di_rbits() & das08jr_di_rbits() `das08_di_rbits()` and `das08jr_di_rbits()` are handlers for the Comedi `INSN_BITS` instruction for the digital input subdevice on "non-JR" and "JR" boards, respectively. Rename them to `das08_di_insn_bits()` and `das08jr_di_insn_bits()` respectively for consistency. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 98df71848184..5590f118e9ac 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -242,8 +242,9 @@ static int das08_ai_insn_read(struct comedi_device *dev, return n; } -static int das08_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int das08_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = 0; data[1] = DAS08_STATUS_DI(inb(dev->iobase + DAS08_STATUS_REG)); @@ -272,9 +273,9 @@ static int das08_do_wbits(struct comedi_device *dev, return insn->n; } -static int das08jr_di_rbits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int das08jr_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = 0; data[1] = inb(dev->iobase + DAS08JR_DI_REG); @@ -402,8 +403,8 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) s->n_chan = thisboard->di_nchan; s->maxdata = 1; s->range_table = &range_digital; - s->insn_bits = - thisboard->is_jr ? das08jr_di_rbits : das08_di_rbits; + s->insn_bits = thisboard->is_jr ? das08jr_di_insn_bits : + das08_di_insn_bits; } else { s->type = COMEDI_SUBD_UNUSED; } From 3919c3d5891b079b5d03c03b4df4e3fca9572eca Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:33 +0100 Subject: [PATCH 0970/1163] staging: comedi: das08: rename das08_do_wbits() & das08jr_do_wbits() `das08_do_wbits()` and `das08jr_do_wbits()` are handlers for the Comedi `INSN_BITS` instruction for the digital output subdevice on "non-JR" and "JR" boards, respectively. Rename them to `das08_do_insn_bits()` and `das08jr_do_insn_bits()` respectively for consistency. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 5590f118e9ac..f74c4b009d8b 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -252,10 +252,9 @@ static int das08_di_insn_bits(struct comedi_device *dev, return insn->n; } -static int das08_do_wbits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) +static int das08_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { struct das08_private_struct *devpriv = dev->private; @@ -283,10 +282,9 @@ static int das08jr_di_insn_bits(struct comedi_device *dev, return insn->n; } -static int das08jr_do_wbits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) +static int das08jr_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (comedi_dio_update_state(s, data)) outb(s->state, dev->iobase + DAS08JR_DO_REG); @@ -417,8 +415,8 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) s->n_chan = thisboard->do_nchan; s->maxdata = 1; s->range_table = &range_digital; - s->insn_bits = - thisboard->is_jr ? das08jr_do_wbits : das08_do_wbits; + s->insn_bits = thisboard->is_jr ? das08jr_do_insn_bits : + das08_do_insn_bits; } else { s->type = COMEDI_SUBD_UNUSED; } From 34cce4628b8509dc894735cdc5de8b10db21873a Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:34 +0100 Subject: [PATCH 0971/1163] staging: comedi: das08: clarify sign-magnitude conversion For DAS08/JR/16 and DAS08/JR/AO-16 boards, the 16-bit analog input readings are assumed to be in a sign-magnitude format and need converting to the COMEDI unsigned sample format. The expressions to do the conversion look a little messy. Use a local variable `magnitude` to make it easier to follow. Also, there seems to be some discrepancy between the manual for these boards and the COMEDI code. The manual implies that 0 is full-scale negative and 65535 is full-scale positive. However, the COMEDI code has used the sign-magnitude conversion for these boards since these two boards were initially supported by a patch from an external contributor to the COMEDI project back in 2001. Assume the code is correct for now, but add a comment to mention the discrepancy. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index f74c4b009d8b..6c9bd10243b7 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -228,11 +228,26 @@ static int das08_ai_insn_read(struct comedi_device *dev, } else if (thisboard->ai_encoding == das08_pcm_encode12) { data[n] = (msb << 8) + lsb; } else if (thisboard->ai_encoding == das08_encode16) { - /* FPOS 16-bit boards are sign-magnitude */ + /* + * "JR" 16-bit boards are sign-magnitude. + * + * XXX The manual seems to imply that 0 is full-scale + * negative and 65535 is full-scale positive, but the + * original COMEDI patch to add support for the + * DAS08/JR/16 and DAS08/JR/16-AO boards have it + * encoded as sign-magnitude. Assume the original + * COMEDI code is correct for now. + */ + unsigned int magnitude = lsb | ((msb & 0x7f) << 8); + + /* + * MSB bit 7 is 0 for negative, 1 for positive voltage. + * COMEDI 16-bit bipolar data value for 0V is 0x8000. + */ if (msb & 0x80) - data[n] = (1 << 15) | lsb | ((msb & 0x7f) << 8); + data[n] = (1 << 15) + magnitude; else - data[n] = (1 << 15) - (lsb | (msb & 0x7f) << 8); + data[n] = (1 << 15) - magnitude; } else { dev_err(dev->class_dev, "bug! unknown ai encoding\n"); return -1; From 57334a30c8da966e4470572d3096873e26c66076 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:35 +0100 Subject: [PATCH 0972/1163] staging: comedi: das08: use better MODULE_DESCRIPTION() Replace the boiler-plate Comedi module description string with something more specific. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 6c9bd10243b7..700a40b23c5f 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -476,5 +476,5 @@ static void __exit das08_exit(void) module_exit(das08_exit); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("Comedi common DAS08 support module"); MODULE_LICENSE("GPL"); From df7f46e83c7f52ee6e7cf96eb8c068b1d1f8c68f Mon Sep 17 00:00:00 2001 From: Abdul Hussain Date: Thu, 11 Jun 2015 10:03:49 +0000 Subject: [PATCH 0973/1163] staging: unisys: Remove unneeded variable This patch remove unneeded variable used to store return value. Signed-off-by: Abdul Hussain Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorbus_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index dcce1f02d54d..6fa17eadc306 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -768,7 +768,6 @@ away: static int visordriver_remove_device(struct device *xdev) { - int rc = 0; struct visor_device *dev; struct visor_driver *drv; @@ -791,7 +790,7 @@ visordriver_remove_device(struct device *xdev) put_device(&dev->device); - return rc; + return 0; } /** A particular type of visor driver calls this function to register From c20a99f8c38f41ce875bfea829ca0dd603f1d11b Mon Sep 17 00:00:00 2001 From: David Kershner Date: Fri, 12 Jun 2015 16:46:06 -0400 Subject: [PATCH 0974/1163] staging: unisys: Move phys_info to iochannel.h This moves phys_info to iochannel.h. It is only used by iochannel.h and is not needed in vmcallinterfaces.h. Signed-off-by: David Kershner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/iochannel.h | 6 ++++++ drivers/staging/unisys/visorbus/vmcallinterface.h | 12 ------------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/unisys/include/iochannel.h b/drivers/staging/unisys/include/iochannel.h index cbb58757e76a..ee28cdc1c703 100644 --- a/drivers/staging/unisys/include/iochannel.h +++ b/drivers/staging/unisys/include/iochannel.h @@ -149,6 +149,12 @@ enum vdisk_mgmt_types { /* structs with pragma pack */ +struct phys_info { + u64 pi_pfn; + u16 pi_off; + u16 pi_len; +} __packed; + /* ///////////// BEGIN PRAGMA PACK PUSH 1 ///////////////////////// */ /* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */ diff --git a/drivers/staging/unisys/visorbus/vmcallinterface.h b/drivers/staging/unisys/visorbus/vmcallinterface.h index dc09caf7d075..7a53df00726a 100644 --- a/drivers/staging/unisys/visorbus/vmcallinterface.h +++ b/drivers/staging/unisys/visorbus/vmcallinterface.h @@ -91,18 +91,6 @@ enum vmcall_monitor_interface_method_tuple { /* VMCALL identification tuples */ /* Structures for IO VMCALLs */ -/* ///////////// BEGIN PRAGMA PACK PUSH 1 ///////////////////////// */ -/* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */ -#pragma pack(push, 1) -struct phys_info { - u64 pi_pfn; - u16 pi_off; - u16 pi_len; -}; - -#pragma pack(pop) -/* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */ - /* ///////////// BEGIN PRAGMA PACK PUSH 1 ///////////////////////// */ /* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */ #pragma pack(push, 1) From 5e54654c41bfb9216b551fd3a3891c2da60eadae Mon Sep 17 00:00:00 2001 From: David Kershner Date: Fri, 12 Jun 2015 16:46:07 -0400 Subject: [PATCH 0975/1163] staging: unisys: convert pack pragma to __packed It was noticed that iochannel.h was still using pragmas to pack the datastructures, should be using __packed instead. Signed-off-by: David Kershner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/iochannel.h | 45 +++++++++------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/drivers/staging/unisys/include/iochannel.h b/drivers/staging/unisys/include/iochannel.h index ee28cdc1c703..538036d378fb 100644 --- a/drivers/staging/unisys/include/iochannel.h +++ b/drivers/staging/unisys/include/iochannel.h @@ -147,23 +147,16 @@ enum vdisk_mgmt_types { VDISK_MGMT_RELEASE, }; -/* structs with pragma pack */ - struct phys_info { u64 pi_pfn; u16 pi_off; u16 pi_len; } __packed; -/* ///////////// BEGIN PRAGMA PACK PUSH 1 ///////////////////////// */ -/* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */ - -#pragma pack(push, 1) - struct guest_phys_info { u64 address; u64 length; -}; +} __packed; #define GPI_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(struct guest_phys_info)) @@ -171,12 +164,12 @@ struct uisscsi_dest { u32 channel; /* channel == bus number */ u32 id; /* id == target number */ u32 lun; /* lun == logical unit number */ -}; +} __packed; struct vhba_wwnn { u32 wwnn1; u32 wwnn2; -}; +} __packed; /* WARNING: Values stired in this structure must contain maximum counts (not * maximum values). */ @@ -193,7 +186,7 @@ struct vhba_config_max { /* 20 bytes */ * bus */ /* max io size is often determined by the resource of the hba. e.g */ /* max scatter gather list length * page size / sector size */ -}; +} __packed; struct uiscmdrsp_scsi { void *scsicmd; /* the handle to the cmd that was received - @@ -232,7 +225,7 @@ struct uiscmdrsp_scsi { * scsi.linuxstat is SAM_STAT_GOOD * That is, there is NO error. */ -}; +} __packed; /* Defines to support sending correct inquiry result when no disk is * configured. @@ -346,7 +339,7 @@ struct sense_data { u8 additional_sense_code_qualifier; u8 fru_code; u8 sense_key_specific[3]; -}; +} __packed; struct net_pkt_xmt { int len; /* full length of data in the packet */ @@ -374,11 +367,11 @@ struct net_pkt_xmt { * guest memory to get to the header. uisnic needs ethhdr to * determine how to route the packet. */ -}; +} __packed; struct net_pkt_xmtdone { u32 xmt_done_result; /* result of NET_XMIT */ -}; +} __packed; /* RCVPOST_BUF_SIZe must be at most page_size(4096) - cache_line_size (64) The * reason is because dev_skb_alloc which is used to generate RCV_POST skbs in @@ -400,7 +393,7 @@ struct net_pkt_rcvpost { u64 unique_num; /* This is used to make sure that * receive posts are returned to */ /* the Adapter which we sent them originally. */ -}; +} __packed; struct net_pkt_rcv { /* the number of receive buffers that can be chained */ @@ -414,17 +407,17 @@ struct net_pkt_rcv { /* NOTE: first rcvbuf in the chain will also be provided in net.buf. */ u64 unique_num; u32 rcvs_dropped_delta; -}; +} __packed; struct net_pkt_enbdis { void *context; u16 enable; /* 1 = enable, 0 = disable */ -}; +} __packed; struct net_pkt_macaddr { void *context; u8 macaddr[MAX_MACADDR_LEN]; /* 6 bytes */ -}; +} __packed; /* cmd rsp packet used for VNIC network traffic */ struct uiscmdrsp_net { @@ -441,7 +434,7 @@ struct uiscmdrsp_net { /* and NET_CONNECT_STATUS */ struct net_pkt_macaddr macaddr; }; -}; +} __packed; struct uiscmdrsp_scsitaskmgmt { enum task_mgmt_types tasktype; @@ -478,7 +471,7 @@ struct uiscmdrsp_scsitaskmgmt { /* result of taskmgmt command - set by IOPart - values are: */ #define TASK_MGMT_FAILED 0 -}; +} __packed; /* The following is used by uissd to send disk add/remove notifications to * Guest */ @@ -488,7 +481,7 @@ struct uiscmdrsp_disknotify { void *v_hba; /* Pointer to vhba_info for channel info to * route msg */ u32 channel, id, lun; /* SCSI Path of Disk to added or removed */ -}; +} __packed; /* The following is used by virthba/vSCSI to send the Acquire/Release commands * to the IOVM. */ @@ -527,7 +520,7 @@ struct uiscmdrsp_vdiskmgmt { /* result of taskmgmt command - set by IOPart - values are: */ #define VDISK_MGMT_FAILED 0 -}; +} __packed; /* keeping cmd & rsp info in one structure for now cmd rsp packet for scsi */ struct uiscmdrsp { @@ -551,7 +544,7 @@ struct uiscmdrsp { struct uiscmdrsp *next; /* General Purpose Queue Link */ struct uiscmdrsp *activeQ_next; /* Used to track active commands */ struct uiscmdrsp *activeQ_prev; /* Used to track active commands */ -}; +} __packed; /* This is just the header of the IO channel. It is assumed that directly after * this header there is a large region of memory which contains the command and @@ -577,10 +570,8 @@ struct spar_io_channel_protocol { #define MAX_CLIENTSTRING_LEN 1024 u8 client_string[MAX_CLIENTSTRING_LEN];/* NULL terminated - so holds * max - 1 bytes */ -}; +} __packed; -#pragma pack(pop) -/* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */ /* * INLINE functions for initializing and accessing I/O data channels From 86ea8acc6b494dbadd16a82ed778a68d5b4d4091 Mon Sep 17 00:00:00 2001 From: David Kershner Date: Fri, 12 Jun 2015 16:46:08 -0400 Subject: [PATCH 0976/1163] staging: unisys: Don't hold device responses until driver loads Currently if a driver is not loaded for a device, we will not respond to the device create until it is done. This causes s-Par to not mark the partition running if the driver for the device is not loaded. Since there are several devices that could be assigned to a guest that don't have an actual driver this will cause us to never go running. If the device driver is loaded, we WILL continue to only respond to the device PAUSE message when the device driver has responded that it is done with the device. Signed-off-by: David Kershner Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorbus_main.c | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 6fa17eadc306..6db47196c189 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -70,7 +70,6 @@ static const struct attribute_group *visorbus_bus_groups[] = { NULL, }; - /** This describes the TYPE of bus. * (Don't confuse this with an INSTANCE of the bus.) */ @@ -745,19 +744,6 @@ visordriver_probe_device(struct device *xdev) away: if (rc != 0) put_device(&dev->device); - /* We could get here more than once if the child driver module is - * unloaded and re-loaded while devices are present. That's why we - * need a flag to be sure that we only respond to the device_create - * once. We cannot respond to the device_create prior to here, - * because until we call drv->probe() above, the channel has not been - * initialized. - */ - if (!dev->responded_to_device_create) { - - dev->responded_to_device_create = true; - if (chipset_responders.device_create) - (*chipset_responders.device_create)(dev, rc); - } return rc; } @@ -1305,15 +1291,15 @@ chipset_device_create(struct visor_device *dev_info) POSTCODE_SEVERITY_INFO); rc = create_visor_device(dev_info); - if (rc < 0) { + if (chipset_responders.device_create) + chipset_responders.device_create(dev_info, rc); + + if (rc < 0) POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, POSTCODE_SEVERITY_ERR); - if (chipset_responders.device_create) - (*chipset_responders.device_create)(dev_info, rc); - } - - POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, dev_no, bus_no, - POSTCODE_SEVERITY_INFO); + else + POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, dev_no, bus_no, + POSTCODE_SEVERITY_INFO); } static void From 441b3e45c2dd12af4b43f8663bbc6602bbc7b183 Mon Sep 17 00:00:00 2001 From: Harisangam Sharvari Date: Tue, 9 Jun 2015 04:27:35 +0000 Subject: [PATCH 0977/1163] Staging: vt6655: Remove unnecessary equality checks in rxtx.c The unnecessary equality checks for bool variable are removed in rxtx.c. These changes were detected with the help of coccinelle tool Signed-off-by: Harisangam Sharvari Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/rxtx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 33c4aa49946d..534338c46619 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -1093,7 +1093,7 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {/* 802.11g packet */ if (byFBOption == AUTO_FB_NONE) { - if (bRTS == true) {/* RTS_need */ + if (bRTS) {/* RTS_need */ pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); pMICHDR = (struct vnt_mic_hdr *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts)); pvRTS = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts) + cbMICHDR); @@ -1115,7 +1115,7 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, } } else { /* Auto Fall Back */ - if (bRTS == true) {/* RTS_need */ + if (bRTS) {/* RTS_need */ pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts)); pvRTS = (void *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts) + cbMICHDR); @@ -1138,7 +1138,7 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, } else {/* 802.11a/b packet */ if (byFBOption == AUTO_FB_NONE) { - if (bRTS == true) { + if (bRTS) { pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab)); pvRTS = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); @@ -1158,7 +1158,7 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, } } else { /* Auto Fall Back */ - if (bRTS == true) { /* RTS_need */ + if (bRTS) { /* RTS_need */ pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab)); pvRTS = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); From 98f196afefa35ace67a9fc54787066134f483641 Mon Sep 17 00:00:00 2001 From: Nizam Haider Date: Tue, 9 Jun 2015 10:14:55 +0530 Subject: [PATCH 0978/1163] Staging: rts5208: xd: Fixed checkpatch warning Fixed a warning, else is not generally useful after a break or return. Signed-off-by: Nizam Haider Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/xd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rts5208/xd.c b/drivers/staging/rts5208/xd.c index 8fd108e50509..10fea7bb8f30 100644 --- a/drivers/staging/rts5208/xd.c +++ b/drivers/staging/rts5208/xd.c @@ -1379,9 +1379,8 @@ static int xd_erase_block(struct rtsx_chip *chip, u32 phy_blk) xd_set_err_code(chip, XD_PRG_ERROR); rtsx_trace(chip); return STATUS_FAIL; - } else { - xd_set_err_code(chip, XD_ERASE_FAIL); } + xd_set_err_code(chip, XD_ERASE_FAIL); retval = xd_reset_cmd(chip); if (retval != STATUS_SUCCESS) { rtsx_trace(chip); From fa70ae09e645da2312912570eba04160edff7835 Mon Sep 17 00:00:00 2001 From: Gnanachandran Dhanapal Date: Tue, 9 Jun 2015 14:47:49 +0000 Subject: [PATCH 0979/1163] Staging: rtl8192e: Casting correct Endianness Casting correct Endianness for __le16 variable used in assignment and condition check Signed-off-by: Gnanachandran Dhanapal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_softmac.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 9dce121d660e..7ce58e248f2d 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1265,7 +1265,7 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon, skb_put(skb, sizeof(struct rtllib_assoc_request_frame) + 2); - hdr->header.frame_ctl = RTLLIB_STYPE_ASSOC_REQ; + hdr->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_ASSOC_REQ); hdr->header.duration_id = cpu_to_le16(37); ether_addr_copy(hdr->header.addr1, beacon->bssid); ether_addr_copy(hdr->header.addr2, ieee->dev->dev_addr); @@ -2243,9 +2243,10 @@ inline int rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb, u8 *ies; struct rtllib_assoc_response_frame *assoc_resp; struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; + u16 frame_ctl = le16_to_cpu(header->frame_ctl); netdev_dbg(ieee->dev, "received [RE]ASSOCIATION RESPONSE (%d)\n", - WLAN_FC_GET_STYPE(header->frame_ctl)); + WLAN_FC_GET_STYPE(frame_ctl)); if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATED && @@ -2389,6 +2390,7 @@ inline int rtllib_rx_auth(struct rtllib_device *ieee, struct sk_buff *skb, inline int rtllib_rx_deauth(struct rtllib_device *ieee, struct sk_buff *skb) { struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; + u16 frame_ctl; if (memcmp(header->addr3, ieee->current_network.bssid, ETH_ALEN) != 0) return 0; @@ -2399,9 +2401,10 @@ inline int rtllib_rx_deauth(struct rtllib_device *ieee, struct sk_buff *skb) if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->state == RTLLIB_LINKED && (ieee->iw_mode == IW_MODE_INFRA)) { + frame_ctl = le16_to_cpu(header->frame_ctl); netdev_info(ieee->dev, "==========>received disassoc/deauth(%x) frame, reason code:%x\n", - WLAN_FC_GET_STYPE(header->frame_ctl), + WLAN_FC_GET_STYPE(frame_ctl), ((struct rtllib_disassoc *)skb->data)->reason); ieee->state = RTLLIB_ASSOCIATING; ieee->softmac_stats.reassoc++; @@ -2427,11 +2430,13 @@ inline int rtllib_rx_frame_softmac(struct rtllib_device *ieee, u16 stype) { struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; + u16 frame_ctl; if (!ieee->proto_started) return 0; - switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { + frame_ctl = le16_to_cpu(header->frame_ctl); + switch (WLAN_FC_GET_STYPE(frame_ctl)) { case RTLLIB_STYPE_ASSOC_RESP: case RTLLIB_STYPE_REASSOC_RESP: if (rtllib_rx_assoc_resp(ieee, skb, rx_stats) == 1) From 67ba748c03bc2103df090b1413661d77c8334ea4 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 8 Jun 2015 23:23:33 +0200 Subject: [PATCH 0980/1163] staging: rtl8192e: remove dm_shadow dm_shadow array is no longer used. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 3 --- drivers/staging/rtl8192e/rtl8192e/rtl_dm.h | 1 - 2 files changed, 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c index d8696293c6e1..d2734520a5e3 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c @@ -158,9 +158,6 @@ const u8 dm_cck_tx_bb_gain_ch14[CCKTxBBGainTableLength][8] = { /*------------------------Define global variable-----------------------------*/ struct dig_t dm_digtable; -u8 dm_shadow[16][256] = { - {0} -}; struct drx_path_sel DM_RxPathSelTable; /*------------------------Define global variable-----------------------------*/ diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h index b0d936703515..ae2034e760d5 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h @@ -217,7 +217,6 @@ struct dcmd_txcmd { /*------------------------Export global variable----------------------------*/ extern struct dig_t dm_digtable; -extern u8 dm_shadow[16][256]; extern struct drx_path_sel DM_RxPathSelTable; /* Pre-calculated gain tables */ From 32215eaa6e395c91cb0191553f14eb0abb69dc68 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 8 Jun 2015 23:23:34 +0200 Subject: [PATCH 0981/1163] staging: rtl8192e: Remove dead code: dig_t::dbg_mode, drx_path_sel::DbgMode dig_t::dbg_mode and drx_path_sel::DbgMode are initialized to one value and checked only once in code.This patch throws them away, and deletes always-true conditions. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 8 ++----- drivers/staging/rtl8192e/rtl8192e/rtl_dm.h | 25 ---------------------- 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c index d2734520a5e3..8532e0c21e75 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c @@ -1308,7 +1308,6 @@ static void dm_dig_init(struct net_device *dev) dm_digtable.dig_algorithm = DIG_ALGO_BY_RSSI; - dm_digtable.dbg_mode = DM_DBG_OFF; dm_digtable.dig_algorithm_switch = 0; dm_digtable.dig_state = DM_STA_DIG_MAX; @@ -1388,8 +1387,7 @@ static void dm_ctrl_initgain_byrssi_by_driverrssi( dm_digtable.CurSTAConnectState = DIG_STA_DISCONNECT; - if (dm_digtable.dbg_mode == DM_DBG_OFF) - dm_digtable.rssi_val = priv->undecorated_smoothed_pwdb; + dm_digtable.rssi_val = priv->undecorated_smoothed_pwdb; dm_initial_gain(dev); dm_pd_th(dev); dm_cs_ratio(dev); @@ -1946,7 +1944,6 @@ static void dm_init_rxpath_selection(struct net_device *dev) DM_RxPathSelTable.cck_method = CCK_Rx_Version_2; else DM_RxPathSelTable.cck_method = CCK_Rx_Version_1; - DM_RxPathSelTable.DbgMode = DM_DBG_OFF; DM_RxPathSelTable.disabledRF = 0; for (i = 0; i < 4; i++) { DM_RxPathSelTable.rf_rssi[i] = 50; @@ -1989,8 +1986,7 @@ static void dm_rxpath_sel_byrssi(struct net_device *dev) DM_RxPathSelTable.cck_method = CCK_Rx_Version_2; for (i = 0; i < RF90_PATH_MAX; i++) { - if (!DM_RxPathSelTable.DbgMode) - DM_RxPathSelTable.rf_rssi[i] = priv->stats.rx_rssi_percentage[i]; + DM_RxPathSelTable.rf_rssi[i] = priv->stats.rx_rssi_percentage[i]; if (priv->brfpath_rxenable[i]) { rf_num++; diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h index ae2034e760d5..b037451c3ada 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h @@ -87,7 +87,6 @@ struct dig_t { u8 dig_enable_flag; u8 dig_algorithm; - u8 dbg_mode; u8 dig_algorithm_switch; long rssi_low_thresh; @@ -130,23 +129,6 @@ enum dm_ratr_sta { DM_RATR_STA_MAX }; -enum dm_dig_op_sta { - DIG_TYPE_THRESH_HIGH = 0, - DIG_TYPE_THRESH_LOW = 1, - DIG_TYPE_THRESH_HIGHPWR_HIGH = 2, - DIG_TYPE_THRESH_HIGHPWR_LOW = 3, - DIG_TYPE_DBG_MODE = 4, - DIG_TYPE_RSSI = 5, - DIG_TYPE_ALGORITHM = 6, - DIG_TYPE_BACKOFF = 7, - DIG_TYPE_PWDB_FACTOR = 8, - DIG_TYPE_RX_GAIN_MIN = 9, - DIG_TYPE_RX_GAIN_MAX = 10, - DIG_TYPE_ENABLE = 20, - DIG_TYPE_DISABLE = 30, - DIG_OP_TYPE_MAX -}; - enum dm_dig_alg { DIG_ALGO_BY_FALSE_ALARM = 0, DIG_ALGO_BY_RSSI = 1, @@ -180,7 +162,6 @@ enum dm_dig_cs_ratio { struct drx_path_sel { u8 Enable; - u8 DbgMode; u8 cck_method; u8 cck_Rx_path; @@ -201,12 +182,6 @@ enum dm_cck_rx_path_method { }; -enum dm_dbg { - DM_DBG_OFF = 0, - DM_DBG_ON = 1, - DM_DBG_MAX -}; - struct dcmd_txcmd { u32 Op; u32 Length; From 8a889aee58037022fee25851778404429a64a8c9 Mon Sep 17 00:00:00 2001 From: Fabian Frederick Date: Wed, 10 Jun 2015 18:32:28 +0200 Subject: [PATCH 0982/1163] Staging: rtl8188eu: use swap() in WMMOnAssocRsp() Use kernel.h macro definition. Thanks to Julia Lawall for Coccinelle scripting support. Signed-off-by: Fabian Frederick Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 2b371757cbfe..32300df7b996 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -603,7 +603,7 @@ void WMMOnAssocRsp(struct 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, change_inx = false; /* entry indx: 0->vo, 1->vi, 2->be, 3->bk. */ for (i = 0; i < 4; i++) { @@ -618,14 +618,8 @@ void WMMOnAssocRsp(struct adapter *padapter) } if (change_inx) { - tmp = edca[i]; - edca[i] = edca[j]; - edca[j] = tmp; - - tmp = inx[i]; - inx[i] = inx[j]; - inx[j] = tmp; - + swap(edca[i], edca[j]); + swap(inx[i], inx[j]); change_inx = false; } } From 8781d5b3499a0ceb19217f937d37c796cce8ca58 Mon Sep 17 00:00:00 2001 From: Fabian Frederick Date: Wed, 10 Jun 2015 18:32:13 +0200 Subject: [PATCH 0983/1163] staging: rtl8712: use swap() in dequeue_xframe_ex() Use kernel.h macro definition. Thanks to Julia Lawall for Coccinelle scripting support. Signed-off-by: Fabian Frederick Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_xmit.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8712/rtl8712_xmit.c b/drivers/staging/rtl8712/rtl8712_xmit.c index 8c756df0438d..86206d34a40e 100644 --- a/drivers/staging/rtl8712/rtl8712_xmit.c +++ b/drivers/staging/rtl8712/rtl8712_xmit.c @@ -188,7 +188,7 @@ static struct xmit_frame *dequeue_xframe_ex(struct xmit_priv *pxmitpriv, struct __queue *pframe_queue = NULL; struct xmit_frame *pxmitframe = NULL; int i, inx[4]; - int j, tmp, acirp_cnt[4]; + int j, acirp_cnt[4]; /*entry indx: 0->vo, 1->vi, 2->be, 3->bk.*/ inx[0] = 0; acirp_cnt[0] = pxmitpriv->voq_cnt; @@ -198,12 +198,8 @@ static struct xmit_frame *dequeue_xframe_ex(struct xmit_priv *pxmitpriv, for (i = 0; i < 4; i++) { for (j = i + 1; j < 4; j++) { if (acirp_cnt[j] < acirp_cnt[i]) { - tmp = acirp_cnt[i]; - acirp_cnt[i] = acirp_cnt[j]; - acirp_cnt[j] = tmp; - tmp = inx[i]; - inx[i] = inx[j]; - inx[j] = tmp; + swap(acirp_cnt[i], acirp_cnt[j]); + swap(inx[i], inx[j]); } } } From 2ccd94e412be244d46fdf3261763d921d4918761 Mon Sep 17 00:00:00 2001 From: Fabian Frederick Date: Wed, 10 Jun 2015 18:32:17 +0200 Subject: [PATCH 0984/1163] staging: rtl8723au: use swap() in WMMOnAssocRsp23a() Use kernel.h macro definition. Thanks to Julia Lawall for Coccinelle scripting support. Signed-off-by: Fabian Frederick Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 5280338aa387..3c1315fc02e5 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -573,7 +573,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, change_inx = false; /* entry indx: 0->vo, 1->vi, 2->be, 3->bk. */ for (i = 0; i < 4; i++) { @@ -589,14 +589,8 @@ void WMMOnAssocRsp23a(struct rtw_adapter *padapter) } if (change_inx) { - tmp = edca[i]; - edca[i] = edca[j]; - edca[j] = tmp; - - tmp = inx[i]; - inx[i] = inx[j]; - inx[j] = tmp; - + swap(edca[i], edca[j]); + swap(inx[i], inx[j]); change_inx = false; } } From 590aeb174ad41292322c12d4fe24885bc7f074e5 Mon Sep 17 00:00:00 2001 From: Fabian Frederick Date: Wed, 10 Jun 2015 18:33:38 +0200 Subject: [PATCH 0985/1163] staging: speakup: use swap() in get_highlight_color() Use kernel.h macro definition. Thanks to Julia Lawall for Coccinelle scripting support. Signed-off-by: Fabian Frederick Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/main.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c index c955976414ee..6c4f9a1ed07f 100644 --- a/drivers/staging/speakup/main.c +++ b/drivers/staging/speakup/main.c @@ -1597,7 +1597,7 @@ static int count_highlight_color(struct vc_data *vc) static int get_highlight_color(struct vc_data *vc) { int i, j; - unsigned int cptr[8], tmp; + unsigned int cptr[8]; int vc_num = vc->vc_num; for (i = 0; i < 8; i++) @@ -1606,11 +1606,8 @@ static int get_highlight_color(struct vc_data *vc) for (i = 0; i < 7; i++) for (j = i + 1; j < 8; j++) if (speakup_console[vc_num]->ht.bgcount[cptr[i]] > - speakup_console[vc_num]->ht.bgcount[cptr[j]]) { - tmp = cptr[i]; - cptr[i] = cptr[j]; - cptr[j] = tmp; - } + speakup_console[vc_num]->ht.bgcount[cptr[j]]) + swap(cptr[i], cptr[j]); for (i = 0; i < 8; i++) if (speakup_console[vc_num]->ht.bgcount[cptr[i]] != 0) From 25e2704c46d2771a1ad51dae35be6d30101480d5 Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Wed, 10 Jun 2015 19:46:25 -0300 Subject: [PATCH 0986/1163] staging: rtl8192u: ieee80211: Fix sparse endianness warnings ieee80211_softmac.c Fix the following endinness warnings detected by sparse: drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:669:34: warning: incorrect type in assignment (different base types) drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:669:34: expected restricted __le16 [usertype] duration_id drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:669:34: got int drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:679:33: warning: incorrect type in assignment (different base types) drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:679:33: expected restricted __le16 [usertype] algorithm drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:679:33: got int drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:1090:32: warning: incorrect type in assignment (different base types) drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:1090:32: expected restricted __le16 [usertype] duration_id drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:1090:32: got int drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:1109:30: warning: incorrect type in assignment (different base types) drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:1109:30: expected restricted __le16 [usertype] listen_interval drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:1109:30: got int drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:3130:24: warning: incorrect type in assignment (different base types) drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:3130:24: expected restricted __le16 [usertype] reason drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:3130:24: got unsigned char [unsigned] [usertype] asRsn Signed-off-by: Gaston Gonzalez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index b00f5fd31abf..5fbade4cf2c4 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -666,7 +666,7 @@ inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *be else auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); - auth->header.duration_id = 0x013a; //FIXME + auth->header.duration_id = cpu_to_le16(0x013a); memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); @@ -676,7 +676,7 @@ inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *be if(ieee->auth_mode == 0) auth->algorithm = WLAN_AUTH_OPEN; else if(ieee->auth_mode == 1) - auth->algorithm = WLAN_AUTH_SHARED_KEY; + auth->algorithm = cpu_to_le16(WLAN_AUTH_SHARED_KEY); else if(ieee->auth_mode == 2) auth->algorithm = WLAN_AUTH_OPEN;//0x80; printk("=================>%s():auth->algorithm is %d\n",__func__,auth->algorithm); @@ -1087,7 +1087,7 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco hdr->header.frame_ctl = IEEE80211_STYPE_ASSOC_REQ; - hdr->header.duration_id= 37; //FIXME + hdr->header.duration_id = cpu_to_le16(37); memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN); memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN); @@ -1106,7 +1106,7 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco if (wmm_info_len) //QOS hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_QOS); - hdr->listen_interval = 0xa; //FIXME + hdr->listen_interval = cpu_to_le16(0xa); hdr->info_element[0].id = MFIE_TYPE_SSID; @@ -3127,7 +3127,7 @@ inline struct sk_buff *ieee80211_disassociate_skb( memcpy(disass->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(disass->header.addr3, beacon->bssid, ETH_ALEN); - disass->reason = asRsn; + disass->reason = cpu_to_le16(asRsn); return skb; } From c40753b5c7ee0d967d56393e760701ca3a924be3 Mon Sep 17 00:00:00 2001 From: Harisangam Sharvari Date: Thu, 11 Jun 2015 12:38:13 +0000 Subject: [PATCH 0987/1163] staging: rtl8192u: Removed redundant bool comparisons in r8192U_dm.c This patch was detected with the help of coccinelle tool. The redundant comparisons of bool variables are removed in r8192U_dm.c. Signed-off-by: Harisangam Sharvari Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index 416a1ddb3ac5..7ca5d8fbc57f 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -563,7 +563,7 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev) break; } } - if (viviflag == true) { + if (viviflag) { write_nic_byte(dev, 0x1ba, 0); viviflag = false; RT_TRACE(COMP_POWER_TRACKING, "we filtered the data\n"); @@ -766,7 +766,7 @@ void dm_txpower_trackingcallback(struct work_struct *work) struct r8192_priv *priv = container_of(dwork, struct r8192_priv, txpower_tracking_wq); struct net_device *dev = priv->ieee80211->dev; - if (priv->bDcut == true) + if (priv->bDcut) dm_TXPowerTrackingCallback_TSSI(dev); else dm_TXPowerTrackingCallback_ThermalMeter(dev); @@ -1301,7 +1301,7 @@ void dm_initialize_txpower_tracking(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); - if (priv->bDcut == true) + if (priv->bDcut) dm_InitializeTXPowerTracking_TSSI(dev); else dm_InitializeTXPowerTracking_ThermalMeter(dev); @@ -1357,7 +1357,7 @@ static void dm_check_txpower_tracking(struct net_device *dev) #ifdef RTL8190P dm_CheckTXPowerTracking_TSSI(dev); #else - if (priv->bDcut == true) + if (priv->bDcut) dm_CheckTXPowerTracking_TSSI(dev); else dm_CheckTXPowerTracking_ThermalMeter(dev); @@ -1467,7 +1467,7 @@ void dm_cck_txpower_adjust(struct net_device *dev, bool binch14) { /* dm_CCKTxPowerAdjust */ struct r8192_priv *priv = ieee80211_priv(dev); - if (priv->bDcut == true) + if (priv->bDcut) dm_CCKTxPowerAdjust_TSSI(dev, binch14); else dm_CCKTxPowerAdjust_ThermalMeter(dev, binch14); @@ -3062,7 +3062,7 @@ static void dm_dynamic_txpower(struct net_device *dev) priv->bDynamicTxLowPower = false; } else { /* high power state check */ - if (priv->undecorated_smoothed_pwdb < txlowpower_threshold && priv->bDynamicTxHighPower == true) + if (priv->undecorated_smoothed_pwdb < txlowpower_threshold && priv->bDynamicTxHighPower) priv->bDynamicTxHighPower = false; /* low power state check */ From 5ee35ea7759ae4a6e25f58ff19d8a60b48510aa5 Mon Sep 17 00:00:00 2001 From: Juston Li Date: Fri, 12 Jun 2015 03:17:22 -0700 Subject: [PATCH 0988/1163] staging: sm750fb: fix c99 comments fixed all checkpatch.pl ERROR: do not use C99 // comments Any C99 comments used to comment out code are simply removed. Also some of the errors occur inside '#if 0' blocks which I might as well fix since checkpatch.pl caught them but the blocks themselves should probably be cleaned up later. Changes since v1: close a comment block Signed-off-by: Juston Li Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/ddk750_chip.c | 11 +----- drivers/staging/sm750fb/ddk750_dvi.c | 4 +- drivers/staging/sm750fb/ddk750_help.c | 2 - drivers/staging/sm750fb/ddk750_sii164.c | 11 ------ drivers/staging/sm750fb/sm750.h | 10 ++--- drivers/staging/sm750fb/sm750_accel.c | 49 ++++++++++++------------- drivers/staging/sm750fb/sm750_accel.h | 2 +- drivers/staging/sm750fb/sm750_cursor.c | 9 ++--- drivers/staging/sm750fb/sm750_help.h | 28 ++------------ drivers/staging/sm750fb/sm750_hw.c | 4 +- drivers/staging/sm750fb/sm750_hw.h | 3 -- 11 files changed, 41 insertions(+), 92 deletions(-) diff --git a/drivers/staging/sm750fb/ddk750_chip.c b/drivers/staging/sm750fb/ddk750_chip.c index 8b47c1bfc401..981736fd3bc4 100644 --- a/drivers/staging/sm750fb/ddk750_chip.c +++ b/drivers/staging/sm750fb/ddk750_chip.c @@ -17,7 +17,7 @@ logical_chip_type_t getChipType(void) char physicalRev; logical_chip_type_t chip; - physicalID = devId750;//either 0x718 or 0x750 + physicalID = devId750; /* either 0x718 or 0x750 */ physicalRev = revId750; if (physicalID == 0x718) @@ -257,7 +257,7 @@ int ddk750_initHw(initchip_param_t *pInitParam) unsigned int ulReg; #if 0 - //move the code to map regiter function. + /* move the code to map regiter function. */ if (getChipType() == SM718) { /* turn on big endian bit*/ ulReg = PEEK32(0x74); @@ -487,8 +487,6 @@ unsigned int calcPllValue(unsigned int request_orig, pll_value_t *pll) } } } - - //printk("Finally: pll->n[%lu],m[%lu],od[%lu],pod[%lu]\n",pll->N,pll->M,pll->OD,pll->POD); return ret; } @@ -580,14 +578,9 @@ pll_value_t *pPLL /* Structure to hold the value to be set in PLL */ } /* Restore input frequency from Khz to hz unit */ -// pPLL->inputFreq *= 1000; ulRequestClk *= 1000; pPLL->inputFreq = DEFAULT_INPUT_CLOCK; /* Default reference clock */ - /* Output debug information */ - //DDKDEBUGPRINT((DISPLAY_LEVEL, "calcPllValue: Requested Frequency = %d\n", ulRequestClk)); - //DDKDEBUGPRINT((DISPLAY_LEVEL, "calcPllValue: Input CLK = %dHz, M=%d, N=%d, OD=%d, POD=%d\n", pPLL->inputFreq, pPLL->M, pPLL->N, pPLL->OD, pPLL->POD)); - /* Return actual frequency that the PLL can set */ ret = calcPLL(pPLL); return ret; diff --git a/drivers/staging/sm750fb/ddk750_dvi.c b/drivers/staging/sm750fb/ddk750_dvi.c index f5932bbf13e8..b2bf7e66d5cb 100644 --- a/drivers/staging/sm750fb/ddk750_dvi.c +++ b/drivers/staging/sm750fb/ddk750_dvi.c @@ -51,7 +51,7 @@ int dviInit( vsyncEnable, deskewEnable, deskewSetting, continuousSyncEnable, pllFilterEnable, pllFilterValue); } - return -1;//error + return -1; /* error */ } @@ -66,7 +66,6 @@ unsigned short dviGetVendorID(void) { dvi_ctrl_device_t *pCurrentDviCtrl; - //pCurrentDviCtrl = getDviCtrl(); pCurrentDviCtrl = g_dcftSupportedDviController; if (pCurrentDviCtrl != (dvi_ctrl_device_t *)0) return pCurrentDviCtrl->pfnGetVendorId(); @@ -86,7 +85,6 @@ unsigned short dviGetDeviceID(void) { dvi_ctrl_device_t *pCurrentDviCtrl; -// pCurrentDviCtrl = getDviCtrl(); pCurrentDviCtrl = g_dcftSupportedDviController; if (pCurrentDviCtrl != (dvi_ctrl_device_t *)0) return pCurrentDviCtrl->pfnGetDeviceId(); diff --git a/drivers/staging/sm750fb/ddk750_help.c b/drivers/staging/sm750fb/ddk750_help.c index 647004d5690c..96c18eb36a2c 100644 --- a/drivers/staging/sm750fb/ddk750_help.c +++ b/drivers/staging/sm750fb/ddk750_help.c @@ -1,5 +1,3 @@ -//#include "ddk750_reg.h" -//#include "ddk750_chip.h" #include "ddk750_help.h" void __iomem * mmio750 = NULL; diff --git a/drivers/staging/sm750fb/ddk750_sii164.c b/drivers/staging/sm750fb/ddk750_sii164.c index 84464c1bfdd8..b6395b87fc21 100644 --- a/drivers/staging/sm750fb/ddk750_sii164.c +++ b/drivers/staging/sm750fb/ddk750_sii164.c @@ -125,10 +125,7 @@ long sii164InitChip( unsigned char pllFilterValue ) { - //unsigned char ucRegIndex, ucRegValue; - //unsigned char ucDeviceAddress, unsigned char config; - //unsigned long delayCount; /* Initialize the i2c bus */ #ifdef USE_HW_I2C @@ -141,10 +138,6 @@ long sii164InitChip( /* Check if SII164 Chip exists */ if ((sii164GetVendorID() == SII164_VENDOR_ID) && (sii164GetDeviceID() == SII164_DEVICE_ID)) { - -#ifdef DDKDEBUG - //sii164PrintRegisterValues(); -#endif /* * Initialize SII164 controller chip. */ @@ -241,10 +234,6 @@ long sii164InitChip( config |= SII164_CONFIGURATION_POWER_NORMAL; i2cWriteReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION, config); -#ifdef DDKDEBUG - //sii164PrintRegisterValues(); -#endif - return 0; } diff --git a/drivers/staging/sm750fb/sm750.h b/drivers/staging/sm750fb/sm750.h index 30aa31239125..273882f9f206 100644 --- a/drivers/staging/sm750fb/sm750.h +++ b/drivers/staging/sm750fb/sm750.h @@ -7,8 +7,6 @@ /* please use revision id to distinguish sm750le and sm750*/ #define SPC_SM750 0 -//#define SPC_SM750LE 8 - #define MB(x) ((x)<<20) #define MHZ(x) ((x) * 1000000) /* align should be 2,4,8,16 */ @@ -95,10 +93,10 @@ struct lynx_cursor{ }; struct lynxfb_crtc{ - unsigned char __iomem * vCursor;//virtual address of cursor - unsigned char __iomem * vScreen;//virtual address of on_screen - int oCursor;//cursor address offset in vidmem - int oScreen;//onscreen address offset in vidmem + unsigned char __iomem * vCursor; /* virtual address of cursor */ + unsigned char __iomem * vScreen; /* virtual address of on_screen */ + int oCursor; /* cursor address offset in vidmem */ + int oScreen; /* onscreen address offset in vidmem */ int channel;/* which channel this crtc stands for*/ resource_size_t vidmem_size;/* this view's video memory max size */ diff --git a/drivers/staging/sm750fb/sm750_accel.c b/drivers/staging/sm750fb/sm750_accel.c index 001e98031056..a2baffdde293 100644 --- a/drivers/staging/sm750fb/sm750_accel.c +++ b/drivers/staging/sm750fb/sm750_accel.c @@ -57,10 +57,10 @@ void hw_de_init(struct lynx_accel * accel) write_dpr(accel, DE_STRETCH_FORMAT, (read_dpr(accel, DE_STRETCH_FORMAT) & clr) | reg); /* disable clipping and transparent */ - write_dpr(accel, DE_CLIP_TL, 0);//dpr2c - write_dpr(accel, DE_CLIP_BR, 0);//dpr30 + write_dpr(accel, DE_CLIP_TL, 0); /* dpr2c */ + write_dpr(accel, DE_CLIP_BR, 0); /* dpr30 */ - write_dpr(accel, DE_COLOR_COMPARE_MASK, 0);//dpr24 + write_dpr(accel, DE_COLOR_COMPARE_MASK, 0); /* dpr24 */ write_dpr(accel, DE_COLOR_COMPARE, 0); reg = FIELD_SET(0, DE_CONTROL, TRANSPARENCY, DISABLE)| @@ -104,25 +104,25 @@ int hw_fillrect(struct lynx_accel * accel, return -1; } - write_dpr(accel, DE_WINDOW_DESTINATION_BASE, base);//dpr40 + write_dpr(accel, DE_WINDOW_DESTINATION_BASE, base); /* dpr40 */ write_dpr(accel, DE_PITCH, FIELD_VALUE(0, DE_PITCH, DESTINATION, pitch/Bpp)| - FIELD_VALUE(0, DE_PITCH, SOURCE, pitch/Bpp));//dpr10 + FIELD_VALUE(0, DE_PITCH, SOURCE, pitch/Bpp)); /* dpr10 */ write_dpr(accel, DE_WINDOW_WIDTH, FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION, pitch/Bpp)| - FIELD_VALUE(0, DE_WINDOW_WIDTH, SOURCE, pitch/Bpp));//dpr44 + FIELD_VALUE(0, DE_WINDOW_WIDTH, SOURCE, pitch/Bpp)); /* dpr44 */ - write_dpr(accel, DE_FOREGROUND, color);//DPR14 + write_dpr(accel, DE_FOREGROUND, color); /* DPR14 */ write_dpr(accel, DE_DESTINATION, FIELD_SET(0, DE_DESTINATION, WRAP, DISABLE)| FIELD_VALUE(0, DE_DESTINATION, X, x)| - FIELD_VALUE(0, DE_DESTINATION, Y, y));//dpr4 + FIELD_VALUE(0, DE_DESTINATION, Y, y)); /* dpr4 */ write_dpr(accel, DE_DIMENSION, FIELD_VALUE(0, DE_DIMENSION, X, width)| - FIELD_VALUE(0, DE_DIMENSION, Y_ET, height));//dpr8 + FIELD_VALUE(0, DE_DIMENSION, Y_ET, height)); /* dpr8 */ deCtrl = FIELD_SET(0, DE_CONTROL, STATUS, START)| @@ -130,7 +130,7 @@ int hw_fillrect(struct lynx_accel * accel, FIELD_SET(0, DE_CONTROL, LAST_PIXEL, ON)| FIELD_SET(0, DE_CONTROL, COMMAND, RECTANGLE_FILL)| FIELD_SET(0, DE_CONTROL, ROP_SELECT, ROP2)| - FIELD_VALUE(0, DE_CONTROL, ROP, rop);//dpr0xc + FIELD_VALUE(0, DE_CONTROL, ROP, rop); /* dpr0xc */ write_dpr(accel, DE_CONTROL, deCtrl); return 0; @@ -236,12 +236,12 @@ unsigned int rop2) /* ROP value */ /* 2D Source Base. It is an address offset (128 bit aligned) from the beginning of frame buffer. */ - write_dpr(accel, DE_WINDOW_SOURCE_BASE, sBase);//dpr40 + write_dpr(accel, DE_WINDOW_SOURCE_BASE, sBase); /* dpr40 */ /* 2D Destination Base. It is an address offset (128 bit aligned) from the beginning of frame buffer. */ - write_dpr(accel, DE_WINDOW_DESTINATION_BASE, dBase);//dpr44 + write_dpr(accel, DE_WINDOW_DESTINATION_BASE, dBase); /* dpr44 */ #if 0 /* Program pitch (distance between the 1st points of two adjacent lines). @@ -254,14 +254,14 @@ unsigned int rop2) /* ROP value */ width *= 3; write_dpr(accel, DE_PITCH, FIELD_VALUE(0, DE_PITCH, DESTINATION, dPitch) | - FIELD_VALUE(0, DE_PITCH, SOURCE, sPitch));//dpr10 + FIELD_VALUE(0, DE_PITCH, SOURCE, sPitch)); /* dpr10 */ } else #endif { write_dpr(accel, DE_PITCH, FIELD_VALUE(0, DE_PITCH, DESTINATION, (dPitch/Bpp)) | - FIELD_VALUE(0, DE_PITCH, SOURCE, (sPitch/Bpp)));//dpr10 + FIELD_VALUE(0, DE_PITCH, SOURCE, (sPitch/Bpp))); /* dpr10 */ } /* Screen Window width in Pixels. @@ -269,7 +269,7 @@ unsigned int rop2) /* ROP value */ */ write_dpr(accel, DE_WINDOW_WIDTH, FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION, (dPitch/Bpp)) | - FIELD_VALUE(0, DE_WINDOW_WIDTH, SOURCE, (sPitch/Bpp)));//dpr3c + FIELD_VALUE(0, DE_WINDOW_WIDTH, SOURCE, (sPitch/Bpp))); /* dpr3c */ if (accel->de_wait() != 0){ return -1; @@ -280,14 +280,14 @@ unsigned int rop2) /* ROP value */ write_dpr(accel, DE_SOURCE, FIELD_SET (0, DE_SOURCE, WRAP, DISABLE) | FIELD_VALUE(0, DE_SOURCE, X_K1, sx) | - FIELD_VALUE(0, DE_SOURCE, Y_K2, sy));//dpr0 + FIELD_VALUE(0, DE_SOURCE, Y_K2, sy)); /* dpr0 */ write_dpr(accel, DE_DESTINATION, FIELD_SET (0, DE_DESTINATION, WRAP, DISABLE) | FIELD_VALUE(0, DE_DESTINATION, X, dx) | - FIELD_VALUE(0, DE_DESTINATION, Y, dy));//dpr04 + FIELD_VALUE(0, DE_DESTINATION, Y, dy)); /* dpr04 */ write_dpr(accel, DE_DIMENSION, FIELD_VALUE(0, DE_DIMENSION, X, width) | - FIELD_VALUE(0, DE_DIMENSION, Y_ET, height));//dpr08 + FIELD_VALUE(0, DE_DIMENSION, Y_ET, height)); /* dpr08 */ de_ctrl = FIELD_VALUE(0, DE_CONTROL, ROP, rop2) | @@ -297,7 +297,7 @@ unsigned int rop2) /* ROP value */ FIELD_SET(0, DE_CONTROL, DIRECTION, RIGHT_TO_LEFT) : FIELD_SET(0, DE_CONTROL, DIRECTION, LEFT_TO_RIGHT)) | FIELD_SET(0, DE_CONTROL, STATUS, START); - write_dpr(accel, DE_CONTROL, de_ctrl);//dpr0c + write_dpr(accel, DE_CONTROL, de_ctrl); /* dpr0c */ } return 0; @@ -346,7 +346,6 @@ int hw_imageblit(struct lynx_accel *accel, if(accel->de_wait() != 0) { -// inf_msg("*** ImageBlit return -1 ***\n"); return -1; } @@ -370,7 +369,7 @@ int hw_imageblit(struct lynx_accel *accel, startBit *= 3; write_dpr(accel, DE_PITCH, FIELD_VALUE(0, DE_PITCH, DESTINATION, dPitch) | - FIELD_VALUE(0, DE_PITCH, SOURCE, dPitch));//dpr10 + FIELD_VALUE(0, DE_PITCH, SOURCE, dPitch)); /* dpr10 */ } else @@ -378,7 +377,7 @@ int hw_imageblit(struct lynx_accel *accel, { write_dpr(accel, DE_PITCH, FIELD_VALUE(0, DE_PITCH, DESTINATION, dPitch/bytePerPixel) | - FIELD_VALUE(0, DE_PITCH, SOURCE, dPitch/bytePerPixel));//dpr10 + FIELD_VALUE(0, DE_PITCH, SOURCE, dPitch/bytePerPixel)); /* dpr10 */ } /* Screen Window width in Pixels. @@ -392,16 +391,16 @@ int hw_imageblit(struct lynx_accel *accel, For mono bitmap, use startBit for X_K1. */ write_dpr(accel, DE_SOURCE, FIELD_SET (0, DE_SOURCE, WRAP, DISABLE) | - FIELD_VALUE(0, DE_SOURCE, X_K1_MONO, startBit));//dpr00 + FIELD_VALUE(0, DE_SOURCE, X_K1_MONO, startBit)); /* dpr00 */ write_dpr(accel, DE_DESTINATION, FIELD_SET (0, DE_DESTINATION, WRAP, DISABLE) | FIELD_VALUE(0, DE_DESTINATION, X, dx) | - FIELD_VALUE(0, DE_DESTINATION, Y, dy));//dpr04 + FIELD_VALUE(0, DE_DESTINATION, Y, dy)); /* dpr04 */ write_dpr(accel, DE_DIMENSION, FIELD_VALUE(0, DE_DIMENSION, X, width) | - FIELD_VALUE(0, DE_DIMENSION, Y_ET, height));//dpr08 + FIELD_VALUE(0, DE_DIMENSION, Y_ET, height)); /* dpr08 */ write_dpr(accel, DE_FOREGROUND, fColor); write_dpr(accel, DE_BACKGROUND, bColor); diff --git a/drivers/staging/sm750fb/sm750_accel.h b/drivers/staging/sm750fb/sm750_accel.h index e9d217b88a50..57e20fb6699e 100644 --- a/drivers/staging/sm750fb/sm750_accel.h +++ b/drivers/staging/sm750fb/sm750_accel.h @@ -113,7 +113,7 @@ #define DE_CONTROL_TRANSPARENCY_ENABLE 1 #define DE_CONTROL_ROP 7:0 -// Pseudo fields. +/* Pseudo fields. */ #define DE_CONTROL_SHORT_STROKE_DIR 27:24 #define DE_CONTROL_SHORT_STROKE_DIR_225 0 diff --git a/drivers/staging/sm750fb/sm750_cursor.c b/drivers/staging/sm750fb/sm750_cursor.c index b14528574d59..cb37ea3bbbea 100644 --- a/drivers/staging/sm750fb/sm750_cursor.c +++ b/drivers/staging/sm750fb/sm750_cursor.c @@ -141,10 +141,10 @@ void hw_cursor_setData(struct lynx_cursor * cursor, { if(opr & (0x80 >> j)) - { //use fg color,id = 2 + { /* use fg color,id = 2 */ data |= 2 << (j*2); }else{ - //use bg color,id = 1 + /* use bg color,id = 1 */ data |= 1 << (j*2); } } @@ -221,10 +221,10 @@ void hw_cursor_setData2(struct lynx_cursor * cursor, { if(opr & (0x80 >> j)) - { //use fg color,id = 2 + { /* use fg color,id = 2 */ data |= 2 << (j*2); }else{ - //use bg color,id = 1 + /* use bg color,id = 1 */ data |= 1 << (j*2); } } @@ -238,7 +238,6 @@ void hw_cursor_setData2(struct lynx_cursor * cursor, /* assume pitch is 1,2,4,8,...*/ if(!(i&(pitch-1))) - //if((i+1) % pitch == 0) { /* need a return */ pstart += offset; diff --git a/drivers/staging/sm750fb/sm750_help.h b/drivers/staging/sm750fb/sm750_help.h index ebc946cfe81b..05777f72c166 100644 --- a/drivers/staging/sm750fb/sm750_help.h +++ b/drivers/staging/sm750fb/sm750_help.h @@ -1,9 +1,7 @@ #ifndef LYNX_HELP_H__ #define LYNX_HELP_H__ -/*****************************************************************************\ - * FIELD MACROS * -\*****************************************************************************/ +/* FIELD MACROS */ #define _LSB(f) (0 ? f) #define _MSB(f) (1 ? f) #define _COUNT(f) (_MSB(f) - _LSB(f) + 1) @@ -17,13 +15,7 @@ #define SET_FIELDV(d, f, v) (((d) & ~GET_MASK(f)) | \ (((v) & RAW_MASK(f)) << _LSB(f))) - -//////////////////////////////////////////////////////////////////////////////// -// // -// Internal macros // -// // -//////////////////////////////////////////////////////////////////////////////// - +/* Internal macros */ #define _F_START(f) (0 ? f) #define _F_END(f) (1 ? f) #define _F_SIZE(f) (1 + _F_END(f) - _F_START(f)) @@ -31,13 +23,7 @@ #define _F_NORMALIZE(v, f) (((v) & _F_MASK(f)) >> _F_START(f)) #define _F_DENORMALIZE(v, f) (((v) << _F_START(f)) & _F_MASK(f)) - -//////////////////////////////////////////////////////////////////////////////// -// // -// Global macros // -// // -//////////////////////////////////////////////////////////////////////////////// - +/* Global macros */ #define FIELD_GET(x, reg, field) \ ( \ _F_NORMALIZE((x), reg ## _ ## field) \ @@ -60,13 +46,7 @@ ~ _F_MASK(reg ## _ ## field) \ ) - -//////////////////////////////////////////////////////////////////////////////// -// // -// Field Macros // -// // -//////////////////////////////////////////////////////////////////////////////// - +/* Field Macros */ #define FIELD_START(field) (0 ? field) #define FIELD_END(field) (1 ? field) #define FIELD_SIZE(field) (1 + FIELD_END(field) - FIELD_START(field)) diff --git a/drivers/staging/sm750fb/sm750_hw.c b/drivers/staging/sm750fb/sm750_hw.c index 131125ca5737..e70961eeb79c 100644 --- a/drivers/staging/sm750fb/sm750_hw.c +++ b/drivers/staging/sm750fb/sm750_hw.c @@ -193,7 +193,6 @@ int hw_sm750_inithw(struct lynx_share* share, struct pci_dev * pdev) /* init 2d engine */ if(!share->accel_off){ hw_sm750_initAccel(share); -// share->accel.de_wait = hw_sm750_deWait; } return 0; @@ -328,7 +327,6 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc* crtc, #endif /* set timing */ -// modparm.pixel_clock = PS_TO_HZ(var->pixclock); modparm.pixel_clock = ps_to_hz(var->pixclock); modparm.vertical_sync_polarity = (var->sync & FB_SYNC_HOR_HIGH_ACT) ? POS:NEG; modparm.horizontal_sync_polarity = (var->sync & FB_SYNC_VERT_HIGH_ACT) ? POS:NEG; @@ -618,7 +616,7 @@ int hw_sm750_pan_display(struct lynxfb_crtc *crtc, const struct fb_info *info) { uint32_t total; - //check params + /* check params */ if ((var->xoffset + var->xres > var->xres_virtual) || (var->yoffset + var->yres > var->yres_virtual)) { return -EINVAL; diff --git a/drivers/staging/sm750fb/sm750_hw.h b/drivers/staging/sm750fb/sm750_hw.h index 4fee28d22b58..93288b3a99d8 100644 --- a/drivers/staging/sm750fb/sm750_hw.h +++ b/drivers/staging/sm750fb/sm750_hw.h @@ -8,9 +8,6 @@ #define SM750LE_REVISION_ID (unsigned char)0xfe #endif -//#define DEFAULT_MEM_CLOCK (DEFAULT_SM750_CHIP_CLOCK/1) -//#define DEFAULT_MASTER_CLOCK (DEFAULT_SM750_CHIP_CLOCK/3) - enum sm750_pnltype{ From 4e1023445343541731f45debf718090310cff632 Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Fri, 12 Jun 2015 00:20:43 +0200 Subject: [PATCH 0989/1163] staging: rtl8188eu: rtw_mlme_ext.c: reorder message callbacks and tables The message handling stored in mlme_sta_tbl and OnAction_tbl are internal and will be declared static, and their declaration removed from rtw_mlme_ext.h, in a later commit. This would break compilation, since they are are referenced before their definition. Reorder these functions and the structures that hold them so that symbols are defined before they are referenced, without the need for forward declarations. This commit only reorders code, there is no content change. Signed-off-by: Luca Ceresoli Cc: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 3291 ++++++++--------- 1 file changed, 1645 insertions(+), 1646 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 052d0f456956..0d1d4bfc6474 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -29,42 +29,6 @@ #include #include -static struct mlme_handler mlme_sta_tbl[] = { - {WIFI_ASSOCREQ, "OnAssocReq", &OnAssocReq}, - {WIFI_ASSOCRSP, "OnAssocRsp", &OnAssocRsp}, - {WIFI_REASSOCREQ, "OnReAssocReq", &OnAssocReq}, - {WIFI_REASSOCRSP, "OnReAssocRsp", &OnAssocRsp}, - {WIFI_PROBEREQ, "OnProbeReq", &OnProbeReq}, - {WIFI_PROBERSP, "OnProbeRsp", &OnProbeRsp}, - - /*---------------------------------------------------------- - below 2 are reserved - -----------------------------------------------------------*/ - {0, "DoReserved", &DoReserved}, - {0, "DoReserved", &DoReserved}, - {WIFI_BEACON, "OnBeacon", &OnBeacon}, - {WIFI_ATIM, "OnATIM", &OnAtim}, - {WIFI_DISASSOC, "OnDisassoc", &OnDisassoc}, - {WIFI_AUTH, "OnAuth", &OnAuthClient}, - {WIFI_DEAUTH, "OnDeAuth", &OnDeAuth}, - {WIFI_ACTION, "OnAction", &OnAction}, -}; - -static struct action_handler OnAction_tbl[] = { - {RTW_WLAN_CATEGORY_SPECTRUM_MGMT, "ACTION_SPECTRUM_MGMT", on_action_spct}, - {RTW_WLAN_CATEGORY_QOS, "ACTION_QOS", &OnAction_qos}, - {RTW_WLAN_CATEGORY_DLS, "ACTION_DLS", &OnAction_dls}, - {RTW_WLAN_CATEGORY_BACK, "ACTION_BACK", &OnAction_back}, - {RTW_WLAN_CATEGORY_PUBLIC, "ACTION_PUBLIC", on_action_public}, - {RTW_WLAN_CATEGORY_RADIO_MEASUREMENT, "ACTION_RADIO_MEASUREMENT", &DoReserved}, - {RTW_WLAN_CATEGORY_FT, "ACTION_FT", &DoReserved}, - {RTW_WLAN_CATEGORY_HT, "ACTION_HT", &OnAction_ht}, - {RTW_WLAN_CATEGORY_SA_QUERY, "ACTION_SA_QUERY", &DoReserved}, - {RTW_WLAN_CATEGORY_WMM, "ACTION_WMM", &OnAction_wmm}, - {RTW_WLAN_CATEGORY_P2P, "ACTION_P2P", &OnAction_p2p}, -}; - - static u8 null_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; /************************************************** @@ -195,1616 +159,6 @@ int rtw_ch_set_search_ch(struct rt_channel_info *ch_set, const u32 ch) return i; } -/**************************************************************************** - -Following are the initialization functions for WiFi MLME - -*****************************************************************************/ - -int init_hw_mlme_ext(struct adapter *padapter) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); - return _SUCCESS; -} - -static void init_mlme_ext_priv_value(struct adapter *padapter) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - unsigned char mixed_datarate[NumRates] = { - _1M_RATE_, _2M_RATE_, _5M_RATE_, _11M_RATE_, _6M_RATE_, - _9M_RATE_, _12M_RATE_, _18M_RATE_, _24M_RATE_, _36M_RATE_, - _48M_RATE_, _54M_RATE_, 0xff - }; - unsigned char mixed_basicrate[NumRates] = { - _1M_RATE_, _2M_RATE_, _5M_RATE_, _11M_RATE_, _6M_RATE_, - _12M_RATE_, _24M_RATE_, 0xff, - }; - - atomic_set(&pmlmeext->event_seq, 0); - pmlmeext->mgnt_seq = 0;/* reset to zero when disconnect at client mode */ - - pmlmeext->cur_channel = padapter->registrypriv.channel; - pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; - pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - pmlmeext->oper_channel = pmlmeext->cur_channel; - pmlmeext->oper_bwmode = pmlmeext->cur_bwmode; - pmlmeext->oper_ch_offset = pmlmeext->cur_ch_offset; - pmlmeext->retry = 0; - - pmlmeext->cur_wireless_mode = padapter->registrypriv.wireless_mode; - - memcpy(pmlmeext->datarate, mixed_datarate, NumRates); - memcpy(pmlmeext->basicrate, mixed_basicrate, NumRates); - - pmlmeext->tx_rate = IEEE80211_CCK_RATE_1MB; - - pmlmeext->sitesurvey_res.state = SCAN_DISABLE; - pmlmeext->sitesurvey_res.channel_idx = 0; - pmlmeext->sitesurvey_res.bss_cnt = 0; - pmlmeext->scan_abort = false; - - pmlmeinfo->state = WIFI_FW_NULL_STATE; - pmlmeinfo->reauth_count = 0; - pmlmeinfo->reassoc_count = 0; - pmlmeinfo->link_count = 0; - pmlmeinfo->auth_seq = 0; - pmlmeinfo->auth_algo = dot11AuthAlgrthm_Open; - pmlmeinfo->key_index = 0; - pmlmeinfo->iv = 0; - - pmlmeinfo->enc_algo = _NO_PRIVACY_; - pmlmeinfo->authModeToggle = 0; - - memset(pmlmeinfo->chg_txt, 0, 128); - - pmlmeinfo->slotTime = SHORT_SLOT_TIME; - pmlmeinfo->preamble_mode = PREAMBLE_AUTO; - - pmlmeinfo->dialogToken = 0; - - pmlmeext->action_public_rxseq = 0xffff; - pmlmeext->action_public_dialog_token = 0xff; -} - -static int has_channel(struct rt_channel_info *channel_set, - u8 chanset_size, - u8 chan) { - int i; - - for (i = 0; i < chanset_size; i++) { - if (channel_set[i].ChannelNum == chan) - return 1; - } - return 0; -} - -static void init_channel_list(struct adapter *padapter, struct rt_channel_info *channel_set, - u8 chanset_size, - struct p2p_channels *channel_list) { - struct p2p_oper_class_map op_class[] = { - { IEEE80211G, 81, 1, 13, 1, BW20 }, - { IEEE80211G, 82, 14, 14, 1, BW20 }, - { -1, 0, 0, 0, 0, BW20 } - }; - - int cla, op; - - cla = 0; - - for (op = 0; op_class[op].op_class; op++) { - u8 ch; - struct p2p_oper_class_map *o = &op_class[op]; - struct p2p_reg_class *reg = NULL; - - for (ch = o->min_chan; ch <= o->max_chan; ch += o->inc) { - if (!has_channel(channel_set, chanset_size, ch)) { - continue; - } - - if ((0 == padapter->registrypriv.ht_enable) && (8 == o->inc)) - continue; - - if ((0 == (padapter->registrypriv.cbw40_enable & BIT(1))) && - ((BW40MINUS == o->bw) || (BW40PLUS == o->bw))) - continue; - - if (reg == NULL) { - reg = &channel_list->reg_class[cla]; - cla++; - reg->reg_class = o->op_class; - reg->channels = 0; - } - reg->channel[reg->channels] = ch; - reg->channels++; - } - } - channel_list->reg_classes = cla; -} - -static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, struct rt_channel_info *channel_set) -{ - u8 index, chanset_size = 0; - u8 b2_4GBand = false; - u8 Index2G = 0; - - memset(channel_set, 0, sizeof(struct rt_channel_info) * MAX_CHANNEL_NUM); - - if (ChannelPlan >= RT_CHANNEL_DOMAIN_MAX && ChannelPlan != RT_CHANNEL_DOMAIN_REALTEK_DEFINE) { - DBG_88E("ChannelPlan ID %x error !!!!!\n", ChannelPlan); - return chanset_size; - } - - if (padapter->registrypriv.wireless_mode & WIRELESS_11G) { - b2_4GBand = true; - if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == ChannelPlan) - Index2G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index2G; - else - Index2G = RTW_ChannelPlanMap[ChannelPlan].Index2G; - } - - if (b2_4GBand) { - for (index = 0; index < RTW_ChannelPlan2G[Index2G].Len; index++) { - channel_set[chanset_size].ChannelNum = RTW_ChannelPlan2G[Index2G].Channel[index]; - - if ((RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN == ChannelPlan) ||/* Channel 1~11 is active, and 12~14 is passive */ - (RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G == ChannelPlan)) { - if (channel_set[chanset_size].ChannelNum >= 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_2G_WORLD == Index2G) {/* channel 12~13, passive scan */ - if (channel_set[chanset_size].ChannelNum <= 11) - channel_set[chanset_size].ScanType = SCAN_ACTIVE; - else - channel_set[chanset_size].ScanType = SCAN_PASSIVE; - } else { - channel_set[chanset_size].ScanType = SCAN_ACTIVE; - } - - chanset_size++; - } - } - return chanset_size; -} - -int init_mlme_ext_priv(struct adapter *padapter) -{ - struct registry_priv *pregistrypriv = &padapter->registrypriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - - pmlmeext->padapter = padapter; - - init_mlme_ext_priv_value(padapter); - pmlmeinfo->bAcceptAddbaReq = pregistrypriv->bAcceptAddbaReq; - - init_mlme_ext_timer(padapter); - -#ifdef CONFIG_88EU_AP_MODE - init_mlme_ap_info(padapter); -#endif - - pmlmeext->max_chan_nums = init_channel_set(padapter, pmlmepriv->ChannelPlan, pmlmeext->channel_set); - init_channel_list(padapter, pmlmeext->channel_set, pmlmeext->max_chan_nums, &pmlmeext->channel_list); - - pmlmeext->chan_scan_time = SURVEY_TO; - pmlmeext->mlmeext_init = true; - - - pmlmeext->active_keep_alive_check = true; - - return _SUCCESS; -} - -void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext) -{ - struct adapter *padapter = pmlmeext->padapter; - - if (!padapter) - return; - - if (padapter->bDriverStopped) { - del_timer_sync(&pmlmeext->survey_timer); - del_timer_sync(&pmlmeext->link_timer); - } -} - -static void _mgt_dispatcher(struct adapter *padapter, struct mlme_handler *ptable, struct recv_frame *precv_frame) -{ - u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - u8 *pframe = precv_frame->rx_data; - - if (ptable->func) { - /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ - if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && - memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) - return; - ptable->func(padapter, precv_frame); - } -} - -void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame) -{ - int index; - struct mlme_handler *ptable; -#ifdef CONFIG_88EU_AP_MODE - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -#endif /* CONFIG_88EU_AP_MODE */ - u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - u8 *pframe = precv_frame->rx_data; - struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, GetAddr2Ptr(pframe)); - - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("+mgt_dispatcher: type(0x%x) subtype(0x%x)\n", - GetFrameType(pframe), GetFrameSubType(pframe))); - - if (GetFrameType(pframe) != WIFI_MGT_TYPE) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("mgt_dispatcher: type(0x%x) error!\n", GetFrameType(pframe))); - return; - } - - /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ - if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && - memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) - return; - - ptable = mlme_sta_tbl; - - index = GetFrameSubType(pframe) >> 4; - - if (index > 13) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Currently we do not support reserved sub-fr-type=%d\n", index)); - return; - } - ptable += index; - - if (psta != NULL) { - if (GetRetry(pframe)) { - if (precv_frame->attrib.seq_num == - psta->RxMgmtFrameSeqNum) { - /* drop the duplicate management frame */ - DBG_88E("Drop duplicate management frame with seq_num=%d.\n", - precv_frame->attrib.seq_num); - return; - } - } - psta->RxMgmtFrameSeqNum = precv_frame->attrib.seq_num; - } - -#ifdef CONFIG_88EU_AP_MODE - switch (GetFrameSubType(pframe)) { - case WIFI_AUTH: - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) - ptable->func = &OnAuth; - else - ptable->func = &OnAuthClient; - /* fall through */ - case WIFI_ASSOCREQ: - case WIFI_REASSOCREQ: - case WIFI_PROBEREQ: - case WIFI_BEACON: - case WIFI_ACTION: - _mgt_dispatcher(padapter, ptable, precv_frame); - break; - default: - _mgt_dispatcher(padapter, ptable, precv_frame); - break; - } -#else - _mgt_dispatcher(padapter, ptable, precv_frame); -#endif -} - -/**************************************************************************** - -Following are the callback functions for each subtype of the management frames - -*****************************************************************************/ - -unsigned int OnProbeReq(struct adapter *padapter, struct recv_frame *precv_frame) -{ - unsigned int ielen; - unsigned char *p; - 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 *cur = &(pmlmeinfo->network); - u8 *pframe = precv_frame->rx_data; - uint len = precv_frame->len; - u8 is_valid_p2p_probereq = false; - - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) - return _SUCCESS; - - if (!check_fwstate(pmlmepriv, _FW_LINKED) && - !check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) - return _SUCCESS; - - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, _SSID_IE_, (int *)&ielen, - len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_); - - /* check (wildcard) SSID */ - if (p != NULL) { - if (is_valid_p2p_probereq) - goto _issue_probersp; - - if ((ielen != 0 && memcmp((void *)(p+2), (void *)cur->Ssid.Ssid, cur->Ssid.SsidLength)) || - (ielen == 0 && pmlmeinfo->hidden_ssid_mode)) - return _SUCCESS; - -_issue_probersp: - - if (check_fwstate(pmlmepriv, _FW_LINKED) && - pmlmepriv->cur_network.join_res) - issue_probersp(padapter, get_sa(pframe), is_valid_p2p_probereq); - } - return _SUCCESS; -} - -unsigned int OnProbeRsp(struct adapter *padapter, struct recv_frame *precv_frame) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { - report_survey_event(padapter, precv_frame); - return _SUCCESS; - } - - return _SUCCESS; -} - -unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) -{ - int cam_idx; - struct sta_info *psta; - 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; - u8 *pframe = precv_frame->rx_data; - uint len = precv_frame->len; - struct wlan_bssid_ex *pbss; - int ret = _SUCCESS; - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); - - if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { - report_survey_event(padapter, precv_frame); - return _SUCCESS; - } - - if (!memcmp(GetAddr3Ptr(pframe), pnetwork->MacAddress, ETH_ALEN)) { - if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { - /* we should update current network before auth, or some IE is wrong */ - pbss = (struct wlan_bssid_ex *)rtw_malloc(sizeof(struct wlan_bssid_ex)); - if (pbss) { - if (collect_bss_info(padapter, precv_frame, pbss) == _SUCCESS) { - update_network(&(pmlmepriv->cur_network.network), pbss, padapter, true); - rtw_get_bcn_info(&(pmlmepriv->cur_network)); - } - kfree(pbss); - } - - /* check the vendor of the assoc AP */ - pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pframe+sizeof(struct rtw_ieee80211_hdr_3addr), len-sizeof(struct rtw_ieee80211_hdr_3addr)); - - /* update TSF Value */ - update_TSF(pmlmeext, pframe, len); - - /* start auth */ - start_clnt_auth(padapter); - - return _SUCCESS; - } - - if (((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) && (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { - psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - if (psta != NULL) { - ret = rtw_check_bcn_info(padapter, pframe, len); - if (!ret) { - DBG_88E_LEVEL(_drv_info_, "ap has changed, disconnect now\n "); - receive_disconnect(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) - update_beacon_info(padapter, pframe, len, psta); - } - } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { - psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - if (psta != NULL) { - /* 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) - update_beacon_info(padapter, pframe, len, psta); - } else { - /* allocate a new CAM entry for IBSS station */ - cam_idx = allocate_fw_sta_entry(padapter); - if (cam_idx == NUM_STA) - goto _END_ONBEACON_; - - /* get supported rate */ - if (update_sta_support_rate(padapter, (pframe + WLAN_HDR_A3_LEN + _BEACON_IE_OFFSET_), (len - WLAN_HDR_A3_LEN - _BEACON_IE_OFFSET_), cam_idx) == _FAIL) { - pmlmeinfo->FW_sta_info[cam_idx].status = 0; - goto _END_ONBEACON_; - } - - /* update TSF Value */ - update_TSF(pmlmeext, pframe, len); - - /* report sta add event */ - report_add_sta_event(padapter, GetAddr2Ptr(pframe), cam_idx); - } - } - } - -_END_ONBEACON_: - - return _SUCCESS; -} - -unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame) -{ -#ifdef CONFIG_88EU_AP_MODE - unsigned int auth_mode, ie_len; - u16 seq; - unsigned char *sa, *p; - u16 algorithm; - int status; - static struct sta_info stat; - 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_info *pmlmeinfo = &(pmlmeext->mlmext_info); - u8 *pframe = precv_frame->rx_data; - uint len = precv_frame->len; - - if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) - return _FAIL; - - DBG_88E("+OnAuth\n"); - - sa = GetAddr2Ptr(pframe); - - auth_mode = psecuritypriv->dot11AuthAlgrthm; - seq = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN + 2)); - algorithm = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN)); - - DBG_88E("auth alg=%x, seq=%X\n", algorithm, seq); - - if (auth_mode == 2 && psecuritypriv->dot11PrivacyAlgrthm != _WEP40_ && - psecuritypriv->dot11PrivacyAlgrthm != _WEP104_) - auth_mode = 0; - - if ((algorithm > 0 && auth_mode == 0) || /* rx a shared-key auth but shared not enabled */ - (algorithm == 0 && auth_mode == 1)) { /* rx a open-system auth but shared-key is enabled */ - DBG_88E("auth rejected due to bad alg [alg=%d, auth_mib=%d] %02X%02X%02X%02X%02X%02X\n", - algorithm, auth_mode, sa[0], sa[1], sa[2], sa[3], sa[4], sa[5]); - - status = _STATS_NO_SUPP_ALG_; - - goto auth_fail; - } - - if (!rtw_access_ctrl(padapter, sa)) { - status = _STATS_UNABLE_HANDLE_STA_; - goto auth_fail; - } - - pstat = rtw_get_stainfo(pstapriv, sa); - if (pstat == NULL) { - /* allocate a new one */ - DBG_88E("going to alloc stainfo for sa=%pM\n", sa); - pstat = rtw_alloc_stainfo(pstapriv, sa); - if (pstat == NULL) { - DBG_88E(" Exceed the upper limit of supported clients...\n"); - status = _STATS_UNABLE_HANDLE_STA_; - goto auth_fail; - } - - pstat->state = WIFI_FW_AUTH_NULL; - pstat->auth_seq = 0; - } else { - spin_lock_bh(&pstapriv->asoc_list_lock); - if (!list_empty(&pstat->asoc_list)) { - list_del_init(&pstat->asoc_list); - pstapriv->asoc_list_cnt--; - } - spin_unlock_bh(&pstapriv->asoc_list_lock); - - if (seq == 1) { - /* TODO: STA re_auth and auth timeout */ - } - } - - spin_lock_bh(&pstapriv->auth_list_lock); - if (list_empty(&pstat->auth_list)) { - list_add_tail(&pstat->auth_list, &pstapriv->auth_list); - pstapriv->auth_list_cnt++; - } - spin_unlock_bh(&pstapriv->auth_list_lock); - - if (pstat->auth_seq == 0) - pstat->expire_to = pstapriv->auth_to; - - if ((pstat->auth_seq + 1) != seq) { - DBG_88E("(1)auth rejected because out of seq [rx_seq=%d, exp_seq=%d]!\n", - seq, pstat->auth_seq+1); - status = _STATS_OUT_OF_AUTH_SEQ_; - goto auth_fail; - } - - if (algorithm == 0 && (auth_mode == 0 || auth_mode == 2)) { - if (seq == 1) { - pstat->state &= ~WIFI_FW_AUTH_NULL; - pstat->state |= WIFI_FW_AUTH_SUCCESS; - pstat->expire_to = pstapriv->assoc_to; - pstat->authalg = algorithm; - } else { - DBG_88E("(2)auth rejected because out of seq [rx_seq=%d, exp_seq=%d]!\n", - seq, pstat->auth_seq+1); - status = _STATS_OUT_OF_AUTH_SEQ_; - goto auth_fail; - } - } else { /* shared system or auto authentication */ - if (seq == 1) { - /* prepare for the challenging txt... */ - - pstat->state &= ~WIFI_FW_AUTH_NULL; - pstat->state |= WIFI_FW_AUTH_STATE; - pstat->authalg = algorithm; - pstat->auth_seq = 2; - } else if (seq == 3) { - /* checking for challenging txt... */ - DBG_88E("checking for challenging txt...\n"); - - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + 4 + _AUTH_IE_OFFSET_ , _CHLGETXT_IE_, (int *)&ie_len, - len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_ - 4); - - if ((p == NULL) || (ie_len <= 0)) { - DBG_88E("auth rejected because challenge failure!(1)\n"); - status = _STATS_CHALLENGE_FAIL_; - goto auth_fail; - } - - if (!memcmp((void *)(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; - } else { - DBG_88E("auth rejected because challenge failure!\n"); - status = _STATS_CHALLENGE_FAIL_; - goto auth_fail; - } - } else { - DBG_88E("(3)auth rejected because out of seq [rx_seq=%d, exp_seq=%d]!\n", - seq, pstat->auth_seq+1); - status = _STATS_OUT_OF_AUTH_SEQ_; - goto auth_fail; - } - } - - /* Now, we are going to issue_auth... */ - pstat->auth_seq = seq + 1; - - issue_auth(padapter, pstat, (unsigned short)(_STATS_SUCCESSFUL_)); - - if (pstat->state & WIFI_FW_AUTH_SUCCESS) - pstat->auth_seq = 0; - - return _SUCCESS; - -auth_fail: - - if (pstat) - rtw_free_stainfo(padapter, pstat); - - pstat = &stat; - memset((char *)pstat, '\0', sizeof(stat)); - pstat->auth_seq = 2; - memcpy(pstat->hwaddr, sa, 6); - - issue_auth(padapter, pstat, (unsigned short)status); - -#endif /* CONFIG_88EU_AP_MODE */ - return _FAIL; -} - -unsigned int OnAuthClient(struct adapter *padapter, struct recv_frame *precv_frame) -{ - unsigned int seq, len, status, offset; - unsigned char *p; - unsigned int go2asoc = 0; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - u8 *pframe = precv_frame->rx_data; - uint pkt_len = precv_frame->len; - - DBG_88E("%s\n", __func__); - - /* check A1 matches or not */ - if (memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN)) - return _SUCCESS; - - if (!(pmlmeinfo->state & WIFI_FW_AUTH_STATE)) - return _SUCCESS; - - offset = (GetPrivacy(pframe)) ? 4 : 0; - - seq = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN + offset + 2)); - status = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN + offset + 4)); - - if (status != 0) { - DBG_88E("clnt auth fail, status: %d\n", status); - if (status == 13) { /* pmlmeinfo->auth_algo == dot11AuthAlgrthm_Auto) */ - if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) - pmlmeinfo->auth_algo = dot11AuthAlgrthm_Open; - else - pmlmeinfo->auth_algo = dot11AuthAlgrthm_Shared; - } - - set_link_timer(pmlmeext, 1); - goto authclnt_fail; - } - - if (seq == 2) { - if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) { - /* legendary shared system */ - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _AUTH_IE_OFFSET_, _CHLGETXT_IE_, (int *)&len, - pkt_len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_); - - if (p == NULL) - goto authclnt_fail; - - memcpy((void *)(pmlmeinfo->chg_txt), (void *)(p + 2), len); - pmlmeinfo->auth_seq = 3; - issue_auth(padapter, NULL, 0); - set_link_timer(pmlmeext, REAUTH_TO); - - return _SUCCESS; - } else { - /* open system */ - go2asoc = 1; - } - } else if (seq == 4) { - if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) - go2asoc = 1; - else - goto authclnt_fail; - } else { - /* this is also illegal */ - goto authclnt_fail; - } - - if (go2asoc) { - DBG_88E_LEVEL(_drv_info_, "auth success, start assoc\n"); - start_clnt_assoc(padapter); - return _SUCCESS; - } -authclnt_fail: - return _FAIL; -} - -unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame) -{ -#ifdef CONFIG_88EU_AP_MODE - u16 capab_info; - struct rtw_ieee802_11_elems elems; - struct sta_info *pstat; - unsigned char reassoc, *p, *pos, *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 = _STATS_SUCCESSFUL_; - unsigned short frame_type, ie_offset = 0; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *cur = &(pmlmeinfo->network); - struct sta_priv *pstapriv = &padapter->stapriv; - u8 *pframe = precv_frame->rx_data; - uint pkt_len = precv_frame->len; - - if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) - return _FAIL; - - frame_type = GetFrameSubType(pframe); - if (frame_type == WIFI_ASSOCREQ) { - reassoc = 0; - ie_offset = _ASOCREQ_IE_OFFSET_; - } else { /* WIFI_REASSOCREQ */ - reassoc = 1; - ie_offset = _REASOCREQ_IE_OFFSET_; - } - - - if (pkt_len < IEEE80211_3ADDR_LEN + ie_offset) { - DBG_88E("handle_assoc(reassoc=%d) - too short payload (len=%lu)" - "\n", reassoc, (unsigned long)pkt_len); - return _FAIL; - } - - pstat = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - if (pstat == NULL) { - status = _RSON_CLS2_; - goto asoc_class2_error; - } - - capab_info = get_unaligned_le16(pframe + WLAN_HDR_A3_LEN); - - left = pkt_len - (IEEE80211_3ADDR_LEN + ie_offset); - pos = pframe + (IEEE80211_3ADDR_LEN + ie_offset); - - - DBG_88E("%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)) { - status = _RSON_CLS2_; - goto asoc_class2_error; - } else { - pstat->state &= (~WIFI_FW_ASSOC_SUCCESS); - pstat->state |= WIFI_FW_ASSOC_STATE; - } - } else { - pstat->state &= (~WIFI_FW_AUTH_SUCCESS); - pstat->state |= WIFI_FW_ASSOC_STATE; - } - pstat->capability = capab_info; - /* now parse all ieee802_11 ie to point to elems */ - if (rtw_ieee802_11_parse_elems(pos, left, &elems, 1) == ParseFailed || - !elems.ssid) { - DBG_88E("STA %pM sent invalid association request\n", - pstat->hwaddr); - status = _STATS_FAILURE_; - goto OnAssocReqFail; - } - - - /* now we should check all the fields... */ - /* checking SSID */ - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _SSID_IE_, &ie_len, - pkt_len - WLAN_HDR_A3_LEN - ie_offset); - if (p == NULL) - status = _STATS_FAILURE_; - - if (ie_len == 0) { /* broadcast ssid, however it is not allowed in assocreq */ - status = _STATS_FAILURE_; - } else { - /* check if ssid match */ - if (memcmp((void *)(p+2), cur->Ssid.Ssid, cur->Ssid.SsidLength)) - status = _STATS_FAILURE_; - - if (ie_len != cur->Ssid.SsidLength) - status = _STATS_FAILURE_; - } - - if (_STATS_SUCCESSFUL_ != status) - goto OnAssocReqFail; - - /* check if the supported rate is ok */ - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _SUPPORTEDRATES_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); - if (p == NULL) { - DBG_88E("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; */ - - status = _STATS_FAILURE_; - goto OnAssocReqFail; - } else { - memcpy(supportRate, p+2, ie_len); - supportRateNum = ie_len; - - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _EXT_SUPPORTEDRATES_IE_ , &ie_len, - pkt_len - WLAN_HDR_A3_LEN - ie_offset); - if (p != NULL) { - if (supportRateNum <= sizeof(supportRate)) { - memcpy(supportRate+supportRateNum, p+2, ie_len); - supportRateNum += ie_len; - } - } - } - - /* todo: mask supportRate between AP & STA -> move to update raid */ - /* get_matched_rate(pmlmeext, supportRate, &supportRateNum, 0); */ - - /* update station supportRate */ - pstat->bssratelen = supportRateNum; - memcpy(pstat->bssrateset, supportRate, supportRateNum); - UpdateBrateTblForSoftAP(pstat->bssrateset, pstat->bssratelen); - - /* check RSN/WPA/WPS */ - pstat->dot8021xalg = 0; - pstat->wpa_psk = 0; - pstat->wpa_group_cipher = 0; - pstat->wpa2_group_cipher = 0; - 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_ie(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_STATUS_INVALID_GROUP_CIPHER; - - if (!pstat->wpa2_pairwise_cipher) - status = WLAN_STATUS_INVALID_PAIRWISE_CIPHER; - } else { - status = WLAN_STATUS_INVALID_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_ie(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; - - 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 (_STATS_SUCCESSFUL_ != status) - goto OnAssocReqFail; - - pstat->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS); - if (wpa_ie == NULL) { - if (elems.wps_ie) { - DBG_88E("STA included WPS IE in " - "(Re)Association Request - assume WPS is " - "used\n"); - pstat->flags |= WLAN_STA_WPS; - /* wpabuf_free(sta->wps_ie); */ - /* sta->wps_ie = wpabuf_alloc_copy(elems.wps_ie + 4, */ - /* elems.wps_ie_len - 4); */ - } else { - DBG_88E("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 */ - /* that the selected registrar of AP is _FLASE */ - 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_content(pmlmepriv->wps_beacon_ie, pmlmepriv->wps_beacon_ie_len, WPS_ATTR_SELECTED_REGISTRAR , &selected_registrar, NULL); - - if (!selected_registrar) { - DBG_88E("selected_registrar is false , or AP is not ready to do WPS\n"); - - status = _STATS_UNABLE_HANDLE_STA_; - - goto OnAssocReqFail; - } - } - } - } else { - int copy_len; - - if (psecuritypriv->wpa_psk == 0) { - DBG_88E("STA %pM: WPA/RSN IE in association " - "request, but AP don't support WPA/RSN\n", pstat->hwaddr); - - status = WLAN_STATUS_INVALID_IE; - - goto OnAssocReqFail; - } - - if (elems.wps_ie) { - DBG_88E("STA included WPS IE in " - "(Re)Association Request - WPS is " - "used\n"); - 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); - } - if (copy_len > 0) - memcpy(pstat->wpa_ie, wpa_ie-2, copy_len); - } - /* check if there is WMM IE & support WWM-PS */ - pstat->flags &= ~WLAN_STA_WME; - pstat->qos_option = 0; - pstat->qos_info = 0; - pstat->has_legacy_ac = true; - pstat->uapsd_vo = 0; - pstat->uapsd_vi = 0; - pstat->uapsd_be = 0; - pstat->uapsd_bk = 0; - if (pmlmepriv->qospriv.qos_option) { - p = pframe + WLAN_HDR_A3_LEN + ie_offset; ie_len = 0; - for (;;) { - p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); - if (p != NULL) { - if (!memcmp(p+2, WMM_IE, 6)) { - pstat->flags |= WLAN_STA_WME; - - pstat->qos_option = 1; - pstat->qos_info = *(p+8); - - pstat->max_sp_len = (pstat->qos_info>>5)&0x3; - - 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)) - pstat->uapsd_vo = BIT(0)|BIT(1); - else - pstat->uapsd_vo = 0; - - if (pstat->qos_info&BIT(1)) - pstat->uapsd_vi = BIT(0)|BIT(1); - else - pstat->uapsd_vi = 0; - - if (pstat->qos_info&BIT(2)) - pstat->uapsd_bk = BIT(0)|BIT(1); - else - pstat->uapsd_bk = 0; - - if (pstat->qos_info&BIT(3)) - pstat->uapsd_be = BIT(0)|BIT(1); - else - pstat->uapsd_be = 0; - } - break; - } - } else { - break; - } - p = p + ie_len + 2; - } - } - - /* save HT capabilities in the sta object */ - memset(&pstat->htpriv.ht_cap, 0, sizeof(struct rtw_ieee80211_ht_cap)); - if (elems.ht_capabilities && elems.ht_capabilities_len >= sizeof(struct rtw_ieee80211_ht_cap)) { - pstat->flags |= WLAN_STA_HT; - - pstat->flags |= WLAN_STA_WME; - - memcpy(&pstat->htpriv.ht_cap, elems.ht_capabilities, sizeof(struct rtw_ieee80211_ht_cap)); - } else { - pstat->flags &= ~WLAN_STA_HT; - } - if ((!pmlmepriv->htpriv.ht_option) && (pstat->flags&WLAN_STA_HT)) { - status = _STATS_FAILURE_; - goto OnAssocReqFail; - } - - if ((pstat->flags & WLAN_STA_HT) && - ((pstat->wpa2_pairwise_cipher&WPA_CIPHER_TKIP) || - (pstat->wpa_pairwise_cipher&WPA_CIPHER_TKIP))) { - DBG_88E("HT: %pM tried to " - "use TKIP with HT association\n", pstat->hwaddr); - - /* status = WLAN_STATUS_CIPHER_REJECTED_PER_POLICY; */ - /* goto OnAssocReqFail; */ - } - - pstat->flags |= WLAN_STA_NONERP; - for (i = 0; i < pstat->bssratelen; i++) { - if ((pstat->bssrateset[i] & 0x7f) > 22) { - pstat->flags &= ~WLAN_STA_NONERP; - break; - } - } - - if (pstat->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) - pstat->flags |= WLAN_STA_SHORT_PREAMBLE; - else - pstat->flags &= ~WLAN_STA_SHORT_PREAMBLE; - - - - if (status != _STATS_SUCCESSFUL_) - goto OnAssocReqFail; - - /* TODO: identify_proprietary_vendor_ie(); */ - /* Realtek proprietary IE */ - /* identify if this is Broadcom sta */ - /* identify if this is ralink sta */ - /* Customer proprietary IE */ - - /* get a unique AID */ - if (pstat->aid > 0) { - DBG_88E(" old AID %d\n", pstat->aid); - } else { - for (pstat->aid = 1; pstat->aid <= NUM_STA; pstat->aid++) - if (pstapriv->sta_aid[pstat->aid - 1] == NULL) - break; - - /* if (pstat->aid > NUM_STA) { */ - if (pstat->aid > pstapriv->max_num_sta) { - pstat->aid = 0; - - DBG_88E(" no room for more AIDs\n"); - - status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; - - goto OnAssocReqFail; - } else { - pstapriv->sta_aid[pstat->aid - 1] = pstat; - DBG_88E("allocate new AID=(%d)\n", pstat->aid); - } - } - - pstat->state &= (~WIFI_FW_ASSOC_STATE); - pstat->state |= WIFI_FW_ASSOC_SUCCESS; - - spin_lock_bh(&pstapriv->auth_list_lock); - if (!list_empty(&pstat->auth_list)) { - list_del_init(&pstat->auth_list); - pstapriv->auth_list_cnt--; - } - spin_unlock_bh(&pstapriv->auth_list_lock); - - spin_lock_bh(&pstapriv->asoc_list_lock); - if (list_empty(&pstat->asoc_list)) { - pstat->expire_to = pstapriv->expire_to; - list_add_tail(&pstat->asoc_list, &pstapriv->asoc_list); - pstapriv->asoc_list_cnt++; - } - spin_unlock_bh(&pstapriv->asoc_list_lock); - - /* now the station is qualified to join our BSS... */ - if (pstat && (pstat->state & WIFI_FW_ASSOC_SUCCESS) && (_STATS_SUCCESSFUL_ == status)) { - /* 1 bss_cap_update & sta_info_update */ - bss_cap_update_on_sta_join(padapter, pstat); - sta_info_update(padapter, pstat); - - /* issue assoc rsp before notify station join event. */ - if (frame_type == WIFI_ASSOCREQ) - issue_asocrsp(padapter, status, pstat, WIFI_ASSOCRSP); - else - issue_asocrsp(padapter, status, pstat, WIFI_REASSOCRSP); - - /* 2 - report to upper layer */ - DBG_88E("indicate_sta_join_event to upper layer - hostapd\n"); - rtw_indicate_sta_assoc_event(padapter, pstat); - - /* 3-(1) report sta add event */ - report_add_sta_event(padapter, pstat->hwaddr, pstat->aid); - } - - return _SUCCESS; - -asoc_class2_error: - - issue_deauth(padapter, (void *)GetAddr2Ptr(pframe), status); - - return _FAIL; - -OnAssocReqFail: - - pstat->aid = 0; - if (frame_type == WIFI_ASSOCREQ) - issue_asocrsp(padapter, status, pstat, WIFI_ASSOCRSP); - else - issue_asocrsp(padapter, status, pstat, WIFI_REASSOCRSP); - -#endif /* CONFIG_88EU_AP_MODE */ - - return _FAIL; -} - -unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *precv_frame) -{ - uint i; - int res; - unsigned short status; - struct ndis_802_11_var_ie *pIE; - 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 *cur_network = &(pmlmeinfo->network); */ - u8 *pframe = precv_frame->rx_data; - uint pkt_len = precv_frame->len; - - DBG_88E("%s\n", __func__); - - /* check A1 matches or not */ - if (memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN)) - return _SUCCESS; - - if (!(pmlmeinfo->state & (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE))) - return _SUCCESS; - - if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) - return _SUCCESS; - - del_timer_sync(&pmlmeext->link_timer); - - /* status */ - status = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + 2)); - if (status > 0) { - DBG_88E("assoc reject, status code: %d\n", status); - pmlmeinfo->state = WIFI_FW_NULL_STATE; - res = -4; - goto report_assoc_result; - } - - /* get capabilities */ - pmlmeinfo->capability = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN)); - - /* set slot time */ - pmlmeinfo->slotTime = (pmlmeinfo->capability & BIT(10)) ? 9 : 20; - - /* AID */ - pmlmeinfo->aid = (int)(le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + 4))&0x3fff); - res = pmlmeinfo->aid; - - /* 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 + WLAN_HDR_A3_LEN); i < pkt_len;) { - pIE = (struct ndis_802_11_var_ie *)(pframe + i); - - switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: - if (!memcmp(pIE->data, WMM_PARA_OUI, 6)) /* WMM */ - WMM_param_handler(padapter, pIE); - break; - case _HT_CAPABILITY_IE_: /* HT caps */ - HT_caps_handler(padapter, pIE); - break; - case _HT_EXTRA_INFO_IE_: /* HT info */ - HT_info_handler(padapter, pIE); - break; - case _ERPINFO_IE_: - ERP_IE_handler(padapter, pIE); - default: - break; - } - - i += (pIE->Length + 2); - } - - pmlmeinfo->state &= (~WIFI_FW_ASSOC_STATE); - pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS; - - /* Update Basic Rate Table for spec, 2010-12-28 , by thomas */ - UpdateBrateTbl(padapter, pmlmeinfo->network.SupportedRates); - -report_assoc_result: - if (res > 0) { - rtw_buf_update(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len, pframe, pkt_len); - } else { - rtw_buf_free(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len); - } - - report_join_res(padapter, res); - - return _SUCCESS; -} - -unsigned int OnDeAuth(struct 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_info *pmlmeinfo = &(pmlmeext->mlmext_info); - u8 *pframe = precv_frame->rx_data; - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); - - /* check A3 */ - if (memcmp(GetAddr3Ptr(pframe), pnetwork->MacAddress, ETH_ALEN)) - return _SUCCESS; - - reason = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN)); - - DBG_88E("%s Reason code(%d)\n", __func__, reason); - -#ifdef CONFIG_88EU_AP_MODE - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - struct sta_info *psta; - struct sta_priv *pstapriv = &padapter->stapriv; - - DBG_88E_LEVEL(_drv_always_, "ap recv deauth reason code(%d) sta:%pM\n", - reason, GetAddr2Ptr(pframe)); - - psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - if (psta) { - u8 updated = 0; - - spin_lock_bh(&pstapriv->asoc_list_lock); - if (!list_empty(&psta->asoc_list)) { - list_del_init(&psta->asoc_list); - pstapriv->asoc_list_cnt--; - updated = ap_free_sta(padapter, psta, false, reason); - } - spin_unlock_bh(&pstapriv->asoc_list_lock); - - associated_clients_update(padapter, updated); - } - - - return _SUCCESS; - } else -#endif - { - DBG_88E_LEVEL(_drv_always_, "sta recv deauth reason code(%d) sta:%pM\n", - reason, GetAddr3Ptr(pframe)); - - receive_disconnect(padapter, GetAddr3Ptr(pframe) , reason); - } - pmlmepriv->LinkDetectInfo.bBusyTraffic = false; - return _SUCCESS; -} - -unsigned int OnDisassoc(struct adapter *padapter, struct recv_frame *precv_frame) -{ - u16 reason; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - u8 *pframe = precv_frame->rx_data; - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); - - /* check A3 */ - if (memcmp(GetAddr3Ptr(pframe), pnetwork->MacAddress, ETH_ALEN)) - return _SUCCESS; - - reason = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN)); - - DBG_88E("%s Reason code(%d)\n", __func__, reason); - -#ifdef CONFIG_88EU_AP_MODE - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - struct sta_info *psta; - struct sta_priv *pstapriv = &padapter->stapriv; - - DBG_88E_LEVEL(_drv_always_, "ap recv disassoc reason code(%d) sta:%pM\n", - reason, GetAddr2Ptr(pframe)); - - psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - if (psta) { - u8 updated = 0; - - spin_lock_bh(&pstapriv->asoc_list_lock); - if (!list_empty(&psta->asoc_list)) { - list_del_init(&psta->asoc_list); - pstapriv->asoc_list_cnt--; - updated = ap_free_sta(padapter, psta, false, reason); - } - spin_unlock_bh(&pstapriv->asoc_list_lock); - - associated_clients_update(padapter, updated); - } - - return _SUCCESS; - } else -#endif - { - DBG_88E_LEVEL(_drv_always_, "ap recv disassoc reason code(%d) sta:%pM\n", - reason, GetAddr3Ptr(pframe)); - - receive_disconnect(padapter, GetAddr3Ptr(pframe), reason); - } - pmlmepriv->LinkDetectInfo.bBusyTraffic = false; - return _SUCCESS; -} - -unsigned int OnAtim(struct adapter *padapter, struct recv_frame *precv_frame) -{ - DBG_88E("%s\n", __func__); - return _SUCCESS; -} - -unsigned int on_action_spct(struct adapter *padapter, struct recv_frame *precv_frame) -{ - struct sta_info *psta = NULL; - struct sta_priv *pstapriv = &padapter->stapriv; - u8 *pframe = precv_frame->rx_data; - u8 *frame_body = (u8 *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); - u8 category; - u8 action; - - DBG_88E(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(padapter->pnetdev)); - - psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - - if (!psta) - goto exit; - - category = frame_body[0]; - if (category != RTW_WLAN_CATEGORY_SPECTRUM_MGMT) - goto exit; - - action = frame_body[1]; - switch (action) { - case RTW_WLAN_ACTION_SPCT_MSR_REQ: - case RTW_WLAN_ACTION_SPCT_MSR_RPRT: - case RTW_WLAN_ACTION_SPCT_TPC_REQ: - case RTW_WLAN_ACTION_SPCT_TPC_RPRT: - break; - case RTW_WLAN_ACTION_SPCT_CHL_SWITCH: - break; - default: - break; - } - -exit: - return _FAIL; -} - -unsigned int OnAction_qos(struct adapter *padapter, struct recv_frame *precv_frame) -{ - return _SUCCESS; -} - -unsigned int OnAction_dls(struct adapter *padapter, struct recv_frame *precv_frame) -{ - return _SUCCESS; -} - -unsigned int OnAction_back(struct 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; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - u8 *pframe = precv_frame->rx_data; - struct sta_priv *pstapriv = &padapter->stapriv; - /* check RA matches or not */ - if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), - ETH_ALEN))/* for if1, sta/ap mode */ - return _SUCCESS; - - DBG_88E("%s\n", __func__); - - if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) - if (!(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) - return _SUCCESS; - - addr = GetAddr2Ptr(pframe); - psta = rtw_get_stainfo(pstapriv, addr); - - if (psta == NULL) - return _SUCCESS; - - frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); - - category = frame_body[0]; - if (category == RTW_WLAN_CATEGORY_BACK) { /* representing Block Ack */ - if (!pmlmeinfo->HT_enable) - return _SUCCESS; - action = frame_body[1]; - DBG_88E("%s, action=%d\n", __func__, action); - switch (action) { - case RTW_WLAN_ACTION_ADDBA_REQ: /* ADDBA request */ - memcpy(&(pmlmeinfo->ADDBA_req), &(frame_body[2]), sizeof(struct ADDBA_request)); - process_addba_req(padapter, (u8 *)&(pmlmeinfo->ADDBA_req), addr); - - if (pmlmeinfo->bAcceptAddbaReq) - issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 0); - else - issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 37);/* reject ADDBA Req */ - break; - case RTW_WLAN_ACTION_ADDBA_RESP: /* ADDBA response */ - status = get_unaligned_le16(&frame_body[3]); - tid = (frame_body[5] >> 2) & 0x7; - if (status == 0) { /* successful */ - DBG_88E("agg_enable for TID=%d\n", tid); - psta->htpriv.agg_enable_bitmap |= 1 << tid; - psta->htpriv.candidate_tid_bitmap &= ~BIT(tid); - } else { - psta->htpriv.agg_enable_bitmap &= ~BIT(tid); - } - break; - case RTW_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)); - 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_88E("%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; -} - -static s32 rtw_action_public_decache(struct recv_frame *recv_frame, s32 token) -{ - struct adapter *adapter = recv_frame->adapter; - struct mlme_ext_priv *mlmeext = &(adapter->mlmeextpriv); - u8 *frame = recv_frame->rx_data; - u16 seq_ctrl = ((recv_frame->attrib.seq_num&0xffff) << 4) | - (recv_frame->attrib.frag_num & 0xf); - - if (GetRetry(frame)) { - if (token >= 0) { - if ((seq_ctrl == mlmeext->action_public_rxseq) && (token == mlmeext->action_public_dialog_token)) { - DBG_88E(FUNC_ADPT_FMT" seq_ctrl = 0x%x, rxseq = 0x%x, token:%d\n", - FUNC_ADPT_ARG(adapter), seq_ctrl, mlmeext->action_public_rxseq, token); - return _FAIL; - } - } else { - if (seq_ctrl == mlmeext->action_public_rxseq) { - DBG_88E(FUNC_ADPT_FMT" seq_ctrl = 0x%x, rxseq = 0x%x\n", - FUNC_ADPT_ARG(adapter), seq_ctrl, mlmeext->action_public_rxseq); - return _FAIL; - } - } - } - - mlmeext->action_public_rxseq = seq_ctrl; - - if (token >= 0) - mlmeext->action_public_dialog_token = token; - - return _SUCCESS; -} - -static unsigned int on_action_public_p2p(struct recv_frame *precv_frame) -{ - u8 *pframe = precv_frame->rx_data; - u8 *frame_body; - u8 dialogToken = 0; - frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); - - dialogToken = frame_body[7]; - - if (rtw_action_public_decache(precv_frame, dialogToken) == _FAIL) - return _FAIL; - - return _SUCCESS; -} - -static unsigned int on_action_public_vendor(struct recv_frame *precv_frame) -{ - unsigned int ret = _FAIL; - u8 *pframe = precv_frame->rx_data; - u8 *frame_body = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); - - if (!memcmp(frame_body + 2, P2P_OUI, 4)) - ret = on_action_public_p2p(precv_frame); - - return ret; -} - -static unsigned int on_action_public_default(struct recv_frame *precv_frame, u8 action) -{ - unsigned int ret = _FAIL; - u8 *pframe = precv_frame->rx_data; - u8 *frame_body = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); - u8 token; - - token = frame_body[2]; - - if (rtw_action_public_decache(precv_frame, token) == _FAIL) - goto exit; - - ret = _SUCCESS; - -exit: - return ret; -} - -unsigned int on_action_public(struct adapter *padapter, struct recv_frame *precv_frame) -{ - unsigned int ret = _FAIL; - u8 *pframe = precv_frame->rx_data; - u8 *frame_body = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); - u8 category, action; - - /* check RA matches or not */ - if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN)) - goto exit; - - category = frame_body[0]; - if (category != RTW_WLAN_CATEGORY_PUBLIC) - goto exit; - - action = frame_body[1]; - switch (action) { - case ACT_PUBLIC_VENDOR: - ret = on_action_public_vendor(precv_frame); - break; - default: - ret = on_action_public_default(precv_frame, action); - break; - } - -exit: - return ret; -} - -unsigned int OnAction_ht(struct adapter *padapter, struct recv_frame *precv_frame) -{ - return _SUCCESS; -} - -unsigned int OnAction_wmm(struct adapter *padapter, struct recv_frame *precv_frame) -{ - return _SUCCESS; -} - -unsigned int OnAction_p2p(struct adapter *padapter, struct recv_frame *precv_frame) -{ - return _SUCCESS; -} - -unsigned int OnAction(struct adapter *padapter, struct recv_frame *precv_frame) -{ - int i; - unsigned char category; - struct action_handler *ptable; - unsigned char *frame_body; - u8 *pframe = precv_frame->rx_data; - - frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); - - category = frame_body[0]; - - for (i = 0; i < sizeof(OnAction_tbl)/sizeof(struct action_handler); i++) { - ptable = &OnAction_tbl[i]; - if (category == ptable->num) - ptable->func(padapter, precv_frame); - } - return _SUCCESS; -} - -unsigned int DoReserved(struct adapter *padapter, struct recv_frame *precv_frame) -{ - return _SUCCESS; -} - struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv) { struct xmit_frame *pmgntframe; @@ -4211,6 +2565,1651 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid /**************************************************************************** +Following are the callback functions for each subtype of the management frames + +*****************************************************************************/ + +unsigned int OnProbeReq(struct adapter *padapter, struct recv_frame *precv_frame) +{ + unsigned int ielen; + unsigned char *p; + 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 *cur = &(pmlmeinfo->network); + u8 *pframe = precv_frame->rx_data; + uint len = precv_frame->len; + u8 is_valid_p2p_probereq = false; + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) + return _SUCCESS; + + if (!check_fwstate(pmlmepriv, _FW_LINKED) && + !check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) + return _SUCCESS; + + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, _SSID_IE_, (int *)&ielen, + len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_); + + /* check (wildcard) SSID */ + if (p != NULL) { + if (is_valid_p2p_probereq) + goto _issue_probersp; + + if ((ielen != 0 && memcmp((void *)(p+2), (void *)cur->Ssid.Ssid, cur->Ssid.SsidLength)) || + (ielen == 0 && pmlmeinfo->hidden_ssid_mode)) + return _SUCCESS; + +_issue_probersp: + + if (check_fwstate(pmlmepriv, _FW_LINKED) && + pmlmepriv->cur_network.join_res) + issue_probersp(padapter, get_sa(pframe), is_valid_p2p_probereq); + } + return _SUCCESS; +} + +unsigned int OnProbeRsp(struct adapter *padapter, struct recv_frame *precv_frame) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { + report_survey_event(padapter, precv_frame); + return _SUCCESS; + } + + return _SUCCESS; +} + +unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) +{ + int cam_idx; + struct sta_info *psta; + 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; + u8 *pframe = precv_frame->rx_data; + uint len = precv_frame->len; + struct wlan_bssid_ex *pbss; + int ret = _SUCCESS; + struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + + if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { + report_survey_event(padapter, precv_frame); + return _SUCCESS; + } + + if (!memcmp(GetAddr3Ptr(pframe), pnetwork->MacAddress, ETH_ALEN)) { + if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { + /* we should update current network before auth, or some IE is wrong */ + pbss = (struct wlan_bssid_ex *)rtw_malloc(sizeof(struct wlan_bssid_ex)); + if (pbss) { + if (collect_bss_info(padapter, precv_frame, pbss) == _SUCCESS) { + update_network(&(pmlmepriv->cur_network.network), pbss, padapter, true); + rtw_get_bcn_info(&(pmlmepriv->cur_network)); + } + kfree(pbss); + } + + /* check the vendor of the assoc AP */ + pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pframe+sizeof(struct rtw_ieee80211_hdr_3addr), len-sizeof(struct rtw_ieee80211_hdr_3addr)); + + /* update TSF Value */ + update_TSF(pmlmeext, pframe, len); + + /* start auth */ + start_clnt_auth(padapter); + + return _SUCCESS; + } + + if (((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) && (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { + psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + if (psta != NULL) { + ret = rtw_check_bcn_info(padapter, pframe, len); + if (!ret) { + DBG_88E_LEVEL(_drv_info_, "ap has changed, disconnect now\n "); + receive_disconnect(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) + update_beacon_info(padapter, pframe, len, psta); + } + } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + if (psta != NULL) { + /* 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) + update_beacon_info(padapter, pframe, len, psta); + } else { + /* allocate a new CAM entry for IBSS station */ + cam_idx = allocate_fw_sta_entry(padapter); + if (cam_idx == NUM_STA) + goto _END_ONBEACON_; + + /* get supported rate */ + if (update_sta_support_rate(padapter, (pframe + WLAN_HDR_A3_LEN + _BEACON_IE_OFFSET_), (len - WLAN_HDR_A3_LEN - _BEACON_IE_OFFSET_), cam_idx) == _FAIL) { + pmlmeinfo->FW_sta_info[cam_idx].status = 0; + goto _END_ONBEACON_; + } + + /* update TSF Value */ + update_TSF(pmlmeext, pframe, len); + + /* report sta add event */ + report_add_sta_event(padapter, GetAddr2Ptr(pframe), cam_idx); + } + } + } + +_END_ONBEACON_: + + return _SUCCESS; +} + +unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame) +{ +#ifdef CONFIG_88EU_AP_MODE + unsigned int auth_mode, ie_len; + u16 seq; + unsigned char *sa, *p; + u16 algorithm; + int status; + static struct sta_info stat; + 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_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 *pframe = precv_frame->rx_data; + uint len = precv_frame->len; + + if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + return _FAIL; + + DBG_88E("+OnAuth\n"); + + sa = GetAddr2Ptr(pframe); + + auth_mode = psecuritypriv->dot11AuthAlgrthm; + seq = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN + 2)); + algorithm = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN)); + + DBG_88E("auth alg=%x, seq=%X\n", algorithm, seq); + + if (auth_mode == 2 && psecuritypriv->dot11PrivacyAlgrthm != _WEP40_ && + psecuritypriv->dot11PrivacyAlgrthm != _WEP104_) + auth_mode = 0; + + if ((algorithm > 0 && auth_mode == 0) || /* rx a shared-key auth but shared not enabled */ + (algorithm == 0 && auth_mode == 1)) { /* rx a open-system auth but shared-key is enabled */ + DBG_88E("auth rejected due to bad alg [alg=%d, auth_mib=%d] %02X%02X%02X%02X%02X%02X\n", + algorithm, auth_mode, sa[0], sa[1], sa[2], sa[3], sa[4], sa[5]); + + status = _STATS_NO_SUPP_ALG_; + + goto auth_fail; + } + + if (!rtw_access_ctrl(padapter, sa)) { + status = _STATS_UNABLE_HANDLE_STA_; + goto auth_fail; + } + + pstat = rtw_get_stainfo(pstapriv, sa); + if (pstat == NULL) { + /* allocate a new one */ + DBG_88E("going to alloc stainfo for sa=%pM\n", sa); + pstat = rtw_alloc_stainfo(pstapriv, sa); + if (pstat == NULL) { + DBG_88E(" Exceed the upper limit of supported clients...\n"); + status = _STATS_UNABLE_HANDLE_STA_; + goto auth_fail; + } + + pstat->state = WIFI_FW_AUTH_NULL; + pstat->auth_seq = 0; + } else { + spin_lock_bh(&pstapriv->asoc_list_lock); + if (!list_empty(&pstat->asoc_list)) { + list_del_init(&pstat->asoc_list); + pstapriv->asoc_list_cnt--; + } + spin_unlock_bh(&pstapriv->asoc_list_lock); + + if (seq == 1) { + /* TODO: STA re_auth and auth timeout */ + } + } + + spin_lock_bh(&pstapriv->auth_list_lock); + if (list_empty(&pstat->auth_list)) { + list_add_tail(&pstat->auth_list, &pstapriv->auth_list); + pstapriv->auth_list_cnt++; + } + spin_unlock_bh(&pstapriv->auth_list_lock); + + if (pstat->auth_seq == 0) + pstat->expire_to = pstapriv->auth_to; + + if ((pstat->auth_seq + 1) != seq) { + DBG_88E("(1)auth rejected because out of seq [rx_seq=%d, exp_seq=%d]!\n", + seq, pstat->auth_seq+1); + status = _STATS_OUT_OF_AUTH_SEQ_; + goto auth_fail; + } + + if (algorithm == 0 && (auth_mode == 0 || auth_mode == 2)) { + if (seq == 1) { + pstat->state &= ~WIFI_FW_AUTH_NULL; + pstat->state |= WIFI_FW_AUTH_SUCCESS; + pstat->expire_to = pstapriv->assoc_to; + pstat->authalg = algorithm; + } else { + DBG_88E("(2)auth rejected because out of seq [rx_seq=%d, exp_seq=%d]!\n", + seq, pstat->auth_seq+1); + status = _STATS_OUT_OF_AUTH_SEQ_; + goto auth_fail; + } + } else { /* shared system or auto authentication */ + if (seq == 1) { + /* prepare for the challenging txt... */ + + pstat->state &= ~WIFI_FW_AUTH_NULL; + pstat->state |= WIFI_FW_AUTH_STATE; + pstat->authalg = algorithm; + pstat->auth_seq = 2; + } else if (seq == 3) { + /* checking for challenging txt... */ + DBG_88E("checking for challenging txt...\n"); + + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + 4 + _AUTH_IE_OFFSET_ , _CHLGETXT_IE_, (int *)&ie_len, + len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_ - 4); + + if ((p == NULL) || (ie_len <= 0)) { + DBG_88E("auth rejected because challenge failure!(1)\n"); + status = _STATS_CHALLENGE_FAIL_; + goto auth_fail; + } + + if (!memcmp((void *)(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; + } else { + DBG_88E("auth rejected because challenge failure!\n"); + status = _STATS_CHALLENGE_FAIL_; + goto auth_fail; + } + } else { + DBG_88E("(3)auth rejected because out of seq [rx_seq=%d, exp_seq=%d]!\n", + seq, pstat->auth_seq+1); + status = _STATS_OUT_OF_AUTH_SEQ_; + goto auth_fail; + } + } + + /* Now, we are going to issue_auth... */ + pstat->auth_seq = seq + 1; + + issue_auth(padapter, pstat, (unsigned short)(_STATS_SUCCESSFUL_)); + + if (pstat->state & WIFI_FW_AUTH_SUCCESS) + pstat->auth_seq = 0; + + return _SUCCESS; + +auth_fail: + + if (pstat) + rtw_free_stainfo(padapter, pstat); + + pstat = &stat; + memset((char *)pstat, '\0', sizeof(stat)); + pstat->auth_seq = 2; + memcpy(pstat->hwaddr, sa, 6); + + issue_auth(padapter, pstat, (unsigned short)status); + +#endif /* CONFIG_88EU_AP_MODE */ + return _FAIL; +} + +unsigned int OnAuthClient(struct adapter *padapter, struct recv_frame *precv_frame) +{ + unsigned int seq, len, status, offset; + unsigned char *p; + unsigned int go2asoc = 0; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 *pframe = precv_frame->rx_data; + uint pkt_len = precv_frame->len; + + DBG_88E("%s\n", __func__); + + /* check A1 matches or not */ + if (memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN)) + return _SUCCESS; + + if (!(pmlmeinfo->state & WIFI_FW_AUTH_STATE)) + return _SUCCESS; + + offset = (GetPrivacy(pframe)) ? 4 : 0; + + seq = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN + offset + 2)); + status = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN + offset + 4)); + + if (status != 0) { + DBG_88E("clnt auth fail, status: %d\n", status); + if (status == 13) { /* pmlmeinfo->auth_algo == dot11AuthAlgrthm_Auto) */ + if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) + pmlmeinfo->auth_algo = dot11AuthAlgrthm_Open; + else + pmlmeinfo->auth_algo = dot11AuthAlgrthm_Shared; + } + + set_link_timer(pmlmeext, 1); + goto authclnt_fail; + } + + if (seq == 2) { + if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) { + /* legendary shared system */ + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _AUTH_IE_OFFSET_, _CHLGETXT_IE_, (int *)&len, + pkt_len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_); + + if (p == NULL) + goto authclnt_fail; + + memcpy((void *)(pmlmeinfo->chg_txt), (void *)(p + 2), len); + pmlmeinfo->auth_seq = 3; + issue_auth(padapter, NULL, 0); + set_link_timer(pmlmeext, REAUTH_TO); + + return _SUCCESS; + } else { + /* open system */ + go2asoc = 1; + } + } else if (seq == 4) { + if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) + go2asoc = 1; + else + goto authclnt_fail; + } else { + /* this is also illegal */ + goto authclnt_fail; + } + + if (go2asoc) { + DBG_88E_LEVEL(_drv_info_, "auth success, start assoc\n"); + start_clnt_assoc(padapter); + return _SUCCESS; + } +authclnt_fail: + return _FAIL; +} + +unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame) +{ +#ifdef CONFIG_88EU_AP_MODE + u16 capab_info; + struct rtw_ieee802_11_elems elems; + struct sta_info *pstat; + unsigned char reassoc, *p, *pos, *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 = _STATS_SUCCESSFUL_; + unsigned short frame_type, ie_offset = 0; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur = &(pmlmeinfo->network); + struct sta_priv *pstapriv = &padapter->stapriv; + u8 *pframe = precv_frame->rx_data; + uint pkt_len = precv_frame->len; + + if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + return _FAIL; + + frame_type = GetFrameSubType(pframe); + if (frame_type == WIFI_ASSOCREQ) { + reassoc = 0; + ie_offset = _ASOCREQ_IE_OFFSET_; + } else { /* WIFI_REASSOCREQ */ + reassoc = 1; + ie_offset = _REASOCREQ_IE_OFFSET_; + } + + + if (pkt_len < IEEE80211_3ADDR_LEN + ie_offset) { + DBG_88E("handle_assoc(reassoc=%d) - too short payload (len=%lu)" + "\n", reassoc, (unsigned long)pkt_len); + return _FAIL; + } + + pstat = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + if (pstat == NULL) { + status = _RSON_CLS2_; + goto asoc_class2_error; + } + + capab_info = get_unaligned_le16(pframe + WLAN_HDR_A3_LEN); + + left = pkt_len - (IEEE80211_3ADDR_LEN + ie_offset); + pos = pframe + (IEEE80211_3ADDR_LEN + ie_offset); + + + DBG_88E("%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)) { + status = _RSON_CLS2_; + goto asoc_class2_error; + } else { + pstat->state &= (~WIFI_FW_ASSOC_SUCCESS); + pstat->state |= WIFI_FW_ASSOC_STATE; + } + } else { + pstat->state &= (~WIFI_FW_AUTH_SUCCESS); + pstat->state |= WIFI_FW_ASSOC_STATE; + } + pstat->capability = capab_info; + /* now parse all ieee802_11 ie to point to elems */ + if (rtw_ieee802_11_parse_elems(pos, left, &elems, 1) == ParseFailed || + !elems.ssid) { + DBG_88E("STA %pM sent invalid association request\n", + pstat->hwaddr); + status = _STATS_FAILURE_; + goto OnAssocReqFail; + } + + + /* now we should check all the fields... */ + /* checking SSID */ + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _SSID_IE_, &ie_len, + pkt_len - WLAN_HDR_A3_LEN - ie_offset); + if (p == NULL) + status = _STATS_FAILURE_; + + if (ie_len == 0) { /* broadcast ssid, however it is not allowed in assocreq */ + status = _STATS_FAILURE_; + } else { + /* check if ssid match */ + if (memcmp((void *)(p+2), cur->Ssid.Ssid, cur->Ssid.SsidLength)) + status = _STATS_FAILURE_; + + if (ie_len != cur->Ssid.SsidLength) + status = _STATS_FAILURE_; + } + + if (_STATS_SUCCESSFUL_ != status) + goto OnAssocReqFail; + + /* check if the supported rate is ok */ + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _SUPPORTEDRATES_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); + if (p == NULL) { + DBG_88E("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; */ + + status = _STATS_FAILURE_; + goto OnAssocReqFail; + } else { + memcpy(supportRate, p+2, ie_len); + supportRateNum = ie_len; + + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _EXT_SUPPORTEDRATES_IE_ , &ie_len, + pkt_len - WLAN_HDR_A3_LEN - ie_offset); + if (p != NULL) { + if (supportRateNum <= sizeof(supportRate)) { + memcpy(supportRate+supportRateNum, p+2, ie_len); + supportRateNum += ie_len; + } + } + } + + /* todo: mask supportRate between AP & STA -> move to update raid */ + /* get_matched_rate(pmlmeext, supportRate, &supportRateNum, 0); */ + + /* update station supportRate */ + pstat->bssratelen = supportRateNum; + memcpy(pstat->bssrateset, supportRate, supportRateNum); + UpdateBrateTblForSoftAP(pstat->bssrateset, pstat->bssratelen); + + /* check RSN/WPA/WPS */ + pstat->dot8021xalg = 0; + pstat->wpa_psk = 0; + pstat->wpa_group_cipher = 0; + pstat->wpa2_group_cipher = 0; + 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_ie(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_STATUS_INVALID_GROUP_CIPHER; + + if (!pstat->wpa2_pairwise_cipher) + status = WLAN_STATUS_INVALID_PAIRWISE_CIPHER; + } else { + status = WLAN_STATUS_INVALID_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_ie(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; + + 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 (_STATS_SUCCESSFUL_ != status) + goto OnAssocReqFail; + + pstat->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS); + if (wpa_ie == NULL) { + if (elems.wps_ie) { + DBG_88E("STA included WPS IE in " + "(Re)Association Request - assume WPS is " + "used\n"); + pstat->flags |= WLAN_STA_WPS; + /* wpabuf_free(sta->wps_ie); */ + /* sta->wps_ie = wpabuf_alloc_copy(elems.wps_ie + 4, */ + /* elems.wps_ie_len - 4); */ + } else { + DBG_88E("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 */ + /* that the selected registrar of AP is _FLASE */ + 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_content(pmlmepriv->wps_beacon_ie, pmlmepriv->wps_beacon_ie_len, WPS_ATTR_SELECTED_REGISTRAR , &selected_registrar, NULL); + + if (!selected_registrar) { + DBG_88E("selected_registrar is false , or AP is not ready to do WPS\n"); + + status = _STATS_UNABLE_HANDLE_STA_; + + goto OnAssocReqFail; + } + } + } + } else { + int copy_len; + + if (psecuritypriv->wpa_psk == 0) { + DBG_88E("STA %pM: WPA/RSN IE in association " + "request, but AP don't support WPA/RSN\n", pstat->hwaddr); + + status = WLAN_STATUS_INVALID_IE; + + goto OnAssocReqFail; + } + + if (elems.wps_ie) { + DBG_88E("STA included WPS IE in " + "(Re)Association Request - WPS is " + "used\n"); + 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); + } + if (copy_len > 0) + memcpy(pstat->wpa_ie, wpa_ie-2, copy_len); + } + /* check if there is WMM IE & support WWM-PS */ + pstat->flags &= ~WLAN_STA_WME; + pstat->qos_option = 0; + pstat->qos_info = 0; + pstat->has_legacy_ac = true; + pstat->uapsd_vo = 0; + pstat->uapsd_vi = 0; + pstat->uapsd_be = 0; + pstat->uapsd_bk = 0; + if (pmlmepriv->qospriv.qos_option) { + p = pframe + WLAN_HDR_A3_LEN + ie_offset; ie_len = 0; + for (;;) { + p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); + if (p != NULL) { + if (!memcmp(p+2, WMM_IE, 6)) { + pstat->flags |= WLAN_STA_WME; + + pstat->qos_option = 1; + pstat->qos_info = *(p+8); + + pstat->max_sp_len = (pstat->qos_info>>5)&0x3; + + 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)) + pstat->uapsd_vo = BIT(0)|BIT(1); + else + pstat->uapsd_vo = 0; + + if (pstat->qos_info&BIT(1)) + pstat->uapsd_vi = BIT(0)|BIT(1); + else + pstat->uapsd_vi = 0; + + if (pstat->qos_info&BIT(2)) + pstat->uapsd_bk = BIT(0)|BIT(1); + else + pstat->uapsd_bk = 0; + + if (pstat->qos_info&BIT(3)) + pstat->uapsd_be = BIT(0)|BIT(1); + else + pstat->uapsd_be = 0; + } + break; + } + } else { + break; + } + p = p + ie_len + 2; + } + } + + /* save HT capabilities in the sta object */ + memset(&pstat->htpriv.ht_cap, 0, sizeof(struct rtw_ieee80211_ht_cap)); + if (elems.ht_capabilities && elems.ht_capabilities_len >= sizeof(struct rtw_ieee80211_ht_cap)) { + pstat->flags |= WLAN_STA_HT; + + pstat->flags |= WLAN_STA_WME; + + memcpy(&pstat->htpriv.ht_cap, elems.ht_capabilities, sizeof(struct rtw_ieee80211_ht_cap)); + } else { + pstat->flags &= ~WLAN_STA_HT; + } + if ((!pmlmepriv->htpriv.ht_option) && (pstat->flags&WLAN_STA_HT)) { + status = _STATS_FAILURE_; + goto OnAssocReqFail; + } + + if ((pstat->flags & WLAN_STA_HT) && + ((pstat->wpa2_pairwise_cipher&WPA_CIPHER_TKIP) || + (pstat->wpa_pairwise_cipher&WPA_CIPHER_TKIP))) { + DBG_88E("HT: %pM tried to " + "use TKIP with HT association\n", pstat->hwaddr); + + /* status = WLAN_STATUS_CIPHER_REJECTED_PER_POLICY; */ + /* goto OnAssocReqFail; */ + } + + pstat->flags |= WLAN_STA_NONERP; + for (i = 0; i < pstat->bssratelen; i++) { + if ((pstat->bssrateset[i] & 0x7f) > 22) { + pstat->flags &= ~WLAN_STA_NONERP; + break; + } + } + + if (pstat->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) + pstat->flags |= WLAN_STA_SHORT_PREAMBLE; + else + pstat->flags &= ~WLAN_STA_SHORT_PREAMBLE; + + + + if (status != _STATS_SUCCESSFUL_) + goto OnAssocReqFail; + + /* TODO: identify_proprietary_vendor_ie(); */ + /* Realtek proprietary IE */ + /* identify if this is Broadcom sta */ + /* identify if this is ralink sta */ + /* Customer proprietary IE */ + + /* get a unique AID */ + if (pstat->aid > 0) { + DBG_88E(" old AID %d\n", pstat->aid); + } else { + for (pstat->aid = 1; pstat->aid <= NUM_STA; pstat->aid++) + if (pstapriv->sta_aid[pstat->aid - 1] == NULL) + break; + + /* if (pstat->aid > NUM_STA) { */ + if (pstat->aid > pstapriv->max_num_sta) { + pstat->aid = 0; + + DBG_88E(" no room for more AIDs\n"); + + status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; + + goto OnAssocReqFail; + } else { + pstapriv->sta_aid[pstat->aid - 1] = pstat; + DBG_88E("allocate new AID=(%d)\n", pstat->aid); + } + } + + pstat->state &= (~WIFI_FW_ASSOC_STATE); + pstat->state |= WIFI_FW_ASSOC_SUCCESS; + + spin_lock_bh(&pstapriv->auth_list_lock); + if (!list_empty(&pstat->auth_list)) { + list_del_init(&pstat->auth_list); + pstapriv->auth_list_cnt--; + } + spin_unlock_bh(&pstapriv->auth_list_lock); + + spin_lock_bh(&pstapriv->asoc_list_lock); + if (list_empty(&pstat->asoc_list)) { + pstat->expire_to = pstapriv->expire_to; + list_add_tail(&pstat->asoc_list, &pstapriv->asoc_list); + pstapriv->asoc_list_cnt++; + } + spin_unlock_bh(&pstapriv->asoc_list_lock); + + /* now the station is qualified to join our BSS... */ + if (pstat && (pstat->state & WIFI_FW_ASSOC_SUCCESS) && (_STATS_SUCCESSFUL_ == status)) { + /* 1 bss_cap_update & sta_info_update */ + bss_cap_update_on_sta_join(padapter, pstat); + sta_info_update(padapter, pstat); + + /* issue assoc rsp before notify station join event. */ + if (frame_type == WIFI_ASSOCREQ) + issue_asocrsp(padapter, status, pstat, WIFI_ASSOCRSP); + else + issue_asocrsp(padapter, status, pstat, WIFI_REASSOCRSP); + + /* 2 - report to upper layer */ + DBG_88E("indicate_sta_join_event to upper layer - hostapd\n"); + rtw_indicate_sta_assoc_event(padapter, pstat); + + /* 3-(1) report sta add event */ + report_add_sta_event(padapter, pstat->hwaddr, pstat->aid); + } + + return _SUCCESS; + +asoc_class2_error: + + issue_deauth(padapter, (void *)GetAddr2Ptr(pframe), status); + + return _FAIL; + +OnAssocReqFail: + + pstat->aid = 0; + if (frame_type == WIFI_ASSOCREQ) + issue_asocrsp(padapter, status, pstat, WIFI_ASSOCRSP); + else + issue_asocrsp(padapter, status, pstat, WIFI_REASSOCRSP); + +#endif /* CONFIG_88EU_AP_MODE */ + + return _FAIL; +} + +unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *precv_frame) +{ + uint i; + int res; + unsigned short status; + struct ndis_802_11_var_ie *pIE; + 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 *cur_network = &(pmlmeinfo->network); */ + u8 *pframe = precv_frame->rx_data; + uint pkt_len = precv_frame->len; + + DBG_88E("%s\n", __func__); + + /* check A1 matches or not */ + if (memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN)) + return _SUCCESS; + + if (!(pmlmeinfo->state & (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE))) + return _SUCCESS; + + if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) + return _SUCCESS; + + del_timer_sync(&pmlmeext->link_timer); + + /* status */ + status = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + 2)); + if (status > 0) { + DBG_88E("assoc reject, status code: %d\n", status); + pmlmeinfo->state = WIFI_FW_NULL_STATE; + res = -4; + goto report_assoc_result; + } + + /* get capabilities */ + pmlmeinfo->capability = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN)); + + /* set slot time */ + pmlmeinfo->slotTime = (pmlmeinfo->capability & BIT(10)) ? 9 : 20; + + /* AID */ + pmlmeinfo->aid = (int)(le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + 4))&0x3fff); + res = pmlmeinfo->aid; + + /* 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 + WLAN_HDR_A3_LEN); i < pkt_len;) { + pIE = (struct ndis_802_11_var_ie *)(pframe + i); + + switch (pIE->ElementID) { + case _VENDOR_SPECIFIC_IE_: + if (!memcmp(pIE->data, WMM_PARA_OUI, 6)) /* WMM */ + WMM_param_handler(padapter, pIE); + break; + case _HT_CAPABILITY_IE_: /* HT caps */ + HT_caps_handler(padapter, pIE); + break; + case _HT_EXTRA_INFO_IE_: /* HT info */ + HT_info_handler(padapter, pIE); + break; + case _ERPINFO_IE_: + ERP_IE_handler(padapter, pIE); + default: + break; + } + + i += (pIE->Length + 2); + } + + pmlmeinfo->state &= (~WIFI_FW_ASSOC_STATE); + pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS; + + /* Update Basic Rate Table for spec, 2010-12-28 , by thomas */ + UpdateBrateTbl(padapter, pmlmeinfo->network.SupportedRates); + +report_assoc_result: + if (res > 0) { + rtw_buf_update(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len, pframe, pkt_len); + } else { + rtw_buf_free(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len); + } + + report_join_res(padapter, res); + + return _SUCCESS; +} + +unsigned int OnDeAuth(struct 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_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 *pframe = precv_frame->rx_data; + struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + + /* check A3 */ + if (memcmp(GetAddr3Ptr(pframe), pnetwork->MacAddress, ETH_ALEN)) + return _SUCCESS; + + reason = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN)); + + DBG_88E("%s Reason code(%d)\n", __func__, reason); + +#ifdef CONFIG_88EU_AP_MODE + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + struct sta_info *psta; + struct sta_priv *pstapriv = &padapter->stapriv; + + DBG_88E_LEVEL(_drv_always_, "ap recv deauth reason code(%d) sta:%pM\n", + reason, GetAddr2Ptr(pframe)); + + psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + if (psta) { + u8 updated = 0; + + spin_lock_bh(&pstapriv->asoc_list_lock); + if (!list_empty(&psta->asoc_list)) { + list_del_init(&psta->asoc_list); + pstapriv->asoc_list_cnt--; + updated = ap_free_sta(padapter, psta, false, reason); + } + spin_unlock_bh(&pstapriv->asoc_list_lock); + + associated_clients_update(padapter, updated); + } + + + return _SUCCESS; + } else +#endif + { + DBG_88E_LEVEL(_drv_always_, "sta recv deauth reason code(%d) sta:%pM\n", + reason, GetAddr3Ptr(pframe)); + + receive_disconnect(padapter, GetAddr3Ptr(pframe) , reason); + } + pmlmepriv->LinkDetectInfo.bBusyTraffic = false; + return _SUCCESS; +} + +unsigned int OnDisassoc(struct adapter *padapter, struct recv_frame *precv_frame) +{ + u16 reason; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 *pframe = precv_frame->rx_data; + struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + + /* check A3 */ + if (memcmp(GetAddr3Ptr(pframe), pnetwork->MacAddress, ETH_ALEN)) + return _SUCCESS; + + reason = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN)); + + DBG_88E("%s Reason code(%d)\n", __func__, reason); + +#ifdef CONFIG_88EU_AP_MODE + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + struct sta_info *psta; + struct sta_priv *pstapriv = &padapter->stapriv; + + DBG_88E_LEVEL(_drv_always_, "ap recv disassoc reason code(%d) sta:%pM\n", + reason, GetAddr2Ptr(pframe)); + + psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + if (psta) { + u8 updated = 0; + + spin_lock_bh(&pstapriv->asoc_list_lock); + if (!list_empty(&psta->asoc_list)) { + list_del_init(&psta->asoc_list); + pstapriv->asoc_list_cnt--; + updated = ap_free_sta(padapter, psta, false, reason); + } + spin_unlock_bh(&pstapriv->asoc_list_lock); + + associated_clients_update(padapter, updated); + } + + return _SUCCESS; + } else +#endif + { + DBG_88E_LEVEL(_drv_always_, "ap recv disassoc reason code(%d) sta:%pM\n", + reason, GetAddr3Ptr(pframe)); + + receive_disconnect(padapter, GetAddr3Ptr(pframe), reason); + } + pmlmepriv->LinkDetectInfo.bBusyTraffic = false; + return _SUCCESS; +} + +unsigned int OnAtim(struct adapter *padapter, struct recv_frame *precv_frame) +{ + DBG_88E("%s\n", __func__); + return _SUCCESS; +} + +unsigned int on_action_spct(struct adapter *padapter, struct recv_frame *precv_frame) +{ + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + u8 *pframe = precv_frame->rx_data; + u8 *frame_body = (u8 *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); + u8 category; + u8 action; + + DBG_88E(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(padapter->pnetdev)); + + psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + + if (!psta) + goto exit; + + category = frame_body[0]; + if (category != RTW_WLAN_CATEGORY_SPECTRUM_MGMT) + goto exit; + + action = frame_body[1]; + switch (action) { + case RTW_WLAN_ACTION_SPCT_MSR_REQ: + case RTW_WLAN_ACTION_SPCT_MSR_RPRT: + case RTW_WLAN_ACTION_SPCT_TPC_REQ: + case RTW_WLAN_ACTION_SPCT_TPC_RPRT: + break; + case RTW_WLAN_ACTION_SPCT_CHL_SWITCH: + break; + default: + break; + } + +exit: + return _FAIL; +} + +unsigned int OnAction_qos(struct adapter *padapter, struct recv_frame *precv_frame) +{ + return _SUCCESS; +} + +unsigned int OnAction_dls(struct adapter *padapter, struct recv_frame *precv_frame) +{ + return _SUCCESS; +} + +unsigned int OnAction_back(struct 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; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 *pframe = precv_frame->rx_data; + struct sta_priv *pstapriv = &padapter->stapriv; + /* check RA matches or not */ + if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), + ETH_ALEN))/* for if1, sta/ap mode */ + return _SUCCESS; + + DBG_88E("%s\n", __func__); + + if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + if (!(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) + return _SUCCESS; + + addr = GetAddr2Ptr(pframe); + psta = rtw_get_stainfo(pstapriv, addr); + + if (psta == NULL) + return _SUCCESS; + + frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); + + category = frame_body[0]; + if (category == RTW_WLAN_CATEGORY_BACK) { /* representing Block Ack */ + if (!pmlmeinfo->HT_enable) + return _SUCCESS; + action = frame_body[1]; + DBG_88E("%s, action=%d\n", __func__, action); + switch (action) { + case RTW_WLAN_ACTION_ADDBA_REQ: /* ADDBA request */ + memcpy(&(pmlmeinfo->ADDBA_req), &(frame_body[2]), sizeof(struct ADDBA_request)); + process_addba_req(padapter, (u8 *)&(pmlmeinfo->ADDBA_req), addr); + + if (pmlmeinfo->bAcceptAddbaReq) + issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 0); + else + issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 37);/* reject ADDBA Req */ + break; + case RTW_WLAN_ACTION_ADDBA_RESP: /* ADDBA response */ + status = get_unaligned_le16(&frame_body[3]); + tid = (frame_body[5] >> 2) & 0x7; + if (status == 0) { /* successful */ + DBG_88E("agg_enable for TID=%d\n", tid); + psta->htpriv.agg_enable_bitmap |= 1 << tid; + psta->htpriv.candidate_tid_bitmap &= ~BIT(tid); + } else { + psta->htpriv.agg_enable_bitmap &= ~BIT(tid); + } + break; + case RTW_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)); + 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_88E("%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; +} + +static s32 rtw_action_public_decache(struct recv_frame *recv_frame, s32 token) +{ + struct adapter *adapter = recv_frame->adapter; + struct mlme_ext_priv *mlmeext = &(adapter->mlmeextpriv); + u8 *frame = recv_frame->rx_data; + u16 seq_ctrl = ((recv_frame->attrib.seq_num&0xffff) << 4) | + (recv_frame->attrib.frag_num & 0xf); + + if (GetRetry(frame)) { + if (token >= 0) { + if ((seq_ctrl == mlmeext->action_public_rxseq) && (token == mlmeext->action_public_dialog_token)) { + DBG_88E(FUNC_ADPT_FMT" seq_ctrl = 0x%x, rxseq = 0x%x, token:%d\n", + FUNC_ADPT_ARG(adapter), seq_ctrl, mlmeext->action_public_rxseq, token); + return _FAIL; + } + } else { + if (seq_ctrl == mlmeext->action_public_rxseq) { + DBG_88E(FUNC_ADPT_FMT" seq_ctrl = 0x%x, rxseq = 0x%x\n", + FUNC_ADPT_ARG(adapter), seq_ctrl, mlmeext->action_public_rxseq); + return _FAIL; + } + } + } + + mlmeext->action_public_rxseq = seq_ctrl; + + if (token >= 0) + mlmeext->action_public_dialog_token = token; + + return _SUCCESS; +} + +static unsigned int on_action_public_p2p(struct recv_frame *precv_frame) +{ + u8 *pframe = precv_frame->rx_data; + u8 *frame_body; + u8 dialogToken = 0; + frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); + + dialogToken = frame_body[7]; + + if (rtw_action_public_decache(precv_frame, dialogToken) == _FAIL) + return _FAIL; + + return _SUCCESS; +} + +static unsigned int on_action_public_vendor(struct recv_frame *precv_frame) +{ + unsigned int ret = _FAIL; + u8 *pframe = precv_frame->rx_data; + u8 *frame_body = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); + + if (!memcmp(frame_body + 2, P2P_OUI, 4)) + ret = on_action_public_p2p(precv_frame); + + return ret; +} + +static unsigned int on_action_public_default(struct recv_frame *precv_frame, u8 action) +{ + unsigned int ret = _FAIL; + u8 *pframe = precv_frame->rx_data; + u8 *frame_body = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); + u8 token; + + token = frame_body[2]; + + if (rtw_action_public_decache(precv_frame, token) == _FAIL) + goto exit; + + ret = _SUCCESS; + +exit: + return ret; +} + +unsigned int on_action_public(struct adapter *padapter, struct recv_frame *precv_frame) +{ + unsigned int ret = _FAIL; + u8 *pframe = precv_frame->rx_data; + u8 *frame_body = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); + u8 category, action; + + /* check RA matches or not */ + if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN)) + goto exit; + + category = frame_body[0]; + if (category != RTW_WLAN_CATEGORY_PUBLIC) + goto exit; + + action = frame_body[1]; + switch (action) { + case ACT_PUBLIC_VENDOR: + ret = on_action_public_vendor(precv_frame); + break; + default: + ret = on_action_public_default(precv_frame, action); + break; + } + +exit: + return ret; +} + +unsigned int OnAction_ht(struct adapter *padapter, struct recv_frame *precv_frame) +{ + return _SUCCESS; +} + +unsigned int OnAction_wmm(struct adapter *padapter, struct recv_frame *precv_frame) +{ + return _SUCCESS; +} + +unsigned int OnAction_p2p(struct adapter *padapter, struct recv_frame *precv_frame) +{ + return _SUCCESS; +} + +unsigned int DoReserved(struct adapter *padapter, struct recv_frame *precv_frame) +{ + return _SUCCESS; +} + +static struct action_handler OnAction_tbl[] = { + {RTW_WLAN_CATEGORY_SPECTRUM_MGMT, "ACTION_SPECTRUM_MGMT", on_action_spct}, + {RTW_WLAN_CATEGORY_QOS, "ACTION_QOS", &OnAction_qos}, + {RTW_WLAN_CATEGORY_DLS, "ACTION_DLS", &OnAction_dls}, + {RTW_WLAN_CATEGORY_BACK, "ACTION_BACK", &OnAction_back}, + {RTW_WLAN_CATEGORY_PUBLIC, "ACTION_PUBLIC", on_action_public}, + {RTW_WLAN_CATEGORY_RADIO_MEASUREMENT, "ACTION_RADIO_MEASUREMENT", &DoReserved}, + {RTW_WLAN_CATEGORY_FT, "ACTION_FT", &DoReserved}, + {RTW_WLAN_CATEGORY_HT, "ACTION_HT", &OnAction_ht}, + {RTW_WLAN_CATEGORY_SA_QUERY, "ACTION_SA_QUERY", &DoReserved}, + {RTW_WLAN_CATEGORY_WMM, "ACTION_WMM", &OnAction_wmm}, + {RTW_WLAN_CATEGORY_P2P, "ACTION_P2P", &OnAction_p2p}, +}; + +unsigned int OnAction(struct adapter *padapter, struct recv_frame *precv_frame) +{ + int i; + unsigned char category; + struct action_handler *ptable; + unsigned char *frame_body; + u8 *pframe = precv_frame->rx_data; + + frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); + + category = frame_body[0]; + + for (i = 0; i < sizeof(OnAction_tbl)/sizeof(struct action_handler); i++) { + ptable = &OnAction_tbl[i]; + if (category == ptable->num) + ptable->func(padapter, precv_frame); + } + return _SUCCESS; +} + +/**************************************************************************** + +Following are the initialization functions for WiFi MLME + +*****************************************************************************/ + +static struct mlme_handler mlme_sta_tbl[] = { + {WIFI_ASSOCREQ, "OnAssocReq", &OnAssocReq}, + {WIFI_ASSOCRSP, "OnAssocRsp", &OnAssocRsp}, + {WIFI_REASSOCREQ, "OnReAssocReq", &OnAssocReq}, + {WIFI_REASSOCRSP, "OnReAssocRsp", &OnAssocRsp}, + {WIFI_PROBEREQ, "OnProbeReq", &OnProbeReq}, + {WIFI_PROBERSP, "OnProbeRsp", &OnProbeRsp}, + + /*---------------------------------------------------------- + below 2 are reserved + -----------------------------------------------------------*/ + {0, "DoReserved", &DoReserved}, + {0, "DoReserved", &DoReserved}, + {WIFI_BEACON, "OnBeacon", &OnBeacon}, + {WIFI_ATIM, "OnATIM", &OnAtim}, + {WIFI_DISASSOC, "OnDisassoc", &OnDisassoc}, + {WIFI_AUTH, "OnAuth", &OnAuthClient}, + {WIFI_DEAUTH, "OnDeAuth", &OnDeAuth}, + {WIFI_ACTION, "OnAction", &OnAction}, +}; + +int init_hw_mlme_ext(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); + return _SUCCESS; +} + +static void init_mlme_ext_priv_value(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + unsigned char mixed_datarate[NumRates] = { + _1M_RATE_, _2M_RATE_, _5M_RATE_, _11M_RATE_, _6M_RATE_, + _9M_RATE_, _12M_RATE_, _18M_RATE_, _24M_RATE_, _36M_RATE_, + _48M_RATE_, _54M_RATE_, 0xff + }; + unsigned char mixed_basicrate[NumRates] = { + _1M_RATE_, _2M_RATE_, _5M_RATE_, _11M_RATE_, _6M_RATE_, + _12M_RATE_, _24M_RATE_, 0xff, + }; + + atomic_set(&pmlmeext->event_seq, 0); + pmlmeext->mgnt_seq = 0;/* reset to zero when disconnect at client mode */ + + pmlmeext->cur_channel = padapter->registrypriv.channel; + pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + pmlmeext->oper_channel = pmlmeext->cur_channel; + pmlmeext->oper_bwmode = pmlmeext->cur_bwmode; + pmlmeext->oper_ch_offset = pmlmeext->cur_ch_offset; + pmlmeext->retry = 0; + + pmlmeext->cur_wireless_mode = padapter->registrypriv.wireless_mode; + + memcpy(pmlmeext->datarate, mixed_datarate, NumRates); + memcpy(pmlmeext->basicrate, mixed_basicrate, NumRates); + + pmlmeext->tx_rate = IEEE80211_CCK_RATE_1MB; + + pmlmeext->sitesurvey_res.state = SCAN_DISABLE; + pmlmeext->sitesurvey_res.channel_idx = 0; + pmlmeext->sitesurvey_res.bss_cnt = 0; + pmlmeext->scan_abort = false; + + pmlmeinfo->state = WIFI_FW_NULL_STATE; + pmlmeinfo->reauth_count = 0; + pmlmeinfo->reassoc_count = 0; + pmlmeinfo->link_count = 0; + pmlmeinfo->auth_seq = 0; + pmlmeinfo->auth_algo = dot11AuthAlgrthm_Open; + pmlmeinfo->key_index = 0; + pmlmeinfo->iv = 0; + + pmlmeinfo->enc_algo = _NO_PRIVACY_; + pmlmeinfo->authModeToggle = 0; + + memset(pmlmeinfo->chg_txt, 0, 128); + + pmlmeinfo->slotTime = SHORT_SLOT_TIME; + pmlmeinfo->preamble_mode = PREAMBLE_AUTO; + + pmlmeinfo->dialogToken = 0; + + pmlmeext->action_public_rxseq = 0xffff; + pmlmeext->action_public_dialog_token = 0xff; +} + +static int has_channel(struct rt_channel_info *channel_set, + u8 chanset_size, + u8 chan) { + int i; + + for (i = 0; i < chanset_size; i++) { + if (channel_set[i].ChannelNum == chan) + return 1; + } + return 0; +} + +static void init_channel_list(struct adapter *padapter, struct rt_channel_info *channel_set, + u8 chanset_size, + struct p2p_channels *channel_list) { + struct p2p_oper_class_map op_class[] = { + { IEEE80211G, 81, 1, 13, 1, BW20 }, + { IEEE80211G, 82, 14, 14, 1, BW20 }, + { -1, 0, 0, 0, 0, BW20 } + }; + + int cla, op; + + cla = 0; + + for (op = 0; op_class[op].op_class; op++) { + u8 ch; + struct p2p_oper_class_map *o = &op_class[op]; + struct p2p_reg_class *reg = NULL; + + for (ch = o->min_chan; ch <= o->max_chan; ch += o->inc) { + if (!has_channel(channel_set, chanset_size, ch)) { + continue; + } + + if ((0 == padapter->registrypriv.ht_enable) && (8 == o->inc)) + continue; + + if ((0 == (padapter->registrypriv.cbw40_enable & BIT(1))) && + ((BW40MINUS == o->bw) || (BW40PLUS == o->bw))) + continue; + + if (reg == NULL) { + reg = &channel_list->reg_class[cla]; + cla++; + reg->reg_class = o->op_class; + reg->channels = 0; + } + reg->channel[reg->channels] = ch; + reg->channels++; + } + } + channel_list->reg_classes = cla; +} + +static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, struct rt_channel_info *channel_set) +{ + u8 index, chanset_size = 0; + u8 b2_4GBand = false; + u8 Index2G = 0; + + memset(channel_set, 0, sizeof(struct rt_channel_info) * MAX_CHANNEL_NUM); + + if (ChannelPlan >= RT_CHANNEL_DOMAIN_MAX && ChannelPlan != RT_CHANNEL_DOMAIN_REALTEK_DEFINE) { + DBG_88E("ChannelPlan ID %x error !!!!!\n", ChannelPlan); + return chanset_size; + } + + if (padapter->registrypriv.wireless_mode & WIRELESS_11G) { + b2_4GBand = true; + if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == ChannelPlan) + Index2G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index2G; + else + Index2G = RTW_ChannelPlanMap[ChannelPlan].Index2G; + } + + if (b2_4GBand) { + for (index = 0; index < RTW_ChannelPlan2G[Index2G].Len; index++) { + channel_set[chanset_size].ChannelNum = RTW_ChannelPlan2G[Index2G].Channel[index]; + + if ((RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN == ChannelPlan) ||/* Channel 1~11 is active, and 12~14 is passive */ + (RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G == ChannelPlan)) { + if (channel_set[chanset_size].ChannelNum >= 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_2G_WORLD == Index2G) {/* channel 12~13, passive scan */ + if (channel_set[chanset_size].ChannelNum <= 11) + channel_set[chanset_size].ScanType = SCAN_ACTIVE; + else + channel_set[chanset_size].ScanType = SCAN_PASSIVE; + } else { + channel_set[chanset_size].ScanType = SCAN_ACTIVE; + } + + chanset_size++; + } + } + return chanset_size; +} + +int init_mlme_ext_priv(struct adapter *padapter) +{ + struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + pmlmeext->padapter = padapter; + + init_mlme_ext_priv_value(padapter); + pmlmeinfo->bAcceptAddbaReq = pregistrypriv->bAcceptAddbaReq; + + init_mlme_ext_timer(padapter); + +#ifdef CONFIG_88EU_AP_MODE + init_mlme_ap_info(padapter); +#endif + + pmlmeext->max_chan_nums = init_channel_set(padapter, pmlmepriv->ChannelPlan, pmlmeext->channel_set); + init_channel_list(padapter, pmlmeext->channel_set, pmlmeext->max_chan_nums, &pmlmeext->channel_list); + + pmlmeext->chan_scan_time = SURVEY_TO; + pmlmeext->mlmeext_init = true; + + + pmlmeext->active_keep_alive_check = true; + + return _SUCCESS; +} + +void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext) +{ + struct adapter *padapter = pmlmeext->padapter; + + if (!padapter) + return; + + if (padapter->bDriverStopped) { + del_timer_sync(&pmlmeext->survey_timer); + del_timer_sync(&pmlmeext->link_timer); + } +} + +static void _mgt_dispatcher(struct adapter *padapter, struct mlme_handler *ptable, struct recv_frame *precv_frame) +{ + u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + u8 *pframe = precv_frame->rx_data; + + if (ptable->func) { + /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ + if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && + memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) + return; + ptable->func(padapter, precv_frame); + } +} + +void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame) +{ + int index; + struct mlme_handler *ptable; +#ifdef CONFIG_88EU_AP_MODE + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; +#endif /* CONFIG_88EU_AP_MODE */ + u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + u8 *pframe = precv_frame->rx_data; + struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, GetAddr2Ptr(pframe)); + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("+mgt_dispatcher: type(0x%x) subtype(0x%x)\n", + GetFrameType(pframe), GetFrameSubType(pframe))); + + if (GetFrameType(pframe) != WIFI_MGT_TYPE) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("mgt_dispatcher: type(0x%x) error!\n", GetFrameType(pframe))); + return; + } + + /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ + if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && + memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) + return; + + ptable = mlme_sta_tbl; + + index = GetFrameSubType(pframe) >> 4; + + if (index > 13) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Currently we do not support reserved sub-fr-type=%d\n", index)); + return; + } + ptable += index; + + if (psta != NULL) { + if (GetRetry(pframe)) { + if (precv_frame->attrib.seq_num == + psta->RxMgmtFrameSeqNum) { + /* drop the duplicate management frame */ + DBG_88E("Drop duplicate management frame with seq_num=%d.\n", + precv_frame->attrib.seq_num); + return; + } + } + psta->RxMgmtFrameSeqNum = precv_frame->attrib.seq_num; + } + +#ifdef CONFIG_88EU_AP_MODE + switch (GetFrameSubType(pframe)) { + case WIFI_AUTH: + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) + ptable->func = &OnAuth; + else + ptable->func = &OnAuthClient; + /* fall through */ + case WIFI_ASSOCREQ: + case WIFI_REASSOCREQ: + case WIFI_PROBEREQ: + case WIFI_BEACON: + case WIFI_ACTION: + _mgt_dispatcher(padapter, ptable, precv_frame); + break; + default: + _mgt_dispatcher(padapter, ptable, precv_frame); + break; + } +#else + _mgt_dispatcher(padapter, ptable, precv_frame); +#endif +} + +/**************************************************************************** + Following are the functions to report events *****************************************************************************/ From 68345dd7bc26f6bd182ba0ceb890041a484bac44 Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Fri, 12 Jun 2015 00:20:44 +0200 Subject: [PATCH 0990/1163] staging: rtl8188eu: rtw_mlme_ext.c: unexport message callbacks These are internal functions. Remove their declaration in rtw_mlme_ext.h and make them static. Signed-off-by: Luca Ceresoli Cc: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 60 ++++++++++++------- .../staging/rtl8188eu/include/rtw_mlme_ext.h | 42 ------------- 2 files changed, 40 insertions(+), 62 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 0d1d4bfc6474..5adbbd715231 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -2569,7 +2569,8 @@ Following are the callback functions for each subtype of the management frames *****************************************************************************/ -unsigned int OnProbeReq(struct adapter *padapter, struct recv_frame *precv_frame) +static unsigned int OnProbeReq(struct adapter *padapter, + struct recv_frame *precv_frame) { unsigned int ielen; unsigned char *p; @@ -2609,7 +2610,8 @@ _issue_probersp: return _SUCCESS; } -unsigned int OnProbeRsp(struct adapter *padapter, struct recv_frame *precv_frame) +static unsigned int OnProbeRsp(struct adapter *padapter, + struct recv_frame *precv_frame) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -2621,7 +2623,8 @@ unsigned int OnProbeRsp(struct adapter *padapter, struct recv_frame *precv_frame return _SUCCESS; } -unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) +static unsigned int OnBeacon(struct adapter *padapter, + struct recv_frame *precv_frame) { int cam_idx; struct sta_info *psta; @@ -2711,7 +2714,8 @@ _END_ONBEACON_: return _SUCCESS; } -unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame) +static unsigned int OnAuth(struct adapter *padapter, + struct recv_frame *precv_frame) { #ifdef CONFIG_88EU_AP_MODE unsigned int auth_mode, ie_len; @@ -2880,7 +2884,8 @@ auth_fail: return _FAIL; } -unsigned int OnAuthClient(struct adapter *padapter, struct recv_frame *precv_frame) +static unsigned int OnAuthClient(struct adapter *padapter, + struct recv_frame *precv_frame) { unsigned int seq, len, status, offset; unsigned char *p; @@ -2955,7 +2960,8 @@ authclnt_fail: return _FAIL; } -unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame) +static unsigned int OnAssocReq(struct adapter *padapter, + struct recv_frame *precv_frame) { #ifdef CONFIG_88EU_AP_MODE u16 capab_info; @@ -3393,7 +3399,8 @@ OnAssocReqFail: return _FAIL; } -unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *precv_frame) +static unsigned int OnAssocRsp(struct adapter *padapter, + struct recv_frame *precv_frame) { uint i; int res; @@ -3483,7 +3490,8 @@ report_assoc_result: return _SUCCESS; } -unsigned int OnDeAuth(struct adapter *padapter, struct recv_frame *precv_frame) +static unsigned int OnDeAuth(struct adapter *padapter, + struct recv_frame *precv_frame) { unsigned short reason; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -3537,7 +3545,8 @@ unsigned int OnDeAuth(struct adapter *padapter, struct recv_frame *precv_frame) return _SUCCESS; } -unsigned int OnDisassoc(struct adapter *padapter, struct recv_frame *precv_frame) +static unsigned int OnDisassoc(struct adapter *padapter, + struct recv_frame *precv_frame) { u16 reason; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -3590,13 +3599,15 @@ unsigned int OnDisassoc(struct adapter *padapter, struct recv_frame *precv_frame return _SUCCESS; } -unsigned int OnAtim(struct adapter *padapter, struct recv_frame *precv_frame) +static unsigned int OnAtim(struct adapter *padapter, + struct recv_frame *precv_frame) { DBG_88E("%s\n", __func__); return _SUCCESS; } -unsigned int on_action_spct(struct adapter *padapter, struct recv_frame *precv_frame) +static unsigned int on_action_spct(struct adapter *padapter, + struct recv_frame *precv_frame) { struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; @@ -3633,17 +3644,20 @@ exit: return _FAIL; } -unsigned int OnAction_qos(struct adapter *padapter, struct recv_frame *precv_frame) +static unsigned int OnAction_qos(struct adapter *padapter, + struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int OnAction_dls(struct adapter *padapter, struct recv_frame *precv_frame) +static unsigned int OnAction_dls(struct adapter *padapter, + struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int OnAction_back(struct adapter *padapter, struct recv_frame *precv_frame) +static unsigned int OnAction_back(struct adapter *padapter, + struct recv_frame *precv_frame) { u8 *addr; struct sta_info *psta = NULL; @@ -3799,7 +3813,8 @@ exit: return ret; } -unsigned int on_action_public(struct adapter *padapter, struct recv_frame *precv_frame) +static unsigned int on_action_public(struct adapter *padapter, + struct recv_frame *precv_frame) { unsigned int ret = _FAIL; u8 *pframe = precv_frame->rx_data; @@ -3828,22 +3843,26 @@ exit: return ret; } -unsigned int OnAction_ht(struct adapter *padapter, struct recv_frame *precv_frame) +static unsigned int OnAction_ht(struct adapter *padapter, + struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int OnAction_wmm(struct adapter *padapter, struct recv_frame *precv_frame) +static unsigned int OnAction_wmm(struct adapter *padapter, + struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int OnAction_p2p(struct adapter *padapter, struct recv_frame *precv_frame) +static unsigned int OnAction_p2p(struct adapter *padapter, + struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int DoReserved(struct adapter *padapter, struct recv_frame *precv_frame) +static unsigned int DoReserved(struct adapter *padapter, + struct recv_frame *precv_frame) { return _SUCCESS; } @@ -3862,7 +3881,8 @@ static struct action_handler OnAction_tbl[] = { {RTW_WLAN_CATEGORY_P2P, "ACTION_P2P", &OnAction_p2p}, }; -unsigned int OnAction(struct adapter *padapter, struct recv_frame *precv_frame) +static unsigned int OnAction(struct adapter *padapter, + struct recv_frame *precv_frame) { int i; unsigned char category; diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h index 1df586aa0a9a..81df31ed6018 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -604,48 +604,6 @@ void start_clnt_auth(struct adapter *padapter); void start_clnt_join(struct adapter *padapter); void start_create_ibss(struct adapter *padapter); -unsigned int OnAssocReq(struct adapter *padapter, - struct recv_frame *precv_frame); -unsigned int OnAssocRsp(struct adapter *padapter, - struct recv_frame *precv_frame); -unsigned int OnProbeReq(struct adapter *padapter, - struct recv_frame *precv_frame); -unsigned int OnProbeRsp(struct adapter *padapter, - struct recv_frame *precv_frame); -unsigned int DoReserved(struct adapter *padapter, - struct recv_frame *precv_frame); -unsigned int OnBeacon(struct adapter *padapter, - struct recv_frame *precv_frame); -unsigned int OnAtim(struct adapter *padapter, - struct recv_frame *precv_frame); -unsigned int OnDisassoc(struct adapter *padapter, - struct recv_frame *precv_frame); -unsigned int OnAuth(struct adapter *padapter, - struct recv_frame *precv_frame); -unsigned int OnAuthClient(struct adapter *padapter, - struct recv_frame *precv_frame); -unsigned int OnDeAuth(struct adapter *padapter, - struct recv_frame *precv_frame); -unsigned int OnAction(struct adapter *padapter, - struct recv_frame *precv_frame); - -unsigned int on_action_spct(struct adapter *padapter, - struct recv_frame *precv_frame); -unsigned int OnAction_qos(struct adapter *padapter, - struct recv_frame *precv_frame); -unsigned int OnAction_dls(struct adapter *padapter, - struct recv_frame *precv_frame); -unsigned int OnAction_back(struct adapter *padapter, - struct recv_frame *precv_frame); -unsigned int on_action_public(struct adapter *padapter, - struct recv_frame *precv_frame); -unsigned int OnAction_ht(struct adapter *padapter, - struct recv_frame *precv_frame); -unsigned int OnAction_wmm(struct adapter *padapter, - struct recv_frame *precv_frame); -unsigned int OnAction_p2p(struct adapter *padapter, - struct recv_frame *precv_frame); - void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res); void mlmeext_sta_del_event_callback(struct adapter *padapter); void mlmeext_sta_add_event_callback(struct adapter *padapter, From 782eddd748d9c4be3272b946085e3099266c3043 Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Fri, 12 Jun 2015 00:20:45 +0200 Subject: [PATCH 0991/1163] staging: rtl8188eu: unexport internal functions These are internal functions. Remove their declaration in rtw_mlme_ext.h and make them static. Signed-off-by: Luca Ceresoli Cc: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 57 ++++++++++++------- .../staging/rtl8188eu/include/rtw_mlme_ext.h | 32 ----------- 2 files changed, 36 insertions(+), 53 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 5adbbd715231..ea442559618e 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -230,7 +230,8 @@ void update_mgntframe_attrib(struct adapter *padapter, struct pkt_attrib *pattri pattrib->retry_ctrl = true; } -void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe) +static void dump_mgntframe(struct adapter *padapter, + struct xmit_frame *pmgntframe) { if (padapter->bSurpriseRemoved || padapter->bDriverStopped) return; @@ -238,7 +239,9 @@ void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe) rtw_hal_mgnt_xmit(padapter, pmgntframe); } -s32 dump_mgntframe_and_wait(struct adapter *padapter, struct xmit_frame *pmgntframe, int timeout_ms) +static s32 dump_mgntframe_and_wait(struct adapter *padapter, + struct xmit_frame *pmgntframe, + int timeout_ms) { s32 ret = _FAIL; struct xmit_buf *pxmitbuf = pmgntframe->pxmitbuf; @@ -258,7 +261,8 @@ s32 dump_mgntframe_and_wait(struct adapter *padapter, struct xmit_frame *pmgntfr return ret; } -s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, struct xmit_frame *pmgntframe) +static s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, + struct xmit_frame *pmgntframe) { s32 ret = _FAIL; u32 timeout_ms = 500;/* 500ms */ @@ -314,7 +318,7 @@ static int update_hidden_ssid(u8 *ies, u32 ies_len, u8 hidden_ssid_mode) return len_diff; } -void issue_beacon(struct adapter *padapter, int timeout_ms) +static void issue_beacon(struct adapter *padapter, int timeout_ms) { struct xmit_frame *pmgntframe; struct pkt_attrib *pattrib; @@ -455,7 +459,8 @@ _issue_bcn: dump_mgntframe(padapter, pmgntframe); } -void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p_probereq) +static void issue_probersp(struct adapter *padapter, unsigned char *da, + u8 is_valid_p2p_probereq) { struct xmit_frame *pmgntframe; struct pkt_attrib *pattrib; @@ -697,13 +702,15 @@ exit: return ret; } -inline void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da) +static inline void issue_probereq(struct adapter *padapter, + struct ndis_802_11_ssid *pssid, u8 *da) { _issue_probereq(padapter, pssid, da, false); } -int issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da, - int try_cnt, int wait_ms) +static int issue_probereq_ex(struct adapter *padapter, + struct ndis_802_11_ssid *pssid, u8 *da, + int try_cnt, int wait_ms) { int ret; int i = 0; @@ -742,7 +749,8 @@ exit: } /* if psta == NULL, indicate we are station(client) now... */ -void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short status) +static void issue_auth(struct adapter *padapter, struct sta_info *psta, + unsigned short status) { struct xmit_frame *pmgntframe; struct pkt_attrib *pattrib; @@ -881,7 +889,8 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short } -void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_info *pstat, int pkt_type) +static void issue_asocrsp(struct adapter *padapter, unsigned short status, + struct sta_info *pstat, int pkt_type) { #ifdef CONFIG_88EU_AP_MODE struct xmit_frame *pmgntframe; @@ -1006,7 +1015,7 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i #endif } -void issue_assocreq(struct adapter *padapter) +static void issue_assocreq(struct adapter *padapter) { int ret = _FAIL; struct xmit_frame *pmgntframe; @@ -1513,8 +1522,9 @@ int issue_deauth(struct adapter *padapter, unsigned char *da, unsigned short rea return _issue_deauth(padapter, da, reason, false); } -int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason, int try_cnt, - int wait_ms) +static int issue_deauth_ex(struct adapter *padapter, u8 *da, + unsigned short reason, int try_cnt, + int wait_ms) { int ret; int i = 0; @@ -1611,7 +1621,8 @@ void issue_action_spct_ch_switch(struct adapter *padapter, u8 *ra, u8 new_ch, u8 dump_mgntframe(padapter, pmgntframe); } -void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned char action, unsigned short status) +static void issue_action_BA(struct adapter *padapter, unsigned char *raddr, + unsigned char action, unsigned short status) { u8 category = RTW_WLAN_CATEGORY_BACK; u16 start_seq; @@ -1963,7 +1974,7 @@ Following are some utility functions for WiFi MLME *****************************************************************************/ -void site_survey(struct adapter *padapter) +static void site_survey(struct adapter *padapter) { unsigned char survey_channel = 0, val8; enum rt_scan_type ScanType = SCAN_PASSIVE; @@ -2067,7 +2078,9 @@ void site_survey(struct adapter *padapter) } /* collect bss info from Beacon and Probe request/response frames. */ -u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame, struct wlan_bssid_ex *bssid) +static u8 collect_bss_info(struct adapter *padapter, + struct recv_frame *precv_frame, + struct wlan_bssid_ex *bssid) { int i; u32 len; @@ -2233,7 +2246,7 @@ u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame, st return _SUCCESS; } -void start_create_ibss(struct adapter *padapter) +static void start_create_ibss(struct adapter *padapter) { unsigned short caps; u8 val8; @@ -2284,7 +2297,7 @@ void start_create_ibss(struct adapter *padapter) } } -void start_clnt_join(struct adapter *padapter) +static void start_clnt_join(struct adapter *padapter) { unsigned short caps; u8 val8; @@ -2339,7 +2352,7 @@ void start_clnt_join(struct adapter *padapter) } } -void start_clnt_auth(struct adapter *padapter) +static void start_clnt_auth(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); @@ -2370,7 +2383,7 @@ void start_clnt_auth(struct adapter *padapter) } -void start_clnt_assoc(struct adapter *padapter) +static void start_clnt_assoc(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); @@ -2385,7 +2398,9 @@ void start_clnt_assoc(struct adapter *padapter) set_link_timer(pmlmeext, REASSOC_TO); } -unsigned int receive_disconnect(struct adapter *padapter, unsigned char *MacAddr, unsigned short reason) +static unsigned int receive_disconnect(struct 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/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h index 81df31ed6018..2417809f3aef 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -497,9 +497,6 @@ void CAM_empty_entry(struct adapter *Adapter, u8 ucIndex); int allocate_fw_sta_entry(struct adapter *padapter); void flush_all_cam_entry(struct adapter *padapter); -void site_survey(struct adapter *padapter); -u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame, - struct wlan_bssid_ex *bssid); void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, struct adapter *adapter, bool update_ie); @@ -541,9 +538,6 @@ unsigned int update_MSC_rate(struct HT_caps_element *pHT_caps); void Update_RA_Entry(struct adapter *padapter, u32 mac_id); void set_sta_rate(struct adapter *padapter, struct sta_info *psta); -unsigned int receive_disconnect(struct adapter *padapter, - unsigned char *macaddr, unsigned short reason); - unsigned char get_highest_rate_idx(u32 mask); int support_short_GI(struct adapter *padapter, struct HT_caps_element *caps); unsigned int is_ap_in_tkip(struct adapter *padapter); @@ -566,44 +560,18 @@ unsigned int setup_beacon_frame(struct adapter *padapter, void update_mgnt_tx_rate(struct adapter *padapter, u8 rate); void update_mgntframe_attrib(struct adapter *padapter, struct pkt_attrib *pattrib); -void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe); -s32 dump_mgntframe_and_wait(struct adapter *padapter, - struct xmit_frame *pmgntframe, int timeout_ms); -s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, - struct xmit_frame *pmgntframe); -void issue_beacon(struct adapter *padapter, int timeout_ms); -void issue_probersp(struct adapter *padapter, unsigned char *da, - u8 is_valid_p2p_probereq); -void issue_assocreq(struct adapter *padapter); -void issue_asocrsp(struct adapter *padapter, unsigned short status, - struct sta_info *pstat, int pkt_type); -void issue_auth(struct adapter *padapter, struct sta_info *psta, - unsigned short status); -void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, - u8 *da); -s32 issue_probereq_ex(struct adapter *adapter, struct ndis_802_11_ssid *pssid, - u8 *da, int try_cnt, int wait_ms); int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int power_mode, int try_cnt, int wait_ms); int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int try_cnt, int wait_ms); int issue_deauth(struct adapter *padapter, unsigned char *da, unsigned short reason); -int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason, - int try_cnt, int wait_ms); void issue_action_spct_ch_switch(struct adapter *padapter, u8 *ra, u8 new_ch, u8 ch_offset); -void issue_action_BA(struct adapter *padapter, unsigned char *raddr, - unsigned char action, unsigned short status); unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr); unsigned int send_beacon(struct adapter *padapter); -void start_clnt_assoc(struct adapter *padapter); -void start_clnt_auth(struct adapter *padapter); -void start_clnt_join(struct adapter *padapter); -void start_create_ibss(struct adapter *padapter); - void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res); void mlmeext_sta_del_event_callback(struct adapter *padapter); void mlmeext_sta_add_event_callback(struct adapter *padapter, From 935142236dbe2ade051dcc3c4d259dadd318b386 Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Fri, 12 Jun 2015 00:20:46 +0200 Subject: [PATCH 0992/1163] staging: rtl8188eu: issue_probersp(): remove unused parameter The is_valid_p2p_probereq is never referenced in the function body. Signed-off-by: Luca Ceresoli Cc: Larry Finger 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 ea442559618e..109c0985fe16 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -459,8 +459,7 @@ _issue_bcn: dump_mgntframe(padapter, pmgntframe); } -static void issue_probersp(struct adapter *padapter, unsigned char *da, - u8 is_valid_p2p_probereq) +static void issue_probersp(struct adapter *padapter, unsigned char *da) { struct xmit_frame *pmgntframe; struct pkt_attrib *pattrib; @@ -2620,7 +2619,7 @@ _issue_probersp: if (check_fwstate(pmlmepriv, _FW_LINKED) && pmlmepriv->cur_network.join_res) - issue_probersp(padapter, get_sa(pframe), is_valid_p2p_probereq); + issue_probersp(padapter, get_sa(pframe)); } return _SUCCESS; } From 863eaa79bac1c0d6df7404e87432d823193e2555 Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Fri, 12 Jun 2015 00:20:47 +0200 Subject: [PATCH 0993/1163] staging: rtl8723au: issue_probersp(): remove unused parameter The is_valid_p2p_probereq is never referenced in the function body. Signed-off-by: Luca Ceresoli Cc: Larry Finger Acked-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 8 +++----- 1 file 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 142f214108c6..0d7e9215cf3e 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -51,8 +51,7 @@ static void issue_probereq(struct rtw_adapter *padapter, 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_probersp(struct rtw_adapter *padapter, unsigned char *da); 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, @@ -760,7 +759,7 @@ OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) if (check_fwstate(pmlmepriv, _FW_LINKED) && pmlmepriv->cur_network.join_res) - issue_probersp(padapter, mgmt->sa, false); + issue_probersp(padapter, mgmt->sa); out: return _SUCCESS; @@ -2503,8 +2502,7 @@ _issue_bcn: dump_mgntframe23a(padapter, pmgntframe); } -static void issue_probersp(struct rtw_adapter *padapter, unsigned char *da, - u8 is_valid_p2p_probereq) +static void issue_probersp(struct rtw_adapter *padapter, unsigned char *da) { struct xmit_frame *pmgntframe; struct pkt_attrib *pattrib; From a26c9eedcdf81c4ddeb4d055c45039d4175969cc Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Fri, 12 Jun 2015 00:20:48 +0200 Subject: [PATCH 0994/1163] staging: rtl8188eu: issue_probersp(): remove unused variable and dead code is_valid_p2p_probereq is initialized to false and never modified. Code depending on it is dead code. Remove all of it. Signed-off-by: Luca Ceresoli Cc: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 109c0985fe16..a68bc3cc3981 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -2594,7 +2594,6 @@ static unsigned int OnProbeReq(struct adapter *padapter, struct wlan_bssid_ex *cur = &(pmlmeinfo->network); u8 *pframe = precv_frame->rx_data; uint len = precv_frame->len; - u8 is_valid_p2p_probereq = false; if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) return _SUCCESS; @@ -2608,15 +2607,10 @@ static unsigned int OnProbeReq(struct adapter *padapter, /* check (wildcard) SSID */ if (p != NULL) { - if (is_valid_p2p_probereq) - goto _issue_probersp; - if ((ielen != 0 && memcmp((void *)(p+2), (void *)cur->Ssid.Ssid, cur->Ssid.SsidLength)) || (ielen == 0 && pmlmeinfo->hidden_ssid_mode)) return _SUCCESS; -_issue_probersp: - if (check_fwstate(pmlmepriv, _FW_LINKED) && pmlmepriv->cur_network.join_res) issue_probersp(padapter, get_sa(pframe)); From ebd21582bd4cfa98a5fbeece4793303c811526fe Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Fri, 12 Jun 2015 00:20:49 +0200 Subject: [PATCH 0995/1163] staging: rtl8188eu: fix wrong debug print Signed-off-by: Luca Ceresoli Cc: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index 2b09972d4cb5..581af88e3024 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -849,7 +849,7 @@ static void start_bss_network(struct adapter *padapter, u8 *pbuf) /* issue beacon frame */ if (send_beacon(padapter) == _FAIL) - DBG_88E("issue_beacon, fail!\n"); + DBG_88E("send_beacon, fail!\n"); } /* update bc/mc sta_info */ From 71d62adb6746e0ac74842540c9faaedd7797e65a Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Fri, 12 Jun 2015 16:20:41 +0530 Subject: [PATCH 0996/1163] staging: rtl8188eu: remove unused enum and CONFIG The CONFIGs, the enum and the function declaration was not being used anywhere. Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/odm.h | 8 -------- drivers/staging/rtl8188eu/include/odm_HWConfig.h | 3 --- 2 files changed, 11 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/odm.h b/drivers/staging/rtl8188eu/include/odm.h index 525eb100cd15..7b83d8c5e1c6 100644 --- a/drivers/staging/rtl8188eu/include/odm.h +++ b/drivers/staging/rtl8188eu/include/odm.h @@ -918,14 +918,6 @@ enum ODM_RF_CONTENT { odm_radiod_txt = 0x1003 }; -enum odm_bb_config_type { - CONFIG_BB_PHY_REG, - CONFIG_BB_AGC_TAB, - CONFIG_BB_AGC_TAB_2G, - CONFIG_BB_AGC_TAB_5G, - CONFIG_BB_PHY_REG_PG, -}; - /* Status code */ enum rt_status { RT_STATUS_SUCCESS, diff --git a/drivers/staging/rtl8188eu/include/odm_HWConfig.h b/drivers/staging/rtl8188eu/include/odm_HWConfig.h index 1de4e6399435..62a00498e473 100644 --- a/drivers/staging/rtl8188eu/include/odm_HWConfig.h +++ b/drivers/staging/rtl8188eu/include/odm_HWConfig.h @@ -120,7 +120,4 @@ void ODM_MacStatusQuery(struct odm_dm_struct *pDM_Odm, bool bPacketToSelf, bool bPacketBeacon); -enum HAL_STATUS ODM_ConfigBBWithHeaderFile(struct odm_dm_struct *pDM_Odm, - enum odm_bb_config_type ConfigType); - #endif From 9393d34e4905ffd77bce3f64815a3b92363b30a4 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Fri, 12 Jun 2015 16:20:42 +0530 Subject: [PATCH 0997/1163] staging: rtl8188eu: remove unused variables These variables were being set but not used afterwards. Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme.c | 3 --- drivers/staging/rtl8188eu/hal/phy.c | 10 ++-------- drivers/staging/rtl8188eu/hal/rtl8188e_dm.c | 2 -- drivers/staging/rtl8188eu/os_dep/osdep_service.c | 3 +-- 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index a0f9f9e63b7f..05584515c5b4 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -638,7 +638,6 @@ exit: void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) { struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); - struct mlme_ext_priv *pmlmeext; spin_lock_bh(&pmlmepriv->lock); @@ -720,8 +719,6 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) spin_unlock_bh(&pmlmepriv->lock); rtw_os_xmit_schedule(adapter); - - pmlmeext = &adapter->mlmeextpriv; } void rtw_dummy_event_callback(struct adapter *adapter, u8 *pbuf) diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c index 6e4c3ee0399a..2eafa503f343 100644 --- a/drivers/staging/rtl8188eu/hal/phy.c +++ b/drivers/staging/rtl8188eu/hal/phy.c @@ -629,7 +629,7 @@ void rtl88eu_dm_txpower_tracking_callback_thermalmeter(struct adapter *adapt) static u8 phy_path_a_iqk(struct adapter *adapt, bool config_pathb) { - u32 reg_eac, reg_e94, reg_e9c, reg_ea4; + u32 reg_eac, reg_e94, reg_e9c; u8 result = 0x00; /* 1 Tx IQK */ @@ -651,7 +651,6 @@ static u8 phy_path_a_iqk(struct adapter *adapt, bool config_pathb) reg_eac = phy_query_bb_reg(adapt, rRx_Power_After_IQK_A_2, bMaskDWord); reg_e94 = phy_query_bb_reg(adapt, rTx_Power_Before_IQK_A, bMaskDWord); reg_e9c = phy_query_bb_reg(adapt, rTx_Power_After_IQK_A, bMaskDWord); - reg_ea4 = phy_query_bb_reg(adapt, rRx_Power_Before_IQK_A_2, bMaskDWord); if (!(reg_eac & BIT28) && (((reg_e94 & 0x03FF0000)>>16) != 0x142) && @@ -1316,8 +1315,7 @@ void rtl88eu_phy_iq_calibrate(struct adapter *adapt, bool recovery) s32 result[4][8]; u8 i, final, chn_index; bool pathaok, pathbok; - s32 reg_e94, reg_e9c, reg_ea4, reg_eac, reg_eb4, reg_ebc, reg_ec4, - reg_ecc; + s32 reg_e94, reg_e9c, reg_ea4, reg_eb4, reg_ebc, reg_ec4; bool is12simular, is13simular, is23simular; bool singletone = false, carrier_sup = false; u32 iqk_bb_reg_92c[IQK_BB_REG_NUM] = { @@ -1389,18 +1387,15 @@ void rtl88eu_phy_iq_calibrate(struct adapter *adapt, bool recovery) 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 != 0xff) { reg_e94 = result[final][0]; reg_e9c = result[final][1]; reg_ea4 = result[final][2]; - reg_eac = result[final][3]; reg_eb4 = result[final][4]; reg_ebc = result[final][5]; dm_odm->RFCalibrateInfo.RegE94 = reg_e94; @@ -1408,7 +1403,6 @@ void rtl88eu_phy_iq_calibrate(struct adapter *adapt, bool recovery) dm_odm->RFCalibrateInfo.RegEB4 = reg_eb4; dm_odm->RFCalibrateInfo.RegEBC = reg_ebc; reg_ec4 = result[final][6]; - reg_ecc = result[final][7]; pathaok = true; pathbok = true; } else { diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c b/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c index 01566210bbd2..fca590949409 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c @@ -151,7 +151,6 @@ void rtl8188e_InitHalDm(struct adapter *Adapter) void rtl8188e_HalDmWatchDog(struct adapter *Adapter) { - bool fw_cur_in_ps = false; bool fw_ps_awake = true; u8 hw_init_completed = false; struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); @@ -163,7 +162,6 @@ void rtl8188e_HalDmWatchDog(struct adapter *Adapter) if (!hw_init_completed) goto skip_dm; - fw_cur_in_ps = Adapter->pwrctrlpriv.bFwCurrentInPSMode; rtw_hal_get_hwreg(Adapter, HW_VAR_FWLPS_RF_ON, (u8 *)(&fw_ps_awake)); /* Fw is under p2p powersaving mode, driver should stop dynamic mechanism. */ diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c b/drivers/staging/rtl8188eu/os_dep/osdep_service.c index abcb3a8589ef..acb4eb120b76 100644 --- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c +++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c @@ -134,7 +134,7 @@ void rtw_buf_free(u8 **buf, u32 *buf_len) void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len) { - u32 ori_len = 0, dup_len = 0; + u32 dup_len = 0; u8 *ori = NULL; u8 *dup = NULL; @@ -153,7 +153,6 @@ void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len) keep_ori: ori = *buf; - ori_len = *buf_len; /* replace buf with dup */ *buf_len = 0; From 4e18248a66b5d95e9140be463228636fde32e2d5 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Fri, 12 Jun 2015 16:20:43 +0530 Subject: [PATCH 0998/1163] staging: rtl8188eu: remove function which does nothing The function rtw_mfree_all_stainfo() is just holding the lock, traversing the list, and then unlocking. It is not doing anything else. So removed the function and modified the places from where it was called. Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 28 -------------------- 1 file changed, 28 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 19b3a0d6de9a..b340e4a9d540 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -143,32 +143,6 @@ inline struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int 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) -{ - struct list_head *plist, *phead; - struct sta_info *psta = NULL; - - - spin_lock_bh(&pstapriv->sta_hash_lock); - - phead = get_list_head(&pstapriv->free_sta_queue); - plist = phead->next; - - while (phead != plist) { - psta = container_of(plist, struct sta_info, list); - plist = plist->next; - } - - 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_priv(struct sta_priv *pstapriv) { struct list_head *phead, *plist; @@ -197,8 +171,6 @@ u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) spin_unlock_bh(&pstapriv->sta_hash_lock); /*===============================*/ - rtw_mfree_sta_priv_lock(pstapriv); - if (pstapriv->pallocated_stainfo_buf) vfree(pstapriv->pallocated_stainfo_buf); } From c5ab1f7faaba2d7f30f87bea2f0b5cf4b958fd2f Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Thu, 28 May 2015 15:06:58 +0300 Subject: [PATCH 0999/1163] Documentation: mention vme_master_mmap() in VME API Signed-off-by: Dmitry Kalinkin Cc: Igor Alekseev Signed-off-by: Greg Kroah-Hartman --- Documentation/vme_api.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/vme_api.txt b/Documentation/vme_api.txt index ffe6e22a2ccd..ca5b82797f6c 100644 --- a/Documentation/vme_api.txt +++ b/Documentation/vme_api.txt @@ -171,6 +171,12 @@ This functions by reading the offset, applying the mask. If the bits selected in the mask match with the values of the corresponding bits in the compare field, the value of swap is written the specified offset. +Parts of a VME window can be mapped into user space memory using the following +function: + + int vme_master_mmap(struct vme_resource *resource, + struct vm_area_struct *vma) + Slave windows ============= From f656eaee6368198f596ae5b8754494ec2b179a16 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Thu, 28 May 2015 15:06:59 +0300 Subject: [PATCH 1000/1163] vme: tsi148: fix DMA lists longer that one item DMA lists on tsi148 weren't processed further than the first item because of the broken logic. This regression was introduced in: ac1a4f2caf7b071 "Staging: VME: Ensure TSI148 link list descriptors..." Signed-off-by: Dmitry Kalinkin Cc: Igor Alekseev Signed-off-by: Greg Kroah-Hartman --- drivers/vme/bridges/vme_tsi148.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/vme/bridges/vme_tsi148.c b/drivers/vme/bridges/vme_tsi148.c index 895c2a31918d..1be41360c9e7 100644 --- a/drivers/vme/bridges/vme_tsi148.c +++ b/drivers/vme/bridges/vme_tsi148.c @@ -1844,8 +1844,8 @@ static int tsi148_dma_list_add(struct vme_dma_list *list, reg_split((unsigned long long)entry->dma_handle, &address_high, &address_low); - entry->descriptor.dnlau = cpu_to_be32(address_high); - entry->descriptor.dnlal = cpu_to_be32(address_low); + prev->descriptor.dnlau = cpu_to_be32(address_high); + prev->descriptor.dnlal = cpu_to_be32(address_low); } From b2383c90a9d691201b9aee557776694cde86a935 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Thu, 28 May 2015 15:07:00 +0300 Subject: [PATCH 1001/1163] vme: tsi148: fix first DMA item mapping This moves DMA mapping of the first list element to vme_list_add, the same place where other elements mappings occur. This prevents extra mapping or over-unmapping in the cases when vme_list_exec is called more or less than one time respectively. Also adds dma_mapping_error check. Signed-off-by: Dmitry Kalinkin Cc: Igor Alekseev Signed-off-by: Greg Kroah-Hartman --- drivers/vme/bridges/vme_tsi148.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/vme/bridges/vme_tsi148.c b/drivers/vme/bridges/vme_tsi148.c index 1be41360c9e7..65623481b84c 100644 --- a/drivers/vme/bridges/vme_tsi148.c +++ b/drivers/vme/bridges/vme_tsi148.c @@ -1833,17 +1833,21 @@ static int tsi148_dma_list_add(struct vme_dma_list *list, /* Add to list */ list_add_tail(&entry->list, &list->entries); + entry->dma_handle = dma_map_single(tsi148_bridge->parent, + &entry->descriptor, + sizeof(struct tsi148_dma_descriptor), DMA_TO_DEVICE); + if (dma_mapping_error(tsi148_bridge->parent, entry->dma_handle)) { + dev_err(tsi148_bridge->parent, "DMA mapping error\n"); + retval = -EINVAL; + goto err_dma; + } + /* Fill out previous descriptors "Next Address" */ if (entry->list.prev != &list->entries) { - prev = list_entry(entry->list.prev, struct tsi148_dma_entry, - list); - /* We need the bus address for the pointer */ - entry->dma_handle = dma_map_single(tsi148_bridge->parent, - &entry->descriptor, - sizeof(struct tsi148_dma_descriptor), DMA_TO_DEVICE); - reg_split((unsigned long long)entry->dma_handle, &address_high, &address_low); + prev = list_entry(entry->list.prev, struct tsi148_dma_entry, + list); prev->descriptor.dnlau = cpu_to_be32(address_high); prev->descriptor.dnlal = cpu_to_be32(address_low); @@ -1851,6 +1855,7 @@ static int tsi148_dma_list_add(struct vme_dma_list *list, return 0; +err_dma: err_dest: err_source: err_align: @@ -1921,10 +1926,6 @@ static int tsi148_dma_list_exec(struct vme_dma_list *list) entry = list_first_entry(&list->entries, struct tsi148_dma_entry, list); - entry->dma_handle = dma_map_single(tsi148_bridge->parent, - &entry->descriptor, - sizeof(struct tsi148_dma_descriptor), DMA_TO_DEVICE); - mutex_unlock(&ctrlr->mtx); reg_split(entry->dma_handle, &bus_addr_high, &bus_addr_low); From 75c66b6db7baacf592268d5d5c4c9ecb6e2bcae7 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Thu, 28 May 2015 15:07:01 +0300 Subject: [PATCH 1002/1163] vme: stop DMA transfer on interruption Signed-off-by: Dmitry Kalinkin Cc: Igor Alekseev Signed-off-by: Greg Kroah-Hartman --- drivers/vme/bridges/vme_ca91cx42.c | 17 ++++++++++++++--- drivers/vme/bridges/vme_tsi148.c | 15 +++++++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/drivers/vme/bridges/vme_ca91cx42.c b/drivers/vme/bridges/vme_ca91cx42.c index 18078ecbfcc6..e9bd65723134 100644 --- a/drivers/vme/bridges/vme_ca91cx42.c +++ b/drivers/vme/bridges/vme_ca91cx42.c @@ -1192,7 +1192,7 @@ static int ca91cx42_dma_list_exec(struct vme_dma_list *list) { struct vme_dma_resource *ctrlr; struct ca91cx42_dma_entry *entry; - int retval = 0; + int retval; dma_addr_t bus_addr; u32 val; struct device *dev; @@ -1245,8 +1245,18 @@ static int ca91cx42_dma_list_exec(struct vme_dma_list *list) iowrite32(val, bridge->base + DGCS); - wait_event_interruptible(bridge->dma_queue, - ca91cx42_dma_busy(ctrlr->parent)); + retval = wait_event_interruptible(bridge->dma_queue, + ca91cx42_dma_busy(ctrlr->parent)); + + if (retval) { + val = ioread32(bridge->base + DGCS); + iowrite32(val | CA91CX42_DGCS_STOP_REQ, bridge->base + DGCS); + /* Wait for the operation to abort */ + wait_event(bridge->dma_queue, + ca91cx42_dma_busy(ctrlr->parent)); + retval = -EINTR; + goto exit; + } /* * Read status register, this register is valid until we kick off a @@ -1261,6 +1271,7 @@ static int ca91cx42_dma_list_exec(struct vme_dma_list *list) val = ioread32(bridge->base + DCTL); } +exit: /* Remove list from running list */ mutex_lock(&ctrlr->mtx); list_del(&list->list); diff --git a/drivers/vme/bridges/vme_tsi148.c b/drivers/vme/bridges/vme_tsi148.c index 65623481b84c..fb1e7ad272ec 100644 --- a/drivers/vme/bridges/vme_tsi148.c +++ b/drivers/vme/bridges/vme_tsi148.c @@ -1892,7 +1892,7 @@ static int tsi148_dma_busy(struct vme_bridge *tsi148_bridge, int channel) static int tsi148_dma_list_exec(struct vme_dma_list *list) { struct vme_dma_resource *ctrlr; - int channel, retval = 0; + int channel, retval; struct tsi148_dma_entry *entry; u32 bus_addr_high, bus_addr_low; u32 val, dctlreg = 0; @@ -1942,9 +1942,19 @@ static int tsi148_dma_list_exec(struct vme_dma_list *list) iowrite32be(dctlreg | TSI148_LCSR_DCTL_DGO, bridge->base + TSI148_LCSR_DMA[channel] + TSI148_LCSR_OFFSET_DCTL); - wait_event_interruptible(bridge->dma_queue[channel], + retval = wait_event_interruptible(bridge->dma_queue[channel], tsi148_dma_busy(ctrlr->parent, channel)); + if (retval) { + iowrite32be(dctlreg | TSI148_LCSR_DCTL_ABT, bridge->base + + TSI148_LCSR_DMA[channel] + TSI148_LCSR_OFFSET_DCTL); + /* Wait for the operation to abort */ + wait_event(bridge->dma_queue[channel], + tsi148_dma_busy(ctrlr->parent, channel)); + retval = -EINTR; + goto exit; + } + /* * Read status register, this register is valid until we kick off a * new transfer. @@ -1957,6 +1967,7 @@ static int tsi148_dma_list_exec(struct vme_dma_list *list) retval = -EIO; } +exit: /* Remove list from running list */ mutex_lock(&ctrlr->mtx); list_del(&list->list); From 615c40dd9f884add78cc3048167b59856d241fa3 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Thu, 28 May 2015 15:07:02 +0300 Subject: [PATCH 1003/1163] staging: vme_user: refactor llseek to switch(){} This makes vme_user_llseek ignore all minors that don't have llseek implementation. Signed-off-by: Dmitry Kalinkin Cc: Igor Alekseev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vme/devices/vme_user.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index 19ba749bb122..da828f48b2ef 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c @@ -430,15 +430,17 @@ static loff_t vme_user_llseek(struct file *file, loff_t off, int whence) size_t image_size; loff_t res; - if (minor == CONTROL_MINOR) - return -EINVAL; + switch (type[minor]) { + case MASTER_MINOR: + case SLAVE_MINOR: + mutex_lock(&image[minor].mutex); + image_size = vme_get_size(image[minor].resource); + res = fixed_size_llseek(file, off, whence, image_size); + mutex_unlock(&image[minor].mutex); + return res; + } - mutex_lock(&image[minor].mutex); - image_size = vme_get_size(image[minor].resource); - res = fixed_size_llseek(file, off, whence, image_size); - mutex_unlock(&image[minor].mutex); - - return res; + return -EINVAL; } /* From e7fd80cbb4a788b2f8b081ab8564752073c30505 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Thu, 28 May 2015 15:07:03 +0300 Subject: [PATCH 1004/1163] vme: check for A64 overflow in vme_check_window() Signed-off-by: Dmitry Kalinkin Cc: Igor Alekseev Signed-off-by: Greg Kroah-Hartman --- drivers/vme/vme.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c index 6bab2c4ed77c..1b78d27aa728 100644 --- a/drivers/vme/vme.c +++ b/drivers/vme/vme.c @@ -199,10 +199,8 @@ static int vme_check_window(u32 aspace, unsigned long long vme_base, retval = -EFAULT; break; case VME_A64: - /* - * Any value held in an unsigned long long can be used as the - * base - */ + if ((size != 0) && (vme_base > U64_MAX + 1 - size)) + retval = -EFAULT; break; case VME_CRCSR: if (((vme_base + size) > VME_CRCSR_MAX) || From ef73f886b53548d83d71a439f51a0c13ea6c1dae Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Thu, 28 May 2015 15:07:04 +0300 Subject: [PATCH 1005/1163] vme: export vme_check_window() Signed-off-by: Dmitry Kalinkin Cc: Igor Alekseev Signed-off-by: Greg Kroah-Hartman --- drivers/vme/vme.c | 5 +++-- include/linux/vme.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c index 1b78d27aa728..56708915ebbe 100644 --- a/drivers/vme/vme.c +++ b/drivers/vme/vme.c @@ -177,8 +177,8 @@ size_t vme_get_size(struct vme_resource *resource) } EXPORT_SYMBOL(vme_get_size); -static int vme_check_window(u32 aspace, unsigned long long vme_base, - unsigned long long size) +int vme_check_window(u32 aspace, unsigned long long vme_base, + unsigned long long size) { int retval = 0; @@ -221,6 +221,7 @@ static int vme_check_window(u32 aspace, unsigned long long vme_base, return retval; } +EXPORT_SYMBOL(vme_check_window); /* * Request a slave image with specific attributes, return some unique diff --git a/include/linux/vme.h b/include/linux/vme.h index 79242e9c06b8..c0131358f351 100644 --- a/include/linux/vme.h +++ b/include/linux/vme.h @@ -120,6 +120,8 @@ void vme_free_consistent(struct vme_resource *, size_t, void *, dma_addr_t); size_t vme_get_size(struct vme_resource *); +int vme_check_window(u32 aspace, unsigned long long vme_base, + unsigned long long size); struct vme_resource *vme_slave_request(struct vme_dev *, u32, u32); int vme_slave_set(struct vme_resource *, int, unsigned long long, From 1cfb645c8b7c82bbce4d77240754fcf5559cc82c Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Thu, 28 May 2015 15:07:06 +0300 Subject: [PATCH 1006/1163] vme: ca91cx42: return error code on DMA error Signed-off-by: Dmitry Kalinkin Cc: Igor Alekseev Signed-off-by: Greg Kroah-Hartman --- drivers/vme/bridges/vme_ca91cx42.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/vme/bridges/vme_ca91cx42.c b/drivers/vme/bridges/vme_ca91cx42.c index e9bd65723134..f692efcf683f 100644 --- a/drivers/vme/bridges/vme_ca91cx42.c +++ b/drivers/vme/bridges/vme_ca91cx42.c @@ -1269,6 +1269,7 @@ static int ca91cx42_dma_list_exec(struct vme_dma_list *list) dev_err(dev, "ca91c042: DMA Error. DGCS=%08X\n", val); val = ioread32(bridge->base + DCTL); + retval = -EIO; } exit: From 5a2f8831243337dd05df42174b4d7b1e01daacda Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Thu, 28 May 2015 15:07:07 +0300 Subject: [PATCH 1007/1163] vme: ca91cx42: fix LM_CTL address mask Universe II datasheet defines following address space values for LM_CTL[16:18] 000=A16 001=A24 010=A32 011,100,101=Reserved 110=User1 111=User2 Mask 5<<16 is not the right one for matching [16:18], instead we should use 7<<16. Signed-off-by: Dmitry Kalinkin Cc: Igor Alekseev Reported-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/vme/bridges/vme_ca91cx42.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/vme/bridges/vme_ca91cx42.h b/drivers/vme/bridges/vme_ca91cx42.h index d46b12dc3b82..d54119e59d55 100644 --- a/drivers/vme/bridges/vme_ca91cx42.h +++ b/drivers/vme/bridges/vme_ca91cx42.h @@ -547,7 +547,7 @@ static const int CA91CX42_LINT_LM[] = { CA91CX42_LINT_LM0, CA91CX42_LINT_LM1, #define CA91CX42_LM_CTL_DATA (1<<22) #define CA91CX42_LM_CTL_SUPR (1<<21) #define CA91CX42_LM_CTL_NPRIV (1<<20) -#define CA91CX42_LM_CTL_AS_M (5<<16) +#define CA91CX42_LM_CTL_AS_M (7<<16) #define CA91CX42_LM_CTL_AS_A16 0 #define CA91CX42_LM_CTL_AS_A24 (1<<16) #define CA91CX42_LM_CTL_AS_A32 (1<<17) From d884dd8c88e04958d809471781290b64f3d1a87a Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Thu, 28 May 2015 15:07:08 +0300 Subject: [PATCH 1008/1163] staging: vme_user: remove unused counters Signed-off-by: Dmitry Kalinkin Cc: Igor Alekseev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vme/devices/vme_user.c | 31 -------------------------- 1 file changed, 31 deletions(-) diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index da828f48b2ef..449b8cd1dcb0 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c @@ -104,18 +104,6 @@ struct image_desc { }; static struct image_desc image[VME_DEVS]; -struct driver_stats { - unsigned long reads; - unsigned long writes; - unsigned long ioctls; - unsigned long irqs; - unsigned long berrs; - unsigned long dmaerrors; - unsigned long timeouts; - unsigned long external; -}; -static struct driver_stats statistics; - static struct cdev *vme_user_cdev; /* Character device */ static struct class *vme_user_sysfs_class; /* Sysfs class */ static struct vme_dev *vme_user_bridge; /* Pointer to user device */ @@ -167,20 +155,6 @@ static const struct vm_operations_struct vme_user_vm_ops = { }; -/* - * Reset all the statistic counters - */ -static void reset_counters(void) -{ - statistics.reads = 0; - statistics.writes = 0; - statistics.ioctls = 0; - statistics.irqs = 0; - statistics.berrs = 0; - statistics.dmaerrors = 0; - statistics.timeouts = 0; -} - static int vme_user_open(struct inode *inode, struct file *file) { int err; @@ -465,8 +439,6 @@ static int vme_user_ioctl(struct inode *inode, struct file *file, dma_addr_t pci_addr; void __user *argp = (void __user *)arg; - statistics.ioctls++; - switch (type[minor]) { case CONTROL_MINOR: switch (cmd) { @@ -765,9 +737,6 @@ static int vme_user_probe(struct vme_dev *vdev) image[i].users = 0; } - /* Initialise statistics counters */ - reset_counters(); - /* Assign major and minor numbers for the driver */ err = register_chrdev_region(MKDEV(VME_MAJOR, 0), VME_DEVS, driver_name); From 5c10439849f75e408112d5f1696623b2fae5a500 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Thu, 28 May 2015 15:07:12 +0300 Subject: [PATCH 1009/1163] vme: tsi148: depend on HAS_DMA for Kconfig Signed-off-by: Dmitry Kalinkin Cc: Igor Alekseev Signed-off-by: Greg Kroah-Hartman --- drivers/vme/bridges/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/vme/bridges/Kconfig b/drivers/vme/bridges/Kconfig index 9331064e0476..f6d854584906 100644 --- a/drivers/vme/bridges/Kconfig +++ b/drivers/vme/bridges/Kconfig @@ -9,7 +9,7 @@ config VME_CA91CX42 config VME_TSI148 tristate "Tempe" - depends on VIRT_TO_BUS + depends on HAS_DMA help If you say Y here you get support for the Tundra TSI148 VME bridge chip. From 2c13087194700b16aada1a9112fad5b3861ac9fb Mon Sep 17 00:00:00 2001 From: David Kershner Date: Fri, 12 Jun 2015 23:12:35 -0400 Subject: [PATCH 1010/1163] staging: unisys: cleanup iochannel includes The iochannel.h file no longer needs to include conttrolvmchannel.h, vbuschannel.h and vmcallinterfaces.h. Signed-off-by: David Kershner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/iochannel.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/unisys/include/iochannel.h b/drivers/staging/unisys/include/iochannel.h index 538036d378fb..64a581a4b4e4 100644 --- a/drivers/staging/unisys/include/iochannel.h +++ b/drivers/staging/unisys/include/iochannel.h @@ -30,13 +30,7 @@ #include -#include "vmcallinterface.h" - -#define _ULTRA_CONTROLVM_CHANNEL_INLINE_ #include -#include "controlvmchannel.h" -#include "vbuschannel.h" -#undef _ULTRA_CONTROLVM_CHANNEL_INLINE_ #include "channel.h" #include "channel_guid.h" From 0be1eb7429b2d23db44e3d15589d20fce53e7043 Mon Sep 17 00:00:00 2001 From: Chaehyun Lim Date: Sat, 13 Jun 2015 15:41:18 +0900 Subject: [PATCH 1011/1163] staging: wilc1000: remove BOOL_T typedef Remove BOOL_T typedef. Signed-off-by: Chaehyun Lim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 6 +++--- drivers/staging/wilc1000/itypes.h | 9 --------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 17ab5cdfcf12..ca59f1b30af5 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -7698,7 +7698,7 @@ static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo) /* HT Cap. IE */ else if (pu8IEs[index] == HT_CAPABILITY_IE) { /* if IE found set the flag */ - pNewJoinBssParam->ht_capable = BTRUE; + pNewJoinBssParam->ht_capable = true; index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */ /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */ continue; @@ -7709,11 +7709,11 @@ static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo) ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && /* OUI Sub Type */ (pu8IEs[index + 7] == 0x01)) { /* Presence of WMM Info/Param element indicates WMM capability */ - pNewJoinBssParam->wmm_cap = BTRUE; + pNewJoinBssParam->wmm_cap = true; /* Check if Bit 7 is set indicating U-APSD capability */ if (pu8IEs[index + 8] & (1 << 7)) { - pNewJoinBssParam->uapsd_cap = BTRUE; + pNewJoinBssParam->uapsd_cap = true; } index += pu8IEs[index + 1] + 2; continue; diff --git a/drivers/staging/wilc1000/itypes.h b/drivers/staging/wilc1000/itypes.h index 2441853f9153..d64ae3522ce5 100644 --- a/drivers/staging/wilc1000/itypes.h +++ b/drivers/staging/wilc1000/itypes.h @@ -36,13 +36,4 @@ #ifndef ITYPES_H #define ITYPES_H -/*****************************************************************************/ -/* Enums */ -/*****************************************************************************/ - -typedef enum { - BFALSE = 0, - BTRUE = 1 -} BOOL_T; - #endif /* ITYPES_H */ From c5b72378a2a47f2ef64eb6a76a8627300999d874 Mon Sep 17 00:00:00 2001 From: Chaehyun Lim Date: Sat, 13 Jun 2015 15:41:19 +0900 Subject: [PATCH 1012/1163] staging: wilc1000: remove itypes.h Remove itypes.h that is not needed. Signed-off-by: Chaehyun Lim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 1 - drivers/staging/wilc1000/host_interface.c | 1 - drivers/staging/wilc1000/itypes.h | 39 --------------------- 3 files changed, 41 deletions(-) delete mode 100644 drivers/staging/wilc1000/itypes.h diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index 9abc73d3646d..792ba6df1053 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -12,7 +12,6 @@ /*****************************************************************************/ /* File Includes */ /*****************************************************************************/ -#include "itypes.h" #include "coreconfigurator.h" /*****************************************************************************/ /* Constants */ diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index ca59f1b30af5..1e9a2f142a3c 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1,6 +1,5 @@ #include "host_interface.h" #include "wilc_oswrapper.h" -#include "itypes.h" #include "coreconfigurator.h" extern s32 TransportInit(void); diff --git a/drivers/staging/wilc1000/itypes.h b/drivers/staging/wilc1000/itypes.h deleted file mode 100644 index d64ae3522ce5..000000000000 --- a/drivers/staging/wilc1000/itypes.h +++ /dev/null @@ -1,39 +0,0 @@ -/*****************************************************************************/ -/* */ -/* Ittiam 802.11 MAC SOFTWARE */ -/* */ -/* ITTIAM SYSTEMS PVT LTD, BANGALORE */ -/* COPYRIGHT(C) 2005 */ -/* */ -/* This program is proprietary to Ittiam Systems Private Limited and */ -/* is protected under Indian Copyright Law as an unpublished work. Its use */ -/* and disclosure is limited by the terms and conditions of a license */ -/* agreement. It may not be copied or otherwise reproduced or disclosed to */ -/* persons outside the licensee's organization except in accordance with the*/ -/* terms and conditions of such an agreement. All copies and */ -/* reproductions shall be the property of Ittiam Systems Private Limited and*/ -/* must bear this notice in its entirety. */ -/* */ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* File Name : itypes.h */ -/* */ -/* Description : This file contains all the data type definitions for */ -/* MAC implementation. */ -/* */ -/* List of Functions : None */ -/* Issues / Problems : None */ -/* */ -/* Revision History : */ -/* */ -/* DD MM YYYY Author(s) Changes */ -/* 01 05 2005 Ittiam Draft */ -/* */ -/*****************************************************************************/ - -#ifndef ITYPES_H -#define ITYPES_H - -#endif /* ITYPES_H */ From 07e9e619db50ad6704e714f8160a59f1de3cf93c Mon Sep 17 00:00:00 2001 From: Dogukan Ergun Date: Sat, 13 Jun 2015 15:04:26 +0300 Subject: [PATCH 1013/1163] staging: rtl8712: fix else after break or return warning This patch fixes checkpatch.pl warning. WARNING: else is not generally useful after a break or return Signed-off-by: Dogukan Ergun Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index cb0b6387789f..3388f971fb48 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -813,8 +813,7 @@ static int r871x_wx_set_pmkid(struct net_device *dev, case IW_PMKSA_ADD: if (!memcmp(strIssueBssid, strZeroMacAddress, ETH_ALEN)) return intReturn; - else - intReturn = true; + intReturn = true; blInserted = false; /* overwrite PMKID */ for (j = 0; j < NUM_PMKID_CACHE; j++) { From e4aea6aa03267b496c21abefe170bb0d77192882 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Sat, 13 Jun 2015 16:34:01 +0300 Subject: [PATCH 1014/1163] staging: vme_user: remove forward declarations Reorder code so that forward declarations are not needed. Signed-off-by: Dmitry Kalinkin Cc: Igor Alekseev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vme/devices/vme_user.c | 139 +++++++++++-------------- 1 file changed, 60 insertions(+), 79 deletions(-) diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index 449b8cd1dcb0..8e46d606d42a 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c @@ -116,44 +116,11 @@ static const int type[VME_DEVS] = { MASTER_MINOR, MASTER_MINOR, CONTROL_MINOR }; - -static int vme_user_open(struct inode *, struct file *); -static int vme_user_release(struct inode *, struct file *); -static ssize_t vme_user_read(struct file *, char __user *, size_t, loff_t *); -static ssize_t vme_user_write(struct file *, const char __user *, size_t, - loff_t *); -static loff_t vme_user_llseek(struct file *, loff_t, int); -static long vme_user_unlocked_ioctl(struct file *, unsigned int, unsigned long); -static int vme_user_mmap(struct file *file, struct vm_area_struct *vma); - -static void vme_user_vm_open(struct vm_area_struct *vma); -static void vme_user_vm_close(struct vm_area_struct *vma); - -static int vme_user_match(struct vme_dev *); -static int vme_user_probe(struct vme_dev *); -static int vme_user_remove(struct vme_dev *); - -static const struct file_operations vme_user_fops = { - .open = vme_user_open, - .release = vme_user_release, - .read = vme_user_read, - .write = vme_user_write, - .llseek = vme_user_llseek, - .unlocked_ioctl = vme_user_unlocked_ioctl, - .compat_ioctl = vme_user_unlocked_ioctl, - .mmap = vme_user_mmap, -}; - struct vme_user_vma_priv { unsigned int minor; atomic_t refcnt; }; -static const struct vm_operations_struct vme_user_vm_ops = { - .open = vme_user_vm_open, - .close = vme_user_vm_close, -}; - static int vme_user_open(struct inode *inode, struct file *file) { @@ -582,6 +549,11 @@ static void vme_user_vm_close(struct vm_area_struct *vma) kfree(vma_priv); } +static const struct vm_operations_struct vme_user_vm_ops = { + .open = vme_user_vm_open, + .close = vme_user_vm_close, +}; + static int vme_user_master_mmap(unsigned int minor, struct vm_area_struct *vma) { int err; @@ -623,6 +595,16 @@ static int vme_user_mmap(struct file *file, struct vm_area_struct *vma) return -ENODEV; } +static const struct file_operations vme_user_fops = { + .open = vme_user_open, + .release = vme_user_release, + .read = vme_user_read, + .write = vme_user_write, + .llseek = vme_user_llseek, + .unlocked_ioctl = vme_user_unlocked_ioctl, + .compat_ioctl = vme_user_unlocked_ioctl, + .mmap = vme_user_mmap, +}; /* * Unallocate a previously allocated buffer @@ -649,52 +631,6 @@ static void buf_unalloc(int num) } } -static struct vme_driver vme_user_driver = { - .name = driver_name, - .match = vme_user_match, - .probe = vme_user_probe, - .remove = vme_user_remove, -}; - - -static int __init vme_user_init(void) -{ - int retval = 0; - - pr_info("VME User Space Access Driver\n"); - - if (bus_num == 0) { - pr_err("No cards, skipping registration\n"); - retval = -ENODEV; - goto err_nocard; - } - - /* Let's start by supporting one bus, we can support more than one - * in future revisions if that ever becomes necessary. - */ - if (bus_num > VME_USER_BUS_MAX) { - pr_err("Driver only able to handle %d buses\n", - VME_USER_BUS_MAX); - bus_num = VME_USER_BUS_MAX; - } - - /* - * Here we just register the maximum number of devices we can and - * leave vme_user_match() to allow only 1 to go through to probe(). - * This way, if we later want to allow multiple user access devices, - * we just change the code in vme_user_match(). - */ - retval = vme_register_driver(&vme_user_driver, VME_MAX_SLOTS); - if (retval != 0) - goto err_reg; - - return retval; - -err_reg: -err_nocard: - return retval; -} - static int vme_user_match(struct vme_dev *vdev) { int i; @@ -916,6 +852,51 @@ static int vme_user_remove(struct vme_dev *dev) return 0; } +static struct vme_driver vme_user_driver = { + .name = driver_name, + .match = vme_user_match, + .probe = vme_user_probe, + .remove = vme_user_remove, +}; + +static int __init vme_user_init(void) +{ + int retval = 0; + + pr_info("VME User Space Access Driver\n"); + + if (bus_num == 0) { + pr_err("No cards, skipping registration\n"); + retval = -ENODEV; + goto err_nocard; + } + + /* Let's start by supporting one bus, we can support more than one + * in future revisions if that ever becomes necessary. + */ + if (bus_num > VME_USER_BUS_MAX) { + pr_err("Driver only able to handle %d buses\n", + VME_USER_BUS_MAX); + bus_num = VME_USER_BUS_MAX; + } + + /* + * Here we just register the maximum number of devices we can and + * leave vme_user_match() to allow only 1 to go through to probe(). + * This way, if we later want to allow multiple user access devices, + * we just change the code in vme_user_match(). + */ + retval = vme_register_driver(&vme_user_driver, VME_MAX_SLOTS); + if (retval != 0) + goto err_reg; + + return retval; + +err_reg: +err_nocard: + return retval; +} + static void __exit vme_user_exit(void) { vme_unregister_driver(&vme_user_driver); From 0b029cb2f57a1499683d6b636fb967e5736ed554 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Sat, 13 Jun 2015 16:34:02 +0300 Subject: [PATCH 1015/1163] staging: vme_user: remove open/release Checking for image[minor].resource != NULL is not needed since all resources are allocated before device is created. image[minor].users accounting is deleted because it's not being used. Signed-off-by: Dmitry Kalinkin Cc: Igor Alekseev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vme/devices/vme_user.c | 44 -------------------------- 1 file changed, 44 deletions(-) diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index 8e46d606d42a..a72f7a9c8d09 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c @@ -99,7 +99,6 @@ struct image_desc { struct mutex mutex; /* Mutex for locking image */ struct device *device; /* Sysfs device */ struct vme_resource *resource; /* VME resource */ - int users; /* Number of current users */ int mmap_count; /* Number of current mmap's */ }; static struct image_desc image[VME_DEVS]; @@ -122,46 +121,6 @@ struct vme_user_vma_priv { }; -static int vme_user_open(struct inode *inode, struct file *file) -{ - int err; - unsigned int minor = MINOR(inode->i_rdev); - - mutex_lock(&image[minor].mutex); - /* Allow device to be opened if a resource is needed and allocated. */ - if (minor < CONTROL_MINOR && image[minor].resource == NULL) { - pr_err("No resources allocated for device\n"); - err = -EINVAL; - goto err_res; - } - - /* Increment user count */ - image[minor].users++; - - mutex_unlock(&image[minor].mutex); - - return 0; - -err_res: - mutex_unlock(&image[minor].mutex); - - return err; -} - -static int vme_user_release(struct inode *inode, struct file *file) -{ - unsigned int minor = MINOR(inode->i_rdev); - - mutex_lock(&image[minor].mutex); - - /* Decrement user count */ - image[minor].users--; - - mutex_unlock(&image[minor].mutex); - - return 0; -} - /* * We are going ot alloc a page during init per window for small transfers. * Small transfers will go VME -> buffer -> user space. Larger (more than a @@ -596,8 +555,6 @@ static int vme_user_mmap(struct file *file, struct vm_area_struct *vma) } static const struct file_operations vme_user_fops = { - .open = vme_user_open, - .release = vme_user_release, .read = vme_user_read, .write = vme_user_write, .llseek = vme_user_llseek, @@ -670,7 +627,6 @@ static int vme_user_probe(struct vme_dev *vdev) mutex_init(&image[i].mutex); image[i].device = NULL; image[i].resource = NULL; - image[i].users = 0; } /* Assign major and minor numbers for the driver */ From 625a9e012dc637fdc4ceadaac74f18155b0406f6 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Sat, 13 Jun 2015 16:34:03 +0300 Subject: [PATCH 1016/1163] staging: vme_user: remove buf_unalloc helper buf_unalloc is essentially a vme_free_consistent: 1) image[i].kern_buf is never NULL in buf_alloc call 2) kern_buf, pci_buf and size_buf get zeroed in vme_user_probe anyway Signed-off-by: Dmitry Kalinkin Cc: Igor Alekseev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vme/devices/vme_user.c | 31 ++++---------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index a72f7a9c8d09..9cca97af3044 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c @@ -563,31 +563,6 @@ static const struct file_operations vme_user_fops = { .mmap = vme_user_mmap, }; -/* - * Unallocate a previously allocated buffer - */ -static void buf_unalloc(int num) -{ - if (image[num].kern_buf) { -#ifdef VME_DEBUG - pr_debug("UniverseII:Releasing buffer at %p\n", - image[num].pci_buf); -#endif - - vme_free_consistent(image[num].resource, image[num].size_buf, - image[num].kern_buf, image[num].pci_buf); - - image[num].kern_buf = NULL; - image[num].pci_buf = 0; - image[num].size_buf = 0; - -#ifdef VME_DEBUG - } else { - pr_debug("UniverseII: Buffer not allocated\n"); -#endif - } -} - static int vme_user_match(struct vme_dev *vdev) { int i; @@ -765,7 +740,8 @@ err_master: err_slave: while (i > SLAVE_MINOR) { i--; - buf_unalloc(i); + vme_free_consistent(image[i].resource, image[i].size_buf, + image[i].kern_buf, image[i].pci_buf); vme_slave_free(image[i].resource); } err_class: @@ -795,7 +771,8 @@ static int vme_user_remove(struct vme_dev *dev) for (i = SLAVE_MINOR; i < (SLAVE_MAX + 1); i++) { vme_slave_set(image[i].resource, 0, 0, 0, 0, VME_A32, 0); - buf_unalloc(i); + vme_free_consistent(image[i].resource, image[i].size_buf, + image[i].kern_buf, image[i].pci_buf); vme_slave_free(image[i].resource); } From 4b4fd43a437626b45c0da21b373eedec38cc46fa Mon Sep 17 00:00:00 2001 From: Alessandro Parini Date: Sat, 13 Jun 2015 17:40:48 +0200 Subject: [PATCH 1017/1163] staging: unisys: fix braces coding style fix coding style issue "braces {} are not necessary for single statement blocks" detected by checkpatch.pl in visorchipset.c Signed-off-by: Alessandro Parini Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchipset.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index cf35d9d3a9bc..ef7d67701499 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -2017,9 +2017,8 @@ cleanup: static void bus_create_response(struct visor_device *bus_info, int response) { - if (response >= 0) { + if (response >= 0) bus_info->state.created = 1; - } bus_responder(CONTROLVM_BUS_CREATE, bus_info->pending_msg_hdr, response); From 35e606de51458f28799409e7e838b195d68923c4 Mon Sep 17 00:00:00 2001 From: Alessandro Parini Date: Sat, 13 Jun 2015 17:40:49 +0200 Subject: [PATCH 1018/1163] staging: unisys: fix "missing a blank line" coding style fix coding style issue "Missing a blank line after declarations" detected by checkpatch.pl in visorchipset.c Signed-off-by: Alessandro Parini Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchipset.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index ef7d67701499..bb8087e70127 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -2399,6 +2399,7 @@ static __init uint32_t visorutil_spar_detect(void) static int init_unisys(void) { int result; + if (!visorutil_spar_detect()) return -ENODEV; From 3c588452c2df09e1f0aa48b0e04bf53c31d61565 Mon Sep 17 00:00:00 2001 From: Anton Gerasimov Date: Sat, 13 Jun 2015 22:23:47 +0300 Subject: [PATCH 1019/1163] staging: fbtft: split long strings Split long function declarations, function calls, comments etc. Signed-off-by: Anton Gerasimov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fb_ra8875.c | 13 ++++++--- drivers/staging/fbtft/fb_tls8204.c | 11 ++++++-- drivers/staging/fbtft/fbtft_device.c | 3 +- drivers/staging/fbtft/flexfb.c | 41 ++++++++++++++++++++-------- 4 files changed, 48 insertions(+), 20 deletions(-) diff --git a/drivers/staging/fbtft/fb_ra8875.c b/drivers/staging/fbtft/fb_ra8875.c index 2c4d4dc70c51..54bc566b09fd 100644 --- a/drivers/staging/fbtft/fb_ra8875.c +++ b/drivers/staging/fbtft/fb_ra8875.c @@ -73,7 +73,9 @@ static int init_display(struct fbtft_par *par) fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__); fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, - "display size %dx%d\n", par->info->var.xres, par->info->var.yres); + "display size %dx%d\n", + par->info->var.xres, + par->info->var.yres); par->fbtftops.reset(par); @@ -101,7 +103,8 @@ static int init_display(struct fbtft_par *par) write_reg(par, 0x1D, 0x0E); write_reg(par, 0x1E, 0x00); write_reg(par, 0x1F, 0x02); - } else if ((par->info->var.xres == 480) && (par->info->var.yres == 272)) { + } else if ((par->info->var.xres == 480) && + (par->info->var.yres == 272)) { /* PLL clock frequency */ write_reg(par, 0x88, 0x0A); write_reg(par, 0x89, 0x02); @@ -125,7 +128,8 @@ static int init_display(struct fbtft_par *par) write_reg(par, 0x1D, 0x07); write_reg(par, 0x1E, 0x00); write_reg(par, 0x1F, 0x09); - } else if ((par->info->var.xres == 640) && (par->info->var.yres == 480)) { + } else if ((par->info->var.xres == 640) && + (par->info->var.yres == 480)) { /* PLL clock frequency */ write_reg(par, 0x88, 0x0B); write_reg(par, 0x89, 0x02); @@ -149,7 +153,8 @@ static int init_display(struct fbtft_par *par) write_reg(par, 0x1D, 0x0E); write_reg(par, 0x1E, 0x00); write_reg(par, 0x1F, 0x01); - } else if ((par->info->var.xres == 800) && (par->info->var.yres == 480)) { + } else if ((par->info->var.xres == 800) && + (par->info->var.yres == 480)) { /* PLL clock frequency */ write_reg(par, 0x88, 0x0B); write_reg(par, 0x89, 0x02); diff --git a/drivers/staging/fbtft/fb_tls8204.c b/drivers/staging/fbtft/fb_tls8204.c index 5ea73b5ce45a..3253a25e9184 100644 --- a/drivers/staging/fbtft/fb_tls8204.c +++ b/drivers/staging/fbtft/fb_tls8204.c @@ -35,7 +35,9 @@ #define WIDTH 84 #define HEIGHT 48 #define TXBUFLEN WIDTH -#define DEFAULT_GAMMA "40" /* gamma is used to control contrast in this driver */ + +/* gamma is used to control contrast in this driver */ +#define DEFAULT_GAMMA "40" static unsigned bs = 4; module_param(bs, uint, 0); @@ -51,7 +53,8 @@ static int init_display(struct fbtft_par *par) write_reg(par, 0x21); /* 5:1 1 2:0 PD - Powerdown control: chip is active 1:0 V - Entry mode: horizontal addressing - 0:1 H - Extended instruction set control: extended + 0:1 H - Extended instruction set control: + extended */ /* H=1 Bias system */ @@ -83,7 +86,9 @@ static int init_display(struct fbtft_par *par) static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye) { - fbtft_par_dbg(DEBUG_SET_ADDR_WIN, par, "%s(xs=%d, ys=%d, xe=%d, ye=%d)\n", __func__, xs, ys, xe, ye); + fbtft_par_dbg(DEBUG_SET_ADDR_WIN, par, + "%s(xs=%d, ys=%d, xe=%d, ye=%d)\n", + __func__, xs, ys, xe, ye); /* H=0 Set X address of RAM */ write_reg(par, 0x80); /* 7:1 1 diff --git a/drivers/staging/fbtft/fbtft_device.c b/drivers/staging/fbtft/fbtft_device.c index df6cd775ac1e..611e128c4071 100644 --- a/drivers/staging/fbtft/fbtft_device.c +++ b/drivers/staging/fbtft/fbtft_device.c @@ -1063,7 +1063,8 @@ static struct fbtft_device_display displays[] = { .display = { .buswidth = 8, .backlight = 1, - .init_sequence = waveshare32b_init_sequence, + .init_sequence = + waveshare32b_init_sequence, }, .bgr = true, .gpios = (const struct fbtft_gpio []) { diff --git a/drivers/staging/fbtft/flexfb.c b/drivers/staging/fbtft/flexfb.c index ca39fe90d1b8..5c813fc9d69b 100644 --- a/drivers/staging/fbtft/flexfb.c +++ b/drivers/staging/fbtft/flexfb.c @@ -134,9 +134,12 @@ static int ssd1351_init[] = { -1,0xfd,0x12,-1,0xfd,0xb1,-1,0xae,-1,0xb3,0xf1,-1, /* ili9320, ili9325 */ -static void flexfb_set_addr_win_1(struct fbtft_par *par, int xs, int ys, int xe, int ye) +static void flexfb_set_addr_win_1(struct fbtft_par *par, + int xs, int ys, int xe, int ye) { - fbtft_par_dbg(DEBUG_SET_ADDR_WIN, par, "%s(xs=%d, ys=%d, xe=%d, ye=%d)\n", __func__, xs, ys, xe, ye); + fbtft_par_dbg(DEBUG_SET_ADDR_WIN, par, + "%s(xs=%d, ys=%d, xe=%d, ye=%d)\n", + __func__, xs, ys, xe, ye); switch (par->info->var.rotate) { /* R20h = Horizontal GRAM Start Address */ /* R21h = Vertical GRAM Start Address */ @@ -161,9 +164,12 @@ static void flexfb_set_addr_win_1(struct fbtft_par *par, int xs, int ys, int xe, } /* ssd1289 */ -static void flexfb_set_addr_win_2(struct fbtft_par *par, int xs, int ys, int xe, int ye) +static void flexfb_set_addr_win_2(struct fbtft_par *par, + int xs, int ys, int xe, int ye) { - fbtft_par_dbg(DEBUG_SET_ADDR_WIN, par, "%s(xs=%d, ys=%d, xe=%d, ye=%d)\n", __func__, xs, ys, xe, ye); + fbtft_par_dbg(DEBUG_SET_ADDR_WIN, par, + "%s(xs=%d, ys=%d, xe=%d, ye=%d)\n", + __func__, xs, ys, xe, ye); switch (par->info->var.rotate) { /* R4Eh - Set GDDRAM X address counter */ @@ -191,9 +197,12 @@ static void flexfb_set_addr_win_2(struct fbtft_par *par, int xs, int ys, int xe, } /* ssd1351 */ -static void set_addr_win_3(struct fbtft_par *par, int xs, int ys, int xe, int ye) +static void set_addr_win_3(struct fbtft_par *par, + int xs, int ys, int xe, int ye) { - fbtft_par_dbg(DEBUG_SET_ADDR_WIN, par, "%s(xs=%d, ys=%d, xe=%d, ye=%d)\n", __func__, xs, ys, xe, ye); + fbtft_par_dbg(DEBUG_SET_ADDR_WIN, par, + "%s(xs=%d, ys=%d, xe=%d, ye=%d)\n", __func__, + xs, ys, xe, ye); write_reg(par, 0x15, xs, xe); write_reg(par, 0x75, ys, ye); @@ -205,7 +214,8 @@ static int flexfb_verify_gpios_dc(struct fbtft_par *par) fbtft_par_dbg(DEBUG_VERIFY_GPIOS, par, "%s()\n", __func__); if (par->gpio.dc < 0) { - dev_err(par->info->device, "Missing info about 'dc' gpio. Aborting.\n"); + dev_err(par->info->device, + "Missing info about 'dc' gpio. Aborting.\n"); return -EINVAL; } @@ -235,7 +245,9 @@ static int flexfb_verify_gpios_db(struct fbtft_par *par) num_db=buswidth/2; for (i=0;i < num_db;i++) { if (par->gpio.db[i] < 0) { - dev_err(par->info->device, "Missing info about 'db%02d' gpio. Aborting.\n", i); + dev_err(par->info->device, + "Missing info about 'db%02d' gpio. Aborting.\n", + i); return -EINVAL; } } @@ -245,7 +257,8 @@ static int flexfb_verify_gpios_db(struct fbtft_par *par) static struct fbtft_display flex_display = { }; -static int flexfb_probe_common(struct spi_device *sdev, struct platform_device *pdev) +static int flexfb_probe_common(struct spi_device *sdev, + struct platform_device *pdev) { struct device *dev; struct fb_info *info; @@ -260,7 +273,8 @@ static int flexfb_probe_common(struct spi_device *sdev, struct platform_device * else dev = &pdev->dev; - fbtft_init_dbg(dev, "%s(%s)\n", __func__, sdev ? "'SPI device'" : "'Platform device'"); + fbtft_init_dbg(dev, "%s(%s)\n", __func__, + sdev ? "'SPI device'" : "'Platform device'"); if (chip) { @@ -403,7 +417,9 @@ static int flexfb_probe_common(struct spi_device *sdev, struct platform_device * par->fbtftops.write_register = fbtft_write_reg16_bus8; break; default: - dev_err(dev, "argument 'regwidth': %d is not supported.\n", regwidth); + dev_err(dev, + "argument 'regwidth': %d is not supported.\n", + regwidth); return -EINVAL; } @@ -483,7 +499,8 @@ static int flexfb_probe_common(struct spi_device *sdev, struct platform_device * par->fbtftops.set_addr_win = set_addr_win_3; break; default: - dev_err(dev, "argument 'setaddrwin': unknown value %d.\n", setaddrwin); + dev_err(dev, "argument 'setaddrwin': unknown value %d.\n", + setaddrwin); return -EINVAL; } From 1e6acab05c91f160f977a2160916abaabc89f976 Mon Sep 17 00:00:00 2001 From: Anton Gerasimov Date: Sat, 13 Jun 2015 22:23:48 +0300 Subject: [PATCH 1020/1163] staging: fbtft: put spaces around assignment operators Put spaces around assignment operators for readability. Signed-off-by: Anton Gerasimov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/flexfb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/fbtft/flexfb.c b/drivers/staging/fbtft/flexfb.c index 5c813fc9d69b..3c7677473ef9 100644 --- a/drivers/staging/fbtft/flexfb.c +++ b/drivers/staging/fbtft/flexfb.c @@ -242,8 +242,8 @@ static int flexfb_verify_gpios_db(struct fbtft_par *par) return -EINVAL; } if (latched) - num_db=buswidth/2; - for (i=0;i < num_db;i++) { + num_db = buswidth/2; + for (i = 0; i < num_db; i++) { if (par->gpio.db[i] < 0) { dev_err(par->info->device, "Missing info about 'db%02d' gpio. Aborting.\n", From c26c5e739ee5de22442f3adabbf58392d09a68e4 Mon Sep 17 00:00:00 2001 From: Anton Gerasimov Date: Sat, 13 Jun 2015 22:23:49 +0300 Subject: [PATCH 1021/1163] staging: fbtft: replace spaces with tabs Indentation with spaces fixed. Signed-off-by: Anton Gerasimov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fb_tinylcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/fbtft/fb_tinylcd.c b/drivers/staging/fbtft/fb_tinylcd.c index c0b1a337fafd..4c740b7e9f53 100644 --- a/drivers/staging/fbtft/fb_tinylcd.c +++ b/drivers/staging/fbtft/fb_tinylcd.c @@ -53,7 +53,7 @@ static int init_display(struct fbtft_par *par) write_reg(par, 0xE5, 0x00); write_reg(par, 0xF0, 0x36, 0xA5, 0x53); write_reg(par, 0xE0, 0x00, 0x35, 0x33, 0x00, 0x00, 0x00, - 0x00, 0x35, 0x33, 0x00, 0x00, 0x00); + 0x00, 0x35, 0x33, 0x00, 0x00, 0x00); write_reg(par, 0x3A, 0x55); write_reg(par, 0x11); udelay(250); From 56cda8acd7174a9cacaed278894c247ee5a8d9fd Mon Sep 17 00:00:00 2001 From: Anton Gerasimov Date: Sat, 13 Jun 2015 22:23:50 +0300 Subject: [PATCH 1022/1163] staging: fbtft: make module descriptions greppable Split module description strings are merged for searchability. Signed-off-by: Anton Gerasimov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fbtft_device.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/fbtft/fbtft_device.c b/drivers/staging/fbtft/fbtft_device.c index 611e128c4071..4f19312e6c7d 100644 --- a/drivers/staging/fbtft/fbtft_device.c +++ b/drivers/staging/fbtft/fbtft_device.c @@ -34,8 +34,7 @@ static struct platform_device *p_device; static char *name; module_param(name, charp, 0); -MODULE_PARM_DESC(name, "Devicename (required). " \ -"name=list => list all supported devices."); +MODULE_PARM_DESC(name, "Devicename (required). name=list => list all supported devices."); static unsigned rotate; module_param(rotate, uint, 0); @@ -61,8 +60,7 @@ MODULE_PARM_DESC(mode, "SPI mode (override device default)"); static char *gpios; module_param(gpios, charp, 0); MODULE_PARM_DESC(gpios, -"List of gpios. Comma separated with the form: reset:23,dc:24 " \ -"(when overriding the default, all gpios must be specified)"); +"List of gpios. Comma separated with the form: reset:23,dc:24 (when overriding the default, all gpios must be specified)"); static unsigned fps; module_param(fps, uint, 0); @@ -88,8 +86,7 @@ MODULE_PARM_DESC(startbyte, "Sets the Start byte used by some SPI displays."); static bool custom; module_param(custom, bool, 0); -MODULE_PARM_DESC(custom, "Add a custom display device. " \ -"Use speed= argument to make it a SPI device, else platform_device"); +MODULE_PARM_DESC(custom, "Add a custom display device. Use speed= argument to make it a SPI device, else platform_device"); static unsigned width; module_param(width, uint, 0); From 6c604d6657f30b1a999ee3c4e1638927feb30ab3 Mon Sep 17 00:00:00 2001 From: Anton Gerasimov Date: Sat, 13 Jun 2015 22:23:51 +0300 Subject: [PATCH 1023/1163] staging: fbtft: remove unnecessary line continuations Removed unnecessary line continuations in several lines. Signed-off-by: Anton Gerasimov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fbtft_device.c | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/fbtft/fbtft_device.c b/drivers/staging/fbtft/fbtft_device.c index 4f19312e6c7d..07146653b537 100644 --- a/drivers/staging/fbtft/fbtft_device.c +++ b/drivers/staging/fbtft/fbtft_device.c @@ -229,7 +229,7 @@ static struct fbtft_device_display displays[] = { .display = { .buswidth = 8, .backlight = 1, - .fbtftops.set_addr_win = \ + .fbtftops.set_addr_win = adafruit18_green_tab_set_addr_win, }, .bgr = true, @@ -773,13 +773,13 @@ static struct fbtft_device_display displays[] = { { "dc", 25 }, {}, }, - .gamma = "0 2 2 2 2 2 2 2 " \ - "2 2 2 2 2 2 2 2 " \ - "2 2 2 2 2 2 2 2 " \ - "2 2 2 2 2 2 2 3 " \ - "3 3 3 3 3 3 3 3 " \ - "3 3 3 3 3 3 3 3 " \ - "3 3 3 4 4 4 4 4 " \ + .gamma = "0 2 2 2 2 2 2 2 " + "2 2 2 2 2 2 2 2 " + "2 2 2 2 2 2 2 2 " + "2 2 2 2 2 2 2 3 " + "3 3 3 3 3 3 3 3 " + "3 3 3 3 3 3 3 3 " + "3 3 3 4 4 4 4 4 " "4 4 4 4 4 4 4" } } @@ -893,7 +893,7 @@ static struct fbtft_device_display displays[] = { .buswidth = 16, .txbuflen = -2, /* disable buffer */ .backlight = 1, - .fbtftops.write = \ + .fbtftops.write = fbtft_write_gpio16_wr_latched, }, .bgr = true, @@ -1289,7 +1289,7 @@ static int __init fbtft_device_init(void) } if (init_num > FBTFT_MAX_INIT_SEQUENCE) { - pr_err(DRVNAME \ + pr_err(DRVNAME ": init parameter: exceeded max array size: %d\n", FBTFT_MAX_INIT_SEQUENCE); return -EINVAL; @@ -1298,7 +1298,7 @@ static int __init fbtft_device_init(void) /* parse module parameter: gpios */ while ((p_gpio = strsep(&gpios, ","))) { if (strchr(p_gpio, ':') == NULL) { - pr_err(DRVNAME \ + pr_err(DRVNAME ": error: missing ':' in gpios parameter: %s\n", p_gpio); return -EINVAL; @@ -1306,14 +1306,14 @@ static int __init fbtft_device_init(void) p_num = p_gpio; p_name = strsep(&p_num, ":"); if (p_name == NULL || p_num == NULL) { - pr_err(DRVNAME \ + pr_err(DRVNAME ": something bad happened parsing gpios parameter: %s\n", p_gpio); return -EINVAL; } ret = kstrtol(p_num, 10, &val); if (ret) { - pr_err(DRVNAME \ + pr_err(DRVNAME ": could not parse number in gpios parameter: %s:%s\n", p_name, p_num); return -EINVAL; @@ -1321,7 +1321,7 @@ static int __init fbtft_device_init(void) strcpy(fbtft_device_param_gpios[i].name, p_name); fbtft_device_param_gpios[i++].gpio = (int) val; if (i == MAX_GPIOS) { - pr_err(DRVNAME \ + pr_err(DRVNAME ": gpios parameter: exceeded max array size: %d\n", MAX_GPIOS); return -EINVAL; @@ -1417,7 +1417,7 @@ static int __init fbtft_device_init(void) if (displays[i].spi) { ret = fbtft_device_spi_device_register(spi); if (ret) { - pr_err(DRVNAME \ + pr_err(DRVNAME ": failed to register SPI device\n"); return ret; } @@ -1426,7 +1426,7 @@ static int __init fbtft_device_init(void) } else { ret = platform_device_register(p_device); if (ret < 0) { - pr_err(DRVNAME \ + pr_err(DRVNAME ": platform_device_register() returned %d\n", ret); return ret; From 8e56b9555111f080880679e1f42d51ae899d123b Mon Sep 17 00:00:00 2001 From: Anton Gerasimov Date: Sat, 13 Jun 2015 22:23:52 +0300 Subject: [PATCH 1024/1163] staging: fbtft: remove unnecessary spaces before tabs The patch removes spaces before tabs so that checkpatch.pl is content. Signed-off-by: Anton Gerasimov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fbtft_device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/fbtft/fbtft_device.c b/drivers/staging/fbtft/fbtft_device.c index 07146653b537..e5aa5332f7d4 100644 --- a/drivers/staging/fbtft/fbtft_device.c +++ b/drivers/staging/fbtft/fbtft_device.c @@ -555,8 +555,8 @@ static struct fbtft_device_display displays[] = { .gpios = (const struct fbtft_gpio []) { /* Wiring for LCD adapter kit */ { "reset", 7 }, - { "dc", 0 }, /* rev 2: 2 */ - { "wr", 1 }, /* rev 2: 3 */ + { "dc", 0 }, /* rev 2: 2 */ + { "wr", 1 }, /* rev 2: 3 */ { "cs", 8 }, { "db00", 17 }, { "db01", 18 }, From bc573c5131f36339f54385c5a9f87cff7c2b693c Mon Sep 17 00:00:00 2001 From: Anton Gerasimov Date: Sat, 13 Jun 2015 22:23:53 +0300 Subject: [PATCH 1025/1163] staging: fbtft: eliminate code duplication Eliminated code duplication when searching for a display. Signed-off-by: Anton Gerasimov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fbtft_device.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/fbtft/fbtft_device.c b/drivers/staging/fbtft/fbtft_device.c index e5aa5332f7d4..211d504901f2 100644 --- a/drivers/staging/fbtft/fbtft_device.c +++ b/drivers/staging/fbtft/fbtft_device.c @@ -1421,8 +1421,6 @@ static int __init fbtft_device_init(void) ": failed to register SPI device\n"); return ret; } - found = true; - break; } else { ret = platform_device_register(p_device); if (ret < 0) { @@ -1431,9 +1429,9 @@ static int __init fbtft_device_init(void) ret); return ret; } - found = true; - break; } + found = true; + break; } } From 9026b5d5afc44f397077d28a02f9d5933127ae7c Mon Sep 17 00:00:00 2001 From: Anton Gerasimov Date: Sat, 13 Jun 2015 22:23:54 +0300 Subject: [PATCH 1026/1163] staging: fbtft: rearrange comments for readability Placed comments to register writes before the function calls to eliminate long strings and make code more readable. Signed-off-by: Anton Gerasimov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fb_ili9320.c | 118 +++++++++++++++++++++-------- 1 file changed, 88 insertions(+), 30 deletions(-) diff --git a/drivers/staging/fbtft/fb_ili9320.c b/drivers/staging/fbtft/fb_ili9320.c index 3a02edd447d4..0301bd5dd9ff 100644 --- a/drivers/staging/fbtft/fb_ili9320.c +++ b/drivers/staging/fbtft/fb_ili9320.c @@ -63,43 +63,101 @@ static int init_display(struct fbtft_par *par) /* Initialization sequence from ILI9320 Application Notes */ /* *********** Start Initial Sequence ********* */ - write_reg(par, 0x00E5, 0x8000); /* Set the Vcore voltage and this setting is must. */ - write_reg(par, 0x0000, 0x0001); /* Start internal OSC. */ - write_reg(par, 0x0001, 0x0100); /* set SS and SM bit */ - write_reg(par, 0x0002, 0x0700); /* set 1 line inversion */ - write_reg(par, 0x0004, 0x0000); /* Resize register */ - write_reg(par, 0x0008, 0x0202); /* set the back and front porch */ - write_reg(par, 0x0009, 0x0000); /* set non-display area refresh cycle */ - write_reg(par, 0x000A, 0x0000); /* FMARK function */ - write_reg(par, 0x000C, 0x0000); /* RGB interface setting */ - write_reg(par, 0x000D, 0x0000); /* Frame marker Position */ - write_reg(par, 0x000F, 0x0000); /* RGB interface polarity */ + /* Set the Vcore voltage and this setting is must. */ + write_reg(par, 0x00E5, 0x8000); + + /* Start internal OSC. */ + write_reg(par, 0x0000, 0x0001); + + /* set SS and SM bit */ + write_reg(par, 0x0001, 0x0100); + + /* set 1 line inversion */ + write_reg(par, 0x0002, 0x0700); + + /* Resize register */ + write_reg(par, 0x0004, 0x0000); + + /* set the back and front porch */ + write_reg(par, 0x0008, 0x0202); + + /* set non-display area refresh cycle */ + write_reg(par, 0x0009, 0x0000); + + /* FMARK function */ + write_reg(par, 0x000A, 0x0000); + + /* RGB interface setting */ + write_reg(par, 0x000C, 0x0000); + + /* Frame marker Position */ + write_reg(par, 0x000D, 0x0000); + + /* RGB interface polarity */ + write_reg(par, 0x000F, 0x0000); + /* ***********Power On sequence *************** */ - write_reg(par, 0x0010, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ - write_reg(par, 0x0011, 0x0007); /* DC1[2:0], DC0[2:0], VC[2:0] */ - write_reg(par, 0x0012, 0x0000); /* VREG1OUT voltage */ - write_reg(par, 0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */ - mdelay(200); /* Dis-charge capacitor power voltage */ - write_reg(par, 0x0010, 0x17B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ - write_reg(par, 0x0011, 0x0031); /* R11h=0x0031 at VCI=3.3V DC1[2:0], DC0[2:0], VC[2:0] */ + /* SAP, BT[3:0], AP, DSTB, SLP, STB */ + write_reg(par, 0x0010, 0x0000); + + /* DC1[2:0], DC0[2:0], VC[2:0] */ + write_reg(par, 0x0011, 0x0007); + + /* VREG1OUT voltage */ + write_reg(par, 0x0012, 0x0000); + + /* VDV[4:0] for VCOM amplitude */ + write_reg(par, 0x0013, 0x0000); + + /* Dis-charge capacitor power voltage */ + mdelay(200); + + /* SAP, BT[3:0], AP, DSTB, SLP, STB */ + write_reg(par, 0x0010, 0x17B0); + + /* R11h=0x0031 at VCI=3.3V DC1[2:0], DC0[2:0], VC[2:0] */ + write_reg(par, 0x0011, 0x0031); mdelay(50); - write_reg(par, 0x0012, 0x0138); /* R12h=0x0138 at VCI=3.3V VREG1OUT voltage */ + + /* R12h=0x0138 at VCI=3.3V VREG1OUT voltage */ + write_reg(par, 0x0012, 0x0138); mdelay(50); - write_reg(par, 0x0013, 0x1800); /* R13h=0x1800 at VCI=3.3V VDV[4:0] for VCOM amplitude */ - write_reg(par, 0x0029, 0x0008); /* R29h=0x0008 at VCI=3.3V VCM[4:0] for VCOMH */ + + /* R13h=0x1800 at VCI=3.3V VDV[4:0] for VCOM amplitude */ + write_reg(par, 0x0013, 0x1800); + + /* R29h=0x0008 at VCI=3.3V VCM[4:0] for VCOMH */ + write_reg(par, 0x0029, 0x0008); mdelay(50); - write_reg(par, 0x0020, 0x0000); /* GRAM horizontal Address */ - write_reg(par, 0x0021, 0x0000); /* GRAM Vertical Address */ + + /* GRAM horizontal Address */ + write_reg(par, 0x0020, 0x0000); + + /* GRAM Vertical Address */ + write_reg(par, 0x0021, 0x0000); /* ------------------ Set GRAM area --------------- */ - write_reg(par, 0x0050, 0x0000); /* Horizontal GRAM Start Address */ - write_reg(par, 0x0051, 0x00EF); /* Horizontal GRAM End Address */ - write_reg(par, 0x0052, 0x0000); /* Vertical GRAM Start Address */ - write_reg(par, 0x0053, 0x013F); /* Vertical GRAM Start Address */ - write_reg(par, 0x0060, 0x2700); /* Gate Scan Line */ - write_reg(par, 0x0061, 0x0001); /* NDL,VLE, REV */ - write_reg(par, 0x006A, 0x0000); /* set scrolling line */ + /* Horizontal GRAM Start Address */ + write_reg(par, 0x0050, 0x0000); + + /* Horizontal GRAM End Address */ + write_reg(par, 0x0051, 0x00EF); + + /* Vertical GRAM Start Address */ + write_reg(par, 0x0052, 0x0000); + + /* Vertical GRAM Start Address */ + write_reg(par, 0x0053, 0x013F); + + /* Gate Scan Line */ + write_reg(par, 0x0060, 0x2700); + + /* NDL,VLE, REV */ + write_reg(par, 0x0061, 0x0001); + + /* set scrolling line */ + write_reg(par, 0x006A, 0x0000); /* -------------- Partial Display Control --------- */ write_reg(par, 0x0080, 0x0000); From 6684d0c4c8284687d14904051e2f16d76e495fa4 Mon Sep 17 00:00:00 2001 From: Anton Gerasimov Date: Sat, 13 Jun 2015 22:23:55 +0300 Subject: [PATCH 1027/1163] staging: fbtft: reformat hardcoded sequences Added spaces after commas in initialization sequences and removed unnecessary line continuations. Signed-off-by: Anton Gerasimov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/flexfb.c | 102 ++++++++++++++++----------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/drivers/staging/fbtft/flexfb.c b/drivers/staging/fbtft/flexfb.c index 3c7677473ef9..2c4ce07f5106 100644 --- a/drivers/staging/fbtft/flexfb.c +++ b/drivers/staging/fbtft/flexfb.c @@ -73,64 +73,64 @@ static int *initp; static int initp_num; /* default init sequences */ -static int st7735r_init[] = { \ --1,0x01,-2,150,-1,0x11,-2,500,-1,0xB1,0x01,0x2C,0x2D,-1,0xB2,0x01,0x2C,0x2D,-1,0xB3,0x01,0x2C,0x2D,0x01,0x2C,0x2D, \ --1,0xB4,0x07,-1,0xC0,0xA2,0x02,0x84,-1,0xC1,0xC5,-1,0xC2,0x0A,0x00,-1,0xC3,0x8A,0x2A,-1,0xC4,0x8A,0xEE,-1,0xC5,0x0E, \ --1,0x20,-1,0x36,0xC0,-1,0x3A,0x05,-1,0xE0,0x0f,0x1a,0x0f,0x18,0x2f,0x28,0x20,0x22,0x1f,0x1b,0x23,0x37,0x00,0x07,0x02,0x10, \ --1,0xE1,0x0f,0x1b,0x0f,0x17,0x33,0x2c,0x29,0x2e,0x30,0x30,0x39,0x3f,0x00,0x07,0x03,0x10,-1,0x29,-2,100,-1,0x13,-2,10,-3 }; +static int st7735r_init[] = { +-1, 0x01, -2, 150, -1, 0x11, -2, 500, -1, 0xB1, 0x01, 0x2C, 0x2D, -1, 0xB2, 0x01, 0x2C, 0x2D, -1, 0xB3, 0x01, 0x2C, 0x2D, 0x01, 0x2C, 0x2D, +-1, 0xB4, 0x07, -1, 0xC0, 0xA2, 0x02, 0x84, -1, 0xC1, 0xC5, -1, 0xC2, 0x0A, 0x00, -1, 0xC3, 0x8A, 0x2A, -1, 0xC4, 0x8A, 0xEE, -1, 0xC5, 0x0E, +-1, 0x20, -1, 0x36, 0xC0, -1, 0x3A, 0x05, -1, 0xE0, 0x0f, 0x1a, 0x0f, 0x18, 0x2f, 0x28, 0x20, 0x22, 0x1f, 0x1b, 0x23, 0x37, 0x00, 0x07, 0x02, 0x10, +-1, 0xE1, 0x0f, 0x1b, 0x0f, 0x17, 0x33, 0x2c, 0x29, 0x2e, 0x30, 0x30, 0x39, 0x3f, 0x00, 0x07, 0x03, 0x10, -1, 0x29, -2, 100, -1, 0x13, -2, 10, -3 }; -static int ssd1289_init[] = { \ --1,0x00,0x0001,-1,0x03,0xA8A4,-1,0x0C,0x0000,-1,0x0D,0x080C,-1,0x0E,0x2B00,-1,0x1E,0x00B7,-1,0x01,0x2B3F,-1,0x02,0x0600, \ --1,0x10,0x0000,-1,0x11,0x6070,-1,0x05,0x0000,-1,0x06,0x0000,-1,0x16,0xEF1C,-1,0x17,0x0003,-1,0x07,0x0233,-1,0x0B,0x0000, \ --1,0x0F,0x0000,-1,0x41,0x0000,-1,0x42,0x0000,-1,0x48,0x0000,-1,0x49,0x013F,-1,0x4A,0x0000,-1,0x4B,0x0000,-1,0x44,0xEF00, \ --1,0x45,0x0000,-1,0x46,0x013F,-1,0x30,0x0707,-1,0x31,0x0204,-1,0x32,0x0204,-1,0x33,0x0502,-1,0x34,0x0507,-1,0x35,0x0204, \ --1,0x36,0x0204,-1,0x37,0x0502,-1,0x3A,0x0302,-1,0x3B,0x0302,-1,0x23,0x0000,-1,0x24,0x0000,-1,0x25,0x8000,-1,0x4f,0x0000, \ --1,0x4e,0x0000,-1,0x22,-3 }; +static int ssd1289_init[] = { +-1, 0x00, 0x0001, -1, 0x03, 0xA8A4, -1, 0x0C, 0x0000, -1, 0x0D, 0x080C, -1, 0x0E, 0x2B00, -1, 0x1E, 0x00B7, -1, 0x01, 0x2B3F, -1, 0x02, 0x0600, +-1, 0x10, 0x0000, -1, 0x11, 0x6070, -1, 0x05, 0x0000, -1, 0x06, 0x0000, -1, 0x16, 0xEF1C, -1, 0x17, 0x0003, -1, 0x07, 0x0233, -1, 0x0B, 0x0000, +-1, 0x0F, 0x0000, -1, 0x41, 0x0000, -1, 0x42, 0x0000, -1, 0x48, 0x0000, -1, 0x49, 0x013F, -1, 0x4A, 0x0000, -1, 0x4B, 0x0000, -1, 0x44, 0xEF00, +-1, 0x45, 0x0000, -1, 0x46, 0x013F, -1, 0x30, 0x0707, -1, 0x31, 0x0204, -1, 0x32, 0x0204, -1, 0x33, 0x0502, -1, 0x34, 0x0507, -1, 0x35, 0x0204, +-1, 0x36, 0x0204, -1, 0x37, 0x0502, -1, 0x3A, 0x0302, -1, 0x3B, 0x0302, -1, 0x23, 0x0000, -1, 0x24, 0x0000, -1, 0x25, 0x8000, -1, 0x4f, 0x0000, +-1, 0x4e, 0x0000, -1, 0x22, -3 }; -static int hx8340bn_init[] = { \ --1,0xC1,0xFF,0x83,0x40,-1,0x11,-2,150,-1,0xCA,0x70,0x00,0xD9,-1,0xB0,0x01,0x11, \ --1,0xC9,0x90,0x49,0x10,0x28,0x28,0x10,0x00,0x06,-2,20,-1,0xC2,0x60,0x71,0x01,0x0E,0x05,0x02,0x09,0x31,0x0A, \ --1,0xC3,0x67,0x30,0x61,0x17,0x48,0x07,0x05,0x33,-2,10,-1,0xB5,0x35,0x20,0x45,-1,0xB4,0x33,0x25,0x4C,-2,10, \ --1,0x3A,0x05,-1,0x29,-2,10,-3 }; +static int hx8340bn_init[] = { +-1, 0xC1, 0xFF, 0x83, 0x40, -1, 0x11, -2, 150, -1, 0xCA, 0x70, 0x00, 0xD9, -1, 0xB0, 0x01, 0x11, +-1, 0xC9, 0x90, 0x49, 0x10, 0x28, 0x28, 0x10, 0x00, 0x06, -2, 20, -1, 0xC2, 0x60, 0x71, 0x01, 0x0E, 0x05, 0x02, 0x09, 0x31, 0x0A, +-1, 0xC3, 0x67, 0x30, 0x61, 0x17, 0x48, 0x07, 0x05, 0x33, -2, 10, -1, 0xB5, 0x35, 0x20, 0x45, -1, 0xB4, 0x33, 0x25, 0x4C, -2, 10, +-1, 0x3A, 0x05, -1, 0x29, -2, 10, -3 }; -static int ili9225_init[] = { \ --1,0x0001,0x011C,-1,0x0002,0x0100,-1,0x0003,0x1030,-1,0x0008,0x0808,-1,0x000C,0x0000,-1,0x000F,0x0A01,-1,0x0020,0x0000, \ --1,0x0021,0x0000,-2,50,-1,0x0010,0x0A00,-1,0x0011,0x1038,-2,50,-1,0x0012,0x1121,-1,0x0013,0x004E,-1,0x0014,0x676F, \ --1,0x0030,0x0000,-1,0x0031,0x00DB,-1,0x0032,0x0000,-1,0x0033,0x0000,-1,0x0034,0x00DB,-1,0x0035,0x0000,-1,0x0036,0x00AF, \ --1,0x0037,0x0000,-1,0x0038,0x00DB,-1,0x0039,0x0000,-1,0x0050,0x0000,-1,0x0051,0x060A,-1,0x0052,0x0D0A,-1,0x0053,0x0303, \ --1,0x0054,0x0A0D,-1,0x0055,0x0A06,-1,0x0056,0x0000,-1,0x0057,0x0303,-1,0x0058,0x0000,-1,0x0059,0x0000,-2,50, \ --1,0x0007,0x1017,-2,50,-3 }; +static int ili9225_init[] = { +-1, 0x0001, 0x011C, -1, 0x0002, 0x0100, -1, 0x0003, 0x1030, -1, 0x0008, 0x0808, -1, 0x000C, 0x0000, -1, 0x000F, 0x0A01, -1, 0x0020, 0x0000, +-1, 0x0021, 0x0000, -2, 50, -1, 0x0010, 0x0A00, -1, 0x0011, 0x1038, -2, 50, -1, 0x0012, 0x1121, -1, 0x0013, 0x004E, -1, 0x0014, 0x676F, +-1, 0x0030, 0x0000, -1, 0x0031, 0x00DB, -1, 0x0032, 0x0000, -1, 0x0033, 0x0000, -1, 0x0034, 0x00DB, -1, 0x0035, 0x0000, -1, 0x0036, 0x00AF, +-1, 0x0037, 0x0000, -1, 0x0038, 0x00DB, -1, 0x0039, 0x0000, -1, 0x0050, 0x0000, -1, 0x0051, 0x060A, -1, 0x0052, 0x0D0A, -1, 0x0053, 0x0303, +-1, 0x0054, 0x0A0D, -1, 0x0055, 0x0A06, -1, 0x0056, 0x0000, -1, 0x0057, 0x0303, -1, 0x0058, 0x0000, -1, 0x0059, 0x0000, -2, 50, +-1, 0x0007, 0x1017, -2, 50, -3 }; -static int ili9320_init[] = { \ --1,0x00E5,0x8000,-1,0x0000,0x0001,-1,0x0001,0x0100,-1,0x0002,0x0700,-1,0x0003,0x1030,-1,0x0004,0x0000,-1,0x0008,0x0202, \ --1,0x0009,0x0000,-1,0x000A,0x0000,-1,0x000C,0x0000,-1,0x000D,0x0000,-1,0x000F,0x0000,-1,0x0010,0x0000,-1,0x0011,0x0007, \ --1,0x0012,0x0000,-1,0x0013,0x0000,-2,200,-1,0x0010,0x17B0,-1,0x0011,0x0031,-2,50,-1,0x0012,0x0138,-2,50,-1,0x0013,0x1800, \ --1,0x0029,0x0008,-2,50,-1,0x0020,0x0000,-1,0x0021,0x0000,-1,0x0030,0x0000,-1,0x0031,0x0505,-1,0x0032,0x0004, \ --1,0x0035,0x0006,-1,0x0036,0x0707,-1,0x0037,0x0105,-1,0x0038,0x0002,-1,0x0039,0x0707,-1,0x003C,0x0704,-1,0x003D,0x0807, \ --1,0x0050,0x0000,-1,0x0051,0x00EF,-1,0x0052,0x0000,-1,0x0053,0x013F,-1,0x0060,0x2700,-1,0x0061,0x0001,-1,0x006A,0x0000, \ --1,0x0080,0x0000,-1,0x0081,0x0000,-1,0x0082,0x0000,-1,0x0083,0x0000,-1,0x0084,0x0000,-1,0x0085,0x0000,-1,0x0090,0x0010, \ --1,0x0092,0x0000,-1,0x0093,0x0003,-1,0x0095,0x0110,-1,0x0097,0x0000,-1,0x0098,0x0000,-1,0x0007,0x0173,-3 }; +static int ili9320_init[] = { +-1, 0x00E5, 0x8000, -1, 0x0000, 0x0001, -1, 0x0001, 0x0100, -1, 0x0002, 0x0700, -1, 0x0003, 0x1030, -1, 0x0004, 0x0000, -1, 0x0008, 0x0202, +-1, 0x0009, 0x0000, -1, 0x000A, 0x0000, -1, 0x000C, 0x0000, -1, 0x000D, 0x0000, -1, 0x000F, 0x0000, -1, 0x0010, 0x0000, -1, 0x0011, 0x0007, +-1, 0x0012, 0x0000, -1, 0x0013, 0x0000, -2, 200, -1, 0x0010, 0x17B0, -1, 0x0011, 0x0031, -2, 50, -1, 0x0012, 0x0138, -2, 50, -1, 0x0013, 0x1800, +-1, 0x0029, 0x0008, -2, 50, -1, 0x0020, 0x0000, -1, 0x0021, 0x0000, -1, 0x0030, 0x0000, -1, 0x0031, 0x0505, -1, 0x0032, 0x0004, +-1, 0x0035, 0x0006, -1, 0x0036, 0x0707, -1, 0x0037, 0x0105, -1, 0x0038, 0x0002, -1, 0x0039, 0x0707, -1, 0x003C, 0x0704, -1, 0x003D, 0x0807, +-1, 0x0050, 0x0000, -1, 0x0051, 0x00EF, -1, 0x0052, 0x0000, -1, 0x0053, 0x013F, -1, 0x0060, 0x2700, -1, 0x0061, 0x0001, -1, 0x006A, 0x0000, +-1, 0x0080, 0x0000, -1, 0x0081, 0x0000, -1, 0x0082, 0x0000, -1, 0x0083, 0x0000, -1, 0x0084, 0x0000, -1, 0x0085, 0x0000, -1, 0x0090, 0x0010, +-1, 0x0092, 0x0000, -1, 0x0093, 0x0003, -1, 0x0095, 0x0110, -1, 0x0097, 0x0000, -1, 0x0098, 0x0000, -1, 0x0007, 0x0173, -3 }; -static int ili9325_init[] = { \ --1,0x00E3,0x3008,-1,0x00E7,0x0012,-1,0x00EF,0x1231,-1,0x0001,0x0100,-1,0x0002,0x0700,-1,0x0003,0x1030,-1,0x0004,0x0000, \ --1,0x0008,0x0207,-1,0x0009,0x0000,-1,0x000A,0x0000,-1,0x000C,0x0000,-1,0x000D,0x0000,-1,0x000F,0x0000,-1,0x0010,0x0000, \ --1,0x0011,0x0007,-1,0x0012,0x0000,-1,0x0013,0x0000,-2,200,-1,0x0010,0x1690,-1,0x0011,0x0223,-2,50,-1,0x0012,0x000D,-2,50, \ --1,0x0013,0x1200,-1,0x0029,0x000A,-1,0x002B,0x000C,-2,50,-1,0x0020,0x0000,-1,0x0021,0x0000,-1,0x0030,0x0000, \ --1,0x0031,0x0506,-1,0x0032,0x0104,-1,0x0035,0x0207,-1,0x0036,0x000F,-1,0x0037,0x0306,-1,0x0038,0x0102,-1,0x0039,0x0707, \ --1,0x003C,0x0702,-1,0x003D,0x1604,-1,0x0050,0x0000,-1,0x0051,0x00EF,-1,0x0052,0x0000,-1,0x0053,0x013F,-1,0x0060,0xA700, \ --1,0x0061,0x0001,-1,0x006A,0x0000,-1,0x0080,0x0000,-1,0x0081,0x0000,-1,0x0082,0x0000,-1,0x0083,0x0000,-1,0x0084,0x0000, \ --1,0x0085,0x0000,-1,0x0090,0x0010,-1,0x0092,0x0600,-1,0x0007,0x0133,-3 }; +static int ili9325_init[] = { +-1, 0x00E3, 0x3008, -1, 0x00E7, 0x0012, -1, 0x00EF, 0x1231, -1, 0x0001, 0x0100, -1, 0x0002, 0x0700, -1, 0x0003, 0x1030, -1, 0x0004, 0x0000, +-1, 0x0008, 0x0207, -1, 0x0009, 0x0000, -1, 0x000A, 0x0000, -1, 0x000C, 0x0000, -1, 0x000D, 0x0000, -1, 0x000F, 0x0000, -1, 0x0010, 0x0000, +-1, 0x0011, 0x0007, -1, 0x0012, 0x0000, -1, 0x0013, 0x0000, -2, 200, -1, 0x0010, 0x1690, -1, 0x0011, 0x0223, -2, 50, -1, 0x0012, 0x000D, -2, 50, +-1, 0x0013, 0x1200, -1, 0x0029, 0x000A, -1, 0x002B, 0x000C, -2, 50, -1, 0x0020, 0x0000, -1, 0x0021, 0x0000, -1, 0x0030, 0x0000, +-1, 0x0031, 0x0506, -1, 0x0032, 0x0104, -1, 0x0035, 0x0207, -1, 0x0036, 0x000F, -1, 0x0037, 0x0306, -1, 0x0038, 0x0102, -1, 0x0039, 0x0707, +-1, 0x003C, 0x0702, -1, 0x003D, 0x1604, -1, 0x0050, 0x0000, -1, 0x0051, 0x00EF, -1, 0x0052, 0x0000, -1, 0x0053, 0x013F, -1, 0x0060, 0xA700, +-1, 0x0061, 0x0001, -1, 0x006A, 0x0000, -1, 0x0080, 0x0000, -1, 0x0081, 0x0000, -1, 0x0082, 0x0000, -1, 0x0083, 0x0000, -1, 0x0084, 0x0000, +-1, 0x0085, 0x0000, -1, 0x0090, 0x0010, -1, 0x0092, 0x0600, -1, 0x0007, 0x0133, -3 }; -static int ili9341_init[] = { \ --1,0x28,-2,20,-1,0xCF,0x00,0x83,0x30,-1,0xED,0x64,0x03,0x12,0x81,-1,0xE8,0x85,0x01,0x79, \ --1,0xCB,0x39,0x2c,0x00,0x34,0x02,-1,0xF7,0x20,-1,0xEA,0x00,0x00,-1,0xC0,0x26,-1,0xC1,0x11, \ --1,0xC5,0x35,0x3E,-1,0xC7,0xBE,-1,0xB1,0x00,0x1B,-1,0xB6,0x0a,0x82,0x27,0x00,-1,0xB7,0x07, \ --1,0x3A,0x55,-1,0x36,0x48,-1,0x11,-2,120,-1,0x29,-2,20,-3 }; +static int ili9341_init[] = { +-1, 0x28, -2, 20, -1, 0xCF, 0x00, 0x83, 0x30, -1, 0xED, 0x64, 0x03, 0x12, 0x81, -1, 0xE8, 0x85, 0x01, 0x79, +-1, 0xCB, 0x39, 0x2c, 0x00, 0x34, 0x02, -1, 0xF7, 0x20, -1, 0xEA, 0x00, 0x00, -1, 0xC0, 0x26, -1, 0xC1, 0x11, +-1, 0xC5, 0x35, 0x3E, -1, 0xC7, 0xBE, -1, 0xB1, 0x00, 0x1B, -1, 0xB6, 0x0a, 0x82, 0x27, 0x00, -1, 0xB7, 0x07, +-1, 0x3A, 0x55, -1, 0x36, 0x48, -1, 0x11, -2, 120, -1, 0x29, -2, 20, -3 }; -static int ssd1351_init[] = { -1,0xfd,0x12,-1,0xfd,0xb1,-1,0xae,-1,0xb3,0xf1,-1,0xca,0x7f,-1,0xa0,0x74, \ - -1,0x15,0x00,0x7f,-1,0x75,0x00,0x7f,-1,0xa1,0x00,-1,0xa2,0x00,-1,0xb5,0x00, \ - -1,0xab,0x01,-1,0xb1,0x32,-1,0xb4,0xa0,0xb5,0x55,-1,0xbb,0x17,-1,0xbe,0x05, \ - -1,0xc1,0xc8,0x80,0xc8,-1,0xc7,0x0f,-1,0xb6,0x01,-1,0xa6,-1,0xaf,-3 }; +static int ssd1351_init[] = { -1, 0xfd, 0x12, -1, 0xfd, 0xb1, -1, 0xae, -1, 0xb3, 0xf1, -1, 0xca, 0x7f, -1, 0xa0, 0x74, + -1, 0x15, 0x00, 0x7f, -1, 0x75, 0x00, 0x7f, -1, 0xa1, 0x00, -1, 0xa2, 0x00, -1, 0xb5, 0x00, + -1, 0xab, 0x01, -1, 0xb1, 0x32, -1, 0xb4, 0xa0, 0xb5, 0x55, -1, 0xbb, 0x17, -1, 0xbe, 0x05, + -1, 0xc1, 0xc8, 0x80, 0xc8, -1, 0xc7, 0x0f, -1, 0xb6, 0x01, -1, 0xa6, -1, 0xaf, -3 }; /* ili9320, ili9325 */ From 38e127275fa5c88fb23ace8011eda05994c4ef78 Mon Sep 17 00:00:00 2001 From: Anton Gerasimov Date: Sat, 13 Jun 2015 22:36:35 +0300 Subject: [PATCH 1028/1163] staging: fbtft: correct a typo in a comment Typo in a comment to register write corrected. Signed-off-by: Anton Gerasimov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fb_ili9320.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/fbtft/fb_ili9320.c b/drivers/staging/fbtft/fb_ili9320.c index 0301bd5dd9ff..ef4fa6b72c79 100644 --- a/drivers/staging/fbtft/fb_ili9320.c +++ b/drivers/staging/fbtft/fb_ili9320.c @@ -147,7 +147,7 @@ static int init_display(struct fbtft_par *par) /* Vertical GRAM Start Address */ write_reg(par, 0x0052, 0x0000); - /* Vertical GRAM Start Address */ + /* Vertical GRAM End Address */ write_reg(par, 0x0053, 0x013F); /* Gate Scan Line */ From 73250a7311204bcc7c1803c6b96021f8b04f9903 Mon Sep 17 00:00:00 2001 From: Joglekar Tejas Date: Sun, 14 Jun 2015 03:01:06 +0000 Subject: [PATCH 1029/1163] staging:rtl8723au:ioctl_cfg80211:spaces required around '>' This patch removes the error given by checkpatch.pl " spaces required around that '>' " Signed-off-by: Joglekar Tejas 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 bc95ce89af06..feb596123cc3 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -1041,7 +1041,7 @@ static u16 rtw_get_cur_max_rate(struct rtw_adapter *adapter) while (pcur_bss->SupportedRates[i] != 0 && pcur_bss->SupportedRates[i] != 0xFF) { rate = pcur_bss->SupportedRates[i] & 0x7F; - if (rate>max_rate) + if (rate > max_rate) max_rate = rate; i++; } From 2a049f7e64bd622f09ddf970e63782f63aeecfa9 Mon Sep 17 00:00:00 2001 From: Joglekar Tejas Date: Sun, 14 Jun 2015 04:25:28 +0000 Subject: [PATCH 1030/1163] staging:rtl8723au:rtw_ap:space prohibited between function name & '(' This patch removes the warning "space prohibited between function name and open parenthesis"given by checkpatch.pl Signed-off-by: Joglekar Tejas 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 645668950e9c..65b209a20c29 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -1642,7 +1642,7 @@ u8 ap_free_sta23a(struct rtw_adapter *padapter, struct sta_info *psta, bool acti return beacon_updated; } -int rtw_ap_inform_ch_switch23a (struct rtw_adapter *padapter, u8 new_ch, u8 ch_offset) +int rtw_ap_inform_ch_switch23a(struct rtw_adapter *padapter, u8 new_ch, u8 ch_offset) { struct list_head *phead, *plist; struct sta_info *psta = NULL; @@ -1663,12 +1663,12 @@ int rtw_ap_inform_ch_switch23a (struct rtw_adapter *padapter, u8 new_ch, u8 ch_o list_for_each(plist, phead) { psta = container_of(plist, struct sta_info, asoc_list); - issue_action_spct_ch_switch23a (padapter, psta->hwaddr, new_ch, ch_offset); + issue_action_spct_ch_switch23a(padapter, psta->hwaddr, new_ch, ch_offset); psta->expire_to = ((pstapriv->expire_to * 2) > 5) ? 5 : (pstapriv->expire_to * 2); } spin_unlock_bh(&pstapriv->asoc_list_lock); - issue_action_spct_ch_switch23a (padapter, bc_addr, new_ch, ch_offset); + issue_action_spct_ch_switch23a(padapter, bc_addr, new_ch, ch_offset); return 0; } @@ -1871,7 +1871,7 @@ void stop_ap_mode23a(struct rtw_adapter *padapter) pmlmeext->bstart_bss = false; /* reset and init security priv , this can refine with rtw_reset_securitypriv23a */ - memset((unsigned char *)&padapter->securitypriv, 0, sizeof (struct security_priv)); + memset((unsigned char *)&padapter->securitypriv, 0, sizeof(struct security_priv)); padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; padapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled; From 2b49e0fce249bd8556828b9601328a679ca43860 Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Sun, 14 Jun 2015 14:40:23 +0200 Subject: [PATCH 1031/1163] staging: rtl8188eu: don't define issue_asocrsp() in non-AP mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If CONFIG_88EU_AP_MODE is undefined, issue_asocrsp() is never referenced. Fixes warning: drivers/staging/rtl8188eu/core/rtw_mlme_ext.c:891:13: warning: ‘issue_asocrsp’ defined but not used [-Wunused-function] Signed-off-by: Luca Ceresoli Fixes: 782eddd748d9 ("staging: rtl8188eu: unexport internal functions") Cc: Greg Kroah-Hartman Cc: Larry Finger Cc: kbuild test robot Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index a68bc3cc3981..11cb0fac5da0 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -888,10 +888,10 @@ static void issue_auth(struct adapter *padapter, struct sta_info *psta, } +#ifdef CONFIG_88EU_AP_MODE static void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_info *pstat, int pkt_type) { -#ifdef CONFIG_88EU_AP_MODE struct xmit_frame *pmgntframe; struct rtw_ieee80211_hdr *pwlanhdr; struct pkt_attrib *pattrib; @@ -1011,8 +1011,8 @@ static void issue_asocrsp(struct adapter *padapter, unsigned short status, pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe(padapter, pmgntframe); -#endif } +#endif /* CONFIG_88EU_AP_MODE */ static void issue_assocreq(struct adapter *padapter) { From f996bd10a049e897255ef3029f9ad94055009996 Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Sun, 14 Jun 2015 14:40:24 +0200 Subject: [PATCH 1032/1163] staging: rtl8188eu: don't define OnAuth() in non-AP mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If CONFIG_88EU_AP_MODE is undefined, OnAuth() is never referenced. Fixes warning: drivers/staging/rtl8188eu/core/rtw_mlme_ext.c:2725:21: warning: ‘OnAuth’ defined but not used [-Wunused-function] Signed-off-by: Luca Ceresoli Fixes: 68345dd7bc26 ("staging: rtl8188eu: rtw_mlme_ext.c: unexport message callbacks") Cc: Greg Kroah-Hartman Cc: Larry Finger Cc: kbuild test robot Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 11cb0fac5da0..a0b8f665fa2f 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -2722,10 +2722,10 @@ _END_ONBEACON_: return _SUCCESS; } +#ifdef CONFIG_88EU_AP_MODE static unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame) { -#ifdef CONFIG_88EU_AP_MODE unsigned int auth_mode, ie_len; u16 seq; unsigned char *sa, *p; @@ -2888,9 +2888,9 @@ auth_fail: issue_auth(padapter, pstat, (unsigned short)status); -#endif /* CONFIG_88EU_AP_MODE */ return _FAIL; } +#endif /* CONFIG_88EU_AP_MODE */ static unsigned int OnAuthClient(struct adapter *padapter, struct recv_frame *precv_frame) From e968542ced9a3272a53e68c4da85558a4636bdc6 Mon Sep 17 00:00:00 2001 From: matt mooney Date: Mon, 15 Jun 2015 20:38:22 -0700 Subject: [PATCH 1033/1163] staging: vt6655: fix c99 comments and line length Change comment style and remove extra spaces before macro names to avoid exceeding 80 characters. Signed-off-by: matt mooney Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/power.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6655/power.h b/drivers/staging/vt6655/power.h index 1083341b2a47..538e68507bb0 100644 --- a/drivers/staging/vt6655/power.h +++ b/drivers/staging/vt6655/power.h @@ -29,9 +29,9 @@ #ifndef __POWER_H__ #define __POWER_H__ -#define C_PWBT 1000 // micro sec. power up before TBTT -#define PS_FAST_INTERVAL 1 // Fast power saving listen interval -#define PS_MAX_INTERVAL 4 // MAX power saving listen interval +#define C_PWBT 1000 /* micro sec. power up before TBTT */ +#define PS_FAST_INTERVAL 1 /* Fast power saving listen interval */ +#define PS_MAX_INTERVAL 4 /* MAX power saving listen interval */ void PSvDisablePowerSaving( @@ -50,4 +50,4 @@ PSbIsNextTBTTWakeUp( void *hDeviceContext ); -#endif //__POWER_H__ +#endif /* __POWER_H__ */ From 576917ad24c5552a34bee2192027dba9ba003b5a Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Mon, 15 Jun 2015 11:58:57 +0900 Subject: [PATCH 1034/1163] staging: wilc1000: change WILC_Char to char change own data type(WILC_Char) to common data type(char) Signed-off-by: Dean Lee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 24 ++--- drivers/staging/wilc1000/coreconfigurator.h | 4 +- drivers/staging/wilc1000/host_interface.c | 88 +++++++++---------- drivers/staging/wilc1000/wilc_memory.c | 8 +- drivers/staging/wilc1000/wilc_memory.h | 8 +- drivers/staging/wilc1000/wilc_oswrapper.h | 3 - drivers/staging/wilc1000/wilc_strutils.c | 6 +- drivers/staging/wilc1000/wilc_strutils.h | 6 +- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 6 +- 9 files changed, 75 insertions(+), 78 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index 792ba6df1053..bbb32318b2c3 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -141,7 +141,7 @@ typedef enum { typedef struct { - WILC_Char *pcRespBuffer; + char *pcRespBuffer; s32 s32MaxRespBuffLen; s32 s32BytesRead; bool bRespRequired; @@ -339,7 +339,7 @@ INLINE u8 get_hex_char(u8 inp) /* This function extracts the MAC address held in a string in standard format */ /* into another buffer as integers. */ -INLINE u16 extract_mac_addr(WILC_Char *str, u8 *buff) +INLINE u16 extract_mac_addr(char *str, u8 *buff) { *buff = 0; while (*str != '\0') { @@ -1095,7 +1095,7 @@ s32 DeallocateSurveyResults(wid_site_survey_reslts_s *pstrSurveyResults) /* */ /*****************************************************************************/ -void ProcessCharWid(WILC_Char *pcPacket, s32 *ps32PktLen, +void ProcessCharWid(char *pcPacket, s32 *ps32PktLen, tstrWID *pstrWID, s8 *ps8WidVal) { u8 *pu8val = (u8 *)ps8WidVal; @@ -1149,7 +1149,7 @@ void ProcessCharWid(WILC_Char *pcPacket, s32 *ps32PktLen, /* */ /*****************************************************************************/ -void ProcessShortWid(WILC_Char *pcPacket, s32 *ps32PktLen, +void ProcessShortWid(char *pcPacket, s32 *ps32PktLen, tstrWID *pstrWID, s8 *ps8WidVal) { u16 *pu16val = (u16 *)ps8WidVal; @@ -1204,7 +1204,7 @@ void ProcessShortWid(WILC_Char *pcPacket, s32 *ps32PktLen, /* */ /*****************************************************************************/ -void ProcessIntWid(WILC_Char *pcPacket, s32 *ps32PktLen, +void ProcessIntWid(char *pcPacket, s32 *ps32PktLen, tstrWID *pstrWID, s8 *ps8WidVal) { u32 *pu32val = (u32 *)ps8WidVal; @@ -1262,7 +1262,7 @@ void ProcessIntWid(WILC_Char *pcPacket, s32 *ps32PktLen, /* */ /*****************************************************************************/ -void ProcessIPwid(WILC_Char *pcPacket, s32 *ps32PktLen, +void ProcessIPwid(char *pcPacket, s32 *ps32PktLen, tstrWID *pstrWID, u8 *pu8ip) { u32 u32val = 0; @@ -1320,7 +1320,7 @@ void ProcessIPwid(WILC_Char *pcPacket, s32 *ps32PktLen, /* */ /*****************************************************************************/ -void ProcessStrWid(WILC_Char *pcPacket, s32 *ps32PktLen, +void ProcessStrWid(char *pcPacket, s32 *ps32PktLen, tstrWID *pstrWID, u8 *pu8val, s32 s32ValueSize) { u16 u16MsgLen = 0; @@ -1377,7 +1377,7 @@ void ProcessStrWid(WILC_Char *pcPacket, s32 *ps32PktLen, /* */ /*****************************************************************************/ -void ProcessAdrWid(WILC_Char *pcPacket, s32 *ps32PktLen, +void ProcessAdrWid(char *pcPacket, s32 *ps32PktLen, tstrWID *pstrWID, u8 *pu8val) { u16 u16MsgLen = 0; @@ -1441,7 +1441,7 @@ void ProcessAdrWid(WILC_Char *pcPacket, s32 *ps32PktLen, /* */ /*****************************************************************************/ -void ProcessBinWid(WILC_Char *pcPacket, s32 *ps32PktLen, +void ProcessBinWid(char *pcPacket, s32 *ps32PktLen, tstrWID *pstrWID, u8 *pu8val, s32 s32ValueSize) { /* WILC_ERROR("processing Binary WIDs is not supported\n"); */ @@ -1802,7 +1802,7 @@ s32 ParseWriteResponse(u8 *pu8RespBuffer) * @version 1.0 */ -s32 CreatePacketHeader(WILC_Char *pcpacket, s32 *ps32PacketLength) +s32 CreatePacketHeader(char *pcpacket, s32 *ps32PacketLength) { s32 s32Error = WILC_SUCCESS; u16 u16MsgLen = (u16)(*ps32PacketLength); @@ -1911,7 +1911,7 @@ s32 CreateConfigPacket(s8 *ps8packet, s32 *ps32PacketLength, return s32Error; } -s32 ConfigWaitResponse(WILC_Char *pcRespBuffer, s32 s32MaxRespBuffLen, s32 *ps32BytesRead, +s32 ConfigWaitResponse(char *pcRespBuffer, s32 s32MaxRespBuffLen, s32 *ps32BytesRead, bool bRespRequired) { s32 s32Error = WILC_SUCCESS; @@ -2016,7 +2016,7 @@ End_ConfigPkt: return s32Error; } #endif -s32 ConfigProvideResponse(WILC_Char *pcRespBuffer, s32 s32RespLen) +s32 ConfigProvideResponse(char *pcRespBuffer, s32 s32RespLen) { s32 s32Error = WILC_SUCCESS; diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h index 6ed82e2b4fc9..6c1dad13f013 100644 --- a/drivers/staging/wilc1000/coreconfigurator.h +++ b/drivers/staging/wilc1000/coreconfigurator.h @@ -461,12 +461,12 @@ typedef struct { #ifndef CONNECT_DIRECT typedef struct wid_site_survey_reslts { - WILC_Char SSID[MAX_SSID_LEN]; + char SSID[MAX_SSID_LEN]; u8 BssType; u8 Channel; u8 SecurityStatus; u8 BSSID[6]; - WILC_Char RxPower; + char RxPower; u8 Reserved; } wid_site_survey_reslts_s; diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 1e9a2f142a3c..e091bbc7bf3e 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -452,7 +452,7 @@ typedef union _tuniHostIFmsgBody { tstrHostIfRemainOnChan strHostIfRemainOnChan; tstrHostIfRegisterFrame strHostIfRegisterFrame; #endif - WILC_Char *pUserData; + char *pUserData; tstrHostIFDelAllSta strHostIFDelAllSta; } tuniHostIFmsgBody; @@ -474,7 +474,7 @@ typedef struct _tstrHostIFmsg { #ifdef CONNECT_DIRECT typedef struct _tstrWidJoinReqExt { - WILC_Char SSID[MAX_SSID_LEN]; + char SSID[MAX_SSID_LEN]; u8 u8channel; u8 BSSID[6]; } tstrWidJoinReqExt; @@ -489,7 +489,7 @@ typedef struct _tstrJoinBssParam { u16 beacon_period; u16 cap_info; u8 au8bssid[6]; - WILC_Char ssid[MAX_SSID_LEN]; + char ssid[MAX_SSID_LEN]; u8 ssidLen; u8 supp_rates[MAX_RATES_SUPPORTED + 1]; u8 ht_capable; @@ -616,8 +616,8 @@ static s32 Handle_SetChannel(void *drvHandler, tstrHostIFSetChan *pstrHostIFSetC /*prepare configuration packet*/ strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL; strWID.enuWIDtype = WID_CHAR; - strWID.ps8WidVal = (WILC_Char *)&(pstrHostIFSetChan->u8SetChan); - strWID.s32ValueSize = sizeof(WILC_Char); + strWID.ps8WidVal = (char *)&(pstrHostIFSetChan->u8SetChan); + strWID.s32ValueSize = sizeof(char); PRINT_D(HOSTINF_DBG, "Setting channel\n"); /*Sending Cfg*/ @@ -944,7 +944,7 @@ static s32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *strHostIFCf strWIDList[u8WidCnt].u16WIDid = WID_BSS_TYPE; strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type; strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; - strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); + strWIDList[u8WidCnt].s32ValueSize = sizeof(char); pstrWFIDrv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); @@ -962,7 +962,7 @@ static s32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *strHostIFCf strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TYPE; strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type; strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; - strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); + strWIDList[u8WidCnt].s32ValueSize = sizeof(char); pstrWFIDrv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); @@ -994,7 +994,7 @@ static s32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *strHostIFCf strWIDList[u8WidCnt].u16WIDid = WID_POWER_MANAGEMENT; strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode; strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; - strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); + strWIDList[u8WidCnt].s32ValueSize = sizeof(char); pstrWFIDrv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); @@ -1064,7 +1064,7 @@ static s32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *strHostIFCf strWIDList[u8WidCnt].u16WIDid = WID_PREAMBLE; strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type; strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; - strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); + strWIDList[u8WidCnt].s32ValueSize = sizeof(char); pstrWFIDrv->strCfgValues.preamble_type = strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); @@ -1076,7 +1076,7 @@ static s32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *strHostIFCf strWIDList[u8WidCnt].u16WIDid = WID_SHORT_SLOT_ALLOWED; strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed; strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; - strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); + strWIDList[u8WidCnt].s32ValueSize = sizeof(char); pstrWFIDrv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); @@ -1092,7 +1092,7 @@ static s32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *strHostIFCf strWIDList[u8WidCnt].u16WIDid = WID_11N_TXOP_PROT_DISABLE; strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled; strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; - strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); + strWIDList[u8WidCnt].s32ValueSize = sizeof(char); pstrWFIDrv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); @@ -1118,7 +1118,7 @@ static s32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *strHostIFCf strWIDList[u8WidCnt].u16WIDid = WID_DTIM_PERIOD; strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period; strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; - strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); + strWIDList[u8WidCnt].s32ValueSize = sizeof(char); pstrWFIDrv->strCfgValues.dtim_period = strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); @@ -1135,7 +1135,7 @@ static s32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *strHostIFCf strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY; strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled; strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; - strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char); + strWIDList[u8WidCnt].s32ValueSize = sizeof(char); pstrWFIDrv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled; } else { WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT); @@ -1332,7 +1332,7 @@ static s32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFscanAttr) /*Scan Type*/ strWIDList[u32WidsCount].u16WIDid = WID_SCAN_TYPE; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; - strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); + strWIDList[u32WidsCount].s32ValueSize = sizeof(char); strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanType)); u32WidsCount++; @@ -1358,7 +1358,7 @@ static s32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFscanAttr) /*Scan Request*/ strWIDList[u32WidsCount].u16WIDid = WID_START_SCAN_REQ; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; - strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); + strWIDList[u32WidsCount].s32ValueSize = sizeof(char); strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanSource)); u32WidsCount++; @@ -1446,7 +1446,7 @@ static s32 Handle_ScanDone(void *drvHandler, tenuScanEvent enuEvent) strWID.u16WIDid = (u16)WID_ABORT_RUNNING_SCAN; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = (s8 *)&u8abort_running_scan; - strWID.s32ValueSize = sizeof(WILC_Char); + strWID.s32ValueSize = sizeof(char); /*Sending Cfg*/ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); @@ -1612,7 +1612,7 @@ static s32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFcon } strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; - strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); + strWIDList[u32WidsCount].s32ValueSize = sizeof(char); strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security)); u32WidsCount++; @@ -1620,7 +1620,7 @@ static s32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFcon strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; - strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); + strWIDList[u32WidsCount].s32ValueSize = sizeof(char); strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type); u32WidsCount++; @@ -1635,7 +1635,7 @@ static s32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFcon strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; - strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); + strWIDList[u32WidsCount].s32ValueSize = sizeof(char); strWIDList[u32WidsCount].ps8WidVal = (s8 *)&u8bssDscListIndex; u32WidsCount++; @@ -1758,7 +1758,7 @@ static s32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFcon } strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; - strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); + strWIDList[u32WidsCount].s32ValueSize = sizeof(char); strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security)); u32WidsCount++; @@ -1771,7 +1771,7 @@ static s32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFcon strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; - strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); + strWIDList[u32WidsCount].s32ValueSize = sizeof(char); strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type); u32WidsCount++; @@ -2093,7 +2093,7 @@ static s32 Handle_FlushConnect(void *drvHandler) strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; - strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); + strWIDList[u32WidsCount].s32ValueSize = sizeof(char); strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(gu8Flushed11iMode)); u32WidsCount++; @@ -2101,7 +2101,7 @@ static s32 Handle_FlushConnect(void *drvHandler) strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; - strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); + strWIDList[u32WidsCount].s32ValueSize = sizeof(char); strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&gu8FlushedAuthType); u32WidsCount++; @@ -2201,7 +2201,7 @@ static s32 Handle_ConnectTimeout(void *drvHandler) strWID.u16WIDid = (u16)WID_DISCONNECT; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = (s8 *)&u16DummyReasonCode; - strWID.s32ValueSize = sizeof(WILC_Char); + strWID.s32ValueSize = sizeof(char); PRINT_D(HOSTINF_DBG, "Sending disconnect request\n"); @@ -2731,19 +2731,19 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx)); strWIDList[0].u16WIDid = (u16)WID_11I_MODE; strWIDList[0].enuWIDtype = WID_CHAR; - strWIDList[0].s32ValueSize = sizeof(WILC_Char); + strWIDList[0].s32ValueSize = sizeof(char); strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode)); strWIDList[1].u16WIDid = WID_AUTH_TYPE; strWIDList[1].enuWIDtype = WID_CHAR; - strWIDList[1].s32ValueSize = sizeof(WILC_Char); + strWIDList[1].s32ValueSize = sizeof(char); strWIDList[1].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type)); strWIDList[2].u16WIDid = (u16)WID_KEY_ID; strWIDList[2].enuWIDtype = WID_CHAR; strWIDList[2].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx)); - strWIDList[2].s32ValueSize = sizeof(WILC_Char); + strWIDList[2].s32ValueSize = sizeof(char); pu8keybuf = (u8 *)WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen); @@ -2811,7 +2811,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) strWID.u16WIDid = (u16)WID_KEY_ID; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx)); - strWID.s32ValueSize = sizeof(WILC_Char); + strWID.s32ValueSize = sizeof(char); PRINT_D(HOSTINF_DBG, "Setting default key index\n"); @@ -2853,7 +2853,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr) /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */ strWIDList[0].u16WIDid = (u16)WID_11I_MODE; strWIDList[0].enuWIDtype = WID_CHAR; - strWIDList[0].s32ValueSize = sizeof(WILC_Char); + strWIDList[0].s32ValueSize = sizeof(char); strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode)); strWIDList[1].u16WIDid = (u16)WID_ADD_RX_GTK; @@ -2957,7 +2957,7 @@ _WPARxGtk_end_case_: strWIDList[0].u16WIDid = (u16)WID_11I_MODE; strWIDList[0].enuWIDtype = WID_CHAR; - strWIDList[0].s32ValueSize = sizeof(WILC_Char); + strWIDList[0].s32ValueSize = sizeof(char); strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode)); strWIDList[1].u16WIDid = (u16)WID_ADD_PTK; @@ -3080,7 +3080,7 @@ static void Handle_Disconnect(void *drvHandler) strWID.u16WIDid = (u16)WID_DISCONNECT; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = (s8 *)&u16DummyReasonCode; - strWID.s32ValueSize = sizeof(WILC_Char); + strWID.s32ValueSize = sizeof(char); @@ -3205,7 +3205,7 @@ static s32 Switch_Log_Terminal(void *drvHandler) strWID.u16WIDid = (u16)WID_LOGTerminal_Switch; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = &dummy; - strWID.s32ValueSize = sizeof(WILC_Char); + strWID.s32ValueSize = sizeof(char); s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv); @@ -3247,7 +3247,7 @@ static s32 Handle_GetChnl(void *drvHandler) strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = (s8 *)&gu8Chnl; - strWID.s32ValueSize = sizeof(WILC_Char); + strWID.s32ValueSize = sizeof(char); PRINT_D(HOSTINF_DBG, "Getting channel value\n"); @@ -3290,7 +3290,7 @@ static void Handle_GetRssi(void *drvHandler) strWID.u16WIDid = (u16)WID_RSSI; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = &gs8Rssi; - strWID.s32ValueSize = sizeof(WILC_Char); + strWID.s32ValueSize = sizeof(char); /*Sending Cfg*/ PRINT_D(HOSTINF_DBG, "Getting RSSI value\n"); @@ -3322,7 +3322,7 @@ static void Handle_GetLinkspeed(void *drvHandler) strWID.u16WIDid = (u16)WID_LINKSPEED; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = &gs8lnkspd; - strWID.s32ValueSize = sizeof(WILC_Char); + strWID.s32ValueSize = sizeof(char); /*Sending Cfg*/ PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n"); @@ -3348,13 +3348,13 @@ s32 Handle_GetStatistics(void *drvHandler, tstrStatistics *pstrStatistics) strWIDList[u32WidsCount].u16WIDid = WID_LINKSPEED; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; - strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); + strWIDList[u32WidsCount].s32ValueSize = sizeof(char); strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u8LinkSpeed)); u32WidsCount++; strWIDList[u32WidsCount].u16WIDid = WID_RSSI; strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; - strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char); + strWIDList[u32WidsCount].s32ValueSize = sizeof(char); strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->s8RSSI)); u32WidsCount++; @@ -3551,7 +3551,7 @@ static void Handle_DelBeacon(void *drvHandler, tstrHostIFDelBeacon *pstrDelBeaco tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; strWID.u16WIDid = (u16)WID_DEL_BEACON; strWID.enuWIDtype = WID_CHAR; - strWID.s32ValueSize = sizeof(WILC_Char); + strWID.s32ValueSize = sizeof(char); strWID.ps8WidVal = &gu8DelBcn; if (strWID.ps8WidVal == NULL) { @@ -4077,7 +4077,7 @@ static void Handle_PowerManagement(void *drvHandler, tstrHostIfPowerMgmtParam *s } PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode); strWID.ps8WidVal = &s8PowerMode; - strWID.s32ValueSize = sizeof(WILC_Char); + strWID.s32ValueSize = sizeof(char); PRINT_D(HOSTINF_DBG, "Handling Power Management\n"); @@ -5483,7 +5483,7 @@ s32 host_int_set_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 scanSource) strWID.u16WIDid = (u16)WID_START_SCAN_REQ; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = (s8 *)&scanSource; - strWID.s32ValueSize = sizeof(WILC_Char); + strWID.s32ValueSize = sizeof(char); return s32Error; } @@ -5513,7 +5513,7 @@ s32 host_int_get_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ScanSource) strWID.u16WIDid = (u16)WID_START_SCAN_REQ; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = (s8 *)pu8ScanSource; - strWID.s32ValueSize = sizeof(WILC_Char); + strWID.s32ValueSize = sizeof(char); return s32Error; } @@ -5733,7 +5733,7 @@ s32 host_int_disconnect_station(WILC_WFIDrvHandle hWFIDrv, u8 assoc_id) strWID.u16WIDid = (u16)WID_DISCONNECT; strWID.enuWIDtype = WID_CHAR; strWID.ps8WidVal = (s8 *)&assoc_id; - strWID.s32ValueSize = sizeof(WILC_Char); + strWID.s32ValueSize = sizeof(char); return s32Error; } @@ -6057,7 +6057,7 @@ s32 host_int_test_set_int_wid(WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr) /*prepare configuration packet*/ strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS; strWID.enuWIDtype = WID_INT; - strWID.ps8WidVal = (WILC_Char *)&u32TestMemAddr; + strWID.ps8WidVal = (char *)&u32TestMemAddr; strWID.s32ValueSize = sizeof(u32); /*Sending Cfg*/ @@ -6266,7 +6266,7 @@ s32 host_int_get_statistics(WILC_WFIDrvHandle hWFIDrv, tstrStatistics *pstrStati WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg)); strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_STATISTICS; - strHostIFmsg.uniHostIFmsgBody.pUserData = (WILC_Char *)pstrStatistics; + strHostIFmsg.uniHostIFmsgBody.pUserData = (char *)pstrStatistics; strHostIFmsg.drvHandler = hWFIDrv; /* send the message */ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL); diff --git a/drivers/staging/wilc1000/wilc_memory.c b/drivers/staging/wilc1000/wilc_memory.c index 2282951eb574..5670b5a0da0f 100644 --- a/drivers/staging/wilc1000/wilc_memory.c +++ b/drivers/staging/wilc1000/wilc_memory.c @@ -7,7 +7,7 @@ * @version 1.0 */ void *WILC_MemoryAlloc(u32 u32Size, tstrWILC_MemoryAttrs *strAttrs, - WILC_Char *pcFileName, u32 u32LineNo) + char *pcFileName, u32 u32LineNo) { if (u32Size > 0) { return kmalloc(u32Size, GFP_ATOMIC); @@ -22,7 +22,7 @@ void *WILC_MemoryAlloc(u32 u32Size, tstrWILC_MemoryAttrs *strAttrs, * @version 1.0 */ void *WILC_MemoryCalloc(u32 u32Size, tstrWILC_MemoryAttrs *strAttrs, - WILC_Char *pcFileName, u32 u32LineNo) + char *pcFileName, u32 u32LineNo) { return kcalloc(u32Size, 1, GFP_KERNEL); } @@ -33,7 +33,7 @@ void *WILC_MemoryCalloc(u32 u32Size, tstrWILC_MemoryAttrs *strAttrs, * @version 1.0 */ void *WILC_MemoryRealloc(void *pvOldBlock, u32 u32NewSize, - tstrWILC_MemoryAttrs *strAttrs, WILC_Char *pcFileName, u32 u32LineNo) + tstrWILC_MemoryAttrs *strAttrs, char *pcFileName, u32 u32LineNo) { if (u32NewSize == 0) { kfree(pvOldBlock); @@ -52,7 +52,7 @@ void *WILC_MemoryRealloc(void *pvOldBlock, u32 u32NewSize, * @version 1.0 */ void WILC_MemoryFree(const void *pvBlock, tstrWILC_MemoryAttrs *strAttrs, - WILC_Char *pcFileName, u32 u32LineNo) + char *pcFileName, u32 u32LineNo) { kfree(pvBlock); } diff --git a/drivers/staging/wilc1000/wilc_memory.h b/drivers/staging/wilc1000/wilc_memory.h index 8a2be8ae7739..1bc4b530b763 100644 --- a/drivers/staging/wilc1000/wilc_memory.h +++ b/drivers/staging/wilc1000/wilc_memory.h @@ -42,7 +42,7 @@ typedef struct { * @version 1.0 */ void *WILC_MemoryAlloc(u32 u32Size, tstrWILC_MemoryAttrs *strAttrs, - WILC_Char *pcFileName, u32 u32LineNo); + char *pcFileName, u32 u32LineNo); /*! * @brief Allocates a given size of bytes and zero filling it @@ -66,7 +66,7 @@ void *WILC_MemoryAlloc(u32 u32Size, tstrWILC_MemoryAttrs *strAttrs, * @version 1.0 */ void *WILC_MemoryCalloc(u32 u32Size, tstrWILC_MemoryAttrs *strAttrs, - WILC_Char *pcFileName, u32 u32LineNo); + char *pcFileName, u32 u32LineNo); /*! * @brief Reallocates a given block to a new size @@ -94,7 +94,7 @@ void *WILC_MemoryCalloc(u32 u32Size, tstrWILC_MemoryAttrs *strAttrs, * @version 1.0 */ void *WILC_MemoryRealloc(void *pvOldBlock, u32 u32NewSize, - tstrWILC_MemoryAttrs *strAttrs, WILC_Char *pcFileName, u32 u32LineNo); + tstrWILC_MemoryAttrs *strAttrs, char *pcFileName, u32 u32LineNo); /*! * @brief Frees given block @@ -114,7 +114,7 @@ void *WILC_MemoryRealloc(void *pvOldBlock, u32 u32NewSize, * @version 1.0 */ void WILC_MemoryFree(const void *pvBlock, tstrWILC_MemoryAttrs *strAttrs, - WILC_Char *pcFileName, u32 u32LineNo); + char *pcFileName, u32 u32LineNo); /*! * @brief standrad malloc wrapper with custom attributes diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h index d5835d6b09f8..e97aa96006e0 100644 --- a/drivers/staging/wilc1000/wilc_oswrapper.h +++ b/drivers/staging/wilc1000/wilc_oswrapper.h @@ -13,9 +13,6 @@ /* OS Wrapper interface version */ #define WILC_OSW_INTERFACE_VER 2 -/* Character types */ -typedef char WILC_Char; - /* Os Configuration File */ #include "wilc_osconfig.h" #include "wilc_platform.h" diff --git a/drivers/staging/wilc1000/wilc_strutils.c b/drivers/staging/wilc1000/wilc_strutils.c index e9f487a3b956..ac9bb061126a 100644 --- a/drivers/staging/wilc1000/wilc_strutils.c +++ b/drivers/staging/wilc1000/wilc_strutils.c @@ -40,13 +40,13 @@ void *WILC_memset(void *pvTarget, u8 u8SetValue, u32 u32Count) * @date 18 Aug 2010 * @version 1.0 */ -WILC_Char *WILC_strncpy(WILC_Char *pcTarget, const WILC_Char *pcSource, +char *WILC_strncpy(char *pcTarget, const char *pcSource, u32 u32Count) { return strncpy(pcTarget, pcSource, u32Count); } -s32 WILC_strncmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2, +s32 WILC_strncmp(const char *pcStr1, const char *pcStr2, u32 u32Count) { s32 s32Result; @@ -74,7 +74,7 @@ s32 WILC_strncmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2, * @date 18 Aug 2010 * @version 1.0 */ -u32 WILC_strlen(const WILC_Char *pcStr) +u32 WILC_strlen(const char *pcStr) { return (u32)strlen(pcStr); } diff --git a/drivers/staging/wilc1000/wilc_strutils.h b/drivers/staging/wilc1000/wilc_strutils.h index 75670a2800bc..bb31beaf5aef 100644 --- a/drivers/staging/wilc1000/wilc_strutils.h +++ b/drivers/staging/wilc1000/wilc_strutils.h @@ -92,7 +92,7 @@ void *WILC_memset(void *pvTarget, u8 u8SetValue, u32 u32Count); * @date 18 Aug 2010 * @version 1.0 */ -WILC_Char *WILC_strncpy(WILC_Char *pcTarget, const WILC_Char *pcSource, +char *WILC_strncpy(char *pcTarget, const char *pcSource, u32 u32Count); /*! @@ -113,7 +113,7 @@ WILC_Char *WILC_strncpy(WILC_Char *pcTarget, const WILC_Char *pcSource, * @date 7 Dec 2010 * @version 1.0 */ -s32 WILC_strncmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2, +s32 WILC_strncmp(const char *pcStr1, const char *pcStr2, u32 u32Count); /*! @@ -125,6 +125,6 @@ s32 WILC_strncmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2, * @date 18 Aug 2010 * @version 1.0 */ -u32 WILC_strlen(const WILC_Char *pcStr); +u32 WILC_strlen(const char *pcStr); #endif diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 2293949031df..9dcb3268d20c 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -829,9 +829,9 @@ static int WILC_WFI_CfgConnect(struct wiphy *wiphy, struct net_device *dev, u32 i; u8 u8security = NO_ENCRYPT; AUTHTYPE_T tenuAuth_type = ANY; - WILC_Char *pcgroup_encrypt_val = NULL; - WILC_Char *pccipher_group = NULL; - WILC_Char *pcwpa_version = NULL; + char *pcgroup_encrypt_val = NULL; + char *pccipher_group = NULL; + char *pcwpa_version = NULL; struct WILC_WFI_priv *priv; tstrWILC_WFIDrv *pstrWFIDrv; From 635c931d6d16dc0f87545e03eb946b3355b72e62 Mon Sep 17 00:00:00 2001 From: Chaehyun Lim Date: Mon, 15 Jun 2015 12:35:48 +0900 Subject: [PATCH 1035/1163] staging: wilc1000: align defines Align the lines of some defines in wilc_errorsupport.h Signed-off-by: Chaehyun Lim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_errorsupport.h | 32 ++++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_errorsupport.h b/drivers/staging/wilc1000/wilc_errorsupport.h index 6963a4694d3f..b9517dc7f661 100644 --- a/drivers/staging/wilc1000/wilc_errorsupport.h +++ b/drivers/staging/wilc1000/wilc_errorsupport.h @@ -13,26 +13,26 @@ #include "linux_wlan_common.h" /* Psitive Numbers to indicate sucess with special status */ -#define WILC_ALREADY_EXSIT (+100) /** The requested object already exists */ +#define WILC_ALREADY_EXSIT (+100) /** The requested object already exists */ /* Generic success will return 0 */ -#define WILC_SUCCESS 0 /** Generic success */ +#define WILC_SUCCESS 0 /** Generic success */ /* Negative numbers to indicate failures */ -#define WILC_FAIL -100 /** Generic Fail */ -#define WILC_BUSY -101 /** Busy with another operation*/ -#define WILC_INVALID_ARGUMENT -102 /** A given argument is invalid*/ -#define WILC_INVALID_STATE -103 /** An API request would violate the Driver state machine (i.e. to start PID while not camped)*/ -#define WILC_BUFFER_OVERFLOW -104 /** In copy operations if the copied data is larger than the allocated buffer*/ -#define WILC_NULL_PTR -105 /** null pointer is passed or used */ -#define WILC_EMPTY -107 -#define WILC_FULL -108 -#define WILC_TIMEOUT -109 -#define WILC_CANCELED -110 /** The required operation have been canceled by the user*/ -#define WILC_INVALID_FILE -112 /** The Loaded file is corruped or having an invalid format */ -#define WILC_NOT_FOUND -113 /** Cant find the file to load */ -#define WILC_NO_MEM -114 -#define WILC_UNSUPPORTED_VERSION -115 +#define WILC_FAIL -100 /** Generic Fail */ +#define WILC_BUSY -101 /** Busy with another operation*/ +#define WILC_INVALID_ARGUMENT -102 /** A given argument is invalid*/ +#define WILC_INVALID_STATE -103 /** An API request would violate the Driver state machine (i.e. to start PID while not camped)*/ +#define WILC_BUFFER_OVERFLOW -104 /** In copy operations if the copied data is larger than the allocated buffer*/ +#define WILC_NULL_PTR -105 /** null pointer is passed or used */ +#define WILC_EMPTY -107 +#define WILC_FULL -108 +#define WILC_TIMEOUT -109 +#define WILC_CANCELED -110 /** The required operation have been canceled by the user*/ +#define WILC_INVALID_FILE -112 /** The Loaded file is corruped or having an invalid format */ +#define WILC_NOT_FOUND -113 /** Cant find the file to load */ +#define WILC_NO_MEM -114 +#define WILC_UNSUPPORTED_VERSION -115 #define WILC_FILE_EOF -116 From c4263e319ef923eab9041174dde248484ed71771 Mon Sep 17 00:00:00 2001 From: Sunghoon Cho Date: Mon, 15 Jun 2015 19:42:31 +0900 Subject: [PATCH 1036/1163] staging: wilc1000: remove multiple blank lines. Remove the warnings for multiple blank lines reported by checkpatch.pl. Signed-off-by: Sunghoon Cho Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigsimulator.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigsimulator.h b/drivers/staging/wilc1000/coreconfigsimulator.h index 25e3c2ce2278..c4f32f0770b1 100644 --- a/drivers/staging/wilc1000/coreconfigsimulator.h +++ b/drivers/staging/wilc1000/coreconfigsimulator.h @@ -8,13 +8,10 @@ * @version 1.0 */ - #ifndef CORECONFIGSIMULATOR_H #define CORECONFIGSIMULATOR_H - extern s32 CoreConfigSimulatorInit (void); extern s32 CoreConfigSimulatorDeInit (void); - -#endif \ No newline at end of file +#endif From 3f5309725e08b2ce2395bcfea09eb518d3ddb499 Mon Sep 17 00:00:00 2001 From: Sunghoon Cho Date: Mon, 15 Jun 2015 19:42:32 +0900 Subject: [PATCH 1037/1163] staging: wilc1000: remove the warnings on prohibited spaces. Remove space prohibited between function name and open parenthesis. Signed-off-by: Sunghoon Cho Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigsimulator.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigsimulator.h b/drivers/staging/wilc1000/coreconfigsimulator.h index c4f32f0770b1..5e01f8e4a41d 100644 --- a/drivers/staging/wilc1000/coreconfigsimulator.h +++ b/drivers/staging/wilc1000/coreconfigsimulator.h @@ -11,7 +11,7 @@ #ifndef CORECONFIGSIMULATOR_H #define CORECONFIGSIMULATOR_H -extern s32 CoreConfigSimulatorInit (void); -extern s32 CoreConfigSimulatorDeInit (void); +extern s32 CoreConfigSimulatorInit(void); +extern s32 CoreConfigSimulatorDeInit(void); #endif From 30ef5c8b97d9dd381f94a919c21096afe6553f5d Mon Sep 17 00:00:00 2001 From: ChengYi He Date: Tue, 16 Jun 2015 03:04:59 +0800 Subject: [PATCH 1038/1163] staging: wilc1000: remove unnecessary cast kmalloc() returns void pointer. Signed-off-by: ChengYi He Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_mon.c | 2 +- drivers/staging/wilc1000/linux_wlan.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/linux_mon.c b/drivers/staging/wilc1000/linux_mon.c index d5860ce749e0..bc7feb459a7a 100644 --- a/drivers/staging/wilc1000/linux_mon.c +++ b/drivers/staging/wilc1000/linux_mon.c @@ -258,7 +258,7 @@ static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len) len += sizeof(struct tx_complete_mon_data *); #endif - mgmt_tx->buff = (char *)kmalloc(len, GFP_ATOMIC); + mgmt_tx->buff = kmalloc(len, GFP_ATOMIC); if (mgmt_tx->buff == NULL) { PRINT_ER("Failed to allocate memory for mgmt_tx buff\n"); return WILC_FAIL; diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 5f871485d973..c1e92722a471 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -580,7 +580,7 @@ static void linux_wlan_dbg(uint8_t *buff) static void *linux_wlan_malloc_atomic(uint32_t sz) { char *pntr = NULL; - pntr = (char *)kmalloc(sz, GFP_ATOMIC); + pntr = kmalloc(sz, GFP_ATOMIC); PRINT_D(MEM_DBG, "Allocating %d bytes at address %p\n", sz, pntr); return (void *)pntr; @@ -588,7 +588,7 @@ static void *linux_wlan_malloc_atomic(uint32_t sz) static void *linux_wlan_malloc(uint32_t sz) { char *pntr = NULL; - pntr = (char *)kmalloc(sz, GFP_KERNEL); + pntr = kmalloc(sz, GFP_KERNEL); PRINT_D(MEM_DBG, "Allocating %d bytes at address %p\n", sz, pntr); return (void *)pntr; } @@ -605,7 +605,7 @@ void linux_wlan_free(void *vp) static void *internal_alloc(uint32_t size, uint32_t flag) { char *pntr = NULL; - pntr = (char *)kmalloc(size, flag); + pntr = kmalloc(size, flag); PRINT_D(MEM_DBG, "Allocating %d bytes at address %p\n", size, pntr); return (void *)pntr; } From 3bc4cc7719f78b35d23c15ac377bcf9935f77d6c Mon Sep 17 00:00:00 2001 From: Hari Prasath Gujulan Elango Date: Mon, 15 Jun 2015 10:10:18 +0000 Subject: [PATCH 1039/1163] staging: comedi: remove commented code This patch removes commented code.This was a checkpatch warning. Signed-off-by: Hari Prasath Gujulan Elango Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 146ab009d5f7..985d94b6cbfd 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1085,11 +1085,6 @@ static int do_chaninfo_ioctl(struct comedi_device *dev, if (put_user(x, it.rangelist + i)) return -EFAULT; } -#if 0 - if (copy_to_user(it.rangelist, s->range_type_list, - s->n_chan * sizeof(unsigned int))) - return -EFAULT; -#endif } return 0; From f194f4e9e5eb313225f5c353c7147edc7688beb7 Mon Sep 17 00:00:00 2001 From: Hari Prasath Gujulan Elango Date: Mon, 15 Jun 2015 10:54:26 +0000 Subject: [PATCH 1040/1163] staging: emxx_udc: remove commented code This patch removes commented code warned by checkpatch.pl Signed-off-by: Hari Prasath Gujulan Elango Signed-off-by: Greg Kroah-Hartman --- drivers/staging/emxx_udc/emxx_udc.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/emxx_udc/emxx_udc.h b/drivers/staging/emxx_udc/emxx_udc.h index c19168f78354..0db6b41333ea 100644 --- a/drivers/staging/emxx_udc/emxx_udc.h +++ b/drivers/staging/emxx_udc/emxx_udc.h @@ -32,8 +32,6 @@ #define UDC_DEBUG_DUMP #endif -/* #define USE_INT_COUNT_OVER */ - /*----------------- Default define */ #define USE_DMA 1 #define USE_SUSPEND_WAIT 1 @@ -117,14 +115,6 @@ #define BIT30 0x40000000 #define BIT31 0x80000000 -#if 0 -/*------- (0x0000) USB Control Register */ -#define USBTESTMODE (BIT18+BIT17+BIT16) -#define TEST_J BIT16 -#define TEST_K BIT17 -#define TEST_SE0_NAK (BIT17+BIT16) -#define TEST_PACKET BIT18 -#endif #define TEST_FORCE_ENABLE (BIT18+BIT16) #define INT_SEL BIT10 From 4c6b0ec2f1cf08419a08c189fd713a810ca9e86a Mon Sep 17 00:00:00 2001 From: Hari Prasath Gujulan Elango Date: Mon, 15 Jun 2015 11:48:53 +0000 Subject: [PATCH 1041/1163] staging: wlan-ng: Replace hard coded values with MACRO's This patch replaces hard coded values with global definitions for the Ethernet IEEE 802.3 interface defined in standard header file. Signed-off-by: Hari Prasath Gujulan Elango Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/p80211conv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c index c0e6ac8a28eb..49f2ef88929d 100644 --- a/drivers/staging/wlan-ng/p80211conv.c +++ b/drivers/staging/wlan-ng/p80211conv.c @@ -129,7 +129,7 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv, } else { /* step 1: classify ether frame, DIX or 802.3? */ proto = ntohs(e_hdr.type); - if (proto <= 1500) { + if (proto <= ETH_DATA_LEN) { pr_debug("802.3 len: %d\n", skb->len); /* codes <= 1500 reserved for 802.3 lengths */ /* it's 802.3, pass ether payload unchanged, */ @@ -531,7 +531,7 @@ int p80211_stt_findproto(u16 proto) Need to do some testing to confirm. */ - if (proto == 0x80f3) /* APPLETALK */ + if (proto == ETH_P_AARP) /* APPLETALK */ return 1; return 0; From 84b2f7985cee050c554bdd813949a8110caca7b5 Mon Sep 17 00:00:00 2001 From: Hari Prasath Gujulan Elango Date: Mon, 15 Jun 2015 09:27:38 +0000 Subject: [PATCH 1042/1163] staging: rtl8188eu: fix typo in comments section This patch fixes a typo in the comment section. Signed-off-by: Hari Prasath Gujulan Elango Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index 2e96234cd253..a14e79f31abf 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -773,7 +773,7 @@ void rtw_stop_drv_threads(struct adapter *padapter) { RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_stop_drv_threads\n")); - /* Below is to termindate rtw_cmd_thread & event_thread... */ + /* Below is to terminate rtw_cmd_thread & event_thread... */ up(&padapter->cmdpriv.cmd_queue_sema); if (padapter->cmdThread) _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema); From 08c40197479f67c6580b88738da72f9cdffb8b4b Mon Sep 17 00:00:00 2001 From: Jakub Sitnicki Date: Tue, 16 Jun 2015 06:17:23 +0200 Subject: [PATCH 1043/1163] staging: rtl8188eu: kill unused INCLUDE_MULTI_FUNC_* macros Also, remove rt_multi_func enum used exclusively by the killed macros. Signed-off-by: Jakub Sitnicki Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtl8188e_hal.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h index 5015748a9f42..7d8e022925e0 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h @@ -188,14 +188,6 @@ struct txpowerinfo24g { #define EFUSE_PROTECT_BYTES_BANK 16 -/* For RTL8723 WiFi/BT/GPS multi-function configuration. */ -enum rt_multi_func { - RT_MULTI_FUNC_NONE = 0x00, - RT_MULTI_FUNC_WIFI = 0x01, - RT_MULTI_FUNC_BT = 0x02, - RT_MULTI_FUNC_GPS = 0x04, -}; - /* For RTL8723 regulator mode. */ enum rt_regulator_mode { RT_SWITCHING_REGULATOR = 0, @@ -378,11 +370,6 @@ struct hal_data_8188e { ((struct hal_data_8188e *)((__pAdapter)->HalData)) #define GET_RF_TYPE(priv) (GET_HAL_DATA(priv)->rf_type) -#define INCLUDE_MULTI_FUNC_BT(_Adapter) \ - (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_BT) -#define INCLUDE_MULTI_FUNC_GPS(_Adapter) \ - (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_GPS) - /* rtl8188e_hal_init.c */ void _8051Reset88E(struct adapter *padapter); void rtl8188e_InitializeFirmwareVars(struct adapter *padapter); From 99c805f4c2912a8cbdb4659de24e1a14bd498ae3 Mon Sep 17 00:00:00 2001 From: David Kershner Date: Mon, 15 Jun 2015 23:31:56 -0400 Subject: [PATCH 1044/1163] staging: unisys: s-Par video channel includes EFI framebuffer The efi framebuffer is defined within the s-Par video channel console. Before we get the device create message for the video console, s-Par has alreaady informed linux about the efi framebuffer and a memory region is already set up for it. Since we do not use the video channel in linux, we are just ignoring the failure of the video channel request_mem_region. Testing: This patch was tested on top of s-Par and we no longer leave the partition in a failed state. Signed-off-by: David Kershner Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorchannel.c | 40 +++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index e0dfaa9c955d..b1155ab9eeeb 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -20,17 +20,24 @@ * independent of the mechanism used to access the channel data. */ +#include + #include "version.h" #include "visorbus.h" -#include #include "controlvmchannel.h" #define MYDRVNAME "visorchannel" +#define SPAR_CONSOLEVIDEO_CHANNEL_PROTOCOL_GUID \ + UUID_LE(0x3cd6e705, 0xd6a2, 0x4aa5, \ + 0xad, 0x5c, 0x7b, 0x8, 0x88, 0x9d, 0xff, 0xe2) +static const uuid_le spar_video_guid = SPAR_CONSOLEVIDEO_CHANNEL_PROTOCOL_GUID; + struct visorchannel { u64 physaddr; ulong nbytes; void __iomem *mapped; + bool requested; struct channel_header chan_hdr; uuid_le guid; ulong size; @@ -72,8 +79,19 @@ visorchannel_create_guts(u64 physaddr, unsigned long channel_bytes, spin_lock_init(&channel->insert_lock); spin_lock_init(&channel->remove_lock); - if (!request_mem_region(physaddr, size, MYDRVNAME)) - goto cleanup; + /* Video driver constains the efi framebuffer so it will get a + * conflict resource when requesting its full mem region. Since + * we are only using the efi framebuffer for video we can ignore + * this. Remember that we haven't requested it so we don't try to + * release later on. + */ + channel->requested = request_mem_region(physaddr, size, MYDRVNAME); + if (!channel->requested) { + if (uuid_le_cmp(guid, spar_video_guid)) { + /* Not the video channel we care about this */ + goto cleanup; + } + } channel->mapped = ioremap_cache(physaddr, size); if (!channel->mapped) { @@ -96,10 +114,17 @@ visorchannel_create_guts(u64 physaddr, unsigned long channel_bytes, guid = channel->chan_hdr.chtype; iounmap(channel->mapped); - release_mem_region(channel->physaddr, channel->nbytes); + if (channel->requested) + release_mem_region(channel->physaddr, channel->nbytes); channel->mapped = NULL; - if (!request_mem_region(channel->physaddr, channel_bytes, MYDRVNAME)) - goto cleanup; + channel->requested = request_mem_region(channel->physaddr, + channel_bytes, MYDRVNAME); + if (!channel->requested) { + if (uuid_le_cmp(guid, spar_video_guid)) { + /* Different we care about this */ + goto cleanup; + } + } channel->mapped = ioremap_cache(channel->physaddr, channel_bytes); if (!channel->mapped) { @@ -143,7 +168,8 @@ visorchannel_destroy(struct visorchannel *channel) return; if (channel->mapped) { iounmap(channel->mapped); - release_mem_region(channel->physaddr, channel->nbytes); + if (channel->requested) + release_mem_region(channel->physaddr, channel->nbytes); } kfree(channel); } From 39630ee2a37e57cc8dfa3cf5a55f8249d6e883bc Mon Sep 17 00:00:00 2001 From: David Kershner Date: Mon, 15 Jun 2015 23:31:57 -0400 Subject: [PATCH 1045/1163] staging: unisys: Remove visorchannel stub Visorchannel directory has been stripped down to almost nothing, and is no longer referenced. This finishes getting rid of the directory. Signed-off-by: David Kershner Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchannel/Kconfig | 9 ---- drivers/staging/unisys/visorchannel/Makefile | 10 ---- drivers/staging/unisys/visorchannel/globals.h | 25 ---------- .../unisys/visorchannel/visorchannel_main.c | 50 ------------------- 4 files changed, 94 deletions(-) delete mode 100644 drivers/staging/unisys/visorchannel/Kconfig delete mode 100644 drivers/staging/unisys/visorchannel/Makefile delete mode 100644 drivers/staging/unisys/visorchannel/globals.h delete mode 100644 drivers/staging/unisys/visorchannel/visorchannel_main.c diff --git a/drivers/staging/unisys/visorchannel/Kconfig b/drivers/staging/unisys/visorchannel/Kconfig deleted file mode 100644 index 3148f6b2a2e9..000000000000 --- a/drivers/staging/unisys/visorchannel/Kconfig +++ /dev/null @@ -1,9 +0,0 @@ -# -# Unisys visorchannel configuration -# - -config UNISYS_VISORCHANNEL - tristate "Unisys visorchannel driver" - ---help--- - If you say Y here, you will enable the Unisys visorchannel driver. - diff --git a/drivers/staging/unisys/visorchannel/Makefile b/drivers/staging/unisys/visorchannel/Makefile deleted file mode 100644 index 0c0cacbd8843..000000000000 --- a/drivers/staging/unisys/visorchannel/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# -# Makefile for Unisys visorchannel -# - -obj-$(CONFIG_UNISYS_VISORCHANNEL) += visorchannel.o - -visorchannel-y := visorchannel_main.o visorchannel_funcs.o - -ccflags-y += -Idrivers/staging/unisys/include -ccflags-y += -Idrivers/staging/unisys/visorutil diff --git a/drivers/staging/unisys/visorchannel/globals.h b/drivers/staging/unisys/visorchannel/globals.h deleted file mode 100644 index 1c3c427e3e13..000000000000 --- a/drivers/staging/unisys/visorchannel/globals.h +++ /dev/null @@ -1,25 +0,0 @@ -/* globals.h - * - * 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. - */ - -#ifndef __VISORCHANNEL_GLOBALS_H__ -#define __VISORCHANNEL_GLOBALS_H__ - -#include "version.h" - -#define MYDRVNAME "visorchannel" - -#endif diff --git a/drivers/staging/unisys/visorchannel/visorchannel_main.c b/drivers/staging/unisys/visorchannel/visorchannel_main.c deleted file mode 100644 index 787d4774b199..000000000000 --- a/drivers/staging/unisys/visorchannel/visorchannel_main.c +++ /dev/null @@ -1,50 +0,0 @@ -/* visorchannel_main.c - * - * 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. - */ - -/* - * This is a module "wrapper" around visorchannel_funcs. - */ - -#include "globals.h" -#include "channel.h" -#include "visorchannel.h" -#include - -#define MYDRVNAME "visorchannel" - -static int __init -visorchannel_init(void) -{ - if (!unisys_spar_platform) - return -ENODEV; - - return 0; -} - -static void -visorchannel_exit(void) -{ -} - -module_init(visorchannel_init); -module_exit(visorchannel_exit); - -MODULE_AUTHOR("Unisys"); -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("Supervisor channel driver for service partition: ver " - VERSION); -MODULE_VERSION(VERSION); From dbb9d619941ad57dbe3c6667764e1eccd5ee5f1b Mon Sep 17 00:00:00 2001 From: David Kershner Date: Mon, 15 Jun 2015 23:31:58 -0400 Subject: [PATCH 1046/1163] staging: unisys: define structures outside of iochannel During testing with visornic the offset of num_rcv_bufs was being reported at 188 instead of 186. The vnic structure starts at 180 and the macaddr is only 6 bytes long. When I defined and packed the structures outside of the struct and then referenced them in the struct the correct offset was generated. Signed-off-by: David Kershner Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/iochannel.h | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/staging/unisys/include/iochannel.h b/drivers/staging/unisys/include/iochannel.h index 64a581a4b4e4..a559812342dc 100644 --- a/drivers/staging/unisys/include/iochannel.h +++ b/drivers/staging/unisys/include/iochannel.h @@ -540,6 +540,16 @@ struct uiscmdrsp { struct uiscmdrsp *activeQ_prev; /* Used to track active commands */ } __packed; +struct iochannel_vhba { + struct vhba_wwnn wwnn; /* 8 bytes */ + struct vhba_config_max max; /* 20 bytes */ +} __packed; /* total = 28 bytes */ +struct iochannel_vnic { + u8 macaddr[6]; /* 6 bytes */ + u32 num_rcv_bufs; /* 4 bytes */ + u32 mtu; /* 4 bytes */ + uuid_le zone_uuid; /* 16 bytes */ +} __packed; /* This is just the header of the IO channel. It is assumed that directly after * this header there is a large region of memory which contains the command and * response queues as specified in cmd_q and rsp_q SIGNAL_QUEUE_HEADERS. @@ -549,17 +559,9 @@ struct spar_io_channel_protocol { struct signal_queue_header cmd_q; struct signal_queue_header rsp_q; union { - struct { - struct vhba_wwnn wwnn; /* 8 bytes */ - struct vhba_config_max max; /* 20 bytes */ - } vhba; /* total = 28 bytes */ - struct { - u8 macaddr[MAX_MACADDR_LEN]; /* 6 bytes */ - u32 num_rcv_bufs; /* 4 bytes */ - u32 mtu; /* 4 bytes */ - uuid_le zone_uuid; /* 16 bytes */ - } vnic; /* total = 30 bytes */ - }; + struct iochannel_vhba vhba; + struct iochannel_vnic vnic; + } __packed; #define MAX_CLIENTSTRING_LEN 1024 u8 client_string[MAX_CLIENTSTRING_LEN];/* NULL terminated - so holds From 68905a14e49c97bf49dacd753e40ddd5b254e2ad Mon Sep 17 00:00:00 2001 From: David Kershner Date: Mon, 15 Jun 2015 23:31:59 -0400 Subject: [PATCH 1047/1163] staging: unisys: Add s-Par visornic ethernet driver This driver creates a network device when s-Par sends a device create message to create network adapter on the visorbus. When the message is received by visorbus, the visornic_probe function is called and the netdev device is created and managed by the visornic driver. Signed-off-by: David Kershner Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/Kconfig | 1 + drivers/staging/unisys/Makefile | 1 + drivers/staging/unisys/visornic/Kconfig | 15 + drivers/staging/unisys/visornic/Makefile | 10 + .../staging/unisys/visornic/visornic_main.c | 2140 +++++++++++++++++ 5 files changed, 2167 insertions(+) create mode 100644 drivers/staging/unisys/visornic/Kconfig create mode 100644 drivers/staging/unisys/visornic/Makefile create mode 100644 drivers/staging/unisys/visornic/visornic_main.c diff --git a/drivers/staging/unisys/Kconfig b/drivers/staging/unisys/Kconfig index 0c3e9a1368a8..778f9d05f98a 100644 --- a/drivers/staging/unisys/Kconfig +++ b/drivers/staging/unisys/Kconfig @@ -12,5 +12,6 @@ menuconfig UNISYSSPAR if UNISYSSPAR source "drivers/staging/unisys/visorbus/Kconfig" +source "drivers/staging/unisys/visornic/Kconfig" endif # UNISYSSPAR diff --git a/drivers/staging/unisys/Makefile b/drivers/staging/unisys/Makefile index 566af8e39aea..a515ebc4f8ec 100644 --- a/drivers/staging/unisys/Makefile +++ b/drivers/staging/unisys/Makefile @@ -2,3 +2,4 @@ # Makefile for Unisys SPAR drivers # obj-$(CONFIG_UNISYS_VISORBUS) += visorbus/ +obj-$(CONFIG_UNISYS_VISORNIC) += visornic/ diff --git a/drivers/staging/unisys/visornic/Kconfig b/drivers/staging/unisys/visornic/Kconfig new file mode 100644 index 000000000000..1676dc7072d5 --- /dev/null +++ b/drivers/staging/unisys/visornic/Kconfig @@ -0,0 +1,15 @@ +# +# Unisys visornic configuration +# + +config UNISYS_VISORNIC + tristate "Unisys visornic driver" + depends on UNISYSSPAR && UNISYS_VISORBUS && NET + ---help--- + The Unisys Visornic driver provides support for s-Par network + devices exposed on the s-Par visorbus. When a message is sent + to visorbus to create a network device, the probe function of + visornic is called to create the netdev device. Networking on + s-Par switches will not work if this driver is not selected. + If you say Y here, you will enable the Unisys visornic driver. + diff --git a/drivers/staging/unisys/visornic/Makefile b/drivers/staging/unisys/visornic/Makefile new file mode 100644 index 000000000000..439e95e03300 --- /dev/null +++ b/drivers/staging/unisys/visornic/Makefile @@ -0,0 +1,10 @@ +# +# Makefile for Unisys channel +# + +obj-$(CONFIG_UNISYS_VISORNIC) += visornic.o + +visornic-y := visornic_main.o + +ccflags-y += -Idrivers/staging/unisys/include + diff --git a/drivers/staging/unisys/visornic/visornic_main.c b/drivers/staging/unisys/visornic/visornic_main.c new file mode 100644 index 000000000000..710074437737 --- /dev/null +++ b/drivers/staging/unisys/visornic/visornic_main.c @@ -0,0 +1,2140 @@ +/* Copyright (c) 2012 - 2015 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 driver lives in a spar partition, and registers to ethernet io + * channels from the visorbus driver. It creates netdev devices and + * forwards transmit to the IO channel and accepts rcvs from the IO + * Partition via the IO channel. + */ + +#include +#include +#include +#include +#include + +#include "visorbus.h" +#include "iochannel.h" + +#define VISORNIC_INFINITE_RESPONSE_WAIT 0 +#define VISORNICSOPENMAX 32 +#define MAXDEVICES 16384 + +/* MAX_BUF = 64 lines x 32 MAXVNIC x 80 characters + * = 163840 bytes + */ +#define MAX_BUF 163840 + +static spinlock_t dev_num_pool_lock; +static void *dev_num_pool; /**< pool to grab device numbers from */ + +static int visornic_probe(struct visor_device *dev); +static void visornic_remove(struct visor_device *dev); +static int visornic_pause(struct visor_device *dev, + visorbus_state_complete_func complete_func); +static int visornic_resume(struct visor_device *dev, + visorbus_state_complete_func complete_func); + +/* DEBUGFS declarations */ +static ssize_t info_debugfs_read(struct file *file, char __user *buf, + size_t len, loff_t *offset); +static ssize_t enable_ints_write(struct file *file, const char __user *buf, + size_t len, loff_t *ppos); +static struct dentry *visornic_debugfs_dir; +static const struct file_operations debugfs_info_fops = { + .read = info_debugfs_read, +}; + +static const struct file_operations debugfs_enable_ints_fops = { + .write = enable_ints_write, +}; + +static struct workqueue_struct *visornic_serverdown_workqueue; +static struct workqueue_struct *visornic_timeout_reset_workqueue; + +/* GUIDS for director channel type supported by this driver. */ +static struct visor_channeltype_descriptor visornic_channel_types[] = { + /* Note that the only channel type we expect to be reported by the + * bus driver is the SPAR_VNIC channel. + */ + { SPAR_VNIC_CHANNEL_PROTOCOL_UUID, "ultravnic" }, + { NULL_UUID_LE, NULL } +}; + +/* This is used to tell the visor bus driver which types of visor devices + * we support, and what functions to call when a visor device that we support + * is attached or removed. + */ +static struct visor_driver visornic_driver = { + .name = "visornic", + .version = "1.0.0.0", + .vertag = NULL, + .owner = THIS_MODULE, + .channel_types = visornic_channel_types, + .probe = visornic_probe, + .remove = visornic_remove, + .pause = visornic_pause, + .resume = visornic_resume, + .channel_interrupt = NULL, +}; + +struct visor_thread_info { + struct task_struct *task; + struct completion has_stopped; + int id; +}; + +struct chanstat { + unsigned long got_rcv; + unsigned long got_enbdisack; + unsigned long got_xmit_done; + unsigned long xmit_fail; + unsigned long sent_enbdis; + unsigned long sent_promisc; + unsigned long sent_post; + unsigned long sent_xmit; + unsigned long reject_count; + unsigned long extra_rcvbufs_sent; +}; + +struct visornic_devdata { + int devnum; + int thread_wait_ms; + unsigned short enabled; /* 0 disabled 1 enabled to receive */ + unsigned short enab_dis_acked; /* NET_RCV_ENABLE/DISABLE acked by + * IOPART + */ + struct visor_device *dev; + char name[99]; + struct list_head list_all; /* < link within list_all_devices list */ + struct kref kref; + struct net_device *netdev; + struct net_device_stats net_stats; + atomic_t interrupt_rcvd; + wait_queue_head_t rsp_queue; + struct sk_buff **rcvbuf; + u64 uniquenum; /* TODO figure out why not used */ + unsigned short old_flags; /* flags as they were prior to + * set_multicast_list + */ + atomic_t usage; /* count of users */ + int num_rcv_bufs; /* indicates how many rcv buffers + * the vnic will post + */ + int num_rcv_bufs_could_not_alloc; + atomic_t num_rcvbuf_in_iovm; + unsigned long alloc_failed_in_if_needed_cnt; + unsigned long alloc_failed_in_repost_rtn_cnt; + int max_outstanding_net_xmits; /* absolute max number of outstanding + * xmits - should never hit this + */ + int upper_threshold_net_xmits; /* high water mark for calling + * netif_stop_queue() + */ + int lower_threshold_net_xmits; /* high water mark for calling + * netif_wake_queue() + */ + struct sk_buff_head xmitbufhead; /* xmitbufhead is the head of the + * xmit buffer list that have been + * sent to the IOPART end + */ + struct work_struct serverdown_completion; + struct work_struct timeout_reset; + struct uiscmdrsp *cmdrsp_rcv; /* cmdrsp_rcv is used for + * posting/unposting rcv buffers + */ + struct uiscmdrsp *xmit_cmdrsp; /* used to issue NET_XMIT - there is + * never more that one xmit in + * progress at a time + */ + bool server_down; /* IOPART is down */ + bool server_change_state; /* Processing SERVER_CHANGESTATE msg */ + struct dentry *eth_debugfs_dir; + struct visor_thread_info threadinfo; + u64 interrupts_rcvd; + u64 interrupts_notme; + u64 interrupts_disabled; + u64 busy_cnt; + spinlock_t priv_lock; /* spinlock to access devdata structures */ + + /* flow control counter */ + u64 flow_control_upper_hits; + u64 flow_control_lower_hits; + + /* debug counters */ + unsigned long n_rcv0; /* # rcvs of 0 buffers */ + unsigned long n_rcv1; /* # rcvs of 1 buffers */ + unsigned long n_rcv2; /* # rcvs of 2 buffers */ + unsigned long n_rcvx; /* # rcvs of >2 buffers */ + unsigned long found_repost_rcvbuf_cnt; /* # times we called + * repost_rcvbuf_cnt + */ + unsigned long repost_found_skb_cnt; /* # times found the skb */ + unsigned long n_repost_deficit; /* # times we couldn't find + * all of the rcv buffers + */ + unsigned long bad_rcv_buf; /* # times we negleted to + * free the rcv skb because + * we didn't know where it + * came from + */ + unsigned long n_rcv_packets_not_accepted;/* # bogs rcv packets */ + + int queuefullmsg_logged; + struct chanstat chstat; +}; + +/* array of open devices maintained by open() and close() */ +static struct net_device *num_visornic_open[VISORNICSOPENMAX]; + +/* List of all visornic_devdata structs, + * linked via the list_all member + */ +static LIST_HEAD(list_all_devices); +static DEFINE_SPINLOCK(lock_all_devices); + +/** + * visor_copy_fragsinfo_from_skb( + * @skb_in: skbuff that we are pulling the frags from + * @firstfraglen: length of first fragment in skb + * @frags_max: max len of frags array + * @frags: frags array filled in on output + * + * Copy the fragment list in the SKB to a phys_info + * array that the IOPART understands. + * Return value indicates number of entries filled in frags + * Negative values indicate an error. + */ +static unsigned int +visor_copy_fragsinfo_from_skb(struct sk_buff *skb, unsigned int firstfraglen, + unsigned int frags_max, + struct phys_info frags[]) +{ + unsigned int count = 0, ii, size, offset = 0, numfrags; + + numfrags = skb_shinfo(skb)->nr_frags; + + while (firstfraglen) { + if (count == frags_max) + return -EINVAL; + + frags[count].pi_pfn = + page_to_pfn(virt_to_page(skb->data + offset)); + frags[count].pi_off = + (unsigned long)(skb->data + offset) & PI_PAGE_MASK; + size = min_t(unsigned int, firstfraglen, + PI_PAGE_SIZE - frags[count].pi_off); + + /* can take smallest of firstfraglen (what's left) OR + * bytes left in the page + */ + frags[count].pi_len = size; + firstfraglen -= size; + offset += size; + count++; + } + if (numfrags) { + if ((count + numfrags) > frags_max) + return -EINVAL; + + for (ii = 0; ii < numfrags; ii++) { + count = add_physinfo_entries(page_to_pfn( + skb_frag_page(&skb_shinfo(skb)->frags[ii])), + skb_shinfo(skb)->frags[ii]. + page_offset, + skb_shinfo(skb)->frags[ii]. + size, count, frags_max, frags); + if (!count) + return -EIO; + } + } + if (skb_shinfo(skb)->frag_list) { + struct sk_buff *skbinlist; + int c; + + for (skbinlist = skb_shinfo(skb)->frag_list; skbinlist; + skbinlist = skbinlist->next) { + c = visor_copy_fragsinfo_from_skb(skbinlist, + skbinlist->len - + skbinlist->data_len, + frags_max - count, + &frags[count]); + if (c < 0) + return c; + count += c; + } + } + return count; +} + +/** + * visort_thread_start - starts thread for the device + * @thrinfo: The thread to start + * @threadfn: Function the thread starts + * @thrcontext: Context to pass to the thread, i.e. devdata + * @name: string describing name of thread + * + * Starts a thread for the device, currently only thread is + * process_incoming_rsps + * Returns 0 on success; + */ +static int visor_thread_start(struct visor_thread_info *thrinfo, + int (*threadfn)(void *), + void *thrcontext, char *name) +{ + /* used to stop the thread */ + init_completion(&thrinfo->has_stopped); + thrinfo->task = kthread_run(threadfn, thrcontext, name); + if (IS_ERR(thrinfo->task)) { + thrinfo->id = 0; + return -EINVAL; + } + thrinfo->id = thrinfo->task->pid; + return 0; +} + +/** + * visor_thread_stop - stop a thread for the device + * @thrinfo: The thread to stop + * + * Stop the thread and wait for completion for a minute + * Returns void. + */ +static void visor_thread_stop(struct visor_thread_info *thrinfo) +{ + if (!thrinfo->id) + return; /* thread not running */ + + kthread_stop(thrinfo->task); + /* give up if the thread has NOT died in 1 minute */ + if (wait_for_completion_timeout(&thrinfo->has_stopped, 60 * HZ)) + thrinfo->id = 0; +} + +/* DebugFS code */ +static ssize_t info_debugfs_read(struct file *file, char __user *buf, + size_t len, loff_t *offset) +{ + int i; + ssize_t bytes_read = 0; + int str_pos = 0; + struct visornic_devdata *devdata; + char *vbuf; + + if (len > MAX_BUF) + len = MAX_BUF; + vbuf = kzalloc(len, GFP_KERNEL); + if (!vbuf) + return -ENOMEM; + + /* for each vnic channel + * dump out channel specific data + */ + for (i = 0; i < VISORNICSOPENMAX; i++) { + if (!num_visornic_open[i]) + continue; + + devdata = netdev_priv(num_visornic_open[i]); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + "Vnic i = %d\n", i); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + "netdev = %s (0x%p), MAC Addr %pM\n", + num_visornic_open[i]->name, + num_visornic_open[i], + num_visornic_open[i]->dev_addr); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + "VisorNic Dev Info = 0x%p\n", devdata); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " num_rcv_bufs = %d\n", + devdata->num_rcv_bufs); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " max_oustanding_next_xmits = %d\n", + devdata->max_outstanding_net_xmits); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " upper_threshold_net_xmits = %d\n", + devdata->upper_threshold_net_xmits); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " lower_threshold_net_xmits = %d\n", + devdata->lower_threshold_net_xmits); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " queuefullmsg_logged = %d\n", + devdata->queuefullmsg_logged); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " chstat.got_rcv = %lu\n", + devdata->chstat.got_rcv); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " chstat.got_enbdisack = %lu\n", + devdata->chstat.got_enbdisack); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " chstat.got_xmit_done = %lu\n", + devdata->chstat.got_xmit_done); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " chstat.xmit_fail = %lu\n", + devdata->chstat.xmit_fail); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " chstat.sent_enbdis = %lu\n", + devdata->chstat.sent_enbdis); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " chstat.sent_promisc = %lu\n", + devdata->chstat.sent_promisc); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " chstat.sent_post = %lu\n", + devdata->chstat.sent_post); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " chstat.sent_xmit = %lu\n", + devdata->chstat.sent_xmit); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " chstat.reject_count = %lu\n", + devdata->chstat.reject_count); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " chstat.extra_rcvbufs_sent = %lu\n", + devdata->chstat.extra_rcvbufs_sent); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " n_rcv0 = %lu\n", devdata->n_rcv0); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " n_rcv1 = %lu\n", devdata->n_rcv1); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " n_rcv2 = %lu\n", devdata->n_rcv2); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " n_rcvx = %lu\n", devdata->n_rcvx); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " num_rcvbuf_in_iovm = %d\n", + atomic_read(&devdata->num_rcvbuf_in_iovm)); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " alloc_failed_in_if_needed_cnt = %lu\n", + devdata->alloc_failed_in_if_needed_cnt); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " alloc_failed_in_repost_rtn_cnt = %lu\n", + devdata->alloc_failed_in_repost_rtn_cnt); + /* str_pos += scnprintf(vbuf + str_pos, len - str_pos, + * " inner_loop_limit_reached_cnt = %lu\n", + * devdata->inner_loop_limit_reached_cnt); + */ + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " found_repost_rcvbuf_cnt = %lu\n", + devdata->found_repost_rcvbuf_cnt); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " repost_found_skb_cnt = %lu\n", + devdata->repost_found_skb_cnt); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " n_repost_deficit = %lu\n", + devdata->n_repost_deficit); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " bad_rcv_buf = %lu\n", + devdata->bad_rcv_buf); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " n_rcv_packets_not_accepted = %lu\n", + devdata->n_rcv_packets_not_accepted); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " interrupts_rcvd = %llu\n", + devdata->interrupts_rcvd); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " interrupts_notme = %llu\n", + devdata->interrupts_notme); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " interrupts_disabled = %llu\n", + devdata->interrupts_disabled); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " busy_cnt = %llu\n", + devdata->busy_cnt); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " flow_control_upper_hits = %llu\n", + devdata->flow_control_upper_hits); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " flow_control_lower_hits = %llu\n", + devdata->flow_control_lower_hits); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " thread_wait_ms = %d\n", + devdata->thread_wait_ms); + str_pos += scnprintf(vbuf + str_pos, len - str_pos, + " netif_queue = %s\n", + netif_queue_stopped(devdata->netdev) ? + "stopped" : "running"); + } + bytes_read = simple_read_from_buffer(buf, len, offset, vbuf, str_pos); + kfree(vbuf); + return bytes_read; +} + +static ssize_t enable_ints_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *ppos) +{ + char buf[4]; + int i, new_value; + struct visornic_devdata *devdata; + + if (count >= ARRAY_SIZE(buf)) + return -EINVAL; + + buf[count] = '\0'; + if (copy_from_user(buf, buffer, count)) + return -EFAULT; + + i = kstrtoint(buf, 10, &new_value); + if (i != 0) + return -EFAULT; + + /* set all counts to new_value usually 0 */ + for (i = 0; i < VISORNICSOPENMAX; i++) { + if (num_visornic_open[i]) { + devdata = netdev_priv(num_visornic_open[i]); + /* TODO update features bit in channel */ + } + } + + return count; +} + +/** + * visornic_serverdown_complete - IOPART went down, need to pause + * device + * @work: Work queue it was scheduled on + * + * The IO partition has gone down and we need to do some cleanup + * for when it comes back. Treat the IO partition as the link + * being down. + * Returns void. + */ +static void +visornic_serverdown_complete(struct work_struct *work) +{ + struct visornic_devdata *devdata; + struct net_device *netdev; + unsigned long flags; + int i = 0, count = 0; + + devdata = container_of(work, struct visornic_devdata, + serverdown_completion); + netdev = devdata->netdev; + + /* Stop using datachan */ + visor_thread_stop(&devdata->threadinfo); + + /* Inform Linux that the link is down */ + netif_carrier_off(netdev); + netif_stop_queue(netdev); + + /* Free the skb for XMITs that haven't been serviced by the server + * We shouldn't have to inform Linux about these IOs because they + * are "lost in the ethernet" + */ + skb_queue_purge(&devdata->xmitbufhead); + + spin_lock_irqsave(&devdata->priv_lock, flags); + /* free rcv buffers */ + for (i = 0; i < devdata->num_rcv_bufs; i++) { + if (devdata->rcvbuf[i]) { + kfree_skb(devdata->rcvbuf[i]); + devdata->rcvbuf[i] = NULL; + count++; + } + } + atomic_set(&devdata->num_rcvbuf_in_iovm, 0); + spin_unlock_irqrestore(&devdata->priv_lock, flags); + + devdata->server_down = true; + devdata->server_change_state = false; +} + +/** + * visornic_serverdown - Command has notified us that IOPARt is down + * @devdata: device that is being managed by IOPART + * + * Schedule the work needed to handle the server down request. Make + * sure we haven't already handled the server change state event. + * Returns 0 if we scheduled the work, -EINVAL on error. + */ +static int +visornic_serverdown(struct visornic_devdata *devdata) +{ + if (!devdata->server_down && !devdata->server_change_state) { + devdata->server_change_state = true; + queue_work(visornic_serverdown_workqueue, + &devdata->serverdown_completion); + } else if (devdata->server_change_state) { + return -EINVAL; + } + return 0; +} + +/** + * alloc_rcv_buf - alloc rcv buffer to be given to the IO Partition. + * @netdev: network adapter the rcv bufs are attached too. + * + * Create an sk_buff (rcv_buf) that will be passed to the IO Partition + * so that it can write rcv data into our memory space. + * Return pointer to sk_buff + */ +static struct sk_buff * +alloc_rcv_buf(struct net_device *netdev) +{ + struct sk_buff *skb; + + /* NOTE: the first fragment in each rcv buffer is pointed to by + * rcvskb->data. For now all rcv buffers will be RCVPOST_BUF_SIZE + * in length, so the firstfrag is large enough to hold 1514. + */ + skb = alloc_skb(RCVPOST_BUF_SIZE, GFP_ATOMIC); + if (!skb) + return NULL; + skb->dev = netdev; + skb->len = RCVPOST_BUF_SIZE; + /* current value of mtu doesn't come into play here; large + * packets will just end up using multiple rcv buffers all of + * same size + */ + skb->data_len = 0; /* dev_alloc_skb already zeroes it out + * for clarification. + */ + return skb; +} + +/** + * post_skb - post a skb to the IO Partition. + * @cmdrsp: cmdrsp packet to be send to the IO Partition + * @devdata: visornic_devdata to post the skb too + * @skb: skb to give to the IO partition + * + * Send the skb to the IO Partition. + * Returns void + */ +static inline void +post_skb(struct uiscmdrsp *cmdrsp, + struct visornic_devdata *devdata, struct sk_buff *skb) +{ + cmdrsp->net.buf = skb; + cmdrsp->net.rcvpost.frag.pi_pfn = page_to_pfn(virt_to_page(skb->data)); + cmdrsp->net.rcvpost.frag.pi_off = + (unsigned long)skb->data & PI_PAGE_MASK; + cmdrsp->net.rcvpost.frag.pi_len = skb->len; + cmdrsp->net.rcvpost.unique_num = devdata->uniquenum; + + if ((cmdrsp->net.rcvpost.frag.pi_off + skb->len) <= PI_PAGE_SIZE) { + cmdrsp->net.type = NET_RCV_POST; + cmdrsp->cmdtype = CMD_NET_TYPE; + visorchannel_signalinsert(devdata->dev->visorchannel, + IOCHAN_TO_IOPART, + cmdrsp); + atomic_inc(&devdata->num_rcvbuf_in_iovm); + devdata->chstat.sent_post++; + } +} + +/** + * send_enbdis - send NET_RCV_ENBDIS to IO Partition + * @netdev: netdevice we are enable/disable, used as context + * return value + * @state: enable = 1/disable = 0 + * @devdata: visornic device we are enabling/disabling + * + * Send the enable/disable message to the IO Partition. + * Returns void + */ +static void +send_enbdis(struct net_device *netdev, int state, + struct visornic_devdata *devdata) +{ + devdata->cmdrsp_rcv->net.enbdis.enable = state; + devdata->cmdrsp_rcv->net.enbdis.context = netdev; + devdata->cmdrsp_rcv->net.type = NET_RCV_ENBDIS; + devdata->cmdrsp_rcv->cmdtype = CMD_NET_TYPE; + visorchannel_signalinsert(devdata->dev->visorchannel, + IOCHAN_TO_IOPART, + devdata->cmdrsp_rcv); + devdata->chstat.sent_enbdis++; +} + +/** + * visornic_disable_with_timeout - Disable network adapter + * @netdev: netdevice to disale + * @timeout: timeout to wait for disable + * + * Disable the network adapter and inform the IO Partition that we + * are disabled, reclaim memory from rcv bufs. + * Returns 0 on success, negative for failure of IO Partition + * responding. + * + */ +static int +visornic_disable_with_timeout(struct net_device *netdev, const int timeout) +{ + struct visornic_devdata *devdata = netdev_priv(netdev); + int i; + unsigned long flags; + int wait = 0; + + /* stop the transmit queue so nothing more can be transmitted */ + netif_stop_queue(netdev); + + /* send a msg telling the other end we are stopping incoming pkts */ + spin_lock_irqsave(&devdata->priv_lock, flags); + devdata->enabled = 0; + devdata->enab_dis_acked = 0; /* must wait for ack */ + spin_unlock_irqrestore(&devdata->priv_lock, flags); + + /* send disable and wait for ack -- don't hold lock when sending + * disable because if the queue is full, insert might sleep. + */ + send_enbdis(netdev, 0, devdata); + + /* wait for ack to arrive before we try to free rcv buffers + * NOTE: the other end automatically unposts the rcv buffers when + * when it gets a disable. + */ + spin_lock_irqsave(&devdata->priv_lock, flags); + while ((timeout == VISORNIC_INFINITE_RESPONSE_WAIT) || + (wait < timeout)) { + if (devdata->enab_dis_acked) + break; + if (devdata->server_down || devdata->server_change_state) { + spin_unlock_irqrestore(&devdata->priv_lock, flags); + return -EIO; + } + set_current_state(TASK_INTERRUPTIBLE); + spin_unlock_irqrestore(&devdata->priv_lock, flags); + wait += schedule_timeout(msecs_to_jiffies(10)); + spin_lock_irqsave(&devdata->priv_lock, flags); + } + + /* Wait for usage to go to 1 (no other users) before freeing + * rcv buffers + */ + if (atomic_read(&devdata->usage) > 1) { + while (1) { + set_current_state(TASK_INTERRUPTIBLE); + spin_unlock_irqrestore(&devdata->priv_lock, flags); + schedule_timeout(msecs_to_jiffies(10)); + spin_lock_irqsave(&devdata->priv_lock, flags); + if (atomic_read(&devdata->usage)) + break; + } + } + + /* we've set enabled to 0, so we can give up the lock. */ + spin_unlock_irqrestore(&devdata->priv_lock, flags); + + /* Free rcv buffers - other end has automatically unposed them on + * disable + */ + for (i = 0; i < devdata->num_rcv_bufs; i++) { + if (devdata->rcvbuf[i]) { + kfree_skb(devdata->rcvbuf[i]); + devdata->rcvbuf[i] = NULL; + } + } + + /* remove references from array */ + for (i = 0; i < VISORNICSOPENMAX; i++) + if (num_visornic_open[i] == netdev) { + num_visornic_open[i] = NULL; + break; + } + + return 0; +} + +/** + * init_rcv_bufs -- initialize receive bufs and send them to the IO Part + * @netdev: struct netdevice + * @devdata: visornic_devdata + * + * Allocate rcv buffers and post them to the IO Partition. + * Return 0 for success, and negative for failure. + */ +static int +init_rcv_bufs(struct net_device *netdev, struct visornic_devdata *devdata) +{ + int i, count; + + /* allocate fixed number of receive buffers to post to uisnic + * post receive buffers after we've allocated a required amount + */ + for (i = 0; i < devdata->num_rcv_bufs; i++) { + devdata->rcvbuf[i] = alloc_rcv_buf(netdev); + if (!devdata->rcvbuf[i]) + break; /* if we failed to allocate one let us stop */ + } + if (i == 0) /* couldn't even allocate one -- bail out */ + return -ENOMEM; + count = i; + + /* Ensure we can alloc 2/3rd of the requeested number of buffers. + * 2/3 is an arbitrary choice; used also in ndis init.c + */ + if (count < ((2 * devdata->num_rcv_bufs) / 3)) { + /* free receive buffers we did alloc and then bail out */ + for (i = 0; i < count; i++) { + kfree_skb(devdata->rcvbuf[i]); + devdata->rcvbuf[i] = NULL; + } + return -ENOMEM; + } + + /* post receive buffers to receive incoming input - without holding + * lock - we've not enabled nor started the queue so there shouldn't + * be any rcv or xmit activity + */ + for (i = 0; i < count; i++) + post_skb(devdata->cmdrsp_rcv, devdata, devdata->rcvbuf[i]); + + return 0; +} + +/** + * visornic_enable_with_timeout - send enable to IO Part + * @netdev: struct net_device + * @timeout: Time to wait for the ACK from the enable + * + * Sends enable to IOVM, inits, and posts receive buffers to IOVM + * timeout is defined in msecs (timeout of 0 specifies infinite wait) + * Return 0 for success, negavite for failure. + */ +static int +visornic_enable_with_timeout(struct net_device *netdev, const int timeout) +{ + int i; + struct visornic_devdata *devdata = netdev_priv(netdev); + unsigned long flags; + int wait = 0; + + /* NOTE: the other end automatically unposts the rcv buffers when it + * gets a disable. + */ + i = init_rcv_bufs(netdev, devdata); + if (i < 0) + return i; + + spin_lock_irqsave(&devdata->priv_lock, flags); + devdata->enabled = 1; + + /* now we're ready, let's send an ENB to uisnic but until we get + * an ACK back from uisnic, we'll drop the packets + */ + devdata->n_rcv_packets_not_accepted = 0; + spin_unlock_irqrestore(&devdata->priv_lock, flags); + + /* send enable and wait for ack -- don't hold lock when sending enable + * because if the queue is full, insert might sleep. + */ + send_enbdis(netdev, 1, devdata); + + spin_lock_irqsave(&devdata->priv_lock, flags); + while ((timeout == VISORNIC_INFINITE_RESPONSE_WAIT) || + (wait < timeout)) { + if (devdata->enab_dis_acked) + break; + if (devdata->server_down || devdata->server_change_state) { + spin_unlock_irqrestore(&devdata->priv_lock, flags); + return -EIO; + } + set_current_state(TASK_INTERRUPTIBLE); + spin_unlock_irqrestore(&devdata->priv_lock, flags); + wait += schedule_timeout(msecs_to_jiffies(10)); + spin_lock_irqsave(&devdata->priv_lock, flags); + } + + spin_unlock_irqrestore(&devdata->priv_lock, flags); + + if (!devdata->enab_dis_acked) + return -EIO; + + /* find an open slot in the array to save off VisorNic references + * for debug + */ + for (i = 0; i < VISORNICSOPENMAX; i++) { + if (!num_visornic_open[i]) { + num_visornic_open[i] = netdev; + break; + } + } + + return 0; +} + +/** + * visornic_timeout_reset - handle xmit timeout resets + * @work work item that scheduled the work + * + * Transmit Timeouts are typically handled by resetting the + * device for our virtual NIC we will send a Disable and Enable + * to the IOVM. If it doesn't respond we will trigger a serverdown. + */ +static void +visornic_timeout_reset(struct work_struct *work) +{ + struct visornic_devdata *devdata; + struct net_device *netdev; + int response = 0; + + devdata = container_of(work, struct visornic_devdata, timeout_reset); + netdev = devdata->netdev; + + netif_stop_queue(netdev); + response = visornic_disable_with_timeout(netdev, 100); + if (response) + goto call_serverdown; + + response = visornic_enable_with_timeout(netdev, 100); + if (response) + goto call_serverdown; + netif_wake_queue(netdev); + + return; + +call_serverdown: + visornic_serverdown(devdata); +} + +/** + * visornic_open - Enable the visornic device and mark the queue started + * @netdev: netdevice to start + * + * Enable the device and start the transmit queue. + * Return 0 for success + */ +static int +visornic_open(struct net_device *netdev) +{ + visornic_enable_with_timeout(netdev, VISORNIC_INFINITE_RESPONSE_WAIT); + + /* start the interface's transmit queue, allowing it to accept + * packets for transmission + */ + netif_start_queue(netdev); + + return 0; +} + +/** + * visornic_close - Disables the visornic device and stops the queues + * @netdev: netdevice to start + * + * Disable the device and stop the transmit queue. + * Return 0 for success + */ +static int +visornic_close(struct net_device *netdev) +{ + netif_stop_queue(netdev); + visornic_disable_with_timeout(netdev, VISORNIC_INFINITE_RESPONSE_WAIT); + + return 0; +} + +/** + * visornic_xmit - send a packet to the IO Partition + * @skb: Packet to be sent + * @netdev: net device the packet is being sent from + * + * Convert the skb to a cmdrsp so the IO Partition can undersand it. + * Send the XMIT command to the IO Partition for processing. This + * function is protected from concurrent calls by a spinlock xmit_lock + * in the net_device struct, but as soon as the function returns it + * can be called again. + * Returns NETDEV_TX_OK for success, NETDEV_TX_BUSY for error. + */ +static int +visornic_xmit(struct sk_buff *skb, struct net_device *netdev) +{ + struct visornic_devdata *devdata; + int len, firstfraglen, padlen; + struct uiscmdrsp *cmdrsp = NULL; + unsigned long flags; + + devdata = netdev_priv(netdev); + spin_lock_irqsave(&devdata->priv_lock, flags); + + if (netif_queue_stopped(netdev) || devdata->server_down || + devdata->server_change_state) { + spin_unlock_irqrestore(&devdata->priv_lock, flags); + devdata->busy_cnt++; + return NETDEV_TX_BUSY; + } + + /* sk_buff struct is used to host network data throughout all the + * linux network subsystems + */ + len = skb->len; + + /* skb->len is the FULL length of data (including fragmentary portion) + * skb->data_len is the length of the fragment portion in frags + * skb->len - skb->data_len is size of the 1st fragment in skb->data + * calculate the length of the first fragment that skb->data is + * pointing to + */ + firstfraglen = skb->len - skb->data_len; + if (firstfraglen < ETH_HEADER_SIZE) { + spin_unlock_irqrestore(&devdata->priv_lock, flags); + devdata->busy_cnt++; + return NETDEV_TX_BUSY; + } + + if ((len < ETH_MIN_PACKET_SIZE) && + ((skb_end_pointer(skb) - skb->data) >= ETH_MIN_PACKET_SIZE)) { + /* pad the packet out to minimum size */ + padlen = ETH_MIN_PACKET_SIZE - len; + memset(&skb->data[len], 0, padlen); + skb->tail += padlen; + skb->len += padlen; + len += padlen; + firstfraglen += padlen; + } + + cmdrsp = devdata->xmit_cmdrsp; + /* clear cmdrsp */ + memset(cmdrsp, 0, SIZEOF_CMDRSP); + cmdrsp->net.type = NET_XMIT; + cmdrsp->cmdtype = CMD_NET_TYPE; + + /* save the pointer to skb -- we'll need it for completion */ + cmdrsp->net.buf = skb; + + if (((devdata->chstat.sent_xmit >= devdata->chstat.got_xmit_done) && + (devdata->chstat.sent_xmit - devdata->chstat.got_xmit_done >= + devdata->max_outstanding_net_xmits)) || + ((devdata->chstat.sent_xmit < devdata->chstat.got_xmit_done) && + (ULONG_MAX - devdata->chstat.got_xmit_done + + devdata->chstat.sent_xmit >= + devdata->max_outstanding_net_xmits))) { + /* too many NET_XMITs queued over to IOVM - need to wait + */ + devdata->chstat.reject_count++; + if (!devdata->queuefullmsg_logged && + ((devdata->chstat.reject_count & 0x3ff) == 1)) + devdata->queuefullmsg_logged = 1; + netif_stop_queue(netdev); + spin_unlock_irqrestore(&devdata->priv_lock, flags); + devdata->busy_cnt++; + return NETDEV_TX_BUSY; + } + if (devdata->queuefullmsg_logged) + devdata->queuefullmsg_logged = 0; + + if (skb->ip_summed == CHECKSUM_UNNECESSARY) { + cmdrsp->net.xmt.lincsum.valid = 1; + cmdrsp->net.xmt.lincsum.protocol = skb->protocol; + if (skb_transport_header(skb) > skb->data) { + cmdrsp->net.xmt.lincsum.hrawoff = + skb_transport_header(skb) - skb->data; + cmdrsp->net.xmt.lincsum.hrawoff = 1; + } + if (skb_network_header(skb) > skb->data) { + cmdrsp->net.xmt.lincsum.nhrawoff = + skb_network_header(skb) - skb->data; + cmdrsp->net.xmt.lincsum.nhrawoffv = 1; + } + cmdrsp->net.xmt.lincsum.csum = skb->csum; + } else { + cmdrsp->net.xmt.lincsum.valid = 0; + } + + /* save off the length of the entire data packet */ + cmdrsp->net.xmt.len = len; + + /* copy ethernet header from first frag into ocmdrsp + * - everything else will be pass in frags & DMA'ed + */ + memcpy(cmdrsp->net.xmt.ethhdr, skb->data, ETH_HEADER_SIZE); + /* copy frags info - from skb->data we need to only provide access + * beyond eth header + */ + cmdrsp->net.xmt.num_frags = + visor_copy_fragsinfo_from_skb(skb, firstfraglen, + MAX_PHYS_INFO, + cmdrsp->net.xmt.frags); + if (cmdrsp->net.xmt.num_frags == -1) { + spin_unlock_irqrestore(&devdata->priv_lock, flags); + devdata->busy_cnt++; + return NETDEV_TX_BUSY; + } + + if (!visorchannel_signalinsert(devdata->dev->visorchannel, + IOCHAN_TO_IOPART, cmdrsp)) { + netif_stop_queue(netdev); + spin_unlock_irqrestore(&devdata->priv_lock, flags); + devdata->busy_cnt++; + return NETDEV_TX_BUSY; + } + + /* Track the skbs that have been sent to the IOVM for XMIT */ + skb_queue_head(&devdata->xmitbufhead, skb); + + /* set the last transmission start time + * linux doc says: Do not forget to update netdev->trans_start to + * jiffies after each new tx packet is given to the hardware. + */ + netdev->trans_start = jiffies; + + /* update xmt stats */ + devdata->net_stats.tx_packets++; + devdata->net_stats.tx_bytes += skb->len; + devdata->chstat.sent_xmit++; + + /* check to see if we have hit the high watermark for + * netif_stop_queue() + */ + if (((devdata->chstat.sent_xmit >= devdata->chstat.got_xmit_done) && + (devdata->chstat.sent_xmit - devdata->chstat.got_xmit_done >= + devdata->upper_threshold_net_xmits)) || + ((devdata->chstat.sent_xmit < devdata->chstat.got_xmit_done) && + (ULONG_MAX - devdata->chstat.got_xmit_done + + devdata->chstat.sent_xmit >= + devdata->upper_threshold_net_xmits))) { + /* too many NET_XMITs queued over to IOVM - need to wait */ + netif_stop_queue(netdev); /* calling stop queue - call + * netif_wake_queue() after lower + * threshold + */ + devdata->flow_control_upper_hits++; + } + spin_unlock_irqrestore(&devdata->priv_lock, flags); + + /* skb will be freed when we get back NET_XMIT_DONE */ + return NETDEV_TX_OK; +} + +/** + * visornic_get_stats - returns net_stats of the visornic device + * @netdev: netdevice + * + * Returns the net_device_stats for the device + */ +static struct net_device_stats * +visornic_get_stats(struct net_device *netdev) +{ + struct visornic_devdata *devdata = netdev_priv(netdev); + + return &devdata->net_stats; +} + +/** + * visornic_ioctl - ioctl function for netdevice. + * @netdev: netdevice + * @ifr: ignored + * @cmd: ignored + * + * Currently not supported. + * Returns EOPNOTSUPP + */ +static int +visornic_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) +{ + return -EOPNOTSUPP; +} + +/** + * visornic_change_mtu - changes mtu of device. + * @netdev: netdevice + * @new_mtu: value of new mtu + * + * MTU cannot be changed by system, must be changed via + * CONTROLVM message. All vnics and pnics in a switch have + * to have the same MTU for everything to work. + * Currently not supported. + * Returns EINVAL + */ +static int +visornic_change_mtu(struct net_device *netdev, int new_mtu) +{ + return -EINVAL; +} + +/** + * visornic_set_multi - changes mtu of device. + * @netdev: netdevice + * + * Only flag we support currently is IFF_PROMISC + * Returns void + */ +static void +visornic_set_multi(struct net_device *netdev) +{ + struct uiscmdrsp *cmdrsp; + struct visornic_devdata *devdata = netdev_priv(netdev); + + /* any filtering changes */ + if (devdata->old_flags != netdev->flags) { + if ((netdev->flags & IFF_PROMISC) != + (devdata->old_flags & IFF_PROMISC)) { + cmdrsp = kmalloc(SIZEOF_CMDRSP, GFP_ATOMIC); + if (!cmdrsp) + return; + cmdrsp->cmdtype = CMD_NET_TYPE; + cmdrsp->net.type = NET_RCV_PROMISC; + cmdrsp->net.enbdis.context = netdev; + cmdrsp->net.enbdis.enable = + (netdev->flags & IFF_PROMISC); + visorchannel_signalinsert(devdata->dev->visorchannel, + IOCHAN_TO_IOPART, + cmdrsp); + kfree(cmdrsp); + } + devdata->old_flags = netdev->flags; + } +} + +/** + * visornic_xmit_timeout - request to timeout the xmit + * @netdev + * + * Queue the work and return. Make sure we have not already + * been informed the IO Partition is gone, if it is gone + * we will already timeout the xmits. + */ +static void +visornic_xmit_timeout(struct net_device *netdev) +{ + struct visornic_devdata *devdata = netdev_priv(netdev); + unsigned long flags; + + spin_lock_irqsave(&devdata->priv_lock, flags); + /* Ensure that a ServerDown message hasn't been received */ + if (!devdata->enabled || + (devdata->server_down && !devdata->server_change_state)) { + spin_unlock_irqrestore(&devdata->priv_lock, flags); + return; + } + spin_unlock_irqrestore(&devdata->priv_lock, flags); + + queue_work(visornic_timeout_reset_workqueue, &devdata->timeout_reset); +} + +/** + * repost_return - repost rcv bufs that have come back + * @cmdrsp: io channel command struct to post + * @devdata: visornic devdata for the device + * @skb: skb + * @netdev: netdevice + * + * Repost rcv buffers that have been returned to us when + * we are finished with them. + * Returns 0 for success, -1 for error. + */ +static inline int +repost_return(struct uiscmdrsp *cmdrsp, struct visornic_devdata *devdata, + struct sk_buff *skb, struct net_device *netdev) +{ + struct net_pkt_rcv copy; + int i = 0, cc, numreposted; + int found_skb = 0; + int status = 0; + + copy = cmdrsp->net.rcv; + switch (copy.numrcvbufs) { + case 0: + devdata->n_rcv0++; + break; + case 1: + devdata->n_rcv1++; + break; + case 2: + devdata->n_rcv2++; + break; + default: + devdata->n_rcvx++; + break; + } + for (cc = 0, numreposted = 0; cc < copy.numrcvbufs; cc++) { + for (i = 0; i < devdata->num_rcv_bufs; i++) { + if (devdata->rcvbuf[i] != copy.rcvbuf[cc]) + continue; + + if ((skb) && devdata->rcvbuf[i] == skb) { + devdata->found_repost_rcvbuf_cnt++; + found_skb = 1; + devdata->repost_found_skb_cnt++; + } + devdata->rcvbuf[i] = alloc_rcv_buf(netdev); + if (!devdata->rcvbuf[i]) { + devdata->num_rcv_bufs_could_not_alloc++; + devdata->alloc_failed_in_repost_rtn_cnt++; + status = -ENOMEM; + break; + } + post_skb(cmdrsp, devdata, devdata->rcvbuf[i]); + numreposted++; + break; + } + } + if (numreposted != copy.numrcvbufs) { + devdata->n_repost_deficit++; + status = -EINVAL; + } + if (skb) { + if (found_skb) { + kfree_skb(skb); + } else { + status = -EINVAL; + devdata->bad_rcv_buf++; + } + } + atomic_dec(&devdata->usage); + return status; +} + +/** + * visornic_rx - Handle receive packets coming back from IO Part + * @cmdrsp: Receive packet returned from IO Part + * + * Got a receive packet back from the IO Part, handle it and send + * it up the stack. + * Returns void + */ +static void +visornic_rx(struct uiscmdrsp *cmdrsp) +{ + struct visornic_devdata *devdata; + struct sk_buff *skb, *prev, *curr; + struct net_device *netdev; + int cc, currsize, off, status; + struct ethhdr *eth; + unsigned long flags; +#ifdef DEBUG + struct phys_info testfrags[MAX_PHYS_INFO]; +#endif + + /* post new rcv buf to the other end using the cmdrsp we have at hand + * post it without holding lock - but we'll use the signal lock to + * synchronize the queue insert the cmdrsp that contains the net.rcv + * is the one we are using to repost, so copy the info we need from it. + */ + skb = cmdrsp->net.buf; + netdev = skb->dev; + + if (!netdev) { + /* We must have previously downed this network device and + * this skb and device is no longer valid. This also means + * the skb reference was removed from devdata->rcvbuf so no + * need to search for it. + * All we can do is free the skb and return. + * Note: We crash if we try to log this here. + */ + kfree_skb(skb); + return; + } + + devdata = netdev_priv(netdev); + + spin_lock_irqsave(&devdata->priv_lock, flags); + atomic_dec(&devdata->num_rcvbuf_in_iovm); + + /* update rcv stats - call it with priv_lock held */ + devdata->net_stats.rx_packets++; + devdata->net_stats.rx_bytes = skb->len; + + atomic_inc(&devdata->usage); /* don't want a close to happen before + * we're done here + */ + + /* set length to how much was ACTUALLY received - + * NOTE: rcv_done_len includes actual length of data rcvd + * including ethhdr + */ + skb->len = cmdrsp->net.rcv.rcv_done_len; + + /* test enabled while holding lock */ + if (!(devdata->enabled && devdata->enab_dis_acked)) { + /* don't process it unless we're in enable mode and until + * we've gotten an ACK saying the other end got our RCV enable + */ + spin_unlock_irqrestore(&devdata->priv_lock, flags); + repost_return(cmdrsp, devdata, skb, netdev); + return; + } + + spin_unlock_irqrestore(&devdata->priv_lock, flags); + + /* when skb was allocated, skb->dev, skb->data, skb->len and + * skb->data_len were setup. AND, data has already put into the + * skb (both first frag and in frags pages) + * NOTE: firstfragslen is the amount of data in skb->data and that + * which is not in nr_frags or frag_list. This is now simply + * RCVPOST_BUF_SIZE. bump tail to show how much data is in + * firstfrag & set data_len to show rest see if we have to chain + * frag_list. + */ + if (skb->len > RCVPOST_BUF_SIZE) { /* do PRECAUTIONARY check */ + if (cmdrsp->net.rcv.numrcvbufs < 2) { + if (repost_return(cmdrsp, devdata, skb, netdev) < 0) + dev_err(&devdata->netdev->dev, + "repost_return failed"); + return; + } + /* length rcvd is greater than firstfrag in this skb rcv buf */ + skb->tail += RCVPOST_BUF_SIZE; /* amount in skb->data */ + skb->data_len = skb->len - RCVPOST_BUF_SIZE; /* amount that + will be in + frag_list */ + } else { + /* data fits in this skb - no chaining - do + * PRECAUTIONARY check + */ + if (cmdrsp->net.rcv.numrcvbufs != 1) { /* should be 1 */ + if (repost_return(cmdrsp, devdata, skb, netdev) < 0) + dev_err(&devdata->netdev->dev, + "repost_return failed"); + return; + } + skb->tail += skb->len; + skb->data_len = 0; /* nothing rcvd in frag_list */ + } + off = skb_tail_pointer(skb) - skb->data; + + /* amount we bumped tail by in the head skb + * it is used to calculate the size of each chained skb below + * it is also used to index into bufline to continue the copy + * (for chansocktwopc) + * if necessary chain the rcv skbs together. + * NOTE: index 0 has the same as cmdrsp->net.rcv.skb; we need to + * chain the rest to that one. + * - do PRECAUTIONARY check + */ + if (cmdrsp->net.rcv.rcvbuf[0] != skb) { + if (repost_return(cmdrsp, devdata, skb, netdev) < 0) + dev_err(&devdata->netdev->dev, "repost_return failed"); + return; + } + + if (cmdrsp->net.rcv.numrcvbufs > 1) { + /* chain the various rcv buffers into the skb's frag_list. */ + /* Note: off was initialized above */ + for (cc = 1, prev = NULL; + cc < cmdrsp->net.rcv.numrcvbufs; cc++) { + curr = (struct sk_buff *)cmdrsp->net.rcv.rcvbuf[cc]; + curr->next = NULL; + if (!prev) /* start of list- set head */ + skb_shinfo(skb)->frag_list = curr; + else + prev->next = curr; + prev = curr; + + /* should we set skb->len and skb->data_len for each + * buffer being chained??? can't hurt! + */ + currsize = min(skb->len - off, + (unsigned int)RCVPOST_BUF_SIZE); + curr->len = currsize; + curr->tail += currsize; + curr->data_len = 0; + off += currsize; + } +#ifdef DEBUG + /* assert skb->len == off */ + if (skb->len != off) { + dev_err(&devdata->netdev->dev, + "%s something wrong; skb->len:%d != off:%d\n", + netdev->name, skb->len, off); + } + /* test code */ + cc = util_copy_fragsinfo_from_skb("rcvchaintest", skb, + RCVPOST_BUF_SIZE, + MAX_PHYS_INFO, testfrags); + if (cc != cmdrsp->net.rcv.numrcvbufs) { + dev_err(&devdata->netdev->dev, + "**** %s Something wrong; rcvd chain length %d different from one we calculated %d\n", + netdev->name, cmdrsp->net.rcv.numrcvbufs, cc); + } + for (i = 0; i < cc; i++) { + dev_inf(&devdata->netdev->dev, + "test:RCVPOST_BUF_SIZE:%d[%d] pfn:%llu off:0x%x len:%d\n", + RCVPOST_BUF_SIZE, i, testfrags[i].pi_pfn, + testfrags[i].pi_off, testfrags[i].pi_len); + } +#endif + } + + /* set up packet's protocl type using ethernet header - this + * sets up skb->pkt_type & it also PULLS out the eth header + */ + skb->protocol = eth_type_trans(skb, netdev); + + eth = eth_hdr(skb); + + skb->csum = 0; + skb->ip_summed = CHECKSUM_NONE; + + do { + if (netdev->flags & IFF_PROMISC) + break; /* accept all packets */ + if (skb->pkt_type == PACKET_BROADCAST) { + if (netdev->flags & IFF_BROADCAST) + break; /* accept all broadcast packets */ + } else if (skb->pkt_type == PACKET_MULTICAST) { + if ((netdev->flags & IFF_MULTICAST) && + (netdev_mc_count(netdev))) { + struct netdev_hw_addr *ha; + int found_mc = 0; + + /* only accept multicast packets that we can + * find in our multicast address list + */ + netdev_for_each_mc_addr(ha, netdev) { + if (ether_addr_equal(eth->h_dest, + ha->addr)) { + found_mc = 1; + break; + } + } + if (found_mc) + break; /* accept packet, dest + matches a multicast + address */ + } + } else if (skb->pkt_type == PACKET_HOST) { + break; /* accept packet, h_dest must match vnic + mac address */ + } else if (skb->pkt_type == PACKET_OTHERHOST) { + /* something is not right */ + dev_err(&devdata->netdev->dev, + "**** FAILED to deliver rcv packet to OS; name:%s Dest:%pM VNIC:%pM\n", + netdev->name, eth->h_dest, netdev->dev_addr); + } + /* drop packet - don't forward it up to OS */ + devdata->n_rcv_packets_not_accepted++; + repost_return(cmdrsp, devdata, skb, netdev); + return; + } while (0); + + status = netif_rx(skb); + /* netif_rx returns various values, but "in practice most drivers + * ignore the return value + */ + + skb = NULL; + /* + * whether the packet got dropped or handled, the skb is freed by + * kernel code, so we shouldn't free it. but we should repost a + * new rcv buffer. + */ + repost_return(cmdrsp, devdata, skb, netdev); +} + +/** + * devdata_initialize - Initialize devdata structure + * @devdata: visornic_devdata structure to initialize + * #dev: visorbus_deviced it belongs to + * + * Setup initial values for the visornic based on channel and default + * values. + * Returns a pointer to the devdata if successful, else NULL + */ +static struct visornic_devdata * +devdata_initialize(struct visornic_devdata *devdata, struct visor_device *dev) +{ + int devnum = -1; + + if (!devdata) + return NULL; + memset(devdata, '\0', sizeof(struct visornic_devdata)); + spin_lock(&dev_num_pool_lock); + devnum = find_first_zero_bit(dev_num_pool, MAXDEVICES); + set_bit(devnum, dev_num_pool); + spin_unlock(&dev_num_pool_lock); + if (devnum == MAXDEVICES) + devnum = -1; + if (devnum < 0) { + kfree(devdata); + return NULL; + } + devdata->devnum = devnum; + devdata->dev = dev; + strncpy(devdata->name, dev_name(&dev->device), sizeof(devdata->name)); + kref_init(&devdata->kref); + spin_lock(&lock_all_devices); + list_add_tail(&devdata->list_all, &list_all_devices); + spin_unlock(&lock_all_devices); + return devdata; +} + +/** + * devdata_release - Frees up a devdata + * @mykref: kref to the devdata + * + * Frees up a devdata. + * Returns void + */ +static void devdata_release(struct kref *mykref) +{ + struct visornic_devdata *devdata = + container_of(mykref, struct visornic_devdata, kref); + + spin_lock(&dev_num_pool_lock); + clear_bit(devdata->devnum, dev_num_pool); + spin_unlock(&dev_num_pool_lock); + spin_lock(&lock_all_devices); + list_del(&devdata->list_all); + spin_unlock(&lock_all_devices); + kfree(devdata); +} + +static const struct net_device_ops visornic_dev_ops = { + .ndo_open = visornic_open, + .ndo_stop = visornic_close, + .ndo_start_xmit = visornic_xmit, + .ndo_get_stats = visornic_get_stats, + .ndo_do_ioctl = visornic_ioctl, + .ndo_change_mtu = visornic_change_mtu, + .ndo_tx_timeout = visornic_xmit_timeout, + .ndo_set_rx_mode = visornic_set_multi, +}; + +/** + * send_rcv_posts_if_needed + * @devdata: visornic device + * + * Send receive buffers to the IO Partition. + * Returns void + */ +static void +send_rcv_posts_if_needed(struct visornic_devdata *devdata) +{ + int i; + struct net_device *netdev; + struct uiscmdrsp *cmdrsp = devdata->cmdrsp_rcv; + int cur_num_rcv_bufs_to_alloc, rcv_bufs_allocated; + + /* don't do this until vnic is marked ready */ + if (!(devdata->enabled && devdata->enab_dis_acked)) + return; + + netdev = devdata->netdev; + rcv_bufs_allocated = 0; + /* this code is trying to prevent getting stuck here forever, + * but still retry it if you cant allocate them all this time. + */ + cur_num_rcv_bufs_to_alloc = devdata->num_rcv_bufs_could_not_alloc; + while (cur_num_rcv_bufs_to_alloc > 0) { + cur_num_rcv_bufs_to_alloc--; + for (i = 0; i < devdata->num_rcv_bufs; i++) { + if (devdata->rcvbuf[i]) + continue; + devdata->rcvbuf[i] = alloc_rcv_buf(netdev); + if (!devdata->rcvbuf[i]) { + devdata->alloc_failed_in_if_needed_cnt++; + break; + } + rcv_bufs_allocated++; + post_skb(cmdrsp, devdata, devdata->rcvbuf[i]); + devdata->chstat.extra_rcvbufs_sent++; + } + } + devdata->num_rcv_bufs_could_not_alloc -= rcv_bufs_allocated; +} + +/** + * draing_queue - drains the response queue + * @cmdrsp: io channel command response message + * @devdata: visornic device to drain + * + * Drain the respones queue of any responses from the IO partition. + * Process the responses as we get them. + * Returns when response queue is empty or when the threadd stops. + */ +static void +drain_queue(struct uiscmdrsp *cmdrsp, struct visornic_devdata *devdata) +{ + unsigned long flags; + struct net_device *netdev; + + /* drain queue */ + while (1) { + /* TODO: CLIENT ACQUIRE -- Don't really need this at the + * moment */ + if (!visorchannel_signalremove(devdata->dev->visorchannel, + IOCHAN_FROM_IOPART, + cmdrsp)) + break; /* queue empty */ + + switch (cmdrsp->net.type) { + case NET_RCV: + devdata->chstat.got_rcv++; + /* process incoming packet */ + visornic_rx(cmdrsp); + break; + case NET_XMIT_DONE: + spin_lock_irqsave(&devdata->priv_lock, flags); + devdata->chstat.got_xmit_done++; + if (cmdrsp->net.xmtdone.xmt_done_result) + devdata->chstat.xmit_fail++; + /* only call queue wake if we stopped it */ + netdev = ((struct sk_buff *)cmdrsp->net.buf)->dev; + /* ASSERT netdev == vnicinfo->netdev; */ + if ((netdev == devdata->netdev) && + netif_queue_stopped(netdev)) { + /* check to see if we have crossed + * the lower watermark for + * netif_wake_queue() + */ + if (((devdata->chstat.sent_xmit >= + devdata->chstat.got_xmit_done) && + (devdata->chstat.sent_xmit - + devdata->chstat.got_xmit_done <= + devdata->lower_threshold_net_xmits)) || + ((devdata->chstat.sent_xmit < + devdata->chstat.got_xmit_done) && + (ULONG_MAX - devdata->chstat.got_xmit_done + + devdata->chstat.sent_xmit <= + devdata->lower_threshold_net_xmits))) { + /* enough NET_XMITs completed + * so can restart netif queue + */ + netif_wake_queue(netdev); + devdata->flow_control_lower_hits++; + } + } + skb_unlink(cmdrsp->net.buf, &devdata->xmitbufhead); + spin_unlock_irqrestore(&devdata->priv_lock, flags); + kfree_skb(cmdrsp->net.buf); + break; + case NET_RCV_ENBDIS_ACK: + devdata->chstat.got_enbdisack++; + netdev = (struct net_device *) + cmdrsp->net.enbdis.context; + spin_lock_irqsave(&devdata->priv_lock, flags); + devdata->enab_dis_acked = 1; + spin_unlock_irqrestore(&devdata->priv_lock, flags); + + if (devdata->server_down && + devdata->server_change_state) { + /* Inform Linux that the link is up */ + devdata->server_down = false; + devdata->server_change_state = false; + netif_wake_queue(netdev); + netif_carrier_on(netdev); + } + break; + case NET_CONNECT_STATUS: + netdev = devdata->netdev; + if (cmdrsp->net.enbdis.enable == 1) { + spin_lock_irqsave(&devdata->priv_lock, flags); + devdata->enabled = cmdrsp->net.enbdis.enable; + spin_unlock_irqrestore(&devdata->priv_lock, + flags); + netif_wake_queue(netdev); + netif_carrier_on(netdev); + } else { + netif_stop_queue(netdev); + netif_carrier_off(netdev); + spin_lock_irqsave(&devdata->priv_lock, flags); + devdata->enabled = cmdrsp->net.enbdis.enable; + spin_unlock_irqrestore(&devdata->priv_lock, + flags); + } + break; + default: + break; + } + /* cmdrsp is now available for reuse */ + + if (kthread_should_stop()) + break; + } +} + +/** + * process_incoming_rsps - Checks the status of the response queue. + * @v: void pointer to the visronic devdata + * + * Main function of the vnic_incoming thread. Peridocially check the + * response queue and drain it if needed. + * Returns when thread has stopped. + */ +static int +process_incoming_rsps(void *v) +{ + struct visornic_devdata *devdata = v; + struct uiscmdrsp *cmdrsp = NULL; + const int SZ = SIZEOF_CMDRSP; + + cmdrsp = kmalloc(SZ, GFP_ATOMIC); + if (!cmdrsp) + complete_and_exit(&devdata->threadinfo.has_stopped, 0); + + while (1) { + wait_event_interruptible_timeout( + devdata->rsp_queue, (atomic_read( + &devdata->interrupt_rcvd) == 1), + msecs_to_jiffies(devdata->thread_wait_ms)); + + /* periodically check to see if there are any rcf bufs which + * need to get sent to the IOSP. This can only happen if + * we run out of memory when trying to allocate skbs. + */ + atomic_set(&devdata->interrupt_rcvd, 0); + send_rcv_posts_if_needed(devdata); + drain_queue(cmdrsp, devdata); + if (kthread_should_stop()) + break; + } + + kfree(cmdrsp); + complete_and_exit(&devdata->threadinfo.has_stopped, 0); +} + +/** + * visornic_probe - probe function for visornic devices + * @dev: The visor device discovered + * + * Called when visorbus discovers a visornic device on its + * bus. It creates a new visornic ethernet adapter. + * Returns 0 or negative for error. + */ +static int visornic_probe(struct visor_device *dev) +{ + struct visornic_devdata *devdata = NULL; + struct net_device *netdev = NULL; + int err; + int channel_offset = 0; + u64 features; + + netdev = alloc_etherdev(sizeof(struct visornic_devdata)); + if (!netdev) + return -ENOMEM; + + netdev->netdev_ops = &visornic_dev_ops; + netdev->watchdog_timeo = (5 * HZ); + netdev->dev.parent = &dev->device; + + /* Get MAC adddress from channel and read it into the device. */ + netdev->addr_len = ETH_ALEN; + channel_offset = offsetof(struct spar_io_channel_protocol, + vnic.macaddr); + err = visorbus_read_channel(dev, channel_offset, netdev->dev_addr, + ETH_ALEN); + if (err < 0) + goto cleanup_netdev; + + devdata = devdata_initialize(netdev_priv(netdev), dev); + if (!devdata) { + err = -ENOMEM; + goto cleanup_netdev; + } + + devdata->netdev = netdev; + init_waitqueue_head(&devdata->rsp_queue); + spin_lock_init(&devdata->priv_lock); + devdata->enabled = 0; /* not yet */ + atomic_set(&devdata->usage, 1); + + /* Setup rcv bufs */ + channel_offset = offsetof(struct spar_io_channel_protocol, + vnic.num_rcv_bufs); + err = visorbus_read_channel(dev, channel_offset, + &devdata->num_rcv_bufs, 4); + if (err) + goto cleanup_netdev; + + devdata->rcvbuf = kmalloc(sizeof(struct sk_buff *) * + devdata->num_rcv_bufs, GFP_KERNEL); + if (!devdata->rcvbuf) { + err = -ENOMEM; + goto cleanup_rcvbuf; + } + + /* set the net_xmit outstanding threshold */ + /* always leave two slots open but you should have 3 at a minimum */ + devdata->max_outstanding_net_xmits = + max(3, ((devdata->num_rcv_bufs / 3) - 2)); + devdata->upper_threshold_net_xmits = + max(2, devdata->max_outstanding_net_xmits - 1); + devdata->lower_threshold_net_xmits = + max(1, devdata->max_outstanding_net_xmits / 2); + + skb_queue_head_init(&devdata->xmitbufhead); + + /* create a cmdrsp we can use to post and unpost rcv buffers */ + devdata->cmdrsp_rcv = kmalloc(SIZEOF_CMDRSP, GFP_ATOMIC); + if (!devdata->cmdrsp_rcv) { + err = -ENOMEM; + goto cleanup_cmdrsp_rcv; + } + devdata->xmit_cmdrsp = kmalloc(SIZEOF_CMDRSP, GFP_ATOMIC); + if (!devdata->xmit_cmdrsp) { + err = -ENOMEM; + goto cleanup_xmit_cmdrsp; + } + INIT_WORK(&devdata->serverdown_completion, + visornic_serverdown_complete); + INIT_WORK(&devdata->timeout_reset, visornic_timeout_reset); + devdata->server_down = false; + devdata->server_change_state = false; + + /*set the default mtu */ + channel_offset = offsetof(struct spar_io_channel_protocol, + vnic.mtu); + err = visorbus_read_channel(dev, channel_offset, &netdev->mtu, 4); + if (err) + goto cleanup_xmit_cmdrsp; + + /* TODO: Setup Interrupt information */ + /* Let's start our threads to get responses */ + channel_offset = offsetof(struct spar_io_channel_protocol, + channel_header.features); + err = visorbus_read_channel(dev, channel_offset, &features, 8); + if (err) + goto cleanup_xmit_cmdrsp; + + features |= ULTRA_IO_CHANNEL_IS_POLLING; + err = visorbus_write_channel(dev, channel_offset, &features, 8); + if (err) + goto cleanup_xmit_cmdrsp; + + devdata->thread_wait_ms = 2; + visor_thread_start(&devdata->threadinfo, process_incoming_rsps, + devdata, "vnic_incoming"); + + err = register_netdev(netdev); + if (err) + goto cleanup_thread_stop; + + /* create debgug/sysfs directories */ + devdata->eth_debugfs_dir = debugfs_create_dir(netdev->name, + visornic_debugfs_dir); + if (!devdata->eth_debugfs_dir) { + err = -ENOMEM; + goto cleanup_thread_stop; + } + + return 0; + +cleanup_thread_stop: + visor_thread_stop(&devdata->threadinfo); + +cleanup_xmit_cmdrsp: + kfree(devdata->xmit_cmdrsp); + +cleanup_cmdrsp_rcv: + kfree(devdata->cmdrsp_rcv); + +cleanup_rcvbuf: + kfree(devdata->rcvbuf); + +cleanup_netdev: + free_netdev(netdev); + return err; +} + +/** + * host_side_disappeared - IO part is gone. + * @devdata: device object + * + * IO partition servicing this device is gone, do cleanup + * Returns void. + */ +static void host_side_disappeared(struct visornic_devdata *devdata) +{ + unsigned long flags; + + spin_lock_irqsave(&devdata->priv_lock, flags); + sprintf(devdata->name, "", devdata->devnum); + devdata->dev = NULL; /* indicate device destroyed */ + spin_unlock_irqrestore(&devdata->priv_lock, flags); +} + +/** + * visornic_remove - Called when visornic dev goes away + * @dev: visornic device that is being removed + * + * Called when DEVICE_DESTROY gets called to remove device. + * Returns void + */ +static void visornic_remove(struct visor_device *dev) +{ + struct visornic_devdata *devdata = dev_get_drvdata(&dev->device); + + if (!devdata) + return; + dev_set_drvdata(&dev->device, NULL); + host_side_disappeared(devdata); + kref_put(&devdata->kref, devdata_release); +} + +/** + * visornic_pause - Called when IO Part disappears + * @dev: visornic device that is being serviced + * @complete_func: call when finished. + * + * Called when the IO Partition has gone down. Need to free + * up resources and wait for IO partition to come back. Mark + * link as down and don't attempt any DMA. When we have freed + * memory call the complete_func so that Command knows we are + * done. If we don't call complete_func, IO part will never + * come back. + * Returns 0 for success. + */ +static int visornic_pause(struct visor_device *dev, + visorbus_state_complete_func complete_func) +{ + struct visornic_devdata *devdata = dev_get_drvdata(&dev->device); + + visornic_serverdown(devdata); + complete_func(dev, 0); + return 0; +} + +/** + * visornic_resume - Called when IO part has recovered + * @dev: visornic device that is being serviced + * @compelte_func: call when finished + * + * Called when the IO partition has recovered. Reestablish + * connection to the IO part and set the link up. Okay to do + * DMA again. + * Returns 0 for success. + */ +static int visornic_resume(struct visor_device *dev, + visorbus_state_complete_func complete_func) +{ + struct visornic_devdata *devdata; + struct net_device *netdev; + unsigned long flags; + + devdata = dev_get_drvdata(&dev->device); + if (!devdata) + return -EINVAL; + + netdev = devdata->netdev; + + if (devdata->server_down && !devdata->server_change_state) { + devdata->server_change_state = true; + /* Must transition channel to ATTACHED state BEFORE + * we can start using the device again. + * TODO: State transitions + */ + visor_thread_start(&devdata->threadinfo, process_incoming_rsps, + devdata, "vnic_incoming"); + init_rcv_bufs(netdev, devdata); + spin_lock_irqsave(&devdata->priv_lock, flags); + devdata->enabled = 1; + + /* Now we're ready, let's send an ENB to uisnic but until + * we get an ACK back from uisnic, we'll drop the packets + */ + devdata->enab_dis_acked = 0; + spin_unlock_irqrestore(&devdata->priv_lock, flags); + + /* send enable and wait for ack - don't hold lock when + * sending enable because if the queue if sull, insert + * might sleep. + */ + send_enbdis(netdev, 1, devdata); + } else if (devdata->server_change_state) { + return -EIO; + } + + complete_func(dev, 0); + return 0; +} + +/** + * visornic_init - Init function + * + * Init function for the visornic driver. Do initial driver setup + * and wait for devices. + * Returns 0 for success, negative for error. + */ +static int visornic_init(void) +{ + struct dentry *ret; + int err = -ENOMEM; + + /* create workqueue for serverdown completion */ + visornic_serverdown_workqueue = + create_singlethread_workqueue("visornic_serverdown"); + if (!visornic_serverdown_workqueue) + return -ENOMEM; + + /* create workqueue for tx timeout reset */ + visornic_timeout_reset_workqueue = + create_singlethread_workqueue("visornic_timeout_reset"); + if (!visornic_timeout_reset_workqueue) + return -ENOMEM; + + visornic_debugfs_dir = debugfs_create_dir("visornic", NULL); + if (!visornic_debugfs_dir) + return err; + + ret = debugfs_create_file("info", S_IRUSR, visornic_debugfs_dir, NULL, + &debugfs_info_fops); + if (!ret) + goto cleanup_debugfs; + ret = debugfs_create_file("enable_ints", S_IWUSR, visornic_debugfs_dir, + NULL, &debugfs_enable_ints_fops); + if (!ret) + goto cleanup_debugfs; + + /* create workqueue for serverdown completion */ + visornic_serverdown_workqueue = + create_singlethread_workqueue("visornic_serverdown"); + if (!visornic_serverdown_workqueue) + goto cleanup_debugfs; + + /* create workqueue for tx timeout reset */ + visornic_timeout_reset_workqueue = + create_singlethread_workqueue("visornic_timeout_reset"); + if (!visornic_timeout_reset_workqueue) + goto cleanup_workqueue; + + spin_lock_init(&dev_num_pool_lock); + dev_num_pool = kzalloc(BITS_TO_LONGS(MAXDEVICES), GFP_KERNEL); + if (!dev_num_pool) + goto cleanup_workqueue; + + visorbus_register_visor_driver(&visornic_driver); + return 0; + +cleanup_workqueue: + flush_workqueue(visornic_serverdown_workqueue); + destroy_workqueue(visornic_serverdown_workqueue); + if (visornic_timeout_reset_workqueue) { + flush_workqueue(visornic_timeout_reset_workqueue); + destroy_workqueue(visornic_timeout_reset_workqueue); + } +cleanup_debugfs: + debugfs_remove_recursive(visornic_debugfs_dir); + + return err; +} + +/** + * visornic_cleanup - driver exit routine + * + * Unregister driver from the bus and free up memory. + */ +static void visornic_cleanup(void) +{ + if (visornic_serverdown_workqueue) { + flush_workqueue(visornic_serverdown_workqueue); + destroy_workqueue(visornic_serverdown_workqueue); + } + if (visornic_timeout_reset_workqueue) { + flush_workqueue(visornic_timeout_reset_workqueue); + destroy_workqueue(visornic_timeout_reset_workqueue); + } + debugfs_remove_recursive(visornic_debugfs_dir); + + visorbus_unregister_visor_driver(&visornic_driver); + kfree(dev_num_pool); + dev_num_pool = NULL; +} + +module_init(visornic_init); +module_exit(visornic_cleanup); + +MODULE_AUTHOR("Unisys"); +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("sPAR nic driver for sparlinux: ver 1.0.0.0"); +MODULE_VERSION("1.0.0.0"); From 56df900cb44d18c3ffaf16e09b83aaf37d912cc5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 16 Jun 2015 09:13:33 -0400 Subject: [PATCH 1048/1163] staging: unisys: visorchannel_write() fix potential memory corruption This fixes the memory corruption case, if nbytes is less than offset and sizeof(struct channel_header) Reported-by: Dan Carpenter Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchannel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index b1155ab9eeeb..20b63496e9f2 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -258,7 +258,7 @@ visorchannel_write(struct visorchannel *channel, ulong offset, return -EIO; if (offset < chdr_size) { - copy_size = min(chdr_size, nbytes) - offset; + copy_size = min(chdr_size - offset, nbytes); memcpy(&channel->chan_hdr + offset, local, copy_size); } From c3ea8a720099873503464049da900d6df7a7a14e Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Tue, 16 Jun 2015 15:28:21 +0900 Subject: [PATCH 1049/1163] staging: wilc1000: rework include wilc_oswrapper.h rework line '#include "wilc_oswrapper.h"' it does not used anywhere after change own data type to common data type. Signed-off-by: Dean Lee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.h | 1 - drivers/staging/wilc1000/fifo_buffer.c | 1 - drivers/staging/wilc1000/fifo_buffer.h | 5 ++++- drivers/staging/wilc1000/host_interface.c | 1 - drivers/staging/wilc1000/wilc_memory.c | 2 +- drivers/staging/wilc1000/wilc_memory.h | 4 +++- drivers/staging/wilc1000/wilc_msgqueue.c | 2 +- drivers/staging/wilc1000/wilc_msgqueue.h | 5 +++++ drivers/staging/wilc1000/wilc_sleep.c | 2 +- drivers/staging/wilc1000/wilc_sleep.h | 3 +++ drivers/staging/wilc1000/wilc_strutils.c | 2 +- drivers/staging/wilc1000/wilc_strutils.h | 4 ++++ drivers/staging/wilc1000/wilc_timer.c | 2 +- drivers/staging/wilc1000/wilc_timer.h | 3 +++ 14 files changed, 27 insertions(+), 10 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h index 6c1dad13f013..3ca067ebe157 100644 --- a/drivers/staging/wilc1000/coreconfigurator.h +++ b/drivers/staging/wilc1000/coreconfigurator.h @@ -12,7 +12,6 @@ #ifndef CORECONFIGURATOR_H #define CORECONFIGURATOR_H -#include "wilc_oswrapper.h" #include "wilc_wlan_if.h" /*****************************************************************************/ /* Constants */ diff --git a/drivers/staging/wilc1000/fifo_buffer.c b/drivers/staging/wilc1000/fifo_buffer.c index c801406d1aa8..b6c07cfc43d2 100644 --- a/drivers/staging/wilc1000/fifo_buffer.c +++ b/drivers/staging/wilc1000/fifo_buffer.c @@ -1,6 +1,5 @@ -#include "wilc_oswrapper.h" #include "fifo_buffer.h" diff --git a/drivers/staging/wilc1000/fifo_buffer.h b/drivers/staging/wilc1000/fifo_buffer.h index 57f7732db2da..7b76998e4238 100644 --- a/drivers/staging/wilc1000/fifo_buffer.h +++ b/drivers/staging/wilc1000/fifo_buffer.h @@ -1,5 +1,8 @@ -#include "wilc_oswrapper.h" +#include +#include +#include "wilc_memory.h" +#include "wilc_strutils.h" #define tHANDLE void * diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index e091bbc7bf3e..3f139aebe9f8 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1,5 +1,4 @@ #include "host_interface.h" -#include "wilc_oswrapper.h" #include "coreconfigurator.h" extern s32 TransportInit(void); diff --git a/drivers/staging/wilc1000/wilc_memory.c b/drivers/staging/wilc1000/wilc_memory.c index 5670b5a0da0f..c70707fefb66 100644 --- a/drivers/staging/wilc1000/wilc_memory.c +++ b/drivers/staging/wilc1000/wilc_memory.c @@ -1,5 +1,5 @@ -#include "wilc_oswrapper.h" +#include "wilc_memory.h" /*! * @author syounan diff --git a/drivers/staging/wilc1000/wilc_memory.h b/drivers/staging/wilc1000/wilc_memory.h index 1bc4b530b763..372d7053e873 100644 --- a/drivers/staging/wilc1000/wilc_memory.h +++ b/drivers/staging/wilc1000/wilc_memory.h @@ -10,6 +10,9 @@ * @version 1.0 */ +#include +#include + /*! * @struct tstrWILC_MemoryAttrs * @brief Memory API options @@ -234,4 +237,3 @@ void WILC_MemoryFree(const void *pvBlock, tstrWILC_MemoryAttrs *strAttrs, #endif - diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c b/drivers/staging/wilc1000/wilc_msgqueue.c index 04fe5a59de5c..16bcef4b5c00 100644 --- a/drivers/staging/wilc1000/wilc_msgqueue.c +++ b/drivers/staging/wilc1000/wilc_msgqueue.c @@ -1,5 +1,5 @@ -#include "wilc_oswrapper.h" +#include "wilc_msgqueue.h" #include /*! diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h b/drivers/staging/wilc1000/wilc_msgqueue.h index 2ca02db95ee2..35b10019eebd 100644 --- a/drivers/staging/wilc1000/wilc_msgqueue.h +++ b/drivers/staging/wilc1000/wilc_msgqueue.h @@ -10,6 +10,11 @@ * @version 1.0 */ +#include "wilc_platform.h" +#include "wilc_errorsupport.h" +#include "wilc_memory.h" +#include "wilc_strutils.h" + /*! * @struct tstrWILC_MsgQueueAttrs * @brief Message Queue API options diff --git a/drivers/staging/wilc1000/wilc_sleep.c b/drivers/staging/wilc1000/wilc_sleep.c index 569b833a71e9..adab3cac64f9 100644 --- a/drivers/staging/wilc1000/wilc_sleep.c +++ b/drivers/staging/wilc1000/wilc_sleep.c @@ -1,5 +1,5 @@ -#include "wilc_oswrapper.h" +#include "wilc_sleep.h" /* * @author mdaftedar diff --git a/drivers/staging/wilc1000/wilc_sleep.h b/drivers/staging/wilc1000/wilc_sleep.h index 261f4ede338c..cf9047f707a7 100644 --- a/drivers/staging/wilc1000/wilc_sleep.h +++ b/drivers/staging/wilc1000/wilc_sleep.h @@ -1,6 +1,9 @@ #ifndef __WILC_SLEEP_H__ #define __WILC_SLEEP_H__ +#include +#include + /*! * @brief forces the current thread to sleep until the given time has elapsed * @param[in] u32TimeMilliSec Time to sleep in Milli seconds diff --git a/drivers/staging/wilc1000/wilc_strutils.c b/drivers/staging/wilc1000/wilc_strutils.c index ac9bb061126a..e0145953ceef 100644 --- a/drivers/staging/wilc1000/wilc_strutils.c +++ b/drivers/staging/wilc1000/wilc_strutils.c @@ -1,7 +1,7 @@ #define _CRT_SECURE_NO_DEPRECATE -#include "wilc_oswrapper.h" +#include "wilc_strutils.h" /*! diff --git a/drivers/staging/wilc1000/wilc_strutils.h b/drivers/staging/wilc1000/wilc_strutils.h index bb31beaf5aef..d1445575a25e 100644 --- a/drivers/staging/wilc1000/wilc_strutils.h +++ b/drivers/staging/wilc1000/wilc_strutils.h @@ -10,6 +10,10 @@ * @version 1.0 */ +#include +#include +#include "wilc_errorsupport.h" + /*! * @brief Compares two memory buffers * @param[in] pvArg1 pointer to the first memory location diff --git a/drivers/staging/wilc1000/wilc_timer.c b/drivers/staging/wilc1000/wilc_timer.c index c31bf0c5e590..dc71157f9c3e 100644 --- a/drivers/staging/wilc1000/wilc_timer.c +++ b/drivers/staging/wilc1000/wilc_timer.c @@ -1,5 +1,5 @@ -#include "wilc_oswrapper.h" +#include "wilc_timer.h" WILC_ErrNo WILC_TimerCreate(WILC_TimerHandle *pHandle, tpfWILC_TimerFunction pfCallback, tstrWILC_TimerAttrs *pstrAttrs) diff --git a/drivers/staging/wilc1000/wilc_timer.h b/drivers/staging/wilc1000/wilc_timer.h index a0f91545240e..931269db3194 100644 --- a/drivers/staging/wilc1000/wilc_timer.h +++ b/drivers/staging/wilc1000/wilc_timer.h @@ -10,6 +10,9 @@ * @version 1.0 */ +#include "wilc_platform.h" +#include "wilc_errorsupport.h" + typedef void (*tpfWILC_TimerFunction)(void *); /*! From 3f4d1c09aef045ff4c37544a9187f29cc2c65720 Mon Sep 17 00:00:00 2001 From: Chaehyun Lim Date: Wed, 17 Jun 2015 11:08:09 +0900 Subject: [PATCH 1050/1163] staging: wilc1000: align defines Align some defines in linux_wlan_common.h Signed-off-by: Chaehyun Lim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan_common.h | 136 ++++++++++--------- 1 file changed, 74 insertions(+), 62 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan_common.h b/drivers/staging/wilc1000/linux_wlan_common.h index 541f19cf44ae..830d96a1f84e 100644 --- a/drivers/staging/wilc1000/linux_wlan_common.h +++ b/drivers/staging/wilc1000/linux_wlan_common.h @@ -22,25 +22,21 @@ enum debug_region { COMP = 0xFFFFFFFF, }; -#define GENERIC_DBG (1 << Generic_debug) -#define HOSTAPD_DBG (1 << Hostapd_debug) -#define HOSTINF_DBG (1 << Hostinf_debug) -#define CORECONFIG_DBG (1 << Coreconfig_debug) -#define CFG80211_DBG (1 << CFG80211_debug) -#define INT_DBG (1 << Interrupt_debug) -#define TX_DBG (1 << TX_debug) -#define RX_DBG (1 << RX_debug) -#define LOCK_DBG (1 << Lock_debug) -#define TCP_ENH (1 << Tcp_enhance) - - -/*Added by Amr - BugID_4720*/ -#define SPIN_DEBUG (1 << Spin_debug) - -#define INIT_DBG (1 << Init_debug) -#define BUS_DBG (1 << Bus_debug) -#define MEM_DBG (1 << Mem_debug) -#define FIRM_DBG (1 << Firmware_debug) +#define GENERIC_DBG (1 << Generic_debug) +#define HOSTAPD_DBG (1 << Hostapd_debug) +#define HOSTINF_DBG (1 << Hostinf_debug) +#define CORECONFIG_DBG (1 << Coreconfig_debug) +#define CFG80211_DBG (1 << CFG80211_debug) +#define INT_DBG (1 << Interrupt_debug) +#define TX_DBG (1 << TX_debug) +#define RX_DBG (1 << RX_debug) +#define LOCK_DBG (1 << Lock_debug) +#define TCP_ENH (1 << Tcp_enhance) +#define SPIN_DEBUG (1 << Spin_debug) +#define INIT_DBG (1 << Init_debug) +#define BUS_DBG (1 << Bus_debug) +#define MEM_DBG (1 << Mem_debug) +#define FIRM_DBG (1 << Firmware_debug) #if defined (WILC_DEBUGFS) extern int wilc_debugfs_init(void); @@ -49,38 +45,45 @@ extern void wilc_debugfs_remove(void); extern atomic_t REGION; extern atomic_t DEBUG_LEVEL; -#define DEBUG (1 << 0) -#define INFO (1 << 1) -#define WRN (1 << 2) -#define ERR (1 << 3) +#define DEBUG (1 << 0) +#define INFO (1 << 1) +#define WRN (1 << 2) +#define ERR (1 << 3) -#define PRINT_D(region, ...) do { \ - if ((atomic_read(&DEBUG_LEVEL) & DEBUG) && ((atomic_read(®ION)) & (region))) { \ +#define PRINT_D(region, ...) \ + do { \ + if ((atomic_read(&DEBUG_LEVEL) & DEBUG) && \ + ((atomic_read(®ION)) & (region))) { \ printk("DBG [%s: %d]", __FUNCTION__, __LINE__); \ - printk(__VA_ARGS__); \ - } \ -} while (0) + printk(__VA_ARGS__); \ + } \ + } while (0) -#define PRINT_INFO(region, ...) do { \ - if ((atomic_read(&DEBUG_LEVEL) & INFO) && ((atomic_read(®ION)) & (region))) { \ - printk("INFO [%s]", __FUNCTION__); \ - printk(__VA_ARGS__); \ - } \ -} while (0) +#define PRINT_INFO(region, ...) \ + do { \ + if ((atomic_read(&DEBUG_LEVEL) & INFO) && \ + ((atomic_read(®ION)) & (region))) { \ + printk("INFO [%s]", __FUNCTION__); \ + printk(__VA_ARGS__); \ + } \ + } while (0) -#define PRINT_WRN(region, ...) do { \ - if ((atomic_read(&DEBUG_LEVEL) & WRN) && ((atomic_read(®ION)) & (region))) { \ +#define PRINT_WRN(region, ...) \ + do { \ + if ((atomic_read(&DEBUG_LEVEL) & WRN) && \ + ((atomic_read(®ION)) & (region))) { \ printk("WRN [%s: %d]", __FUNCTION__, __LINE__); \ - printk(__VA_ARGS__); \ - } \ -} while (0) + printk(__VA_ARGS__); \ + } \ + } while (0) -#define PRINT_ER(...) do { \ - if ((atomic_read(&DEBUG_LEVEL) & ERR)) { \ +#define PRINT_ER(...) \ + do { \ + if ((atomic_read(&DEBUG_LEVEL) & ERR)) { \ printk("ERR [%s: %d]", __FUNCTION__, __LINE__); \ - printk(__VA_ARGS__); \ - } \ -} while (0) + printk(__VA_ARGS__); \ + } \ + } while (0) #else @@ -89,27 +92,36 @@ extern atomic_t DEBUG_LEVEL; #define DEBUG 1 #define INFO 0 #define WRN 0 -#define PRINT_D(region, ...) do { if (DEBUG == 1 && ((REGION)&(region))) { \ - printk("DBG [%s: %d]", __FUNCTION__, __LINE__); \ - printk(__VA_ARGS__); \ - } \ - } while (0) -#define PRINT_INFO(region, ...) do { if (INFO == 1 && ((REGION)&(region))) { \ - printk("INFO [%s]", __FUNCTION__); \ - printk(__VA_ARGS__); \ - } \ - } while (0) +#define PRINT_D(region, ...) \ + do { \ + if (DEBUG == 1 && ((REGION)&(region))) { \ + printk("DBG [%s: %d]", __FUNCTION__, __LINE__); \ + printk(__VA_ARGS__); \ + } \ + } while (0) -#define PRINT_WRN(region, ...) do { if (WRN == 1 && ((REGION)&(region))) { \ - printk("WRN [%s: %d]", __FUNCTION__, __LINE__); \ - printk(__VA_ARGS__); \ - } \ - } while (0) +#define PRINT_INFO(region, ...) \ + do { \ + if (INFO == 1 && ((REGION)&(region))) { \ + printk("INFO [%s]", __FUNCTION__); \ + printk(__VA_ARGS__); \ + } \ + } while (0) -#define PRINT_ER(...) do { printk("ERR [%s: %d]", __FUNCTION__, __LINE__); \ - printk(__VA_ARGS__); \ - } while (0) +#define PRINT_WRN(region, ...) \ + do { \ + if (WRN == 1 && ((REGION)&(region))) { \ + printk("WRN [%s: %d]", __FUNCTION__, __LINE__); \ + printk(__VA_ARGS__); \ + } \ + } while (0) + +#define PRINT_ER(...) \ + do { \ + printk("ERR [%s: %d]", __FUNCTION__, __LINE__); \ + printk(__VA_ARGS__); \ + } while (0) #endif #define FN_IN /* PRINT_D(">>> \n") */ From f717c0ebb37ba3c8223ee7aa3047e94cb4a86c6f Mon Sep 17 00:00:00 2001 From: Abdul Hussain Date: Tue, 16 Jun 2015 09:49:49 +0000 Subject: [PATCH 1051/1163] Staging: wilc1000: Assign proper boolean value This patch assign proper boolean value to boolean variable. Signed-off-by: Abdul Hussain Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 3f139aebe9f8..3228824697f9 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -7814,7 +7814,7 @@ static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo) pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1]; rsnIndex += 2; } - pNewJoinBssParam->rsn_found = 1; + pNewJoinBssParam->rsn_found = true; index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */ continue; } else From 5a66bf20b8e17ed3abb1d115049ab9d636bd2d35 Mon Sep 17 00:00:00 2001 From: Abdul Hussain Date: Tue, 16 Jun 2015 09:44:06 +0000 Subject: [PATCH 1052/1163] Staging: wilc1000: Boolean tests don't need comparisons This patch removes unwanted true and false from boolean tests. Signed-off-by: Abdul Hussain Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 8 ++++---- drivers/staging/wilc1000/linux_mon.c | 2 +- drivers/staging/wilc1000/linux_wlan.c | 2 +- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 4 ++-- drivers/staging/wilc1000/wilc_wlan.c | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index bbb32318b2c3..523c863b22ac 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -1716,7 +1716,7 @@ s32 ParseResponse(u8 *resp, tstrWID *pstrWIDcfgResult) idx++; } idx += 3; - if ((u16WIDid == g_wid_num) && (num_wid_processed == false)) { + if ((u16WIDid == g_wid_num) && (!num_wid_processed)) { num_wid_processed = true; if (-2 == further_process_response(&resp[idx], u16WIDid, cfg_len, true, 0, &pstrWIDcfgResult[ResCnt])) { @@ -1922,7 +1922,7 @@ s32 ConfigWaitResponse(char *pcRespBuffer, s32 s32MaxRespBuffLen, s32 *ps32Bytes * gstrConfigPktInfo.bRespRequired = bRespRequired;*/ - if (gstrConfigPktInfo.bRespRequired == true) { + if (gstrConfigPktInfo.bRespRequired) { down(&SemHandlePktResp); *ps32BytesRead = gstrConfigPktInfo.s32BytesRead; @@ -1983,7 +1983,7 @@ s32 SendConfigPkt(u8 u8Mode, tstrWID *pstrWIDs, ConfigWaitResponse(gps8ConfigPacket, MAX_PACKET_BUFF_SIZE, &s32RcvdRespLen, bRespRequired); - if (bRespRequired == true) { + if (bRespRequired) { /* If the operating Mode is GET, then we expect a response frame from */ /* the driver. Hence start listening to the port for response */ if (g_oper_mode == GET_CFG) { @@ -2020,7 +2020,7 @@ s32 ConfigProvideResponse(char *pcRespBuffer, s32 s32RespLen) { s32 s32Error = WILC_SUCCESS; - if (gstrConfigPktInfo.bRespRequired == true) { + if (gstrConfigPktInfo.bRespRequired) { if (s32RespLen <= gstrConfigPktInfo.s32MaxRespBuffLen) { WILC_memcpy(gstrConfigPktInfo.pcRespBuffer, pcRespBuffer, s32RespLen); gstrConfigPktInfo.s32BytesRead = s32RespLen; diff --git a/drivers/staging/wilc1000/linux_mon.c b/drivers/staging/wilc1000/linux_mon.c index bc7feb459a7a..aaac9a08fe64 100644 --- a/drivers/staging/wilc1000/linux_mon.c +++ b/drivers/staging/wilc1000/linux_mon.c @@ -452,7 +452,7 @@ void WILC_mgm_HOSTAPD_ACK(void *priv, bool bStatus) cb_hdr->rate = 5; /* txrate->bitrate / 5; */ - if (true == bStatus) { + if (bStatus) { /* success */ cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_RTS; } else { diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index c1e92722a471..c1cf5be312a4 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -309,7 +309,7 @@ static int dev_state_ev_handler(struct notifier_block *this, unsigned long event - if (bEnablePS == true) + if (bEnablePS) host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 1, 0); PRINT_D(GENERIC_DBG, "[%s] Up IP\n", dev_iface->ifa_label); diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 9dcb3268d20c..92064db9eb05 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -624,7 +624,7 @@ static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent, } } - if (bNeedScanRefresh == true) { + if (bNeedScanRefresh) { /*BugID_5418*/ /*Also, refrsh DIRECT- results if */ refresh_scan(priv, 1, true); @@ -2817,7 +2817,7 @@ int WILC_WFI_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, return -EIO; } - if (bEnablePS == true) + if (bEnablePS) host_int_set_power_mgmt(priv->hWILCWFIDrv, enabled, timeout); diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index 762470c4e052..db9e7173c957 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -559,7 +559,7 @@ static int wilc_wlan_txq_add_net_pkt(void *priv, uint8_t *buffer, uint32_t buffe #ifdef TCP_ACK_FILTER tqe->tcp_PendingAck_index = NOT_TCP_ACK; #ifdef TCP_ENHANCEMENTS - if (is_TCP_ACK_Filter_Enabled() == true) + if (is_TCP_ACK_Filter_Enabled()) #endif tcp_process(tqe); #endif @@ -2337,7 +2337,7 @@ u16 Set_machw_change_vir_if(bool bValue) PRINT_ER("Error while Reading reg WILC_CHANGING_VIR_IF\n"); } - if (bValue == true) { + if (bValue) { reg |= (BIT31); } else { reg &= ~(BIT31); From f0feeaff9c60bfb3dbadf09da15d70cf35700f29 Mon Sep 17 00:00:00 2001 From: Hari Prasath Gujulan Elango Date: Tue, 16 Jun 2015 07:38:02 +0000 Subject: [PATCH 1053/1163] staging: wilc1000: remove unwanted code This patch removes SIOCDEVPRIVATE + 1 ioctl. It currently is just a stub which does some useless printks and returns. In the original code, if the user passes priv_cmd.total_len == 0 then it will Oops. Also it leaks memory every time it's called. In the future, we will implement this functionality using generic API functions Signed-off-by: Hari Prasath Gujulan Elango Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 57 --------------------------- 1 file changed, 57 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index c1cf5be312a4..8ecbb2d50900 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -2393,63 +2393,6 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) #endif switch (cmd) { - /* [[ added by tony for SIOCDEVPRIVATE */ - case SIOCDEVPRIVATE + 1: - { - android_wifi_priv_cmd priv_cmd; - - PRINT_INFO(GENERIC_DBG, "in SIOCDEVPRIVATE+1\n"); - - if (copy_from_user(&priv_cmd, req->ifr_data, sizeof(android_wifi_priv_cmd))) { - s32Error = -EFAULT; - goto done; - } - - buff = kmalloc(priv_cmd.total_len, GFP_KERNEL); - if (!buff) { - s32Error = -ENOMEM; - goto done; - } - - if (copy_from_user(buff, priv_cmd.buf, priv_cmd.total_len)) { - s32Error = -EFAULT; - goto done; - } - - PRINT_INFO(GENERIC_DBG, "%s: Android private cmd \"%s\" on %s\n", __FUNCTION__, buff, req->ifr_name); - - if (strncasecmp(buff, "SCAN-ACTIVE", strlen("SCAN-ACTIVE")) == 0) { - PRINT_INFO(GENERIC_DBG, "%s, SCAN-ACTIVE command\n", __FUNCTION__); - } else if (strncasecmp(buff, "SCAN-PASSIVE", strlen("SCAN-PASSIVE")) == 0) { - PRINT_INFO(GENERIC_DBG, "%s, SCAN-PASSIVE command\n", __FUNCTION__); - } else if (strncasecmp(buff, "RXFILTER-START", strlen("RXFILTER-START")) == 0) { - PRINT_INFO(GENERIC_DBG, "%s, RXFILTER-START command\n", __FUNCTION__); - } else if (strncasecmp(buff, "RXFILTER-STOP", strlen("RXFILTER-STOP")) == 0) { - PRINT_INFO(GENERIC_DBG, "%s, RXFILTER-STOP command\n", __FUNCTION__); - } else if (strncasecmp(buff, "RXFILTER-ADD", strlen("RXFILTER-ADD")) == 0) { - int filter_num = *(buff + strlen("RXFILTER-ADD") + 1) - '0'; - PRINT_INFO(GENERIC_DBG, "%s, RXFILTER-ADD command, filter_num=%d\n", __FUNCTION__, filter_num); - } else if (strncasecmp(buff, "RXFILTER-REMOVE", strlen("RXFILTER-REMOVE")) == 0) { - int filter_num = *(buff + strlen("RXFILTER-REMOVE") + 1) - '0'; - PRINT_INFO(GENERIC_DBG, "%s, RXFILTER-REMOVE command, filter_num=%d\n", __FUNCTION__, filter_num); - } else if (strncasecmp(buff, "BTCOEXSCAN-START", strlen("BTCOEXSCAN-START")) == 0) { - PRINT_INFO(GENERIC_DBG, "%s, BTCOEXSCAN-START command\n", __FUNCTION__); - } else if (strncasecmp(buff, "BTCOEXSCAN-STOP", strlen("BTCOEXSCAN-STOP")) == 0) { - PRINT_INFO(GENERIC_DBG, "%s, BTCOEXSCAN-STOP command\n", __FUNCTION__); - } else if (strncasecmp(buff, "BTCOEXMODE", strlen("BTCOEXMODE")) == 0) { - PRINT_INFO(GENERIC_DBG, "%s, BTCOEXMODE command\n", __FUNCTION__); - } else if (strncasecmp(buff, "SETBAND", strlen("SETBAND")) == 0) { - uint band = *(buff + strlen("SETBAND") + 1) - '0'; - PRINT_INFO(GENERIC_DBG, "%s, SETBAND command, band=%d\n", __FUNCTION__, band); - } else if (strncasecmp(buff, "GETBAND", strlen("GETBAND")) == 0) { - PRINT_INFO(GENERIC_DBG, "%s, GETBAND command\n", __FUNCTION__); - } else if (strncasecmp(buff, "COUNTRY", strlen("COUNTRY")) == 0) { - char *country_code = buff + strlen("COUNTRY") + 1; - PRINT_INFO(GENERIC_DBG, "%s, COUNTRY command, country_code=%s\n", __FUNCTION__, country_code); - } else { - PRINT_INFO(GENERIC_DBG, "%s, Unknown command\n", __FUNCTION__); - } - } break; /* ]] 2013-06-24 */ case SIOCSIWPRIV: From 7b174df6508658335954dde1ca04785644ed6c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= Date: Tue, 16 Jun 2015 15:21:23 +0200 Subject: [PATCH 1054/1163] staging: ft1000: ft1000-usb: ft1000_hw.c: fix long lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix checkpatch.pl warnings about lines longer than 80 characters. Signed-off-by: Michał Kępień Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_hw.c | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c index e6fb066e0dd2..e6b5976a09e3 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c @@ -399,8 +399,8 @@ int dsp_reload(struct ft1000_usb *ft1000dev) card_reset_dsp(ft1000dev, 0); msleep(1000); - status = - ft1000_write_register(ft1000dev, HOST_INTF_BE, FT1000_REG_SUP_CTRL); + status = ft1000_write_register(ft1000dev, HOST_INTF_BE, + FT1000_REG_SUP_CTRL); /* Let's check for FEFE */ status = @@ -587,8 +587,8 @@ static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev) goto err; } - pipe = - usb_sndbulkpipe(pFt1000Dev->dev, pFt1000Dev->bulk_out_endpointAddr); + pipe = usb_sndbulkpipe(pFt1000Dev->dev, + pFt1000Dev->bulk_out_endpointAddr); maxlen = usb_maxpacket(pFt1000Dev->dev, pipe, usb_pipeout(pipe)); pdata = (u8 *)skb->data; @@ -1049,8 +1049,8 @@ static int ft1000_dsp_prov(void *arg) /* Check if doorbell is available */ pr_debug("check if doorbell is cleared\n"); - status = - ft1000_read_register(dev, &tempword, FT1000_REG_DOORBELL); + status = ft1000_read_register(dev, &tempword, + FT1000_REG_DOORBELL); if (status) { pr_debug("ft1000_read_register error\n"); break; @@ -1071,9 +1071,8 @@ static int ft1000_dsp_prov(void *arg) pr_debug("*** Provision Data Sent to DSP\n"); /* Send provisioning data */ - ptr = - list_entry(info->prov_list.next, struct prov_record, - list); + ptr = list_entry(info->prov_list.next, + struct prov_record, list); len = *(u16 *)ptr->pprov_data; len = htons(len); len += PSEUDOSZ; @@ -1261,7 +1260,7 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) if (tempword & FT1000_DB_DPRAM_TX) { mdelay(10); status = ft1000_read_register(dev, &tempword, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); if (tempword & FT1000_DB_DPRAM_TX) break; } @@ -1295,8 +1294,8 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) info->DSPInfoBlk[10] = 0x7200; info->DSPInfoBlk[11] = htons(info->DSPInfoBlklen); status = ft1000_write_dpram32(dev, 0, - (u8 *)&info->DSPInfoBlk[0], - (unsigned short)(info->DSPInfoBlklen + 22)); + (u8 *)&info->DSPInfoBlk[0], + (unsigned short)(info->DSPInfoBlklen + 22)); status = ft1000_write_register(dev, FT1000_DB_DPRAM_TX, FT1000_REG_DOORBELL); dev->DrvMsgPend = 0; @@ -1355,8 +1354,9 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) *pmsg++ = convert.wrd; *pmsg++ = htons(info->DrvErrNum); - status = card_send_command(dev, (unsigned char *)&tempbuffer[0], - (u16)(0x0012 + PSEUDOSZ)); + status = card_send_command(dev, + (unsigned char *)&tempbuffer[0], + (u16)(0x0012 + PSEUDOSZ)); if (status) goto out; info->DrvErrNum = 0; @@ -1526,7 +1526,7 @@ int ft1000_poll(void *dev_id) usleep_range(9000, 11000); /* Program WMARK register */ status = ft1000_write_register(dev, 0x600, - FT1000_REG_MAG_WATERMARK); + FT1000_REG_MAG_WATERMARK); /* clear ASIC reset doorbell */ status = ft1000_write_register(dev, FT1000_DSP_ASIC_RESET, @@ -1542,9 +1542,9 @@ int ft1000_poll(void *dev_id) FT1000_REG_SUP_CTRL); /* copy dsp session record from Adapter block */ status = ft1000_write_dpram32(dev, 0, - (u8 *)&info->DSPSess.Rec[0], 1024); + (u8 *)&info->DSPSess.Rec[0], 1024); status = ft1000_write_register(dev, 0x600, - FT1000_REG_MAG_WATERMARK); + FT1000_REG_MAG_WATERMARK); /* ring doorbell to tell DSP that * ASIC is out of reset * */ @@ -1556,21 +1556,21 @@ int ft1000_poll(void *dev_id) if (!dev->fAppMsgPend) { /* Reset ASIC and DSP */ status = ft1000_read_dpram16(dev, - FT1000_MAG_DSP_TIMER0, - (u8 *)&info->DSP_TIME[0], - FT1000_MAG_DSP_TIMER0_INDX); + FT1000_MAG_DSP_TIMER0, + (u8 *)&info->DSP_TIME[0], + FT1000_MAG_DSP_TIMER0_INDX); status = ft1000_read_dpram16(dev, - FT1000_MAG_DSP_TIMER1, - (u8 *)&info->DSP_TIME[1], - FT1000_MAG_DSP_TIMER1_INDX); + FT1000_MAG_DSP_TIMER1, + (u8 *)&info->DSP_TIME[1], + FT1000_MAG_DSP_TIMER1_INDX); status = ft1000_read_dpram16(dev, - FT1000_MAG_DSP_TIMER2, - (u8 *)&info->DSP_TIME[2], - FT1000_MAG_DSP_TIMER2_INDX); + FT1000_MAG_DSP_TIMER2, + (u8 *)&info->DSP_TIME[2], + FT1000_MAG_DSP_TIMER2_INDX); status = ft1000_read_dpram16(dev, - FT1000_MAG_DSP_TIMER3, - (u8 *)&info->DSP_TIME[3], - FT1000_MAG_DSP_TIMER3_INDX); + FT1000_MAG_DSP_TIMER3, + (u8 *)&info->DSP_TIME[3], + FT1000_MAG_DSP_TIMER3_INDX); info->CardReady = 0; info->DrvErrNum = DSP_CONDRESET_INFO; pr_debug("DSP conditional reset requested\n"); From f9d3faee24235609013b4927635c73dbbde02595 Mon Sep 17 00:00:00 2001 From: Peter Karlsson Date: Wed, 17 Jun 2015 17:32:10 +0200 Subject: [PATCH 1055/1163] staging: ft1000-usb: Removed unnecessary parenthes Fix checkpatch warning about unnecessary parenthes. Signed-off-by: Peter Karlsson 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 2593413412a3..a19e3930edce 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c @@ -317,7 +317,7 @@ static int ft1000_open(struct inode *inode, struct file *file) /* Search for available application info block */ for (i = 0; i < MAX_NUM_APP; i++) { - if ((dev->app_info[i].fileobject == NULL)) + if (dev->app_info[i].fileobject == NULL) break; } From 8103a48d3691bdd8ba757ab24a273120f4b1ae47 Mon Sep 17 00:00:00 2001 From: Peter Karlsson Date: Wed, 17 Jun 2015 17:32:11 +0200 Subject: [PATCH 1056/1163] staging: ft1000-usb: Removed global initialization Fix checkpatch error about initialize globals to 0. Signed-off-by: Peter Karlsson 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 a19e3930edce..409266b1a886 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c @@ -55,7 +55,7 @@ struct list_head freercvpool; /* lock to arbitrate free buffer list for receive command data */ spinlock_t free_buff_lock; -int numofmsgbuf = 0; +int numofmsgbuf; /* * Table of entry-point routines for char device From 25fe2274de25e1583faa38e3b7c574c0c9125de1 Mon Sep 17 00:00:00 2001 From: Abdul Hussain Date: Wed, 17 Jun 2015 04:48:23 +0000 Subject: [PATCH 1057/1163] Staging: wilc1000: Remove casting the values returned by kmalloc() This patch removes casting the values returned by memory allocation functions. Signed-off-by: Abdul Hussain Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_mon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wilc1000/linux_mon.c b/drivers/staging/wilc1000/linux_mon.c index aaac9a08fe64..30d1c76e89c2 100644 --- a/drivers/staging/wilc1000/linux_mon.c +++ b/drivers/staging/wilc1000/linux_mon.c @@ -247,7 +247,7 @@ static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len) nic = netdev_priv(dev); netif_stop_queue(dev); - mgmt_tx = (struct tx_complete_mon_data *)kmalloc(sizeof(struct tx_complete_mon_data), GFP_ATOMIC); + mgmt_tx = kmalloc(sizeof(struct tx_complete_mon_data), GFP_ATOMIC); if (mgmt_tx == NULL) { PRINT_ER("Failed to allocate memory for mgmt_tx structure\n"); return WILC_FAIL; From 93f822bbe8eab5c7b6b06cbee94600900cf320b2 Mon Sep 17 00:00:00 2001 From: Sunghoon Cho Date: Wed, 17 Jun 2015 14:42:32 +0900 Subject: [PATCH 1058/1163] staging: wilc1000: remove the warnings on the multiple blank lines. This patch removes the warnings reported by checkpatch.pl regarding on the multiple blank line uses. Signed-off-by: Sunghoon Cho Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 2331a006ec0e..a8b1501421b6 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -35,16 +35,12 @@ #include /* struct iphdr */ #include /* struct tcphdr */ #include - #include #include - #include #include #include #include - - #include #include #include "host_interface.h" @@ -55,8 +51,6 @@ #define FLOW_CONTROL_UPPER_THRESHOLD 256 /*iftype*/ - - enum stats_flags { WILC_WFI_RX_PKT = 1 << 0, WILC_WFI_TX_PKT = 1 << 1, @@ -131,14 +125,11 @@ struct WILC_WFI_priv { #ifdef WILC_P2P struct wilc_wfi_p2pListenParams strRemainOnChanParams; u64 u64tx_cookie; - #endif bool bCfgScanning; u32 u32RcvdChCount; - - u8 au8AssociatedBss[ETH_ALEN]; struct sta_info assoc_stainfo; struct net_device_stats stats; @@ -180,7 +171,6 @@ typedef struct { } struct_frame_reg; - #define NUM_CONCURRENT_IFC 2 typedef struct { uint8_t aSrcAddress[ETH_ALEN]; @@ -191,8 +181,6 @@ typedef struct { typedef struct { int mac_status; int wilc1000_initialized; - - #if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO) unsigned short dev_irq_num; #endif @@ -224,9 +212,6 @@ typedef struct { struct task_struct *rx_bh_thread; struct semaphore rx_sem; #endif - - - struct semaphore rxq_thread_started; struct semaphore txq_thread_started; From 9f5e9a2bdf62b3d1c80cf0b1ab97e8cd4bb6bb8b Mon Sep 17 00:00:00 2001 From: Sunghoon Cho Date: Wed, 17 Jun 2015 14:42:33 +0900 Subject: [PATCH 1059/1163] staging: wilc1000: remove unnecessary blank line. This patch removes blank line which is not necesssary after an open brace. Signed-off-by: Sunghoon Cho Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index a8b1501421b6..7f58551a8671 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -57,7 +57,6 @@ enum stats_flags { }; struct WILC_WFI_stats { - unsigned long rx_packets; unsigned long tx_packets; unsigned long rx_bytes; From 1d1c5b24f949a014a636687711fcec0f84359ffd Mon Sep 17 00:00:00 2001 From: Sunghoon Cho Date: Wed, 17 Jun 2015 14:42:36 +0900 Subject: [PATCH 1060/1163] staging: wilc1000: add a blank line This adds a blank line after struct declaration, WILC_WFI_mon_priv. Signed-off-by: Sunghoon Cho Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 7f58551a8671..d413fa3861c0 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -248,6 +248,7 @@ typedef struct { struct WILC_WFI_mon_priv { struct net_device *real_ndev; }; + extern struct net_device *WILC_WFI_devs[]; #endif From cb547643c37cc78b7eabeb236bcc618b31e66d5b Mon Sep 17 00:00:00 2001 From: Fabio Falzoi Date: Sun, 14 Jun 2015 15:48:47 +0200 Subject: [PATCH 1061/1163] Staging: rts5208: helper function to manage sd erase status Use a helper function to manage SD erase status when SUPPORT_SD_LOCK is defined Signed-off-by: Fabio Falzoi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_chip.c | 38 ++++++++++++++++------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c index 0c1716ebc827..e7d328086d8a 100644 --- a/drivers/staging/rts5208/rtsx_chip.c +++ b/drivers/staging/rts5208/rtsx_chip.c @@ -1143,11 +1143,30 @@ static void rtsx_monitor_aspm_config(struct rtsx_chip *chip) } } -void rtsx_polling_func(struct rtsx_chip *chip) +static void rtsx_manage_sd_lock(struct rtsx_chip *chip) { #ifdef SUPPORT_SD_LOCK struct sd_info *sd_card = &chip->sd_card; + u8 val; + + if (!sd_card->sd_erase_status) + return; + + if (chip->card_exist & SD_CARD) { + rtsx_read_register(chip, 0xFD30, &val); + if (val & 0x02) { + sd_card->sd_erase_status = SD_NOT_ERASE; + sd_card->sd_lock_notify = 1; + chip->need_reinit |= SD_CARD; + } + } else { + sd_card->sd_erase_status = SD_NOT_ERASE; + } #endif +} + +void rtsx_polling_func(struct rtsx_chip *chip) +{ bool ss_allowed; if (rtsx_chk_stat(chip, RTSX_STAT_SUSPEND)) @@ -1180,22 +1199,7 @@ void rtsx_polling_func(struct rtsx_chip *chip) } #endif -#ifdef SUPPORT_SD_LOCK - if (sd_card->sd_erase_status) { - if (chip->card_exist & SD_CARD) { - u8 val; - - rtsx_read_register(chip, 0xFD30, &val); - if (val & 0x02) { - sd_card->sd_erase_status = SD_NOT_ERASE; - sd_card->sd_lock_notify = 1; - chip->need_reinit |= SD_CARD; - } - } else { - sd_card->sd_erase_status = SD_NOT_ERASE; - } - } -#endif + rtsx_manage_sd_lock(chip); rtsx_init_cards(chip); From 507635763d83f425debd41c58e6c95e31db56323 Mon Sep 17 00:00:00 2001 From: Fabio Falzoi Date: Sun, 14 Jun 2015 15:48:48 +0200 Subject: [PATCH 1062/1163] Staging: rts5208: helper function to manage power off Use a helper function to check if power off is needed. Signed-off-by: Fabio Falzoi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_chip.c | 34 +++++++++++++++++------------ 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c index e7d328086d8a..5946cc47e86b 100644 --- a/drivers/staging/rts5208/rtsx_chip.c +++ b/drivers/staging/rts5208/rtsx_chip.c @@ -1143,6 +1143,25 @@ static void rtsx_monitor_aspm_config(struct rtsx_chip *chip) } } +static void rtsx_manage_ocp(struct rtsx_chip *chip) +{ +#ifdef SUPPORT_OCP + if (!chip->ocp_int) + return; + + rtsx_read_register(chip, OCPSTAT, &chip->ocp_stat); + + if (chip->card_exist & SD_CARD) + sd_power_off_card3v3(chip); + else if (chip->card_exist & MS_CARD) + ms_power_off_card3v3(chip); + else if (chip->card_exist & XD_CARD) + xd_power_off_card3v3(chip); + + chip->ocp_int = 0; +#endif +} + static void rtsx_manage_sd_lock(struct rtsx_chip *chip) { #ifdef SUPPORT_SD_LOCK @@ -1184,20 +1203,7 @@ void rtsx_polling_func(struct rtsx_chip *chip) if (rtsx_chk_stat(chip, RTSX_STAT_SS)) return; -#ifdef SUPPORT_OCP - if (chip->ocp_int) { - rtsx_read_register(chip, OCPSTAT, &chip->ocp_stat); - - if (chip->card_exist & SD_CARD) - sd_power_off_card3v3(chip); - else if (chip->card_exist & MS_CARD) - ms_power_off_card3v3(chip); - else if (chip->card_exist & XD_CARD) - xd_power_off_card3v3(chip); - - chip->ocp_int = 0; - } -#endif + rtsx_manage_ocp(chip); rtsx_manage_sd_lock(chip); From 319499380ceac581cbb73caf64d6814e7c606344 Mon Sep 17 00:00:00 2001 From: Fabio Falzoi Date: Sun, 14 Jun 2015 15:48:49 +0200 Subject: [PATCH 1063/1163] Staging: rts5208: helper function to manage ss Use a helper function to manage ss_counter Signed-off-by: Fabio Falzoi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_chip.c | 66 ++++++++++++++--------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c index 5946cc47e86b..373ccd03f0b2 100644 --- a/drivers/staging/rts5208/rtsx_chip.c +++ b/drivers/staging/rts5208/rtsx_chip.c @@ -1184,10 +1184,40 @@ static void rtsx_manage_sd_lock(struct rtsx_chip *chip) #endif } +static bool rtsx_is_ss_allowed(struct rtsx_chip *chip) +{ + u32 val; + + if (!chip->ss_en || CHECK_PID(chip, 0x5288)) + return false; + + if (CHK_SDIO_EXIST(chip) && !CHK_SDIO_IGNORED(chip)) { + rtsx_read_cfg_dw(chip, 1, 0x04, &val); + if (val & 0x07) + return false; + } + + return true; +} + +static void rtsx_manage_ss(struct rtsx_chip *chip) +{ + if (!rtsx_is_ss_allowed(chip) || chip->sd_io) + return; + + if (rtsx_get_stat(chip) != RTSX_STAT_IDLE) { + chip->ss_counter = 0; + return; + } + + if (chip->ss_counter < (chip->ss_idle_period / POLLING_INTERVAL)) + chip->ss_counter++; + else + rtsx_exclusive_enter_ss(chip); +} + void rtsx_polling_func(struct rtsx_chip *chip) { - bool ss_allowed; - if (rtsx_chk_stat(chip, RTSX_STAT_SUSPEND)) return; @@ -1209,37 +1239,7 @@ void rtsx_polling_func(struct rtsx_chip *chip) rtsx_init_cards(chip); - if (chip->ss_en) { - ss_allowed = true; - - if (CHECK_PID(chip, 0x5288)) { - ss_allowed = false; - } else { - if (CHK_SDIO_EXIST(chip) && !CHK_SDIO_IGNORED(chip)) { - u32 val; - - rtsx_read_cfg_dw(chip, 1, 0x04, &val); - if (val & 0x07) - ss_allowed = false; - } - } - } else { - ss_allowed = false; - } - - if (ss_allowed && !chip->sd_io) { - if (rtsx_get_stat(chip) != RTSX_STAT_IDLE) { - chip->ss_counter = 0; - } else { - if (chip->ss_counter < - (chip->ss_idle_period / POLLING_INTERVAL)) { - chip->ss_counter++; - } else { - rtsx_exclusive_enter_ss(chip); - return; - } - } - } + rtsx_manage_ss(chip); if (CHECK_PID(chip, 0x5208)) { rtsx_monitor_aspm_config(chip); From 884a27e36e0ebd009f2efc3a0b8d40cb0290907d Mon Sep 17 00:00:00 2001 From: Fabio Falzoi Date: Sun, 14 Jun 2015 15:48:50 +0200 Subject: [PATCH 1064/1163] Staging: rts5208: helper function to manage aspm Use a helper function to manage aspm mode Signed-off-by: Fabio Falzoi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_chip.c | 51 +++++++++++++++++------------ 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c index 373ccd03f0b2..ee331f2e4a0e 100644 --- a/drivers/staging/rts5208/rtsx_chip.c +++ b/drivers/staging/rts5208/rtsx_chip.c @@ -1216,6 +1216,35 @@ static void rtsx_manage_ss(struct rtsx_chip *chip) rtsx_exclusive_enter_ss(chip); } +static void rtsx_manage_aspm(struct rtsx_chip *chip) +{ + u8 data; + + if (!CHECK_PID(chip, 0x5208)) + return; + + rtsx_monitor_aspm_config(chip); + +#ifdef SUPPORT_SDIO_ASPM + if (!CHK_SDIO_EXIST(chip) || CHK_SDIO_IGNORED(chip) || + !chip->aspm_l0s_l1_en || !chip->dynamic_aspm) + return; + + if (chip->sd_io) { + dynamic_configure_sdio_aspm(chip); + return; + } + + if (chip->sdio_aspm) + return; + + dev_dbg(rtsx_dev(chip), "SDIO enter ASPM!\n"); + data = 0x30 | (chip->aspm_level[1] << 2); + rtsx_write_register(chip, ASPM_FORCE_CTL, 0xFC, data); + chip->sdio_aspm = 1; +#endif +} + void rtsx_polling_func(struct rtsx_chip *chip) { if (rtsx_chk_stat(chip, RTSX_STAT_SUSPEND)) @@ -1241,27 +1270,7 @@ void rtsx_polling_func(struct rtsx_chip *chip) rtsx_manage_ss(chip); - if (CHECK_PID(chip, 0x5208)) { - rtsx_monitor_aspm_config(chip); - -#ifdef SUPPORT_SDIO_ASPM - if (CHK_SDIO_EXIST(chip) && !CHK_SDIO_IGNORED(chip) && - chip->aspm_l0s_l1_en && chip->dynamic_aspm) { - if (chip->sd_io) { - dynamic_configure_sdio_aspm(chip); - } else { - if (!chip->sdio_aspm) { - dev_dbg(rtsx_dev(chip), "SDIO enter ASPM!\n"); - rtsx_write_register(chip, - ASPM_FORCE_CTL, 0xFC, - 0x30 | - (chip->aspm_level[1] << 2)); - chip->sdio_aspm = 1; - } - } - } -#endif - } + rtsx_manage_aspm(chip); if (chip->idle_counter < IDLE_MAX_COUNT) { chip->idle_counter++; From 76d833a8d9425618b7798227554d6a6729f3de5d Mon Sep 17 00:00:00 2001 From: Fabio Falzoi Date: Sun, 14 Jun 2015 15:48:51 +0200 Subject: [PATCH 1065/1163] Staging: rts5208: helper function to manage idle Use a helper function to manage idle state Signed-off-by: Fabio Falzoi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_chip.c | 45 ++++++++++++++++------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c index ee331f2e4a0e..01b20fb31c6e 100644 --- a/drivers/staging/rts5208/rtsx_chip.c +++ b/drivers/staging/rts5208/rtsx_chip.c @@ -1245,6 +1245,30 @@ static void rtsx_manage_aspm(struct rtsx_chip *chip) #endif } +static void rtsx_manage_idle(struct rtsx_chip *chip) +{ + if (chip->idle_counter < IDLE_MAX_COUNT) { + chip->idle_counter++; + return; + } + + if (rtsx_get_stat(chip) == RTSX_STAT_IDLE) + return; + + dev_dbg(rtsx_dev(chip), "Idle state!\n"); + rtsx_set_stat(chip, RTSX_STAT_IDLE); + +#if !defined(LED_AUTO_BLINK) && defined(REGULAR_BLINK) + chip->led_toggle_counter = 0; +#endif + rtsx_force_power_on(chip, SSC_PDCTL); + + turn_off_led(chip, LED_GPIO); + + if (chip->auto_power_down && !chip->card_ready && !chip->sd_io) + rtsx_force_power_down(chip, SSC_PDCTL | OC_PDCTL); +} + void rtsx_polling_func(struct rtsx_chip *chip) { if (rtsx_chk_stat(chip, RTSX_STAT_SUSPEND)) @@ -1272,26 +1296,7 @@ void rtsx_polling_func(struct rtsx_chip *chip) rtsx_manage_aspm(chip); - if (chip->idle_counter < IDLE_MAX_COUNT) { - chip->idle_counter++; - } else { - if (rtsx_get_stat(chip) != RTSX_STAT_IDLE) { - dev_dbg(rtsx_dev(chip), "Idle state!\n"); - rtsx_set_stat(chip, RTSX_STAT_IDLE); - -#if !defined(LED_AUTO_BLINK) && defined(REGULAR_BLINK) - chip->led_toggle_counter = 0; -#endif - rtsx_force_power_on(chip, SSC_PDCTL); - - turn_off_led(chip, LED_GPIO); - - if (chip->auto_power_down && !chip->card_ready && - !chip->sd_io) - rtsx_force_power_down(chip, - SSC_PDCTL | OC_PDCTL); - } - } + rtsx_manage_idle(chip); switch (rtsx_get_stat(chip)) { case RTSX_STAT_RUN: From 00aa7161fc2253fa1347a2795193e95690b9af86 Mon Sep 17 00:00:00 2001 From: Fabio Falzoi Date: Sun, 14 Jun 2015 15:48:52 +0200 Subject: [PATCH 1066/1163] Staging: rts5208: helper function to manage 1lun and 2lun modes Use a helper function to manage lun modes when SUPPORT_OCP is defined Signed-off-by: Fabio Falzoi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_chip.c | 97 ++++++++++++++++------------- 1 file changed, 53 insertions(+), 44 deletions(-) diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c index 01b20fb31c6e..298163a6dd50 100644 --- a/drivers/staging/rts5208/rtsx_chip.c +++ b/drivers/staging/rts5208/rtsx_chip.c @@ -1269,6 +1269,55 @@ static void rtsx_manage_idle(struct rtsx_chip *chip) rtsx_force_power_down(chip, SSC_PDCTL | OC_PDCTL); } +static void rtsx_manage_2lun_mode(struct rtsx_chip *chip) +{ +#ifdef SUPPORT_OCP + u8 sd_oc, ms_oc; + + sd_oc = chip->ocp_stat & (SD_OC_NOW | SD_OC_EVER); + ms_oc = chip->ocp_stat & (MS_OC_NOW | MS_OC_EVER); + + if (sd_oc || ms_oc) + dev_dbg(rtsx_dev(chip), "Over current, OCPSTAT is 0x%x\n", + chip->ocp_stat); + + if (sd_oc && (chip->card_exist & SD_CARD)) { + rtsx_write_register(chip, CARD_OE, SD_OUTPUT_EN, 0); + card_power_off(chip, SD_CARD); + chip->card_fail |= SD_CARD; + } + + if (ms_oc && (chip->card_exist & MS_CARD)) { + rtsx_write_register(chip, CARD_OE, MS_OUTPUT_EN, 0); + card_power_off(chip, MS_CARD); + chip->card_fail |= MS_CARD; + } +#endif +} + +static void rtsx_manage_1lun_mode(struct rtsx_chip *chip) +{ +#ifdef SUPPORT_OCP + if (!(chip->ocp_stat & (SD_OC_NOW | SD_OC_EVER))) + return; + + dev_dbg(rtsx_dev(chip), "Over current, OCPSTAT is 0x%x\n", + chip->ocp_stat); + + if (chip->card_exist & SD_CARD) { + rtsx_write_register(chip, CARD_OE, SD_OUTPUT_EN, 0); + chip->card_fail |= SD_CARD; + } else if (chip->card_exist & MS_CARD) { + rtsx_write_register(chip, CARD_OE, MS_OUTPUT_EN, 0); + chip->card_fail |= MS_CARD; + } else if (chip->card_exist & XD_CARD) { + rtsx_write_register(chip, CARD_OE, XD_OUTPUT_EN, 0); + chip->card_fail |= XD_CARD; + } + card_power_off(chip, SD_CARD); +#endif +} + void rtsx_polling_func(struct rtsx_chip *chip) { if (rtsx_chk_stat(chip, RTSX_STAT_SUSPEND)) @@ -1317,50 +1366,10 @@ void rtsx_polling_func(struct rtsx_chip *chip) break; } -#ifdef SUPPORT_OCP - if (CHECK_LUN_MODE(chip, SD_MS_2LUN)) { - if (chip->ocp_stat & - (SD_OC_NOW | SD_OC_EVER | MS_OC_NOW | MS_OC_EVER)) - dev_dbg(rtsx_dev(chip), "Over current, OCPSTAT is 0x%x\n", - chip->ocp_stat); - - if (chip->ocp_stat & (SD_OC_NOW | SD_OC_EVER)) { - if (chip->card_exist & SD_CARD) { - rtsx_write_register(chip, CARD_OE, SD_OUTPUT_EN, - 0); - card_power_off(chip, SD_CARD); - chip->card_fail |= SD_CARD; - } - } - if (chip->ocp_stat & (MS_OC_NOW | MS_OC_EVER)) { - if (chip->card_exist & MS_CARD) { - rtsx_write_register(chip, CARD_OE, MS_OUTPUT_EN, - 0); - card_power_off(chip, MS_CARD); - chip->card_fail |= MS_CARD; - } - } - } else { - if (chip->ocp_stat & (SD_OC_NOW | SD_OC_EVER)) { - dev_dbg(rtsx_dev(chip), "Over current, OCPSTAT is 0x%x\n", - chip->ocp_stat); - if (chip->card_exist & SD_CARD) { - rtsx_write_register(chip, CARD_OE, SD_OUTPUT_EN, - 0); - chip->card_fail |= SD_CARD; - } else if (chip->card_exist & MS_CARD) { - rtsx_write_register(chip, CARD_OE, MS_OUTPUT_EN, - 0); - chip->card_fail |= MS_CARD; - } else if (chip->card_exist & XD_CARD) { - rtsx_write_register(chip, CARD_OE, XD_OUTPUT_EN, - 0); - chip->card_fail |= XD_CARD; - } - card_power_off(chip, SD_CARD); - } - } -#endif + if (CHECK_LUN_MODE(chip, SD_MS_2LUN)) + rtsx_manage_2lun_mode(chip); + else + rtsx_manage_1lun_mode(chip); delink_stage: if (chip->auto_delink_en && chip->auto_delink_allowed && From a9b693cd77d70fb93dad8cbce667a49cd9b87352 Mon Sep 17 00:00:00 2001 From: Fabio Falzoi Date: Sun, 14 Jun 2015 15:48:53 +0200 Subject: [PATCH 1067/1163] Staging: rts5208: helper function to manage delink states Use a helper function to manage delink states Signed-off-by: Fabio Falzoi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_chip.c | 141 ++++++++++++++-------------- 1 file changed, 72 insertions(+), 69 deletions(-) diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c index 298163a6dd50..d6fb6cdf7d01 100644 --- a/drivers/staging/rts5208/rtsx_chip.c +++ b/drivers/staging/rts5208/rtsx_chip.c @@ -1318,6 +1318,77 @@ static void rtsx_manage_1lun_mode(struct rtsx_chip *chip) #endif } +static void rtsx_delink_stage1(struct rtsx_chip *chip, int enter_L1, + int stage3_cnt) +{ + u8 val; + + rtsx_set_stat(chip, RTSX_STAT_DELINK); + + if (chip->asic_code && CHECK_PID(chip, 0x5208)) + rtsx_set_phy_reg_bit(chip, 0x1C, 2); + + if (chip->card_exist) + dev_dbg(rtsx_dev(chip), "False card inserted, do force delink\n"); + else + dev_dbg(rtsx_dev(chip), "No card inserted, do delink\n"); + + if (enter_L1) + rtsx_write_register(chip, HOST_SLEEP_STATE, 0x03, 1); + + if (chip->card_exist) + val = 0x03; + else + val = 0x0A; + + rtsx_write_register(chip, CHANGE_LINK_STATE, val, val); + + if (enter_L1) + rtsx_enter_L1(chip); + + if (chip->card_exist) + chip->auto_delink_cnt = stage3_cnt + 1; +} + +static void rtsx_delink_stage(struct rtsx_chip *chip) +{ + int delink_stage1_cnt, delink_stage2_cnt, delink_stage3_cnt; + int enter_L1; + + if (!chip->auto_delink_en || !chip->auto_delink_allowed || + chip->card_ready || chip->card_ejected || chip->sd_io) { + chip->auto_delink_cnt = 0; + return; + } + + enter_L1 = chip->auto_delink_in_L1 && + (chip->aspm_l0s_l1_en || chip->ss_en); + + delink_stage1_cnt = chip->delink_stage1_step; + delink_stage2_cnt = delink_stage1_cnt + chip->delink_stage2_step; + delink_stage3_cnt = delink_stage2_cnt + chip->delink_stage3_step; + + if (chip->auto_delink_cnt > delink_stage3_cnt) + return; + + if (chip->auto_delink_cnt == delink_stage1_cnt) + rtsx_delink_stage1(chip, enter_L1, delink_stage3_cnt); + + if (chip->auto_delink_cnt == delink_stage2_cnt) { + dev_dbg(rtsx_dev(chip), "Try to do force delink\n"); + + if (enter_L1) + rtsx_exit_L1(chip); + + if (chip->asic_code && CHECK_PID(chip, 0x5208)) + rtsx_set_phy_reg_bit(chip, 0x1C, 2); + + rtsx_write_register(chip, CHANGE_LINK_STATE, 0x0A, 0x0A); + } + + chip->auto_delink_cnt++; +} + void rtsx_polling_func(struct rtsx_chip *chip) { if (rtsx_chk_stat(chip, RTSX_STAT_SUSPEND)) @@ -1372,75 +1443,7 @@ void rtsx_polling_func(struct rtsx_chip *chip) rtsx_manage_1lun_mode(chip); delink_stage: - if (chip->auto_delink_en && chip->auto_delink_allowed && - !chip->card_ready && !chip->card_ejected && !chip->sd_io) { - int enter_L1 = chip->auto_delink_in_L1 && ( - chip->aspm_l0s_l1_en || chip->ss_en); - int delink_stage1_cnt = chip->delink_stage1_step; - int delink_stage2_cnt = delink_stage1_cnt + - chip->delink_stage2_step; - int delink_stage3_cnt = delink_stage2_cnt + - chip->delink_stage3_step; - - if (chip->auto_delink_cnt <= delink_stage3_cnt) { - if (chip->auto_delink_cnt == delink_stage1_cnt) { - rtsx_set_stat(chip, RTSX_STAT_DELINK); - - if (chip->asic_code && CHECK_PID(chip, 0x5208)) - rtsx_set_phy_reg_bit(chip, 0x1C, 2); - - if (chip->card_exist) { - dev_dbg(rtsx_dev(chip), "False card inserted, do force delink\n"); - - if (enter_L1) - rtsx_write_register(chip, - HOST_SLEEP_STATE, - 0x03, 1); - - rtsx_write_register(chip, - CHANGE_LINK_STATE, - 0x0A, 0x0A); - - if (enter_L1) - rtsx_enter_L1(chip); - - chip->auto_delink_cnt = - delink_stage3_cnt + 1; - } else { - dev_dbg(rtsx_dev(chip), "No card inserted, do delink\n"); - - if (enter_L1) - rtsx_write_register(chip, - HOST_SLEEP_STATE, - 0x03, 1); - - rtsx_write_register(chip, - CHANGE_LINK_STATE, - 0x02, 0x02); - - if (enter_L1) - rtsx_enter_L1(chip); - } - } - - if (chip->auto_delink_cnt == delink_stage2_cnt) { - dev_dbg(rtsx_dev(chip), "Try to do force delink\n"); - - if (enter_L1) - rtsx_exit_L1(chip); - - if (chip->asic_code && CHECK_PID(chip, 0x5208)) - rtsx_set_phy_reg_bit(chip, 0x1C, 2); - - rtsx_write_register(chip, CHANGE_LINK_STATE, - 0x0A, 0x0A); - } - - chip->auto_delink_cnt++; - } - } else { - chip->auto_delink_cnt = 0; - } + rtsx_delink_stage(chip); } void rtsx_undo_delink(struct rtsx_chip *chip) From 07a55cd9b27a3a3f349617bd5037426ff2995f1c Mon Sep 17 00:00:00 2001 From: Andreas Ruprecht Date: Mon, 15 Jun 2015 15:03:00 +0200 Subject: [PATCH 1068/1163] staging: rtl8723au: core: Remove unneeded #ifdefs In rtw_mlme_ext.c, nested #ifdef blocks form the following structure inside the file: #ifdef CONFIG_8723AU_AP_MODE (line 1323) [...] #ifdef CONFIG_8723AU_AP_MODE (line 1720) [...] #endif (2 more ifdef blocks with CONFIG_8723AU_AP_MODE follow) [...] #endif /* CONFIG_8723AU_AP_MODE */ (line 1763) The inner #ifdefs are unnecessary as they depend on the same condition as the outer #ifdef and can thus be removed. Signed-off-by: Andreas Ruprecht Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 0d7e9215cf3e..be9a3d560a43 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1717,7 +1717,6 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) /* now the station is qualified to join our BSS... */ 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); @@ -1736,21 +1735,17 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) /* 3-(1) report sta add event */ report_add_sta_event23a(padapter, pstat->hwaddr, pstat->aid); -#endif } return _SUCCESS; asoc_class2_error: -#ifdef CONFIG_8723AU_AP_MODE issue_deauth23a(padapter, mgmt->sa, status); -#endif return _FAIL; OnAssocReq23aFail: -#ifdef CONFIG_8723AU_AP_MODE pstat->aid = 0; if (ieee80211_is_assoc_req(mgmt->frame_control)) issue_assocrsp(padapter, status, pstat, @@ -1758,7 +1753,6 @@ OnAssocReq23aFail: else issue_assocrsp(padapter, status, pstat, IEEE80211_STYPE_REASSOC_RESP); -#endif #endif /* CONFIG_8723AU_AP_MODE */ From ff8453b3138aa5da64f70edbfb0912c536ce4510 Mon Sep 17 00:00:00 2001 From: Daniele Alessandrelli Date: Mon, 15 Jun 2015 20:44:20 +0200 Subject: [PATCH 1069/1163] staging: rtl8723au: include/rtl8723a_hal.h: fix Rsvd1 size in fw header struct The size of field Rsvd1 in struct rt_8723a_firmware_hdr should be u8 otherwise we exceeds the boundaries of "LONG WORD 0". This patch fixes the issue. Signed-off-by: Daniele Alessandrelli Acked-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtl8723a_hal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index 8ee301b44f0f..d40e420dd050 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -85,7 +85,7 @@ struct rt_8723a_firmware_hdr { u8 Function; /* Reserved for different FW function indcation, for further use when driver needs to download different FW in different conditions */ u16 Version; /* FW Version */ u8 Subversion; /* FW Subversion, default 0x00 */ - u16 Rsvd1; + u8 Rsvd1; /* LONG WORD 1 ---- */ From 5534b8a1902f1b1710b1c714f6efc9adfdc86f93 Mon Sep 17 00:00:00 2001 From: Daniele Alessandrelli Date: Mon, 15 Jun 2015 20:44:21 +0200 Subject: [PATCH 1070/1163] staging: rtl8723au: include/rtl8723a_hal.h: use __leXX types in fw header struct This patch makes fields in struct rt_8723a_firmware_hdr use endianness-aware types (__leXX), thus fixing the following sparse warnings: CHECK drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:263:37: warning: cast to restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:265:39: warning: cast to restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:277:13: warning: cast to restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:277:13: warning: cast to restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:277:13: warning: cast to restricted __le16 Signed-off-by: Daniele Alessandrelli Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723au/include/rtl8723a_hal.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index d40e420dd050..77a0fd485b51 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -80,10 +80,13 @@ struct rt_8723a_firmware_hdr { /* 8-byte alinment required */ /* LONG WORD 0 ---- */ - u16 Signature; /* 92C0: test chip; 92C, 88C0: test chip; 88C1: MP A-cut; 92C1: MP A-cut */ + __le16 Signature; /* + * 92C0: test chip; 92C, 88C0: test chip; + * 88C1: MP A-cut; 92C1: MP A-cut + */ u8 Category; /* AP/NIC and USB/PCI */ u8 Function; /* Reserved for different FW function indcation, for further use when driver needs to download different FW in different conditions */ - u16 Version; /* FW Version */ + __le16 Version; /* FW Version */ u8 Subversion; /* FW Subversion, default 0x00 */ u8 Rsvd1; @@ -93,16 +96,16 @@ struct rt_8723a_firmware_hdr { u8 Date; /* Release time Date field */ u8 Hour; /* Release time Hour field */ u8 Minute; /* Release time Minute field */ - u16 RamCodeSize; /* The size of RAM code */ - u16 Rsvd2; + __le16 RamCodeSize; /* The size of RAM code */ + __le16 Rsvd2; /* LONG WORD 2 ---- */ - u32 SvnIdx; /* The SVN entry index */ - u32 Rsvd3; + __le32 SvnIdx; /* The SVN entry index */ + __le32 Rsvd3; /* LONG WORD 3 ---- */ - u32 Rsvd4; - u32 Rsvd5; + __le32 Rsvd4; + __le32 Rsvd5; }; #define DRIVER_EARLY_INT_TIME 0x05 From 3bfef6500818677abdbf5c0d8c3bce0caae539a3 Mon Sep 17 00:00:00 2001 From: Prasanna Karthik Date: Wed, 17 Jun 2015 12:50:14 +0000 Subject: [PATCH 1071/1163] staging:rtl8723au: Fix return statement reported by coccinelle Modified return statement and removed local declaration no longer needed. No Compiler warnings. Signed-off-by: Prasanna Karthik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c b/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c index 4909835cc540..11d635d2eac8 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c @@ -500,7 +500,6 @@ phy_RF6052_Config_ParaFile_Fail: int PHY_RF6052_Config8723A(struct rtw_adapter *Adapter) { struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); - int rtStatus = _SUCCESS; /* Initialize general global value */ /* TODO: Extend RF_PATH_C and RF_PATH_D in the future */ @@ -510,8 +509,7 @@ int PHY_RF6052_Config8723A(struct rtw_adapter *Adapter) pHalData->NumTotalRFPath = 2; /* Config BB and RF */ - rtStatus = phy_RF6052_Config_ParaFile(Adapter); - return rtStatus; + return phy_RF6052_Config_ParaFile(Adapter); } /* End of HalRf6052.c */ From 5699c0f4fcf9196652d3bba24c8c83557dc82d97 Mon Sep 17 00:00:00 2001 From: Abdul Hussain Date: Tue, 16 Jun 2015 05:43:16 +0000 Subject: [PATCH 1072/1163] staging: vt6656: Boolean tests don't need comparisons. This patch remove true and false from boolean tests. Signed-off-by: Abdul Hussain Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 2 +- drivers/staging/vt6656/main_usb.c | 2 +- drivers/staging/vt6656/rxtx.c | 2 +- drivers/staging/vt6656/usbpipe.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 67ff13f4f731..a215563de07d 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -389,7 +389,7 @@ void vnt_update_ifs(struct vnt_private *priv) } } - if (ofdm_rate == true) + if (ofdm_rate) max_min = 4; else max_min = 5; diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index ab3ab84cb0a7..cb8c2db70734 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -522,7 +522,7 @@ static int vnt_start(struct ieee80211_hw *hw) priv->rx_buf_sz = MAX_TOTAL_SIZE_WITH_ALL_HEADERS; - if (vnt_alloc_bufs(priv) == false) { + if (!vnt_alloc_bufs(priv)) { dev_dbg(&priv->usb->dev, "vnt_alloc_bufs fail...\n"); return -ENOMEM; } diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 5c589962a1e8..8116791f4f06 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -87,7 +87,7 @@ static struct vnt_usb_send_context return NULL; context = priv->tx_context[ii]; - if (context->in_use == false) { + if (!context->in_use) { context->in_use = true; memset(context->data, 0, MAX_TOTAL_SIZE_WITH_ALL_HEADERS); diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 88bf518f23eb..a5912dde9b31 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -141,7 +141,7 @@ int vnt_start_interrupt_urb(struct vnt_private *priv) { int status = STATUS_FAILURE; - if (priv->int_buf.in_use == true) + if (priv->int_buf.in_use) return STATUS_FAILURE; priv->int_buf.in_use = true; From b51c88171ee9c8e9fac8a99b64fd0a056a8fcb85 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 16 Jun 2015 23:43:11 +0100 Subject: [PATCH 1073/1163] staging: vt6655: remove suspend struct notifier_block. The only thing this does is vt6655_suspend which is already been called upon suspend. Remove function device_notify_reboot and structure device_notifier. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 37 ---------------------------- 1 file changed, 37 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 8dbde24eb154..c393b737ce6c 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -148,15 +148,6 @@ static void device_free_info(struct vnt_private *pDevice); static bool device_get_pci_info(struct vnt_private *, struct pci_dev *pcid); static void device_print_info(struct vnt_private *pDevice); -#ifdef CONFIG_PM -static int device_notify_reboot(struct notifier_block *, unsigned long event, void *ptr); -static struct notifier_block device_notifier = { - .notifier_call = device_notify_reboot, - .next = NULL, - .priority = 0, -}; -#endif - static void device_init_rd0_ring(struct vnt_private *pDevice); static void device_init_rd1_ring(struct vnt_private *pDevice); static void device_init_td0_ring(struct vnt_private *pDevice); @@ -1892,42 +1883,14 @@ static int __init vt6655_init_module(void) int ret; ret = pci_register_driver(&device_driver); -#ifdef CONFIG_PM - if (ret >= 0) - register_reboot_notifier(&device_notifier); -#endif return ret; } static void __exit vt6655_cleanup_module(void) { -#ifdef CONFIG_PM - unregister_reboot_notifier(&device_notifier); -#endif pci_unregister_driver(&device_driver); } module_init(vt6655_init_module); module_exit(vt6655_cleanup_module); - -#ifdef CONFIG_PM -static int -device_notify_reboot(struct notifier_block *nb, unsigned long event, void *p) -{ - struct pci_dev *pdev = NULL; - - switch (event) { - case SYS_DOWN: - case SYS_HALT: - case SYS_POWER_OFF: - for_each_pci_dev(pdev) { - if (pci_dev_driver(pdev) == &device_driver) { - if (pci_get_drvdata(pdev)) - vt6655_suspend(pdev, PMSG_HIBERNATE); - } - } - } - return NOTIFY_DONE; -} -#endif From e75e8cacba0ea26571f6ce5145c6d0a235161454 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 16 Jun 2015 23:43:12 +0100 Subject: [PATCH 1074/1163] staging: vt6655: use module_pci_driver helper Remove vt6655_init_module and vt6655_cleanup_module and replace module_pci_driver Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index c393b737ce6c..0bfc9390bbb5 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1878,19 +1878,4 @@ static struct pci_driver device_driver = { #endif }; -static int __init vt6655_init_module(void) -{ - int ret; - - ret = pci_register_driver(&device_driver); - - return ret; -} - -static void __exit vt6655_cleanup_module(void) -{ - pci_unregister_driver(&device_driver); -} - -module_init(vt6655_init_module); -module_exit(vt6655_cleanup_module); +module_pci_driver(device_driver); From b62b54378c4a3badbab2c76c12b44b67d94af215 Mon Sep 17 00:00:00 2001 From: Hari Prasath Gujulan Elango Date: Wed, 17 Jun 2015 07:26:59 +0000 Subject: [PATCH 1075/1163] staging: slicoss: remove unused macro This patch removes a couple of ununsed MACRO's in this header file Signed-off-by: Hari Prasath Gujulan Elango Signed-off-by: Greg Kroah-Hartman --- drivers/staging/slicoss/slic.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h index 67a8c9eb2dca..00b8af63e7ff 100644 --- a/drivers/staging/slicoss/slic.h +++ b/drivers/staging/slicoss/slic.h @@ -514,8 +514,6 @@ struct adapter { #define FLUSH true #define DONT_FLUSH false -#define SIOCSLICDUMPCARD (SIOCDEVPRIVATE+9) #define SIOCSLICSETINTAGG (SIOCDEVPRIVATE+10) -#define SIOCSLICTRACEDUMP (SIOCDEVPRIVATE+11) #endif /* __SLIC_DRIVER_H__ */ From 716baa7b430c66187a41e4d41eedf5de01343b21 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Tue, 16 Jun 2015 23:13:21 +0800 Subject: [PATCH 1076/1163] staging: nvec: remove duplicated const Sparse checking warning: "drivers/staging/nvec/nvec_ps2.c:172:14: warning: duplicate const". Remove the duplicated const to fix the warning. Signed-off-by: Peng Fan Acked-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec_ps2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/nvec/nvec_ps2.c b/drivers/staging/nvec/nvec_ps2.c index 6ebbc82323c3..0922dd3a08d3 100644 --- a/drivers/staging/nvec/nvec_ps2.c +++ b/drivers/staging/nvec/nvec_ps2.c @@ -169,8 +169,8 @@ static int nvec_mouse_resume(struct device *dev) } #endif -static const SIMPLE_DEV_PM_OPS(nvec_mouse_pm_ops, nvec_mouse_suspend, - nvec_mouse_resume); +static SIMPLE_DEV_PM_OPS(nvec_mouse_pm_ops, nvec_mouse_suspend, + nvec_mouse_resume); static struct platform_driver nvec_mouse_driver = { .probe = nvec_mouse_probe, From 4c05c50d727c992223dc024b79b9f3f30d6c9b54 Mon Sep 17 00:00:00 2001 From: Hari Prasath Gujulan Elango Date: Tue, 16 Jun 2015 14:15:46 +0000 Subject: [PATCH 1077/1163] staging: comedi: use BIT macro for bit shift operation This patch silences the Checkpatch.pl warning 'Prefer using the BIT macro' Signed-off-by: Hari Prasath Gujulan Elango Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedidev.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 28f26062a54c..28a5d3a037a1 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -227,12 +227,12 @@ struct comedi_async { * @COMEDI_CB_ERROR_MASK: events that indicate an error has occurred * @COMEDI_CB_CANCEL_MASK: events that will cancel an async command */ -#define COMEDI_CB_EOS (1 << 0) -#define COMEDI_CB_EOA (1 << 1) -#define COMEDI_CB_BLOCK (1 << 2) -#define COMEDI_CB_EOBUF (1 << 3) -#define COMEDI_CB_ERROR (1 << 4) -#define COMEDI_CB_OVERFLOW (1 << 5) +#define COMEDI_CB_EOS BIT(0) +#define COMEDI_CB_EOA BIT(1) +#define COMEDI_CB_BLOCK BIT(2) +#define COMEDI_CB_EOBUF BIT(3) +#define COMEDI_CB_ERROR BIT(4) +#define COMEDI_CB_OVERFLOW BIT(5) #define COMEDI_CB_ERROR_MASK (COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW) #define COMEDI_CB_CANCEL_MASK (COMEDI_CB_EOA | COMEDI_CB_ERROR_MASK) From d46bc00c3fac4c1066dd88582f215187436d1711 Mon Sep 17 00:00:00 2001 From: Hari Prasath Gujulan Elango Date: Tue, 16 Jun 2015 13:43:50 +0000 Subject: [PATCH 1078/1163] staging: comedi: amplc_pci230: rename 'todo' variable This patch renames the very generic variable name 'todo' to nsamples. Signed-off-by: Hari Prasath Gujulan Elango Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci230.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 20d592002557..42e4923bcf03 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -2011,17 +2011,17 @@ static void pci230_handle_ai(struct comedi_device *dev, struct comedi_cmd *cmd = &async->cmd; unsigned int status_fifo; unsigned int i; - unsigned int todo; + unsigned int nsamples; unsigned int fifoamount; unsigned short val; /* Determine number of samples to read. */ - todo = comedi_nsamples_left(s, PCI230_ADC_FIFOLEVEL_HALFFULL); - if (todo == 0) + nsamples = comedi_nsamples_left(s, PCI230_ADC_FIFOLEVEL_HALFFULL); + if (nsamples == 0) return; fifoamount = 0; - for (i = 0; i < todo; i++) { + for (i = 0; i < nsamples; i++) { if (fifoamount == 0) { /* Read FIFO state. */ status_fifo = inw(devpriv->daqio + PCI230_ADCCON); From 0c027bc378932fa3208c3d847cc1d9b2b98ad725 Mon Sep 17 00:00:00 2001 From: Abdul Hussain Date: Tue, 16 Jun 2015 07:04:51 +0000 Subject: [PATCH 1079/1163] Staging: lustre: Use memdup_user rather than duplicating its implementation This patch uses memdup_user rather than duplicating its implementation Signed-off-by: Abdul Hussain Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/file.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 4f9b1c796285..3075db211106 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -2361,14 +2361,9 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct hsm_state_set *hss; int rc; - hss = kzalloc(sizeof(*hss), GFP_NOFS); - if (!hss) - return -ENOMEM; - - if (copy_from_user(hss, (char *)arg, sizeof(*hss))) { - kfree(hss); - return -EFAULT; - } + hss = memdup_user((char *)arg, sizeof(*hss)); + if (IS_ERR(hss)) + return PTR_ERR(hss); rc = ll_hsm_state_set(inode, hss); @@ -2488,14 +2483,9 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case LL_IOC_HSM_IMPORT: { struct hsm_user_import *hui; - hui = kzalloc(sizeof(*hui), GFP_NOFS); - if (!hui) - return -ENOMEM; - - if (copy_from_user(hui, (void *)arg, sizeof(*hui))) { - kfree(hui); - return -EFAULT; - } + hui = memdup_user((void *)arg, sizeof(*hui)); + if (IS_ERR(hui)) + return PTR_ERR(hui); rc = ll_hsm_import(inode, file, hui); From 4a07594e702cfa12efb2177c9a2eb347c7cb84f9 Mon Sep 17 00:00:00 2001 From: Abdul Hussain Date: Tue, 16 Jun 2015 07:05:17 +0000 Subject: [PATCH 1080/1163] Staging: lustre: Use memdup_user rather than duplicating its implementation This patch uses memdup_user rather than duplicating its implementation Signed-off-by: Abdul Hussain Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dir.c | 32 +++++++---------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index c2eb4f2ea5b5..3d746a94f92e 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -1747,15 +1747,9 @@ out_quotactl: struct hsm_user_request *hur; ssize_t totalsize; - hur = kzalloc(sizeof(*hur), GFP_NOFS); - if (!hur) - return -ENOMEM; - - /* We don't know the true size yet; copy the fixed-size part */ - if (copy_from_user(hur, (void *)arg, sizeof(*hur))) { - kfree(hur); - return -EFAULT; - } + hur = memdup_user((void *)arg, sizeof(*hur)); + if (IS_ERR(hur)) + return PTR_ERR(hur); /* Compute the whole struct size */ totalsize = hur_len(hur); @@ -1833,13 +1827,9 @@ out_quotactl: struct hsm_copy *copy; int rc; - copy = kzalloc(sizeof(*copy), GFP_NOFS); - if (!copy) - return -ENOMEM; - if (copy_from_user(copy, (char *)arg, sizeof(*copy))) { - kfree(copy); - return -EFAULT; - } + copy = memdup_user((char *)arg, sizeof(*copy)); + if (IS_ERR(copy)) + return PTR_ERR(copy); rc = ll_ioc_copy_start(inode->i_sb, copy); if (copy_to_user((char *)arg, copy, sizeof(*copy))) @@ -1852,13 +1842,9 @@ out_quotactl: struct hsm_copy *copy; int rc; - copy = kzalloc(sizeof(*copy), GFP_NOFS); - if (!copy) - return -ENOMEM; - if (copy_from_user(copy, (char *)arg, sizeof(*copy))) { - kfree(copy); - return -EFAULT; - } + copy = memdup_user((char *)arg, sizeof(*copy)); + if (IS_ERR(copy)) + return PTR_ERR(copy); rc = ll_ioc_copy_end(inode->i_sb, copy); if (copy_to_user((char *)arg, copy, sizeof(*copy))) From 79b45a0ff001946378f9c36469487326a0e9d2b2 Mon Sep 17 00:00:00 2001 From: Maxime Lorrillere Date: Tue, 16 Jun 2015 11:35:28 +0200 Subject: [PATCH 1081/1163] staging:lustre fix lines starting with spaces in libcfs/hash.c This patch fixes lines starting with spaces. Signed-off-by: Maxime Lorrillere Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/libcfs/hash.c | 32 ++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/lustre/lustre/libcfs/hash.c b/drivers/staging/lustre/lustre/libcfs/hash.c index a55567e0de9e..0ed063145230 100644 --- a/drivers/staging/lustre/lustre/libcfs/hash.c +++ b/drivers/staging/lustre/lustre/libcfs/hash.c @@ -427,31 +427,31 @@ cfs_hash_dd_hnode_del(struct cfs_hash *hs, struct cfs_hash_bd *bd, } static cfs_hash_hlist_ops_t cfs_hash_hh_hops = { - .hop_hhead = cfs_hash_hh_hhead, - .hop_hhead_size = cfs_hash_hh_hhead_size, - .hop_hnode_add = cfs_hash_hh_hnode_add, - .hop_hnode_del = cfs_hash_hh_hnode_del, + .hop_hhead = cfs_hash_hh_hhead, + .hop_hhead_size = cfs_hash_hh_hhead_size, + .hop_hnode_add = cfs_hash_hh_hnode_add, + .hop_hnode_del = cfs_hash_hh_hnode_del, }; static cfs_hash_hlist_ops_t cfs_hash_hd_hops = { - .hop_hhead = cfs_hash_hd_hhead, - .hop_hhead_size = cfs_hash_hd_hhead_size, - .hop_hnode_add = cfs_hash_hd_hnode_add, - .hop_hnode_del = cfs_hash_hd_hnode_del, + .hop_hhead = cfs_hash_hd_hhead, + .hop_hhead_size = cfs_hash_hd_hhead_size, + .hop_hnode_add = cfs_hash_hd_hnode_add, + .hop_hnode_del = cfs_hash_hd_hnode_del, }; static cfs_hash_hlist_ops_t cfs_hash_dh_hops = { - .hop_hhead = cfs_hash_dh_hhead, - .hop_hhead_size = cfs_hash_dh_hhead_size, - .hop_hnode_add = cfs_hash_dh_hnode_add, - .hop_hnode_del = cfs_hash_dh_hnode_del, + .hop_hhead = cfs_hash_dh_hhead, + .hop_hhead_size = cfs_hash_dh_hhead_size, + .hop_hnode_add = cfs_hash_dh_hnode_add, + .hop_hnode_del = cfs_hash_dh_hnode_del, }; static cfs_hash_hlist_ops_t cfs_hash_dd_hops = { - .hop_hhead = cfs_hash_dd_hhead, - .hop_hhead_size = cfs_hash_dd_hhead_size, - .hop_hnode_add = cfs_hash_dd_hnode_add, - .hop_hnode_del = cfs_hash_dd_hnode_del, + .hop_hhead = cfs_hash_dd_hhead, + .hop_hhead_size = cfs_hash_dd_hhead_size, + .hop_hnode_add = cfs_hash_dd_hnode_add, + .hop_hnode_del = cfs_hash_dd_hnode_del, }; static void From da2a7272e6e6071dbbe81d3ca65d9adcde5a8e23 Mon Sep 17 00:00:00 2001 From: Prasanna Karthik Date: Tue, 16 Jun 2015 13:42:02 +0000 Subject: [PATCH 1082/1163] staging:lustre:mdc: Fix return statement reported by coccinelle Modified return statement and removed local declaration no longer needed. No Compiler warnings. Signed-off-by: Prasanna Karthik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/mdc/mdc_request.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index c23511f7c142..7f208a6621e6 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -2090,7 +2090,6 @@ static int mdc_hsm_copytool_send(int len, void *val) { struct kuc_hdr *lh = (struct kuc_hdr *)val; struct hsm_action_list *hal = (struct hsm_action_list *)(lh + 1); - int rc; if (len < sizeof(*lh) + sizeof(*hal)) { CERROR("Short HSM message %d < %d\n", len, @@ -2111,9 +2110,7 @@ static int mdc_hsm_copytool_send(int len, void *val) lh->kuc_msglen, hal->hal_count, hal->hal_fsname); /* Broadcast to HSM listeners */ - rc = libcfs_kkuc_group_put(KUC_GRP_HSM, lh); - - return rc; + return libcfs_kkuc_group_put(KUC_GRP_HSM, lh); } /** From 80cf407fd48b27ebc2c1221c916d7a4c53178b89 Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Sun, 14 Jun 2015 19:59:34 -0300 Subject: [PATCH 1083/1163] staging: rtl8192u: ieee80211: Fix incorrect type in assignment Added le16_to_cpu() conversion fixing the following warning in assignment detected by sparse: drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:2157:30: warning: invalid assignment: += drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:2157:30: left side has type unsigned long drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:2157:30: right side has type restricted __le16 Signed-off-by: Gaston Gonzalez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 5fbade4cf2c4..1b11acb96233 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -2154,7 +2154,7 @@ void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device * ieee80211_sta_wakeup(ieee, 0); /* update the tx status */ - ieee->stats.tx_bytes += txb->payload_size; + ieee->stats.tx_bytes += le16_to_cpu(txb->payload_size); ieee->stats.tx_packets++; tcb_desc = (cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); if (tcb_desc->bMulticast) { From 8f1574c7c0480ea8eec86514c490810e6f3c299a Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 15 Jun 2015 21:05:56 +0200 Subject: [PATCH 1084/1163] staging: rtl8192e: Remove unused code in rtl819x_HT.h Delete unused enums, structures and macros. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_HT.h | 128 -------------------------- 1 file changed, 128 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index f7076d7ddc53..05358102cbdb 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -19,45 +19,12 @@ #ifndef _RTL819XU_HTTYPE_H_ #define _RTL819XU_HTTYPE_H_ - -#define HT_OPMODE_NO_PROTECT 0 -#define HT_OPMODE_OPTIONAL 1 -#define HT_OPMODE_40MHZ_PROTECT 2 -#define HT_OPMODE_MIXED 3 - #define MIMO_PS_STATIC 0 #define MIMO_PS_DYNAMIC 1 #define MIMO_PS_NOLIMIT 3 - - #define sHTCLng 4 - -#define HT_SUPPORTED_MCS_1SS_BITMAP 0x000000ff -#define HT_SUPPORTED_MCS_2SS_BITMAP 0x0000ff00 -#define HT_SUPPORTED_MCS_1SS_2SS_BITMAP \ - (HT_MCS_1SS_BITMAP | HT_MCS_1SS_2SS_BITMAP) - -enum ht_mcs_rate { - HT_MCS0 = 0x00000001, - HT_MCS1 = 0x00000002, - HT_MCS2 = 0x00000004, - HT_MCS3 = 0x00000008, - HT_MCS4 = 0x00000010, - HT_MCS5 = 0x00000020, - HT_MCS6 = 0x00000040, - HT_MCS7 = 0x00000080, - HT_MCS8 = 0x00000100, - HT_MCS9 = 0x00000200, - HT_MCS10 = 0x00000400, - HT_MCS11 = 0x00000800, - HT_MCS12 = 0x00001000, - HT_MCS13 = 0x00002000, - HT_MCS14 = 0x00004000, - HT_MCS15 = 0x00008000, -}; - enum ht_channel_width { HT_CHANNEL_WIDTH_20 = 0, HT_CHANNEL_WIDTH_20_40 = 1, @@ -77,27 +44,6 @@ enum chnl_op { CHNLOP_SWCHNL = 3, }; -enum ht_action { - ACT_RECOMMAND_WIDTH = 0, - ACT_MIMO_PWR_SAVE = 1, - ACT_PSMP = 2, - ACT_SET_PCO_PHASE = 3, - ACT_MIMO_CHL_MEASURE = 4, - ACT_RECIPROCITY_CORRECT = 5, - ACT_MIMO_CSI_MATRICS = 6, - ACT_MIMO_NOCOMPR_STEER = 7, - ACT_MIMO_COMPR_STEER = 8, - ACT_ANTENNA_SELECT = 9, -}; - - -enum ht_bw40_sc { - SC_MODE_DUPLICATE = 0, - SC_MODE_LOWER = 1, - SC_MODE_UPPER = 2, - SC_MODE_FULL40MHZ = 3, -}; - struct ht_capab_ele { u8 AdvCoding:1; @@ -158,12 +104,6 @@ struct ht_info_ele { u8 BasicMSC[16]; } __packed; -struct mimops_ctrl { - u8 MimoPsEnable:1; - u8 MimoPsMode:1; - u8 Reserved:6; -}; - enum ht_spec_ver { HT_SPEC_VER_IEEE = 0, HT_SPEC_VER_EWC = 1, @@ -260,43 +200,6 @@ struct rt_hi_throughput { u8 bAcceptAddbaReq; } __packed; - - -struct rt_htinfo_sta_entry { - u8 bEnableHT; - - u8 bSupportCck; - - u16 AMSDU_MaxSize; - - u8 AMPDU_Factor; - u8 MPDU_Density; - - u8 HTHighestOperaRate; - - u8 bBw40MHz; - - u8 bCurTxBW40MHz; - - u8 bCurShortGI20MHz; - - u8 bCurShortGI40MHz; - - u8 MimoPs; - - u8 McsRateSet[16]; - - u8 bCurRxReorderEnable; - - u16 nAMSDU_MaxSize; - -}; - - - - - - struct bss_ht { u8 bdSupportHT; @@ -315,31 +218,6 @@ struct bss_ht { u8 bdHT1R; }; -struct mimo_rssi { - u32 EnableAntenna; - u32 AntennaA; - u32 AntennaB; - u32 AntennaC; - u32 AntennaD; - u32 Average; -}; - -struct mimo_evm { - u32 EVM1; - u32 EVM2; -}; - -struct false_alarm_stats { - u32 Cnt_Parity_Fail; - u32 Cnt_Rate_Illegal; - u32 Cnt_Crc8_fail; - u32 Cnt_Mcs_fail; - u32 Cnt_Ofdm_fail; - u32 Cnt_Cck_fail; - u32 Cnt_all; -}; - - extern u8 MCS_FILTER_ALL[16]; extern u8 MCS_FILTER_1SS[16]; @@ -347,8 +225,6 @@ extern u8 MCS_FILTER_1SS[16]; #define RATE_ADPT_2SS_MASK 0xF0 #define RATE_ADPT_MCS32_MASK 0x01 -#define IS_11N_MCS_RATE(rate) (rate&0x80) - enum ht_aggre_size { HT_AGG_SIZE_8K = 0, HT_AGG_SIZE_16K = 1, @@ -371,10 +247,6 @@ enum ht_iot_peer { HT_IOT_PEER_MAX = 11, }; -enum ht_iot_peer_subtype { - HT_IOT_PEER_ATHEROS_DIR635 = 0, -}; - enum ht_iot_action { HT_IOT_ACT_TX_USE_AMSDU_4K = 0x00000001, HT_IOT_ACT_TX_USE_AMSDU_8K = 0x00000002, From b27c7160c52bec835e4a439f29feecc0360f301e Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 15 Jun 2015 21:05:57 +0200 Subject: [PATCH 1085/1163] staging: rtl8192e: Remove unused code in rtllib.h Delete macros, structure members and declarations etc. that are not referenced anywhere in code. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 448 ------------------------------ 1 file changed, 448 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 5c3a9793171b..f2f7efb94121 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -261,28 +261,6 @@ struct sw_chnl_cmd { #define MGN_MCS14_SG 0x9e #define MGN_MCS15_SG 0x9f -enum hal_def_variable { - HAL_DEF_TPC_ENABLE, - HAL_DEF_INIT_GAIN, - HAL_DEF_PROT_IMP_MODE, - HAL_DEF_HIGH_POWER_MECHANISM, - HAL_DEF_RATE_ADAPTIVE_MECHANISM, - HAL_DEF_ANTENNA_DIVERSITY_MECHANISM, - HAL_DEF_LED, - HAL_DEF_CW_MAX_MIN, - - HAL_DEF_WOWLAN, - HAL_DEF_ENDPOINTS, - HAL_DEF_MIN_TX_POWER_DBM, - HAL_DEF_MAX_TX_POWER_DBM, - HW_DEF_EFUSE_REPG_SECTION1_FLAG, - HW_DEF_EFUSE_REPG_DATA, - HW_DEF_GPIO, - HAL_DEF_PCI_SUPPORT_ASPM, - HAL_DEF_THERMAL_VALUE, - HAL_DEF_USB_IN_TOKEN_REV, -}; - enum hw_variables { HW_VAR_ETHER_ADDR, HW_VAR_MULTICAST_REG, @@ -401,27 +379,14 @@ enum rt_op_mode { #define IEEE_PARAM_AUTH_ALGS 5 #define IEEE_PARAM_IEEE_802_1X 6 #define IEEE_PARAM_WPAX_SELECT 7 -#define IEEE_PROTO_WPA 1 -#define IEEE_PROTO_RSN 2 -#define IEEE_WPAX_USEGROUP 0 -#define IEEE_WPAX_WEP40 1 -#define IEEE_WPAX_TKIP 2 -#define IEEE_WPAX_WRAP 3 -#define IEEE_WPAX_CCMP 4 -#define IEEE_WPAX_WEP104 5 - -#define IEEE_KEY_MGMT_IEEE8021X 1 -#define IEEE_KEY_MGMT_PSK 2 #define IEEE_MLME_STA_DEAUTH 1 #define IEEE_MLME_STA_DISASSOC 2 #define IEEE_CRYPT_ERR_UNKNOWN_ALG 2 -#define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3 #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4 #define IEEE_CRYPT_ERR_KEY_SET_FAILED 5 -#define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6 #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7 #define IEEE_CRYPT_ALG_NAME_LEN 16 @@ -468,7 +433,6 @@ struct ieee_param { #define msleep_interruptible_rsl msleep_interruptible -#define RTLLIB_DATA_LEN 2304 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section * 6.2.1.1.2. * @@ -482,23 +446,13 @@ struct ieee_param { #define RTLLIB_3ADDR_LEN 24 #define RTLLIB_4ADDR_LEN 30 #define RTLLIB_FCS_LEN 4 -#define RTLLIB_HLEN (RTLLIB_4ADDR_LEN) -#define RTLLIB_FRAME_LEN (RTLLIB_DATA_LEN + RTLLIB_HLEN) -#define RTLLIB_MGMT_HDR_LEN 24 -#define RTLLIB_DATA_HDR3_LEN 24 -#define RTLLIB_DATA_HDR4_LEN 30 #define RTLLIB_SKBBUFFER_SIZE 2500 #define MIN_FRAG_THRESHOLD 256U #define MAX_FRAG_THRESHOLD 2346U -#define MAX_HT_DATA_FRAG_THRESHOLD 0x2000 - -#define HT_AMSDU_SIZE_4K 3839 -#define HT_AMSDU_SIZE_8K 7935 /* Frame control field constants */ -#define RTLLIB_FCTL_VERS 0x0003 #define RTLLIB_FCTL_FTYPE 0x000c #define RTLLIB_FCTL_STYPE 0x00f0 #define RTLLIB_FCTL_FRAMETYPE 0x00fc @@ -535,9 +489,6 @@ struct ieee_param { #define RTLLIB_STYPE_RTS 0x00B0 #define RTLLIB_STYPE_CTS 0x00C0 #define RTLLIB_STYPE_ACK 0x00D0 -#define RTLLIB_STYPE_CFEND 0x00E0 -#define RTLLIB_STYPE_CFENDACK 0x00F0 -#define RTLLIB_STYPE_BLOCKACK 0x0094 /* data */ #define RTLLIB_STYPE_DATA 0x0000 @@ -545,9 +496,6 @@ struct ieee_param { #define RTLLIB_STYPE_DATA_CFPOLL 0x0020 #define RTLLIB_STYPE_DATA_CFACKPOLL 0x0030 #define RTLLIB_STYPE_NULLFUNC 0x0040 -#define RTLLIB_STYPE_CFACK 0x0050 -#define RTLLIB_STYPE_CFPOLL 0x0060 -#define RTLLIB_STYPE_CFACKPOLL 0x0070 #define RTLLIB_STYPE_QOS_DATA 0x0080 #define RTLLIB_STYPE_QOS_NULL 0x00C0 @@ -576,13 +524,6 @@ enum act_category { ACT_CAT_WMM = 17, }; -enum ts_action { - ACT_ADDTSREQ = 0, - ACT_ADDTSRSP = 1, - ACT_DELTS = 2, - ACT_SCHEDULE = 3, -}; - enum ba_action { ACT_ADDBAREQ = 0, ACT_ADDBARSP = 1, @@ -604,20 +545,11 @@ enum led_ctl_mode { 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, - LED_CTL_STOP_WPS_FAIL = 12, - LED_CTL_STOP_WPS_FAIL_OVERLAP = 13, }; enum rt_rf_type_def { RF_1T2R = 0, RF_2T4R, - RF_2T2R, - RF_1T1R, - RF_2T2R_GREEN, - RF_819X_MAX_TYPE }; enum wireless_mode { @@ -630,25 +562,12 @@ enum wireless_mode { WIRELESS_MODE_N_5G = 0x20 }; -enum wireless_network_type { - WIRELESS_11B = 1, - WIRELESS_11G = 2, - WIRELESS_11A = 4, - WIRELESS_11N = 8 -}; - -#define OUI_SUBTYPE_WMM_INFO 0 -#define OUI_SUBTYPE_WMM_PARAM 1 -#define OUI_SUBTYPE_QOS_CAPABI 5 - #ifndef ETH_P_PAE #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 */ #endif /* ETH_P_PAE */ -#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */ - #ifndef ETH_P_80211_RAW #define ETH_P_80211_RAW (ETH_P_ECONET + 1) #endif @@ -674,7 +593,6 @@ enum _REG_PREAMBLE_MODE { #define SNAP_SIZE sizeof(struct rtllib_snap_hdr) -#define WLAN_FC_GET_VERS(fc) ((fc) & RTLLIB_FCTL_VERS) #define WLAN_FC_GET_TYPE(fc) ((fc) & RTLLIB_FCTL_FTYPE) #define WLAN_FC_GET_STYPE(fc) ((fc) & RTLLIB_FCTL_STYPE) #define WLAN_FC_MORE_DATA(fc) ((fc) & RTLLIB_FCTL_MOREDATA) @@ -688,30 +606,15 @@ enum _REG_PREAMBLE_MODE { #define WLAN_AUTH_SHARED_KEY 1 #define WLAN_AUTH_LEAP 128 -#define WLAN_AUTH_CHALLENGE_LEN 128 - #define WLAN_CAPABILITY_ESS (1<<0) #define WLAN_CAPABILITY_IBSS (1<<1) -#define WLAN_CAPABILITY_CF_POLLABLE (1<<2) -#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3) #define WLAN_CAPABILITY_PRIVACY (1<<4) #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5) -#define WLAN_CAPABILITY_PBCC (1<<6) -#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7) -#define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8) -#define WLAN_CAPABILITY_QOS (1<<9) #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10) -#define WLAN_CAPABILITY_DSSS_OFDM (1<<13) - -/* 802.11g ERP information element */ -#define WLAN_ERP_NON_ERP_PRESENT (1<<0) -#define WLAN_ERP_USE_PROTECTION (1<<1) -#define WLAN_ERP_BARKER_PREAMBLE (1<<2) #define RTLLIB_STATMASK_SIGNAL (1<<0) #define RTLLIB_STATMASK_RSSI (1<<1) #define RTLLIB_STATMASK_NOISE (1<<2) -#define RTLLIB_STATMASK_RATE (1<<3) #define RTLLIB_STATMASK_WEMASK 0x7 #define RTLLIB_CCK_MODULATION (1<<0) @@ -736,44 +639,6 @@ enum _REG_PREAMBLE_MODE { #define RTLLIB_OFDM_RATE_54MB 0x6C #define RTLLIB_BASIC_RATE_MASK 0x80 -#define RTLLIB_CCK_RATE_1MB_MASK (1<<0) -#define RTLLIB_CCK_RATE_2MB_MASK (1<<1) -#define RTLLIB_CCK_RATE_5MB_MASK (1<<2) -#define RTLLIB_CCK_RATE_11MB_MASK (1<<3) -#define RTLLIB_OFDM_RATE_6MB_MASK (1<<4) -#define RTLLIB_OFDM_RATE_9MB_MASK (1<<5) -#define RTLLIB_OFDM_RATE_12MB_MASK (1<<6) -#define RTLLIB_OFDM_RATE_18MB_MASK (1<<7) -#define RTLLIB_OFDM_RATE_24MB_MASK (1<<8) -#define RTLLIB_OFDM_RATE_36MB_MASK (1<<9) -#define RTLLIB_OFDM_RATE_48MB_MASK (1<<10) -#define RTLLIB_OFDM_RATE_54MB_MASK (1<<11) - -#define RTLLIB_CCK_RATES_MASK 0x0000000F -#define RTLLIB_CCK_BASIC_RATES_MASK (RTLLIB_CCK_RATE_1MB_MASK | \ - RTLLIB_CCK_RATE_2MB_MASK) -#define RTLLIB_CCK_DEFAULT_RATES_MASK (RTLLIB_CCK_BASIC_RATES_MASK | \ - RTLLIB_CCK_RATE_5MB_MASK | \ - RTLLIB_CCK_RATE_11MB_MASK) - -#define RTLLIB_OFDM_RATES_MASK 0x00000FF0 -#define RTLLIB_OFDM_BASIC_RATES_MASK (RTLLIB_OFDM_RATE_6MB_MASK | \ - RTLLIB_OFDM_RATE_12MB_MASK | \ - RTLLIB_OFDM_RATE_24MB_MASK) -#define RTLLIB_OFDM_DEFAULT_RATES_MASK (RTLLIB_OFDM_BASIC_RATES_MASK | \ - RTLLIB_OFDM_RATE_9MB_MASK | \ - RTLLIB_OFDM_RATE_18MB_MASK | \ - RTLLIB_OFDM_RATE_36MB_MASK | \ - RTLLIB_OFDM_RATE_48MB_MASK | \ - RTLLIB_OFDM_RATE_54MB_MASK) -#define RTLLIB_DEFAULT_RATES_MASK (RTLLIB_OFDM_DEFAULT_RATES_MASK | \ - RTLLIB_CCK_DEFAULT_RATES_MASK) - -#define RTLLIB_NUM_OFDM_RATES 8 -#define RTLLIB_NUM_CCK_RATES 4 -#define RTLLIB_OFDM_SHIFT_MASK_A 4 - - /* this is stolen and modified from the madwifi driver*/ #define RTLLIB_FC0_TYPE_MASK 0x0c #define RTLLIB_FC0_TYPE_DATA 0x08 @@ -829,7 +694,6 @@ struct rtllib_rx_stats { u32 TimeStampHigh; bool bShift; bool bIsQosData; - u8 UserPriority; u8 RxDrvInfoSize; u8 RxBufShift; @@ -843,17 +707,13 @@ struct rtllib_rx_stats { bool bPacketMatchBSSID; bool bIsCCK; bool bPacketToSelf; - u8 *virtual_address; u16 packetlength; u16 fraglength; u16 fragoffset; u16 ntotalfrag; - bool bisrxaggrsubframe; bool bPacketBeacon; bool bToSelfBA; - char cck_adc_pwdb[4]; u16 Seq_Num; - u8 nTotalAggPkt; }; /* IEEE 802.11 requires that STA supports concurrent reception of at least @@ -1111,15 +971,6 @@ struct rtllib_assoc_request_frame { struct rtllib_info_element info_element[0]; } __packed; -struct rtllib_reassoc_request_frame { - struct rtllib_hdr_3addr header; - __le16 capability; - __le16 listen_interval; - u8 current_ap[ETH_ALEN]; - /* SSID, supported rates, RSN */ - struct rtllib_info_element info_element[0]; -} __packed; - struct rtllib_assoc_response_frame { struct rtllib_hdr_3addr header; __le16 capability; @@ -1139,12 +990,6 @@ struct rtllib_txb { struct sk_buff *fragments[0]; }; -#define MAX_TX_AGG_COUNT 16 -struct rtllib_drv_agg_txb { - u8 nr_drv_agg_frames; - struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT]; -} __packed; - #define MAX_SUBFRAME_COUNT 64 struct rtllib_rxb { u8 nr_subframes; @@ -1165,9 +1010,6 @@ union frameqos { } field; }; -/* SWEEP TABLE ENTRIES NUMBER*/ -#define MAX_SWEEP_TAB_ENTRIES 42 -#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7 /* 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 @@ -1181,8 +1023,6 @@ union frameqos { #define RTLLIB_SOFTMAC_SCAN_TIME 100 #define RTLLIB_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2) -#define CRC_LENGTH 4U - #define MAX_WPA_IE_LEN 64 #define MAX_WZC_IE_LEN 256 @@ -1196,12 +1036,6 @@ union frameqos { #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \ NETWORK_HAS_QOS_INFORMATION) /* 802.11h */ -#define NETWORK_HAS_POWER_CONSTRAINT (1<<5) -#define NETWORK_HAS_CSA (1<<6) -#define NETWORK_HAS_QUIET (1<<7) -#define NETWORK_HAS_IBSS_DFS (1<<8) -#define NETWORK_HAS_TPC_REPORT (1<<9) - #define NETWORK_HAS_ERP_VALUE (1<<10) #define QOS_QUEUE_NUM 4 @@ -1211,7 +1045,6 @@ union frameqos { #define QOS_OUI_INFO_SUB_TYPE 0 #define QOS_OUI_PARAM_SUB_TYPE 1 #define QOS_VERSION_1 1 -#define QOS_AIFSN_MIN_VALUE 2 struct rtllib_qos_information_element { u8 elementID; @@ -1263,31 +1096,6 @@ struct rtllib_wmm_ac_param { u16 ac_txop_limit; }; -struct rtllib_wmm_ts_info { - u8 ac_dir_tid; - u8 ac_up_psb; - u8 reserved; -} __packed; - -struct rtllib_wmm_tspec_elem { - struct rtllib_wmm_ts_info ts_info; - u16 norm_msdu_size; - u16 max_msdu_size; - u32 min_serv_inter; - u32 max_serv_inter; - u32 inact_inter; - u32 suspen_inter; - u32 serv_start_time; - u32 min_data_rate; - u32 mean_data_rate; - u32 peak_data_rate; - u32 max_burst_size; - u32 delay_bound; - u32 min_phy_rate; - u16 surp_band_allow; - u16 medium_time; -} __packed; - enum eap_type { EAP_PACKET = 0, EAPOL_START, @@ -1352,13 +1160,6 @@ struct rtllib_softmac_stats { unsigned int txretrycount; }; -#define BEACON_PROBE_SSID_ID_POSITION 12 - -struct rtllib_info_element_hdr { - u8 id; - u8 len; -} __packed; - /* These are the data types that can make up management packets * * u16 auth_algorithm; @@ -1409,12 +1210,6 @@ enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame}; ((up) < 6) ? WME_AC_VI : \ WME_AC_VO) -#define AC2UP(_ac) ( \ - ((_ac) == WME_AC_VO) ? 6 : \ - ((_ac) == WME_AC_VI) ? 5 : \ - ((_ac) == WME_AC_BK) ? 1 : \ - 0) - #define ETHER_ADDR_LEN 6 /* length of an Ethernet address */ #define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address * plus ether type*/ @@ -1425,14 +1220,6 @@ struct ether_header { u16 ether_type; } __packed; -#ifndef ETHERTYPE_PAE -#define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */ -#endif -#ifndef ETHERTYPE_IP -#define ETHERTYPE_IP 0x0800 /* IP protocol */ -#endif - - enum erp_t { ERP_NonERPpresent = 0x01, ERP_UseProtection = 0x02, @@ -1503,7 +1290,6 @@ struct rtllib_network { bool unknown_cap_exist; bool berp_info_valid; bool buseprotection; - bool bIsNetgear854T; u8 SignalStrength; u8 RSSI; struct list_head list; @@ -1552,17 +1338,7 @@ enum rtllib_state { #define CFG_RTLLIB_RESERVE_FCS (1<<0) #define CFG_RTLLIB_COMPUTE_FCS (1<<1) -#define CFG_RTLLIB_RTS (1<<2) -#define RTLLIB_24GHZ_MIN_CHANNEL 1 -#define RTLLIB_24GHZ_MAX_CHANNEL 14 -#define RTLLIB_24GHZ_CHANNELS (RTLLIB_24GHZ_MAX_CHANNEL - \ - RTLLIB_24GHZ_MIN_CHANNEL + 1) - -#define RTLLIB_52GHZ_MIN_CHANNEL 34 -#define RTLLIB_52GHZ_MAX_CHANNEL 165 -#define RTLLIB_52GHZ_CHANNELS (RTLLIB_52GHZ_MAX_CHANNEL - \ - RTLLIB_52GHZ_MIN_CHANNEL + 1) struct tx_pending { int frag; struct rtllib_txb *txb; @@ -1623,9 +1399,6 @@ enum rt_rf_power_state { #define MAX_SUPPORT_WOL_PATTERN_NUM 8 -#define MAX_WOL_BIT_MASK_SIZE 16 -#define MAX_WOL_PATTERN_SIZE 128 - enum wol_pattern_type { eNetBIOS = 0, eIPv4IPv6ARP, @@ -1646,38 +1419,15 @@ struct rt_pwr_save_ctrl { bool bInactivePs; bool bIPSModeBackup; - bool bHaltAdapterClkRQ; bool bSwRfProcessing; enum rt_rf_power_state eInactivePowerState; - struct work_struct InactivePsWorkItem; - struct timer_list InactivePsTimer; - enum ips_callback_function ReturnPoint; - bool bTmpBssDesc; enum rt_join_action tmpJoinAction; - struct rtllib_network tmpBssDesc; - - bool bTmpScanOnly; - bool bTmpActiveScan; - bool bTmpFilterHiddenAP; - bool bTmpUpdateParms; - u8 tmpSsidBuf[33]; - struct octet_string tmpSsid2Scan; - bool bTmpSsid2Scan; - u8 tmpNetworkType; - u8 tmpChannelNumber; - u16 tmpBcnPeriod; - u8 tmpDtimPeriod; - u16 tmpmCap; - struct octet_string tmpSuppRateSet; u8 tmpSuppRateBuf[MAX_NUM_RATES]; - bool bTmpSuppRate; - struct ibss_parms tmpIbpm; bool bTmpIbpm; bool bLeisurePs; - u32 PowerProfile; u8 LpsIdleCount; u8 RegMaxLPSAwakeIntvl; u8 LPSAwakeIntvl; @@ -1686,17 +1436,7 @@ struct rt_pwr_save_ctrl { u32 RegRfPsLevel; bool bFwCtrlLPS; - u8 FWCtrlPSMode; - bool LinkReqInIPSRFOffPgs; - bool BufConnectinfoBefore; - - - bool bGpioRfSw; - - u8 RegAMDPciASPM; - - u8 oWLANMode; struct rt_pm_wol_info PmWoLPatternInfo[MAX_SUPPORT_WOL_PATTERN_NUM]; }; @@ -1757,13 +1497,6 @@ enum fw_cmd_io_type { FW_CMD_TX_FEEDBACK_CCX_ENABLE = 21, FW_CMD_LPS_ENTER = 22, FW_CMD_LPS_LEAVE = 23, - FW_CMD_DIG_MODE_SS = 24, - FW_CMD_DIG_MODE_FA = 25, - FW_CMD_ADD_A2_ENTRY = 26, - FW_CMD_CTRL_DM_BY_DRIVER = 27, - FW_CMD_CTRL_DM_BY_DRIVER_NEW = 28, - FW_CMD_PAPE_CONTROL = 29, - FW_CMD_CHAN_SET = 30, }; #define RT_MAX_LD_SLOT_NUM 10 @@ -1783,10 +1516,6 @@ struct rt_link_detect { bool bBusyTraffic; bool bHigherBusyTraffic; bool bHigherBusyRxTraffic; - u8 IdleCount; - u32 NumTxUnicastOkInPeriod; - u32 LastNumTxUnicast; - u32 LastNumRxUnicast; }; struct sw_cam_table { @@ -1823,17 +1552,6 @@ struct rate_adaptive { u8 PreRATRState; }; -enum ratr_table_mode_8192s { - 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_A = 8, -}; #define NUM_PMKID_CACHE 16 struct rt_pmkid_list { @@ -1841,8 +1559,6 @@ struct rt_pmkid_list { u8 PMKID[16]; u8 SsidBuf[33]; u8 bUsed; - u8 *ssid_octet; - u16 ssid_length; }; struct rt_intel_promisc_mode { @@ -1853,18 +1569,8 @@ struct rt_intel_promisc_mode { /*************** DRIVER STATUS *****/ #define STATUS_SCANNING 0 -#define STATUS_SCAN_HW 1 -#define STATUS_SCAN_ABORTING 2 -#define STATUS_SETTING_CHAN 3 /*************** DRIVER STATUS *****/ -enum { - NO_USE = 0, - USED = 1, - HW_SEC = 2, - SW_SEC = 3, -}; - enum { LPS_IS_WAKE = 0, LPS_IS_SLEEP = 1, @@ -1880,27 +1586,17 @@ struct rtllib_device { unsigned long status; short hwscan_ch_bk; - enum ht_extchnl_offset chan_offset_bk; - enum ht_channel_width bandwidth_bk; u8 hwscan_sem_up; u8 CntAfterLink; enum rt_op_mode OpMode; - u8 VersionID; /* The last AssocReq/Resp IEs */ u8 *assocreq_ies, *assocresp_ies; size_t assocreq_ies_len, assocresp_ies_len; - bool b_customer_lenovo_id; - bool bForcedShowRxRate; - bool bForcedShowRateStill; - u8 SystemQueryDataRateCount; bool bForcedBgMode; - bool bUseRAMask; - bool b1x1RecvCombine; u8 RF_Type; - bool b1SSSupport; u8 hwsec_active; bool is_silent_reset; @@ -1945,7 +1641,6 @@ struct rtllib_device { struct rx_ts_record RxTsRecord[TOTAL_TS_NUM]; struct rx_reorder_entry RxReorderEntry[128]; struct list_head RxReorder_Unused_List; - u8 ForcedPriority; /* Bookkeeping structures */ @@ -1964,8 +1659,6 @@ struct rtllib_device { bool bNetPromiscuousMode; struct rt_intel_promisc_mode IntelPromiscuousModeInfo; - struct iw_spy_data spy_data; - spinlock_t lock; spinlock_t wpax_suitlist_lock; @@ -1983,17 +1676,8 @@ struct rtllib_device { /* If the host performs {en,de}cryption, then set to 1 */ int host_encrypt; - int host_encrypt_msdu; int host_decrypt; - /* host performs multicast decryption */ - int host_mc_decrypt; - /* host should strip IV and ICV from protected frames */ - /* meaningful only when hardware decryption is being used */ - int host_strip_iv_icv; - - int host_open_frag; - int host_build_iv; int ieee802_1x; /* is IEEE 802.1X used */ /* WPA data */ @@ -2014,8 +1698,6 @@ struct rtllib_device { struct lib80211_crypt_info crypt_info; struct sw_cam_table swcamtable[TOTAL_CAM_ENTRY]; - int bcrx_sta_key; /* use individual keys to override default keys even - * with RX of broad/multicast frames */ struct rt_pmkid_list PMKIDList[NUM_PMKID_CACHE]; @@ -2044,21 +1726,15 @@ struct rtllib_device { enum rtllib_state state; int short_slot; - int reg_mode; int mode; /* A, B, G */ int modulation; /* CCK, OFDM */ int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ - int abg_true; /* ABG flag */ /* used for forcing the ibss workqueue to terminate * without wait for the syncro scan to terminate */ short sync_scan_hurryup; u16 scan_watch_dog; - int perfect_rssi; - int worst_rssi; - - u16 prev_seq_ctl; /* used to drop duplicate frames */ /* map of allowed channels. 0 is dummy */ void *pDot11dInfo; @@ -2070,7 +1746,6 @@ struct rtllib_device { int rate; /* current rate */ int basic_rate; - u32 currentRate; short active_scan; @@ -2116,7 +1791,6 @@ struct rtllib_device { short ssid_set; /* set on initialization */ - u8 qos_support; unsigned int wmm_acm; /* for discarding duplicated packets in IBSS */ @@ -2136,16 +1810,12 @@ struct rtllib_device { struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM]; int mgmt_queue_head; int mgmt_queue_tail; -#define RTLLIB_QUEUE_LIMIT 128 u8 AsocRetryCount; - unsigned int hw_header; struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE]; struct sk_buff_head skb_aggQ[MAX_QUEUE_SIZE]; - struct sk_buff_head skb_drv_aggQ[MAX_QUEUE_SIZE]; u32 sta_edca_param[4]; bool aggregation; bool enable_rx_imm_BA; - bool bibsscoordinator; bool bdynamic_txpower_enable; @@ -2168,7 +1838,6 @@ struct rtllib_device { struct rt_link_detect LinkDetectInfo; bool bIsAggregateFrame; struct rt_pwr_save_ctrl PowerSaveControl; - u8 amsdu_in_process; /* used if IEEE_SOFTMAC_TX_QUEUE is set */ struct tx_pending tx_pending; @@ -2215,11 +1884,6 @@ struct rtllib_device { struct net_device *dev); int (*reset_port)(struct net_device *dev); - int (*is_queue_full)(struct net_device *dev, int pri); - - int (*handle_management)(struct net_device *dev, - struct rtllib_network *network, u16 type); - int (*is_qos_active)(struct net_device *dev, struct sk_buff *skb); /* Softmac-generated frames (management) are TXed via this * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is @@ -2255,25 +1919,6 @@ struct rtllib_device { */ void (*set_chan)(struct net_device *dev, short ch); - /* These are not used if the ieee stack takes care of - * scanning (IEEE_SOFTMAC_SCAN feature set). - * In this case only the set_chan is used. - * - * The syncro version is similar to the start_scan but - * does not return until all channels has been scanned. - * this is called in user context and should sleep, - * it is called in a work_queue when switching to ad-hoc mode - * or in behalf of iwlist scan when the card is associated - * and root user ask for a scan. - * the function stop_scan should stop both the syncro and - * background scanning and can sleep. - * The function start_scan should initiate the background - * scanning and can't sleep. - */ - void (*scan_syncro)(struct net_device *dev); - void (*start_scan)(struct net_device *dev); - void (*stop_scan)(struct net_device *dev); - void (*rtllib_start_hw_scan)(struct net_device *dev); void (*rtllib_stop_hw_scan)(struct net_device *dev); @@ -2315,24 +1960,16 @@ struct rtllib_device { void (*SetWirelessMode)(struct net_device *dev, u8 wireless_mode); bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device *dev); u8 (*rtllib_ap_sec_type)(struct rtllib_device *ieee); - void (*HalUsbRxAggrHandler)(struct net_device *dev, bool Value); void (*InitialGainHandler)(struct net_device *dev, u8 Operation); bool (*SetFwCmdHandler)(struct net_device *dev, enum fw_cmd_io_type FwCmdIO); - void (*UpdateHalRAMaskHandler)(struct net_device *dev, bool bMulticast, - u8 macId, u8 MimoPs, u8 WirelessMode, - u8 bCurTxBW40MHz, u8 rssi_level); void (*UpdateBeaconInterruptHandler)(struct net_device *dev, bool start); - void (*UpdateInterruptMaskHandler)(struct net_device *dev, u32 AddMSR, - u32 RemoveMSR); - u16 (*rtl_11n_user_show_rates)(struct net_device *dev); void (*ScanOperationBackupHandler)(struct net_device *dev, u8 Operation); void (*LedControlHandler)(struct net_device *dev, enum led_ctl_mode LedAction); void (*SetHwRegHandler)(struct net_device *dev, u8 variable, u8 *val); - void (*GetHwRegHandler)(struct net_device *dev, u8 variable, u8 *val); void (*AllowAllDestAddrHandler)(struct net_device *dev, bool bAllowAllDA, bool WriteIntoReg); @@ -2409,30 +2046,6 @@ static inline int rtllib_is_empty_essid(const char *essid, int essid_len) return 1; } -static inline int rtllib_is_valid_mode(struct rtllib_device *ieee, int mode) -{ - /* It is possible for both access points and our device to support - * combinations of modes, so as long as there is one valid combination - * of ap/device supported modes, then return success - */ - if ((mode & IEEE_A) && - (ieee->modulation & RTLLIB_OFDM_MODULATION) && - (ieee->freq_band & RTLLIB_52GHZ_BAND)) - return 1; - - if ((mode & IEEE_G) && - (ieee->modulation & RTLLIB_OFDM_MODULATION) && - (ieee->freq_band & RTLLIB_24GHZ_BAND)) - return 1; - - if ((mode & IEEE_B) && - (ieee->modulation & RTLLIB_CCK_MODULATION) && - (ieee->freq_band & RTLLIB_24GHZ_BAND)) - return 1; - - return 0; -} - static inline int rtllib_get_hdrlen(u16 fc) { int hdrlen = RTLLIB_3ADDR_LEN; @@ -2508,8 +2121,6 @@ static inline int rtllib_is_cck_rate(u8 rate) extern void free_rtllib(struct net_device *dev); extern struct net_device *alloc_rtllib(int sizeof_priv); -extern int rtllib_set_encryption(struct rtllib_device *ieee); - /* rtllib_tx.c */ extern int rtllib_encrypt_fragment( @@ -2589,7 +2200,6 @@ extern void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr); extern void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl); extern void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee); -extern void rtllib_check_all_nets(struct rtllib_device *ieee); extern void rtllib_start_protocol(struct rtllib_device *ieee); extern void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown); @@ -2628,11 +2238,6 @@ extern u16 rtllib_query_seqnum(struct rtllib_device *ieee, struct sk_buff *skb, u8 *dst); extern u8 rtllib_ap_sec_type(struct rtllib_device *ieee); -/* rtllib_crypt_ccmp&tkip&wep.c */ -extern void rtllib_tkip_null(void); -extern void rtllib_wep_null(void); -extern void rtllib_ccmp_null(void); - /* rtllib_softmac_wx.c */ extern int rtllib_wx_get_wap(struct rtllib_device *ieee, @@ -2762,16 +2367,6 @@ void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh); extern const long rtllib_wlan_frequencies[]; -static inline void rtllib_increment_scans(struct rtllib_device *ieee) -{ - ieee->scans++; -} - -static inline int rtllib_get_scans(struct rtllib_device *ieee) -{ - return ieee->scans; -} - static inline const char *escape_essid(const char *essid, u8 essid_len) { static char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; @@ -2785,10 +2380,6 @@ static inline const char *escape_essid(const char *essid, u8 essid_len) return escaped; } -#define CONVERT_RATE(_ieee, _MGN_RATE) \ - ((_MGN_RATE < MGN_MCS0) ? (_MGN_RATE) : \ - (HTMcsToDataRate(_ieee, (u8)_MGN_RATE))) - /* fun with the built-in rtllib stack... */ bool rtllib_MgntDisconnect(struct rtllib_device *rtllib, u8 asRsn); @@ -2799,7 +2390,6 @@ bool rtllib_MgntDisconnect(struct rtllib_device *rtllib, u8 asRsn); extern void rtllib_update_active_chan_map(struct rtllib_device *ieee); extern void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record *pTS); -extern int rtllib_data_xmit(struct sk_buff *skb, struct net_device *dev); extern int rtllib_parse_info_param(struct rtllib_device *ieee, struct rtllib_info_element *info_element, u16 length, @@ -2815,46 +2405,8 @@ extern void HTUseDefaultSetting(struct rtllib_device *ieee); u8 MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee); extern void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p); #ifndef ENABLE_LOCK_DEBUG -#define SPIN_LOCK_IEEE(plock) spin_lock_irqsave((plock), flags) -#define SPIN_UNLOCK_IEEE(plock) spin_unlock_irqrestore((plock), flags) -#define SPIN_LOCK_IEEE_REORDER(plock) spin_lock_irqsave((plock), flags) -#define SPIN_UNLOCK_IEEE_REORDER(plock) spin_unlock_irqrestore((plock), flags) -#define SPIN_LOCK_IEEE_WPAX(plock) spin_lock_irqsave((plock), flags) -#define SPIN_UNLOCK_IEEE_WPAX(plock) spin_unlock_irqrestore((plock), flags) -#define SPIN_LOCK_IEEE_MGNTTX(plock) spin_lock_irqsave((plock), flags) -#define SPIN_UNLOCK_IEEE_MGNTTX(plock) spin_unlock_irqrestore((plock), flags) -#define SPIN_LOCK_IEEE_BCN(plock) spin_lock_irqsave((plock), flags) -#define SPIN_UNLOCK_IEEE_BCN(plock) spin_unlock_irqrestore((plock), flags) -#define SPIN_LOCK_MSH_STAINFO(plock) spin_lock_irqsave((plock), flags) -#define SPIN_UNLOCK_MSH_STAINFO(plock) spin_unlock_irqrestore((plock), flags) -#define SPIN_LOCK_MSH_PREQ(plock) spin_lock_irqsave((plock), flags) -#define SPIN_UNLOCK_MSH_PREQ(plock) spin_unlock_irqrestore((plock), flags) -#define SPIN_LOCK_MSH_QUEUE(plock) spin_lock_irqsave((plock), flags) -#define SPIN_UNLOCK_MSH_QUEUE(plock) spin_unlock_irqrestore((plock), flags) -#define SPIN_LOCK_PRIV_RFPS(plock) spin_lock_irqsave((plock), flags) -#define SPIN_UNLOCK_PRIV_RFPS(plock) spin_unlock_irqrestore((plock), flags) -#define SPIN_LOCK_PRIV_IRQTH(plock) spin_lock_irqsave((plock), flags) -#define SPIN_UNLOCK_PRIV_IRQTH(plock) spin_unlock_irqrestore((plock), flags) -#define SPIN_LOCK_PRIV_TX(plock) spin_lock_irqsave((plock), flags) -#define SPIN_UNLOCK_PRIV_TX(plock) spin_unlock_irqrestore((plock), flags) -#define SPIN_LOCK_PRIV_D3(plock) spin_lock_irqsave((plock), flags) -#define SPIN_UNLOCK_PRIV_D3(plock) spin_unlock_irqrestore((plock), flags) -#define SPIN_LOCK_PRIV_RF(plock) spin_lock_irqsave((plock), flags) -#define SPIN_UNLOCK_PRIV_RF(plock) spin_unlock_irqrestore((plock), flags) -#define SPIN_LOCK_PRIV_PS(plock) spin_lock_irqsave((plock), flags) -#define SPIN_UNLOCK_PRIV_PS(plock) spin_unlock_irqrestore((plock), flags) #define SEM_DOWN_IEEE_WX(psem) down(psem) #define SEM_UP_IEEE_WX(psem) up(psem) -#define SEM_DOWN_IEEE_SCAN(psem) down(psem) -#define SEM_UP_IEEE_SCAN(psem) up(psem) -#define SEM_DOWN_IEEE_IPS(psem) down(psem) -#define SEM_UP_IEEE_IPS(psem) up(psem) -#define SEM_DOWN_PRIV_WX(psem) down(psem) -#define SEM_UP_PRIV_WX(psem) up(psem) -#define SEM_DOWN_PRIV_RF(psem) down(psem) -#define SEM_UP_PRIV_RF(psem) up(psem) -#define MUTEX_LOCK_PRIV(pmutex) mutex_lock(pmutex) -#define MUTEX_UNLOCK_PRIV(pmutex) mutex_unlock(pmutex) #endif #endif /* RTLLIB_H */ From bcf5b92d9bbf0b7683199615f0f184e89fa486bc Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 15 Jun 2015 21:05:58 +0200 Subject: [PATCH 1086/1163] staging: rtl8192e: Remove rt_hi_throughput::ChnkOp Field was initialized and never used. This patch also removes chnl_op enum that was only referenced by ChnkOp init code. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_HT.h | 8 -------- drivers/staging/rtl8192e/rtl819x_HTProc.c | 1 - 2 files changed, 9 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index 05358102cbdb..0c263d9f7246 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -37,13 +37,6 @@ enum ht_extchnl_offset { HT_EXTCHNL_OFFSET_LOWER = 3, }; -enum chnl_op { - CHNLOP_NONE = 0, - CHNLOP_SCAN = 1, - CHNLOP_SWBW = 2, - CHNLOP_SWCHNL = 3, -}; - struct ht_capab_ele { u8 AdvCoding:1; @@ -173,7 +166,6 @@ struct rt_hi_throughput { u8 PeerBandwidth; u8 bSwBwInProgress; - enum chnl_op ChnlOp; u8 SwBwStep; u8 bRegRT2RTAggregation; diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index dcf8db1a7d29..b5c3647b0f80 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -676,7 +676,6 @@ void HTInitializeHTInfo(struct rtllib_device *ieee) sizeof(pHTInfo->PeerHTInfoBuf)); pHTInfo->bSwBwInProgress = false; - pHTInfo->ChnlOp = CHNLOP_NONE; pHTInfo->ePeerHTSpecVer = HT_SPEC_VER_IEEE; From 5c3ea2f5b94daafe9b714cd573ff4dc5b21b8153 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 15 Jun 2015 21:05:59 +0200 Subject: [PATCH 1087/1163] staging: rtl8192e: Remove ENABLE_LOCK_DEBUG reference ENABLE_LOCK_DEBUG macro was never set, so condition that used it can be resolved manually. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index f2f7efb94121..5d93f245935d 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -2404,9 +2404,7 @@ extern void HTUseDefaultSetting(struct rtllib_device *ieee); #define RT_ASOC_RETRY_LIMIT 5 u8 MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee); extern void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p); -#ifndef ENABLE_LOCK_DEBUG #define SEM_DOWN_IEEE_WX(psem) down(psem) #define SEM_UP_IEEE_WX(psem) up(psem) -#endif #endif /* RTLLIB_H */ From f52598466088295caf013713a1472588731c094f Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 15 Jun 2015 21:06:00 +0200 Subject: [PATCH 1088/1163] staging: rtl8192e: Remove rtllib_stop_queue() This function was declared but never unused. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 1 - drivers/staging/rtl8192e/rtllib_softmac.c | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 5d93f245935d..293173350ddf 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -2220,7 +2220,6 @@ extern void rtllib_softmac_start_protocol(struct rtllib_device *ieee, extern void rtllib_reset_queue(struct rtllib_device *ieee); extern void rtllib_wake_queue(struct rtllib_device *ieee); -extern void rtllib_stop_queue(struct rtllib_device *ieee); extern void rtllib_wake_all_queues(struct rtllib_device *ieee); extern void rtllib_stop_all_queues(struct rtllib_device *ieee); extern struct sk_buff *rtllib_get_beacon(struct rtllib_device *ieee); diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 7ce58e248f2d..95e739eb057c 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -2613,18 +2613,6 @@ exit: spin_unlock_irqrestore(&ieee->lock, flags); } - -void rtllib_stop_queue(struct rtllib_device *ieee) -{ - - if (!netif_queue_stopped(ieee->dev)) { - netif_stop_queue(ieee->dev); - ieee->softmac_stats.swtxstop++; - } - ieee->queue_stop = 1; - -} - void rtllib_stop_all_queues(struct rtllib_device *ieee) { unsigned int i; From 4b2f218471a63214a5e1785421eb4cf9aae0ba1d Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 15 Jun 2015 21:06:01 +0200 Subject: [PATCH 1089/1163] staging: rtl8192e: Remove rtllib_wake_queue() This function was declared but never unused. Also remove dequeue_mgmt() and rtllib_resume_tx() that are no longer used. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 1 - drivers/staging/rtl8192e/rtllib_softmac.c | 80 ----------------------- 2 files changed, 81 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 293173350ddf..b4eb24e25770 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -2219,7 +2219,6 @@ extern void rtllib_softmac_start_protocol(struct rtllib_device *ieee, u8 mesh_flag); extern void rtllib_reset_queue(struct rtllib_device *ieee); -extern void rtllib_wake_queue(struct rtllib_device *ieee); extern void rtllib_wake_all_queues(struct rtllib_device *ieee); extern void rtllib_stop_all_queues(struct rtllib_device *ieee); extern struct sk_buff *rtllib_get_beacon(struct rtllib_device *ieee); diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 95e739eb057c..a1237729938f 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -147,21 +147,6 @@ static void enqueue_mgmt(struct rtllib_device *ieee, struct sk_buff *skb) } -static struct sk_buff *dequeue_mgmt(struct rtllib_device *ieee) -{ - struct sk_buff *ret; - - if (ieee->mgmt_queue_tail == ieee->mgmt_queue_head) - return NULL; - - ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail]; - - ieee->mgmt_queue_tail = - (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM; - - return ret; -} - static void init_mgmt_queue(struct rtllib_device *ieee) { ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0; @@ -2532,30 +2517,6 @@ void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee) } -/* called with ieee->lock acquired */ -static void rtllib_resume_tx(struct rtllib_device *ieee) -{ - int i; - - for (i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; - i++) { - - if (ieee->queue_stop) { - ieee->tx_pending.frag = i; - return; - } - - ieee->softmac_data_hard_start_xmit( - ieee->tx_pending.txb->fragments[i], - ieee->dev, ieee->rate); - ieee->stats.tx_packets++; - } - - rtllib_txb_free(ieee->tx_pending.txb); - ieee->tx_pending.txb = NULL; -} - - void rtllib_reset_queue(struct rtllib_device *ieee) { unsigned long flags; @@ -2572,47 +2533,6 @@ void rtllib_reset_queue(struct rtllib_device *ieee) } EXPORT_SYMBOL(rtllib_reset_queue); -void rtllib_wake_queue(struct rtllib_device *ieee) -{ - - unsigned long flags; - struct sk_buff *skb; - struct rtllib_hdr_3addr *header; - - spin_lock_irqsave(&ieee->lock, flags); - if (!ieee->queue_stop) - goto exit; - - ieee->queue_stop = 0; - - if (ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE) { - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))) { - - header = (struct rtllib_hdr_3addr *) skb->data; - - header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); - - if (ieee->seq_ctrl[0] == 0xFFF) - ieee->seq_ctrl[0] = 0; - else - ieee->seq_ctrl[0]++; - - ieee->softmac_data_hard_start_xmit(skb, ieee->dev, - ieee->basic_rate); - } - } - if (!ieee->queue_stop && ieee->tx_pending.txb) - rtllib_resume_tx(ieee); - - if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)) { - ieee->softmac_stats.swtxawake++; - netif_wake_queue(ieee->dev); - } - -exit: - spin_unlock_irqrestore(&ieee->lock, flags); -} - void rtllib_stop_all_queues(struct rtllib_device *ieee) { unsigned int i; From 79b7d693d57bba56dcfb66e59189b98dbdc39ede Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 15 Jun 2015 21:06:02 +0200 Subject: [PATCH 1090/1163] staging: rtl8192e: Remove rtllib_is_shortslot() This function was declared but never unused. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 1 - drivers/staging/rtl8192e/rtllib_softmac.c | 5 ----- 2 files changed, 6 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index b4eb24e25770..4b6ccb8614a2 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -2170,7 +2170,6 @@ extern int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len); /* rtllib_softmac.c */ extern short rtllib_is_54g(struct rtllib_network *net); -extern short rtllib_is_shortslot(const struct rtllib_network *net); extern int rtllib_rx_frame_softmac(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats, u16 type, diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index a1237729938f..dc3fc129f7e8 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -28,11 +28,6 @@ short rtllib_is_54g(struct rtllib_network *net) return (net->rates_ex_len > 0) || (net->rates_len > 4); } -short rtllib_is_shortslot(const struct rtllib_network *net) -{ - return net->capability & WLAN_CAPABILITY_SHORT_SLOT_TIME; -} - /* returns the total length needed for placing the RATE MFIE * tag and the EXTENDED RATE MFIE tag if needed. * It encludes two bytes per tag for the tag itself and its len From 0992510c7a4e00789ea91ec9fc5f8dfd19eab8dd Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 15 Jun 2015 21:06:03 +0200 Subject: [PATCH 1091/1163] staging: rtl8192e: Remove rtllib_wx_get_encode_ext() This function was declared but never unused. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 3 -- drivers/staging/rtl8192e/rtllib_wx.c | 57 ---------------------------- 2 files changed, 60 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 4b6ccb8614a2..6d6e637fa6b4 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -2153,9 +2153,6 @@ extern int rtllib_wx_get_encode(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); #if WIRELESS_EXT >= 18 -extern int rtllib_wx_get_encode_ext(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); extern int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c index f31d864df6cc..967ba8bc80bb 100644 --- a/drivers/staging/rtl8192e/rtllib_wx.c +++ b/drivers/staging/rtl8192e/rtllib_wx.c @@ -682,63 +682,6 @@ done: } EXPORT_SYMBOL(rtllib_wx_set_encode_ext); -int rtllib_wx_get_encode_ext(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct iw_point *encoding = &wrqu->encoding; - struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; - struct lib80211_crypt_data *crypt; - int idx, max_key_len; - - max_key_len = encoding->length - sizeof(*ext); - if (max_key_len < 0) - return -EINVAL; - - idx = encoding->flags & IW_ENCODE_INDEX; - if (idx) { - if (idx < 1 || idx > NUM_WEP_KEYS) - return -EINVAL; - idx--; - } else { - idx = ieee->crypt_info.tx_keyidx; - } - if (!(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) && - (ext->alg != IW_ENCODE_ALG_WEP)) - if (idx != 0 || (ieee->iw_mode != IW_MODE_INFRA)) - return -EINVAL; - - crypt = ieee->crypt_info.crypt[idx]; - - encoding->flags = idx + 1; - memset(ext, 0, sizeof(*ext)); - - if (crypt == NULL || crypt->ops == NULL) { - ext->alg = IW_ENCODE_ALG_NONE; - ext->key_len = 0; - encoding->flags |= IW_ENCODE_DISABLED; - } else { - if (strcmp(crypt->ops->name, "R-WEP") == 0) - ext->alg = IW_ENCODE_ALG_WEP; - else if (strcmp(crypt->ops->name, "R-TKIP")) - ext->alg = IW_ENCODE_ALG_TKIP; - else if (strcmp(crypt->ops->name, "R-CCMP")) - ext->alg = IW_ENCODE_ALG_CCMP; - else - return -EINVAL; - ext->key_len = crypt->ops->get_key(ext->key, SCM_KEY_LEN, - NULL, crypt->priv); - encoding->flags |= IW_ENCODE_ENABLED; - if (ext->key_len && - (ext->alg == IW_ENCODE_ALG_TKIP || - ext->alg == IW_ENCODE_ALG_CCMP)) - ext->ext_flags |= IW_ENCODE_EXT_TX_SEQ_VALID; - - } - - return 0; -} - int rtllib_wx_set_mlme(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) From d12bc89af1c7edf0b5ad34a76e605510795d1736 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 15 Jun 2015 21:06:04 +0200 Subject: [PATCH 1092/1163] staging: rtl8192e: Remove rtllib_device::get_nic_desc_num() This function/callback was initialized and never called. rtl8192_get_nic_desc_num() function that was default implementation was also removed. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 17 ----------------- drivers/staging/rtl8192e/rtllib.h | 1 - 2 files changed, 18 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 4c53c873aff1..71289ca91fae 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -440,22 +440,6 @@ bool MgntActSet_RF_State(struct net_device *dev, return bActionAllowed; } - -static short rtl8192_get_nic_desc_num(struct net_device *dev, int prio) -{ - struct r8192_priv *priv = rtllib_priv(dev); - struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; - - /* For now, we reserved two free descriptor as a safety boundary - * between the tail and the head - */ - if ((prio == MGNT_QUEUE) && (skb_queue_len(&ring->queue) > 10)) - RT_TRACE(COMP_DBG, - "-----[%d]---------ring->idx=%d queue_len=%d---------\n", - prio, ring->idx, skb_queue_len(&ring->queue)); - return skb_queue_len(&ring->queue); -} - static short rtl8192_check_nic_enough_desc(struct net_device *dev, int prio) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1046,7 +1030,6 @@ static void rtl8192_init_priv_handler(struct net_device *dev) priv->rtllib->data_hard_stop = rtl8192_data_hard_stop; priv->rtllib->data_hard_resume = rtl8192_data_hard_resume; priv->rtllib->check_nic_enough_desc = rtl8192_check_nic_enough_desc; - priv->rtllib->get_nic_desc_num = rtl8192_get_nic_desc_num; priv->rtllib->handle_assoc_response = rtl8192_handle_assoc_response; priv->rtllib->handle_beacon = rtl8192_handle_beacon; priv->rtllib->SetWirelessMode = rtl8192_SetWirelessMode; diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 6d6e637fa6b4..22cbd45ea25b 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1952,7 +1952,6 @@ struct rtllib_device { /* check whether Tx hw resource available */ short (*check_nic_enough_desc)(struct net_device *dev, int queue_index); - short (*get_nic_desc_num)(struct net_device *dev, int queue_index); void (*SetBWModeHandler)(struct net_device *dev, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset); From 814732423fa55d0cf7a86dba663a2f2685c02a80 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 15 Jun 2015 21:06:05 +0200 Subject: [PATCH 1093/1163] staging: rtl8192e: Remove WIRELESS_EXT checks Current WIRELESS_EXT version is at least 22. Resolve ifdefs and delete dead code. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 22cbd45ea25b..f785e842335f 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -421,16 +421,6 @@ struct ieee_param { } u; }; - -#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 - #define msleep_interruptible_rsl msleep_interruptible /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section @@ -2151,11 +2141,9 @@ extern int rtllib_wx_set_encode(struct rtllib_device *ieee, extern int rtllib_wx_get_encode(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -#if WIRELESS_EXT >= 18 extern int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -#endif extern int rtllib_wx_set_auth(struct rtllib_device *ieee, struct iw_request_info *info, struct iw_param *data, char *extra); From 7f5678ee533b2e9a1c7a4c436e42607be50e0fb5 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 15 Jun 2015 21:06:06 +0200 Subject: [PATCH 1094/1163] staging: rtl8192e: Remove rtllib_network::last_associate Variable was initialized and never used. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 1 - drivers/staging/rtl8192e/rtllib_rx.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index f785e842335f..38956948b220 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1246,7 +1246,6 @@ struct rtllib_network { unsigned long last_scanned; u8 mode; u32 flags; - u32 last_associate; u32 time_stamp[2]; u16 beacon_interval; u16 listen_interval; diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 2bef1f63be79..48a188a1ad46 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -2326,7 +2326,6 @@ static inline int rtllib_network_init( /* Where to pull this? beacon->listen_interval;*/ network->listen_interval = 0x0A; network->rates_len = network->rates_ex_len = 0; - network->last_associate = 0; network->ssid_len = 0; network->hidden_ssid_len = 0; memset(network->hidden_ssid, 0, sizeof(network->hidden_ssid)); @@ -2504,7 +2503,6 @@ static inline void update_network(struct rtllib_device *ieee, dst->qos_data.active = qos_active; dst->qos_data.old_param_count = old_param; - /* dst->last_associate is not overwritten */ dst->wmm_info = src->wmm_info; if (src->wmm_param[0].ac_aci_acm_aifsn || src->wmm_param[1].ac_aci_acm_aifsn || From 6898f7d1ea5835b0d9b594f38531d8f787d2e495 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 15 Jun 2015 21:06:07 +0200 Subject: [PATCH 1095/1163] staging: rtl8192e: Remove rt_pwr_save_ctrl members Following members were removed: - tmpJoinAction - tmpSuppRateBuf - bTmpIbpm As a consequence several unused defines/enums/structs were also removed from rtllib.h Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 36 ------------------------------- 1 file changed, 36 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 38956948b220..49f31ec2646b 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1368,42 +1368,12 @@ enum ips_callback_function { IPS_CALLBACK_JOIN_REQUEST = 2, }; -enum rt_join_action { - RT_JOIN_INFRA = 1, - RT_JOIN_IBSS = 2, - RT_START_IBSS = 3, - RT_NO_ACTION = 4, -}; - -struct ibss_parms { - u16 atimWin; -}; -#define MAX_NUM_RATES 264 - enum rt_rf_power_state { eRfOn, eRfSleep, eRfOff }; -#define MAX_SUPPORT_WOL_PATTERN_NUM 8 - -enum wol_pattern_type { - eNetBIOS = 0, - eIPv4IPv6ARP, - eIPv4IPv6TCPSYN, - eMACIDOnly, - eNoDefined, -}; - -struct rt_pm_wol_info { - u32 PatternId; - u32 Mask[4]; - u16 CrcRemainder; - u8 WFMIndex; - enum wol_pattern_type PatternType; -}; - struct rt_pwr_save_ctrl { bool bInactivePs; @@ -1412,10 +1382,6 @@ struct rt_pwr_save_ctrl { enum rt_rf_power_state eInactivePowerState; enum ips_callback_function ReturnPoint; - enum rt_join_action tmpJoinAction; - u8 tmpSuppRateBuf[MAX_NUM_RATES]; - bool bTmpIbpm; - bool bLeisurePs; u8 LpsIdleCount; u8 RegMaxLPSAwakeIntvl; @@ -1426,8 +1392,6 @@ struct rt_pwr_save_ctrl { bool bFwCtrlLPS; - struct rt_pm_wol_info PmWoLPatternInfo[MAX_SUPPORT_WOL_PATTERN_NUM]; - }; #define RT_RF_CHANGE_SOURCE u32 From 48eb2b7ea64dff6e659181325a0e464994170e59 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 15 Jun 2015 21:06:08 +0200 Subject: [PATCH 1096/1163] staging: rtl8192e: Remove unused rtllib_device members Delete several members of rtllib_device including their initializers if needed. Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 6 ------ drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 1 - drivers/staging/rtl8192e/rtllib.h | 12 ------------ drivers/staging/rtl8192e/rtllib_module.c | 3 --- drivers/staging/rtl8192e/rtllib_softmac.c | 6 ------ 5 files changed, 28 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 71289ca91fae..49110d32cf88 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -1059,8 +1059,6 @@ static void rtl8192_init_priv_handler(struct net_device *dev) priv->rtllib->UpdateBeaconInterruptHandler = NULL; priv->rtllib->ScanOperationBackupHandler = PHY_ScanOperationBackup8192; - - priv->rtllib->rtllib_rfkill_poll = NULL; } static void rtl8192_init_priv_constant(struct net_device *dev) @@ -1080,7 +1078,6 @@ static void rtl8192_init_priv_variable(struct net_device *dev) priv->AcmMethod = eAcmWay2_SW; priv->dot11CurrentPreambleMode = PREAMBLE_AUTO; - priv->rtllib->hwscan_sem_up = 1; priv->rtllib->status = 0; priv->polling_timer_on = 0; priv->up_first_time = 1; @@ -1150,10 +1147,7 @@ static void rtl8192_init_priv_variable(struct net_device *dev) priv->rtllib->host_encrypt = 1; priv->rtllib->host_decrypt = 1; - priv->rtllib->dot11PowerSaveMode = eActive; priv->rtllib->fts = DEFAULT_FRAG_THRESHOLD; - priv->rtllib->MaxMssDensity = 0; - priv->rtllib->MinSpaceCfg = 0; priv->card_type = PCI; diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c index 8532e0c21e75..1b21f3835446 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c @@ -1812,7 +1812,6 @@ static void dm_init_ctstoself(struct net_device *dev) struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); priv->rtllib->bCTSToSelfEnable = true; - priv->rtllib->CTSToSelfTH = CTSToSelfTHVal; } static void dm_ctstoself(struct net_device *dev) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 49f31ec2646b..f3a4bbc35f80 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1538,8 +1538,6 @@ struct rtllib_device { bool disable_mgnt_queue; unsigned long status; - short hwscan_ch_bk; - u8 hwscan_sem_up; u8 CntAfterLink; enum rt_op_mode OpMode; @@ -1557,7 +1555,6 @@ struct rtllib_device { bool ieee_up; bool cannot_notify; bool bSupportRemoteWakeUp; - enum rt_ps_mode dot11PowerSaveMode; bool actscanning; bool FirstIe_InScan; bool be_scan_inprogress; @@ -1567,7 +1564,6 @@ struct rtllib_device { bool is_set_key; bool wx_set_enc; struct rt_hi_throughput *pHTInfo; - spinlock_t bw_spinlock; spinlock_t reorder_spinlock; u8 Regdot11HTOperationalRateSet[16]; @@ -1576,12 +1572,9 @@ struct rtllib_device { u8 RegHTSuppRateSet[16]; u8 HTCurrentOperaRate; u8 HTHighestOperaRate; - u8 MinSpaceCfg; - u8 MaxMssDensity; u8 bTxDisableRateFallBack; u8 bTxUseDriverAssingedRate; u8 bTxEnableFwCalcDur; - atomic_t atm_chnlop; atomic_t atm_swbw; struct list_head Tx_TS_Admit_List; @@ -1634,7 +1627,6 @@ struct rtllib_device { int ieee802_1x; /* is IEEE 802.1X used */ /* WPA data */ - bool bHalfNMode; bool bHalfWirelessN24GMode; int wpa_enabled; int drop_unencrypted; @@ -1766,14 +1758,11 @@ struct rtllib_device { u8 AsocRetryCount; struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE]; struct sk_buff_head skb_aggQ[MAX_QUEUE_SIZE]; - u32 sta_edca_param[4]; bool aggregation; - bool enable_rx_imm_BA; bool bdynamic_txpower_enable; bool bCTSToSelfEnable; - u8 CTSToSelfTH; u32 fsync_time_interval; u32 fsync_rate_bitmap; @@ -1929,7 +1918,6 @@ struct rtllib_device { void (*rtllib_ips_leave_wq)(struct net_device *dev); void (*rtllib_ips_leave)(struct net_device *dev); void (*LeisurePSLeave)(struct net_device *dev); - void (*rtllib_rfkill_poll)(struct net_device *dev); /* This must be the last item so that it points to the data * allocated beyond this structure by alloc_rtllib diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c index 845d9b8a4aa2..578b41bbd98a 100644 --- a/drivers/staging/rtl8192e/rtllib_module.c +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -136,15 +136,12 @@ struct net_device *alloc_rtllib(int sizeof_priv) spin_lock_init(&ieee->lock); spin_lock_init(&ieee->wpax_suitlist_lock); - spin_lock_init(&ieee->bw_spinlock); spin_lock_init(&ieee->reorder_spinlock); - atomic_set(&(ieee->atm_chnlop), 0); atomic_set(&(ieee->atm_swbw), 0); /* SAM FIXME */ lib80211_crypt_info_init(&ieee->crypt_info, "RTLLIB", &ieee->lock); - ieee->bHalfNMode = false; ieee->wpa_enabled = 0; ieee->tkip_countermeasures = 0; ieee->drop_unencrypted = 0; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index dc3fc129f7e8..6d1120547c1c 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1715,7 +1715,6 @@ inline void rtllib_softmac_new_net(struct rtllib_device *ieee, !(ieee->softmac_features & IEEE_SOFTMAC_SCAN)) rtllib_stop_scan_syncro(ieee); - ieee->hwscan_ch_bk = ieee->current_network.channel; HTResetIOTSetting(ieee->pHTInfo); ieee->wmm_acm = 0; if (ieee->iw_mode == IW_MODE_INFRA) { @@ -3022,12 +3021,7 @@ void rtllib_softmac_init(struct rtllib_device *ieee) ieee->is_set_key = false; init_mgmt_queue(ieee); - ieee->sta_edca_param[0] = 0x0000A403; - ieee->sta_edca_param[1] = 0x0000A427; - ieee->sta_edca_param[2] = 0x005E4342; - ieee->sta_edca_param[3] = 0x002F3262; ieee->aggregation = true; - ieee->enable_rx_imm_BA = true; ieee->tx_pending.txb = NULL; _setup_timer(&ieee->associate_timer, From 0941f87fd52333ffd2abc8a09c3102392b1f7b0c Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 15 Jun 2015 21:06:09 +0200 Subject: [PATCH 1097/1163] staging: rtl8192e: Remove softmac_hint11d_wq queue This queue is never used, and function handler is empty Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 1 - drivers/staging/rtl8192e/rtllib_softmac.c | 6 ------ 2 files changed, 7 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index f3a4bbc35f80..74c2a2856ec6 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1794,7 +1794,6 @@ struct rtllib_device { struct work_struct ips_leave_wq; struct delayed_work associate_procedure_wq; struct delayed_work softmac_scan_wq; - struct delayed_work softmac_hint11d_wq; struct delayed_work associate_retry_wq; struct delayed_work start_ibss_wq; struct delayed_work hw_wakeup_wq; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 6d1120547c1c..3f4a932e2353 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -492,10 +492,6 @@ void rtllib_send_probe_requests(struct rtllib_device *ieee, u8 is_mesh) } } -static void rtllib_softmac_hint11d_wq(void *data) -{ -} - void rtllib_update_active_chan_map(struct rtllib_device *ieee) { memcpy(ieee->active_channel_map, GET_DOT11D_INFO(ieee)->channel_map, @@ -3045,8 +3041,6 @@ void rtllib_softmac_init(struct rtllib_device *ieee) (void *)rtllib_associate_procedure_wq, ieee); INIT_DELAYED_WORK_RSL(&ieee->softmac_scan_wq, (void *)rtllib_softmac_scan_wq, ieee); - INIT_DELAYED_WORK_RSL(&ieee->softmac_hint11d_wq, - (void *)rtllib_softmac_hint11d_wq, ieee); INIT_DELAYED_WORK_RSL(&ieee->associate_retry_wq, (void *)rtllib_associate_retry_wq, ieee); INIT_WORK_RSL(&ieee->wx_sync_scan_wq, (void *)rtllib_wx_sync_scan_wq, From 47eae6ddd9cf12781cefe6ec458d791174cb59b9 Mon Sep 17 00:00:00 2001 From: Mateusz Kulikowski Date: Mon, 15 Jun 2015 21:06:10 +0200 Subject: [PATCH 1098/1163] staging: rtl8192e: Remove rtllib_device::agregation Variable is always true; Resolve condition where it is used (and change indentation of conditional expression). Signed-off-by: Mateusz Kulikowski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 1 - drivers/staging/rtl8192e/rtllib_rx.c | 52 +++++++++++------------ drivers/staging/rtl8192e/rtllib_softmac.c | 1 - 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 74c2a2856ec6..fd38c6dd146b 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1758,7 +1758,6 @@ struct rtllib_device { u8 AsocRetryCount; struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE]; struct sk_buff_head skb_aggQ[MAX_QUEUE_SIZE]; - bool aggregation; bool bdynamic_txpower_enable; diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 48a188a1ad46..da862c3da4ce 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1883,38 +1883,34 @@ static void rtllib_parse_mife_generic(struct rtllib_device *ieee, } } - if (ieee->aggregation) { - if (network->bssht.bdSupportHT) { - if (info_element->len >= 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0xe0 && - info_element->data[2] == 0x4c && - info_element->data[3] == 0x02) { - ht_realtek_agg_len = min_t(u8, - info_element->len, - MAX_IE_LEN); - memcpy(ht_realtek_agg_buf, - info_element->data, - info_element->len); - } - if (ht_realtek_agg_len >= 5) { - network->realtek_cap_exit = true; - network->bssht.bdRT2RTAggregation = true; - - if ((ht_realtek_agg_buf[4] == 1) && - (ht_realtek_agg_buf[5] & 0x02)) - network->bssht.bdRT2RTLongSlotTime = true; - - if ((ht_realtek_agg_buf[4] == 1) && - (ht_realtek_agg_buf[5] & RT_HT_CAP_USE_92SE)) - network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE; - } + if (network->bssht.bdSupportHT) { + if (info_element->len >= 4 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0xe0 && + info_element->data[2] == 0x4c && + info_element->data[3] == 0x02) { + ht_realtek_agg_len = min_t(u8, info_element->len, + MAX_IE_LEN); + memcpy(ht_realtek_agg_buf, info_element->data, + info_element->len); } if (ht_realtek_agg_len >= 5) { - if ((ht_realtek_agg_buf[5] & RT_HT_CAP_USE_SOFTAP)) - network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_SOFTAP; + network->realtek_cap_exit = true; + network->bssht.bdRT2RTAggregation = true; + + if ((ht_realtek_agg_buf[4] == 1) && + (ht_realtek_agg_buf[5] & 0x02)) + network->bssht.bdRT2RTLongSlotTime = true; + + if ((ht_realtek_agg_buf[4] == 1) && + (ht_realtek_agg_buf[5] & RT_HT_CAP_USE_92SE)) + network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE; } } + if (ht_realtek_agg_len >= 5) { + if ((ht_realtek_agg_buf[5] & RT_HT_CAP_USE_SOFTAP)) + network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_SOFTAP; + } if ((info_element->len >= 3 && info_element->data[0] == 0x00 && diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 3f4a932e2353..444fac73a8a8 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -3017,7 +3017,6 @@ void rtllib_softmac_init(struct rtllib_device *ieee) ieee->is_set_key = false; init_mgmt_queue(ieee); - ieee->aggregation = true; ieee->tx_pending.txb = NULL; _setup_timer(&ieee->associate_timer, From 2e59e40d5d63ff805c9a5299be8b8e5e299dc6b6 Mon Sep 17 00:00:00 2001 From: Gnanachandran Dhanapal Date: Tue, 16 Jun 2015 07:25:48 +0000 Subject: [PATCH 1099/1163] Staging: rtl8192e: Timer setup using macro rather assignment This patch shall replaces user defined timer setup function with standard timer setup macro. Also removes init_timer, because timer can be initialized in setup_timer macro as well. Signed-off-by: Gnanachandran Dhanapal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 2 -- drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 1 - drivers/staging/rtl8192e/rtl819x_TS.h | 1 - drivers/staging/rtl8192e/rtl819x_TSProc.c | 18 +++++++++--------- drivers/staging/rtl8192e/rtllib_module.c | 6 ------ drivers/staging/rtl8192e/rtllib_softmac.c | 4 ++-- 6 files changed, 11 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 49110d32cf88..c6cdb43b864c 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -1252,12 +1252,10 @@ static short rtl8192_init(struct net_device *dev) init_hal_dm(dev); - init_timer(&priv->watch_dog_timer); setup_timer(&priv->watch_dog_timer, watch_dog_timer_callback, (unsigned long) dev); - init_timer(&priv->gpio_polling_timer); setup_timer(&priv->gpio_polling_timer, check_rfctrl_gpio_timer, (unsigned long)dev); diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c index 1b21f3835446..3de7cc549794 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c @@ -2179,7 +2179,6 @@ static void dm_init_fsync(struct net_device *dev) priv->rtllib->fsync_state = Default_Fsync; priv->framesyncMonitor = 1; - init_timer(&priv->fsync_timer); setup_timer(&priv->fsync_timer, dm_fsync_timer_callback, (unsigned long) dev); } diff --git a/drivers/staging/rtl8192e/rtl819x_TS.h b/drivers/staging/rtl8192e/rtl819x_TS.h index b3e721bf975c..b8fed556928c 100644 --- a/drivers/staging/rtl8192e/rtl819x_TS.h +++ b/drivers/staging/rtl8192e/rtl819x_TS.h @@ -67,7 +67,6 @@ struct rx_ts_record { u8 num; }; -void _setup_timer(struct timer_list *, void *, unsigned long); #endif diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 8a5dd6ef8074..05aea4321b9d 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -154,22 +154,22 @@ void TSInitialize(struct rtllib_device *ieee) for (count = 0; count < TOTAL_TS_NUM; count++) { pTxTS->num = count; - _setup_timer(&pTxTS->TsCommonInfo.SetupTimer, + setup_timer(&pTxTS->TsCommonInfo.SetupTimer, TsSetupTimeOut, (unsigned long) pTxTS); - _setup_timer(&pTxTS->TsCommonInfo.InactTimer, + setup_timer(&pTxTS->TsCommonInfo.InactTimer, TsInactTimeout, (unsigned long) pTxTS); - _setup_timer(&pTxTS->TsAddBaTimer, + setup_timer(&pTxTS->TsAddBaTimer, TsAddBaProcess, (unsigned long) pTxTS); - _setup_timer(&pTxTS->TxPendingBARecord.Timer, + setup_timer(&pTxTS->TxPendingBARecord.Timer, BaSetupTimeOut, (unsigned long) pTxTS); - _setup_timer(&pTxTS->TxAdmittedBARecord.Timer, + setup_timer(&pTxTS->TxAdmittedBARecord.Timer, TxBaInactTimeout, (unsigned long) pTxTS); @@ -186,19 +186,19 @@ void TSInitialize(struct rtllib_device *ieee) pRxTS->num = count; INIT_LIST_HEAD(&pRxTS->RxPendingPktList); - _setup_timer(&pRxTS->TsCommonInfo.SetupTimer, + setup_timer(&pRxTS->TsCommonInfo.SetupTimer, TsSetupTimeOut, (unsigned long) pRxTS); - _setup_timer(&pRxTS->TsCommonInfo.InactTimer, + setup_timer(&pRxTS->TsCommonInfo.InactTimer, TsInactTimeout, (unsigned long) pRxTS); - _setup_timer(&pRxTS->RxAdmittedBARecord.Timer, + setup_timer(&pRxTS->RxAdmittedBARecord.Timer, RxBaInactTimeout, (unsigned long) pRxTS); - _setup_timer(&pRxTS->RxPktPendingTimer, + setup_timer(&pRxTS->RxPktPendingTimer, RxPktPendingTimeout, (unsigned long) pRxTS); diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c index 578b41bbd98a..224dc99af131 100644 --- a/drivers/staging/rtl8192e/rtllib_module.c +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -57,12 +57,6 @@ u32 rt_global_debug_component = COMP_ERR; EXPORT_SYMBOL(rt_global_debug_component); -void _setup_timer(struct timer_list *ptimer, void *fun, unsigned long data) -{ - ptimer->function = fun; - ptimer->data = data; - init_timer(ptimer); -} static inline int rtllib_networks_allocate(struct rtllib_device *ieee) { diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 444fac73a8a8..d320c31732f2 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -3019,11 +3019,11 @@ void rtllib_softmac_init(struct rtllib_device *ieee) ieee->tx_pending.txb = NULL; - _setup_timer(&ieee->associate_timer, + setup_timer(&ieee->associate_timer, rtllib_associate_abort_cb, (unsigned long) ieee); - _setup_timer(&ieee->beacon_timer, + setup_timer(&ieee->beacon_timer, rtllib_send_beacon_cb, (unsigned long) ieee); From 231fe7ca1ad57cc08ce9a68aebe7592d37f1688b Mon Sep 17 00:00:00 2001 From: Niranjan Dighe Date: Tue, 16 Jun 2015 05:04:01 +0000 Subject: [PATCH 1100/1163] Staging: sm750fb: replace spaces by tabs This patch replaces spaces by tabs at the start of the line and in between variable declarations. Signed-off-by: Niranjan Dighe Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/ddk750_dvi.h | 60 ++++++++++++++-------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/drivers/staging/sm750fb/ddk750_dvi.h b/drivers/staging/sm750fb/ddk750_dvi.h index 50bcec29b2c0..c8d31f3bae85 100644 --- a/drivers/staging/sm750fb/ddk750_dvi.h +++ b/drivers/staging/sm750fb/ddk750_dvi.h @@ -4,16 +4,16 @@ /* dvi chip stuffs structros */ typedef long (*PFN_DVICTRL_INIT)( - unsigned char edgeSelect, - unsigned char busSelect, - unsigned char dualEdgeClkSelect, - unsigned char hsyncEnable, - unsigned char vsyncEnable, - unsigned char deskewEnable, - unsigned char deskewSetting, - unsigned char continuousSyncEnable, - unsigned char pllFilterEnable, - unsigned char pllFilterValue); + unsigned char edgeSelect, + unsigned char busSelect, + unsigned char dualEdgeClkSelect, + unsigned char hsyncEnable, + unsigned char vsyncEnable, + unsigned char deskewEnable, + unsigned char deskewSetting, + unsigned char continuousSyncEnable, + unsigned char pllFilterEnable, + unsigned char pllFilterValue); typedef void (*PFN_DVICTRL_RESETCHIP)(void); typedef char* (*PFN_DVICTRL_GETCHIPSTRING)(void); typedef unsigned short (*PFN_DVICTRL_GETVENDORID)(void); @@ -29,16 +29,16 @@ typedef void (*PFN_DVICTRL_CLEARINTERRUPT)(void); /* Structure to hold all the function pointer to the DVI Controller. */ typedef struct _dvi_ctrl_device_t { - PFN_DVICTRL_INIT pfnInit; - PFN_DVICTRL_RESETCHIP pfnResetChip; - PFN_DVICTRL_GETCHIPSTRING pfnGetChipString; - PFN_DVICTRL_GETVENDORID pfnGetVendorId; - PFN_DVICTRL_GETDEVICEID pfnGetDeviceId; - PFN_DVICTRL_SETPOWER pfnSetPower; - PFN_DVICTRL_HOTPLUGDETECTION pfnEnableHotPlugDetection; - PFN_DVICTRL_ISCONNECTED pfnIsConnected; - PFN_DVICTRL_CHECKINTERRUPT pfnCheckInterrupt; - PFN_DVICTRL_CLEARINTERRUPT pfnClearInterrupt; + PFN_DVICTRL_INIT pfnInit; + PFN_DVICTRL_RESETCHIP pfnResetChip; + PFN_DVICTRL_GETCHIPSTRING pfnGetChipString; + PFN_DVICTRL_GETVENDORID pfnGetVendorId; + PFN_DVICTRL_GETDEVICEID pfnGetDeviceId; + PFN_DVICTRL_SETPOWER pfnSetPower; + PFN_DVICTRL_HOTPLUGDETECTION pfnEnableHotPlugDetection; + PFN_DVICTRL_ISCONNECTED pfnIsConnected; + PFN_DVICTRL_CHECKINTERRUPT pfnCheckInterrupt; + PFN_DVICTRL_CLEARINTERRUPT pfnClearInterrupt; } dvi_ctrl_device_t; #define DVI_CTRL_SII164 @@ -46,16 +46,16 @@ typedef struct _dvi_ctrl_device_t /* dvi functions prototype */ int dviInit( - unsigned char edgeSelect, - unsigned char busSelect, - unsigned char dualEdgeClkSelect, - unsigned char hsyncEnable, - unsigned char vsyncEnable, - unsigned char deskewEnable, - unsigned char deskewSetting, - unsigned char continuousSyncEnable, - unsigned char pllFilterEnable, - unsigned char pllFilterValue + unsigned char edgeSelect, + unsigned char busSelect, + unsigned char dualEdgeClkSelect, + unsigned char hsyncEnable, + unsigned char vsyncEnable, + unsigned char deskewEnable, + unsigned char deskewSetting, + unsigned char continuousSyncEnable, + unsigned char pllFilterEnable, + unsigned char pllFilterValue ); unsigned short dviGetVendorID(void); From 658373e54c462dc48bdfaa393da549fd7cc594b1 Mon Sep 17 00:00:00 2001 From: Niranjan Dighe Date: Tue, 16 Jun 2015 05:05:47 +0000 Subject: [PATCH 1101/1163] Staging: sm750fb: correct spacing between lines of code This patch corrects line spacing by removing and adding newline characters wherever necessary Signed-off-by: Niranjan Dighe Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/ddk750_dvi.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/sm750fb/ddk750_dvi.h b/drivers/staging/sm750fb/ddk750_dvi.h index c8d31f3bae85..83bbd6d62061 100644 --- a/drivers/staging/sm750fb/ddk750_dvi.h +++ b/drivers/staging/sm750fb/ddk750_dvi.h @@ -14,6 +14,7 @@ typedef long (*PFN_DVICTRL_INIT)( unsigned char continuousSyncEnable, unsigned char pllFilterEnable, unsigned char pllFilterValue); + typedef void (*PFN_DVICTRL_RESETCHIP)(void); typedef char* (*PFN_DVICTRL_GETCHIPSTRING)(void); typedef unsigned short (*PFN_DVICTRL_GETVENDORID)(void); @@ -24,8 +25,6 @@ typedef unsigned char (*PFN_DVICTRL_ISCONNECTED)(void); typedef unsigned char (*PFN_DVICTRL_CHECKINTERRUPT)(void); typedef void (*PFN_DVICTRL_CLEARINTERRUPT)(void); - - /* Structure to hold all the function pointer to the DVI Controller. */ typedef struct _dvi_ctrl_device_t { @@ -40,10 +39,9 @@ typedef struct _dvi_ctrl_device_t PFN_DVICTRL_CHECKINTERRUPT pfnCheckInterrupt; PFN_DVICTRL_CLEARINTERRUPT pfnClearInterrupt; } dvi_ctrl_device_t; + #define DVI_CTRL_SII164 - - /* dvi functions prototype */ int dviInit( unsigned char edgeSelect, @@ -61,7 +59,5 @@ int dviInit( unsigned short dviGetVendorID(void); unsigned short dviGetDeviceID(void); - - #endif From 92a0616a4f37ce520b8011ac0e3638ffa618ff16 Mon Sep 17 00:00:00 2001 From: Abdul Hussain Date: Tue, 16 Jun 2015 07:18:08 +0000 Subject: [PATCH 1102/1163] Staging: lusture: Remove an open coded simple_open() function This patch removes an open coded simple_open() function and replace file operations references to the function with simple_open() instead Signed-off-by: Abdul Hussain Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/fld/lproc_fld.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c index b35ff288dbd5..da822101e005 100644 --- a/drivers/staging/lustre/lustre/fld/lproc_fld.c +++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c @@ -142,13 +142,6 @@ fld_debugfs_cache_flush_write(struct file *file, const char __user *buffer, return count; } -static int -fld_debugfs_cache_flush_open(struct inode *inode, struct file *file) -{ - file->private_data = inode->i_private; - return 0; -} - static int fld_debugfs_cache_flush_release(struct inode *inode, struct file *file) { @@ -158,7 +151,7 @@ fld_debugfs_cache_flush_release(struct inode *inode, struct file *file) static struct file_operations fld_debugfs_cache_flush_fops = { .owner = THIS_MODULE, - .open = fld_debugfs_cache_flush_open, + .open = simple_open, .write = fld_debugfs_cache_flush_write, .release = fld_debugfs_cache_flush_release, }; From d4f4708ae0d0e7e99d5d5c42b3b4a317dab3c01b Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 17 Jun 2015 10:38:50 +0200 Subject: [PATCH 1103/1163] Revert "staging: board: disable as it breaks the build" This reverts commit d13778d537a0ed6115d2a79a942af999cfb8eec6. Commit 13c11072536f2613 ("staging:board: remove unnecessary function") fixed the build of drivers/staging/board/board.c. Signed-off-by: Geert Uytterhoeven Reviewed-by: Simon Horman Acked-by: Simon Horman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/board/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/board/Kconfig b/drivers/staging/board/Kconfig index 0a89ad16371f..b8ee81840666 100644 --- a/drivers/staging/board/Kconfig +++ b/drivers/staging/board/Kconfig @@ -1,7 +1,6 @@ config STAGING_BOARD bool "Staging Board Support" depends on OF_ADDRESS - depends on BROKEN help Select to enable per-board staging support code. From b0c750f74e10fd30a363bfa3467639f12954effa Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 17 Jun 2015 10:38:51 +0200 Subject: [PATCH 1104/1163] staging: board: Initialize staging board code earlier Currently the staging board code is initialized from a late_initcall(). However, unused PM domains are also disabled from a late_initcall(), which happens before due to link order. Change the initialization of staging board code from using late_initcall() to device_initcall() to fix this. Signed-off-by: Geert Uytterhoeven Acked-by: Simon Horman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/board/board.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/board/board.h b/drivers/staging/board/board.h index 2390ed6c31a4..e9c914985d4a 100644 --- a/drivers/staging/board/board.h +++ b/drivers/staging/board/board.h @@ -15,6 +15,6 @@ static int __init runtime_board_check(void) \ return 0; \ } \ \ -late_initcall(runtime_board_check) +device_initcall(runtime_board_check) #endif /* __BOARD_H__ */ From 72ee8626eeb121587d2e3a57d06611d2e0c3cc1b Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 17 Jun 2015 10:38:52 +0200 Subject: [PATCH 1105/1163] staging: board: Add support for translating hwirq to virq numbers As of commit 9a1091ef0017c40a ("irqchip: gic: Support hierarchy irq domain."), GIC IRQ numbers are virtual, breaking hardcoded hardware IRQ numbers in platform device resources. Add support for translating hardware IRQ numbers to virtual IRQ numbers, and fixing up platform device resources with hardcoded IRQ numbers. Add a copyright header, including the original author. Signed-off-by: Geert Uytterhoeven Acked-by: Simon Horman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/board/board.c | 80 +++++++++++++++++++++++++++++++++++ drivers/staging/board/board.h | 5 +++ 2 files changed, 85 insertions(+) diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c index d5a6abc84519..8712f566b311 100644 --- a/drivers/staging/board/board.c +++ b/drivers/staging/board/board.c @@ -1,10 +1,27 @@ +/* + * Copyright (C) 2014 Magnus Damm + * Copyright (C) 2015 Glider bvba + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + */ + +#define pr_fmt(fmt) "board_staging: " fmt + #include +#include #include #include #include #include +#include + #include "board.h" +static struct device_node *irqc_node __initdata; +static unsigned int irqc_base __initdata; + static bool find_by_address(u64 base_address) { struct device_node *dn = of_find_all_nodes(NULL); @@ -38,3 +55,66 @@ bool __init board_staging_dt_node_available(const struct resource *resource, return false; /* Nothing found */ } + +int __init board_staging_gic_setup_xlate(const char *gic_match, + unsigned int base) +{ + WARN_ON(irqc_node); + + irqc_node = of_find_compatible_node(NULL, NULL, gic_match); + + WARN_ON(!irqc_node); + if (!irqc_node) + return -ENOENT; + + irqc_base = base; + return 0; +} + +static void __init gic_fixup_resource(struct resource *res) +{ + struct of_phandle_args irq_data; + unsigned int hwirq = res->start; + unsigned int virq; + + if (resource_type(res) != IORESOURCE_IRQ || !irqc_node) + return; + + irq_data.np = irqc_node; + irq_data.args_count = 3; + irq_data.args[0] = 0; + irq_data.args[1] = hwirq - irqc_base; + switch (res->flags & + (IORESOURCE_IRQ_LOWEDGE | IORESOURCE_IRQ_HIGHEDGE | + IORESOURCE_IRQ_LOWLEVEL | IORESOURCE_IRQ_HIGHLEVEL)) { + case IORESOURCE_IRQ_LOWEDGE: + irq_data.args[2] = IRQ_TYPE_EDGE_FALLING; + break; + case IORESOURCE_IRQ_HIGHEDGE: + irq_data.args[2] = IRQ_TYPE_EDGE_RISING; + break; + case IORESOURCE_IRQ_LOWLEVEL: + irq_data.args[2] = IRQ_TYPE_LEVEL_LOW; + break; + case IORESOURCE_IRQ_HIGHLEVEL: + default: + irq_data.args[2] = IRQ_TYPE_LEVEL_HIGH; + break; + } + + virq = irq_create_of_mapping(&irq_data); + if (WARN_ON(!virq)) + return; + + pr_debug("hwirq %u -> virq %u\n", hwirq, virq); + res->start = virq; +} + +void __init board_staging_gic_fixup_resources(struct resource *res, + unsigned int nres) +{ + unsigned int i; + + for (i = 0; i < nres; i++) + gic_fixup_resource(&res[i]); +} diff --git a/drivers/staging/board/board.h b/drivers/staging/board/board.h index e9c914985d4a..3af6dbe22f91 100644 --- a/drivers/staging/board/board.h +++ b/drivers/staging/board/board.h @@ -1,10 +1,15 @@ #ifndef __BOARD_H__ #define __BOARD_H__ + #include #include +struct resource; + bool board_staging_dt_node_available(const struct resource *resource, unsigned int num_resources); +int board_staging_gic_setup_xlate(const char *gic_match, unsigned int base); +void board_staging_gic_fixup_resources(struct resource *res, unsigned int nres); #define board_staging(str, fn) \ static int __init runtime_board_check(void) \ From a85890883e18d9b1ab6e500584ee5a4db7d1e39f Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 17 Jun 2015 10:38:53 +0200 Subject: [PATCH 1106/1163] staging: board: kzm9d: Translate hwirq numbers to virq numbers As of commit 9a1091ef0017c40a ("irqchip: gic: Support hierarchy irq domain."), GIC IRQ numbers are virtual, breaking hardcoded hardware IRQ numbers in platform device resources. Translate the hardware IRQ numbers to virtual IRQ numbers to fix this. Signed-off-by: Geert Uytterhoeven Acked-by: Simon Horman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/board/kzm9d.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/staging/board/kzm9d.c b/drivers/staging/board/kzm9d.c index 533f3026e17a..8d1eb09bc66e 100644 --- a/drivers/staging/board/kzm9d.c +++ b/drivers/staging/board/kzm9d.c @@ -4,16 +4,22 @@ #include #include "board.h" -static const struct resource usbs1_res[] __initconst = { +static struct resource usbs1_res[] __initdata = { DEFINE_RES_MEM(0xe2800000, 0x2000), DEFINE_RES_IRQ(159), }; static void __init kzm9d_init(void) { - if (!board_staging_dt_node_available(usbs1_res, ARRAY_SIZE(usbs1_res))) + board_staging_gic_setup_xlate("arm,cortex-a9-gic", 32); + + if (!board_staging_dt_node_available(usbs1_res, + ARRAY_SIZE(usbs1_res))) { + board_staging_gic_fixup_resources(usbs1_res, + ARRAY_SIZE(usbs1_res)); platform_device_register_simple("emxx_udc", -1, usbs1_res, ARRAY_SIZE(usbs1_res)); + } } board_staging("renesas,kzm9d", kzm9d_init); From 225d68d852f16369c1f9e61f7aa58cfffcaaff5d Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 17 Jun 2015 10:38:54 +0200 Subject: [PATCH 1107/1163] staging: board: Add support for devices with complex dependencies Add support for easy registering of one ore more platform devices that may: - need clocks that are described in DT, - be part of a PM Domain. All these dependencies are optional. Signed-off-by: Geert Uytterhoeven Acked-by: Simon Horman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/board/board.c | 56 +++++++++++++++++++++++++++++++++++ drivers/staging/board/board.h | 20 +++++++++++++ 2 files changed, 76 insertions(+) diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c index 8712f566b311..29d456e29f38 100644 --- a/drivers/staging/board/board.c +++ b/drivers/staging/board/board.c @@ -9,6 +9,7 @@ #define pr_fmt(fmt) "board_staging: " fmt +#include #include #include #include @@ -16,6 +17,8 @@ #include #include #include +#include +#include #include "board.h" @@ -118,3 +121,56 @@ void __init board_staging_gic_fixup_resources(struct resource *res, for (i = 0; i < nres; i++) gic_fixup_resource(&res[i]); } + +int __init board_staging_register_clock(const struct board_staging_clk *bsc) +{ + int error; + + pr_debug("Aliasing clock %s for con_id %s dev_id %s\n", bsc->clk, + bsc->con_id, bsc->dev_id); + error = clk_add_alias(bsc->con_id, bsc->dev_id, bsc->clk, NULL); + if (error) + pr_err("Failed to alias clock %s (%d)\n", bsc->clk, error); + + return error; +} + +int __init board_staging_register_device(const struct board_staging_dev *dev) +{ + struct platform_device *pdev = dev->pdev; + unsigned int i; + int error; + + pr_debug("Trying to register device %s\n", pdev->name); + if (board_staging_dt_node_available(pdev->resource, + pdev->num_resources)) { + pr_warn("Skipping %s, already in DT\n", pdev->name); + return -EEXIST; + } + + board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources); + + for (i = 0; i < dev->nclocks; i++) + board_staging_register_clock(&dev->clocks[i]); + + error = platform_device_register(pdev); + if (error) { + pr_err("Failed to register device %s (%d)\n", pdev->name, + error); + return error; + } + + if (dev->domain) + __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL); + + return error; +} + +void __init board_staging_register_devices(const struct board_staging_dev *devs, + unsigned int ndevs) +{ + unsigned int i; + + for (i = 0; i < ndevs; i++) + board_staging_register_device(&devs[i]); +} diff --git a/drivers/staging/board/board.h b/drivers/staging/board/board.h index 3af6dbe22f91..42ed12513220 100644 --- a/drivers/staging/board/board.h +++ b/drivers/staging/board/board.h @@ -4,12 +4,32 @@ #include #include +struct board_staging_clk { + const char *clk; + const char *con_id; + const char *dev_id; +}; + +struct board_staging_dev { + /* Platform Device */ + struct platform_device *pdev; + /* Clocks (optional) */ + const struct board_staging_clk *clocks; + unsigned int nclocks; + /* Generic PM Domain (optional) */ + const char *domain; +}; + struct resource; bool board_staging_dt_node_available(const struct resource *resource, unsigned int num_resources); int board_staging_gic_setup_xlate(const char *gic_match, unsigned int base); void board_staging_gic_fixup_resources(struct resource *res, unsigned int nres); +int board_staging_register_clock(const struct board_staging_clk *bsc); +int board_staging_register_device(const struct board_staging_dev *dev); +void board_staging_register_devices(const struct board_staging_dev *devs, + unsigned int ndevs); #define board_staging(str, fn) \ static int __init runtime_board_check(void) \ From 1bbf29ab8f89d2a804e075c4f226a08c1cb7f915 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 17 Jun 2015 10:38:55 +0200 Subject: [PATCH 1108/1163] staging: board: armadillo800eva: Board staging for sh_mobile_lcdc_fb Add staging board support for the r8a7740-based armadillo800eva board and add platform devices to allow in-tree continuous development of the drivers on the armadillo800eva board. When DT bindings are ready for theses drivers then the platform devices in the armadillo800eva staging board code can easily be removed. Until then we use platform devices to continuously improve the driver and integrate code. Added platform devices: - sh_mobile_lcdc_fb for the on-board LCD. Signed-off-by: Geert Uytterhoeven Acked-by: Simon Horman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/board/Makefile | 3 +- drivers/staging/board/armadillo800eva.c | 105 ++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 drivers/staging/board/armadillo800eva.c diff --git a/drivers/staging/board/Makefile b/drivers/staging/board/Makefile index 65d39ecfad63..6842745feb94 100644 --- a/drivers/staging/board/Makefile +++ b/drivers/staging/board/Makefile @@ -1,2 +1,3 @@ obj-y := board.o -obj-$(CONFIG_ARCH_EMEV2) += kzm9d.o +obj-$(CONFIG_ARCH_EMEV2) += kzm9d.o +obj-$(CONFIG_ARCH_R8A7740) += armadillo800eva.o diff --git a/drivers/staging/board/armadillo800eva.c b/drivers/staging/board/armadillo800eva.c new file mode 100644 index 000000000000..81df77bd55cc --- /dev/null +++ b/drivers/staging/board/armadillo800eva.c @@ -0,0 +1,105 @@ +/* + * Staging board support for Armadillo 800 eva. + * Enable not-yet-DT-capable devices here. + * + * Based on board-armadillo800eva.c + * + * Copyright (C) 2012 Renesas Solutions Corp. + * Copyright (C) 2012 Kuninori Morimoto + * + * 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; version 2 of the License. + * + * 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